From 07e51b9da3031655b97e9e49fe6042f05804914d Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Thu, 11 Jul 2024 05:20:09 +0000 Subject: [PATCH 01/18] Implement u8listSetVal in SAI/src/utils.h --- dash-pipeline/SAI/src/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dash-pipeline/SAI/src/utils.h b/dash-pipeline/SAI/src/utils.h index 211463112..e468911d8 100644 --- a/dash-pipeline/SAI/src/utils.h +++ b/dash-pipeline/SAI/src/utils.h @@ -285,7 +285,7 @@ namespace dash template void u8listSetVal(const sai_attribute_value_t &value, T &t, int bits = -1) { - assert (0 && "NYI"); + t->set_value(value.u8list.list, value.u8list.count); } template From 56099bbce58e4037fcd5ab194fb455b958391e1c Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Fri, 28 Jun 2024 16:32:39 +0000 Subject: [PATCH 02/18] Base on PR524, add flow involved packet path in pipeline: 1. Update flow table 2. Add dash headers towards DPAPP --- dash-pipeline/Makefile | 2 + dash-pipeline/SAI/specs/dash_flow.yaml | 284 +++++++++--------- dash-pipeline/SAI/specs/sai_spec.yaml | 24 ++ .../SAI/utils/sai_spec/sai_spec_utils.py | 1 + dash-pipeline/bmv2/dash_headers.p4 | 161 +++++++++- dash-pipeline/bmv2/dash_metadata.p4 | 134 +-------- dash-pipeline/bmv2/dash_parser.p4 | 33 +- dash-pipeline/bmv2/dash_pipeline.p4 | 49 ++- dash-pipeline/bmv2/stages/conntrack_lookup.p4 | 270 ++++++++++------- dash-pipeline/bmv2/underlay.p4 | 8 + 10 files changed, 586 insertions(+), 380 deletions(-) diff --git a/dash-pipeline/Makefile b/dash-pipeline/Makefile index 40cf83f46..17555ce89 100644 --- a/dash-pipeline/Makefile +++ b/dash-pipeline/Makefile @@ -5,6 +5,7 @@ ifeq ($(HAVE_DPAPP),y) DPAPP_LINK = veth4 DPAPP_LINK_PEER = veth5 SWITCH_PORT_DPAPP = --interface 2@$(DPAPP_LINK) +D_DPAPP_CONNTRACK = -DDPAPP_CONNTRACK endif mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) @@ -129,6 +130,7 @@ $(P4_OUTDIR)/dash_pipeline_p4rt.txt: $(P4_SRC) -w / \ $(DOCKER_P4C_BMV2_IMG) p4c-bm2-ss \ -DTARGET_BMV2_V1MODEL \ + $(D_DPAPP_CONNTRACK) \ $(P4_MAIN) \ -o $(P4_OUTDIR)/dash_pipeline.json \ --p4runtime-files $(P4_OUTDIR)/dash_pipeline_p4rt.json,$(P4_OUTDIR)/dash_pipeline_p4rt.txt \ diff --git a/dash-pipeline/SAI/specs/dash_flow.yaml b/dash-pipeline/SAI/specs/dash_flow.yaml index 866fcbdb5..dacb55bca 100644 --- a/dash-pipeline/SAI/specs/dash_flow.yaml +++ b/dash-pipeline/SAI/specs/dash_flow.yaml @@ -95,12 +95,6 @@ sai_apis: type: sai_uint16_t objects: null valid_only: null - - !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry - name: ip_proto - description: Exact matched key ip_proto - type: sai_uint8_t - objects: null - valid_only: null - !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry name: src_ip description: Exact matched key src_ip @@ -125,6 +119,12 @@ sai_apis: type: sai_uint16_t objects: null valid_only: null + - !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry + name: ip_proto + description: Exact matched key ip_proto + type: sai_uint8_t + objects: null + valid_only: null attributes: - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute name: SAI_FLOW_ENTRY_ATTR_ACTION @@ -140,24 +140,11 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_VERSION - description: Action parameter version - type: sai_uint32_t - attr_value_field: u32 - default: '0' - isresourcetype: false - flags: CREATE_AND_SET - object_name: null - allow_null: false - valid_only: null - is_vlan: false - deprecated: false - - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_DASH_DIRECTION - description: Action parameter DASH direction - type: sai_dash_direction_t - attr_value_field: s32 - default: SAI_DASH_DIRECTION_INVALID + name: SAI_FLOW_ENTRY_ATTR_IS_UNIDIRECTIONAL + description: Action parameter is unidirectional + type: bool + attr_value_field: booldata + default: 'false' isresourcetype: false flags: CREATE_AND_SET object_name: null @@ -166,11 +153,11 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_DASH_FLOW_ACTION - description: Action parameter DASH flow action - type: sai_dash_flow_action_t - attr_value_field: s32 - default: SAI_DASH_FLOW_ACTION_NONE + name: SAI_FLOW_ENTRY_ATTR_STATE + description: Action parameter state + type: sai_uint8_t + attr_value_field: u8 + default: '0' isresourcetype: false flags: CREATE_AND_SET object_name: null @@ -179,8 +166,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_METER_CLASS - description: Action parameter meter class + name: SAI_FLOW_ENTRY_ATTR_VERSION + description: Action parameter version type: sai_uint32_t attr_value_field: u32 default: '0' @@ -192,24 +179,11 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_IS_UNIDIRECTIONAL_FLOW - description: Action parameter is unidirectional flow - type: bool - attr_value_field: booldata - default: 'false' - isresourcetype: false - flags: CREATE_AND_SET - object_name: null - allow_null: false - valid_only: null - is_vlan: false - deprecated: false - - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_ENI_MAC - description: Action parameter reverse flow ENI MAC - type: sai_mac_t - attr_value_field: mac - default: vendor + name: SAI_FLOW_ENTRY_ATTR_DASH_DIRECTION + description: Action parameter DASH direction + type: sai_dash_direction_t + attr_value_field: s32 + default: SAI_DASH_DIRECTION_INVALID isresourcetype: false flags: CREATE_AND_SET object_name: null @@ -218,8 +192,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_VNET_ID - description: Action parameter reverse flow VNET id + name: SAI_FLOW_ENTRY_ATTR_TUNNEL_ID + description: Action parameter tunnel id type: sai_uint16_t attr_value_field: u16 default: '0' @@ -231,10 +205,10 @@ sai_apis: is_vlan: true deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_IP_PROTO - description: Action parameter reverse flow IP protocol - type: sai_uint8_t - attr_value_field: u8 + name: SAI_FLOW_ENTRY_ATTR_ROUTING_ACTIONS + description: Action parameter routing actions + type: sai_uint32_t + attr_value_field: u32 default: '0' isresourcetype: false flags: CREATE_AND_SET @@ -244,11 +218,11 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_SRC_IP - description: Action parameter reverse flow src IP - type: sai_ip_address_t - attr_value_field: ipaddr - default: 0.0.0.0 + name: SAI_FLOW_ENTRY_ATTR_METER_CLASS + description: Action parameter meter class + type: sai_uint32_t + attr_value_field: u32 + default: '0' isresourcetype: false flags: CREATE_AND_SET object_name: null @@ -257,11 +231,11 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_DST_IP - description: Action parameter reverse flow dst IP - type: sai_ip_address_t - attr_value_field: ipaddr - default: 0.0.0.0 + name: SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_VNI + description: Action parameter encap data VNI + type: sai_uint32_t + attr_value_field: u32 + default: '0' isresourcetype: false flags: CREATE_AND_SET object_name: null @@ -270,34 +244,34 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_SRC_PORT - description: Action parameter reverse flow src port - type: sai_uint16_t - attr_value_field: u16 + name: SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_DEST_VNET_VNI + description: Action parameter encap data destination VNET VNI + type: sai_uint32_t + attr_value_field: u32 default: '0' isresourcetype: false flags: CREATE_AND_SET object_name: null allow_null: false valid_only: null - is_vlan: true + is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_DST_PORT - description: Action parameter reverse flow dst port - type: sai_uint16_t - attr_value_field: u16 + name: SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_SIP + description: Action parameter encap data underlay sip + type: sai_uint32_t + attr_value_field: u32 default: '0' isresourcetype: false flags: CREATE_AND_SET object_name: null allow_null: false valid_only: null - is_vlan: true + is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_UNDERLAY0_VNET_ID - description: Action parameter underlay0 VNET id + name: SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_DIP + description: Action parameter encap data underlay dip type: sai_uint32_t attr_value_field: u32 default: '0' @@ -309,11 +283,11 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_UNDERLAY0_SIP - description: Action parameter underlay0 sip - type: sai_uint32_t - attr_value_field: u32 - default: '0' + name: SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_SMAC + description: Action parameter encap data underlay source MAC + type: sai_mac_t + attr_value_field: mac + default: vendor isresourcetype: false flags: CREATE_AND_SET object_name: null @@ -322,11 +296,11 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DIP - description: Action parameter underlay0 dip - type: sai_uint32_t - attr_value_field: u32 - default: '0' + name: SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_DMAC + description: Action parameter encap data underlay destination MAC + type: sai_mac_t + attr_value_field: mac + default: vendor isresourcetype: false flags: CREATE_AND_SET object_name: null @@ -335,8 +309,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DASH_ENCAPSULATION - description: Action parameter underlay0 DASH encapsulation + name: SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_DASH_ENCAPSULATION + description: Action parameter encap data DASH encapsulation type: sai_dash_encapsulation_t attr_value_field: s32 default: SAI_DASH_ENCAPSULATION_INVALID @@ -348,8 +322,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_UNDERLAY1_VNET_ID - description: Action parameter underlay1 VNET id + name: SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_VNI + description: Action parameter tunnel data VNI type: sai_uint32_t attr_value_field: u32 default: '0' @@ -361,8 +335,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_UNDERLAY1_SIP - description: Action parameter underlay1 sip + name: SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_DEST_VNET_VNI + description: Action parameter tunnel data destination VNET VNI type: sai_uint32_t attr_value_field: u32 default: '0' @@ -374,8 +348,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DIP - description: Action parameter underlay1 dip + name: SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_SIP + description: Action parameter tunnel data underlay sip type: sai_uint32_t attr_value_field: u32 default: '0' @@ -387,8 +361,21 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_UNDERLAY1_SMAC - description: Action parameter underlay1 source MAC + name: SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_DIP + description: Action parameter tunnel data underlay dip + type: sai_uint32_t + attr_value_field: u32 + default: '0' + isresourcetype: false + flags: CREATE_AND_SET + object_name: null + allow_null: false + valid_only: null + is_vlan: false + deprecated: false + - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute + name: SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_SMAC + description: Action parameter tunnel data underlay source MAC type: sai_mac_t attr_value_field: mac default: vendor @@ -400,8 +387,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DMAC - description: Action parameter underlay1 destination MAC + name: SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_DMAC + description: Action parameter tunnel data underlay destination MAC type: sai_mac_t attr_value_field: mac default: vendor @@ -413,8 +400,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DASH_ENCAPSULATION - description: Action parameter underlay1 DASH encapsulation + name: SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_DASH_ENCAPSULATION + description: Action parameter tunnel data DASH encapsulation type: sai_dash_encapsulation_t attr_value_field: s32 default: SAI_DASH_ENCAPSULATION_INVALID @@ -426,8 +413,21 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_DST_MAC - description: Action parameter dst MAC + name: SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_IS_IPV6 + description: Action parameter overlay data is ipv6 + type: bool + attr_value_field: booldata + default: 'false' + isresourcetype: false + flags: CREATE_AND_SET + object_name: null + allow_null: false + valid_only: null + is_vlan: false + deprecated: false + - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute + name: SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_DST_MAC + description: Action parameter overlay data dst MAC type: sai_mac_t attr_value_field: mac default: vendor @@ -439,8 +439,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_SIP - description: Action parameter sip + name: SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_SIP + description: Action parameter overlay data sip type: sai_ip_address_t attr_value_field: ipaddr default: 0.0.0.0 @@ -452,8 +452,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_DIP - description: Action parameter dip + name: SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_DIP + description: Action parameter overlay data dip type: sai_ip_address_t attr_value_field: ipaddr default: 0.0.0.0 @@ -465,8 +465,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_SIP_MASK - description: Action parameter sip mask + name: SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_SIP_MASK + description: Action parameter overlay data sip mask type: sai_ip_address_t attr_value_field: ipaddr default: 0.0.0.0 @@ -478,8 +478,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_DIP_MASK - description: Action parameter dip mask + name: SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_DIP_MASK + description: Action parameter overlay data dip mask type: sai_ip_address_t attr_value_field: ipaddr default: 0.0.0.0 @@ -539,33 +539,33 @@ sai_apis: name: SAI_FLOW_ENTRY_ACTION_SET_FLOW_ENTRY_ATTR id: 26241621 attr_param_id: - SAI_FLOW_ENTRY_ATTR_VERSION: 1 - SAI_FLOW_ENTRY_ATTR_DASH_DIRECTION: 2 - SAI_FLOW_ENTRY_ATTR_DASH_FLOW_ACTION: 3 - SAI_FLOW_ENTRY_ATTR_METER_CLASS: 4 - SAI_FLOW_ENTRY_ATTR_IS_UNIDIRECTIONAL_FLOW: 5 - SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_ENI_MAC: 6 - SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_VNET_ID: 7 - SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_IP_PROTO: 8 - SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_SRC_IP: 9 - SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_DST_IP: 10 - SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_SRC_PORT: 11 - SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_DST_PORT: 12 - SAI_FLOW_ENTRY_ATTR_UNDERLAY0_VNET_ID: 13 - SAI_FLOW_ENTRY_ATTR_UNDERLAY0_SIP: 14 - SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DIP: 15 - SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DASH_ENCAPSULATION: 16 - SAI_FLOW_ENTRY_ATTR_UNDERLAY1_VNET_ID: 17 - SAI_FLOW_ENTRY_ATTR_UNDERLAY1_SIP: 18 - SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DIP: 19 - SAI_FLOW_ENTRY_ATTR_UNDERLAY1_SMAC: 20 - SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DMAC: 21 - SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DASH_ENCAPSULATION: 22 - SAI_FLOW_ENTRY_ATTR_DST_MAC: 23 - SAI_FLOW_ENTRY_ATTR_SIP: 24 - SAI_FLOW_ENTRY_ATTR_DIP: 25 - SAI_FLOW_ENTRY_ATTR_SIP_MASK: 26 - SAI_FLOW_ENTRY_ATTR_DIP_MASK: 27 + SAI_FLOW_ENTRY_ATTR_IS_UNIDIRECTIONAL: 1 + SAI_FLOW_ENTRY_ATTR_STATE: 2 + SAI_FLOW_ENTRY_ATTR_VERSION: 3 + SAI_FLOW_ENTRY_ATTR_DASH_DIRECTION: 4 + SAI_FLOW_ENTRY_ATTR_TUNNEL_ID: 5 + SAI_FLOW_ENTRY_ATTR_ROUTING_ACTIONS: 6 + SAI_FLOW_ENTRY_ATTR_METER_CLASS: 7 + SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_VNI: 8 + SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_DEST_VNET_VNI: 9 + SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_SIP: 10 + SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_DIP: 11 + SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_SMAC: 12 + SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_DMAC: 13 + SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_DASH_ENCAPSULATION: 14 + SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_VNI: 15 + SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_DEST_VNET_VNI: 16 + SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_SIP: 17 + SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_DIP: 18 + SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_SMAC: 19 + SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_DMAC: 20 + SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_DASH_ENCAPSULATION: 21 + SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_IS_IPV6: 22 + SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_DST_MAC: 23 + SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_SIP: 24 + SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_DIP: 25 + SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_SIP_MASK: 26 + SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_DIP_MASK: 27 SAI_FLOW_ENTRY_ATTR_VENDOR_METADATA: 28 SAI_FLOW_ENTRY_ATTR_FLOW_DATA_PB: 29 - !!python/object:utils.sai_spec.sai_api.SaiApi @@ -684,8 +684,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_BULK_GET_SESSION_ATTR_BULK_GET_SESSION_SERVER_IP - description: Action parameter bulk get session server IP + name: SAI_FLOW_ENTRY_BULK_GET_SESSION_ATTR_BULK_GET_SESSION_IP + description: Action parameter bulk get session IP type: sai_ip_address_t attr_value_field: ipaddr default: 0.0.0.0 @@ -697,8 +697,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_BULK_GET_SESSION_ATTR_BULK_GET_SESSION_SERVER_PORT - description: Action parameter bulk get session server port + name: SAI_FLOW_ENTRY_BULK_GET_SESSION_ATTR_BULK_GET_SESSION_PORT + description: Action parameter bulk get session port type: sai_uint16_t attr_value_field: u16 default: '0' diff --git a/dash-pipeline/SAI/specs/sai_spec.yaml b/dash-pipeline/SAI/specs/sai_spec.yaml index ed86286e3..33800030b 100644 --- a/dash-pipeline/SAI/specs/sai_spec.yaml +++ b/dash-pipeline/SAI/specs/sai_spec.yaml @@ -377,6 +377,30 @@ enums: name: SWITCHING_TO_STANDALONE description: '' value: '12' +- !!python/object:utils.sai_spec.sai_enum.SaiEnum + name: sai_dash_flow_state_t + description: '' + members: + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: FLOW_MISS + description: '' + value: '0' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: FLOW_CREATED + description: '' + value: '1' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: FLOW_SYNCED + description: '' + value: '2' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: FLOW_PENDING_DELETE + description: '' + value: '3' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: FLOW_PENDING_RESIMULATION + description: '' + value: '4' - !!python/object:utils.sai_spec.sai_enum.SaiEnum name: sai_dash_eni_mac_override_type_t description: '' diff --git a/dash-pipeline/SAI/utils/sai_spec/sai_spec_utils.py b/dash-pipeline/SAI/utils/sai_spec/sai_spec_utils.py index daf0d465b..791a4896e 100644 --- a/dash-pipeline/SAI/utils/sai_spec/sai_spec_utils.py +++ b/dash-pipeline/SAI/utils/sai_spec/sai_spec_utils.py @@ -24,6 +24,7 @@ def load_word_fixers() -> None: "pb": "protocol buffer", "proto": "protocol", "smac": "source MAC", + "dest": "destination", "dpu": "DPU" } diff --git a/dash-pipeline/bmv2/dash_headers.p4 b/dash-pipeline/bmv2/dash_headers.p4 index 60fc1d0f5..b2238e57e 100644 --- a/dash-pipeline/bmv2/dash_headers.p4 +++ b/dash-pipeline/bmv2/dash_headers.p4 @@ -6,6 +6,65 @@ typedef bit<32> IPv4Address; typedef bit<128> IPv6Address; typedef bit<128> IPv4ORv6Address; +enum bit<16> dash_direction_t { + INVALID = 0, + OUTBOUND = 1, + INBOUND = 2 +}; + +typedef bit<32> dash_meter_class_t; + +enum bit<8> dash_packet_source_t { + EXTERNAL = 0, // Packets from external sources. + PIPELINE = 1, // Packets from P4 pipeline. + DPAPP = 2, // Packets from data plane app. + PEER = 3 // Packets from the paired DPU. +}; + +enum bit<4> dash_packet_type_t { + REGULAR = 0, // Regular packets from external sources. + FLOW_SYNC_REQ = 1, // Flow sync request packet. + FLOW_SYNC_ACK = 2, // Flow sync ack packet. + DP_PROBE_REQ = 3, // Data plane probe packet. + DP_PROBE_ACK = 4 // Data plane probe ack packet. +}; + +// Packet subtype for one kind of packet type +enum bit<4> dash_packet_subtype_t { + NONE = 0, // no op + FLOW_CREATE = 1, // New flow creation. + FLOW_UPDATE = 2, // Flow resimulation or any other reason causing existing flow to be updated. + FLOW_DELETE = 3 // Flow deletion. +}; + +enum bit<16> dash_encapsulation_t { + INVALID = 0, + VXLAN = 1, + NVGRE = 2 +} + +header encap_data_t { + bit<24> vni; + bit<24> dest_vnet_vni; + IPv4Address underlay_sip; + IPv4Address underlay_dip; + EthernetAddress underlay_smac; + EthernetAddress underlay_dmac; + dash_encapsulation_t dash_encapsulation; +} +const bit<16> ENCAP_DATA_HDR_SIZE=(24+24+32+32+48+48+16)/8; + +header overlay_rewrite_data_t { + EthernetAddress dmac; + IPv4ORv6Address sip; + IPv4ORv6Address dip; + IPv6Address sip_mask; + IPv6Address dip_mask; + bit<7> reserved; + bool is_ipv6; +} +const bit<16> OVERLAY_REWRITE_DATA_HDR_SIZE=(48+128+128+128+128+8)/8; + header ethernet_t { EthernetAddress dst_addr; EthernetAddress src_addr; @@ -93,7 +152,103 @@ header ipv6_t { const bit<16> IPV6_HDR_SIZE=320/8; + +#ifdef DPAPP_CONNTRACK +enum bit<16> dash_flow_enabled_key_t { + ENI_ADDR = (1 << 0), + VNI = (1 << 1), + PROTOCOL = (1 << 2), + SRC_IP = (1 << 3), + DST_IP = (1 << 4), + SRC_PORT = (1 << 5), + DST_PORT = (1 << 6) +} + +enum bit<16> dash_flow_entry_bulk_get_session_mode_t { + SAI_DASH_FLOW_ENTRY_BULK_GET_SESSION_MODE_GRPC = 0, + SAI_DASH_FLOW_ENTRY_BULK_GET_SESSION_MODE_VENDOR = 1, + SAI_DASH_FLOW_ENTRY_BULK_GET_SESSION_MODE_EVENT = 2, + SAI_DASH_FLOW_ENTRY_BULK_GET_SESSION_MODE_EVENT_WITHOUT_FLOW_STATE = 3 +} + +enum bit<16> dash_flow_entry_bulk_get_session_filter_key_t { + INVAILD = 0, + FLOW_TABLE_ID = 1, + ENI_ADDR = 2, + IP_PROTOCOL = 3, + SRC_IP_ADDR = 4, + DST_IP_ADDR = 5, + SRC_L4_PORT = 6, + DST_L4_PORT = 7, + KEY_VERSION = 8 +} + +enum bit<8> dash_flow_entry_bulk_get_session_op_key_t { + FILTER_OP_INVALID = 0, + FILTER_OP_EQUAL_TO = 1, + FILTER_OP_GREATER_THAN = 2, + FILTER_OP_GREATER_THAN_OR_EQUAL_TO = 3, + FILTER_OP_LESS_THAN = 4, + FILTER_OP_LESS_THAN_OR_EQUAL_TO = 5 +} + +struct flow_table_data_t { + bit<16> id; + bit<32> max_flow_count; + bit<16> flow_enabled_key; + bit<32> flow_ttl_in_milliseconds; +} + +header flow_key_t { + EthernetAddress eni_mac; + bit<16> vnet_id; + IPv4ORv6Address src_ip; + IPv4ORv6Address dst_ip; + bit<16> src_port; + bit<16> dst_port; + bit<8> ip_proto; + bit<7> reserved; + bit<1> is_ip_v6; +} +const bit<16> FLOW_KEY_HDR_SIZE=(48+16+128+128+16+16+8+8)/8; + +header flow_data_t { + bit<7> reserved; + bit<1> is_unidirectional; + bit<32> version; + dash_direction_t direction; + bit<16> tunnel_id; + bit<32> routing_actions; + dash_meter_class_t meter_class; +} +const bit<16> FLOW_DATA_HDR_SIZE=(8+32+16+16+32+32)/8; + +// dash packet metadata +header dash_packet_meta_t { + dash_packet_source_t packet_source; + dash_packet_type_t packet_type; + dash_packet_subtype_t packet_subtype; + bit<16> length; +} +const bit<16> PACKET_META_HDR_SIZE=(8+4+4+16)/8; + +#define DASH_ETHTYPE 0x876d +#define DPAPP_MAC 0x02fe23f0e413 + +#endif // DPAPP_CONNTRACK + struct headers_t { +#ifdef DPAPP_CONNTRACK + /* packet metadata headers */ + ethernet_t dp_ethernet; + dash_packet_meta_t packet_meta; + flow_key_t flow_key; + flow_data_t flow_data; // flow common data + overlay_rewrite_data_t flow_overlay_data; + encap_data_t flow_encap_data; + encap_data_t flow_tunnel_data; +#endif // DPAPP_CONNTRACK + /* Underlay 1 headers */ ethernet_t u1_ethernet; ipv4_t u1_ipv4; @@ -122,10 +277,4 @@ struct headers_t { tcp_t customer_tcp; } -enum bit<16> dash_encapsulation_t { - INVALID = 0, - VXLAN = 1, - NVGRE = 2 -} - #endif /* _SIRIUS_HEADERS_P4_ */ diff --git a/dash-pipeline/bmv2/dash_metadata.p4 b/dash-pipeline/bmv2/dash_metadata.p4 index 48f01561c..fbe329cb0 100644 --- a/dash-pipeline/bmv2/dash_metadata.p4 +++ b/dash-pipeline/bmv2/dash_metadata.p4 @@ -14,26 +14,6 @@ enum bit<32> dash_routing_actions_t { NAT_PORT = (1 << 4) }; -enum bit<16> dash_direction_t { - INVALID = 0, - OUTBOUND = 1, - INBOUND = 2 -}; - -enum bit<8> dash_packet_source_t { - EXTERNAL = 0, // Packets from external sources. - DPAPP = 1, // Packets from data plane app. - PEER = 2 // Packets from the paired DPU. -}; - -enum bit<8> dash_packet_type_t { - REGULAR = 0, // Regular packets from external sources. - FLOW_SYNC_REQ = 1, // Flow sync request packet. - FLOW_SYNC_ACK = 2, // Flow sync ack packet. - DP_PROBE_REQ = 3, // Data plane probe packet. - DP_PROBE_ACK = 4 // Data plane probe ack packet. -}; - // Pipeline stages: enum bit<16> dash_pipeline_stage_t { INVALID = 0, @@ -51,74 +31,6 @@ enum bit<16> dash_pipeline_stage_t { ROUTING_ACTION_APPLY = 300 }; -enum bit<16> dash_flow_enabled_key_t { - ENI_ADDR = (1 << 0), - VNI = (1 << 1), - PROTOCOL = (1 << 2), - SRC_IP = (1 << 3), - DST_IP = (1 << 4), - SRC_PORT = (1 << 5), - DST_PORT = (1 << 6) -} - -struct flow_table_data_t { - bit<16> id; - bit<32> max_flow_count; - dash_flow_enabled_key_t flow_enabled_key; - bit<32> flow_ttl_in_milliseconds; -} - -enum bit<32> dash_flow_action_t { - NONE = 0 -} - -struct flow_key_t { - EthernetAddress eni_mac; - bit<8> ip_proto; - bit<16> vnet_id; - IPv4ORv6Address src_ip; - IPv4ORv6Address dst_ip; - bit<16> src_port; - bit<16> dst_port; - bool is_ipv6; -} - -struct flow_data_t { - bit<32> version; - dash_direction_t dash_direction; - dash_flow_action_t actions; -} - -enum bit<16> dash_flow_entry_bulk_get_session_mode_t { - SAI_DASH_FLOW_ENTRY_BULK_GET_SESSION_MODE_GRPC = 0, - SAI_DASH_FLOW_ENTRY_BULK_GET_SESSION_MODE_VENDOR = 1, - SAI_DASH_FLOW_ENTRY_BULK_GET_SESSION_MODE_EVENT = 2, - SAI_DASH_FLOW_ENTRY_BULK_GET_SESSION_MODE_EVENT_WITHOUT_FLOW_STATE = 3 -} - -enum bit<16> dash_flow_entry_bulk_get_session_filter_key_t -{ - INVAILD = 0, - FLOW_TABLE_ID = 1, - ENI_ADDR = 2, - IP_PROTOCOL = 3, - SRC_IP_ADDR = 4, - DST_IP_ADDR = 5, - SRC_L4_PORT = 6, - DST_L4_PORT = 7, - KEY_VERSION = 8 -} - -enum bit<8> dash_flow_entry_bulk_get_session_op_key_t -{ - FILTER_OP_INVALID = 0, - FILTER_OP_EQUAL_TO = 1, - FILTER_OP_GREATER_THAN = 2, - FILTER_OP_GREATER_THAN_OR_EQUAL_TO = 3, - FILTER_OP_LESS_THAN = 4, - FILTER_OP_LESS_THAN_OR_EQUAL_TO = 5 -} - enum bit<8> dash_eni_mac_override_type_t { NONE = 0, SRC_MAC = 1, @@ -133,14 +45,6 @@ enum bit<8> dash_eni_mac_type_t { struct conntrack_data_t { bool allow_in; bool allow_out; - flow_table_data_t flow_table; - EthernetAddress eni_mac; - flow_data_t flow_data; - flow_key_t flow_key; - flow_key_t reverse_flow_key; - bit<1> is_unidirectional_flow; - bit<16> bulk_get_session_id; - bit<16> bulk_get_session_filter_id; } enum bit<16> dash_tunnel_dscp_mode_t { @@ -173,24 +77,6 @@ struct meter_context_t { IPv4ORv6Address meter_policy_lookup_ip; } -struct encap_data_t { - bit<24> vni; - IPv4Address underlay_sip; - IPv4Address underlay_dip; - dash_encapsulation_t dash_encapsulation; - EthernetAddress underlay_smac; - EthernetAddress underlay_dmac; -} - -struct overlay_rewrite_data_t { - bool is_ipv6; - EthernetAddress dmac; - IPv4ORv6Address sip; - IPv4ORv6Address dip; - IPv6Address sip_mask; - IPv6Address dip_mask; -} - // HA roles enum bit<8> dash_ha_role_t { DEAD = 0, @@ -229,8 +115,8 @@ enum bit<8> dash_ha_state_t { SWITCHING_TO_STANDALONE = 12 }; -// Flow sync state -enum bit<8> dash_ha_flow_sync_state_t { +// Flow state +enum bit<8> dash_flow_state_t { FLOW_MISS = 0, // Flow not created yet FLOW_CREATED = 1, // Flow is created but not synched or waiting for ack FLOW_SYNCED = 2, // Flow has been synched to its peer @@ -238,13 +124,6 @@ enum bit<8> dash_ha_flow_sync_state_t { FLOW_PENDING_RESIMULATION = 4 // Flow is marked as pending resimulation }; -// HA flow sync operations -enum bit<8> dash_ha_flow_sync_op_t { - FLOW_CREATE = 0, // New flow creation. - FLOW_UPDATE = 1, // Flow resimulation or any other reason causing existing flow to be updated. - FLOW_DELETE = 2 // Flow deletion. -}; - struct ha_data_t { // HA scope settings bit<16> ha_scope_id; @@ -261,7 +140,7 @@ struct ha_data_t { bit<16> dp_channel_src_port_max; // HA packet/flow state - dash_ha_flow_sync_state_t flow_sync_state; + dash_flow_state_t flow_sync_state; } struct metadata_t { @@ -303,13 +182,18 @@ struct metadata_t { // Flow data conntrack_data_t conntrack_data; +#ifdef DPAPP_CONNTRACK + flow_table_data_t flow_table; + dash_flow_state_t flow_state; + bit<16> bulk_get_session_id; + bit<16> bulk_get_session_filter_id; +#endif // DPAPP_CONNTRACK // Stage transition control dash_pipeline_stage_t target_stage; // Actions bit<32> routing_actions; - bit<32> flow_actions; // Action data bool dropped; diff --git a/dash-pipeline/bmv2/dash_parser.p4 b/dash-pipeline/bmv2/dash_parser.p4 index d6eed01fc..3ff5652bf 100644 --- a/dash-pipeline/bmv2/dash_parser.p4 +++ b/dash-pipeline/bmv2/dash_parser.p4 @@ -29,14 +29,35 @@ parser dash_parser( ) { state start { +#ifdef DPAPP_CONNTRACK + // By default, packet is REGULAR from EXTERNAL + hd.packet_meta.setValid(); + hd.packet_meta.packet_source = dash_packet_source_t.EXTERNAL; + hd.packet_meta.packet_type = dash_packet_type_t.REGULAR; + hd.packet_meta.packet_subtype = dash_packet_subtype_t.NONE; + hd.packet_meta.length = PACKET_META_HDR_SIZE; +#endif // DPAPP_CONNTRACK + packet.extract(hd.u0_ethernet); transition select(hd.u0_ethernet.ether_type) { IPV4_ETHTYPE: parse_u0_ipv4; IPV6_ETHTYPE: parse_u0_ipv6; +#ifdef DPAPP_CONNTRACK + DASH_ETHTYPE: parse_dash; +#endif // DPAPP_CONNTRACK default: accept; } } +#ifdef DPAPP_CONNTRACK + state parse_dash { + packet.extract(hd.packet_meta); + // TODO extract flow_key, etc by checking packet type/subtype + packet.extract(hd.flow_key); + transition parse_customer_ethernet; + } +#endif // DPAPP_CONNTRACK + state parse_u0_ipv4 { packet.extract(hd.u0_ipv4); verify(hd.u0_ipv4.version == 4w4, error.IPv4IncorrectVersion); @@ -138,7 +159,17 @@ control dash_deparser( ) { apply { - packet.emit(hdr.u0_ethernet); +#ifdef DPAPP_CONNTRACK + packet.emit(hdr.dp_ethernet); + packet.emit(hdr.packet_meta); + packet.emit(hdr.flow_key); + packet.emit(hdr.flow_data); + packet.emit(hdr.flow_overlay_data); + packet.emit(hdr.flow_encap_data); + packet.emit(hdr.flow_tunnel_data); +#endif // DPAPP_CONNTRACK + + packet.emit(hdr.u0_ethernet); packet.emit(hdr.u0_ipv4); packet.emit(hdr.u0_ipv4options); packet.emit(hdr.u0_ipv6); diff --git a/dash-pipeline/bmv2/dash_pipeline.p4 b/dash-pipeline/bmv2/dash_pipeline.p4 index 0113ec195..19f110514 100644 --- a/dash-pipeline/bmv2/dash_pipeline.p4 +++ b/dash-pipeline/bmv2/dash_pipeline.p4 @@ -8,8 +8,11 @@ #include "dash_tunnel.p4" #include "dash_outbound.p4" #include "dash_inbound.p4" -#include "dash_conntrack.p4" +#ifdef DPAPP_CONNTRACK #include "stages/conntrack_lookup.p4" +#else +#include "dash_conntrack.p4" +#endif #include "stages/direction_lookup.p4" #include "stages/eni_lookup.p4" #include "stages/ha.p4" @@ -250,6 +253,9 @@ control dash_ingress( } apply { + meta.encap_data.setValid(); + meta.tunnel_data.setValid(); + meta.overlay_data.setValid(); #ifdef TARGET_DPDK_PNA #ifdef DPDK_PNA_SEND_TO_PORT_FIX_MERGED @@ -265,6 +271,11 @@ control dash_ingress( #endif // DPDK_PNA_SEND_TO_PORT_FIX_MERGED #endif // TARGET_DPDK_PNA +#ifdef DPAPP_CONNTRACK + // If packet is from DPAPP, just do conntrack_lookup + if (hdr.packet_meta.packet_source != dash_packet_source_t.DPAPP) { +#endif // DPAPP_CONNTRACK + if (meta.is_fast_path_icmp_flow_redirection_packet) { UPDATE_COUNTER(port_lb_fast_path_icmp_in, 0); } @@ -337,16 +348,24 @@ control dash_ingress( if (meta.eni_data.admin_state == 0) { deny(); } - - conntrack_lookup_stage.apply(hdr, meta); - + UPDATE_ENI_COUNTER(eni_rx); if (meta.is_fast_path_icmp_flow_redirection_packet) { UPDATE_ENI_COUNTER(eni_lb_fast_path_icmp_in); } + +#ifdef DPAPP_CONNTRACK + } // from dpapp + conntrack_lookup_stage.apply(hdr, meta); +#endif // DPAPP_CONNTRACK + ha_stage.apply(hdr, meta); +#ifdef DPAPP_CONNTRACK + if (meta.flow_state == dash_flow_state_t.FLOW_MISS) { +#endif // DPAPP_CONNTRACK + acl_group.apply(); if (meta.direction == dash_direction_t.OUTBOUND) { @@ -361,6 +380,15 @@ control dash_ingress( tunnel_stage.apply(hdr, meta); +#ifdef DPAPP_CONNTRACK + if (!meta.dropped) { + conntrack_set_flow_data.apply(hdr, meta); + standard_metadata.egress_spec = 2; // vpp port + return; + } + } +#endif // DPAPP_CONNTRACK + routing_action_apply.apply(hdr, meta); tunnel_stage_encap.apply(hdr, meta); @@ -396,6 +424,19 @@ control dash_ingress( UPDATE_ENI_COUNTER(eni_inbound_tx); } } + +#ifdef DPAPP_CONNTRACK + // Drop dash header in fast path + if (meta.flow_state == dash_flow_state_t.FLOW_CREATED) { + hdr.dp_ethernet.setInvalid(); + hdr.packet_meta.setInvalid(); + hdr.flow_key.setInvalid(); + hdr.flow_data.setInvalid(); + hdr.flow_overlay_data.setInvalid(); + hdr.flow_encap_data.setInvalid(); + hdr.flow_tunnel_data.setInvalid(); + } +#endif // DPAPP_CONNTRACK } } diff --git a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 index 99e1c011c..4907c73c9 100644 --- a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 +++ b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 @@ -1,8 +1,53 @@ #ifndef _DASH_STAGE_CONNTRACK_LOOKUP_P4 #define _DASH_STAGE_CONNTRACK_LOOKUP_P4 +#ifdef DPAPP_CONNTRACK #include "../dash_metadata.p4" +control conntrack_set_flow_data(inout headers_t hdr, inout metadata_t meta) +{ + apply { + bit<16> length = 0; + + hdr.flow_data.setValid(); + hdr.flow_data.is_unidirectional = 0; + hdr.flow_data.version = 0; + hdr.flow_data.direction = meta.direction; + hdr.flow_data.tunnel_id = meta.dash_tunnel_id; + hdr.flow_data.routing_actions = meta.routing_actions; + hdr.flow_data.meter_class = meta.meter_class; + length = length + FLOW_DATA_HDR_SIZE; + + if (meta.routing_actions & dash_routing_actions_t.STATIC_ENCAP != 0) { + hdr.flow_encap_data= meta.encap_data; + length = length + ENCAP_DATA_HDR_SIZE; + } + + if (meta.dash_tunnel_id != 0) { + hdr.flow_tunnel_data= meta.tunnel_data; + length = length + ENCAP_DATA_HDR_SIZE; + } + + if (meta.routing_actions != 0) { + hdr.flow_overlay_data= meta.overlay_data; + length = length + OVERLAY_REWRITE_DATA_HDR_SIZE; + } + + length = length + FLOW_KEY_HDR_SIZE; + + hdr.packet_meta.setValid(); + hdr.packet_meta.packet_source = dash_packet_source_t.PIPELINE; + hdr.packet_meta.packet_type = dash_packet_type_t.REGULAR; + hdr.packet_meta.packet_subtype = dash_packet_subtype_t.FLOW_CREATE; + hdr.packet_meta.length = length + PACKET_META_HDR_SIZE; + + hdr.dp_ethernet.setValid(); + hdr.dp_ethernet.dst_addr = DPAPP_MAC; + hdr.dp_ethernet.src_addr = meta.encap_data.underlay_smac; + hdr.dp_ethernet.ether_type = DASH_ETHTYPE; + } +} + control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { // // Flow table: @@ -12,15 +57,15 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { @SaiVal[type="sai_dash_flow_enabled_key_t"] dash_flow_enabled_key_t dash_flow_enabled_key, bit<32> flow_ttl_in_milliseconds) { - meta.conntrack_data.flow_table.max_flow_count = max_flow_count; - meta.conntrack_data.flow_table.flow_enabled_key = dash_flow_enabled_key; - meta.conntrack_data.flow_table.flow_ttl_in_milliseconds = flow_ttl_in_milliseconds; + meta.flow_table.max_flow_count = max_flow_count; + meta.flow_table.flow_enabled_key = dash_flow_enabled_key; + meta.flow_table.flow_ttl_in_milliseconds = flow_ttl_in_milliseconds; } @SaiTable[name = "flow_table", api = "dash_flow", order = 0, isobject="true"] table flow_table { key = { - meta.conntrack_data.flow_table.id : exact; + meta.flow_table.id : exact; } actions = { @@ -33,108 +78,115 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { // action set_flow_entry_attr( /* Flow basic metadata */ + bit<1> is_unidirectional, + dash_flow_state_t state, bit<32> version, @SaiVal[type="sai_dash_direction_t"] dash_direction_t dash_direction, - @SaiVal[type="sai_dash_flow_action_t"] dash_flow_action_t dash_flow_action, + bit<16> tunnel_id, + bit<32> routing_actions, bit<32> meter_class, - bit<1> is_unidirectional_flow, - - /* Reverse flow key */ - EthernetAddress reverse_flow_eni_mac, - bit<16> reverse_flow_vnet_id, - bit<8> reverse_flow_ip_proto, - IPv4ORv6Address reverse_flow_src_ip, - IPv4ORv6Address reverse_flow_dst_ip, - bit<16> reverse_flow_src_port, - bit<16> reverse_flow_dst_port, /* Flow encap related attributes */ - bit<24> underlay0_vnet_id, - IPv4Address underlay0_sip, - IPv4Address underlay0_dip, - @SaiVal[type="sai_dash_encapsulation_t"] dash_encapsulation_t underlay0_dash_encapsulation, - - bit<24> underlay1_vnet_id, - IPv4Address underlay1_sip, - IPv4Address underlay1_dip, - EthernetAddress underlay1_smac, - EthernetAddress underlay1_dmac, - @SaiVal[type="sai_dash_encapsulation_t"] dash_encapsulation_t underlay1_dash_encapsulation, - + bit<24> encap_data_vni, + bit<24> encap_data_dest_vnet_vni, + IPv4Address encap_data_underlay_sip, + IPv4Address encap_data_underlay_dip, + EthernetAddress encap_data_underlay_smac, + EthernetAddress encap_data_underlay_dmac, + @SaiVal[type="sai_dash_encapsulation_t"] dash_encapsulation_t encap_data_dash_encapsulation, + + /* Flow tunnel related attributes */ + bit<24> tunnel_data_vni, + bit<24> tunnel_data_dest_vnet_vni, + IPv4Address tunnel_data_underlay_sip, + IPv4Address tunnel_data_underlay_dip, + EthernetAddress tunnel_data_underlay_smac, + EthernetAddress tunnel_data_underlay_dmac, + @SaiVal[type="sai_dash_encapsulation_t"] dash_encapsulation_t tunnel_data_dash_encapsulation, + /* Flow overlay rewrite related attributes */ - EthernetAddress dst_mac, - IPv4ORv6Address sip, - IPv4ORv6Address dip, - IPv6Address sip_mask, - IPv6Address dip_mask, - - /* Extra flow metadata */ + bit<1> overlay_data_is_ipv6, + EthernetAddress overlay_data_dst_mac, + IPv4ORv6Address overlay_data_sip, + IPv4ORv6Address overlay_data_dip, + IPv6Address overlay_data_sip_mask, + IPv6Address overlay_data_dip_mask, + + /* Extra flow metadata, unused */ @SaiVal[type="sai_u8_list_t"] bit<16> vendor_metadata, @SaiVal[type="sai_u8_list_t"] bit<16> flow_data_pb) { - /* Set Flow basic metadata */ - meta.conntrack_data.flow_data.version = version; - meta.conntrack_data.flow_data.dash_direction = dash_direction; - meta.conntrack_data.flow_data.actions = dash_flow_action; - meta.meter_class = meter_class; - meta.conntrack_data.is_unidirectional_flow = is_unidirectional_flow; - - /* Set reverse flow key */ - meta.conntrack_data.reverse_flow_key.eni_mac = reverse_flow_eni_mac; - meta.conntrack_data.reverse_flow_key.vnet_id = reverse_flow_vnet_id; - meta.conntrack_data.reverse_flow_key.ip_proto = reverse_flow_ip_proto; - meta.conntrack_data.reverse_flow_key.src_ip = reverse_flow_src_ip; - meta.conntrack_data.reverse_flow_key.dst_ip = reverse_flow_dst_ip; - meta.conntrack_data.reverse_flow_key.src_port = reverse_flow_src_port; - meta.conntrack_data.reverse_flow_key.dst_port = reverse_flow_dst_port; + meta.flow_state = state; + // TODO check FLOW_SYNCED in ha + // Do state FSM later + if (state != dash_flow_state_t.FLOW_CREATED) { + return; + } + /* Set basic metadata */ + meta.direction = dash_direction; + meta.dash_tunnel_id = tunnel_id; + meta.routing_actions = routing_actions; + meta.meter_class = meter_class; /* Set encapsulation metadata */ - meta.encap_data.vni = underlay0_vnet_id; - meta.encap_data.underlay_sip = underlay0_sip; - meta.encap_data.underlay_dip = underlay0_dip; - meta.encap_data.dash_encapsulation = underlay0_dash_encapsulation; + meta.encap_data.vni = encap_data_vni; + meta.encap_data.dest_vnet_vni = encap_data_dest_vnet_vni; + meta.encap_data.underlay_sip = encap_data_underlay_sip; + meta.encap_data.underlay_dip = encap_data_underlay_dip; + meta.encap_data.underlay_smac = encap_data_underlay_smac; + meta.encap_data.underlay_dmac = encap_data_underlay_dmac; + meta.encap_data.dash_encapsulation = encap_data_dash_encapsulation; - meta.tunnel_data.vni = underlay1_vnet_id; - meta.tunnel_data.underlay_sip = underlay1_sip; - meta.tunnel_data.underlay_dip = underlay1_dip; - meta.tunnel_data.dash_encapsulation = underlay1_dash_encapsulation; - meta.tunnel_data.underlay_smac = underlay1_smac; - meta.tunnel_data.underlay_dmac = underlay1_dmac; + /* Set tunnel metadata */ + meta.tunnel_data.vni = tunnel_data_vni; + meta.tunnel_data.dest_vnet_vni = tunnel_data_dest_vnet_vni; + meta.tunnel_data.underlay_sip = tunnel_data_underlay_sip; + meta.tunnel_data.underlay_dip = tunnel_data_underlay_dip; + meta.tunnel_data.underlay_smac = tunnel_data_underlay_smac; + meta.tunnel_data.underlay_dmac = tunnel_data_underlay_dmac; + meta.tunnel_data.dash_encapsulation = tunnel_data_dash_encapsulation; /* Set overlay rewrite metadata */ - meta.overlay_data.dmac = dst_mac; - meta.overlay_data.sip = sip; - meta.overlay_data.dip = dip; - meta.overlay_data.sip_mask = sip_mask; - meta.overlay_data.dip_mask = dip_mask; + meta.overlay_data.is_ipv6 = (bool)overlay_data_is_ipv6; + meta.overlay_data.dmac = overlay_data_dst_mac; + meta.overlay_data.sip = overlay_data_sip; + meta.overlay_data.dip = overlay_data_dip; + meta.overlay_data.sip_mask = overlay_data_sip_mask; + meta.overlay_data.dip_mask = overlay_data_dip_mask; + } + + action flow_miss() { + meta.flow_state = dash_flow_state_t.FLOW_MISS; } @SaiTable[name = "flow", api = "dash_flow", order = 1, enable_bulk_get_api = "true", enable_bulk_get_server = "true"] table flow_entry { key = { - meta.conntrack_data.flow_key.eni_mac : exact; - meta.conntrack_data.flow_key.vnet_id : exact; - meta.conntrack_data.flow_key.ip_proto : exact; - meta.conntrack_data.flow_key.src_ip : exact; - meta.conntrack_data.flow_key.dst_ip : exact; - meta.conntrack_data.flow_key.src_port : exact; - meta.conntrack_data.flow_key.dst_port : exact; - meta.conntrack_data.flow_key.is_ipv6 : exact @SaiVal[name = "src_ip_is_v6"]; + hdr.flow_key.eni_mac : exact; + hdr.flow_key.vnet_id : exact; + hdr.flow_key.src_ip : exact; + hdr.flow_key.dst_ip : exact; + hdr.flow_key.src_port : exact; + hdr.flow_key.dst_port : exact; + hdr.flow_key.ip_proto : exact; + hdr.flow_key.is_ip_v6 : exact @SaiVal[name = "src_ip_is_v6"]; } actions = { set_flow_entry_attr; + @defaultonly flow_miss; } + const default_action = flow_miss; } - + // // Flow bulk get session filter: // For API generation only and has no effect on the dataplane // action set_flow_entry_bulk_get_session_filter_attr( - @SaiVal[type="sai_dash_flow_entry_bulk_get_session_filter_key_t"] dash_flow_entry_bulk_get_session_filter_key_t dash_flow_entry_bulk_get_session_filter_key, + @SaiVal[type="sai_dash_flow_entry_bulk_get_session_filter_key_t"] dash_flow_entry_bulk_get_session_filter_key_t dash_flow_entry_bulk_get_session_filter_key, @SaiVal[type="sai_dash_flow_entry_bulk_get_session_op_key_t"] dash_flow_entry_bulk_get_session_op_key_t dash_flow_entry_bulk_get_session_op_key, bit<64> int_value, IPv4ORv6Address ip_value, @@ -148,14 +200,14 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { // action set_flow_entry_bulk_get_session_attr( /* Mode and limitation */ - @SaiVal[type="sai_dash_flow_entry_bulk_get_session_mode_t"] dash_flow_entry_bulk_get_session_mode_t dash_flow_entry_bulk_get_session_mode, + @SaiVal[type="sai_dash_flow_entry_bulk_get_session_mode_t"] dash_flow_entry_bulk_get_session_mode_t dash_flow_entry_bulk_get_session_mode, bit<32> bulk_get_entry_limitation, - + /* GRPC Session server IP and port */ - IPv4ORv6Address bulk_get_session_server_ip, - bit<16> bulk_get_session_server_port, + IPv4ORv6Address bulk_get_session_ip, + bit<16> bulk_get_session_port, - /* Session filters */ + /* Session filters */ @SaiVal[type="sai_object_id_t"] bit<16> first_flow_entry_bulk_get_session_filter_id, @SaiVal[type="sai_object_id_t"] bit<16> second_flow_entry_bulk_get_session_filter_id, @SaiVal[type="sai_object_id_t"] bit<16> third_flow_entry_bulk_get_session_filter_id, @@ -164,12 +216,11 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { { } - @SaiTable[name = "flow_entry_bulk_get_session_filter", api = "dash_flow", order = 2, isobject="true"] table flow_entry_bulk_get_session_filter { key = { - meta.conntrack_data.bulk_get_session_filter_id: exact @SaiVal[name = "bulk_get_session_filter_id", type="sai_object_id_t"]; + meta.bulk_get_session_filter_id: exact @SaiVal[name = "bulk_get_session_filter_id", type="sai_object_id_t"]; } actions = { @@ -180,7 +231,7 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { @SaiTable[name = "flow_entry_bulk_get_session", api = "dash_flow", order = 3, isobject="true"] table flow_entry_bulk_get_session { key = { - meta.conntrack_data.bulk_get_session_id: exact @SaiVal[name = "bulk_get_session_id", type="sai_object_id_t"]; + meta.bulk_get_session_id: exact @SaiVal[name = "bulk_get_session_id", type="sai_object_id_t"]; } actions = { @@ -188,33 +239,48 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { } } - apply { - flow_table.apply(); + action set_flow_key() + { + hdr.flow_key.setValid(); + hdr.flow_key.is_ip_v6 = meta.is_overlay_ip_v6; + // TODO remove hardcode flow_enabled_key later + meta.flow_table.flow_enabled_key = dash_flow_enabled_key_t.ENI_ADDR | + dash_flow_enabled_key_t.VNI | + dash_flow_enabled_key_t.PROTOCOL | + dash_flow_enabled_key_t.SRC_IP | + dash_flow_enabled_key_t.DST_IP | + dash_flow_enabled_key_t.SRC_PORT | + dash_flow_enabled_key_t.DST_PORT; - if (meta.conntrack_data.flow_table.flow_enabled_key & dash_flow_enabled_key_t.ENI_ADDR != 0) { - meta.conntrack_data.flow_key.eni_mac = meta.eni_addr; + if (meta.flow_table.flow_enabled_key & dash_flow_enabled_key_t.ENI_ADDR != 0) { + hdr.flow_key.eni_mac = meta.eni_addr; } - - if (meta.conntrack_data.flow_table.flow_enabled_key & dash_flow_enabled_key_t.VNI != 0) { - meta.conntrack_data.flow_key.vnet_id = meta.vnet_id; - } - - if (meta.conntrack_data.flow_table.flow_enabled_key & dash_flow_enabled_key_t.PROTOCOL != 0) { - meta.conntrack_data.flow_key.ip_proto = meta.ip_protocol; + if (meta.flow_table.flow_enabled_key & dash_flow_enabled_key_t.VNI != 0) { + hdr.flow_key.vnet_id = meta.vnet_id; + } + if (meta.flow_table.flow_enabled_key & dash_flow_enabled_key_t.PROTOCOL != 0) { + hdr.flow_key.ip_proto = meta.ip_protocol; + } + if (meta.flow_table.flow_enabled_key & dash_flow_enabled_key_t.SRC_IP != 0) { + hdr.flow_key.src_ip = meta.src_ip_addr; } - if (meta.conntrack_data.flow_table.flow_enabled_key & dash_flow_enabled_key_t.SRC_IP != 0) { - meta.conntrack_data.flow_key.src_ip = meta.src_ip_addr; + if (meta.flow_table.flow_enabled_key & dash_flow_enabled_key_t.DST_IP != 0) { + hdr.flow_key.dst_ip = meta.dst_ip_addr; } - if (meta.conntrack_data.flow_table.flow_enabled_key & dash_flow_enabled_key_t.DST_IP != 0) { - meta.conntrack_data.flow_key.dst_ip = meta.dst_ip_addr; + + if (meta.flow_table.flow_enabled_key & dash_flow_enabled_key_t.SRC_PORT != 0) { + hdr.flow_key.src_port = meta.src_l4_port; } - if (meta.conntrack_data.flow_table.flow_enabled_key & dash_flow_enabled_key_t.SRC_PORT != 0) { - meta.conntrack_data.flow_key.src_port = meta.src_l4_port; + if (meta.flow_table.flow_enabled_key & dash_flow_enabled_key_t.DST_PORT != 0) { + hdr.flow_key.dst_port = meta.dst_l4_port; } + } - if (meta.conntrack_data.flow_table.flow_enabled_key & dash_flow_enabled_key_t.DST_PORT != 0) { - meta.conntrack_data.flow_key.dst_port = meta.dst_l4_port; + apply { + if (!hdr.flow_key.isValid()) { + flow_table.apply(); + set_flow_key(); } flow_entry.apply(); @@ -222,5 +288,5 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { flow_entry_bulk_get_session.apply(); } } - +#endif // DPAPP_CONNTRACK #endif /* _DASH_STAGE_CONNTRACK_LOOKUP_P4 */ diff --git a/dash-pipeline/bmv2/underlay.p4 b/dash-pipeline/bmv2/underlay.p4 index a55e71dcd..ba8811d7a 100644 --- a/dash-pipeline/bmv2/underlay.p4 +++ b/dash-pipeline/bmv2/underlay.p4 @@ -50,6 +50,12 @@ control underlay( action def_act() { #ifdef TARGET_BMV2_V1MODEL +#ifdef DPAPP_CONNTRACK + if (hdr.packet_meta.packet_source == dash_packet_source_t.DPAPP) { + standard_metadata.egress_spec = 0; + } + else +#endif // DPAPP_CONNTRACK standard_metadata.egress_spec = standard_metadata.ingress_port; #endif // TARGET_BMV2_V1MODEL @@ -82,6 +88,8 @@ control underlay( /* Send packet on same port it arrived (echo) by default */ @defaultonly def_act; } + + const default_action = def_act; } apply { From 735147e2288baa217699ce54fc803ce5e14073ad Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Tue, 16 Jul 2024 12:39:49 +0000 Subject: [PATCH 03/18] Add flow state FSM --- dash-pipeline/bmv2/dash_metadata.p4 | 1 + dash-pipeline/bmv2/dash_parser.p4 | 24 ++++- dash-pipeline/bmv2/dash_pipeline.p4 | 28 +++--- dash-pipeline/bmv2/stages/conntrack_lookup.p4 | 91 ++++++++++++++++++- 4 files changed, 123 insertions(+), 21 deletions(-) diff --git a/dash-pipeline/bmv2/dash_metadata.p4 b/dash-pipeline/bmv2/dash_metadata.p4 index fbe329cb0..a92bf2b78 100644 --- a/dash-pipeline/bmv2/dash_metadata.p4 +++ b/dash-pipeline/bmv2/dash_metadata.p4 @@ -187,6 +187,7 @@ struct metadata_t { dash_flow_state_t flow_state; bit<16> bulk_get_session_id; bit<16> bulk_get_session_filter_id; + bool to_dpapp; #endif // DPAPP_CONNTRACK // Stage transition control diff --git a/dash-pipeline/bmv2/dash_parser.p4 b/dash-pipeline/bmv2/dash_parser.p4 index 3ff5652bf..b3797f51d 100644 --- a/dash-pipeline/bmv2/dash_parser.p4 +++ b/dash-pipeline/bmv2/dash_parser.p4 @@ -52,8 +52,28 @@ parser dash_parser( #ifdef DPAPP_CONNTRACK state parse_dash { packet.extract(hd.packet_meta); - // TODO extract flow_key, etc by checking packet type/subtype - packet.extract(hd.flow_key); + if (hd.packet_meta.packet_subtype != dash_packet_subtype_t.NONE) { + // Flow create/update/delete, extract flow_key + packet.extract(hd.flow_key); + } + + if (hd.packet_meta.packet_subtype == dash_packet_subtype_t.FLOW_DELETE) { + // Flow delete, extract flow_data ... + packet.extract(hd.flow_data); + + if (hd.flow_data.routing_actions != 0) { + packet.extract(hd.flow_overlay_data); + } + + if (hd.flow_data.routing_actions & dash_routing_actions_t.STATIC_ENCAP != 0) { + packet.extract(hd.flow_encap_data); + } + + if (hd.flow_data.tunnel_id != 0) { + packet.extract(hd.flow_tunnel_data); + } + } + transition parse_customer_ethernet; } #endif // DPAPP_CONNTRACK diff --git a/dash-pipeline/bmv2/dash_pipeline.p4 b/dash-pipeline/bmv2/dash_pipeline.p4 index 19f110514..a4b3a536a 100644 --- a/dash-pipeline/bmv2/dash_pipeline.p4 +++ b/dash-pipeline/bmv2/dash_pipeline.p4 @@ -363,7 +363,8 @@ control dash_ingress( ha_stage.apply(hdr, meta); #ifdef DPAPP_CONNTRACK - if (meta.flow_state == dash_flow_state_t.FLOW_MISS) { + if (meta.flow_state == dash_flow_state_t.FLOW_MISS && + hdr.packet_meta.packet_source == dash_packet_source_t.EXTERNAL) { #endif // DPAPP_CONNTRACK acl_group.apply(); @@ -380,13 +381,19 @@ control dash_ingress( tunnel_stage.apply(hdr, meta); + if (meta.dropped) { + drop_action(); + return; + } + #ifdef DPAPP_CONNTRACK - if (!meta.dropped) { - conntrack_set_flow_data.apply(hdr, meta); + } + + conntrack_flow_handle.apply(hdr, meta); + if (meta.to_dpapp) { standard_metadata.egress_spec = 2; // vpp port return; } - } #endif // DPAPP_CONNTRACK routing_action_apply.apply(hdr, meta); @@ -424,19 +431,6 @@ control dash_ingress( UPDATE_ENI_COUNTER(eni_inbound_tx); } } - -#ifdef DPAPP_CONNTRACK - // Drop dash header in fast path - if (meta.flow_state == dash_flow_state_t.FLOW_CREATED) { - hdr.dp_ethernet.setInvalid(); - hdr.packet_meta.setInvalid(); - hdr.flow_key.setInvalid(); - hdr.flow_data.setInvalid(); - hdr.flow_overlay_data.setInvalid(); - hdr.flow_encap_data.setInvalid(); - hdr.flow_tunnel_data.setInvalid(); - } -#endif // DPAPP_CONNTRACK } } diff --git a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 index 4907c73c9..cb8714643 100644 --- a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 +++ b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 @@ -4,7 +4,37 @@ #ifdef DPAPP_CONNTRACK #include "../dash_metadata.p4" -control conntrack_set_flow_data(inout headers_t hdr, inout metadata_t meta) +action conntrack_set_meta_from_dash_header(in headers_t hdr, out metadata_t meta) +{ + /* basic metadata */ + meta.direction = hdr.flow_data.direction; + meta.dash_tunnel_id = hdr.flow_data.tunnel_id; + meta.routing_actions = hdr.flow_data.routing_actions; + meta.meter_class = hdr.flow_data.meter_class; + + /* encapsulation metadata */ + meta.encap_data = hdr.flow_encap_data; + + /* tunnel metadata */ + meta.tunnel_data = hdr.flow_tunnel_data; + + /* overlay rewrite metadata */ + meta.overlay_data = hdr.flow_overlay_data; +} + +action conntrack_strip_dash_header(inout headers_t hdr) +{ + hdr.dp_ethernet.setInvalid(); + hdr.packet_meta.setInvalid(); + hdr.flow_key.setInvalid(); + hdr.flow_data.setInvalid(); + hdr.flow_overlay_data.setInvalid(); + hdr.flow_encap_data.setInvalid(); + hdr.flow_tunnel_data.setInvalid(); +} + +control conntrack_build_dash_header(inout headers_t hdr, in metadata_t meta, + dash_packet_subtype_t packet_subtype) { apply { bit<16> length = 0; @@ -38,7 +68,7 @@ control conntrack_set_flow_data(inout headers_t hdr, inout metadata_t meta) hdr.packet_meta.setValid(); hdr.packet_meta.packet_source = dash_packet_source_t.PIPELINE; hdr.packet_meta.packet_type = dash_packet_type_t.REGULAR; - hdr.packet_meta.packet_subtype = dash_packet_subtype_t.FLOW_CREATE; + hdr.packet_meta.packet_subtype = packet_subtype; hdr.packet_meta.length = length + PACKET_META_HDR_SIZE; hdr.dp_ethernet.setValid(); @@ -48,6 +78,63 @@ control conntrack_set_flow_data(inout headers_t hdr, inout metadata_t meta) } } +control conntrack_flow_miss_handle(inout headers_t hdr, inout metadata_t meta) +{ + apply { + if ((hdr.customer_tcp.isValid() && hdr.customer_tcp.flags == 0x2 /* SYN */) + || hdr.customer_udp.isValid()) { + conntrack_build_dash_header.apply(hdr, meta, dash_packet_subtype_t.FLOW_CREATE); + meta.to_dpapp = true; // trap to dpapp + return; + } + else if ((hdr.customer_tcp.flags & 0b000101 /* FIN/RST */) != 0 + && hdr.packet_meta.packet_source == dash_packet_source_t.DPAPP) { + /* Flow should be just deleted by dpapp */ + conntrack_set_meta_from_dash_header(hdr, meta); + return; + } + + // should not reach here + meta.dropped = true; // drop it + } +} + +control conntrack_flow_created_handle(inout headers_t hdr, inout metadata_t meta) +{ + apply { + if (hdr.customer_tcp.isValid()) { + if ((hdr.customer_tcp.flags & 0b000101 /* FIN/RST */) != 0) { + conntrack_build_dash_header.apply(hdr, meta, dash_packet_subtype_t.FLOW_DELETE); + meta.to_dpapp = true; // trap to dpapp + return; + } + } + + // TODO update flow timestamp for aging + } +} + + +control conntrack_flow_handle(inout headers_t hdr, inout metadata_t meta) +{ + apply { + switch (meta.flow_state) { + dash_flow_state_t.FLOW_MISS: { + conntrack_flow_miss_handle.apply(hdr, meta); + } + dash_flow_state_t.FLOW_CREATED: { + conntrack_flow_created_handle.apply(hdr, meta); + } + } + + // Drop dash header if not sending to dpapp + if (!meta.to_dpapp) { + conntrack_strip_dash_header(hdr); + } + } +} + + control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { // // Flow table: From e939e3d4af688c572ce5a604bb95dfc0edf706e9 Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Wed, 28 Aug 2024 13:22:00 +0000 Subject: [PATCH 04/18] 1. remove the use of DPAPP_CONNTRACK 2. refactor dash_ingress --- dash-pipeline/Makefile | 2 - dash-pipeline/SAI/specs/dash_acl.yaml | 64 ++-- .../SAI/specs/dash_direction_lookup.yaml | 4 +- dash-pipeline/SAI/specs/dash_eni.yaml | 8 +- .../SAI/specs/dash_inbound_routing.yaml | 10 +- .../SAI/specs/dash_outbound_ca_to_pa.yaml | 2 +- .../SAI/specs/dash_outbound_routing.yaml | 6 +- .../SAI/specs/dash_pa_validation.yaml | 4 +- dash-pipeline/SAI/specs/dash_tunnel.yaml | 4 +- dash-pipeline/SAI/specs/dash_vip.yaml | 4 +- dash-pipeline/SAI/specs/dash_vnet.yaml | 4 +- dash-pipeline/bmv2/dash_headers.p4 | 15 +- dash-pipeline/bmv2/dash_metadata.p4 | 3 +- dash-pipeline/bmv2/dash_parser.p4 | 8 - dash-pipeline/bmv2/dash_pipeline.p4 | 346 ++++++++++-------- dash-pipeline/bmv2/stages/conntrack_lookup.p4 | 2 - dash-pipeline/bmv2/underlay.p4 | 9 +- 17 files changed, 264 insertions(+), 231 deletions(-) diff --git a/dash-pipeline/Makefile b/dash-pipeline/Makefile index 17555ce89..40cf83f46 100644 --- a/dash-pipeline/Makefile +++ b/dash-pipeline/Makefile @@ -5,7 +5,6 @@ ifeq ($(HAVE_DPAPP),y) DPAPP_LINK = veth4 DPAPP_LINK_PEER = veth5 SWITCH_PORT_DPAPP = --interface 2@$(DPAPP_LINK) -D_DPAPP_CONNTRACK = -DDPAPP_CONNTRACK endif mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) @@ -130,7 +129,6 @@ $(P4_OUTDIR)/dash_pipeline_p4rt.txt: $(P4_SRC) -w / \ $(DOCKER_P4C_BMV2_IMG) p4c-bm2-ss \ -DTARGET_BMV2_V1MODEL \ - $(D_DPAPP_CONNTRACK) \ $(P4_MAIN) \ -o $(P4_OUTDIR)/dash_pipeline.json \ --p4runtime-files $(P4_OUTDIR)/dash_pipeline_p4rt.json,$(P4_OUTDIR)/dash_pipeline_p4rt.txt \ diff --git a/dash-pipeline/SAI/specs/dash_acl.yaml b/dash-pipeline/SAI/specs/dash_acl.yaml index 378ccb2c5..879eca6f7 100644 --- a/dash-pipeline/SAI/specs/dash_acl.yaml +++ b/dash-pipeline/SAI/specs/dash_acl.yaml @@ -27,11 +27,11 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 50200087 + id: 37949057 actions: default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: default - id: 25655048 + id: 21989040 attr_param_id: {} - !!python/object:utils.sai_spec.sai_api.SaiApi name: dash_acl_rule @@ -194,116 +194,116 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 41950136 + id: 43936368 actions: SAI_DASH_ACL_RULE_ACTION_PERMIT: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_PERMIT - id: 32161567 + id: 24892843 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_PERMIT_AND_CONTINUE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_PERMIT_AND_CONTINUE - id: 20706700 + id: 26577723 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_DENY: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_DENY - id: 28146588 + id: 31332881 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_DENY_AND_CONTINUE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_DENY_AND_CONTINUE - id: 31424218 + id: 24146215 attr_param_id: {} - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 43016664 + id: 48549629 actions: SAI_DASH_ACL_RULE_ACTION_PERMIT: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_PERMIT - id: 32161567 + id: 24892843 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_PERMIT_AND_CONTINUE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_PERMIT_AND_CONTINUE - id: 20706700 + id: 26577723 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_DENY: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_DENY - id: 28146588 + id: 31332881 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_DENY_AND_CONTINUE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_DENY_AND_CONTINUE - id: 31424218 + id: 24146215 attr_param_id: {} - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 49695908 + id: 40869404 actions: SAI_DASH_ACL_RULE_ACTION_PERMIT: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_PERMIT - id: 32161567 + id: 24892843 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_PERMIT_AND_CONTINUE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_PERMIT_AND_CONTINUE - id: 20706700 + id: 26577723 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_DENY: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_DENY - id: 28146588 + id: 31332881 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_DENY_AND_CONTINUE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_DENY_AND_CONTINUE - id: 31424218 + id: 24146215 attr_param_id: {} - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 49209582 + id: 49672642 actions: SAI_DASH_ACL_RULE_ACTION_PERMIT: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_PERMIT - id: 18858683 + id: 22622424 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_PERMIT_AND_CONTINUE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_PERMIT_AND_CONTINUE - id: 24263137 + id: 27458076 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_DENY: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_DENY - id: 29962337 + id: 27228779 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_DENY_AND_CONTINUE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_DENY_AND_CONTINUE - id: 26077229 + id: 29275145 attr_param_id: {} - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 36478314 + id: 37932124 actions: SAI_DASH_ACL_RULE_ACTION_PERMIT: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_PERMIT - id: 18858683 + id: 22622424 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_PERMIT_AND_CONTINUE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_PERMIT_AND_CONTINUE - id: 24263137 + id: 27458076 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_DENY: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_DENY - id: 29962337 + id: 27228779 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_DENY_AND_CONTINUE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_DENY_AND_CONTINUE - id: 26077229 + id: 29275145 attr_param_id: {} - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 39012793 + id: 46113118 actions: SAI_DASH_ACL_RULE_ACTION_PERMIT: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_PERMIT - id: 18858683 + id: 22622424 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_PERMIT_AND_CONTINUE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_PERMIT_AND_CONTINUE - id: 24263137 + id: 27458076 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_DENY: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_DENY - id: 29962337 + id: 27228779 attr_param_id: {} SAI_DASH_ACL_RULE_ACTION_DENY_AND_CONTINUE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DASH_ACL_RULE_ACTION_DENY_AND_CONTINUE - id: 26077229 + id: 29275145 attr_param_id: {} diff --git a/dash-pipeline/SAI/specs/dash_direction_lookup.yaml b/dash-pipeline/SAI/specs/dash_direction_lookup.yaml index d92d63487..14cd33034 100644 --- a/dash-pipeline/SAI/specs/dash_direction_lookup.yaml +++ b/dash-pipeline/SAI/specs/dash_direction_lookup.yaml @@ -64,10 +64,10 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 44703784 + id: 49875338 actions: SAI_DIRECTION_LOOKUP_ENTRY_ACTION_SET_OUTBOUND_DIRECTION: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_DIRECTION_LOOKUP_ENTRY_ACTION_SET_OUTBOUND_DIRECTION - id: 17408972 + id: 32588257 attr_param_id: SAI_DIRECTION_LOOKUP_ENTRY_ATTR_DASH_ENI_MAC_OVERRIDE_TYPE: 1 diff --git a/dash-pipeline/SAI/specs/dash_eni.yaml b/dash-pipeline/SAI/specs/dash_eni.yaml index 2cf2b98d2..cd9a43b1f 100644 --- a/dash-pipeline/SAI/specs/dash_eni.yaml +++ b/dash-pipeline/SAI/specs/dash_eni.yaml @@ -64,11 +64,11 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 36648123 + id: 39883185 actions: SAI_ENI_ETHER_ADDRESS_MAP_ENTRY_ACTION_SET_ENI: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_ENI_ETHER_ADDRESS_MAP_ENTRY_ACTION_SET_ENI - id: 24618133 + id: 19019152 attr_param_id: SAI_ENI_ETHER_ADDRESS_MAP_ENTRY_ATTR_ENI_ID: 1 - !!python/object:utils.sai_spec.sai_api.SaiApi @@ -1616,9 +1616,9 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 45859274 + id: 38483381 actions: default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: default - id: 27167550 + id: 30359009 attr_param_id: {} diff --git a/dash-pipeline/SAI/specs/dash_inbound_routing.yaml b/dash-pipeline/SAI/specs/dash_inbound_routing.yaml index 9a3a6e783..ae5b95803 100644 --- a/dash-pipeline/SAI/specs/dash_inbound_routing.yaml +++ b/dash-pipeline/SAI/specs/dash_inbound_routing.yaml @@ -141,26 +141,26 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 38920290 + id: 46226512 actions: SAI_INBOUND_ROUTING_ENTRY_ACTION_TUNNEL_DECAP: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_INBOUND_ROUTING_ENTRY_ACTION_TUNNEL_DECAP - id: 22253429 + id: 19753110 attr_param_id: SAI_INBOUND_ROUTING_ENTRY_ATTR_METER_CLASS_OR: 1 SAI_INBOUND_ROUTING_ENTRY_ATTR_METER_CLASS_AND: 2 SAI_INBOUND_ROUTING_ENTRY_ACTION_TUNNEL_DECAP_PA_VALIDATE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_INBOUND_ROUTING_ENTRY_ACTION_TUNNEL_DECAP_PA_VALIDATE - id: 27987616 + id: 25922590 attr_param_id: SAI_INBOUND_ROUTING_ENTRY_ATTR_SRC_VNET_ID: 1 SAI_INBOUND_ROUTING_ENTRY_ATTR_METER_CLASS_OR: 2 SAI_INBOUND_ROUTING_ENTRY_ATTR_METER_CLASS_AND: 3 SAI_INBOUND_ROUTING_ENTRY_ACTION_VXLAN_DECAP: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_INBOUND_ROUTING_ENTRY_ACTION_VXLAN_DECAP - id: 32581635 + id: 29008246 attr_param_id: {} SAI_INBOUND_ROUTING_ENTRY_ACTION_VXLAN_DECAP_PA_VALIDATE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_INBOUND_ROUTING_ENTRY_ACTION_VXLAN_DECAP_PA_VALIDATE - id: 22711915 + id: 21551298 attr_param_id: {} diff --git a/dash-pipeline/SAI/specs/dash_outbound_ca_to_pa.yaml b/dash-pipeline/SAI/specs/dash_outbound_ca_to_pa.yaml index 685d7142e..7c594d82e 100644 --- a/dash-pipeline/SAI/specs/dash_outbound_ca_to_pa.yaml +++ b/dash-pipeline/SAI/specs/dash_outbound_ca_to_pa.yaml @@ -261,7 +261,7 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 43335456 + id: 48765007 actions: SAI_OUTBOUND_CA_TO_PA_ENTRY_ACTION_SET_TUNNEL_MAPPING: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_OUTBOUND_CA_TO_PA_ENTRY_ACTION_SET_TUNNEL_MAPPING diff --git a/dash-pipeline/SAI/specs/dash_outbound_routing.yaml b/dash-pipeline/SAI/specs/dash_outbound_routing.yaml index 8b8f499a1..05effc7b2 100644 --- a/dash-pipeline/SAI/specs/dash_outbound_routing.yaml +++ b/dash-pipeline/SAI/specs/dash_outbound_routing.yaml @@ -294,7 +294,7 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 44010720 + id: 38546097 actions: SAI_OUTBOUND_ROUTING_ENTRY_ACTION_ROUTE_VNET: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_OUTBOUND_ROUTING_ENTRY_ACTION_ROUTE_VNET @@ -367,9 +367,9 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 34522254 + id: 40572680 actions: default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: default - id: 20489967 + id: 30077100 attr_param_id: {} diff --git a/dash-pipeline/SAI/specs/dash_pa_validation.yaml b/dash-pipeline/SAI/specs/dash_pa_validation.yaml index c52119654..ffe4beccb 100644 --- a/dash-pipeline/SAI/specs/dash_pa_validation.yaml +++ b/dash-pipeline/SAI/specs/dash_pa_validation.yaml @@ -70,9 +70,9 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 35526612 + id: 43665660 actions: SAI_PA_VALIDATION_ENTRY_ACTION_PERMIT: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_PA_VALIDATION_ENTRY_ACTION_PERMIT - id: 32591400 + id: 19504487 attr_param_id: {} diff --git a/dash-pipeline/SAI/specs/dash_tunnel.yaml b/dash-pipeline/SAI/specs/dash_tunnel.yaml index b73273e6b..30a8fdd08 100644 --- a/dash-pipeline/SAI/specs/dash_tunnel.yaml +++ b/dash-pipeline/SAI/specs/dash_tunnel.yaml @@ -53,9 +53,9 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 44400659 + id: 34128771 actions: default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: default - id: 27891720 + id: 18727423 attr_param_id: {} diff --git a/dash-pipeline/SAI/specs/dash_vip.yaml b/dash-pipeline/SAI/specs/dash_vip.yaml index 590ea7191..6a1e3daf0 100644 --- a/dash-pipeline/SAI/specs/dash_vip.yaml +++ b/dash-pipeline/SAI/specs/dash_vip.yaml @@ -64,9 +64,9 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 45245089 + id: 48212080 actions: SAI_VIP_ENTRY_ACTION_ACCEPT: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: SAI_VIP_ENTRY_ACTION_ACCEPT - id: 26041632 + id: 22859453 attr_param_id: {} diff --git a/dash-pipeline/SAI/specs/dash_vnet.yaml b/dash-pipeline/SAI/specs/dash_vnet.yaml index 594d0bddb..8240bcab4 100644 --- a/dash-pipeline/SAI/specs/dash_vnet.yaml +++ b/dash-pipeline/SAI/specs/dash_vnet.yaml @@ -27,9 +27,9 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 49590243 + id: 39583935 actions: default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: default - id: 20510911 + id: 28116018 attr_param_id: {} diff --git a/dash-pipeline/bmv2/dash_headers.p4 b/dash-pipeline/bmv2/dash_headers.p4 index b2238e57e..8b33df509 100644 --- a/dash-pipeline/bmv2/dash_headers.p4 +++ b/dash-pipeline/bmv2/dash_headers.p4 @@ -52,7 +52,7 @@ header encap_data_t { EthernetAddress underlay_dmac; dash_encapsulation_t dash_encapsulation; } -const bit<16> ENCAP_DATA_HDR_SIZE=(24+24+32+32+48+48+16)/8; +const bit<16> ENCAP_DATA_HDR_SIZE=encap_data_t.minSizeInBytes(); header overlay_rewrite_data_t { EthernetAddress dmac; @@ -63,7 +63,7 @@ header overlay_rewrite_data_t { bit<7> reserved; bool is_ipv6; } -const bit<16> OVERLAY_REWRITE_DATA_HDR_SIZE=(48+128+128+128+128+8)/8; +const bit<16> OVERLAY_REWRITE_DATA_HDR_SIZE=overlay_rewrite_data_t.minSizeInBytes(); header ethernet_t { EthernetAddress dst_addr; @@ -153,7 +153,6 @@ header ipv6_t { const bit<16> IPV6_HDR_SIZE=320/8; -#ifdef DPAPP_CONNTRACK enum bit<16> dash_flow_enabled_key_t { ENI_ADDR = (1 << 0), VNI = (1 << 1), @@ -210,7 +209,7 @@ header flow_key_t { bit<7> reserved; bit<1> is_ip_v6; } -const bit<16> FLOW_KEY_HDR_SIZE=(48+16+128+128+16+16+8+8)/8; +const bit<16> FLOW_KEY_HDR_SIZE=flow_key_t.minSizeInBytes(); header flow_data_t { bit<7> reserved; @@ -221,7 +220,7 @@ header flow_data_t { bit<32> routing_actions; dash_meter_class_t meter_class; } -const bit<16> FLOW_DATA_HDR_SIZE=(8+32+16+16+32+32)/8; +const bit<16> FLOW_DATA_HDR_SIZE=flow_data_t.minSizeInBytes(); // dash packet metadata header dash_packet_meta_t { @@ -230,15 +229,12 @@ header dash_packet_meta_t { dash_packet_subtype_t packet_subtype; bit<16> length; } -const bit<16> PACKET_META_HDR_SIZE=(8+4+4+16)/8; +const bit<16> PACKET_META_HDR_SIZE=dash_packet_meta_t.minSizeInBytes(); #define DASH_ETHTYPE 0x876d #define DPAPP_MAC 0x02fe23f0e413 -#endif // DPAPP_CONNTRACK - struct headers_t { -#ifdef DPAPP_CONNTRACK /* packet metadata headers */ ethernet_t dp_ethernet; dash_packet_meta_t packet_meta; @@ -247,7 +243,6 @@ struct headers_t { overlay_rewrite_data_t flow_overlay_data; encap_data_t flow_encap_data; encap_data_t flow_tunnel_data; -#endif // DPAPP_CONNTRACK /* Underlay 1 headers */ ethernet_t u1_ethernet; diff --git a/dash-pipeline/bmv2/dash_metadata.p4 b/dash-pipeline/bmv2/dash_metadata.p4 index a92bf2b78..c30999eb2 100644 --- a/dash-pipeline/bmv2/dash_metadata.p4 +++ b/dash-pipeline/bmv2/dash_metadata.p4 @@ -182,13 +182,12 @@ struct metadata_t { // Flow data conntrack_data_t conntrack_data; -#ifdef DPAPP_CONNTRACK flow_table_data_t flow_table; dash_flow_state_t flow_state; bit<16> bulk_get_session_id; bit<16> bulk_get_session_filter_id; + bool flow_enabled; bool to_dpapp; -#endif // DPAPP_CONNTRACK // Stage transition control dash_pipeline_stage_t target_stage; diff --git a/dash-pipeline/bmv2/dash_parser.p4 b/dash-pipeline/bmv2/dash_parser.p4 index b3797f51d..d2bd275f4 100644 --- a/dash-pipeline/bmv2/dash_parser.p4 +++ b/dash-pipeline/bmv2/dash_parser.p4 @@ -29,27 +29,22 @@ parser dash_parser( ) { state start { -#ifdef DPAPP_CONNTRACK // By default, packet is REGULAR from EXTERNAL hd.packet_meta.setValid(); hd.packet_meta.packet_source = dash_packet_source_t.EXTERNAL; hd.packet_meta.packet_type = dash_packet_type_t.REGULAR; hd.packet_meta.packet_subtype = dash_packet_subtype_t.NONE; hd.packet_meta.length = PACKET_META_HDR_SIZE; -#endif // DPAPP_CONNTRACK packet.extract(hd.u0_ethernet); transition select(hd.u0_ethernet.ether_type) { IPV4_ETHTYPE: parse_u0_ipv4; IPV6_ETHTYPE: parse_u0_ipv6; -#ifdef DPAPP_CONNTRACK DASH_ETHTYPE: parse_dash; -#endif // DPAPP_CONNTRACK default: accept; } } -#ifdef DPAPP_CONNTRACK state parse_dash { packet.extract(hd.packet_meta); if (hd.packet_meta.packet_subtype != dash_packet_subtype_t.NONE) { @@ -76,7 +71,6 @@ parser dash_parser( transition parse_customer_ethernet; } -#endif // DPAPP_CONNTRACK state parse_u0_ipv4 { packet.extract(hd.u0_ipv4); @@ -179,7 +173,6 @@ control dash_deparser( ) { apply { -#ifdef DPAPP_CONNTRACK packet.emit(hdr.dp_ethernet); packet.emit(hdr.packet_meta); packet.emit(hdr.flow_key); @@ -187,7 +180,6 @@ control dash_deparser( packet.emit(hdr.flow_overlay_data); packet.emit(hdr.flow_encap_data); packet.emit(hdr.flow_tunnel_data); -#endif // DPAPP_CONNTRACK packet.emit(hdr.u0_ethernet); packet.emit(hdr.u0_ipv4); diff --git a/dash-pipeline/bmv2/dash_pipeline.p4 b/dash-pipeline/bmv2/dash_pipeline.p4 index a4b3a536a..1f82917c8 100644 --- a/dash-pipeline/bmv2/dash_pipeline.p4 +++ b/dash-pipeline/bmv2/dash_pipeline.p4 @@ -8,11 +8,8 @@ #include "dash_tunnel.p4" #include "dash_outbound.p4" #include "dash_inbound.p4" -#ifdef DPAPP_CONNTRACK -#include "stages/conntrack_lookup.p4" -#else #include "dash_conntrack.p4" -#endif +#include "stages/conntrack_lookup.p4" #include "stages/direction_lookup.p4" #include "stages/eni_lookup.p4" #include "stages/ha.p4" @@ -20,65 +17,94 @@ #include "stages/metering_update.p4" #include "underlay.p4" -control dash_ingress( +control dash_inbound_routing_stage( inout headers_t hdr , inout metadata_t meta -#ifdef TARGET_BMV2_V1MODEL - , inout standard_metadata_t standard_metadata -#endif // TARGET_BMV2_V1MODEL -#ifdef TARGET_DPDK_PNA - , in pna_main_input_metadata_t istd - , inout pna_main_output_metadata_t ostd -#endif // TARGET_DPDK_PNA ) { - action drop_action() { -#ifdef TARGET_BMV2_V1MODEL - mark_to_drop(standard_metadata); -#endif // TARGET_BMV2_V1MODEL -#ifdef TARGET_DPDK_PNA - drop_packet(); -#endif // TARGET_DPDK_PNA - } - action deny() { meta.dropped = true; } - action accept() { + action permit() { } - @SaiTable[name = "vip", api = "dash_vip"] - table vip { + action vxlan_decap() {} + action vxlan_decap_pa_validate() {} + + action tunnel_decap(inout headers_t hdr, + inout metadata_t meta, + bit<32> meter_class_or, + @SaiVal[default_value="4294967295"] bit<32> meter_class_and) { + set_meter_attrs(meta, meter_class_or, meter_class_and); + } + + action tunnel_decap_pa_validate(inout headers_t hdr, + inout metadata_t meta, + @SaiVal[type="sai_object_id_t"] bit<16> src_vnet_id, + bit<32> meter_class_or, + @SaiVal[default_value="4294967295"] bit<32> meter_class_and) { + meta.vnet_id = src_vnet_id; + set_meter_attrs(meta, meter_class_or, meter_class_and); + } + + @SaiTable[name = "pa_validation", api = "dash_pa_validation"] + table pa_validation { key = { - hdr.u0_ipv4.dst_addr : exact @SaiVal[name = "VIP", type="sai_ip_address_t"]; + meta.vnet_id: exact @SaiVal[type="sai_object_id_t"]; + hdr.u0_ipv4.src_addr : exact @SaiVal[name = "sip", type="sai_ip_address_t"]; } actions = { - accept; + permit; @defaultonly deny; } const default_action = deny; } - action set_appliance(EthernetAddress neighbor_mac, - EthernetAddress mac) { - meta.encap_data.underlay_dmac = neighbor_mac; - meta.encap_data.underlay_smac = mac; + @SaiTable[name = "inbound_routing", api = "dash_inbound_routing"] + table inbound_routing { + key = { + meta.eni_id: exact @SaiVal[type="sai_object_id_t"]; + hdr.u0_vxlan.vni : exact @SaiVal[name = "VNI"]; + hdr.u0_ipv4.src_addr : ternary @SaiVal[name = "sip", type="sai_ip_address_t"]; + } + actions = { + tunnel_decap(hdr, meta); + tunnel_decap_pa_validate(hdr, meta); + vxlan_decap; // Deprecated, but cannot be removed until SWSS is updated. + vxlan_decap_pa_validate; // Deprecated, but cannot be removed until SWSS is updated. + @defaultonly deny; + } + + const default_action = deny; } - /* This table API should be implemented manually using underlay SAI */ - @SaiTable[ignored = "true"] - table appliance { - key = { - meta.appliance_id : ternary; + apply { + if (meta.direction != dash_direction_t.INBOUND) { + return; } - actions = { - set_appliance; + switch (inbound_routing.apply().action_run) { + tunnel_decap_pa_validate: { + pa_validation.apply(); + } + deny: { + UPDATE_ENI_COUNTER(inbound_routing_entry_miss_drop); + } } } +} + +control dash_eni_stage( + inout headers_t hdr + , inout metadata_t meta + ) +{ + action deny() { + meta.dropped = true; + } #define ACL_GROUPS_PARAM(prefix) \ @SaiVal[type="sai_object_id_t"] bit<16> ## prefix ##_stage1_dash_acl_group_id, \ @@ -175,107 +201,59 @@ control dash_ingress( const default_action = deny; } - action permit() { + apply { + if (!eni.apply().hit) { + UPDATE_COUNTER(eni_miss_drop, 0); + } } +} - action vxlan_decap() {} - action vxlan_decap_pa_validate() {} - - action tunnel_decap(inout headers_t hdr, - inout metadata_t meta, - bit<32> meter_class_or, - @SaiVal[default_value="4294967295"] bit<32> meter_class_and) { - set_meter_attrs(meta, meter_class_or, meter_class_and); +// direction lookup, eni lookup, etc +control dash_lookup_stage( + inout headers_t hdr + , inout metadata_t meta + ) +{ + action deny() { + meta.dropped = true; } - action tunnel_decap_pa_validate(inout headers_t hdr, - inout metadata_t meta, - @SaiVal[type="sai_object_id_t"] bit<16> src_vnet_id, - bit<32> meter_class_or, - @SaiVal[default_value="4294967295"] bit<32> meter_class_and) { - meta.vnet_id = src_vnet_id; - set_meter_attrs(meta, meter_class_or, meter_class_and); + action accept() { } - @SaiTable[name = "pa_validation", api = "dash_pa_validation"] - table pa_validation { + @SaiTable[name = "vip", api = "dash_vip"] + table vip { key = { - meta.vnet_id: exact @SaiVal[type="sai_object_id_t"]; - hdr.u0_ipv4.src_addr : exact @SaiVal[name = "sip", type="sai_ip_address_t"]; - } - - actions = { - permit; - @defaultonly deny; + hdr.u0_ipv4.dst_addr : exact @SaiVal[name = "VIP", type="sai_ip_address_t"]; } - const default_action = deny; - } - - @SaiTable[name = "inbound_routing", api = "dash_inbound_routing"] - table inbound_routing { - key = { - meta.eni_id: exact @SaiVal[type="sai_object_id_t"]; - hdr.u0_vxlan.vni : exact @SaiVal[name = "VNI"]; - hdr.u0_ipv4.src_addr : ternary @SaiVal[name = "sip", type="sai_ip_address_t"]; - } actions = { - tunnel_decap(hdr, meta); - tunnel_decap_pa_validate(hdr, meta); - vxlan_decap; // Deprecated, but cannot be removed until SWSS is updated. - vxlan_decap_pa_validate; // Deprecated, but cannot be removed until SWSS is updated. + accept; @defaultonly deny; } const default_action = deny; } - action set_acl_group_attrs(@SaiVal[type="sai_ip_addr_family_t", isresourcetype="true"] bit<32> ip_addr_family) { - if (ip_addr_family == 0) /* SAI_IP_ADDR_FAMILY_IPV4 */ { - if (meta.is_overlay_ip_v6 == 1) { - meta.dropped = true; - } - } else { - if (meta.is_overlay_ip_v6 == 0) { - meta.dropped = true; - } - } + action set_appliance(EthernetAddress neighbor_mac, + EthernetAddress mac) { + meta.encap_data.underlay_dmac = neighbor_mac; + meta.encap_data.underlay_smac = mac; } - @SaiTable[name = "dash_acl_group", api = "dash_acl", isobject="true"] - table acl_group { + /* This table API should be implemented manually using underlay SAI */ + @SaiTable[ignored = "true"] + table appliance { key = { - meta.stage1_dash_acl_group_id : exact @SaiVal[name = "dash_acl_group_id"]; + meta.appliance_id : ternary; } + actions = { - set_acl_group_attrs(); + set_appliance; } } apply { - meta.encap_data.setValid(); - meta.tunnel_data.setValid(); - meta.overlay_data.setValid(); - -#ifdef TARGET_DPDK_PNA -#ifdef DPDK_PNA_SEND_TO_PORT_FIX_MERGED - // As of 2023-Jan-26, the version of the pna.p4 header file - // included with p4c defines send_to_port with a parameter - // that has no 'in' direction. The following commit in the - // public pna repo fixes this, but this fix has not yet been - // copied into the p4c repo. - // https://github.com/p4lang/pna/commit/b9fdfb888e5385472c34ff773914c72b78b63058 - // Until p4c is updated with this fix, the following line will - // give a compile-time error. - send_to_port(istd.input_port); -#endif // DPDK_PNA_SEND_TO_PORT_FIX_MERGED -#endif // TARGET_DPDK_PNA - -#ifdef DPAPP_CONNTRACK - // If packet is from DPAPP, just do conntrack_lookup - if (hdr.packet_meta.packet_source != dash_packet_source_t.DPAPP) { -#endif // DPAPP_CONNTRACK - if (meta.is_fast_path_icmp_flow_redirection_packet) { UPDATE_COUNTER(port_lb_fast_path_icmp_in, 0); } @@ -302,16 +280,7 @@ control dash_ingress( meta.eni_data.dscp_mode = dash_tunnel_dscp_mode_t.PRESERVE_MODEL; meta.eni_data.dscp = (bit<6>)hdr.u0_ipv4.diffserv; - if (meta.direction == dash_direction_t.INBOUND) { - switch (inbound_routing.apply().action_run) { - tunnel_decap_pa_validate: { - pa_validation.apply(); - } - deny: { - UPDATE_ENI_COUNTER(inbound_routing_entry_miss_drop); - } - } - } + dash_inbound_routing_stage.apply(hdr, meta); do_tunnel_decap(hdr, meta); @@ -340,10 +309,7 @@ control dash_ingress( meta.dst_l4_port = hdr.customer_udp.dst_port; } - if (!eni.apply().hit) { - UPDATE_COUNTER(eni_miss_drop, 0); - deny(); - } + dash_eni_stage.apply(hdr, meta); if (meta.eni_data.admin_state == 0) { deny(); @@ -353,20 +319,37 @@ control dash_ingress( if (meta.is_fast_path_icmp_flow_redirection_packet) { UPDATE_ENI_COUNTER(eni_lb_fast_path_icmp_in); } + } +} +control dash_match_stage( + inout headers_t hdr + , inout metadata_t meta + ) +{ + action set_acl_group_attrs(@SaiVal[type="sai_ip_addr_family_t", isresourcetype="true"] bit<32> ip_addr_family) { + if (ip_addr_family == 0) /* SAI_IP_ADDR_FAMILY_IPV4 */ { + if (meta.is_overlay_ip_v6 == 1) { + meta.dropped = true; + } + } else { + if (meta.is_overlay_ip_v6 == 0) { + meta.dropped = true; + } + } + } -#ifdef DPAPP_CONNTRACK - } // from dpapp - conntrack_lookup_stage.apply(hdr, meta); -#endif // DPAPP_CONNTRACK - - ha_stage.apply(hdr, meta); - -#ifdef DPAPP_CONNTRACK - if (meta.flow_state == dash_flow_state_t.FLOW_MISS && - hdr.packet_meta.packet_source == dash_packet_source_t.EXTERNAL) { -#endif // DPAPP_CONNTRACK + @SaiTable[name = "dash_acl_group", api = "dash_acl", isobject="true"] + table acl_group { + key = { + meta.stage1_dash_acl_group_id : exact @SaiVal[name = "dash_acl_group_id"]; + } + actions = { + set_acl_group_attrs(); + } + } + apply { acl_group.apply(); if (meta.direction == dash_direction_t.OUTBOUND) { @@ -380,21 +363,90 @@ control dash_ingress( } tunnel_stage.apply(hdr, meta); + } +} - if (meta.dropped) { - drop_action(); - return; +control dash_ingress( + inout headers_t hdr + , inout metadata_t meta +#ifdef TARGET_BMV2_V1MODEL + , inout standard_metadata_t standard_metadata +#endif // TARGET_BMV2_V1MODEL +#ifdef TARGET_DPDK_PNA + , in pna_main_input_metadata_t istd + , inout pna_main_output_metadata_t ostd +#endif // TARGET_DPDK_PNA + ) +{ + action drop_action() { +#ifdef TARGET_BMV2_V1MODEL + mark_to_drop(standard_metadata); +#endif // TARGET_BMV2_V1MODEL +#ifdef TARGET_DPDK_PNA + drop_packet(); +#endif // TARGET_DPDK_PNA + } + + apply { + meta.flow_enabled = false; + + meta.encap_data.setValid(); + meta.tunnel_data.setValid(); + meta.overlay_data.setValid(); + +#ifdef TARGET_DPDK_PNA +#ifdef DPDK_PNA_SEND_TO_PORT_FIX_MERGED + // As of 2023-Jan-26, the version of the pna.p4 header file + // included with p4c defines send_to_port with a parameter + // that has no 'in' direction. The following commit in the + // public pna repo fixes this, but this fix has not yet been + // copied into the p4c repo. + // https://github.com/p4lang/pna/commit/b9fdfb888e5385472c34ff773914c72b78b63058 + // Until p4c is updated with this fix, the following line will + // give a compile-time error. + send_to_port(istd.input_port); +#endif // DPDK_PNA_SEND_TO_PORT_FIX_MERGED +#endif // TARGET_DPDK_PNA + + // If packet is from DPAPP, just do conntrack_lookup + if (hdr.packet_meta.packet_source != dash_packet_source_t.DPAPP) { + dash_lookup_stage.apply(hdr, meta); + } + else { + meta.flow_enabled = true; } -#ifdef DPAPP_CONNTRACK + if (meta.flow_enabled) { + conntrack_lookup_stage.apply(hdr, meta); } - conntrack_flow_handle.apply(hdr, meta); - if (meta.to_dpapp) { - standard_metadata.egress_spec = 2; // vpp port - return; + ha_stage.apply(hdr, meta); + + if (!meta.flow_enabled || + (meta.flow_state == dash_flow_state_t.FLOW_MISS && + hdr.packet_meta.packet_source == dash_packet_source_t.EXTERNAL)) + { + dash_match_stage.apply(hdr, meta); + if (meta.dropped) { + drop_action(); + return; + } + } + + if (meta.flow_enabled) { + conntrack_flow_handle.apply(hdr, meta); + if (meta.to_dpapp) { +#ifdef TARGET_BMV2_V1MODEL + standard_metadata.egress_spec = 2; //FIXME hard-code vpp port +#else //FIXME DPDK_PNA + drop_action(); +#endif // TARGET_BMV2_V1MODEL + return; + } + } + else { + hdr.packet_meta.setInvalid(); } -#endif // DPAPP_CONNTRACK routing_action_apply.apply(hdr, meta); diff --git a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 index cb8714643..4510363f1 100644 --- a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 +++ b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 @@ -1,7 +1,6 @@ #ifndef _DASH_STAGE_CONNTRACK_LOOKUP_P4 #define _DASH_STAGE_CONNTRACK_LOOKUP_P4 -#ifdef DPAPP_CONNTRACK #include "../dash_metadata.p4" action conntrack_set_meta_from_dash_header(in headers_t hdr, out metadata_t meta) @@ -375,5 +374,4 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { flow_entry_bulk_get_session.apply(); } } -#endif // DPAPP_CONNTRACK #endif /* _DASH_STAGE_CONNTRACK_LOOKUP_P4 */ diff --git a/dash-pipeline/bmv2/underlay.p4 b/dash-pipeline/bmv2/underlay.p4 index ba8811d7a..ec242d214 100644 --- a/dash-pipeline/bmv2/underlay.p4 +++ b/dash-pipeline/bmv2/underlay.p4 @@ -50,13 +50,12 @@ control underlay( action def_act() { #ifdef TARGET_BMV2_V1MODEL -#ifdef DPAPP_CONNTRACK if (hdr.packet_meta.packet_source == dash_packet_source_t.DPAPP) { - standard_metadata.egress_spec = 0; + standard_metadata.egress_spec = 0; /* FIXME */ + } + else { + standard_metadata.egress_spec = standard_metadata.ingress_port; } - else -#endif // DPAPP_CONNTRACK - standard_metadata.egress_spec = standard_metadata.ingress_port; #endif // TARGET_BMV2_V1MODEL #ifdef TARGET_DPDK_PNA From 46ae92a9751a6649f2c4b5303be4ec9c27773885 Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Fri, 30 Aug 2024 13:00:12 +0000 Subject: [PATCH 05/18] Manually merge #616 and #617 changes in bmv2 --- dash-pipeline/bmv2/dash_headers.p4 | 4 ++-- dash-pipeline/bmv2/dash_metadata.p4 | 1 + dash-pipeline/bmv2/dash_pipeline.p4 | 24 ++++++++++++++++--- dash-pipeline/bmv2/stages/conntrack_lookup.p4 | 4 ++-- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/dash-pipeline/bmv2/dash_headers.p4 b/dash-pipeline/bmv2/dash_headers.p4 index 8b33df509..c0b2772f8 100644 --- a/dash-pipeline/bmv2/dash_headers.p4 +++ b/dash-pipeline/bmv2/dash_headers.p4 @@ -154,7 +154,7 @@ const bit<16> IPV6_HDR_SIZE=320/8; enum bit<16> dash_flow_enabled_key_t { - ENI_ADDR = (1 << 0), + ENI_MAC = (1 << 0), VNI = (1 << 1), PROTOCOL = (1 << 2), SRC_IP = (1 << 3), @@ -173,7 +173,7 @@ enum bit<16> dash_flow_entry_bulk_get_session_mode_t { enum bit<16> dash_flow_entry_bulk_get_session_filter_key_t { INVAILD = 0, FLOW_TABLE_ID = 1, - ENI_ADDR = 2, + ENI_MAC = 2, IP_PROTOCOL = 3, SRC_IP_ADDR = 4, DST_IP_ADDR = 5, diff --git a/dash-pipeline/bmv2/dash_metadata.p4 b/dash-pipeline/bmv2/dash_metadata.p4 index c30999eb2..41bce39ce 100644 --- a/dash-pipeline/bmv2/dash_metadata.p4 +++ b/dash-pipeline/bmv2/dash_metadata.p4 @@ -204,6 +204,7 @@ struct metadata_t { overlay_rewrite_data_t overlay_data; bit<16> dash_tunnel_id; bit<32> meter_class; + bit<8> local_region_id; } #endif /* _SIRIUS_METADATA_P4_ */ diff --git a/dash-pipeline/bmv2/dash_pipeline.p4 b/dash-pipeline/bmv2/dash_pipeline.p4 index 1f82917c8..0d180b0cd 100644 --- a/dash-pipeline/bmv2/dash_pipeline.p4 +++ b/dash-pipeline/bmv2/dash_pipeline.p4 @@ -235,7 +235,24 @@ control dash_lookup_stage( const default_action = deny; } - action set_appliance(EthernetAddress neighbor_mac, + action set_appliance(bit<8> local_region_id) { + meta.local_region_id = local_region_id; + } + + @SaiTable[name = "dash_appliance", api = "dash_appliance", order = 0, isobject="true"] + table appliance { + key = { + meta.appliance_id : exact @SaiVal[type="sai_object_id_t"]; + } + + actions = { + set_appliance; + @defaultonly accept; + } + const default_action = accept; + } + + action set_underlay_mac(EthernetAddress neighbor_mac, EthernetAddress mac) { meta.encap_data.underlay_dmac = neighbor_mac; meta.encap_data.underlay_smac = mac; @@ -243,13 +260,13 @@ control dash_lookup_stage( /* This table API should be implemented manually using underlay SAI */ @SaiTable[ignored = "true"] - table appliance { + table underlay_mac { key = { meta.appliance_id : ternary; } actions = { - set_appliance; + set_underlay_mac; } } @@ -272,6 +289,7 @@ control dash_lookup_stage( direction_lookup_stage.apply(hdr, meta); appliance.apply(); + underlay_mac.apply(); /* Outer header processing */ eni_lookup_stage.apply(hdr, meta); diff --git a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 index 4510363f1..052e5c889 100644 --- a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 +++ b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 @@ -330,7 +330,7 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { hdr.flow_key.setValid(); hdr.flow_key.is_ip_v6 = meta.is_overlay_ip_v6; // TODO remove hardcode flow_enabled_key later - meta.flow_table.flow_enabled_key = dash_flow_enabled_key_t.ENI_ADDR | + meta.flow_table.flow_enabled_key = dash_flow_enabled_key_t.ENI_MAC | dash_flow_enabled_key_t.VNI | dash_flow_enabled_key_t.PROTOCOL | dash_flow_enabled_key_t.SRC_IP | @@ -338,7 +338,7 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { dash_flow_enabled_key_t.SRC_PORT | dash_flow_enabled_key_t.DST_PORT; - if (meta.flow_table.flow_enabled_key & dash_flow_enabled_key_t.ENI_ADDR != 0) { + if (meta.flow_table.flow_enabled_key & dash_flow_enabled_key_t.ENI_MAC != 0) { hdr.flow_key.eni_mac = meta.eni_addr; } if (meta.flow_table.flow_enabled_key & dash_flow_enabled_key_t.VNI != 0) { From ab45aaf022ad3ee2ccacebfcb3748afd9989e4ad Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Fri, 30 Aug 2024 13:36:31 +0000 Subject: [PATCH 06/18] Still use bulk_get_session_server_ip, bulk_get_session_server_port --- dash-pipeline/SAI/specs/dash_appliance.yaml | 4 ++-- dash-pipeline/SAI/specs/dash_flow.yaml | 8 ++++---- dash-pipeline/bmv2/stages/conntrack_lookup.p4 | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dash-pipeline/SAI/specs/dash_appliance.yaml b/dash-pipeline/SAI/specs/dash_appliance.yaml index 4523dae51..78ee6d1b3 100644 --- a/dash-pipeline/SAI/specs/dash_appliance.yaml +++ b/dash-pipeline/SAI/specs/dash_appliance.yaml @@ -27,9 +27,9 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 42701762 + id: 41127208 actions: default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: default - id: 21793905 + id: 29471696 attr_param_id: {} diff --git a/dash-pipeline/SAI/specs/dash_flow.yaml b/dash-pipeline/SAI/specs/dash_flow.yaml index 229d11019..9db3b7865 100644 --- a/dash-pipeline/SAI/specs/dash_flow.yaml +++ b/dash-pipeline/SAI/specs/dash_flow.yaml @@ -684,8 +684,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_BULK_GET_SESSION_ATTR_BULK_GET_SESSION_IP - description: Action parameter bulk get session IP + name: SAI_FLOW_ENTRY_BULK_GET_SESSION_ATTR_BULK_GET_SESSION_SERVER_IP + description: Action parameter bulk get session server IP type: sai_ip_address_t attr_value_field: ipaddr default: 0.0.0.0 @@ -697,8 +697,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_BULK_GET_SESSION_ATTR_BULK_GET_SESSION_PORT - description: Action parameter bulk get session port + name: SAI_FLOW_ENTRY_BULK_GET_SESSION_ATTR_BULK_GET_SESSION_SERVER_PORT + description: Action parameter bulk get session server port type: sai_uint16_t attr_value_field: u16 default: '0' diff --git a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 index 052e5c889..5b835d745 100644 --- a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 +++ b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 @@ -290,8 +290,8 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { bit<32> bulk_get_entry_limitation, /* GRPC Session server IP and port */ - IPv4ORv6Address bulk_get_session_ip, - bit<16> bulk_get_session_port, + IPv4ORv6Address bulk_get_session_server_ip, + bit<16> bulk_get_session_server_port, /* Session filters */ @SaiVal[type="sai_object_id_t"] bit<16> first_flow_entry_bulk_get_session_filter_id, From 738954097793acbcab54a712e7f256cc3e75fa65 Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Mon, 2 Sep 2024 12:36:18 +0000 Subject: [PATCH 07/18] Fix per comments --- dash-pipeline/bmv2/dash_headers.p4 | 2 +- dash-pipeline/bmv2/dash_metadata.p4 | 2 +- dash-pipeline/bmv2/dash_parser.p4 | 8 +++++--- dash-pipeline/bmv2/dash_pipeline.p4 | 1 + test/test-cases/functional/ptf/saidashacl.py | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dash-pipeline/bmv2/dash_headers.p4 b/dash-pipeline/bmv2/dash_headers.p4 index c0b2772f8..dab640802 100644 --- a/dash-pipeline/bmv2/dash_headers.p4 +++ b/dash-pipeline/bmv2/dash_headers.p4 @@ -232,7 +232,7 @@ header dash_packet_meta_t { const bit<16> PACKET_META_HDR_SIZE=dash_packet_meta_t.minSizeInBytes(); #define DASH_ETHTYPE 0x876d -#define DPAPP_MAC 0x02fe23f0e413 +#define DPAPP_MAC 0x02fe23f0e413 /* FIXME temp hardcode */ struct headers_t { /* packet metadata headers */ diff --git a/dash-pipeline/bmv2/dash_metadata.p4 b/dash-pipeline/bmv2/dash_metadata.p4 index 1a8d11890..9425b3854 100644 --- a/dash-pipeline/bmv2/dash_metadata.p4 +++ b/dash-pipeline/bmv2/dash_metadata.p4 @@ -142,7 +142,7 @@ struct ha_data_t { bit<16> dp_channel_src_port_max; // HA packet/flow state - dash_flow_state_t flow_sync_state; + dash_flow_state_t ha_flow_state; } struct metadata_t { diff --git a/dash-pipeline/bmv2/dash_parser.p4 b/dash-pipeline/bmv2/dash_parser.p4 index d2bd275f4..8592cf453 100644 --- a/dash-pipeline/bmv2/dash_parser.p4 +++ b/dash-pipeline/bmv2/dash_parser.p4 @@ -40,14 +40,16 @@ parser dash_parser( transition select(hd.u0_ethernet.ether_type) { IPV4_ETHTYPE: parse_u0_ipv4; IPV6_ETHTYPE: parse_u0_ipv6; - DASH_ETHTYPE: parse_dash; + DASH_ETHTYPE: parse_dash_hdr; default: accept; } } - state parse_dash { + state parse_dash_hdr { packet.extract(hd.packet_meta); - if (hd.packet_meta.packet_subtype != dash_packet_subtype_t.NONE) { + if (hd.packet_meta.packet_subtype == dash_packet_subtype_t.FLOW_CREATE + || hd.packet_meta.packet_subtype == dash_packet_subtype_t.FLOW_UPDATE + || hd.packet_meta.packet_subtype == dash_packet_subtype_t.FLOW_DELETE) { // Flow create/update/delete, extract flow_key packet.extract(hd.flow_key); } diff --git a/dash-pipeline/bmv2/dash_pipeline.p4 b/dash-pipeline/bmv2/dash_pipeline.p4 index 6dd4dfcc8..32dece5ca 100644 --- a/dash-pipeline/bmv2/dash_pipeline.p4 +++ b/dash-pipeline/bmv2/dash_pipeline.p4 @@ -230,6 +230,7 @@ control dash_ingress( apply { meta.flow_enabled = false; + meta.rx_encap.setValid(); meta.encap_data.setValid(); meta.tunnel_data.setValid(); meta.overlay_data.setValid(); diff --git a/test/test-cases/functional/ptf/saidashacl.py b/test/test-cases/functional/ptf/saidashacl.py index 192779bf6..34dff83f2 100644 --- a/test/test-cases/functional/ptf/saidashacl.py +++ b/test/test-cases/functional/ptf/saidashacl.py @@ -229,7 +229,7 @@ def setUpSwitch(self): disable_fast_path_icmp_flow_redirection=0, full_flow_resimulation_requested=False, max_resimulated_flow_per_second=0, - outbound_routing_group_id=0) + outbound_routing_group_id=self.outbound_routing_group) self.eam = sai_thrift_eni_ether_address_map_entry_t( switch_id=self.switch_id, address=self.eni_mac) From 51230087b7a692bea075beb5fe2f818aab663cfe Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Mon, 2 Sep 2024 13:08:48 +0000 Subject: [PATCH 08/18] Rename type of is_ipv6 in overlay_data_t from bool to bit<1>, as make p4c-dpdk-pna fails due to: terminate called after throwing an instance of 'Util::CompilerBug' what(): In file: /p4c/backends/dpdk/dpdkArch.cpp:467 Compiler Bug: header fields should be of type bit<> or varbit<>found this is_ipv6 --- dash-pipeline/bmv2/dash_conntrack.p4 | 2 +- dash-pipeline/bmv2/dash_headers.p4 | 2 +- dash-pipeline/bmv2/routing_actions/routing_action_nat46.p4 | 6 +++--- dash-pipeline/bmv2/routing_actions/routing_action_nat64.p4 | 6 +++--- dash-pipeline/bmv2/stages/conntrack_lookup.p4 | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dash-pipeline/bmv2/dash_conntrack.p4 b/dash-pipeline/bmv2/dash_conntrack.p4 index d4e1cb582..1b6195920 100644 --- a/dash-pipeline/bmv2/dash_conntrack.p4 +++ b/dash-pipeline/bmv2/dash_conntrack.p4 @@ -48,7 +48,7 @@ control ConntrackIn(inout headers_t hdr, } restart_expire_timer(); // reset expiration timer for entry meta.conntrack_data.allow_in = true; - meta.overlay_data.is_ipv6 = false; + meta.overlay_data.is_ipv6 = 0; meta.overlay_data.sip = (IPv4ORv6Address)original_overlay_sip; meta.overlay_data.dip = (IPv4ORv6Address)original_overlay_dip; } diff --git a/dash-pipeline/bmv2/dash_headers.p4 b/dash-pipeline/bmv2/dash_headers.p4 index dab640802..87b952ee5 100644 --- a/dash-pipeline/bmv2/dash_headers.p4 +++ b/dash-pipeline/bmv2/dash_headers.p4 @@ -61,7 +61,7 @@ header overlay_rewrite_data_t { IPv6Address sip_mask; IPv6Address dip_mask; bit<7> reserved; - bool is_ipv6; + bit<1> is_ipv6; } const bit<16> OVERLAY_REWRITE_DATA_HDR_SIZE=overlay_rewrite_data_t.minSizeInBytes(); diff --git a/dash-pipeline/bmv2/routing_actions/routing_action_nat46.p4 b/dash-pipeline/bmv2/routing_actions/routing_action_nat46.p4 index 06948c45a..ae774e5bf 100644 --- a/dash-pipeline/bmv2/routing_actions/routing_action_nat46.p4 +++ b/dash-pipeline/bmv2/routing_actions/routing_action_nat46.p4 @@ -11,7 +11,7 @@ action push_action_nat46( { meta.routing_actions = meta.routing_actions | dash_routing_actions_t.NAT46; - meta.overlay_data.is_ipv6 = true; + meta.overlay_data.is_ipv6 = 1; meta.overlay_data.sip = sip; meta.overlay_data.sip_mask = sip_mask; meta.overlay_data.dip = dip; @@ -27,7 +27,7 @@ control do_action_nat46( return; } - REQUIRES(meta.overlay_data.is_ipv6 == true); + REQUIRES(meta.overlay_data.is_ipv6 == 1); hdr.u0_ipv6.setValid(); hdr.u0_ipv6.version = 6; @@ -48,4 +48,4 @@ control do_action_nat46( } } -#endif /* _DASH_ROUTING_ACTION_NAT46_P4_ */ \ No newline at end of file +#endif /* _DASH_ROUTING_ACTION_NAT46_P4_ */ diff --git a/dash-pipeline/bmv2/routing_actions/routing_action_nat64.p4 b/dash-pipeline/bmv2/routing_actions/routing_action_nat64.p4 index 1f3bebab7..3b56e3964 100644 --- a/dash-pipeline/bmv2/routing_actions/routing_action_nat64.p4 +++ b/dash-pipeline/bmv2/routing_actions/routing_action_nat64.p4 @@ -9,7 +9,7 @@ action push_action_nat64( { meta.routing_actions = meta.routing_actions | dash_routing_actions_t.NAT64; - meta.overlay_data.is_ipv6 = false; + meta.overlay_data.is_ipv6 = 0; meta.overlay_data.sip = (IPv4ORv6Address)src; meta.overlay_data.dip = (IPv4ORv6Address)dst; } @@ -23,7 +23,7 @@ control do_action_nat64( return; } - REQUIRES(meta.overlay_data.is_ipv6 == false); + REQUIRES(meta.overlay_data.is_ipv6 == 0); hdr.u0_ipv4.setValid(); hdr.u0_ipv4.version = 4; @@ -44,4 +44,4 @@ control do_action_nat64( } } -#endif /* _DASH_ROUTING_ACTION_NAT64_P4_ */ \ No newline at end of file +#endif /* _DASH_ROUTING_ACTION_NAT64_P4_ */ diff --git a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 index 5b835d745..f53e77591 100644 --- a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 +++ b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 @@ -235,7 +235,7 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { meta.tunnel_data.dash_encapsulation = tunnel_data_dash_encapsulation; /* Set overlay rewrite metadata */ - meta.overlay_data.is_ipv6 = (bool)overlay_data_is_ipv6; + meta.overlay_data.is_ipv6 = overlay_data_is_ipv6; meta.overlay_data.dmac = overlay_data_dst_mac; meta.overlay_data.sip = overlay_data_sip; meta.overlay_data.dip = overlay_data_dip; From 68c7deb39aec33b52852d7353aef4a11950a4146 Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Tue, 3 Sep 2024 01:32:05 +0000 Subject: [PATCH 09/18] redefine encap_data_t -> meta_encap_data_t and overlay_rewrite_data_t -> meta_overlay_rewrite_data_t, as header in struct is not well supported for target dpdk-pna. --- dash-pipeline/bmv2/dash_metadata.p4 | 37 +++++++++++ dash-pipeline/bmv2/dash_pipeline.p4 | 2 + dash-pipeline/bmv2/stages/conntrack_lookup.p4 | 61 +++++++++++++++++++ 3 files changed, 100 insertions(+) diff --git a/dash-pipeline/bmv2/dash_metadata.p4 b/dash-pipeline/bmv2/dash_metadata.p4 index 9425b3854..b3cd19a72 100644 --- a/dash-pipeline/bmv2/dash_metadata.p4 +++ b/dash-pipeline/bmv2/dash_metadata.p4 @@ -145,6 +145,31 @@ struct ha_data_t { dash_flow_state_t ha_flow_state; } +#ifdef TARGET_DPDK_PNA +// redefine encap_data_t -> meta_encap_data_t +// redefine overlay_rewrite_data_t -> meta_overlay_rewrite_data_t +// header in struct is not well supported for target dpdk-pna +struct meta_encap_data_t { + bit<24> vni; + bit<24> dest_vnet_vni; + IPv4Address underlay_sip; + IPv4Address underlay_dip; + EthernetAddress underlay_smac; + EthernetAddress underlay_dmac; + dash_encapsulation_t dash_encapsulation; +} + +struct meta_overlay_rewrite_data_t { + EthernetAddress dmac; + IPv4ORv6Address sip; + IPv4ORv6Address dip; + IPv6Address sip_mask; + IPv6Address dip_mask; + bit<7> reserved; + bit<1> is_ipv6; +} +#endif // TARGET_DPDK_PNA + struct metadata_t { // Packet type dash_packet_source_t packet_source; // TODO: Parse packet source in parser. @@ -154,7 +179,11 @@ struct metadata_t { dash_direction_t direction; dash_eni_mac_type_t eni_mac_type; dash_eni_mac_override_type_t eni_mac_override_type; +#ifdef TARGET_DPDK_PNA + meta_encap_data_t rx_encap; +#else encap_data_t rx_encap; +#endif // TARGET_DPDK_PNA EthernetAddress eni_addr; bit<16> vnet_id; bit<16> dst_vnet_id; @@ -200,11 +229,19 @@ struct metadata_t { // Action data bool dropped; +#ifdef TARGET_DPDK_PNA + // encap_data is for underlay + meta_encap_data_t encap_data; + // tunnel_data is used by dash_tunnel_id + meta_encap_data_t tunnel_data; + meta_overlay_rewrite_data_t overlay_data; +#else // encap_data is for underlay encap_data_t encap_data; // tunnel_data is used by dash_tunnel_id encap_data_t tunnel_data; overlay_rewrite_data_t overlay_data; +#endif // TARGET_DPDK_PNA bit<16> dash_tunnel_id; bit<32> meter_class; bit<8> local_region_id; diff --git a/dash-pipeline/bmv2/dash_pipeline.p4 b/dash-pipeline/bmv2/dash_pipeline.p4 index 32dece5ca..d1de27d3d 100644 --- a/dash-pipeline/bmv2/dash_pipeline.p4 +++ b/dash-pipeline/bmv2/dash_pipeline.p4 @@ -230,10 +230,12 @@ control dash_ingress( apply { meta.flow_enabled = false; +#ifndef TARGET_DPDK_PNA meta.rx_encap.setValid(); meta.encap_data.setValid(); meta.tunnel_data.setValid(); meta.overlay_data.setValid(); +#endif // TARGET_DPDK_PNA #ifdef TARGET_DPDK_PNA #ifdef DPDK_PNA_SEND_TO_PORT_FIX_MERGED diff --git a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 index f53e77591..c46bb2ba6 100644 --- a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 +++ b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 @@ -12,13 +12,42 @@ action conntrack_set_meta_from_dash_header(in headers_t hdr, out metadata_t meta meta.meter_class = hdr.flow_data.meter_class; /* encapsulation metadata */ +#ifdef TARGET_DPDK_PNA + meta.encap_data.vni = hdr.flow_encap_data.vni; + meta.encap_data.dest_vnet_vni = hdr.flow_encap_data.dest_vnet_vni; + meta.encap_data.underlay_sip = hdr.flow_encap_data.underlay_sip; + meta.encap_data.underlay_dip = hdr.flow_encap_data.underlay_dip; + meta.encap_data.underlay_smac = hdr.flow_encap_data.underlay_smac; + meta.encap_data.underlay_dmac = hdr.flow_encap_data.underlay_dmac; + meta.encap_data.dash_encapsulation = hdr.flow_encap_data.dash_encapsulation; +#else meta.encap_data = hdr.flow_encap_data; +#endif // TARGET_DPDK_PNA /* tunnel metadata */ +#ifdef TARGET_DPDK_PNA + meta.tunnel_data.vni = hdr.flow_tunnel_data.vni; + meta.tunnel_data.dest_vnet_vni = hdr.flow_tunnel_data.dest_vnet_vni; + meta.tunnel_data.underlay_sip = hdr.flow_tunnel_data.underlay_sip; + meta.tunnel_data.underlay_dip = hdr.flow_tunnel_data.underlay_dip; + meta.tunnel_data.underlay_smac = hdr.flow_tunnel_data.underlay_smac; + meta.tunnel_data.underlay_dmac = hdr.flow_tunnel_data.underlay_dmac; + meta.tunnel_data.dash_encapsulation = hdr.flow_tunnel_data.dash_encapsulation; +#else meta.tunnel_data = hdr.flow_tunnel_data; +#endif // TARGET_DPDK_PNA /* overlay rewrite metadata */ +#ifdef TARGET_DPDK_PNA + meta.overlay_data.dmac = hdr.flow_overlay_data.dmac; + meta.overlay_data.sip = hdr.flow_overlay_data.sip; + meta.overlay_data.dip = hdr.flow_overlay_data.dip; + meta.overlay_data.sip_mask = hdr.flow_overlay_data.sip_mask; + meta.overlay_data.dip_mask = hdr.flow_overlay_data.dip_mask; + meta.overlay_data.is_ipv6 = hdr.flow_overlay_data.is_ipv6; +#else meta.overlay_data = hdr.flow_overlay_data; +#endif // TARGET_DPDK_PNA } action conntrack_strip_dash_header(inout headers_t hdr) @@ -48,17 +77,49 @@ control conntrack_build_dash_header(inout headers_t hdr, in metadata_t meta, length = length + FLOW_DATA_HDR_SIZE; if (meta.routing_actions & dash_routing_actions_t.STATIC_ENCAP != 0) { +#ifdef TARGET_DPDK_PNA + hdr.flow_encap_data.setValid(); + hdr.flow_encap_data.vni = meta.encap_data.vni; + hdr.flow_encap_data.dest_vnet_vni = meta.encap_data.dest_vnet_vni; + hdr.flow_encap_data.underlay_sip = meta.encap_data.underlay_sip; + hdr.flow_encap_data.underlay_dip = meta.encap_data.underlay_dip; + hdr.flow_encap_data.underlay_smac = meta.encap_data.underlay_smac; + hdr.flow_encap_data.underlay_dmac = meta.encap_data.underlay_dmac; + hdr.flow_encap_data.dash_encapsulation = meta.encap_data.dash_encapsulation; +#else hdr.flow_encap_data= meta.encap_data; +#endif // TARGET_DPDK_PNA length = length + ENCAP_DATA_HDR_SIZE; } if (meta.dash_tunnel_id != 0) { +#ifdef TARGET_DPDK_PNA + hdr.flow_tunnel_data.setValid(); + hdr.flow_tunnel_data.vni = meta.tunnel_data.vni; + hdr.flow_tunnel_data.dest_vnet_vni = meta.tunnel_data.dest_vnet_vni; + hdr.flow_tunnel_data.underlay_sip = meta.tunnel_data.underlay_sip; + hdr.flow_tunnel_data.underlay_dip = meta.tunnel_data.underlay_dip; + hdr.flow_tunnel_data.underlay_smac = meta.tunnel_data.underlay_smac; + hdr.flow_tunnel_data.underlay_dmac = meta.tunnel_data.underlay_dmac; + hdr.flow_tunnel_data.dash_encapsulation = meta.tunnel_data.dash_encapsulation; +#else hdr.flow_tunnel_data= meta.tunnel_data; +#endif // TARGET_DPDK_PNA length = length + ENCAP_DATA_HDR_SIZE; } if (meta.routing_actions != 0) { +#ifdef TARGET_DPDK_PNA + hdr.flow_overlay_data.setValid(); + hdr.flow_overlay_data.dmac = meta.overlay_data.dmac; + hdr.flow_overlay_data.sip = meta.overlay_data.sip; + hdr.flow_overlay_data.dip = meta.overlay_data.dip; + hdr.flow_overlay_data.sip_mask = meta.overlay_data.sip_mask; + hdr.flow_overlay_data.dip_mask = meta.overlay_data.dip_mask; + hdr.flow_overlay_data.is_ipv6 = meta.overlay_data.is_ipv6; +#else hdr.flow_overlay_data= meta.overlay_data; +#endif // TARGET_DPDK_PNA length = length + OVERLAY_REWRITE_DATA_HDR_SIZE; } From 73256bcb9cffad2dbacbac59ed20093989eaaffb Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Thu, 5 Sep 2024 10:23:54 +0000 Subject: [PATCH 10/18] Revert set_flow_entry_attr params for flow SAI backward compatible --- .wordlist.txt | 2 + dash-pipeline/SAI/specs/dash_flow.yaml | 322 ++++++++++-------- dash-pipeline/SAI/specs/sai_spec.yaml | 32 +- dash-pipeline/bmv2/dash_headers.p4 | 21 +- dash-pipeline/bmv2/dash_metadata.p4 | 29 +- dash-pipeline/bmv2/dash_parser.p4 | 9 +- dash-pipeline/bmv2/dash_pipeline.p4 | 3 +- dash-pipeline/bmv2/stages/conntrack_lookup.p4 | 145 ++++---- documentation/dataplane/dash-flow-api.md | 4 + documentation/high-avail/ha-api-hld.md | 19 +- 10 files changed, 324 insertions(+), 262 deletions(-) diff --git a/.wordlist.txt b/.wordlist.txt index 44ec48bb5..2ae74c92e 100644 --- a/.wordlist.txt +++ b/.wordlist.txt @@ -315,6 +315,7 @@ Jinja jitter journaled json +Junhua keepalive keepalives Keysight @@ -738,6 +739,7 @@ Gan Ze AppDBMemoryEstimation Ivantsiv +Zhai Zhixiong Niu validonly diff --git a/dash-pipeline/SAI/specs/dash_flow.yaml b/dash-pipeline/SAI/specs/dash_flow.yaml index 9db3b7865..b106f147a 100644 --- a/dash-pipeline/SAI/specs/dash_flow.yaml +++ b/dash-pipeline/SAI/specs/dash_flow.yaml @@ -95,6 +95,12 @@ sai_apis: type: sai_uint16_t objects: null valid_only: null + - !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry + name: ip_proto + description: Exact matched key ip_proto + type: sai_uint8_t + objects: null + valid_only: null - !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry name: src_ip description: Exact matched key src_ip @@ -119,12 +125,6 @@ sai_apis: type: sai_uint16_t objects: null valid_only: null - - !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry - name: ip_proto - description: Exact matched key ip_proto - type: sai_uint8_t - objects: null - valid_only: null attributes: - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute name: SAI_FLOW_ENTRY_ATTR_ACTION @@ -140,11 +140,11 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_IS_UNIDIRECTIONAL - description: Action parameter is unidirectional - type: bool - attr_value_field: booldata - default: 'false' + name: SAI_FLOW_ENTRY_ATTR_VERSION + description: Action parameter version + type: sai_uint32_t + attr_value_field: u32 + default: '0' isresourcetype: false flags: CREATE_AND_SET object_name: null @@ -153,11 +153,11 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_STATE - description: Action parameter state - type: sai_uint8_t - attr_value_field: u8 - default: '0' + name: SAI_FLOW_ENTRY_ATTR_DASH_DIRECTION + description: Action parameter DASH direction + type: sai_dash_direction_t + attr_value_field: s32 + default: SAI_DASH_DIRECTION_INVALID isresourcetype: false flags: CREATE_AND_SET object_name: null @@ -166,8 +166,21 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_VERSION - description: Action parameter version + name: SAI_FLOW_ENTRY_ATTR_DASH_FLOW_ACTION + description: Action parameter DASH flow action + type: sai_dash_flow_action_t + attr_value_field: s32 + default: SAI_DASH_FLOW_ACTION_NONE + isresourcetype: false + flags: CREATE_AND_SET + object_name: null + allow_null: false + valid_only: null + is_vlan: false + deprecated: false + - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute + name: SAI_FLOW_ENTRY_ATTR_METER_CLASS + description: Action parameter meter class type: sai_uint32_t attr_value_field: u32 default: '0' @@ -179,11 +192,11 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_DASH_DIRECTION - description: Action parameter DASH direction - type: sai_dash_direction_t - attr_value_field: s32 - default: SAI_DASH_DIRECTION_INVALID + name: SAI_FLOW_ENTRY_ATTR_IS_UNIDIRECTIONAL_FLOW + description: Action parameter is unidirectional flow + type: bool + attr_value_field: booldata + default: 'false' isresourcetype: false flags: CREATE_AND_SET object_name: null @@ -192,8 +205,21 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_TUNNEL_ID - description: Action parameter tunnel id + name: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_ENI_MAC + description: Action parameter reverse flow ENI MAC + type: sai_mac_t + attr_value_field: mac + default: vendor + isresourcetype: false + flags: CREATE_AND_SET + object_name: null + allow_null: false + valid_only: null + is_vlan: false + deprecated: false + - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute + name: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_VNET_ID + description: Action parameter reverse flow VNET id type: sai_uint16_t attr_value_field: u16 default: '0' @@ -205,10 +231,10 @@ sai_apis: is_vlan: true deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_ROUTING_ACTIONS - description: Action parameter routing actions - type: sai_uint32_t - attr_value_field: u32 + name: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_IP_PROTO + description: Action parameter reverse flow IP protocol + type: sai_uint8_t + attr_value_field: u8 default: '0' isresourcetype: false flags: CREATE_AND_SET @@ -218,11 +244,11 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_METER_CLASS - description: Action parameter meter class - type: sai_uint32_t - attr_value_field: u32 - default: '0' + name: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_SRC_IP + description: Action parameter reverse flow src IP + type: sai_ip_address_t + attr_value_field: ipaddr + default: 0.0.0.0 isresourcetype: false flags: CREATE_AND_SET object_name: null @@ -231,11 +257,11 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_VNI - description: Action parameter encap data VNI - type: sai_uint32_t - attr_value_field: u32 - default: '0' + name: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_DST_IP + description: Action parameter reverse flow dst IP + type: sai_ip_address_t + attr_value_field: ipaddr + default: 0.0.0.0 isresourcetype: false flags: CREATE_AND_SET object_name: null @@ -244,34 +270,34 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_DEST_VNET_VNI - description: Action parameter encap data destination VNET VNI - type: sai_uint32_t - attr_value_field: u32 + name: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_SRC_PORT + description: Action parameter reverse flow src port + type: sai_uint16_t + attr_value_field: u16 default: '0' isresourcetype: false flags: CREATE_AND_SET object_name: null allow_null: false valid_only: null - is_vlan: false + is_vlan: true deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_SIP - description: Action parameter encap data underlay sip - type: sai_uint32_t - attr_value_field: u32 + name: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_DST_PORT + description: Action parameter reverse flow dst port + type: sai_uint16_t + attr_value_field: u16 default: '0' isresourcetype: false flags: CREATE_AND_SET object_name: null allow_null: false valid_only: null - is_vlan: false + is_vlan: true deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_DIP - description: Action parameter encap data underlay dip + name: SAI_FLOW_ENTRY_ATTR_UNDERLAY0_VNET_ID + description: Action parameter underlay0 VNET id type: sai_uint32_t attr_value_field: u32 default: '0' @@ -283,11 +309,11 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_SMAC - description: Action parameter encap data underlay source MAC - type: sai_mac_t - attr_value_field: mac - default: vendor + name: SAI_FLOW_ENTRY_ATTR_UNDERLAY0_SIP + description: Action parameter underlay0 sip + type: sai_uint32_t + attr_value_field: u32 + default: '0' isresourcetype: false flags: CREATE_AND_SET object_name: null @@ -296,11 +322,11 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_DMAC - description: Action parameter encap data underlay destination MAC - type: sai_mac_t - attr_value_field: mac - default: vendor + name: SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DIP + description: Action parameter underlay0 dip + type: sai_uint32_t + attr_value_field: u32 + default: '0' isresourcetype: false flags: CREATE_AND_SET object_name: null @@ -309,8 +335,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_DASH_ENCAPSULATION - description: Action parameter encap data DASH encapsulation + name: SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DASH_ENCAPSULATION + description: Action parameter underlay0 DASH encapsulation type: sai_dash_encapsulation_t attr_value_field: s32 default: SAI_DASH_ENCAPSULATION_INVALID @@ -322,8 +348,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_VNI - description: Action parameter tunnel data VNI + name: SAI_FLOW_ENTRY_ATTR_UNDERLAY1_VNET_ID + description: Action parameter underlay1 VNET id type: sai_uint32_t attr_value_field: u32 default: '0' @@ -335,8 +361,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_DEST_VNET_VNI - description: Action parameter tunnel data destination VNET VNI + name: SAI_FLOW_ENTRY_ATTR_UNDERLAY1_SIP + description: Action parameter underlay1 sip type: sai_uint32_t attr_value_field: u32 default: '0' @@ -348,8 +374,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_SIP - description: Action parameter tunnel data underlay sip + name: SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DIP + description: Action parameter underlay1 dip type: sai_uint32_t attr_value_field: u32 default: '0' @@ -361,21 +387,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_DIP - description: Action parameter tunnel data underlay dip - type: sai_uint32_t - attr_value_field: u32 - default: '0' - isresourcetype: false - flags: CREATE_AND_SET - object_name: null - allow_null: false - valid_only: null - is_vlan: false - deprecated: false - - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_SMAC - description: Action parameter tunnel data underlay source MAC + name: SAI_FLOW_ENTRY_ATTR_UNDERLAY1_SMAC + description: Action parameter underlay1 source MAC type: sai_mac_t attr_value_field: mac default: vendor @@ -387,8 +400,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_DMAC - description: Action parameter tunnel data underlay destination MAC + name: SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DMAC + description: Action parameter underlay1 destination MAC type: sai_mac_t attr_value_field: mac default: vendor @@ -400,8 +413,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_DASH_ENCAPSULATION - description: Action parameter tunnel data DASH encapsulation + name: SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DASH_ENCAPSULATION + description: Action parameter underlay1 DASH encapsulation type: sai_dash_encapsulation_t attr_value_field: s32 default: SAI_DASH_ENCAPSULATION_INVALID @@ -413,21 +426,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_IS_IPV6 - description: Action parameter overlay data is ipv6 - type: bool - attr_value_field: booldata - default: 'false' - isresourcetype: false - flags: CREATE_AND_SET - object_name: null - allow_null: false - valid_only: null - is_vlan: false - deprecated: false - - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_DST_MAC - description: Action parameter overlay data dst MAC + name: SAI_FLOW_ENTRY_ATTR_DST_MAC + description: Action parameter dst MAC type: sai_mac_t attr_value_field: mac default: vendor @@ -439,8 +439,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_SIP - description: Action parameter overlay data sip + name: SAI_FLOW_ENTRY_ATTR_SIP + description: Action parameter sip type: sai_ip_address_t attr_value_field: ipaddr default: 0.0.0.0 @@ -452,8 +452,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_DIP - description: Action parameter overlay data dip + name: SAI_FLOW_ENTRY_ATTR_DIP + description: Action parameter dip type: sai_ip_address_t attr_value_field: ipaddr default: 0.0.0.0 @@ -465,8 +465,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_SIP_MASK - description: Action parameter overlay data sip mask + name: SAI_FLOW_ENTRY_ATTR_SIP_MASK + description: Action parameter sip mask type: sai_ip_address_t attr_value_field: ipaddr default: 0.0.0.0 @@ -478,8 +478,8 @@ sai_apis: is_vlan: false deprecated: false - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute - name: SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_DIP_MASK - description: Action parameter overlay data dip mask + name: SAI_FLOW_ENTRY_ATTR_DIP_MASK + description: Action parameter dip mask type: sai_ip_address_t attr_value_field: ipaddr default: 0.0.0.0 @@ -529,6 +529,45 @@ sai_apis: valid_only: null is_vlan: false deprecated: false + - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute + name: SAI_FLOW_ENTRY_ATTR_DASH_FLOW_SYNC_STATE + description: Action parameter DASH flow sync state + type: sai_dash_flow_sync_state_t + attr_value_field: s32 + default: SAI_DASH_FLOW_SYNC_STATE_FLOW_MISS + isresourcetype: false + flags: CREATE_AND_SET + object_name: null + allow_null: false + valid_only: null + is_vlan: false + deprecated: false + - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute + name: SAI_FLOW_ENTRY_ATTR_UNDERLAY0_SMAC + description: Action parameter underlay0 source MAC + type: sai_mac_t + attr_value_field: mac + default: vendor + isresourcetype: false + flags: CREATE_AND_SET + object_name: null + allow_null: false + valid_only: null + is_vlan: false + deprecated: false + - !!python/object:utils.sai_spec.sai_attribute.SaiAttribute + name: SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DMAC + description: Action parameter underlay0 destination MAC + type: sai_mac_t + attr_value_field: mac + default: vendor + isresourcetype: false + flags: CREATE_AND_SET + object_name: null + allow_null: false + valid_only: null + is_vlan: false + deprecated: false stats: [] p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: @@ -539,35 +578,38 @@ sai_apis: name: SAI_FLOW_ENTRY_ACTION_SET_FLOW_ENTRY_ATTR id: 26241621 attr_param_id: - SAI_FLOW_ENTRY_ATTR_IS_UNIDIRECTIONAL: 1 - SAI_FLOW_ENTRY_ATTR_STATE: 2 - SAI_FLOW_ENTRY_ATTR_VERSION: 3 - SAI_FLOW_ENTRY_ATTR_DASH_DIRECTION: 4 - SAI_FLOW_ENTRY_ATTR_TUNNEL_ID: 5 - SAI_FLOW_ENTRY_ATTR_ROUTING_ACTIONS: 6 - SAI_FLOW_ENTRY_ATTR_METER_CLASS: 7 - SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_VNI: 8 - SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_DEST_VNET_VNI: 9 - SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_SIP: 10 - SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_DIP: 11 - SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_SMAC: 12 - SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_UNDERLAY_DMAC: 13 - SAI_FLOW_ENTRY_ATTR_ENCAP_DATA_DASH_ENCAPSULATION: 14 - SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_VNI: 15 - SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_DEST_VNET_VNI: 16 - SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_SIP: 17 - SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_DIP: 18 - SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_SMAC: 19 - SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_UNDERLAY_DMAC: 20 - SAI_FLOW_ENTRY_ATTR_TUNNEL_DATA_DASH_ENCAPSULATION: 21 - SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_IS_IPV6: 22 - SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_DST_MAC: 23 - SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_SIP: 24 - SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_DIP: 25 - SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_SIP_MASK: 26 - SAI_FLOW_ENTRY_ATTR_OVERLAY_DATA_DIP_MASK: 27 - SAI_FLOW_ENTRY_ATTR_VENDOR_METADATA: 28 - SAI_FLOW_ENTRY_ATTR_FLOW_DATA_PB: 29 + SAI_FLOW_ENTRY_ATTR_VERSION: 1 + SAI_FLOW_ENTRY_ATTR_DASH_DIRECTION: 2 + SAI_FLOW_ENTRY_ATTR_DASH_FLOW_ACTION: 3 + SAI_FLOW_ENTRY_ATTR_METER_CLASS: 4 + SAI_FLOW_ENTRY_ATTR_IS_UNIDIRECTIONAL_FLOW: 5 + SAI_FLOW_ENTRY_ATTR_DASH_FLOW_SYNC_STATE: 6 + SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_ENI_MAC: 7 + SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_VNET_ID: 8 + SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_IP_PROTO: 9 + SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_SRC_IP: 10 + SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_DST_IP: 11 + SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_SRC_PORT: 12 + SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_DST_PORT: 13 + SAI_FLOW_ENTRY_ATTR_UNDERLAY0_VNET_ID: 14 + SAI_FLOW_ENTRY_ATTR_UNDERLAY0_SIP: 15 + SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DIP: 16 + SAI_FLOW_ENTRY_ATTR_UNDERLAY0_SMAC: 17 + SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DMAC: 18 + SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DASH_ENCAPSULATION: 19 + SAI_FLOW_ENTRY_ATTR_UNDERLAY1_VNET_ID: 20 + SAI_FLOW_ENTRY_ATTR_UNDERLAY1_SIP: 21 + SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DIP: 22 + SAI_FLOW_ENTRY_ATTR_UNDERLAY1_SMAC: 23 + SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DMAC: 24 + SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DASH_ENCAPSULATION: 25 + SAI_FLOW_ENTRY_ATTR_DST_MAC: 26 + SAI_FLOW_ENTRY_ATTR_SIP: 27 + SAI_FLOW_ENTRY_ATTR_DIP: 28 + SAI_FLOW_ENTRY_ATTR_SIP_MASK: 29 + SAI_FLOW_ENTRY_ATTR_DIP_MASK: 30 + SAI_FLOW_ENTRY_ATTR_VENDOR_METADATA: 32 + SAI_FLOW_ENTRY_ATTR_FLOW_DATA_PB: 33 - !!python/object:utils.sai_spec.sai_api.SaiApi name: flow_entry_bulk_get_session_filter description: flow entry bulk get session filter diff --git a/dash-pipeline/SAI/specs/sai_spec.yaml b/dash-pipeline/SAI/specs/sai_spec.yaml index 3419f1395..c4f5472a2 100644 --- a/dash-pipeline/SAI/specs/sai_spec.yaml +++ b/dash-pipeline/SAI/specs/sai_spec.yaml @@ -380,45 +380,45 @@ enums: description: '' value: '12' - !!python/object:utils.sai_spec.sai_enum.SaiEnum - name: sai_dash_flow_state_t + name: sai_dash_eni_mac_override_type_t description: '' members: - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember - name: FLOW_MISS + name: NONE description: '' value: '0' - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember - name: FLOW_CREATED + name: SRC_MAC description: '' value: '1' - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember - name: FLOW_SYNCED + name: DST_MAC description: '' value: '2' - - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember - name: FLOW_PENDING_DELETE - description: '' - value: '3' - - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember - name: FLOW_PENDING_RESIMULATION - description: '' - value: '4' - !!python/object:utils.sai_spec.sai_enum.SaiEnum - name: sai_dash_eni_mac_override_type_t + name: sai_dash_flow_sync_state_t description: '' members: - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember - name: NONE + name: FLOW_MISS description: '' value: '0' - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember - name: SRC_MAC + name: FLOW_CREATED description: '' value: '1' - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember - name: DST_MAC + name: FLOW_SYNCED description: '' value: '2' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: FLOW_PENDING_DELETE + description: '' + value: '3' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: FLOW_PENDING_RESIMULATION + description: '' + value: '4' port_extenstion: !!python/object:utils.sai_spec.sai_api_extension.SaiApiExtension attributes: [] stats: diff --git a/dash-pipeline/bmv2/dash_headers.p4 b/dash-pipeline/bmv2/dash_headers.p4 index 87b952ee5..061217773 100644 --- a/dash-pipeline/bmv2/dash_headers.p4 +++ b/dash-pipeline/bmv2/dash_headers.p4 @@ -45,7 +45,7 @@ enum bit<16> dash_encapsulation_t { header encap_data_t { bit<24> vni; - bit<24> dest_vnet_vni; + bit<8> reserved; IPv4Address underlay_sip; IPv4Address underlay_dip; EthernetAddress underlay_smac; @@ -153,6 +153,19 @@ header ipv6_t { const bit<16> IPV6_HDR_SIZE=320/8; +// Flow sync state +enum bit<8> dash_flow_sync_state_t { + FLOW_MISS = 0, // Flow not created yet + FLOW_CREATED = 1, // Flow is created but not synched or waiting for ack + FLOW_SYNCED = 2, // Flow has been synched to its peer + FLOW_PENDING_DELETE = 3, // Flow is pending deletion, waiting for ack + FLOW_PENDING_RESIMULATION = 4 // Flow is marked as pending resimulation +} + +enum bit<32> dash_flow_action_t { + NONE = 0 +} + enum bit<16> dash_flow_enabled_key_t { ENI_MAC = (1 << 0), VNI = (1 << 1), @@ -214,10 +227,10 @@ const bit<16> FLOW_KEY_HDR_SIZE=flow_key_t.minSizeInBytes(); header flow_data_t { bit<7> reserved; bit<1> is_unidirectional; - bit<32> version; + dash_flow_sync_state_t sync_state; dash_direction_t direction; - bit<16> tunnel_id; - bit<32> routing_actions; + bit<32> version; + dash_flow_action_t actions; dash_meter_class_t meter_class; } const bit<16> FLOW_DATA_HDR_SIZE=flow_data_t.minSizeInBytes(); diff --git a/dash-pipeline/bmv2/dash_metadata.p4 b/dash-pipeline/bmv2/dash_metadata.p4 index b3cd19a72..fcd90b011 100644 --- a/dash-pipeline/bmv2/dash_metadata.p4 +++ b/dash-pipeline/bmv2/dash_metadata.p4 @@ -117,15 +117,6 @@ enum bit<8> dash_ha_state_t { SWITCHING_TO_STANDALONE = 12 }; -// Flow state -enum bit<8> dash_flow_state_t { - FLOW_MISS = 0, // Flow not created yet - FLOW_CREATED = 1, // Flow is created but not synched or waiting for ack - FLOW_SYNCED = 2, // Flow has been synched to its peer - FLOW_PENDING_DELETE = 3, // Flow is pending deletion, waiting for ack - FLOW_PENDING_RESIMULATION = 4 // Flow is marked as pending resimulation -}; - struct ha_data_t { // HA scope settings bit<16> ha_scope_id; @@ -140,18 +131,24 @@ struct ha_data_t { bit<16> dp_channel_dst_port; bit<16> dp_channel_src_port_min; bit<16> dp_channel_src_port_max; - - // HA packet/flow state - dash_flow_state_t ha_flow_state; } #ifdef TARGET_DPDK_PNA // redefine encap_data_t -> meta_encap_data_t // redefine overlay_rewrite_data_t -> meta_overlay_rewrite_data_t // header in struct is not well supported for target dpdk-pna +struct meta_flow_data_t { + bit<7> reserved; + bit<1> is_unidirectional; + dash_flow_sync_state_t sync_state; + dash_direction_t direction; + bit<32> version; + dash_flow_action_t actions; + dash_meter_class_t meter_class; +} struct meta_encap_data_t { bit<24> vni; - bit<24> dest_vnet_vni; + bit<8> reserved; IPv4Address underlay_sip; IPv4Address underlay_dip; EthernetAddress underlay_smac; @@ -214,8 +211,12 @@ struct metadata_t { // Flow data conntrack_data_t conntrack_data; +#ifdef TARGET_DPDK_PNA + meta_flow_data_t flow_data; +#else + flow_data_t flow_data; +#endif // TARGET_DPDK_PNA flow_table_data_t flow_table; - dash_flow_state_t flow_state; bit<16> bulk_get_session_id; bit<16> bulk_get_session_filter_id; bool flow_enabled; diff --git a/dash-pipeline/bmv2/dash_parser.p4 b/dash-pipeline/bmv2/dash_parser.p4 index 8592cf453..69a728531 100644 --- a/dash-pipeline/bmv2/dash_parser.p4 +++ b/dash-pipeline/bmv2/dash_parser.p4 @@ -58,17 +58,16 @@ parser dash_parser( // Flow delete, extract flow_data ... packet.extract(hd.flow_data); - if (hd.flow_data.routing_actions != 0) { + if (hd.flow_data.actions != 0) { packet.extract(hd.flow_overlay_data); } - if (hd.flow_data.routing_actions & dash_routing_actions_t.STATIC_ENCAP != 0) { + if (hd.flow_data.actions & dash_routing_actions_t.STATIC_ENCAP != 0) { packet.extract(hd.flow_encap_data); } - if (hd.flow_data.tunnel_id != 0) { - packet.extract(hd.flow_tunnel_data); - } + // FIXME: assume no tunnel data + // packet.extract(hd.flow_tunnel_data); } transition parse_customer_ethernet; diff --git a/dash-pipeline/bmv2/dash_pipeline.p4 b/dash-pipeline/bmv2/dash_pipeline.p4 index d1de27d3d..8f451c468 100644 --- a/dash-pipeline/bmv2/dash_pipeline.p4 +++ b/dash-pipeline/bmv2/dash_pipeline.p4 @@ -232,6 +232,7 @@ control dash_ingress( #ifndef TARGET_DPDK_PNA meta.rx_encap.setValid(); + meta.flow_data.setValid(); meta.encap_data.setValid(); meta.tunnel_data.setValid(); meta.overlay_data.setValid(); @@ -268,7 +269,7 @@ control dash_ingress( ha_stage.apply(hdr, meta); if (!meta.flow_enabled || - (meta.flow_state == dash_flow_state_t.FLOW_MISS && + (meta.flow_data.sync_state == dash_flow_sync_state_t.FLOW_MISS && hdr.packet_meta.packet_source == dash_packet_source_t.EXTERNAL)) { dash_match_stage.apply(hdr, meta); diff --git a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 index c46bb2ba6..78d63344e 100644 --- a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 +++ b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 @@ -7,14 +7,13 @@ action conntrack_set_meta_from_dash_header(in headers_t hdr, out metadata_t meta { /* basic metadata */ meta.direction = hdr.flow_data.direction; - meta.dash_tunnel_id = hdr.flow_data.tunnel_id; - meta.routing_actions = hdr.flow_data.routing_actions; + meta.dash_tunnel_id = 0; + meta.routing_actions = (bit<32>)hdr.flow_data.actions; meta.meter_class = hdr.flow_data.meter_class; /* encapsulation metadata */ #ifdef TARGET_DPDK_PNA meta.encap_data.vni = hdr.flow_encap_data.vni; - meta.encap_data.dest_vnet_vni = hdr.flow_encap_data.dest_vnet_vni; meta.encap_data.underlay_sip = hdr.flow_encap_data.underlay_sip; meta.encap_data.underlay_dip = hdr.flow_encap_data.underlay_dip; meta.encap_data.underlay_smac = hdr.flow_encap_data.underlay_smac; @@ -27,7 +26,6 @@ action conntrack_set_meta_from_dash_header(in headers_t hdr, out metadata_t meta /* tunnel metadata */ #ifdef TARGET_DPDK_PNA meta.tunnel_data.vni = hdr.flow_tunnel_data.vni; - meta.tunnel_data.dest_vnet_vni = hdr.flow_tunnel_data.dest_vnet_vni; meta.tunnel_data.underlay_sip = hdr.flow_tunnel_data.underlay_sip; meta.tunnel_data.underlay_dip = hdr.flow_tunnel_data.underlay_dip; meta.tunnel_data.underlay_smac = hdr.flow_tunnel_data.underlay_smac; @@ -71,8 +69,7 @@ control conntrack_build_dash_header(inout headers_t hdr, in metadata_t meta, hdr.flow_data.is_unidirectional = 0; hdr.flow_data.version = 0; hdr.flow_data.direction = meta.direction; - hdr.flow_data.tunnel_id = meta.dash_tunnel_id; - hdr.flow_data.routing_actions = meta.routing_actions; + hdr.flow_data.actions = (dash_flow_action_t)meta.routing_actions; hdr.flow_data.meter_class = meta.meter_class; length = length + FLOW_DATA_HDR_SIZE; @@ -80,7 +77,6 @@ control conntrack_build_dash_header(inout headers_t hdr, in metadata_t meta, #ifdef TARGET_DPDK_PNA hdr.flow_encap_data.setValid(); hdr.flow_encap_data.vni = meta.encap_data.vni; - hdr.flow_encap_data.dest_vnet_vni = meta.encap_data.dest_vnet_vni; hdr.flow_encap_data.underlay_sip = meta.encap_data.underlay_sip; hdr.flow_encap_data.underlay_dip = meta.encap_data.underlay_dip; hdr.flow_encap_data.underlay_smac = meta.encap_data.underlay_smac; @@ -96,7 +92,6 @@ control conntrack_build_dash_header(inout headers_t hdr, in metadata_t meta, #ifdef TARGET_DPDK_PNA hdr.flow_tunnel_data.setValid(); hdr.flow_tunnel_data.vni = meta.tunnel_data.vni; - hdr.flow_tunnel_data.dest_vnet_vni = meta.tunnel_data.dest_vnet_vni; hdr.flow_tunnel_data.underlay_sip = meta.tunnel_data.underlay_sip; hdr.flow_tunnel_data.underlay_dip = meta.tunnel_data.underlay_dip; hdr.flow_tunnel_data.underlay_smac = meta.tunnel_data.underlay_smac; @@ -178,11 +173,11 @@ control conntrack_flow_created_handle(inout headers_t hdr, inout metadata_t meta control conntrack_flow_handle(inout headers_t hdr, inout metadata_t meta) { apply { - switch (meta.flow_state) { - dash_flow_state_t.FLOW_MISS: { + switch (meta.flow_data.sync_state) { + dash_flow_sync_state_t.FLOW_MISS: { conntrack_flow_miss_handle.apply(hdr, meta); } - dash_flow_state_t.FLOW_CREATED: { + dash_flow_sync_state_t.FLOW_CREATED: { conntrack_flow_created_handle.apply(hdr, meta); } } @@ -225,87 +220,91 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { // action set_flow_entry_attr( /* Flow basic metadata */ - bit<1> is_unidirectional, - dash_flow_state_t state, bit<32> version, @SaiVal[type="sai_dash_direction_t"] dash_direction_t dash_direction, - bit<16> tunnel_id, - bit<32> routing_actions, + @SaiVal[type="sai_dash_flow_action_t"] dash_flow_action_t dash_flow_action, bit<32> meter_class, + bit<1> is_unidirectional_flow, + @SaiVal[type="sai_dash_flow_sync_state_t"] dash_flow_sync_state_t dash_flow_sync_state, + + /* Reverse flow key */ + EthernetAddress reverse_flow_eni_mac, + bit<16> reverse_flow_vnet_id, + bit<8> reverse_flow_ip_proto, + IPv4ORv6Address reverse_flow_src_ip, + IPv4ORv6Address reverse_flow_dst_ip, + bit<16> reverse_flow_src_port, + bit<16> reverse_flow_dst_port, /* Flow encap related attributes */ - bit<24> encap_data_vni, - bit<24> encap_data_dest_vnet_vni, - IPv4Address encap_data_underlay_sip, - IPv4Address encap_data_underlay_dip, - EthernetAddress encap_data_underlay_smac, - EthernetAddress encap_data_underlay_dmac, - @SaiVal[type="sai_dash_encapsulation_t"] dash_encapsulation_t encap_data_dash_encapsulation, - - /* Flow tunnel related attributes */ - bit<24> tunnel_data_vni, - bit<24> tunnel_data_dest_vnet_vni, - IPv4Address tunnel_data_underlay_sip, - IPv4Address tunnel_data_underlay_dip, - EthernetAddress tunnel_data_underlay_smac, - EthernetAddress tunnel_data_underlay_dmac, - @SaiVal[type="sai_dash_encapsulation_t"] dash_encapsulation_t tunnel_data_dash_encapsulation, + bit<24> underlay0_vnet_id, + IPv4Address underlay0_sip, + IPv4Address underlay0_dip, + EthernetAddress underlay0_smac, + EthernetAddress underlay0_dmac, + @SaiVal[type="sai_dash_encapsulation_t"] dash_encapsulation_t underlay0_dash_encapsulation, + + bit<24> underlay1_vnet_id, + IPv4Address underlay1_sip, + IPv4Address underlay1_dip, + EthernetAddress underlay1_smac, + EthernetAddress underlay1_dmac, + @SaiVal[type="sai_dash_encapsulation_t"] dash_encapsulation_t underlay1_dash_encapsulation, /* Flow overlay rewrite related attributes */ - bit<1> overlay_data_is_ipv6, - EthernetAddress overlay_data_dst_mac, - IPv4ORv6Address overlay_data_sip, - IPv4ORv6Address overlay_data_dip, - IPv6Address overlay_data_sip_mask, - IPv6Address overlay_data_dip_mask, - - /* Extra flow metadata, unused */ + EthernetAddress dst_mac, + IPv4ORv6Address sip, + IPv4ORv6Address dip, + IPv6Address sip_mask, + IPv6Address dip_mask, + @SaiVal[name = "ip_is_v6"]bit<1> is_ipv6, + + /* Extra flow metadata */ @SaiVal[type="sai_u8_list_t"] bit<16> vendor_metadata, @SaiVal[type="sai_u8_list_t"] bit<16> flow_data_pb) { - meta.flow_state = state; - // TODO check FLOW_SYNCED in ha - // Do state FSM later - if (state != dash_flow_state_t.FLOW_CREATED) { - return; - } - - /* Set basic metadata */ + /* Set Flow basic metadata */ + meta.flow_data.version = version; + meta.flow_data.direction = dash_direction; + meta.flow_data.actions = dash_flow_action; + meta.flow_data.meter_class = meter_class; + meta.flow_data.is_unidirectional= is_unidirectional_flow; + meta.flow_data.sync_state = dash_flow_sync_state; + + /* Also set basic metadata */ meta.direction = dash_direction; - meta.dash_tunnel_id = tunnel_id; - meta.routing_actions = routing_actions; + meta.routing_actions = (bit<32>)dash_flow_action; meta.meter_class = meter_class; + /* Reverse flow key is not used by now */ + ; + /* Set encapsulation metadata */ - meta.encap_data.vni = encap_data_vni; - meta.encap_data.dest_vnet_vni = encap_data_dest_vnet_vni; - meta.encap_data.underlay_sip = encap_data_underlay_sip; - meta.encap_data.underlay_dip = encap_data_underlay_dip; - meta.encap_data.underlay_smac = encap_data_underlay_smac; - meta.encap_data.underlay_dmac = encap_data_underlay_dmac; - meta.encap_data.dash_encapsulation = encap_data_dash_encapsulation; - - - /* Set tunnel metadata */ - meta.tunnel_data.vni = tunnel_data_vni; - meta.tunnel_data.dest_vnet_vni = tunnel_data_dest_vnet_vni; - meta.tunnel_data.underlay_sip = tunnel_data_underlay_sip; - meta.tunnel_data.underlay_dip = tunnel_data_underlay_dip; - meta.tunnel_data.underlay_smac = tunnel_data_underlay_smac; - meta.tunnel_data.underlay_dmac = tunnel_data_underlay_dmac; - meta.tunnel_data.dash_encapsulation = tunnel_data_dash_encapsulation; + meta.encap_data.vni = underlay0_vnet_id; + meta.encap_data.underlay_sip = underlay0_sip; + meta.encap_data.underlay_dip = underlay0_dip; + meta.encap_data.dash_encapsulation = underlay0_dash_encapsulation; + meta.encap_data.underlay_smac = underlay0_smac; + meta.encap_data.underlay_dmac = underlay0_dmac; + + meta.tunnel_data.vni = underlay1_vnet_id; + meta.tunnel_data.underlay_sip = underlay1_sip; + meta.tunnel_data.underlay_dip = underlay1_dip; + meta.tunnel_data.dash_encapsulation = underlay1_dash_encapsulation; + meta.tunnel_data.underlay_smac = underlay1_smac; + meta.tunnel_data.underlay_dmac = underlay1_dmac; /* Set overlay rewrite metadata */ - meta.overlay_data.is_ipv6 = overlay_data_is_ipv6; - meta.overlay_data.dmac = overlay_data_dst_mac; - meta.overlay_data.sip = overlay_data_sip; - meta.overlay_data.dip = overlay_data_dip; - meta.overlay_data.sip_mask = overlay_data_sip_mask; - meta.overlay_data.dip_mask = overlay_data_dip_mask; + meta.overlay_data.dmac = dst_mac; + meta.overlay_data.sip = sip; + meta.overlay_data.dip = dip; + meta.overlay_data.sip_mask = sip_mask; + meta.overlay_data.dip_mask = dip_mask; + meta.overlay_data.is_ipv6 = is_ipv6; } action flow_miss() { - meta.flow_state = dash_flow_state_t.FLOW_MISS; + meta.flow_data.sync_state = dash_flow_sync_state_t.FLOW_MISS; } @SaiTable[name = "flow", api = "dash_flow", order = 1, enable_bulk_get_api = "true", enable_bulk_get_server = "true"] diff --git a/documentation/dataplane/dash-flow-api.md b/documentation/dataplane/dash-flow-api.md index 5710bce10..bb5286728 100644 --- a/documentation/dataplane/dash-flow-api.md +++ b/documentation/dataplane/dash-flow-api.md @@ -3,6 +3,7 @@ | Rev | Date | Author | Change Description | | --- | ---- | ------ | ------------------ | | 0.1 | 03/20/2024 | Zhixiong Niu | Initial version | +| 0.2 | 09/10/2024 | Junhua Zhai | Added flow attributes - flow_sync_state, underlay0 SMAC/DMAC | ## Table of Contents @@ -207,6 +208,7 @@ These are the basic attributes of flow entry. | SAI_FLOW_ENTRY_ATTR_DASH_FLOW_ACTION | `sai_dash_flow_action_t` | Action to be applied on the flow | | SAI_FLOW_ENTRY_ATTR_METER_CLASS | `sai_uint32_t` | Meter class for flow entry, used for traffic metering and policing. | | SAI_FLOW_ENTRY_ATTR_IS_UNIDIRECTIONAL_FLOW | `bool` | Indicates if the flow is unidirectional | +| SAI_FLOW_ENTRY_ATTR_DASH_FLOW_SYNC_STATE | `sai_dash_flow_sync_state_t` | [Flow sync state](https://github.com/sonic-net/DASH/blob/main/documentation/high-avail/ha-api-hld.md#44-flow) | #### Reverse flow key @@ -231,6 +233,8 @@ These are the related attributes of flow encapsulation. | SAI_FLOW_ENTRY_ATTR_UNDERLAY0_VNI | `sai_uint32_t` | Destination VNI in the underlay network | | SAI_FLOW_ENTRY_ATTR_UNDERLAY0_SIP | `sai_uint32_t` | Source IP address in the underlay network | | SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DIP | `sai_uint32_t` | Destination IP address in the underlay network | +| SAI_FLOW_ENTRY_ATTR_UNDERLAY0_SMAC | `sai_mac_t` | Source MAC address in the underlay network | +| SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DMAC | `sai_mac_t` | Destination MAC address in the underlay network | | SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DASH_ENCAPSULATION | `sai_dash_encapsulation_t` | Encapsulation method for DASH traffic in the underlay network | | SAI_FLOW_ENTRY_ATTR_UNDERLAY1_VNI | `sai_uint32_t` | Destination VNI in the 2nd underlay network | | SAI_FLOW_ENTRY_ATTR_UNDERLAY1_SIP | `sai_uint32_t` | Source IP address in the 2nd underlay network | diff --git a/documentation/high-avail/ha-api-hld.md b/documentation/high-avail/ha-api-hld.md index 30406b894..39aff79ab 100644 --- a/documentation/high-avail/ha-api-hld.md +++ b/documentation/high-avail/ha-api-hld.md @@ -9,6 +9,7 @@ | 0.5 | 04/08/2024 | Riff Jiang | Added support for bulk sync. | | 0.6 | 04/09/2024 | Riff Jiang | Added support for flow reconcile for planned and unplanned switchover. | | 0.7 | 06/20/2024 | Mukesh Velayudhan | Added DPU scope DPU driven attributes and description. | +| 0.8 | 09/10/2024 | Junhua Zhai| Updated flow attr name and type for flow sync state. | 1. [1. Terminology](#1-terminology) 2. [2. Background](#2-background) @@ -175,20 +176,20 @@ To support HA, each flow contains the following SAI attributes: | Attribute name | Type | Description | | -------------- | ---- | ----------- | -| SAI_FLOW_ATTR_FLOW_VERSION | `sai_uint32_t` | The flow version. | -| SAI_FLOW_ATTR_FLOW_SYNC_STATE | `sai_dash_ha_flow_sync_state_t` | The flow sync state. | +| SAI_FLOW_ENTRY_ATTR_VERSION | `sai_uint32_t` | The flow version. | +| SAI_FLOW_ENTRY_ATTR_DASH_FLOW_SYNC_STATE | `sai_dash_flow_sync_state_t` | The flow sync state. | The flow sync state is defined as below: ```c -typedef enum _sai_dash_ha_flow_sync_state_t +typedef enum _sai_dash_flow_sync_state_t { - SAI_DASH_HA_FLOW_SYNC_STATE_FLOW_MISS, - SAI_DASH_HA_FLOW_SYNC_STATE_FLOW_CREATED, - SAI_DASH_HA_FLOW_SYNC_STATE_FLOW_SYNCED, - SAI_DASH_HA_FLOW_SYNC_STATE_FLOW_PENDING_DELETE, - SAI_DASH_HA_FLOW_SYNC_STATE_FLOW_PENDING_RESIMULATION -} sai_dash_ha_flow_sync_state_t; + SAI_DASH_FLOW_SYNC_STATE_FLOW_MISS, + SAI_DASH_FLOW_SYNC_STATE_FLOW_CREATED, + SAI_DASH_FLOW_SYNC_STATE_FLOW_SYNCED, + SAI_DASH_FLOW_SYNC_STATE_FLOW_PENDING_DELETE, + SAI_DASH_FLOW_SYNC_STATE_FLOW_PENDING_RESIMULATION +} sai_dash_flow_sync_state_t; ``` The flow sync state is a small state machine that represents if the flow is synched or not, so we can make the packet processing decision accordingly to achieve HA. From bceb710dddf42ad846c59de1375cc3875ae26925 Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Fri, 18 Oct 2024 06:13:46 +0000 Subject: [PATCH 11/18] Implement flow actions, being same as routing actions --- dash-pipeline/SAI/specs/dash_tunnel.yaml | 4 +- dash-pipeline/SAI/specs/sai_spec.yaml | 36 +++++++ dash-pipeline/bmv2/dash_headers.p4 | 11 +- dash-pipeline/bmv2/dash_inbound.p4 | 1 - dash-pipeline/bmv2/dash_metadata.p4 | 10 +- dash-pipeline/bmv2/dash_parser.p4 | 7 +- dash-pipeline/bmv2/dash_pipeline.p4 | 9 +- dash-pipeline/bmv2/dash_routing_types.p4 | 48 +++++---- dash-pipeline/bmv2/dash_tunnel.p4 | 13 --- .../routing_action_encap_underlay.p4 | 102 ++++++++++++++++++ .../routing_actions/routing_action_set_mac.p4 | 43 ++++++++ .../routing_action_static_encap.p4 | 60 ----------- .../bmv2/routing_actions/routing_actions.p4 | 5 +- dash-pipeline/bmv2/stages/conntrack_lookup.p4 | 6 +- .../outbound_pre_routing_action_apply.p4 | 6 +- .../bmv2/stages/routing_action_apply.p4 | 5 +- dash-pipeline/bmv2/stages/tunnel_stage.p4 | 43 ++++---- 17 files changed, 262 insertions(+), 147 deletions(-) create mode 100644 dash-pipeline/bmv2/routing_actions/routing_action_encap_underlay.p4 create mode 100644 dash-pipeline/bmv2/routing_actions/routing_action_set_mac.p4 delete mode 100644 dash-pipeline/bmv2/routing_actions/routing_action_static_encap.p4 diff --git a/dash-pipeline/SAI/specs/dash_tunnel.yaml b/dash-pipeline/SAI/specs/dash_tunnel.yaml index 30a8fdd08..d9fe8e4f3 100644 --- a/dash-pipeline/SAI/specs/dash_tunnel.yaml +++ b/dash-pipeline/SAI/specs/dash_tunnel.yaml @@ -53,9 +53,9 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 34128771 + id: 49206552 actions: default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: default - id: 18727423 + id: 27084508 attr_param_id: {} diff --git a/dash-pipeline/SAI/specs/sai_spec.yaml b/dash-pipeline/SAI/specs/sai_spec.yaml index 39943cb74..058d29cbb 100644 --- a/dash-pipeline/SAI/specs/sai_spec.yaml +++ b/dash-pipeline/SAI/specs/sai_spec.yaml @@ -331,6 +331,42 @@ enums: name: NONE description: '' value: '0' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: ENCAP_U0 + description: '' + value: '1' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: ENCAP_U1 + description: '' + value: '2' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: SET_SMAC + description: '' + value: '4' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: SET_DMAC + description: '' + value: '8' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: NAT + description: '' + value: '16' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: NAT46 + description: '' + value: '32' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: NAT64 + description: '' + value: '64' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: NAT_PORT + description: '' + value: '128' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: REVERSE_TUNNEL + description: '' + value: '256' - !!python/object:utils.sai_spec.sai_enum.SaiEnum name: sai_dash_ha_state_t description: '' diff --git a/dash-pipeline/bmv2/dash_headers.p4 b/dash-pipeline/bmv2/dash_headers.p4 index 061217773..e077e5502 100644 --- a/dash-pipeline/bmv2/dash_headers.p4 +++ b/dash-pipeline/bmv2/dash_headers.p4 @@ -163,7 +163,16 @@ enum bit<8> dash_flow_sync_state_t { } enum bit<32> dash_flow_action_t { - NONE = 0 + NONE = 0, + ENCAP_U0 = (1 << 0), + ENCAP_U1 = (1 << 1), + SET_SMAC = (1 << 2), + SET_DMAC = (1 << 3), + NAT = (1 << 4), + NAT46 = (1 << 5), + NAT64 = (1 << 6), + NAT_PORT = (1 << 7), + REVERSE_TUNNEL = (1 << 8) } enum bit<16> dash_flow_enabled_key_t { diff --git a/dash-pipeline/bmv2/dash_inbound.p4 b/dash-pipeline/bmv2/dash_inbound.p4 index 14c39590c..9aec57685 100644 --- a/dash-pipeline/bmv2/dash_inbound.p4 +++ b/dash-pipeline/bmv2/dash_inbound.p4 @@ -39,7 +39,6 @@ control inbound(inout headers_t hdr, do_tunnel_encap(hdr, meta, - meta.overlay_data.dmac, meta.encap_data.underlay_dmac, meta.encap_data.underlay_smac, meta.encap_data.underlay_dip, diff --git a/dash-pipeline/bmv2/dash_metadata.p4 b/dash-pipeline/bmv2/dash_metadata.p4 index 2f66db0e6..5a18cd6e2 100644 --- a/dash-pipeline/bmv2/dash_metadata.p4 +++ b/dash-pipeline/bmv2/dash_metadata.p4 @@ -6,15 +6,7 @@ #define MAX_ENI 64 #define MAX_HA_SET 1 -enum bit<32> dash_routing_actions_t { - STATIC_ENCAP = (1 << 0), - NAT = (1 << 1), - NAT46 = (1 << 2), - NAT64 = (1 << 3), - NAT_PORT = (1 << 4), - TUNNEL = (1 << 5), - REVERSE_TUNNEL = (1 << 6) -}; +typedef dash_flow_action_t dash_routing_actions_t; // Pipeline stages: enum bit<16> dash_pipeline_stage_t { diff --git a/dash-pipeline/bmv2/dash_parser.p4 b/dash-pipeline/bmv2/dash_parser.p4 index 69a728531..d9f0b17de 100644 --- a/dash-pipeline/bmv2/dash_parser.p4 +++ b/dash-pipeline/bmv2/dash_parser.p4 @@ -62,12 +62,13 @@ parser dash_parser( packet.extract(hd.flow_overlay_data); } - if (hd.flow_data.actions & dash_routing_actions_t.STATIC_ENCAP != 0) { + if (hd.flow_data.actions & dash_routing_actions_t.ENCAP_U0 != 0) { packet.extract(hd.flow_encap_data); } - // FIXME: assume no tunnel data - // packet.extract(hd.flow_tunnel_data); + if (hd.flow_data.actions & dash_routing_actions_t.ENCAP_U1 != 0) { + packet.extract(hd.flow_tunnel_data); + } } transition parse_customer_ethernet; diff --git a/dash-pipeline/bmv2/dash_pipeline.p4 b/dash-pipeline/bmv2/dash_pipeline.p4 index b7d61c003..f101f12d6 100644 --- a/dash-pipeline/bmv2/dash_pipeline.p4 +++ b/dash-pipeline/bmv2/dash_pipeline.p4 @@ -168,6 +168,8 @@ control dash_lookup_stage( if (meta.is_fast_path_icmp_flow_redirection_packet) { UPDATE_ENI_COUNTER(eni_lb_fast_path_icmp_in); } + + do_tunnel_decap(hdr, meta); } } @@ -209,7 +211,6 @@ control dash_match_stage( inbound.apply(hdr, meta); } - tunnel_stage.apply(hdr, meta); } } @@ -259,7 +260,7 @@ control dash_ingress( #endif // DPDK_PNA_SEND_TO_PORT_FIX_MERGED #endif // TARGET_DPDK_PNA - // If packet is from DPAPP, just do conntrack_lookup + // If packet is from DPAPP, not do common lookup if (hdr.packet_meta.packet_source != dash_packet_source_t.DPAPP) { dash_lookup_stage.apply(hdr, meta); } @@ -271,8 +272,6 @@ control dash_ingress( conntrack_lookup_stage.apply(hdr, meta); } - do_tunnel_decap(hdr, meta); - ha_stage.apply(hdr, meta); if (!meta.flow_enabled || @@ -303,8 +302,6 @@ control dash_ingress( routing_action_apply.apply(hdr, meta); - tunnel_stage_encap.apply(hdr, meta); - /* Underlay routing */ meta.dst_ip_addr = (bit<128>)hdr.u0_ipv4.dst_addr; diff --git a/dash-pipeline/bmv2/dash_routing_types.p4 b/dash-pipeline/bmv2/dash_routing_types.p4 index ee2d4fa3f..dca3d1f52 100644 --- a/dash-pipeline/bmv2/dash_routing_types.p4 +++ b/dash-pipeline/bmv2/dash_routing_types.p4 @@ -123,14 +123,16 @@ action route_service_tunnel( #ifndef DISABLE_128BIT_ARITHMETIC // As of 2024-Feb-09, p4c-dpdk does not yet support arithmetic on 128-bit operands. // This lack of support extends to cast operations. - push_action_static_encap(hdr = hdr, - meta = meta, - encap = dash_encapsulation, - vni = tunnel_key, - underlay_sip = underlay_sip == 0 ? hdr.u0_ipv4.src_addr : (IPv4Address)underlay_sip, - underlay_dip = underlay_dip == 0 ? hdr.u0_ipv4.dst_addr : (IPv4Address)underlay_dip, - overlay_dmac = hdr.u0_ethernet.dst_addr); - + push_action_set_dmac(hdr, + meta, + hdr.u0_ethernet.dst_addr); + + push_action_encap_u0(hdr = hdr, + meta = meta, + encap = dash_encapsulation, + vni = tunnel_key, + underlay_sip = underlay_sip == 0 ? hdr.u0_ipv4.src_addr : (IPv4Address)underlay_sip, + underlay_dip = underlay_dip == 0 ? hdr.u0_ipv4.dst_addr : (IPv4Address)underlay_dip); #endif set_meter_attrs(meta, meter_class_or, meter_class_and); @@ -154,10 +156,13 @@ action set_tunnel_mapping( if (use_dst_vnet_vni == 1) meta.vnet_id = meta.dst_vnet_id; - push_action_static_encap(hdr = hdr, - meta = meta, - underlay_dip = underlay_dip, - overlay_dmac = overlay_dmac); + push_action_set_dmac(hdr, + meta, + overlay_dmac); + + push_action_encap_u0(hdr = hdr, + meta = meta, + underlay_dip = underlay_dip); set_meter_attrs(meta, meter_class_or, 0xffffffff); } @@ -181,14 +186,17 @@ action set_private_link_mapping( meta.target_stage = dash_pipeline_stage_t.OUTBOUND_PRE_ROUTING_ACTION_APPLY; meta.dash_tunnel_id = dash_tunnel_id; - push_action_static_encap(hdr = hdr, - meta = meta, - encap = dash_encapsulation, - vni = tunnel_key, - // PL has its own underlay SIP, so override - underlay_sip = meta.eni_data.pl_underlay_sip, - underlay_dip = underlay_dip, - overlay_dmac = hdr.u0_ethernet.dst_addr); + push_action_set_dmac(hdr, + meta, + hdr.u0_ethernet.dst_addr); + + push_action_encap_u0(hdr = hdr, + meta = meta, + encap = dash_encapsulation, + vni = tunnel_key, + // PL has its own underlay SIP, so override + underlay_sip = meta.eni_data.pl_underlay_sip, + underlay_dip = underlay_dip); #ifndef DISABLE_128BIT_ARITHMETIC // As of 2024-Feb-09, p4c-dpdk does not yet support arithmetic on diff --git a/dash-pipeline/bmv2/dash_tunnel.p4 b/dash-pipeline/bmv2/dash_tunnel.p4 index 4d39f5e65..d1e4238fe 100644 --- a/dash-pipeline/bmv2/dash_tunnel.p4 +++ b/dash-pipeline/bmv2/dash_tunnel.p4 @@ -6,13 +6,11 @@ #ifdef TARGET_BMV2_V1MODEL #define PUSH_VXLAN_TUNNEL_DEF(underlay_id, overlay_id) \ action push_vxlan_tunnel_ ## underlay_id ## (inout headers_t hdr, \ - in EthernetAddress overlay_dmac, \ in EthernetAddress underlay_dmac, \ in EthernetAddress underlay_smac, \ in IPv4Address underlay_dip, \ in IPv4Address underlay_sip, \ in bit<24> tunnel_key) { \ - hdr. ## overlay_id ## _ethernet.dst_addr = (overlay_dmac == 0) ? hdr. ## overlay_id ## _ethernet.dst_addr : overlay_dmac; \ hdr. ## underlay_id ## _ethernet.setValid(); \ hdr. ## underlay_id ## _ethernet.dst_addr = underlay_dmac; \ hdr. ## underlay_id ## _ethernet.src_addr = underlay_smac; \ @@ -60,13 +58,11 @@ action push_vxlan_tunnel_ ## underlay_id ## (inout headers_t hdr, \ #ifdef TARGET_DPDK_PNA #define PUSH_VXLAN_TUNNEL_DEF(underlay_id, overlay_id) \ action push_vxlan_tunnel_ ## underlay_id ## (inout headers_t hdr, \ - in EthernetAddress overlay_dmac, \ in EthernetAddress underlay_dmac, \ in EthernetAddress underlay_smac, \ in IPv4Address underlay_dip, \ in IPv4Address underlay_sip, \ in bit<24> tunnel_key) { \ - hdr. ## overlay_id ## _ethernet.dst_addr = overlay_dmac; \ hdr. ## underlay_id ## _ethernet.setValid(); \ hdr. ## underlay_id ## _ethernet.dst_addr = underlay_dmac; \ hdr. ## underlay_id ## _ethernet.src_addr = underlay_smac; \ @@ -113,13 +109,11 @@ action push_vxlan_tunnel_ ## underlay_id ## (inout headers_t hdr, \ #ifdef TARGET_BMV2_V1MODEL #define PUSH_NVGRE_TUNNEL_DEF(underlay_id, overlay_id) \ action push_nvgre_tunnel_ ## underlay_id ## (inout headers_t hdr, \ - in EthernetAddress overlay_dmac, \ in EthernetAddress underlay_dmac, \ in EthernetAddress underlay_smac, \ in IPv4Address underlay_dip, \ in IPv4Address underlay_sip, \ in bit<24> tunnel_key) { \ - hdr. ## overlay_id ## _ethernet.dst_addr = overlay_dmac; \ hdr. ## underlay_id ## _ethernet.setValid(); \ hdr. ## underlay_id ## _ethernet.dst_addr = underlay_dmac; \ hdr. ## underlay_id ## _ethernet.src_addr = underlay_smac; \ @@ -159,13 +153,11 @@ action push_nvgre_tunnel_ ## underlay_id ## (inout headers_t hdr, \ #ifdef TARGET_DPDK_PNA #define PUSH_NVGRE_TUNNEL_DEF(underlay_id, overlay_id) \ action push_nvgre_tunnel_ ## underlay_id ## (inout headers_t hdr, \ - in EthernetAddress overlay_dmac, \ in EthernetAddress underlay_dmac, \ in EthernetAddress underlay_smac, \ in IPv4Address underlay_dip, \ in IPv4Address underlay_sip, \ in bit<24> tunnel_key) { \ - hdr. ## overlay_id ## _ethernet.dst_addr = overlay_dmac; \ hdr. ## underlay_id ## _ethernet.setValid(); \ hdr. ## underlay_id ## _ethernet.dst_addr = underlay_dmac; \ hdr. ## underlay_id ## _ethernet.src_addr = underlay_smac; \ @@ -213,7 +205,6 @@ PUSH_NVGRE_TUNNEL_DEF(u1, u0) #define do_tunnel_encap(hdr, \ meta, \ - overlay_dmac, \ underlay_dmac, \ underlay_smac, \ underlay_dip, \ @@ -223,7 +214,6 @@ PUSH_NVGRE_TUNNEL_DEF(u1, u0) if (dash_encapsulation == dash_encapsulation_t.VXLAN) { \ if (meta.tunnel_pointer == 0) { \ push_vxlan_tunnel_u0(hdr, \ - overlay_dmac, \ underlay_dmac, \ underlay_smac, \ underlay_dip, \ @@ -231,7 +221,6 @@ PUSH_NVGRE_TUNNEL_DEF(u1, u0) tunnel_key); \ } else if (meta.tunnel_pointer == 1) { \ push_vxlan_tunnel_u1(hdr, \ - overlay_dmac, \ underlay_dmac, \ underlay_smac, \ underlay_dip, \ @@ -241,7 +230,6 @@ PUSH_NVGRE_TUNNEL_DEF(u1, u0) } else if (dash_encapsulation == dash_encapsulation_t.NVGRE) { \ if (meta.tunnel_pointer == 0) { \ push_nvgre_tunnel_u0(hdr, \ - overlay_dmac, \ underlay_dmac, \ underlay_smac, \ underlay_dip, \ @@ -249,7 +237,6 @@ PUSH_NVGRE_TUNNEL_DEF(u1, u0) tunnel_key); \ } else if (meta.tunnel_pointer == 1) { \ push_nvgre_tunnel_u1(hdr, \ - overlay_dmac, \ underlay_dmac, \ underlay_smac, \ underlay_dip, \ diff --git a/dash-pipeline/bmv2/routing_actions/routing_action_encap_underlay.p4 b/dash-pipeline/bmv2/routing_actions/routing_action_encap_underlay.p4 new file mode 100644 index 000000000..50027b4fc --- /dev/null +++ b/dash-pipeline/bmv2/routing_actions/routing_action_encap_underlay.p4 @@ -0,0 +1,102 @@ +#ifndef _DASH_ROUTING_ACTION_ENCAP_UNDERLAY_P4_ +#define _DASH_ROUTING_ACTION_ENCAP_UNDERLAY_P4_ + +action push_action_encap_u0( + in headers_t hdr, + inout metadata_t meta, + in dash_encapsulation_t encap = dash_encapsulation_t.VXLAN, + in bit<24> vni = 0, + in IPv4Address underlay_sip = 0, + in IPv4Address underlay_dip = 0, + in EthernetAddress underlay_smac = 0, + in EthernetAddress underlay_dmac = 0) +{ + meta.routing_actions = meta.routing_actions | dash_routing_actions_t.ENCAP_U0; + + meta.encap_data.dash_encapsulation = encap; + meta.encap_data.vni = vni == 0 ? meta.encap_data.vni : vni; + + meta.encap_data.underlay_smac = underlay_smac == 0 ? meta.encap_data.underlay_smac : underlay_smac; + meta.encap_data.underlay_dmac = underlay_dmac == 0 ? meta.encap_data.underlay_dmac : underlay_dmac; + meta.encap_data.underlay_sip = underlay_sip == 0 ? meta.encap_data.underlay_sip : underlay_sip; + meta.encap_data.underlay_dip = underlay_dip == 0 ? meta.encap_data.underlay_dip : underlay_dip; +} + +action push_action_encap_u1( + in headers_t hdr, + inout metadata_t meta, + in dash_encapsulation_t encap = dash_encapsulation_t.VXLAN, + in bit<24> vni = 0, + in IPv4Address underlay_sip = 0, + in IPv4Address underlay_dip = 0, + in EthernetAddress underlay_smac = 0, + in EthernetAddress underlay_dmac = 0) +{ + meta.routing_actions = meta.routing_actions | dash_routing_actions_t.ENCAP_U1; + + meta.tunnel_data.dash_encapsulation = encap; + meta.tunnel_data.vni = vni == 0 ? meta.tunnel_data.vni : vni; + + meta.tunnel_data.underlay_smac = underlay_smac == 0 ? meta.tunnel_data.underlay_smac : underlay_smac; + meta.tunnel_data.underlay_dmac = underlay_dmac == 0 ? meta.tunnel_data.underlay_dmac : underlay_dmac; + meta.tunnel_data.underlay_sip = underlay_sip == 0 ? meta.tunnel_data.underlay_sip : underlay_sip; + meta.tunnel_data.underlay_dip = underlay_dip == 0 ? meta.tunnel_data.underlay_dip : underlay_dip; +} + +control do_action_encap_u0( + inout headers_t hdr, + inout metadata_t meta) +{ + apply { + if (meta.routing_actions & dash_routing_actions_t.ENCAP_U0 == 0) { + return; + } + + if (meta.encap_data.dash_encapsulation == dash_encapsulation_t.VXLAN) { + push_vxlan_tunnel_u0(hdr, + meta.encap_data.underlay_dmac, + meta.encap_data.underlay_smac, + meta.encap_data.underlay_dip, + meta.encap_data.underlay_sip, + meta.encap_data.vni); + } + else if (meta.encap_data.dash_encapsulation == dash_encapsulation_t.NVGRE) { + push_vxlan_tunnel_u0(hdr, + meta.encap_data.underlay_dmac, + meta.encap_data.underlay_smac, + meta.encap_data.underlay_dip, + meta.encap_data.underlay_sip, + meta.encap_data.vni); + } + } +} + +control do_action_encap_u1( + inout headers_t hdr, + inout metadata_t meta) +{ + apply { + if (meta.routing_actions & dash_routing_actions_t.ENCAP_U1 == 0) { + return; + } + + if (meta.encap_data.dash_encapsulation == dash_encapsulation_t.VXLAN) { + push_vxlan_tunnel_u1(hdr, + meta.encap_data.underlay_dmac, + meta.encap_data.underlay_smac, + meta.encap_data.underlay_dip, + meta.encap_data.underlay_sip, + meta.encap_data.vni); + } + else if (meta.encap_data.dash_encapsulation == dash_encapsulation_t.NVGRE) { + push_vxlan_tunnel_u1(hdr, + meta.encap_data.underlay_dmac, + meta.encap_data.underlay_smac, + meta.encap_data.underlay_dip, + meta.encap_data.underlay_sip, + meta.encap_data.vni); + } + } +} + +#endif /* _DASH_ROUTING_ACTION_ENCAP_UNDERLAY_P4_ */ diff --git a/dash-pipeline/bmv2/routing_actions/routing_action_set_mac.p4 b/dash-pipeline/bmv2/routing_actions/routing_action_set_mac.p4 new file mode 100644 index 000000000..03963d9af --- /dev/null +++ b/dash-pipeline/bmv2/routing_actions/routing_action_set_mac.p4 @@ -0,0 +1,43 @@ +#ifndef _DASH_ROUTING_ACTION_SET_MAC_P4_ +#define _DASH_ROUTING_ACTION_SET_MAC_P4_ + +action push_action_set_smac( + in headers_t hdr, + inout metadata_t meta, + in EthernetAddress overlay_dmac) +{ + // not used by now +} + +action push_action_set_dmac( + in headers_t hdr, + inout metadata_t meta, + in EthernetAddress overlay_dmac) +{ + meta.routing_actions = meta.routing_actions | dash_routing_actions_t.SET_DMAC; + meta.overlay_data.dmac = overlay_dmac; +} + +control do_action_set_smac( + inout headers_t hdr, + inout metadata_t meta) +{ + apply { + // not used by now + } +} + +control do_action_set_dmac( + inout headers_t hdr, + inout metadata_t meta) +{ + apply { + if (meta.routing_actions & dash_routing_actions_t.SET_DMAC == 0) { + return; + } + + hdr.customer_ethernet.dst_addr = meta.overlay_data.dmac; + } +} + +#endif /* _DASH_ROUTING_ACTION_SET_MAC_P4_ */ diff --git a/dash-pipeline/bmv2/routing_actions/routing_action_static_encap.p4 b/dash-pipeline/bmv2/routing_actions/routing_action_static_encap.p4 deleted file mode 100644 index 17d37cd0d..000000000 --- a/dash-pipeline/bmv2/routing_actions/routing_action_static_encap.p4 +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef _DASH_ROUTING_ACTION_STATIC_ENCAP_P4_ -#define _DASH_ROUTING_ACTION_STATIC_ENCAP_P4_ - -action push_action_static_encap( - in headers_t hdr, - inout metadata_t meta, - in dash_encapsulation_t encap = dash_encapsulation_t.VXLAN, - in bit<24> vni = 0, - in IPv4Address underlay_sip = 0, - in IPv4Address underlay_dip = 0, - in EthernetAddress underlay_smac = 0, - in EthernetAddress underlay_dmac = 0, - in EthernetAddress overlay_dmac = 0) -{ - meta.routing_actions = meta.routing_actions | dash_routing_actions_t.STATIC_ENCAP; - - meta.encap_data.dash_encapsulation = encap; - meta.encap_data.vni = vni == 0 ? meta.encap_data.vni : vni; - - meta.encap_data.underlay_smac = underlay_smac == 0 ? meta.encap_data.underlay_smac : underlay_smac; - meta.encap_data.underlay_dmac = underlay_dmac == 0 ? meta.encap_data.underlay_dmac : underlay_dmac; - meta.encap_data.underlay_sip = underlay_sip == 0 ? meta.encap_data.underlay_sip : underlay_sip; - meta.encap_data.underlay_dip = underlay_dip == 0 ? meta.encap_data.underlay_dip : underlay_dip; - - meta.overlay_data.dmac = overlay_dmac == 0 ? meta.overlay_data.dmac : overlay_dmac; -} - -control do_action_static_encap( - inout headers_t hdr, - inout metadata_t meta) -{ - apply { - if (meta.routing_actions & dash_routing_actions_t.STATIC_ENCAP == 0) { - return; - } - - if (meta.encap_data.dash_encapsulation == dash_encapsulation_t.VXLAN) { - push_vxlan_tunnel_u0(hdr, - meta.overlay_data.dmac, - meta.encap_data.underlay_dmac, - meta.encap_data.underlay_smac, - meta.encap_data.underlay_dip, - meta.encap_data.underlay_sip, - meta.encap_data.vni); - } - else if (meta.encap_data.dash_encapsulation == dash_encapsulation_t.NVGRE) { - push_vxlan_tunnel_u0(hdr, - meta.overlay_data.dmac, - meta.encap_data.underlay_dmac, - meta.encap_data.underlay_smac, - meta.encap_data.underlay_dip, - meta.encap_data.underlay_sip, - meta.encap_data.vni); - } - - meta.tunnel_pointer = meta.tunnel_pointer + 1; - } -} - -#endif /* _DASH_ROUTING_ACTION_STATIC_ENCAP_P4_ */ diff --git a/dash-pipeline/bmv2/routing_actions/routing_actions.p4 b/dash-pipeline/bmv2/routing_actions/routing_actions.p4 index 3dbaa49c8..eb228c9a4 100644 --- a/dash-pipeline/bmv2/routing_actions/routing_actions.p4 +++ b/dash-pipeline/bmv2/routing_actions/routing_actions.p4 @@ -1,8 +1,9 @@ #ifndef _DASH_ROUTING_ACTIONS_P4_ #define _DASH_ROUTING_ACTIONS_P4_ -#include "routing_action_static_encap.p4" +#include "routing_action_encap_underlay.p4" +#include "routing_action_set_mac.p4" #include "routing_action_nat46.p4" #include "routing_action_nat64.p4" -#endif /* _DASH_ROUTING_ACTIONS_P4_ */ \ No newline at end of file +#endif /* _DASH_ROUTING_ACTIONS_P4_ */ diff --git a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 index 78d63344e..1c690fa11 100644 --- a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 +++ b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 @@ -73,7 +73,7 @@ control conntrack_build_dash_header(inout headers_t hdr, in metadata_t meta, hdr.flow_data.meter_class = meta.meter_class; length = length + FLOW_DATA_HDR_SIZE; - if (meta.routing_actions & dash_routing_actions_t.STATIC_ENCAP != 0) { + if (meta.routing_actions & dash_routing_actions_t.ENCAP_U0 != 0) { #ifdef TARGET_DPDK_PNA hdr.flow_encap_data.setValid(); hdr.flow_encap_data.vni = meta.encap_data.vni; @@ -88,7 +88,7 @@ control conntrack_build_dash_header(inout headers_t hdr, in metadata_t meta, length = length + ENCAP_DATA_HDR_SIZE; } - if (meta.dash_tunnel_id != 0) { + if (meta.routing_actions & dash_routing_actions_t.ENCAP_U1 != 0) { #ifdef TARGET_DPDK_PNA hdr.flow_tunnel_data.setValid(); hdr.flow_tunnel_data.vni = meta.tunnel_data.vni; @@ -273,7 +273,7 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { /* Also set basic metadata */ meta.direction = dash_direction; - meta.routing_actions = (bit<32>)dash_flow_action; + meta.routing_actions = dash_flow_action; meta.meter_class = meter_class; /* Reverse flow key is not used by now */ diff --git a/dash-pipeline/bmv2/stages/outbound_pre_routing_action_apply.p4 b/dash-pipeline/bmv2/stages/outbound_pre_routing_action_apply.p4 index 74329f13d..5b536e959 100644 --- a/dash-pipeline/bmv2/stages/outbound_pre_routing_action_apply.p4 +++ b/dash-pipeline/bmv2/stages/outbound_pre_routing_action_apply.p4 @@ -1,6 +1,8 @@ #ifndef _DASH_STAGE_OUTBOUND_PRE_ROUTING_ACTION_APPLY_P4_ #define _DASH_STAGE_OUTBOUND_PRE_ROUTING_ACTION_APPLY_P4_ +#include "tunnel_stage.p4" + control outbound_pre_routing_action_apply_stage( inout headers_t hdr, inout metadata_t meta) @@ -11,9 +13,11 @@ control outbound_pre_routing_action_apply_stage( return; } + tunnel_stage.apply(hdr, meta); + // Once it is done, move to routing action apply stage. meta.target_stage = dash_pipeline_stage_t.ROUTING_ACTION_APPLY; } } -#endif /* _DASH_STAGE_OUTBOUND_PRE_ROUTING_ACTION_APPLY_P4_ */ \ No newline at end of file +#endif /* _DASH_STAGE_OUTBOUND_PRE_ROUTING_ACTION_APPLY_P4_ */ diff --git a/dash-pipeline/bmv2/stages/routing_action_apply.p4 b/dash-pipeline/bmv2/stages/routing_action_apply.p4 index 9543060fd..bb54c4245 100644 --- a/dash-pipeline/bmv2/stages/routing_action_apply.p4 +++ b/dash-pipeline/bmv2/stages/routing_action_apply.p4 @@ -2,7 +2,6 @@ #define _DASH_STAGE_ACTION_APPLY_P4_ #include "../routing_actions/routing_actions.p4" -#include "tunnel_stage.p4" control routing_action_apply( inout headers_t hdr, @@ -11,11 +10,13 @@ control routing_action_apply( apply { do_action_nat46.apply(hdr, meta); do_action_nat64.apply(hdr, meta); + do_action_set_dmac.apply(hdr, meta); // Encaps needs to be added after all other transforms, from inner ones to outer ones, // because it requires the transforms on the inner packet to be finished in order to // get the correct inner packet size and other informations. - do_action_static_encap.apply(hdr, meta); + do_action_encap_u0.apply(hdr, meta); + do_action_encap_u1.apply(hdr, meta); } } diff --git a/dash-pipeline/bmv2/stages/tunnel_stage.p4 b/dash-pipeline/bmv2/stages/tunnel_stage.p4 index bf8b878ab..24c8bec85 100644 --- a/dash-pipeline/bmv2/stages/tunnel_stage.p4 +++ b/dash-pipeline/bmv2/stages/tunnel_stage.p4 @@ -11,13 +11,24 @@ control tunnel_stage( @SaiVal[type="sai_dash_encapsulation_t", default_value="SAI_DASH_ENCAPSULATION_VXLAN"] dash_encapsulation_t dash_encapsulation, bit<24> tunnel_key) { - push_action_static_encap(hdr = hdr, - meta = meta, - encap = dash_encapsulation, - vni = tunnel_key, - underlay_sip = hdr.u0_ipv4.src_addr, - underlay_dip = dip, - overlay_dmac = hdr.u0_ethernet.dst_addr); + if (meta.routing_actions & dash_routing_actions_t.ENCAP_U0 == 0) { + meta.tunnel_pointer = 0; + push_action_encap_u0(hdr = hdr, + meta = meta, + encap = dash_encapsulation, + vni = tunnel_key, + underlay_sip = hdr.customer_ipv4.src_addr, + underlay_dip = dip); + } + else { + meta.tunnel_pointer = 1; + push_action_encap_u1(hdr = hdr, + meta = meta, + encap = dash_encapsulation, + vni = tunnel_key, + underlay_sip = hdr.u0_ipv4.src_addr, + underlay_dip = dip); + } } @SaiTable[name = "dash_tunnel", api = "dash_tunnel", order = 0, isobject="true"] @@ -31,25 +42,9 @@ control tunnel_stage( } } - apply { - tunnel.apply(); - } -} - -control tunnel_stage_encap( - inout headers_t hdr, - inout metadata_t meta) -{ apply { if (meta.dash_tunnel_id != 0) { - do_tunnel_encap(hdr, meta, - meta.overlay_data.dmac, - meta.tunnel_data.underlay_dmac, - meta.tunnel_data.underlay_smac, - meta.tunnel_data.underlay_dip, - meta.tunnel_data.underlay_sip, - meta.tunnel_data.dash_encapsulation, - meta.tunnel_data.vni); + tunnel.apply(); } } } From 443f27f5d3bc4ccb7ba3df3ee471bde2ee8bff7d Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Fri, 18 Oct 2024 06:40:59 +0000 Subject: [PATCH 12/18] Rename encap_data -> u0_encap_data, tunnel_data -> u1_encap_data --- dash-pipeline/bmv2/dash_headers.p4 | 4 +- dash-pipeline/bmv2/dash_inbound.p4 | 10 +- dash-pipeline/bmv2/dash_metadata.p4 | 12 +-- dash-pipeline/bmv2/dash_parser.p4 | 8 +- dash-pipeline/bmv2/dash_pipeline.p4 | 8 +- .../routing_action_encap_underlay.p4 | 72 +++++++-------- dash-pipeline/bmv2/stages/conntrack_lookup.p4 | 92 +++++++++---------- dash-pipeline/bmv2/stages/outbound_mapping.p4 | 2 +- dash-pipeline/bmv2/stages/pre_pipeline.p4 | 6 +- 9 files changed, 105 insertions(+), 109 deletions(-) diff --git a/dash-pipeline/bmv2/dash_headers.p4 b/dash-pipeline/bmv2/dash_headers.p4 index e077e5502..ca8873963 100644 --- a/dash-pipeline/bmv2/dash_headers.p4 +++ b/dash-pipeline/bmv2/dash_headers.p4 @@ -263,8 +263,8 @@ struct headers_t { flow_key_t flow_key; flow_data_t flow_data; // flow common data overlay_rewrite_data_t flow_overlay_data; - encap_data_t flow_encap_data; - encap_data_t flow_tunnel_data; + encap_data_t flow_u0_encap_data; + encap_data_t flow_u1_encap_data; /* Underlay 1 headers */ ethernet_t u1_ethernet; diff --git a/dash-pipeline/bmv2/dash_inbound.p4 b/dash-pipeline/bmv2/dash_inbound.p4 index 9aec57685..9a087c479 100644 --- a/dash-pipeline/bmv2/dash_inbound.p4 +++ b/dash-pipeline/bmv2/dash_inbound.p4 @@ -39,12 +39,12 @@ control inbound(inout headers_t hdr, do_tunnel_encap(hdr, meta, - meta.encap_data.underlay_dmac, - meta.encap_data.underlay_smac, - meta.encap_data.underlay_dip, - meta.encap_data.underlay_sip, + meta.u0_encap_data.underlay_dmac, + meta.u0_encap_data.underlay_smac, + meta.u0_encap_data.underlay_dip, + meta.u0_encap_data.underlay_sip, dash_encapsulation_t.VXLAN, - meta.encap_data.vni); + meta.u0_encap_data.vni); } } diff --git a/dash-pipeline/bmv2/dash_metadata.p4 b/dash-pipeline/bmv2/dash_metadata.p4 index 5a18cd6e2..5c47df536 100644 --- a/dash-pipeline/bmv2/dash_metadata.p4 +++ b/dash-pipeline/bmv2/dash_metadata.p4 @@ -225,16 +225,12 @@ struct metadata_t { // Action data bool dropped; #ifdef TARGET_DPDK_PNA - // encap_data is for underlay - meta_encap_data_t encap_data; - // tunnel_data is used by dash_tunnel_id - meta_encap_data_t tunnel_data; + meta_encap_data_t u0_encap_data; + meta_encap_data_t u1_encap_data; meta_overlay_rewrite_data_t overlay_data; #else - // encap_data is for underlay - encap_data_t encap_data; - // tunnel_data is used by dash_tunnel_id - encap_data_t tunnel_data; + encap_data_t u0_encap_data; + encap_data_t u1_encap_data; bit<1> enable_reverse_tunnel_learning; IPv4Address reverse_tunnel_sip; overlay_rewrite_data_t overlay_data; diff --git a/dash-pipeline/bmv2/dash_parser.p4 b/dash-pipeline/bmv2/dash_parser.p4 index d9f0b17de..fcb6929f5 100644 --- a/dash-pipeline/bmv2/dash_parser.p4 +++ b/dash-pipeline/bmv2/dash_parser.p4 @@ -63,11 +63,11 @@ parser dash_parser( } if (hd.flow_data.actions & dash_routing_actions_t.ENCAP_U0 != 0) { - packet.extract(hd.flow_encap_data); + packet.extract(hd.flow_u0_encap_data); } if (hd.flow_data.actions & dash_routing_actions_t.ENCAP_U1 != 0) { - packet.extract(hd.flow_tunnel_data); + packet.extract(hd.flow_u1_encap_data); } } @@ -180,8 +180,8 @@ control dash_deparser( packet.emit(hdr.flow_key); packet.emit(hdr.flow_data); packet.emit(hdr.flow_overlay_data); - packet.emit(hdr.flow_encap_data); - packet.emit(hdr.flow_tunnel_data); + packet.emit(hdr.flow_u0_encap_data); + packet.emit(hdr.flow_u1_encap_data); packet.emit(hdr.u0_ethernet); packet.emit(hdr.u0_ipv4); diff --git a/dash-pipeline/bmv2/dash_pipeline.p4 b/dash-pipeline/bmv2/dash_pipeline.p4 index f101f12d6..bca08e76f 100644 --- a/dash-pipeline/bmv2/dash_pipeline.p4 +++ b/dash-pipeline/bmv2/dash_pipeline.p4 @@ -75,14 +75,14 @@ control dash_eni_stage( meta.eni_data.pl_sip = pl_sip; meta.eni_data.pl_sip_mask = pl_sip_mask; meta.eni_data.pl_underlay_sip = pl_underlay_sip; - meta.encap_data.underlay_dip = vm_underlay_dip; + meta.u0_encap_data.underlay_dip = vm_underlay_dip; meta.eni_data.outbound_routing_group_data.outbound_routing_group_id = outbound_routing_group_id; if (dash_tunnel_dscp_mode == dash_tunnel_dscp_mode_t.PIPE_MODEL) { meta.eni_data.dscp = dscp; } /* vm_vni is the encap VNI used for tunnel between inbound DPU -> VM * and not a VNET identifier */ - meta.encap_data.vni = vm_vni; + meta.u0_encap_data.vni = vm_vni; meta.vnet_id = vnet_id; meta.enable_reverse_tunnel_learning = enable_reverse_tunnel_learning; @@ -241,8 +241,8 @@ control dash_ingress( #ifndef TARGET_DPDK_PNA meta.rx_encap.setValid(); meta.flow_data.setValid(); - meta.encap_data.setValid(); - meta.tunnel_data.setValid(); + meta.u0_encap_data.setValid(); + meta.u1_encap_data.setValid(); meta.overlay_data.setValid(); #endif // TARGET_DPDK_PNA diff --git a/dash-pipeline/bmv2/routing_actions/routing_action_encap_underlay.p4 b/dash-pipeline/bmv2/routing_actions/routing_action_encap_underlay.p4 index 50027b4fc..b85c1ba58 100644 --- a/dash-pipeline/bmv2/routing_actions/routing_action_encap_underlay.p4 +++ b/dash-pipeline/bmv2/routing_actions/routing_action_encap_underlay.p4 @@ -13,13 +13,13 @@ action push_action_encap_u0( { meta.routing_actions = meta.routing_actions | dash_routing_actions_t.ENCAP_U0; - meta.encap_data.dash_encapsulation = encap; - meta.encap_data.vni = vni == 0 ? meta.encap_data.vni : vni; + meta.u0_encap_data.dash_encapsulation = encap; + meta.u0_encap_data.vni = vni == 0 ? meta.u0_encap_data.vni : vni; - meta.encap_data.underlay_smac = underlay_smac == 0 ? meta.encap_data.underlay_smac : underlay_smac; - meta.encap_data.underlay_dmac = underlay_dmac == 0 ? meta.encap_data.underlay_dmac : underlay_dmac; - meta.encap_data.underlay_sip = underlay_sip == 0 ? meta.encap_data.underlay_sip : underlay_sip; - meta.encap_data.underlay_dip = underlay_dip == 0 ? meta.encap_data.underlay_dip : underlay_dip; + meta.u0_encap_data.underlay_smac = underlay_smac == 0 ? meta.u0_encap_data.underlay_smac : underlay_smac; + meta.u0_encap_data.underlay_dmac = underlay_dmac == 0 ? meta.u0_encap_data.underlay_dmac : underlay_dmac; + meta.u0_encap_data.underlay_sip = underlay_sip == 0 ? meta.u0_encap_data.underlay_sip : underlay_sip; + meta.u0_encap_data.underlay_dip = underlay_dip == 0 ? meta.u0_encap_data.underlay_dip : underlay_dip; } action push_action_encap_u1( @@ -34,13 +34,13 @@ action push_action_encap_u1( { meta.routing_actions = meta.routing_actions | dash_routing_actions_t.ENCAP_U1; - meta.tunnel_data.dash_encapsulation = encap; - meta.tunnel_data.vni = vni == 0 ? meta.tunnel_data.vni : vni; + meta.u1_encap_data.dash_encapsulation = encap; + meta.u1_encap_data.vni = vni == 0 ? meta.u1_encap_data.vni : vni; - meta.tunnel_data.underlay_smac = underlay_smac == 0 ? meta.tunnel_data.underlay_smac : underlay_smac; - meta.tunnel_data.underlay_dmac = underlay_dmac == 0 ? meta.tunnel_data.underlay_dmac : underlay_dmac; - meta.tunnel_data.underlay_sip = underlay_sip == 0 ? meta.tunnel_data.underlay_sip : underlay_sip; - meta.tunnel_data.underlay_dip = underlay_dip == 0 ? meta.tunnel_data.underlay_dip : underlay_dip; + meta.u1_encap_data.underlay_smac = underlay_smac == 0 ? meta.u1_encap_data.underlay_smac : underlay_smac; + meta.u1_encap_data.underlay_dmac = underlay_dmac == 0 ? meta.u1_encap_data.underlay_dmac : underlay_dmac; + meta.u1_encap_data.underlay_sip = underlay_sip == 0 ? meta.u1_encap_data.underlay_sip : underlay_sip; + meta.u1_encap_data.underlay_dip = underlay_dip == 0 ? meta.u1_encap_data.underlay_dip : underlay_dip; } control do_action_encap_u0( @@ -52,21 +52,21 @@ control do_action_encap_u0( return; } - if (meta.encap_data.dash_encapsulation == dash_encapsulation_t.VXLAN) { + if (meta.u0_encap_data.dash_encapsulation == dash_encapsulation_t.VXLAN) { push_vxlan_tunnel_u0(hdr, - meta.encap_data.underlay_dmac, - meta.encap_data.underlay_smac, - meta.encap_data.underlay_dip, - meta.encap_data.underlay_sip, - meta.encap_data.vni); + meta.u0_encap_data.underlay_dmac, + meta.u0_encap_data.underlay_smac, + meta.u0_encap_data.underlay_dip, + meta.u0_encap_data.underlay_sip, + meta.u0_encap_data.vni); } - else if (meta.encap_data.dash_encapsulation == dash_encapsulation_t.NVGRE) { + else if (meta.u0_encap_data.dash_encapsulation == dash_encapsulation_t.NVGRE) { push_vxlan_tunnel_u0(hdr, - meta.encap_data.underlay_dmac, - meta.encap_data.underlay_smac, - meta.encap_data.underlay_dip, - meta.encap_data.underlay_sip, - meta.encap_data.vni); + meta.u0_encap_data.underlay_dmac, + meta.u0_encap_data.underlay_smac, + meta.u0_encap_data.underlay_dip, + meta.u0_encap_data.underlay_sip, + meta.u0_encap_data.vni); } } } @@ -80,21 +80,21 @@ control do_action_encap_u1( return; } - if (meta.encap_data.dash_encapsulation == dash_encapsulation_t.VXLAN) { + if (meta.u0_encap_data.dash_encapsulation == dash_encapsulation_t.VXLAN) { push_vxlan_tunnel_u1(hdr, - meta.encap_data.underlay_dmac, - meta.encap_data.underlay_smac, - meta.encap_data.underlay_dip, - meta.encap_data.underlay_sip, - meta.encap_data.vni); + meta.u0_encap_data.underlay_dmac, + meta.u0_encap_data.underlay_smac, + meta.u0_encap_data.underlay_dip, + meta.u0_encap_data.underlay_sip, + meta.u0_encap_data.vni); } - else if (meta.encap_data.dash_encapsulation == dash_encapsulation_t.NVGRE) { + else if (meta.u0_encap_data.dash_encapsulation == dash_encapsulation_t.NVGRE) { push_vxlan_tunnel_u1(hdr, - meta.encap_data.underlay_dmac, - meta.encap_data.underlay_smac, - meta.encap_data.underlay_dip, - meta.encap_data.underlay_sip, - meta.encap_data.vni); + meta.u0_encap_data.underlay_dmac, + meta.u0_encap_data.underlay_smac, + meta.u0_encap_data.underlay_dip, + meta.u0_encap_data.underlay_sip, + meta.u0_encap_data.vni); } } } diff --git a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 index 1c690fa11..60d847bff 100644 --- a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 +++ b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 @@ -13,26 +13,26 @@ action conntrack_set_meta_from_dash_header(in headers_t hdr, out metadata_t meta /* encapsulation metadata */ #ifdef TARGET_DPDK_PNA - meta.encap_data.vni = hdr.flow_encap_data.vni; - meta.encap_data.underlay_sip = hdr.flow_encap_data.underlay_sip; - meta.encap_data.underlay_dip = hdr.flow_encap_data.underlay_dip; - meta.encap_data.underlay_smac = hdr.flow_encap_data.underlay_smac; - meta.encap_data.underlay_dmac = hdr.flow_encap_data.underlay_dmac; - meta.encap_data.dash_encapsulation = hdr.flow_encap_data.dash_encapsulation; + meta.u0_encap_data.vni = hdr.flow_u0_encap_data.vni; + meta.u0_encap_data.underlay_sip = hdr.flow_u0_encap_data.underlay_sip; + meta.u0_encap_data.underlay_dip = hdr.flow_u0_encap_data.underlay_dip; + meta.u0_encap_data.underlay_smac = hdr.flow_u0_encap_data.underlay_smac; + meta.u0_encap_data.underlay_dmac = hdr.flow_u0_encap_data.underlay_dmac; + meta.u0_encap_data.dash_encapsulation = hdr.flow_u0_encap_data.dash_encapsulation; #else - meta.encap_data = hdr.flow_encap_data; + meta.u0_encap_data = hdr.flow_u0_encap_data; #endif // TARGET_DPDK_PNA /* tunnel metadata */ #ifdef TARGET_DPDK_PNA - meta.tunnel_data.vni = hdr.flow_tunnel_data.vni; - meta.tunnel_data.underlay_sip = hdr.flow_tunnel_data.underlay_sip; - meta.tunnel_data.underlay_dip = hdr.flow_tunnel_data.underlay_dip; - meta.tunnel_data.underlay_smac = hdr.flow_tunnel_data.underlay_smac; - meta.tunnel_data.underlay_dmac = hdr.flow_tunnel_data.underlay_dmac; - meta.tunnel_data.dash_encapsulation = hdr.flow_tunnel_data.dash_encapsulation; + meta.u1_encap_data.vni = hdr.flow_u1_encap_data.vni; + meta.u1_encap_data.underlay_sip = hdr.flow_u1_encap_data.underlay_sip; + meta.u1_encap_data.underlay_dip = hdr.flow_u1_encap_data.underlay_dip; + meta.u1_encap_data.underlay_smac = hdr.flow_u1_encap_data.underlay_smac; + meta.u1_encap_data.underlay_dmac = hdr.flow_u1_encap_data.underlay_dmac; + meta.u1_encap_data.dash_encapsulation = hdr.flow_u1_encap_data.dash_encapsulation; #else - meta.tunnel_data = hdr.flow_tunnel_data; + meta.u1_encap_data = hdr.flow_u1_encap_data; #endif // TARGET_DPDK_PNA /* overlay rewrite metadata */ @@ -55,8 +55,8 @@ action conntrack_strip_dash_header(inout headers_t hdr) hdr.flow_key.setInvalid(); hdr.flow_data.setInvalid(); hdr.flow_overlay_data.setInvalid(); - hdr.flow_encap_data.setInvalid(); - hdr.flow_tunnel_data.setInvalid(); + hdr.flow_u0_encap_data.setInvalid(); + hdr.flow_u1_encap_data.setInvalid(); } control conntrack_build_dash_header(inout headers_t hdr, in metadata_t meta, @@ -75,30 +75,30 @@ control conntrack_build_dash_header(inout headers_t hdr, in metadata_t meta, if (meta.routing_actions & dash_routing_actions_t.ENCAP_U0 != 0) { #ifdef TARGET_DPDK_PNA - hdr.flow_encap_data.setValid(); - hdr.flow_encap_data.vni = meta.encap_data.vni; - hdr.flow_encap_data.underlay_sip = meta.encap_data.underlay_sip; - hdr.flow_encap_data.underlay_dip = meta.encap_data.underlay_dip; - hdr.flow_encap_data.underlay_smac = meta.encap_data.underlay_smac; - hdr.flow_encap_data.underlay_dmac = meta.encap_data.underlay_dmac; - hdr.flow_encap_data.dash_encapsulation = meta.encap_data.dash_encapsulation; + hdr.flow_u0_encap_data.setValid(); + hdr.flow_u0_encap_data.vni = meta.u0_encap_data.vni; + hdr.flow_u0_encap_data.underlay_sip = meta.u0_encap_data.underlay_sip; + hdr.flow_u0_encap_data.underlay_dip = meta.u0_encap_data.underlay_dip; + hdr.flow_u0_encap_data.underlay_smac = meta.u0_encap_data.underlay_smac; + hdr.flow_u0_encap_data.underlay_dmac = meta.u0_encap_data.underlay_dmac; + hdr.flow_u0_encap_data.dash_encapsulation = meta.u0_encap_data.dash_encapsulation; #else - hdr.flow_encap_data= meta.encap_data; + hdr.flow_u0_encap_data= meta.u0_encap_data; #endif // TARGET_DPDK_PNA length = length + ENCAP_DATA_HDR_SIZE; } if (meta.routing_actions & dash_routing_actions_t.ENCAP_U1 != 0) { #ifdef TARGET_DPDK_PNA - hdr.flow_tunnel_data.setValid(); - hdr.flow_tunnel_data.vni = meta.tunnel_data.vni; - hdr.flow_tunnel_data.underlay_sip = meta.tunnel_data.underlay_sip; - hdr.flow_tunnel_data.underlay_dip = meta.tunnel_data.underlay_dip; - hdr.flow_tunnel_data.underlay_smac = meta.tunnel_data.underlay_smac; - hdr.flow_tunnel_data.underlay_dmac = meta.tunnel_data.underlay_dmac; - hdr.flow_tunnel_data.dash_encapsulation = meta.tunnel_data.dash_encapsulation; + hdr.flow_u1_encap_data.setValid(); + hdr.flow_u1_encap_data.vni = meta.u1_encap_data.vni; + hdr.flow_u1_encap_data.underlay_sip = meta.u1_encap_data.underlay_sip; + hdr.flow_u1_encap_data.underlay_dip = meta.u1_encap_data.underlay_dip; + hdr.flow_u1_encap_data.underlay_smac = meta.u1_encap_data.underlay_smac; + hdr.flow_u1_encap_data.underlay_dmac = meta.u1_encap_data.underlay_dmac; + hdr.flow_u1_encap_data.dash_encapsulation = meta.u1_encap_data.dash_encapsulation; #else - hdr.flow_tunnel_data= meta.tunnel_data; + hdr.flow_u1_encap_data= meta.u1_encap_data; #endif // TARGET_DPDK_PNA length = length + ENCAP_DATA_HDR_SIZE; } @@ -128,7 +128,7 @@ control conntrack_build_dash_header(inout headers_t hdr, in metadata_t meta, hdr.dp_ethernet.setValid(); hdr.dp_ethernet.dst_addr = DPAPP_MAC; - hdr.dp_ethernet.src_addr = meta.encap_data.underlay_smac; + hdr.dp_ethernet.src_addr = meta.u0_encap_data.underlay_smac; hdr.dp_ethernet.ether_type = DASH_ETHTYPE; } } @@ -280,19 +280,19 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { ; /* Set encapsulation metadata */ - meta.encap_data.vni = underlay0_vnet_id; - meta.encap_data.underlay_sip = underlay0_sip; - meta.encap_data.underlay_dip = underlay0_dip; - meta.encap_data.dash_encapsulation = underlay0_dash_encapsulation; - meta.encap_data.underlay_smac = underlay0_smac; - meta.encap_data.underlay_dmac = underlay0_dmac; - - meta.tunnel_data.vni = underlay1_vnet_id; - meta.tunnel_data.underlay_sip = underlay1_sip; - meta.tunnel_data.underlay_dip = underlay1_dip; - meta.tunnel_data.dash_encapsulation = underlay1_dash_encapsulation; - meta.tunnel_data.underlay_smac = underlay1_smac; - meta.tunnel_data.underlay_dmac = underlay1_dmac; + meta.u0_encap_data.vni = underlay0_vnet_id; + meta.u0_encap_data.underlay_sip = underlay0_sip; + meta.u0_encap_data.underlay_dip = underlay0_dip; + meta.u0_encap_data.dash_encapsulation = underlay0_dash_encapsulation; + meta.u0_encap_data.underlay_smac = underlay0_smac; + meta.u0_encap_data.underlay_dmac = underlay0_dmac; + + meta.u1_encap_data.vni = underlay1_vnet_id; + meta.u1_encap_data.underlay_sip = underlay1_sip; + meta.u1_encap_data.underlay_dip = underlay1_dip; + meta.u1_encap_data.dash_encapsulation = underlay1_dash_encapsulation; + meta.u1_encap_data.underlay_smac = underlay1_smac; + meta.u1_encap_data.underlay_dmac = underlay1_dmac; /* Set overlay rewrite metadata */ meta.overlay_data.dmac = dst_mac; diff --git a/dash-pipeline/bmv2/stages/outbound_mapping.p4 b/dash-pipeline/bmv2/stages/outbound_mapping.p4 index 83e7be65f..e44624d16 100644 --- a/dash-pipeline/bmv2/stages/outbound_mapping.p4 +++ b/dash-pipeline/bmv2/stages/outbound_mapping.p4 @@ -30,7 +30,7 @@ control outbound_mapping_stage( } action set_vnet_attrs(bit<24> vni) { - meta.encap_data.vni = vni; + meta.u0_encap_data.vni = vni; } @SaiTable[name = "vnet", api = "dash_vnet", isobject="true"] diff --git a/dash-pipeline/bmv2/stages/pre_pipeline.p4 b/dash-pipeline/bmv2/stages/pre_pipeline.p4 index 8edfcd602..fc94c672b 100644 --- a/dash-pipeline/bmv2/stages/pre_pipeline.p4 +++ b/dash-pipeline/bmv2/stages/pre_pipeline.p4 @@ -25,8 +25,8 @@ control pre_pipeline_stage(inout headers_t hdr, action set_underlay_mac(EthernetAddress neighbor_mac, EthernetAddress mac) { - meta.encap_data.underlay_dmac = neighbor_mac; - meta.encap_data.underlay_smac = mac; + meta.u0_encap_data.underlay_dmac = neighbor_mac; + meta.u0_encap_data.underlay_smac = mac; } /* This table API should be implemented manually using underlay SAI */ @@ -109,7 +109,7 @@ control pre_pipeline_stage(inout headers_t hdr, if (vip.apply().hit) { /* Use the same VIP that was in packet's destination if it's present in the VIP table */ - meta.encap_data.underlay_sip = meta.rx_encap.underlay_dip; + meta.u0_encap_data.underlay_sip = meta.rx_encap.underlay_dip; } else { UPDATE_COUNTER(vip_miss_drop, 0); From 590d9fbdeda825dcc5a3f1d1e3b806688ff1ddcd Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Fri, 18 Oct 2024 07:35:24 +0000 Subject: [PATCH 13/18] Rollback the definition of enable_reverse_tunnel_learning for all targets --- dash-pipeline/bmv2/dash_metadata.p4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dash-pipeline/bmv2/dash_metadata.p4 b/dash-pipeline/bmv2/dash_metadata.p4 index 5c47df536..c57677d17 100644 --- a/dash-pipeline/bmv2/dash_metadata.p4 +++ b/dash-pipeline/bmv2/dash_metadata.p4 @@ -231,10 +231,10 @@ struct metadata_t { #else encap_data_t u0_encap_data; encap_data_t u1_encap_data; - bit<1> enable_reverse_tunnel_learning; - IPv4Address reverse_tunnel_sip; overlay_rewrite_data_t overlay_data; #endif // TARGET_DPDK_PNA + bit<1> enable_reverse_tunnel_learning; + IPv4Address reverse_tunnel_sip; bit<16> dash_tunnel_id; bit<32> meter_class; bit<8> local_region_id; From 2cf40479799b718c1e7a81a78c723826756cee57 Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Mon, 21 Oct 2024 15:00:45 +0000 Subject: [PATCH 14/18] flow sync state is not in flow_data --- dash-pipeline/bmv2/dash_headers.p4 | 1 - dash-pipeline/bmv2/dash_metadata.p4 | 1 + dash-pipeline/bmv2/dash_pipeline.p4 | 2 +- dash-pipeline/bmv2/stages/conntrack_lookup.p4 | 6 +++--- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dash-pipeline/bmv2/dash_headers.p4 b/dash-pipeline/bmv2/dash_headers.p4 index ca8873963..3455ca49e 100644 --- a/dash-pipeline/bmv2/dash_headers.p4 +++ b/dash-pipeline/bmv2/dash_headers.p4 @@ -236,7 +236,6 @@ const bit<16> FLOW_KEY_HDR_SIZE=flow_key_t.minSizeInBytes(); header flow_data_t { bit<7> reserved; bit<1> is_unidirectional; - dash_flow_sync_state_t sync_state; dash_direction_t direction; bit<32> version; dash_flow_action_t actions; diff --git a/dash-pipeline/bmv2/dash_metadata.p4 b/dash-pipeline/bmv2/dash_metadata.p4 index c57677d17..3f86cd0eb 100644 --- a/dash-pipeline/bmv2/dash_metadata.p4 +++ b/dash-pipeline/bmv2/dash_metadata.p4 @@ -210,6 +210,7 @@ struct metadata_t { #else flow_data_t flow_data; #endif // TARGET_DPDK_PNA + dash_flow_sync_state_t flow_sync_state; flow_table_data_t flow_table; bit<16> bulk_get_session_id; bit<16> bulk_get_session_filter_id; diff --git a/dash-pipeline/bmv2/dash_pipeline.p4 b/dash-pipeline/bmv2/dash_pipeline.p4 index bca08e76f..abfa597d1 100644 --- a/dash-pipeline/bmv2/dash_pipeline.p4 +++ b/dash-pipeline/bmv2/dash_pipeline.p4 @@ -275,7 +275,7 @@ control dash_ingress( ha_stage.apply(hdr, meta); if (!meta.flow_enabled || - (meta.flow_data.sync_state == dash_flow_sync_state_t.FLOW_MISS && + (meta.flow_sync_state == dash_flow_sync_state_t.FLOW_MISS && hdr.packet_meta.packet_source == dash_packet_source_t.EXTERNAL)) { dash_match_stage.apply(hdr, meta); diff --git a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 index 60d847bff..a0126611e 100644 --- a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 +++ b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 @@ -173,7 +173,7 @@ control conntrack_flow_created_handle(inout headers_t hdr, inout metadata_t meta control conntrack_flow_handle(inout headers_t hdr, inout metadata_t meta) { apply { - switch (meta.flow_data.sync_state) { + switch (meta.flow_sync_state) { dash_flow_sync_state_t.FLOW_MISS: { conntrack_flow_miss_handle.apply(hdr, meta); } @@ -269,9 +269,9 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { meta.flow_data.actions = dash_flow_action; meta.flow_data.meter_class = meter_class; meta.flow_data.is_unidirectional= is_unidirectional_flow; - meta.flow_data.sync_state = dash_flow_sync_state; /* Also set basic metadata */ + meta.flow_sync_state = dash_flow_sync_state; meta.direction = dash_direction; meta.routing_actions = dash_flow_action; meta.meter_class = meter_class; @@ -304,7 +304,7 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { } action flow_miss() { - meta.flow_data.sync_state = dash_flow_sync_state_t.FLOW_MISS; + meta.flow_sync_state = dash_flow_sync_state_t.FLOW_MISS; } @SaiTable[name = "flow", api = "dash_flow", order = 1, enable_bulk_get_api = "true", enable_bulk_get_server = "true"] From c6bc6fcefe5f525c64b625a556d2560ef0904399 Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Tue, 22 Oct 2024 16:29:40 +0000 Subject: [PATCH 15/18] Add param reverse_flow_dst_ip_is_v6 for flow action --- dash-pipeline/SAI/specs/dash_flow.yaml | 38 +++++++++---------- dash-pipeline/bmv2/stages/conntrack_lookup.p4 | 5 ++- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/dash-pipeline/SAI/specs/dash_flow.yaml b/dash-pipeline/SAI/specs/dash_flow.yaml index b106f147a..fdbdd73a6 100644 --- a/dash-pipeline/SAI/specs/dash_flow.yaml +++ b/dash-pipeline/SAI/specs/dash_flow.yaml @@ -591,25 +591,25 @@ sai_apis: SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_DST_IP: 11 SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_SRC_PORT: 12 SAI_FLOW_ENTRY_ATTR_REVERSE_FLOW_DST_PORT: 13 - SAI_FLOW_ENTRY_ATTR_UNDERLAY0_VNET_ID: 14 - SAI_FLOW_ENTRY_ATTR_UNDERLAY0_SIP: 15 - SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DIP: 16 - SAI_FLOW_ENTRY_ATTR_UNDERLAY0_SMAC: 17 - SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DMAC: 18 - SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DASH_ENCAPSULATION: 19 - SAI_FLOW_ENTRY_ATTR_UNDERLAY1_VNET_ID: 20 - SAI_FLOW_ENTRY_ATTR_UNDERLAY1_SIP: 21 - SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DIP: 22 - SAI_FLOW_ENTRY_ATTR_UNDERLAY1_SMAC: 23 - SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DMAC: 24 - SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DASH_ENCAPSULATION: 25 - SAI_FLOW_ENTRY_ATTR_DST_MAC: 26 - SAI_FLOW_ENTRY_ATTR_SIP: 27 - SAI_FLOW_ENTRY_ATTR_DIP: 28 - SAI_FLOW_ENTRY_ATTR_SIP_MASK: 29 - SAI_FLOW_ENTRY_ATTR_DIP_MASK: 30 - SAI_FLOW_ENTRY_ATTR_VENDOR_METADATA: 32 - SAI_FLOW_ENTRY_ATTR_FLOW_DATA_PB: 33 + SAI_FLOW_ENTRY_ATTR_UNDERLAY0_VNET_ID: 15 + SAI_FLOW_ENTRY_ATTR_UNDERLAY0_SIP: 16 + SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DIP: 17 + SAI_FLOW_ENTRY_ATTR_UNDERLAY0_SMAC: 18 + SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DMAC: 19 + SAI_FLOW_ENTRY_ATTR_UNDERLAY0_DASH_ENCAPSULATION: 20 + SAI_FLOW_ENTRY_ATTR_UNDERLAY1_VNET_ID: 21 + SAI_FLOW_ENTRY_ATTR_UNDERLAY1_SIP: 22 + SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DIP: 23 + SAI_FLOW_ENTRY_ATTR_UNDERLAY1_SMAC: 24 + SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DMAC: 25 + SAI_FLOW_ENTRY_ATTR_UNDERLAY1_DASH_ENCAPSULATION: 26 + SAI_FLOW_ENTRY_ATTR_DST_MAC: 27 + SAI_FLOW_ENTRY_ATTR_SIP: 28 + SAI_FLOW_ENTRY_ATTR_DIP: 29 + SAI_FLOW_ENTRY_ATTR_SIP_MASK: 30 + SAI_FLOW_ENTRY_ATTR_DIP_MASK: 31 + SAI_FLOW_ENTRY_ATTR_VENDOR_METADATA: 33 + SAI_FLOW_ENTRY_ATTR_FLOW_DATA_PB: 34 - !!python/object:utils.sai_spec.sai_api.SaiApi name: flow_entry_bulk_get_session_filter description: flow entry bulk get session filter diff --git a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 index a0126611e..c55f17da1 100644 --- a/dash-pipeline/bmv2/stages/conntrack_lookup.p4 +++ b/dash-pipeline/bmv2/stages/conntrack_lookup.p4 @@ -235,6 +235,7 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { IPv4ORv6Address reverse_flow_dst_ip, bit<16> reverse_flow_src_port, bit<16> reverse_flow_dst_port, + bit<1> reverse_flow_dst_ip_is_v6, /* Flow encap related attributes */ bit<24> underlay0_vnet_id, @@ -257,7 +258,7 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { IPv4ORv6Address dip, IPv6Address sip_mask, IPv6Address dip_mask, - @SaiVal[name = "ip_is_v6"]bit<1> is_ipv6, + bit<1> dip_is_v6, /* Extra flow metadata */ @SaiVal[type="sai_u8_list_t"] bit<16> vendor_metadata, @@ -300,7 +301,7 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) { meta.overlay_data.dip = dip; meta.overlay_data.sip_mask = sip_mask; meta.overlay_data.dip_mask = dip_mask; - meta.overlay_data.is_ipv6 = is_ipv6; + meta.overlay_data.is_ipv6 = dip_is_v6; } action flow_miss() { From cb6d2bfa091b06c1c3f3adca3d23b44fde29012d Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Thu, 24 Oct 2024 01:55:19 +0000 Subject: [PATCH 16/18] Use concrete SNAT/DNAT to replace NAT in flow actions --- dash-pipeline/SAI/specs/sai_spec.yaml | 14 +++++++++----- dash-pipeline/bmv2/dash_headers.p4 | 11 ++++++----- dash-pipeline/bmv2/dash_pipeline.p4 | 2 -- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/dash-pipeline/SAI/specs/sai_spec.yaml b/dash-pipeline/SAI/specs/sai_spec.yaml index 058d29cbb..e79de0027 100644 --- a/dash-pipeline/SAI/specs/sai_spec.yaml +++ b/dash-pipeline/SAI/specs/sai_spec.yaml @@ -348,25 +348,29 @@ enums: description: '' value: '8' - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember - name: NAT + name: SNAT description: '' value: '16' - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember - name: NAT46 + name: DNAT description: '' value: '32' - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember - name: NAT64 + name: NAT46 description: '' value: '64' - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember - name: NAT_PORT + name: NAT64 description: '' value: '128' - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember - name: REVERSE_TUNNEL + name: SNAT_PORT description: '' value: '256' + - !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember + name: DNAT_PORT + description: '' + value: '512' - !!python/object:utils.sai_spec.sai_enum.SaiEnum name: sai_dash_ha_state_t description: '' diff --git a/dash-pipeline/bmv2/dash_headers.p4 b/dash-pipeline/bmv2/dash_headers.p4 index 3455ca49e..1b3b6085e 100644 --- a/dash-pipeline/bmv2/dash_headers.p4 +++ b/dash-pipeline/bmv2/dash_headers.p4 @@ -168,11 +168,12 @@ enum bit<32> dash_flow_action_t { ENCAP_U1 = (1 << 1), SET_SMAC = (1 << 2), SET_DMAC = (1 << 3), - NAT = (1 << 4), - NAT46 = (1 << 5), - NAT64 = (1 << 6), - NAT_PORT = (1 << 7), - REVERSE_TUNNEL = (1 << 8) + SNAT = (1 << 4), + DNAT = (1 << 5), + NAT46 = (1 << 6), + NAT64 = (1 << 7), + SNAT_PORT = (1 << 8), + DNAT_PORT = (1 << 9) } enum bit<16> dash_flow_enabled_key_t { diff --git a/dash-pipeline/bmv2/dash_pipeline.p4 b/dash-pipeline/bmv2/dash_pipeline.p4 index abfa597d1..49a737cd9 100644 --- a/dash-pipeline/bmv2/dash_pipeline.p4 +++ b/dash-pipeline/bmv2/dash_pipeline.p4 @@ -88,8 +88,6 @@ control dash_eni_stage( meta.enable_reverse_tunnel_learning = enable_reverse_tunnel_learning; meta.reverse_tunnel_sip = reverse_tunnel_sip; - meta.routing_actions = meta.routing_actions | dash_routing_actions_t.REVERSE_TUNNEL; - if (meta.is_overlay_ip_v6 == 1) { if (meta.direction == dash_direction_t.OUTBOUND) { ACL_GROUPS_COPY_TO_META(outbound_v6); From ecec3484dda07b2ebffbec3d7298494c1416b028 Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Thu, 24 Oct 2024 03:27:52 +0000 Subject: [PATCH 17/18] update dash_tunnel.yaml --- dash-pipeline/SAI/specs/dash_tunnel.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dash-pipeline/SAI/specs/dash_tunnel.yaml b/dash-pipeline/SAI/specs/dash_tunnel.yaml index ca5333206..688357744 100644 --- a/dash-pipeline/SAI/specs/dash_tunnel.yaml +++ b/dash-pipeline/SAI/specs/dash_tunnel.yaml @@ -122,11 +122,11 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 40012474 + id: 41269458 actions: default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: default - id: 23738116 + id: 19698973 attr_param_id: {} - !!python/object:utils.sai_spec.sai_api.SaiApi name: dash_tunnel_next_hop @@ -152,9 +152,9 @@ sai_apis: p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta tables: - !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable - id: 34229686 + id: 37329198 actions: default: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction name: default - id: 31749609 + id: 17571304 attr_param_id: {} From 4c3bdf9ab1c3eb1d7cb102abe3bac83549315025 Mon Sep 17 00:00:00 2001 From: Junhua Zhai Date: Fri, 25 Oct 2024 02:08:11 +0000 Subject: [PATCH 18/18] Correct push_vxlan_tunnel to push_nvgre_tunnel for dash_encapsulation_t.NVGRE --- .../bmv2/routing_actions/routing_action_encap_underlay.p4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dash-pipeline/bmv2/routing_actions/routing_action_encap_underlay.p4 b/dash-pipeline/bmv2/routing_actions/routing_action_encap_underlay.p4 index b85c1ba58..ebe27c786 100644 --- a/dash-pipeline/bmv2/routing_actions/routing_action_encap_underlay.p4 +++ b/dash-pipeline/bmv2/routing_actions/routing_action_encap_underlay.p4 @@ -61,7 +61,7 @@ control do_action_encap_u0( meta.u0_encap_data.vni); } else if (meta.u0_encap_data.dash_encapsulation == dash_encapsulation_t.NVGRE) { - push_vxlan_tunnel_u0(hdr, + push_nvgre_tunnel_u0(hdr, meta.u0_encap_data.underlay_dmac, meta.u0_encap_data.underlay_smac, meta.u0_encap_data.underlay_dip, @@ -89,7 +89,7 @@ control do_action_encap_u1( meta.u0_encap_data.vni); } else if (meta.u0_encap_data.dash_encapsulation == dash_encapsulation_t.NVGRE) { - push_vxlan_tunnel_u1(hdr, + push_nvgre_tunnel_u1(hdr, meta.u0_encap_data.underlay_dmac, meta.u0_encap_data.underlay_smac, meta.u0_encap_data.underlay_dip,