Skip to content

Commit 610623d

Browse files
authored
[dash-p4] Update P4 to support PL redirect map (#663)
PL redirect map implementation. HLD PR #664. --------- Signed-off-by: Junhua Zhai <[email protected]>
1 parent 6508581 commit 610623d

15 files changed

+438
-4
lines changed

dash-pipeline/SAI/specs/dash_eni.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,33 @@ sai_apis:
16681668
valid_only: null
16691669
is_vlan: false
16701670
deprecated: false
1671+
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
1672+
name: SAI_ENI_STAT_OUTBOUND_PORT_MAP_MISS_DROP_PACKETS
1673+
description: DASH ENI OUTBOUND_PORT_MAP_MISS_DROP_PACKETS stat count
1674+
type: sai_uint64_t
1675+
attr_value_field: u64
1676+
default: null
1677+
isresourcetype: false
1678+
flags: READ_ONLY
1679+
object_name: null
1680+
allow_null: false
1681+
valid_only: null
1682+
is_vlan: false
1683+
deprecated: false
1684+
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
1685+
name: SAI_ENI_STAT_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_MISS_DROP_PACKETS
1686+
description: DASH ENI OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_MISS_DROP_PACKETS stat
1687+
count
1688+
type: sai_uint64_t
1689+
attr_value_field: u64
1690+
default: null
1691+
isresourcetype: false
1692+
flags: READ_ONLY
1693+
object_name: null
1694+
allow_null: false
1695+
valid_only: null
1696+
is_vlan: false
1697+
deprecated: false
16711698
p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta
16721699
tables:
16731700
- !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable

dash-pipeline/SAI/specs/dash_outbound_ca_to_pa.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,19 @@ sai_apis:
257257
valid_only: null
258258
is_vlan: false
259259
deprecated: false
260+
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
261+
name: SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OUTBOUND_PORT_MAP_ID
262+
description: Action parameter outbound port map id
263+
type: sai_object_id_t
264+
attr_value_field: u16
265+
default: SAI_NULL_OBJECT_ID
266+
isresourcetype: false
267+
flags: CREATE_AND_SET
268+
object_name: SAI_OBJECT_TYPE_OUTBOUND_PORT_MAP
269+
allow_null: true
270+
valid_only: SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_ACTION == SAI_OUTBOUND_CA_TO_PA_ENTRY_ACTION_SET_PRIVATE_LINK_MAPPING
271+
is_vlan: false
272+
deprecated: false
260273
stats: []
261274
p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta
262275
tables:
@@ -398,3 +411,9 @@ sai_apis:
398411
bitwidth: 32
399412
ip_is_v6_field_id: 0
400413
skipattr: null
414+
SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OUTBOUND_PORT_MAP_ID: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaActionParam
415+
id: 12
416+
field: u16
417+
bitwidth: 16
418+
ip_is_v6_field_id: 0
419+
skipattr: null
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
!!python/object:utils.sai_spec.sai_api_group.SaiApiGroup
2+
name: dash_outbound_port_map
3+
description: DASH outbound port map
4+
api_type: overlay
5+
sai_apis:
6+
- !!python/object:utils.sai_spec.sai_api.SaiApi
7+
name: outbound_port_map
8+
description: outbound port map
9+
is_object: true
10+
enums: []
11+
structs: []
12+
attributes:
13+
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
14+
name: SAI_OUTBOUND_PORT_MAP_ATTR_COUNTER_ID
15+
description: Attach a counter. When it is empty, then packet hits won't be counted.
16+
type: sai_object_id_t
17+
attr_value_field: null
18+
default: SAI_NULL_OBJECT_ID
19+
isresourcetype: false
20+
flags: CREATE_AND_SET
21+
object_name: SAI_OBJECT_TYPE_COUNTER
22+
allow_null: true
23+
valid_only: null
24+
is_vlan: false
25+
deprecated: false
26+
stats: []
27+
p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta
28+
tables:
29+
- !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable
30+
id: 42579810
31+
single_match_priority: false
32+
stage: null
33+
keys:
34+
- !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaKey
35+
name: outbound_port_map_id
36+
id: 1
37+
match_type: exact
38+
field: u16
39+
bitwidth: 16
40+
ip_is_v6_field_id: 0
41+
is_object_key: true
42+
actions:
43+
SAI_OUTBOUND_PORT_MAP_ACTION_SET_PORT_MAP_ATTR: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction
44+
name: SAI_OUTBOUND_PORT_MAP_ACTION_SET_PORT_MAP_ATTR
45+
id: 32437678
46+
attr_params: {}
47+
- !!python/object:utils.sai_spec.sai_api.SaiApi
48+
name: outbound_port_map_port_range_entry
49+
description: outbound port map port range entry
50+
is_object: false
51+
enums:
52+
- !!python/object:utils.sai_spec.sai_enum.SaiEnum
53+
name: sai_outbound_port_map_port_range_entry_action_t
54+
description: 'Attribute data for #SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_ACTION'
55+
members:
56+
- !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember
57+
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_SKIP_MAPPING
58+
description: ''
59+
value: '0'
60+
- !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember
61+
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_MAP_TO_PRIVATE_LINK_SERVICE
62+
description: ''
63+
value: '1'
64+
structs:
65+
- !!python/object:utils.sai_spec.sai_struct.SaiStruct
66+
name: sai_outbound_port_map_port_range_entry_t
67+
description: Entry for outbound_port_map_port_range_entry
68+
members:
69+
- !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry
70+
name: switch_id
71+
description: Switch ID
72+
type: sai_object_id_t
73+
objects: SAI_OBJECT_TYPE_SWITCH
74+
valid_only: null
75+
- !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry
76+
name: outbound_port_map_id
77+
description: Exact matched key outbound_port_map_id
78+
type: sai_object_id_t
79+
objects: SAI_OBJECT_TYPE_OUTBOUND_PORT_MAP
80+
valid_only: null
81+
- !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry
82+
name: dst_port_range
83+
description: Range matched key dst_port_range
84+
type: sai_u32_range_t
85+
objects: null
86+
valid_only: null
87+
attributes:
88+
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
89+
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_ACTION
90+
description: Action
91+
type: sai_outbound_port_map_port_range_entry_action_t
92+
attr_value_field: null
93+
default: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_SKIP_MAPPING
94+
isresourcetype: false
95+
flags: CREATE_AND_SET
96+
object_name: null
97+
allow_null: false
98+
valid_only: null
99+
is_vlan: false
100+
deprecated: false
101+
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
102+
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_BACKEND_IP
103+
description: Action parameter back end IP
104+
type: sai_ip_address_t
105+
attr_value_field: ipaddr
106+
default: 0.0.0.0
107+
isresourcetype: false
108+
flags: CREATE_AND_SET
109+
object_name: null
110+
allow_null: false
111+
valid_only: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_ACTION == SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_MAP_TO_PRIVATE_LINK_SERVICE
112+
is_vlan: false
113+
deprecated: false
114+
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
115+
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_MATCH_PORT_BASE
116+
description: Action parameter match port base
117+
type: sai_uint16_t
118+
attr_value_field: u16
119+
default: '0'
120+
isresourcetype: false
121+
flags: CREATE_AND_SET
122+
object_name: null
123+
allow_null: false
124+
valid_only: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_ACTION == SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_MAP_TO_PRIVATE_LINK_SERVICE
125+
is_vlan: true
126+
deprecated: false
127+
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
128+
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_BACKEND_PORT_BASE
129+
description: Action parameter back end port base
130+
type: sai_uint16_t
131+
attr_value_field: u16
132+
default: '0'
133+
isresourcetype: false
134+
flags: CREATE_AND_SET
135+
object_name: null
136+
allow_null: false
137+
valid_only: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_ACTION == SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_MAP_TO_PRIVATE_LINK_SERVICE
138+
is_vlan: true
139+
deprecated: false
140+
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
141+
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_COUNTER_ID
142+
description: Attach a counter. When it is empty, then packet hits won't be counted.
143+
type: sai_object_id_t
144+
attr_value_field: null
145+
default: SAI_NULL_OBJECT_ID
146+
isresourcetype: false
147+
flags: CREATE_AND_SET
148+
object_name: SAI_OBJECT_TYPE_COUNTER
149+
allow_null: true
150+
valid_only: null
151+
is_vlan: false
152+
deprecated: false
153+
stats: []
154+
p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta
155+
tables:
156+
- !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable
157+
id: 35152152
158+
single_match_priority: true
159+
stage: null
160+
keys:
161+
- !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaKey
162+
name: outbound_port_map_id
163+
id: 1
164+
match_type: exact
165+
field: u16
166+
bitwidth: 16
167+
ip_is_v6_field_id: 0
168+
is_object_key: false
169+
- !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaKey
170+
name: dst_port_range
171+
id: 2
172+
match_type: range
173+
field: u32range
174+
bitwidth: 16
175+
ip_is_v6_field_id: 0
176+
is_object_key: false
177+
actions:
178+
SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_SKIP_MAPPING: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction
179+
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_SKIP_MAPPING
180+
id: 22713701
181+
attr_params: {}
182+
SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_MAP_TO_PRIVATE_LINK_SERVICE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction
183+
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_MAP_TO_PRIVATE_LINK_SERVICE
184+
id: 23926714
185+
attr_params:
186+
SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_BACKEND_IP: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaActionParam
187+
id: 1
188+
field: ipaddr
189+
bitwidth: 32
190+
ip_is_v6_field_id: 0
191+
skipattr: null
192+
SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_MATCH_PORT_BASE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaActionParam
193+
id: 2
194+
field: u16
195+
bitwidth: 16
196+
ip_is_v6_field_id: 0
197+
skipattr: null
198+
SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_BACKEND_PORT_BASE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaActionParam
199+
id: 3
200+
field: u16
201+
bitwidth: 16
202+
ip_is_v6_field_id: 0
203+
skipattr: null

dash-pipeline/SAI/specs/sai_spec.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ api_types:
1515
- SAI_API_DASH_TUNNEL
1616
- SAI_API_DASH_FLOW
1717
- SAI_API_DASH_APPLIANCE
18+
- SAI_API_DASH_OUTBOUND_PORT_MAP
1819
object_types:
1920
- SAI_OBJECT_TYPE_DASH_ACL_GROUP
2021
- SAI_OBJECT_TYPE_DASH_ACL_RULE
@@ -43,6 +44,8 @@ object_types:
4344
- SAI_OBJECT_TYPE_DASH_APPLIANCE
4445
- SAI_OBJECT_TYPE_DASH_TUNNEL_MEMBER
4546
- SAI_OBJECT_TYPE_DASH_TUNNEL_NEXT_HOP
47+
- SAI_OBJECT_TYPE_OUTBOUND_PORT_MAP
48+
- SAI_OBJECT_TYPE_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY
4649
object_entries:
4750
- !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry
4851
name: direction_lookup_entry
@@ -104,6 +107,12 @@ object_entries:
104107
type: sai_meter_bucket_entry_t
105108
objects: null
106109
valid_only: object_type == SAI_OBJECT_TYPE_METER_BUCKET_ENTRY,
110+
- !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry
111+
name: outbound_port_map_port_range_entry
112+
description: Object entry for DASH API outbound_port_map_port_range_entry
113+
type: sai_outbound_port_map_port_range_entry_t
114+
objects: null
115+
valid_only: object_type == SAI_OBJECT_TYPE_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY,
107116
enums:
108117
- !!python/object:utils.sai_spec.sai_enum.SaiEnum
109118
name: sai_dash_direction_t
@@ -566,3 +575,4 @@ api_groups:
566575
- !inc 'dash_tunnel.yaml'
567576
- !inc 'dash_flow.yaml'
568577
- !inc 'dash_appliance.yaml'
578+
- !inc 'dash_outbound_port_map.yaml'

dash-pipeline/SAI/utils/sai_spec/sai_spec_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def load_word_fixers() -> None:
2525
"proto": "protocol",
2626
"smac": "source MAC",
2727
"dest": "destination",
28-
"dpu": "DPU"
28+
"dpu": "DPU",
29+
"backend": "back end"
2930
}
3031

