Skip to content

Commit

Permalink
Manually merge sonic-net#616 and sonic-net#617 changes in bmv2
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyzhai committed Aug 30, 2024
1 parent e939e3d commit 46ae92a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dash-pipeline/bmv2/dash_headers.p4
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions dash-pipeline/bmv2/dash_metadata.p4
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
24 changes: 21 additions & 3 deletions dash-pipeline/bmv2/dash_pipeline.p4
Original file line number Diff line number Diff line change
Expand Up @@ -235,21 +235,38 @@ 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;
}

/* 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;
}
}

Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions dash-pipeline/bmv2/stages/conntrack_lookup.p4
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,15 @@ 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 |
dash_flow_enabled_key_t.DST_IP |
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) {
Expand Down

0 comments on commit 46ae92a

Please sign in to comment.