get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 54987,
    "url": "http://patches.dpdk.org/api/patches/54987/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1560957293-17294-22-git-send-email-ndragazis@arrikto.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": "<1560957293-17294-22-git-send-email-ndragazis@arrikto.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1560957293-17294-22-git-send-email-ndragazis@arrikto.com",
    "date": "2019-06-19T15:14:46",
    "name": "[21/28] drivers/virtio_vhost_user: use additional device resources",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": true,
    "hash": "d6d80f9aee9ffcac22c768e6e1f2e936a5e4d3a3",
    "submitter": {
        "id": 1339,
        "url": "http://patches.dpdk.org/api/people/1339/?format=api",
        "name": "Nikos Dragazis",
        "email": "ndragazis@arrikto.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/1560957293-17294-22-git-send-email-ndragazis@arrikto.com/mbox/",
    "series": [
        {
            "id": 5082,
            "url": "http://patches.dpdk.org/api/series/5082/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=5082",
            "date": "2019-06-19T15:14:25",
            "name": "vhost: add virtio-vhost-user transport",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/5082/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/54987/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/54987/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 4BC6B1C42E;\n\tWed, 19 Jun 2019 17:16:40 +0200 (CEST)",
            "from mx0.arrikto.com (mx0.arrikto.com [212.71.252.59])\n\tby dpdk.org (Postfix) with ESMTP id 9ACD51C3A0\n\tfor <dev@dpdk.org>; Wed, 19 Jun 2019 17:15:46 +0200 (CEST)",
            "from troi.prod.arr (mail.arr [10.99.0.5])\n\tby mx0.arrikto.com (Postfix) with ESMTP id 69350182019;\n\tWed, 19 Jun 2019 18:15:46 +0300 (EEST)",
            "from localhost.localdomain (unknown [10.89.50.133])\n\tby troi.prod.arr (Postfix) with ESMTPSA id D58742B2;\n\tWed, 19 Jun 2019 18:15:45 +0300 (EEST)"
        ],
        "From": "Nikos Dragazis <ndragazis@arrikto.com>",
        "To": "dev@dpdk.org",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>,\n\tTiwei Bie <tiwei.bie@intel.com>, Zhihong Wang <zhihong.wang@intel.com>,\n\tStefan Hajnoczi <stefanha@redhat.com>, Wei Wang <wei.w.wang@intel.com>,\n\tStojaczyk Dariusz <dariusz.stojaczyk@intel.com>,\n\tVangelis Koukis <vkoukis@arrikto.com>",
        "Date": "Wed, 19 Jun 2019 18:14:46 +0300",
        "Message-Id": "<1560957293-17294-22-git-send-email-ndragazis@arrikto.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1560957293-17294-1-git-send-email-ndragazis@arrikto.com>",
        "References": "<1560957293-17294-1-git-send-email-ndragazis@arrikto.com>",
        "Subject": "[dpdk-dev] [PATCH 21/28] drivers/virtio_vhost_user: use additional\n\tdevice resources",
        "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": "Enhance the virtio-vhost-user device driver so that it utilizes the\ndevice's additional resource capabilities. In specific, this patch adds\nsupport for the doorbells and shared_memory capabilities. The former is\nused to find the location of the device doorbells. The latter is used to\nfind the location of the vhost memory regions in the device's memory\naddress space. Also, support has been added for the notification\ncapability, though this configuration structure is not currently being\nused by the virtio-vhost-user driver due to DPDK's poll-mode nature.\n\nSigned-off-by: Nikos Dragazis <ndragazis@arrikto.com>\n---\n .../virtio_vhost_user/trans_virtio_vhost_user.c    | 22 ++++++++++++++--------\n drivers/virtio_vhost_user/virtio_pci.c             | 16 ++++++++++++++++\n drivers/virtio_vhost_user/virtio_pci.h             | 19 +++++++++++++++++++\n 3 files changed, 49 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/drivers/virtio_vhost_user/trans_virtio_vhost_user.c b/drivers/virtio_vhost_user/trans_virtio_vhost_user.c\nindex 72018a4..45863bd 100644\n--- a/drivers/virtio_vhost_user/trans_virtio_vhost_user.c\n+++ b/drivers/virtio_vhost_user/trans_virtio_vhost_user.c\n@@ -198,11 +198,14 @@ vvu_vring_call(struct virtio_net *dev, struct vhost_virtqueue *vq)\n \tstruct vvu_connection *conn =\n \t\tcontainer_of(dev, struct vvu_connection, device);\n \tstruct vvu_socket *vvu_socket = conn->vvu_socket;\n+\tstruct virtio_hw *hw = &vvu_socket->pdev->hw;\n \tuint16_t vq_idx = vq->vring_idx;\n+\tuint16_t *notify_addr = (void *)((uint8_t *)vvu_socket->doorbells +\n+\t\t\t\tvq_idx * hw->doorbell_off_multiplier);\n \n \tRTE_LOG(DEBUG, VHOST_CONFIG, \"%s vq_idx %u\\n\", __func__, vq_idx);\n \n-\trte_write16(rte_cpu_to_le_16(vq_idx), &vvu_socket->doorbells[vq_idx]);\n+\trte_write16(rte_cpu_to_le_16(vq_idx), notify_addr);\n \treturn 0;\n }\n \n@@ -265,14 +268,14 @@ vvu_map_mem_regions(struct virtio_net *dev, struct VhostUserMsg *msg __rte_unuse\n \tstruct vvu_connection *conn =\n \t\tcontainer_of(dev, struct vvu_connection, device);\n \tstruct vvu_socket *vvu_socket = conn->vvu_socket;\n-\tstruct rte_pci_device *pci_dev = vvu_socket->pdev->pci_dev;\n+\tstruct virtio_hw *hw = &vvu_socket->pdev->hw;\n \tuint8_t *mmap_addr;\n \tuint32_t i;\n \n-\t/* Memory regions start after the doorbell registers */\n-\tmmap_addr = (uint8_t *)pci_dev->mem_resource[2].addr +\n-\t\t    RTE_ALIGN_CEIL((vvu_socket->max_vhost_queues + 1 /* log fd */) *\n-\t\t\t\t   sizeof(uint16_t), 4096);\n+\t/* Get the starting address of vhost memory regions from\n+\t * the shared memory virtio PCI capability\n+\t */\n+\tmmap_addr = hw->shared_memory_cfg;\n \n \tfor (i = 0; i < dev->mem->nregions; i++) {\n \t\tstruct rte_vhost_mem_region *reg = &dev->mem->regions[i];\n@@ -780,10 +783,13 @@ vvu_virtio_pci_init_intr(struct vvu_socket *vvu_socket)\n static int\n vvu_virtio_pci_init_bar(struct vvu_socket *vvu_socket)\n {\n-\tstruct rte_pci_device *pci_dev = vvu_socket->pdev->pci_dev;\n+\tstruct virtio_hw *hw = &vvu_socket->pdev->hw;\n \tstruct virtio_net *dev = NULL; /* just for sizeof() */\n \n-\tvvu_socket->doorbells = pci_dev->mem_resource[2].addr;\n+\t/* Get the starting address of the doorbells from\n+\t * the doorbell virtio PCI capability\n+\t */\n+\tvvu_socket->doorbells = hw->doorbell_base;\n \tif (!vvu_socket->doorbells) {\n \t\tRTE_LOG(ERR, VHOST_CONFIG, \"BAR 2 not available\\n\");\n \t\treturn -1;\ndiff --git a/drivers/virtio_vhost_user/virtio_pci.c b/drivers/virtio_vhost_user/virtio_pci.c\nindex 9c2c981..7996729 100644\n--- a/drivers/virtio_vhost_user/virtio_pci.c\n+++ b/drivers/virtio_vhost_user/virtio_pci.c\n@@ -1,5 +1,6 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n  * Copyright(c) 2010-2014 Intel Corporation\n+ * Copyright(c) 2019 Arrikto Inc.\n  */\n #include <stdint.h>\n \n@@ -407,6 +408,18 @@ virtio_read_caps(struct rte_pci_device *dev, struct virtio_hw *hw)\n \t\tcase VIRTIO_PCI_CAP_ISR_CFG:\n \t\t\thw->isr = get_cfg_addr(dev, &cap);\n \t\t\tbreak;\n+\t\tcase VIRTIO_PCI_CAP_DOORBELL_CFG:\n+\t\t\trte_pci_read_config(dev, &hw->doorbell_off_multiplier,\n+\t\t\t\t\t4, pos + sizeof(cap));\n+\t\t\thw->doorbell_base = get_cfg_addr(dev, &cap);\n+\t\t\trte_pci_read_config(dev, &hw->doorbell_length, 4, pos + 10);\n+\t\t\tbreak;\n+\t\tcase VIRTIO_PCI_CAP_NOTIFICATION_CFG:\n+\t\t\thw->notify_cfg = get_cfg_addr(dev, &cap);\n+\t\t\tbreak;\n+\t\tcase VIRTIO_PCI_CAP_SHARED_MEMORY_CFG:\n+\t\t\thw->shared_memory_cfg = get_cfg_addr(dev, &cap);\n+\t\t\tbreak;\n \t\t}\n \n next:\n@@ -426,6 +439,9 @@ virtio_read_caps(struct rte_pci_device *dev, struct virtio_hw *hw)\n \tRTE_LOG(DEBUG, VIRTIO_PCI_CONFIG, \"isr cfg mapped at: %p\\n\", hw->isr);\n \tRTE_LOG(DEBUG, VIRTIO_PCI_CONFIG, \"notify base: %p, notify off multiplier: %u\\n\",\n \t\thw->notify_base, hw->notify_off_multiplier);\n+\tRTE_LOG(DEBUG, VIRTIO_PCI_CONFIG, \"doorbell base: %p, doorbell off multiplier: %u\\n\", hw->doorbell_base, hw->doorbell_off_multiplier);\n+\tRTE_LOG(DEBUG, VIRTIO_PCI_CONFIG, \"notification cfg mapped at: %p\\n\", hw->notify_cfg);\n+\tRTE_LOG(DEBUG, VIRTIO_PCI_CONFIG, \"shared memory region mapped at: %p\\n\", hw->shared_memory_cfg);\n \n \treturn 0;\n }\ndiff --git a/drivers/virtio_vhost_user/virtio_pci.h b/drivers/virtio_vhost_user/virtio_pci.h\nindex 018e0b7..12373d1 100644\n--- a/drivers/virtio_vhost_user/virtio_pci.h\n+++ b/drivers/virtio_vhost_user/virtio_pci.h\n@@ -1,5 +1,6 @@\n /* SPDX-License-Identifier: BSD-3-Clause\n  * Copyright(c) 2010-2014 Intel Corporation\n+ * Copyright(c) 2019 Arrikto Inc.\n  */\n \n /* XXX This file is based on drivers/net/virtio/virtio_pci.h.  It would be\n@@ -117,6 +118,10 @@ struct virtqueue;\n #define VIRTIO_PCI_CAP_DEVICE_CFG\t4\n /* PCI configuration access */\n #define VIRTIO_PCI_CAP_PCI_CFG\t\t5\n+/* Additional capabilities for the virtio-vhost-user device */\n+#define VIRTIO_PCI_CAP_DOORBELL_CFG    6\n+#define VIRTIO_PCI_CAP_NOTIFICATION_CFG 7\n+#define VIRTIO_PCI_CAP_SHARED_MEMORY_CFG 8\n \n /* This is the PCI capability header: */\n struct virtio_pci_cap {\n@@ -161,6 +166,12 @@ struct virtio_pci_common_cfg {\n \tuint32_t queue_used_hi;\t\t/* read-write */\n };\n \n+/* Fields in VIRTIO_PCI_CAP_NOTIFICATION_CFG */\n+struct virtio_pci_notification_cfg {\n+\tuint16_t notification_select;              /* read-write */\n+\tuint16_t notification_msix_vector;         /* read-write */\n+};\n+\n struct virtio_hw;\n \n struct virtio_pci_ops {\n@@ -200,6 +211,14 @@ struct virtio_hw {\n \tuint16_t    *notify_base;\n \tstruct virtio_pci_common_cfg *common_cfg;\n \tvoid\t    *dev_cfg;\n+\t/* virtio-vhost-user additional device resource capabilities\n+\t * https://stefanha.github.io/virtio/vhost-user-slave.html#x1-2830007\n+\t */\n+\tuint32_t    doorbell_off_multiplier;\n+\tuint16_t    *doorbell_base;\n+\tuint32_t     doorbell_length;\n+\tstruct virtio_pci_notification_cfg *notify_cfg;\n+\tuint8_t     *shared_memory_cfg;\n \t/*\n \t * App management thread and virtio interrupt handler thread\n \t * both can change device state, this lock is meant to avoid\n",
    "prefixes": [
        "21/28"
    ]
}