-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an example P4 program with unusual table name annotations.
- Loading branch information
Showing
10 changed files
with
733 additions
and
2 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,113 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
header ethernet_t { | ||
bit<48> dst_addr; | ||
bit<48> src_addr; | ||
bit<16> eth_type; | ||
} | ||
|
||
struct Headers { | ||
ethernet_t eth_hdr; | ||
} | ||
|
||
struct Meta {} | ||
|
||
parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t sm) { | ||
state start { | ||
transition parse_hdrs; | ||
} | ||
state parse_hdrs { | ||
pkt.extract(hdr.eth_hdr); | ||
transition accept; | ||
} | ||
} | ||
|
||
|
||
control tables(inout Headers h, inout Meta m, inout standard_metadata_t s) { | ||
action increment() { | ||
h.eth_hdr.dst_addr = h.eth_hdr.dst_addr + 1; | ||
} | ||
|
||
@name("prefix|simple_table_1") | ||
table simple_table_1 { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name"); | ||
} | ||
actions = { | ||
NoAction; | ||
increment; | ||
} | ||
} | ||
@name("@prefix@simple_table_2") | ||
table simple_table_2 { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name") ; | ||
} | ||
actions = { | ||
NoAction; | ||
increment; | ||
} | ||
} | ||
@name("<>]{]prefix/simple_table_3") | ||
table simple_table_3 { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name") ; | ||
} | ||
actions = { | ||
NoAction; | ||
increment; | ||
} | ||
} | ||
@name("!@#$%^&*()_+=-prefix^simple_table_1") | ||
table simple_table_4 { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name") ; | ||
} | ||
actions = { | ||
NoAction; | ||
increment; | ||
} | ||
} | ||
@name("prefix◕‿◕😀ツsimple_table_1") | ||
table simple_table_5 { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name") ; | ||
} | ||
actions = { | ||
NoAction; | ||
increment; | ||
} | ||
} | ||
|
||
apply { | ||
simple_table_1.apply(); | ||
simple_table_2.apply(); | ||
simple_table_3.apply(); | ||
simple_table_4.apply(); | ||
simple_table_5.apply(); | ||
} | ||
} | ||
|
||
|
||
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
|
||
apply { | ||
tables.apply(h, m, sm); | ||
} | ||
} | ||
|
||
control vrfy(inout Headers h, inout Meta m) { apply {} } | ||
|
||
control update(inout Headers h, inout Meta m) { apply {} } | ||
|
||
control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { apply {} } | ||
|
||
control deparser(packet_out pkt, in Headers h) { | ||
apply { | ||
pkt.emit(h); | ||
} | ||
} | ||
|
||
V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; | ||
|
119 changes: 119 additions & 0 deletions
119
testdata/p4_16_samples_outputs/nonstandard_table_names-bmv2-first.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,119 @@ | ||
#include <core.p4> | ||
#define V1MODEL_VERSION 20180101 | ||
#include <v1model.p4> | ||
|
||
header ethernet_t { | ||
bit<48> dst_addr; | ||
bit<48> src_addr; | ||
bit<16> eth_type; | ||
} | ||
|
||
struct Headers { | ||
ethernet_t eth_hdr; | ||
} | ||
|
||
struct Meta { | ||
} | ||
|
||
parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t sm) { | ||
state start { | ||
transition parse_hdrs; | ||
} | ||
state parse_hdrs { | ||
pkt.extract<ethernet_t>(hdr.eth_hdr); | ||
transition accept; | ||
} | ||
} | ||
|
||
control tables(inout Headers h, inout Meta m, inout standard_metadata_t s) { | ||
action increment() { | ||
h.eth_hdr.dst_addr = h.eth_hdr.dst_addr + 48w1; | ||
} | ||
@name("prefix|simple_table_1") table simple_table_1 { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name"); | ||
} | ||
actions = { | ||
NoAction(); | ||
increment(); | ||
} | ||
default_action = NoAction(); | ||
} | ||
@name("@prefix@simple_table_2") table simple_table_2 { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name"); | ||
} | ||
actions = { | ||
NoAction(); | ||
increment(); | ||
} | ||
default_action = NoAction(); | ||
} | ||
@name("<>]{]prefix/simple_table_3") table simple_table_3 { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name"); | ||
} | ||
actions = { | ||
NoAction(); | ||
increment(); | ||
} | ||
default_action = NoAction(); | ||
} | ||
@name("!@#$%^&*()_+=-prefix^simple_table_1") table simple_table_4 { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name"); | ||
} | ||
actions = { | ||
NoAction(); | ||
increment(); | ||
} | ||
default_action = NoAction(); | ||
} | ||
@name("prefix◕‿◕😀ツsimple_table_1") table simple_table_5 { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name"); | ||
} | ||
actions = { | ||
NoAction(); | ||
increment(); | ||
} | ||
default_action = NoAction(); | ||
} | ||
apply { | ||
simple_table_1.apply(); | ||
simple_table_2.apply(); | ||
simple_table_3.apply(); | ||
simple_table_4.apply(); | ||
simple_table_5.apply(); | ||
} | ||
} | ||
|
||
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
@name("tables") tables() tables_inst; | ||
apply { | ||
tables_inst.apply(h, m, sm); | ||
} | ||
} | ||
|
||
control vrfy(inout Headers h, inout Meta m) { | ||
apply { | ||
} | ||
} | ||
|
||
control update(inout Headers h, inout Meta m) { | ||
apply { | ||
} | ||
} | ||
|
||
control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
apply { | ||
} | ||
} | ||
|
||
control deparser(packet_out pkt, in Headers h) { | ||
apply { | ||
pkt.emit<Headers>(h); | ||
} | ||
} | ||
|
||
V1Switch<Headers, Meta>(p(), vrfy(), ingress(), egress(), update(), deparser()) main; |
131 changes: 131 additions & 0 deletions
131
testdata/p4_16_samples_outputs/nonstandard_table_names-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,131 @@ | ||
#include <core.p4> | ||
#define V1MODEL_VERSION 20180101 | ||
#include <v1model.p4> | ||
|
||
header ethernet_t { | ||
bit<48> dst_addr; | ||
bit<48> src_addr; | ||
bit<16> eth_type; | ||
} | ||
|
||
struct Headers { | ||
ethernet_t eth_hdr; | ||
} | ||
|
||
struct Meta { | ||
} | ||
|
||
parser p(packet_in pkt, out Headers hdr, inout Meta m, inout standard_metadata_t sm) { | ||
state start { | ||
pkt.extract<ethernet_t>(hdr.eth_hdr); | ||
transition accept; | ||
} | ||
} | ||
|
||
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
@noWarn("unused") @name(".NoAction") action NoAction_1() { | ||
} | ||
@noWarn("unused") @name(".NoAction") action NoAction_2() { | ||
} | ||
@noWarn("unused") @name(".NoAction") action NoAction_3() { | ||
} | ||
@noWarn("unused") @name(".NoAction") action NoAction_4() { | ||
} | ||
@noWarn("unused") @name(".NoAction") action NoAction_5() { | ||
} | ||
@name("ingress.tables.increment") action tables_increment_0() { | ||
h.eth_hdr.dst_addr = h.eth_hdr.dst_addr + 48w1; | ||
} | ||
@name("ingress.tables.increment") action tables_increment_1() { | ||
h.eth_hdr.dst_addr = h.eth_hdr.dst_addr + 48w1; | ||
} | ||
@name("ingress.tables.increment") action tables_increment_2() { | ||
h.eth_hdr.dst_addr = h.eth_hdr.dst_addr + 48w1; | ||
} | ||
@name("ingress.tables.increment") action tables_increment_3() { | ||
h.eth_hdr.dst_addr = h.eth_hdr.dst_addr + 48w1; | ||
} | ||
@name("ingress.tables.increment") action tables_increment_4() { | ||
h.eth_hdr.dst_addr = h.eth_hdr.dst_addr + 48w1; | ||
} | ||
@name("ingress.tables.prefix|simple_table_1") table tables_prefix_simple_table { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name"); | ||
} | ||
actions = { | ||
NoAction_1(); | ||
tables_increment_0(); | ||
} | ||
default_action = NoAction_1(); | ||
} | ||
@name("ingress.tables.@prefix@simple_table_2") table tables__prefix_simple_table { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name"); | ||
} | ||
actions = { | ||
NoAction_2(); | ||
tables_increment_1(); | ||
} | ||
default_action = NoAction_2(); | ||
} | ||
@name("ingress.tables.<>]{]prefix/simple_table_3") table tables______prefix_simple_table { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name"); | ||
} | ||
actions = { | ||
NoAction_3(); | ||
tables_increment_2(); | ||
} | ||
default_action = NoAction_3(); | ||
} | ||
@name("ingress.tables.!@#$%^&*()_+=-prefix^simple_table_1") table tables_______________prefix_simple_table { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name"); | ||
} | ||
actions = { | ||
NoAction_4(); | ||
tables_increment_3(); | ||
} | ||
default_action = NoAction_4(); | ||
} | ||
@name("ingress.tables.prefix◕‿◕😀ツsimple_table_1") table tables_prefix________________simple_table { | ||
key = { | ||
h.eth_hdr.eth_type: exact @name("dummy_name"); | ||
} | ||
actions = { | ||
NoAction_5(); | ||
tables_increment_4(); | ||
} | ||
default_action = NoAction_5(); | ||
} | ||
apply { | ||
tables_prefix_simple_table.apply(); | ||
tables__prefix_simple_table.apply(); | ||
tables______prefix_simple_table.apply(); | ||
tables_______________prefix_simple_table.apply(); | ||
tables_prefix________________simple_table.apply(); | ||
} | ||
} | ||
|
||
control vrfy(inout Headers h, inout Meta m) { | ||
apply { | ||
} | ||
} | ||
|
||
control update(inout Headers h, inout Meta m) { | ||
apply { | ||
} | ||
} | ||
|
||
control egress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
apply { | ||
} | ||
} | ||
|
||
control deparser(packet_out pkt, in Headers h) { | ||
apply { | ||
pkt.emit<Headers>(h); | ||
} | ||
} | ||
|
||
V1Switch<Headers, Meta>(p(), vrfy(), ingress(), egress(), update(), deparser()) main; |
Oops, something went wrong.