3132
# Load all SAI acronyms

dash-pipeline/bmv2/dash_counters.p4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,7 @@ DEFINE_ENI_PACKET_COUNTER(outbound_ca_pa_entry_miss_drop)
102102
DEFINE_ENI_PACKET_COUNTER(inbound_routing_entry_miss_drop)
103103
DEFINE_ENI_PACKET_COUNTER(outbound_routing_group_miss_drop)
104104
DEFINE_ENI_PACKET_COUNTER(outbound_routing_group_disabled_drop)
105+
DEFINE_ENI_PACKET_COUNTER(outbound_port_map_miss_drop)
106+
DEFINE_ENI_PACKET_COUNTER(outbound_port_map_port_range_entry_miss_drop)
105107

106108
#endif // __DASH_COUNTERS__

dash-pipeline/bmv2/dash_headers.p4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ header overlay_rewrite_data_t {
6060
IPv4ORv6Address dip;
6161
IPv6Address sip_mask;
6262
IPv6Address dip_mask;
63+
bit<16> sport;
64+
bit<16> dport;
6365
bit<7> reserved;
6466
bit<1> is_ipv6;
6567
}

dash-pipeline/bmv2/dash_metadata.p4

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ struct eni_data_t {
6666
IPv4Address vip;
6767
}
6868

