-
Notifications
You must be signed in to change notification settings - Fork 0
ported v1model test #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| /* | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| 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; |
There was a problem hiding this comment.
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