Skip to content

Commit

Permalink
[P4_Symbolic] Adding p4_symbolic/testdata/parser/fall_through_transit…
Browse files Browse the repository at this point in the history
…ion.p4 [Evaluate parsers symbolically.]
  • Loading branch information
kishanps authored and VSuryaprasad-HCL committed Dec 6, 2024
1 parent f48f3c9 commit aa4d303
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 7 deletions.
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;

0 comments on commit aa4d303

Please sign in to comment.