From f9de4ebcd0c09b929e5835b23dd260b587b811d6 Mon Sep 17 00:00:00 2001 From: r12f Date: Sat, 1 Jun 2024 17:38:25 +0000 Subject: [PATCH] Default action for SAI objects or entries with only 1 table actions. --- dash-pipeline/SAI/specs/dash_acl.yaml | 6 +++++- dash-pipeline/SAI/specs/dash_eni.yaml | 6 +++++- dash-pipeline/SAI/specs/dash_ha.yaml | 12 ++++++++++-- dash-pipeline/SAI/specs/dash_meter.yaml | 18 +++++++++++++++--- dash-pipeline/SAI/specs/dash_tunnel.yaml | 6 +++++- dash-pipeline/SAI/specs/dash_vnet.yaml | 6 +++++- .../SAI/utils/dash_p4/dash_p4_table.py | 3 +++ 7 files changed, 48 insertions(+), 9 deletions(-) diff --git a/dash-pipeline/SAI/specs/dash_acl.yaml b/dash-pipeline/SAI/specs/dash_acl.yaml index 9b8f7fd51..c3167dd27 100644 --- a/dash-pipeline/SAI/specs/dash_acl.yaml +++ b/dash-pipeline/SAI/specs/dash_acl.yaml @@ -26,7 +26,11 @@ sai_apis: tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable id: 50200087 - actions: {} + actions: + default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction + name: default + id: 25655048 + attr_param_id: {} - !!python/object:utils.sai_spec.sai_api.SaiApi name: dash_acl_rule description: '' diff --git a/dash-pipeline/SAI/specs/dash_eni.yaml b/dash-pipeline/SAI/specs/dash_eni.yaml index 1be5879be..681fcd4b1 100644 --- a/dash-pipeline/SAI/specs/dash_eni.yaml +++ b/dash-pipeline/SAI/specs/dash_eni.yaml @@ -1442,4 +1442,8 @@ sai_apis: tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable id: 45859274 - actions: {} + actions: + default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction + name: default + id: 27167550 + attr_param_id: {} diff --git a/dash-pipeline/SAI/specs/dash_ha.yaml b/dash-pipeline/SAI/specs/dash_ha.yaml index a40afa19b..d3de42be4 100644 --- a/dash-pipeline/SAI/specs/dash_ha.yaml +++ b/dash-pipeline/SAI/specs/dash_ha.yaml @@ -362,7 +362,11 @@ sai_apis: tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable id: 45319666 - actions: {} + actions: + default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction + name: default + id: 21324178 + attr_param_id: {} - !!python/object:utils.sai_spec.sai_api.SaiApi name: ha_scope description: '' @@ -435,4 +439,8 @@ sai_apis: tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable id: 49681752 - actions: {} + actions: + default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction + name: default + id: 25507507 + attr_param_id: {} diff --git a/dash-pipeline/SAI/specs/dash_meter.yaml b/dash-pipeline/SAI/specs/dash_meter.yaml index 1fa48f027..79f57238a 100644 --- a/dash-pipeline/SAI/specs/dash_meter.yaml +++ b/dash-pipeline/SAI/specs/dash_meter.yaml @@ -38,7 +38,11 @@ sai_apis: tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable id: 45482818 - actions: {} + actions: + default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction + name: default + id: 21630451 + attr_param_id: {} - !!python/object:utils.sai_spec.sai_api.SaiApi name: meter_policy description: '' @@ -63,7 +67,11 @@ sai_apis: tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable id: 40733610 - actions: {} + actions: + default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction + name: default + id: 20564717 + attr_param_id: {} - !!python/object:utils.sai_spec.sai_api.SaiApi name: meter_rule description: '' @@ -112,4 +120,8 @@ sai_apis: tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable id: 44484556 - actions: {} + actions: + default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction + name: default + id: 19652160 + attr_param_id: {} diff --git a/dash-pipeline/SAI/specs/dash_tunnel.yaml b/dash-pipeline/SAI/specs/dash_tunnel.yaml index 027412538..6d7c225aa 100644 --- a/dash-pipeline/SAI/specs/dash_tunnel.yaml +++ b/dash-pipeline/SAI/specs/dash_tunnel.yaml @@ -50,4 +50,8 @@ sai_apis: tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable id: 44400659 - actions: {} + actions: + default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction + name: default + id: 27891720 + attr_param_id: {} diff --git a/dash-pipeline/SAI/specs/dash_vnet.yaml b/dash-pipeline/SAI/specs/dash_vnet.yaml index 8caa323e1..ef055b4ae 100644 --- a/dash-pipeline/SAI/specs/dash_vnet.yaml +++ b/dash-pipeline/SAI/specs/dash_vnet.yaml @@ -26,4 +26,8 @@ sai_apis: tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable id: 49590243 - actions: {} + actions: + default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction + name: default + id: 20510911 + attr_param_id: {} diff --git a/dash-pipeline/SAI/utils/dash_p4/dash_p4_table.py b/dash-pipeline/SAI/utils/dash_p4/dash_p4_table.py index 46e17143d..6b4a2ff71 100644 --- a/dash-pipeline/SAI/utils/dash_p4/dash_p4_table.py +++ b/dash-pipeline/SAI/utils/dash_p4/dash_p4_table.py @@ -277,6 +277,9 @@ def create_sai_action_enum(self, sai_api: SaiApi) -> None: # If the table represents an SAI object, it should not have an action enum. # If the table has only 1 action, we don't need to create the action enum. if len(self.actions) <= 1 and self.is_object != "false": + # We still need to create the p4 meta action here for generating default action code in libsai. + if len(self.actions) == 1: + sai_api.p4_meta.tables[0].actions["default"] = SaiApiP4MetaAction("default", self.actions[0].id) return action_enum_member_value = 0