get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 10404,
    "url": "http://patches.dpdk.org/api/patches/10404/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1454694945-18040-5-git-send-email-david.marchand@6wind.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": "<1454694945-18040-5-git-send-email-david.marchand@6wind.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1454694945-18040-5-git-send-email-david.marchand@6wind.com",
    "date": "2016-02-05T17:55:45",
    "name": "[dpdk-dev,4/4] virtio: use ioport api",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "3c2214f6354fd86f240732597be7589d5eb95f7d",
    "submitter": {
        "id": 3,
        "url": "http://patches.dpdk.org/api/people/3/?format=api",
        "name": "David Marchand",
        "email": "david.marchand@6wind.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1454694945-18040-5-git-send-email-david.marchand@6wind.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/10404/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/10404/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 E9230C382;\n\tFri,  5 Feb 2016 18:55:57 +0100 (CET)",
            "from mail-wm0-f51.google.com (mail-wm0-f51.google.com\n\t[74.125.82.51]) by dpdk.org (Postfix) with ESMTP id 9A79BC370\n\tfor <dev@dpdk.org>; Fri,  5 Feb 2016 18:55:55 +0100 (CET)",
            "by mail-wm0-f51.google.com with SMTP id r129so37533098wmr.0\n\tfor <dev@dpdk.org>; Fri, 05 Feb 2016 09:55:55 -0800 (PST)",
            "from gloops.dev.6wind.com (144.77.126.78.rev.sfr.net.\n\t[78.126.77.144]) by smtp.gmail.com with ESMTPSA id\n\tgt7sm16942517wjc.1.2016.02.05.09.55.54\n\t(version=TLSv1/SSLv3 cipher=OTHER);\n\tFri, 05 Feb 2016 09:55:54 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=6wind-com.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=Pz1WwQZ4F0ZT6enn2te3JCnmBGZRhuv4mIxo25WrIkU=;\n\tb=LrFgWFKYTv3trllsm5PwlyPHi+00Wchny/wAgDA9pvAhDxW8HznFgGTMRHJTxsx7Er\n\t7CFQVK7MjDyhTo+VL8KSFu68VYw7LqAzjw7hT6fydUtQZj1Fjh/s/cX5sFMw39wyKbmS\n\tl6/lCCAy0j+GDMAfA7MKPC63iPuMb/ryM+u3LH2oisbXXJdtILPXeLI2YgfunuZ8Ll2O\n\tk+NDu+HuDHAwC+oKThRR8EW6dawccDJJaVi2gPNn0x8lcyPUzJX24X2OLiirClrpCMzT\n\t+dOTYhJSfuSmO1Sx4qccAzY92CAY/Rh1twL3CzElyd4T1Y+QrwHqSL2dP2Th0ORp/b5v\n\tojAw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=Pz1WwQZ4F0ZT6enn2te3JCnmBGZRhuv4mIxo25WrIkU=;\n\tb=WNQsjwJyR/tgvSi08U/rHc5vBh/uvfVR3a9ofy/ceg72p8sBZReRGY0f6CVsonEhak\n\t5BPSoJODSVyzadDTeYhvD/j8vX61iJLUajZ0wDP15A7oUKSkyEKV8f+6w9dNQwBTF+Y2\n\teKavSDFi6186A4Eijvj478Kx2mUOwiAYpOpMr+MG9E3+lwregYSR1UIkJp5SVok2Gn7i\n\tL/9/e3CzQSJ2wjYLL6ELLGlfZAr2QkMYoWqx1ffG5RH69yy2TJzUU6JhzsY9JD5Ul1gJ\n\tIcrbNliKeSUmKiQAZ4eozgxK0jI7ddSFDMHF10qxPChpLS2HuTg3obrvHfpUg9A5jYFf\n\t7U6w==",
        "X-Gm-Message-State": "AG10YOTz7MJAd+VfNBgeZac/tFNQQfAnHAFdtz8JrYHkITzbmHB0IjsytXLsoc5feyg5qo9s",
        "X-Received": "by 10.28.9.67 with SMTP id 64mr38640136wmj.10.1454694955506;\n\tFri, 05 Feb 2016 09:55:55 -0800 (PST)",
        "From": "David Marchand <david.marchand@6wind.com>",
        "To": "dev@dpdk.org",
        "Date": "Fri,  5 Feb 2016 18:55:45 +0100",
        "Message-Id": "<1454694945-18040-5-git-send-email-david.marchand@6wind.com>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1454694945-18040-1-git-send-email-david.marchand@6wind.com>",
        "References": "<1454694945-18040-1-git-send-email-david.marchand@6wind.com>",
        "Subject": "[dpdk-dev] [PATCH 4/4] virtio: use ioport api",
        "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": "Signed-off-by: David Marchand <david.marchand@6wind.com>\n---\n drivers/net/virtio/virtio_pci.c | 339 +++++++---------------------------------\n drivers/net/virtio/virtio_pci.h |  38 +----\n 2 files changed, 55 insertions(+), 322 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c\nindex b1610dd..e04c0db 100644\n--- a/drivers/net/virtio/virtio_pci.c\n+++ b/drivers/net/virtio/virtio_pci.c\n@@ -49,74 +49,35 @@\n #define PCI_CAPABILITY_LIST\t0x34\n #define PCI_CAP_ID_VNDR\t\t0x09\n \n-#define VIRTIO_PCI_REG_ADDR(hw, reg) \\\n-\t(unsigned short)((hw)->io_base + (reg))\n-\n-#define VIRTIO_READ_REG_1(hw, reg) \\\n-\tinb((VIRTIO_PCI_REG_ADDR((hw), (reg))))\n-#define VIRTIO_WRITE_REG_1(hw, reg, value) \\\n-\toutb_p((unsigned char)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg))))\n-\n-#define VIRTIO_READ_REG_2(hw, reg) \\\n-\tinw((VIRTIO_PCI_REG_ADDR((hw), (reg))))\n-#define VIRTIO_WRITE_REG_2(hw, reg, value) \\\n-\toutw_p((unsigned short)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg))))\n-\n-#define VIRTIO_READ_REG_4(hw, reg) \\\n-\tinl((VIRTIO_PCI_REG_ADDR((hw), (reg))))\n-#define VIRTIO_WRITE_REG_4(hw, reg, value) \\\n-\toutl_p((unsigned int)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg))))\n+/*\n+ * The remaining space is defined by each driver as the per-driver\n+ * configuration space.\n+ */\n+#define VIRTIO_PCI_CONFIG(hw) (((hw)->use_msix) ? 24 : 20)\n \n static void\n legacy_read_dev_config(struct virtio_hw *hw, size_t offset,\n \t\t       void *dst, int length)\n {\n-\tuint64_t off;\n-\tuint8_t *d;\n-\tint size;\n-\n-\toff = VIRTIO_PCI_CONFIG(hw) + offset;\n-\tfor (d = dst; length > 0; d += size, off += size, length -= size) {\n-\t\tif (length >= 4) {\n-\t\t\tsize = 4;\n-\t\t\t*(uint32_t *)d = VIRTIO_READ_REG_4(hw, off);\n-\t\t} else if (length >= 2) {\n-\t\t\tsize = 2;\n-\t\t\t*(uint16_t *)d = VIRTIO_READ_REG_2(hw, off);\n-\t\t} else {\n-\t\t\tsize = 1;\n-\t\t\t*d = VIRTIO_READ_REG_1(hw, off);\n-\t\t}\n-\t}\n+\trte_eal_pci_ioport_read(&hw->io, dst, length,\n+\t\t\t\tVIRTIO_PCI_CONFIG(hw) + offset);\n }\n \n static void\n legacy_write_dev_config(struct virtio_hw *hw, size_t offset,\n \t\t\tconst void *src, int length)\n {\n-\tuint64_t off;\n-\tconst uint8_t *s;\n-\tint size;\n-\n-\toff = VIRTIO_PCI_CONFIG(hw) + offset;\n-\tfor (s = src; length > 0; s += size, off += size, length -= size) {\n-\t\tif (length >= 4) {\n-\t\t\tsize = 4;\n-\t\t\tVIRTIO_WRITE_REG_4(hw, off, *(const uint32_t *)s);\n-\t\t} else if (length >= 2) {\n-\t\t\tsize = 2;\n-\t\t\tVIRTIO_WRITE_REG_2(hw, off, *(const uint16_t *)s);\n-\t\t} else {\n-\t\t\tsize = 1;\n-\t\t\tVIRTIO_WRITE_REG_1(hw, off, *s);\n-\t\t}\n-\t}\n+\trte_eal_pci_ioport_write(&hw->io, src, length,\n+\t\t\t\t VIRTIO_PCI_CONFIG(hw) + offset);\n }\n \n static uint64_t\n legacy_get_features(struct virtio_hw *hw)\n {\n-\treturn VIRTIO_READ_REG_4(hw, VIRTIO_PCI_HOST_FEATURES);\n+\tuint64_t dst;\n+\n+\trte_eal_pci_ioport_read(&hw->io, &dst, 4, VIRTIO_PCI_HOST_FEATURES);\n+\treturn dst;\n }\n \n static void\n@@ -127,19 +88,23 @@ legacy_set_features(struct virtio_hw *hw, uint64_t features)\n \t\t\t\"only 32 bit features are allowed for legacy virtio!\");\n \t\treturn;\n \t}\n-\tVIRTIO_WRITE_REG_4(hw, VIRTIO_PCI_GUEST_FEATURES, features);\n+\trte_eal_pci_ioport_write(&hw->io, &features, 4,\n+\t\t\t\t VIRTIO_PCI_GUEST_FEATURES);\n }\n \n static uint8_t\n legacy_get_status(struct virtio_hw *hw)\n {\n-\treturn VIRTIO_READ_REG_1(hw, VIRTIO_PCI_STATUS);\n+\tuint8_t dst;\n+\n+\trte_eal_pci_ioport_read(&hw->io, &dst, 1, VIRTIO_PCI_STATUS);\n+\treturn dst;\n }\n \n static void\n legacy_set_status(struct virtio_hw *hw, uint8_t status)\n {\n-\tVIRTIO_WRITE_REG_1(hw, VIRTIO_PCI_STATUS, status);\n+\trte_eal_pci_ioport_write(&hw->io, &status, 1, VIRTIO_PCI_STATUS);\n }\n \n static void\n@@ -151,148 +116,63 @@ legacy_reset(struct virtio_hw *hw)\n static uint8_t\n legacy_get_isr(struct virtio_hw *hw)\n {\n-\treturn VIRTIO_READ_REG_1(hw, VIRTIO_PCI_ISR);\n+\tuint8_t dst;\n+\n+\trte_eal_pci_ioport_read(&hw->io, &dst, 1, VIRTIO_PCI_ISR);\n+\treturn dst;\n }\n \n /* Enable one vector (0) for Link State Intrerrupt */\n static uint16_t\n legacy_set_config_irq(struct virtio_hw *hw, uint16_t vec)\n {\n-\tVIRTIO_WRITE_REG_2(hw, VIRTIO_MSI_CONFIG_VECTOR, vec);\n-\treturn VIRTIO_READ_REG_2(hw, VIRTIO_MSI_CONFIG_VECTOR);\n+\tuint16_t dst;\n+\n+\trte_eal_pci_ioport_write(&hw->io, &vec, 2, VIRTIO_MSI_CONFIG_VECTOR);\n+\trte_eal_pci_ioport_read(&hw->io, &dst, 2, VIRTIO_MSI_CONFIG_VECTOR);\n+\treturn dst;\n }\n \n static uint16_t\n legacy_get_queue_num(struct virtio_hw *hw, uint16_t queue_id)\n {\n-\tVIRTIO_WRITE_REG_2(hw, VIRTIO_PCI_QUEUE_SEL, queue_id);\n-\treturn VIRTIO_READ_REG_2(hw, VIRTIO_PCI_QUEUE_NUM);\n+\tuint16_t dst;\n+\n+\trte_eal_pci_ioport_write(&hw->io, &queue_id, 2, VIRTIO_PCI_QUEUE_SEL);\n+\trte_eal_pci_ioport_read(&hw->io, &dst, 2, VIRTIO_PCI_QUEUE_NUM);\n+\treturn dst;\n }\n \n static void\n legacy_setup_queue(struct virtio_hw *hw, struct virtqueue *vq)\n {\n-\tVIRTIO_WRITE_REG_2(hw, VIRTIO_PCI_QUEUE_SEL, vq->vq_queue_index);\n+\tuint32_t src;\n \n-\tVIRTIO_WRITE_REG_4(hw, VIRTIO_PCI_QUEUE_PFN,\n-\t\tvq->mz->phys_addr >> VIRTIO_PCI_QUEUE_ADDR_SHIFT);\n+\trte_eal_pci_ioport_write(&hw->io, &vq->vq_queue_index, 2,\n+\t\t\t VIRTIO_PCI_QUEUE_SEL);\n+\tsrc = vq->mz->phys_addr >> VIRTIO_PCI_QUEUE_ADDR_SHIFT;\n+\trte_eal_pci_ioport_write(&hw->io, &src, 4, VIRTIO_PCI_QUEUE_PFN);\n }\n \n static void\n legacy_del_queue(struct virtio_hw *hw, struct virtqueue *vq)\n {\n-\tVIRTIO_WRITE_REG_2(hw, VIRTIO_PCI_QUEUE_SEL, vq->vq_queue_index);\n+\tuint32_t src = 0;\n \n-\tVIRTIO_WRITE_REG_4(hw, VIRTIO_PCI_QUEUE_PFN, 0);\n+\trte_eal_pci_ioport_write(&hw->io, &vq->vq_queue_index, 2,\n+\t\t\t VIRTIO_PCI_QUEUE_SEL);\n+\trte_eal_pci_ioport_write(&hw->io, &src, 4, VIRTIO_PCI_QUEUE_PFN);\n }\n \n static void\n legacy_notify_queue(struct virtio_hw *hw, struct virtqueue *vq)\n {\n-\tVIRTIO_WRITE_REG_2(hw, VIRTIO_PCI_QUEUE_NOTIFY, vq->vq_queue_index);\n+\trte_eal_pci_ioport_write(&hw->io, &vq->vq_queue_index, 2,\n+\t\t\t VIRTIO_PCI_QUEUE_NOTIFY);\n }\n \n #ifdef RTE_EXEC_ENV_LINUXAPP\n static int\n-parse_sysfs_value(const char *filename, unsigned long *val)\n-{\n-\tFILE *f;\n-\tchar buf[BUFSIZ];\n-\tchar *end = NULL;\n-\n-\tf = fopen(filename, \"r\");\n-\tif (f == NULL) {\n-\t\tPMD_INIT_LOG(ERR, \"%s(): cannot open sysfs value %s\",\n-\t\t\t     __func__, filename);\n-\t\treturn -1;\n-\t}\n-\n-\tif (fgets(buf, sizeof(buf), f) == NULL) {\n-\t\tPMD_INIT_LOG(ERR, \"%s(): cannot read sysfs value %s\",\n-\t\t\t     __func__, filename);\n-\t\tfclose(f);\n-\t\treturn -1;\n-\t}\n-\t*val = strtoul(buf, &end, 0);\n-\tif ((buf[0] == '\\0') || (end == NULL) || (*end != '\\n')) {\n-\t\tPMD_INIT_LOG(ERR, \"%s(): cannot parse sysfs value %s\",\n-\t\t\t     __func__, filename);\n-\t\tfclose(f);\n-\t\treturn -1;\n-\t}\n-\tfclose(f);\n-\treturn 0;\n-}\n-\n-static int\n-get_uio_dev(struct rte_pci_addr *loc, char *buf, unsigned int buflen,\n-\t\t\tunsigned int *uio_num)\n-{\n-\tstruct dirent *e;\n-\tDIR *dir;\n-\tchar dirname[PATH_MAX];\n-\n-\t/*\n-\t * depending on kernel version, uio can be located in uio/uioX\n-\t * or uio:uioX\n-\t */\n-\tsnprintf(dirname, sizeof(dirname),\n-\t\t     SYSFS_PCI_DEVICES \"/\" PCI_PRI_FMT \"/uio\",\n-\t\t     loc->domain, loc->bus, loc->devid, loc->function);\n-\tdir = opendir(dirname);\n-\tif (dir == NULL) {\n-\t\t/* retry with the parent directory */\n-\t\tsnprintf(dirname, sizeof(dirname),\n-\t\t\t     SYSFS_PCI_DEVICES \"/\" PCI_PRI_FMT,\n-\t\t\t     loc->domain, loc->bus, loc->devid, loc->function);\n-\t\tdir = opendir(dirname);\n-\n-\t\tif (dir == NULL) {\n-\t\t\tPMD_INIT_LOG(ERR, \"Cannot opendir %s\", dirname);\n-\t\t\treturn -1;\n-\t\t}\n-\t}\n-\n-\t/* take the first file starting with \"uio\" */\n-\twhile ((e = readdir(dir)) != NULL) {\n-\t\t/* format could be uio%d ...*/\n-\t\tint shortprefix_len = sizeof(\"uio\") - 1;\n-\t\t/* ... or uio:uio%d */\n-\t\tint longprefix_len = sizeof(\"uio:uio\") - 1;\n-\t\tchar *endptr;\n-\n-\t\tif (strncmp(e->d_name, \"uio\", 3) != 0)\n-\t\t\tcontinue;\n-\n-\t\t/* first try uio%d */\n-\t\terrno = 0;\n-\t\t*uio_num = strtoull(e->d_name + shortprefix_len, &endptr, 10);\n-\t\tif (errno == 0 && endptr != (e->d_name + shortprefix_len)) {\n-\t\t\tsnprintf(buf, buflen, \"%s/uio%u\", dirname, *uio_num);\n-\t\t\tbreak;\n-\t\t}\n-\n-\t\t/* then try uio:uio%d */\n-\t\terrno = 0;\n-\t\t*uio_num = strtoull(e->d_name + longprefix_len, &endptr, 10);\n-\t\tif (errno == 0 && endptr != (e->d_name + longprefix_len)) {\n-\t\t\tsnprintf(buf, buflen, \"%s/uio:uio%u\", dirname,\n-\t\t\t\t     *uio_num);\n-\t\t\tbreak;\n-\t\t}\n-\t}\n-\tclosedir(dir);\n-\n-\t/* No uio resource found */\n-\tif (e == NULL) {\n-\t\tPMD_INIT_LOG(ERR, \"Could not find uio resource\");\n-\t\treturn -1;\n-\t}\n-\n-\treturn 0;\n-}\n-\n-static int\n legacy_virtio_has_msix(const struct rte_pci_addr *loc)\n {\n \tDIR *d;\n@@ -311,132 +191,20 @@ legacy_virtio_has_msix(const struct rte_pci_addr *loc)\n \n /* Extract I/O port numbers from sysfs */\n static int\n-virtio_resource_init_by_uio(struct rte_pci_device *pci_dev)\n+legacy_virtio_resource_init(struct rte_pci_device *pci_dev,\n+\t\t\t    struct virtio_hw *hw)\n {\n-\tchar dirname[PATH_MAX];\n-\tchar filename[PATH_MAX];\n-\tunsigned long start, size;\n-\tunsigned int uio_num;\n-\n-\tif (get_uio_dev(&pci_dev->addr, dirname, sizeof(dirname), &uio_num) < 0)\n-\t\treturn -1;\n-\n-\t/* get portio size */\n-\tsnprintf(filename, sizeof(filename),\n-\t\t     \"%s/portio/port0/size\", dirname);\n-\tif (parse_sysfs_value(filename, &size) < 0) {\n-\t\tPMD_INIT_LOG(ERR, \"%s(): cannot parse size\",\n-\t\t\t     __func__);\n-\t\treturn -1;\n-\t}\n-\n-\t/* get portio start */\n-\tsnprintf(filename, sizeof(filename),\n-\t\t \"%s/portio/port0/start\", dirname);\n-\tif (parse_sysfs_value(filename, &start) < 0) {\n-\t\tPMD_INIT_LOG(ERR, \"%s(): cannot parse portio start\",\n-\t\t\t     __func__);\n+\tif (rte_eal_pci_ioport_map(pci_dev, 0, &hw->io) < 0)\n \t\treturn -1;\n-\t}\n-\tpci_dev->mem_resource[0].addr = (void *)(uintptr_t)start;\n-\tpci_dev->mem_resource[0].len =  (uint64_t)size;\n-\tPMD_INIT_LOG(DEBUG,\n-\t\t     \"PCI Port IO found start=0x%lx with size=0x%lx\",\n-\t\t     start, size);\n-\n-\t/* save fd */\n-\tmemset(dirname, 0, sizeof(dirname));\n-\tsnprintf(dirname, sizeof(dirname), \"/dev/uio%u\", uio_num);\n-\tpci_dev->intr_handle.fd = open(dirname, O_RDWR);\n-\tif (pci_dev->intr_handle.fd < 0) {\n-\t\tPMD_INIT_LOG(ERR, \"Cannot open %s: %s\\n\",\n-\t\t\tdirname, strerror(errno));\n-\t\treturn -1;\n-\t}\n-\n-\tpci_dev->intr_handle.type = RTE_INTR_HANDLE_UIO;\n-\tpci_dev->driver->drv_flags |= RTE_PCI_DRV_INTR_LSC;\n-\n-\treturn 0;\n-}\n-\n-/* Extract port I/O numbers from proc/ioports */\n-static int\n-virtio_resource_init_by_ioports(struct rte_pci_device *pci_dev)\n-{\n-\tuint16_t start, end;\n-\tint size;\n-\tFILE *fp;\n-\tchar *line = NULL;\n-\tchar pci_id[16];\n-\tint found = 0;\n-\tsize_t linesz;\n-\n-\tsnprintf(pci_id, sizeof(pci_id), PCI_PRI_FMT,\n-\t\t pci_dev->addr.domain,\n-\t\t pci_dev->addr.bus,\n-\t\t pci_dev->addr.devid,\n-\t\t pci_dev->addr.function);\n-\n-\tfp = fopen(\"/proc/ioports\", \"r\");\n-\tif (fp == NULL) {\n-\t\tPMD_INIT_LOG(ERR, \"%s(): can't open ioports\", __func__);\n-\t\treturn -1;\n-\t}\n \n-\twhile (getdelim(&line, &linesz, '\\n', fp) > 0) {\n-\t\tchar *ptr = line;\n-\t\tchar *left;\n-\t\tint n;\n-\n-\t\tn = strcspn(ptr, \":\");\n-\t\tptr[n] = 0;\n-\t\tleft = &ptr[n + 1];\n-\n-\t\twhile (*left && isspace(*left))\n-\t\t\tleft++;\n-\n-\t\tif (!strncmp(left, pci_id, strlen(pci_id))) {\n-\t\t\tfound = 1;\n-\n-\t\t\twhile (*ptr && isspace(*ptr))\n-\t\t\t\tptr++;\n-\n-\t\t\tsscanf(ptr, \"%04hx-%04hx\", &start, &end);\n-\t\t\tsize = end - start + 1;\n-\n-\t\t\tbreak;\n-\t\t}\n-\t}\n-\n-\tfree(line);\n-\tfclose(fp);\n-\n-\tif (!found)\n-\t\treturn -1;\n-\n-\tpci_dev->mem_resource[0].addr = (void *)(uintptr_t)(uint32_t)start;\n-\tpci_dev->mem_resource[0].len =  (uint64_t)size;\n-\tPMD_INIT_LOG(DEBUG,\n-\t\t\"PCI Port IO found start=0x%x with size=0x%x\",\n-\t\tstart, size);\n-\n-\t/* can't support lsc interrupt without uio */\n-\tpci_dev->driver->drv_flags &= ~RTE_PCI_DRV_INTR_LSC;\n+\tif (pci_dev->intr_handle.type != RTE_INTR_HANDLE_UNKNOWN)\n+\t\tpci_dev->driver->drv_flags |= RTE_PCI_DRV_INTR_LSC;\n+\telse\n+\t\tpci_dev->driver->drv_flags &= ~RTE_PCI_DRV_INTR_LSC;\n \n \treturn 0;\n }\n \n-/* Extract I/O port numbers from sysfs */\n-static int\n-legacy_virtio_resource_init(struct rte_pci_device *pci_dev)\n-{\n-\tif (virtio_resource_init_by_uio(pci_dev) == 0)\n-\t\treturn 0;\n-\telse\n-\t\treturn virtio_resource_init_by_ioports(pci_dev);\n-}\n-\n #else\n static int\n legacy_virtio_has_msix(const struct rte_pci_addr *loc __rte_unused)\n@@ -882,12 +650,11 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)\n \t}\n \n \tPMD_INIT_LOG(INFO, \"trying with legacy virtio pci.\");\n-\tif (legacy_virtio_resource_init(dev) < 0)\n+\tif (legacy_virtio_resource_init(dev, hw) < 0)\n \t\treturn -1;\n \n \thw->vtpci_ops = &legacy_ops;\n \thw->use_msix = legacy_virtio_has_msix(&dev->addr);\n-\thw->io_base  = (uint32_t)(uintptr_t)dev->mem_resource[0].addr;\n \thw->modern   = 0;\n \n \treturn 0;\ndiff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h\nindex 0544a07..b69785e 100644\n--- a/drivers/net/virtio/virtio_pci.h\n+++ b/drivers/net/virtio/virtio_pci.h\n@@ -36,13 +36,7 @@\n \n #include <stdint.h>\n \n-#ifdef __FreeBSD__\n-#include <sys/types.h>\n-#include <machine/cpufunc.h>\n-#else\n-#include <sys/io.h>\n-#endif\n-\n+#include <rte_pci.h>\n #include <rte_ethdev.h>\n \n struct virtqueue;\n@@ -249,7 +243,7 @@ struct virtio_net_config;\n \n struct virtio_hw {\n \tstruct virtqueue *cvq;\n-\tuint32_t    io_base;\n+\tstruct rte_pci_ioport io;\n \tuint64_t    guest_features;\n \tuint32_t    max_tx_queues;\n \tuint32_t    max_rx_queues;\n@@ -282,12 +276,6 @@ struct virtio_net_config {\n } __attribute__((packed));\n \n /*\n- * The remaining space is defined by each driver as the per-driver\n- * configuration space.\n- */\n-#define VIRTIO_PCI_CONFIG(hw) (((hw)->use_msix) ? 24 : 20)\n-\n-/*\n  * How many bits to shift physical queue address written to QUEUE_PFN.\n  * 12 is historical, and due to x86 page size.\n  */\n@@ -296,28 +284,6 @@ struct virtio_net_config {\n /* The alignment to use between consumer and producer parts of vring. */\n #define VIRTIO_PCI_VRING_ALIGN 4096\n \n-#ifdef __FreeBSD__\n-\n-static inline void\n-outb_p(unsigned char data, unsigned int port)\n-{\n-\n-\toutb(port, (u_char)data);\n-}\n-\n-static inline void\n-outw_p(unsigned short data, unsigned int port)\n-{\n-\toutw(port, (u_short)data);\n-}\n-\n-static inline void\n-outl_p(unsigned int data, unsigned int port)\n-{\n-\toutl(port, (u_int)data);\n-}\n-#endif\n-\n static inline int\n vtpci_with_feature(struct virtio_hw *hw, uint64_t bit)\n {\n",
    "prefixes": [
        "dpdk-dev",
        "4/4"
    ]
}