get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/95953/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 95953,
    "url": "http://patchwork.dpdk.org/api/patches/95953/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20210716082314.33865-4-heinrich.kuhn@netronome.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": "<20210716082314.33865-4-heinrich.kuhn@netronome.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210716082314.33865-4-heinrich.kuhn@netronome.com",
    "date": "2021-07-16T08:23:10",
    "name": "[3/7] net/nfp: move CPP bridge to a separate file",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "fede6ca736ed1eb64f6cd991886d1f73366ce8a6",
    "submitter": {
        "id": 1523,
        "url": "http://patchwork.dpdk.org/api/people/1523/?format=api",
        "name": "Heinrich Kuhn",
        "email": "heinrich.kuhn@netronome.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20210716082314.33865-4-heinrich.kuhn@netronome.com/mbox/",
    "series": [
        {
            "id": 17855,
            "url": "http://patchwork.dpdk.org/api/series/17855/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=17855",
            "date": "2021-07-16T08:23:07",
            "name": "Refactor the NFP PMD",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/17855/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/95953/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/95953/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 0FA06A0C50;\n\tFri, 16 Jul 2021 10:24:11 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 8AED74134E;\n\tFri, 16 Jul 2021 10:24:01 +0200 (CEST)",
            "from mail-ej1-f50.google.com (mail-ej1-f50.google.com\n [209.85.218.50]) by mails.dpdk.org (Postfix) with ESMTP id CA9B341343\n for <dev@dpdk.org>; Fri, 16 Jul 2021 10:24:00 +0200 (CEST)",
            "by mail-ej1-f50.google.com with SMTP id hr1so13972936ejc.1\n for <dev@dpdk.org>; Fri, 16 Jul 2021 01:24:00 -0700 (PDT)",
            "from localhost.localdomain ([155.93.216.150])\n by smtp.gmail.com with ESMTPSA id q9sm2636777ejf.70.2021.07.16.01.23.58\n (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);\n Fri, 16 Jul 2021 01:23:59 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=netronome-com.20150623.gappssmtp.com; s=20150623;\n h=from:to:cc:subject:date:message-id:in-reply-to:references\n :mime-version:content-transfer-encoding;\n bh=dcZhyuO0NqhPvk+ocPkKVwF+BzQOcWVZqA+Om/Ve1NY=;\n b=LvyVA1MP4BUBm6RjLTuMuffm+GpPYNU13LazMVJ/8Y5U6jrxMsmt+cIEyGVt7bCsJJ\n UBPJV+L/UA4BO7Ju0CesYra9MYJOS0A6yaTXt+uIKSyYaW8JxmKWmw0w7zKJ0AQ+hsfZ\n O+iUjUXikFCwghH90nQ79qQhK8m33xjKdgFshE5/HY0a4Ss+roUzuofEM4X173jMu4mh\n I5PiNuJGZYrFFdhMoAS0/gE70/d+FEENsWMffLzJ3cWXQTeMuLI1K3QM4vno+oaQOKG0\n 8bOSEW/GEGgm9UJi3PRqnwYIIDfojnEGDww0WaGhVB8gyEuhyyPE6aa3quCh9+3J04Xg\n lMgw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20161025;\n h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n :references:mime-version:content-transfer-encoding;\n bh=dcZhyuO0NqhPvk+ocPkKVwF+BzQOcWVZqA+Om/Ve1NY=;\n b=jS36ETsCXYCuXSmN6jENQa0PXAiN7FQEWjTXRTq5OQv7qwTxeSq2Kto4/QWC4LQ5Sg\n rbpcrIHCE3MzLuDssC8TLulIrvaaq+Tw8oHZcAx8zfxGkIFWdk13MdAICfukYKu+9CYm\n kDg+PeccXs/CeDMOd9AUkEeortwIUQmSTDDoMylyIUDi8DQjqb3xFEcUzaSR+R3irHvs\n t3yMvF4aBuhw+5gIDgANJo8wSNtmGxI7YLt0bOs3mRrr6WlL6IVXSHRxkutTqepsuB12\n 1WyYFBefD0GCZYdnEO54uJQWQQWw7H3qzH2uH6AdBs+ArFwdVCOQgToOMw3GakRpVQwT\n YNdg==",
        "X-Gm-Message-State": "AOAM533zlznCRfwZ1sH2yKvQsW+/hga951wMBt8Prb84pB/1K9y038rp\n NIjxBInI34qyS4Q9tsi3cF0svRQYlptHIrHPmZI67J4dGiAaPzvGKOTFh2T729VjOovUAQjIYMw\n Ul59xltbfB690BGKeL8mCozfljxsxfmsqqT473oVgp6XDWDY26TyIYVN5fL/1rkMW",
        "X-Google-Smtp-Source": "\n ABdhPJzcmpw47SA8Q0htbfLGHjjXVDB7Z9dg4Z5QxFOGB9TQsSZi4fgOXIfAsdHOFfyAd6aTy65NGw==",
        "X-Received": "by 2002:a17:906:288d:: with SMTP id\n o13mr10339133ejd.120.1626423840146;\n Fri, 16 Jul 2021 01:24:00 -0700 (PDT)",
        "From": "Heinrich Kuhn <heinrich.kuhn@netronome.com>",
        "To": "dev@dpdk.org",
        "Cc": "heinrich.kuhn@corigine.com,\n\tHeinrich Kuhn <heinrich.kuhn@netronome.com>",
        "Date": "Fri, 16 Jul 2021 10:23:10 +0200",
        "Message-Id": "<20210716082314.33865-4-heinrich.kuhn@netronome.com>",
        "X-Mailer": "git-send-email 2.30.1 (Apple Git-130)",
        "In-Reply-To": "<20210716082314.33865-1-heinrich.kuhn@netronome.com>",
        "References": "<20210716082314.33865-1-heinrich.kuhn@netronome.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH 3/7] net/nfp: move CPP bridge to a separate file",
        "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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This commit moves the CPP bridge logic to a separate file. A new\ncorresponding header file is also created.\n\nSigned-off-by: Heinrich Kuhn <heinrich.kuhn@netronome.com>\n---\n drivers/net/nfp/meson.build      |   1 +\n drivers/net/nfp/nfp_cpp_bridge.c | 392 +++++++++++++++++++++++++++++++\n drivers/net/nfp/nfp_cpp_bridge.h |  36 +++\n drivers/net/nfp/nfp_net.c        | 367 +----------------------------\n 4 files changed, 430 insertions(+), 366 deletions(-)\n create mode 100644 drivers/net/nfp/nfp_cpp_bridge.c\n create mode 100644 drivers/net/nfp/nfp_cpp_bridge.h",
    "diff": "diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build\nindex 1b289e2354..b46ac2d40f 100644\n--- a/drivers/net/nfp/meson.build\n+++ b/drivers/net/nfp/meson.build\n@@ -20,4 +20,5 @@ sources = files(\n         'nfpcore/nfp_hwinfo.c',\n         'nfp_net.c',\n         'nfp_rxtx.c',\n+        'nfp_cpp_bridge.c',\n )\ndiff --git a/drivers/net/nfp/nfp_cpp_bridge.c b/drivers/net/nfp/nfp_cpp_bridge.c\nnew file mode 100644\nindex 0000000000..d916793338\n--- /dev/null\n+++ b/drivers/net/nfp/nfp_cpp_bridge.c\n@@ -0,0 +1,392 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2014-2021 Netronome Systems, Inc.\n+ * All rights reserved.\n+ *\n+ * Small portions derived from code Copyright(c) 2010-2015 Intel Corporation.\n+ */\n+\n+/*\n+ * vim:shiftwidth=8:noexpandtab\n+ *\n+ * @file dpdk/pmd/nfp_cpp_bridge.c\n+ *\n+ * Netronome vNIC DPDK Poll-Mode Driver: CPP Bridge\n+ */\n+\n+#include <rte_service_component.h>\n+\n+#include \"nfpcore/nfp_cpp.h\"\n+#include \"nfpcore/nfp_mip.h\"\n+#include \"nfpcore/nfp_nsp.h\"\n+\n+#include \"nfp_net_logs.h\"\n+#include \"nfp_cpp_bridge.h\"\n+\n+#include <sys/ioctl.h>\n+\n+/* Prototypes */\n+static int nfp_cpp_bridge_serve_write(int sockfd, struct nfp_cpp *cpp);\n+static int nfp_cpp_bridge_serve_read(int sockfd, struct nfp_cpp *cpp);\n+static int nfp_cpp_bridge_serve_ioctl(int sockfd, struct nfp_cpp *cpp);\n+\n+void nfp_register_cpp_service(struct nfp_cpp *cpp)\n+{\n+\tuint32_t *cpp_service_id = NULL;\n+\tstruct rte_service_spec service;\n+\n+\tmemset(&service, 0, sizeof(struct rte_service_spec));\n+\tsnprintf(service.name, sizeof(service.name), \"nfp_cpp_service\");\n+\tservice.callback = nfp_cpp_bridge_service_func;\n+\tservice.callback_userdata = (void *)cpp;\n+\n+\tif (rte_service_component_register(&service,\n+\t\t\t\t\t   cpp_service_id))\n+\t\tRTE_LOG(WARNING, PMD, \"NFP CPP bridge service register() failed\");\n+\telse\n+\t\tRTE_LOG(DEBUG, PMD, \"NFP CPP bridge service registered\");\n+}\n+\n+/*\n+ * Serving a write request to NFP from host programs. The request\n+ * sends the write size and the CPP target. The bridge makes use\n+ * of CPP interface handler configured by the PMD setup.\n+ */\n+static int\n+nfp_cpp_bridge_serve_write(int sockfd, struct nfp_cpp *cpp)\n+{\n+\tstruct nfp_cpp_area *area;\n+\toff_t offset, nfp_offset;\n+\tuint32_t cpp_id, pos, len;\n+\tuint32_t tmpbuf[16];\n+\tsize_t count, curlen, totlen = 0;\n+\tint err = 0;\n+\n+\tPMD_CPP_LOG(DEBUG, \"%s: offset size %zu, count_size: %zu\\n\", __func__,\n+\t\tsizeof(off_t), sizeof(size_t));\n+\n+\t/* Reading the count param */\n+\terr = recv(sockfd, &count, sizeof(off_t), 0);\n+\tif (err != sizeof(off_t))\n+\t\treturn -EINVAL;\n+\n+\tcurlen = count;\n+\n+\t/* Reading the offset param */\n+\terr = recv(sockfd, &offset, sizeof(off_t), 0);\n+\tif (err != sizeof(off_t))\n+\t\treturn -EINVAL;\n+\n+\t/* Obtain target's CPP ID and offset in target */\n+\tcpp_id = (offset >> 40) << 8;\n+\tnfp_offset = offset & ((1ull << 40) - 1);\n+\n+\tPMD_CPP_LOG(DEBUG, \"%s: count %zu and offset %jd\\n\", __func__, count,\n+\t\toffset);\n+\tPMD_CPP_LOG(DEBUG, \"%s: cpp_id %08x and nfp_offset %jd\\n\", __func__,\n+\t\tcpp_id, nfp_offset);\n+\n+\t/* Adjust length if not aligned */\n+\tif (((nfp_offset + (off_t)count - 1) & ~(NFP_CPP_MEMIO_BOUNDARY - 1)) !=\n+\t    (nfp_offset & ~(NFP_CPP_MEMIO_BOUNDARY - 1))) {\n+\t\tcurlen = NFP_CPP_MEMIO_BOUNDARY -\n+\t\t\t(nfp_offset & (NFP_CPP_MEMIO_BOUNDARY - 1));\n+\t}\n+\n+\twhile (count > 0) {\n+\t\t/* configure a CPP PCIe2CPP BAR for mapping the CPP target */\n+\t\tarea = nfp_cpp_area_alloc_with_name(cpp, cpp_id, \"nfp.cdev\",\n+\t\t\t\t\t\t    nfp_offset, curlen);\n+\t\tif (!area) {\n+\t\t\tRTE_LOG(ERR, PMD, \"%s: area alloc fail\\n\", __func__);\n+\t\t\treturn -EIO;\n+\t\t}\n+\n+\t\t/* mapping the target */\n+\t\terr = nfp_cpp_area_acquire(area);\n+\t\tif (err < 0) {\n+\t\t\tRTE_LOG(ERR, PMD, \"area acquire failed\\n\");\n+\t\t\tnfp_cpp_area_free(area);\n+\t\t\treturn -EIO;\n+\t\t}\n+\n+\t\tfor (pos = 0; pos < curlen; pos += len) {\n+\t\t\tlen = curlen - pos;\n+\t\t\tif (len > sizeof(tmpbuf))\n+\t\t\t\tlen = sizeof(tmpbuf);\n+\n+\t\t\tPMD_CPP_LOG(DEBUG, \"%s: Receive %u of %zu\\n\", __func__,\n+\t\t\t\t\t   len, count);\n+\t\t\terr = recv(sockfd, tmpbuf, len, MSG_WAITALL);\n+\t\t\tif (err != (int)len) {\n+\t\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\t\"%s: error when receiving, %d of %zu\\n\",\n+\t\t\t\t\t__func__, err, count);\n+\t\t\t\tnfp_cpp_area_release(area);\n+\t\t\t\tnfp_cpp_area_free(area);\n+\t\t\t\treturn -EIO;\n+\t\t\t}\n+\t\t\terr = nfp_cpp_area_write(area, pos, tmpbuf, len);\n+\t\t\tif (err < 0) {\n+\t\t\t\tRTE_LOG(ERR, PMD, \"nfp_cpp_area_write error\\n\");\n+\t\t\t\tnfp_cpp_area_release(area);\n+\t\t\t\tnfp_cpp_area_free(area);\n+\t\t\t\treturn -EIO;\n+\t\t\t}\n+\t\t}\n+\n+\t\tnfp_offset += pos;\n+\t\ttotlen += pos;\n+\t\tnfp_cpp_area_release(area);\n+\t\tnfp_cpp_area_free(area);\n+\n+\t\tcount -= pos;\n+\t\tcurlen = (count > NFP_CPP_MEMIO_BOUNDARY) ?\n+\t\t\t NFP_CPP_MEMIO_BOUNDARY : count;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * Serving a read request to NFP from host programs. The request\n+ * sends the read size and the CPP target. The bridge makes use\n+ * of CPP interface handler configured by the PMD setup. The read\n+ * data is sent to the requester using the same socket.\n+ */\n+static int\n+nfp_cpp_bridge_serve_read(int sockfd, struct nfp_cpp *cpp)\n+{\n+\tstruct nfp_cpp_area *area;\n+\toff_t offset, nfp_offset;\n+\tuint32_t cpp_id, pos, len;\n+\tuint32_t tmpbuf[16];\n+\tsize_t count, curlen, totlen = 0;\n+\tint err = 0;\n+\n+\tPMD_CPP_LOG(DEBUG, \"%s: offset size %zu, count_size: %zu\\n\", __func__,\n+\t\tsizeof(off_t), sizeof(size_t));\n+\n+\t/* Reading the count param */\n+\terr = recv(sockfd, &count, sizeof(off_t), 0);\n+\tif (err != sizeof(off_t))\n+\t\treturn -EINVAL;\n+\n+\tcurlen = count;\n+\n+\t/* Reading the offset param */\n+\terr = recv(sockfd, &offset, sizeof(off_t), 0);\n+\tif (err != sizeof(off_t))\n+\t\treturn -EINVAL;\n+\n+\t/* Obtain target's CPP ID and offset in target */\n+\tcpp_id = (offset >> 40) << 8;\n+\tnfp_offset = offset & ((1ull << 40) - 1);\n+\n+\tPMD_CPP_LOG(DEBUG, \"%s: count %zu and offset %jd\\n\", __func__, count,\n+\t\t\t   offset);\n+\tPMD_CPP_LOG(DEBUG, \"%s: cpp_id %08x and nfp_offset %jd\\n\", __func__,\n+\t\t\t   cpp_id, nfp_offset);\n+\n+\t/* Adjust length if not aligned */\n+\tif (((nfp_offset + (off_t)count - 1) & ~(NFP_CPP_MEMIO_BOUNDARY - 1)) !=\n+\t    (nfp_offset & ~(NFP_CPP_MEMIO_BOUNDARY - 1))) {\n+\t\tcurlen = NFP_CPP_MEMIO_BOUNDARY -\n+\t\t\t(nfp_offset & (NFP_CPP_MEMIO_BOUNDARY - 1));\n+\t}\n+\n+\twhile (count > 0) {\n+\t\tarea = nfp_cpp_area_alloc_with_name(cpp, cpp_id, \"nfp.cdev\",\n+\t\t\t\t\t\t    nfp_offset, curlen);\n+\t\tif (!area) {\n+\t\t\tRTE_LOG(ERR, PMD, \"%s: area alloc failed\\n\", __func__);\n+\t\t\treturn -EIO;\n+\t\t}\n+\n+\t\terr = nfp_cpp_area_acquire(area);\n+\t\tif (err < 0) {\n+\t\t\tRTE_LOG(ERR, PMD, \"area acquire failed\\n\");\n+\t\t\tnfp_cpp_area_free(area);\n+\t\t\treturn -EIO;\n+\t\t}\n+\n+\t\tfor (pos = 0; pos < curlen; pos += len) {\n+\t\t\tlen = curlen - pos;\n+\t\t\tif (len > sizeof(tmpbuf))\n+\t\t\t\tlen = sizeof(tmpbuf);\n+\n+\t\t\terr = nfp_cpp_area_read(area, pos, tmpbuf, len);\n+\t\t\tif (err < 0) {\n+\t\t\t\tRTE_LOG(ERR, PMD, \"nfp_cpp_area_read error\\n\");\n+\t\t\t\tnfp_cpp_area_release(area);\n+\t\t\t\tnfp_cpp_area_free(area);\n+\t\t\t\treturn -EIO;\n+\t\t\t}\n+\t\t\tPMD_CPP_LOG(DEBUG, \"%s: sending %u of %zu\\n\", __func__,\n+\t\t\t\t\t   len, count);\n+\n+\t\t\terr = send(sockfd, tmpbuf, len, 0);\n+\t\t\tif (err != (int)len) {\n+\t\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\t\"%s: error when sending: %d of %zu\\n\",\n+\t\t\t\t\t__func__, err, count);\n+\t\t\t\tnfp_cpp_area_release(area);\n+\t\t\t\tnfp_cpp_area_free(area);\n+\t\t\t\treturn -EIO;\n+\t\t\t}\n+\t\t}\n+\n+\t\tnfp_offset += pos;\n+\t\ttotlen += pos;\n+\t\tnfp_cpp_area_release(area);\n+\t\tnfp_cpp_area_free(area);\n+\n+\t\tcount -= pos;\n+\t\tcurlen = (count > NFP_CPP_MEMIO_BOUNDARY) ?\n+\t\t\tNFP_CPP_MEMIO_BOUNDARY : count;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+ * Serving a ioctl command from host NFP tools. This usually goes to\n+ * a kernel driver char driver but it is not available when the PF is\n+ * bound to the PMD. Currently just one ioctl command is served and it\n+ * does not require any CPP access at all.\n+ */\n+static int\n+nfp_cpp_bridge_serve_ioctl(int sockfd, struct nfp_cpp *cpp)\n+{\n+\tuint32_t cmd, ident_size, tmp;\n+\tint err;\n+\n+\t/* Reading now the IOCTL command */\n+\terr = recv(sockfd, &cmd, 4, 0);\n+\tif (err != 4) {\n+\t\tRTE_LOG(ERR, PMD, \"%s: read error from socket\\n\", __func__);\n+\t\treturn -EIO;\n+\t}\n+\n+\t/* Only supporting NFP_IOCTL_CPP_IDENTIFICATION */\n+\tif (cmd != NFP_IOCTL_CPP_IDENTIFICATION) {\n+\t\tRTE_LOG(ERR, PMD, \"%s: unknown cmd %d\\n\", __func__, cmd);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\terr = recv(sockfd, &ident_size, 4, 0);\n+\tif (err != 4) {\n+\t\tRTE_LOG(ERR, PMD, \"%s: read error from socket\\n\", __func__);\n+\t\treturn -EIO;\n+\t}\n+\n+\ttmp = nfp_cpp_model(cpp);\n+\n+\tPMD_CPP_LOG(DEBUG, \"%s: sending NFP model %08x\\n\", __func__, tmp);\n+\n+\terr = send(sockfd, &tmp, 4, 0);\n+\tif (err != 4) {\n+\t\tRTE_LOG(ERR, PMD, \"%s: error writing to socket\\n\", __func__);\n+\t\treturn -EIO;\n+\t}\n+\n+\ttmp = cpp->interface;\n+\n+\tPMD_CPP_LOG(DEBUG, \"%s: sending NFP interface %08x\\n\", __func__, tmp);\n+\n+\terr = send(sockfd, &tmp, 4, 0);\n+\tif (err != 4) {\n+\t\tRTE_LOG(ERR, PMD, \"%s: error writing to socket\\n\", __func__);\n+\t\treturn -EIO;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * This is the code to be executed by a service core. The CPP bridge interface\n+ * is based on a unix socket and requests usually received by a kernel char\n+ * driver, read, write and ioctl, are handled by the CPP bridge. NFP host tools\n+ * can be executed with a wrapper library and LD_LIBRARY being completely\n+ * unaware of the CPP bridge performing the NFP kernel char driver for CPP\n+ * accesses.\n+ */\n+int32_t\n+nfp_cpp_bridge_service_func(void *args)\n+{\n+\tstruct sockaddr address;\n+\tstruct nfp_cpp *cpp = args;\n+\tint sockfd, datafd, op, ret;\n+\n+\tunlink(\"/tmp/nfp_cpp\");\n+\tsockfd = socket(AF_UNIX, SOCK_STREAM, 0);\n+\tif (sockfd < 0) {\n+\t\tRTE_LOG(ERR, PMD, \"%s: socket creation error. Service failed\\n\",\n+\t\t\t__func__);\n+\t\treturn -EIO;\n+\t}\n+\n+\tmemset(&address, 0, sizeof(struct sockaddr));\n+\n+\taddress.sa_family = AF_UNIX;\n+\tstrcpy(address.sa_data, \"/tmp/nfp_cpp\");\n+\n+\tret = bind(sockfd, (const struct sockaddr *)&address,\n+\t\t   sizeof(struct sockaddr));\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, PMD, \"%s: bind error (%d). Service failed\\n\",\n+\t\t\t\t  __func__, errno);\n+\t\tclose(sockfd);\n+\t\treturn ret;\n+\t}\n+\n+\tret = listen(sockfd, 20);\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, PMD, \"%s: listen error(%d). Service failed\\n\",\n+\t\t\t\t  __func__, errno);\n+\t\tclose(sockfd);\n+\t\treturn ret;\n+\t}\n+\n+\tfor (;;) {\n+\t\tdatafd = accept(sockfd, NULL, NULL);\n+\t\tif (datafd < 0) {\n+\t\t\tRTE_LOG(ERR, PMD, \"%s: accept call error (%d)\\n\",\n+\t\t\t\t\t  __func__, errno);\n+\t\t\tRTE_LOG(ERR, PMD, \"%s: service failed\\n\", __func__);\n+\t\t\tclose(sockfd);\n+\t\t\treturn -EIO;\n+\t\t}\n+\n+\t\twhile (1) {\n+\t\t\tret = recv(datafd, &op, 4, 0);\n+\t\t\tif (ret <= 0) {\n+\t\t\t\tPMD_CPP_LOG(DEBUG, \"%s: socket close\\n\",\n+\t\t\t\t\t\t   __func__);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\tPMD_CPP_LOG(DEBUG, \"%s: getting op %u\\n\", __func__, op);\n+\n+\t\t\tif (op == NFP_BRIDGE_OP_READ)\n+\t\t\t\tnfp_cpp_bridge_serve_read(datafd, cpp);\n+\n+\t\t\tif (op == NFP_BRIDGE_OP_WRITE)\n+\t\t\t\tnfp_cpp_bridge_serve_write(datafd, cpp);\n+\n+\t\t\tif (op == NFP_BRIDGE_OP_IOCTL)\n+\t\t\t\tnfp_cpp_bridge_serve_ioctl(datafd, cpp);\n+\n+\t\t\tif (op == 0)\n+\t\t\t\tbreak;\n+\t\t}\n+\t\tclose(datafd);\n+\t}\n+\tclose(sockfd);\n+\n+\treturn 0;\n+}\n+/*\n+ * Local variables:\n+ * c-file-style: \"Linux\"\n+ * indent-tabs-mode: t\n+ * End:\n+ */\ndiff --git a/drivers/net/nfp/nfp_cpp_bridge.h b/drivers/net/nfp/nfp_cpp_bridge.h\nnew file mode 100644\nindex 0000000000..aea5fdc784\n--- /dev/null\n+++ b/drivers/net/nfp/nfp_cpp_bridge.h\n@@ -0,0 +1,36 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright (c) 2014-2021 Netronome Systems, Inc.\n+ * All rights reserved.\n+ *\n+ * Small portions derived from code Copyright(c) 2010-2015 Intel Corporation.\n+ */\n+\n+/*\n+ * vim:shiftwidth=8:noexpandtab\n+ *\n+ * @file dpdk/pmd/nfp_cpp_bridge.h\n+ *\n+ * Netronome vNIC DPDK Poll-Mode Driver: CPP Bridge header file\n+ */\n+\n+#ifndef _NFP_CPP_BRIDGE_H_\n+#define _NFP_CPP_BRIDGE_H_\n+\n+#define NFP_CPP_MEMIO_BOUNDARY\t(1 << 20)\n+#define NFP_BRIDGE_OP_READ\t20\n+#define NFP_BRIDGE_OP_WRITE\t30\n+#define NFP_BRIDGE_OP_IOCTL\t40\n+\n+#define NFP_IOCTL 'n'\n+#define NFP_IOCTL_CPP_IDENTIFICATION _IOW(NFP_IOCTL, 0x8f, uint32_t)\n+\n+void nfp_register_cpp_service(struct nfp_cpp *cpp);\n+int32_t nfp_cpp_bridge_service_func(void *args);\n+\n+#endif /* _NFP_CPP_BRIDGE_H_ */\n+/*\n+ * Local variables:\n+ * c-file-style: \"Linux\"\n+ * indent-tabs-mode: t\n+ * End:\n+ */\ndiff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c\nindex 5bfc23ba04..d79c70c5b7 100644\n--- a/drivers/net/nfp/nfp_net.c\n+++ b/drivers/net/nfp/nfp_net.c\n@@ -41,6 +41,7 @@\n #include \"nfp_rxtx.h\"\n #include \"nfp_net_logs.h\"\n #include \"nfp_net_ctrl.h\"\n+#include \"nfp_cpp_bridge.h\"\n \n #include <sys/types.h>\n #include <sys/socket.h>\n@@ -81,8 +82,6 @@ static int nfp_net_rss_hash_write(struct rte_eth_dev *dev,\n \t\t\tstruct rte_eth_rss_conf *rss_conf);\n static int nfp_set_mac_addr(struct rte_eth_dev *dev,\n \t\t\t     struct rte_ether_addr *mac_addr);\n-static int32_t nfp_cpp_bridge_service_func(void *args);\n-static void nfp_register_cpp_service(struct nfp_cpp *cpp);\n static int nfp_fw_setup(struct rte_pci_device *dev,\n \t\t\tstruct nfp_cpp *cpp,\n \t\t\tstruct nfp_eth_table *nfp_eth_table,\n@@ -1926,353 +1925,6 @@ nfp_net_init(struct rte_eth_dev *eth_dev)\n \treturn err;\n }\n \n-#define NFP_CPP_MEMIO_BOUNDARY\t\t(1 << 20)\n-\n-/*\n- * Serving a write request to NFP from host programs. The request\n- * sends the write size and the CPP target. The bridge makes use\n- * of CPP interface handler configured by the PMD setup.\n- */\n-static int\n-nfp_cpp_bridge_serve_write(int sockfd, struct nfp_cpp *cpp)\n-{\n-\tstruct nfp_cpp_area *area;\n-\toff_t offset, nfp_offset;\n-\tuint32_t cpp_id, pos, len;\n-\tuint32_t tmpbuf[16];\n-\tsize_t count, curlen, totlen = 0;\n-\tint err = 0;\n-\n-\tPMD_CPP_LOG(DEBUG, \"%s: offset size %zu, count_size: %zu\\n\", __func__,\n-\t\tsizeof(off_t), sizeof(size_t));\n-\n-\t/* Reading the count param */\n-\terr = recv(sockfd, &count, sizeof(off_t), 0);\n-\tif (err != sizeof(off_t))\n-\t\treturn -EINVAL;\n-\n-\tcurlen = count;\n-\n-\t/* Reading the offset param */\n-\terr = recv(sockfd, &offset, sizeof(off_t), 0);\n-\tif (err != sizeof(off_t))\n-\t\treturn -EINVAL;\n-\n-\t/* Obtain target's CPP ID and offset in target */\n-\tcpp_id = (offset >> 40) << 8;\n-\tnfp_offset = offset & ((1ull << 40) - 1);\n-\n-\tPMD_CPP_LOG(DEBUG, \"%s: count %zu and offset %jd\\n\", __func__, count,\n-\t\toffset);\n-\tPMD_CPP_LOG(DEBUG, \"%s: cpp_id %08x and nfp_offset %jd\\n\", __func__,\n-\t\tcpp_id, nfp_offset);\n-\n-\t/* Adjust length if not aligned */\n-\tif (((nfp_offset + (off_t)count - 1) & ~(NFP_CPP_MEMIO_BOUNDARY - 1)) !=\n-\t    (nfp_offset & ~(NFP_CPP_MEMIO_BOUNDARY - 1))) {\n-\t\tcurlen = NFP_CPP_MEMIO_BOUNDARY -\n-\t\t\t(nfp_offset & (NFP_CPP_MEMIO_BOUNDARY - 1));\n-\t}\n-\n-\twhile (count > 0) {\n-\t\t/* configure a CPP PCIe2CPP BAR for mapping the CPP target */\n-\t\tarea = nfp_cpp_area_alloc_with_name(cpp, cpp_id, \"nfp.cdev\",\n-\t\t\t\t\t\t    nfp_offset, curlen);\n-\t\tif (!area) {\n-\t\t\tRTE_LOG(ERR, PMD, \"%s: area alloc fail\\n\", __func__);\n-\t\t\treturn -EIO;\n-\t\t}\n-\n-\t\t/* mapping the target */\n-\t\terr = nfp_cpp_area_acquire(area);\n-\t\tif (err < 0) {\n-\t\t\tRTE_LOG(ERR, PMD, \"area acquire failed\\n\");\n-\t\t\tnfp_cpp_area_free(area);\n-\t\t\treturn -EIO;\n-\t\t}\n-\n-\t\tfor (pos = 0; pos < curlen; pos += len) {\n-\t\t\tlen = curlen - pos;\n-\t\t\tif (len > sizeof(tmpbuf))\n-\t\t\t\tlen = sizeof(tmpbuf);\n-\n-\t\t\tPMD_CPP_LOG(DEBUG, \"%s: Receive %u of %zu\\n\", __func__,\n-\t\t\t\t\t   len, count);\n-\t\t\terr = recv(sockfd, tmpbuf, len, MSG_WAITALL);\n-\t\t\tif (err != (int)len) {\n-\t\t\t\tRTE_LOG(ERR, PMD,\n-\t\t\t\t\t\"%s: error when receiving, %d of %zu\\n\",\n-\t\t\t\t\t__func__, err, count);\n-\t\t\t\tnfp_cpp_area_release(area);\n-\t\t\t\tnfp_cpp_area_free(area);\n-\t\t\t\treturn -EIO;\n-\t\t\t}\n-\t\t\terr = nfp_cpp_area_write(area, pos, tmpbuf, len);\n-\t\t\tif (err < 0) {\n-\t\t\t\tRTE_LOG(ERR, PMD, \"nfp_cpp_area_write error\\n\");\n-\t\t\t\tnfp_cpp_area_release(area);\n-\t\t\t\tnfp_cpp_area_free(area);\n-\t\t\t\treturn -EIO;\n-\t\t\t}\n-\t\t}\n-\n-\t\tnfp_offset += pos;\n-\t\ttotlen += pos;\n-\t\tnfp_cpp_area_release(area);\n-\t\tnfp_cpp_area_free(area);\n-\n-\t\tcount -= pos;\n-\t\tcurlen = (count > NFP_CPP_MEMIO_BOUNDARY) ?\n-\t\t\t NFP_CPP_MEMIO_BOUNDARY : count;\n-\t}\n-\n-\treturn 0;\n-}\n-\n-/*\n- * Serving a read request to NFP from host programs. The request\n- * sends the read size and the CPP target. The bridge makes use\n- * of CPP interface handler configured by the PMD setup. The read\n- * data is sent to the requester using the same socket.\n- */\n-static int\n-nfp_cpp_bridge_serve_read(int sockfd, struct nfp_cpp *cpp)\n-{\n-\tstruct nfp_cpp_area *area;\n-\toff_t offset, nfp_offset;\n-\tuint32_t cpp_id, pos, len;\n-\tuint32_t tmpbuf[16];\n-\tsize_t count, curlen, totlen = 0;\n-\tint err = 0;\n-\n-\tPMD_CPP_LOG(DEBUG, \"%s: offset size %zu, count_size: %zu\\n\", __func__,\n-\t\tsizeof(off_t), sizeof(size_t));\n-\n-\t/* Reading the count param */\n-\terr = recv(sockfd, &count, sizeof(off_t), 0);\n-\tif (err != sizeof(off_t))\n-\t\treturn -EINVAL;\n-\n-\tcurlen = count;\n-\n-\t/* Reading the offset param */\n-\terr = recv(sockfd, &offset, sizeof(off_t), 0);\n-\tif (err != sizeof(off_t))\n-\t\treturn -EINVAL;\n-\n-\t/* Obtain target's CPP ID and offset in target */\n-\tcpp_id = (offset >> 40) << 8;\n-\tnfp_offset = offset & ((1ull << 40) - 1);\n-\n-\tPMD_CPP_LOG(DEBUG, \"%s: count %zu and offset %jd\\n\", __func__, count,\n-\t\t\t   offset);\n-\tPMD_CPP_LOG(DEBUG, \"%s: cpp_id %08x and nfp_offset %jd\\n\", __func__,\n-\t\t\t   cpp_id, nfp_offset);\n-\n-\t/* Adjust length if not aligned */\n-\tif (((nfp_offset + (off_t)count - 1) & ~(NFP_CPP_MEMIO_BOUNDARY - 1)) !=\n-\t    (nfp_offset & ~(NFP_CPP_MEMIO_BOUNDARY - 1))) {\n-\t\tcurlen = NFP_CPP_MEMIO_BOUNDARY -\n-\t\t\t(nfp_offset & (NFP_CPP_MEMIO_BOUNDARY - 1));\n-\t}\n-\n-\twhile (count > 0) {\n-\t\tarea = nfp_cpp_area_alloc_with_name(cpp, cpp_id, \"nfp.cdev\",\n-\t\t\t\t\t\t    nfp_offset, curlen);\n-\t\tif (!area) {\n-\t\t\tRTE_LOG(ERR, PMD, \"%s: area alloc failed\\n\", __func__);\n-\t\t\treturn -EIO;\n-\t\t}\n-\n-\t\terr = nfp_cpp_area_acquire(area);\n-\t\tif (err < 0) {\n-\t\t\tRTE_LOG(ERR, PMD, \"area acquire failed\\n\");\n-\t\t\tnfp_cpp_area_free(area);\n-\t\t\treturn -EIO;\n-\t\t}\n-\n-\t\tfor (pos = 0; pos < curlen; pos += len) {\n-\t\t\tlen = curlen - pos;\n-\t\t\tif (len > sizeof(tmpbuf))\n-\t\t\t\tlen = sizeof(tmpbuf);\n-\n-\t\t\terr = nfp_cpp_area_read(area, pos, tmpbuf, len);\n-\t\t\tif (err < 0) {\n-\t\t\t\tRTE_LOG(ERR, PMD, \"nfp_cpp_area_read error\\n\");\n-\t\t\t\tnfp_cpp_area_release(area);\n-\t\t\t\tnfp_cpp_area_free(area);\n-\t\t\t\treturn -EIO;\n-\t\t\t}\n-\t\t\tPMD_CPP_LOG(DEBUG, \"%s: sending %u of %zu\\n\", __func__,\n-\t\t\t\t\t   len, count);\n-\n-\t\t\terr = send(sockfd, tmpbuf, len, 0);\n-\t\t\tif (err != (int)len) {\n-\t\t\t\tRTE_LOG(ERR, PMD,\n-\t\t\t\t\t\"%s: error when sending: %d of %zu\\n\",\n-\t\t\t\t\t__func__, err, count);\n-\t\t\t\tnfp_cpp_area_release(area);\n-\t\t\t\tnfp_cpp_area_free(area);\n-\t\t\t\treturn -EIO;\n-\t\t\t}\n-\t\t}\n-\n-\t\tnfp_offset += pos;\n-\t\ttotlen += pos;\n-\t\tnfp_cpp_area_release(area);\n-\t\tnfp_cpp_area_free(area);\n-\n-\t\tcount -= pos;\n-\t\tcurlen = (count > NFP_CPP_MEMIO_BOUNDARY) ?\n-\t\t\tNFP_CPP_MEMIO_BOUNDARY : count;\n-\t}\n-\treturn 0;\n-}\n-\n-#define NFP_IOCTL 'n'\n-#define NFP_IOCTL_CPP_IDENTIFICATION _IOW(NFP_IOCTL, 0x8f, uint32_t)\n-/*\n- * Serving a ioctl command from host NFP tools. This usually goes to\n- * a kernel driver char driver but it is not available when the PF is\n- * bound to the PMD. Currently just one ioctl command is served and it\n- * does not require any CPP access at all.\n- */\n-static int\n-nfp_cpp_bridge_serve_ioctl(int sockfd, struct nfp_cpp *cpp)\n-{\n-\tuint32_t cmd, ident_size, tmp;\n-\tint err;\n-\n-\t/* Reading now the IOCTL command */\n-\terr = recv(sockfd, &cmd, 4, 0);\n-\tif (err != 4) {\n-\t\tRTE_LOG(ERR, PMD, \"%s: read error from socket\\n\", __func__);\n-\t\treturn -EIO;\n-\t}\n-\n-\t/* Only supporting NFP_IOCTL_CPP_IDENTIFICATION */\n-\tif (cmd != NFP_IOCTL_CPP_IDENTIFICATION) {\n-\t\tRTE_LOG(ERR, PMD, \"%s: unknown cmd %d\\n\", __func__, cmd);\n-\t\treturn -EINVAL;\n-\t}\n-\n-\terr = recv(sockfd, &ident_size, 4, 0);\n-\tif (err != 4) {\n-\t\tRTE_LOG(ERR, PMD, \"%s: read error from socket\\n\", __func__);\n-\t\treturn -EIO;\n-\t}\n-\n-\ttmp = nfp_cpp_model(cpp);\n-\n-\tPMD_CPP_LOG(DEBUG, \"%s: sending NFP model %08x\\n\", __func__, tmp);\n-\n-\terr = send(sockfd, &tmp, 4, 0);\n-\tif (err != 4) {\n-\t\tRTE_LOG(ERR, PMD, \"%s: error writing to socket\\n\", __func__);\n-\t\treturn -EIO;\n-\t}\n-\n-\ttmp = cpp->interface;\n-\n-\tPMD_CPP_LOG(DEBUG, \"%s: sending NFP interface %08x\\n\", __func__, tmp);\n-\n-\terr = send(sockfd, &tmp, 4, 0);\n-\tif (err != 4) {\n-\t\tRTE_LOG(ERR, PMD, \"%s: error writing to socket\\n\", __func__);\n-\t\treturn -EIO;\n-\t}\n-\n-\treturn 0;\n-}\n-\n-#define NFP_BRIDGE_OP_READ\t20\n-#define NFP_BRIDGE_OP_WRITE\t30\n-#define NFP_BRIDGE_OP_IOCTL\t40\n-\n-/*\n- * This is the code to be executed by a service core. The CPP bridge interface\n- * is based on a unix socket and requests usually received by a kernel char\n- * driver, read, write and ioctl, are handled by the CPP bridge. NFP host tools\n- * can be executed with a wrapper library and LD_LIBRARY being completely\n- * unaware of the CPP bridge performing the NFP kernel char driver for CPP\n- * accesses.\n- */\n-static int32_t\n-nfp_cpp_bridge_service_func(void *args)\n-{\n-\tstruct sockaddr address;\n-\tstruct nfp_cpp *cpp = args;\n-\tint sockfd, datafd, op, ret;\n-\n-\tunlink(\"/tmp/nfp_cpp\");\n-\tsockfd = socket(AF_UNIX, SOCK_STREAM, 0);\n-\tif (sockfd < 0) {\n-\t\tRTE_LOG(ERR, PMD, \"%s: socket creation error. Service failed\\n\",\n-\t\t\t__func__);\n-\t\treturn -EIO;\n-\t}\n-\n-\tmemset(&address, 0, sizeof(struct sockaddr));\n-\n-\taddress.sa_family = AF_UNIX;\n-\tstrcpy(address.sa_data, \"/tmp/nfp_cpp\");\n-\n-\tret = bind(sockfd, (const struct sockaddr *)&address,\n-\t\t   sizeof(struct sockaddr));\n-\tif (ret < 0) {\n-\t\tRTE_LOG(ERR, PMD, \"%s: bind error (%d). Service failed\\n\",\n-\t\t\t\t  __func__, errno);\n-\t\tclose(sockfd);\n-\t\treturn ret;\n-\t}\n-\n-\tret = listen(sockfd, 20);\n-\tif (ret < 0) {\n-\t\tRTE_LOG(ERR, PMD, \"%s: listen error(%d). Service failed\\n\",\n-\t\t\t\t  __func__, errno);\n-\t\tclose(sockfd);\n-\t\treturn ret;\n-\t}\n-\n-\tfor (;;) {\n-\t\tdatafd = accept(sockfd, NULL, NULL);\n-\t\tif (datafd < 0) {\n-\t\t\tRTE_LOG(ERR, PMD, \"%s: accept call error (%d)\\n\",\n-\t\t\t\t\t  __func__, errno);\n-\t\t\tRTE_LOG(ERR, PMD, \"%s: service failed\\n\", __func__);\n-\t\t\tclose(sockfd);\n-\t\t\treturn -EIO;\n-\t\t}\n-\n-\t\twhile (1) {\n-\t\t\tret = recv(datafd, &op, 4, 0);\n-\t\t\tif (ret <= 0) {\n-\t\t\t\tPMD_CPP_LOG(DEBUG, \"%s: socket close\\n\",\n-\t\t\t\t\t\t   __func__);\n-\t\t\t\tbreak;\n-\t\t\t}\n-\n-\t\t\tPMD_CPP_LOG(DEBUG, \"%s: getting op %u\\n\", __func__, op);\n-\n-\t\t\tif (op == NFP_BRIDGE_OP_READ)\n-\t\t\t\tnfp_cpp_bridge_serve_read(datafd, cpp);\n-\n-\t\t\tif (op == NFP_BRIDGE_OP_WRITE)\n-\t\t\t\tnfp_cpp_bridge_serve_write(datafd, cpp);\n-\n-\t\t\tif (op == NFP_BRIDGE_OP_IOCTL)\n-\t\t\t\tnfp_cpp_bridge_serve_ioctl(datafd, cpp);\n-\n-\t\t\tif (op == 0)\n-\t\t\t\tbreak;\n-\t\t}\n-\t\tclose(datafd);\n-\t}\n-\tclose(sockfd);\n-\n-\treturn 0;\n-}\n-\n #define DEFAULT_FW_PATH       \"/lib/firmware/netronome\"\n \n static int\n@@ -2491,23 +2143,6 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev)\n \treturn ret;\n }\n \n-static void nfp_register_cpp_service(struct nfp_cpp *cpp)\n-{\n-\tuint32_t *cpp_service_id = NULL;\n-\tstruct rte_service_spec service;\n-\n-\tmemset(&service, 0, sizeof(struct rte_service_spec));\n-\tsnprintf(service.name, sizeof(service.name), \"nfp_cpp_service\");\n-\tservice.callback = nfp_cpp_bridge_service_func;\n-\tservice.callback_userdata = (void *)cpp;\n-\n-\tif (rte_service_component_register(&service,\n-\t\t\t\t\t   cpp_service_id))\n-\t\tRTE_LOG(WARNING, PMD, \"NFP CPP bridge service register() failed\");\n-\telse\n-\t\tRTE_LOG(DEBUG, PMD, \"NFP CPP bridge service registered\");\n-}\n-\n static int nfp_pf_init(struct rte_pci_device *pci_dev)\n {\n \tstruct nfp_pf_dev *pf_dev = NULL;\n",
    "prefixes": [
        "3/7"
    ]
}