Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic Table First draft #435

Merged
merged 45 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e553d88
Initial changes for generic tables
saynb Apr 13, 2023
1d8eff5
second changes
saynb Apr 13, 2023
4690968
3rd changes
saynb Apr 14, 2023
55bf9be
4th changes
saynb Apr 14, 2023
f775ddc
5th changes
saynb Apr 14, 2023
07b2da6
Adding p4types and p4info changes for GenericData (#4)
saynb May 12, 2023
e4a5309
Adding varbits and a readme writeup (#5)
saynb May 12, 2023
fd132e7
Adding proto changes
saynb May 12, 2023
2a5eae6
Adding genericTable for direct resources. Adding P4datatypespec to ge…
saynb May 19, 2023
35dc65a
* Adding more container types
saynb May 26, 2023
6e7c5f1
* Add Table categories introduction
saynb May 26, 2023
d6e042b
* Adding 3-level property details (Table, Entry, field)
saynb Jun 2, 2023
53b105f
* Adding Read RPC details in table categories
saynb Jun 9, 2023
b0c29d2
Expanding combinations
saynb Jun 16, 2023
4ab7546
review comments
saynb Jun 23, 2023
88a0dd1
* Explain more on indexed tables. How are duplicates handled
saynb Jun 29, 2023
74c1661
Update Go dependencies (#438)
antoninbas Jul 6, 2023
d76a364
Fixes https://github.com/p4lang/p4runtime/issues/439 (#440)
chrispsommers Jul 6, 2023
be046f3
* Adding categories and properties in p4info
saynb Jul 7, 2023
cd271fd
* Removed GenericTable category from the p4info
saynb Jul 13, 2023
1131a75
Adding space for dummy commit
saynb Jul 21, 2023
eef4daf
Correcting typo
saynb Aug 3, 2023
0e2fb58
Adding dev branches to workflows (#443)
saynb Aug 4, 2023
119bdd6
Merge branch 'main' into generic_table_2
saynb Aug 8, 2023
5797394
Merge branch 'generic-table-dev' of https://github.com/saynb/p4runtim…
saynb Aug 8, 2023
e9e996e
Correcting linter errors
saynb Aug 8, 2023
3a5f4e4
Generating go and py files
saynb Aug 8, 2023
29aab4e
Adding text regarding direct resources as GenericTables in TableEntry
saynb Aug 11, 2023
185fa08
some review comment changes
saynb Aug 19, 2023
090aa0a
Andy review comments
saynb Aug 25, 2023
48f04d9
remove whitespace
saynb Aug 25, 2023
b101dab
* Correcting GenericTable.md according to the p4info
saynb Sep 7, 2023
4d4d9f7
* Removing float from p4info and spec
saynb Sep 7, 2023
89f11d9
* Adding section to P4DataTypeSpec to indicate adding to
saynb Sep 7, 2023
371d184
Moving GenericTable.md to docs
saynb Sep 7, 2023
b4dfa73
Correcting spec for removal of p4_type in generic_type. Adding genera…
saynb Sep 7, 2023
a8ec796
* Shortening the field names in `GenericTable` to remove "genric_table_"
saynb Sep 7, 2023
1c026e4
* Making default_value as bytes
saynb Sep 7, 2023
727bab2
Adding default string value
saynb Sep 7, 2023
7f1a54a
review comments
saynb Sep 7, 2023
2cbd34c
linter error
saynb Sep 7, 2023
9ff6e4e
Review comments
saynb Sep 22, 2023
0fcf0c4
Correcting whitespace errors
saynb Dec 7, 2023
71eef58
Resolving conflicts in spec and proto only
saynb Feb 22, 2024
8bbd503
Updating generated code
saynb Feb 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
371 changes: 371 additions & 0 deletions docs/v1/P4Runtime-Spec.mdk

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/v1/assets/generic-tables-insert-flow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 124 additions & 0 deletions proto/p4/GenericTable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# GenericTable example p4info

Below is an example for realizing MulticastGroupEntry as a GenericTable.
The key (MatchFields) comprise of only the group_id. 2 different ways of
defining the data fields has been presented. Only 1 of them is required.

```
generic_tables {
generic_table_type_id : 145
generic_table_type_name : "MulticastGroup"
generic_table_properties : {
read-only : False
saynb marked this conversation as resolved.
Show resolved Hide resolved
}
generic_table_properties : {
modify-only : False
}
generic_table_properties : {
reset-only : False
}
generic_table_properties : {
volatile : False
}
generic_table_properties : {
indexed : True
}

saynb marked this conversation as resolved.
Show resolved Hide resolved
preamble {
id: 45332650
name: "MulticastGroup"
alias: "multicast_group"
}
generic_match_fields {
id: 1
name: "multicast_group_id"
match_type: EXACT
saynb marked this conversation as resolved.
Show resolved Hide resolved
type {
saynb marked this conversation as resolved.
Show resolved Hide resolved
type : "bytes"
width : 32
}
}
union_refs {
id: 23557840
}
saynb marked this conversation as resolved.
Show resolved Hide resolved
size: 1024
}
```

In the below one, both `instance` and `port` are separate
repeated fields. So the check on `len(instance_array) == len(port_array)`
needs to be a runtime check. This however keeps implementation simpler
and faster since we avoid further recursive nesting.

`port` is a varbytes of max size 64 bits each. The field has a `repeated_type`
as well, so it is defined as list of varbits through p4info.
saynb marked this conversation as resolved.
Show resolved Hide resolved

```
unions {
preamble {
id: 23557840
name: "multicast_group_member_add"
alias: "multicast_group_member_add"
}
params {
id: 1
name: "instance"
type {
container_type : "list"
container_max_size : 10
type : "bytes"
width : 32
}
}
params {
id: 2
name: "port"
type {
container_type : "list"
container_max_size : 10
type : "varbytes"
max_bit_width : 64
}
}
}

```

The below one is similar to the above but both `instance` and `port` have
been converted to a list of structs.

```
unions {
preamble {
id: 23557841
name: "multicast_group_member_add_2"
alias: "multicast_group_member_add_2"
}
params {
id: 1
name: "replica"
type {
saynb marked this conversation as resolved.
Show resolved Hide resolved
container_type : "list"
type : "struct"
}
params {
param {
id: 1
name: "instance"
type {
type : "bytes"
width : 32
}
}
param : {
id: 2
name: "port"
type {
type : "varbytes"
max_bit_width : 64
}
}
}
}
}
```
105 changes: 105 additions & 0 deletions proto/p4/config/v1/p4info.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ message P4Info {
repeated ValueSet value_sets = 10;
repeated Register registers = 11;
repeated Digest digests = 12;
repeated GenericTable generic_tables = 13;
repeated Union unions = 14;
repeated Extern externs = 100;
P4TypeInfo type_info = 200;
}
Expand Down Expand Up @@ -103,6 +105,7 @@ message P4Ids {
DIRECT_METER = 0x15;
REGISTER = 0x16;
DIGEST = 0x17;
GENERIC_TABLE = 0x18;
saynb marked this conversation as resolved.
Show resolved Hide resolved

// externs for other architectures (vendor extensions)
OTHER_EXTERNS_START = 0x80;
Expand All @@ -114,6 +117,22 @@ message P4Ids {
}
}

// A subtype of P4IDs for GenericTables
message GenericTableType {
saynb marked this conversation as resolved.
Show resolved Hide resolved
// The ID space is for Generic tables. In the Preamble ID, the MSB will be
// 0x18 but the next MSB is reserved for this enum. This shortens the ID
// space for tables in each type but it is still 64k (16 bits) for each table
enum Prefix {

GENERIC_TABLES_START = 0x00;

// max value for an unsigned 8-bit byte
MAX = 0xff;
// requires protoc >= 3.5.0
// reserved 0x100 to max;
}
}

message Preamble {
// ids share the same number-space; e.g. table ids cannot overlap with counter
// ids. Even though this is irrelevant to this proto definition, the ids are
Expand Down Expand Up @@ -397,3 +416,89 @@ message Digest {
Preamble preamble = 1;
P4DataTypeSpec type_spec = 2;
}

////// Begin : GenericTables messages

message GenericMatchField {
uint32 id = 1;
string name = 2;
bool repeated = 3;
saynb marked this conversation as resolved.
Show resolved Hide resolved
GenericDataTypeSpec type_spec = 4;
saynb marked this conversation as resolved.
Show resolved Hide resolved
enum MatchType {
UNSPECIFIED = 0;
EXACT = 2;
LPM = 3;
TERNARY = 4;
RANGE = 5;
OPTIONAL = 6;
}
oneof match {
MatchType match_type = 5;
// used for architecture-specific match types which are not part of the core
// P4 language or of the PSA architecture.
saynb marked this conversation as resolved.
Show resolved Hide resolved
string other_match_type = 6;
}
// Documentation of the match field
Documentation doc = 7;
repeated string annotations = 8;
// Optional. If present, the location of `annotations[i]` is given by
// `annotation_locations[i]`.
repeated StructuredAnnotation structured_annotations = 9;
repeated SourceLocation annotation_locations = 10;
}

// used to list all possible unions in a Table
message UnionRef {
uint32 id = 1;
enum Scope {
TABLE_AND_DEFAULT = 0;
TABLE_ONLY = 1;
DEFAULT_ONLY = 2;
}
Scope scope = 3;
repeated string annotations = 2;
// Optional. If present, the location of `annotations[i]` is given by
// `annotation_locations[i]`.
repeated SourceLocation annotation_locations = 5;
repeated StructuredAnnotation structured_annotations = 4;
}

message Union {
Preamble preamble = 1;
message Param {
uint32 id = 1;
string name = 2;
bool repeated = 3;
saynb marked this conversation as resolved.
Show resolved Hide resolved
repeated string annotations = 4;
GenericDataTypeSpec type_spec = 5;
// Documentation of the Param
Documentation doc = 6;
repeated StructuredAnnotation structured_annotations = 7;
// Optional. If present, the location of `annotations[i]` is given by
// `annotation_locations[i]`.
repeated SourceLocation annotation_locations = 8;
}
repeated Param params = 2;
}

// All Tables of one type will be grouped in one message.
message GenericTable {
uint32 generic_table_type_id = 1;
saynb marked this conversation as resolved.
Show resolved Hide resolved
string generic_table_type_name = 2;
repeated string generic_table_properties = 3
repeated GenericTableInstance instances = 4;
}

message GenericTableInstance {
saynb marked this conversation as resolved.
Show resolved Hide resolved
Preamble preamble = 1;
repeated GenericMatchField generic_match_fields = 2;
repeated UnionRef union_refs = 3;
// 0 (default value) means that the table does not have a const default action
uint32 const_default_union_id= 4;
int64 size = 5; // max number of entries in table
saynb marked this conversation as resolved.
Show resolved Hide resolved
// architecture-specific table properties which are not part of the core P4
// language or of the PSA architecture.
google.protobuf.Any other_properties = 100;
}

////// End: GenericTables
Loading