Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/105663/?format=api
http://patchwork.dpdk.org/api/patches/105663/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20220106160333.762686-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": "<20220106160333.762686-2-xiaoyun.li@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20220106160333.762686-2-xiaoyun.li@intel.com", "date": "2022-01-06T16:03:32", "name": "[v5,1/2] net: add functions to calculate UDP/TCP cksum in mbuf", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "19c9a375f006fdc1f01666f92bdd236f1f429a56", "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/20220106160333.762686-2-xiaoyun.li@intel.com/mbox/", "series": [ { "id": 21088, "url": "http://patchwork.dpdk.org/api/series/21088/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=21088", "date": "2022-01-06T16:03:31", "name": "Add functions to calculate UDP/TCP cksum in mbuf", "version": 5, "mbox": "http://patchwork.dpdk.org/series/21088/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/105663/comments/", "check": "success", "checks": "http://patchwork.dpdk.org/api/patches/105663/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 E6172A0351;\n\tThu, 6 Jan 2022 17:13:48 +0100 (CET)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 476C54115A;\n\tThu, 6 Jan 2022 17:13:44 +0100 (CET)", "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n by mails.dpdk.org (Postfix) with ESMTP id 5BB0841152\n for <dev@dpdk.org>; Thu, 6 Jan 2022 17:13:42 +0100 (CET)", "from orsmga007.jf.intel.com ([10.7.209.58])\n by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 06 Jan 2022 08:13:27 -0800", "from dpdk-xiaoyun3.sh.intel.com ([10.67.119.214])\n by orsmga007.jf.intel.com with ESMTP; 06 Jan 2022 08:13:24 -0800" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1641485622; x=1673021622;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=doBtOVZkZLMPhEOaWY1V3sLXPyRrvJO1NKMdX2LdUI8=;\n b=bvAz8pPou8NYx5P5ysbpNvyDqUoSMhATDqDb+nXm0HcxAGJjuZZOyncr\n Jq6yBUWJ+eqH2NZyGGLNyAP4iGLMKSaZSRSV5Rjncq7gVcAWcEhov4EF/\n HIRurCh6Ysmp6XgTX+bn3s6FuRWk32CkYgLz0iiAK9cT+jALAi6OvjCr4\n Y9k7AjJCK0eZ3XOT6EeMSoTEB/al6FzWd5VBGl5hkk7pmYdj3KgZK55vY\n L8HYM/aN1Q1DM50jCON1wYvYhklo0g0/JBf+xKZPM9pAVvjpuNPK4LMVl\n Jb7z5sGMITCp+hS4rfWP5shq8q7pFODfcn66z8+eSd1X2KkI13ItCZns9 g==;", "X-IronPort-AV": [ "E=McAfee;i=\"6200,9189,10217\"; a=\"241500759\"", "E=Sophos;i=\"5.88,267,1635231600\"; d=\"scan'208\";a=\"241500759\"", "E=Sophos;i=\"5.88,267,1635231600\"; d=\"scan'208\";a=\"513457505\"" ], "X-ExtLoop1": "1", "From": "Xiaoyun Li <xiaoyun.li@intel.com>", "To": "Aman.Deep.Singh@intel.com, ferruh.yigit@intel.com, olivier.matz@6wind.com,\n mb@smartsharesystems.com, konstantin.ananyev@intel.com,\n stephen@networkplumber.org, vladimir.medvedkin@intel.com", "Cc": "dev@dpdk.org, Xiaoyun Li <xiaoyun.li@intel.com>,\n Aman Singh <aman.deep.singh@intel.com>, Sunil Pai G <sunil.pai.g@intel.com>", "Subject": "[PATCH v5 1/2] net: add functions to calculate UDP/TCP cksum in mbuf", "Date": "Fri, 7 Jan 2022 00:03:32 +0800", "Message-Id": "<20220106160333.762686-2-xiaoyun.li@intel.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20220106160333.762686-1-xiaoyun.li@intel.com>", "References": "<20211015051306.320328-1-xiaoyun.li@intel.com>\n <20220106160333.762686-1-xiaoyun.li@intel.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>\nAcked-by: Aman Singh <aman.deep.singh@intel.com>\nTested-by: Sunil Pai G <sunil.pai.g@intel.com>\n---\n doc/guides/rel_notes/release_22_03.rst | 11 ++\n lib/net/rte_ip.h | 186 +++++++++++++++++++++++++\n 2 files changed, 197 insertions(+)", "diff": "diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst\nindex 6d99d1eaa9..785fd22001 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,14 @@ 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+\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 +92,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\n", "prefixes": [ "v5", "1/2" ] }{ "id": 105663, "url": "