get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 64965,
    "url": "http://patches.dpdk.org/api/patches/64965/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1579539790-3882-31-git-send-email-matan@mellanox.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": "<1579539790-3882-31-git-send-email-matan@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1579539790-3882-31-git-send-email-matan@mellanox.com",
    "date": "2020-01-20T17:03:02",
    "name": "[v1,30/38] vdpa/mlx5: map doorbell",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "eeac8281c1c47eb5ec9ee60e5aa41edad46b3db0",
    "submitter": {
        "id": 796,
        "url": "http://patches.dpdk.org/api/people/796/?format=api",
        "name": "Matan Azrad",
        "email": "matan@mellanox.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/1579539790-3882-31-git-send-email-matan@mellanox.com/mbox/",
    "series": [
        {
            "id": 8223,
            "url": "http://patches.dpdk.org/api/series/8223/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8223",
            "date": "2020-01-20T17:02:37",
            "name": "Introduce mlx5 vDPA driver",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/8223/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/64965/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/64965/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 850C9A0526;\n\tMon, 20 Jan 2020 18:08:24 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id ED1941C0BD;\n\tMon, 20 Jan 2020 18:04:05 +0100 (CET)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by dpdk.org (Postfix) with ESMTP id C23A41BFAF\n for <dev@dpdk.org>; Mon, 20 Jan 2020 18:03:14 +0100 (CET)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n asafp@mellanox.com)\n with ESMTPS (AES256-SHA encrypted); 20 Jan 2020 19:03:13 +0200",
            "from pegasus07.mtr.labs.mlnx (pegasus07.mtr.labs.mlnx\n [10.210.16.112])\n by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 00KH3BGn024424;\n Mon, 20 Jan 2020 19:03:13 +0200"
        ],
        "From": "Matan Azrad <matan@mellanox.com>",
        "To": "dev@dpdk.org",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>,\n Thomas Monjalon <thomas@monjalon.net>",
        "Date": "Mon, 20 Jan 2020 17:03:02 +0000",
        "Message-Id": "<1579539790-3882-31-git-send-email-matan@mellanox.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1579539790-3882-1-git-send-email-matan@mellanox.com>",
        "References": "<1579539790-3882-1-git-send-email-matan@mellanox.com>",
        "Subject": "[dpdk-dev] [PATCH v1 30/38] vdpa/mlx5: map doorbell",
        "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 <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "The HW support only 4 bytes doorbell writing detection.\nThe virtio device set only 2 bytes when it rings the doorbell.\n\nMap the virtio doorbell detected by the virtio queue kickfd to the HW\nVAR space when it expects to get the virtio emulation doorbell.\n\nUse the EAL interrupt mechanism to get notification when a new event\nappears in kickfd by the guest and write 4 bytes to the HW doorbell space\nin the notification callback.\n\nSigned-off-by: Matan Azrad <matan@mellanox.com>\n---\n drivers/vdpa/mlx5/mlx5_vdpa.h       |  3 ++\n drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 84 ++++++++++++++++++++++++++++++++++++-\n 2 files changed, 86 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.h b/drivers/vdpa/mlx5/mlx5_vdpa.h\nindex 318f1e8..8503b7b 100644\n--- a/drivers/vdpa/mlx5/mlx5_vdpa.h\n+++ b/drivers/vdpa/mlx5/mlx5_vdpa.h\n@@ -66,6 +66,7 @@ struct mlx5_vdpa_virtq {\n \t\tvoid *buf;\n \t\tuint32_t size;\n \t} umems[3];\n+\tstruct rte_intr_handle intr_handle;\n };\n \n struct mlx5_vdpa_steer {\n@@ -103,6 +104,8 @@ struct mlx5_vdpa_priv {\n \tuint16_t log_max_rqt_size;\n \tSLIST_HEAD(virtq_list, mlx5_vdpa_virtq) virtq_list;\n \tstruct mlx5_vdpa_steer steer;\n+\tstruct mlx5dv_var *var;\n+\tvoid *virtq_db_addr;\n \tSLIST_HEAD(mr_list, mlx5_vdpa_query_mr) mr_list;\n };\n \ndiff --git a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c\nindex a294117..fbcf971 100644\n--- a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c\n+++ b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c\n@@ -3,20 +3,65 @@\n  */\n #include <string.h>\n #include <assert.h>\n+#include <unistd.h>\n+#include <sys/mman.h>\n \n #include <rte_malloc.h>\n #include <rte_errno.h>\n+#include <rte_io.h>\n \n #include \"mlx5_vdpa_utils.h\"\n #include \"mlx5_vdpa.h\"\n \n \n+static void\n+mlx5_vdpa_virtq_handler(void *cb_arg)\n+{\n+\tstruct mlx5_vdpa_virtq *virtq = cb_arg;\n+\tstruct mlx5_vdpa_priv *priv = virtq->priv;\n+\tuint64_t buf;\n+\tint nbytes;\n+\n+\tdo {\n+\t\tnbytes = read(virtq->intr_handle.fd, &buf, 8);\n+\t\tif (nbytes < 0) {\n+\t\t\tif (errno == EINTR ||\n+\t\t\t    errno == EWOULDBLOCK ||\n+\t\t\t    errno == EAGAIN)\n+\t\t\t\tcontinue;\n+\t\t\tDRV_LOG(ERR,  \"Failed to read kickfd of virtq %d: %s\",\n+\t\t\t\tvirtq->index, strerror(errno));\n+\t\t}\n+\t\tbreak;\n+\t} while (1);\n+\tassert(priv->virtq_db_addr);\n+\trte_write32(virtq->index, priv->virtq_db_addr);\n+\tDRV_LOG(DEBUG, \"Ring virtq %u doorbell.\", virtq->index);\n+}\n+\n static int\n mlx5_vdpa_virtq_unset(struct mlx5_vdpa_virtq *virtq)\n {\n-\tint ret __rte_unused;\n \tunsigned i;\n+\tint retries = MLX5_VDPA_INTR_RETRIES;\n+\tint ret = -EAGAIN;\n \n+\tif (virtq->intr_handle.fd) {\n+\t\twhile (retries-- && ret == -EAGAIN) {\n+\t\t\tret = rte_intr_callback_unregister(&virtq->intr_handle,\n+\t\t\t\t\t\t\tmlx5_vdpa_virtq_handler,\n+\t\t\t\t\t\t\tvirtq);\n+\t\t\tif (ret == -EAGAIN) {\n+\t\t\t\tDRV_LOG(DEBUG, \"Try again to unregister fd %d \"\n+\t\t\t\t\t\"of virtq %d interrupt, retries = %d.\",\n+\t\t\t\t\tvirtq->intr_handle.fd,\n+\t\t\t\t\t(int)virtq->index, retries);\n+\t\t\t\tusleep(MLX5_VDPA_INTR_RETRIES_USEC);\n+\t\t\t}\n+\t\t}\n+\t\tassert(!ret);\n+\t\tmemset(&virtq->intr_handle, 0, sizeof(virtq->intr_handle));\n+\t}\n \tif (virtq->virtq) {\n \t\tret = mlx5_devx_cmd_destroy(virtq->virtq);\n \t\tassert(!ret);\n@@ -62,6 +107,15 @@\n \t\tassert(!ret);\n \t\tpriv->td = NULL;\n \t}\n+\tif (priv->virtq_db_addr) {\n+\t\tret = munmap(priv->virtq_db_addr, priv->var->length);\n+\t\tassert(!ret);\n+\t\tpriv->virtq_db_addr = NULL;\n+\t}\n+\tif (priv->var) {\n+\t\tmlx5_glue->dv_free_var(priv->var);\n+\t\tpriv->var = NULL;\n+\t}\n \tpriv->features = 0;\n }\n \n@@ -207,6 +261,17 @@\n \tif (mlx5_vdpa_virtq_modify(virtq, 1))\n \t\tgoto error;\n \tvirtq->enable = 1;\n+\tvirtq->intr_handle.fd = vq.kickfd;\n+\tvirtq->intr_handle.type = RTE_INTR_HANDLE_EXT;\n+\tif (rte_intr_callback_register(&virtq->intr_handle,\n+\t\t\t\t       mlx5_vdpa_virtq_handler, virtq)) {\n+\t\tvirtq->intr_handle.fd = 0;\n+\t\tDRV_LOG(ERR, \"Failed to register virtq %d interrupt.\", index);\n+\t\tgoto error;\n+\t} else {\n+\t\tDRV_LOG(DEBUG, \"Register fd %d interrupt for virtq %d.\",\n+\t\t\tvirtq->intr_handle.fd, index);\n+\t}\n \treturn 0;\n error:\n \tmlx5_vdpa_virtq_unset(virtq);\n@@ -281,6 +346,23 @@\n \t\tDRV_LOG(ERR, \"Failed to configure negotiated features.\");\n \t\treturn -1;\n \t}\n+\tpriv->var = mlx5_glue->dv_alloc_var(priv->ctx, 0);\n+\tif (!priv->var) {\n+\t\tDRV_LOG(ERR, \"Failed to allocate VAR %u.\\n\", errno);\n+\t\treturn -1;\n+\t}\n+\t/* Always map the entire page. */\n+\tpriv->virtq_db_addr = mmap(NULL, priv->var->length, PROT_READ |\n+\t\t\t\t   PROT_WRITE, MAP_SHARED, priv->ctx->cmd_fd,\n+\t\t\t\t   priv->var->mmap_off);\n+\tif (priv->virtq_db_addr == MAP_FAILED) {\n+\t\tDRV_LOG(ERR, \"Failed to map doorbell page %u.\", errno);\n+\t\tpriv->virtq_db_addr = NULL;\n+\t\tgoto error;\n+\t} else {\n+\t\tDRV_LOG(DEBUG, \"VAR address of doorbell mapping is %p.\",\n+\t\t\tpriv->virtq_db_addr);\n+\t}\n \tpriv->td = mlx5_devx_cmd_create_td(priv->ctx);\n \tif (!priv->td) {\n \t\tDRV_LOG(ERR, \"Failed to create transpprt domain.\");\n",
    "prefixes": [
        "v1",
        "30/38"
    ]
}