Skip to content

Commit

Permalink
[SAIP4] Introduce new unsupported tunnel_decap action. (sonic-net#641)
Browse files Browse the repository at this point in the history
Co-authored-by: kishanps <[email protected]>
Co-authored-by: rhalstea <[email protected]>
Co-authored-by: smolkaj <[email protected]>
  • Loading branch information
4 people authored Oct 21, 2024
1 parent 3e2f9fb commit e39edad
Show file tree
Hide file tree
Showing 12 changed files with 184 additions and 213 deletions.
24 changes: 12 additions & 12 deletions sai_p4/fixed/ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@
#define MIRRORING_MIRROR_AS_IPV4_ERSPAN_ACTION_ID 0x01000007 // 16777223
#define CLONING_INGRESS_CLONE_ACTION_ID 0x0100001C // 16777244
#define CLONING_MIRROR_WITH_VLAN_TAG_AND_IPFIX_ENCAPSULATION_ACTION_ID \
0x0100001D // 16777245
#define L3_ADMIT_ACTION_ID 0x01000008 // 16777224
#define MIRRORING_SET_PRE_SESSION_ACTION_ID 0x01000009 // 16777225
#define SELECT_ECMP_HASH_ALGORITHM_ACTION_ID 0x010000A // 16777226
#define COMPUTE_ECMP_HASH_IPV4_ACTION_ID 0x0100000B // 16777227
#define COMPUTE_ECMP_HASH_IPV6_ACTION_ID 0x0100000C // 16777228
#define COMPUTE_LAG_HASH_IPV4_ACTION_ID 0x0100000D // 16777229
#define COMPUTE_LAG_HASH_IPV6_ACTION_ID 0x0100000E // 16777230
#define ROUTING_SET_METADATA_AND_DROP_ACTION_ID 0x01000015 // 16777237
#define MARK_FOR_TUNNEL_DECAP_AND_SET_VRF_ACTION_ID 0x01000016 // 16777238
#define DISABLE_VLAN_CHECKS_ACTION_ID 0x0100001A // 16777242
// Next available action id: 0x0100001E (16777246)
0x0100001D // 16777245
#define L3_ADMIT_ACTION_ID 0x01000008 // 16777224
#define MIRRORING_SET_PRE_SESSION_ACTION_ID 0x01000009 // 16777225
#define SELECT_ECMP_HASH_ALGORITHM_ACTION_ID 0x010000A // 16777226
#define COMPUTE_ECMP_HASH_IPV4_ACTION_ID 0x0100000B // 16777227
#define COMPUTE_ECMP_HASH_IPV6_ACTION_ID 0x0100000C // 16777228
#define COMPUTE_LAG_HASH_IPV4_ACTION_ID 0x0100000D // 16777229
#define COMPUTE_LAG_HASH_IPV6_ACTION_ID 0x0100000E // 16777230
#define ROUTING_SET_METADATA_AND_DROP_ACTION_ID 0x01000015 // 16777237
#define TUNNEL_DECAP_ACTION_ID 0x01000016 // 16777238
#define DISABLE_VLAN_CHECKS_ACTION_ID 0x0100001A // 16777242
// Next available action id: 0x0100001F (16777247)

// --- Action Profiles and Selectors (8 most significant bits = 0x11) ----------
// This value should ideally be 0x11000001, but we currently have this value for
Expand Down
35 changes: 18 additions & 17 deletions sai_p4/fixed/tunnel_termination.p4
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,23 @@
#ifndef SAI_TUNNEL_TERMINATION_P4_
#define SAI_TUNNEL_TERMINATION_P4_

// Should be applied at the beginning of the pre-ingress stage.
control tunnel_termination_lookup(in headers_t headers,
#include <v1model.p4>
#include "headers.p4"
#include "metadata.p4"
#include "ids.h"
#include "minimum_guaranteed_sizes.p4"

// Should be applied at the end of the pre-ingress stage.
control tunnel_termination(inout headers_t headers,
inout local_metadata_t local_metadata) {
bool marked_for_ip_in_ipv6_decap = false;

// Sets SAI_TUNNEL_TERM_TABLE_ENTRY_ATTR_VR_ID.
@id(MARK_FOR_TUNNEL_DECAP_AND_SET_VRF_ACTION_ID)
action mark_for_tunnel_decap_and_set_vrf(vrf_id_t vrf_id) {
// Actual decap is delayed until the end of the pre-ingress stage.
local_metadata.apply_tunnel_decap_at_end_of_pre_ingress = true;
local_metadata.vrf_id = vrf_id;
@id(TUNNEL_DECAP_ACTION_ID)
@unsupported
action tunnel_decap() {
// Bmv2 does not support if statements in actions, so control metadata is
// set and decapping is performed post-action.
marked_for_ip_in_ipv6_decap = true;
}

// Models SAI_TUNNEL_TERM_TABLE.
Expand All @@ -36,6 +43,7 @@ control tunnel_termination_lookup(in headers_t headers,
@unsupported
@p4runtime_role(P4RUNTIME_ROLE_ROUTING)
@id(IPV6_TUNNEL_TERMINATION_TABLE_ID)
@unsupported
table ipv6_tunnel_termination_table {
key = {
// Sets `SAI_TUNNEL_TERM_TABLE_ENTRY_ATTR_DST_IP[_MASK]`.
Expand All @@ -46,7 +54,7 @@ control tunnel_termination_lookup(in headers_t headers,
@id(2) @name("src_ipv6") @format(IPV6_ADDRESS);
}
actions = {
@proto_id(1) mark_for_tunnel_decap_and_set_vrf;
@proto_id(1) tunnel_decap;
}
size = IPV6_TUNNEL_TERMINATION_TABLE_MINIMUM_GUARANTEED_SIZE;
}
Expand All @@ -61,15 +69,8 @@ control tunnel_termination_lookup(in headers_t headers,
ipv6_tunnel_termination_table.apply();
}
}
}

}

// Should be applied at the end of the pre-ingress stage.
control tunnel_termination_decap(inout headers_t headers,
in local_metadata_t local_metadata) {
apply {
if (local_metadata.apply_tunnel_decap_at_end_of_pre_ingress) {
if (marked_for_ip_in_ipv6_decap) {
// Currently, this should only ever be set for IP-in-IPv6 packets.
// TODO: Remove guard once p4-symbolic suports assertions.
#ifndef PLATFORM_P4SYMBOLIC
Expand Down
3 changes: 1 addition & 2 deletions sai_p4/instantiations/google/fabric_border_router.p4
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ control ingress(inout headers_t headers,
apply {
packet_out_decap.apply(headers, local_metadata, standard_metadata);
if (!local_metadata.bypass_ingress) {
tunnel_termination_lookup.apply(headers, local_metadata);
vlan_untag.apply(headers, local_metadata, standard_metadata);
acl_pre_ingress.apply(headers, local_metadata, standard_metadata);
ingress_vlan_checks.apply(headers, local_metadata, standard_metadata);
tunnel_termination_decap.apply(headers, local_metadata);
tunnel_termination.apply(headers, local_metadata);
admit_google_system_mac.apply(headers, local_metadata);
l3_admit.apply(headers, local_metadata, standard_metadata);
routing_lookup.apply(headers, local_metadata, standard_metadata);
Expand Down
89 changes: 42 additions & 47 deletions sai_p4/instantiations/google/fabric_border_router.p4info.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,6 @@ pkg_info {
arch: "v1model"
organization: "Google"
}
tables {
preamble {
id: 33554507
name: "ingress.tunnel_termination_lookup.ipv6_tunnel_termination_table"
alias: "ipv6_tunnel_termination_table"
annotations: "@unsupported"
annotations: "@p4runtime_role(\"sdn_controller\")"
}
match_fields {
id: 1
name: "dst_ipv6"
annotations: "@format(IPV6_ADDRESS)"
bitwidth: 128
match_type: TERNARY
}
match_fields {
id: 2
name: "src_ipv6"
annotations: "@format(IPV6_ADDRESS)"
bitwidth: 128
match_type: TERNARY
}
action_refs {
id: 16777238
annotations: "@proto_id(1)"
}
action_refs {
id: 21257015
annotations: "@defaultonly"
scope: DEFAULT_ONLY
}
size: 126
}
tables {
preamble {
id: 33554509
Expand Down Expand Up @@ -161,6 +128,40 @@ tables {
direct_resource_ids: 318767361
size: 254
}
tables {
preamble {
id: 33554507
name: "ingress.tunnel_termination.ipv6_tunnel_termination_table"
alias: "ipv6_tunnel_termination_table"
annotations: "@unsupported"
annotations: "@p4runtime_role(\"sdn_controller\")"
annotations: "@unsupported"
}
match_fields {
id: 1
name: "dst_ipv6"
annotations: "@format(IPV6_ADDRESS)"
bitwidth: 128
match_type: TERNARY
}
match_fields {
id: 2
name: "src_ipv6"
annotations: "@format(IPV6_ADDRESS)"
bitwidth: 128
match_type: TERNARY
}
action_refs {
id: 16777238
annotations: "@proto_id(1)"
}
action_refs {
id: 21257015
annotations: "@defaultonly"
scope: DEFAULT_ONLY
}
size: 126
}
tables {
preamble {
id: 33554503
Expand Down Expand Up @@ -1125,20 +1126,6 @@ actions {
annotations: "@sai_action(SAI_PACKET_ACTION_DROP)"
}
}
actions {
preamble {
id: 16777238
name: "ingress.tunnel_termination_lookup.mark_for_tunnel_decap_and_set_vrf"
alias: "mark_for_tunnel_decap_and_set_vrf"
}
params {
id: 1
name: "vrf_id"
type_name {
name: "vrf_id_t"
}
}
}
actions {
preamble {
id: 16777242
Expand All @@ -1163,6 +1150,14 @@ actions {
}
}
}
actions {
preamble {
id: 16777238
name: "ingress.tunnel_termination.tunnel_decap"
alias: "tunnel_decap"
annotations: "@unsupported"
}
}
actions {
preamble {
id: 16777224
Expand Down
3 changes: 1 addition & 2 deletions sai_p4/instantiations/google/middleblock.p4
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ control ingress(inout headers_t headers,
apply {
packet_out_decap.apply(headers, local_metadata, standard_metadata);
if (!local_metadata.bypass_ingress) {
tunnel_termination_lookup.apply(headers, local_metadata);
vlan_untag.apply(headers, local_metadata, standard_metadata);
acl_pre_ingress.apply(headers, local_metadata, standard_metadata);
ingress_vlan_checks.apply(headers, local_metadata, standard_metadata);
tunnel_termination_decap.apply(headers, local_metadata);
tunnel_termination.apply(headers, local_metadata);
admit_google_system_mac.apply(headers, local_metadata);
l3_admit.apply(headers, local_metadata, standard_metadata);
routing_lookup.apply(headers, local_metadata, standard_metadata);
Expand Down
89 changes: 42 additions & 47 deletions sai_p4/instantiations/google/middleblock.p4info.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,6 @@ pkg_info {
arch: "v1model"
organization: "Google"
}
tables {
preamble {
id: 33554507
name: "ingress.tunnel_termination_lookup.ipv6_tunnel_termination_table"
alias: "ipv6_tunnel_termination_table"
annotations: "@unsupported"
annotations: "@p4runtime_role(\"sdn_controller\")"
}
match_fields {
id: 1
name: "dst_ipv6"
annotations: "@format(IPV6_ADDRESS)"
bitwidth: 128
match_type: TERNARY
}
match_fields {
id: 2
name: "src_ipv6"
annotations: "@format(IPV6_ADDRESS)"
bitwidth: 128
match_type: TERNARY
}
action_refs {
id: 16777238
annotations: "@proto_id(1)"
}
action_refs {
id: 21257015
annotations: "@defaultonly"
scope: DEFAULT_ONLY
}
size: 126
}
tables {
preamble {
id: 33554509
Expand Down Expand Up @@ -153,6 +120,40 @@ tables {
direct_resource_ids: 318767361
size: 254
}
tables {
preamble {
id: 33554507
name: "ingress.tunnel_termination.ipv6_tunnel_termination_table"
alias: "ipv6_tunnel_termination_table"
annotations: "@unsupported"
annotations: "@p4runtime_role(\"sdn_controller\")"
annotations: "@unsupported"
}
match_fields {
id: 1
name: "dst_ipv6"
annotations: "@format(IPV6_ADDRESS)"
bitwidth: 128
match_type: TERNARY
}
match_fields {
id: 2
name: "src_ipv6"
annotations: "@format(IPV6_ADDRESS)"
bitwidth: 128
match_type: TERNARY
}
action_refs {
id: 16777238
annotations: "@proto_id(1)"
}
action_refs {
id: 21257015
annotations: "@defaultonly"
scope: DEFAULT_ONLY
}
size: 126
}
tables {
preamble {
id: 33554503
Expand Down Expand Up @@ -1080,20 +1081,6 @@ actions {
annotations: "@sai_action(SAI_PACKET_ACTION_DROP)"
}
}
actions {
preamble {
id: 16777238
name: "ingress.tunnel_termination_lookup.mark_for_tunnel_decap_and_set_vrf"
alias: "mark_for_tunnel_decap_and_set_vrf"
}
params {
id: 1
name: "vrf_id"
type_name {
name: "vrf_id_t"
}
}
}
actions {
preamble {
id: 16777242
Expand All @@ -1118,6 +1105,14 @@ actions {
}
}
}
actions {
preamble {
id: 16777238
name: "ingress.tunnel_termination.tunnel_decap"
alias: "tunnel_decap"
annotations: "@unsupported"
}
}
actions {
preamble {
id: 16777224
Expand Down
8 changes: 4 additions & 4 deletions sai_p4/instantiations/google/sai_pd.proto
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ message Ipv6TunnelTerminationTableEntry {
}
Match match = 1;
message Action {
MarkForTunnelDecapAndSetVrfAction mark_for_tunnel_decap_and_set_vrf = 1;
// CAUTION: This action is not (yet) supported.
TunnelDecapAction tunnel_decap = 1;
}
Action action = 2;
int32 priority = 3;
Expand Down Expand Up @@ -858,9 +859,8 @@ message SetMetadataAndDropAction {
string route_metadata = 1; // Format::HEX_STRING / 6 bits
}

message MarkForTunnelDecapAndSetVrfAction {
string vrf_id = 1; // Format::STRING
}
// CAUTION: This action is not (yet) supported.
message TunnelDecapAction {}

message SetIpNexthopAndDisableRewritesAction {
// Refers to 'router_interface_table.router_interface_id'.
Expand Down
Loading

0 comments on commit e39edad

Please sign in to comment.