Show a patch.

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

{
    "id": 42279,
    "url": "http://patches.dpdk.org/api/patches/42279/",
    "web_url": "http://patches.dpdk.org/patch/42279/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "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"
    },
    "msgid": "<20180704215438.5579-13-maxime.coquelin@redhat.com>",
    "date": "2018-07-04T21:54:35",
    "name": "[v7,12/15] vhost: add Rx support for packed ring",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d9e0b9be1fee4ccc82fc44020d61d9c689235ad8",
    "submitter": {
        "id": 512,
        "url": "http://patches.dpdk.org/api/people/512/",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/patch/42279/mbox/",
    "series": [
        {
            "id": 404,
            "url": "http://patches.dpdk.org/api/series/404/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=404",
            "date": "2018-07-04T21:54:23",
            "name": "Vhost: add support to packed ring layout",
            "version": 7,
            "mbox": "http://patches.dpdk.org/series/404/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/42279/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/42279/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "In-Reply-To": "<20180704215438.5579-1-maxime.coquelin@redhat.com>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id EA2C41BF81;\n\tWed,  4 Jul 2018 23:55:13 +0200 (CEST)",
            "from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73])\n\tby dpdk.org (Postfix) with ESMTP id AA2051BF70\n\tfor <dev@dpdk.org>; Wed,  4 Jul 2018 23:55:12 +0200 (CEST)",
            "from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6])\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 559C14075623;\n\tWed,  4 Jul 2018 21:55:12 +0000 (UTC)",
            "from localhost.localdomain (ovpn-112-34.ams2.redhat.com\n\t[10.36.112.34])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 327692156880;\n\tWed,  4 Jul 2018 21:55:10 +0000 (UTC)"
        ],
        "References": "<20180704215438.5579-1-maxime.coquelin@redhat.com>",
        "Delivered-To": "patchwork@dpdk.org",
        "X-BeenThere": "dev@dpdk.org",
        "X-Scanned-By": "MIMEDefang 2.78 on 10.11.54.6",
        "Message-Id": "<20180704215438.5579-13-maxime.coquelin@redhat.com>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Precedence": "list",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "X-Greylist": [
            "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.5]); Wed, 04 Jul 2018 21:55:12 +0000 (UTC)",
            "inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.5]); \n\tWed, 04 Jul 2018 21:55:12 +0000 (UTC) for IP:'10.11.54.6'\n\tDOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com'\n\tHELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:''"
        ],
        "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>",
        "To": "tiwei.bie@intel.com, zhihong.wang@intel.com, jfreimann@redhat.com,\n\tdev@dpdk.org",
        "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>",
        "Date": "Wed,  4 Jul 2018 23:54:35 +0200",
        "Cc": "mst@redhat.com, jasowang@redhat.com, wexu@redhat.com,\n\tMaxime Coquelin <maxime.coquelin@redhat.com>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Subject": "[dpdk-dev] [PATCH v7 12/15] vhost: add Rx support for packed ring"
    },
    "content": "Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n lib/librte_vhost/virtio_net.c | 117 +++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 116 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c\nindex 1a04df807..764f7cd23 100644\n--- a/lib/librte_vhost/virtio_net.c\n+++ b/lib/librte_vhost/virtio_net.c\n@@ -561,6 +561,65 @@ fill_vec_buf_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \treturn 0;\n }\n \n+/*\n+ * Returns -1 on fail, 0 on success\n+ */\n+static inline int\n+reserve_avail_buf_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n+\t\t\t\tuint32_t size, struct buf_vector *buf_vec,\n+\t\t\t\tuint16_t *nr_vec, uint16_t *num_buffers,\n+\t\t\t\tuint16_t *nr_descs)\n+{\n+\tuint16_t avail_idx;\n+\tuint16_t vec_idx = 0;\n+\tuint16_t max_tries, tries = 0;\n+\n+\tuint16_t buf_id = 0;\n+\tuint16_t len = 0;\n+\tuint16_t desc_count;\n+\n+\t*num_buffers = 0;\n+\tavail_idx = vq->last_avail_idx;\n+\n+\tif (rxvq_is_mergeable(dev))\n+\t\tmax_tries = vq->size;\n+\telse\n+\t\tmax_tries = 1;\n+\n+\twhile (size > 0) {\n+\t\tif (unlikely(fill_vec_buf_packed(dev, vq,\n+\t\t\t\t\t\tavail_idx, &desc_count,\n+\t\t\t\t\t\tbuf_vec, &vec_idx,\n+\t\t\t\t\t\t&buf_id, &len,\n+\t\t\t\t\t\tVHOST_ACCESS_RO) < 0))\n+\t\t\treturn -1;\n+\n+\t\tlen = RTE_MIN(len, size);\n+\t\tupdate_shadow_used_ring_packed(vq, buf_id, len, desc_count);\n+\t\tsize -= len;\n+\n+\t\tavail_idx += desc_count;\n+\t\tif (avail_idx >= vq->size)\n+\t\t\tavail_idx -= vq->size;\n+\n+\t\t*nr_descs += desc_count;\n+\t\ttries++;\n+\t\t*num_buffers += 1;\n+\n+\t\t/*\n+\t\t * if we tried all available ring items, and still\n+\t\t * can't get enough buf, it means something abnormal\n+\t\t * happened.\n+\t\t */\n+\t\tif (unlikely(tries > max_tries))\n+\t\t\treturn -1;\n+\t}\n+\n+\t*nr_vec = vec_idx;\n+\n+\treturn 0;\n+}\n+\n static __rte_always_inline int\n copy_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\t\t    struct rte_mbuf *m, struct buf_vector *buf_vec,\n@@ -773,6 +832,59 @@ virtio_dev_rx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \treturn pkt_idx;\n }\n \n+static __rte_always_inline uint32_t\n+virtio_dev_rx_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n+\tstruct rte_mbuf **pkts, uint32_t count)\n+{\n+\tuint32_t pkt_idx = 0;\n+\tuint16_t num_buffers;\n+\tstruct buf_vector buf_vec[BUF_VECTOR_MAX];\n+\n+\tfor (pkt_idx = 0; pkt_idx < count; pkt_idx++) {\n+\t\tuint32_t pkt_len = pkts[pkt_idx]->pkt_len + dev->vhost_hlen;\n+\t\tuint16_t nr_vec = 0;\n+\t\tuint16_t nr_descs = 0;\n+\n+\t\tif (unlikely(reserve_avail_buf_packed(dev, vq,\n+\t\t\t\t\t\tpkt_len, buf_vec, &nr_vec,\n+\t\t\t\t\t\t&num_buffers, &nr_descs) < 0)) {\n+\t\t\tVHOST_LOG_DEBUG(VHOST_DATA,\n+\t\t\t\t\"(%d) failed to get enough desc from vring\\n\",\n+\t\t\t\tdev->vid);\n+\t\t\tvq->shadow_used_idx -= num_buffers;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\trte_prefetch0((void *)(uintptr_t)buf_vec[0].buf_addr);\n+\n+\t\tVHOST_LOG_DEBUG(VHOST_DATA, \"(%d) current index %d | end index %d\\n\",\n+\t\t\tdev->vid, vq->last_avail_idx,\n+\t\t\tvq->last_avail_idx + num_buffers);\n+\n+\t\tif (copy_mbuf_to_desc(dev, vq, pkts[pkt_idx],\n+\t\t\t\t\t\tbuf_vec, nr_vec,\n+\t\t\t\t\t\tnum_buffers) < 0) {\n+\t\t\tvq->shadow_used_idx -= num_buffers;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tvq->last_avail_idx += nr_descs;\n+\t\tif (vq->last_avail_idx >= vq->size) {\n+\t\t\tvq->last_avail_idx -= vq->size;\n+\t\t\tvq->avail_wrap_counter ^= 1;\n+\t\t}\n+\t}\n+\n+\tdo_data_copy_enqueue(dev, vq);\n+\n+\tif (likely(vq->shadow_used_idx)) {\n+\t\tflush_shadow_used_ring_packed(dev, vq);\n+\t\tvhost_vring_call(dev, vq);\n+\t}\n+\n+\treturn pkt_idx;\n+}\n+\n static __rte_always_inline uint32_t\n virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n \tstruct rte_mbuf **pkts, uint32_t count)\n@@ -804,7 +916,10 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n \tif (count == 0)\n \t\tgoto out;\n \n-\tcount = virtio_dev_rx_split(dev, vq, pkts, count);\n+\tif (vq_is_packed(dev))\n+\t\tcount = virtio_dev_rx_packed(dev, vq, pkts, count);\n+\telse\n+\t\tcount = virtio_dev_rx_split(dev, vq, pkts, count);\n \n out:\n \tif (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))\n",
    "prefixes": [
        "v7",
        "12/15"
    ]
}