get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 6904,
    "url": "https://patches.dpdk.org/api/patches/6904/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1441400308-5725-5-git-send-email-stephen@networkplumber.org/",
    "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": "<1441400308-5725-5-git-send-email-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1441400308-5725-5-git-send-email-stephen@networkplumber.org",
    "date": "2015-09-04T20:58:28",
    "name": "[dpdk-dev,4/4] virtio: use any layout on transmit",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "cc5a4bbd3abc432ef2ac0fd1b58e7356066243fd",
    "submitter": {
        "id": 27,
        "url": "https://patches.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1441400308-5725-5-git-send-email-stephen@networkplumber.org/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/6904/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/6904/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 CA5208D95;\n\tFri,  4 Sep 2015 22:58:38 +0200 (CEST)",
            "from mail-pa0-f46.google.com (mail-pa0-f46.google.com\n\t[209.85.220.46]) by dpdk.org (Postfix) with ESMTP id EFD0C8D8B\n\tfor <dev@dpdk.org>; Fri,  4 Sep 2015 22:58:36 +0200 (CEST)",
            "by pacfv12 with SMTP id fv12so35113169pac.2\n\tfor <dev@dpdk.org>; Fri, 04 Sep 2015 13:58:36 -0700 (PDT)",
            "from urahara.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net.\n\t[50.53.82.155]) by smtp.gmail.com with ESMTPSA id\n\tu5sm3524262pdr.63.2015.09.04.13.58.35\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tFri, 04 Sep 2015 13:58:35 -0700 (PDT)"
        ],
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=C4UHPu7jb3siAVO+MsYnJGa+LT1YUaajawY3dMaOHns=;\n\tb=cI2ZuwBbpACDLCpmU7c74PlCADk8wx450ahAospO1i3pt/2EkvFS95ChVumoulOHas\n\tSDy0wTP1fjT/gYEO03j4bTF3ddQ4NFmjP3MDK3ZDUTkFyT4DsMAGv9pEPa2X/R6BFiuC\n\tm1dSMFVXq5+bCWXUL7rpf7oG9FuhIH4K0VO4vw/Qm1mDytw8Tl0B8mTVwTWwRfspvFQQ\n\tm0f//NTafzc0SCS2iQVmU14wW55Sqd2kByxc8dmZitCMLXLEoZhiKytlNYkEbvksvPV3\n\tWo14k/LvvWZSFeDnCZZTUmlXWIRuSaJgUnSz63VVADFamuufP9Iq42jEw1F3bca4DQml\n\tFySg==",
        "X-Gm-Message-State": "ALoCoQmvHEwf2jBngU7adRpNEyIZ/BAcMLPJf0PQkXxaisUIAw4ve1bx9onbh9XmLogH1CxmwLA9",
        "X-Received": "by 10.66.154.97 with SMTP id vn1mr5098768pab.74.1441400316413;\n\tFri, 04 Sep 2015 13:58:36 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "huawei.xie@intel.com,\n\tchangchun.ouyang@intel.com",
        "Date": "Fri,  4 Sep 2015 13:58:28 -0700",
        "Message-Id": "<1441400308-5725-5-git-send-email-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.1.4",
        "In-Reply-To": "<1441400308-5725-1-git-send-email-stephen@networkplumber.org>",
        "References": "<1441400308-5725-1-git-send-email-stephen@networkplumber.org>",
        "Cc": "dev@dpdk.org",
        "Subject": "[dpdk-dev] [PATCH 4/4] virtio: use any layout on transmit",
        "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": "Virtio supports a feature that allows sender to put transmit\nheader prepended to data.  It requires that the mbuf be writeable, correct\nalignment, and the feature has been negotiatied.  If all this works out,\nthen it will be the optimum way to transmit a single segment packet.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n drivers/net/virtio/virtio_ethdev.h |  3 +-\n drivers/net/virtio/virtio_rxtx.c   | 67 ++++++++++++++++++++++++++------------\n 2 files changed, 49 insertions(+), 21 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h\nindex 07a9265..f260fbb 100644\n--- a/drivers/net/virtio/virtio_ethdev.h\n+++ b/drivers/net/virtio/virtio_ethdev.h\n@@ -65,7 +65,8 @@\n \t 1u << VIRTIO_NET_F_CTRL_RX\t  |\t\\\n \t 1u << VIRTIO_NET_F_CTRL_VLAN\t  |\t\\\n \t 1u << VIRTIO_NET_F_MRG_RXBUF     |\t\\\n-\t 1u << VIRTIO_RING_F_INDIRECT_DESC)\n+\t 1u << VIRTIO_RING_F_INDIRECT_DESC|\t\\\n+\t 1u << VIRTIO_F_ANY_LAYOUT)\n \n /*\n  * CQ function prototype\ndiff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c\nindex 8979695..5ec9b29 100644\n--- a/drivers/net/virtio/virtio_rxtx.c\n+++ b/drivers/net/virtio/virtio_rxtx.c\n@@ -200,13 +200,14 @@ virtqueue_enqueue_recv_refill(struct virtqueue *vq, struct rte_mbuf *cookie)\n \n static int\n virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie,\n-\t\t       int use_indirect)\n+\t\t       int use_indirect, int can_push)\n {\n \tstruct vq_desc_extra *dxp;\n \tstruct vring_desc *start_dp;\n \tuint16_t seg_num = cookie->nb_segs;\n-\tuint16_t needed = use_indirect ? 1 : 1 + seg_num;\n+\tuint16_t needed = use_indirect ? 1 : !can_push + seg_num;\n \tuint16_t head_idx, idx;\n+\tuint16_t head_size = txvq->hw->vtnet_hdr_size;\n \tunsigned long offs;\n \n \tif (unlikely(txvq->vq_free_cnt == 0))\n@@ -236,27 +237,31 @@ virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie,\n \t\tidx = 0;\n \t}\n \n-\toffs = offsetof(struct virtio_tx_region, tx_hdr)\n-\t\t+ idx * sizeof(struct virtio_tx_region);\n+\tif (can_push) {\n+\t\t/* put on zero'd transmit header (no offloads) */\n+\t\tvoid *hdr = rte_pktmbuf_prepend(cookie, head_size);\n \n-\tstart_dp[idx].addr = txvq->virtio_net_hdr_mem + offs;\n-\tstart_dp[idx].len = txvq->hw->vtnet_hdr_size;\n-\tstart_dp[idx].flags = VRING_DESC_F_NEXT;\n+\t\tmemset(hdr, 0, head_size);\n+\t} else {\n+\t\toffs = offsetof(struct virtio_tx_region, tx_hdr)\n+\t\t\t+ idx * sizeof(struct virtio_tx_region);\n \n-\tfor (; ((seg_num > 0) && (cookie != NULL)); seg_num--) {\n+\t\tstart_dp[idx].addr = txvq->virtio_net_hdr_mem + offs;\n+\t\tstart_dp[idx].len = head_size;\n+\t\tstart_dp[idx].flags = VRING_DESC_F_NEXT;\n \t\tidx = start_dp[idx].next;\n+\t}\n+\n+\tfor (; ((seg_num > 0) && (cookie != NULL)); seg_num--) {\n \t\tstart_dp[idx].addr  = RTE_MBUF_DATA_DMA_ADDR(cookie);\n \t\tstart_dp[idx].len   = cookie->data_len;\n-\t\tstart_dp[idx].flags = VRING_DESC_F_NEXT;\n \t\tcookie = cookie->next;\n+\t\tstart_dp[idx].flags = cookie ? VRING_DESC_F_NEXT : 0;\n+\t\tidx = start_dp[idx].next;\n \t}\n \n-\tstart_dp[idx].flags &= ~VRING_DESC_F_NEXT;\n-\n \tif (use_indirect)\n \t\tidx = txvq->vq_ring.desc[head_idx].next;\n-\telse\n-\t\tidx = start_dp[idx].next;\n \n \ttxvq->vq_desc_head_idx = idx;\n \tif (txvq->vq_desc_head_idx == VQ_RING_DESC_CHAIN_END)\n@@ -762,6 +767,26 @@ virtio_recv_mergeable_pkts(void *rx_queue,\n \treturn nb_rx;\n }\n \n+/* Evaluate whether the virtio header can just be put in place in the mbuf */\n+static int virtio_xmit_push_ok(const struct virtqueue *txvq,\n+\t\t\t       const struct rte_mbuf *m)\n+{\n+\tif (rte_mbuf_refcnt_read(m) != 1)\n+\t\treturn 0;\t/* no mbuf is shared */\n+\n+\tif (rte_pktmbuf_headroom(m) < txvq->hw->vtnet_hdr_size)\n+\t\treturn 0;\t/* no space in headroom */\n+\n+\tif (!rte_is_aligned(rte_pktmbuf_mtod(m, char *),\n+\t\t\t    sizeof(struct virtio_net_hdr_mrg_rxbuf)))\n+\t\treturn 0;\t/* not alligned */\n+\n+\tif (m->nb_segs > 1)\n+\t\treturn 0;\t/* better off using indirect */\n+\n+\treturn vtpci_with_feature(txvq->hw, VIRTIO_F_ANY_LAYOUT);\n+}\n+\n uint16_t\n virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)\n {\n@@ -781,14 +806,16 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)\n \n \tfor (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {\n \t\tstruct rte_mbuf *txm = tx_pkts[nb_tx];\n-\t\tint use_indirect, slots, need;\n-\n-\t\tuse_indirect = vtpci_with_feature(txvq->hw,\n-\t\t\t\t\t\t  VIRTIO_RING_F_INDIRECT_DESC)\n-\t\t\t&& (txm->nb_segs < VIRTIO_MAX_TX_INDIRECT);\n+\t\tint use_indirect = 0, slots, need;\n+\t\tint can_push = virtio_xmit_push_ok(txvq, txm);\n+\t\t\n+\t\tif (!can_push &&\n+\t\t    txm->nb_segs < VIRTIO_MAX_TX_INDIRECT &&\n+\t\t    vtpci_with_feature(txvq->hw, VIRTIO_RING_F_INDIRECT_DESC))\n+\t\t\tuse_indirect = 1;\n \n \t\t/* How many ring entries are needed to this Tx? */\n-\t\tslots = use_indirect ? 1 : 1 + txm->nb_segs;\n+\t\tslots = use_indirect ? 1 : !can_push + txm->nb_segs;\n \t\tneed = slots - txvq->vq_free_cnt;\n \n \t\t/* Positive value indicates it need free vring descriptors */\n@@ -816,7 +843,7 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)\n \t\t}\n \n \t\t/* Enqueue Packet buffers */\n-\t\terror = virtqueue_enqueue_xmit(txvq, txm, use_indirect);\n+\t\terror = virtqueue_enqueue_xmit(txvq, txm, use_indirect, can_push);\n \t\tif (unlikely(error)) {\n \t\t\tif (error == ENOSPC)\n \t\t\t\tPMD_TX_LOG(ERR, \"virtqueue_enqueue Free count = 0\");\n",
    "prefixes": [
        "dpdk-dev",
        "4/4"
    ]
}