get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 9604,
    "url": "http://patches.dpdk.org/api/patches/9604/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1450675280-12056-3-git-send-email-jijiang.liu@intel.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<1450675280-12056-3-git-send-email-jijiang.liu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1450675280-12056-3-git-send-email-jijiang.liu@intel.com",
    "date": "2015-12-21T05:21:18",
    "name": "[dpdk-dev,v6,2/4] vhost/lib: add guest offload setting",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "803201207680e2f1f815313ba9f71e1d7328dc98",
    "submitter": {
        "id": 52,
        "url": "http://patches.dpdk.org/api/people/52/?format=api",
        "name": "Jijiang Liu",
        "email": "jijiang.liu@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1450675280-12056-3-git-send-email-jijiang.liu@intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/9604/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/9604/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 D92728DAF;\n\tMon, 21 Dec 2015 06:21:37 +0100 (CET)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id F04AE5A4F\n\tfor <dev@dpdk.org>; Mon, 21 Dec 2015 06:21:34 +0100 (CET)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga101.jf.intel.com with ESMTP; 20 Dec 2015 21:21:34 -0800",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby fmsmga002.fm.intel.com with ESMTP; 20 Dec 2015 21:21:32 -0800",
            "from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com\n\t[10.239.29.89])\n\tby shvmail01.sh.intel.com with ESMTP id tBL5LUEC025894;\n\tMon, 21 Dec 2015 13:21:30 +0800",
            "from shecgisg004.sh.intel.com (localhost [127.0.0.1])\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP\n\tid tBL5LQnx012105; Mon, 21 Dec 2015 13:21:28 +0800",
            "(from jijiangl@localhost)\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id tBL5LQAt012101; \n\tMon, 21 Dec 2015 13:21:26 +0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.20,458,1444719600\"; d=\"scan'208\";a=\"877985641\"",
        "From": "Jijiang Liu <jijiang.liu@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Mon, 21 Dec 2015 13:21:18 +0800",
        "Message-Id": "<1450675280-12056-3-git-send-email-jijiang.liu@intel.com>",
        "X-Mailer": "git-send-email 1.7.12.2",
        "In-Reply-To": "<1450675280-12056-1-git-send-email-jijiang.liu@intel.com>",
        "References": "<1450675280-12056-1-git-send-email-jijiang.liu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v6 2/4] vhost/lib: add guest offload setting",
        "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": "Add guest offload setting in vhost lib.\n\nRefer to the feature bits description in the Virtual I/O Device (VIRTIO) Version 1.0 below, \n\n1. VIRTIO_NET_F_GUEST_CSUM (1) Driver handles packets with partial checksum.\n\n2. If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the VIRTIO_NET_HDR_F_NEEDS_- CSUM bit in flags MAY be set: if so, the checksum on the packet is incomplete and csum_start and csum_offset indicate how to calculate it (see Packet Transmission point 1).\n\n3. If the VIRTIO_NET_F_GUEST_TSO4, TSO6 or UFO options were negotiated, then gso_type MAY be something other than VIRTIO_NET_HDR_GSO_NONE, and gso_size field indicates the desired MSS (see Packet Transmission point 2).\n\nIn order to support these features, the following changes are added,\n \n1. Extend 'VHOST_SUPPORTED_FEATURES' macro to add the offload features negotiation.\n \n2. Enqueue these offloads: convert some fields in mbuf to the fields in virtio_net_hdr.\n\nThere are more explanations for the implementation.\n\nFor VM2VM case, there is no need to do checksum, for we\nthink the data should be reliable enough, and setting VIRTIO_NET_HDR_F_NEEDS_CSUM\nat RX side will let the TCP layer to bypass the checksum validation,\nso that the RX side could receive the packet in the end.\n\nIn terms of us-vhost, at vhost RX side, the offload information is inherited from mbuf, which is\nin turn inherited from TX side. If we can still get those info at RX\nside, it means the packet is from another VM at same host.  So, it's\nsafe to set the VIRTIO_NET_HDR_F_NEEDS_CSUM, to skip checksum validation.\n\nSigned-off-by: Jijiang Liu <jijiang.liu@intel.com>\n---\n lib/librte_vhost/vhost_rxtx.c |   47 +++++++++++++++++++++++++++++++++++++++-\n lib/librte_vhost/virtio-net.c |    5 +++-\n 2 files changed, 49 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c\nindex 47d5f85..9d97e19 100644\n--- a/lib/librte_vhost/vhost_rxtx.c\n+++ b/lib/librte_vhost/vhost_rxtx.c\n@@ -54,6 +54,44 @@ is_valid_virt_queue_idx(uint32_t idx, int is_tx, uint32_t qp_nb)\n \treturn (is_tx ^ (idx & 1)) == 0 && idx < qp_nb * VIRTIO_QNUM;\n }\n \n+static void\n+virtio_enqueue_offload(struct rte_mbuf *m_buf, struct virtio_net_hdr *net_hdr)\n+{\n+\tmemset(net_hdr, 0, sizeof(struct virtio_net_hdr));\n+\n+\tif (m_buf->ol_flags & PKT_TX_L4_MASK) {\n+\t\tnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;\n+\t\tnet_hdr->csum_start = m_buf->l2_len + m_buf->l3_len;\n+\n+\t\tswitch (m_buf->ol_flags & PKT_TX_L4_MASK) {\n+\t\tcase PKT_TX_TCP_CKSUM:\n+\t\t\tnet_hdr->csum_offset = (offsetof(struct tcp_hdr,\n+\t\t\t\t\t\tcksum));\n+\t\t\tbreak;\n+\t\tcase PKT_TX_UDP_CKSUM:\n+\t\t\tnet_hdr->csum_offset = (offsetof(struct udp_hdr,\n+\t\t\t\t\t\tdgram_cksum));\n+\t\t\tbreak;\n+\t\tcase PKT_TX_SCTP_CKSUM:\n+\t\t\tnet_hdr->csum_offset = (offsetof(struct sctp_hdr,\n+\t\t\t\t\t\tcksum));\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\tif (m_buf->ol_flags & PKT_TX_TCP_SEG) {\n+\t\tif (m_buf->ol_flags & PKT_TX_IPV4)\n+\t\t\tnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;\n+\t\telse\n+\t\t\tnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;\n+\t\tnet_hdr->gso_size = m_buf->tso_segsz;\n+\t\tnet_hdr->hdr_len = m_buf->l2_len + m_buf->l3_len\n+\t\t\t\t\t+ m_buf->l4_len;\n+\t}\n+\n+\treturn;\n+}\n+\n /**\n  * This function adds buffers to the virtio devices RX virtqueue. Buffers can\n  * be received from the physical port or from another virtio device. A packet\n@@ -67,7 +105,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n {\n \tstruct vhost_virtqueue *vq;\n \tstruct vring_desc *desc;\n-\tstruct rte_mbuf *buff;\n+\tstruct rte_mbuf *buff, *first_buff;\n \t/* The virtio_hdr is initialised to 0. */\n \tstruct virtio_net_hdr_mrg_rxbuf virtio_hdr = {{0, 0, 0, 0, 0, 0}, 0};\n \tuint64_t buff_addr = 0;\n@@ -139,6 +177,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n \t\tdesc = &vq->desc[head[packet_success]];\n \n \t\tbuff = pkts[packet_success];\n+\t\tfirst_buff = buff;\n \n \t\t/* Convert from gpa to vva (guest physical addr -> vhost virtual addr) */\n \t\tbuff_addr = gpa_to_vva(dev, desc->addr);\n@@ -221,7 +260,9 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n \n \t\tif (unlikely(uncompleted_pkt == 1))\n \t\t\tcontinue;\n-\n+\n+\t\tvirtio_enqueue_offload(first_buff, &virtio_hdr.hdr);\n+\n \t\trte_memcpy((void *)(uintptr_t)buff_hdr_addr,\n \t\t\t(const void *)&virtio_hdr, vq->vhost_hlen);\n \n@@ -295,6 +336,8 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint32_t queue_id,\n \tLOG_DEBUG(VHOST_DATA, \"(%\"PRIu64\") RX: Num merge buffers %d\\n\",\n \t\tdev->device_fh, virtio_hdr.num_buffers);\n \n+\tvirtio_enqueue_offload(pkt, &virtio_hdr.hdr);\n+\n \trte_memcpy((void *)(uintptr_t)vb_hdr_addr,\n \t\t(const void *)&virtio_hdr, vq->vhost_hlen);\n \ndiff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c\nindex 81bd309..839a333 100644\n--- a/lib/librte_vhost/virtio-net.c\n+++ b/lib/librte_vhost/virtio-net.c\n@@ -80,7 +80,10 @@ static struct virtio_net_config_ll *ll_root;\n \t\t\t\t(1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \\\n \t\t\t\t(1ULL << VIRTIO_NET_F_HOST_TSO4) | \\\n \t\t\t\t(1ULL << VIRTIO_NET_F_HOST_TSO6) | \\\n-\t\t\t\t(1ULL << VIRTIO_NET_F_CSUM))\n+\t\t\t\t(1ULL << VIRTIO_NET_F_CSUM)    | \\\n+\t\t\t\t(1ULL << VIRTIO_NET_F_GUEST_CSUM) | \\\n+\t\t\t\t(1ULL << VIRTIO_NET_F_GUEST_TSO4) | \\\n+\t\t\t\t(1ULL << VIRTIO_NET_F_GUEST_TSO6))\n \n static uint64_t VHOST_FEATURES = VHOST_SUPPORTED_FEATURES;\n \n",
    "prefixes": [
        "dpdk-dev",
        "v6",
        "2/4"
    ]
}