get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 110692,
    "url": "https://patches.dpdk.org/api/patches/110692/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20220505102729.821075-6-maxime.coquelin@redhat.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": "<20220505102729.821075-6-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220505102729.821075-6-maxime.coquelin@redhat.com",
    "date": "2022-05-05T10:27:28",
    "name": "[5/6] net/vhost: perform SW checksum in Rx path",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "a836d804f639a59ad6f5c7a63b110fd85bae0360",
    "submitter": {
        "id": 512,
        "url": "https://patches.dpdk.org/api/people/512/?format=api",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.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/20220505102729.821075-6-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 22794,
            "url": "https://patches.dpdk.org/api/series/22794/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=22794",
            "date": "2022-05-05T10:27:23",
            "name": "Vhost checksum offload improvements",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/22794/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/110692/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/110692/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id D0819A04FF;\n\tThu,  5 May 2022 12:28:04 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id D9D164283D;\n\tThu,  5 May 2022 12:27:44 +0200 (CEST)",
            "from us-smtp-delivery-74.mimecast.com\n (us-smtp-delivery-74.mimecast.com [170.10.133.74])\n by mails.dpdk.org (Postfix) with ESMTP id E4E2442829\n for <dev@dpdk.org>; Thu,  5 May 2022 12:27:43 +0200 (CEST)",
            "from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-116-oNJLhKyMMzOGH66ekVeukA-1; Thu, 05 May 2022 06:27:42 -0400",
            "from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com\n [10.11.54.10])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F17B86B8AB;\n Thu,  5 May 2022 10:27:42 +0000 (UTC)",
            "from max-t490s.redhat.com (unknown [10.39.208.18])\n by smtp.corp.redhat.com (Postfix) with ESMTP id DFD4C415F2E;\n Thu,  5 May 2022 10:27:40 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1651746463;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=w8w5EzFQgJDW+ds2CormPz3WlzGWCW3rQ3AnTlsawys=;\n b=dEU+8Khk1Tv4xMDK8dNydsvhGQlTXw67N0f5pqMS82WFrNVeIb3U7/juphuQgkQre+u4Ti\n ZpHpn+4YT6C0Kvp+S69JLd3FJKb4La9CYoiygPygNv/SLa7oUdiZ+WlNutJofjBvZ62ykV\n JXppIeZN6DgDbpMB3y5zoFVGYq1JP08=",
        "X-MC-Unique": "oNJLhKyMMzOGH66ekVeukA-1",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org, jasowang@redhat.com, chenbo.xia@intel.com,\n david.marchand@redhat.com, olivier.matz@6wind.com",
        "Cc": "stable@dpdk.org,\n\tMaxime Coquelin <maxime.coquelin@redhat.com>",
        "Subject": "[PATCH 5/6] net/vhost: perform SW checksum in Rx path",
        "Date": "Thu,  5 May 2022 12:27:28 +0200",
        "Message-Id": "<20220505102729.821075-6-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20220505102729.821075-1-maxime.coquelin@redhat.com>",
        "References": "<20220505102729.821075-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 2.85 on 10.11.54.10",
        "Authentication-Results": "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "Virtio specification supports host checksum offloading\nfor L4, which is enabled with VIRTIO_NET_F_CSUM feature\nnegotiation. However, the Vhost PMD does not advertise\nRx checksum offload capabilities, so we can end-up with\nthe VIRTIO_NET_F_CSUM feature being negociated, implying\nthe Vhost library returns packets with checksum being\noffloaded while the application did not request for it.\n\nAdvertising these offload capabilities at the ethdev level\nis not enough, because we could still end-up with the\napplication not enabling these offloads while the guest\nstill negotiate them.\n\nThis patch advertizes the Rx checksum offload capabilities,\nand introduces a compatibility layer to cover the case\nVIRTIO_NET_F_CSUM has been negotiated but the application\ndoes not configure the Rx checksum offloads. This function\nperformis the L4 Rx checksum in SW for UDP and TCP. Note\nthat it is not needed to calculate the pseudo-header\nchecksum, because the Virtio specification requires that\nthe driver do it.\n\nThis patch does not advertize SCTP checksum offloading\ncapability for now, but it could be handled later if the\nneed arises.\n\nReported-by: Jason Wang <jasowang@redhat.com>\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n doc/guides/nics/features/vhost.ini |  1 +\n drivers/net/vhost/rte_eth_vhost.c  | 83 ++++++++++++++++++++++++++++++\n 2 files changed, 84 insertions(+)",
    "diff": "diff --git a/doc/guides/nics/features/vhost.ini b/doc/guides/nics/features/vhost.ini\nindex ef81abb439..15f4dfe5e8 100644\n--- a/doc/guides/nics/features/vhost.ini\n+++ b/doc/guides/nics/features/vhost.ini\n@@ -7,6 +7,7 @@\n Link status          = Y\n Free Tx mbuf on demand = Y\n Queue status event   = Y\n+L4 checksum offload  = P\n Basic stats          = Y\n Extended stats       = Y\n x86-32               = Y\ndiff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c\nindex baa973ad6d..d5303f7368 100644\n--- a/drivers/net/vhost/rte_eth_vhost.c\n+++ b/drivers/net/vhost/rte_eth_vhost.c\n@@ -12,6 +12,7 @@\n #include <ethdev_vdev.h>\n #include <rte_malloc.h>\n #include <rte_memcpy.h>\n+#include <rte_net.h>\n #include <rte_bus_vdev.h>\n #include <rte_kvargs.h>\n #include <rte_vhost.h>\n@@ -107,10 +108,12 @@ struct pmd_internal {\n \tchar *iface_name;\n \tuint64_t flags;\n \tuint64_t disable_flags;\n+\tuint64_t features;\n \tuint16_t max_queues;\n \tint vid;\n \trte_atomic32_t started;\n \tbool vlan_strip;\n+\tbool rx_sw_csum;\n };\n \n struct internal_list {\n@@ -362,6 +365,70 @@ vhost_update_single_packet_xstats(struct vhost_queue *vq, struct rte_mbuf *buf)\n \tvhost_count_xcast_packets(vq, buf);\n }\n \n+static void\n+vhost_dev_csum_configure(struct rte_eth_dev *eth_dev)\n+{\n+\tstruct pmd_internal *internal = eth_dev->data->dev_private;\n+\tconst struct rte_eth_rxmode *rxmode = &eth_dev->data->dev_conf.rxmode;\n+\n+\tinternal->rx_sw_csum = false;\n+\n+\t/* SW checksum is not compatible with legacy mode */\n+\tif (!(internal->flags & RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS))\n+\t\treturn;\n+\n+\tif (internal->features & (1ULL << VIRTIO_NET_F_CSUM)) {\n+\t\tif (!(rxmode->offloads &\n+\t\t\t\t(RTE_ETH_RX_OFFLOAD_UDP_CKSUM | RTE_ETH_RX_OFFLOAD_TCP_CKSUM))) {\n+\t\t\tVHOST_LOG(NOTICE, \"Rx csum will be done in SW, may impact performance.\");\n+\t\t\tinternal->rx_sw_csum = true;\n+\t\t}\n+\t}\n+}\n+\n+static void\n+vhost_dev_rx_sw_csum(struct rte_mbuf *mbuf)\n+{\n+\tstruct rte_net_hdr_lens hdr_lens;\n+\tuint32_t ptype, hdr_len;\n+\tuint16_t csum = 0, csum_offset;\n+\n+\t/* Return early if the L4 checksum was not offloaded */\n+\tif ((mbuf->ol_flags & RTE_MBUF_F_RX_L4_CKSUM_MASK) != RTE_MBUF_F_RX_L4_CKSUM_NONE)\n+\t\treturn;\n+\n+\tptype = rte_net_get_ptype(mbuf, &hdr_lens, RTE_PTYPE_ALL_MASK);\n+\n+\thdr_len = hdr_lens.l2_len + hdr_lens.l3_len;\n+\n+\tswitch (ptype & RTE_PTYPE_L4_MASK) {\n+\tcase RTE_PTYPE_L4_TCP:\n+\t\tcsum_offset = offsetof(struct rte_tcp_hdr, cksum) + hdr_len;\n+\t\tbreak;\n+\tcase RTE_PTYPE_L4_UDP:\n+\t\tcsum_offset = offsetof(struct rte_udp_hdr, dgram_cksum) + hdr_len;\n+\t\tbreak;\n+\tdefault:\n+\t\t/* Unsupported packet type */\n+\t\treturn;\n+\t}\n+\n+\t/* The pseudo-header checksum is already performed, as per Virtio spec */\n+\tif (rte_raw_cksum_mbuf(mbuf, hdr_len, rte_pktmbuf_pkt_len(mbuf) - hdr_len, &csum) < 0)\n+\t\treturn;\n+\n+\tcsum = ~csum;\n+\t/* See RFC768 */\n+\tif (unlikely((ptype & RTE_PTYPE_L4_UDP) && csum == 0))\n+\t\tcsum = 0xffff;\n+\n+\tif (rte_pktmbuf_data_len(mbuf) >= csum_offset + 1)\n+\t\t*rte_pktmbuf_mtod_offset(mbuf, uint16_t *, csum_offset) = csum;\n+\n+\tmbuf->ol_flags &= ~RTE_MBUF_F_RX_L4_CKSUM_MASK;\n+\tmbuf->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;\n+}\n+\n static uint16_t\n eth_vhost_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)\n {\n@@ -402,6 +469,9 @@ eth_vhost_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)\n \t\tif (r->internal->vlan_strip)\n \t\t\trte_vlan_strip(bufs[i]);\n \n+\t\tif (r->internal->rx_sw_csum)\n+\t\t\tvhost_dev_rx_sw_csum(bufs[i]);\n+\n \t\tr->stats.bytes += bufs[i]->pkt_len;\n \t\tr->stats.xstats[VHOST_BYTE] += bufs[i]->pkt_len;\n \n@@ -805,6 +875,11 @@ new_device(int vid)\n \t\teth_dev->data->numa_node = newnode;\n #endif\n \n+\tif (rte_vhost_get_negotiated_features(vid, &internal->features)) {\n+\t\tVHOST_LOG(ERR, \"Failed to get device features\\n\");\n+\t\treturn -1;\n+\t}\n+\n \tinternal->vid = vid;\n \tif (rte_atomic32_read(&internal->started) == 1) {\n \t\tqueue_setup(eth_dev, internal);\n@@ -827,6 +902,8 @@ new_device(int vid)\n \n \teth_dev->data->dev_link.link_status = RTE_ETH_LINK_UP;\n \n+\tvhost_dev_csum_configure(eth_dev);\n+\n \trte_atomic32_set(&internal->dev_attached, 1);\n \tupdate_queuing_status(eth_dev);\n \n@@ -1131,6 +1208,8 @@ eth_dev_configure(struct rte_eth_dev *dev)\n \n \tinternal->vlan_strip = !!(rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP);\n \n+\tvhost_dev_csum_configure(dev);\n+\n \treturn 0;\n }\n \n@@ -1281,6 +1360,10 @@ eth_dev_info(struct rte_eth_dev *dev,\n \tdev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS |\n \t\t\t\tRTE_ETH_TX_OFFLOAD_VLAN_INSERT;\n \tdev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_VLAN_STRIP;\n+\tif (internal->flags & RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS) {\n+\t\tdev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_UDP_CKSUM |\n+\t\t\tRTE_ETH_RX_OFFLOAD_TCP_CKSUM;\n+\t}\n \n \treturn 0;\n }\n",
    "prefixes": [
        "5/6"
    ]
}