Skip to content

Commit

Permalink
[dash-p4] Update DASH BM P4 code for fast path SAI API generation (so…
Browse files Browse the repository at this point in the history
…nic-net#517)

This change is to support generating the load balancer fast path SAI APIs. It follows the HLD in the doc repo: <https://github.com/sonic-net/DASH/blob/main/documentation/load-bal-service/fast-path-icmp-flow-redirection.md>.

This change doesn't really contains any real behavior for parsing fast path packets and etc. These updates will come later time.

The updated SAI headers can be previewed here: <r12f/SAI@d0e2904>
  • Loading branch information
r12f authored Feb 15, 2024
1 parent f34f825 commit 08800bf
Show file tree
Hide file tree
Showing 22 changed files with 126 additions and 37 deletions.
2 changes: 2 additions & 0 deletions dash-pipeline/bmv2/dash_metadata.p4
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ struct metadata_t {
bit<16> meter_class;
bit<32> meter_bucket_index;
bit<16> tunnel_pointer;
bool is_fast_path_icmp_flow_redirection_packet;
bit<1> fast_path_icmp_flow_redirection_disabled;
}

#endif /* _SIRIUS_METADATA_P4_ */
47 changes: 45 additions & 2 deletions dash-pipeline/bmv2/dash_pipeline.p4
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "dash_conntrack.p4"
#include "underlay.p4"

#define MAX_ENI 64

control dash_ingress(
inout headers_t hdr
, inout metadata_t meta
Expand Down Expand Up @@ -38,6 +40,13 @@ control dash_ingress(
action accept() {
}

#ifdef TARGET_BMV2_V1MODEL
@SaiCounter[name="lb_fast_path_icmp_in", attr_type="stats"]
counter(1, CounterType.packets_and_bytes) port_lb_fast_path_icmp_in_counter;
@SaiCounter[name="lb_fast_path_eni_miss", attr_type="stats"]
counter(1, CounterType.packets_and_bytes) port_lb_fast_path_eni_miss_counter;
#endif

@SaiTable[name = "vip", api = "dash_vip"]
table vip {
key = {
Expand Down Expand Up @@ -106,6 +115,11 @@ control dash_ingress(
meta.stage4_dash_acl_group_id = ## prefix ##_stage4_dash_acl_group_id; \
meta.stage5_dash_acl_group_id = ## prefix ##_stage5_dash_acl_group_id;

#ifdef TARGET_BMV2_V1MODEL
@SaiCounter[name="lb_fast_path_icmp_in", attr_type="stats", action_names="set_eni_attrs"]
counter(MAX_ENI, CounterType.packets_and_bytes) eni_lb_fast_path_icmp_in_counter;
#endif

action set_eni_attrs(bit<32> cps,
bit<32> pps,
bit<32> flows,
Expand All @@ -121,7 +135,8 @@ control dash_ingress(
ACL_GROUPS_PARAM(inbound_v4),
ACL_GROUPS_PARAM(inbound_v6),
ACL_GROUPS_PARAM(outbound_v4),
ACL_GROUPS_PARAM(outbound_v6)) {
ACL_GROUPS_PARAM(outbound_v6),
bit<1> disable_fast_path_icmp_flow_redirection) {
meta.eni_data.cps = cps;
meta.eni_data.pps = pps;
meta.eni_data.flows = flows;
Expand Down Expand Up @@ -150,6 +165,8 @@ control dash_ingress(
}
meta.meter_policy_id = v4_meter_policy_id;
}

meta.fast_path_icmp_flow_redirection_disabled = disable_fast_path_icmp_flow_redirection;
}

@SaiTable[name = "eni", api = "dash_eni", order=1, isobject="true"]
Expand Down Expand Up @@ -362,10 +379,22 @@ control dash_ingress(
#endif // DPDK_PNA_SEND_TO_PORT_FIX_MERGED
#endif // TARGET_DPDK_PNA

if (meta.is_fast_path_icmp_flow_redirection_packet) {
#ifdef TARGET_BMV2_V1MODEL
port_lb_fast_path_icmp_in_counter.count(0);
#endif
}

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 = hdr.u0_ipv4.dst_addr;
} else {
if (meta.is_fast_path_icmp_flow_redirection_packet) {
#ifdef TARGET_BMV2_V1MODEL
port_lb_fast_path_eni_miss_counter.count(0);
#endif
}
}

/* If Outer VNI matches with a reserved VNI, then the direction is Outbound - */
Expand All @@ -380,7 +409,14 @@ control dash_ingress(
hdr.customer_ethernet.src_addr :
hdr.customer_ethernet.dst_addr;

eni_ether_address_map.apply();
if (!eni_ether_address_map.apply().hit) {
if (meta.is_fast_path_icmp_flow_redirection_packet) {
#ifdef TARGET_BMV2_V1MODEL
port_lb_fast_path_eni_miss_counter.count(0);
#endif
}
}

if (meta.direction == dash_direction_t.OUTBOUND) {
tunnel_decap(hdr, meta);
} else if (meta.direction == dash_direction_t.INBOUND) {
Expand Down Expand Up @@ -421,6 +457,13 @@ control dash_ingress(
if (meta.eni_data.admin_state == 0) {
deny();
}

if (meta.is_fast_path_icmp_flow_redirection_packet) {
#ifdef TARGET_BMV2_V1MODEL
eni_lb_fast_path_icmp_in_counter.count((bit<32>)meta.eni_id);
#endif
}

acl_group.apply();


Expand Down
4 changes: 4 additions & 0 deletions dash-pipeline/tests/libsai/vnet_out/vnet_out.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ int main(int argc, char **argv)
attr.value.u32 = 0;
attrs.push_back(attr);

attr.id = SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION;
attr.value.booldata = false;
attrs.push_back(attr);

status = dash_eni_api->create_eni(&eni_id, switch_id, attrs.size(), attrs.data());

if (status != SAI_STATUS_SUCCESS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def test_sai_thrift_create_eni(saithrift_client):
outbound_v6_stage2_dash_acl_group_id = 0,
outbound_v6_stage3_dash_acl_group_id = 0,
outbound_v6_stage4_dash_acl_group_id = 0,
outbound_v6_stage5_dash_acl_group_id = 0)
outbound_v6_stage5_dash_acl_group_id = 0,
disable_fast_path_icmp_flow_redirection = 0)
assert (eni != SAI_NULL_OBJECT_ID);

eam = sai_thrift_eni_ether_address_map_entry_t(switch_id=switch_id, address = eth_addr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,21 +170,21 @@ Port level counter will be added as port stats extensions following the [SAI ext

| Attribute name | Description |
| -------------- | ----------- |
| SAI_PORT_ATTR_LB_FAST_PATH_ICMP_IN_PKTS | The number of fast path packets received |
| SAI_PORT_ATTR_LB_FAST_PATH_ICMP_IN_BYTES | The total bytes of fast path packets received |
| SAI_PORT_ATTR_LB_FAST_PATH_ENI_MISS_PKTS | The number of fast path packet received but could not find corresponding ENI to process |
| SAI_PORT_ATTR_LB_FAST_PATH_ENI_MISS_BYTES | The total bytes of fast path packet received but could not find corresponding ENI to process |
| SAI_PORT_STAT_LB_FAST_PATH_ICMP_IN_PACKETS | The number of fast path packets received |
| SAI_PORT_STAT_LB_FAST_PATH_ICMP_IN_BYTES | The total bytes of fast path packets received |
| SAI_PORT_STAT_LB_FAST_PATH_ENI_MISS_PACKETS | The number of fast path packet received but could not find corresponding ENI to process |
| SAI_PORT_STAT_LB_FAST_PATH_ENI_MISS_BYTES | The total bytes of fast path packet received but could not find corresponding ENI to process |

#### ENI stats attributes

| Attribute name | Description |
| -------------- | ----------- |
| SAI_ENI_ATTR_LB_FAST_PATH_ICMP_IN_PKTS | The number of fast path packets received |
| SAI_ENI_ATTR_LB_FAST_PATH_ICMP_IN_BYTES | The total bytes of fast path packets received |
| SAI_ENI_STAT_LB_FAST_PATH_ICMP_IN_PACKETS | The number of fast path packets received |
| SAI_ENI_STAT_LB_FAST_PATH_ICMP_IN_BYTES | The total bytes of fast path packets received |

#### Flow table stats attributes

| Attribute name | Description |
| -------------- | ----------- |
| SAI_ENI_ATTR_LB_FAST_PATH_FLOW_REDIRECTED_COUNT | The number of flows that redirected due to fast path packet received |
| SAI_ENI_ATTR_LB_FAST_PATH_FLOW_MISS_COUNT | The number of flows that is missing when trying to redirected by fast path packets |
| SAI_ENI_STAT_LB_FAST_PATH_FLOW_REDIRECTED_COUNT | The number of flows that redirected due to fast path packet received |
| SAI_ENI_STAT_LB_FAST_PATH_FLOW_MISS_COUNT | The number of flows that is missing when trying to redirected by fast path packets |
3 changes: 2 additions & 1 deletion test/test-cases/functional/ptf/sai_dash_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ def eni_create(self, **kwargs):
"outbound_v6_stage2_dash_acl_group_id": 0,
"outbound_v6_stage3_dash_acl_group_id": 0,
"outbound_v6_stage4_dash_acl_group_id": 0,
"outbound_v6_stage5_dash_acl_group_id": 0
"outbound_v6_stage5_dash_acl_group_id": 0,
"disable_fast_path_icmp_flow_redirection": 0,
}
default_kwargs.update(kwargs)

Expand Down
3 changes: 2 additions & 1 deletion test/test-cases/functional/ptf/saidashacl.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ def setUpSwitch(self):
outbound_v6_stage2_dash_acl_group_id=self.out_v6_stage2_acl_group_id,
outbound_v6_stage3_dash_acl_group_id=self.out_v6_stage3_acl_group_id,
outbound_v6_stage4_dash_acl_group_id=0,
outbound_v6_stage5_dash_acl_group_id=0)
outbound_v6_stage5_dash_acl_group_id=0,
disable_fast_path_icmp_flow_redirection=0)

self.eam = sai_thrift_eni_ether_address_map_entry_t(
switch_id=self.switch_id, address=self.eni_mac)
Expand Down
3 changes: 2 additions & 1 deletion test/test-cases/functional/ptf/saidashvnet_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def configureVnet(self):
outbound_v6_stage2_dash_acl_group_id = 0,
outbound_v6_stage3_dash_acl_group_id = 0,
outbound_v6_stage4_dash_acl_group_id = 0,
outbound_v6_stage5_dash_acl_group_id = 0)
outbound_v6_stage5_dash_acl_group_id = 0,
disable_fast_path_icmp_flow_redirection = 0)

self.eam = sai_thrift_eni_ether_address_map_entry_t(switch_id=self.switch_id, address = self.eni_mac)
status = sai_thrift_create_eni_ether_address_map_entry(self.client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE4_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE5_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_V4_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0"
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION", "False"
]
},
{
Expand Down Expand Up @@ -161,7 +162,8 @@
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE4_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE5_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_V4_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0"
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION", "False"
]
},
{
Expand Down Expand Up @@ -200,7 +202,8 @@
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE4_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE5_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_V4_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0"
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION", "False"
]
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@
"SAI_ENI_ATTR_V4_METER_POLICY_ID",
"0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID",
"0"
"0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION",
"False"
]
},
{
Expand Down Expand Up @@ -229,7 +231,9 @@
"SAI_ENI_ATTR_V4_METER_POLICY_ID",
"0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID",
"0"
"0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION",
"False"
]
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE4_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE5_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_V4_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0"
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION", "False"
]
},
{
Expand Down Expand Up @@ -135,7 +136,8 @@
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE4_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE5_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_V4_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0"
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION", "False"
]
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def test_vnet_eni_create(self, dpu):
"SAI_ENI_ATTR_V4_METER_POLICY_ID",
"0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID",
"0"
"0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION",
"False"
]
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ def test_vnet_inbound_routing_entry_create_setup(self, dpu):
"SAI_ENI_ATTR_V4_METER_POLICY_ID",
"0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID",
"0"
"0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION",
"False"
]
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ def test_vnet_outbound_routing_entry_create(self, dpu):
"SAI_ENI_ATTR_V4_METER_POLICY_ID",
"0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID",
"0"
"0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION",
"False"
]
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def make_create_commands(self):
conf.generate()
ret = add_extra_attrs('SAI_OBJECT_TYPE_ENI', conf.items(), ["SAI_ENI_ATTR_V4_METER_POLICY_ID", "0", "SAI_ENI_ATTR_V6_METER_POLICY_ID", "0",
'SAI_ENI_ATTR_PL_SIP', '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'SAI_ENI_ATTR_PL_SIP_MASK',
'2001:0db8:85a3:0000:0000:0000:0000:0000', 'SAI_ENI_ATTR_PL_UNDERLAY_SIP', '10.0.0.18'])
'2001:0db8:85a3:0000:0000:0000:0000:0000', 'SAI_ENI_ATTR_PL_UNDERLAY_SIP', '10.0.0.18',
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION", "False"])

