Skip to content

Commit

Permalink
Add @command_line("--loopsUnroll") for parser-unroll tests
Browse files Browse the repository at this point in the history
- remove duplicate runs now unneeded

Signed-off-by: Chris Dodd <cdodd@nvidia.com>
  • Loading branch information
ChrisDodd committed Feb 18, 2025
1 parent 2708299 commit 28b0e73
Show file tree
Hide file tree
Showing 167 changed files with 410 additions and 5,284 deletions.
4 changes: 0 additions & 4 deletions backends/p4test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ set (P4_XFAIL_TESTS
# will be no P4Info file.
p4c_add_tests_w_p4runtime("p4" ${P4TEST_DRIVER} "${P4TEST_SUITES}" "${P4_XFAIL_TESTS}" "${P4RUNTIME_EXCLUDE}" "-a '--maxErrorCount 100'")

set (P4TEST_PARSERUNROLL
"${P4C_SOURCE_DIR}/testdata/p4_16_samples/parser-unroll-*.p4")
p4c_add_tests("p4unroll" ${P4TEST_DRIVER} "${P4TEST_PARSERUNROLL}" "" "-a '--maxErrorCount 100 --loopsUnroll'")

set (P4TEST_PARSER_INLINE_TESTS "${P4C_SOURCE_DIR}/testdata/p4_16_samples/parser-inline/*.p4")
p4c_add_tests("p4" ${P4TEST_DRIVER} "${P4TEST_PARSER_INLINE_TESTS}" "" "-a '--maxErrorCount 100 --parser-inline-opt'")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ p4tools_add_xfail_reason(
# Unexpected error in RPC handling
issue3374.p4
control-hs-index-test6.p4
parser-unroll-test1.p4
)

p4tools_add_xfail_reason(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ p4tools_add_xfail_reason(
# terminate called after throwing an instance of 'std::runtime_error'
# Type is not convertible to string
control-hs-index-test3.p4
parser-unroll-test1.p4
# terminate called after throwing an instance of 'std::out_of_range'
control-hs-index-test2.p4
)
Expand Down
4 changes: 3 additions & 1 deletion testdata/p4_16_samples/parser-unroll-issue3537-1.p4
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <core.p4>
#include <v1model.p4>

@command_line("--loopsUnroll")

struct H { }

struct M { }
Expand Down Expand Up @@ -68,4 +70,4 @@ control ComputeChecksumI(inout H hdr, inout M meta) {


V1Switch(ParserI(), VerifyChecksumI(), IngressI(), EgressI(),
ComputeChecksumI(), DeparserI()) main;
ComputeChecksumI(), DeparserI()) main;
1 change: 1 addition & 0 deletions testdata/p4_16_samples/parser-unroll-issue3537.p4
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <core.p4>
#include <v1model.p4>
@command_line("--loopsUnroll")

header h1_t {}
header h2_t {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <core.p4>
#include <dpdk/psa.p4>
@command_line("--loopsUnroll")

typedef bit<48> eth_addr_t;

Expand Down
1 change: 1 addition & 0 deletions testdata/p4_16_samples/parser-unroll-t1-cond.p4
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// examples for simple IP/tcp.
#include <core.p4>
#include <v1model.p4>
@command_line("--loopsUnroll")

typedef bit<48> MacAddress;
typedef bit<32> ip4Addr_t;
Expand Down
3 changes: 2 additions & 1 deletion testdata/p4_16_samples/parser-unroll-test1.p4
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "v1model.p4"
@command_line("--loopsUnroll")

const bit<16> TYPE_IPV4 = 0x800;
const bit<16> TYPE_SRCROUTING = 0x1234;
Expand Down Expand Up @@ -102,4 +103,4 @@ control computeChecksum(inout headers hdr, inout metadata meta) {
apply {}
}
V1Switch(MyParser(), verifyChecksum(), mau(), mau(), computeChecksum(),
deparse()) main;
deparse()) main;
1 change: 1 addition & 0 deletions testdata/p4_16_samples/parser-unroll-test10.p4
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <core.p4>
#include <v1model.p4>
@command_line("--loopsUnroll")

header test_h {
bit<8> field;
Expand Down
3 changes: 2 additions & 1 deletion testdata/p4_16_samples/parser-unroll-test2.p4
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "v1model.p4"
@command_line("--loopsUnroll")

const bit<16> TYPE_IPV4 = 0x800;
const bit<16> TYPE_SRCROUTING = 0x1234;
Expand Down Expand Up @@ -99,4 +100,4 @@ control computeChecksum(inout headers hdr, inout metadata meta) {
apply {}
}
V1Switch(MyParser(), verifyChecksum(), mau(), mau(), computeChecksum(),
deparse()) main;
deparse()) main;
3 changes: 2 additions & 1 deletion testdata/p4_16_samples/parser-unroll-test3.p4
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "v1model.p4"
@command_line("--loopsUnroll")

const bit<16> TYPE_IPV4 = 0x800;
const bit<16> TYPE_SRCROUTING = 0x1234;
Expand Down Expand Up @@ -114,4 +115,4 @@ control computeChecksum(inout headers hdr, inout metadata meta) {
apply {}
}
V1Switch(MyParser(), verifyChecksum(), mau(), mau(), computeChecksum(),
deparse()) main;
deparse()) main;
3 changes: 2 additions & 1 deletion testdata/p4_16_samples/parser-unroll-test4.p4
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "v1model.p4"
@command_line("--loopsUnroll")

const bit<16> TYPE_IPV4 = 0x800;
const bit<16> TYPE_SRCROUTING = 0x1234;
Expand Down Expand Up @@ -107,4 +108,4 @@ control computeChecksum(inout headers hdr, inout metadata meta) {
apply {}
}
V1Switch(MyParser(), verifyChecksum(), mau(), mau(), computeChecksum(),
deparse()) main;
deparse()) main;
3 changes: 2 additions & 1 deletion testdata/p4_16_samples/parser-unroll-test5.p4
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "v1model.p4"
@command_line("--loopsUnroll")

