Skip to content

Commit b8f6ba8

Browse files
kcudniklguohan
authored andcommitted
Add switch notification attributes list to metadata (#886)
* Add switch notification attributes list to metadata * Add define and sanity checks
1 parent 9d00364 commit b8f6ba8

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

meta/parse.pl

+35
Original file line numberDiff line numberDiff line change
@@ -3278,6 +3278,39 @@ sub CreateNotificationEnum
32783278
CreateEnumHelperMethod("sai_switch_notification_type_t");
32793279
}
32803280

3281+
sub CreateSwitchNotificationAttributesList
3282+
{
3283+
#
3284+
# create notification attributes list for easy use on places where only
3285+
# notifications must be processed instead of looping through all switch
3286+
# attributes
3287+
#
3288+
3289+
WriteSectionComment "SAI Switch Notification Attributes List";
3290+
3291+
WriteHeader "extern const sai_attr_metadata_t* const sai_metadata_switch_notify_attr[];";
3292+
WriteSource "const sai_attr_metadata_t* const sai_metadata_switch_notify_attr[] = {";
3293+
3294+
for my $name (sort keys %NOTIFICATIONS)
3295+
{
3296+
next if not $name =~ /^sai_(\w+)_notification_fn/;
3297+
3298+
WriteSource "&sai_metadata_attr_SAI_SWITCH_ATTR_" . uc($1) . "_NOTIFY,";
3299+
}
3300+
3301+
WriteSource "NULL";
3302+
WriteSource "};";
3303+
3304+
my $count = scalar(keys %NOTIFICATIONS);
3305+
3306+
WriteHeader "extern const size_t sai_metadata_switch_notify_attr_count;";
3307+
WriteSource "const size_t sai_metadata_switch_notify_attr_count = $count;";
3308+
3309+
WriteSectionComment "Define SAI_METADATA_SWITCH_NOTIFY_ATTR_COUNT";
3310+
3311+
WriteHeader "#define SAI_METADATA_SWITCH_NOTIFY_ATTR_COUNT $count";
3312+
}
3313+
32813314
sub WriteHeaderHeader
32823315
{
32833316
WriteSectionComment "AUTOGENERATED FILE! DO NOT EDIT";
@@ -3502,6 +3535,8 @@ sub MergeExtensionsEnums
35023535

35033536
CreateNotificationEnum();
35043537

3538+
CreateSwitchNotificationAttributesList();
3539+
35053540
CreateSerializeMethods();
35063541

35073542
WriteHeaderFotter();

meta/saisanitycheck.c

+32
Original file line numberDiff line numberDiff line change
@@ -4368,9 +4368,39 @@ void check_acl_user_defined_field()
43684368

43694369
void check_label_size()
43704370
{
4371+
SAI_META_LOG_ENTER();
4372+
43714373
META_ASSERT_TRUE(sizeof(sai_label_id_t) == sizeof(uint32_t), "label is expected to be 32 bit");
43724374
}
43734375

4376+
void check_switch_notify_list()
4377+
{
4378+
SAI_META_LOG_ENTER();
4379+
4380+
size_t i;
4381+
4382+
for (i = 0; i < sai_metadata_switch_notify_attr_count; ++i)
4383+
{
4384+
META_ASSERT_NOT_NULL(sai_metadata_switch_notify_attr[i]);
4385+
}
4386+
4387+
/* check for NULL guard */
4388+
4389+
META_ASSERT_NULL(sai_metadata_switch_notify_attr[i]);
4390+
}
4391+
4392+
void check_defines()
4393+
{
4394+
SAI_META_LOG_ENTER();
4395+
4396+
/*
4397+
* Check if defines are equal to their static values.
4398+
*/
4399+
4400+
META_ASSERT_TRUE(SAI_METADATA_SWITCH_NOTIFY_ATTR_COUNT == sai_metadata_switch_notify_attr_count, "notify define must be equal");
4401+
META_ASSERT_TRUE(SAI_METADATA_SWITCH_NOTIFY_ATTR_COUNT > 3, "there must be at least 3 notifications defined");
4402+
}
4403+
43744404
int main(int argc, char **argv)
43754405
{
43764406
debug = (argc > 1);
@@ -4411,6 +4441,8 @@ int main(int argc, char **argv)
44114441
check_get_attr_metadata();
44124442
check_acl_user_defined_field();
44134443
check_label_size();
4444+
check_switch_notify_list();
4445+
check_defines();
44144446

44154447
i = SAI_OBJECT_TYPE_NULL + 1;
44164448

0 commit comments

Comments
 (0)