get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 104853,
    "url": "http://patchwork.dpdk.org/api/patches/104853/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20211203113805.1025301-2-xiaoyun.li@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<20211203113805.1025301-2-xiaoyun.li@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20211203113805.1025301-2-xiaoyun.li@intel.com",
    "date": "2021-12-03T11:38:04",
    "name": "[v4,1/2] net: add functions to calculate UDP/TCP cksum in mbuf",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "62b049c5b73aaf1c069e4f68d29d267e8a642020",
    "submitter": {
        "id": 798,
        "url": "http://patchwork.dpdk.org/api/people/798/?format=api",
        "name": "Li, Xiaoyun",
        "email": "xiaoyun.li@intel.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patchwork.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20211203113805.1025301-2-xiaoyun.li@intel.com/mbox/",
    "series": [
        {
            "id": 20849,
            "url": "http://patchwork.dpdk.org/api/series/20849/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=20849",
            "date": "2021-12-03T11:38:03",
            "name": "Add functions to calculate UDP/TCP cksum in mbuf",
            "version": 4,
            "mbox": "http://patchwork.dpdk.org/series/20849/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/104853/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/104853/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 4899AA0C45;\n\tFri,  3 Dec 2021 12:48:29 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 34CE74270B;\n\tFri,  3 Dec 2021 12:48:29 +0100 (CET)",
            "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n by mails.dpdk.org (Postfix) with ESMTP id E69944067B\n for <dev@dpdk.org>; Fri,  3 Dec 2021 12:48:26 +0100 (CET)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 03 Dec 2021 03:48:25 -0800",
            "from dpdk-xiaoyun3.sh.intel.com ([10.67.119.214])\n by orsmga008.jf.intel.com with ESMTP; 03 Dec 2021 03:48:23 -0800"
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10186\"; a=\"217650670\"",
            "E=Sophos;i=\"5.87,284,1631602800\"; d=\"scan'208\";a=\"217650670\"",
            "E=Sophos;i=\"5.87,284,1631602800\"; d=\"scan'208\";a=\"513677174\""
        ],
        "X-ExtLoop1": "1",
        "From": "Xiaoyun Li <xiaoyun.li@intel.com>",
        "To": "ferruh.yigit@intel.com, olivier.matz@6wind.com, mb@smartsharesystems.com,\n konstantin.ananyev@intel.com, stephen@networkplumber.org,\n vladimir.medvedkin@intel.com",
        "Cc": "dev@dpdk.org,\n\tXiaoyun Li <xiaoyun.li@intel.com>",
        "Subject": "[PATCH v4 1/2] net: add functions to calculate UDP/TCP cksum in mbuf",
        "Date": "Fri,  3 Dec 2021 19:38:04 +0800",
        "Message-Id": "<20211203113805.1025301-2-xiaoyun.li@intel.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20211203113805.1025301-1-xiaoyun.li@intel.com>",
        "References": "<20211015051306.320328-1-xiaoyun.li@intel.com>\n <20211203113805.1025301-1-xiaoyun.li@intel.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "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": "Add functions to call rte_raw_cksum_mbuf() to calculate IPv4/6\nUDP/TCP checksum in mbuf which can be over multi-segments.\n\nSigned-off-by: Xiaoyun Li <xiaoyun.li@intel.com>\n---\n doc/guides/rel_notes/release_22_03.rst |  10 ++\n lib/net/rte_ip.h                       | 186 +++++++++++++++++++++++++\n lib/net/version.map                    |  10 ++\n 3 files changed, 206 insertions(+)",
    "diff": "diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst\nindex 6d99d1eaa9..7a082c4427 100644\n--- a/doc/guides/rel_notes/release_22_03.rst\n+++ b/doc/guides/rel_notes/release_22_03.rst\n@@ -55,6 +55,13 @@ New Features\n      Also, make sure to start the actual text at the margin.\n      =======================================================\n \n+* **Added functions to calculate UDP/TCP checksum in mbuf.**\n+  * Added the following functions to calculate UDP/TCP checksum of packets\n+    which can be over multi-segments:\n+    - ``rte_ipv4_udptcp_cksum_mbuf()``\n+    - ``rte_ipv4_udptcp_cksum_mbuf_verify()``\n+    - ``rte_ipv6_udptcp_cksum_mbuf()``\n+    - ``rte_ipv6_udptcp_cksum_mbuf_verify()``\n \n Removed Items\n -------------\n@@ -84,6 +91,9 @@ API Changes\n    Also, make sure to start the actual text at the margin.\n    =======================================================\n \n+* net: added experimental functions ``rte_ipv4_udptcp_cksum_mbuf()``,\n+  ``rte_ipv4_udptcp_cksum_mbuf_verify()``, ``rte_ipv6_udptcp_cksum_mbuf()``,\n+  ``rte_ipv6_udptcp_cksum_mbuf_verify()``\n \n ABI Changes\n -----------\ndiff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h\nindex c575250852..534f401d26 100644\n--- a/lib/net/rte_ip.h\n+++ b/lib/net/rte_ip.h\n@@ -400,6 +400,65 @@ rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr)\n \treturn cksum;\n }\n \n+/**\n+ * @internal Calculate the non-complemented IPv4 L4 checksum of a packet\n+ */\n+static inline uint16_t\n+__rte_ipv4_udptcp_cksum_mbuf(const struct rte_mbuf *m,\n+\t\t\t     const struct rte_ipv4_hdr *ipv4_hdr,\n+\t\t\t     uint16_t l4_off)\n+{\n+\tuint16_t raw_cksum;\n+\tuint32_t cksum;\n+\n+\tif (l4_off > m->pkt_len)\n+\t\treturn 0;\n+\n+\tif (rte_raw_cksum_mbuf(m, l4_off, m->pkt_len - l4_off, &raw_cksum))\n+\t\treturn 0;\n+\n+\tcksum = raw_cksum + rte_ipv4_phdr_cksum(ipv4_hdr, 0);\n+\n+\tcksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff);\n+\n+\treturn (uint16_t)cksum;\n+}\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Compute the IPv4 UDP/TCP checksum of a packet.\n+ *\n+ * @param m\n+ *   The pointer to the mbuf.\n+ * @param ipv4_hdr\n+ *   The pointer to the contiguous IPv4 header.\n+ * @param l4_off\n+ *   The offset in bytes to start L4 checksum.\n+ * @return\n+ *   The complemented checksum to set in the L4 header.\n+ */\n+__rte_experimental\n+static inline uint16_t\n+rte_ipv4_udptcp_cksum_mbuf(const struct rte_mbuf *m,\n+\t\t\t   const struct rte_ipv4_hdr *ipv4_hdr, uint16_t l4_off)\n+{\n+\tuint16_t cksum = __rte_ipv4_udptcp_cksum_mbuf(m, ipv4_hdr, l4_off);\n+\n+\tcksum = ~cksum;\n+\n+\t/*\n+\t * Per RFC 768: If the computed checksum is zero for UDP,\n+\t * it is transmitted as all ones\n+\t * (the equivalent in one's complement arithmetic).\n+\t */\n+\tif (cksum == 0 && ipv4_hdr->next_proto_id == IPPROTO_UDP)\n+\t\tcksum = 0xffff;\n+\n+\treturn cksum;\n+}\n+\n /**\n  * Validate the IPv4 UDP or TCP checksum.\n  *\n@@ -426,6 +485,38 @@ rte_ipv4_udptcp_cksum_verify(const struct rte_ipv4_hdr *ipv4_hdr,\n \treturn 0;\n }\n \n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Verify the IPv4 UDP/TCP checksum of a packet.\n+ *\n+ * In case of UDP, the caller must first check if udp_hdr->dgram_cksum is 0\n+ * (i.e. no checksum).\n+ *\n+ * @param m\n+ *   The pointer to the mbuf.\n+ * @param ipv4_hdr\n+ *   The pointer to the contiguous IPv4 header.\n+ * @param l4_off\n+ *   The offset in bytes to start L4 checksum.\n+ * @return\n+ *   Return 0 if the checksum is correct, else -1.\n+ */\n+__rte_experimental\n+static inline uint16_t\n+rte_ipv4_udptcp_cksum_mbuf_verify(const struct rte_mbuf *m,\n+\t\t\t\t  const struct rte_ipv4_hdr *ipv4_hdr,\n+\t\t\t\t  uint16_t l4_off)\n+{\n+\tuint16_t cksum = __rte_ipv4_udptcp_cksum_mbuf(m, ipv4_hdr, l4_off);\n+\n+\tif (cksum != 0xffff)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n /**\n  * IPv6 Header\n  */\n@@ -538,6 +629,68 @@ rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr)\n \treturn cksum;\n }\n \n+/**\n+ * @internal Calculate the non-complemented IPv6 L4 checksum of a packet\n+ */\n+static inline uint16_t\n+__rte_ipv6_udptcp_cksum_mbuf(const struct rte_mbuf *m,\n+\t\t\t     const struct rte_ipv6_hdr *ipv6_hdr,\n+\t\t\t     uint16_t l4_off)\n+{\n+\tuint16_t raw_cksum;\n+\tuint32_t cksum;\n+\n+\tif (l4_off > m->pkt_len)\n+\t\treturn 0;\n+\n+\tif (rte_raw_cksum_mbuf(m, l4_off, m->pkt_len - l4_off, &raw_cksum))\n+\t\treturn 0;\n+\n+\tcksum = raw_cksum + rte_ipv6_phdr_cksum(ipv6_hdr, 0);\n+\n+\tcksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff);\n+\n+\treturn (uint16_t)cksum;\n+}\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Process the IPv6 UDP or TCP checksum of a packet.\n+ *\n+ * The IPv6 header must not be followed by extension headers. The layer 4\n+ * checksum must be set to 0 in the L4 header by the caller.\n+ *\n+ * @param m\n+ *   The pointer to the mbuf.\n+ * @param ipv6_hdr\n+ *   The pointer to the contiguous IPv6 header.\n+ * @param l4_off\n+ *   The offset in bytes to start L4 checksum.\n+ * @return\n+ *   The complemented checksum to set in the L4 header.\n+ */\n+__rte_experimental\n+static inline uint16_t\n+rte_ipv6_udptcp_cksum_mbuf(const struct rte_mbuf *m,\n+\t\t\t   const struct rte_ipv6_hdr *ipv6_hdr, uint16_t l4_off)\n+{\n+\tuint16_t cksum = __rte_ipv6_udptcp_cksum_mbuf(m, ipv6_hdr, l4_off);\n+\n+\tcksum = ~cksum;\n+\n+\t/*\n+\t * Per RFC 768: If the computed checksum is zero for UDP,\n+\t * it is transmitted as all ones\n+\t * (the equivalent in one's complement arithmetic).\n+\t */\n+\tif (cksum == 0 && ipv6_hdr->proto == IPPROTO_UDP)\n+\t\tcksum = 0xffff;\n+\n+\treturn cksum;\n+}\n+\n /**\n  * Validate the IPv6 UDP or TCP checksum.\n  *\n@@ -565,6 +718,39 @@ rte_ipv6_udptcp_cksum_verify(const struct rte_ipv6_hdr *ipv6_hdr,\n \treturn 0;\n }\n \n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice.\n+ *\n+ * Validate the IPv6 UDP or TCP checksum of a packet.\n+ *\n+ * In case of UDP, the caller must first check if udp_hdr->dgram_cksum is 0:\n+ * this is either invalid or means no checksum in some situations. See 8.1\n+ * (Upper-Layer Checksums) in RFC 8200.\n+ *\n+ * @param m\n+ *   The pointer to the mbuf.\n+ * @param ipv6_hdr\n+ *   The pointer to the contiguous IPv6 header.\n+ * @param l4_off\n+ *   The offset in bytes to start L4 checksum.\n+ * @return\n+ *   Return 0 if the checksum is correct, else -1.\n+ */\n+__rte_experimental\n+static inline int\n+rte_ipv6_udptcp_cksum_mbuf_verify(const struct rte_mbuf *m,\n+\t\t\t\t  const struct rte_ipv6_hdr *ipv6_hdr,\n+\t\t\t\t  uint16_t l4_off)\n+{\n+\tuint16_t cksum = __rte_ipv6_udptcp_cksum_mbuf(m, ipv6_hdr, l4_off);\n+\n+\tif (cksum != 0xffff)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n /** IPv6 fragment extension header. */\n #define\tRTE_IPV6_EHDR_MF_SHIFT\t0\n #define\tRTE_IPV6_EHDR_MF_MASK\t1\ndiff --git a/lib/net/version.map b/lib/net/version.map\nindex 4f4330d1c4..0f2aacdef8 100644\n--- a/lib/net/version.map\n+++ b/lib/net/version.map\n@@ -12,3 +12,13 @@ DPDK_22 {\n \n \tlocal: *;\n };\n+\n+EXPERIMENTAL {\n+\tglobal:\n+\n+\t# added in 22.03\n+\trte_ipv4_udptcp_cksum_mbuf;\n+\trte_ipv4_udptcp_cksum_mbuf_verify;\n+\trte_ipv6_udptcp_cksum_mbuf;\n+\trte_ipv6_udptcp_cksum_mbuf_verify;\n+};\n",
    "prefixes": [
        "v4",
        "1/2"
    ]
}