69+
struct port_map_context_t {
70+
bit<16> map_id;
71+
IPv6Address service_rewrite_sip;
72+
IPv6Address service_rewrite_sip_mask;
73+
IPv6Address service_rewrite_dip;
74+
IPv6Address service_rewrite_dip_mask;
75+
}
76+
6977
struct meter_context_t {
7078
bit<32> meter_class_or;
7179
bit<32> meter_class_and;
@@ -134,7 +142,6 @@ struct ha_data_t {
134142
struct meta_flow_data_t {
135143
bit<7> reserved;
136144
bit<1> is_unidirectional;
137-
dash_flow_sync_state_t sync_state;
138145
dash_direction_t direction;
139146
bit<32> version;
140147
dash_flow_action_t actions;
@@ -157,6 +164,8 @@ struct meta_overlay_rewrite_data_t {
157164
IPv4ORv6Address dip;
158165
IPv6Address sip_mask;
159166
IPv6Address dip_mask;
167+
bit<16> sport;
168+
bit<16> dport;
160169
bit<7> reserved;
161170
bit<1> is_ipv6;
162171
}
@@ -199,6 +208,7 @@ struct metadata_t {
199208
bit<16> tunnel_pointer;
200209
bool is_fast_path_icmp_flow_redirection_packet;
201210
bit<1> fast_path_icmp_flow_redirection_disabled;
211+
port_map_context_t port_map_ctx;
202212
meter_context_t meter_context;
203213

204214
// HA

dash-pipeline/bmv2/dash_routing_types.p4

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ action set_private_link_mapping(
181181
bit<32> meter_class_or,
182182
@SaiVal[type="sai_object_id_t"] bit<16> dash_tunnel_id,
183183
bit<1> flow_resimulation_requested,
184-
dash_routing_actions_t routing_actions_disabled_in_flow_resimulation)
184+
dash_routing_actions_t routing_actions_disabled_in_flow_resimulation,
185+
@SaiVal[type="sai_object_id_t"] bit<16> outbound_port_map_id)
185186
{
186187
meta.target_stage = dash_pipeline_stage_t.OUTBOUND_PRE_ROUTING_ACTION_APPLY;
187188
meta.dash_tunnel_id = dash_tunnel_id;
@@ -208,10 +209,12 @@ action set_private_link_mapping(
208209
meta = meta,
209210
dip = overlay_dip,
210211
dip_mask = overlay_dip_mask,
211-
sip = ((( (IPv6Address)hdr.u0_ipv4.src_addr & ~overlay_sip_mask) | overlay_sip) & ~meta.eni_data.pl_sip_mask) | meta.eni_data.pl_sip,
212+
sip = ((( meta.src_ip_addr & ~overlay_sip_mask) | overlay_sip) & ~meta.eni_data.pl_sip_mask) | meta.eni_data.pl_sip,
212213
sip_mask = 0xffffffffffffffffffffffff);
213214
#endif /* DISABLE_128BIT_ARITHMETIC */
214215

216+
meta.port_map_ctx.map_id = outbound_port_map_id;
217+
215218
set_meter_attrs(meta, meter_class_or, 0xffffffff);
216219
}
217220

0 commit comments

Comments
 (0)