-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dash-p4] Add skeleton for matching stage transition control and extr…
…act the matching stages in outbound pipeline into dedicated file. (#527) ## Problem Currently, the routing types in DASH is used to define 2 things: - Stage transition: which stage we need to run as the next stage - Routing actions: what SDN transformations are required if this stage is the last stage used to match the packets. Although the concepts are there, in DASH P4 code, these concepts are not reflected in a modularized way, and sometimes not that obvious as the transition cannot be found in the definitions of the routing types (P4 table actions). ## What this change is doing This commit contains 2 changes inside: - Add skeleton for matching stage transition control - Extract the matching stages in outbound pipeline into dedicated file These changes are intended to help with: - Modularization and readability of the pipeline. - Make the stage transition control more explicit and obvious. This commit will not change any generated SAI APIs.
- Loading branch information
Showing
6 changed files
with
136 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#ifndef _DASH_STAGE_OUTBOUND_MAPPING_P4_ | ||
#define _DASH_STAGE_OUTBOUND_MAPPING_P4_ | ||
|
||
#include "../dash_routing_types.p4" | ||
|
||
control outbound_mapping_stage(inout headers_t hdr, | ||
inout metadata_t meta) | ||
{ | ||
DEFINE_TABLE_COUNTER(ca_to_pa_counter) | ||
|
||
@SaiTable[name = "outbound_ca_to_pa", api = "dash_outbound_ca_to_pa"] | ||
table ca_to_pa { | ||
key = { | ||
/* Flow for express route */ | ||
meta.dst_vnet_id: exact @SaiVal[type="sai_object_id_t"]; | ||
meta.is_lkup_dst_ip_v6 : exact @SaiVal[name = "dip_is_v6"]; | ||
meta.lkup_dst_ip_addr : exact @SaiVal[name = "dip"]; | ||
} | ||
|
||
actions = { | ||
set_tunnel_mapping(hdr, meta); | ||
set_private_link_mapping(hdr, meta); | ||
@defaultonly drop(meta); | ||
} | ||
const default_action = drop(meta); | ||
|
||
ATTACH_TABLE_COUNTER(ca_to_pa_counter) | ||
} | ||
|
||
action set_vnet_attrs(bit<24> vni) { | ||
meta.encap_data.vni = vni; | ||
} | ||
|
||
@SaiTable[name = "vnet", api = "dash_vnet", isobject="true"] | ||
table vnet { | ||
key = { | ||
meta.vnet_id : exact @SaiVal[type="sai_object_id_t"]; | ||
} | ||
|
||
actions = { | ||
set_vnet_attrs; | ||
} | ||
} | ||
|
||
apply { | ||
if (meta.target_stage != dash_pipeline_stage_t.OUTBOUND_MAPPING) { | ||
return; | ||
} | ||
|
||
switch (ca_to_pa.apply().action_run) { | ||
set_tunnel_mapping: { | ||
vnet.apply(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif /* _DASH_STAGE_OUTBOUND_MAPPING_P4_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef _DASH_STAGE_OUTBOUND_ROUTING_P4_ | ||
#define _DASH_STAGE_OUTBOUND_ROUTING_P4_ | ||
|
||
#include "../dash_routing_types.p4" | ||
|
||
control outbound_routing_stage(inout headers_t hdr, | ||
inout metadata_t meta) | ||
{ | ||
DEFINE_TABLE_COUNTER(routing_counter) | ||
|
||
@SaiTable[name = "outbound_routing", api = "dash_outbound_routing"] | ||
table routing { | ||
key = { | ||
meta.eni_id : exact @SaiVal[type="sai_object_id_t"]; | ||
meta.is_overlay_ip_v6 : exact @SaiVal[name = "destination_is_v6"]; | ||
meta.dst_ip_addr : lpm @SaiVal[name = "destination"]; | ||
} | ||
|
||
actions = { | ||
route_vnet(hdr, meta); /* for expressroute - ecmp of overlay */ | ||
route_vnet_direct(hdr, meta); | ||
route_direct(hdr, meta); | ||
route_service_tunnel(hdr, meta); | ||
drop(meta); | ||
} | ||
const default_action = drop(meta); | ||
|
||
ATTACH_TABLE_COUNTER(routing_counter) | ||
} | ||
|
||
apply { | ||
if (meta.target_stage != dash_pipeline_stage_t.OUTBOUND_ROUTING) { | ||
return; | ||
} | ||
|
||
routing.apply(); | ||
} | ||
} | ||
|
||
#endif /* _DASH_STAGE_OUTBOUND_ROUTING_P4_ */ |