Skip to content

Commit

Permalink
Add dpapp_mac
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyzhai committed Nov 14, 2024
1 parent 2bc6a69 commit 7614d49
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
1 change: 0 additions & 1 deletion dash-pipeline/bmv2/dash_headers.p4
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ header dash_packet_meta_t {
const bit<16> PACKET_META_HDR_SIZE=dash_packet_meta_t.minSizeInBytes();

#define DASH_ETHTYPE 0x876d
#define DPAPP_MAC 0x02fe23f0e413 /* FIXME temp hardcode */

struct headers_t {
/* packet metadata headers */
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 @@ -243,6 +243,7 @@ struct metadata_t {
bit<16> dash_tunnel_next_hop_id;
bit<32> meter_class;
bit<8> local_region_id;
EthernetAddress dpapp_mac;
}

#endif /* _SIRIUS_METADATA_P4_ */
2 changes: 1 addition & 1 deletion dash-pipeline/bmv2/stages/conntrack_lookup.p4
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ control conntrack_build_dash_header(inout headers_t hdr, in metadata_t meta,
hdr.packet_meta.length = length + PACKET_META_HDR_SIZE;

hdr.dp_ethernet.setValid();
hdr.dp_ethernet.dst_addr = DPAPP_MAC;
hdr.dp_ethernet.dst_addr = meta.dpapp_mac;
hdr.dp_ethernet.src_addr = meta.u0_encap_data.underlay_smac;
hdr.dp_ethernet.ether_type = DASH_ETHTYPE;
}
Expand Down
2 changes: 2 additions & 0 deletions dash-pipeline/bmv2/stages/pre_pipeline.p4
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ control pre_pipeline_stage(inout headers_t hdr,

action set_internal_config(EthernetAddress neighbor_mac,
EthernetAddress mac,
EthernetAddress dpapp_mac,
bit<1> flow_enabled) {
meta.u0_encap_data.underlay_dmac = neighbor_mac;
meta.u0_encap_data.underlay_smac = mac;
meta.dpapp_mac = dpapp_mac;
meta.flow_enabled = (bool)flow_enabled;
}

Expand Down
16 changes: 15 additions & 1 deletion test/test-cases/functional/ptf/p4_dash_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def get_action(self, name):

def set_internal_config(neighbor_mac :bytes = None,
mac :bytes = None,
dpapp_mac :bytes = None,
flow_enabled :bytes = None):
'''
Set dash pipeline internal config by updating table entry of internal_config.
Expand Down Expand Up @@ -90,6 +91,11 @@ def set_internal_config(neighbor_mac :bytes = None,
changed += 1

param = entry.action.action.params[2]
if dpapp_mac and dpapp_mac != param.value:
param.value = dpapp_mac
changed += 1

param = entry.action.action.params[3]
if flow_enabled and flow_enabled != param.value:
param.value = flow_enabled
changed += 1
Expand Down Expand Up @@ -126,6 +132,13 @@ def set_internal_config(neighbor_mac :bytes = None,

param = action.params.add()
param.param_id = 3
if dpapp_mac:
param.value = dpapp_mac
else: # default value
param.value = b'\x00\x00\x00\x00\x00\x00'

param = action.params.add()
param.param_id = 4
if flow_enabled:
param.value = flow_enabled
else: # default value
Expand All @@ -147,7 +160,8 @@ def setUp(self, *args, **kwargs):
if _setUp is not None:
_setUp(self, *args, **kwargs)
print(f'*** Enable Flow lookup')
set_internal_config(flow_enabled = b'\x01')
set_internal_config(dpapp_mac = mac_in_bytes(get_mac("veth5")),
flow_enabled = b'\x01')
return

def tearDown(self, *args, **kwargs):
Expand Down

0 comments on commit 7614d49

Please sign in to comment.