-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bmv2 backend crash for unused action selectors
When an action selector is declared as a control local but never referenced by a table, the compiler cannot figure out the selector input, which means the action selector cannot be included in the bmv2 JSON.
- Loading branch information
1 parent
4dbab3d
commit 7c2f154
Showing
7 changed files
with
303 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
struct H { }; | ||
struct M { | ||
bit<32> hash1; | ||
} | ||
|
||
parser ParserI(packet_in pk, out H hdr, inout M meta, inout standard_metadata_t | ||
smeta) { | ||
state start { transition accept; } | ||
} | ||
|
||
action empty() { } | ||
|
||
control IngressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) { | ||
|
||
action drop() { smeta.drop = 1; } | ||
|
||
action_selector (HashAlgorithm.identity, 32w1024, 32w10) as; | ||
|
||
table indirect_ws { | ||
key = { meta.hash1 : selector; } | ||
actions = { drop; NoAction; } | ||
const default_action = NoAction(); | ||
implementation = as; | ||
} | ||
|
||
apply { | ||
indirect_ws.apply(); | ||
} | ||
|
||
}; | ||
|
||
control EgressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) { | ||
apply { } | ||
}; | ||
|
||
control DeparserI(packet_out pk, in H hdr) { | ||
apply { } | ||
} | ||
|
||
control VerifyChecksumI(in H hdr, inout M meta) { | ||
apply { } | ||
} | ||
|
||
control ComputeChecksumI(inout H hdr, inout M meta) { | ||
apply { } | ||
} | ||
|
||
V1Switch(ParserI(), VerifyChecksumI(), IngressI(), EgressI(), | ||
ComputeChecksumI(), DeparserI()) main; |
60 changes: 60 additions & 0 deletions
60
testdata/p4_16_samples_outputs/action_selector_unused-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,60 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
struct H { | ||
} | ||
|
||
struct M { | ||
bit<32> hash1; | ||
} | ||
|
||
parser ParserI(packet_in pk, out H hdr, inout M meta, inout standard_metadata_t smeta) { | ||
state start { | ||
transition accept; | ||
} | ||
} | ||
|
||
action empty() { | ||
} | ||
control IngressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) { | ||
action drop() { | ||
smeta.drop = 1w1; | ||
} | ||
action_selector(HashAlgorithm.identity, 32w1024, 32w10) as; | ||
table indirect_ws { | ||
key = { | ||
meta.hash1: selector @name("meta.hash1") ; | ||
} | ||
actions = { | ||
drop(); | ||
NoAction(); | ||
} | ||
const default_action = NoAction(); | ||
implementation = as; | ||
} | ||
apply { | ||
indirect_ws.apply(); | ||
} | ||
} | ||
|
||
control EgressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control DeparserI(packet_out pk, in H hdr) { | ||
apply { | ||
} | ||
} | ||
|
||
control VerifyChecksumI(in H hdr, inout M meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control ComputeChecksumI(inout H hdr, inout M meta) { | ||
apply { | ||
} | ||
} | ||
|
||
V1Switch<H, M>(ParserI(), VerifyChecksumI(), IngressI(), EgressI(), ComputeChecksumI(), DeparserI()) main; |
58 changes: 58 additions & 0 deletions
58
testdata/p4_16_samples_outputs/action_selector_unused-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,58 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
struct H { | ||
} | ||
|
||
struct M { | ||
bit<32> hash1; | ||
} | ||
|
||
parser ParserI(packet_in pk, out H hdr, inout M meta, inout standard_metadata_t smeta) { | ||
state start { | ||
transition accept; | ||
} | ||
} | ||
|
||
control IngressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) { | ||
@name("drop") action drop_0() { | ||
smeta.drop = 1w1; | ||
} | ||
@name("as") action_selector(HashAlgorithm.identity, 32w1024, 32w10) as_0; | ||
@name("indirect_ws") table indirect_ws_0 { | ||
key = { | ||
meta.hash1: selector @name("meta.hash1") ; | ||
} | ||
actions = { | ||
drop_0(); | ||
NoAction(); | ||
} | ||
const default_action = NoAction(); | ||
implementation = as_0; | ||
} | ||
apply { | ||
indirect_ws_0.apply(); | ||
} | ||
} | ||
|
||
control EgressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control DeparserI(packet_out pk, in H hdr) { | ||
apply { | ||
} | ||
} | ||
|
||
control VerifyChecksumI(in H hdr, inout M meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control ComputeChecksumI(inout H hdr, inout M meta) { | ||
apply { | ||
} | ||
} | ||
|
||
V1Switch<H, M>(ParserI(), VerifyChecksumI(), IngressI(), EgressI(), ComputeChecksumI(), DeparserI()) main; |
60 changes: 60 additions & 0 deletions
60
testdata/p4_16_samples_outputs/action_selector_unused-bmv2-midend.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,60 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
struct H { | ||
} | ||
|
||
struct M { | ||
bit<32> hash1; | ||
} | ||
|
||
parser ParserI(packet_in pk, out H hdr, inout M meta, inout standard_metadata_t smeta) { | ||
state start { | ||
transition accept; | ||
} | ||
} | ||
|
||
control IngressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) { | ||
@name("NoAction") action NoAction_0() { | ||
} | ||
@name("drop") action drop_0() { | ||
smeta.drop = 1w1; | ||
} | ||
@name("as") action_selector(HashAlgorithm.identity, 32w1024, 32w10) as; | ||
@name("indirect_ws") table indirect_ws { | ||
key = { | ||
meta.hash1: selector @name("meta.hash1") ; | ||
} | ||
actions = { | ||
drop_0(); | ||
NoAction_0(); | ||
} | ||
const default_action = NoAction_0(); | ||
implementation = as; | ||
} | ||
apply { | ||
indirect_ws.apply(); | ||
} | ||
} | ||
|
||
control EgressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control DeparserI(packet_out pk, in H hdr) { | ||
apply { | ||
} | ||
} | ||
|
||
control VerifyChecksumI(in H hdr, inout M meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control ComputeChecksumI(inout H hdr, inout M meta) { | ||
apply { | ||
} | ||
} | ||
|
||
V1Switch<H, M>(ParserI(), VerifyChecksumI(), IngressI(), EgressI(), ComputeChecksumI(), DeparserI()) main; |
60 changes: 60 additions & 0 deletions
60
testdata/p4_16_samples_outputs/action_selector_unused-bmv2.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,60 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
struct H { | ||
} | ||
|
||
struct M { | ||
bit<32> hash1; | ||
} | ||
|
||
parser ParserI(packet_in pk, out H hdr, inout M meta, inout standard_metadata_t smeta) { | ||
state start { | ||
transition accept; | ||
} | ||
} | ||
|
||
action empty() { | ||
} | ||
control IngressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) { | ||
action drop() { | ||
smeta.drop = 1; | ||
} | ||
action_selector(HashAlgorithm.identity, 32w1024, 32w10) as; | ||
table indirect_ws { | ||
key = { | ||
meta.hash1: selector; | ||
} | ||
actions = { | ||
drop; | ||
NoAction; | ||
} | ||
const default_action = NoAction(); | ||
implementation = as; | ||
} | ||
apply { | ||
indirect_ws.apply(); | ||
} | ||
} | ||
|
||
control EgressI(inout H hdr, inout M meta, inout standard_metadata_t smeta) { | ||
apply { | ||
} | ||
} | ||
|
||
control DeparserI(packet_out pk, in H hdr) { | ||
apply { | ||
} | ||
} | ||
|
||
control VerifyChecksumI(in H hdr, inout M meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control ComputeChecksumI(inout H hdr, inout M meta) { | ||
apply { | ||
} | ||
} | ||
|
||
V1Switch(ParserI(), VerifyChecksumI(), IngressI(), EgressI(), ComputeChecksumI(), DeparserI()) main; |
Empty file.