Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/135026/?format=api
http://patchwork.dpdk.org/api/patches/135026/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20231211143926.3502839-1-mtahhan@redhat.com/", "project": { "id": 1, "url": "http://patchwork.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20231211143926.3502839-1-mtahhan@redhat.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20231211143926.3502839-1-mtahhan@redhat.com", "date": "2023-12-11T14:39:26", "name": "[v3] net/af_xdp: enable uds-path instead of use_cni", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "e8b5e4b5154d5cd9250410170c261fb39cfec535", "submitter": { "id": 3236, "url": "http://patchwork.dpdk.org/api/people/3236/?format=api", "name": "Maryam Tahhan", "email": "mtahhan@redhat.com" }, "delegate": { "id": 319, "url": "http://patchwork.dpdk.org/api/users/319/?format=api", "username": "fyigit", "first_name": "Ferruh", "last_name": "Yigit", "email": "ferruh.yigit@amd.com" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20231211143926.3502839-1-mtahhan@redhat.com/mbox/", "series": [ { "id": 30509, "url": "http://patchwork.dpdk.org/api/series/30509/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=30509", "date": "2023-12-11T14:39:26", "name": "[v3] net/af_xdp: enable uds-path instead of use_cni", "version": 3, "mbox": "http://patchwork.dpdk.org/series/30509/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/135026/comments/", "check": "warning", "checks": "http://patchwork.dpdk.org/api/patches/135026/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 46AD8433D8;\n\tMon, 11 Dec 2023 15:39:37 +0100 (CET)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id ED3A6402CF;\n\tMon, 11 Dec 2023 15:39:36 +0100 (CET)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by mails.dpdk.org (Postfix) with ESMTP id 029EC40289\n for <dev@dpdk.org>; Mon, 11 Dec 2023 15:39:34 +0100 (CET)", "from mail-qv1-f72.google.com (mail-qv1-f72.google.com\n [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-157-rDUecZFUP_iArpvoRE7uKQ-1; Mon, 11 Dec 2023 09:39:31 -0500", "by mail-qv1-f72.google.com with SMTP id\n 6a1803df08f44-67ab4382912so80162816d6.1\n for <dev@dpdk.org>; Mon, 11 Dec 2023 06:39:31 -0800 (PST)", "from nfvsdn-06.redhat.com (nat-pool-232-132.redhat.com.\n [66.187.232.132]) by smtp.gmail.com with ESMTPSA id\n u14-20020ac8750e000000b00425488c789fsm3240477qtq.86.2023.12.11.06.39.29\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 11 Dec 2023 06:39:29 -0800 (PST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1702305574;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=8NvfO67q7KHSw3ce1lzOTE+t5ZH6xJ0pgdfeH6lxJhQ=;\n b=gD3e/vpgXDqsU+0LiYmLy3QZzAjF/4JllN6z4VsvaZUgjC8E0RMQwYKDTzPF+TyxDSrtp/\n FmChqMJA9cUsvyl17j3v1ajKzWgDV81bNyP1gzsEjVwyYr8zBwUtv5YgIygrqVAXwmHVKp\n SkLsBbPemjPWxS+FTQTvgyXLDbhfjqk=", "X-MC-Unique": "rDUecZFUP_iArpvoRE7uKQ-1", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1702305571; x=1702910371;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-message-state:from:to:cc:subject:date:message-id\n :reply-to;\n bh=8NvfO67q7KHSw3ce1lzOTE+t5ZH6xJ0pgdfeH6lxJhQ=;\n b=S/9VhwaNmE3Y3kjrgaBJvqsB1BdmF1bGgDyz3xbV2gAcxfXM67aqV9wUYQqzfIjpaR\n E73CNMJyDn8UAT8fBTCM+6QcCqa+imu64BVObzL+0aIez1QlfKdRvNszpNgLHwVMEoHv\n cdJG5X1gAE0RDj+hEtP2VveeLybiMplxbXC7SllUyCw1rmKULOFEXUDDR6dXvYerVMVw\n tYZkLFOOzB3TVxjijNfFs+o8bMWU4tRV0aj50t8tWneqU0IhdeW9RJl3NpLCQs2+xUHm\n ZAjwYAX0ccfuMYb8+RPqHQAbYZZsILXBKUux7MF9puYmmQd9ASEWV2Yv+o8CnBu9pqXQ\n yauQ==", "X-Gm-Message-State": "AOJu0YwvtBi2o628m0Yz1Cpvj77okSrHweMusZYIaFqRCJ4Ppu/V0BXw\n K/kC+5Mj3JhNdTlA7ohCd5piABs/VH9xkMoHG7HQJgUJ4aFVOhgYvpwKARc3V05CRlo557tFG+z\n Cods=", "X-Received": [ "by 2002:a05:6214:21a1:b0:67a:9b28:b4cc with SMTP id\n t1-20020a05621421a100b0067a9b28b4ccmr7642256qvc.31.1702305570380;\n Mon, 11 Dec 2023 06:39:30 -0800 (PST)", "by 2002:a05:6214:21a1:b0:67a:9b28:b4cc with SMTP id\n t1-20020a05621421a100b0067a9b28b4ccmr7642234qvc.31.1702305569974;\n Mon, 11 Dec 2023 06:39:29 -0800 (PST)" ], "X-Google-Smtp-Source": "\n AGHT+IEQD1gr3UNm3tddggxSMD+J/w8FK2dOAjZiJhoO0KoC2p+1+9AdpBrAtomMU7Ht4M9q4wBDKw==", "From": "Maryam Tahhan <mtahhan@redhat.com>", "To": "ferruh.yigit@amd.com, stephen@networkplumber.org, lihuisong@huawei.com,\n fengchengwen@huawei.com, liuyonglong@huawei.com,\n shibin.koikkara.reeny@intel.com, ciara.loftus@intel.com", "Cc": "dev@dpdk.org,\n\tMaryam Tahhan <mtahhan@redhat.com>", "Subject": "[v3] net/af_xdp: enable uds-path instead of use_cni", "Date": "Mon, 11 Dec 2023 09:39:26 -0500", "Message-ID": "<20231211143926.3502839-1-mtahhan@redhat.com>", "X-Mailer": "git-send-email 2.41.0", "MIME-Version": "1.0", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "With the original 'use_cni' implementation, (using a\nhardcoded socket rather than a configurable one),\nif a single pod is requesting multiple net devices\nand these devices are from different pools, then\nthe container attempts to mount all the netdev UDSes\nin the pod as /tmp/afxdp.sock. Which means that at best\nonly 1 netdev will handshake correctly with the AF_XDP\nDP. This patch addresses this by making the socket\nparameter configurable using a new vdev param called\n'uds_path' and removing the previous 'use_cni' param.\nTested with the AF_XDP DP CNI PR 81, single and multiple\ninterfaces.\n\nv3:\n* Remove `use_cni` vdev argument as it's no longer needed.\n* Update incorrect CNI references for the AF_XDP DP in the\n documentation.\n* Update the documentation to run a simple example with the\n AF_XDP DP plugin in K8s.\n\nv2:\n* Rename sock_path to uds_path.\n* Update documentation to reflect when CAP_BPF is needed.\n* Fix testpmd arguments in the provided example for Pods.\n* Use AF_XDP API to update the xskmap entry.\n\nSigned-off-by: Maryam Tahhan <mtahhan@redhat.com>\n---\n doc/guides/howto/af_xdp_cni.rst | 334 +++++++++++++++-------------\n drivers/net/af_xdp/rte_eth_af_xdp.c | 76 +++----\n 2 files changed, 216 insertions(+), 194 deletions(-)", "diff": "diff --git a/doc/guides/howto/af_xdp_cni.rst b/doc/guides/howto/af_xdp_cni.rst\nindex a1a6d5b99c..b71fef61c7 100644\n--- a/doc/guides/howto/af_xdp_cni.rst\n+++ b/doc/guides/howto/af_xdp_cni.rst\n@@ -1,71 +1,65 @@\n .. SPDX-License-Identifier: BSD-3-Clause\n Copyright(c) 2023 Intel Corporation.\n \n-Using a CNI with the AF_XDP driver\n-==================================\n+Using the AF_XDP Device Plugin with the AF_XDP driver\n+======================================================\n \n Introduction\n ------------\n \n-CNI, the Container Network Interface, is a technology for configuring\n-container network interfaces\n-and which can be used to setup Kubernetes networking.\n+The `AF_XDP Device Plugin for Kubernetes`_ is a project that provisions\n+and advertises interfaces (that can be used with AF_XDP) to Kubernetes.\n+The project also includes a `CNI`_.\n+\n AF_XDP is a Linux socket Address Family that enables an XDP program\n to redirect packets to a memory buffer in userspace.\n \n-This document explains how to enable the `AF_XDP Plugin for Kubernetes`_ within\n-a DPDK application using the :doc:`../nics/af_xdp` to connect and use these technologies.\n-\n-.. _AF_XDP Plugin for Kubernetes: https://github.com/intel/afxdp-plugins-for-kubernetes\n+This document explains how to use the `AF_XDP Device Plugin for Kubernetes`_ with\n+a DPDK :doc:`../nics/af_xdp` based application running in a Pod.\n \n+.. _AF_XDP Device Plugin for Kubernetes: https://github.com/intel/afxdp-plugins-for-kubernetes\n+.. _CNI: https://github.com/containernetworking/cni\n \n Background\n ----------\n \n-The standard :doc:`../nics/af_xdp` initialization process involves loading an eBPF program\n-onto the kernel netdev to be used by the PMD.\n-This operation requires root or escalated Linux privileges\n-and thus prevents the PMD from working in an unprivileged container.\n-The AF_XDP CNI plugin handles this situation\n-by providing a device plugin that performs the program loading.\n-\n-At a technical level the CNI opens a Unix Domain Socket and listens for a client\n-to make requests over that socket.\n-A DPDK application acting as a client connects and initiates a configuration \"handshake\".\n-The client then receives a file descriptor which points to the XSKMAP\n-associated with the loaded eBPF program.\n-The XSKMAP is a BPF map of AF_XDP sockets (XSK).\n-The client can then proceed with creating an AF_XDP socket\n-and inserting that socket into the XSKMAP pointed to by the descriptor.\n-\n-The EAL vdev argument ``use_cni`` is used to indicate that the user wishes\n-to run the PMD in unprivileged mode and to receive the XSKMAP file descriptor\n-from the CNI.\n-When this flag is set,\n-the ``XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD`` libbpf flag\n-should be used when creating the socket\n-to instruct libbpf not to load the default libbpf program on the netdev.\n-Instead the loading is handled by the CNI.\n+The standard :doc:`../nics/af_xdp` initialization process involves\n+loading an eBPF program onto the kernel netdev to be used by the PMD.\n+This operation requires root or escalated Linux privileges and prevents\n+the PMD from working in an unprivileged container. The AF_XDP Device plugin\n+addresses this situation by providing an entity that manages eBPF program\n+lifecycle for Pod interfaces that wish to use AF_XDP, this in turn allows\n+the pod to be used without privilege escalation.\n+\n+In order for the pod to run without privilege escalation, the AF_XDP DP\n+creates a Unix Domain Socket (UDS) and listens for Pods to make requests\n+for XSKMAP(s) File Descriptors (FDs) for interfaces in their network namespace.\n+In other words, the DPDK application running in the Pod connects to this UDS and\n+initiates a \"handshake\" to retrieve the XSKMAP(s) FD(s). Upon a successful \"handshake\",\n+the DPDK application receives the FD(s) for the XSKMAP(s) associated with the relevant\n+netdevs. The DPDK application can then create the AF_XDP socket(s), and attach\n+the socket(s) to the netdev queue(s) by inserting the socket(s) into the XSKMAP(s).\n+\n+The EAL vdev argument ``uds_path`` is used to indicate that the user\n+wishes to run the AF_XDP PMD in unprivileged mode and to receive the XSKMAP\n+FD from the AF_XDP DP. When this param is used, the\n+``XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD`` libbpf flag is used when creating the\n+AF_XDP socket to instruct libbpf/libxdp not to load the default eBPF redirect\n+program for AF_XDP on the netdev. Instead the lifecycle management of the eBPF\n+program is handled by the AF_XDP DP.\n \n .. note::\n \n- The Unix Domain Socket file path appear in the end user is \"/tmp/afxdp.sock\".\n-\n+ The UDS file path inside the pod appears at \"/tmp/afxdp_dp/<netdev>/afxdp.sock\".\n \n Prerequisites\n -------------\n \n-Docker and container prerequisites:\n-\n-* Set up the device plugin\n- as described in the instructions for `AF_XDP Plugin for Kubernetes`_.\n-\n-* The Docker image should contain the libbpf and libxdp libraries,\n- which are dependencies for AF_XDP,\n- and should include support for the ``ethtool`` command.\n+Device Plugin and DPDK container prerequisites:\n+* Create a DPDK container image.\n \n-* The Pod should have enabled the capabilities ``CAP_NET_RAW`` and ``CAP_BPF``\n- for AF_XDP along with support for hugepages.\n+* Set up the device plugin and prepare the Pod Spec as described in\n+ the instructions for `AF_XDP Device Plugin for Kubernetes`_.\n \n * Increase locked memory limit so containers have enough memory for packet buffers.\n For example:\n@@ -85,115 +79,142 @@ Docker and container prerequisites:\n Example\n -------\n \n-Howto run dpdk-testpmd with CNI plugin:\n+How to run dpdk-testpmd with AF_XDP Device plugin:\n \n-* Clone the CNI plugin\n+* Clone the AF_XDP Device plugin\n \n .. code-block:: console\n \n # git clone https://github.com/intel/afxdp-plugins-for-kubernetes.git\n \n-* Build the CNI plugin\n+* Build the AF_XDP Device plugin and the CNI\n \n .. code-block:: console\n \n # cd afxdp-plugins-for-kubernetes/\n- # make build\n+ # make image\n \n- .. note::\n+* Make sure to modify the image used by the `daemonset.yml`_ file in the deployments directory with\n+ the following configuration:\n \n- CNI plugin has a dependence on the config.json.\n+ .. _daemonset.yml : https://github.com/intel/afxdp-plugins-for-kubernetes/blob/main/deployments/daemonset.yml\n \n- Sample Config.json\n+ .. code-block:: yaml\n \n- .. code-block:: json\n+ image: afxdp-device-plugin:latest\n \n- {\n- \"logLevel\":\"debug\",\n- \"logFile\":\"afxdp-dp-e2e.log\",\n- \"pools\":[\n- {\n- \"name\":\"e2e\",\n- \"mode\":\"primary\",\n- \"timeout\":30,\n- \"ethtoolCmds\" : [\"-L -device- combined 1\"],\n- \"devices\":[\n- {\n- \"name\":\"ens785f0\"\n- }\n- ]\n- }\n- ]\n- }\n+ .. note::\n \n- For further reference please use the `config.json`_\n+ This will select the AF_XDP DP image that was built locally. Detailed configuration\n+ options can be found in the AF_XDP Device Plugin `readme`_ .\n \n- .. _config.json: https://github.com/intel/afxdp-plugins-for-kubernetes/blob/v0.0.2/test/e2e/config.json\n+ .. _readme: https://github.com/intel/afxdp-plugins-for-kubernetes#readme\n \n-* Create the Network Attachment definition\n+* Deploy the AF_XDP Device Plugin and CNI\n \n .. code-block:: console\n \n- # kubectl create -f nad.yaml\n+ # kubectl create -f deployments/daemonset.yml\n+\n+* Create a Network Attachment Definition (NAD)\n+\n+ .. code-block:: console\n+\n+ # kubectl create -f nad.yaml\n \n Sample nad.yml\n \n .. code-block:: yaml\n \n- apiVersion: \"k8s.cni.cncf.io/v1\"\n- kind: NetworkAttachmentDefinition\n- metadata:\n- name: afxdp-e2e-test\n- annotations:\n- k8s.v1.cni.cncf.io/resourceName: afxdp/e2e\n- spec:\n- config: '{\n- \"cniVersion\": \"0.3.0\",\n- \"type\": \"afxdp\",\n- \"mode\": \"cdq\",\n- \"logFile\": \"afxdp-cni-e2e.log\",\n- \"logLevel\": \"debug\",\n- \"ipam\": {\n- \"type\": \"host-local\",\n- \"subnet\": \"192.168.1.0/24\",\n- \"rangeStart\": \"192.168.1.200\",\n- \"rangeEnd\": \"192.168.1.216\",\n- \"routes\": [\n- { \"dst\": \"0.0.0.0/0\" }\n- ],\n- \"gateway\": \"192.168.1.1\"\n- }\n- }'\n-\n- For further reference please use the `nad.yaml`_\n-\n- .. _nad.yaml: https://github.com/intel/afxdp-plugins-for-kubernetes/blob/v0.0.2/test/e2e/nad.yaml\n-\n-* Build the Docker image\n+ apiVersion: \"k8s.cni.cncf.io/v1\"\n+ kind: NetworkAttachmentDefinition\n+ metadata:\n+ name: afxdp-network\n+ annotations:\n+ k8s.v1.cni.cncf.io/resourceName: afxdp/myPool\n+ spec:\n+ config: '{\n+ \"cniVersion\": \"0.3.0\",\n+ \"type\": \"afxdp\",\n+ \"mode\": \"primary\",\n+ \"logFile\": \"afxdp-cni.log\",\n+ \"logLevel\": \"debug\",\n+ \"ethtoolCmds\" : [\"-N -device- rx-flow-hash udp4 fn\",\n+ \"-N -device- flow-type udp4 dst-port 2152 action 22\"\n+ ],\n+ \"ipam\": {\n+ \"type\": \"host-local\",\n+ \"subnet\": \"192.168.1.0/24\",\n+ \"rangeStart\": \"192.168.1.200\",\n+ \"rangeEnd\": \"192.168.1.220\",\n+ \"routes\": [\n+ { \"dst\": \"0.0.0.0/0\" }\n+ ],\n+ \"gateway\": \"192.168.1.1\"\n+ }\n+ }'\n+\n+ For further reference please use the example provided by the AF_XDP DP `nad.yaml`_\n+\n+ .. _nad.yaml: https://github.com/intel/afxdp-plugins-for-kubernetes/blob/main/examples/network-attachment-definition.yaml\n+\n+* Build a DPDK container image (using Docker)\n \n .. code-block:: console\n \n- # docker build -t afxdp-e2e-test -f Dockerfile .\n+ # docker build -t dpdk -f Dockerfile .\n \n- Sample Dockerfile:\n+ Sample Dockerfile (should be placed in top level DPDK directory):\n \n .. code-block:: console\n \n- FROM ubuntu:20.04\n- RUN apt-get update -y\n- RUN apt install build-essential libelf-dev -y\n- RUN apt-get install iproute2 acl -y\n- RUN apt install python3-pyelftools ethtool -y\n- RUN apt install libnuma-dev libjansson-dev libpcap-dev net-tools -y\n- RUN apt-get install clang llvm -y\n- COPY ./libbpf<version>.tar.gz /tmp\n- RUN cd /tmp && tar -xvmf libbpf<version>.tar.gz && cd libbpf/src && make install\n- COPY ./libxdp<version>.tar.gz /tmp\n- RUN cd /tmp && tar -xvmf libxdp<version>.tar.gz && cd libxdp && make install\n+ FROM fedora:38\n+\n+ # Setup container to build DPDK applications\n+ RUN dnf -y upgrade && dnf -y install \\\n+ libbsd-devel \\\n+ numactl-libs \\\n+ libbpf-devel \\\n+ libbpf \\\n+ meson \\\n+ ninja-build \\\n+ libxdp-devel \\\n+ libxdp \\\n+ numactl-devel \\\n+ python3-pyelftools \\\n+ python38 \\\n+ iproute\n+ RUN dnf groupinstall -y 'Development Tools'\n+\n+ # Create DPDK dir and copy over sources\n+ WORKDIR /dpdk\n+ COPY app app\n+ COPY builddir builddir\n+ COPY buildtools buildtools\n+ COPY config config\n+ COPY devtools devtools\n+ COPY drivers drivers\n+ COPY dts dts\n+ COPY examples examples\n+ COPY kernel kernel\n+ COPY lib lib\n+ COPY license license\n+ COPY MAINTAINERS MAINTAINERS\n+ COPY Makefile Makefile\n+ COPY meson.build meson.build\n+ COPY meson_options.txt meson_options.txt\n+ COPY usertools usertools\n+ COPY VERSION VERSION\n+ COPY ABI_VERSION ABI_VERSION\n+ COPY doc doc\n+\n+ # Build DPDK\n+ RUN meson setup build\n+ RUN ninja -C build\n \n .. note::\n \n- All the files that need to COPY-ed should be in the same directory as the Dockerfile\n+ Ensure the Dockerfile is placed in the top level DPDK directory.\n \n * Run the Pod\n \n@@ -205,49 +226,52 @@ Howto run dpdk-testpmd with CNI plugin:\n \n .. code-block:: yaml\n \n- apiVersion: v1\n- kind: Pod\n- metadata:\n- name: afxdp-e2e-test\n- annotations:\n- k8s.v1.cni.cncf.io/networks: afxdp-e2e-test\n- spec:\n- containers:\n- - name: afxdp\n- image: afxdp-e2e-test:latest\n- imagePullPolicy: Never\n- env:\n- - name: LD_LIBRARY_PATH\n- value: /usr/lib64/:/usr/local/lib/\n- command: [\"tail\", \"-f\", \"/dev/null\"]\n- securityContext:\n+ apiVersion: v1\n+ kind: Pod\n+ metadata:\n+ name: dpdk\n+ annotations:\n+ k8s.v1.cni.cncf.io/networks: afxdp-network\n+ spec:\n+ containers:\n+ - name: testpmd\n+ image: dpdk:latest\n+ command: [\"tail\", \"-f\", \"/dev/null\"]\n+ securityContext:\n capabilities:\n- add:\n- - CAP_NET_RAW\n- - CAP_BPF\n- resources:\n- requests:\n- hugepages-2Mi: 2Gi\n- memory: 2Gi\n- afxdp/e2e: '1'\n- limits:\n- hugepages-2Mi: 2Gi\n- memory: 2Gi\n- afxdp/e2e: '1'\n+ add:\n+ - NET_RAW\n+ - IPC_LOCK\n+ resources:\n+ requests:\n+ afxdp/myPool: '1'\n+ limits:\n+ hugepages-1Gi: 2Gi\n+ cpu: 2\n+ memory: 256Mi\n+ afxdp/myPool: '1'\n+ volumeMounts:\n+ - name: hugepages\n+ mountPath: /dev/hugepages\n+ volumes:\n+ - name: hugepages\n+ emptyDir:\n+ medium: HugePages\n \n For further reference please use the `pod.yaml`_\n \n- .. _pod.yaml: https://github.com/intel/afxdp-plugins-for-kubernetes/blob/v0.0.2/test/e2e/pod-1c1d.yaml\n+ .. _pod.yaml: https://github.com/intel/afxdp-plugins-for-kubernetes/blob/main/examples/pod-spec.yaml\n \n-* Run DPDK with a command like the following:\n+.. note::\n \n- .. code-block:: console\n+ For Kernel versions older than 5.19 `CAP_BPF` is also required in\n+ the container capabilities stanza.\n \n- kubectl exec -i <Pod name> --container <containers name> -- \\\n- /<Path>/dpdk-testpmd -l 0,1 --no-pci \\\n- --vdev=net_af_xdp0,use_cni=1,iface=<interface name> \\\n- -- --no-mlockall --in-memory\n+* Run DPDK with a command like the following:\n \n-For further reference please use the `e2e`_ test case in `AF_XDP Plugin for Kubernetes`_\n+ .. code-block:: console\n \n- .. _e2e: https://github.com/intel/afxdp-plugins-for-kubernetes/tree/v0.0.2/test/e2e\n+ kubectl exec -i dpdk --container testpmd -- \\\n+ ./build/app/dpdk-testpmd -l 0-2 --no-pci --main-lcore=2 \\\n+ --vdev net_af_xdp,iface=<interface name>,start_queue=22,queue_count=1,uds_path=/tmp/afxdp_dp/<interface name>/afxdp.sock \\\n+ -- -i --a --nb-cores=2 --rxq=1 --txq=1 --forward-mode=macswap;\ndiff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c\nindex 353c8688ec..c13b8038f8 100644\n--- a/drivers/net/af_xdp/rte_eth_af_xdp.c\n+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c\n@@ -88,7 +88,6 @@ RTE_LOG_REGISTER_DEFAULT(af_xdp_logtype, NOTICE);\n #define UDS_MAX_CMD_LEN\t\t\t64\n #define UDS_MAX_CMD_RESP\t\t128\n #define UDS_XSK_MAP_FD_MSG\t\t\"/xsk_map_fd\"\n-#define UDS_SOCK\t\t\t\"/tmp/afxdp.sock\"\n #define UDS_CONNECT_MSG\t\t\t\"/connect\"\n #define UDS_HOST_OK_MSG\t\t\t\"/host_ok\"\n #define UDS_HOST_NAK_MSG\t\t\"/host_nak\"\n@@ -170,7 +169,7 @@ struct pmd_internals {\n \tchar prog_path[PATH_MAX];\n \tbool custom_prog_configured;\n \tbool force_copy;\n-\tbool use_cni;\n+\tchar uds_path[PATH_MAX];\n \tstruct bpf_map *map;\n \n \tstruct rte_ether_addr eth_addr;\n@@ -190,7 +189,7 @@ struct pmd_process_private {\n #define ETH_AF_XDP_PROG_ARG\t\t\t\"xdp_prog\"\n #define ETH_AF_XDP_BUDGET_ARG\t\t\t\"busy_budget\"\n #define ETH_AF_XDP_FORCE_COPY_ARG\t\t\"force_copy\"\n-#define ETH_AF_XDP_USE_CNI_ARG\t\t\t\"use_cni\"\n+#define ETH_AF_XDP_USE_CNI_UDS_PATH_ARG\t\"uds_path\"\n \n static const char * const valid_arguments[] = {\n \tETH_AF_XDP_IFACE_ARG,\n@@ -200,7 +199,7 @@ static const char * const valid_arguments[] = {\n \tETH_AF_XDP_PROG_ARG,\n \tETH_AF_XDP_BUDGET_ARG,\n \tETH_AF_XDP_FORCE_COPY_ARG,\n-\tETH_AF_XDP_USE_CNI_ARG,\n+\tETH_AF_XDP_USE_CNI_UDS_PATH_ARG,\n \tNULL\n };\n \n@@ -1351,7 +1350,7 @@ configure_preferred_busy_poll(struct pkt_rx_queue *rxq)\n }\n \n static int\n-init_uds_sock(struct sockaddr_un *server)\n+init_uds_sock(struct sockaddr_un *server, const char *uds_path)\n {\n \tint sock;\n \n@@ -1362,7 +1361,7 @@ init_uds_sock(struct sockaddr_un *server)\n \t}\n \n \tserver->sun_family = AF_UNIX;\n-\tstrlcpy(server->sun_path, UDS_SOCK, sizeof(server->sun_path));\n+\tstrlcpy(server->sun_path, uds_path, sizeof(server->sun_path));\n \n \tif (connect(sock, (struct sockaddr *)server, sizeof(struct sockaddr_un)) < 0) {\n \t\tclose(sock);\n@@ -1382,7 +1381,7 @@ struct msg_internal {\n };\n \n static int\n-send_msg(int sock, char *request, int *fd)\n+send_msg(int sock, char *request, int *fd, const char *uds_path)\n {\n \tint snd;\n \tstruct iovec iov;\n@@ -1393,7 +1392,7 @@ send_msg(int sock, char *request, int *fd)\n \n \tmemset(&dst, 0, sizeof(dst));\n \tdst.sun_family = AF_UNIX;\n-\tstrlcpy(dst.sun_path, UDS_SOCK, sizeof(dst.sun_path));\n+\tstrlcpy(dst.sun_path, uds_path, sizeof(dst.sun_path));\n \n \t/* Initialize message header structure */\n \tmemset(&msgh, 0, sizeof(msgh));\n@@ -1471,7 +1470,7 @@ read_msg(int sock, char *response, struct sockaddr_un *s, int *fd)\n \n static int\n make_request_cni(int sock, struct sockaddr_un *server, char *request,\n-\t\t int *req_fd, char *response, int *out_fd)\n+\t\t int *req_fd, char *response, int *out_fd, const char *uds_path)\n {\n \tint rval;\n \n@@ -1483,7 +1482,7 @@ make_request_cni(int sock, struct sockaddr_un *server, char *request,\n \tif (req_fd == NULL)\n \t\trval = write(sock, request, strlen(request));\n \telse\n-\t\trval = send_msg(sock, request, req_fd);\n+\t\trval = send_msg(sock, request, req_fd, uds_path);\n \n \tif (rval < 0) {\n \t\tAF_XDP_LOG(ERR, \"Write error %s\\n\", strerror(errno));\n@@ -1507,7 +1506,7 @@ check_response(char *response, char *exp_resp, long size)\n }\n \n static int\n-get_cni_fd(char *if_name)\n+get_cni_fd(char *if_name, const char *uds_path)\n {\n \tchar request[UDS_MAX_CMD_LEN], response[UDS_MAX_CMD_RESP];\n \tchar hostname[MAX_LONG_OPT_SZ], exp_resp[UDS_MAX_CMD_RESP];\n@@ -1520,14 +1519,14 @@ get_cni_fd(char *if_name)\n \t\treturn -1;\n \n \tmemset(&server, 0, sizeof(server));\n-\tsock = init_uds_sock(&server);\n+\tsock = init_uds_sock(&server, uds_path);\n \tif (sock < 0)\n \t\treturn -1;\n \n \t/* Initiates handshake to CNI send: /connect,hostname */\n \tsnprintf(request, sizeof(request), \"%s,%s\", UDS_CONNECT_MSG, hostname);\n \tmemset(response, 0, sizeof(response));\n-\tif (make_request_cni(sock, &server, request, NULL, response, &out_fd) < 0) {\n+\tif (make_request_cni(sock, &server, request, NULL, response, &out_fd, uds_path) < 0) {\n \t\tAF_XDP_LOG(ERR, \"Error in processing cmd [%s]\\n\", request);\n \t\tgoto err_close;\n \t}\n@@ -1541,7 +1540,7 @@ get_cni_fd(char *if_name)\n \t/* Request for \"/version\" */\n \tstrlcpy(request, UDS_VERSION_MSG, UDS_MAX_CMD_LEN);\n \tmemset(response, 0, sizeof(response));\n-\tif (make_request_cni(sock, &server, request, NULL, response, &out_fd) < 0) {\n+\tif (make_request_cni(sock, &server, request, NULL, response, &out_fd, uds_path) < 0) {\n \t\tAF_XDP_LOG(ERR, \"Error in processing cmd [%s]\\n\", request);\n \t\tgoto err_close;\n \t}\n@@ -1549,7 +1548,7 @@ get_cni_fd(char *if_name)\n \t/* Request for file descriptor for netdev name*/\n \tsnprintf(request, sizeof(request), \"%s,%s\", UDS_XSK_MAP_FD_MSG, if_name);\n \tmemset(response, 0, sizeof(response));\n-\tif (make_request_cni(sock, &server, request, NULL, response, &out_fd) < 0) {\n+\tif (make_request_cni(sock, &server, request, NULL, response, &out_fd, uds_path) < 0) {\n \t\tAF_XDP_LOG(ERR, \"Error in processing cmd [%s]\\n\", request);\n \t\tgoto err_close;\n \t}\n@@ -1571,7 +1570,7 @@ get_cni_fd(char *if_name)\n \t/* Initiate close connection */\n \tstrlcpy(request, UDS_FIN_MSG, UDS_MAX_CMD_LEN);\n \tmemset(response, 0, sizeof(response));\n-\tif (make_request_cni(sock, &server, request, NULL, response, &out_fd) < 0) {\n+\tif (make_request_cni(sock, &server, request, NULL, response, &out_fd, uds_path) < 0) {\n \t\tAF_XDP_LOG(ERR, \"Error in processing cmd [%s]\\n\", request);\n \t\tgoto err_close;\n \t}\n@@ -1640,7 +1639,7 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,\n #endif\n \n \t/* Disable libbpf from loading XDP program */\n-\tif (internals->use_cni)\n+\tif (strnlen(internals->uds_path, PATH_MAX))\n \t\tcfg.libbpf_flags |= XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD;\n \n \tif (strnlen(internals->prog_path, PATH_MAX)) {\n@@ -1694,18 +1693,17 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,\n \t\t}\n \t}\n \n-\tif (internals->use_cni) {\n-\t\tint err, fd, map_fd;\n+\tif (strnlen(internals->uds_path, PATH_MAX)) {\n+\t\tint err, map_fd;\n \n \t\t/* get socket fd from CNI plugin */\n-\t\tmap_fd = get_cni_fd(internals->if_name);\n+\t\tmap_fd = get_cni_fd(internals->if_name, internals->uds_path);\n \t\tif (map_fd < 0) {\n \t\t\tAF_XDP_LOG(ERR, \"Failed to receive CNI plugin fd\\n\");\n \t\t\tgoto out_xsk;\n \t\t}\n-\t\t/* get socket fd */\n-\t\tfd = xsk_socket__fd(rxq->xsk);\n-\t\terr = bpf_map_update_elem(map_fd, &rxq->xsk_queue_idx, &fd, 0);\n+\n+\t\terr = xsk_socket__update_xskmap(rxq->xsk, map_fd);\n \t\tif (err) {\n \t\t\tAF_XDP_LOG(ERR, \"Failed to insert unprivileged xsk in map.\\n\");\n \t\t\tgoto out_xsk;\n@@ -1957,7 +1955,7 @@ parse_name_arg(const char *key __rte_unused,\n \n /** parse xdp prog argument */\n static int\n-parse_prog_arg(const char *key __rte_unused,\n+parse_path_arg(const char *key __rte_unused,\n \t const char *value, void *extra_args)\n {\n \tchar *path = extra_args;\n@@ -2023,7 +2021,7 @@ xdp_get_channels_info(const char *if_name, int *max_queues,\n static int\n parse_parameters(struct rte_kvargs *kvlist, char *if_name, int *start_queue,\n \t\t int *queue_cnt, int *shared_umem, char *prog_path,\n-\t\t int *busy_budget, int *force_copy, int *use_cni)\n+\t\t int *busy_budget, int *force_copy, char *uds_path)\n {\n \tint ret;\n \n@@ -2050,7 +2048,7 @@ parse_parameters(struct rte_kvargs *kvlist, char *if_name, int *start_queue,\n \t\tgoto free_kvlist;\n \n \tret = rte_kvargs_process(kvlist, ETH_AF_XDP_PROG_ARG,\n-\t\t\t\t &parse_prog_arg, prog_path);\n+\t\t\t\t &parse_path_arg, prog_path);\n \tif (ret < 0)\n \t\tgoto free_kvlist;\n \n@@ -2064,8 +2062,8 @@ parse_parameters(struct rte_kvargs *kvlist, char *if_name, int *start_queue,\n \tif (ret < 0)\n \t\tgoto free_kvlist;\n \n-\tret = rte_kvargs_process(kvlist, ETH_AF_XDP_USE_CNI_ARG,\n-\t\t\t\t &parse_integer_arg, use_cni);\n+\tret = rte_kvargs_process(kvlist, ETH_AF_XDP_USE_CNI_UDS_PATH_ARG,\n+\t\t\t\t &parse_path_arg, uds_path);\n \tif (ret < 0)\n \t\tgoto free_kvlist;\n \n@@ -2108,7 +2106,7 @@ static struct rte_eth_dev *\n init_internals(struct rte_vdev_device *dev, const char *if_name,\n \t int start_queue_idx, int queue_cnt, int shared_umem,\n \t const char *prog_path, int busy_budget, int force_copy,\n-\t int use_cni)\n+\t\t const char *uds_path)\n {\n \tconst char *name = rte_vdev_device_name(dev);\n \tconst unsigned int numa_node = dev->device.numa_node;\n@@ -2137,7 +2135,7 @@ init_internals(struct rte_vdev_device *dev, const char *if_name,\n #endif\n \tinternals->shared_umem = shared_umem;\n \tinternals->force_copy = force_copy;\n-\tinternals->use_cni = use_cni;\n+\tstrlcpy(internals->uds_path, uds_path, PATH_MAX);\n \n \tif (xdp_get_channels_info(if_name, &internals->max_queue_cnt,\n \t\t\t\t &internals->combined_queue_cnt)) {\n@@ -2196,7 +2194,7 @@ init_internals(struct rte_vdev_device *dev, const char *if_name,\n \teth_dev->data->dev_link = pmd_link;\n \teth_dev->data->mac_addrs = &internals->eth_addr;\n \teth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;\n-\tif (!internals->use_cni)\n+\tif (!strnlen(internals->uds_path, PATH_MAX))\n \t\teth_dev->dev_ops = &ops;\n \telse\n \t\teth_dev->dev_ops = &ops_cni;\n@@ -2327,7 +2325,7 @@ rte_pmd_af_xdp_probe(struct rte_vdev_device *dev)\n \tchar prog_path[PATH_MAX] = {'\\0'};\n \tint busy_budget = -1, ret;\n \tint force_copy = 0;\n-\tint use_cni = 0;\n+\tchar uds_path[PATH_MAX] = {'\\0'};\n \tstruct rte_eth_dev *eth_dev = NULL;\n \tconst char *name = rte_vdev_device_name(dev);\n \n@@ -2370,20 +2368,20 @@ rte_pmd_af_xdp_probe(struct rte_vdev_device *dev)\n \n \tif (parse_parameters(kvlist, if_name, &xsk_start_queue_idx,\n \t\t\t &xsk_queue_cnt, &shared_umem, prog_path,\n-\t\t\t &busy_budget, &force_copy, &use_cni) < 0) {\n+\t\t\t\t &busy_budget, &force_copy, uds_path) < 0) {\n \t\tAF_XDP_LOG(ERR, \"Invalid kvargs value\\n\");\n \t\treturn -EINVAL;\n \t}\n \n-\tif (use_cni && busy_budget > 0) {\n+\tif (strnlen(uds_path, PATH_MAX) && busy_budget > 0) {\n \t\tAF_XDP_LOG(ERR, \"When '%s' parameter is used, '%s' parameter is not valid\\n\",\n-\t\t\tETH_AF_XDP_USE_CNI_ARG, ETH_AF_XDP_BUDGET_ARG);\n+\t\t\tETH_AF_XDP_USE_CNI_UDS_PATH_ARG, ETH_AF_XDP_BUDGET_ARG);\n \t\treturn -EINVAL;\n \t}\n \n-\tif (use_cni && strnlen(prog_path, PATH_MAX)) {\n+\tif (strnlen(uds_path, PATH_MAX) && strnlen(prog_path, PATH_MAX)) {\n \t\tAF_XDP_LOG(ERR, \"When '%s' parameter is used, '%s' parameter is not valid\\n\",\n-\t\t\tETH_AF_XDP_USE_CNI_ARG, ETH_AF_XDP_PROG_ARG);\n+\t\t\tETH_AF_XDP_USE_CNI_UDS_PATH_ARG, ETH_AF_XDP_PROG_ARG);\n \t\t\treturn -EINVAL;\n \t}\n \n@@ -2410,7 +2408,7 @@ rte_pmd_af_xdp_probe(struct rte_vdev_device *dev)\n \n \teth_dev = init_internals(dev, if_name, xsk_start_queue_idx,\n \t\t\t\t xsk_queue_cnt, shared_umem, prog_path,\n-\t\t\t\t busy_budget, force_copy, use_cni);\n+\t\t\t\t busy_budget, force_copy, uds_path);\n \tif (eth_dev == NULL) {\n \t\tAF_XDP_LOG(ERR, \"Failed to init internals\\n\");\n \t\treturn -1;\n@@ -2471,4 +2469,4 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_xdp,\n \t\t\t \"xdp_prog=<string> \"\n \t\t\t \"busy_budget=<int> \"\n \t\t\t \"force_copy=<int> \"\n-\t\t\t \"use_cni=<int> \");\n+\t\t\t \"uds_path=<string> \");\n", "prefixes": [ "v3" ] }{ "id": 135026, "url": "