### Install P4Runtime Python Library Source: https://github.com/p4lang/p4runtime/blob/main/py/README.md Install the P4Runtime Python library using pip3. You can install the latest version or specify a particular version. ```bash pip3 install p4runtime ``` ```bash pip3 install p4runtime==1.3.0 ``` -------------------------------- ### P4Runtime Wildcard Read Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Demonstrates how to construct a ReadRequest to retrieve the entire forwarding state of a device by using wildcard entities. ```protobuf device_id: "DEVICE_ID" entities { extern_entry { } // read all extern instances for all supported extern types table_entry { } // read all table entries for all tables action_profile_member { } // read all members for all action profiles action_profile_group { } // read all groups for all action profiles ... } ``` -------------------------------- ### Wildcard Reads Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Illustrates how to perform wildcard reads for the entire forwarding state of a device using the Read RPC. ```APIDOC ## Wildcard Reads P4Runtime allows wildcard reads of P4 entities by omitting or using default values for parts of the entity key in the `ReadRequest`. To read the entire forwarding state for a given device, the P4Runtime client can generate the following `ReadRequest`: [source,protobuf] ---- device_id: "DEVICE_ID" entities { extern_entry { } // read all extern instances for all supported extern types table_entry { } // read all table entries for all tables action_profile_member { } // read all members for all action profiles action_profile_group { } // read all groups for all action profiles ... } ---- An empty `Entity` message is not supported for wildcard reads of the entire forwarding state. ``` -------------------------------- ### Install cargo-outdir Source: https://github.com/p4lang/p4runtime/blob/main/rust/README.md Command to install the `cargo-outdir` utility, which helps in locating generated build files. ```bash cargo install cargo-outdir ``` -------------------------------- ### PkgInfo Annotation Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Demonstrates the usage of multiple @pkginfo, @brief, and @description annotations on the main block to define P4 program metadata. Custom annotations are also shown. ```p4 @pkginfo(name="switch.p4",version="2") @pkginfo(organization="p4.org") @pkginfo(contact="info@p4.org") @pkginfo(url="www.p4.org") @brief("L2/L3 switch") @description("L2/L3 switch.\ Built for data-center profile.") @my_annotation1(...) // Not well-known, this will appear in PkgInfo annotations @my_annotation2(...) // Not well-known, this will appear in PkgInfo annotations PSA_Switch(IgPipeline, PacketReplicationEngine(), EgPipeline, BufferingQueueingEngine()) main; ``` -------------------------------- ### P4Runtime Write RPC Error Reporting Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Illustrates a grpc::Status for a P4Runtime Write RPC where the first and third updates failed, and the second succeeded. This example shows how errors are reported using UNKNOWN status codes and packed p4.Error messages in the details field. ```protobuf code_ = 2 // UNKNOWN error_message_ = "Write failure." binary_error_details { code: 2 // UNKNOWN message: "Write failure." details { canonical_code: 8 // RESOURCE_EXHAUSTED message: "Table is full." space: "targetX-psa-vendorY" } } ``` -------------------------------- ### Value Set Example with Multiple Matches Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Demonstrates a P4 Value Set with multiple match fields of different kinds, including ternary and custom matches. This example is useful for understanding complex P4 data structures. ```p4 struct match_t { bit<8> f8; @match(ternary) bit<16> f16; @match(custom) bit<32> f32; } @id(1) value_set(4) pvs; select ({ hdr.f8, hdr.f16, hdr.f32 }) { /* ... */ } ``` -------------------------------- ### P4 Register Declaration Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Illustrates a P4-16 header union and a register declaration using that union. ```p4 header_union ip_t { ipv4_t ipv4; ipv6_t ipv6; } Register >(128) register_ip; ``` -------------------------------- ### P4Info Entry for Register Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Shows the corresponding P4Info message structure for the P4 register declaration, including type specifications for headers and header unions. ```protobuf registers { preamble { id: 369119267 name: "register_ip" alias: "register_ip" } type_spec { header_union { name: "ip_t" } } size: 128 } type_info { headers { key: "ipv4_t" value { members { name: "version" type_spec { bit { bitwidth: 4 } } } ... headers { key: "ipv6_t" value { members { name: "version" type_spec { bit { bitwidth: 4 } } } ... header_unions { key: "ip_t" value { members { name: "ipv4" header { name: "ipv4_t" } } members { name: "ipv6" header { name: "ipv6_t" } } } } } ``` -------------------------------- ### P4 Code Example with Type Aliases Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/guidance-for-generating-p4info.md Demonstrates P4_16 type definitions using 'typedef' and 'type' keywords, including a 'p4runtime_translation' annotation. This example illustrates how nested type definitions and annotations affect P4Info generation. ```p4 typedef bit<10> T1uint_t; @p4runtime_translation("mycompany.com/myco_p4lib/v1/T1_t", 32) type T1uint_t T1_t; type T1_t T2_t; T2_t f3; ``` -------------------------------- ### P4 Code Annotations for PkgInfo Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Illustrates various annotations that can be applied to the 'main' block in P4 code to populate PkgInfo messages. Includes examples for @pkginfo, @brief, @description, and custom annotations. ```p4 @pkginfo(key=value) @pkginfo(key=value[,key=value,...]) @brief("A brief description") @description("A longer\ description") @custom_annotation(...) @another_custom_annotation(...) @platform_property(key=value) @platform_property(key=value[,key=value,...]) ``` -------------------------------- ### Action Profile Action Set Example (protobuf) Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc This protobuf message defines an action set for an action profile, including individual actions with their weights and watch ports. It demonstrates how to program multiple actions within a single update. ```protobuf table_entry { table_id: 0x0212ab34 match { /* lpm match */ } action { action_profile_action_set { action_profile_actions { action { /* set nexthop 1 */ } weight: 1 watch_port: "\x01" } action_profile_actions { action { /* set nexthop 2 */ } weight: 2 watch_port: "\x02" } action_profile_actions { action { /* set nexthop 3 */ } weight: 3 watch_port: "\x03" } } } } ``` -------------------------------- ### Action Profile Group Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Defines a group of members for an action profile. This allows for collective actions or load balancing configurations. ```protobuf action_profile_group { action_profile_id: 0x11ab12cd group_id: GROUP_ID members { member_id: MEMBER_ID_1 weight: 1 watch_port: "\x01" } members { member_id: MEMBER_ID_2 weight: 2 watch_port: "\x02" } members { member_id: MEMBER_ID_3 weight: 3 watch_port: "\x03" } } ``` -------------------------------- ### Action Profile Member Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Defines members for an action profile. Used for configuring individual members within an action profile. ```protobuf action_profile_member { action_profile_id: 0x11ab12cd member_id: MEMBER_ID_1 action { /* set nexthop 1 */ } } action_profile_member { action_profile_id: 0x11ab12cd member_id: MEMBER_ID_2 action { /* set nexthop 2 */ } } action_profile_member { action_profile_id: 0x11ab12cd member_id: MEMBER_ID_3 action { /* set nexthop 3 */ } } ``` -------------------------------- ### ARP Packet Multicast Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Illustrates a P4 program snippet for multicasting ARP packets by setting the multicast_group metadata. This example assumes a 10-bit multicast group metadata type. ```p4 control arp_multicast(inout H hdr, inout M smeta) { apply { if (hdr.ethernet.isValid() && hdr.ethernet.eth_type == ETH_TYPE_ARP) { smeta.multicast_group = (MulticastGroup_t) 1; } } } ``` -------------------------------- ### Connect to P4Runtime gRPC Service using p4runtime-tonic Source: https://github.com/p4lang/p4runtime/blob/main/rust/README.md Example of establishing a connection to a P4Runtime gRPC service using the P4RuntimeClient from the p4runtime-tonic crate. This is typically used for implementing P4Runtime clients. ```rust use p4runtime_tonic::p4::v1::p4_runtime_client::P4RuntimeClient; let mut client = P4RuntimeClient::connect("http://[::1]:50051").await?; ``` -------------------------------- ### Add P4Runtime Go Library to go.mod Source: https://github.com/p4lang/p4runtime/blob/main/py/README.md Include the P4Runtime Go library in your project by adding its repository URL to your go.mod file. This example shows how to specify a version. ```go module your_module_name go 1.13 require ( github.com/p4lang/p4runtime v1.3.0 ) ``` -------------------------------- ### Navigate to Generated Code with cargo-outdir Source: https://github.com/p4lang/p4runtime/blob/main/rust/README.md Command to navigate to the build directory containing generated files for a specific crate, after installing `cargo-outdir`. ```bash cd $(cargo outdir --no-names) ``` -------------------------------- ### Construct WriteRequest using p4runtime-prost Source: https://github.com/p4lang/p4runtime/blob/main/rust/README.md Example of creating a WriteRequest message using the p4runtime-prost crate. This is useful for constructing or serializing P4Runtime messages when gRPC functionality is not required. ```rust use p4runtime_prost::p4::v1::WriteRequest; let request = WriteRequest { device_id: 1, // ... other fields }; ``` -------------------------------- ### Action Profile Action Set with Multiple Weights Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Configures an action profile set with multiple actions and weights, allowing for complex load balancing or weighted forwarding. This example demonstrates specifying multiple instances of the same action with different weights. ```protobuf table_entry { table_id: 0x0212ab34 match { /* lpm match */ } action { action_profile_action_set { action_profile_actions { action { /* set nexthop 1 */ } weight: 100 watch_port: "\x01" } action_profile_actions { action { /* set nexthop 1 */ } weight: 100 watch_port: "\x01" } action_profile_actions { action { /* set nexthop 2 */ } weight: 2 watch_port: "\x02" } } } } ``` -------------------------------- ### Empty Expression List Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Demonstrates an empty expression list annotation in P4. The generated P4Info will contain a structured annotation with the specified name. ```p4 @Empty[] table t { ... } ``` ```protobuf structured_annotations { name: "Empty" } ``` -------------------------------- ### Update Generated Protobuf Files Source: https://github.com/p4lang/p4runtime/blob/main/py/README.md Run this script to update generated Go and Python files after updating Protobuf files. Ensure Docker is installed and your user is in the 'docker' group. ```bash ./codegen/update.sh ``` -------------------------------- ### Key-Value Pair List Annotation Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Illustrates a key-value pair list annotation with mixed expression types. The generated P4Info will represent these key-value pairs with their evaluated values. ```p4 @MixedKV[label="text", my_bool=true, int_val=2*3] table t { ... } ``` ```protobuf structured_annotations { name: "MixedKV" kv_pair_list { kv_pairs { key: "label" value { string_value: "text" } } kv_pairs { key: "my_bool" value { bool_value: true } } kv_pairs { key: "int_val" value { int64_value: 6 } } } } ``` -------------------------------- ### Complex P4 Types Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Illustrates the use of complex P4 types like Digest with tuples and Register with header unions, which require specific handling in P4Runtime. ```p4 Digest, bit<8> > >() digest_complex; digest_complex.pack({ hdr.ipv4.version, hdr.ipv4.protocol }); // ... header_union ip_t { ipv4_t ipv4; ipv6_t ipv6; } Register >(128) register_ip; ``` -------------------------------- ### Valid Bytestring Encodings for P4Runtime Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Examples of valid P4Runtime binary string encodings for various P4 integer types. These demonstrate how different bitwidths and signedness are handled, including cases for read-write symmetry. ```text P4 type | Integer value | P4Runtime binary string | Read-write symmetry `bit<8>` | 99 (0x63) | `\x63` | yes `bit<16>` | 99 (0x63) | `\x00\x63` | no `bit<16>` | 99 (0x63) | `\x63` | yes `bit<16>` | 12388 (0x3064) | `\x30\x64` | yes `bit<16>` | 12388 (0x3064) | `\x00\x30\x64` | no `bit<12>` | 99 (0x63) | `\x00\x63` | no `bit<12>` | 99 (0x63) | `\x63` | yes `bit<12>` | 99 (0x63) | `\x00\x00\x63` | no `int<8>` | 99 (0x63) | `\x63` | yes `int<8>` | -99 (-0x63) | `\x9d` | yes `int<8>` | -99 (-0x63) | `\xff\x9d` | no `int<12>` | -739 (-0x2e3) | `\xfd\x1d` | yes `int<16>` | 0 (0x0) | `\x00\x00` | no `int<16>` | 0 (0x0) | `\x00` | yes ``` -------------------------------- ### Read Counter Entry by Index (C++) Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Example of reading a specific counter entry by setting its index. Note that scalar fields with default values (like index 0) are omitted in text dumps. ```c++ p4::v1::CounterEntry entry; entry.set_counter_id(); ``` -------------------------------- ### P4 Extern Definition Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc An example of an extern definition for a custom packet counter in P4. This defines the `MyNewPacketCounter` extern with `size`, `counter`, and `increment` methods. ```p4 // T must be a bit type, it indicates the width of each counter cell extern MyNewPacketCounter { counter(bit<32> size); increment(in bit<32> index); } ``` -------------------------------- ### Build, Tag, and Push P4Runtime Docker Image Source: https://github.com/p4lang/p4runtime/blob/main/docs/tools/README.md Commands to build the Docker image from Dockerfile.asciidoc, tag it for Docker Hub, and push the latest version. Requires write permissions to the p4lang Docker Hub repository and prior login. ```bash docker build -t p4rt-asciidoc -f Dockerfile.asciidoc . docker tag p4rt-asciidoc p4lang/p4rt-asciidoc:latest docker push p4lang/p4rt-asciidoc:latest ``` -------------------------------- ### Build P4Runtime Specification with Docker Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/README.md Build the P4Runtime specification documentation, including images, using the p4lang/p4rt-asciidoc Docker image. ```bash docker run -v `pwd`/docs/v1:/usr/src/p4-spec p4lang/p4rt-asciidoc:latest make build_spec_with_images ``` -------------------------------- ### Find Proto Files Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/p4runtime-id-notes.md Lists all .proto files within the p4lang/p4runtime repository. ```bash $ find . -name '*.proto' ./proto/p4/v1/p4runtime.proto ./proto/p4/v1/p4data.proto ./proto/p4/config/v1/p4info.proto ./proto/p4/config/v1/p4types.proto ``` -------------------------------- ### P4Runtime ValueSetEntry Update Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc An example of a P4Runtime 'MODIFY' update for a Value Set, adding members with specific EtherType values. ```protobuf type: MODIFY entity { value_set_entry { value_set_id: 0x03000001 members { match { field_id: 1 exact { value: 0x22f3 } } match { field_id: 1 exact { value: 0x893b } } } } } ``` -------------------------------- ### Build P4Runtime Protobufs with Docker Source: https://github.com/p4lang/p4runtime/blob/main/py/README.md Use Docker to compile P4Runtime Protobuf files and generate bindings for C++, Python, and Go. Specify an absolute path for the output directory. ```sh docker build -t p4runtime -f codegen/Dockerfile . docker run -v :/out/ -t p4runtime /p4runtime/codegen/compile_protos.sh /out/ ``` -------------------------------- ### Build Documentation with Cargo Doc Source: https://github.com/p4lang/p4runtime/blob/main/rust/README.md Command to build and open the documentation for the P4Runtime Rust crates. This allows you to navigate and view the source code of generated elements. ```bash cargo doc --open ``` -------------------------------- ### Build P4Runtime Protobufs with Bazel Source: https://github.com/p4lang/p4runtime/blob/main/py/README.md Use Bazel to build all protobuf files in the repository. This command is used in the continuous integration system. ```sh bazel build //... ``` -------------------------------- ### P4 Documentation Annotations Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Illustrates how to use @brief and @description annotations in P4 code to generate Documentation messages. ```p4 @brief(string...) @description(string...) ``` ```p4 @brief("Match IPv4 addresses to next-hop MAC and port") @description("Match IPv4 addresses to next-hop MAC and port. \ Uses LPM match type.") table my_ipv4_lkup { ... } ``` -------------------------------- ### StreamError for Malformed Packet-Out Metadata Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Example of a StreamError response when a PacketOut message contains unknown metadata field IDs. The server returns INVALID_ARGUMENT. ```protobuf error { canonical_code: 3 // INVALID_ARGUMENT message: "Unknown metadata field id 7." packet_out { // copied from the PacketOut message received from the client packet_out { payload: ... metadata { id: 7 name: "I_should_not_be_here" bitwidth: 32 } // more metadata ... } } } ``` -------------------------------- ### P4 User-Defined Types with Translation Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Defines custom types with `@p4runtime_translation` annotations for different controller representations. Shows examples for string and bitwidth translations. ```p4 // Controller refers to ports as a string, e.g. "eth0". @p4runtime_translation("p4.org/psa/v1/PortId_String_t", string) type bit<9> PortId_String_t; // Controller refers to ports as a 32-bit integer, e.g. 0xffffffff. @p4runtime_translation("p4.org/psa/v1/PortId_Bit32_t", bit<32>) type bit<9> PortId_Bit32_t; // Same as above. @p4runtime_translation("p4.org/psa/v1/PortId_32_t", 32) type bit<9> PortId_32_t; ``` -------------------------------- ### Unset Election ID Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Illustrates how an unset election_id is treated as lower than any specified election_id, preventing a controller from becoming primary. Useful for standby controllers. ```protobuf election_id : { high: 0 low: 0 } ``` -------------------------------- ### Define a trTCM Direct Meter in P4 Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Example of defining a trTCM direct meter with the `@two_rate_three_color` annotation in a V1Model P4 program. This mode is the default for meters. ```p4 @two_rate_three_color direct_meter(MeterType.bytes) my_meter; ``` -------------------------------- ### P4Runtime WriteRequest for Value Set Membership Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Sets membership for a P4 Value Set using a WriteRequest. It includes examples of modifying entries with different match types. ```protobuf type: MODIFY entity { value_set_entry { value_set_id: 0x03000001 members { match { field_id: 1 exact { value: 0xac } } // match for field_id 2 is missing => don't care match match { field_id: 3 other { ... } // some serialized Any message (architecture-specific) } } members { match { field_id: 1 exact { value: 0xdc } } match { field_id: 2 ternary { value: 0x88 mask: 8f } } match { field_id: 3 other { ... } // some serialized Any message (architecture-specific) } } } } ``` -------------------------------- ### P4 Code: Simple bit type Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/guidance-for-generating-p4info.md Example of a P4 field with a simple bitwidth type. For such cases, `type_name` is unset and `bitwidth` is derived directly from the bitwidth. ```p4 bit<10> f1; type_list(f1) -> [bit<10>] type_name: left unset in P4Info message bitwidth: 10 ``` -------------------------------- ### Setting a Counter Entry Index in C++ Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Demonstrates how to set a specific index for a P4Runtime CounterEntry message using C++ client code. This is equivalent to specifying a particular entry in a counter array. ```c++ p4::v1::CounterEntry entry; entry.set_counter_id(); entry.mutable_index(); // The above line sets the index field; it is equivalent to: // auto *index = entry.mutable_index(); // index->set_index(0); ``` -------------------------------- ### Mixed Expression List Example Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Shows a mixed expression list annotation with string, integer, and boolean expressions. The compiler evaluates these expressions into their respective types in the generated P4Info. ```p4 #define TEXT_CONST "hello" #define NUM_CONST 6 @MixedExprList[1,TEXT_CONST,true,1==2,5+NUM_CONST] table t { ... } ``` ```protobuf structured_annotations { name: "MixedExprList" expression_list { expressions { int64_value: 1 } expressions { string_value: "hello" } expressions { bool_value: true } expressions { bool_value: false } expressions { int64_value: 11 } } } ``` -------------------------------- ### P4Info TypeInfo for Translated Types Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Illustrates the P4Info message structure for user-defined types that use the `@p4runtime_translation` annotation. Shows how `P4NewTypeSpec` and `P4NewTypeTranslation` are populated. ```protobuf type_info { new_types { key: "PortId_String_t" value { // P4NewTypeSpec translated_type { // P4NewTypeTranslation uri: "p4.org/psa/v1/PortId_String_t" sdn_string: {} } } } } type_info { new_types { key: "PortId_Bit32_t" value { // P4NewTypeSpec translated_type { // P4NewTypeTranslation uri: "p4.org/psa/v1/PortId_Bit32_t" sdn_bitwidth: 32 } } } } ``` -------------------------------- ### Invalid Bytestring Encodings for P4Runtime Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Examples of invalid P4Runtime binary string encodings that would result in an OUT_OF_RANGE error. These highlight common mistakes in padding, length, and sign extension. ```text P4 type | P4Runtime binary string `bit<8>` | `\x01\x63` `bit<8>` | `empty string` `bit<16>` | `\x01\x00\x63` `bit<12>` | `\x10\x63` `bit<12>` | `\x01\x00\x63` `bit<12>` | `\x00\x40\x63` `int<8>` | `\x00\x9d` `int<12>` | `\x8d\x1d` `int<16>` | `empty string` ``` -------------------------------- ### P4Info Message: Type Info for Custom Type Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/guidance-for-generating-p4info.md Example of the `type_info` field in a P4Info message describing a custom type. The `original_type` is used when the type definition lacks a `p4runtime_translation` annotation. ```protobuf type_info { new_types { key: "MyCustomType_t" value { original_type { bitstring { bit { bitwidth: 7 } } } } } } ``` -------------------------------- ### PkgInfo Message Definition Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc Defines the PkgInfo message for package-level metadata. It includes fields for name, version, documentation, annotations, and target architecture. ```protobuf // Can be used to manage multiple P4 packages. message PkgInfo { // a definitive name for this configuration, e.g. switch.p4_v1.0 string name = 1; // configuration version, free-format string string version = 2; // brief and detailed descriptions Documentation doc = 3; // Miscellaneous metadata, free-form; a way to extend PkgInfo repeated string annotations = 4; // Optional. If present, the location of `annotations[i]` is given by // `annotation_locations[i]`. repeated SourceLocation annotation_locations = 10; // the target architecture, e.g. "psa" string arch = 5; // organization which produced the configuration, e.g. "p4.org" ``` -------------------------------- ### P4Runtime Clone Session Entry Configuration Source: https://github.com/p4lang/p4runtime/blob/main/docs/v1/P4Runtime-Spec.adoc This Protobuf text format shows how to insert a clone session entry into the Packet Replication Engine (PRE) via P4Runtime. It specifies the session ID, destination replica, class of service, and packet length for cloning. ```protobuf type: INSERT entity { packet_replication_engine_entry { clone_session_entry { session_id: 100 replicas { port: "\xff\xff\xff\xfd" instance: 1 } // to CPU class_of_service: 2 packet_length_bytes: 4096 } } } ```