get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 64114,
    "url": "https://patches.dpdk.org/api/patches/64114/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20191223072519.18899-1-xuan.ding@intel.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": "<20191223072519.18899-1-xuan.ding@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20191223072519.18899-1-xuan.ding@intel.com",
    "date": "2019-12-23T07:25:19",
    "name": "[v4] net/virtio-user: fix packed ring server mode",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "359a76ebc259d086f8f161cb2a3ebd4bda369e3c",
    "submitter": {
        "id": 1401,
        "url": "https://patches.dpdk.org/api/people/1401/?format=api",
        "name": "Ding, Xuan",
        "email": "xuan.ding@intel.com"
    },
    "delegate": {
        "id": 2642,
        "url": "https://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20191223072519.18899-1-xuan.ding@intel.com/mbox/",
    "series": [
        {
            "id": 7937,
            "url": "https://patches.dpdk.org/api/series/7937/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=7937",
            "date": "2019-12-23T07:25:19",
            "name": "[v4] net/virtio-user: fix packed ring server mode",
            "version": 4,
            "mbox": "https://patches.dpdk.org/series/7937/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/64114/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/64114/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 B5708A0352;\n\tMon, 23 Dec 2019 08:26:06 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 1E3D937B4;\n\tMon, 23 Dec 2019 08:26:05 +0100 (CET)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n by dpdk.org (Postfix) with ESMTP id 3CE4D1252;\n Mon, 23 Dec 2019 08:26:02 +0100 (CET)",
            "from orsmga006.jf.intel.com ([10.7.209.51])\n by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n 22 Dec 2019 23:26:01 -0800",
            "from dpdk-xuanding-dev2.sh.intel.com ([10.67.119.47])\n by orsmga006.jf.intel.com with ESMTP; 22 Dec 2019 23:25:59 -0800"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.69,346,1571727600\"; d=\"scan'208\";a=\"219087381\"",
        "From": "Xuan Ding <xuan.ding@intel.com>",
        "To": "maxime.coquelin@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com,\n yong.liu@intel.com, xiaolong.ye@intel.com",
        "Cc": "dev@dpdk.org,\n\tXuan Ding <xuan.ding@intel.com>,\n\tstable@dpdk.org",
        "Date": "Mon, 23 Dec 2019 07:25:19 +0000",
        "Message-Id": "<20191223072519.18899-1-xuan.ding@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20191218022406.86245-1-xuan.ding@intel.com>",
        "References": "<20191218022406.86245-1-xuan.ding@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v4] net/virtio-user: fix packed ring server mode",
        "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": "This patch fixes the situation where datapath does not work properly when\nvhost reconnects to virtio in server mode with packed ring.\n\nCurrently, virtio and vhost share memory of vring. For split ring, vhost\ncan read the status of discriptors directly from the available ring and\nthe used ring during reconnection. Therefore, the datapath can continue.\n\nBut for packed ring, when reconnecting to virtio, vhost cannot get the\nstatus of discriptors only through the descriptor ring. By resetting Tx\nand Rx queues, the datapath can restart from the beginning.\n\nFixes: 4c3f5822eb214 (\"net/virtio: add packed virtqueue defines\")\nCc: stable@dpdk.org\n\nSigned-off-by: Xuan Ding <xuan.ding@intel.com>\n---\n\nv4:\n* Moved change log below '---' marker.\n\nv3:\n* Removed an extra asterisk from a comment.\n* Renamed device reset function and moved it to virtio_user_ethdev.c.\n\nv2:\n* Renamed queue reset functions and moved them to virtqueue.c.\n\n drivers/net/virtio/virtio_ethdev.c      |  4 +-\n drivers/net/virtio/virtio_user_ethdev.c | 40 ++++++++++++++\n drivers/net/virtio/virtqueue.c          | 71 +++++++++++++++++++++++++\n drivers/net/virtio/virtqueue.h          |  4 ++\n 4 files changed, 117 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c\nindex 044eb10a7..f9d0ea70d 100644\n--- a/drivers/net/virtio/virtio_ethdev.c\n+++ b/drivers/net/virtio/virtio_ethdev.c\n@@ -1913,6 +1913,8 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)\n \t\t\tgoto err_vtpci_init;\n \t}\n \n+\trte_spinlock_init(&hw->state_lock);\n+\n \t/* reset device and negotiate default features */\n \tret = virtio_init_device(eth_dev, VIRTIO_PMD_DEFAULT_GUEST_FEATURES);\n \tif (ret < 0)\n@@ -2155,8 +2157,6 @@ virtio_dev_configure(struct rte_eth_dev *dev)\n \t\t\treturn -EBUSY;\n \t\t}\n \n-\trte_spinlock_init(&hw->state_lock);\n-\n \thw->use_simple_rx = 1;\n \n \tif (vtpci_with_feature(hw, VIRTIO_F_IN_ORDER)) {\ndiff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c\nindex 3fc172573..425f48230 100644\n--- a/drivers/net/virtio/virtio_user_ethdev.c\n+++ b/drivers/net/virtio/virtio_user_ethdev.c\n@@ -25,12 +25,48 @@\n #define virtio_user_get_dev(hw) \\\n \t((struct virtio_user_dev *)(hw)->virtio_user_dev)\n \n+static void\n+virtio_user_reset_queues_packed(struct rte_eth_dev *dev)\n+{\n+\tstruct virtio_hw *hw = dev->data->dev_private;\n+\tstruct virtnet_rx *rxvq;\n+\tstruct virtnet_tx *txvq;\n+\tuint16_t i;\n+\n+\t/* Add lock to avoid queue contention. */\n+\trte_spinlock_lock(&hw->state_lock);\n+\thw->started = 0;\n+\n+\t/*\n+\t * Waitting for datapath to complete before resetting queues.\n+\t * 1 ms should be enough for the ongoing Tx/Rx function to finish.\n+\t */\n+\trte_delay_ms(1);\n+\n+\t/* Vring reset for each Tx queue and Rx queue. */\n+\tfor (i = 0; i < dev->data->nb_rx_queues; i++) {\n+\t\trxvq = dev->data->rx_queues[i];\n+\t\tvirtqueue_rxvq_reset_packed(rxvq->vq);\n+\t\tvirtio_dev_rx_queue_setup_finish(dev, i);\n+\t}\n+\n+\tfor (i = 0; i < dev->data->nb_tx_queues; i++) {\n+\t\ttxvq = dev->data->tx_queues[i];\n+\t\tvirtqueue_txvq_reset_packed(txvq->vq);\n+\t}\n+\n+\thw->started = 1;\n+\trte_spinlock_unlock(&hw->state_lock);\n+}\n+\n+\n static int\n virtio_user_server_reconnect(struct virtio_user_dev *dev)\n {\n \tint ret;\n \tint connectfd;\n \tstruct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id];\n+\tstruct virtio_hw *hw = eth_dev->data->dev_private;\n \n \tconnectfd = accept(dev->listenfd, NULL, NULL);\n \tif (connectfd < 0)\n@@ -51,6 +87,10 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)\n \n \tdev->features &= dev->device_features;\n \n+\t/* For packed ring, resetting queues is required in reconnection. */\n+\tif (vtpci_packed_queue(hw))\n+\t\tvirtio_user_reset_queues_packed(eth_dev);\n+\n \tret = virtio_user_start_device(dev);\n \tif (ret < 0)\n \t\treturn -1;\ndiff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c\nindex 5ff1e3587..0b4e3bf3e 100644\n--- a/drivers/net/virtio/virtqueue.c\n+++ b/drivers/net/virtio/virtqueue.c\n@@ -141,3 +141,74 @@ virtqueue_rxvq_flush(struct virtqueue *vq)\n \telse\n \t\tvirtqueue_rxvq_flush_split(vq);\n }\n+\n+int\n+virtqueue_rxvq_reset_packed(struct virtqueue *vq)\n+{\n+\tint size = vq->vq_nentries;\n+\tstruct vq_desc_extra *dxp;\n+\tstruct virtnet_rx *rxvq;\n+\tuint16_t desc_idx;\n+\n+\tvq->vq_used_cons_idx = 0;\n+\tvq->vq_desc_head_idx = 0;\n+\tvq->vq_avail_idx = 0;\n+\tvq->vq_desc_tail_idx = (uint16_t)(vq->vq_nentries - 1);\n+\tvq->vq_free_cnt = vq->vq_nentries;\n+\n+\tvq->vq_packed.used_wrap_counter = 1;\n+\tvq->vq_packed.cached_flags = VRING_PACKED_DESC_F_AVAIL;\n+\tvq->vq_packed.event_flags_shadow = 0;\n+\tvq->vq_packed.cached_flags |= VRING_DESC_F_WRITE;\n+\n+\trxvq = &vq->rxq;\n+\tmemset(rxvq->mz->addr, 0, rxvq->mz->len);\n+\n+\tfor (desc_idx = 0; desc_idx < vq->vq_nentries; desc_idx++) {\n+\t\tdxp = &vq->vq_descx[desc_idx];\n+\t\tif (dxp->cookie != NULL) {\n+\t\t\trte_pktmbuf_free(dxp->cookie);\n+\t\t\tdxp->cookie = NULL;\n+\t\t}\n+\t}\n+\n+\tvring_desc_init_packed(vq, size);\n+\n+\treturn 0;\n+}\n+\n+int\n+virtqueue_txvq_reset_packed(struct virtqueue *vq)\n+{\n+\tint size = vq->vq_nentries;\n+\tstruct vq_desc_extra *dxp;\n+\tstruct virtnet_tx *txvq;\n+\tuint16_t desc_idx;\n+\n+\tvq->vq_used_cons_idx = 0;\n+\tvq->vq_desc_head_idx = 0;\n+\tvq->vq_avail_idx = 0;\n+\tvq->vq_desc_tail_idx = (uint16_t)(vq->vq_nentries - 1);\n+\tvq->vq_free_cnt = vq->vq_nentries;\n+\n+\tvq->vq_packed.used_wrap_counter = 1;\n+\tvq->vq_packed.cached_flags = VRING_PACKED_DESC_F_AVAIL;\n+\tvq->vq_packed.event_flags_shadow = 0;\n+\n+\ttxvq = &vq->txq;\n+\tmemset(txvq->mz->addr, 0, txvq->mz->len);\n+\tmemset(txvq->virtio_net_hdr_mz->addr, 0,\n+\t\ttxvq->virtio_net_hdr_mz->len);\n+\n+\tfor (desc_idx = 0; desc_idx < vq->vq_nentries; desc_idx++) {\n+\t\tdxp = &vq->vq_descx[desc_idx];\n+\t\tif (dxp->cookie != NULL) {\n+\t\t\trte_pktmbuf_free(dxp->cookie);\n+\t\t\tdxp->cookie = NULL;\n+\t\t}\n+\t}\n+\n+\tvring_desc_init_packed(vq, size);\n+\n+\treturn 0;\n+}\ndiff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h\nindex 8d7f197b1..58ad7309a 100644\n--- a/drivers/net/virtio/virtqueue.h\n+++ b/drivers/net/virtio/virtqueue.h\n@@ -443,6 +443,10 @@ struct rte_mbuf *virtqueue_detach_unused(struct virtqueue *vq);\n /* Flush the elements in the used ring. */\n void virtqueue_rxvq_flush(struct virtqueue *vq);\n \n+int virtqueue_rxvq_reset_packed(struct virtqueue *vq);\n+\n+int virtqueue_txvq_reset_packed(struct virtqueue *vq);\n+\n static inline int\n virtqueue_full(const struct virtqueue *vq)\n {\n",
    "prefixes": [
        "v4"
    ]
}