• Stars
    star
    165
  • Rank 228,906 (Top 5 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An implementation framework for a P4Runtime server

PI LIBRARY REPOSITORY

Build Status

This repository has submodules; after cloning it you should run git submodule update --init --recursive.

Dependencies

Compiler versions

The following compiler versions are supported:

  • gcc / g++: >= 5
  • clang / clang++: >= 3.8

The following compiler versions are tested in CI:

  • gcc / g++: 9.3
  • clang / clang++: 8, 10

Dependencies based on configure flags

Based on the command-line flags you intend on providing to configure, you need to install different dependencies.

Configure flag Default (yes / no) Dependencies Remarks
--with-bmv2 no bmv2 and its deps Implies --with-fe-cpp
--with-proto no Protobuf, gRPC, libboost-thread-dev -
--with-fe-cpp no - -
--with-internal-rpc no nanomsg -
--with-cli no readline -
--with-sysrepo no same as --with-proto + sysrepo and its deps -

Additional CI tests dependencies

  • libtool binary; we use libtool as part of the build system, libtool binary is required to run some of the generated binaries uner valgrind
  • valgrind, as some tests use it to check for memory errors
  • Boost library, for some of the C++ tests: we currently require boost/optional.hpp and boost/functional/hash.hpp

Installing dependencies from package repositories

Dependency Ubuntu / Debian Fedora
readline libreadline-dev readline-devel
valgrind valgrind valgrind
libtool binary libtool-bin libtool
Boost library libboost-dev libboost-system-dev libboost-thread-dev boost-devel boost-system boost-thread
gRPC Install from source (see below) grpc-devel grpc-plugins
Protobuf Install from source (see below) protobuf-devel

Installing other dependencies from source

Some dependencies are not available as packages or the available version is not compatible.

git clone --depth=1 -b v3.18.1 https://github.com/google/protobuf.git
cd protobuf/
./autogen.sh
./configure
make
[sudo] make install
[sudo] ldconfig
git clone --depth=1 -b v1.43.2 https://github.com/google/grpc.git
cd grpc/
git submodule update --init --recursive
make
[sudo] make install
[sudo] ldconfig

You may be able to use different versions of Protobuf / gRPC, or a more recent version of nanomsg. However, the versions above are the ones we use for development and CI testing. When running configure with --with-proto, the script will verify that Protobuf >= 3.0.0 and gRPC >= 1.3.0 are installed.

Building p4runtime.proto

To include p4runtime.proto in the build, please run configure with --with-proto.

./autogen.sh
./configure --with-proto
make
make check
[sudo] make install

Bazel support

We include tentative support for the Bazel build system. This should enable other Bazel projects to easily import this repository. For the great majority of users who wish to build and install PI, we recommend using the autotools-based build system.

We use bazelisk to install Bazel as part of CI. bazelisk will install the official latest Bazel release.

To build the P4Runtime PI frontend and run the tests:

bazel build //proto/frontend:pifeproto
bazel test //proto/tests:pi_proto_tests

To use PI in another Bazel project, do the following in your WORKSPACE file:

  1. Import this project, for example using git_repository.
  2. Import dependencies:
load("//bazel:deps.bzl", "PI_deps")
PI_deps()

# Transitive dependencies

load("@com_github_p4lang_p4runtime//:p4runtime_deps.bzl", "p4runtime_deps")
p4runtime_deps()

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()

load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
switched_rules_by_language(
    name = "com_google_googleapis_imports",
    grpc = True,
    cc = True,
    python = True,
)

load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
grpc_deps()
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
grpc_extra_deps()
load("@com_github_grpc_grpc//bazel:grpc_python_deps.bzl", "grpc_python_deps")
grpc_python_deps()

load("@rules_python//python:pip.bzl", "pip_import", "pip_repositories")
pip_repositories()
pip_import(
    name = "grpc_python_dependencies",
    requirements = "@com_github_grpc_grpc//:requirements.bazel.txt",
)

load("@grpc_python_dependencies//:requirements.bzl", "pip_install")
pip_install()

load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")
boost_deps()

PI CLI

For now the PI CLI supports an experimental version of table_add and table_delete. Because these two functions have been implemented in the bmv2 PI implementation, you can test the PI CLI with the bmv2 simple_switch. Assuming bmv2 is installed on your system, build the PI and the CLI with ./configure --with-bmv2 --with-cli && make. You can then experiment with the following commands:

simple_switch tests/testdata/simple_router.json  // to start the switch
./CLI/pi_CLI_bmv2 -c tests/testdata/simple_router.json  // to start the CLI
PI CLI> assign_device 0 0 -- port=9090  // 0 0 : device id + config id
PI CLI> table_add ipv4_lpm 10.0.0.1/24 => set_nhop 10.0.0.1 1
PI CLI> table_dump ipv4_lpm
PI CLI> table_delete ipv4_lpm <handle returned by table_add>

Contributing

See CONTRIBUTING.md.

More Repositories

1

tutorials

P4 language tutorials
P4
1,332
star
2

p4c

P4_16 reference compiler
C++
671
star
3

behavioral-model

The reference P4 software switch
C++
536
star
4

p4-spec

TeX
175
star
5

p4factory

Compile P4 and run the P4 behavioral simulator
C
174
star
6

p4app-switchML

Switch ML Application
C++
167
star
7

switch

Consolidated switch repo (API, SAI and Nettlink)
C
152
star
8

p4runtime

Specification documents for the P4Runtime control-plane API
Rust
146
star
9

ptf

Packet Test Framework
Python
144
star
10

p4pi

P4 on Raspberry Pi for Networking Education
JavaScript
123
star
11

p4app

Python
112
star
12

p4-applications

P4 Applications WG repo
P4
107
star
13

p4runtime-shell

An interactive Python shell for P4Runtime
Python
76
star
14

p4-dpdk-target

P4 driver SW for P4 DPDK target.
C++
56
star
15

pna

Portable NIC Architecture
P4
54
star
16

tdi

Table-Driven Interface (TDI) for a P4-programmable backend device.
C++
39
star
17

papers

Repository for papers related to P4
C
38
star
18

ntf

Network Test Framework
Python
37
star
19

education

P4 for Education
36
star
20

scapy-vxlan

A scapy clone, with support for additional packet headers
Python
36
star
21

p4-hlir

Python
32
star
22

p4ofagent

Openflow agent on a P4 dataplane
C
27
star
23

p4c-bm

Generates the JSON configuration for the behavioral-model (bmv2), as well as the C/C++ PD code
Python
24
star
24

p4lang.github.io

Deprecated P4.org website
HTML
23
star
25

p4analyzer

A Language Server Protocol (LSP) compliant analyzer for the P4 language
Rust
19
star
26

p4c-behavioral

[deprecated] P4 compiler for the behavioral model
C
18
star
27

p4app-TCP-INT

C
18
star
28

p4-constraints

Constraints on P4 objects enforced at runtime
C++
14
star
29

p4-build

Infrastructure needed to generate, build and install the PD library for a given P4 program
C++
12
star
30

gsoc

P4.org's Participation in Google Summer of Code
9
star
31

third-party

Third-party dependencies for p4lang software
Dockerfile
8
star
32

project-ideas

Ideas for P4 Projects.
6
star
33

target-utils

C
4
star
34

target-syslibs

C
3
star
35

hackathons

P4
2
star
36

governance

1
star