Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/29674/?format=api
https://patches.dpdk.org/api/patches/29674/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1507201331-228465-4-git-send-email-mark.b.kavanagh@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": "<1507201331-228465-4-git-send-email-mark.b.kavanagh@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1507201331-228465-4-git-send-email-mark.b.kavanagh@intel.com", "date": "2017-10-05T11:02:08", "name": "[dpdk-dev,v7,3/6] gso: add VxLAN GSO support", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "86c9ab6f9326c165cacef312d4da65cb9d90a139", "submitter": { "id": 133, "url": "https://patches.dpdk.org/api/people/133/?format=api", "name": "Mark Kavanagh", "email": "mark.b.kavanagh@intel.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1507201331-228465-4-git-send-email-mark.b.kavanagh@intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/29674/comments/", "check": "warning", "checks": "https://patches.dpdk.org/api/patches/29674/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 035601AF03;\n\tThu, 5 Oct 2017 13:02:30 +0200 (CEST)", "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id 0CFA21AEE8\n\tfor <dev@dpdk.org>; Thu, 5 Oct 2017 13:02:24 +0200 (CEST)", "from fmsmga005.fm.intel.com ([10.253.24.32])\n\tby fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t05 Oct 2017 04:02:24 -0700", "from silpixa00380299.ir.intel.com ([10.237.222.17])\n\tby fmsmga005.fm.intel.com with ESMTP; 05 Oct 2017 04:02:23 -0700" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.42,481,1500966000\"; d=\"scan'208\";a=\"159160329\"", "From": "Mark Kavanagh <mark.b.kavanagh@intel.com>", "To": "dev@dpdk.org", "Cc": "jiayu.hu@intel.com, jianfeng.tan@intel.com, konstantin.ananyev@intel.com,\n\tferruh.yigit@intel.com, thomas@monjalon.net,\n\tMark Kavanagh <mark.b.kavanagh@intel.com>", "Date": "Thu, 5 Oct 2017 12:02:08 +0100", "Message-Id": "<1507201331-228465-4-git-send-email-mark.b.kavanagh@intel.com>", "X-Mailer": "git-send-email 1.9.3", "In-Reply-To": "<1507201331-228465-1-git-send-email-mark.b.kavanagh@intel.com>", "References": "<1506962749-106779-1-git-send-email-mark.b.kavanagh@intel.com>\n\t<1507201331-228465-1-git-send-email-mark.b.kavanagh@intel.com>", "Subject": "[dpdk-dev] [PATCH v7 3/6] gso: add VxLAN GSO support", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <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": "This patch adds a framework that allows GSO on tunneled packets.\nFurthermore, it leverages that framework to provide GSO support for\nVxLAN-encapsulated packets.\n\nSupported VxLAN packets must have an outer IPv4 header (prepended by an\noptional VLAN tag), and contain an inner TCP/IPv4 packet (with an optional\ninner VLAN tag).\n\nVxLAN GSO doesn't check if input packets have correct checksums and\ndoesn't update checksums for output packets. Additionally, it doesn't\nprocess IP fragmented packets.\n\nAs with TCP/IPv4 GSO, VxLAN GSO uses a two-segment MBUF to organize each\noutput packet, which mandates support for multi-segment mbufs in the TX\nfunctions of the NIC driver. Also, if a packet is GSOed, VxLAN GSO\nreduces its MBUF refcnt by 1. As a result, when all of its GSO'd segments\nare freed, the packet is freed automatically.\n\nSigned-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com>\nSigned-off-by: Jiayu Hu <jiayu.hu@intel.com>\n---\n doc/guides/rel_notes/release_17_11.rst | 2 +\n lib/librte_gso/Makefile | 1 +\n lib/librte_gso/gso_common.h | 25 +++++++\n lib/librte_gso/gso_tunnel_tcp4.c | 120 +++++++++++++++++++++++++++++++++\n lib/librte_gso/gso_tunnel_tcp4.h | 75 +++++++++++++++++++++\n lib/librte_gso/rte_gso.c | 14 +++-\n 6 files changed, 235 insertions(+), 2 deletions(-)\n create mode 100644 lib/librte_gso/gso_tunnel_tcp4.c\n create mode 100644 lib/librte_gso/gso_tunnel_tcp4.h", "diff": "diff --git a/doc/guides/rel_notes/release_17_11.rst b/doc/guides/rel_notes/release_17_11.rst\nindex dd37169..c58eeb1 100644\n--- a/doc/guides/rel_notes/release_17_11.rst\n+++ b/doc/guides/rel_notes/release_17_11.rst\n@@ -48,6 +48,8 @@ New Features\n ones (e.g. MTU is 1500B). Supported packet types are:\n \n * TCP/IPv4 packets.\n+ * VxLAN packets, which must have an outer IPv4 header, and contain\n+ an inner TCP/IPv4 packet.\n \n The GSO library doesn't check if the input packets have correct\n checksums, and doesn't update checksums for output packets.\ndiff --git a/lib/librte_gso/Makefile b/lib/librte_gso/Makefile\nindex 2be64d1..e6d41df 100644\n--- a/lib/librte_gso/Makefile\n+++ b/lib/librte_gso/Makefile\n@@ -44,6 +44,7 @@ LIBABIVER := 1\n SRCS-$(CONFIG_RTE_LIBRTE_GSO) += rte_gso.c\n SRCS-$(CONFIG_RTE_LIBRTE_GSO) += gso_common.c\n SRCS-$(CONFIG_RTE_LIBRTE_GSO) += gso_tcp4.c\n+SRCS-$(CONFIG_RTE_LIBRTE_GSO) += gso_tunnel_tcp4.c\n \n # install this header file\n SYMLINK-$(CONFIG_RTE_LIBRTE_GSO)-include += rte_gso.h\ndiff --git a/lib/librte_gso/gso_common.h b/lib/librte_gso/gso_common.h\nindex a8ad638..95d54e7 100644\n--- a/lib/librte_gso/gso_common.h\n+++ b/lib/librte_gso/gso_common.h\n@@ -39,6 +39,7 @@\n #include <rte_mbuf.h>\n #include <rte_ip.h>\n #include <rte_tcp.h>\n+#include <rte_udp.h>\n \n #define IS_FRAGMENTED(frag_off) (((frag_off) & IPV4_HDR_OFFSET_MASK) != 0 \\\n \t\t|| ((frag_off) & IPV4_HDR_MF_FLAG) == IPV4_HDR_MF_FLAG)\n@@ -49,6 +50,30 @@\n #define IS_IPV4_TCP(flag) (((flag) & (PKT_TX_TCP_SEG | PKT_TX_IPV4)) == \\\n \t\t(PKT_TX_TCP_SEG | PKT_TX_IPV4))\n \n+#define IS_IPV4_VXLAN_TCP4(flag) (((flag) & (PKT_TX_TCP_SEG | PKT_TX_IPV4 | \\\n+\t\t\t\tPKT_TX_OUTER_IPV4 | PKT_TX_TUNNEL_VXLAN)) == \\\n+\t\t(PKT_TX_TCP_SEG | PKT_TX_IPV4 | PKT_TX_OUTER_IPV4 | \\\n+\t\t PKT_TX_TUNNEL_VXLAN))\n+\n+/**\n+ * Internal function which updates the UDP header of a packet, following\n+ * segmentation. This is required to update the header's datagram length field.\n+ *\n+ * @param pkt\n+ * The packet containing the UDP header.\n+ * @param udp_offset\n+ * The offset of the UDP header from the start of the packet.\n+ */\n+static inline void\n+update_udp_header(struct rte_mbuf *pkt, uint16_t udp_offset)\n+{\n+\tstruct udp_hdr *udp_hdr;\n+\n+\tudp_hdr = (struct udp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +\n+\t\t\tudp_offset);\n+\tudp_hdr->dgram_len = rte_cpu_to_be_16(pkt->pkt_len - udp_offset);\n+}\n+\n /**\n * Internal function which updates the TCP header of a packet, following\n * segmentation. This is required to update the header's 'sent' sequence\ndiff --git a/lib/librte_gso/gso_tunnel_tcp4.c b/lib/librte_gso/gso_tunnel_tcp4.c\nnew file mode 100644\nindex 0000000..5e8c8e5\n--- /dev/null\n+++ b/lib/librte_gso/gso_tunnel_tcp4.c\n@@ -0,0 +1,120 @@\n+/*-\n+ * BSD LICENSE\n+ *\n+ * Copyright(c) 2017 Intel Corporation. All rights reserved.\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ * * Redistributions in binary form must reproduce the above copyright\n+ * notice, this list of conditions and the following disclaimer in\n+ * the documentation and/or other materials provided with the\n+ * distribution.\n+ * * Neither the name of Intel Corporation nor the names of its\n+ * contributors may be used to endorse or promote products derived\n+ * from this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include \"gso_common.h\"\n+#include \"gso_tunnel_tcp4.h\"\n+\n+static void\n+update_tunnel_ipv4_tcp_headers(struct rte_mbuf *pkt, uint8_t ipid_delta,\n+\t\tstruct rte_mbuf **segs, uint16_t nb_segs)\n+{\n+\tstruct ipv4_hdr *ipv4_hdr;\n+\tstruct tcp_hdr *tcp_hdr;\n+\tuint32_t sent_seq;\n+\tuint16_t outer_id, inner_id, tail_idx, i;\n+\tuint16_t outer_ipv4_offset, inner_ipv4_offset, udp_offset, tcp_offset;\n+\n+\touter_ipv4_offset = pkt->outer_l2_len;\n+\tudp_offset = outer_ipv4_offset + pkt->outer_l3_len;\n+\tinner_ipv4_offset = udp_offset + pkt->l2_len;\n+\ttcp_offset = inner_ipv4_offset + pkt->l3_len;\n+\n+\t/* Outer IPv4 header. */\n+\tipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +\n+\t\t\touter_ipv4_offset);\n+\touter_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);\n+\n+\t/* Inner IPv4 header. */\n+\tipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +\n+\t\t\tinner_ipv4_offset);\n+\tinner_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);\n+\n+\ttcp_hdr = (struct tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);\n+\tsent_seq = rte_be_to_cpu_32(tcp_hdr->sent_seq);\n+\ttail_idx = nb_segs - 1;\n+\n+\tfor (i = 0; i < nb_segs; i++) {\n+\t\tupdate_ipv4_header(segs[i], outer_ipv4_offset, outer_id);\n+\t\tupdate_udp_header(segs[i], udp_offset);\n+\t\tupdate_ipv4_header(segs[i], inner_ipv4_offset, inner_id);\n+\t\tupdate_tcp_header(segs[i], tcp_offset, sent_seq, i < tail_idx);\n+\t\touter_id++;\n+\t\tinner_id += ipid_delta;\n+\t\tsent_seq += (segs[i]->pkt_len - segs[i]->data_len);\n+\t}\n+}\n+\n+int\n+gso_tunnel_tcp4_segment(struct rte_mbuf *pkt,\n+\t\tuint16_t gso_size,\n+\t\tuint8_t ipid_delta,\n+\t\tstruct rte_mempool *direct_pool,\n+\t\tstruct rte_mempool *indirect_pool,\n+\t\tstruct rte_mbuf **pkts_out,\n+\t\tuint16_t nb_pkts_out)\n+{\n+\tstruct ipv4_hdr *inner_ipv4_hdr;\n+\tuint16_t pyld_unit_size, hdr_offset, frag_off;\n+\tint ret = 1;\n+\n+\thdr_offset = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len;\n+\tinner_ipv4_hdr = (struct ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +\n+\t\t\thdr_offset);\n+\t/*\n+\t * Don't process the packet whose MF bit or offset in the inner\n+\t * IPv4 header are non-zero.\n+\t */\n+\tfrag_off = rte_be_to_cpu_16(inner_ipv4_hdr->fragment_offset);\n+\tif (unlikely(IS_FRAGMENTED(frag_off))) {\n+\t\tpkts_out[0] = pkt;\n+\t\treturn 1;\n+\t}\n+\n+\thdr_offset += pkt->l3_len + pkt->l4_len;\n+\t/* Don't process the packet without data */\n+\tif (hdr_offset >= pkt->pkt_len) {\n+\t\tpkts_out[0] = pkt;\n+\t\treturn 1;\n+\t}\n+\tpyld_unit_size = gso_size - hdr_offset;\n+\n+\t/* Segment the payload */\n+\tret = gso_do_segment(pkt, hdr_offset, pyld_unit_size, direct_pool,\n+\t\t\tindirect_pool, pkts_out, nb_pkts_out);\n+\tif (ret <= 1)\n+\t\treturn ret;\n+\n+\tupdate_tunnel_ipv4_tcp_headers(pkt, ipid_delta, pkts_out, ret);\n+\n+\treturn ret;\n+}\ndiff --git a/lib/librte_gso/gso_tunnel_tcp4.h b/lib/librte_gso/gso_tunnel_tcp4.h\nnew file mode 100644\nindex 0000000..3c67f0c\n--- /dev/null\n+++ b/lib/librte_gso/gso_tunnel_tcp4.h\n@@ -0,0 +1,75 @@\n+/*-\n+ * BSD LICENSE\n+ *\n+ * Copyright(c) 2017 Intel Corporation. All rights reserved.\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ * * Redistributions in binary form must reproduce the above copyright\n+ * notice, this list of conditions and the following disclaimer in\n+ * the documentation and/or other materials provided with the\n+ * distribution.\n+ * * Neither the name of Intel Corporation nor the names of its\n+ * contributors may be used to endorse or promote products derived\n+ * from this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#ifndef _GSO_TUNNEL_TCP4_H_\n+#define _GSO_TUNNEL_TCP4_H_\n+\n+#include <stdint.h>\n+#include <rte_mbuf.h>\n+\n+/**\n+ * Segment a tunneling packet with inner TCP/IPv4 headers. This function\n+ * doesn't check if the input packet has correct checksums, and doesn't\n+ * update checksums for output GSO segments. Furthermore, it doesn't\n+ * process IP fragment packets.\n+ *\n+ * @param pkt\n+ * The packet mbuf to segment.\n+ * @param gso_size\n+ * The max length of a GSO segment, measured in bytes.\n+ * @param ipid_delta\n+ * The increasing unit of IP ids.\n+ * @param direct_pool\n+ * MBUF pool used for allocating direct buffers for output segments.\n+ * @param indirect_pool\n+ * MBUF pool used for allocating indirect buffers for output segments.\n+ * @param pkts_out\n+ * Pointer array used to store the MBUF addresses of output GSO\n+ * segments, when it succeeds. If the memory space in pkts_out is\n+ * insufficient, it fails and returns -EINVAL.\n+ * @param nb_pkts_out\n+ * The max number of items that 'pkts_out' can keep.\n+ *\n+ * @return\n+ * - The number of GSO segments filled in pkts_out on success.\n+ * - Return -ENOMEM if run out of memory in MBUF pools.\n+ * - Return -EINVAL for invalid parameters.\n+ */\n+int gso_tunnel_tcp4_segment(struct rte_mbuf *pkt,\n+\t\tuint16_t gso_size,\n+\t\tuint8_t ipid_delta,\n+\t\tstruct rte_mempool *direct_pool,\n+\t\tstruct rte_mempool *indirect_pool,\n+\t\tstruct rte_mbuf **pkts_out,\n+\t\tuint16_t nb_pkts_out);\n+#endif\ndiff --git a/lib/librte_gso/rte_gso.c b/lib/librte_gso/rte_gso.c\nindex 2b6fc2d..a6f38e2 100644\n--- a/lib/librte_gso/rte_gso.c\n+++ b/lib/librte_gso/rte_gso.c\n@@ -39,6 +39,7 @@\n #include \"rte_gso.h\"\n #include \"gso_common.h\"\n #include \"gso_tcp4.h\"\n+#include \"gso_tunnel_tcp4.h\"\n \n int\n rte_gso_segment(struct rte_mbuf *pkt,\n@@ -59,7 +60,8 @@\n \n \tif ((gso_ctx->gso_size < RTE_GSO_SEG_SIZE_MIN) ||\n \t\t\t(gso_ctx->gso_size >= pkt->pkt_len) ||\n-\t\t\t(gso_ctx->gso_types & DEV_TX_OFFLOAD_TCP_TSO) !=\n+\t\t\t(gso_ctx->gso_types & (DEV_TX_OFFLOAD_TCP_TSO |\n+\t\t\t DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) !=\n \t\t\tgso_ctx->gso_types) {\n \t\tpkt->ol_flags &= (~PKT_TX_TCP_SEG);\n \t\tpkts_out[0] = pkt;\n@@ -72,12 +74,20 @@\n \tipid_delta = (gso_ctx->flag != RTE_GSO_FLAG_IPID_FIXED);\n \tol_flags = pkt->ol_flags;\n \n-\tif (IS_IPV4_TCP(pkt->ol_flags)) {\n+\tif (IS_IPV4_VXLAN_TCP4(pkt->ol_flags)\n+\t\t&& (gso_ctx->gso_types & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) {\n+\t\tpkt->ol_flags &= (~PKT_TX_TCP_SEG);\n+\t\tret = gso_tunnel_tcp4_segment(pkt, gso_size, ipid_delta,\n+\t\t\t\tdirect_pool, indirect_pool,\n+\t\t\t\tpkts_out, nb_pkts_out);\n+\t} else if (IS_IPV4_TCP(pkt->ol_flags) &&\n+\t\t\t(gso_ctx->gso_types & DEV_TX_OFFLOAD_TCP_TSO)) {\n \t\tpkt->ol_flags &= (~PKT_TX_TCP_SEG);\n \t\tret = gso_tcp4_segment(pkt, gso_size, ipid_delta,\n \t\t\t\tdirect_pool, indirect_pool,\n \t\t\t\tpkts_out, nb_pkts_out);\n \t} else {\n+\t\t/* unsupported packet, skip */\n \t\tpkts_out[0] = pkt;\n \t\tRTE_LOG(WARNING, GSO, \"Unsupported packet type\\n\");\n \t\treturn 1;\n", "prefixes": [ "dpdk-dev", "v7", "3/6" ] }{ "id": 29674, "url": "