Skip to content

Commit

Permalink
Rename encap_data -> u0_encap_data, tunnel_data -> u1_encap_data
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyzhai committed Oct 18, 2024
1 parent bceb710 commit 443f27f
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 109 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 @@ -263,8 +263,8 @@ struct headers_t {
flow_key_t flow_key;
flow_data_t flow_data; // flow common data
overlay_rewrite_data_t flow_overlay_data;
encap_data_t flow_encap_data;
encap_data_t flow_tunnel_data;
encap_data_t flow_u0_encap_data;
encap_data_t flow_u1_encap_data;

/* Underlay 1 headers */
ethernet_t u1_ethernet;
Expand Down
10 changes: 5 additions & 5 deletions dash-pipeline/bmv2/dash_inbound.p4
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ control inbound(inout headers_t hdr,

do_tunnel_encap(hdr,
meta,
meta.encap_data.underlay_dmac,
meta.encap_data.underlay_smac,
meta.encap_data.underlay_dip,
meta.encap_data.underlay_sip,
meta.u0_encap_data.underlay_dmac,
meta.u0_encap_data.underlay_smac,
meta.u0_encap_data.underlay_dip,
meta.u0_encap_data.underlay_sip,
dash_encapsulation_t.VXLAN,
meta.encap_data.vni);
meta.u0_encap_data.vni);
}
}

Expand Down
12 changes: 4 additions & 8 deletions dash-pipeline/bmv2/dash_metadata.p4
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,12 @@ struct metadata_t {
// Action data
bool dropped;
#ifdef TARGET_DPDK_PNA
// encap_data is for underlay
meta_encap_data_t encap_data;
// tunnel_data is used by dash_tunnel_id
meta_encap_data_t tunnel_data;
meta_encap_data_t u0_encap_data;
meta_encap_data_t u1_encap_data;
meta_overlay_rewrite_data_t overlay_data;
#else
// encap_data is for underlay
encap_data_t encap_data;
// tunnel_data is used by dash_tunnel_id
encap_data_t tunnel_data;
encap_data_t u0_encap_data;
encap_data_t u1_encap_data;
bit<1> enable_reverse_tunnel_learning;
IPv4Address reverse_tunnel_sip;
overlay_rewrite_data_t overlay_data;
Expand Down
8 changes: 4 additions & 4 deletions dash-pipeline/bmv2/dash_parser.p4
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ parser dash_parser(
}

if (hd.flow_data.actions & dash_routing_actions_t.ENCAP_U0 != 0) {
packet.extract(hd.flow_encap_data);
packet.extract(hd.flow_u0_encap_data);
}

if (hd.flow_data.actions & dash_routing_actions_t.ENCAP_U1 != 0) {
packet.extract(hd.flow_tunnel_data);
packet.extract(hd.flow_u1_encap_data);
}
}