const bit<16> TYPE_IPV4 = 0x800;
const bit<16> TYPE_SRCROUTING = 0x1234;
Expand Down Expand Up @@ -109,4 +110,4 @@ control computeChecksum(inout headers hdr, inout metadata meta) {
apply {}
}
V1Switch(MyParser(), verifyChecksum(), mau(), mau(), computeChecksum(),
deparse()) main;
deparse()) main;
1 change: 1 addition & 0 deletions testdata/p4_16_samples/parser-unroll-test6.p4
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* -*- Mode:C; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
#include <v1model.p4>
@command_line("--loopsUnroll")

header test_header_t {
bit<8> value;
Expand Down
1 change: 1 addition & 0 deletions testdata/p4_16_samples/parser-unroll-test7.p4
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <core.p4>
#include <v1model.p4>
@command_line("--loopsUnroll")

header S {
bit<8> t;
Expand Down
1 change: 1 addition & 0 deletions testdata/p4_16_samples/parser-unroll-test8.p4
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <core.p4>
#define V1MODEL_VERSION 20180101
#include <v1model.p4>
@command_line("--loopsUnroll")

header h_index1 {
bit<8> index;
Expand Down
1 change: 1 addition & 0 deletions testdata/p4_16_samples/parser-unroll-test9.p4
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <core.p4>
#define V1MODEL_VERSION 20180101
#include <v1model.p4>
@command_line("--loopsUnroll")

header h_stack {
bit<8> i1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <core.p4>
@command_line("--loopsUnroll")

parser p(packet_in packet, out bit<8> f, out bit<4> g) {
state start {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <core.p4>
@command_line("--loopsUnroll")

struct S {
bit<8> f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

struct H {
@command_line("--loopsUnroll") struct H {
}

struct M {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

struct H {
@command_line("--loopsUnroll") struct H {
}

struct M {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

struct H {
@command_line("--loopsUnroll") struct H {
}

struct M {
Expand All @@ -11,9 +11,6 @@ struct M {
parser ParserI(packet_in packet, out H hdr, inout M meta, inout standard_metadata_t smeta) {
@name("ParserI.tmp_0") bit<16> tmp_0;
@name("ParserI.tmp_2") bit<16> tmp_2;
state start {
transition s1;
}
state s1 {
packet.advance(32w16);
tmp_0 = packet.lookahead<bit<16>>();
Expand All @@ -34,6 +31,9 @@ parser ParserI(packet_in packet, out H hdr, inout M meta, inout standard_metadat
state s4 {
transition accept;
}
state start {
transition s1;
}
}

control IngressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

struct H {
@command_line("--loopsUnroll") struct H {
}

struct M {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
parser-unroll-issue3537-1.p4(43): [--Wwarn=unused] warning: Control Aux is not used; removing
parser-unroll-issue3537-1.p4(45): [--Wwarn=unused] warning: Control Aux is not used; removing
control Aux(inout M meta) {
^^^
[--Wwarn=invalid] warning: Parser cycle can't be unrolled, because ParserUnroll can't detect the number of loop iterations:
Parser ParserI state chain: start, s1, s2, s2
[--Wwarn=invalid] warning: Parser cycle can't be unrolled, because ParserUnroll can't detect the number of loop iterations:
Parser ParserI state chain: start, s1, s2, s1
[--Wwarn=invalid] warning: Parser cycle can't be unrolled, because ParserUnroll can't detect the number of loop iterations:
Parser ParserI state chain: start, s1, s1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

header h1_t {
@command_line("--loopsUnroll") header h1_t {
}

header h2_t {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

header h1_t {
@command_line("--loopsUnroll") header h1_t {
}

header h2_t {
Expand Down
20 changes: 10 additions & 10 deletions testdata/p4_16_samples_outputs/parser-unroll-issue3537-midend.p4
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

header h1_t {
@command_line("--loopsUnroll") header h1_t {
}

header h2_t {
Expand Down Expand Up @@ -39,15 +39,6 @@ struct M {
}

parser ParserI(packet_in packet, out H hdr, inout M meta, inout standard_metadata_t smeta) {
state start {
packet.extract<h1_t>(hdr.h1);
packet.extract<h2_t>(hdr.h2);
transition select(hdr.h2.f1) {
16w0x800: parse_ipv4;
16w0x86dd: parse_ipv6;
default: accept;
}
}
state parse_ipv4 {
packet.extract<h3_t>(hdr.h3);
transition select(hdr.h3.f2, hdr.h3.f3) {
Expand Down Expand Up @@ -76,6 +67,15 @@ parser ParserI(packet_in packet, out H hdr, inout M meta, inout standard_metadat
default: accept;
}
}
state start {
packet.extract<h1_t>(hdr.h1);
packet.extract<h2_t>(hdr.h2);
transition select(hdr.h2.f1) {
16w0x800: parse_ipv4;
16w0x86dd: parse_ipv6;
default: accept;
}
}
}

control IngressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) {
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_16_samples_outputs/parser-unroll-issue3537.p4
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

header h1_t {
@command_line("--loopsUnroll") header h1_t {
}

header h2_t {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
parser-unroll-issue3537.p4(71): [--Wwarn=unused] warning: Control Aux is not used; removing
parser-unroll-issue3537.p4(72): [--Wwarn=unused] warning: Control Aux is not used; removing
control Aux(inout M meta) {
^^^
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <core.p4>
#include <dpdk/psa.p4>

typedef bit<48> eth_addr_t;
@command_line("--loopsUnroll") typedef bit<48> eth_addr_t;
header ethernet_h {
eth_addr_t dstAddr;
eth_addr_t srcAddr;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <core.p4>
#include <dpdk/psa.p4>

typedef bit<48> eth_addr_t;
@command_line("--loopsUnroll") typedef bit<48> eth_addr_t;
header ethernet_h {
eth_addr_t dstAddr;
eth_addr_t srcAddr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@ struct headers_t {
}

parser in_parser(packet_in pkt, out headers_t hdr, inout empty_t user_meta, in psa_ingress_parser_input_metadata_t istd, in empty_t resubmit_meta, in empty_t recirculate_meta) {
state start {
pkt.extract<ethernet_h>(hdr.ethernet);
transition select(hdr.ethernet.etherType) {
16w0x8100: parse_vlan1;
16w0x88a8: parse_vlan2;
default: accept;
}
state parse_vlan1 {
pkt.extract<vlan_h>(hdr.vlan);
transition accept;
}
state parse_vlan2 {
pkt.extract<vlan_h>(hdr.vlan);
Expand All @@ -37,9 +33,13 @@ parser in_parser(packet_in pkt, out headers_t hdr, inout empty_t user_meta, in p
default: reject;
}
}
state parse_vlan1 {
pkt.extract<vlan_h>(hdr.vlan);
transition accept;
state start {
pkt.extract<ethernet_h>(hdr.ethernet);
transition select(hdr.ethernet.etherType) {
16w0x8100: parse_vlan1;
16w0x88a8: parse_vlan2;
default: accept;
}
}
}

Expand All @@ -49,18 +49,18 @@ control in_cntrl(inout headers_t hdr, inout empty_t user_meta, in psa_ingress_in
}

control in_deparser(packet_out packet, out empty_t clone_i2e_meta, out empty_t resubmit_meta, out empty_t normal_meta, inout headers_t hdr, in empty_t meta, in psa_ingress_output_metadata_t istd) {
@hidden action parserunrollissue4006_twice_extracted_header54() {
@hidden action parserunrollissue4006_twice_extracted_header55() {
packet.emit<ethernet_h>(hdr.ethernet);
packet.emit<vlan_h>(hdr.vlan);
}
@hidden table tbl_parserunrollissue4006_twice_extracted_header54 {
@hidden table tbl_parserunrollissue4006_twice_extracted_header55 {
actions = {
parserunrollissue4006_twice_extracted_header54();
parserunrollissue4006_twice_extracted_header55();
}
const default_action = parserunrollissue4006_twice_extracted_header54();
const default_action = parserunrollissue4006_twice_extracted_header55();
}
apply {
tbl_parserunrollissue4006_twice_extracted_header54.apply();
tbl_parserunrollissue4006_twice_extracted_header55.apply();
}
}

Expand Down
Loading

0 comments on commit 28b0e73

Please sign in to comment.