-
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.
Support new ActionProfile annotations for P4Runtime. (#4533)
* Support new ActionProfile annotations for P4Runtime. * Fix golden tests. * Add tests for new annotations. * Fix broken ebpf test. * Fixed error message for bad 'max_member_weights' annotation and made the default value for 'selector_size_semantics' absence. * Fix minor issues based on fruffy's comments. * Fix build issues.
- Loading branch information
1 parent
204ee83
commit 450398d
Showing
17 changed files
with
565 additions
and
22 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
88 changes: 88 additions & 0 deletions
88
testdata/p4_16_samples/action_profile_sum_of_members_annotation.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,88 @@ | ||
/* | ||
Copyright 2019-present Barefoot Networks, Inc. | ||
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> | ||
|
||
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() { mark_to_drop(smeta); } | ||
|
||
// For an action profile without an action selector, the | ||
// `max_group_size`, `selector_size_semantics`, and `max_member_weight` | ||
// annotations are meaningless and should result in a warning. | ||
@name("ap") @max_group_size(200) | ||
@selector_size_semantics("sum_of_members") @max_member_weight(4000) | ||
action_profile(32w128) my_action_profile; | ||
|
||
// For an action profile with an action selector using the `sum_of_members` | ||
// size semantics, all of these annotations are meaningful and should result | ||
// in no warnings. | ||
@name("ap_ws") @max_group_size(200) | ||
@selector_size_semantics("sum_of_members") @max_member_weight(4000) | ||
action_selector(HashAlgorithm.identity, 32w1024, 32w10) | ||
my_action_selector; | ||
|
||
table indirect { | ||
key = { } | ||
actions = { drop; NoAction; } | ||
const default_action = NoAction(); | ||
implementation = my_action_profile; | ||
} | ||
|
||
table indirect_ws { | ||
key = { meta.hash1 : selector; } | ||
actions = { drop; NoAction; } | ||
const default_action = NoAction(); | ||
implementation = my_action_selector; | ||
} | ||
|
||
apply { | ||
indirect.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(inout H hdr, inout M meta) { | ||
apply { } | ||
} | ||
|
||
control ComputeChecksumI(inout H hdr, inout M meta) { | ||
apply { } | ||
} | ||
|
||
V1Switch(ParserI(), VerifyChecksumI(), IngressI(), EgressI(), | ||
ComputeChecksumI(), 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
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
9 changes: 6 additions & 3 deletions
9
testdata/p4_16_samples_outputs/action_profile_max_group_size_annotation.p4-stderr
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
action_profile_max_group_size_annotation.p4(39): [--Wwarn=ignore] warning: Ignoring annotation @max_group_size on action profile 'ap', which does not have a selector | ||
@name("ap") @max_group_size(200) implementation = action_profile(32w128); | ||
^^^^^^^^^^^^^^ | ||
action_profile_max_group_size_annotation.p4(44): [--Wwarn=ignore] warning: Ignoring annotation @max_group_size on action profile 'ap', which does not have a selector | ||
implementation = action_profile(32w128); | ||
^^^^^^^^^^^^^^ | ||
action_profile_max_group_size_annotation.p4(57): [--Wwarn=ignore] warning: Ignoring annotation @max_member_weight on action profile 'ap_ws', which does not use 'sum_of_members' as its SelectorSizeSemantics | ||
implementation = action_selector(HashAlgorithm.identity, 32w1024, 32w10); | ||
^^^^^^^^^^^^^^ |
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 |
---|---|---|
|
@@ -70,6 +70,8 @@ action_profiles { | |
with_selector: true | ||
size: 1024 | ||
max_group_size: 200 | ||
sum_of_weights { | ||
} | ||
} | ||
type_info { | ||
} |
71 changes: 71 additions & 0 deletions
71
testdata/p4_16_samples_outputs/action_profile_sum_of_members_annotation-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,71 @@ | ||
#include <core.p4> | ||
#define V1MODEL_VERSION 20180101 | ||
#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() { | ||
mark_to_drop(smeta); | ||
} | ||
@name("ap") @max_group_size(200) @selector_size_semantics("sum_of_members") @max_member_weight(4000) action_profile(32w128) my_action_profile; | ||
@name("ap_ws") @max_group_size(200) @selector_size_semantics("sum_of_members") @max_member_weight(4000) action_selector(HashAlgorithm.identity, 32w1024, 32w10) my_action_selector; | ||
table indirect { | ||
actions = { | ||
drop(); | ||
NoAction(); | ||
} | ||
const default_action = NoAction(); | ||
implementation = my_action_profile; | ||
} | ||
table indirect_ws { | ||
key = { | ||
meta.hash1: selector @name("meta.hash1"); | ||
} | ||
actions = { | ||
drop(); | ||
NoAction(); | ||
} | ||
const default_action = NoAction(); | ||
implementation = my_action_selector; | ||
} | ||
apply { | ||
indirect.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(inout 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; |
Oops, something went wrong.