-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional tests and bug-fixes for varbits
- Loading branch information
mbudiu-vmw
committed
May 16, 2017
1 parent
78696d4
commit 2a32b34
Showing
30 changed files
with
1,145 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
header H { | ||
varbit<32> var; | ||
} | ||
|
||
struct Parsed_packet { | ||
H h1; | ||
H h2; | ||
} | ||
|
||
struct Metadata { | ||
} | ||
|
||
control DeparserI(packet_out packet, in Parsed_packet hdr) { | ||
apply { | ||
packet.emit(hdr.h2); | ||
packet.emit(hdr.h1); | ||
} | ||
} | ||
|
||
parser parserI(packet_in pkt, out Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
state start { | ||
pkt.extract<H>(hdr.h1, 32w16); | ||
pkt.extract<H>(hdr.h2, 32w16); | ||
transition accept; | ||
} | ||
} | ||
|
||
control ingress(inout Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control egress(inout Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control vc(in Parsed_packet hdr, inout Metadata meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control uc(inout Parsed_packet hdr, inout Metadata meta) { | ||
apply { | ||
} | ||
} | ||
|
||
V1Switch<Parsed_packet, Metadata>(parserI(), vc(), ingress(), egress(), uc(), DeparserI()) main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
packet 0 12 34 56 78 90 | ||
expect 0 56 78 12 34 90 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
header S { | ||
bit<32> size; | ||
} | ||
|
||
header H { | ||
varbit<32> var; | ||
} | ||
|
||
struct Parsed_packet { | ||
S s; | ||
H h; | ||
} | ||
|
||
struct Metadata { | ||
} | ||
|
||
parser parserI(packet_in pkt, out Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
state start { | ||
pkt.extract(hdr.s); | ||
bit<32> size = hdr.s.size; | ||
pkt.extract(hdr.h, size); | ||
transition accept; | ||
} | ||
} | ||
|
||
control DeparserI(packet_out packet, in Parsed_packet hdr) { | ||
apply { | ||
packet.emit(hdr.h); | ||
} | ||
} | ||
|
||
control ingress(inout Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control egress(inout Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control vc(in Parsed_packet hdr, inout Metadata meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control uc(inout Parsed_packet hdr, inout Metadata meta) { | ||
apply { | ||
} | ||
} | ||
|
||
V1Switch<Parsed_packet, Metadata>(parserI(), vc(), ingress(), egress(), uc(), DeparserI()) main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# size | ||
packet 0 00000008 12 34 56 78 90 | ||
expect 0 12 34 56 78 90 | ||
packet 0 00000010 12 34 56 78 90 | ||
expect 0 12 34 56 78 90 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
header S { | ||
bit<32> size; | ||
} | ||
|
||
header H { | ||
varbit<32> var; | ||
} | ||
|
||
struct Parsed_packet { | ||
S s1; | ||
H h; | ||
S s2; | ||
} | ||
|
||
struct Metadata { | ||
} | ||
|
||
parser parserI(packet_in pkt, out Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
state start { | ||
pkt.extract(hdr.s1); | ||
bit<32> size = hdr.s1.size; | ||
pkt.extract(hdr.h, size); | ||
pkt.extract(hdr.s2); | ||
transition accept; | ||
} | ||
} | ||
|
||
control DeparserI(packet_out packet, in Parsed_packet hdr) { | ||
apply { | ||
packet.emit(hdr.s2); | ||
} | ||
} | ||
|
||
control ingress(inout Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control egress(inout Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control vc(in Parsed_packet hdr, inout Metadata meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control uc(inout Parsed_packet hdr, inout Metadata meta) { | ||
apply { | ||
} | ||
} | ||
|
||
V1Switch<Parsed_packet, Metadata>(parserI(), vc(), ingress(), egress(), uc(), DeparserI()) main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# size | ||
packet 0 00000008 12 34 56 78 90 | ||
expect 0 34 56 78 90 | ||
packet 0 00000010 12 34 56 78 90 | ||
expect 0 56 78 90 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
header S { | ||
bit<32> size; | ||
} | ||
|
||
header H { | ||
varbit<32> var; | ||
} | ||
|
||
struct Parsed_packet { | ||
S s1; | ||
H h; | ||
S s2; | ||
} | ||
|
||
struct Metadata { | ||
} | ||
|
||
parser parserI(packet_in pkt, out Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
state start { | ||
pkt.extract(hdr.s1); | ||
pkt.extract(hdr.h, hdr.s1.size); | ||
pkt.extract(hdr.s2); | ||
transition accept; | ||
} | ||
} | ||
|
||
control DeparserI(packet_out packet, in Parsed_packet hdr) { | ||
apply { | ||
packet.emit(hdr.s2); | ||
} | ||
} | ||
|
||
control ingress(inout Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control egress(inout Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control vc(in Parsed_packet hdr, inout Metadata meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control uc(inout Parsed_packet hdr, inout Metadata meta) { | ||
apply { | ||
} | ||
} | ||
|
||
V1Switch<Parsed_packet, Metadata>(parserI(), vc(), ingress(), egress(), uc(), DeparserI()) main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# size | ||
packet 0 00000008 12 34 56 78 90 | ||
expect 0 34 56 78 90 | ||
packet 0 00000010 12 34 56 78 90 | ||
expect 0 56 78 90 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
header H { | ||
varbit<32> var; | ||
} | ||
|
||
struct Parsed_packet { | ||
H h1; | ||
H h2; | ||
} | ||
|
||
struct Metadata { | ||
} | ||
|
||
control DeparserI(packet_out packet, in Parsed_packet hdr) { | ||
apply { | ||
packet.emit<H>(hdr.h2); | ||
packet.emit<H>(hdr.h1); | ||
} | ||
} | ||
|
||
parser parserI(packet_in pkt, out Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
state start { | ||
pkt.extract<H>(hdr.h1, 32w16); | ||
pkt.extract<H>(hdr.h2, 32w16); | ||
transition accept; | ||
} | ||
} | ||
|
||
control ingress(inout Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control egress(inout Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control vc(in Parsed_packet hdr, inout Metadata meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control uc(inout Parsed_packet hdr, inout Metadata meta) { | ||
apply { | ||
} | ||
} | ||
|
||
V1Switch<Parsed_packet, Metadata>(parserI(), vc(), ingress(), egress(), uc(), DeparserI()) main; |
51 changes: 51 additions & 0 deletions
51
testdata/p4_16_samples_outputs/issue447-1-bmv2-frontend.p4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
header H { | ||
varbit<32> var; | ||
} | ||
|
||
struct Parsed_packet { | ||
H h1; | ||
H h2; | ||
} | ||
|
||
struct Metadata { | ||
} | ||
|
||
control DeparserI(packet_out packet, in Parsed_packet hdr) { | ||
apply { | ||
packet.emit<H>(hdr.h2); | ||
packet.emit<H>(hdr.h1); | ||
} | ||
} | ||
|
||
parser parserI(packet_in pkt, out Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
state start { | ||
pkt.extract<H>(hdr.h1, 32w16); | ||
pkt.extract<H>(hdr.h2, 32w16); | ||
transition accept; | ||
} | ||
} | ||
|
||
control ingress(inout Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control egress(inout Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control vc(in Parsed_packet hdr, inout Metadata meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control uc(inout Parsed_packet hdr, inout Metadata meta) { | ||
apply { | ||
} | ||
} | ||
|
||
V1Switch<Parsed_packet, Metadata>(parserI(), vc(), ingress(), egress(), uc(), DeparserI()) main; |
Oops, something went wrong.