-
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.
Don't apply defaultArguments in table action lists (#4434)
Co-authored-by: Chris Dodd <[email protected]>
- Loading branch information
Showing
10 changed files
with
395 additions
and
0 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,40 @@ | ||
/* | ||
Copyright 2013-present Barefoot Networks, Inc. | ||
Copyright 2024 NVIDIA CORPORATION. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
header hdr { | ||
bit<16> key; | ||
bit<32> a; | ||
bit<32> b; | ||
} | ||
|
||
control compute(inout hdr h) { | ||
action add(bit<32> va, bit<32> vb = 0) { | ||
h.a = h.a + va; | ||
h.b = h.b + vb; | ||
} | ||
table t { | ||
key = { h.key : exact; } | ||
actions = { add; } | ||
const default_action = add(10, 0); | ||
} | ||
apply { t.apply(); } | ||
} | ||
|
||
#include "arith-inline-skeleton.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,17 @@ | ||
# bit<16> key bit<32> A bit<32> B | ||
# In the output A = (A + 10), B = (B + 0) | ||
|
||
packet 0 0000 00000000 ABCDEF01 | ||
expect 0 0000 0000000A ABCDEF01 | ||
|
||
packet 0 0000 00000001 00000000 | ||
expect 0 0000 0000000B 00000000 | ||
|
||
packet 0 0000 00000001 00000000 | ||
expect 0 0000 0000000B 00000000 | ||
|
||
packet 0 0000 00000011 00000000 | ||
expect 0 0000 0000001B 00000000 | ||
|
||
packet 0 0000 FFFFFFFF 00000000 | ||
expect 0 0000 00000009 00000000 |
73 changes: 73 additions & 0 deletions
73
testdata/p4_16_samples_outputs/default-action-arg-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,73 @@ | ||
#include <core.p4> | ||
#define V1MODEL_VERSION 20180101 | ||
#include <v1model.p4> | ||
|
||
header hdr { | ||
bit<16> key; | ||
bit<32> a; | ||
bit<32> b; | ||
} | ||
|
||
control compute(inout hdr h) { | ||
action add(bit<32> va, bit<32> vb=0) { | ||
h.a = h.a + va; | ||
h.b = h.b + vb; | ||
} | ||
table t { | ||
key = { | ||
h.key: exact @name("h.key"); | ||
} | ||
actions = { | ||
add(); | ||
} | ||
const default_action = add(32w10, 32w0); | ||
} | ||
apply { | ||
t.apply(); | ||
} | ||
} | ||
|
||
struct Headers { | ||
hdr h; | ||
} | ||
|
||
struct Meta { | ||
} | ||
|
||
parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
state start { | ||
b.extract<hdr>(h.h); | ||
transition accept; | ||
} | ||
} | ||
|
||
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 b, in Headers h) { | ||
apply { | ||
b.emit<hdr>(h.h); | ||
} | ||
} | ||
|
||
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
compute() c; | ||
apply { | ||
c.apply(h.h); | ||
sm.egress_spec = 9w0; | ||
} | ||
} | ||
|
||
V1Switch<Headers, Meta>(p(), vrfy(), ingress(), egress(), update(), deparser()) main; |
66 changes: 66 additions & 0 deletions
66
testdata/p4_16_samples_outputs/default-action-arg-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,66 @@ | ||
#include <core.p4> | ||
#define V1MODEL_VERSION 20180101 | ||
#include <v1model.p4> | ||
|
||
header hdr { | ||
bit<16> key; | ||
bit<32> a; | ||
bit<32> b; | ||
} | ||
|
||
struct Headers { | ||
hdr h; | ||
} | ||
|
||
struct Meta { | ||
} | ||
|
||
parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
state start { | ||
b.extract<hdr>(h.h); | ||
transition accept; | ||
} | ||
} | ||
|
||
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 b, in Headers h) { | ||
apply { | ||
b.emit<hdr>(h.h); | ||
} | ||
} | ||
|
||
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
@name("ingress.c.add") action c_add_0(@name("va") bit<32> va, @name("vb") bit<32> vb=0) { | ||
h.h.a = h.h.a + va; | ||
h.h.b = h.h.b + vb; | ||
} | ||
@name("ingress.c.t") table c_t { | ||
key = { | ||
h.h.key: exact @name("h.key"); | ||
} | ||
actions = { | ||
c_add_0(); | ||
} | ||
const default_action = c_add_0(32w10, 32w0); | ||
} | ||
apply { | ||
c_t.apply(); | ||
sm.egress_spec = 9w0; | ||
} | ||
} | ||
|
||
V1Switch<Headers, Meta>(p(), vrfy(), ingress(), egress(), update(), deparser()) main; |
75 changes: 75 additions & 0 deletions
75
testdata/p4_16_samples_outputs/default-action-arg-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,75 @@ | ||
#include <core.p4> | ||
#define V1MODEL_VERSION 20180101 | ||
#include <v1model.p4> | ||
|
||
header hdr { | ||
bit<16> key; | ||
bit<32> a; | ||
bit<32> b; | ||
} | ||
|
||
struct Headers { | ||
hdr h; | ||
} | ||
|
||
struct Meta { | ||
} | ||
|
||
parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
state start { | ||
b.extract<hdr>(h.h); | ||
transition accept; | ||
} | ||
} | ||
|
||
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 b, in Headers h) { | ||
apply { | ||
b.emit<hdr>(h.h); | ||
} | ||
} | ||
|
||
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
@name("ingress.c.add") action c_add_0(@name("va") bit<32> va, @name("vb") bit<32> vb=0) { | ||
h.h.a = h.h.a + va; | ||
h.h.b = h.h.b + vb; | ||
} | ||
@name("ingress.c.t") table c_t { | ||
key = { | ||
h.h.key: exact @name("h.key"); | ||
} | ||
actions = { | ||
c_add_0(); | ||
} | ||
const default_action = c_add_0(32w10, 32w0); | ||
} | ||
@hidden action arithinlineskeleton51() { | ||
sm.egress_spec = 9w0; | ||
} | ||
@hidden table tbl_arithinlineskeleton51 { | ||
actions = { | ||
arithinlineskeleton51(); | ||
} | ||
const default_action = arithinlineskeleton51(); | ||
} | ||
apply { | ||
c_t.apply(); | ||
tbl_arithinlineskeleton51.apply(); | ||
} | ||
} | ||
|
||
V1Switch<Headers, Meta>(p(), vrfy(), ingress(), egress(), update(), deparser()) 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,73 @@ | ||
#include <core.p4> | ||
#define V1MODEL_VERSION 20180101 | ||
#include <v1model.p4> | ||
|
||
header hdr { | ||
bit<16> key; | ||
bit<32> a; | ||
bit<32> b; | ||
} | ||
|
||
control compute(inout hdr h) { | ||
action add(bit<32> va, bit<32> vb=0) { | ||
h.a = h.a + va; | ||
h.b = h.b + vb; | ||
} | ||
table t { | ||
key = { | ||
h.key: exact; | ||
} | ||
actions = { | ||
add; | ||
} | ||
const default_action = add(10, 0); | ||
} | ||
apply { | ||
t.apply(); | ||
} | ||
} | ||
|
||
struct Headers { | ||
hdr h; | ||
} | ||
|
||
struct Meta { | ||
} | ||
|
||
parser p(packet_in b, out Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
state start { | ||
b.extract(h.h); | ||
transition accept; | ||
} | ||
} | ||
|
||
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 b, in Headers h) { | ||
apply { | ||
b.emit(h.h); | ||
} | ||
} | ||
|
||
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) { | ||
compute() c; | ||
apply { | ||
c.apply(h.h); | ||
sm.egress_spec = 0; | ||
} | ||
} | ||
|
||
V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main; |
Empty file.
3 changes: 3 additions & 0 deletions
3
testdata/p4_16_samples_outputs/default-action-arg-bmv2.p4.entries.txtpb
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,3 @@ | ||
# proto-file: p4/v1/p4runtime.proto | ||
# proto-message: p4.v1.WriteRequest | ||
|
Oops, something went wrong.