Skip to content

Commit

Permalink
Update expected output files for modified test programs
Browse files Browse the repository at this point in the history
  • Loading branch information
jafingerhut committed Oct 9, 2024
1 parent b062eaa commit ccfca0a
Show file tree
Hide file tree
Showing 19 changed files with 532 additions and 42 deletions.
162 changes: 162 additions & 0 deletions testdata/p4_16_errors_outputs/multicast-bmv2-first.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
#include <core.p4>
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

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, inout standard_metadata_t standard_metadata) {
@name("parse_ethernet") state parse_ethernet {
packet.extract<ethernet_t>(hdr.ethernet);
transition select(hdr.ethernet.etherType) {
16w0x800: parse_ipv4;
default: accept;
}
}
@name("parse_ipv4") state parse_ipv4 {
packet.extract<ipv4_t>(hdr.ipv4);
transition accept;
}
@name("start") state start {
transition parse_ethernet;
}
}

control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@name(".rewrite_mac") action rewrite_mac(bit<48> smac) {
hdr.ethernet.srcAddr = smac;
}
@name("._drop") action _drop() {
mark_to_drop(standard_metadata);
}
@name("send_frame") table send_frame {
actions = {
rewrite_mac();
_drop();
@defaultonly NoAction();
}
key = {
standard_metadata.egress_port: exact @name("standard_metadata.egress_port");
}
size = 256;
default_action = NoAction();
}
apply {
send_frame.apply();
}
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@name(".bcast") action bcast() {
standard_metadata.mcast_grp = 16w1;
}
@name(".set_dmac") action set_dmac(bit<48> dmac) {
hdr.ethernet.dstAddr = dmac;
}
@name("._drop") action _drop() {
mark_to_drop(standard_metadata);
}
@name(".set_nhop") action set_nhop(bit<32> nhop_ipv4, bit<9> port) {
meta.routing_metadata.nhop_ipv4 = nhop_ipv4;
standard_metadata.egress_spec = 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;
standard_metadata.egress_spec = port;
hdr.ipv4.ttl = hdr.ipv4.ttl + 8w255;
}
@name("broadcast") table broadcast {
actions = {
bcast();
@defaultonly NoAction();
}
size = 1;
default_action = NoAction();
}
@name("forward") table forward {
actions = {
set_dmac();
_drop();
@defaultonly NoAction();
}
key = {
meta.routing_metadata.nhop_ipv4: exact @name("meta.routing_metadata.nhop_ipv4");
}
size = 512;
default_action = NoAction();
}
@name("ipv4_lpm") table ipv4_lpm {
actions = {
set_nhop();
_drop();
@defaultonly NoAction();
}
key = {
hdr.ipv4.dstAddr: lpm @name("hdr.ipv4.dstAddr");
}
size = 1024;
default_action = NoAction();
}
apply {
if (hdr.ipv4.isValid()) {
ipv4_lpm.apply();
forward.apply();
} else {
broadcast.apply();
}
}
}

control DeparserImpl(packet_out packet, in headers hdr) {
apply {
packet.emit<ethernet_t>(hdr.ethernet);
packet.emit<ipv4_t>(hdr.ipv4);
}
}

control verifyChecksum(inout headers hdr, inout metadata meta) {
apply {
}
}

control computeChecksum(inout headers hdr, inout metadata meta) {
apply {
}
}

V1Switch<headers, metadata>(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main;
154 changes: 154 additions & 0 deletions testdata/p4_16_errors_outputs/multicast-bmv2.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#include <core.p4>
#define V1MODEL_VERSION 20180101
#include <v1model.p4>

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, inout standard_metadata_t standard_metadata) {
@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;
}
}

control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@name(".rewrite_mac") action rewrite_mac(bit<48> smac) {
hdr.ethernet.srcAddr = smac;
}
@name("._drop") action _drop() {
mark_to_drop(standard_metadata);
}
@name("send_frame") table send_frame {
actions = {
rewrite_mac;
_drop;
}
key = {
standard_metadata.egress_port: exact;
}
size = 256;
}
apply {
send_frame.apply();
}
}

control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) {
@name(".bcast") action bcast() {
standard_metadata.mcast_grp = 1;
}
@name(".set_dmac") action set_dmac(bit<48> dmac) {
hdr.ethernet.dstAddr = dmac;
}
@name("._drop") action _drop() {
mark_to_drop(standard_metadata);
}
@name(".set_nhop") action set_nhop(bit<32> nhop_ipv4, bit<9> port) {
meta.routing_metadata.nhop_ipv4 = nhop_ipv4;
standard_metadata.egress_spec = 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;
standard_metadata.egress_spec = 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 DeparserImpl(packet_out packet, in headers hdr) {
apply {
packet.emit(hdr.ethernet);
packet.emit(hdr.ipv4);
}
}

control verifyChecksum(inout headers hdr, inout metadata meta) {
apply {
}
}

control computeChecksum(inout headers hdr, inout metadata meta) {
apply {
}
}

V1Switch(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main;
Loading

0 comments on commit ccfca0a

Please sign in to comment.