get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 58224,
    "url": "http://patches.dpdk.org/api/patches/58224/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190829080000.20806-7-maxime.coquelin@redhat.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": "<20190829080000.20806-7-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190829080000.20806-7-maxime.coquelin@redhat.com",
    "date": "2019-08-29T07:59:51",
    "name": "[06/15] net/virtio: add skeleton for virtio vDPA driver",
    "commit_ref": null,
    "pull_url": null,
    "state": "rejected",
    "archived": true,
    "hash": "1786bcdf48da54314bee729dfd413da892d15ef9",
    "submitter": {
        "id": 512,
        "url": "http://patches.dpdk.org/api/people/512/?format=api",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190829080000.20806-7-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 6163,
            "url": "http://patches.dpdk.org/api/series/6163/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=6163",
            "date": "2019-08-29T07:59:45",
            "name": "Introduce Virtio vDPA driver",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/6163/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/58224/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/58224/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 78B421D452;\n\tThu, 29 Aug 2019 10:00:40 +0200 (CEST)",
            "from mx1.redhat.com (mx1.redhat.com [209.132.183.28])\n\tby dpdk.org (Postfix) with ESMTP id 039611D452;\n\tThu, 29 Aug 2019 10:00:39 +0200 (CEST)",
            "from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 624DA308123B;\n\tThu, 29 Aug 2019 08:00:38 +0000 (UTC)",
            "from localhost.localdomain (ovpn-112-52.ams2.redhat.com\n\t[10.36.112.52])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id D7E6E5D6B2;\n\tThu, 29 Aug 2019 08:00:33 +0000 (UTC)"
        ],
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "tiwei.bie@intel.com, zhihong.wang@intel.com, amorenoz@redhat.com,\n\txiao.w.wang@intel.com, dev@dpdk.org, jfreimann@redhat.com",
        "Cc": "stable@dpdk.org,\n\tMaxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Thu, 29 Aug 2019 09:59:51 +0200",
        "Message-Id": "<20190829080000.20806-7-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20190829080000.20806-1-maxime.coquelin@redhat.com>",
        "References": "<20190829080000.20806-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.15",
        "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.49]); Thu, 29 Aug 2019 08:00:38 +0000 (UTC)",
        "Subject": "[dpdk-dev] [PATCH 06/15] net/virtio: add skeleton for virtio vDPA\n\tdriver",
        "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 adds the base for the Virtio vDPA driver.\nThis driver can be used either for development purpose, when\nprobed with a para-virtualized Virtio device from a guest, or\nit can be used with real HW supporting full Virtio offload\n(both data and control paths).\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n config/common_linux              |   1 +\n drivers/net/virtio/Makefile      |   4 +\n drivers/net/virtio/meson.build   |   3 +-\n drivers/net/virtio/virtio_vdpa.c | 301 +++++++++++++++++++++++++++++++\n 4 files changed, 308 insertions(+), 1 deletion(-)\n create mode 100644 drivers/net/virtio/virtio_vdpa.c",
    "diff": "diff --git a/config/common_linux b/config/common_linux\nindex 6e252553a..293a8ff48 100644\n--- a/config/common_linux\n+++ b/config/common_linux\n@@ -27,6 +27,7 @@ CONFIG_RTE_LIBRTE_VDEV_NETVSC_PMD=y\n CONFIG_RTE_LIBRTE_NFP_PMD=y\n CONFIG_RTE_LIBRTE_POWER=y\n CONFIG_RTE_VIRTIO_USER=y\n+CONFIG_RTE_VIRTIO_VDPA=y\n CONFIG_RTE_PROC_INFO=y\n \n CONFIG_RTE_LIBRTE_VMBUS=y\ndiff --git a/drivers/net/virtio/Makefile b/drivers/net/virtio/Makefile\nindex 6c2c9967b..0760074ad 100644\n--- a/drivers/net/virtio/Makefile\n+++ b/drivers/net/virtio/Makefile\n@@ -45,4 +45,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_user/virtio_user_dev.c\n SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_user_ethdev.c\n endif\n \n+ifeq ($(CONFIG_RTE_VIRTIO_VDPA),y)\n+SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_vdpa.c\n+endif\n+\n include $(RTE_SDK)/mk/rte.lib.mk\ndiff --git a/drivers/net/virtio/meson.build b/drivers/net/virtio/meson.build\nindex 794905401..f5f1f6e68 100644\n--- a/drivers/net/virtio/meson.build\n+++ b/drivers/net/virtio/meson.build\n@@ -6,8 +6,9 @@ sources += files('virtio_ethdev.c',\n \t'virtio_pci.c',\n \t'virtio_rxtx.c',\n \t'virtio_rxtx_simple.c',\n+\t'virtio_vdpa.c',\n \t'virtqueue.c')\n-deps += ['kvargs', 'bus_pci']\n+deps += ['kvargs', 'bus_pci', 'vhost']\n \n if arch_subdir == 'x86'\n \tsources += files('virtio_rxtx_simple_sse.c')\ndiff --git a/drivers/net/virtio/virtio_vdpa.c b/drivers/net/virtio/virtio_vdpa.c\nnew file mode 100644\nindex 000000000..bbb417b94\n--- /dev/null\n+++ b/drivers/net/virtio/virtio_vdpa.c\n@@ -0,0 +1,301 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2017 Intel Corporation\n+ * Copyright(c) 2019 Red Hat, Inc.\n+ */\n+\n+#include <unistd.h>\n+#include <sys/ioctl.h>\n+\n+#include <rte_kvargs.h>\n+#include <rte_malloc.h>\n+#include <rte_vdpa.h>\n+#include <rte_vfio.h>\n+#include <rte_vhost.h>\n+\n+#include \"virtio_pci.h\"\n+#include \"virtqueue.h\"\n+\n+#ifndef PAGE_SIZE\n+#define PAGE_SIZE 4096\n+#endif\n+\n+#define DRV_LOG(level, fmt, args...) \\\n+\trte_log(RTE_LOG_ ## level, virtio_vdpa_logtype, \\\n+\t\t\"VIRTIO_VDPA %s(): \" fmt \"\\n\", __func__, ##args)\n+\n+#define VIRTIO_VDPA_MODE\t\t\"vdpa\"\n+\n+static const char * const virtio_vdpa_valid_arguments[] = {\n+\tVIRTIO_VDPA_MODE,\n+\tNULL\n+};\n+\n+static int virtio_vdpa_logtype;\n+\n+struct virtio_vdpa_device {\n+\tstruct rte_vdpa_dev_addr dev_addr;\n+\tstruct rte_pci_device *pdev;\n+\tstruct virtio_hw hw;\n+\tint vfio_container_fd;\n+\tint vfio_group_fd;\n+\tint vfio_dev_fd;\n+\tint iommu_group_num;\n+\tint vid;\n+\tint did;\n+\tuint16_t max_queue_pairs;\n+\tbool has_ctrl_vq;\n+\tstruct virtqueue *vqs;\n+\tstruct virtqueue *cvq;\n+\trte_spinlock_t lock;\n+};\n+\n+struct internal_list {\n+\tTAILQ_ENTRY(internal_list) next;\n+\tstruct virtio_vdpa_device *dev;\n+};\n+\n+TAILQ_HEAD(internal_list_head, internal_list);\n+static struct internal_list_head internal_list =\n+\tTAILQ_HEAD_INITIALIZER(internal_list);\n+\n+static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;\n+\n+static struct internal_list *\n+find_internal_resource_by_dev(struct rte_pci_device *pdev)\n+{\n+\tint found = 0;\n+\tstruct internal_list *list;\n+\n+\tpthread_mutex_lock(&internal_list_lock);\n+\n+\tTAILQ_FOREACH(list, &internal_list, next) {\n+\t\tif (pdev == list->dev->pdev) {\n+\t\t\tfound = 1;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\tpthread_mutex_unlock(&internal_list_lock);\n+\n+\tif (!found)\n+\t\treturn NULL;\n+\n+\treturn list;\n+}\n+\n+static int\n+virtio_vdpa_vfio_setup(struct virtio_vdpa_device *dev)\n+{\n+\tstruct rte_pci_device *pdev = dev->pdev;\n+\tchar devname[RTE_DEV_NAME_MAX_LEN] = {0};\n+\tint iommu_group_num;\n+\n+\tdev->vfio_dev_fd = -1;\n+\tdev->vfio_group_fd = -1;\n+\tdev->vfio_container_fd = -1;\n+\tdev->iommu_group_num = -1;\n+\n+\trte_pci_device_name(&pdev->addr, devname, RTE_DEV_NAME_MAX_LEN);\n+\trte_vfio_get_group_num(rte_pci_get_sysfs_path(), devname,\n+\t\t\t&iommu_group_num);\n+\n+\tdev->vfio_container_fd = rte_vfio_container_create();\n+\tif (dev->vfio_container_fd < 0)\n+\t\treturn -1;\n+\n+\tdev->vfio_group_fd =\n+\t\trte_vfio_container_group_bind(dev->vfio_container_fd,\n+\t\t\tiommu_group_num);\n+\tif (dev->vfio_group_fd < 0)\n+\t\tgoto err_container_destroy;\n+\n+\tif (rte_pci_map_device(pdev))\n+\t\tgoto err_container_unbind;\n+\n+\tdev->vfio_dev_fd = pdev->intr_handle.vfio_dev_fd;\n+\tdev->iommu_group_num = iommu_group_num;\n+\n+\treturn 0;\n+\n+err_container_unbind:\n+\trte_vfio_container_group_unbind(dev->vfio_container_fd,\n+\t\t\tiommu_group_num);\n+err_container_destroy:\n+\trte_vfio_container_destroy(dev->vfio_container_fd);\n+\n+\tdev->vfio_dev_fd = -1;\n+\tdev->vfio_group_fd = -1;\n+\tdev->vfio_container_fd = -1;\n+\tdev->iommu_group_num = -1;\n+\n+\treturn -1;\n+}\n+\n+static struct rte_vdpa_dev_ops virtio_vdpa_ops = {\n+};\n+\n+static inline int\n+open_int(const char *key __rte_unused, const char *value, void *extra_args)\n+{\n+\tuint16_t *n = extra_args;\n+\n+\tif (value == NULL || extra_args == NULL)\n+\t\treturn -EINVAL;\n+\n+\t*n = (uint16_t)strtoul(value, NULL, 0);\n+\tif (*n == USHRT_MAX && errno == ERANGE)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+static int\n+virtio_vdpa_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n+\t\tstruct rte_pci_device *pci_dev)\n+{\n+\tstruct virtio_vdpa_device *dev;\n+\tstruct internal_list *list = NULL;\n+\tstruct rte_kvargs *kvlist = NULL;\n+\tint ret, vdpa_mode = 0;\n+\n+\tif (rte_eal_process_type() != RTE_PROC_PRIMARY)\n+\t\treturn 0;\n+\n+\tif (!pci_dev->device.devargs)\n+\t\treturn -1;\n+\n+\tkvlist = rte_kvargs_parse(pci_dev->device.devargs->args,\n+\t\t\tvirtio_vdpa_valid_arguments);\n+\tif (kvlist == NULL)\n+\t\treturn -1;\n+\n+\t/* probe only when vdpa mode is specified */\n+\tif (rte_kvargs_count(kvlist, VIRTIO_VDPA_MODE) == 0)\n+\t\tgoto err_free_kvargs;\n+\n+\tret = rte_kvargs_process(kvlist, VIRTIO_VDPA_MODE, &open_int,\n+\t\t\t&vdpa_mode);\n+\tif (ret < 0 || vdpa_mode == 0)\n+\t\tgoto err_free_kvargs;\n+\n+\tlist = rte_zmalloc(\"virtio_vdpa\", sizeof(*list), 0);\n+\tif (list == NULL)\n+\t\tgoto err_free_kvargs;\n+\n+\tdev = rte_zmalloc(\"virtio_vdpa\", sizeof(*dev), 0);\n+\tif (!dev)\n+\t\tgoto err_free_list;\n+\n+\tdev->pdev = pci_dev;\n+\trte_spinlock_init(&dev->lock);\n+\n+\tif (virtio_vdpa_vfio_setup(dev) < 0) {\n+\t\tDRV_LOG(ERR, \"failed to setup device %s\", pci_dev->name);\n+\t\tgoto err_free_vvdev;\n+\t}\n+\n+\tdev->dev_addr.pci_addr = pci_dev->addr;\n+\tdev->dev_addr.type = PCI_ADDR;\n+\tdev->max_queue_pairs = 1;\n+\tlist->dev = dev;\n+\n+\tif (vtpci_init(pci_dev, &dev->hw))\n+\t\tgoto err_free_vfio;\n+\n+\tdev->did = rte_vdpa_register_device(&dev->dev_addr,\n+\t\t\t\t&virtio_vdpa_ops);\n+\n+\tif (dev->did < 0) {\n+\t\tDRV_LOG(ERR, \"failed to register device %s\", pci_dev->name);\n+\t\tgoto err_free_vfio;\n+\t}\n+\n+\tpthread_mutex_lock(&internal_list_lock);\n+\tTAILQ_INSERT_TAIL(&internal_list, list, next);\n+\tpthread_mutex_unlock(&internal_list_lock);\n+\n+\trte_kvargs_free(kvlist);\n+\n+\treturn 0;\n+\n+err_free_vfio:\n+\trte_vfio_container_destroy(dev->vfio_container_fd);\n+err_free_vvdev:\n+\trte_free(dev);\n+err_free_list:\n+\trte_free(list);\n+err_free_kvargs:\n+\trte_kvargs_free(kvlist);\n+\n+\treturn 1;\n+}\n+\n+static int\n+virtio_vdpa_pci_remove(struct rte_pci_device *pci_dev)\n+{\n+\tstruct virtio_vdpa_device *dev;\n+\tstruct internal_list *list;\n+\n+\tif (rte_eal_process_type() != RTE_PROC_PRIMARY)\n+\t\treturn 0;\n+\n+\tlist = find_internal_resource_by_dev(pci_dev);\n+\tif (list == NULL) {\n+\t\tDRV_LOG(ERR, \"Invalid device: %s\", pci_dev->name);\n+\t\treturn -1;\n+\t}\n+\n+\tdev = list->dev;\n+\n+\trte_vdpa_unregister_device(dev->did);\n+\trte_pci_unmap_device(dev->pdev);\n+\trte_vfio_container_group_unbind(dev->vfio_container_fd,\n+\t\t\tdev->iommu_group_num);\n+\trte_vfio_container_destroy(dev->vfio_container_fd);\n+\n+\tpthread_mutex_lock(&internal_list_lock);\n+\tTAILQ_REMOVE(&internal_list, list, next);\n+\tpthread_mutex_unlock(&internal_list_lock);\n+\n+\trte_free(dev->vqs);\n+\trte_free(list);\n+\trte_free(dev);\n+\n+\treturn 0;\n+}\n+\n+static const struct rte_pci_id pci_id_virtio_vdpa_map[] = {\n+\t{ .class_id = RTE_CLASS_ANY_ID,\n+\t  .vendor_id = VIRTIO_PCI_VENDORID,\n+\t  .device_id = VIRTIO_PCI_LEGACY_DEVICEID_NET,\n+\t  .subsystem_vendor_id = VIRTIO_PCI_VENDORID,\n+\t  .subsystem_device_id = VIRTIO_PCI_SUBSY_DEVICEID_NET,\n+\t},\n+\t{ .class_id = RTE_CLASS_ANY_ID,\n+\t  .vendor_id = VIRTIO_PCI_VENDORID,\n+\t  .device_id = VIRTIO_PCI_MODERN_DEVICEID_NET,\n+\t  .subsystem_vendor_id = VIRTIO_PCI_VENDORID,\n+\t  .subsystem_device_id = VIRTIO_PCI_SUBSY_DEVICEID_NET,\n+\t},\n+\t{ .vendor_id = 0, /* sentinel */\n+\t},\n+};\n+\n+static struct rte_pci_driver rte_virtio_vdpa = {\n+\t.id_table = pci_id_virtio_vdpa_map,\n+\t.drv_flags = 0,\n+\t.probe = virtio_vdpa_pci_probe,\n+\t.remove = virtio_vdpa_pci_remove,\n+};\n+\n+RTE_PMD_REGISTER_PCI(net_virtio_vdpa, rte_virtio_vdpa);\n+RTE_PMD_REGISTER_PCI_TABLE(net_virtio_vdpa, pci_id_virtio_vdpa_map);\n+RTE_PMD_REGISTER_KMOD_DEP(net_virtio_vdpa, \"* vfio-pci\");\n+\n+RTE_INIT(virtio_vdpa_init_log)\n+{\n+\tvirtio_vdpa_logtype = rte_log_register(\"pmd.net.virtio_vdpa\");\n+\tif (virtio_vdpa_logtype >= 0)\n+\t\trte_log_set_level(virtio_vdpa_logtype, RTE_LOG_NOTICE);\n+}\n+\n",
    "prefixes": [
        "06/15"
    ]
}