get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 51321,
    "url": "https://patches.dpdk.org/api/patches/51321/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20190319064312.13743-5-tiwei.bie@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": "<20190319064312.13743-5-tiwei.bie@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190319064312.13743-5-tiwei.bie@intel.com",
    "date": "2019-03-19T06:43:06",
    "name": "[04/10] net/virtio: optimize flags update for packed ring",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "7901f24b13a62fba4cf78011230999f1d43d6bc9",
    "submitter": {
        "id": 617,
        "url": "https://patches.dpdk.org/api/people/617/?format=api",
        "name": "Tiwei Bie",
        "email": "tiwei.bie@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/20190319064312.13743-5-tiwei.bie@intel.com/mbox/",
    "series": [
        {
            "id": 3795,
            "url": "https://patches.dpdk.org/api/series/3795/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=3795",
            "date": "2019-03-19T06:43:02",
            "name": "net/virtio: cleanups and fixes for packed/split ring",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/3795/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/51321/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/51321/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 010BD4CC5;\n\tTue, 19 Mar 2019 07:43:51 +0100 (CET)",
            "from mga07.intel.com (mga07.intel.com [134.134.136.100])\n\tby dpdk.org (Postfix) with ESMTP id A032A2956\n\tfor <dev@dpdk.org>; Tue, 19 Mar 2019 07:43:39 +0100 (CET)",
            "from orsmga007.jf.intel.com ([10.7.209.58])\n\tby orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t18 Mar 2019 23:43:39 -0700",
            "from dpdk-tbie.sh.intel.com ([10.67.104.173])\n\tby orsmga007.jf.intel.com with ESMTP; 18 Mar 2019 23:43:38 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.58,496,1544515200\"; d=\"scan'208\";a=\"123847051\"",
        "From": "Tiwei Bie <tiwei.bie@intel.com>",
        "To": "maxime.coquelin@redhat.com,\n\tzhihong.wang@intel.com,\n\tdev@dpdk.org",
        "Date": "Tue, 19 Mar 2019 14:43:06 +0800",
        "Message-Id": "<20190319064312.13743-5-tiwei.bie@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20190319064312.13743-1-tiwei.bie@intel.com>",
        "References": "<20190319064312.13743-1-tiwei.bie@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 04/10] net/virtio: optimize flags update for\n\tpacked ring",
        "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Cache the AVAIL, USED and WRITE bits to avoid calculating\nthem as much as possible. Note that, the WRITE bit isn't\ncached for control queue.\n\nSigned-off-by: Tiwei Bie <tiwei.bie@intel.com>\n---\n drivers/net/virtio/virtio_ethdev.c | 35 ++++++++++++++----------------\n drivers/net/virtio/virtio_rxtx.c   | 31 ++++++++++----------------\n drivers/net/virtio/virtqueue.h     |  8 +++----\n 3 files changed, 32 insertions(+), 42 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c\nindex ff16fb63e..9060b6b33 100644\n--- a/drivers/net/virtio/virtio_ethdev.c\n+++ b/drivers/net/virtio/virtio_ethdev.c\n@@ -149,7 +149,7 @@ virtio_send_command_packed(struct virtnet_ctl *cvq,\n \tint head;\n \tstruct vring_packed_desc *desc = vq->ring_packed.desc_packed;\n \tstruct virtio_pmd_ctrl *result;\n-\tbool avail_wrap_counter;\n+\tuint16_t flags;\n \tint sum = 0;\n \tint nb_descs = 0;\n \tint k;\n@@ -161,14 +161,15 @@ virtio_send_command_packed(struct virtnet_ctl *cvq,\n \t * One RX packet for ACK.\n \t */\n \thead = vq->vq_avail_idx;\n-\tavail_wrap_counter = vq->avail_wrap_counter;\n+\tflags = vq->cached_flags;\n \tdesc[head].addr = cvq->virtio_net_hdr_mem;\n \tdesc[head].len = sizeof(struct virtio_net_ctrl_hdr);\n \tvq->vq_free_cnt--;\n \tnb_descs++;\n \tif (++vq->vq_avail_idx >= vq->vq_nentries) {\n \t\tvq->vq_avail_idx -= vq->vq_nentries;\n-\t\tvq->avail_wrap_counter ^= 1;\n+\t\tvq->cached_flags ^=\n+\t\t\tVRING_DESC_F_AVAIL(1) | VRING_DESC_F_USED(1);\n \t}\n \n \tfor (k = 0; k < pkt_num; k++) {\n@@ -177,34 +178,31 @@ virtio_send_command_packed(struct virtnet_ctl *cvq,\n \t\t\t+ sizeof(ctrl->status) + sizeof(uint8_t) * sum;\n \t\tdesc[vq->vq_avail_idx].len = dlen[k];\n \t\tdesc[vq->vq_avail_idx].flags = VRING_DESC_F_NEXT |\n-\t\t\tVRING_DESC_F_AVAIL(vq->avail_wrap_counter) |\n-\t\t\tVRING_DESC_F_USED(!vq->avail_wrap_counter);\n+\t\t\tvq->cached_flags;\n \t\tsum += dlen[k];\n \t\tvq->vq_free_cnt--;\n \t\tnb_descs++;\n \t\tif (++vq->vq_avail_idx >= vq->vq_nentries) {\n \t\t\tvq->vq_avail_idx -= vq->vq_nentries;\n-\t\t\tvq->avail_wrap_counter ^= 1;\n+\t\t\tvq->cached_flags ^=\n+\t\t\t\tVRING_DESC_F_AVAIL(1) | VRING_DESC_F_USED(1);\n \t\t}\n \t}\n \n \tdesc[vq->vq_avail_idx].addr = cvq->virtio_net_hdr_mem\n \t\t+ sizeof(struct virtio_net_ctrl_hdr);\n \tdesc[vq->vq_avail_idx].len = sizeof(ctrl->status);\n-\tdesc[vq->vq_avail_idx].flags = VRING_DESC_F_WRITE |\n-\t\tVRING_DESC_F_AVAIL(vq->avail_wrap_counter) |\n-\t\tVRING_DESC_F_USED(!vq->avail_wrap_counter);\n+\tdesc[vq->vq_avail_idx].flags = VRING_DESC_F_WRITE | vq->cached_flags;\n \tvq->vq_free_cnt--;\n \tnb_descs++;\n \tif (++vq->vq_avail_idx >= vq->vq_nentries) {\n \t\tvq->vq_avail_idx -= vq->vq_nentries;\n-\t\tvq->avail_wrap_counter ^= 1;\n+\t\tvq->cached_flags ^=\n+\t\t\tVRING_DESC_F_AVAIL(1) | VRING_DESC_F_USED(1);\n \t}\n \n \tvirtio_wmb(vq->hw->weak_barriers);\n-\tdesc[head].flags = VRING_DESC_F_NEXT |\n-\t\tVRING_DESC_F_AVAIL(avail_wrap_counter) |\n-\t\tVRING_DESC_F_USED(!avail_wrap_counter);\n+\tdesc[head].flags = VRING_DESC_F_NEXT | flags;\n \n \tvirtio_wmb(vq->hw->weak_barriers);\n \tvirtqueue_notify(vq);\n@@ -226,12 +224,12 @@ virtio_send_command_packed(struct virtnet_ctl *cvq,\n \tPMD_INIT_LOG(DEBUG, \"vq->vq_free_cnt=%d\\n\"\n \t\t\t\"vq->vq_avail_idx=%d\\n\"\n \t\t\t\"vq->vq_used_cons_idx=%d\\n\"\n-\t\t\t\"vq->avail_wrap_counter=%d\\n\"\n+\t\t\t\"vq->cached_flags=0x%x\\n\"\n \t\t\t\"vq->used_wrap_counter=%d\\n\",\n \t\t\tvq->vq_free_cnt,\n \t\t\tvq->vq_avail_idx,\n \t\t\tvq->vq_used_cons_idx,\n-\t\t\tvq->avail_wrap_counter,\n+\t\t\tvq->cached_flags,\n \t\t\tvq->used_wrap_counter);\n \n \tresult = cvq->virtio_net_hdr_mz->addr;\n@@ -491,11 +489,10 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx)\n \tvq->vq_nentries = vq_size;\n \tvq->event_flags_shadow = 0;\n \tif (vtpci_packed_queue(hw)) {\n-\t\tvq->avail_wrap_counter = 1;\n \t\tvq->used_wrap_counter = 1;\n-\t\tvq->avail_used_flags =\n-\t\t\tVRING_DESC_F_AVAIL(vq->avail_wrap_counter) |\n-\t\t\tVRING_DESC_F_USED(!vq->avail_wrap_counter);\n+\t\tvq->cached_flags = VRING_DESC_F_AVAIL(1);\n+\t\tif (queue_type == VTNET_RQ)\n+\t\t\tvq->cached_flags |= VRING_DESC_F_WRITE;\n \t}\n \n \t/*\ndiff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c\nindex 771d3c3f6..3c354baef 100644\n--- a/drivers/net/virtio/virtio_rxtx.c\n+++ b/drivers/net/virtio/virtio_rxtx.c\n@@ -431,7 +431,7 @@ virtqueue_enqueue_recv_refill_packed(struct virtqueue *vq,\n \t\t\t\t     struct rte_mbuf **cookie, uint16_t num)\n {\n \tstruct vring_packed_desc *start_dp = vq->ring_packed.desc_packed;\n-\tuint16_t flags = VRING_DESC_F_WRITE | vq->avail_used_flags;\n+\tuint16_t flags = vq->cached_flags;\n \tstruct virtio_hw *hw = vq->hw;\n \tstruct vq_desc_extra *dxp;\n \tuint16_t idx;\n@@ -460,11 +460,9 @@ virtqueue_enqueue_recv_refill_packed(struct virtqueue *vq,\n \t\tstart_dp[idx].flags = flags;\n \t\tif (++vq->vq_avail_idx >= vq->vq_nentries) {\n \t\t\tvq->vq_avail_idx -= vq->vq_nentries;\n-\t\t\tvq->avail_wrap_counter ^= 1;\n-\t\t\tvq->avail_used_flags =\n-\t\t\t\tVRING_DESC_F_AVAIL(vq->avail_wrap_counter) |\n-\t\t\t\tVRING_DESC_F_USED(!vq->avail_wrap_counter);\n-\t\t\tflags = VRING_DESC_F_WRITE | vq->avail_used_flags;\n+\t\t\tvq->cached_flags ^=\n+\t\t\t\tVRING_DESC_F_AVAIL(1) | VRING_DESC_F_USED(1);\n+\t\t\tflags = vq->cached_flags;\n \t\t}\n \t}\n \tvq->vq_free_cnt = (uint16_t)(vq->vq_free_cnt - num);\n@@ -643,7 +641,7 @@ virtqueue_enqueue_xmit_packed_fast(struct virtnet_tx *txvq,\n \tdxp->ndescs = 1;\n \tdxp->cookie = cookie;\n \n-\tflags = vq->avail_used_flags;\n+\tflags = vq->cached_flags;\n \n \t/* prepend cannot fail, checked by caller */\n \thdr = (struct virtio_net_hdr *)\n@@ -662,8 +660,7 @@ virtqueue_enqueue_xmit_packed_fast(struct virtnet_tx *txvq,\n \n \tif (++vq->vq_avail_idx >= vq->vq_nentries) {\n \t\tvq->vq_avail_idx -= vq->vq_nentries;\n-\t\tvq->avail_wrap_counter ^= 1;\n-\t\tvq->avail_used_flags ^=\n+\t\tvq->cached_flags ^=\n \t\t\tVRING_DESC_F_AVAIL(1) | VRING_DESC_F_USED(1);\n \t}\n \n@@ -705,7 +702,7 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie,\n \n \thead_dp = &vq->ring_packed.desc_packed[idx];\n \thead_flags = cookie->next ? VRING_DESC_F_NEXT : 0;\n-\thead_flags |= vq->avail_used_flags;\n+\thead_flags |= vq->cached_flags;\n \n \tif (can_push) {\n \t\t/* prepend cannot fail, checked by caller */\n@@ -730,10 +727,8 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie,\n \t\tidx++;\n \t\tif (idx >= vq->vq_nentries) {\n \t\t\tidx -= vq->vq_nentries;\n-\t\t\tvq->avail_wrap_counter ^= 1;\n-\t\t\tvq->avail_used_flags =\n-\t\t\t\tVRING_DESC_F_AVAIL(vq->avail_wrap_counter) |\n-\t\t\t\tVRING_DESC_F_USED(!vq->avail_wrap_counter);\n+\t\t\tvq->cached_flags ^=\n+\t\t\t\tVRING_DESC_F_AVAIL(1) | VRING_DESC_F_USED(1);\n \t\t}\n \t}\n \n@@ -746,17 +741,15 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie,\n \t\tstart_dp[idx].len  = cookie->data_len;\n \t\tif (likely(idx != head_idx)) {\n \t\t\tflags = cookie->next ? VRING_DESC_F_NEXT : 0;\n-\t\t\tflags |= vq->avail_used_flags;\n+\t\t\tflags |= vq->cached_flags;\n \t\t\tstart_dp[idx].flags = flags;\n \t\t}\n \t\tprev = idx;\n \t\tidx++;\n \t\tif (idx >= vq->vq_nentries) {\n \t\t\tidx -= vq->vq_nentries;\n-\t\t\tvq->avail_wrap_counter ^= 1;\n-\t\t\tvq->avail_used_flags =\n-\t\t\t\tVRING_DESC_F_AVAIL(vq->avail_wrap_counter) |\n-\t\t\t\tVRING_DESC_F_USED(!vq->avail_wrap_counter);\n+\t\t\tvq->cached_flags ^=\n+\t\t\t\tVRING_DESC_F_AVAIL(1) | VRING_DESC_F_USED(1);\n \t\t}\n \t} while ((cookie = cookie->next) != NULL);\n \ndiff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h\nindex 24fa873c3..80c0c43c3 100644\n--- a/drivers/net/virtio/virtqueue.h\n+++ b/drivers/net/virtio/virtqueue.h\n@@ -193,10 +193,10 @@ struct virtqueue {\n \tstruct virtio_hw  *hw; /**< virtio_hw structure pointer. */\n \tstruct vring vq_ring;  /**< vring keeping desc, used and avail */\n \tstruct vring_packed ring_packed;  /**< vring keeping descs */\n-\tbool avail_wrap_counter;\n \tbool used_wrap_counter;\n+\tuint16_t cached_flags; /**< cached flags for descs */\n \tuint16_t event_flags_shadow;\n-\tuint16_t avail_used_flags;\n+\n \t/**\n \t * Last consumed descriptor in the used table,\n \t * trails vq_ring.used->idx.\n@@ -478,9 +478,9 @@ virtqueue_notify(struct virtqueue *vq)\n \tif (vtpci_packed_queue((vq)->hw)) { \\\n \t\tPMD_INIT_LOG(DEBUG, \\\n \t\t\"VQ: - size=%d; free=%d; used_cons_idx=%d; avail_idx=%d;\" \\\n-\t\t\"VQ: - avail_wrap_counter=%d; used_wrap_counter=%d\", \\\n+\t\t\" cached_flags=0x%x; used_wrap_counter=%d\", \\\n \t\t(vq)->vq_nentries, (vq)->vq_free_cnt, (vq)->vq_used_cons_idx, \\\n-\t\t(vq)->vq_avail_idx, (vq)->avail_wrap_counter, \\\n+\t\t(vq)->vq_avail_idx, (vq)->cached_flags, \\\n \t\t(vq)->used_wrap_counter); \\\n \t\tbreak; \\\n \t} \\\n",
    "prefixes": [
        "04/10"
    ]
}