get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 10215,
    "url": "https://patches.dpdk.org/api/patches/10215/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1454043483-24579-4-git-send-email-yuanhan.liu@linux.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": "<1454043483-24579-4-git-send-email-yuanhan.liu@linux.intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1454043483-24579-4-git-send-email-yuanhan.liu@linux.intel.com",
    "date": "2016-01-29T04:57:58",
    "name": "[dpdk-dev,v3,3/8] vhost: log used vring changes",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "03f1e26ed0cf36f7a41ee55900d094a9aa714bc0",
    "submitter": {
        "id": 307,
        "url": "https://patches.dpdk.org/api/people/307/?format=api",
        "name": "Yuanhan Liu",
        "email": "yuanhan.liu@linux.intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1454043483-24579-4-git-send-email-yuanhan.liu@linux.intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/10215/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/10215/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 36412C550;\n\tFri, 29 Jan 2016 05:57:28 +0100 (CET)",
            "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby dpdk.org (Postfix) with ESMTP id 1F975C54A\n\tfor <dev@dpdk.org>; Fri, 29 Jan 2016 05:57:26 +0100 (CET)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby orsmga102.jf.intel.com with ESMTP; 28 Jan 2016 20:57:25 -0800",
            "from yliu-dev.sh.intel.com ([10.239.66.49])\n\tby fmsmga001.fm.intel.com with ESMTP; 28 Jan 2016 20:57:23 -0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.22,362,1449561600\"; d=\"scan'208\";a=\"891622433\"",
        "From": "Yuanhan Liu <yuanhan.liu@linux.intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Fri, 29 Jan 2016 12:57:58 +0800",
        "Message-Id": "<1454043483-24579-4-git-send-email-yuanhan.liu@linux.intel.com>",
        "X-Mailer": "git-send-email 1.9.0",
        "In-Reply-To": "<1454043483-24579-1-git-send-email-yuanhan.liu@linux.intel.com>",
        "References": "<1450321921-27799-1-git-send-email-yuanhan.liu@linux.intel.com>\n\t<1454043483-24579-1-git-send-email-yuanhan.liu@linux.intel.com>",
        "Cc": "\"Michael S. Tsirkin\" <mst@redhat.com>,\n\tVictor Kaplansky <vkaplans@redhat.com>",
        "Subject": "[dpdk-dev] [PATCH v3 3/8] vhost: log used vring changes",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://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": "<http://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": "Every time we update virtio used ring, we need to log it. And it's\nbeen done by a new vhost_log_write() wrapper, vhost_log_used_vring().\n\nSigned-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>\nSigned-off-by: Victor Kaplansky <victork@redhat.com>\nTested-by: Pavel Fedin <p.fedin@samsung.com>\n---\n\nv3: remove the unnecessary var \"addr\" iat vhost_log_used_vring()\n---\n lib/librte_vhost/rte_virtio_net.h |  3 +-\n lib/librte_vhost/vhost_rxtx.c     | 77 +++++++++++++++++++++++++++------------\n lib/librte_vhost/virtio-net.c     |  4 ++\n 3 files changed, 59 insertions(+), 25 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h\nindex 2c891ae..4a2303a 100644\n--- a/lib/librte_vhost/rte_virtio_net.h\n+++ b/lib/librte_vhost/rte_virtio_net.h\n@@ -91,7 +91,8 @@ struct vhost_virtqueue {\n \tint\t\t\tcallfd;\t\t\t/**< Used to notify the guest (trigger interrupt). */\n \tint\t\t\tkickfd;\t\t\t/**< Currently unused as polling mode is enabled. */\n \tint\t\t\tenabled;\n-\tuint64_t\t\treserved[16];\t\t/**< Reserve some spaces for future extension. */\n+\tuint64_t\t\tlog_guest_addr;\t\t/**< Physical address of used ring, for logging */\n+\tuint64_t\t\treserved[15];\t\t/**< Reserve some spaces for future extension. */\n \tstruct buf_vector\tbuf_vec[BUF_VECTOR_MAX];\t/**< for scatter RX. */\n } __rte_cache_aligned;\n \ndiff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c\nindex d485364..9f7b1f8 100644\n--- a/lib/librte_vhost/vhost_rxtx.c\n+++ b/lib/librte_vhost/vhost_rxtx.c\n@@ -72,6 +72,13 @@ vhost_log_write(struct virtio_net *dev, uint64_t addr, uint64_t len)\n \t}\n }\n \n+static inline void __attribute__((always_inline))\n+vhost_log_used_vring(struct virtio_net *dev, struct vhost_virtqueue *vq,\n+\t\t     uint64_t offset, uint64_t len)\n+{\n+\tvhost_log_write(dev, vq->log_guest_addr + offset, len);\n+}\n+\n static bool\n is_valid_virt_queue_idx(uint32_t idx, int is_tx, uint32_t qp_nb)\n {\n@@ -158,6 +165,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n \t\tuint32_t offset = 0, vb_offset = 0;\n \t\tuint32_t pkt_len, len_to_cpy, data_len, total_copied = 0;\n \t\tuint8_t hdr = 0, uncompleted_pkt = 0;\n+\t\tuint16_t idx;\n \n \t\t/* Get descriptor from available ring */\n \t\tdesc = &vq->desc[head[packet_success]];\n@@ -229,16 +237,18 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n \t\t}\n \n \t\t/* Update used ring with desc information */\n-\t\tvq->used->ring[res_cur_idx & (vq->size - 1)].id =\n-\t\t\t\t\t\t\thead[packet_success];\n+\t\tidx = res_cur_idx & (vq->size - 1);\n+\t\tvq->used->ring[idx].id = head[packet_success];\n \n \t\t/* Drop the packet if it is uncompleted */\n \t\tif (unlikely(uncompleted_pkt == 1))\n-\t\t\tvq->used->ring[res_cur_idx & (vq->size - 1)].len =\n-\t\t\t\t\t\t\tvq->vhost_hlen;\n+\t\t\tvq->used->ring[idx].len = vq->vhost_hlen;\n \t\telse\n-\t\t\tvq->used->ring[res_cur_idx & (vq->size - 1)].len =\n-\t\t\t\t\t\t\tpkt_len + vq->vhost_hlen;\n+\t\t\tvq->used->ring[idx].len = pkt_len + vq->vhost_hlen;\n+\n+\t\tvhost_log_used_vring(dev, vq,\n+\t\t\toffsetof(struct vring_used, ring[idx]),\n+\t\t\tsizeof(vq->used->ring[idx]));\n \n \t\tres_cur_idx++;\n \t\tpacket_success++;\n@@ -265,6 +275,9 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n \n \t*(volatile uint16_t *)&vq->used->idx += count;\n \tvq->last_used_idx = res_end_idx;\n+\tvhost_log_used_vring(dev, vq,\n+\t\toffsetof(struct vring_used, idx),\n+\t\tsizeof(vq->used->idx));\n \n \t/* flush used->idx update before we read avail->flags. */\n \trte_mb();\n@@ -294,6 +307,7 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint32_t queue_id,\n \tuint32_t seg_avail;\n \tuint32_t vb_avail;\n \tuint32_t cpy_len, entry_len;\n+\tuint16_t idx;\n \n \tif (pkt == NULL)\n \t\treturn 0;\n@@ -331,16 +345,18 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint32_t queue_id,\n \tentry_len = vq->vhost_hlen;\n \n \tif (vb_avail == 0) {\n-\t\tuint32_t desc_idx =\n-\t\t\tvq->buf_vec[vec_idx].desc_idx;\n+\t\tuint32_t desc_idx = vq->buf_vec[vec_idx].desc_idx;\n+\n+\t\tif ((vq->desc[desc_idx].flags & VRING_DESC_F_NEXT) == 0) {\n+\t\t\tidx = cur_idx & (vq->size - 1);\n \n-\t\tif ((vq->desc[desc_idx].flags\n-\t\t\t& VRING_DESC_F_NEXT) == 0) {\n \t\t\t/* Update used ring with desc information */\n-\t\t\tvq->used->ring[cur_idx & (vq->size - 1)].id\n-\t\t\t\t= vq->buf_vec[vec_idx].desc_idx;\n-\t\t\tvq->used->ring[cur_idx & (vq->size - 1)].len\n-\t\t\t\t= entry_len;\n+\t\t\tvq->used->ring[idx].id = vq->buf_vec[vec_idx].desc_idx;\n+\t\t\tvq->used->ring[idx].len = entry_len;\n+\n+\t\t\tvhost_log_used_vring(dev, vq,\n+\t\t\t\t\toffsetof(struct vring_used, ring[idx]),\n+\t\t\t\t\tsizeof(vq->used->ring[idx]));\n \n \t\t\tentry_len = 0;\n \t\t\tcur_idx++;\n@@ -383,10 +399,13 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint32_t queue_id,\n \t\t\tif ((vq->desc[vq->buf_vec[vec_idx].desc_idx].flags &\n \t\t\t\tVRING_DESC_F_NEXT) == 0) {\n \t\t\t\t/* Update used ring with desc information */\n-\t\t\t\tvq->used->ring[cur_idx & (vq->size - 1)].id\n+\t\t\t\tidx = cur_idx & (vq->size - 1);\n+\t\t\t\tvq->used->ring[idx].id\n \t\t\t\t\t= vq->buf_vec[vec_idx].desc_idx;\n-\t\t\t\tvq->used->ring[cur_idx & (vq->size - 1)].len\n-\t\t\t\t\t= entry_len;\n+\t\t\t\tvq->used->ring[idx].len = entry_len;\n+\t\t\t\tvhost_log_used_vring(dev, vq,\n+\t\t\t\t\toffsetof(struct vring_used, ring[idx]),\n+\t\t\t\t\tsizeof(vq->used->ring[idx]));\n \t\t\t\tentry_len = 0;\n \t\t\t\tcur_idx++;\n \t\t\t\tentry_success++;\n@@ -419,16 +438,18 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint32_t queue_id,\n \n \t\t\t\t\tif ((vq->desc[desc_idx].flags &\n \t\t\t\t\t\tVRING_DESC_F_NEXT) == 0) {\n-\t\t\t\t\t\tuint16_t wrapped_idx =\n-\t\t\t\t\t\t\tcur_idx & (vq->size - 1);\n+\t\t\t\t\t\tidx = cur_idx & (vq->size - 1);\n \t\t\t\t\t\t/*\n \t\t\t\t\t\t * Update used ring with the\n \t\t\t\t\t\t * descriptor information\n \t\t\t\t\t\t */\n-\t\t\t\t\t\tvq->used->ring[wrapped_idx].id\n+\t\t\t\t\t\tvq->used->ring[idx].id\n \t\t\t\t\t\t\t= desc_idx;\n-\t\t\t\t\t\tvq->used->ring[wrapped_idx].len\n+\t\t\t\t\t\tvq->used->ring[idx].len\n \t\t\t\t\t\t\t= entry_len;\n+\t\t\t\t\t\tvhost_log_used_vring(dev, vq,\n+\t\t\t\t\t\t\toffsetof(struct vring_used, ring[idx]),\n+\t\t\t\t\t\t\tsizeof(vq->used->ring[idx]));\n \t\t\t\t\t\tentry_success++;\n \t\t\t\t\t\tentry_len = 0;\n \t\t\t\t\t\tcur_idx++;\n@@ -451,10 +472,13 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint32_t queue_id,\n \t\t\t\t * This whole packet completes.\n \t\t\t\t */\n \t\t\t\t/* Update used ring with desc information */\n-\t\t\t\tvq->used->ring[cur_idx & (vq->size - 1)].id\n+\t\t\t\tidx = cur_idx & (vq->size - 1);\n+\t\t\t\tvq->used->ring[idx].id\n \t\t\t\t\t= vq->buf_vec[vec_idx].desc_idx;\n-\t\t\t\tvq->used->ring[cur_idx & (vq->size - 1)].len\n-\t\t\t\t\t= entry_len;\n+\t\t\t\tvq->used->ring[idx].len = entry_len;\n+\t\t\t\tvhost_log_used_vring(dev, vq,\n+\t\t\t\t\toffsetof(struct vring_used, ring[idx]),\n+\t\t\t\t\tsizeof(vq->used->ring[idx]));\n \t\t\t\tentry_success++;\n \t\t\t\tbreak;\n \t\t\t}\n@@ -682,6 +706,9 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,\n \t\t/* Update used index buffer information. */\n \t\tvq->used->ring[used_idx].id = head[entry_success];\n \t\tvq->used->ring[used_idx].len = 0;\n+\t\tvhost_log_used_vring(dev, vq,\n+\t\t\t\toffsetof(struct vring_used, ring[used_idx]),\n+\t\t\t\tsizeof(vq->used->ring[used_idx]));\n \n \t\t/* Allocate an mbuf and populate the structure. */\n \t\tm = rte_pktmbuf_alloc(mbuf_pool);\n@@ -802,6 +829,8 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,\n \n \trte_compiler_barrier();\n \tvq->used->idx += entry_success;\n+\tvhost_log_used_vring(dev, vq, offsetof(struct vring_used, idx),\n+\t\t\tsizeof(vq->used->idx));\n \t/* Kick guest if required. */\n \tif (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT))\n \t\teventfd_write(vq->callfd, (eventfd_t)1);\ndiff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c\nindex de78a0f..03044f6 100644\n--- a/lib/librte_vhost/virtio-net.c\n+++ b/lib/librte_vhost/virtio-net.c\n@@ -666,12 +666,16 @@ set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr)\n \t\treturn -1;\n \t}\n \n+\tvq->log_guest_addr = addr->log_guest_addr;\n+\n \tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") mapped address desc: %p\\n\",\n \t\t\tdev->device_fh, vq->desc);\n \tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") mapped address avail: %p\\n\",\n \t\t\tdev->device_fh, vq->avail);\n \tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") mapped address used: %p\\n\",\n \t\t\tdev->device_fh, vq->used);\n+\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") log_guest_addr: %\"PRIx64\"\\n\",\n+\t\t\tdev->device_fh, vq->log_guest_addr);\n \n \treturn 0;\n }\n",
    "prefixes": [
        "dpdk-dev",
        "v3",
        "3/8"
    ]
}