Skip to content
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

[P4_Symbolic] Adding p4_symbolic/testdata/parser/fall_through_transition.p4 [Evaluate parsers symbolically.] #822

Merged
merged 4 commits into from
Dec 11, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions p4_symbolic/ir/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,10 @@ ir_parsing_test(
p4_deps = ["//p4_symbolic/testdata:common/headers.p4"],
p4_program = "//p4_symbolic/testdata:parser/hex_string_transition.p4",
)

ir_parsing_test(
name = "fall_through_transition_test",
golden_file = "expected/fall_through_transition.txt",
p4_deps = ["//p4_symbolic/testdata:common/headers.p4"],
p4_program = "//p4_symbolic/testdata:parser/fall_through_transition.p4",
)
7 changes: 0 additions & 7 deletions p4_symbolic/ir/expected/fall_through_transition.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,4 @@ errors {
value: 3
}
}
deparsers {
key: "deparser"
value {
name: "deparser"
header_order: "ethernet"
}
}

68 changes: 68 additions & 0 deletions p4_symbolic/testdata/parser/fall_through_transition.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include <v1model.p4>
#include "../common/headers.p4"

struct local_metadata_t {
/* empty */
}

struct headers_t {
ethernet_t ethernet;
ipv4_t ipv4;
}

parser packet_parser(packet_in packet, out headers_t headers,
inout local_metadata_t local_metadata,
inout standard_metadata_t standard_metadata) {
state start {
transition parse_ethernet;
}

state parse_ethernet {
packet.extract(headers.ethernet);
transition select(headers.ethernet.ether_type) {
ETHERTYPE_IPV4: parse_ipv4;
}
}

state parse_ipv4 {
packet.extract(headers.ipv4);
transition accept;
}
}

control empty_verify_checksum(inout headers_t headers,
inout local_metadata_t local_metadata) {
apply {}
} // control empty_verify_checksum

control ingress(inout headers_t headers,
inout local_metadata_t local_metadata,
inout standard_metadata_t standard_metadata) {
apply {}
} // control ingress

control egress(inout headers_t headers,
inout local_metadata_t local_metadata,
inout standard_metadata_t standard_metadata) {
apply {}
} // control egress

control empty_compute_checksum(inout headers_t headers,
inout local_metadata_t local_metadata) {
apply {}
} // control empty_compute_checksum

control packet_deparser(packet_out packet, in headers_t headers) {
apply {
packet.emit(headers.ethernet);
}
} // control packet_deparser

V1Switch(
packet_parser(),
empty_verify_checksum(),
ingress(),
egress(),
empty_compute_checksum(),
packet_deparser()
) main;
Loading