Skip to content

Commit

Permalink
[dash-p4] Add ENI mac override support on direction lookup stage. (#602)
Browse files Browse the repository at this point in the history
This PR adds support to select which MAC address to use for looking up
the ENI in the direction lookup stage.

This change follows the ExpressRoute gateway bypass HLD defined in this
PR here: #601.
  • Loading branch information
r12f authored Jul 31, 2024
1 parent 2433a6a commit 2d622bc
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 11 deletions.
16 changes: 15 additions & 1 deletion dash-pipeline/SAI/specs/dash_direction_lookup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ sai_apis:
valid_only: null
deprecated: false
is_vlan: false
- !!python/object:utils.sai_spec.sai_attribute.SaiAttribute
name: SAI_DIRECTION_LOOKUP_ENTRY_ATTR_DASH_ENI_MAC_OVERRIDE_TYPE
description: Action parameter DASH ENI MAC override type
type: sai_dash_eni_mac_override_type_t
attr_value_field: s32
default: SAI_DASH_ENI_MAC_OVERRIDE_TYPE_NONE
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:
Expand All @@ -56,4 +69,5 @@ sai_apis:
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
attr_param_id: {}
attr_param_id:
SAI_DIRECTION_LOOKUP_ENTRY_ATTR_DASH_ENI_MAC_OVERRIDE_TYPE: 1
16 changes: 16 additions & 0 deletions dash-pipeline/SAI/specs/sai_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,22 @@ enums:
name: SWITCHING_TO_STANDALONE
description: ''
value: '12'
- !!python/object:utils.sai_spec.sai_enum.SaiEnum
name: sai_dash_eni_mac_override_type_t
description: ''
members:
- !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember
name: NONE
description: ''
value: '0'
- !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember
name: SRC_MAC
description: ''
value: '1'
- !!python/object:utils.sai_spec.sai_enum_member.SaiEnumMember
name: DST_MAC
description: ''
value: '2'
port_extenstion: !!python/object:utils.sai_spec.sai_api_extension.SaiApiExtension
attributes: []
stats:
Expand Down
13 changes: 13 additions & 0 deletions dash-pipeline/bmv2/dash_metadata.p4
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ enum bit<8> dash_flow_entry_bulk_get_session_op_key_t
FILTER_OP_LESS_THAN_OR_EQUAL_TO = 5
}

enum bit<8> dash_eni_mac_override_type_t {
NONE = 0,
SRC_MAC = 1,
DST_MAC = 2
};

enum bit<8> dash_eni_mac_type_t {
SRC_MAC = 0,
DST_MAC = 1
};

struct conntrack_data_t {
bool allow_in;
bool allow_out;
Expand Down Expand Up @@ -260,6 +271,8 @@ struct metadata_t {

// Lookup context
dash_direction_t direction;
dash_eni_mac_type_t eni_mac_type;
dash_eni_mac_override_type_t eni_mac_override_type;
EthernetAddress eni_addr;
bit<16> vnet_id;
bit<16> dst_vnet_id;
Expand Down
19 changes: 18 additions & 1 deletion dash-pipeline/bmv2/stages/direction_lookup.p4
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,29 @@ control direction_lookup_stage(
inout headers_t hdr,
inout metadata_t meta)
{
action set_outbound_direction() {
action set_eni_mac_type(
dash_eni_mac_type_t eni_mac_type,
dash_eni_mac_override_type_t eni_mac_override_type
) {
meta.eni_mac_type = eni_mac_type;

if (eni_mac_override_type == dash_eni_mac_override_type_t.SRC_MAC) {
meta.eni_mac_type = dash_eni_mac_type_t.SRC_MAC;
} else if (eni_mac_override_type == dash_eni_mac_override_type_t.DST_MAC) {
meta.eni_mac_type = dash_eni_mac_type_t.DST_MAC;
}
}

action set_outbound_direction(
@SaiVal[type="sai_dash_eni_mac_override_type_t"] dash_eni_mac_override_type_t dash_eni_mac_override_type
) {
meta.direction = dash_direction_t.OUTBOUND;
set_eni_mac_type(dash_eni_mac_type_t.SRC_MAC, dash_eni_mac_override_type);
}

action set_inbound_direction() {
meta.direction = dash_direction_t.INBOUND;
meta.eni_mac_type = dash_eni_mac_type_t.DST_MAC;
}

@SaiTable[name = "direction_lookup", api = "dash_direction_lookup"]
Expand Down
8 changes: 5 additions & 3 deletions dash-pipeline/bmv2/stages/eni_lookup.p4
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ control eni_lookup_stage(

apply {
/* Put VM's MAC in the direction agnostic metadata field */
meta.eni_addr = meta.direction == dash_direction_t.OUTBOUND ?
hdr.customer_ethernet.src_addr :
hdr.customer_ethernet.dst_addr;
if (meta.eni_mac_type == dash_eni_mac_type_t.SRC_MAC) {
meta.eni_addr = hdr.customer_ethernet.src_addr;
} else {
meta.eni_addr = hdr.customer_ethernet.dst_addr;
}

if (!eni_ether_address_map.apply().hit) {
UPDATE_COUNTER(eni_miss_drop, 0);
Expand Down
5 changes: 3 additions & 2 deletions dash-pipeline/bmv2/stages/outbound_mapping.p4
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

#include "../dash_routing_types.p4"

control outbound_mapping_stage(inout headers_t hdr,
inout metadata_t meta)
control outbound_mapping_stage(
inout headers_t hdr,
inout metadata_t meta)
{
DEFINE_TABLE_COUNTER(ca_to_pa_counter)

Expand Down
8 changes: 4 additions & 4 deletions dash-pipeline/bmv2/stages/outbound_routing.p4
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

#include "../dash_routing_types.p4"

control outbound_routing_stage(inout headers_t hdr,
inout metadata_t meta)
control outbound_routing_stage(
inout headers_t hdr,
inout metadata_t meta)
{

action set_outbound_routing_group_attr(bit<1> disabled) {
meta.eni_data.outbound_routing_group_data.disabled = (bool)disabled;
}
Expand Down Expand Up @@ -64,7 +64,7 @@ control outbound_routing_stage(inout headers_t hdr,
}

if (!routing.apply().hit) {
UPDATE_ENI_COUNTER(outbound_routing_entry_miss_drop);
UPDATE_ENI_COUNTER(outbound_routing_entry_miss_drop);
}
}

Expand Down

0 comments on commit 2d622bc

Please sign in to comment.