Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
35 changes: 35 additions & 0 deletions backends/dpdk/DpdkXfail.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
p4c_add_xfail_reason("dpdk"
"Unhandled type for varbit<32> Ingress_s"
testdata/p4_16_samples/psa-dpdk-issue447-5.p4
)

p4c_add_xfail_reason("dpdk"
"Field local_metadata_ipv4_lkp_ipv4_sa is not a member of structure struct M"
testdata/p4_16_samples/psa-dpdk-hash.p4
)

p4c_add_xfail_reason("dpdk"
"ostd: declaration not found"
testdata/p4_16_samples/psa-dpdk-issue1660.p4
)

p4c_add_xfail_reason("dpdk"
"not implemented"
testdata/p4_16_samples/psa-dpdk-issue1630.p4
)

p4c_add_xfail_reason("dpdk"
"Error compiling"
testdata/p4_16_samples/psa-dpdk-issue2314.p4
)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All failing cases with same fail message used as regex should be combined

p4c_add_xfail_reason("dpdk"
"Error compiling"
testdata/p4_16_samples/psa-dpdk-pred.p4
)

p4c_add_xfail_reason("dpdk"
"Error compiling"
testdata/p4_16_samples/psa-dpdk-issue1653-complex.p4
)

p4c_add_xfail_reason("dpdk"
"Expected packet length argument for count method of indirect counter"
testdata/p4_16_samples/psa-example-counters-bmv2.p4
Expand Down
100 changes: 100 additions & 0 deletions testdata/p4_16_samples/arith-inline-skeleton-d.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what the copyright message should be. Also this file does not include psa.p4, not required?

Copyright 2013-present Barefoot Networks, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// P4 program fragment - used by the arith-* compiler tests
// This fragment expects a two definitions:
// - a header hdr
// - a control compute(inout hdr h)

// This is false if the P4 core library has not been included
#ifdef _CORE_P4_

struct Headers {
hdr h;
}

struct Meta {}

parser p(packet_in b, out Headers h, inout Meta m, in psa_ingress_parser_input_metadata_t x,
in EMPTY_RESUB resub_meta,
in EMPTY_RECIRC recirc_meta) {
state start {
b.extract(h.h);
transition accept;
}
}

parser egressParserImpl(
packet_in buffer,
out EMPTY_H a,
inout Meta b,
in psa_egress_parser_input_metadata_t c,
in EMPTY_BRIDGE d,
in EMPTY_CLONE e,
in EMPTY_CLONE f) {
state start {
transition accept;
}
}

control ingress(inout Headers h, inout Meta m, in psa_ingress_input_metadata_t istd,
inout psa_ingress_output_metadata_t ostd) {
compute() c;
apply {
c.apply(h.h);
ostd.egress_port = (PortId_t)(PortIdUint_t)0;
}
}

control egressControlImpl(
inout EMPTY_H h,
inout Meta meta,
in psa_egress_input_metadata_t x,
inout psa_egress_output_metadata_t ostd)
{
apply { }
}

control deparser(packet_out b, out EMPTY_CLONE clone_i2e_meta,
out EMPTY_RESUB resubmit_meta,
out EMPTY_BRIDGE normal_meta,
inout Headers h,
in Meta local_metadata,
in psa_ingress_output_metadata_t istd) {
apply { b.emit(h.h); }
}

control egressDeparserImpl(
packet_out buffer,
out EMPTY_CLONE a,
out EMPTY_RECIRC b,
inout EMPTY_H c,
in Meta d,
in psa_egress_output_metadata_t e,
in psa_egress_deparser_input_metadata_t f) {
apply { }
}

IngressPipeline(p(), ingress(), deparser()) ip;
EgressPipeline(egressParserImpl(), egressControlImpl(), egressDeparserImpl()) ep;

PSA_Switch(
ip,
PacketReplicationEngine(),
ep,
BufferingQueueingEngine()) main;

#endif
72 changes: 72 additions & 0 deletions testdata/p4_16_samples/arith-skeleton-d.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While porting, we should ignore the tests which does not involve any backend processing. This will not compile with ./p4c-dpdk I assume and our regression script will not run this, does it?

Copyright 2013-present Barefoot Networks, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// P4 program fragment - used by the arith-* compiler tests

// This is false if the P4 core library has not been included
#ifdef _CORE_P4_

struct Headers {
hdr h;
}

struct Meta {}

parser p(packet_in b, out Headers h, inout Meta m, in psa_ingress_parser_input_metadata_t x,
in EMPTY_RESUB resub_meta,
in EMPTY_RECIRC recirc_meta) {
state start {
b.extract(h.h);
transition accept;
}
}

parser egressParserImpl(
packet_in buffer,
out EMPTY_H a,
inout Meta b,
in psa_egress_parser_input_metadata_t c,
in EMPTY_BRIDGE d,
in EMPTY_CLONE e,
in EMPTY_CLONE f) {
state start {
transition accept;
}
}

control deparser(packet_out b, out EMPTY_CLONE clone_i2e_meta,
out EMPTY_RESUB resubmit_meta,
out EMPTY_BRIDGE normal_meta,
inout Headers h,
in Meta local_metadata,
in psa_ingress_output_metadata_t istd ) {
apply { b.emit(h.h); }
}

control egressDeparserImpl(
packet_out buffer,
out EMPTY_CLONE a,
out EMPTY_RECIRC b,
inout EMPTY_H c,
in Meta d,
in psa_egress_output_metadata_t e,
in psa_egress_deparser_input_metadata_t f) {
apply { }
}



#endif
179 changes: 179 additions & 0 deletions testdata/p4_16_samples/p4-dpdk-multicast.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
#include <core.p4>
#include <psa.p4>

header EMPTY_H {};
struct EMPTY_RESUB {};
struct EMPTY_CLONE {};
struct EMPTY_BRIDGE {};
struct EMPTY_RECIRC {};


struct routing_metadata_t {
bit<32> nhop_ipv4;
}

header ethernet_t {
bit<48> dstAddr;
bit<48> srcAddr;
bit<16> etherType;
}

header ipv4_t {
bit<4> version;
bit<4> ihl;
bit<8> diffserv;
bit<16> totalLen;
bit<16> identification;
bit<3> flags;
bit<13> fragOffset;
bit<8> ttl;
bit<8> protocol;
bit<16> hdrChecksum;
bit<32> srcAddr;
bit<32> dstAddr;
}

struct metadata {
@name("routing_metadata")
routing_metadata_t routing_metadata;
}

struct headers {
@name("ethernet")
ethernet_t ethernet;
@name("ipv4")
ipv4_t ipv4;
}

parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, in psa_ingress_parser_input_metadata_t x,
in EMPTY_RESUB resub_meta,
in EMPTY_RECIRC recirc_meta) {
@name("parse_ethernet") state parse_ethernet {
packet.extract(hdr.ethernet);
transition select(hdr.ethernet.etherType) {
16w0x800: parse_ipv4;
default: accept;
}
}
@name("parse_ipv4") state parse_ipv4 {
packet.extract(hdr.ipv4);
transition accept;
}
@name("start") state start {
transition parse_ethernet;
}
}

