forked from sonic-net/DASH
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
201 additions
and
3 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
107 changes: 107 additions & 0 deletions
107
dash-pipeline/bmv2/routing_actions/routing_action_reverse_tunnel.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,107 @@ | ||
#ifndef _DASH_ROUTING_ACTION_REVERSE_TUNNEL_P4_ | ||
#define _DASH_ROUTING_ACTION_REVERSE_TUNNEL_P4_ | ||
|
||
action push_action_reverse_tunnel( | ||
in headers_t hdr, | ||
inout metadata_t meta, | ||
in bit<16> dash_reverse_tunnel_id) | ||
{ | ||
meta.routing_actions = meta.routing_actions | dash_routing_actions_t.REVERSE_TUNNEL; | ||
|
||
meta.dash_reverse_tunnel_id = dash_reverse_tunnel_id; | ||
} | ||
|
||
control do_action_reverse_tunnel( | ||
inout headers_t hdr, | ||
inout metadata_t meta) | ||
{ | ||
// | ||
// Reverse Tunnel | ||
// | ||
action set_reverse_tunnel_attrs( | ||
@SaiVal[type="sai_dash_encapsulation_t", default_value="SAI_DASH_ENCAPSULATION_VXLAN"] dash_encapsulation_t dash_encapsulation, | ||
bit<24> tunnel_key | ||
) { | ||
meta.reverse_tunnel_data.dash_encapsulation = dash_encapsulation; | ||
meta.reverse_tunnel_data.vni = tunnel_key; | ||
} | ||
|
||
@SaiTable[name = "dash_reverse_tunnel", api = "dash_reverse_tunnel", order = 0, isobject="true"] | ||
table reverse_tunnel { | ||
key = { | ||
meta.dash_reverse_tunnel_id : exact @SaiVal[type="sai_object_id_t"]; | ||
} | ||
|
||
actions = { | ||
set_reverse_tunnel_attrs; | ||
} | ||
} | ||
|
||
// | ||
// Reverse tunnel member | ||
// | ||
action set_reverse_tunnel_member_attrs( | ||
@SaiVal[type="sai_object_id_t"] bit<16> dash_reverse_tunnel_next_hop_id | ||
) { | ||
meta.dash_reverse_tunnel_next_hop_id = dash_reverse_tunnel_next_hop_id; | ||
} | ||
|
||
@SaiTable[name = "dash_reverse_tunnel", api = "dash_reverse_tunnel", order = 1, isobject="true"] | ||
table reverse_tunnel_member { | ||
key = { | ||
meta.dash_reverse_tunnel_id : exact @SaiVal[type="sai_object_id_t"]; | ||
meta.dash_reverse_tunnel_member_id : exact @SaiVal[type="sai_object_id_t"]; | ||
} | ||
|
||
actions = { | ||
set_reverse_tunnel_member_attrs; | ||
} | ||
} | ||
|
||
// | ||
// Reverse tunnel next hop | ||
// | ||
action set_reverse_tunnel_next_hop_attrs( | ||
@SaiVal[type="sai_ip_address_t"] IPv4Address dip, | ||
@SaiVal[type="sai_ip_address_t"] IPv4Address sip | ||
) { | ||
meta.reverse_tunnel_data.underlay_dip = dip; | ||
meta.reverse_tunnel_data.underlay_sip = sip; | ||
} | ||
|
||
@SaiTable[name = "dash_reverse_tunnel", api = "dash_reverse_tunnel", order = 2, isobject="true"] | ||
table reverse_tunnel_next_hop { | ||
key = { | ||
meta.dash_reverse_tunnel_next_hop_id : exact @SaiVal[type="sai_object_id_t"]; | ||
} | ||
|
||
actions = { | ||
set_reverse_tunnel_next_hop_attrs; | ||
} | ||
} | ||
|
||
apply { | ||
if (meta.routing_actions & dash_routing_actions_t.REVERSE_TUNNEL == 0) { | ||
return; | ||
} | ||
|
||
if (!reverse_tunnel.apply().hit) { | ||
UPDATE_ENI_COUNTER(reverse_tunnel_miss_drop); | ||
return; | ||
} | ||
|
||
meta.dash_reverse_tunnel_member_id = 0; // TODO: ECMP group selection! | ||
|
||
if (!reverse_tunnel_member.apply().hit) { | ||
UPDATE_ENI_COUNTER(reverse_tunnel_member_miss_drop); | ||
return; | ||
} | ||
|
||
if (!reverse_tunnel_next_hop.apply().hit) { | ||
UPDATE_ENI_COUNTER(reverse_tunnel_next_hop_miss_drop); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
#endif /* _DASH_ROUTING_ACTION_REVERSE_TUNNEL_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
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,70 @@ | ||
#ifndef _DASH_STAGE_OUTBOUND_REVERSE_reverse_routing_P4_ | ||
#define _DASH_STAGE_OUTBOUND_REVERSE_reverse_routing_P4_ | ||
|
||
control outbound_reverse_routing_stage( | ||
inout headers_t hdr, | ||
inout metadata_t meta | ||
) { | ||
// | ||
// Reverse routing group table | ||
// | ||
action set_outbound_reverse_routing_group_attr(bit<1> disabled) { | ||
meta.outbound_reverse_routing_data.disabled = (bool)disabled; | ||
} | ||
|
||
@SaiTable[name = "outbound_reverse_routing_group", api = "dash_outbound_reverse_routing", order = 1, isobject="true"] | ||
table outbound_reverse_routing_group { | ||
key = { | ||
meta.outbound_reverse_routing_data.routing_group_id: exact @SaiVal[type="sai_object_id_t"]; | ||
} | ||
|
||
actions = { | ||
set_outbound_reverse_routing_group_attr; | ||
} | ||
} | ||
|
||
// | ||
// Reverse routing table | ||
// | ||
action set_outbound_reverse_routing_entry_attr( | ||
@SaiVal[type="sai_object_id_t"] bit<16> dash_reverse_tunnel_id, | ||
dash_routing_actions_t routing_actions_disabled_in_flow_resimulation | ||
) { | ||
push_action_reverse_tunnel(hdr, meta, dash_reverse_tunnel_id); | ||
} | ||
|
||
DEFINE_TABLE_COUNTER(reverse_routing_counter) | ||
|
||
@SaiTable[name = "outbound_reverse_routing", api = "dash_outbound_reverse_routing"] | ||
table reverse_routing { | ||
key = { | ||
meta.outbound_reverse_routing_data.routing_group_id : exact @SaiVal[type="sai_object_id_t"]; | ||
meta.is_overlay_ip_v6 : exact @SaiVal[name = "source_is_v6"]; | ||
meta.src_ip_addr : lpm @SaiVal[name = "source"]; | ||
} | ||
|
||
actions = { | ||
set_outbound_reverse_routing_entry_attr; | ||
} | ||
|
||
size = 4 * 1024 * 1024; | ||
|
||
ATTACH_TABLE_COUNTER(reverse_routing_counter) | ||
} | ||
|
||
apply { | ||
// If reverse routing stage tables are not hit, we don't need to drop the packet. | ||
// This simply means no reverse routing is needed, and we can continue to the next stage. | ||
if (!outbound_reverse_routing_group.apply().hit) { | ||
return; | ||
} | ||
|
||
if (meta.outbound_reverse_routing_data.disabled) { | ||
return; | ||
} | ||
|
||
reverse_routing.apply(); | ||
} | ||
} | ||
|
||
#endif /* _DASH_STAGE_OUTBOUND_REVERSE_reverse_routing_P4_ */ |