Skip to content

Commit

Permalink
Merge pull request #5 from ipdk-io/P4RuntimeProtoChange
Browse files Browse the repository at this point in the history
Integrate idpf extensions to p4runtime
  • Loading branch information
aashishkuma authored Mar 11, 2024
2 parents 40e36a3 + aee94d1 commit 07f6717
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 12 deletions.
52 changes: 52 additions & 0 deletions proto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ proto_library(
# strip_import_prefix = "proto",
)

proto_library(
name = "idpf_p4info_proto",
srcs = ["idpf/p4info.proto"],
deps = [
":p4info_proto",
],
# TODO(github.com/grpc/grpc/issues/20675): strip_import_prefix breaks
# cc_grpc_library. Make proto folder the Bazel root folder as a workaround.
# strip_import_prefix = "proto",
)

proto_library(
name = "p4runtime_proto",
srcs = ["p4/v1/p4runtime.proto"],
Expand All @@ -51,6 +62,18 @@ proto_library(
# strip_import_prefix = "proto",
)

proto_library(
name = "idpf_p4runtime_proto",
srcs = ["idpf/p4runtime.proto"],
deps = [
":p4runtime_proto",
"@com_google_protobuf//:any_proto",
],
# TODO(github.com/grpc/grpc/issues/20675): strip_import_prefix brakes
# cc_grpc_library. Make proto folder the Bazel root folder as a workaround.
# strip_import_prefix = "proto",
)

cc_proto_library(
name = "p4types_cc_proto",
deps = [":p4types_proto"],
Expand All @@ -61,6 +84,11 @@ cc_proto_library(
deps = [":p4info_proto"],
)

cc_proto_library(
name = "idpf_p4info_cc_proto",
deps = [":idpf_p4info_proto"],
)

cc_proto_library(
name = "p4data_cc_proto",
deps = [":p4data_proto"],
Expand All @@ -71,6 +99,11 @@ cc_proto_library(
deps = [":p4runtime_proto"],
)

cc_proto_library(
name = "idpf_p4runtime_cc_proto",
deps = [":idpf_p4runtime_proto"],
)

py_proto_library(
name = "p4types_py_proto",
deps = [":p4types_proto"],
Expand All @@ -81,6 +114,11 @@ py_proto_library(
deps = [":p4info_proto"],
)

py_proto_library(
name = "idpf_p4info_py_proto",
deps = [":idpf_p4info_proto"],
)

py_proto_library(
name = "p4data_py_proto",
deps = [":p4data_proto"],
Expand All @@ -91,6 +129,20 @@ py_proto_library(
deps = [":p4runtime_proto"],
)

py_proto_library(
name = "idpf_p4runtime_py_proto",
deps = [":idpf_p4runtime_proto"],
)

go_proto_library(
name = "idpf_p4info_go_proto",
importpath = "github.com/p4lang/p4runtime/go/idpf",
protos = [
":idpf_p4info_proto",
":idpf_p4runtime_proto",
],
)

go_proto_library(
name = "p4info_go_proto",
importpath = "github.com/p4lang/p4runtime/go/p4/config/v1",
Expand Down
75 changes: 75 additions & 0 deletions proto/idpf/p4info.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) 2024, Intel 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.
//
// For licensing information, see the file ‘LICENSE’ in the root folder

syntax = "proto3";

import "p4/config/v1/p4info.proto";

// This is an extension of p4/config/v1/p4info.proto.
// It provides support for the meter externs in the Intel IPU E2100.

package idpf;

option go_package = "github.com/p4lang/p4runtime/go/idpf";

message P4Ids {
enum Prefix {
UNSPECIFIED = 0;
MATCH_VALUE_LOOKUP_TABLE = 0x81;
TERNARY_MATCH_LOOKUP_TABLE = 0x82;
TSMETER = 0x83;
DIRECT_TSMETER = 0x84;
PACKET_MOD_METER = 0x85;
DIRECT_PACKET_MOD_METER = 0x86;
}
}

message Param {
uint32 id = 1;
string name = 2;
uint32 bitwidth = 3;
}

message MatchValueLookupTable {
p4.config.v1.Preamble preamble = 1;
repeated p4.config.v1.MatchField match_fields = 2;
repeated Param params = 3;
uint32 size = 4;
}

message TSMeter {
p4.config.v1.Preamble preamble = 1;
p4.config.v1.MeterSpec spec = 2;
int32 size = 3;
uint32 index_width = 4;
}

message DirectTSMeter {
p4.config.v1.Preamble preamble = 1;
p4.config.v1.MeterSpec spec = 2;
}

message PacketModMeter {
p4.config.v1.Preamble preamble = 1;
p4.config.v1.MeterSpec spec = 2;
int32 size = 3;
uint32 index_width = 4;
}

message DirectPacketModMeter {
p4.config.v1.Preamble preamble = 1;
p4.config.v1.MeterSpec spec = 2;
}
57 changes: 57 additions & 0 deletions proto/idpf/p4runtime.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) 2024, Intel 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.
//
// For licensing information, see the file ‘LICENSE’ in the root folder

syntax = "proto3";

import "google/protobuf/any.proto";
import "p4/v1/p4runtime.proto";

// This is an extension of p4/v1/p4runtime.proto
// It provides support for the meter externs in the Intel IPU E2100.

package idpf;

option go_package = "github.com/p4lang/p4runtime/go/idpf";

// MatchValueLookupTable
message MVLUTEntry {
uint32 mvlut_id = 1;
message ConfigParam {
message Param {
uint32 param_id = 1;
uint64 param_value = 2;
}
repeated Param params = 1;
}
repeated p4.v1.FieldMatch match = 2;
ConfigParam param = 3;
}

// DANGER -- this is an extension of p4.v1.Action with some additional fields.
// as such it needs to be identical to that with just extra stuff added.
// It is unfortunate that protobuf does not support versioning and extension.
message Action {
uint32 action_id = 1;
message Param {
uint32 param_id = 2;
bytes value = 3;
// extra stuff added for idpf
string param_name = 5;
string proto_id = 6;
string key_name = 7;
}
repeated Param params = 4;
}
12 changes: 0 additions & 12 deletions proto/p4/config/v1/p4info.proto
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,3 @@ message Digest {
Preamble preamble = 1;
P4DataTypeSpec type_spec = 2;
}

message PacketModMeter {
Preamble preamble = 1;
MeterSpec spec = 2;
int32 size = 3;
uint32 index_width = 4;
}

message DirectPacketModMeter {
Preamble preamble = 1;
MeterSpec spec = 2;
}

0 comments on commit 07f6717

Please sign in to comment.