parser egressParserImpl(
packet_in buffer,
out EMPTY_H a,
inout metadata b,
in psa_egress_parser_input_metadata_t c,
in EMPTY_BRIDGE d,
in EMPTY_CLONE e,
in EMPTY_CLONE f) {
state start {
transition accept;
}
}



control ingress(inout headers hdr, inout metadata meta, in psa_ingress_input_metadata_t istd,
inout psa_ingress_output_metadata_t ostd) {
@name(".bcast") action bcast() {
ostd.multicast_group = (MulticastGroup_t)(MulticastGroupUint_t)1;
}
@name(".set_dmac") action set_dmac(bit<48> dmac) {
hdr.ethernet.dstAddr = dmac;
}
@name("._drop") action _drop() {
ingress_drop(ostd);
}
@name(".set_nhop") action set_nhop(bit<32> nhop_ipv4, bit<9> port) {
meta.routing_metadata.nhop_ipv4 = nhop_ipv4;
ostd.egress_port = (PortId_t)(PortIdUint_t)port;
hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255;
}
@name(".set_nhop_redirect") action set_nhop_redirect(bit<32> nhop_ipv4, bit<9> port) {
meta.routing_metadata.nhop_ipv4 = nhop_ipv4;
ostd.egress_port = (PortId_t)(PortIdUint_t)port;
hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255;
}
@name("broadcast") table broadcast {
actions = {
bcast;
}
size = 1;
}
@name("forward") table forward {
actions = {
set_dmac;
_drop;
}
key = {
meta.routing_metadata.nhop_ipv4: exact;
}
size = 512;
}
@name("ipv4_lpm") table ipv4_lpm {
actions = {
set_nhop;
_drop;
}
key = {
hdr.ipv4.dstAddr: lpm;
}
size = 1024;
}
apply {
if (hdr.ipv4.isValid()) {
ipv4_lpm.apply();
forward.apply();
}
else {
broadcast.apply();
}
}
}

control egressControlImpl(
inout EMPTY_H hdr,
inout metadata meta,
in psa_egress_input_metadata_t x,
inout psa_egress_output_metadata_t ostd)
{
apply { }
}

control DeparserImpl(packet_out packet, out EMPTY_CLONE clone_i2e_meta,
out EMPTY_RESUB resubmit_meta,
out EMPTY_BRIDGE normal_meta,
inout headers hdr,
in metadata local_metadata,
in psa_ingress_output_metadata_t istd ) {
apply {
packet.emit(hdr.ethernet);
packet.emit(hdr.ipv4);
}
}

control egressDeparserImpl(
packet_out buffer,
out EMPTY_CLONE a,
out EMPTY_RECIRC b,
inout EMPTY_H c,
in metadata d,
in psa_egress_output_metadata_t e,
in psa_egress_deparser_input_metadata_t f) {
apply { }
}

IngressPipeline(ParserImpl(), ingress(), DeparserImpl()) ip;
EgressPipeline(egressParserImpl(), egressControlImpl(), egressDeparserImpl()) ep;

PSA_Switch(
ip,
PacketReplicationEngine(),
ep,
BufferingQueueingEngine()) main;
Loading