get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2209,
    "url": "https://patches.dpdk.org/api/patches/2209/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1420565213-17429-7-git-send-email-rkerur@gmail.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<1420565213-17429-7-git-send-email-rkerur@gmail.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1420565213-17429-7-git-send-email-rkerur@gmail.com",
    "date": "2015-01-06T17:26:53",
    "name": "[dpdk-dev,v4,7/7] Move common functions in eal_pci.c",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "ab29621a23aebae27e995f75506c80de36cccd9c",
    "submitter": {
        "id": 134,
        "url": "https://patches.dpdk.org/api/people/134/?format=api",
        "name": "Ravi Kerur",
        "email": "rkerur@gmail.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1420565213-17429-7-git-send-email-rkerur@gmail.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/2209/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/2209/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 BF79A5A79;\n\tTue,  6 Jan 2015 18:27:28 +0100 (CET)",
            "from mail-pd0-f177.google.com (mail-pd0-f177.google.com\n\t[209.85.192.177]) by dpdk.org (Postfix) with ESMTP id 0334E5A61\n\tfor <dev@dpdk.org>; Tue,  6 Jan 2015 18:27:20 +0100 (CET)",
            "by mail-pd0-f177.google.com with SMTP id ft15so30638835pdb.22\n\tfor <dev@dpdk.org>; Tue, 06 Jan 2015 09:27:19 -0800 (PST)",
            "from iaas-l305162.englab.brocade.com ([144.49.130.148])\n\tby mx.google.com with ESMTPSA id\n\tnl14sm46887340pdb.81.2015.01.06.09.27.18\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tTue, 06 Jan 2015 09:27:18 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=tUrfihxsdbWTygBFqgfCjViUs89xE+9Hhu/cQyc+oqo=;\n\tb=QppSfr1Lh6J7azi+FQGY7C2PNe56ApVRBSWnCGazDgj0xc4uopmLR5Os5ORRuKVPvd\n\tmuiWA5b5445qlfWaIU4CJ45PWOWllnaJ/RAz9v/Y35eOJASCxFR6zSKkxckrvia0rWP5\n\tj9ReQpSdFEmj6NWfep1hHJ+2PrsG6/nOX5Mep3UgoV16rFyimQBTDKHZl0HoKbC2Ipa0\n\t3mKq6aB+7F2jVCxTB+nDI2i2pe3DHpRAOjwivfnkVPEXaZnHiePoimP0S/BezE7jdTut\n\tbJZ7t7iSQzM1L/mPB/DXEvPhLyd27WRb1lSCjF7HVyA6JgxoR+mTtbzkUG2GpQs36mpG\n\tMlzQ==",
        "X-Received": "by 10.68.213.132 with SMTP id\n\tns4mr138755772pbc.148.1420565239289; \n\tTue, 06 Jan 2015 09:27:19 -0800 (PST)",
        "From": "Ravi Kerur <rkerur@gmail.com>",
        "To": "dev@dpdk.org",
        "Date": "Tue,  6 Jan 2015 12:26:53 -0500",
        "Message-Id": "<1420565213-17429-7-git-send-email-rkerur@gmail.com>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1420565213-17429-1-git-send-email-rkerur@gmail.com>",
        "References": "<1420565170-17365-1-git-send-email-rkerur@gmail.com>\n\t<1420565213-17429-1-git-send-email-rkerur@gmail.com>",
        "Subject": "[dpdk-dev] [PATCH v4 7/7] Move common functions in eal_pci.c",
        "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": "Changes in v4\nMove common functions in eal_pci.c to librte_eal/common/\neal_common_pci.c file.\n\nFollowing functions are moved to eal_common_pci.c file.\n\nvoid *pci_map_resource(void *requested_addr, const int vfio_fd,\n      const char *devname, off_t offset, size_t size);\nint pci_addr_comparison(struct rte_pci_addr *addr,\n                        struct rte_pci_addr *addr2);\nint rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr,\n                        struct rte_pci_device *dev);\n\nUse RTE_EXEC_ENV_BSDAPP to differentiate minor differences in\ncommon function.\nFix checkpatch warnings and errors.\n\nChanges in v3\nN/A\n\nChanges in v2\nN/A\n\nChanges in v1\nN/A\n\nSigned-off-by: Ravi Kerur <rkerur@gmail.com>\n---\n lib/librte_eal/bsdapp/eal/eal_pci.c        | 127 +--------------------\n lib/librte_eal/common/eal_common_pci.c     | 171 ++++++++++++++++++++++++++++-\n lib/librte_eal/common/eal_private.h        |  60 ++++++++++\n lib/librte_eal/linuxapp/eal/eal_pci.c      | 113 +------------------\n lib/librte_eal/linuxapp/eal/eal_pci_init.h |   6 -\n lib/librte_eal/linuxapp/eal/eal_pci_uio.c  |  36 ++----\n lib/librte_eal/linuxapp/eal/eal_pci_vfio.c |   9 +-\n 7 files changed, 245 insertions(+), 277 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c\nindex 74ecce7..5c81ea3 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_pci.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c\n@@ -109,7 +109,7 @@ TAILQ_HEAD(uio_res_list, uio_resource);\n static struct uio_res_list *uio_res_list = NULL;\n \n /* unbind kernel driver for this device */\n-static int\n+int\n pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused)\n {\n \tRTE_LOG(ERR, EAL, \"RTE_PCI_DRV_FORCE_UNBIND flag is not implemented \"\n@@ -117,45 +117,6 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused)\n \treturn -ENOTSUP;\n }\n \n-/* map a particular resource from a file */\n-static void *\n-pci_map_resource(void *requested_addr, const char *devname, off_t offset,\n-\t\t size_t size)\n-{\n-\tint fd;\n-\tvoid *mapaddr;\n-\n-\t/*\n-\t * open devname, to mmap it\n-\t */\n-\tfd = open(devname, O_RDWR);\n-\tif (fd < 0) {\n-\t\tRTE_LOG(ERR, EAL, \"Cannot open %s: %s\\n\",\n-\t\t\tdevname, strerror(errno));\n-\t\tgoto fail;\n-\t}\n-\n-\t/* Map the PCI memory resource of device */\n-\tmapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,\n-\t\t\tMAP_SHARED, fd, offset);\n-\tclose(fd);\n-\tif (mapaddr == MAP_FAILED ||\n-\t\t\t(requested_addr != NULL && mapaddr != requested_addr)) {\n-\t\tRTE_LOG(ERR, EAL, \"%s(): cannot mmap(%s(%d), %p, 0x%lx, 0x%lx):\"\n-\t\t\t\" %s (%p)\\n\", __func__, devname, fd, requested_addr,\n-\t\t\t(unsigned long)size, (unsigned long)offset,\n-\t\t\tstrerror(errno), mapaddr);\n-\t\tgoto fail;\n-\t}\n-\n-\tRTE_LOG(DEBUG, EAL, \"  PCI memory mapped at %p\\n\", mapaddr);\n-\n-\treturn mapaddr;\n-\n-fail:\n-\treturn NULL;\n-}\n-\n static int\n pci_uio_map_secondary(struct rte_pci_device *dev)\n {\n@@ -169,7 +130,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)\n \t\t\tcontinue;\n \n \t\tfor (i = 0; i != uio_res->nb_maps; i++) {\n-\t\t\tif (pci_map_resource(uio_res->maps[i].addr,\n+\t\t\tif (pci_map_resource(uio_res->maps[i].addr, INT_MIN,\n \t\t\t\t\t     uio_res->path,\n \t\t\t\t\t     (off_t)uio_res->maps[i].offset,\n \t\t\t\t\t     (size_t)uio_res->maps[i].size)\n@@ -187,7 +148,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)\n }\n \n /* map the PCI resource of a PCI device in virtual memory */\n-static int\n+int\n pci_uio_map_resource(struct rte_pci_device *dev)\n {\n \tint i, j;\n@@ -253,7 +214,8 @@ pci_uio_map_resource(struct rte_pci_device *dev)\n \t\tmaps[j].phaddr = dev->mem_resource[i].phys_addr;\n \t\tmaps[j].size = dev->mem_resource[i].len;\n \t\tif (maps[j].addr != NULL ||\n-\t\t    (mapaddr = pci_map_resource(NULL, devname, (off_t)offset,\n+\t\t    (mapaddr = pci_map_resource(NULL, INT_MIN, devname,\n+\t\t\t\t\t\t(off_t)offset,\n \t\t\t\t\t\t(size_t)maps[j].size)\n \t\t    ) == NULL) {\n \t\t\trte_free(uio_res);\n@@ -270,20 +232,6 @@ pci_uio_map_resource(struct rte_pci_device *dev)\n \treturn (0);\n }\n \n-/* Compare two PCI device addresses. */\n-static int\n-pci_addr_comparison(struct rte_pci_addr *addr, struct rte_pci_addr *addr2)\n-{\n-\tuint64_t dev_addr = (addr->domain << 24) + (addr->bus << 16) + (addr->devid << 8) + addr->function;\n-\tuint64_t dev_addr2 = (addr2->domain << 24) + (addr2->bus << 16) + (addr2->devid << 8) + addr2->function;\n-\n-\tif (dev_addr > dev_addr2)\n-\t\treturn 1;\n-\telse\n-\t\treturn 0;\n-}\n-\n-\n /* Scan one pci sysfs entry, and fill the devices list from it. */\n static int\n pci_scan_one(int dev_pci_fd, struct pci_conf *conf)\n@@ -425,71 +373,6 @@ error:\n \treturn -1;\n }\n \n-/*\n- * If vendor/device ID match, call the devinit() function of the\n- * driver.\n- */\n-int\n-rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dev)\n-{\n-\tstruct rte_pci_id *id_table;\n-\tint ret;\n-\n-\tfor (id_table = dr->id_table ; id_table->vendor_id != 0; id_table++) {\n-\n-\t\t/* check if device's identifiers match the driver's ones */\n-\t\tif (id_table->vendor_id != dev->id.vendor_id &&\n-\t\t\t\tid_table->vendor_id != PCI_ANY_ID)\n-\t\t\tcontinue;\n-\t\tif (id_table->device_id != dev->id.device_id &&\n-\t\t\t\tid_table->device_id != PCI_ANY_ID)\n-\t\t\tcontinue;\n-\t\tif (id_table->subsystem_vendor_id != dev->id.subsystem_vendor_id &&\n-\t\t\t\tid_table->subsystem_vendor_id != PCI_ANY_ID)\n-\t\t\tcontinue;\n-\t\tif (id_table->subsystem_device_id != dev->id.subsystem_device_id &&\n-\t\t\t\tid_table->subsystem_device_id != PCI_ANY_ID)\n-\t\t\tcontinue;\n-\n-\t\tstruct rte_pci_addr *loc = &dev->addr;\n-\n-\t\tRTE_LOG(DEBUG, EAL, \"PCI device \"PCI_PRI_FMT\" on NUMA socket %i\\n\",\n-\t\t\t\tloc->domain, loc->bus, loc->devid, loc->function,\n-\t\t\t\tdev->numa_node);\n-\n-\t\tRTE_LOG(DEBUG, EAL, \"  probe driver: %x:%x %s\\n\", dev->id.vendor_id,\n-\t\t\t\tdev->id.device_id, dr->name);\n-\n-\t\t/* no initialization when blacklisted, return without error */\n-\t\tif (dev->devargs != NULL &&\n-\t\t\tdev->devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {\n-\n-\t\t\tRTE_LOG(DEBUG, EAL, \"  Device is blacklisted, not initializing\\n\");\n-\t\t\treturn 0;\n-\t\t}\n-\n-\t\tif (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {\n-\t\t\t/* map resources for devices that use igb_uio */\n-\t\t\tret = pci_uio_map_resource(dev);\n-\t\t\tif (ret != 0)\n-\t\t\t\treturn ret;\n-\t\t} else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&\n-\t\t           rte_eal_process_type() == RTE_PROC_PRIMARY) {\n-\t\t\t/* unbind current driver */\n-\t\t\tif (pci_unbind_kernel_driver(dev) < 0)\n-\t\t\t\treturn -1;\n-\t\t}\n-\n-\t\t/* reference driver structure */\n-\t\tdev->driver = dr;\n-\n-\t\t/* call the driver devinit() function */\n-\t\treturn dr->devinit(dr, dev);\n-\t}\n-\t/* return positive value if driver is not found */\n-\treturn 1;\n-}\n-\n /* Init the PCI EAL subsystem */\n int\n rte_eal_pci_init(void)\ndiff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c\nindex f3c7f71..e2cdfad 100644\n--- a/lib/librte_eal/common/eal_common_pci.c\n+++ b/lib/librte_eal/common/eal_common_pci.c\n@@ -61,11 +61,15 @@\n  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n  */\n \n-#include <string.h>\n-#include <inttypes.h>\n-#include <stdint.h>\n-#include <stdlib.h>\n #include <stdio.h>\n+#include <stdlib.h>\n+#include <stdint.h>\n+#include <string.h>\n+#include <stdarg.h>\n+#include <unistd.h>\n+#include <sys/file.h>\n+#include <stddef.h>\n+#include <sys/mman.h>\n #include <sys/queue.h>\n \n #include <rte_interrupts.h>\n@@ -154,8 +158,9 @@ rte_eal_pci_probe(void)\n \t\t\tret = pci_probe_all_drivers(dev);\n \t\tif (ret < 0)\n \t\t\trte_exit(EXIT_FAILURE, \"Requested device \" PCI_PRI_FMT\n-\t\t\t\t \" cannot be used\\n\", dev->addr.domain, dev->addr.bus,\n-\t\t\t\t dev->addr.devid, dev->addr.function);\n+\t\t\t\t \" cannot be used\\n\",\n+\t\t\t\tdev->addr.domain, dev->addr.bus,\n+\t\t\t\tdev->addr.devid, dev->addr.function);\n \t}\n \n \treturn 0;\n@@ -205,3 +210,157 @@ rte_eal_pci_unregister(struct rte_pci_driver *driver)\n {\n \tTAILQ_REMOVE(&pci_driver_list, driver, next);\n }\n+\n+/* map a particular resource from a file */\n+void *\n+pci_map_resource(void *requested_addr, const int vfio_fd,\n+\t\tconst char *devname, off_t offset, size_t size)\n+{\n+\tint fd;\n+\tvoid *mapaddr;\n+\n+\t/*\n+\t * For non VFIO environment, vfio_fd is INT_MIN.\n+\t */\n+\tif (vfio_fd == INT_MIN) {\n+\t\t/*\n+\t\t * open devname, to mmap it\n+\t\t */\n+\t\tfd = open(devname, O_RDWR);\n+\t\tif (fd < 0) {\n+\t\t\tRTE_LOG(ERR, EAL, \"Cannot open %s: %s\\n\",\n+\t\t\t\tdevname, strerror(errno));\n+\t\t\tgoto fail;\n+\t\t}\n+\t} else {\n+\t\tfd = vfio_fd;\n+\t}\n+\n+\t/* Map the PCI memory resource of device */\n+\tmapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,\n+\t\t\tMAP_SHARED, fd, offset);\n+\t/*\n+\t * Close applies only for non VFIO.\n+\t */\n+\tif (vfio_fd == INT_MIN)\n+\t\tclose(fd);\n+\n+\tif (mapaddr == MAP_FAILED ||\n+\t\t(requested_addr != NULL && mapaddr != requested_addr)) {\n+\t\tRTE_LOG(ERR, EAL,\n+\t\t\"%s(): cannot mmap(%s(%d), %p, 0x%lx, 0x%lx): %s (%p)\\n\",\n+\t\t__func__, (devname ? devname : \"vfio\"), fd, requested_addr,\n+\t\t(unsigned long)size, (unsigned long)offset,\n+\t\tstrerror(errno), mapaddr);\n+\t\tgoto fail;\n+\t}\n+\n+\tRTE_LOG(DEBUG, EAL, \"  PCI memory mapped at %p\\n\", mapaddr);\n+\n+\treturn mapaddr;\n+\n+fail:\n+\treturn NULL;\n+}\n+\n+/* Compare two PCI device addresses. */\n+int\n+pci_addr_comparison(struct rte_pci_addr *addr,\n+\t\t\tstruct rte_pci_addr *addr2)\n+{\n+\tuint64_t dev_addr = (addr->domain << 24) + (addr->bus << 16) +\n+\t\t\t\t(addr->devid << 8) + addr->function;\n+\tuint64_t dev_addr2 = (addr2->domain << 24) + (addr2->bus << 16) +\n+\t\t\t\t(addr2->devid << 8) + addr2->function;\n+\n+\tif (dev_addr > dev_addr2)\n+\t\treturn 1;\n+\telse\n+\t\treturn 0;\n+}\n+\n+/*\n+ * If vendor/device ID match, call the devinit() function of the\n+ * driver.\n+ */\n+int\n+rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr,\n+\t\t\tstruct rte_pci_device *dev)\n+{\n+\tstruct rte_pci_id *id_table;\n+\tint ret;\n+\n+\tfor (id_table = dr->id_table ; id_table->vendor_id != 0; id_table++) {\n+\n+\t\t/* check if device's identifiers match the driver's ones */\n+\t\tif (id_table->vendor_id != dev->id.vendor_id &&\n+\t\t\t\tid_table->vendor_id != PCI_ANY_ID)\n+\t\t\tcontinue;\n+\t\tif (id_table->device_id != dev->id.device_id &&\n+\t\t\t\tid_table->device_id != PCI_ANY_ID)\n+\t\t\tcontinue;\n+\t\tif (id_table->subsystem_vendor_id !=\n+\t\t\t\tdev->id.subsystem_vendor_id &&\n+\t\t\t\tid_table->subsystem_vendor_id != PCI_ANY_ID)\n+\t\t\tcontinue;\n+\t\tif (id_table->subsystem_device_id !=\n+\t\t\t\tdev->id.subsystem_device_id &&\n+\t\t\t\tid_table->subsystem_device_id != PCI_ANY_ID)\n+\t\t\tcontinue;\n+\n+\t\tstruct rte_pci_addr *loc = &dev->addr;\n+\n+\t\tRTE_LOG(DEBUG, EAL,\n+\t\t\t\"PCI device \"PCI_PRI_FMT\" on NUMA socket %i\\n\",\n+\t\t\tloc->domain, loc->bus, loc->devid, loc->function,\n+\t\t\tdev->numa_node);\n+\n+\t\tRTE_LOG(DEBUG, EAL,\n+\t\t\t\"  probe driver: %x:%x %s\\n\", dev->id.vendor_id,\n+\t\t\tdev->id.device_id, dr->name);\n+\n+\t\t/* no initialization when blacklisted, return without error */\n+\t\tif (dev->devargs != NULL &&\n+\t\t\tdev->devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {\n+\n+\t\t\tRTE_LOG(DEBUG, EAL,\n+\t\t\t\t\"  Device is blacklisted, not initializing\\n\");\n+\t\t\treturn 0;\n+\t\t}\n+\n+\t\tif (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {\n+\n+#ifdef RTE_EXEC_ENV_BSDAPP\n+\t\t\t/* map resources for devices that use igb_uio */\n+\t\t\tret = pci_uio_map_resource(dev);\n+#else /* RTE_EXEC_ENV_BSDAPP */\n+#ifdef RTE_PCI_CONFIG\n+\t\t\t/*\n+\t\t\t * Set PCIe config space for high performance.\n+\t\t\t * Return value can be ignored.\n+\t\t\t */\n+\t\t\tpci_config_space_set(dev);\n+#endif /* RTE_PCI_CONFIG */\n+\t\t\t/* map resources for devices that use igb_uio */\n+\t\t\tret = pci_map_device(dev);\n+\n+#endif /* RTE_EXEC_ENV_BSDAPP */\n+\n+\t\t\tif (ret != 0)\n+\t\t\t\treturn ret;\n+\t\t} else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&\n+\t\t\trte_eal_process_type() == RTE_PROC_PRIMARY) {\n+\t\t\t/* unbind current driver */\n+\t\t\tif (pci_unbind_kernel_driver(dev) < 0)\n+\t\t\t\treturn -1;\n+\t\t}\n+\n+\t\t/* reference driver structure */\n+\t\tdev->driver = dr;\n+\n+\t\t/* call the driver devinit() function */\n+\t\treturn dr->devinit(dr, dev);\n+\t}\n+\t/* return positive value if driver is not found */\n+\treturn 1;\n+}\ndiff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h\nindex 71ba5fd..64edbe0 100644\n--- a/lib/librte_eal/common/eal_private.h\n+++ b/lib/librte_eal/common/eal_private.h\n@@ -37,6 +37,7 @@\n #include <stdio.h>\n \n #include <rte_eal.h>\n+#include <rte_pci.h>\n \n /**\n  * Initialize the memzone subsystem (private to eal).\n@@ -348,4 +349,63 @@ int rte_eal_hugepage_init(void);\n  */\n int rte_eal_hugepage_attach(void);\n \n+/**\n+ * This function maps a particular resource from a file\n+ *\n+ * This function is private to the EAL.\n+ */\n+void *\n+pci_map_resource(void *requested_addr, const int vfio_fd,\n+\t\tconst char *devname, off_t offset, size_t size);\n+\n+/**\n+ * This function compares two PCI device addresses\n+ *\n+ * This function is private to the EAL.\n+ */\n+int\n+pci_addr_comparison(struct rte_pci_addr *addr,\n+\t\tstruct rte_pci_addr *addr2);\n+\n+/**\n+ * This function maps PCI resource of a PCI\n+ * device in virtual memory\n+ *\n+ * This function is private to the EAL.\n+ */\n+int\n+pci_uio_map_resource(struct rte_pci_device *dev);\n+\n+/**\n+ * This function unbinds kernel driver for this device\n+ *\n+ * This function is private to the EAL.\n+ */\n+int\n+pci_unbind_kernel_driver(struct rte_pci_device *dev);\n+\n+#ifdef RTE_EXEC_ENV_LINUXAPP\n+#ifdef RTE_PCI_CONFIG\n+/**\n+ * This function sets PCIe config space for\n+ * high performance\n+ *\n+ * This function is private to the EAL.\n+ */\n+void\n+pci_config_space_set(struct rte_pci_device *dev);\n+\n+#endif /* RTE_PCI_CONFIG */\n+\n+/**\n+ * This function maps resources for devices\n+ *  that use igb_uio\n+ *\n+ * This function is private to the EAL.\n+ */\n+int\n+pci_map_device(struct rte_pci_device *dev);\n+\n+#endif /* RTE_EXEC_ENV_LINUXAPP */\n+\n #endif /* _EAL_PRIVATE_H_ */\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c\nindex b5f5410..6e4d856 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c\n@@ -59,7 +59,7 @@\n struct mapped_pci_res_list *pci_res_list = NULL;\n \n /* unbind kernel driver for this device */\n-static int\n+int\n pci_unbind_kernel_driver(struct rte_pci_device *dev)\n {\n \tint n;\n@@ -115,28 +115,6 @@ pci_find_max_end_va(void)\n \treturn RTE_PTR_ADD(last->addr, last->len);\n }\n \n-\n-/* map a particular resource from a file */\n-void *\n-pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size)\n-{\n-\tvoid *mapaddr;\n-\n-\t/* Map the PCI memory resource of device */\n-\tmapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE,\n-\t\t\tMAP_SHARED, fd, offset);\n-\tif (mapaddr == MAP_FAILED) {\n-\t\tRTE_LOG(ERR, EAL, \"%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s (%p)\\n\",\n-\t\t\t__func__, fd, requested_addr,\n-\t\t\t(unsigned long)size, (unsigned long)offset,\n-\t\t\tstrerror(errno), mapaddr);\n-\t} else {\n-\t\tRTE_LOG(DEBUG, EAL, \"  PCI memory mapped at %p\\n\", mapaddr);\n-\t}\n-\n-\treturn mapaddr;\n-}\n-\n /* parse the \"resource\" sysfs file */\n #define IORESOURCE_MEM  0x00000200\n \n@@ -200,20 +178,6 @@ error:\n \treturn -1;\n }\n \n-/* Compare two PCI device addresses. */\n-static int\n-pci_addr_comparison(struct rte_pci_addr *addr, struct rte_pci_addr *addr2)\n-{\n-\tuint64_t dev_addr = (addr->domain << 24) + (addr->bus << 16) + (addr->devid << 8) + addr->function;\n-\tuint64_t dev_addr2 = (addr2->domain << 24) + (addr2->bus << 16) + (addr2->devid << 8) + addr2->function;\n-\n-\tif (dev_addr > dev_addr2)\n-\t\treturn 1;\n-\telse\n-\t\treturn 0;\n-}\n-\n-\n /* Scan one pci sysfs entry, and fill the devices list from it. */\n static int\n pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,\n@@ -483,7 +447,7 @@ pci_config_max_read_request_size(struct rte_pci_device *dev)\n \treturn 0;\n }\n \n-static void\n+void\n pci_config_space_set(struct rte_pci_device *dev)\n {\n \tif (rte_eal_process_type() != RTE_PROC_PRIMARY)\n@@ -497,7 +461,7 @@ pci_config_space_set(struct rte_pci_device *dev)\n }\n #endif\n \n-static int\n+int\n pci_map_device(struct rte_pci_device *dev)\n {\n \tint ret, mapped = 0;\n@@ -521,77 +485,6 @@ pci_map_device(struct rte_pci_device *dev)\n \treturn 0;\n }\n \n-/*\n- * If vendor/device ID match, call the devinit() function of the\n- * driver.\n- */\n-int\n-rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dev)\n-{\n-\tint ret;\n-\tstruct rte_pci_id *id_table;\n-\n-\tfor (id_table = dr->id_table ; id_table->vendor_id != 0; id_table++) {\n-\n-\t\t/* check if device's identifiers match the driver's ones */\n-\t\tif (id_table->vendor_id != dev->id.vendor_id &&\n-\t\t\t\tid_table->vendor_id != PCI_ANY_ID)\n-\t\t\tcontinue;\n-\t\tif (id_table->device_id != dev->id.device_id &&\n-\t\t\t\tid_table->device_id != PCI_ANY_ID)\n-\t\t\tcontinue;\n-\t\tif (id_table->subsystem_vendor_id != dev->id.subsystem_vendor_id &&\n-\t\t\t\tid_table->subsystem_vendor_id != PCI_ANY_ID)\n-\t\t\tcontinue;\n-\t\tif (id_table->subsystem_device_id != dev->id.subsystem_device_id &&\n-\t\t\t\tid_table->subsystem_device_id != PCI_ANY_ID)\n-\t\t\tcontinue;\n-\n-\t\tstruct rte_pci_addr *loc = &dev->addr;\n-\n-\t\tRTE_LOG(DEBUG, EAL, \"PCI device \"PCI_PRI_FMT\" on NUMA socket %i\\n\",\n-\t\t\t\tloc->domain, loc->bus, loc->devid, loc->function,\n-\t\t\t\tdev->numa_node);\n-\n-\t\tRTE_LOG(DEBUG, EAL, \"  probe driver: %x:%x %s\\n\", dev->id.vendor_id,\n-\t\t\t\tdev->id.device_id, dr->name);\n-\n-\t\t/* no initialization when blacklisted, return without error */\n-\t\tif (dev->devargs != NULL &&\n-\t\t\tdev->devargs->type == RTE_DEVTYPE_BLACKLISTED_PCI) {\n-\t\t\tRTE_LOG(DEBUG, EAL, \"  Device is blacklisted, not initializing\\n\");\n-\t\t\treturn 1;\n-\t\t}\n-\n-\t\tif (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {\n-#ifdef RTE_PCI_CONFIG\n-\t\t\t/*\n-\t\t\t * Set PCIe config space for high performance.\n-\t\t\t * Return value can be ignored.\n-\t\t\t */\n-\t\t\tpci_config_space_set(dev);\n-#endif\n-\t\t\t/* map resources for devices that use igb_uio */\n-\t\t\tret = pci_map_device(dev);\n-\t\t\tif (ret != 0)\n-\t\t\t\treturn ret;\n-\t\t} else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&\n-\t\t           rte_eal_process_type() == RTE_PROC_PRIMARY) {\n-\t\t\t/* unbind current driver */\n-\t\t\tif (pci_unbind_kernel_driver(dev) < 0)\n-\t\t\t\treturn -1;\n-\t\t}\n-\n-\t\t/* reference driver structure */\n-\t\tdev->driver = dr;\n-\n-\t\t/* call the driver devinit() function */\n-\t\treturn dr->devinit(dr, dev);\n-\t}\n-\t/* return positive value if driver is not found */\n-\treturn 1;\n-}\n-\n /* Init the PCI EAL subsystem */\n int\n rte_eal_pci_init(void)\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci_init.h b/lib/librte_eal/linuxapp/eal/eal_pci_init.h\nindex 1070eb8..8d0dea8 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci_init.h\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci_init.h\n@@ -65,12 +65,6 @@ extern struct mapped_pci_res_list *pci_res_list;\n extern void *pci_map_addr;\n void *pci_find_max_end_va(void);\n \n-void *pci_map_resource(void *requested_addr, int fd, off_t offset,\n-\t\tsize_t size);\n-\n-/* map IGB_UIO resource prototype */\n-int pci_uio_map_resource(struct rte_pci_device *dev);\n-\n #ifdef VFIO_PRESENT\n \n #define VFIO_MAX_GROUPS 64\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\nindex e53f06b..893b650 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c\n@@ -46,6 +46,7 @@\n #include \"rte_pci_dev_ids.h\"\n #include \"eal_filesystem.h\"\n #include \"eal_pci_init.h\"\n+#include \"eal_private.h\"\n \n static int pci_parse_sysfs_value(const char *filename, uint64_t *val);\n \n@@ -117,7 +118,7 @@ pci_uio_get_mappings(const char *devname, struct pci_map maps[], int nb_maps)\n static int\n pci_uio_map_secondary(struct rte_pci_device *dev)\n {\n-\tint fd, i;\n+\tint i;\n \tstruct mapped_pci_resource *uio_res;\n \n \tTAILQ_FOREACH(uio_res, pci_res_list, next) {\n@@ -127,27 +128,15 @@ pci_uio_map_secondary(struct rte_pci_device *dev)\n \t\t\tcontinue;\n \n \t\tfor (i = 0; i != uio_res->nb_maps; i++) {\n-\t\t\t/*\n-\t\t\t * open devname, to mmap it\n-\t\t\t */\n-\t\t\tfd = open(uio_res->path, O_RDWR);\n-\t\t\tif (fd < 0) {\n-\t\t\t\tRTE_LOG(ERR, EAL, \"Cannot open %s: %s\\n\",\n-\t\t\t\t\tuio_res->path, strerror(errno));\n-\t\t\t\treturn -1;\n-\t\t\t}\n-\n-\t\t\tif (pci_map_resource(uio_res->maps[i].addr, fd,\n+\t\t\tif (pci_map_resource(uio_res->maps[i].addr, INT_MIN,\n+\t\t\t\t\t     uio_res->path,\n \t\t\t\t\t     (off_t)uio_res->maps[i].offset,\n \t\t\t\t\t     (size_t)uio_res->maps[i].size)\n \t\t\t    != uio_res->maps[i].addr) {\n \t\t\t\tRTE_LOG(ERR, EAL,\n \t\t\t\t\t\"Cannot mmap device resource\\n\");\n-\t\t\t\tclose(fd);\n \t\t\t\treturn -1;\n \t\t\t}\n-\t\t\t/* fd is not needed in slave process, close it */\n-\t\t\tclose(fd);\n \t\t}\n \t\treturn 0;\n \t}\n@@ -344,7 +333,6 @@ pci_uio_map_resource(struct rte_pci_device *dev)\n \n \tmaps = uio_res->maps;\n \tfor (i = 0; i != PCI_MAX_RESOURCE; i++) {\n-\t\tint fd;\n \n \t\t/* skip empty BAR */\n \t\tphaddr = dev->mem_resource[i].phys_addr;\n@@ -361,16 +349,6 @@ pci_uio_map_resource(struct rte_pci_device *dev)\n \t\t\tint fail = 0;\n \t\t\toffset = j * pagesz;\n \n-\t\t\t/*\n-\t\t\t * open devname, to mmap it\n-\t\t\t */\n-\t\t\tfd = open(devname, O_RDWR);\n-\t\t\tif (fd < 0) {\n-\t\t\t\tRTE_LOG(ERR, EAL, \"Cannot open %s: %s\\n\",\n-\t\t\t\t\tdevname, strerror(errno));\n-\t\t\t\treturn -1;\n-\t\t\t}\n-\n \t\t\tif (maps[j].addr != NULL)\n \t\t\t\tfail = 1;\n \t\t\telse {\n@@ -378,7 +356,9 @@ pci_uio_map_resource(struct rte_pci_device *dev)\n \t\t\t\tif (pci_map_addr == NULL)\n \t\t\t\t\tpci_map_addr = pci_find_max_end_va();\n \n-\t\t\t\tmapaddr = pci_map_resource(pci_map_addr, fd, (off_t)offset,\n+\t\t\t\tmapaddr = pci_map_resource(pci_map_addr,\n+\t\t\t\t\t\tINT_MIN, devname,\n+\t\t\t\t\t\t(off_t)offset,\n \t\t\t\t\t\t(size_t)maps[j].size);\n \t\t\t\tif (mapaddr == MAP_FAILED)\n \t\t\t\t\tfail = 1;\n@@ -388,10 +368,8 @@ pci_uio_map_resource(struct rte_pci_device *dev)\n \n \t\t\tif (fail) {\n \t\t\t\trte_free(uio_res);\n-\t\t\t\tclose(fd);\n \t\t\t\treturn -1;\n \t\t\t}\n-\t\t\tclose(fd);\n \n \t\t\tmaps[j].addr = mapaddr;\n \t\t\tmaps[j].offset = offset;\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c\nindex c1246e8..a29fdd9 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c\n@@ -48,6 +48,7 @@\n #include \"eal_filesystem.h\"\n #include \"eal_pci_init.h\"\n #include \"eal_vfio.h\"\n+#include \"eal_private.h\"\n \n /**\n  * @file\n@@ -726,12 +727,12 @@ pci_vfio_map_resource(struct rte_pci_device *dev)\n \t\t\tif (pci_map_addr == NULL)\n \t\t\t\tpci_map_addr = pci_find_max_end_va();\n \n-\t\t\tbar_addr = pci_map_resource(pci_map_addr, vfio_dev_fd, reg.offset,\n-\t\t\t\t\treg.size);\n+\t\t\tbar_addr = pci_map_resource(pci_map_addr, vfio_dev_fd,\n+\t\t\t\t\tNULL, reg.offset, reg.size);\n \t\t\tpci_map_addr = RTE_PTR_ADD(bar_addr, (size_t) reg.size);\n \t\t} else {\n-\t\t\tbar_addr = pci_map_resource(maps[i].addr, vfio_dev_fd, reg.offset,\n-\t\t\t\t\treg.size);\n+\t\t\tbar_addr = pci_map_resource(maps[i].addr, vfio_dev_fd,\n+\t\t\t\t\tNULL, reg.offset, reg.size);\n \t\t}\n \n \t\tif (bar_addr == MAP_FAILED ||\n",
    "prefixes": [
        "dpdk-dev",
        "v4",
        "7/7"
    ]
}