Fix VLAN and MPLS problem for fabric.p4

MPLS and VLAN won't work if we port fabric.p4 to PSA like architecture

Change-Id: Ife2ed4a09816981c712f4a3b78408536a21defee
This commit is contained in:
Yi Tseng 2018-01-22 17:18:16 -08:00
parent 239492c218
commit bd46d05410
5 changed files with 226 additions and 477 deletions

View File

@ -154,13 +154,10 @@ control Forwarding (
if(fabric_metadata.fwd_type == FWD_BRIDGING) bridging.apply();
else if (fabric_metadata.fwd_type == FWD_MPLS) {
mpls.apply();
if (hdr.ipv4.isValid()) {
hdr.ethernet.ether_type = ETHERTYPE_IPV4;
fabric_metadata.original_ether_type = ETHERTYPE_IPV4;
} else {
hdr.ethernet.ether_type = ETHERTYPE_IPV6;
fabric_metadata.original_ether_type = ETHERTYPE_IPV6;
}
// TODO: IPv6
hdr.vlan_tag.ether_type = ETHERTYPE_IPV4;
fabric_metadata.original_ether_type = ETHERTYPE_IPV4;
}
else if (fabric_metadata.fwd_type == FWD_IPV4_UNICAST) unicast_v4.apply();
else if (fabric_metadata.fwd_type == FWD_IPV4_MULTICAST) multicast_v4.apply();

View File

@ -63,7 +63,7 @@ control Next (
action push_mpls (mpls_label_t label, bit<3> tc) {
// Suppose that the maximum number of label is one.
hdr.mpls.setValid();
hdr.ethernet.ether_type = ETHERTYPE_MPLS;
hdr.vlan_tag.ether_type = ETHERTYPE_MPLS;
hdr.mpls.label = label;
hdr.mpls.tc = tc;
hdr.mpls.bos = 1w1; // BOS = TRUE
@ -157,11 +157,7 @@ control EgressNextControl (
apply {
// pop internal vlan if the meta is set
if (fabric_metadata.pop_vlan_at_egress) {
if (hdr.mpls.isValid()) {
hdr.ethernet.ether_type = ETHERTYPE_MPLS;
} else {
hdr.ethernet.ether_type = fabric_metadata.original_ether_type;
}
hdr.ethernet.ether_type = hdr.vlan_tag.ether_type;
hdr.vlan_tag.setInvalid();
}
}

View File

@ -129,7 +129,6 @@ struct fabric_metadata_t {
struct parsed_headers_t {
ethernet_t ethernet;
vlan_tag_t vlan_tag;
vlan_tag_t inner_vlan_tag;
mpls_t mpls;
ipv4_t ipv4;
ipv6_t ipv6;

View File

@ -41,8 +41,6 @@ inout standard_metadata_t standard_metadata) {
packet.extract(hdr.ethernet);
fabric_metadata.original_ether_type = hdr.ethernet.ether_type;
transition select(hdr.ethernet.ether_type){
ETHERTYPE_QINQ_NON_STD: parse_vlan_tag;
ETHERTYPE_QINQ: parse_vlan_tag;
ETHERTYPE_VLAN: parse_vlan_tag;
ETHERTYPE_MPLS: parse_mpls;
ETHERTYPE_ARP: parse_arp;
@ -54,21 +52,11 @@ inout standard_metadata_t standard_metadata) {
state parse_vlan_tag {
packet.extract(hdr.vlan_tag);
transition select(hdr.vlan_tag.ether_type){
ETHERTYPE_VLAN: parse_inner_vlan_tag;
ETHERTYPE_ARP: parse_arp;
ETHERTYPE_IPV4: parse_ipv4;
ETHERTYPE_IPV6: parse_ipv6;
default: accept;
}
}
state parse_inner_vlan_tag {
packet.extract(hdr.inner_vlan_tag);
transition select(hdr.vlan_tag.ether_type){
ETHERTYPE_ARP: parse_arp;
ETHERTYPE_IPV4: parse_ipv4;
ETHERTYPE_IPV6: parse_ipv6;
ETHERTYPE_MPLS: parse_mpls;
default: accept;
}
}
@ -139,7 +127,6 @@ control FabricDeparser(packet_out packet, in parsed_headers_t hdr) {
packet.emit(hdr.packet_in);
packet.emit(hdr.ethernet);
packet.emit(hdr.vlan_tag);
packet.emit(hdr.inner_vlan_tag);
packet.emit(hdr.mpls);
packet.emit(hdr.arp);
packet.emit(hdr.ipv4);

File diff suppressed because it is too large Load Diff