ret = add_extra_attrs('SAI_OBJECT_TYPE_OUTBOUND_CA_TO_PA_ENTRY', ret, [ 'SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_METER_CLASS', '0',
'SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_METER_CLASS_OVERRIDE', 'True' ])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@
"SAI_ENI_ATTR_V4_METER_POLICY_ID",
"0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID",
"0"
"0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION",
"False"
]
},
{
Expand Down Expand Up @@ -213,7 +215,9 @@
"SAI_ENI_ATTR_V4_METER_POLICY_ID",
"0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID",
"0"
"0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION",
"False"
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion test/test-cases/scale/saic/test_sai_vnet_outbound_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ def make_create_vnet_config(self):
conf.generate()
ret = add_extra_attrs('SAI_OBJECT_TYPE_ENI', conf.items(), ["SAI_ENI_ATTR_V4_METER_POLICY_ID", "0", "SAI_ENI_ATTR_V6_METER_POLICY_ID", "0",
'SAI_ENI_ATTR_PL_SIP', '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'SAI_ENI_ATTR_PL_SIP_MASK',
'2001:0db8:85a3:0000:0000:0000:0000:0000', 'SAI_ENI_ATTR_PL_UNDERLAY_SIP', '10.0.0.18'])
'2001:0db8:85a3:0000:0000:0000:0000:0000', 'SAI_ENI_ATTR_PL_UNDERLAY_SIP', '10.0.0.18',
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION", "False"])

ret = add_extra_attrs('SAI_OBJECT_TYPE_OUTBOUND_CA_TO_PA_ENTRY', ret, [ 'SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_METER_CLASS', '0',
'SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_METER_CLASS_OVERRIDE', 'True' ])
Expand Down
4 changes: 3 additions & 1 deletion test/test-cases/scale/saic/vnet_inbound_setup_commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@
"SAI_ENI_ATTR_V4_METER_POLICY_ID",
"0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID",
"0"
"0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION",
"False"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE4_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE5_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_V4_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0"
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION", "False"
]
},
{
Expand Down Expand Up @@ -170,7 +171,8 @@
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE4_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE5_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_V4_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0"
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION", "False"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE4_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE5_DASH_ACL_GROUP_ID", "0",
"SAI_ENI_ATTR_V4_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0"
"SAI_ENI_ATTR_V6_METER_POLICY_ID", "0",
"SAI_ENI_ATTR_DISABLE_FAST_PATH_ICMP_FLOW_REDIRECTION", "False"
]
},
{
Expand Down
Loading

0 comments on commit 08800bf

Please sign in to comment.