get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 16932,
    "url": "https://patches.dpdk.org/api/patches/16932/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1478251718-7464-1-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": "<1478251718-7464-1-git-send-email-yuanhan.liu@linux.intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1478251718-7464-1-git-send-email-yuanhan.liu@linux.intel.com",
    "date": "2016-11-04T09:28:38",
    "name": "[dpdk-dev] net/virtio: cache Rx/Tx offload enabled check",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "41280ae9550ca0808f4372452f6e1658ae55c9e0",
    "submitter": {
        "id": 307,
        "url": "https://patches.dpdk.org/api/people/307/?format=api",
        "name": "Yuanhan Liu",
        "email": "yuanhan.liu@linux.intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1478251718-7464-1-git-send-email-yuanhan.liu@linux.intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/16932/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/16932/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 74BD028FD;\n\tFri,  4 Nov 2016 10:28:04 +0100 (CET)",
            "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby dpdk.org (Postfix) with ESMTP id 074002716\n\tfor <dev@dpdk.org>; Fri,  4 Nov 2016 10:28:00 +0100 (CET)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby orsmga102.jf.intel.com with ESMTP; 04 Nov 2016 02:27:48 -0700",
            "from yliu-dev.sh.intel.com ([10.239.67.162])\n\tby fmsmga006.fm.intel.com with ESMTP; 04 Nov 2016 02:27:46 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.31,442,1473145200\"; d=\"scan'208\";a=\"27325332\"",
        "From": "Yuanhan Liu <yuanhan.liu@linux.intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Yuanhan Liu <yuanhan.liu@linux.intel.com>,\n\tOlivier Matz <olivier.matz@6wind.com>",
        "Date": "Fri,  4 Nov 2016 17:28:38 +0800",
        "Message-Id": "<1478251718-7464-1-git-send-email-yuanhan.liu@linux.intel.com>",
        "X-Mailer": "git-send-email 1.9.0",
        "Subject": "[dpdk-dev] [PATCH] net/virtio: cache Rx/Tx offload enabled check",
        "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": "It's not a good idea to do Rx/Tx offload enabled check at the data\npath. Instead, we could do the check at init stage and store the\nresult, so that we could avoid the check again and again at the\ncritical datapath.\n\nCc: Olivier Matz <olivier.matz@6wind.com>\nSigned-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>\n---\n drivers/net/virtio/virtio_ethdev.c | 19 +++++++++++++++++++\n drivers/net/virtio/virtio_pci.h    |  2 ++\n drivers/net/virtio/virtio_rxtx.c   | 30 ++++--------------------------\n 3 files changed, 25 insertions(+), 26 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c\nindex b388134..708c0e0 100644\n--- a/drivers/net/virtio/virtio_ethdev.c\n+++ b/drivers/net/virtio/virtio_ethdev.c\n@@ -1141,6 +1141,22 @@ rx_func_get(struct rte_eth_dev *eth_dev)\n \t\teth_dev->rx_pkt_burst = &virtio_recv_pkts;\n }\n \n+static inline int\n+rx_offload_enabled(struct virtio_hw *hw)\n+{\n+\treturn vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_CSUM) ||\n+\t\tvtpci_with_feature(hw, VIRTIO_NET_F_GUEST_TSO4) ||\n+\t\tvtpci_with_feature(hw, VIRTIO_NET_F_GUEST_TSO6);\n+}\n+\n+static inline int\n+tx_offload_enabled(struct virtio_hw *hw)\n+{\n+\treturn vtpci_with_feature(hw, VIRTIO_NET_F_CSUM) ||\n+\t\tvtpci_with_feature(hw, VIRTIO_NET_F_HOST_TSO4) ||\n+\t\tvtpci_with_feature(hw, VIRTIO_NET_F_HOST_TSO6);\n+}\n+\n /* reset device and renegotiate features if needed */\n static int\n virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)\n@@ -1161,6 +1177,9 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)\n \tif (virtio_negotiate_features(hw, req_features) < 0)\n \t\treturn -1;\n \n+\thw->tx_offload = tx_offload_enabled(hw);\n+\thw->rx_offload = rx_offload_enabled(hw);\n+\n \t/* If host does not support status then disable LSC */\n \tif (!vtpci_with_feature(hw, VIRTIO_NET_F_STATUS))\n \t\teth_dev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC;\ndiff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h\nindex 0c5ed31..442eed2 100644\n--- a/drivers/net/virtio/virtio_pci.h\n+++ b/drivers/net/virtio/virtio_pci.h\n@@ -264,6 +264,8 @@ struct virtio_hw {\n \tstruct virtio_net_config *dev_cfg;\n \tconst struct virtio_pci_ops *vtpci_ops;\n \tvoid\t    *virtio_user_dev;\n+\tint         tx_offload;\n+\tint         rx_offload;\n };\n \n /*\ndiff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c\nindex b4c4aa4..ba46595 100644\n--- a/drivers/net/virtio/virtio_rxtx.c\n+++ b/drivers/net/virtio/virtio_rxtx.c\n@@ -250,14 +250,6 @@ virtio_tso_fix_cksum(struct rte_mbuf *m)\n \t}\n }\n \n-static inline int\n-tx_offload_enabled(struct virtio_hw *hw)\n-{\n-\treturn vtpci_with_feature(hw, VIRTIO_NET_F_CSUM) ||\n-\t\tvtpci_with_feature(hw, VIRTIO_NET_F_HOST_TSO4) ||\n-\t\tvtpci_with_feature(hw, VIRTIO_NET_F_HOST_TSO6);\n-}\n-\n static inline void\n virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie,\n \t\t       uint16_t needed, int use_indirect, int can_push)\n@@ -270,9 +262,7 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie,\n \tuint16_t head_idx, idx;\n \tuint16_t head_size = vq->hw->vtnet_hdr_size;\n \tstruct virtio_net_hdr *hdr;\n-\tint offload;\n \n-\toffload = tx_offload_enabled(vq->hw);\n \thead_idx = vq->vq_desc_head_idx;\n \tidx = head_idx;\n \tdxp = &vq->vq_descx[idx];\n@@ -286,7 +276,7 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie,\n \t\thdr = (struct virtio_net_hdr *)\n \t\t\trte_pktmbuf_prepend(cookie, head_size);\n \t\t/* if offload disabled, it is not zeroed below, do it now */\n-\t\tif (offload == 0)\n+\t\tif (vq->hw->tx_offload == 0)\n \t\t\tmemset(hdr, 0, head_size);\n \t} else if (use_indirect) {\n \t\t/* setup tx ring slot to point to indirect\n@@ -318,7 +308,7 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie,\n \t}\n \n \t/* Checksum Offload / TSO */\n-\tif (offload) {\n+\tif (vq->hw->tx_offload) {\n \t\tif (cookie->ol_flags & PKT_TX_TCP_SEG)\n \t\t\tcookie->ol_flags |= PKT_TX_TCP_CKSUM;\n \n@@ -798,14 +788,6 @@ virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr)\n \treturn 0;\n }\n \n-static inline int\n-rx_offload_enabled(struct virtio_hw *hw)\n-{\n-\treturn vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_CSUM) ||\n-\t\tvtpci_with_feature(hw, VIRTIO_NET_F_GUEST_TSO4) ||\n-\t\tvtpci_with_feature(hw, VIRTIO_NET_F_GUEST_TSO6);\n-}\n-\n #define VIRTIO_MBUF_BURST_SZ 64\n #define DESC_PER_CACHELINE (RTE_CACHE_LINE_SIZE / sizeof(struct vring_desc))\n uint16_t\n@@ -821,7 +803,6 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)\n \tint error;\n \tuint32_t i, nb_enqueued;\n \tuint32_t hdr_size;\n-\tint offload;\n \tstruct virtio_net_hdr *hdr;\n \n \tnb_used = VIRTQUEUE_NUSED(vq);\n@@ -840,7 +821,6 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)\n \tnb_rx = 0;\n \tnb_enqueued = 0;\n \thdr_size = hw->vtnet_hdr_size;\n-\toffload = rx_offload_enabled(hw);\n \n \tfor (i = 0; i < num ; i++) {\n \t\trxm = rcv_pkts[i];\n@@ -871,7 +851,7 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)\n \t\tif (hw->vlan_strip)\n \t\t\trte_vlan_strip(rxm);\n \n-\t\tif (offload && virtio_rx_offload(rxm, hdr) < 0) {\n+\t\tif (hw->rx_offload && virtio_rx_offload(rxm, hdr) < 0) {\n \t\t\tvirtio_discard_rxbuf(vq, rxm);\n \t\t\trxvq->stats.errors++;\n \t\t\tcontinue;\n@@ -936,7 +916,6 @@ virtio_recv_mergeable_pkts(void *rx_queue,\n \tuint16_t extra_idx;\n \tuint32_t seg_res;\n \tuint32_t hdr_size;\n-\tint offload;\n \n \tnb_used = VIRTQUEUE_NUSED(vq);\n \n@@ -952,7 +931,6 @@ virtio_recv_mergeable_pkts(void *rx_queue,\n \textra_idx = 0;\n \tseg_res = 0;\n \thdr_size = hw->vtnet_hdr_size;\n-\toffload = rx_offload_enabled(hw);\n \n \twhile (i < nb_used) {\n \t\tstruct virtio_net_hdr_mrg_rxbuf *header;\n@@ -998,7 +976,7 @@ virtio_recv_mergeable_pkts(void *rx_queue,\n \t\trx_pkts[nb_rx] = rxm;\n \t\tprev = rxm;\n \n-\t\tif (offload && virtio_rx_offload(rxm, &header->hdr) < 0) {\n+\t\tif (hw->rx_offload && virtio_rx_offload(rxm, &header->hdr) < 0) {\n \t\t\tvirtio_discard_rxbuf(vq, rxm);\n \t\t\trxvq->stats.errors++;\n \t\t\tcontinue;\n",
    "prefixes": [
        "dpdk-dev"
    ]
}