Skip to content

Commit

Permalink
Update P4 to support PL redirect map
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyzhai committed Jan 24, 2025
1 parent f5b4b70 commit 0dff593
Show file tree
Hide file tree
Showing 12 changed files with 401 additions and 6 deletions.
27 changes: 23 additions & 4 deletions dash-pipeline/SAI/specs/dash_outbound_ca_to_pa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,19 @@ sai_apis:
valid_only: null
is_vlan: false
deprecated: false
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OUTBOUND_PORT_MAP_ID
description: Action parameter outbound port map id
type: sai_object_id_t
attr_value_field: u16
default: SAI_NULL_OBJECT_ID
isresourcetype: false
flags: CREATE_AND_SET
object_name: SAI_OBJECT_TYPE_OUTBOUND_PORT_MAP
allow_null: true
valid_only: SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_ACTION == SAI_OUTBOUND_CA_TO_PA_ENTRY_ACTION_SET_PRIVATE_LINK_MAPPING
is_vlan: false
deprecated: false
stats: []
p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta
tables:
Expand Down Expand Up @@ -373,26 +386,32 @@ sai_apis:
bitwidth: 24
ip_is_v6_field_id: 0
skipattr: null
SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_METER_CLASS_OR: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaActionParam
SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OUTBOUND_PORT_MAP_ID: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaActionParam
id: 8
field: u16
bitwidth: 16
ip_is_v6_field_id: 0
skipattr: null
SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_METER_CLASS_OR: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaActionParam
id: 9
field: u32
bitwidth: 32
ip_is_v6_field_id: 0
skipattr: null
SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_DASH_TUNNEL_ID: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaActionParam
id: 9
id: 10
field: u16
bitwidth: 16
ip_is_v6_field_id: 0
skipattr: null
SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_FLOW_RESIMULATION_REQUESTED: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaActionParam
id: 10
id: 11
field: booldata
bitwidth: 1
ip_is_v6_field_id: 0
skipattr: null
SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_ROUTING_ACTIONS_DISABLED_IN_FLOW_RESIMULATION: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaActionParam
id: 11
id: 12
field: u32
bitwidth: 32
ip_is_v6_field_id: 0
Expand Down
207 changes: 207 additions & 0 deletions dash-pipeline/SAI/specs/dash_outbound_port_map.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
!!python/object:utils.sai_spec.sai_api_group.SaiApiGroup
name: dash_outbound_port_map
description: DASH outbound port map
api_type: overlay
sai_apis:
- !!python/object:utils.sai_spec.sai_api.SaiApi
name: outbound_port_map
description: outbound port map
is_object: true
enums: []
structs: []
attributes:
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_OUTBOUND_PORT_MAP_ATTR_COUNTER_ID
description: Attach a counter. When it is empty, then packet hits won't be counted.
type: sai_object_id_t
attr_value_field: null
default: SAI_NULL_OBJECT_ID
isresourcetype: false
flags: CREATE_AND_SET
object_name: SAI_OBJECT_TYPE_COUNTER
allow_null: true
valid_only: null
is_vlan: false
deprecated: false
stats: []
p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta
tables:
- !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable
id: 42579810
stage: null
keys:
- !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaKey
name: outbound_port_map_id
id: 1
match_type: exact
field: u16
bitwidth: 16
ip_is_v6_field_id: 0
is_object_key: true
actions:
SAI_OUTBOUND_PORT_MAP_ACTION_SET_PORT_MAP_ATTR: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction
name: SAI_OUTBOUND_PORT_MAP_ACTION_SET_PORT_MAP_ATTR
id: 32437678
attr_params: {}
- !!python/object:utils.sai_spec.sai_api.SaiApi
name: outbound_port_map_port_range_entry
description: outbound port map port range entry
is_object: false
enums:
- !!python/object:utils.sai_spec.sai_enum.SaiEnum
name: sai_outbound_port_map_port_range_entry_action_t
description: 'Attribute data for #SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_ACTION'
members:
- !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_SKIP_MAPPING
description: ''
value: '0'
- !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_MAP_TO_PRIVATE_LINK_SERVICE
description: ''
value: '1'
structs:
- !!python/object:utils.sai_spec.sai_struct.SaiStruct
name: sai_outbound_port_map_port_range_entry_t
description: Entry for outbound_port_map_port_range_entry
members:
- !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry
name: switch_id
description: Switch ID
type: sai_object_id_t
objects: SAI_OBJECT_TYPE_SWITCH
valid_only: null
- !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry
name: outbound_port_map_id
description: Exact matched key outbound_port_map_id
type: sai_object_id_t
objects: SAI_OBJECT_TYPE_OUTBOUND_PORT_MAP
valid_only: null
- !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry
name: dst_port_range
description: Range matched key dst_port_range
type: sai_u32_range_t
objects: null
valid_only: null
- !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry
name: priority
description: Rule priority in table
type: sai_uint32_t
objects: null
valid_only: null
attributes:
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_ACTION
description: Action
type: sai_outbound_port_map_port_range_entry_action_t
attr_value_field: null
default: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_SKIP_MAPPING
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_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_BACKEND_IP
description: Action parameter back end IP
type: sai_ip_address_t
attr_value_field: ipaddr
default: 0.0.0.0
isresourcetype: false
flags: CREATE_AND_SET
object_name: null
allow_null: false
valid_only: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_ACTION == SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_MAP_TO_PRIVATE_LINK_SERVICE
is_vlan: false
deprecated: false
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_MATCH_PORT_BASE
description: Action parameter match port base
type: sai_uint16_t
attr_value_field: u16
default: '0'
isresourcetype: false
flags: CREATE_AND_SET
object_name: null
allow_null: false
valid_only: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_ACTION == SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_MAP_TO_PRIVATE_LINK_SERVICE
is_vlan: true
deprecated: false
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_BACKEND_PORT_BASE
description: Action parameter back end port base
type: sai_uint16_t
attr_value_field: u16
default: '0'
isresourcetype: false
flags: CREATE_AND_SET
object_name: null
allow_null: false
valid_only: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_ACTION == SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_MAP_TO_PRIVATE_LINK_SERVICE
is_vlan: true
deprecated: false
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_COUNTER_ID
description: Attach a counter. When it is empty, then packet hits won't be counted.
type: sai_object_id_t
attr_value_field: null
default: SAI_NULL_OBJECT_ID
isresourcetype: false
flags: CREATE_AND_SET
object_name: SAI_OBJECT_TYPE_COUNTER
allow_null: true
valid_only: null
is_vlan: false
deprecated: false
stats: []
p4_meta: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4Meta
tables:
- !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaTable
id: 35152152
stage: null
keys:
- !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaKey
name: outbound_port_map_id
id: 1
match_type: exact
field: u16
bitwidth: 16
ip_is_v6_field_id: 0
is_object_key: false
- !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaKey
name: dst_port_range
id: 2
match_type: range
field: u32range
bitwidth: 16
ip_is_v6_field_id: 0
is_object_key: false
actions:
SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_SKIP_MAPPING: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_SKIP_MAPPING
id: 22713701
attr_params: {}
SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_MAP_TO_PRIVATE_LINK_SERVICE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaAction
name: SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ACTION_MAP_TO_PRIVATE_LINK_SERVICE
id: 23926714
attr_params:
SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_BACKEND_IP: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaActionParam
id: 1
field: ipaddr
bitwidth: 32
ip_is_v6_field_id: 0
skipattr: null
SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_MATCH_PORT_BASE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaActionParam
id: 2
field: u16
bitwidth: 16
ip_is_v6_field_id: 0
skipattr: null
SAI_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY_ATTR_BACKEND_PORT_BASE: !!python/object:utils.sai_spec.sai_api_p4_meta.SaiApiP4MetaActionParam
id: 3
field: u16
bitwidth: 16
ip_is_v6_field_id: 0
skipattr: null
10 changes: 10 additions & 0 deletions dash-pipeline/SAI/specs/sai_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ api_types:
- SAI_API_DASH_TUNNEL
- SAI_API_DASH_FLOW
- SAI_API_DASH_APPLIANCE
- SAI_API_DASH_OUTBOUND_PORT_MAP
object_types:
- SAI_OBJECT_TYPE_DASH_ACL_GROUP
- SAI_OBJECT_TYPE_DASH_ACL_RULE
Expand Down Expand Up @@ -43,6 +44,8 @@ object_types:
- SAI_OBJECT_TYPE_DASH_APPLIANCE
- SAI_OBJECT_TYPE_DASH_TUNNEL_MEMBER
- SAI_OBJECT_TYPE_DASH_TUNNEL_NEXT_HOP
- SAI_OBJECT_TYPE_OUTBOUND_PORT_MAP
- SAI_OBJECT_TYPE_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY
object_entries:
- !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry
name: direction_lookup_entry
Expand Down Expand Up @@ -104,6 +107,12 @@ object_entries:
type: sai_meter_bucket_entry_t
objects: null
valid_only: object_type == SAI_OBJECT_TYPE_METER_BUCKET_ENTRY,
- !!python/object:utils.sai_spec.sai_struct_entry.SaiStructEntry
name: outbound_port_map_port_range_entry
description: Object entry for DASH API outbound_port_map_port_range_entry
type: sai_outbound_port_map_port_range_entry_t
objects: null
valid_only: object_type == SAI_OBJECT_TYPE_OUTBOUND_PORT_MAP_PORT_RANGE_ENTRY,
enums:
- !!python/object:utils.sai_spec.sai_enum.SaiEnum
name: sai_dash_direction_t
Expand Down Expand Up @@ -566,3 +575,4 @@ api_groups:
- !inc 'dash_tunnel.yaml'
- !inc 'dash_flow.yaml'
- !inc 'dash_appliance.yaml'
- !inc 'dash_outbound_port_map.yaml'
3 changes: 2 additions & 1 deletion dash-pipeline/SAI/utils/sai_spec/sai_spec_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def load_word_fixers() -> None:
"proto": "protocol",
"smac": "source MAC",
"dest": "destination",
"dpu": "DPU"
"dpu": "DPU",
"backend": "back end"
}

