get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 41233,
    "url": "http://patches.dpdk.org/api/patches/41233/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1529352372-22198-1-git-send-email-alejandro.lucero@netronome.com/",
    "project": {
        "id": 1,
        "url": "http://patches.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": "<1529352372-22198-1-git-send-email-alejandro.lucero@netronome.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1529352372-22198-1-git-send-email-alejandro.lucero@netronome.com",
    "date": "2018-06-18T20:06:12",
    "name": "net/nfp: use generic PCI config access functions",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "dcac1f5d8afaa1cb2dd2e4b0f4368e1113f5d887",
    "submitter": {
        "id": 270,
        "url": "http://patches.dpdk.org/api/people/270/?format=api",
        "name": "Alejandro Lucero",
        "email": "alejandro.lucero@netronome.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1529352372-22198-1-git-send-email-alejandro.lucero@netronome.com/mbox/",
    "series": [
        {
            "id": 156,
            "url": "http://patches.dpdk.org/api/series/156/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=156",
            "date": "2018-06-18T20:06:12",
            "name": "net/nfp: use generic PCI config access functions",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/156/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/41233/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/41233/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 3A8ED2C17;\n\tMon, 18 Jun 2018 22:06:35 +0200 (CEST)",
            "from netronome.com (host-79-78-33-110.static.as9105.net\n\t[79.78.33.110]) by dpdk.org (Postfix) with ESMTP id 7544F2C16\n\tfor <dev@dpdk.org>; Mon, 18 Jun 2018 22:06:33 +0200 (CEST)",
            "from netronome.com (localhost [127.0.0.1])\n\tby netronome.com (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id\n\tw5IK6CGw022237 for <dev@dpdk.org>; Mon, 18 Jun 2018 21:06:12 +0100",
            "(from alucero@localhost)\n\tby netronome.com (8.14.4/8.14.4/Submit) id w5IK6Cfc022236\n\tfor dev@dpdk.org; Mon, 18 Jun 2018 21:06:12 +0100"
        ],
        "From": "Alejandro Lucero <alejandro.lucero@netronome.com>",
        "To": "dev@dpdk.org",
        "Date": "Mon, 18 Jun 2018 21:06:12 +0100",
        "Message-Id": "<1529352372-22198-1-git-send-email-alejandro.lucero@netronome.com>",
        "X-Mailer": "git-send-email 1.9.1",
        "Subject": "[dpdk-dev] [PATCH] net/nfp: use generic PCI config access functions",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This patch avoids direct access to device config sysfs file using\nrte_pci_read_config instead.\n\nApart from replicating code, it turns out this direct access does\nnot always work if non-root users execute DPDK apps. In those cases\nit is mandatory to go through VFIO specific function for reading pci\nconfig space.\n\nSigned-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>\n---\n drivers/net/nfp/nfp_net.c                  |   4 +-\n drivers/net/nfp/nfpcore/nfp_cpp.h          |   6 +-\n drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 111 ++++++++++-------------------\n drivers/net/nfp/nfpcore/nfp_cppcore.c      |   9 +--\n 4 files changed, 47 insertions(+), 83 deletions(-)",
    "diff": "diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c\nindex 3658696..1422d05 100644\n--- a/drivers/net/nfp/nfp_net.c\n+++ b/drivers/net/nfp/nfp_net.c\n@@ -3130,9 +3130,9 @@ static int nfp_pf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \t * use a lock file if UIO is being used.\n \t */\n \tif (dev->kdrv == RTE_KDRV_VFIO)\n-\t\tcpp = nfp_cpp_from_device_name(dev->device.name, 0);\n+\t\tcpp = nfp_cpp_from_device_name(dev, 0);\n \telse\n-\t\tcpp = nfp_cpp_from_device_name(dev->device.name, 1);\n+\t\tcpp = nfp_cpp_from_device_name(dev, 1);\n \n \tif (!cpp) {\n \t\tPMD_DRV_LOG(ERR, \"A CPP handle can not be obtained\");\ndiff --git a/drivers/net/nfp/nfpcore/nfp_cpp.h b/drivers/net/nfp/nfpcore/nfp_cpp.h\nindex de2ff84..1427954 100644\n--- a/drivers/net/nfp/nfpcore/nfp_cpp.h\n+++ b/drivers/net/nfp/nfpcore/nfp_cpp.h\n@@ -6,6 +6,8 @@\n #ifndef __NFP_CPP_H__\n #define __NFP_CPP_H__\n \n+#include <rte_ethdev_pci.h>\n+\n #include \"nfp-common/nfp_platform.h\"\n #include \"nfp-common/nfp_resid.h\"\n \n@@ -54,7 +56,7 @@ struct nfp_cpp_operations {\n \tsize_t area_priv_size;\n \n \t/* Instance an NFP CPP */\n-\tint (*init)(struct nfp_cpp *cpp, const char *devname);\n+\tint (*init)(struct nfp_cpp *cpp, struct rte_pci_device *dev);\n \n \t/*\n \t * Free the bus.\n@@ -181,7 +183,7 @@ int nfp_cpp_serial_set(struct nfp_cpp *cpp, const uint8_t *serial,\n  *\n  * @return NFP CPP handle, or NULL on failure (and set errno accordingly).\n  */\n-struct nfp_cpp *nfp_cpp_from_device_name(const char *devname,\n+struct nfp_cpp *nfp_cpp_from_device_name(struct rte_pci_device *dev,\n \t\t\t\t\t int driver_lock_needed);\n \n /*\ndiff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c\nindex 2f5e7f6..2a1ec96 100644\n--- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c\n+++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c\n@@ -31,6 +31,7 @@\n #include <sys/file.h>\n #include <sys/stat.h>\n \n+#include <rte_ethdev_pci.h>\n #include <rte_string_fns.h>\n \n #include \"nfp_cpp.h\"\n@@ -639,61 +640,32 @@ struct nfp6000_area_priv {\n }\n \n static int\n-nfp6000_set_model(struct nfp_pcie_user *desc, struct nfp_cpp *cpp)\n+nfp6000_set_model(struct rte_pci_device *dev, struct nfp_cpp *cpp)\n {\n-\tchar tmp_str[80];\n-\tuint32_t tmp;\n-\tint fp;\n-\n-\tsnprintf(tmp_str, sizeof(tmp_str), \"%s/%s/config\", PCI_DEVICES,\n-\t\t desc->busdev);\n-\n-\tfp = open(tmp_str, O_RDONLY);\n-\tif (!fp)\n-\t\treturn -1;\n-\n-\tlseek(fp, 0x2e, SEEK_SET);\n+\tuint32_t model;\n \n-\tif (read(fp, &tmp, sizeof(tmp)) != sizeof(tmp)) {\n-\t\tprintf(\"Error reading config file for model\\n\");\n+\tif (rte_pci_read_config(dev, &model, 4, 0x2e) < 0) {\n+\t\tprintf(\"nfp set model failed\\n\");\n \t\treturn -1;\n \t}\n \n-\ttmp = tmp << 16;\n-\n-\tif (close(fp) == -1)\n-\t\treturn -1;\n-\n-\tnfp_cpp_model_set(cpp, tmp);\n+\tmodel  = model << 16;\n+\tnfp_cpp_model_set(cpp, model);\n \n \treturn 0;\n }\n \n static int\n-nfp6000_set_interface(struct nfp_pcie_user *desc, struct nfp_cpp *cpp)\n+nfp6000_set_interface(struct rte_pci_device *dev, struct nfp_cpp *cpp)\n {\n-\tchar tmp_str[80];\n-\tuint16_t tmp;\n-\tint fp;\n-\n-\tsnprintf(tmp_str, sizeof(tmp_str), \"%s/%s/config\", PCI_DEVICES,\n-\t\t desc->busdev);\n+\tuint16_t interface;\n \n-\tfp = open(tmp_str, O_RDONLY);\n-\tif (!fp)\n-\t\treturn -1;\n-\n-\tlseek(fp, 0x154, SEEK_SET);\n-\n-\tif (read(fp, &tmp, sizeof(tmp)) != sizeof(tmp)) {\n-\t\tprintf(\"error reading config file for interface\\n\");\n+\tif (rte_pci_read_config(dev, &interface, 2, 0x154) < 0) {\n+\t\tprintf(\"nfp set interface failed\\n\");\n \t\treturn -1;\n \t}\n \n-\tif (close(fp) == -1)\n-\t\treturn -1;\n-\n-\tnfp_cpp_interface_set(cpp, tmp);\n+\tnfp_cpp_interface_set(cpp, interface);\n \n \treturn 0;\n }\n@@ -704,7 +676,7 @@ struct nfp6000_area_priv {\n #define PCI_EXT_CAP_NEXT(header)\t((header >> 20) & 0xffc)\n #define PCI_EXT_CAP_ID_DSN\t0x03\n static int\n-nfp_pci_find_next_ext_capability(int fp, int cap)\n+nfp_pci_find_next_ext_capability(struct rte_pci_device *dev, int cap)\n {\n \tuint32_t header;\n \tint ttl;\n@@ -713,9 +685,8 @@ struct nfp6000_area_priv {\n \t/* minimum 8 bytes per capability */\n \tttl = (PCI_CFG_SPACE_EXP_SIZE - PCI_CFG_SPACE_SIZE) / 8;\n \n-\tlseek(fp, pos, SEEK_SET);\n-\tif (read(fp, &header, sizeof(header)) != sizeof(header)) {\n-\t\tprintf(\"error reading config file for serial\\n\");\n+\tif (rte_pci_read_config(dev, &header, 4, pos) < 0) {\n+\t\tprintf(\"nfp error reading extended capabilities\\n\");\n \t\treturn -1;\n \t}\n \n@@ -734,9 +705,8 @@ struct nfp6000_area_priv {\n \t\tif (pos < PCI_CFG_SPACE_SIZE)\n \t\t\tbreak;\n \n-\t\tlseek(fp, pos, SEEK_SET);\n-\t\tif (read(fp, &header, sizeof(header)) != sizeof(header)) {\n-\t\t\tprintf(\"error reading config file for serial\\n\");\n+\t\tif (rte_pci_read_config(dev, &header, 4, pos) < 0) {\n+\t\t\tprintf(\"nfp error reading extended capabilities\\n\");\n \t\t\treturn -1;\n \t\t}\n \t}\n@@ -745,56 +715,47 @@ struct nfp6000_area_priv {\n }\n \n static int\n-nfp6000_set_serial(struct nfp_pcie_user *desc, struct nfp_cpp *cpp)\n+nfp6000_set_serial(struct rte_pci_device *dev, struct nfp_cpp *cpp)\n {\n-\tchar tmp_str[80];\n \tuint16_t tmp;\n \tuint8_t serial[6];\n \tint serial_len = 6;\n-\tint fp, pos;\n+\tint pos;\n \n-\tsnprintf(tmp_str, sizeof(tmp_str), \"%s/%s/config\", PCI_DEVICES,\n-\t\t desc->busdev);\n-\n-\tfp = open(tmp_str, O_RDONLY);\n-\tif (!fp)\n-\t\treturn -1;\n-\n-\tpos = nfp_pci_find_next_ext_capability(fp, PCI_EXT_CAP_ID_DSN);\n+\tpos = nfp_pci_find_next_ext_capability(dev, PCI_EXT_CAP_ID_DSN);\n \tif (pos <= 0) {\n-\t\tprintf(\"PCI_EXT_CAP_ID_DSN not found. Using default offset\\n\");\n-\t\tlseek(fp, 0x156, SEEK_SET);\n+\t\tprintf(\"PCI_EXT_CAP_ID_DSN not found. nfp set serial failed\\n\");\n+\t\treturn -1;\n \t} else {\n-\t\tlseek(fp, pos + 6, SEEK_SET);\n+\t\tpos += 6;\n \t}\n \n-\tif (read(fp, &tmp, sizeof(tmp)) != sizeof(tmp)) {\n-\t\tprintf(\"error reading config file for serial\\n\");\n+\tif (rte_pci_read_config(dev, &tmp, 2, pos) < 0) {\n+\t\tprintf(\"nfp set serial failed\\n\");\n \t\treturn -1;\n \t}\n \n \tserial[4] = (uint8_t)((tmp >> 8) & 0xff);\n \tserial[5] = (uint8_t)(tmp & 0xff);\n \n-\tif (read(fp, &tmp, sizeof(tmp)) != sizeof(tmp)) {\n-\t\tprintf(\"error reading config file for serial\\n\");\n+\tpos += 2;\n+\tif (rte_pci_read_config(dev, &tmp, 2, pos) < 0) {\n+\t\tprintf(\"nfp set serial failed\\n\");\n \t\treturn -1;\n \t}\n \n \tserial[2] = (uint8_t)((tmp >> 8) & 0xff);\n \tserial[3] = (uint8_t)(tmp & 0xff);\n \n-\tif (read(fp, &tmp, sizeof(tmp)) != sizeof(tmp)) {\n-\t\tprintf(\"error reading config file for serial\\n\");\n+\tpos += 2;\n+\tif (rte_pci_read_config(dev, &tmp, 2, pos) < 0) {\n+\t\tprintf(\"nfp set serial failed\\n\");\n \t\treturn -1;\n \t}\n \n \tserial[0] = (uint8_t)((tmp >> 8) & 0xff);\n \tserial[1] = (uint8_t)(tmp & 0xff);\n \n-\tif (close(fp) == -1)\n-\t\treturn -1;\n-\n \tnfp_cpp_serial_set(cpp, serial, serial_len);\n \n \treturn 0;\n@@ -833,7 +794,7 @@ struct nfp6000_area_priv {\n }\n \n static int\n-nfp6000_init(struct nfp_cpp *cpp, const char *devname)\n+nfp6000_init(struct nfp_cpp *cpp, struct rte_pci_device *dev)\n {\n \tchar link[120];\n \tchar tmp_str[80];\n@@ -848,7 +809,7 @@ struct nfp6000_area_priv {\n \n \n \tmemset(desc->busdev, 0, BUSDEV_SZ);\n-\tstrlcpy(desc->busdev, devname, sizeof(desc->busdev));\n+\tstrlcpy(desc->busdev, dev->device.name, sizeof(desc->busdev));\n \n \tif (cpp->driver_lock_needed) {\n \t\tret = nfp_acquire_process_lock(desc);\n@@ -874,11 +835,11 @@ struct nfp6000_area_priv {\n \tif (desc->device == -1)\n \t\treturn -1;\n \n-\tif (nfp6000_set_model(desc, cpp) < 0)\n+\tif (nfp6000_set_model(dev, cpp) < 0)\n \t\treturn -1;\n-\tif (nfp6000_set_interface(desc, cpp) < 0)\n+\tif (nfp6000_set_interface(dev, cpp) < 0)\n \t\treturn -1;\n-\tif (nfp6000_set_serial(desc, cpp) < 0)\n+\tif (nfp6000_set_serial(dev, cpp) < 0)\n \t\treturn -1;\n \tif (nfp6000_set_barsz(desc) < 0)\n \t\treturn -1;\ndiff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c\nindex f61143f..75d3c97 100644\n--- a/drivers/net/nfp/nfpcore/nfp_cppcore.c\n+++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c\n@@ -12,6 +12,7 @@\n #include <sys/types.h>\n \n #include <rte_byteorder.h>\n+#include <rte_ethdev_pci.h>\n \n #include \"nfp_cpp.h\"\n #include \"nfp_target.h\"\n@@ -542,7 +543,7 @@ struct nfp_cpp_area *\n }\n \n static struct nfp_cpp *\n-nfp_cpp_alloc(const char *devname, int driver_lock_needed)\n+nfp_cpp_alloc(struct rte_pci_device *dev, int driver_lock_needed)\n {\n \tconst struct nfp_cpp_operations *ops;\n \tstruct nfp_cpp *cpp;\n@@ -561,7 +562,7 @@ struct nfp_cpp_area *\n \tcpp->driver_lock_needed = driver_lock_needed;\n \n \tif (cpp->op->init) {\n-\t\terr = cpp->op->init(cpp, devname);\n+\t\terr = cpp->op->init(cpp, dev);\n \t\tif (err < 0) {\n \t\t\tfree(cpp);\n \t\t\treturn NULL;\n@@ -604,9 +605,9 @@ struct nfp_cpp_area *\n }\n \n struct nfp_cpp *\n-nfp_cpp_from_device_name(const char *devname, int driver_lock_needed)\n+nfp_cpp_from_device_name(struct rte_pci_device *dev, int driver_lock_needed)\n {\n-\treturn nfp_cpp_alloc(devname, driver_lock_needed);\n+\treturn nfp_cpp_alloc(dev, driver_lock_needed);\n }\n \n /*\n",
    "prefixes": []
}