get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 13541,
    "url": "http://patches.dpdk.org/api/patches/13541/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1465822926-23742-11-git-send-email-viktorin@rehivetech.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": "<1465822926-23742-11-git-send-email-viktorin@rehivetech.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1465822926-23742-11-git-send-email-viktorin@rehivetech.com",
    "date": "2016-06-13T13:02:00",
    "name": "[dpdk-dev,v2,10/16] vfio: extract setup logic out of pci_vfio_map_resource",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "68c63b1241d1eeae8e15ee8187f9d77c533fecba",
    "submitter": {
        "id": 292,
        "url": "http://patches.dpdk.org/api/people/292/?format=api",
        "name": "Jan Viktorin",
        "email": "viktorin@rehivetech.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1465822926-23742-11-git-send-email-viktorin@rehivetech.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/13541/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/13541/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id A2D7C5955;\n\tMon, 13 Jun 2016 15:07:43 +0200 (CEST)",
            "from wes1-so1.wedos.net (wes1-so1.wedos.net [46.28.106.15])\n\tby dpdk.org (Postfix) with ESMTP id C5F1A567C\n\tfor <dev@dpdk.org>; Mon, 13 Jun 2016 15:07:32 +0200 (CEST)",
            "from pcviktorin.fit.vutbr.cz (pcviktorin.fit.vutbr.cz\n\t[147.229.13.147])\n\tby wes1-so1.wedos.net (Postfix) with ESMTPSA id 3rStNh3rLhzC6S;\n\tMon, 13 Jun 2016 15:07:32 +0200 (CEST)"
        ],
        "From": "Jan Viktorin <viktorin@rehivetech.com>",
        "To": "dev@dpdk.org",
        "Cc": "Jan Viktorin <viktorin@rehivetech.com>,\n\tAnatoly Burakov <anatoly.burakov@intel.com>,\n\tDavid Marchand <david.marchand@6wind.com>,\n\tKeith Wiles <keith.wiles@intel.com>,\n\tSantosh Shukla <sshukla@mvista.com>, \n\tStephen Hemminger <stephen@networkplumber.org>,\n\tShreyansh Jain <shreyansh.jain@nxp.com>",
        "Date": "Mon, 13 Jun 2016 15:02:00 +0200",
        "Message-Id": "<1465822926-23742-11-git-send-email-viktorin@rehivetech.com>",
        "X-Mailer": "git-send-email 2.8.0",
        "In-Reply-To": [
            "<1465822926-23742-1-git-send-email-viktorin@rehivetech.com>",
            "<1461937456-22943-1-git-send-email-viktorin@rehivetech.com>"
        ],
        "References": [
            "<1465822926-23742-1-git-send-email-viktorin@rehivetech.com>",
            "<1461937456-22943-1-git-send-email-viktorin@rehivetech.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v2 10/16] vfio: extract setup logic out of\n\tpci_vfio_map_resource",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "The setup logic access the global vfio_cfg variable that will be moved in the\nfollowing commits. We need to separate all accesses to this variable to a\ngeneral code.\n\nSigned-off-by: Jan Viktorin <viktorin@rehivetech.com>\n---\nv2\n* fixed lost viable code (A. Burakov)\n---\n lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 85 +++++++++++++++++-------------\n 1 file changed, 49 insertions(+), 36 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c\nindex 2b3dd2e..27ce6a8 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c\n@@ -411,37 +411,22 @@ clear_current_group(void)\n \tvfio_cfg.vfio_groups[vfio_cfg.vfio_group_idx].fd = -1;\n }\n \n-\n-/*\n- * map the PCI resources of a PCI device in virtual memory (VFIO version).\n- * primary and secondary processes follow almost exactly the same path\n+/**\n+ * Setup vfio_cfg for the device indentified by its address. It discovers\n+ * the configured I/O MMU groups or sets a new one for the device. If a new\n+ * groups is assigned, the DMA mapping is performed.\n+ * Returns 0 on success, a negative value on failure and a positive value in\n+ * case the given device cannot be managed this way.\n  */\n-int\n-pci_vfio_map_resource(struct rte_pci_device *dev)\n+static int pci_vfio_setup_device(const char *pci_addr, int *vfio_dev_fd,\n+\t\tstruct vfio_device_info *device_info)\n {\n \tstruct vfio_group_status group_status = {\n \t\t\t.argsz = sizeof(group_status)\n \t};\n-\tstruct vfio_device_info device_info = { .argsz = sizeof(device_info) };\n-\tint vfio_group_fd, vfio_dev_fd;\n+\tint vfio_group_fd;\n \tint iommu_group_no;\n-\tchar pci_addr[PATH_MAX] = {0};\n-\tstruct rte_pci_addr *loc = &dev->addr;\n-\tint i, ret, msix_bar;\n-\tstruct mapped_pci_resource *vfio_res = NULL;\n-\tstruct mapped_pci_res_list *vfio_res_list = RTE_TAILQ_CAST(rte_vfio_tailq.head, mapped_pci_res_list);\n-\n-\tstruct pci_map *maps;\n-\tuint32_t msix_table_offset = 0;\n-\tuint32_t msix_table_size = 0;\n-\tuint32_t ioport_bar;\n-\n-\tdev->intr_handle.fd = -1;\n-\tdev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;\n-\n-\t/* store PCI address string */\n-\tsnprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,\n-\t\t\tloc->domain, loc->bus, loc->devid, loc->function);\n+\tint ret;\n \n \t/* get group number */\n \tret = pci_vfio_get_group_no(pci_addr, &iommu_group_no);\n@@ -476,8 +461,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev)\n \t}\n \n \t/*\n-\t * at this point, we know at least one port on this device is bound to VFIO,\n-\t * so we can proceed to try and set this particular port up\n+\t * at this point, we know that this group is viable (meaning, all devices\n+\t * are either bound to VFIO or not bound to anything)\n \t */\n \n \t/* check if the group is viable */\n@@ -495,11 +480,6 @@ pci_vfio_map_resource(struct rte_pci_device *dev)\n \t\treturn -1;\n \t}\n \n-\t/*\n-\t * at this point, we know that this group is viable (meaning, all devices\n-\t * are either bound to VFIO or not bound to anything)\n-\t */\n-\n \t/* check if group does not have a container yet */\n \tif (!(group_status.flags & VFIO_GROUP_FLAGS_CONTAINER_SET)) {\n \n@@ -546,8 +526,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev)\n \t}\n \n \t/* get a file descriptor for the device */\n-\tvfio_dev_fd = ioctl(vfio_group_fd, VFIO_GROUP_GET_DEVICE_FD, pci_addr);\n-\tif (vfio_dev_fd < 0) {\n+\t*vfio_dev_fd = ioctl(vfio_group_fd, VFIO_GROUP_GET_DEVICE_FD, pci_addr);\n+\tif (*vfio_dev_fd < 0) {\n \t\t/* if we cannot get a device fd, this simply means that this\n \t\t * particular port is not bound to VFIO\n \t\t */\n@@ -557,14 +537,47 @@ pci_vfio_map_resource(struct rte_pci_device *dev)\n \t}\n \n \t/* test and setup the device */\n-\tret = ioctl(vfio_dev_fd, VFIO_DEVICE_GET_INFO, &device_info);\n+\tret = ioctl(*vfio_dev_fd, VFIO_DEVICE_GET_INFO, device_info);\n \tif (ret) {\n \t\tRTE_LOG(ERR, EAL, \"  %s cannot get device info, \"\n \t\t\t\t\"error %i (%s)\\n\", pci_addr, errno, strerror(errno));\n-\t\tclose(vfio_dev_fd);\n+\t\tclose(*vfio_dev_fd);\n \t\treturn -1;\n \t}\n \n+\treturn 0;\n+}\n+\n+/*\n+ * map the PCI resources of a PCI device in virtual memory (VFIO version).\n+ * primary and secondary processes follow almost exactly the same path\n+ */\n+int\n+pci_vfio_map_resource(struct rte_pci_device *dev)\n+{\n+\tstruct vfio_device_info device_info = { .argsz = sizeof(device_info) };\n+\tchar pci_addr[PATH_MAX] = {0};\n+\tint vfio_dev_fd;\n+\tstruct rte_pci_addr *loc = &dev->addr;\n+\tint i, ret, msix_bar;\n+\tstruct mapped_pci_resource *vfio_res = NULL;\n+\tstruct mapped_pci_res_list *vfio_res_list = RTE_TAILQ_CAST(rte_vfio_tailq.head, mapped_pci_res_list);\n+\n+\tstruct pci_map *maps;\n+\tuint32_t msix_table_offset = 0;\n+\tuint32_t msix_table_size = 0;\n+\tuint32_t ioport_bar;\n+\n+\tdev->intr_handle.fd = -1;\n+\tdev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;\n+\n+\t/* store PCI address string */\n+\tsnprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,\n+\t\t\tloc->domain, loc->bus, loc->devid, loc->function);\n+\n+\tif ((ret = pci_vfio_setup_device(pci_addr, &vfio_dev_fd, &device_info)))\n+\t\treturn ret;\n+\n \t/* get MSI-X BAR, if any (we have to know where it is because we can't\n \t * easily mmap it when using VFIO) */\n \tmsix_bar = -1;\n",
    "prefixes": [
        "dpdk-dev",
        "v2",
        "10/16"
    ]
}