Expand Down Expand Up @@ -180,8 +180,8 @@ control dash_deparser(
packet.emit(hdr.flow_key);
packet.emit(hdr.flow_data);
packet.emit(hdr.flow_overlay_data);
packet.emit(hdr.flow_encap_data);
packet.emit(hdr.flow_tunnel_data);
packet.emit(hdr.flow_u0_encap_data);
packet.emit(hdr.flow_u1_encap_data);

packet.emit(hdr.u0_ethernet);
packet.emit(hdr.u0_ipv4);
Expand Down
8 changes: 4 additions & 4 deletions dash-pipeline/bmv2/dash_pipeline.p4
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ control dash_eni_stage(
meta.eni_data.pl_sip = pl_sip;
meta.eni_data.pl_sip_mask = pl_sip_mask;
meta.eni_data.pl_underlay_sip = pl_underlay_sip;
meta.encap_data.underlay_dip = vm_underlay_dip;
meta.u0_encap_data.underlay_dip = vm_underlay_dip;
meta.eni_data.outbound_routing_group_data.outbound_routing_group_id = outbound_routing_group_id;
if (dash_tunnel_dscp_mode == dash_tunnel_dscp_mode_t.PIPE_MODEL) {
meta.eni_data.dscp = dscp;
}
/* vm_vni is the encap VNI used for tunnel between inbound DPU -> VM
* and not a VNET identifier */
meta.encap_data.vni = vm_vni;
meta.u0_encap_data.vni = vm_vni;
meta.vnet_id = vnet_id;

meta.enable_reverse_tunnel_learning = enable_reverse_tunnel_learning;
Expand Down Expand Up @@ -241,8 +241,8 @@ control dash_ingress(
#ifndef TARGET_DPDK_PNA
meta.rx_encap.setValid();
meta.flow_data.setValid();
meta.encap_data.setValid();
meta.tunnel_data.setValid();
meta.u0_encap_data.setValid();
meta.u1_encap_data.setValid();
meta.overlay_data.setValid();
#endif // TARGET_DPDK_PNA

Expand Down
72 changes: 36 additions & 36 deletions dash-pipeline/bmv2/routing_actions/routing_action_encap_underlay.p4
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ action push_action_encap_u0(
{
meta.routing_actions = meta.routing_actions | dash_routing_actions_t.ENCAP_U0;

meta.encap_data.dash_encapsulation = encap;
meta.encap_data.vni = vni == 0 ? meta.encap_data.vni : vni;
meta.u0_encap_data.dash_encapsulation = encap;
meta.u0_encap_data.vni = vni == 0 ? meta.u0_encap_data.vni : vni;

meta.encap_data.underlay_smac = underlay_smac == 0 ? meta.encap_data.underlay_smac : underlay_smac;
meta.encap_data.underlay_dmac = underlay_dmac == 0 ? meta.encap_data.underlay_dmac : underlay_dmac;
meta.encap_data.underlay_sip = underlay_sip == 0 ? meta.encap_data.underlay_sip : underlay_sip;
meta.encap_data.underlay_dip = underlay_dip == 0 ? meta.encap_data.underlay_dip : underlay_dip;
meta.u0_encap_data.underlay_smac = underlay_smac == 0 ? meta.u0_encap_data.underlay_smac : underlay_smac;
meta.u0_encap_data.underlay_dmac = underlay_dmac == 0 ? meta.u0_encap_data.underlay_dmac : underlay_dmac;
meta.u0_encap_data.underlay_sip = underlay_sip == 0 ? meta.u0_encap_data.underlay_sip : underlay_sip;
meta.u0_encap_data.underlay_dip = underlay_dip == 0 ? meta.u0_encap_data.underlay_dip : underlay_dip;
}

action push_action_encap_u1(
Expand All @@ -34,13 +34,13 @@ action push_action_encap_u1(
{
meta.routing_actions = meta.routing_actions | dash_routing_actions_t.ENCAP_U1;

meta.tunnel_data.dash_encapsulation = encap;
meta.tunnel_data.vni = vni == 0 ? meta.tunnel_data.vni : vni;
meta.u1_encap_data.dash_encapsulation = encap;
meta.u1_encap_data.vni = vni == 0 ? meta.u1_encap_data.vni : vni;

meta.tunnel_data.underlay_smac = underlay_smac == 0 ? meta.tunnel_data.underlay_smac : underlay_smac;
meta.tunnel_data.underlay_dmac = underlay_dmac == 0 ? meta.tunnel_data.underlay_dmac : underlay_dmac;
meta.tunnel_data.underlay_sip = underlay_sip == 0 ? meta.tunnel_data.underlay_sip : underlay_sip;
meta.tunnel_data.underlay_dip = underlay_dip == 0 ? meta.tunnel_data.underlay_dip : underlay_dip;
meta.u1_encap_data.underlay_smac = underlay_smac == 0 ? meta.u1_encap_data.underlay_smac : underlay_smac;
meta.u1_encap_data.underlay_dmac = underlay_dmac == 0 ? meta.u1_encap_data.underlay_dmac : underlay_dmac;
meta.u1_encap_data.underlay_sip = underlay_sip == 0 ? meta.u1_encap_data.underlay_sip : underlay_sip;
meta.u1_encap_data.underlay_dip = underlay_dip == 0 ? meta.u1_encap_data.underlay_dip : underlay_dip;
}

control do_action_encap_u0(
Expand All @@ -52,21 +52,21 @@ control do_action_encap_u0(
return;
}

if (meta.encap_data.dash_encapsulation == dash_encapsulation_t.VXLAN) {
if (meta.u0_encap_data.dash_encapsulation == dash_encapsulation_t.VXLAN) {
push_vxlan_tunnel_u0(hdr,
meta.encap_data.underlay_dmac,
meta.encap_data.underlay_smac,
meta.encap_data.underlay_dip,
meta.encap_data.underlay_sip,
meta.encap_data.vni);
meta.u0_encap_data.underlay_dmac,
meta.u0_encap_data.underlay_smac,
meta.u0_encap_data.underlay_dip,
meta.u0_encap_data.underlay_sip,
meta.u0_encap_data.vni);
}
else if (meta.encap_data.dash_encapsulation == dash_encapsulation_t.NVGRE) {
else if (meta.u0_encap_data.dash_encapsulation == dash_encapsulation_t.NVGRE) {
push_vxlan_tunnel_u0(hdr,
meta.encap_data.underlay_dmac,
meta.encap_data.underlay_smac,
meta.encap_data.underlay_dip,
meta.encap_data.underlay_sip,
meta.encap_data.vni);
meta.u0_encap_data.underlay_dmac,
meta.u0_encap_data.underlay_smac,
meta.u0_encap_data.underlay_dip,
meta.u0_encap_data.underlay_sip,
meta.u0_encap_data.vni);
}
}
}
Expand All @@ -80,21 +80,21 @@ control do_action_encap_u1(
return;
}

if (meta.encap_data.dash_encapsulation == dash_encapsulation_t.VXLAN) {
if (meta.u0_encap_data.dash_encapsulation == dash_encapsulation_t.VXLAN) {
push_vxlan_tunnel_u1(hdr,
meta.encap_data.underlay_dmac,
meta.encap_data.underlay_smac,
meta.encap_data.underlay_dip,
meta.encap_data.underlay_sip,
meta.encap_data.vni);
meta.u0_encap_data.underlay_dmac,
meta.u0_encap_data.underlay_smac,
meta.u0_encap_data.underlay_dip,
meta.u0_encap_data.underlay_sip,
meta.u0_encap_data.vni);
}
else if (meta.encap_data.dash_encapsulation == dash_encapsulation_t.NVGRE) {
else if (meta.u0_encap_data.dash_encapsulation == dash_encapsulation_t.NVGRE) {
push_vxlan_tunnel_u1(hdr,
meta.encap_data.underlay_dmac,
meta.encap_data.underlay_smac,
meta.encap_data.underlay_dip,
meta.encap_data.underlay_sip,
meta.encap_data.vni);
meta.u0_encap_data.underlay_dmac,
meta.u0_encap_data.underlay_smac,
meta.u0_encap_data.underlay_dip,
meta.u0_encap_data.underlay_sip,
meta.u0_encap_data.vni);
}
}
}
Expand Down
92 changes: 46 additions & 46 deletions dash-pipeline/bmv2/stages/conntrack_lookup.p4
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ action conntrack_set_meta_from_dash_header(in headers_t hdr, out metadata_t meta

/* encapsulation metadata */
#ifdef TARGET_DPDK_PNA
meta.encap_data.vni = hdr.flow_encap_data.vni;
meta.encap_data.underlay_sip = hdr.flow_encap_data.underlay_sip;
meta.encap_data.underlay_dip = hdr.flow_encap_data.underlay_dip;
meta.encap_data.underlay_smac = hdr.flow_encap_data.underlay_smac;
meta.encap_data.underlay_dmac = hdr.flow_encap_data.underlay_dmac;
meta.encap_data.dash_encapsulation = hdr.flow_encap_data.dash_encapsulation;
meta.u0_encap_data.vni = hdr.flow_u0_encap_data.vni;
meta.u0_encap_data.underlay_sip = hdr.flow_u0_encap_data.underlay_sip;
meta.u0_encap_data.underlay_dip = hdr.flow_u0_encap_data.underlay_dip;
meta.u0_encap_data.underlay_smac = hdr.flow_u0_encap_data.underlay_smac;
meta.u0_encap_data.underlay_dmac = hdr.flow_u0_encap_data.underlay_dmac;
meta.u0_encap_data.dash_encapsulation = hdr.flow_u0_encap_data.dash_encapsulation;
#else
meta.encap_data = hdr.flow_encap_data;
meta.u0_encap_data = hdr.flow_u0_encap_data;
#endif // TARGET_DPDK_PNA

/* tunnel metadata */
#ifdef TARGET_DPDK_PNA
meta.tunnel_data.vni = hdr.flow_tunnel_data.vni;
meta.tunnel_data.underlay_sip = hdr.flow_tunnel_data.underlay_sip;
meta.tunnel_data.underlay_dip = hdr.flow_tunnel_data.underlay_dip;
meta.tunnel_data.underlay_smac = hdr.flow_tunnel_data.underlay_smac;
meta.tunnel_data.underlay_dmac = hdr.flow_tunnel_data.underlay_dmac;
meta.tunnel_data.dash_encapsulation = hdr.flow_tunnel_data.dash_encapsulation;
meta.u1_encap_data.vni = hdr.flow_u1_encap_data.vni;
meta.u1_encap_data.underlay_sip = hdr.flow_u1_encap_data.underlay_sip;
meta.u1_encap_data.underlay_dip = hdr.flow_u1_encap_data.underlay_dip;
meta.u1_encap_data.underlay_smac = hdr.flow_u1_encap_data.underlay_smac;
meta.u1_encap_data.underlay_dmac = hdr.flow_u1_encap_data.underlay_dmac;
meta.u1_encap_data.dash_encapsulation = hdr.flow_u1_encap_data.dash_encapsulation;
#else
meta.tunnel_data = hdr.flow_tunnel_data;
meta.u1_encap_data = hdr.flow_u1_encap_data;
#endif // TARGET_DPDK_PNA

/* overlay rewrite metadata */
Expand All @@ -55,8 +55,8 @@ action conntrack_strip_dash_header(inout headers_t hdr)
hdr.flow_key.setInvalid();
hdr.flow_data.setInvalid();
hdr.flow_overlay_data.setInvalid();
hdr.flow_encap_data.setInvalid();
hdr.flow_tunnel_data.setInvalid();
hdr.flow_u0_encap_data.setInvalid();
hdr.flow_u1_encap_data.setInvalid();
}

control conntrack_build_dash_header(inout headers_t hdr, in metadata_t meta,
Expand All @@ -75,30 +75,30 @@ control conntrack_build_dash_header(inout headers_t hdr, in metadata_t meta,

if (meta.routing_actions & dash_routing_actions_t.ENCAP_U0 != 0) {
#ifdef TARGET_DPDK_PNA
hdr.flow_encap_data.setValid();
hdr.flow_encap_data.vni = meta.encap_data.vni;
hdr.flow_encap_data.underlay_sip = meta.encap_data.underlay_sip;
hdr.flow_encap_data.underlay_dip = meta.encap_data.underlay_dip;
hdr.flow_encap_data.underlay_smac = meta.encap_data.underlay_smac;
hdr.flow_encap_data.underlay_dmac = meta.encap_data.underlay_dmac;
hdr.flow_encap_data.dash_encapsulation = meta.encap_data.dash_encapsulation;
hdr.flow_u0_encap_data.setValid();
hdr.flow_u0_encap_data.vni = meta.u0_encap_data.vni;
hdr.flow_u0_encap_data.underlay_sip = meta.u0_encap_data.underlay_sip;
hdr.flow_u0_encap_data.underlay_dip = meta.u0_encap_data.underlay_dip;
hdr.flow_u0_encap_data.underlay_smac = meta.u0_encap_data.underlay_smac;
hdr.flow_u0_encap_data.underlay_dmac = meta.u0_encap_data.underlay_dmac;
hdr.flow_u0_encap_data.dash_encapsulation = meta.u0_encap_data.dash_encapsulation;
#else
hdr.flow_encap_data= meta.encap_data;
hdr.flow_u0_encap_data= meta.u0_encap_data;
#endif // TARGET_DPDK_PNA
length = length + ENCAP_DATA_HDR_SIZE;
}

if (meta.routing_actions & dash_routing_actions_t.ENCAP_U1 != 0) {
#ifdef TARGET_DPDK_PNA
hdr.flow_tunnel_data.setValid();
hdr.flow_tunnel_data.vni = meta.tunnel_data.vni;
hdr.flow_tunnel_data.underlay_sip = meta.tunnel_data.underlay_sip;
hdr.flow_tunnel_data.underlay_dip = meta.tunnel_data.underlay_dip;
hdr.flow_tunnel_data.underlay_smac = meta.tunnel_data.underlay_smac;
hdr.flow_tunnel_data.underlay_dmac = meta.tunnel_data.underlay_dmac;
hdr.flow_tunnel_data.dash_encapsulation = meta.tunnel_data.dash_encapsulation;
hdr.flow_u1_encap_data.setValid();
hdr.flow_u1_encap_data.vni = meta.u1_encap_data.vni;
hdr.flow_u1_encap_data.underlay_sip = meta.u1_encap_data.underlay_sip;
hdr.flow_u1_encap_data.underlay_dip = meta.u1_encap_data.underlay_dip;
hdr.flow_u1_encap_data.underlay_smac = meta.u1_encap_data.underlay_smac;
hdr.flow_u1_encap_data.underlay_dmac = meta.u1_encap_data.underlay_dmac;
hdr.flow_u1_encap_data.dash_encapsulation = meta.u1_encap_data.dash_encapsulation;
#else
hdr.flow_tunnel_data= meta.tunnel_data;
hdr.flow_u1_encap_data= meta.u1_encap_data;
#endif // TARGET_DPDK_PNA
length = length + ENCAP_DATA_HDR_SIZE;
}
Expand Down Expand Up @@ -128,7 +128,7 @@ control conntrack_build_dash_header(inout headers_t hdr, in metadata_t meta,

hdr.dp_ethernet.setValid();
hdr.dp_ethernet.dst_addr = DPAPP_MAC;
hdr.dp_ethernet.src_addr = meta.encap_data.underlay_smac;
hdr.dp_ethernet.src_addr = meta.u0_encap_data.underlay_smac;
hdr.dp_ethernet.ether_type = DASH_ETHTYPE;
}
}
Expand Down Expand Up @@ -280,19 +280,19 @@ control conntrack_lookup_stage(inout headers_t hdr, inout metadata_t meta) {
;

/* Set encapsulation metadata */
meta.encap_data.vni = underlay0_vnet_id;
meta.encap_data.underlay_sip = underlay0_sip;
meta.encap_data.underlay_dip = underlay0_dip;
meta.encap_data.dash_encapsulation = underlay0_dash_encapsulation;
meta.encap_data.underlay_smac = underlay0_smac;
meta.encap_data.underlay_dmac = underlay0_dmac;

meta.tunnel_data.vni = underlay1_vnet_id;
meta.tunnel_data.underlay_sip = underlay1_sip;
meta.tunnel_data.underlay_dip = underlay1_dip;
meta.tunnel_data.dash_encapsulation = underlay1_dash_encapsulation;
meta.tunnel_data.underlay_smac = underlay1_smac;
meta.tunnel_data.underlay_dmac = underlay1_dmac;
meta.u0_encap_data.vni = underlay0_vnet_id;
meta.u0_encap_data.underlay_sip = underlay0_sip;
meta.u0_encap_data.underlay_dip = underlay0_dip;
meta.u0_encap_data.dash_encapsulation = underlay0_dash_encapsulation;
meta.u0_encap_data.underlay_smac = underlay0_smac;
meta.u0_encap_data.underlay_dmac = underlay0_dmac;

meta.u1_encap_data.vni = underlay1_vnet_id;
meta.u1_encap_data.underlay_sip = underlay1_sip;
meta.u1_encap_data.underlay_dip = underlay1_dip;
meta.u1_encap_data.dash_encapsulation = underlay1_dash_encapsulation;
meta.u1_encap_data.underlay_smac = underlay1_smac;
meta.u1_encap_data.underlay_dmac = underlay1_dmac;

/* Set overlay rewrite metadata */
meta.overlay_data.dmac = dst_mac;
Expand Down
2 changes: 1 addition & 1 deletion dash-pipeline/bmv2/stages/outbound_mapping.p4
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ control outbound_mapping_stage(
}

action set_vnet_attrs(bit<24> vni) {
meta.encap_data.vni = vni;
meta.u0_encap_data.vni = vni;
}

@SaiTable[name = "vnet", api = "dash_vnet", isobject="true"]
Expand Down
6 changes: 3 additions & 3 deletions dash-pipeline/bmv2/stages/pre_pipeline.p4
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ control pre_pipeline_stage(inout headers_t hdr,

action set_underlay_mac(EthernetAddress neighbor_mac,
EthernetAddress mac) {
meta.encap_data.underlay_dmac = neighbor_mac;
meta.encap_data.underlay_smac = mac;
meta.u0_encap_data.underlay_dmac = neighbor_mac;
meta.u0_encap_data.underlay_smac = mac;
}

/* This table API should be implemented manually using underlay SAI */
Expand Down Expand Up @@ -109,7 +109,7 @@ control pre_pipeline_stage(inout headers_t hdr,

if (vip.apply().hit) {
/* Use the same VIP that was in packet's destination if it's present in the VIP table */
meta.encap_data.underlay_sip = meta.rx_encap.underlay_dip;
meta.u0_encap_data.underlay_sip = meta.rx_encap.underlay_dip;
} else {
UPDATE_COUNTER(vip_miss_drop, 0);

Expand Down

0 comments on commit 443f27f

Please sign in to comment.