{"id":19454581,"url":"https://github.com/p4lang/pi","last_synced_at":"2025-05-16T11:03:58.331Z","repository":{"id":37706196,"uuid":"51870280","full_name":"p4lang/PI","owner":"p4lang","description":"An implementation framework for a P4Runtime server","archived":false,"fork":false,"pushed_at":"2025-02-05T20:41:39.000Z","size":3198,"stargazers_count":172,"open_issues_count":24,"forks_count":110,"subscribers_count":59,"default_branch":"main","last_synced_at":"2025-05-16T11:03:56.449Z","etag":null,"topics":["p4","p4runtime"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/p4lang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-16T21:07:15.000Z","updated_at":"2025-05-14T03:11:24.000Z","dependencies_parsed_at":"2022-08-19T10:22:32.840Z","dependency_job_id":"dbf5806b-e59d-4021-b97d-5067f903241c","html_url":"https://github.com/p4lang/PI","commit_stats":{"total_commits":611,"total_committers":42,"mean_commits":"14.547619047619047","dds":0.2029459901800328,"last_synced_commit":"21592d61b314ba0c44a7409a733dbf9e46da6556"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4lang%2FPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4lang%2FPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4lang%2FPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4lang%2FPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p4lang","download_url":"https://codeload.github.com/p4lang/PI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518384,"owners_count":22084374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["p4","p4runtime"],"created_at":"2024-11-10T17:10:17.639Z","updated_at":"2025-05-16T11:03:58.312Z","avatar_url":"https://github.com/p4lang.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PI LIBRARY REPOSITORY\n\n![Build Status](https://github.com/p4lang/PI/workflows/Test/badge.svg?branch=main)\n\n**This repository has submodules; after cloning it you should run `git submodule\n  update --init --recursive`.**\n\n## Dependencies\n\n### Compiler versions\n\nThe following compiler versions are supported:\n\n- gcc / g++: \u003e= 5\n- clang / clang++: \u003e= 3.8\n\nThe following compiler versions are tested in CI:\n\n- gcc / g++: 9.3\n- clang / clang++: 8, 10\n\n### Dependencies based on configure flags\n\nBased on the command-line flags you intend on providing to `configure`, you need\nto install different dependencies.\n\n| Configure flag        | Default (yes / no) | Dependencies | Remarks |\n| --------------------- | --- | --- | --- |\n| `--with-bmv2`         | no  | bmv2 and its deps | Implies `--with-fe-cpp` |\n| `--with-proto`        | no  | Protobuf, gRPC, libboost-thread-dev | - |\n| `--with-fe-cpp`       | no  | - | - |\n| `--with-internal-rpc` | no  | nanomsg | - |\n| `--with-cli`          | no  | readline | - |\n| `--with-sysrepo`      | no  | same as `--with-proto` + sysrepo and its deps| - |\n\n### Additional CI tests dependencies\n\n- libtool binary; we use libtool as part of the build system, libtool binary is\n  required to run some of the generated binaries uner valgrind\n- valgrind, as some tests use it to check for memory errors\n- Boost library, for some of the C++ tests: we currently require\n  `boost/optional.hpp` and `boost/functional/hash.hpp`\n\n### Installing dependencies from package repositories\n\n| Dependency | Ubuntu / Debian | Fedora |\n| ---------- | --- | --- |\n| [readline](https://tiswww.case.edu/php/chet/readline/rltop.html) | libreadline-dev | readline-devel |\n| valgrind | valgrind | valgrind |\n| libtool binary | libtool-bin | libtool |\n| Boost library | libboost-dev libboost-system-dev libboost-thread-dev | boost-devel boost-system boost-thread |\n| [gRPC](https://github.com/grpc/grpc) | Install from source (see below) | grpc-devel grpc-plugins |\n| [Protobuf](https://github.com/google/protobuf) | Install from source (see below) | protobuf-devel |\n\n### Installing other dependencies from source\n\nSome dependencies are not available as packages or the available version\nis not compatible.\n\n- [bmv2](https://github.com/p4lang/behavioral-model) and all its dependencies:\n  follow instructions in the [bmv2\n  README](https://github.com/p4lang/behavioral-model/blob/master/README.md)\n- [nanomsg 1.0.0](https://github.com/nanomsg/nanomsg/releases/tag/1.0.0)\n- [Protobuf v3.18.1](https://github.com/google/protobuf/releases/tag/v3.18.1):\n```\ngit clone --depth=1 -b v3.18.1 https://github.com/google/protobuf.git\ncd protobuf/\n./autogen.sh\n./configure\nmake\n[sudo] make install\n[sudo] ldconfig\n```\n- [gRPC v1.43.2](https://github.com/grpc/grpc/releases/tag/v1.43.2):\n```\ngit clone --depth=1 -b v1.43.2 https://github.com/google/grpc.git\ncd grpc/\ngit submodule update --init --recursive\nmkdir -p \"cmake/build\"\npushd \"cmake/build\"\ncmake \\\n  -DCMAKE_BUILD_TYPE=Release \\\n  -DgRPC_INSTALL=ON \\\n  -DgRPC_BUILD_TESTS=OFF \\\n  -DgRPC_SSL_PROVIDER=package \\\n  ../..\nmake\n[sudo] make install\npopd\n```\n- [sysrepo](https://github.com/sysrepo/sysrepo) and all its dependencies: see\n  instructions in [proto/README.md](proto/README.md)\n\nYou may be able to use different versions of Protobuf / gRPC, or a more recent\nversion of nanomsg. However, the versions above are the ones we use for\ndevelopment and CI testing. When running `configure` with `--with-proto`, the\nscript will verify that Protobuf \u003e= 3.0.0 and gRPC \u003e= 1.3.0 are installed.\n\n## Building p4runtime.proto\n\nTo include `p4runtime.proto` in the build, please run `configure` with\n`--with-proto`.\n\n```\n./autogen.sh\n./configure --with-proto\nmake\nmake check\n[sudo] make install\n```\n\n## Bazel support\n\nWe include **tentative** support for the [Bazel](https://bazel.build/) build\nsystem. This should enable other Bazel projects to easily import this\nrepository. For the great majority of users who wish to build and install PI, we\nrecommend using the autotools-based build system.\n\nWe use [bazelisk](https://github.com/bazelbuild/bazelisk) to install Bazel as\npart of [CI](.github/workflows/bazel-build.yml). bazelisk will install the\nofficial latest Bazel release.\n\nTo build the P4Runtime PI frontend and run the tests:\n```\nbazel build //proto/frontend:pifeproto\nbazel test //proto/tests:pi_proto_tests\n```\n\nTo use PI in another Bazel project, do the following in your `WORKSPACE` file:\n1. Import this project, for example using `git_repository`.\n2. Import dependencies:\n```\nload(\"//bazel:deps.bzl\", \"PI_deps\")\nPI_deps()\n\n# Transitive dependencies\n\nload(\"@com_github_p4lang_p4runtime//:p4runtime_deps.bzl\", \"p4runtime_deps\")\np4runtime_deps()\n\nload(\"@com_google_protobuf//:protobuf_deps.bzl\", \"protobuf_deps\")\nprotobuf_deps()\n\nload(\"@rules_proto//proto:repositories.bzl\", \"rules_proto_dependencies\", \"rules_proto_toolchains\")\nrules_proto_dependencies()\nrules_proto_toolchains()\n\nload(\"@com_google_googleapis//:repository_rules.bzl\", \"switched_rules_by_language\")\nswitched_rules_by_language(\n    name = \"com_google_googleapis_imports\",\n    grpc = True,\n    cc = True,\n    python = True,\n)\n\nload(\"@com_github_grpc_grpc//bazel:grpc_deps.bzl\", \"grpc_deps\")\ngrpc_deps()\nload(\"@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl\", \"grpc_extra_deps\")\ngrpc_extra_deps()\nload(\"@com_github_grpc_grpc//bazel:grpc_python_deps.bzl\", \"grpc_python_deps\")\ngrpc_python_deps()\n\nload(\"@rules_python//python:pip.bzl\", \"pip_import\", \"pip_repositories\")\npip_repositories()\npip_import(\n    name = \"grpc_python_dependencies\",\n    requirements = \"@com_github_grpc_grpc//:requirements.bazel.txt\",\n)\n\nload(\"@grpc_python_dependencies//:requirements.bzl\", \"pip_install\")\npip_install()\n\nload(\"@com_github_nelhage_rules_boost//:boost/boost.bzl\", \"boost_deps\")\nboost_deps()\n```\n\n## PI CLI\n\nFor now the PI CLI supports an experimental version of `table_add` and\n`table_delete`. Because these two functions have been implemented in the bmv2 PI\nimplementation, you can test the PI CLI with the bmv2 `simple_switch`. Assuming\nbmv2 is installed on your system, build the PI and the CLI with `./configure\n--with-bmv2 --with-cli \u0026\u0026 make`. You can then experiment with the following\ncommands:\n\n    simple_switch tests/testdata/simple_router.json  // to start the switch\n    ./CLI/pi_CLI_bmv2 -c tests/testdata/simple_router.json  // to start the CLI\n    PI CLI\u003e assign_device 0 0 -- port=9090  // 0 0 : device id + config id\n    PI CLI\u003e table_add ipv4_lpm 10.0.0.1/24 =\u003e set_nhop 10.0.0.1 1\n    PI CLI\u003e table_dump ipv4_lpm\n    PI CLI\u003e table_delete ipv4_lpm \u003chandle returned by table_add\u003e\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp4lang%2Fpi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp4lang%2Fpi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp4lang%2Fpi/lists"}