get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 35135,
    "url": "http://patches.dpdk.org/api/patches/35135/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180212154612.5297-3-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": "<20180212154612.5297-3-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180212154612.5297-3-maxime.coquelin@redhat.com",
    "date": "2018-02-12T15:46:11",
    "name": "[dpdk-dev,v2,2/3] virtio: fix resuming port with rx vector path",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "96d083f89ffa9e3e57517b25fd6ece983ba7873b",
    "submitter": {
        "id": 512,
        "url": "http://patches.dpdk.org/api/people/512/?format=api",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20180212154612.5297-3-maxime.coquelin@redhat.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/35135/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/35135/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 0CD6B1B385;\n\tMon, 12 Feb 2018 16:46:45 +0100 (CET)",
            "from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73])\n\tby dpdk.org (Postfix) with ESMTP id 504F11B374;\n\tMon, 12 Feb 2018 16:46:43 +0100 (CET)",
            "from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4])\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 D6DCC40A0971;\n\tMon, 12 Feb 2018 15:46:42 +0000 (UTC)",
            "from localhost.localdomain (ovpn-112-42.ams2.redhat.com\n\t[10.36.112.42])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 47B022026DFD;\n\tMon, 12 Feb 2018 15:46:40 +0000 (UTC)"
        ],
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "tiwei.bie@intel.com, yliu@fridaylinux.org, ferruh.yigit@intel.com,\n\tvictork@redhat.com, thomas@monjalon.net, olivier.matz@6wind.com,\n\tjianfeng.tan@intel.com",
        "Cc": "dev@dpdk.org, stable@dpdk.org, zhihong.wang@intel.com,\n\tqian.q.xu@intel.com, \n\tlei.a.yao@intel.com, Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Mon, 12 Feb 2018 16:46:11 +0100",
        "Message-Id": "<20180212154612.5297-3-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20180212154612.5297-1-maxime.coquelin@redhat.com>",
        "References": "<20180212154612.5297-1-maxime.coquelin@redhat.com>",
        "X-Scanned-By": "MIMEDefang 2.78 on 10.11.54.4",
        "X-Greylist": [
            "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.7]); Mon, 12 Feb 2018 15:46:42 +0000 (UTC)",
            "inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.7]); \n\tMon, 12 Feb 2018 15:46:42 +0000 (UTC) for IP:'10.11.54.4'\n\tDOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com'\n\tHELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:''"
        ],
        "Subject": "[dpdk-dev] [PATCH v2 2/3] virtio: fix resuming port with rx vector\n\tpath",
        "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://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": "<https://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": "Since commit efc83a1e7fc3 (\"net/virtio: fix queue setup consistency\"),\nwhen resuming a virtio port, the rx rings are refilled with new mbufs\nuntil they are full (vq->vq_free_cnt == 0). This is done without\nensuring that the descriptor index remains a multiple of\nRTE_VIRTIO_VPMD_RX_REARM_THRESH, which is a prerequisite when using the\nvector mode. This can cause an out of bound access in the rx ring.\n\nThis commit changes the vector refill method from\nvirtqueue_enqueue_recv_refill_simple() to virtio_rxq_rearm_vec(), which\nproperly checks that the refill is done by batch of\nRTE_VIRTIO_VPMD_RX_REARM_THRESH.\n\nAs virtqueue_enqueue_recv_refill_simple() is no more used, this\npatch also removes the function.\n\nFixes: efc83a1e7fc3 (\"net/virtio: fix queue setup consistency\")\n\nReviewed-by: Jianfeng Tan <jianfeng.tan@intel.com>\nSigned-off-by: Tiwei Bie <tiwei.bie@intel.com>\nSigned-off-by: Olivier Matz <olivier.matz@6wind.com>\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n drivers/net/virtio/virtio_rxtx.c        | 38 ++++++++++++++++++---------------\n drivers/net/virtio/virtio_rxtx.h        |  3 ---\n drivers/net/virtio/virtio_rxtx_simple.c | 31 +--------------------------\n drivers/net/virtio/virtio_rxtx_simple.h |  2 +-\n 4 files changed, 23 insertions(+), 51 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c\nindex 854af399e..8dbf2a30e 100644\n--- a/drivers/net/virtio/virtio_rxtx.c\n+++ b/drivers/net/virtio/virtio_rxtx.c\n@@ -30,6 +30,7 @@\n #include \"virtio_pci.h\"\n #include \"virtqueue.h\"\n #include \"virtio_rxtx.h\"\n+#include \"virtio_rxtx_simple.h\"\n \n #ifdef RTE_LIBRTE_VIRTIO_DEBUG_DUMP\n #define VIRTIO_DUMP_PACKET(m, len) rte_pktmbuf_dump(stdout, m, len)\n@@ -437,6 +438,8 @@ virtio_dev_rx_queue_setup_finish(struct rte_eth_dev *dev, uint16_t queue_idx)\n \t\t\tvq->vq_ring.desc[desc_idx].flags =\n \t\t\t\tVRING_DESC_F_WRITE;\n \t\t}\n+\n+\t\tvirtio_rxq_vec_setup(rxvq);\n \t}\n \n \tmemset(&rxvq->fake_mbuf, 0, sizeof(rxvq->fake_mbuf));\n@@ -446,30 +449,31 @@ virtio_dev_rx_queue_setup_finish(struct rte_eth_dev *dev, uint16_t queue_idx)\n \t\t\t&rxvq->fake_mbuf;\n \t}\n \n-\twhile (!virtqueue_full(vq)) {\n-\t\tm = rte_mbuf_raw_alloc(rxvq->mpool);\n-\t\tif (m == NULL)\n-\t\t\tbreak;\n+\tif (hw->use_simple_rx) {\n+\t\twhile (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {\n+\t\t\tvirtio_rxq_rearm_vec(rxvq);\n+\t\t\tnbufs += RTE_VIRTIO_VPMD_RX_REARM_THRESH;\n+\t\t}\n+\t} else {\n+\t\twhile (!virtqueue_full(vq)) {\n+\t\t\tm = rte_mbuf_raw_alloc(rxvq->mpool);\n+\t\t\tif (m == NULL)\n+\t\t\t\tbreak;\n \n-\t\t/* Enqueue allocated buffers */\n-\t\tif (hw->use_simple_rx)\n-\t\t\terror = virtqueue_enqueue_recv_refill_simple(vq, m);\n-\t\telse\n+\t\t\t/* Enqueue allocated buffers */\n \t\t\terror = virtqueue_enqueue_recv_refill(vq, m);\n-\n-\t\tif (error) {\n-\t\t\trte_pktmbuf_free(m);\n-\t\t\tbreak;\n+\t\t\tif (error) {\n+\t\t\t\trte_pktmbuf_free(m);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tnbufs++;\n \t\t}\n-\t\tnbufs++;\n-\t}\n \n-\tvq_update_avail_idx(vq);\n+\t\tvq_update_avail_idx(vq);\n+\t}\n \n \tPMD_INIT_LOG(DEBUG, \"Allocated %d bufs\", nbufs);\n \n-\tvirtio_rxq_vec_setup(rxvq);\n-\n \tVIRTQUEUE_DUMP(vq);\n \n \treturn 0;\ndiff --git a/drivers/net/virtio/virtio_rxtx.h b/drivers/net/virtio/virtio_rxtx.h\nindex 49e9d98ee..685cc4f81 100644\n--- a/drivers/net/virtio/virtio_rxtx.h\n+++ b/drivers/net/virtio/virtio_rxtx.h\n@@ -60,7 +60,4 @@ struct virtnet_ctl {\n \n int virtio_rxq_vec_setup(struct virtnet_rx *rxvq);\n \n-int virtqueue_enqueue_recv_refill_simple(struct virtqueue *vq,\n-\tstruct rte_mbuf *m);\n-\n #endif /* _VIRTIO_RXTX_H_ */\ndiff --git a/drivers/net/virtio/virtio_rxtx_simple.c b/drivers/net/virtio/virtio_rxtx_simple.c\nindex b1f610ffa..515207581 100644\n--- a/drivers/net/virtio/virtio_rxtx_simple.c\n+++ b/drivers/net/virtio/virtio_rxtx_simple.c\n@@ -27,35 +27,6 @@\n #pragma GCC diagnostic ignored \"-Wcast-qual\"\n #endif\n \n-int __attribute__((cold))\n-virtqueue_enqueue_recv_refill_simple(struct virtqueue *vq,\n-\tstruct rte_mbuf *cookie)\n-{\n-\tstruct vq_desc_extra *dxp;\n-\tstruct vring_desc *start_dp;\n-\tuint16_t desc_idx;\n-\n-\tcookie->port = vq->rxq.port_id;\n-\tcookie->data_off = RTE_PKTMBUF_HEADROOM;\n-\n-\tdesc_idx = vq->vq_avail_idx & (vq->vq_nentries - 1);\n-\tdxp = &vq->vq_descx[desc_idx];\n-\tdxp->cookie = (void *)cookie;\n-\tvq->sw_ring[desc_idx] = cookie;\n-\n-\tstart_dp = vq->vq_ring.desc;\n-\tstart_dp[desc_idx].addr =\n-\t\tVIRTIO_MBUF_ADDR(cookie, vq) +\n-\t\tRTE_PKTMBUF_HEADROOM - vq->hw->vtnet_hdr_size;\n-\tstart_dp[desc_idx].len = cookie->buf_len -\n-\t\tRTE_PKTMBUF_HEADROOM + vq->hw->vtnet_hdr_size;\n-\n-\tvq->vq_free_cnt--;\n-\tvq->vq_avail_idx++;\n-\n-\treturn 0;\n-}\n-\n uint16_t\n virtio_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,\n \tuint16_t nb_pkts)\n@@ -78,7 +49,7 @@ virtio_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,\n \trte_compiler_barrier();\n \n \tif (nb_used >= VIRTIO_TX_FREE_THRESH)\n-\t\tvirtio_xmit_cleanup(vq);\n+\t\tvirtio_xmit_cleanup_simple(vq);\n \n \tnb_commit = nb_pkts = RTE_MIN((vq->vq_free_cnt >> 1), nb_pkts);\n \tdesc_idx = (uint16_t)(vq->vq_avail_idx & desc_idx_max);\ndiff --git a/drivers/net/virtio/virtio_rxtx_simple.h b/drivers/net/virtio/virtio_rxtx_simple.h\nindex 2d8e6b14a..303904d64 100644\n--- a/drivers/net/virtio/virtio_rxtx_simple.h\n+++ b/drivers/net/virtio/virtio_rxtx_simple.h\n@@ -60,7 +60,7 @@ virtio_rxq_rearm_vec(struct virtnet_rx *rxvq)\n #define VIRTIO_TX_FREE_NR 32\n /* TODO: vq->tx_free_cnt could mean num of free slots so we could avoid shift */\n static inline void\n-virtio_xmit_cleanup(struct virtqueue *vq)\n+virtio_xmit_cleanup_simple(struct virtqueue *vq)\n {\n \tuint16_t i, desc_idx;\n \tuint32_t nb_free = 0;\n",
    "prefixes": [
        "dpdk-dev",
        "v2",
        "2/3"
    ]
}