6969our %GLOBAL_APIS = ();
7070our %OBJECT_TYPE_BULK_MAP = ();
7171our %SAI_ENUMS_CUSTOM_RANGES = ();
72+ our %ATTR_API_VER = ();
7273
7374my $FLAGS = " MANDATORY_ON_CREATE|CREATE_ONLY|CREATE_AND_SET|READ_ONLY|KEY" ;
7475my $ENUM_FLAGS_TYPES = " (none|strict|mixed|ranges|free)" ;
@@ -2294,6 +2295,46 @@ sub ProcessIsExtensionAttr
22942295 return " false" ;
22952296}
22962297
2298+ sub ProcessApiVersion
2299+ {
2300+ my ($attr , $type ) = @_ ;
2301+
2302+ # for those attributes use the same version as MIN, since those
2303+ # attributes are auto generated
2304+
2305+ $attr = " SAI_ACL_ENTRY_ATTR_USER_DEFINED_FIELD_GROUP_MIN"
2306+ if ($attr =~ / ^SAI_ACL_ENTRY_ATTR_USER_DEFINED_FIELD_GROUP_\d +$ / );
2307+
2308+ $attr = " SAI_ACL_TABLE_ATTR_USER_DEFINED_FIELD_GROUP_MIN"
2309+ if ($attr =~ / ^SAI_ACL_TABLE_ATTR_USER_DEFINED_FIELD_GROUP_\d +$ / );
2310+
2311+ if (not defined $ATTR_API_VER {$attr } and scalar (keys %ATTR_API_VER ) != 0)
2312+ {
2313+ LogWarning " no version defined for $attr in saiattrversion.h" ;
2314+
2315+ return " SAI_VERSION(0,0,0)" ;
2316+ }
2317+
2318+ return " SAI_VERSION(0,0,0)" if not defined $ATTR_API_VER {$attr };
2319+
2320+ return " SAI_VERSION($1 ,$2 ,$3 )" if $ATTR_API_VER {$attr } =~ / ^v(\d +)\. (\d +)\. (\d +)$ / ;
2321+
2322+ LogInfo " Setting $attr version to SAI_API_VERSION (future release)" ;
2323+
2324+ return " SAI_API_VERSION" ;
2325+ }
2326+
2327+ sub ProcessNextRelease
2328+ {
2329+ my ($attr , $type ) = @_ ;
2330+
2331+ return " false" if not defined $ATTR_API_VER {$attr };
2332+
2333+ return " false" if $ATTR_API_VER {$attr } =~ / ^v(\d +)\. (\d +)\. (\d +)$ / ;
2334+
2335+ return " true" ;
2336+ }
2337+
22972338sub ProcessSingleObjectType
22982339{
22992340 my ($typedef , $objecttype ) = @_ ;
@@ -2355,6 +2396,8 @@ sub ProcessSingleObjectType
23552396 my $isresourcetype = ProcessIsResourceType($attr , $meta {isresourcetype });
23562397 my $isdeprecated = ProcessIsDeprecatedType($attr , $meta {deprecated });
23572398 my $isrelaxed = ProcessRelaxedType($attr , $meta {relaxed });
2399+ my $apiversion = ProcessApiVersion($attr );
2400+ my $nextrelease = ProcessNextRelease($attr );
23582401
23592402 my $ismandatoryoncreate = ($flags =~ / MANDATORY/ ) ? " true" : " false" ;
23602403 my $iscreateonly = ($flags =~ / CREATE_ONLY/ ) ? " true" : " false" ;
@@ -2413,7 +2456,8 @@ sub ProcessSingleObjectType
24132456 WriteSource " .isresourcetype = $isresourcetype ," ;
24142457 WriteSource " .isdeprecated = $isdeprecated ," ;
24152458 WriteSource " .isconditionrelaxed = $isrelaxed ," ;
2416- WriteSource " .iscustom = ($attr >= 0x10000000) && ($attr < 0x20000000)" ;
2459+ WriteSource " .apiversion = $apiversion ," ;
2460+ WriteSource " .nextrelease = $nextrelease ," ;
24172461
24182462 WriteSource " };" ;
24192463
@@ -2467,6 +2511,15 @@ sub CreateMetadata
24672511 }
24682512}
24692513
2514+ sub ProcessAttrVersion
2515+ {
2516+ WriteSectionComment " Have attr versions" ;
2517+
2518+ my $count = scalar (keys %ATTR_API_VER );
2519+
2520+ WriteHeader " #define SAI_METADATA_HAVE_ATTR_VERSION ($count )" ;
2521+ }
2522+
24702523sub ProcessSaiStatus
24712524{
24722525 my $filename = " ../inc/saistatus.h" ;
@@ -4371,6 +4424,24 @@ sub ExtractObjectTypeBulkMap
43714424 %OBJECT_TYPE_BULK_MAP = %otmap ;
43724425}
43734426
4427+ sub ExtractAttrApiVersion
4428+ {
4429+ my $data = ReadHeaderFile(" saiattrversion.h" );
4430+
4431+ my @lines = split /\n/,$data ;
4432+
4433+ for my $line (@lines )
4434+ {
4435+ if (not $line =~ / #define (SAI_\w +_ATTR_\w +) "(v\d +\.\d +\.\d +|HEAD)"/ )
4436+ {
4437+ LogError " invalid line in saiattrversion.h: $line " ;
4438+ next ;
4439+ }
4440+
4441+ $ATTR_API_VER {$1 } = $2 ;
4442+ }
4443+ }
4444+
43744445sub CheckObjectTypeStatitics
43754446{
43764447 #
@@ -5534,6 +5605,8 @@ sub CreateDefineMaxConditionsLen
55345605
55355606ExtractStatsFunctionMap();
55365607
5608+ ExtractAttrApiVersion();
5609+
55375610ExtractUnionsInfo();
55385611
55395612CheckHeadersStyle() if not defined $optionDisableStyleCheck ;
@@ -5552,6 +5625,8 @@ sub CreateDefineMaxConditionsLen
55525625
55535626WriteHeaderHeader();
55545627
5628+ ProcessAttrVersion();
5629+
55555630ProcessSaiStatus();
55565631
55575632ProcessExtraRangeDefines();
0 commit comments