# Load all SAI acronyms
Expand Down
2 changes: 2 additions & 0 deletions dash-pipeline/bmv2/dash_headers.p4
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ header overlay_rewrite_data_t {
IPv4ORv6Address dip;
IPv6Address sip_mask;
IPv6Address dip_mask;
bit<16> sport;
bit<16> dport;
bit<7> reserved;
bit<1> is_ipv6;
}
Expand Down
8 changes: 7 additions & 1 deletion dash-pipeline/bmv2/dash_metadata.p4
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ struct eni_data_t {
IPv4Address vip;
}

struct port_map_context_t {
bit<16> map_id;
}

struct meter_context_t {
bit<32> meter_class_or;
bit<32> meter_class_and;
Expand Down Expand Up @@ -134,7 +138,6 @@ struct ha_data_t {
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;
Expand All @@ -156,6 +159,8 @@ struct meta_overlay_rewrite_data_t {
IPv4ORv6Address dip;
IPv6Address sip_mask;
IPv6Address dip_mask;
bit<16> sport;
bit<16> dport;
bit<7> reserved;
bit<1> is_ipv6;
}
Expand Down Expand Up @@ -198,6 +203,7 @@ struct metadata_t {
bit<16> tunnel_pointer;
bool is_fast_path_icmp_flow_redirection_packet;
bit<1> fast_path_icmp_flow_redirection_disabled;
port_map_context_t port_map_ctx;
meter_context_t meter_context;

// HA
Expand Down
3 changes: 3 additions & 0 deletions dash-pipeline/bmv2/dash_routing_types.p4
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ action set_private_link_mapping(
IPv6Address overlay_dip_mask,
@SaiVal[type="sai_dash_encapsulation_t"] dash_encapsulation_t dash_encapsulation,
bit<24> tunnel_key,
@SaiVal[type="sai_object_id_t"] bit<16> outbound_port_map_id,
bit<32> meter_class_or,
@SaiVal[type="sai_object_id_t"] bit<16> dash_tunnel_id,
bit<1> flow_resimulation_requested,
Expand Down Expand Up @@ -212,6 +213,8 @@ action set_private_link_mapping(
sip_mask = 0xffffffffffffffffffffffff);
#endif /* DISABLE_128BIT_ARITHMETIC */

meta.port_map_ctx.map_id = outbound_port_map_id;

set_meter_attrs(meta, meter_class_or, 0xffffffff);
}

Expand Down
Loading

0 comments on commit 0dff593

Please sign in to comment.