Skip to content

Commit

Permalink
temp checkin.
Browse files Browse the repository at this point in the history
  • Loading branch information
r12f committed May 27, 2024
1 parent b0755f2 commit 2f6c15f
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions dash-pipeline/SAI/utils/dash_p4/dash_p4_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,27 @@ def create_sai_action_enum(self, sai_api: SaiApi) -> None:
]

action_enum = SaiEnum(
name = f"SAI_{self.name.upper()}_ATTR_ACTION",
name = f"sai_{self.name.upper()}_action_t",
description = f"Attribute data for SAI_{ self.name.upper() }_ATTR_ACTION",
members = action_enum_members
)

sai_api.enums.append(action_enum)

sai_attr_action = SaiAttribute(
name = f"SAI_{self.name.upper()}_ATTR_ACTION",
description = "Action",
type = f"sai_{self.name.lower()}_action_t",
flags = "MANDATORY_ON_CREATE | CREATE_ONLY"
)

sai_api.attributes.append(sai_attr_action)

def create_sai_stats(self, sai_api: SaiApi) -> None:
sai_api.stats = [counter.to_sai() for counter in self.counters if counter.attr_type == "stats"]

def create_sai_attributes(self, sai_api: SaiApi) -> None:
sai_api.attributes = [attr.to_sai() for attr in self.sai_attributes if attr.skipattr != "true"]
sai_api.attributes.extend([attr.to_sai() for attr in self.sai_attributes if attr.skipattr != "true"])

# If the table has an counter attached, we need to create a counter attribute for it.
# The counter attribute only counts that packets that hits any entry, but not the packet that misses all entries.
Expand All @@ -302,16 +311,17 @@ def create_sai_attributes(self, sai_api: SaiApi) -> None:

sai_api.attributes.append(counter_attr)

# If any match key in this table supports priority, we need to add a priority attribute.
if any([key.match_type != "exact" for key in self.keys]) and all([key.match_type != "lpm" for key in self.keys]):
priority_attr = SaiAttribute(
name = f"SAI_{self.name.upper()}_ATTR_PRIORITY",
description = "Rule priority in table",
type = "sai_uint32_t",
flags = "MANDATORY_ON_CREATE | CREATE_ONLY"
)
if self.is_object == "true":
# If any match key in this table supports priority, we need to add a priority attribute.
if any([key.match_type != "exact" for key in self.keys]) and all([key.match_type != "lpm" for key in self.keys]):
priority_attr = SaiAttribute(
name = f"SAI_{self.name.upper()}_ATTR_PRIORITY",
description = "Rule priority in table",
type = "sai_uint32_t",
flags = "MANDATORY_ON_CREATE | CREATE_ONLY"
)

sai_api.attributes.append(priority_attr)
sai_api.attributes.append(priority_attr)

# If any match key contains an IP address, we need to add an IP address family attribute
# for IPv4 and IPv6 support.
Expand Down

0 comments on commit 2f6c15f

Please sign in to comment.