{"id":19454584,"url":"https://github.com/p4lang/p4-dpdk-target","last_synced_at":"2025-04-09T20:02:17.877Z","repository":{"id":38188985,"uuid":"415878637","full_name":"p4lang/p4-dpdk-target","owner":"p4lang","description":"P4 driver SW for P4 DPDK target.","archived":false,"fork":false,"pushed_at":"2025-01-27T17:12:36.000Z","size":1686,"stargazers_count":59,"open_issues_count":16,"forks_count":20,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-04-09T20:01:39.485Z","etag":null,"topics":["dpdk","p4"],"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","changelog":"CHANGELOG.md","contributing":null,"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":"2021-10-11T10:30:15.000Z","updated_at":"2025-03-20T15:17:21.000Z","dependencies_parsed_at":"2024-06-28T19:44:56.436Z","dependency_job_id":"4d6b5dde-8ab9-4301-a218-35e95744b3c2","html_url":"https://github.com/p4lang/p4-dpdk-target","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4lang%2Fp4-dpdk-target","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4lang%2Fp4-dpdk-target/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4lang%2Fp4-dpdk-target/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4lang%2Fp4-dpdk-target/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p4lang","download_url":"https://codeload.github.com/p4lang/p4-dpdk-target/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103864,"owners_count":21048245,"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":["dpdk","p4"],"created_at":"2024-11-10T17:10:18.631Z","updated_at":"2025-04-09T20:02:17.799Z","avatar_url":"https://github.com/p4lang.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nP4 DPDK Target Components\n=========================\np4-dpdk-target repo contains the P4-DPDK target specific code that supports\nthe target independent Table Driven Interface (TDI).\n\np4-dpdk-target works in conjunction with following repos:\n\n    Table Driven Interface:\n        (https://github.com/p4lang/tdi)\n        TDI (Table Driven Interface) provides the target independent frontend\n        interface while p4-dpdk-target provides the target dependent backend\n        for DPDK SWX pipeline.\n        p4-dpdk-target submodules tdi repo.  p4-dpdk-target isn't currently\n        defined in p4-dpdk-target/include/bf_rt directory. \n\n    DPDK SWX Pipeline:\n        (https://github.com/DPDK/dpdk/blob/main/lib/pipeline)\n        Version: 22.07-rc2\n\n        P4 DPDK SWX pipeline implements the P4 pipeline in a DPDK software switch.\n        The software switch is driven by artifacts generated by the P4 compiler\n        for P4 DPDK SWX pipeline.\n        p4-dpdk-target submodules dpdk repo to build P4 DPDK pipeline.\n        Note about DPDK Patches (p4-dpdk-target/src/lld/dpdk/patch):\n           DPDK patches 007-Fix-pipeline-structs-initialization.patch\n           is a temporary solution and will be removed.\n           The fixes are being worked upon and will be committed soon.\n\n    P4 Compiler DPDK Backend:\n        (https://github.com/p4lang/p4c/tree/main/backends/dpdk)\n        P4C DPDK backend creates the artifact files used by p4-dpdk-target \n        and DPDK SWX pipeline.\n        p4-dpdk-target uses bfrt.json to define the program independent frontend \n        bf_rt interface.\n        context.json is used to map the P4 runtime info to the P4 DPDK target\n        specific info.\n        The P4 DPDK spec file from P4C DPDK, which is used by DPDK SWX pipeline\n        to setup the software pipeline, is also loaded through p4-dpdk-target.\n\n    P4-OVS:\n\t(https://github.com/ipdk-io/ovs)\n        The remote control plane interfaces like P4 Runtime and OpenConfig are\n        supported through P4-OVS.  P4-OVS maps these remote protocol messages \n        and maps them to tdi_rt interface.\n\nCode Organization\n=================\nThe drivers are P4 independent. At the time of device initialization, \nthey take artifacts associated with P4 as inputs.\n\np4-dpdk-target is organized as follows\n\n    include/\n        Header files associated with various driver modules\n        bf_rt:\n            bf_rt defines the interim frontend interface with bfrt.\n        tdi_rt:\n            tdi_rt defines the frontend interface with TDI.\n\n    src/\n        Driver source files. Largely they are categorized into these submodules.\n\n        pipe_mgr:\n            P4 Pipeline Mgmt API (e.g. tables, actions, stats, meters)\n        port_mgr:\n            Port Mgmt API\n        lld:\n            Low Level Driver (e.g. DPDK library)\n        dvm:\n            Device Mgmt (e.g. device/port instantiation, HA sequences)\n        tdi_rt:\n            P4 program independent and object driven implementation with TDI.\n        bf_rt:\n            P4 program independent and object driven implementation.\n        bf_pal:\n            Platform related code to support device and port management.\n        ctx_json:\n            Utility used for parsing cJSON structures in context JSON.\n\n    bf_switchd/\n        Reference implementation of application to exercise the drivers.\n\n    third-party\n    \ttdi:\n               Target independent frontend interface.\n\n    tools/\n        Scripts to help dependencies installation, ports setup and executing.\n\n    dependencies/\n        Python requirements files used by the driver.    \n\n    doc/\n        Files used for doxygen.\n\n\nBuilding and installing\n=======================\nThe building of drivers produces a set of libraries that need to be\nloaded (or linked to) the application.\n\nNote: SDE is the top level directory with this p4-dpdk-target, syslibs and utils repo cloned in next step\n#Create install directory under SDE\n    sudo -s\n    mkdir install\n\n#Set environment variables\nTo set environment variables for SDE, see below :-\n    cd p4-dpdk-target/tools/setup\n    source p4sde_env_setup.sh \u003cpath to SDE directory\u003e\nEnsure SDE, SDE_INSTALL and LD_LIBRARY_PATH environment variables are set correctly\n\n# Install dependent packages\nTo Install the dependencies for p4-driver on the platform Fedora 33, see below:-\nNote:- Make sure that your yum repository proxy and environment proxies are set properly and you have sudo access.\n\n    pip3 install distro (dependency)\n    cd p4-dpdk-target/tools/setup\n    python3 install_dep.py\n\n# Building P4 DPDK target\n    cd $SDE/p4-dpdk-target\n    git submodule update --init --recursive --force\n    ./autogen.sh\n    ./configure --prefix=$SDE_INSTALL  (For both bfrt and TDI build)\n    ./configure --prefix=$SDE_INSTALL --with-generic-flags=yes (For TDI build)\n    make -j\n    make install\n\nArtifacts installed\n===================\nHere're the artifacts that get installed for p4-driver.\n\nBuild artifacts:\n\n    header files for driver API to $SDE_INSTALL/include/\n\n    libdriver.[a,la,so] to $SDE_INSTALL/lib/\n        driver library to manage the device\n    bf_switchd to $SDE_INSTALL/bin\n        reference implementation to exercise driver API\n\nRunning Reference App\n======================\n    bf_switchd is a reference application that can be configured through a debug CLI.\n\n# Running of bf_switchd\n    Need to set PYTHONPATH and PYTHONHOME for bfrt_python/tdi_python to work.\n    export SDE_INSTALL=\u003cpath to install directory\u003e\n    export LD_LIBRARY_PATH=$SDE_INSTALL/lib:$SDE_INSTALL/lib64:$SDE_INSTALL/lib/x86_64-linux-gnu\n    export PYTHONPATH=$SDE_INSTALL/lib/python3.8/:$SDE_INSTALL/lib/python3.8/lib-dynload:$SDE_INSTALL/lib/python3.8/site-packages\n    export PYTHONHOME=$SDE_INSTALL/lib/python3.8\n    cd $SDE_INSTALL/bin\n    ./bf_switchd --install-dir $SDE_INSTALL --conf-file $SDE_INSTALL/share/dpdk/\u003cP4 program name\u003e/\u003cP4 program name\u003e.conf --init-mode=cold --status-port 7777\n\n# Config file used by bf_switchd\n    bf_switchd uses a config file to initialize.  Following are some of the key fields:\n        bfrt-config: Use file generated from the P4C DPDK for P4 pipeline definition.\n        port-config: Optional file to describe initial ports topology.\n        context:     Use file generated from the P4C DPDK to map P4 to P4 DPDK.\n        config:      Use file generated from the P4C DPDK to setup P4 DPDK pipeline.\n    {\n        \"chip_list\": [\n            {\n                \"id\": \"asic-0\",\n                \"chip_family\": \"dpdk\",\n                \"instance\": 0\n            }\n        ],\n        \"instance\": 0,\n        \"p4_devices\": [\n            {\n                \"device-id\": 0,\n\t\t\"eal-args\": \"dummy -n 4 -c 3\",\n                \"mempools\": [\n                  {\n                       \"name\": \"MEMPOOL0\",\n                       \"buffer_size\": 2304,\n                       \"pool_size\": 1024,\n                       \"cache_size\": 256,\n                       \"numa_node\": 0\n                   }\n\t        ],\n                \"p4_programs\": [\n                    {\n                        \"program-name\": \"\u003cP4 program name\u003e\",\n                        \"bfrt-config\": \"share/dpdk/\u003cP4 program name\u003e/tdi.json\",\n                        \"port-config\": \"share/dpdk/\u003cP4 program name\u003e/ports_topology.json\",\n                        \"p4_pipelines\": [\n                            {\n                                \"p4_pipeline_name\": \"pipe\",\n\t\t\t\t\"core_id\": 1,\n\t\t\t\t\"numa_node\": 0,\n                                \"context\": \"share/dpdk/\u003cP4 program name\u003e/pipe/context.json\",\n                                \"config\": \"share/dpdk/\u003cP4 program name\u003e/pipe/\u003cP4 program name\u003e.spec\",\n\t\t\t\t\"pipe_scope\": [\n\t\t\t\t\t0,\n\t\t\t\t        1,\n\t\t\t\t        2,\n\t\t\t\t        3\n\t\t\t\t],\n                                \"path\": \"share/dpdk/\u003cP4 program name\u003e\"\n                            }\n                        ]\n                    }\n                ]\n            }\n        ]\n    }\n\n\n# CLI interface\n    Once bf_switchd starts running, bfshell is available.\n\n    bfshell\u003e tdi_python\n\n    tdi.\u003cP4 program\u003e.enable\n    pipe = tdi.\u003cP4 program\u003e.pipe.ingress\n    from netaddr import IPAddress\n    pipe.\u003cP4 table\u003e.\u003cP4 action\u003e(\u003caction parameters\u003e)\n    eg) pipe.ipv4_lpm.add_with_send(dst_addr=IPAddress('192.168.2.0'),dst_addr_p_length=24, port=1)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp4lang%2Fp4-dpdk-target","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp4lang%2Fp4-dpdk-target","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp4lang%2Fp4-dpdk-target/lists"}