Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1405/?format=api
https://patches.dpdk.org/api/patches/1405/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1416524335-22753-11-git-send-email-olivier.matz@6wind.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": "<1416524335-22753-11-git-send-email-olivier.matz@6wind.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1416524335-22753-11-git-send-email-olivier.matz@6wind.com", "date": "2014-11-20T22:58:52", "name": "[dpdk-dev,v3,10/13] mbuf: generic support for TCP segmentation offload", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "b90f5585e28de9c2507fef00f89e03c8079ef8fa", "submitter": { "id": 8, "url": "https://patches.dpdk.org/api/people/8/?format=api", "name": "Olivier Matz", "email": "olivier.matz@6wind.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1416524335-22753-11-git-send-email-olivier.matz@6wind.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/1405/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/1405/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 B9FA37FDD;\n\tThu, 20 Nov 2014 23:48:53 +0100 (CET)", "from mail-wg0-f43.google.com (mail-wg0-f43.google.com\n\t[74.125.82.43]) by dpdk.org (Postfix) with ESMTP id A38DD7F40\n\tfor <dev@dpdk.org>; Thu, 20 Nov 2014 23:48:42 +0100 (CET)", "by mail-wg0-f43.google.com with SMTP id l18so5107714wgh.2\n\tfor <dev@dpdk.org>; Thu, 20 Nov 2014 14:59:14 -0800 (PST)", "from glumotte.dev.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net.\n\t[82.239.227.177]) by mx.google.com with ESMTPSA id\n\tcz3sm5380581wjb.23.2014.11.20.14.59.13 for <multiple recipients>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tThu, 20 Nov 2014 14:59:14 -0800 (PST)" ], "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=0f9XaobTuxT02tMiXXZVpbGV841dZAuKpTLyCPixVLo=;\n\tb=WfzUIcBlRqpjzHuK0F04+1BLiD2zkxWt91CxzjaflZi6+LKl0gAc51P1s1AFN2ONT1\n\tXxKypYZzpkMFm0WM3KWkx8erF0DKMWG2b1bwhxuwJdPWQc6JGBFRY9od361V5hau/DuB\n\tIZA9QUW1eqGqZBxtdlaq4Mup0fug2tIjnIH1irYzWitskCPdPc64ZGSy++dZvyCC+/z/\n\tu+SubF2AArsbciEfAIHjwicuzmUd0C4M0/O5D99ACufAu2cGyXru6EePPRMxx3xm8Lmn\n\tjNGIrFN7A0Bn0EXqKiIVhJZ5Zp/0OZhl7S0Op9PfVvmVxJhUy5QOUrHwmNeGJ6WC3tmE\n\tQ8yQ==", "X-Gm-Message-State": "ALoCoQk+1hNJsFqY1kEvEwUw1NZ5GG1XHGGdXGBEYUkFpNntD1vPr/BExC3wVCLLFa4xhhfYRZaX", "X-Received": "by 10.180.104.2 with SMTP id ga2mr19761637wib.64.1416524354520; \n\tThu, 20 Nov 2014 14:59:14 -0800 (PST)", "From": "Olivier Matz <olivier.matz@6wind.com>", "To": "dev@dpdk.org", "Date": "Thu, 20 Nov 2014 23:58:52 +0100", "Message-Id": "<1416524335-22753-11-git-send-email-olivier.matz@6wind.com>", "X-Mailer": "git-send-email 2.1.0", "In-Reply-To": "<1416524335-22753-1-git-send-email-olivier.matz@6wind.com>", "References": "<1415984609-2484-1-git-send-email-olivier.matz@6wind.com>\n\t<1416524335-22753-1-git-send-email-olivier.matz@6wind.com>", "Cc": "jigsaw@gmail.com", "Subject": "[dpdk-dev] [PATCH v3 10/13] mbuf: generic support for TCP\n\tsegmentation offload", "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": "Some of the NICs supported by DPDK have a possibility to accelerate TCP\ntraffic by using segmentation offload. The application prepares a packet\nwith valid TCP header with size up to 64K and deleguates the\nsegmentation to the NIC.\n\nImplement the generic part of TCP segmentation offload in rte_mbuf. It\nintroduces 2 new fields in rte_mbuf: l4_len (length of L4 header in bytes)\nand tso_segsz (MSS of packets).\n\nTo delegate the TCP segmentation to the hardware, the user has to:\n\n- set the PKT_TX_TCP_SEG flag in mbuf->ol_flags (this flag implies\n PKT_TX_TCP_CKSUM)\n- set PKT_TX_IP_CKSUM if it's IPv4, and set the IP checksum to 0 in\n the packet\n- fill the mbuf offload information: l2_len, l3_len, l4_len, tso_segsz\n- calculate the pseudo header checksum without taking ip_len in account,\n and set it in the TCP header, for instance by using\n rte_ipv4_phdr_cksum(ip_hdr, ol_flags)\n\nThe API is inspired from ixgbe hardware (the next commit adds the\nsupport for ixgbe), but it seems generic enough to be used for other\nhw/drivers in the future.\n\nThis commit also reworks the way l2_len and l3_len are used in igb\nand ixgbe drivers as the l2_l3_len is not available anymore in mbuf.\n\nSigned-off-by: Mirek Walukiewicz <miroslaw.walukiewicz@intel.com>\nSigned-off-by: Olivier Matz <olivier.matz@6wind.com>\nAcked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>\n---\n app/test-pmd/testpmd.c | 2 +-\n examples/ipv4_multicast/main.c | 2 +-\n lib/librte_mbuf/rte_mbuf.c | 1 +\n lib/librte_mbuf/rte_mbuf.h | 45 +++++++++++++++++++++++----------------\n lib/librte_net/rte_ip.h | 39 +++++++++++++++++++++++++++------\n lib/librte_pmd_e1000/igb_rxtx.c | 11 +++++++++-\n lib/librte_pmd_ixgbe/ixgbe_rxtx.c | 11 +++++++++-\n 7 files changed, 82 insertions(+), 29 deletions(-)", "diff": "diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c\nindex 12adafa..632a993 100644\n--- a/app/test-pmd/testpmd.c\n+++ b/app/test-pmd/testpmd.c\n@@ -408,7 +408,7 @@ testpmd_mbuf_ctor(struct rte_mempool *mp,\n \tmb->ol_flags = 0;\n \tmb->data_off = RTE_PKTMBUF_HEADROOM;\n \tmb->nb_segs = 1;\n-\tmb->l2_l3_len = 0;\n+\tmb->tx_offload = 0;\n \tmb->vlan_tci = 0;\n \tmb->hash.rss = 0;\n }\ndiff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c\nindex 590d11a..80c5140 100644\n--- a/examples/ipv4_multicast/main.c\n+++ b/examples/ipv4_multicast/main.c\n@@ -302,7 +302,7 @@ mcast_out_pkt(struct rte_mbuf *pkt, int use_clone)\n \t/* copy metadata from source packet*/\n \thdr->port = pkt->port;\n \thdr->vlan_tci = pkt->vlan_tci;\n-\thdr->l2_l3_len = pkt->l2_l3_len;\n+\thdr->tx_offload = pkt->tx_offload;\n \thdr->hash = pkt->hash;\n \n \thdr->ol_flags = pkt->ol_flags;\ndiff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c\nindex 9b57b3a..87c2963 100644\n--- a/lib/librte_mbuf/rte_mbuf.c\n+++ b/lib/librte_mbuf/rte_mbuf.c\n@@ -241,6 +241,7 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)\n \tcase PKT_TX_UDP_CKSUM: return \"PKT_TX_UDP_CKSUM\";\n \tcase PKT_TX_IEEE1588_TMST: return \"PKT_TX_IEEE1588_TMST\";\n \tcase PKT_TX_VXLAN_CKSUM: return \"PKT_TX_VXLAN_CKSUM\";\n+\tcase PKT_TX_TCP_SEG: return \"PKT_TX_TCP_SEG\";\n \tdefault: return NULL;\n \t}\n }\ndiff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex 10ddd93..bc6c363 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -2,6 +2,7 @@\n * BSD LICENSE\n *\n * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ * Copyright 2014 6WIND S.A.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n@@ -125,6 +126,20 @@ extern \"C\" {\n \n #define PKT_TX_VLAN_PKT (1ULL << 55) /**< TX packet is a 802.1q VLAN packet. */\n \n+/**\n+ * TCP segmentation offload. To enable this offload feature for a\n+ * packet to be transmitted on hardware supporting TSO:\n+ * - set the PKT_TX_TCP_SEG flag in mbuf->ol_flags (this flag implies\n+ * PKT_TX_TCP_CKSUM)\n+ * - if it's IPv4, set the PKT_TX_IP_CKSUM flag and write the IP checksum\n+ * to 0 in the packet\n+ * - fill the mbuf offload information: l2_len, l3_len, l4_len, tso_segsz\n+ * - calculate the pseudo header checksum without taking ip_len in accound,\n+ * and set it in the TCP header. Refer to rte_ipv4_phdr_cksum() and\n+ * rte_ipv6_phdr_cksum() that can be used as helpers.\n+ */\n+#define PKT_TX_TCP_SEG (1ULL << 49)\n+\n /* Use final bit of flags to indicate a control mbuf */\n #define CTRL_MBUF_FLAG (1ULL << 63) /**< Mbuf contains control data */\n \n@@ -226,22 +241,18 @@ struct rte_mbuf {\n \n \t/* fields to support TX offloads */\n \tunion {\n-\t\tuint16_t l2_l3_len; /**< combined l2/l3 lengths as single var */\n+\t\tuint64_t tx_offload; /**< combined for easy fetch */\n \t\tstruct {\n-\t\t\tuint16_t l3_len:9; /**< L3 (IP) Header Length. */\n-\t\t\tuint16_t l2_len:7; /**< L2 (MAC) Header Length. */\n-\t\t};\n-\t};\n+\t\t\tuint64_t l2_len:7; /**< L2 (MAC) Header Length. */\n+\t\t\tuint64_t l3_len:9; /**< L3 (IP) Header Length. */\n+\t\t\tuint64_t l4_len:8; /**< L4 (TCP/UDP) Header Length. */\n+\t\t\tuint64_t tso_segsz:16; /**< TCP TSO segment size */\n \n-\t/* fields for TX offloading of tunnels */\n-\tunion {\n-\t\tuint16_t inner_l2_l3_len;\n-\t\t/**< combined inner l2/l3 lengths as single var */\n-\t\tstruct {\n-\t\t\tuint16_t inner_l3_len:9;\n-\t\t\t/**< inner L3 (IP) Header Length. */\n-\t\t\tuint16_t inner_l2_len:7;\n-\t\t\t/**< inner L2 (MAC) Header Length. */\n+\t\t\t/* fields for TX offloading of tunnels */\n+\t\t\tuint64_t inner_l3_len:9; /**< inner L3 (IP) Hdr Length. */\n+\t\t\tuint64_t inner_l2_len:7; /**< inner L2 (MAC) Hdr Length. */\n+\n+\t\t\t/* uint64_t unused:8; */\n \t\t};\n \t};\n } __rte_cache_aligned;\n@@ -593,8 +604,7 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m)\n {\n \tm->next = NULL;\n \tm->pkt_len = 0;\n-\tm->l2_l3_len = 0;\n-\tm->inner_l2_l3_len = 0;\n+\tm->tx_offload = 0;\n \tm->vlan_tci = 0;\n \tm->nb_segs = 1;\n \tm->port = 0xff;\n@@ -663,8 +673,7 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, struct rte_mbuf *md)\n \tmi->data_len = md->data_len;\n \tmi->port = md->port;\n \tmi->vlan_tci = md->vlan_tci;\n-\tmi->l2_l3_len = md->l2_l3_len;\n-\tmi->inner_l2_l3_len = md->inner_l2_l3_len;\n+\tmi->tx_offload = md->tx_offload;\n \tmi->hash = md->hash;\n \n \tmi->next = NULL;\ndiff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h\nindex 387b06c..20c3ae1 100644\n--- a/lib/librte_net/rte_ip.h\n+++ b/lib/librte_net/rte_ip.h\n@@ -81,6 +81,7 @@\n \n #include <rte_memcpy.h>\n #include <rte_byteorder.h>\n+#include <rte_mbuf.h>\n \n #ifdef __cplusplus\n extern \"C\" {\n@@ -312,13 +313,21 @@ rte_ipv4_cksum(const struct ipv4_hdr *ipv4_hdr)\n *\n * The checksum field must be set to 0 by the caller.\n *\n+ * Depending on the ol_flags, the pseudo-header checksum expected by the\n+ * drivers is not the same. For instance, when TSO is enabled, the IP\n+ * payload length must not be included in the packet.\n+ *\n+ * When ol_flags is 0, it computes the standard pseudo-header checksum.\n+ *\n * @param ipv4_hdr\n * The pointer to the contiguous IPv4 header.\n+ * @param ol_flags\n+ * The ol_flags of the associated mbuf.\n * @return\n * The non-complemented checksum to set in the L4 header.\n */\n static inline uint16_t\n-rte_ipv4_phdr_cksum(const struct ipv4_hdr *ipv4_hdr)\n+rte_ipv4_phdr_cksum(const struct ipv4_hdr *ipv4_hdr, uint64_t ol_flags)\n {\n \tstruct ipv4_psd_header {\n \t\tuint32_t src_addr; /* IP address of source host. */\n@@ -332,9 +341,13 @@ rte_ipv4_phdr_cksum(const struct ipv4_hdr *ipv4_hdr)\n \tpsd_hdr.dst_addr = ipv4_hdr->dst_addr;\n \tpsd_hdr.zero = 0;\n \tpsd_hdr.proto = ipv4_hdr->next_proto_id;\n-\tpsd_hdr.len = rte_cpu_to_be_16(\n-\t\t(uint16_t)(rte_be_to_cpu_16(ipv4_hdr->total_length)\n-\t\t\t- sizeof(struct ipv4_hdr)));\n+\tif (ol_flags & PKT_TX_TCP_SEG) {\n+\t\tpsd_hdr.len = 0;\n+\t} else {\n+\t\tpsd_hdr.len = rte_cpu_to_be_16(\n+\t\t\t(uint16_t)(rte_be_to_cpu_16(ipv4_hdr->total_length)\n+\t\t\t\t- sizeof(struct ipv4_hdr)));\n+\t}\n \treturn rte_raw_cksum((const char *)&psd_hdr, sizeof(psd_hdr));\n }\n \n@@ -361,7 +374,7 @@ rte_ipv4_udptcp_cksum(const struct ipv4_hdr *ipv4_hdr, const void *l4_hdr)\n \t\tsizeof(struct ipv4_hdr);\n \n \tcksum = rte_raw_cksum(l4_hdr, l4_len);\n-\tcksum += rte_ipv4_phdr_cksum(ipv4_hdr);\n+\tcksum += rte_ipv4_phdr_cksum(ipv4_hdr, 0);\n \n \tcksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff);\n \tcksum = (~cksum) & 0xffff;\n@@ -386,13 +399,21 @@ struct ipv6_hdr {\n /**\n * Process the pseudo-header checksum of an IPv6 header.\n *\n+ * Depending on the ol_flags, the pseudo-header checksum expected by the\n+ * drivers is not the same. For instance, when TSO is enabled, the IPv6\n+ * payload length must not be included in the packet.\n+ *\n+ * When ol_flags is 0, it computes the standard pseudo-header checksum.\n+ *\n * @param ipv6_hdr\n * The pointer to the contiguous IPv6 header.\n+ * @param ol_flags\n+ * The ol_flags of the associated mbuf.\n * @return\n * The non-complemented checksum to set in the L4 header.\n */\n static inline uint16_t\n-rte_ipv6_phdr_cksum(const struct ipv6_hdr *ipv6_hdr)\n+rte_ipv6_phdr_cksum(const struct ipv6_hdr *ipv6_hdr, uint64_t ol_flags)\n {\n \tstruct ipv6_psd_header {\n \t\tuint8_t src_addr[16]; /* IP address of source host. */\n@@ -404,7 +425,11 @@ rte_ipv6_phdr_cksum(const struct ipv6_hdr *ipv6_hdr)\n \trte_memcpy(&psd_hdr.src_addr, ipv6_hdr->src_addr,\n \t\tsizeof(ipv6_hdr->src_addr) + sizeof(ipv6_hdr->dst_addr));\n \tpsd_hdr.proto = (ipv6_hdr->proto << 24);\n-\tpsd_hdr.len = ipv6_hdr->payload_len;\n+\tif (ol_flags & PKT_TX_TCP_SEG) {\n+\t\tpsd_hdr.len = 0;\n+\t} else {\n+\t\tpsd_hdr.len = ipv6_hdr->payload_len;\n+\t}\n \n \treturn rte_raw_cksum((const char *)&psd_hdr, sizeof(psd_hdr));\n }\ndiff --git a/lib/librte_pmd_e1000/igb_rxtx.c b/lib/librte_pmd_e1000/igb_rxtx.c\nindex 433c616..848d5d1 100644\n--- a/lib/librte_pmd_e1000/igb_rxtx.c\n+++ b/lib/librte_pmd_e1000/igb_rxtx.c\n@@ -367,6 +367,13 @@ eth_igb_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,\n \tstruct rte_mbuf *tx_pkt;\n \tstruct rte_mbuf *m_seg;\n \tunion igb_vlan_macip vlan_macip_lens;\n+\tunion {\n+\t\tuint16_t u16;\n+\t\tstruct {\n+\t\t\tuint16_t l3_len:9;\n+\t\t\tuint16_t l2_len:7;\n+\t\t};\n+\t} l2_l3_len;\n \tuint64_t buf_dma_addr;\n \tuint32_t olinfo_status;\n \tuint32_t cmd_type_len;\n@@ -404,8 +411,10 @@ eth_igb_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,\n \t\ttx_last = (uint16_t) (tx_id + tx_pkt->nb_segs - 1);\n \n \t\tol_flags = tx_pkt->ol_flags;\n+\t\tl2_l3_len.l2_len = tx_pkt->l2_len;\n+\t\tl2_l3_len.l3_len = tx_pkt->l3_len;\n \t\tvlan_macip_lens.f.vlan_tci = tx_pkt->vlan_tci;\n-\t\tvlan_macip_lens.f.l2_l3_len = tx_pkt->l2_l3_len;\n+\t\tvlan_macip_lens.f.l2_l3_len = l2_l3_len.u16;\n \t\ttx_ol_req = ol_flags & IGB_TX_OFFLOAD_MASK;\n \n \t\t/* If a Context Descriptor need be built . */\ndiff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c\nindex ca35db2..2df3385 100644\n--- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c\n+++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c\n@@ -546,6 +546,13 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,\n \tstruct rte_mbuf *tx_pkt;\n \tstruct rte_mbuf *m_seg;\n \tunion ixgbe_vlan_macip vlan_macip_lens;\n+\tunion {\n+\t\tuint16_t u16;\n+\t\tstruct {\n+\t\t\tuint16_t l3_len:9;\n+\t\t\tuint16_t l2_len:7;\n+\t\t};\n+\t} l2_l3_len;\n \tuint64_t buf_dma_addr;\n \tuint32_t olinfo_status;\n \tuint32_t cmd_type_len;\n@@ -588,8 +595,10 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,\n \t\t/* If hardware offload required */\n \t\ttx_ol_req = ol_flags & IXGBE_TX_OFFLOAD_MASK;\n \t\tif (tx_ol_req) {\n+\t\t\tl2_l3_len.l2_len = tx_pkt->l2_len;\n+\t\t\tl2_l3_len.l3_len = tx_pkt->l3_len;\n \t\t\tvlan_macip_lens.f.vlan_tci = tx_pkt->vlan_tci;\n-\t\t\tvlan_macip_lens.f.l2_l3_len = tx_pkt->l2_l3_len;\n+\t\t\tvlan_macip_lens.f.l2_l3_len = l2_l3_len.u16;\n \n \t\t\t/* If new context need be built or reuse the exist ctx. */\n \t\t\tctx = what_advctx_update(txq, tx_ol_req,\n", "prefixes": [ "dpdk-dev", "v3", "10/13" ] }{ "id": 1405, "url": "