* [dpdk-dev] [RFC 00/16] enhance checksum offload API @ 2015-01-21 23:36 Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 01/16] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz ` (19 more replies) 0 siblings, 20 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev The goal of this series is to clarify and simplify the mbuf offload API. Several issues are solved: - simplify the definitions of PKT_TX_IP_CKSUM and PKT_TX_IPV4, each flag has now only one meaning. No impact on the code. - add a feature flag for OUTER_IP_CHECKSUM (from Jijiang's patches) - remove the PKT_TX_UDP_TUNNEL_PKT flag: it is useless from an API point of view. It was added because i40e need this info for some reason. We have 3 solutions: - remove the flag and adapt the driver to the API (the choice I made for this series). - remove the flag and stop advertising OUTER_IP_CHECKSUM in i40e - keep this flag, penalizing performance of drivers that do not require the flag. It would also mean that drivers won't support outer IP checksum for all tunnel types, but only for the tunnel types having a flag. - a side effect of this API clarification is that there is only one way for doing one operation. If the hardware has several ways to do the same operation, a choice has to be made in the driver. The patch adds new tunnel types to testpmd csum forward engine. Note: the i40e patches should be carefully checked by i40e experts. [1] http://dpdk.org/ml/archives/dev/2015-January/011127.html Jijiang Liu (2): ethdev: add outer IP offload capability flag i40e: advertise outer IPv4 checksum capability Olivier Matz (14): mbuf: remove PKT_TX_IPV4_CSUM mbuf: enhance the API documentation of offload flags i40e: call i40e_txd_enable_checksum only for offloaded packets i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag testpmd: replace tx_checksum command by csum testpmd: move csum_show in a function testpmd: add csum parse_tunnel command testpmd: rename vxlan in outer_ip in csum commands testpmd: introduce parse_ipv* in csum fwd engine testpmd: use a structure to store offload info in csum fwd engine testpmd: introduce parse_vxlan in csum fwd engine testpmd: support gre tunnels in csum fwd engine testpmd: support ipip tunnel in csum forward engine app/test-pmd/cmdline.c | 228 ++++++++++++++------- app/test-pmd/csumonly.c | 416 +++++++++++++++++++++++++------------- app/test-pmd/testpmd.h | 9 +- lib/librte_ether/rte_ethdev.h | 1 + lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 49 +++-- lib/librte_pmd_i40e/i40e_ethdev.c | 3 +- lib/librte_pmd_i40e/i40e_rxtx.c | 23 ++- 8 files changed, 490 insertions(+), 240 deletions(-) -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 01/16] mbuf: remove PKT_TX_IPV4_CSUM 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 02/16] mbuf: enhance the API documentation of offload flags Olivier Matz ` (18 subsequent siblings) 19 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev This alias is only used in one place of i40e driver. Remove it and only keep the legacy flag PKT_TX_IP_CSUM. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_mbuf/rte_mbuf.h | 1 - lib/librte_pmd_i40e/i40e_rxtx.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 16059c6..a554247 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -142,7 +142,6 @@ extern "C" { #define PKT_TX_L4_MASK (3ULL << 52) /**< Mask for L4 cksum offload request. */ #define PKT_TX_IP_CKSUM (1ULL << 54) /**< IP cksum of TX pkt. computed by NIC. */ -#define PKT_TX_IPV4_CSUM PKT_TX_IP_CKSUM /**< Alias of PKT_TX_IP_CKSUM. */ /** Packet is IPv4 without requiring IP checksum offload. */ #define PKT_TX_IPV4 (1ULL << 55) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 2beae3c..8e9df96 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -501,7 +501,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags, << I40E_TX_DESC_LENGTH_MACLEN_SHIFT; /* Enable L3 checksum offloads */ - if (ol_flags & PKT_TX_IPV4_CSUM) { + if (ol_flags & PKT_TX_IP_CKSUM) { *td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM; *td_offset |= (l3_len >> 2) << I40E_TX_DESC_LENGTH_IPLEN_SHIFT; } else if (ol_flags & PKT_TX_IPV4) { -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 02/16] mbuf: enhance the API documentation of offload flags 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 01/16] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 03/16] i40e: call i40e_txd_enable_checksum only for offloaded packets Olivier Matz ` (17 subsequent siblings) 19 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev Based on http://dpdk.org/ml/archives/dev/2015-January/011127.html Also adapt the csum forward engine code to the API. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 6 +++--- lib/librte_mbuf/rte_mbuf.h | 43 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 41711fd..4b438d1 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -183,16 +183,15 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, ipv4_hdr = l3_hdr; ipv4_hdr->hdr_checksum = 0; + ol_flags |= PKT_TX_IPV4; if (tso_segsz != 0 && l4_proto == IPPROTO_TCP) { ol_flags |= PKT_TX_IP_CKSUM; } else { if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ol_flags |= PKT_TX_IP_CKSUM; - else { + else ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); - ol_flags |= PKT_TX_IPV4; - } } } else if (ethertype == _htons(ETHER_TYPE_IPv6)) ol_flags |= PKT_TX_IPV6; @@ -261,6 +260,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr->hdr_checksum = 0; + ol_flags |= PKT_TX_OUTER_IPV4; if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ol_flags |= PKT_TX_OUTER_IP_CKSUM; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index a554247..191a42c 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -141,24 +141,53 @@ extern "C" { #define PKT_TX_UDP_CKSUM (3ULL << 52) /**< UDP cksum of TX pkt. computed by NIC. */ #define PKT_TX_L4_MASK (3ULL << 52) /**< Mask for L4 cksum offload request. */ -#define PKT_TX_IP_CKSUM (1ULL << 54) /**< IP cksum of TX pkt. computed by NIC. */ +/** + * Offload the IP checksum in the hardware. The flag PKT_TX_IPV4 should + * also be set by the application, altough a PMD will only check + * PKT_TX_IP_CKSUM. + * - set the IP checksum field in the packet to 0 + * - fill the mbuf offload information: l2_len, l3_len + */ +#define PKT_TX_IP_CKSUM (1ULL << 54) -/** Packet is IPv4 without requiring IP checksum offload. */ +/** + * Packet is IPv4. This flag must be set when using any offload feature + * (TSO, L3 or L4 checksum) to tell the NIC that the packet is an IPv4 + * packet. + */ #define PKT_TX_IPV4 (1ULL << 55) -/** Tell the NIC it's an IPv6 packet.*/ +/** + * Packet is IPv6. This flag must be set when using an offload feature + * (TSO or L4 checksum) to tell the NIC that the packet is an IPv6 + * packet. + */ #define PKT_TX_IPV6 (1ULL << 56) #define PKT_TX_VLAN_PKT (1ULL << 57) /**< TX packet is a 802.1q VLAN packet. */ -/** Outer IP checksum of TX packet, computed by NIC for tunneling packet. - * The tunnel type must also be specified, ex: PKT_TX_UDP_TUNNEL_PKT. */ +/** + * Offload the IP checksum of an external header in the hardware. The + * flag PKT_TX_OUTER_IPV4 should also be set by the application, altough + * a PMD will only check PKT_TX_IP_CKSUM. The IP checksum field in the + * packet must be set to 0. + * - set the outer IP checksum field in the packet to 0 + * - fill the mbuf offload information: outer_l2_len, outer_l3_len + */ #define PKT_TX_OUTER_IP_CKSUM (1ULL << 58) -/** Packet is outer IPv4 without requiring IP checksum offload for tunneling packet. */ +/** + * Packet outer header is IPv4. This flag must be set when using any + * outer offload feature (L3 or L4 checksum) to tell the NIC that the + * packet is an IPv4 packet. + */ #define PKT_TX_OUTER_IPV4 (1ULL << 59) -/** Tell the NIC it's an outer IPv6 packet for tunneling packet */ +/** + * Packet outer header is IPv6. This flag must be set when using any + * outer offload feature (L4 checksum) to tell the NIC that the packet + * is an IPv6 packet. + */ #define PKT_TX_OUTER_IPV6 (1ULL << 60) /* Use final bit of flags to indicate a control mbuf */ -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 03/16] i40e: call i40e_txd_enable_checksum only for offloaded packets 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 01/16] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 02/16] mbuf: enhance the API documentation of offload flags Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 04/16] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag Olivier Matz ` (16 subsequent siblings) 19 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev >From i40e datasheet: The IP header type and its offload. In case of tunneling, the IIPT relates to the inner IP header. See also EIPT field for the outer (External) IP header offload. 00 - non IP packet or packet type is not defined by software 01 - IPv6 packet 10 - IPv4 packet with no IP checksum offload 11 - IPv4 packet with IP checksum offload Therefore it is not needed to fill the IIPT field if no offload is requested (we can keep the value to 00). For instance, the linux driver code does not set it when (skb->ip_summed != CHECKSUM_PARTIAL). We can do the same in the dpdk driver. The function i40e_txd_enable_checksum() that fills the offload registers can only be called for packets requiring an offload. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_rxtx.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 8e9df96..9acdeee 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -74,6 +74,11 @@ #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS) +#define I40E_TX_CKSUM_OFFLOAD_MASK ( \ + PKT_TX_IP_CKSUM | \ + PKT_TX_L4_MASK | \ + PKT_TX_OUTER_IP_CKSUM) + #define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \ (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM) @@ -1272,10 +1277,12 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) /* Enable checksum offloading */ cd_tunneling_params = 0; - i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, - l2_len, l3_len, outer_l2_len, - outer_l3_len, - &cd_tunneling_params); + if (ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK) { + i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, + l2_len, l3_len, outer_l2_len, + outer_l3_len, + &cd_tunneling_params); + } if (unlikely(nb_ctx)) { /* Setup TX context descriptor if required */ -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 04/16] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (2 preceding siblings ...) 2015-01-21 23:36 ` [dpdk-dev] [RFC 03/16] i40e: call i40e_txd_enable_checksum only for offloaded packets Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-23 8:06 ` Liu, Jijiang 2015-01-21 23:36 ` [dpdk-dev] [RFC 05/16] mbuf: remove " Olivier Matz ` (15 subsequent siblings) 19 siblings, 1 reply; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev The definition of the flag in rte_mbuf.h was: TX packet is an UDP tunneled packet. It must be specified when using outer checksum offload (PKT_TX_OUTER_IP_CKSUM) This flag was used to tell the NIC that the offload type is UDP (I40E_TXD_CTX_UDP_TUNNELING flag). In the datasheet, it says it's required to specify the tunnel type in the register. However, some tests (see [1]) showed that it also works without this flag. Moreover, it is not explained how the hardware use this information. From a network perspective, this information is useless for calculating the outer IP checksum as it does not depend on the payload. Having this flag in the API would force the application to specify the tunnel type for something that looks only useful for this PMD. It will limit the number of possible tunnel types (we would need a flag for each tunnel type) and therefore prevent to support outer IP checksum for proprietary tunnels. Finally, if a hardware advertises "I support outer IP checksum", it must be supported for any payload types. [1] http://dpdk.org/ml/archives/dev/2015-January/011380.html Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_rxtx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 9acdeee..0786255 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -482,7 +482,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags, } /* UDP tunneling packet TX checksum offload */ - if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) { + if (unlikely(ol_flags & PKT_TX_OUTER_IP_CKSUM)) { *td_offset |= (outer_l2_len >> 1) << I40E_TX_DESC_LENGTH_MACLEN_SHIFT; @@ -497,7 +497,6 @@ i40e_txd_enable_checksum(uint64_t ol_flags, /* Now set the ctx descriptor fields */ *cd_tunneling |= (outer_l3_len >> 2) << I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT | - I40E_TXD_CTX_UDP_TUNNELING | (l2_len >> 1) << I40E_TXD_CTX_QW0_NATLEN_SHIFT; @@ -1165,8 +1164,7 @@ i40e_calc_context_desc(uint64_t flags) { uint64_t mask = 0ULL; - if (flags | PKT_TX_UDP_TUNNEL_PKT) - mask |= PKT_TX_UDP_TUNNEL_PKT; + mask |= PKT_TX_OUTER_IP_CKSUM; #ifdef RTE_LIBRTE_IEEE1588 mask |= PKT_TX_IEEE1588_TMST; -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [RFC 04/16] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag 2015-01-21 23:36 ` [dpdk-dev] [RFC 04/16] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag Olivier Matz @ 2015-01-23 8:06 ` Liu, Jijiang 2015-01-23 8:47 ` Zhang, Helin 0 siblings, 1 reply; 109+ messages in thread From: Liu, Jijiang @ 2015-01-23 8:06 UTC (permalink / raw) To: Olivier Matz, Zhang, Helin; +Cc: dev Hi, > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Thursday, January 22, 2015 7:36 AM > To: dev@dpdk.org > Cc: olivier.matz@6wind.com; Ananyev, Konstantin; Liu, Jijiang > Subject: [RFC 04/16] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag > > The definition of the flag in rte_mbuf.h was: > TX packet is an UDP tunneled packet. It must be specified when using > outer checksum offload (PKT_TX_OUTER_IP_CKSUM) > > This flag was used to tell the NIC that the offload type is UDP > (I40E_TXD_CTX_UDP_TUNNELING flag). In the datasheet, it says it's required > to specify the tunnel type in the register. However, some tests (see [1]) > showed that it also works without this flag. > > Moreover, it is not explained how the hardware use this information. From a > network perspective, this information is useless for calculating the outer IP > checksum as it does not depend on the payload. > > Having this flag in the API would force the application to specify the tunnel > type for something that looks only useful for this PMD. It will limit the > number of possible tunnel types (we would need a flag for each tunnel type) > and therefore prevent to support outer IP checksum for proprietary tunnels. > > Finally, if a hardware advertises "I support outer IP checksum", it must be > supported for any payload types. > > [1] http://dpdk.org/ml/archives/dev/2015-January/011380.html > > Signed-off-by: Olivier Matz <olivier.matz@6wind.com> > --- > lib/librte_pmd_i40e/i40e_rxtx.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c > index 9acdeee..0786255 100644 > --- a/lib/librte_pmd_i40e/i40e_rxtx.c > +++ b/lib/librte_pmd_i40e/i40e_rxtx.c > @@ -482,7 +482,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags, > } > > /* UDP tunneling packet TX checksum offload */ > - if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) { > + if (unlikely(ol_flags & PKT_TX_OUTER_IP_CKSUM)) { This way will disable FVL TX checksum offload capability of inner IP and inner L4 using B.1 method. Again, the B.1 in http://dpdk.org/ml/archives/dev/2014-December/009213.html should be supported and allowed. Helin, you are i40e maintainer, what's your point? > *td_offset |= (outer_l2_len >> 1) > << I40E_TX_DESC_LENGTH_MACLEN_SHIFT; > @@ -497,7 +497,6 @@ i40e_txd_enable_checksum(uint64_t ol_flags, > /* Now set the ctx descriptor fields */ > *cd_tunneling |= (outer_l3_len >> 2) << > I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT | > - I40E_TXD_CTX_UDP_TUNNELING | > (l2_len >> 1) << > I40E_TXD_CTX_QW0_NATLEN_SHIFT; > > @@ -1165,8 +1164,7 @@ i40e_calc_context_desc(uint64_t flags) { > uint64_t mask = 0ULL; > > - if (flags | PKT_TX_UDP_TUNNEL_PKT) > - mask |= PKT_TX_UDP_TUNNEL_PKT; > + mask |= PKT_TX_OUTER_IP_CKSUM; > > #ifdef RTE_LIBRTE_IEEE1588 > mask |= PKT_TX_IEEE1588_TMST; > -- > 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [RFC 04/16] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag 2015-01-23 8:06 ` Liu, Jijiang @ 2015-01-23 8:47 ` Zhang, Helin 2015-01-23 9:06 ` Olivier MATZ 0 siblings, 1 reply; 109+ messages in thread From: Zhang, Helin @ 2015-01-23 8:47 UTC (permalink / raw) To: Liu, Jijiang, Olivier Matz; +Cc: dev Hi guys > -----Original Message----- > From: Liu, Jijiang > Sent: Friday, January 23, 2015 4:06 PM > To: Olivier Matz; Zhang, Helin > Cc: Ananyev, Konstantin; dev@dpdk.org > Subject: RE: [RFC 04/16] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT > flag > > Hi, > > > -----Original Message----- > > From: Olivier Matz [mailto:olivier.matz@6wind.com] > > Sent: Thursday, January 22, 2015 7:36 AM > > To: dev@dpdk.org > > Cc: olivier.matz@6wind.com; Ananyev, Konstantin; Liu, Jijiang > > Subject: [RFC 04/16] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT > > flag > > > > The definition of the flag in rte_mbuf.h was: > > TX packet is an UDP tunneled packet. It must be specified when using > > outer checksum offload (PKT_TX_OUTER_IP_CKSUM) > > > > This flag was used to tell the NIC that the offload type is UDP > > (I40E_TXD_CTX_UDP_TUNNELING flag). In the datasheet, it says it's > > required to specify the tunnel type in the register. However, some > > tests (see [1]) showed that it also works without this flag. > > > > Moreover, it is not explained how the hardware use this information. > > From a network perspective, this information is useless for > > calculating the outer IP checksum as it does not depend on the payload. > > > > Having this flag in the API would force the application to specify the > > tunnel type for something that looks only useful for this PMD. It will > > limit the number of possible tunnel types (we would need a flag for > > each tunnel type) and therefore prevent to support outer IP checksum for > proprietary tunnels. > > > > Finally, if a hardware advertises "I support outer IP checksum", it > > must be supported for any payload types. > > > > [1] http://dpdk.org/ml/archives/dev/2015-January/011380.html > > > > Signed-off-by: Olivier Matz <olivier.matz@6wind.com> > > --- > > lib/librte_pmd_i40e/i40e_rxtx.c | 6 ++---- > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c > > b/lib/librte_pmd_i40e/i40e_rxtx.c index 9acdeee..0786255 100644 > > --- a/lib/librte_pmd_i40e/i40e_rxtx.c > > +++ b/lib/librte_pmd_i40e/i40e_rxtx.c > > @@ -482,7 +482,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags, > > } > > > > /* UDP tunneling packet TX checksum offload */ > > - if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) { > > + if (unlikely(ol_flags & PKT_TX_OUTER_IP_CKSUM)) { > > This way will disable FVL TX checksum offload capability of inner IP and inner > L4 using B.1 method. > > Again, the B.1 in > http://dpdk.org/ml/archives/dev/2014-December/009213.html should be > supported and allowed. > > Helin, you are i40e maintainer, what's your point? Can we list all the possible checksum cases (with or without hardware offloads)? 1. Outer IP (hw csum) + inner IP (hw csum) + L4 (hw csum) 2. Outer IP (hw csum) + inner IP (hw csum) + L4 (sw csum) 3. Outer IP (hw csum) + inner IP (sw csum) + L4 (hw csum) 4. Outer IP (hw csum) + inner IP (sw csum) + L4 (sw csum) 5. Outer IP (sw csum) + inner IP (hw csum) + L4 (hw csum) 6. Outer IP (sw csum) + inner IP (hw csum) + L4 (sw csum) 7. Outer IP (sw csum) + inner IP (sw csum) + L4 (hw csum) 8. Outer IP (sw csum) + inner IP (sw csum) + L4 (sw csum) Does any hardware support all of these cases? If yes, I think we should to have a solution to support all of them. > > > > *td_offset |= (outer_l2_len >> 1) > > << I40E_TX_DESC_LENGTH_MACLEN_SHIFT; @@ -497,7 > +497,6 @@ > > i40e_txd_enable_checksum(uint64_t ol_flags, > > /* Now set the ctx descriptor fields */ > > *cd_tunneling |= (outer_l3_len >> 2) << > > I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT | > > - I40E_TXD_CTX_UDP_TUNNELING | > > (l2_len >> 1) << > > I40E_TXD_CTX_QW0_NATLEN_SHIFT; > > > > > > > @@ -1165,8 +1164,7 @@ i40e_calc_context_desc(uint64_t flags) { > > uint64_t mask = 0ULL; > > > > - if (flags | PKT_TX_UDP_TUNNEL_PKT) > > - mask |= PKT_TX_UDP_TUNNEL_PKT; > > + mask |= PKT_TX_OUTER_IP_CKSUM; > > > > #ifdef RTE_LIBRTE_IEEE1588 > > mask |= PKT_TX_IEEE1588_TMST; > > -- > > 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [RFC 04/16] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag 2015-01-23 8:47 ` Zhang, Helin @ 2015-01-23 9:06 ` Olivier MATZ 0 siblings, 0 replies; 109+ messages in thread From: Olivier MATZ @ 2015-01-23 9:06 UTC (permalink / raw) To: Zhang, Helin, Liu, Jijiang; +Cc: dev Hi Helin, On 01/23/2015 09:47 AM, Zhang, Helin wrote: >>> diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c >>> b/lib/librte_pmd_i40e/i40e_rxtx.c index 9acdeee..0786255 100644 >>> --- a/lib/librte_pmd_i40e/i40e_rxtx.c >>> +++ b/lib/librte_pmd_i40e/i40e_rxtx.c >>> @@ -482,7 +482,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags, >>> } >>> >>> /* UDP tunneling packet TX checksum offload */ >>> - if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) { >>> + if (unlikely(ol_flags & PKT_TX_OUTER_IP_CKSUM)) { >> >> This way will disable FVL TX checksum offload capability of inner IP and inner >> L4 using B.1 method. >> >> Again, the B.1 in >> http://dpdk.org/ml/archives/dev/2014-December/009213.html should be >> supported and allowed. >> >> Helin, you are i40e maintainer, what's your point? > > Can we list all the possible checksum cases (with or without hardware offloads)? > 1. Outer IP (hw csum) + inner IP (hw csum) + L4 (hw csum) > 2. Outer IP (hw csum) + inner IP (hw csum) + L4 (sw csum) > 3. Outer IP (hw csum) + inner IP (sw csum) + L4 (hw csum) case 6 in [1] > 4. Outer IP (hw csum) + inner IP (sw csum) + L4 (sw csum) case 1 in [1] > 5. Outer IP (sw csum) + inner IP (hw csum) + L4 (hw csum) > 6. Outer IP (sw csum) + inner IP (hw csum) + L4 (sw csum) > 7. Outer IP (sw csum) + inner IP (sw csum) + L4 (hw csum) case 3 and 4 in [1] > 8. Outer IP (sw csum) + inner IP (sw csum) + L4 (sw csum) no hardware offload Removing the PKT_TX_UDP_TUNNEL_PKT does not prevent to do an operation from the user point of view. In i40e, there are 2 ways to calculate the inner checksums. The idea is to have only one in the mbuf API, and to let the driver decide how to talk to the hardware, but it's not the user problem. Regards, Olivier [1] http://dpdk.org/ml/archives/dev/2015-January/011127.html ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 05/16] mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (3 preceding siblings ...) 2015-01-21 23:36 ` [dpdk-dev] [RFC 04/16] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 06/16] ethdev: add outer IP offload capability flag Olivier Matz ` (14 subsequent siblings) 19 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev Since previous commit, this flag is not used by any PMD, remove it from mbuf API and from csumonly (testpmd). In csumonly, the PKT_TX_OUTER_IP_CKSUM flag is already set for vxlan checksum, providing enough information to the underlying driver. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 4 ---- lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 5 +---- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 4b438d1..ca5ca39 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -255,9 +255,6 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, struct udp_hdr *udp_hdr; uint64_t ol_flags = 0; - if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) - ol_flags |= PKT_TX_UDP_TUNNEL_PKT; - if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_OUTER_IPV4; @@ -473,7 +470,6 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) { PKT_TX_UDP_CKSUM, PKT_TX_L4_MASK }, { PKT_TX_TCP_CKSUM, PKT_TX_L4_MASK }, { PKT_TX_SCTP_CKSUM, PKT_TX_L4_MASK }, - { PKT_TX_UDP_TUNNEL_PKT, PKT_TX_UDP_TUNNEL_PKT }, { PKT_TX_IPV4, PKT_TX_IPV4 }, { PKT_TX_IPV6, PKT_TX_IPV6 }, { PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM }, diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 1b14e02..2a4bc8c 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -240,7 +240,6 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask) case PKT_TX_SCTP_CKSUM: return "PKT_TX_SCTP_CKSUM"; case PKT_TX_UDP_CKSUM: return "PKT_TX_UDP_CKSUM"; case PKT_TX_IEEE1588_TMST: return "PKT_TX_IEEE1588_TMST"; - case PKT_TX_UDP_TUNNEL_PKT: return "PKT_TX_UDP_TUNNEL_PKT"; case PKT_TX_TCP_SEG: return "PKT_TX_TCP_SEG"; case PKT_TX_IPV4: return "PKT_TX_IPV4"; case PKT_TX_IPV6: return "PKT_TX_IPV6"; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 191a42c..d841caa 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -117,11 +117,8 @@ extern "C" { * and set it in the TCP header. Refer to rte_ipv4_phdr_cksum() and * rte_ipv6_phdr_cksum() that can be used as helpers. */ -#define PKT_TX_TCP_SEG (1ULL << 49) +#define PKT_TX_TCP_SEG (1ULL << 50) -/** TX packet is an UDP tunneled packet. It must be specified when using - * outer checksum offload (PKT_TX_OUTER_IP_CKSUM) */ -#define PKT_TX_UDP_TUNNEL_PKT (1ULL << 50) /**< TX packet is an UDP tunneled packet */ #define PKT_TX_IEEE1588_TMST (1ULL << 51) /**< TX IEEE1588 packet to timestamp. */ /** -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 06/16] ethdev: add outer IP offload capability flag 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (4 preceding siblings ...) 2015-01-21 23:36 ` [dpdk-dev] [RFC 05/16] mbuf: remove " Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 07/16] i40e: advertise outer IPv4 checksum capability Olivier Matz ` (13 subsequent siblings) 19 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev From: Jijiang Liu <jijiang.liu@intel.com> If the flag is advertised by a PMD, the NIC supports the outer IP checksum TX offload of tunneling packets, therefore an application can set the PKT_TX_OUTER_IP_CKSUM flag in mbufs when transmitting on this port. Signed-off-by: Jijiang Liu <jijiang.liu@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_ether/rte_ethdev.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 1200c1c..84160c3 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -916,6 +916,7 @@ struct rte_eth_conf { #define DEV_TX_OFFLOAD_SCTP_CKSUM 0x00000010 #define DEV_TX_OFFLOAD_TCP_TSO 0x00000020 #define DEV_TX_OFFLOAD_UDP_TSO 0x00000040 +#define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080 /**< Used for tunneling packet. */ struct rte_eth_dev_info { struct rte_pci_device *pci_dev; /**< Device PCI information. */ -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 07/16] i40e: advertise outer IPv4 checksum capability 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (5 preceding siblings ...) 2015-01-21 23:36 ` [dpdk-dev] [RFC 06/16] ethdev: add outer IP offload capability flag Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 08/16] testpmd: replace tx_checksum command by csum Olivier Matz ` (12 subsequent siblings) 19 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev From: Jijiang Liu <jijiang.liu@intel.com> Advertise the DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM flag in the PMD features. It means that the i40e PMD supports the offload of outer IP checksum when transmitting tunneling packet. Signed-off-by: Jijiang Liu <jijiang.liu@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c b/lib/librte_pmd_i40e/i40e_ethdev.c index b47a3d2..2244495 100644 --- a/lib/librte_pmd_i40e/i40e_ethdev.c +++ b/lib/librte_pmd_i40e/i40e_ethdev.c @@ -1516,7 +1516,8 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) DEV_TX_OFFLOAD_IPV4_CKSUM | DEV_TX_OFFLOAD_UDP_CKSUM | DEV_TX_OFFLOAD_TCP_CKSUM | - DEV_TX_OFFLOAD_SCTP_CKSUM; + DEV_TX_OFFLOAD_SCTP_CKSUM | + DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; dev_info->reta_size = pf->hash_lut_size; dev_info->default_rxconf = (struct rte_eth_rxconf) { -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 08/16] testpmd: replace tx_checksum command by csum 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (6 preceding siblings ...) 2015-01-21 23:36 ` [dpdk-dev] [RFC 07/16] i40e: advertise outer IPv4 checksum capability Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 09/16] testpmd: move csum_show in a function Olivier Matz ` (11 subsequent siblings) 19 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev Replace the "tx_checksum" command by "csum". It has several advantages: - it's more coherent with the forward engine name - it's shorter - the next commit will introduce a command that is related to the csum forward engine, but about rx side. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 70 +++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 4beb404..1aecbbb 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -316,7 +316,7 @@ static void cmd_help_long_parsed(void *parsed_result, " Disable hardware insertion of a VLAN header in" " packets sent on a port.\n\n" - "tx_cksum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n" + "csum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n" " Select hardware or software calculation of the" " checksum with when transmitting a packet using the" " csum forward engine.\n" @@ -326,7 +326,7 @@ static void cmd_help_long_parsed(void *parsed_result, " the forward engine)\n" " Please check the NIC datasheet for HW limits.\n\n" - "tx_checksum show (port_id)\n" + "csum show (port_id)\n" " Display tx checksum offload configuration\n\n" "tso set (segsize) (portid)\n" @@ -2858,8 +2858,8 @@ cmdline_parse_inst_t cmd_tx_vlan_reset = { /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ -struct cmd_tx_cksum_result { - cmdline_fixed_string_t tx_cksum; +struct cmd_csum_result { + cmdline_fixed_string_t csum; cmdline_fixed_string_t mode; cmdline_fixed_string_t proto; cmdline_fixed_string_t hwsw; @@ -2867,11 +2867,11 @@ struct cmd_tx_cksum_result { }; static void -cmd_tx_cksum_parsed(void *parsed_result, +cmd_csum_parsed(void *parsed_result, __attribute__((unused)) struct cmdline *cl, __attribute__((unused)) void *data) { - struct cmd_tx_cksum_result *res = parsed_result; + struct cmd_csum_result *res = parsed_result; int hw = 0; uint16_t ol_flags, mask = 0; struct rte_eth_dev_info dev_info; @@ -2940,49 +2940,49 @@ cmd_tx_cksum_parsed(void *parsed_result, } } -cmdline_parse_token_string_t cmd_tx_cksum_tx_cksum = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, - tx_cksum, "tx_checksum"); -cmdline_parse_token_string_t cmd_tx_cksum_mode = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_csum = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, + csum, "csum"); +cmdline_parse_token_string_t cmd_csum_mode = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, mode, "set"); -cmdline_parse_token_string_t cmd_tx_cksum_proto = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_proto = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, proto, "ip#tcp#udp#sctp#vxlan"); -cmdline_parse_token_string_t cmd_tx_cksum_hwsw = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_hwsw = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, hwsw, "hw#sw"); -cmdline_parse_token_num_t cmd_tx_cksum_portid = - TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_num_t cmd_csum_portid = + TOKEN_NUM_INITIALIZER(struct cmd_csum_result, port_id, UINT8); -cmdline_parse_inst_t cmd_tx_cksum_set = { - .f = cmd_tx_cksum_parsed, +cmdline_parse_inst_t cmd_csum_set = { + .f = cmd_csum_parsed, .data = NULL, .help_str = "enable/disable hardware calculation of L3/L4 checksum when " - "using csum forward engine: tx_cksum set ip|tcp|udp|sctp|vxlan hw|sw <port>", + "using csum forward engine: csum set ip|tcp|udp|sctp|vxlan hw|sw <port>", .tokens = { - (void *)&cmd_tx_cksum_tx_cksum, - (void *)&cmd_tx_cksum_mode, - (void *)&cmd_tx_cksum_proto, - (void *)&cmd_tx_cksum_hwsw, - (void *)&cmd_tx_cksum_portid, + (void *)&cmd_csum_csum, + (void *)&cmd_csum_mode, + (void *)&cmd_csum_proto, + (void *)&cmd_csum_hwsw, + (void *)&cmd_csum_portid, NULL, }, }; -cmdline_parse_token_string_t cmd_tx_cksum_mode_show = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_mode_show = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, mode, "show"); -cmdline_parse_inst_t cmd_tx_cksum_show = { - .f = cmd_tx_cksum_parsed, +cmdline_parse_inst_t cmd_csum_show = { + .f = cmd_csum_parsed, .data = NULL, - .help_str = "show checksum offload configuration: tx_cksum show <port>", + .help_str = "show checksum offload configuration: csum show <port>", .tokens = { - (void *)&cmd_tx_cksum_tx_cksum, - (void *)&cmd_tx_cksum_mode_show, - (void *)&cmd_tx_cksum_portid, + (void *)&cmd_csum_csum, + (void *)&cmd_csum_mode_show, + (void *)&cmd_csum_portid, NULL, }, }; @@ -8721,8 +8721,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_tx_vlan_set, (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, - (cmdline_parse_inst_t *)&cmd_tx_cksum_set, - (cmdline_parse_inst_t *)&cmd_tx_cksum_show, + (cmdline_parse_inst_t *)&cmd_csum_set, + (cmdline_parse_inst_t *)&cmd_csum_show, (cmdline_parse_inst_t *)&cmd_tso_set, (cmdline_parse_inst_t *)&cmd_tso_show, (cmdline_parse_inst_t *)&cmd_link_flow_control_set, -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 09/16] testpmd: move csum_show in a function 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (7 preceding siblings ...) 2015-01-21 23:36 ` [dpdk-dev] [RFC 08/16] testpmd: replace tx_checksum command by csum Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-23 11:03 ` Liu, Jijiang 2015-01-21 23:36 ` [dpdk-dev] [RFC 10/16] testpmd: add csum parse_tunnel command Olivier Matz ` (10 subsequent siblings) 19 siblings, 1 reply; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev No functional changes in this commit, we just move the code that displays the csum forward engine configuration in a function. This makes the next commit easier to read as it will also use this function. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 82 +++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 1aecbbb..260a273 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2867,14 +2867,56 @@ struct cmd_csum_result { }; static void +csum_show(int port_id) +{ + struct rte_eth_dev_info dev_info; + uint16_t ol_flags; + + ol_flags = ports[port_id].tx_ol_flags; + printf("IP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); + printf("UDP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); + printf("TCP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); + printf("SCTP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); + printf("VxLAN checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw"); + + /* display warnings if configuration is not supported by the NIC */ + rte_eth_dev_info_get(port_id, &dev_info); + if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { + printf("Warning: hardware IP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { + printf("Warning: hardware UDP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { + printf("Warning: hardware TCP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { + printf("Warning: hardware SCTP checksum enabled but not " + "supported by port %d\n", port_id); + } + +} + +static void cmd_csum_parsed(void *parsed_result, __attribute__((unused)) struct cmdline *cl, __attribute__((unused)) void *data) { struct cmd_csum_result *res = parsed_result; int hw = 0; - uint16_t ol_flags, mask = 0; - struct rte_eth_dev_info dev_info; + uint16_t mask = 0; if (port_id_is_invalid(res->port_id)) { printf("invalid port %d\n", res->port_id); @@ -2903,41 +2945,7 @@ cmd_csum_parsed(void *parsed_result, else ports[res->port_id].tx_ol_flags &= (~mask); } - - ol_flags = ports[res->port_id].tx_ol_flags; - printf("IP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); - printf("UDP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); - printf("TCP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); - printf("SCTP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); - printf("VxLAN checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw"); - - /* display warnings if configuration is not supported by the NIC */ - rte_eth_dev_info_get(res->port_id, &dev_info); - if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { - printf("Warning: hardware IP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { - printf("Warning: hardware UDP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { - printf("Warning: hardware TCP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { - printf("Warning: hardware SCTP checksum enabled but not " - "supported by port %d\n", res->port_id); - } + csum_show(res->port_id); } cmdline_parse_token_string_t cmd_csum_csum = -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [RFC 09/16] testpmd: move csum_show in a function 2015-01-21 23:36 ` [dpdk-dev] [RFC 09/16] testpmd: move csum_show in a function Olivier Matz @ 2015-01-23 11:03 ` Liu, Jijiang 2015-01-23 17:53 ` Olivier MATZ 0 siblings, 1 reply; 109+ messages in thread From: Liu, Jijiang @ 2015-01-23 11:03 UTC (permalink / raw) To: Olivier Matz; +Cc: dev Hi, -----Original Message----- From: Olivier Matz [mailto:olivier.matz@6wind.com] Sent: Thursday, January 22, 2015 7:36 AM To: dev@dpdk.org Cc: olivier.matz@6wind.com; Ananyev, Konstantin; Liu, Jijiang Subject: [RFC 09/16] testpmd: move csum_show in a function No functional changes in this commit, we just move the code that displays the csum forward engine configuration in a function. This makes the next commit easier to read as it will also use this function. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 82 +++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 1aecbbb..260a273 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2867,14 +2867,56 @@ struct cmd_csum_result { }; static void +csum_show(int port_id) +{ + struct rte_eth_dev_info dev_info; + uint16_t ol_flags; + + ol_flags = ports[port_id].tx_ol_flags; + printf("IP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); + printf("UDP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); + printf("TCP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); + printf("SCTP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); + printf("VxLAN checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw"); + + /* display warnings if configuration is not supported by the NIC */ + rte_eth_dev_info_get(port_id, &dev_info); + if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { + printf("Warning: hardware IP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { + printf("Warning: hardware UDP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { + printf("Warning: hardware TCP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { + printf("Warning: hardware SCTP checksum enabled but not " + "supported by port %d\n", port_id); + } The ESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM check is missed here. + +} + +static void cmd_csum_parsed(void *parsed_result, __attribute__((unused)) struct cmdline *cl, __attribute__((unused)) void *data) { struct cmd_csum_result *res = parsed_result; int hw = 0; - uint16_t ol_flags, mask = 0; - struct rte_eth_dev_info dev_info; + uint16_t mask = 0; if (port_id_is_invalid(res->port_id)) { printf("invalid port %d\n", res->port_id); @@ -2903,41 +2945,7 @@ cmd_csum_parsed(void *parsed_result, else ports[res->port_id].tx_ol_flags &= (~mask); } - - ol_flags = ports[res->port_id].tx_ol_flags; - printf("IP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); - printf("UDP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); - printf("TCP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); - printf("SCTP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); - printf("VxLAN checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw"); - - /* display warnings if configuration is not supported by the NIC */ - rte_eth_dev_info_get(res->port_id, &dev_info); - if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { - printf("Warning: hardware IP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { - printf("Warning: hardware UDP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { - printf("Warning: hardware TCP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { - printf("Warning: hardware SCTP checksum enabled but not " - "supported by port %d\n", res->port_id); - } + csum_show(res->port_id); } cmdline_parse_token_string_t cmd_csum_csum = -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [RFC 09/16] testpmd: move csum_show in a function 2015-01-23 11:03 ` Liu, Jijiang @ 2015-01-23 17:53 ` Olivier MATZ 0 siblings, 0 replies; 109+ messages in thread From: Olivier MATZ @ 2015-01-23 17:53 UTC (permalink / raw) To: Liu, Jijiang; +Cc: dev Hi Jijiang, On 01/23/2015 12:03 PM, Liu, Jijiang wrote: > + /* display warnings if configuration is not supported by the NIC */ > + rte_eth_dev_info_get(port_id, &dev_info); > + if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) && > + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { > + printf("Warning: hardware IP checksum enabled but not " > + "supported by port %d\n", port_id); > + } > + if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) && > + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { > + printf("Warning: hardware UDP checksum enabled but not " > + "supported by port %d\n", port_id); > + } > + if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) && > + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { > + printf("Warning: hardware TCP checksum enabled but not " > + "supported by port %d\n", port_id); > + } > + if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) && > + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { > + printf("Warning: hardware SCTP checksum enabled but not " > + "supported by port %d\n", port_id); > + } > > The ESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM check is missed here. Yes, it should be added in this patch: ethdev: add outer IP offload capability flag I'll do it for the next version. Regards, Olivier ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 10/16] testpmd: add csum parse_tunnel command 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (8 preceding siblings ...) 2015-01-21 23:36 ` [dpdk-dev] [RFC 09/16] testpmd: move csum_show in a function Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 11/16] testpmd: rename vxlan in outer_ip in csum commands Olivier Matz ` (9 subsequent siblings) 19 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev Add a new command related to csum forward engine: csum parse-tunnel (on|off) (port_id) If enabled, the tunnel packets received by the csum forward engine are parsed and seen as "outer-headers/inner-headers/data". If disabled, the parsing of the csum forward engine stops at the first l4 layer. A tunnel packet is seens as "headers/data" (inner headers are included in payload). Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/csumonly.c | 3 ++- app/test-pmd/testpmd.h | 5 +++- 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 260a273..1d294bc 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -326,6 +326,10 @@ static void cmd_help_long_parsed(void *parsed_result, " the forward engine)\n" " Please check the NIC datasheet for HW limits.\n\n" + "csum parse-tunnel (on|off) (port_id)\n" + " If disabled, treat tunnel packets as non-tunneled" + " packets (treat inner headers as payload).\n\n" + "csum show (port_id)\n" " Display tx checksum offload configuration\n\n" @@ -2873,6 +2877,8 @@ csum_show(int port_id) uint16_t ol_flags; ol_flags = ports[port_id].tx_ol_flags; + printf("Parse tunnel is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off"); printf("IP checksum offload is %s\n", (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); printf("UDP checksum offload is %s\n", @@ -2995,6 +3001,63 @@ cmdline_parse_inst_t cmd_csum_show = { }, }; +/* Enable/disable tunnel parsing */ +struct cmd_csum_tunnel_result { + cmdline_fixed_string_t csum; + cmdline_fixed_string_t parse; + cmdline_fixed_string_t onoff; + uint8_t port_id; +}; + +static void +cmd_csum_tunnel_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_csum_tunnel_result *res = parsed_result; + + if (port_id_is_invalid(res->port_id)) { + printf("invalid port %d\n", res->port_id); + return; + } + + if (!strcmp(res->onoff, "on")) + ports[res->port_id].tx_ol_flags |= + TESTPMD_TX_OFFLOAD_PARSE_TUNNEL; + else + ports[res->port_id].tx_ol_flags &= + (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL); + + csum_show(res->port_id); +} + +cmdline_parse_token_string_t cmd_csum_tunnel_csum = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + csum, "csum"); +cmdline_parse_token_string_t cmd_csum_tunnel_parse = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + parse, "parse_tunnel"); +cmdline_parse_token_string_t cmd_csum_tunnel_onoff = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + onoff, "on#off"); +cmdline_parse_token_num_t cmd_csum_tunnel_portid = + TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, + port_id, UINT8); + +cmdline_parse_inst_t cmd_csum_tunnel = { + .f = cmd_csum_tunnel_parsed, + .data = NULL, + .help_str = "enable/disable parsing of tunnels for csum engine: " + "csum parse_tunnel on|off <port>", + .tokens = { + (void *)&cmd_csum_tunnel_csum, + (void *)&cmd_csum_tunnel_parse, + (void *)&cmd_csum_tunnel_onoff, + (void *)&cmd_csum_tunnel_portid, + NULL, + }, +}; + /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */ struct cmd_tso_set_result { cmdline_fixed_string_t tso; @@ -8731,6 +8794,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, (cmdline_parse_inst_t *)&cmd_csum_set, (cmdline_parse_inst_t *)&cmd_csum_show, + (cmdline_parse_inst_t *)&cmd_csum_tunnel, (cmdline_parse_inst_t *)&cmd_tso_set, (cmdline_parse_inst_t *)&cmd_tso_show, (cmdline_parse_inst_t *)&cmd_link_flow_control_set, diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index ca5ca39..858eb47 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -373,7 +373,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) l3_hdr = (char *)eth_hdr + l2_len; /* check if it's a supported tunnel (only vxlan for now) */ - if (l4_proto == IPPROTO_UDP) { + if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && + l4_proto == IPPROTO_UDP) { udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len); /* check udp destination port, 4789 is the default diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 8f5e6c7..36277de 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -127,8 +127,11 @@ struct fwd_stream { #define TESTPMD_TX_OFFLOAD_SCTP_CKSUM 0x0008 /** Offload VxLAN checksum in csum forward engine */ #define TESTPMD_TX_OFFLOAD_VXLAN_CKSUM 0x0010 +/** Parse tunnel in csum forward engine. If set, dissect tunnel headers + * of rx packets. If not set, treat inner headers as payload. */ +#define TESTPMD_TX_OFFLOAD_PARSE_TUNNEL 0x0020 /** Insert VLAN header in forward engine */ -#define TESTPMD_TX_OFFLOAD_INSERT_VLAN 0x0020 +#define TESTPMD_TX_OFFLOAD_INSERT_VLAN 0x0040 /** * The data structure associated with each port. -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 11/16] testpmd: rename vxlan in outer_ip in csum commands 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (9 preceding siblings ...) 2015-01-21 23:36 ` [dpdk-dev] [RFC 10/16] testpmd: add csum parse_tunnel command Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-23 11:21 ` Liu, Jijiang 2015-01-21 23:36 ` [dpdk-dev] [RFC 12/16] testpmd: introduce parse_ipv* in csum fwd engine Olivier Matz ` (8 subsequent siblings) 19 siblings, 1 reply; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev The tx_checksum command concerns outer IP checksum, not VxLAN checksum. Actually there is no checkum in VxLAN header, there is one checksum in outer IP header, and one checksum in outer UDP header. This option only controls the outer IP checksum. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 16 ++++++++-------- app/test-pmd/csumonly.c | 25 ++++++++++++++----------- app/test-pmd/testpmd.h | 4 ++-- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 1d294bc..451c728 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -316,12 +316,12 @@ static void cmd_help_long_parsed(void *parsed_result, " Disable hardware insertion of a VLAN header in" " packets sent on a port.\n\n" - "csum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n" + "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n" " Select hardware or software calculation of the" " checksum with when transmitting a packet using the" " csum forward engine.\n" " ip|udp|tcp|sctp always concern the inner layer.\n" - " vxlan concerns the outer IP and UDP layer (in" + " outer-ip concerns the outer IP layer (in" " case the packet is recognized as a vxlan packet by" " the forward engine)\n" " Please check the NIC datasheet for HW limits.\n\n" @@ -2887,8 +2887,8 @@ csum_show(int port_id) (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); printf("SCTP checksum offload is %s\n", (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); - printf("VxLAN checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw"); + printf("Outer-Ip checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw"); /* display warnings if configuration is not supported by the NIC */ rte_eth_dev_info_get(port_id, &dev_info); @@ -2942,8 +2942,8 @@ cmd_csum_parsed(void *parsed_result, mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM; } else if (!strcmp(res->proto, "sctp")) { mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM; - } else if (!strcmp(res->proto, "vxlan")) { - mask = TESTPMD_TX_OFFLOAD_VXLAN_CKSUM; + } else if (!strcmp(res->proto, "outer-ip")) { + mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM; } if (hw) @@ -2962,7 +2962,7 @@ cmdline_parse_token_string_t cmd_csum_mode = mode, "set"); cmdline_parse_token_string_t cmd_csum_proto = TOKEN_STRING_INITIALIZER(struct cmd_csum_result, - proto, "ip#tcp#udp#sctp#vxlan"); + proto, "ip#tcp#udp#sctp#outer-ip"); cmdline_parse_token_string_t cmd_csum_hwsw = TOKEN_STRING_INITIALIZER(struct cmd_csum_result, hwsw, "hw#sw"); @@ -2974,7 +2974,7 @@ cmdline_parse_inst_t cmd_csum_set = { .f = cmd_csum_parsed, .data = NULL, .help_str = "enable/disable hardware calculation of L3/L4 checksum when " - "using csum forward engine: csum set ip|tcp|udp|sctp|vxlan hw|sw <port>", + "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>", .tokens = { (void *)&cmd_csum_csum, (void *)&cmd_csum_mode, diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 858eb47..3921643 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -259,13 +259,16 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_OUTER_IPV4; - if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ol_flags |= PKT_TX_OUTER_IP_CKSUM; else ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); - } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) + } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ol_flags |= PKT_TX_OUTER_IPV6; + /* outer UDP checksum is always done in software as we have no + * hardware supporting it today, and no API for it. */ + udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len); /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { @@ -300,8 +303,8 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, * The testpmd command line for this forward engine sets the flags * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control * wether a checksum must be calculated in software or in hardware. The - * IP, UDP, TCP and SCTP flags always concern the inner layer. The - * VxLAN flag concerns the outer IP (if packet is recognized as a vxlan packet). + * IP, UDP, TCP and SCTP flags always concern the inner layer. The + * OUTER_IP is only useful for tunnel packets. */ static void pkt_burst_checksum_forward(struct fwd_stream *fs) @@ -432,18 +435,18 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* step 4: fill the mbuf meta data (flags and header lengths) */ if (tunnel == 1) { - if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) { + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { m->outer_l2_len = outer_l2_len; m->outer_l3_len = outer_l3_len; m->l2_len = l4_tun_len + l2_len; m->l3_len = l3_len; } else { - /* if we don't do vxlan cksum in hw, - outer checksum will be wrong because - we changed the ip, but it shows that - we can process the inner header cksum - in the nic */ + /* if there is a outer UDP cksum + processed in sw and the inner in hw, + the outer checksum will be wrong as + the payload will be modified by the + hardware */ m->l2_len = outer_l2_len + outer_l3_len + sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr) + l2_len; @@ -502,7 +505,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) "m->l4_len=%d\n", m->l2_len, m->l3_len, m->l4_len); if ((tunnel == 1) && - (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)) + (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM)) printf("tx: m->outer_l2_len=%d m->outer_l3_len=%d\n", m->outer_l2_len, m->outer_l3_len); if (tso_segsz != 0) diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 36277de..ecb7d38 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -125,8 +125,8 @@ struct fwd_stream { #define TESTPMD_TX_OFFLOAD_TCP_CKSUM 0x0004 /** Offload SCTP checksum in csum forward engine */ #define TESTPMD_TX_OFFLOAD_SCTP_CKSUM 0x0008 -/** Offload VxLAN checksum in csum forward engine */ -#define TESTPMD_TX_OFFLOAD_VXLAN_CKSUM 0x0010 +/** Offload outer IP checksum in csum forward engine for recognized tunnels */ +#define TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM 0x0010 /** Parse tunnel in csum forward engine. If set, dissect tunnel headers * of rx packets. If not set, treat inner headers as payload. */ #define TESTPMD_TX_OFFLOAD_PARSE_TUNNEL 0x0020 -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [RFC 11/16] testpmd: rename vxlan in outer_ip in csum commands 2015-01-21 23:36 ` [dpdk-dev] [RFC 11/16] testpmd: rename vxlan in outer_ip in csum commands Olivier Matz @ 2015-01-23 11:21 ` Liu, Jijiang 2015-01-23 17:49 ` Olivier MATZ 0 siblings, 1 reply; 109+ messages in thread From: Liu, Jijiang @ 2015-01-23 11:21 UTC (permalink / raw) To: Olivier Matz; +Cc: dev Hi, > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Thursday, January 22, 2015 7:37 AM > To: dev@dpdk.org > Cc: olivier.matz@6wind.com; Ananyev, Konstantin; Liu, Jijiang > Subject: [RFC 11/16] testpmd: rename vxlan in outer_ip in csum commands > > The tx_checksum command concerns outer IP checksum, not VxLAN checksum. > Actually there is no checkum in VxLAN header, there is one checksum in outer IP > header, and one checksum in outer UDP header. This option only controls the > outer IP checksum. > > Signed-off-by: Olivier Matz <olivier.matz@6wind.com> > --- > app/test-pmd/cmdline.c | 16 ++++++++-------- app/test-pmd/csumonly.c | 25 > ++++++++++++++----------- app/test-pmd/testpmd.h | 4 ++-- > 3 files changed, 24 insertions(+), 21 deletions(-) > > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index > 1d294bc..451c728 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -316,12 +316,12 @@ static void cmd_help_long_parsed(void > *parsed_result, > " Disable hardware insertion of a VLAN header in" > " packets sent on a port.\n\n" > > - "csum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n" > + "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) > (port_id)\n" > " Select hardware or software calculation of the" > " checksum with when transmitting a packet using the" > " csum forward engine.\n" > " ip|udp|tcp|sctp always concern the inner layer.\n" > - " vxlan concerns the outer IP and UDP layer (in" > + " outer-ip concerns the outer IP layer (in" > " case the packet is recognized as a vxlan packet by" > " the forward engine)\n" > " Please check the NIC datasheet for HW limits.\n\n" > @@ -2887,8 +2887,8 @@ csum_show(int port_id) > (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); > printf("SCTP checksum offload is %s\n", > (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : > "sw"); > - printf("VxLAN checksum offload is %s\n", > - (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : > "sw"); > + printf("Outer-Ip checksum offload is %s\n", > + (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : > "sw"); > > /* display warnings if configuration is not supported by the NIC */ > rte_eth_dev_info_get(port_id, &dev_info); @@ -2942,8 +2942,8 @@ > cmd_csum_parsed(void *parsed_result, > mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM; > } else if (!strcmp(res->proto, "sctp")) { > mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM; > - } else if (!strcmp(res->proto, "vxlan")) { > - mask = TESTPMD_TX_OFFLOAD_VXLAN_CKSUM; > + } else if (!strcmp(res->proto, "outer-ip")) { > + mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM; > } > > if (hw) > @@ -2962,7 +2962,7 @@ cmdline_parse_token_string_t cmd_csum_mode = > mode, "set"); > cmdline_parse_token_string_t cmd_csum_proto = > TOKEN_STRING_INITIALIZER(struct cmd_csum_result, > - proto, "ip#tcp#udp#sctp#vxlan"); > + proto, "ip#tcp#udp#sctp#outer-ip"); > cmdline_parse_token_string_t cmd_csum_hwsw = > TOKEN_STRING_INITIALIZER(struct cmd_csum_result, > hwsw, "hw#sw"); > @@ -2974,7 +2974,7 @@ cmdline_parse_inst_t cmd_csum_set = { > .f = cmd_csum_parsed, > .data = NULL, > .help_str = "enable/disable hardware calculation of L3/L4 checksum > when " > - "using csum forward engine: csum set ip|tcp|udp|sctp|vxlan > hw|sw <port>", > + "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip > hw|sw > +<port>", > .tokens = { > (void *)&cmd_csum_csum, > (void *)&cmd_csum_mode, > diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index > 858eb47..3921643 100644 > --- a/app/test-pmd/csumonly.c > +++ b/app/test-pmd/csumonly.c > @@ -259,13 +259,16 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t > outer_ethertype, > ipv4_hdr->hdr_checksum = 0; > ol_flags |= PKT_TX_OUTER_IPV4; > > - if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) > + if (testpmd_ol_flags & > TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) > ol_flags |= PKT_TX_OUTER_IP_CKSUM; > else > ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); > - } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) > + } else if (testpmd_ol_flags & > TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) > ol_flags |= PKT_TX_OUTER_IPV6; > > + /* outer UDP checksum is always done in software as we have no > + * hardware supporting it today, and no API for it. */ > + > udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len); > /* do not recalculate udp cksum if it was 0 */ > if (udp_hdr->dgram_cksum != 0) { > @@ -300,8 +303,8 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t > outer_ethertype, > * The testpmd command line for this forward engine sets the flags > * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control > * wether a checksum must be calculated in software or in hardware. The > - * IP, UDP, TCP and SCTP flags always concern the inner layer. The > - * VxLAN flag concerns the outer IP (if packet is recognized as a vxlan packet). > + * IP, UDP, TCP and SCTP flags always concern the inner layer. The > + * OUTER_IP is only useful for tunnel packets. > */ > static void > pkt_burst_checksum_forward(struct fwd_stream *fs) @@ -432,18 +435,18 @@ > pkt_burst_checksum_forward(struct fwd_stream *fs) > /* step 4: fill the mbuf meta data (flags and header lengths) */ > > if (tunnel == 1) { > - if (testpmd_ol_flags & > TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) { > + if (testpmd_ol_flags & > TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { > m->outer_l2_len = outer_l2_len; > m->outer_l3_len = outer_l3_len; > m->l2_len = l4_tun_len + l2_len; > m->l3_len = l3_len; There should be m->l4_len = l4_len here. > } > else { > - /* if we don't do vxlan cksum in hw, > - outer checksum will be wrong because > - we changed the ip, but it shows that > - we can process the inner header cksum > - in the nic */ > + /* if there is a outer UDP cksum > + processed in sw and the inner in hw, > + the outer checksum will be wrong as > + the payload will be modified by the > + hardware */ > m->l2_len = outer_l2_len + outer_l3_len + > sizeof(struct udp_hdr) + > sizeof(struct vxlan_hdr) + l2_len; @@ - > 502,7 +505,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > "m->l4_len=%d\n", > m->l2_len, m->l3_len, m->l4_len); > if ((tunnel == 1) && > - (testpmd_ol_flags & > TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)) > + (testpmd_ol_flags & > TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM)) > printf("tx: m->outer_l2_len=%d m- > >outer_l3_len=%d\n", > m->outer_l2_len, m->outer_l3_len); > if (tso_segsz != 0) > diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index > 36277de..ecb7d38 100644 > --- a/app/test-pmd/testpmd.h > +++ b/app/test-pmd/testpmd.h > @@ -125,8 +125,8 @@ struct fwd_stream { > #define TESTPMD_TX_OFFLOAD_TCP_CKSUM 0x0004 > /** Offload SCTP checksum in csum forward engine */ > #define TESTPMD_TX_OFFLOAD_SCTP_CKSUM 0x0008 > -/** Offload VxLAN checksum in csum forward engine */ > -#define TESTPMD_TX_OFFLOAD_VXLAN_CKSUM 0x0010 > +/** Offload outer IP checksum in csum forward engine for recognized tunnels > */ > +#define TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM 0x0010 > /** Parse tunnel in csum forward engine. If set, dissect tunnel headers > * of rx packets. If not set, treat inner headers as payload. */ > #define TESTPMD_TX_OFFLOAD_PARSE_TUNNEL 0x0020 > -- > 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [RFC 11/16] testpmd: rename vxlan in outer_ip in csum commands 2015-01-23 11:21 ` Liu, Jijiang @ 2015-01-23 17:49 ` Olivier MATZ 0 siblings, 0 replies; 109+ messages in thread From: Olivier MATZ @ 2015-01-23 17:49 UTC (permalink / raw) To: Liu, Jijiang; +Cc: dev Hi Jijiang, On 01/23/2015 12:21 PM, Liu, Jijiang wrote: >> static void >> pkt_burst_checksum_forward(struct fwd_stream *fs) @@ -432,18 +435,18 @@ >> pkt_burst_checksum_forward(struct fwd_stream *fs) >> /* step 4: fill the mbuf meta data (flags and header lengths) */ >> >> if (tunnel == 1) { >> - if (testpmd_ol_flags & >> TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) { >> + if (testpmd_ol_flags & >> TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { >> m->outer_l2_len = outer_l2_len; >> m->outer_l3_len = outer_l3_len; >> m->l2_len = l4_tun_len + l2_len; >> m->l3_len = l3_len; > > There should be m->l4_len = l4_len here. Right, thank you for reporting it. I'll fix that (but not in this patch which is just a renaming of another part of the code). Regards, Olivier ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 12/16] testpmd: introduce parse_ipv* in csum fwd engine 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (10 preceding siblings ...) 2015-01-21 23:36 ` [dpdk-dev] [RFC 11/16] testpmd: rename vxlan in outer_ip in csum commands Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 13/16] testpmd: use a structure to store offload info " Olivier Matz ` (7 subsequent siblings) 19 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev These functions may be used to parse encapsulated layers when we will support IP over GRE tunnels. No functional change. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 51 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 3921643..b023f12 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -104,6 +104,42 @@ get_udptcp_checksum(void *l3_hdr, void *l4_hdr, uint16_t ethertype) return rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr); } +/* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */ +static void +parse_ipv4(struct ipv4_hdr *ipv4_hdr, uint16_t *l3_len, uint8_t *l4_proto, + uint16_t *l4_len) +{ + struct tcp_hdr *tcp_hdr; + + *l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; + *l4_proto = ipv4_hdr->next_proto_id; + + /* only fill l4_len for TCP, it's useful for TSO */ + if (*l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv4_hdr + *l3_len); + *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + } else + *l4_len = 0; +} + +/* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */ +static void +parse_ipv6(struct ipv6_hdr *ipv6_hdr, uint16_t *l3_len, uint8_t *l4_proto, + uint16_t *l4_len) +{ + struct tcp_hdr *tcp_hdr; + + *l3_len = sizeof(struct ipv6_hdr); + *l4_proto = ipv6_hdr->proto; + + /* only fill l4_len for TCP, it's useful for TSO */ + if (*l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv6_hdr + *l3_len); + *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + } else + *l4_len = 0; +} + /* * Parse an ethernet header to fill the ethertype, l2_len, l3_len and * ipproto. This function is able to recognize IPv4/IPv6 with one optional vlan @@ -115,7 +151,6 @@ parse_ethernet(struct ether_hdr *eth_hdr, uint16_t *ethertype, uint16_t *l2_len, { struct ipv4_hdr *ipv4_hdr; struct ipv6_hdr *ipv6_hdr; - struct tcp_hdr *tcp_hdr; *l2_len = sizeof(struct ether_hdr); *ethertype = eth_hdr->ether_type; @@ -130,26 +165,18 @@ parse_ethernet(struct ether_hdr *eth_hdr, uint16_t *ethertype, uint16_t *l2_len, switch (*ethertype) { case _htons(ETHER_TYPE_IPv4): ipv4_hdr = (struct ipv4_hdr *) ((char *)eth_hdr + *l2_len); - *l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; - *l4_proto = ipv4_hdr->next_proto_id; + parse_ipv4(ipv4_hdr, l3_len, l4_proto, l4_len); break; case _htons(ETHER_TYPE_IPv6): ipv6_hdr = (struct ipv6_hdr *) ((char *)eth_hdr + *l2_len); - *l3_len = sizeof(struct ipv6_hdr); - *l4_proto = ipv6_hdr->proto; + parse_ipv6(ipv6_hdr, l3_len, l4_proto, l4_len); break; default: + *l4_len = 0; *l3_len = 0; *l4_proto = 0; break; } - - if (*l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)eth_hdr + - *l2_len + *l3_len); - *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; - } else - *l4_len = 0; } /* modify the IPv4 or IPv4 source address of a packet */ -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 13/16] testpmd: use a structure to store offload info in csum fwd engine 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (11 preceding siblings ...) 2015-01-21 23:36 ` [dpdk-dev] [RFC 12/16] testpmd: introduce parse_ipv* in csum fwd engine Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 14/16] testpmd: introduce parse_vxlan " Olivier Matz ` (6 subsequent siblings) 19 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev To simplify the API of parse_* functions, store all the offload information for the current packet in a structure. No functional change. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 222 +++++++++++++++++++++++++----------------------- 1 file changed, 115 insertions(+), 107 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index b023f12..0b89d89 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -86,6 +86,21 @@ #define _htons(x) (x) #endif +/* structure that caches offload info for the current packet */ +struct testpmd_offload_info { + uint16_t ethertype; + uint16_t l2_len; + uint16_t l3_len; + uint16_t l4_len; + uint8_t l4_proto; + uint8_t l4_tun_len; + uint8_t is_tunnel; + uint16_t outer_ethertype; + uint16_t outer_l2_len; + uint16_t outer_l3_len; + uint16_t tso_segsz; +}; + static uint16_t get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags) { @@ -106,38 +121,36 @@ get_udptcp_checksum(void *l3_hdr, void *l4_hdr, uint16_t ethertype) /* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */ static void -parse_ipv4(struct ipv4_hdr *ipv4_hdr, uint16_t *l3_len, uint8_t *l4_proto, - uint16_t *l4_len) +parse_ipv4(struct ipv4_hdr *ipv4_hdr, struct testpmd_offload_info *info) { struct tcp_hdr *tcp_hdr; - *l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; - *l4_proto = ipv4_hdr->next_proto_id; + info->l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; + info->l4_proto = ipv4_hdr->next_proto_id; /* only fill l4_len for TCP, it's useful for TSO */ - if (*l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)ipv4_hdr + *l3_len); - *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + if (info->l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv4_hdr + info->l3_len); + info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2; } else - *l4_len = 0; + info->l4_len = 0; } /* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */ static void -parse_ipv6(struct ipv6_hdr *ipv6_hdr, uint16_t *l3_len, uint8_t *l4_proto, - uint16_t *l4_len) +parse_ipv6(struct ipv6_hdr *ipv6_hdr, struct testpmd_offload_info *info) { struct tcp_hdr *tcp_hdr; - *l3_len = sizeof(struct ipv6_hdr); - *l4_proto = ipv6_hdr->proto; + info->l3_len = sizeof(struct ipv6_hdr); + info->l4_proto = ipv6_hdr->proto; /* only fill l4_len for TCP, it's useful for TSO */ - if (*l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)ipv6_hdr + *l3_len); - *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + if (info->l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv6_hdr + info->l3_len); + info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2; } else - *l4_len = 0; + info->l4_len = 0; } /* @@ -146,35 +159,34 @@ parse_ipv6(struct ipv6_hdr *ipv6_hdr, uint16_t *l3_len, uint8_t *l4_proto, * header. The l4_len argument is only set in case of TCP (useful for TSO). */ static void -parse_ethernet(struct ether_hdr *eth_hdr, uint16_t *ethertype, uint16_t *l2_len, - uint16_t *l3_len, uint8_t *l4_proto, uint16_t *l4_len) +parse_ethernet(struct ether_hdr *eth_hdr, struct testpmd_offload_info *info) { struct ipv4_hdr *ipv4_hdr; struct ipv6_hdr *ipv6_hdr; - *l2_len = sizeof(struct ether_hdr); - *ethertype = eth_hdr->ether_type; + info->l2_len = sizeof(struct ether_hdr); + info->ethertype = eth_hdr->ether_type; - if (*ethertype == _htons(ETHER_TYPE_VLAN)) { + if (info->ethertype == _htons(ETHER_TYPE_VLAN)) { struct vlan_hdr *vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1); - *l2_len += sizeof(struct vlan_hdr); - *ethertype = vlan_hdr->eth_proto; + info->l2_len += sizeof(struct vlan_hdr); + info->ethertype = vlan_hdr->eth_proto; } - switch (*ethertype) { + switch (info->ethertype) { case _htons(ETHER_TYPE_IPv4): - ipv4_hdr = (struct ipv4_hdr *) ((char *)eth_hdr + *l2_len); - parse_ipv4(ipv4_hdr, l3_len, l4_proto, l4_len); + ipv4_hdr = (struct ipv4_hdr *) ((char *)eth_hdr + info->l2_len); + parse_ipv4(ipv4_hdr, info); break; case _htons(ETHER_TYPE_IPv6): - ipv6_hdr = (struct ipv6_hdr *) ((char *)eth_hdr + *l2_len); - parse_ipv6(ipv6_hdr, l3_len, l4_proto, l4_len); + ipv6_hdr = (struct ipv6_hdr *) ((char *)eth_hdr + info->l2_len); + parse_ipv6(ipv6_hdr, info); break; default: - *l4_len = 0; - *l3_len = 0; - *l4_proto = 0; + info->l4_len = 0; + info->l3_len = 0; + info->l4_proto = 0; break; } } @@ -197,8 +209,8 @@ change_ip_addresses(void *l3_hdr, uint16_t ethertype) /* if possible, calculate the checksum of a packet in hw or sw, * depending on the testpmd command line configuration */ static uint64_t -process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, - uint8_t l4_proto, uint16_t tso_segsz, uint16_t testpmd_ol_flags) +process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, + uint16_t testpmd_ol_flags) { struct ipv4_hdr *ipv4_hdr = l3_hdr; struct udp_hdr *udp_hdr; @@ -206,12 +218,12 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, struct sctp_hdr *sctp_hdr; uint64_t ol_flags = 0; - if (ethertype == _htons(ETHER_TYPE_IPv4)) { + if (info->ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr = l3_hdr; ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_IPV4; - if (tso_segsz != 0 && l4_proto == IPPROTO_TCP) { + if (info->tso_segsz != 0 && info->l4_proto == IPPROTO_TCP) { ol_flags |= PKT_TX_IP_CKSUM; } else { if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) @@ -220,41 +232,44 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); } - } else if (ethertype == _htons(ETHER_TYPE_IPv6)) + } else if (info->ethertype == _htons(ETHER_TYPE_IPv6)) ol_flags |= PKT_TX_IPV6; else return 0; /* packet type not supported, nothing to do */ - if (l4_proto == IPPROTO_UDP) { - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len); + if (info->l4_proto == IPPROTO_UDP) { + udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info->l3_len); /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { udp_hdr->dgram_cksum = 0; if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) { ol_flags |= PKT_TX_UDP_CKSUM; udp_hdr->dgram_cksum = get_psd_sum(l3_hdr, - ethertype, ol_flags); + info->ethertype, ol_flags); } else { udp_hdr->dgram_cksum = get_udptcp_checksum(l3_hdr, udp_hdr, - ethertype); + info->ethertype); } } - } else if (l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + l3_len); + } else if (info->l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + info->l3_len); tcp_hdr->cksum = 0; - if (tso_segsz != 0) { + if (info->tso_segsz != 0) { ol_flags |= PKT_TX_TCP_SEG; - tcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype, ol_flags); + tcp_hdr->cksum = get_psd_sum(l3_hdr, info->ethertype, + ol_flags); } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) { ol_flags |= PKT_TX_TCP_CKSUM; - tcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype, ol_flags); + tcp_hdr->cksum = get_psd_sum(l3_hdr, info->ethertype, + ol_flags); } else { tcp_hdr->cksum = - get_udptcp_checksum(l3_hdr, tcp_hdr, ethertype); + get_udptcp_checksum(l3_hdr, tcp_hdr, + info->ethertype); } - } else if (l4_proto == IPPROTO_SCTP) { - sctp_hdr = (struct sctp_hdr *)((char *)l3_hdr + l3_len); + } else if (info->l4_proto == IPPROTO_SCTP) { + sctp_hdr = (struct sctp_hdr *)((char *)l3_hdr + info->l3_len); sctp_hdr->cksum = 0; /* sctp payload must be a multiple of 4 to be * offloaded */ @@ -274,15 +289,15 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, * meaning IP + UDP). The caller already checked that it's a vxlan * packet */ static uint64_t -process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, - uint16_t outer_l3_len, uint16_t testpmd_ol_flags) +process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, +uint16_t testpmd_ol_flags) { struct ipv4_hdr *ipv4_hdr = outer_l3_hdr; struct ipv6_hdr *ipv6_hdr = outer_l3_hdr; struct udp_hdr *udp_hdr; uint64_t ol_flags = 0; - if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { + if (info->outer_ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_OUTER_IPV4; @@ -296,11 +311,11 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, /* outer UDP checksum is always done in software as we have no * hardware supporting it today, and no API for it. */ - udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len); + udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + info->outer_l3_len); /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { udp_hdr->dgram_cksum = 0; - if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) + if (info->outer_ethertype == _htons(ETHER_TYPE_IPv4)) udp_hdr->dgram_cksum = rte_ipv4_udptcp_cksum(ipv4_hdr, udp_hdr); else @@ -347,14 +362,9 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) uint16_t i; uint64_t ol_flags; uint16_t testpmd_ol_flags; - uint8_t l4_proto, l4_tun_len = 0; - uint16_t ethertype = 0, outer_ethertype = 0; - uint16_t l2_len = 0, l3_len = 0, l4_len = 0; - uint16_t outer_l2_len = 0, outer_l3_len = 0; - uint16_t tso_segsz; - int tunnel = 0; uint32_t rx_bad_ip_csum; uint32_t rx_bad_l4_csum; + struct testpmd_offload_info info; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES uint64_t start_tsc; @@ -381,13 +391,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) txp = &ports[fs->tx_port]; testpmd_ol_flags = txp->tx_ol_flags; - tso_segsz = txp->tso_segsz; + memset(&info, 0, sizeof(info)); + info.tso_segsz = txp->tso_segsz; for (i = 0; i < nb_rx; i++) { ol_flags = 0; - tunnel = 0; - l4_tun_len = 0; + info.is_tunnel = 0; m = pkts_burst[i]; /* Update the L3/L4 checksum error packet statistics */ @@ -398,49 +408,47 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) * and inner headers */ eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); - parse_ethernet(eth_hdr, ðertype, &l2_len, &l3_len, - &l4_proto, &l4_len); - l3_hdr = (char *)eth_hdr + l2_len; + parse_ethernet(eth_hdr, &info); + l3_hdr = (char *)eth_hdr + info.l2_len; /* check if it's a supported tunnel (only vxlan for now) */ if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && - l4_proto == IPPROTO_UDP) { - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len); + info.l4_proto == IPPROTO_UDP) { + udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info.l3_len); /* check udp destination port, 4789 is the default * vxlan port (rfc7348) */ if (udp_hdr->dst_port == _htons(4789)) { - l4_tun_len = ETHER_VXLAN_HLEN; - tunnel = 1; + info.l4_tun_len = ETHER_VXLAN_HLEN; + info.is_tunnel = 1; /* currently, this flag is set by i40e only if the * packet is vxlan */ } else if (m->ol_flags & (PKT_RX_TUNNEL_IPV4_HDR | PKT_RX_TUNNEL_IPV6_HDR)) - tunnel = 1; + info.is_tunnel = 1; - if (tunnel == 1) { - outer_ethertype = ethertype; - outer_l2_len = l2_len; - outer_l3_len = l3_len; + if (info.is_tunnel == 1) { + info.outer_ethertype = info.ethertype; + info.outer_l2_len = info.l2_len; + info.outer_l3_len = info.l3_len; outer_l3_hdr = l3_hdr; eth_hdr = (struct ether_hdr *)((char *)udp_hdr + sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr)); - parse_ethernet(eth_hdr, ðertype, &l2_len, - &l3_len, &l4_proto, &l4_len); - l3_hdr = (char *)eth_hdr + l2_len; + parse_ethernet(eth_hdr, &info); + l3_hdr = (char *)eth_hdr + info.l2_len; } } /* step 2: change all source IPs (v4 or v6) so we need * to recompute the chksums even if they were correct */ - change_ip_addresses(l3_hdr, ethertype); - if (tunnel == 1) - change_ip_addresses(outer_l3_hdr, outer_ethertype); + change_ip_addresses(l3_hdr, info.ethertype); + if (info.is_tunnel == 1) + change_ip_addresses(outer_l3_hdr, info.outer_ethertype); /* step 3: depending on user command line configuration, * recompute checksum either in software or flag the @@ -448,25 +456,24 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) * is configured, prepare the mbuf for TCP segmentation. */ /* process checksums of inner headers first */ - ol_flags |= process_inner_cksums(l3_hdr, ethertype, - l3_len, l4_proto, tso_segsz, testpmd_ol_flags); + ol_flags |= process_inner_cksums(l3_hdr, &info, testpmd_ol_flags); /* Then process outer headers if any. Note that the software * checksum will be wrong if one of the inner checksums is * processed in hardware. */ - if (tunnel == 1) { - ol_flags |= process_outer_cksums(outer_l3_hdr, - outer_ethertype, outer_l3_len, testpmd_ol_flags); + if (info.is_tunnel == 1) { + ol_flags |= process_outer_cksums(outer_l3_hdr, &info, + testpmd_ol_flags); } /* step 4: fill the mbuf meta data (flags and header lengths) */ - if (tunnel == 1) { + if (info.is_tunnel == 1) { if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { - m->outer_l2_len = outer_l2_len; - m->outer_l3_len = outer_l3_len; - m->l2_len = l4_tun_len + l2_len; - m->l3_len = l3_len; + m->outer_l2_len = info.outer_l2_len; + m->outer_l3_len = info.outer_l3_len; + m->l2_len = info.l4_tun_len + info.l2_len; + m->l3_len = info.l3_len; } else { /* if there is a outer UDP cksum @@ -474,21 +481,22 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) the outer checksum will be wrong as the payload will be modified by the hardware */ - m->l2_len = outer_l2_len + outer_l3_len + + m->l2_len = info.outer_l2_len + + info.outer_l3_len + sizeof(struct udp_hdr) + - sizeof(struct vxlan_hdr) + l2_len; - m->l3_len = l3_len; - m->l4_len = l4_len; + sizeof(struct vxlan_hdr) + info.l2_len; + m->l3_len = info.l3_len; + m->l4_len = info.l4_len; } } else { /* this is only useful if an offload flag is * set, but it does not hurt to fill it in any * case */ - m->l2_len = l2_len; - m->l3_len = l3_len; - m->l4_len = l4_len; + m->l2_len = info.l2_len; + m->l3_len = info.l3_len; + m->l4_len = info.l4_len; } - m->tso_segsz = tso_segsz; + m->tso_segsz = info.tso_segsz; m->ol_flags = ol_flags; /* if verbose mode is enabled, dump debug info */ @@ -515,27 +523,27 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* dump rx parsed packet info */ printf("rx: l2_len=%d ethertype=%x l3_len=%d " "l4_proto=%d l4_len=%d\n", - l2_len, rte_be_to_cpu_16(ethertype), - l3_len, l4_proto, l4_len); - if (tunnel == 1) + info.l2_len, rte_be_to_cpu_16(info.ethertype), + info.l3_len, info.l4_proto, info.l4_len); + if (info.is_tunnel == 1) printf("rx: outer_l2_len=%d outer_ethertype=%x " - "outer_l3_len=%d\n", outer_l2_len, - rte_be_to_cpu_16(outer_ethertype), - outer_l3_len); + "outer_l3_len=%d\n", info.outer_l2_len, + rte_be_to_cpu_16(info.outer_ethertype), + info.outer_l3_len); /* dump tx packet info */ if ((testpmd_ol_flags & (TESTPMD_TX_OFFLOAD_IP_CKSUM | TESTPMD_TX_OFFLOAD_UDP_CKSUM | TESTPMD_TX_OFFLOAD_TCP_CKSUM | TESTPMD_TX_OFFLOAD_SCTP_CKSUM)) || - tso_segsz != 0) + info.tso_segsz != 0) printf("tx: m->l2_len=%d m->l3_len=%d " "m->l4_len=%d\n", m->l2_len, m->l3_len, m->l4_len); - if ((tunnel == 1) && + if ((info.is_tunnel == 1) && (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM)) printf("tx: m->outer_l2_len=%d m->outer_l3_len=%d\n", m->outer_l2_len, m->outer_l3_len); - if (tso_segsz != 0) + if (info.tso_segsz != 0) printf("tx: m->tso_segsz=%d\n", m->tso_segsz); printf("tx: flags="); for (j = 0; j < sizeof(tx_flags)/sizeof(*tx_flags); j++) { -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 14/16] testpmd: introduce parse_vxlan in csum fwd engine 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (12 preceding siblings ...) 2015-01-21 23:36 ` [dpdk-dev] [RFC 13/16] testpmd: use a structure to store offload info " Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 15/16] testpmd: support gre tunnels " Olivier Matz ` (5 subsequent siblings) 19 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev Move code parsing vxlan into a function. It will ease the support of GRE tunnels and IPIP tunnels in next commits. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 68 +++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 0b89d89..52af0e7 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -93,7 +93,6 @@ struct testpmd_offload_info { uint16_t l3_len; uint16_t l4_len; uint8_t l4_proto; - uint8_t l4_tun_len; uint8_t is_tunnel; uint16_t outer_ethertype; uint16_t outer_l2_len; @@ -191,6 +190,34 @@ parse_ethernet(struct ether_hdr *eth_hdr, struct testpmd_offload_info *info) } } +/* Parse a vxlan header */ +static void +parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, + uint64_t mbuf_olflags) +{ + struct ether_hdr *eth_hdr; + + /* check udp destination port, 4789 is the default vxlan port + * (rfc7348) or that the rx offload flag is set (i40e only + * currently) */ + if (udp_hdr->dst_port != _htons(4789) && + (mbuf_olflags & (PKT_RX_TUNNEL_IPV4_HDR | + PKT_RX_TUNNEL_IPV6_HDR)) != 0) + return; + + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + eth_hdr = (struct ether_hdr *)((char *)udp_hdr + + sizeof(struct udp_hdr) + + sizeof(struct vxlan_hdr)); + + parse_ethernet(eth_hdr, info); + info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */ +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -356,7 +383,6 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) struct rte_mbuf *m; struct ether_hdr *eth_hdr; void *l3_hdr = NULL, *outer_l3_hdr = NULL; /* can be IPv4 or IPv6 */ - struct udp_hdr *udp_hdr; uint16_t nb_rx; uint16_t nb_tx; uint16_t i; @@ -414,33 +440,15 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* check if it's a supported tunnel (only vxlan for now) */ if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && info.l4_proto == IPPROTO_UDP) { + struct udp_hdr *udp_hdr; udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info.l3_len); + parse_vxlan(udp_hdr, &info, m->ol_flags); + } - /* check udp destination port, 4789 is the default - * vxlan port (rfc7348) */ - if (udp_hdr->dst_port == _htons(4789)) { - info.l4_tun_len = ETHER_VXLAN_HLEN; - info.is_tunnel = 1; - - /* currently, this flag is set by i40e only if the - * packet is vxlan */ - } else if (m->ol_flags & (PKT_RX_TUNNEL_IPV4_HDR | - PKT_RX_TUNNEL_IPV6_HDR)) - info.is_tunnel = 1; - - if (info.is_tunnel == 1) { - info.outer_ethertype = info.ethertype; - info.outer_l2_len = info.l2_len; - info.outer_l3_len = info.l3_len; - outer_l3_hdr = l3_hdr; - - eth_hdr = (struct ether_hdr *)((char *)udp_hdr + - sizeof(struct udp_hdr) + - sizeof(struct vxlan_hdr)); - - parse_ethernet(eth_hdr, &info); - l3_hdr = (char *)eth_hdr + info.l2_len; - } + /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ + if (info.is_tunnel) { + outer_l3_hdr = l3_hdr; + l3_hdr = (char *)l3_hdr + info.outer_l3_len + info.l2_len; } /* step 2: change all source IPs (v4 or v6) so we need @@ -472,7 +480,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { m->outer_l2_len = info.outer_l2_len; m->outer_l3_len = info.outer_l3_len; - m->l2_len = info.l4_tun_len + info.l2_len; + m->l2_len = info.l2_len; m->l3_len = info.l3_len; } else { @@ -482,9 +490,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) the payload will be modified by the hardware */ m->l2_len = info.outer_l2_len + - info.outer_l3_len + - sizeof(struct udp_hdr) + - sizeof(struct vxlan_hdr) + info.l2_len; + info.outer_l3_len + info.l2_len; m->l3_len = info.l3_len; m->l4_len = info.l4_len; } -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 15/16] testpmd: support gre tunnels in csum fwd engine 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (13 preceding siblings ...) 2015-01-21 23:36 ` [dpdk-dev] [RFC 14/16] testpmd: introduce parse_vxlan " Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 16/16] testpmd: support ipip tunnel in csum forward engine Olivier Matz ` (4 subsequent siblings) 19 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev Add support for Ethernet over GRE and IP over GRE tunnels. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 6 ++-- app/test-pmd/csumonly.c | 87 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 84 insertions(+), 9 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 451c728..9304207 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -321,9 +321,9 @@ static void cmd_help_long_parsed(void *parsed_result, " checksum with when transmitting a packet using the" " csum forward engine.\n" " ip|udp|tcp|sctp always concern the inner layer.\n" - " outer-ip concerns the outer IP layer (in" - " case the packet is recognized as a vxlan packet by" - " the forward engine)\n" + " outer-ip concerns the outer IP layer in" + " case the packet is recognized as a tunnel packet by" + " the forward engine (vxlan and gre are supported)\n" " Please check the NIC datasheet for HW limits.\n\n" "csum parse-tunnel (on|off) (port_id)\n" diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 52af0e7..02c01f6 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -100,6 +100,12 @@ struct testpmd_offload_info { uint16_t tso_segsz; }; +/* simplified GRE header (flags must be 0) */ +struct simple_gre_hdr { + uint16_t flags; + uint16_t proto; +}; + static uint16_t get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags) { @@ -218,6 +224,60 @@ parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */ } +/* Parse a gre header */ +static void +parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) +{ + struct ether_hdr *eth_hdr; + struct ipv4_hdr *ipv4_hdr; + struct ipv6_hdr *ipv6_hdr; + + /* if flags != 0; it's not supported */ + if (gre_hdr->flags != 0) + return; + + if (gre_hdr->proto == _htons(ETHER_TYPE_IPv4)) { + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + ipv4_hdr = (struct ipv4_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + parse_ipv4(ipv4_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv4); + info->l2_len = 0; + + } else if (gre_hdr->proto == _htons(ETHER_TYPE_IPv6)) { + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + ipv6_hdr = (struct ipv6_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + info->ethertype = _htons(ETHER_TYPE_IPv6); + parse_ipv6(ipv6_hdr, info); + info->l2_len = 0; + + } else if (gre_hdr->proto == _htons(0x6558)) { /* ETH_P_TEB in linux */ + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + eth_hdr = (struct ether_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + parse_ethernet(eth_hdr, info); + } else + return; + + info->l2_len += sizeof(struct simple_gre_hdr); +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -368,6 +428,8 @@ uint16_t testpmd_ol_flags) * Ether / (vlan) / IP|IP6 / UDP|TCP|SCTP . * Ether / (vlan) / outer IP|IP6 / outer UDP / VxLAN / Ether / IP|IP6 / * UDP|TCP|SCTP + * Ether / (vlan) / outer IP|IP6 / GRE / Ether / IP|IP6 / UDP|TCP|SCTP + * Ether / (vlan) / outer IP|IP6 / GRE / IP|IP6 / UDP|TCP|SCTP * * The testpmd command line for this forward engine sets the flags * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control @@ -437,12 +499,25 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) parse_ethernet(eth_hdr, &info); l3_hdr = (char *)eth_hdr + info.l2_len; - /* check if it's a supported tunnel (only vxlan for now) */ - if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && - info.l4_proto == IPPROTO_UDP) { - struct udp_hdr *udp_hdr; - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info.l3_len); - parse_vxlan(udp_hdr, &info, m->ol_flags); + /* check if it's a supported tunnel */ + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) { + if (info.l4_proto == IPPROTO_UDP) { + struct udp_hdr *udp_hdr; + udp_hdr = (struct udp_hdr *)((char *)l3_hdr + + info.l3_len); + parse_vxlan(udp_hdr, &info, m->ol_flags); + } else if (info.l4_proto == IPPROTO_GRE) { + struct simple_gre_hdr *gre_hdr; + gre_hdr = (struct simple_gre_hdr *) + ((char *)l3_hdr + info.l3_len); + parse_gre(gre_hdr, &info); + } + } + info.l4_proto == IPPROTO_GRE) { + struct simple_gre_hdr *gre_hdr; + gre_hdr = (struct simple_gre_hdr *)((char *)l3_hdr + + info.l3_len); + parse_gre(gre_hdr, &info); } /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [RFC 16/16] testpmd: support ipip tunnel in csum forward engine 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (14 preceding siblings ...) 2015-01-21 23:36 ` [dpdk-dev] [RFC 15/16] testpmd: support gre tunnels " Olivier Matz @ 2015-01-21 23:36 ` Olivier Matz 2015-01-21 23:41 ` [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier MATZ ` (3 subsequent siblings) 19 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-21 23:36 UTC (permalink / raw) To: dev Add support for IP over IP tunnels. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 2 +- app/test-pmd/csumonly.c | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 9304207..b1832e3 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -323,7 +323,7 @@ static void cmd_help_long_parsed(void *parsed_result, " ip|udp|tcp|sctp always concern the inner layer.\n" " outer-ip concerns the outer IP layer in" " case the packet is recognized as a tunnel packet by" - " the forward engine (vxlan and gre are supported)\n" + " the forward engine (vxlan, gre and ipip are supported)\n" " Please check the NIC datasheet for HW limits.\n\n" "csum parse-tunnel (on|off) (port_id)\n" diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 02c01f6..407e3b3 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -278,6 +278,35 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) info->l2_len += sizeof(struct simple_gre_hdr); } + +/* Parse an encapsulated ip or ipv6 header */ +static void +parse_encap_ip(void *encap_ip, struct testpmd_offload_info *info) +{ + struct ipv4_hdr *ipv4_hdr = encap_ip; + struct ipv6_hdr *ipv6_hdr = encap_ip; + uint8_t ip_version; + + ip_version = (ipv4_hdr->version_ihl & 0xf0) >> 4; + + if (ip_version != 4 && ip_version != 6) + return; + + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + if (ip_version == 4) { + parse_ipv4(ipv4_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv4); + } else { + parse_ipv6(ipv6_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv6); + } + info->l2_len = 0; +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -430,6 +459,7 @@ uint16_t testpmd_ol_flags) * UDP|TCP|SCTP * Ether / (vlan) / outer IP|IP6 / GRE / Ether / IP|IP6 / UDP|TCP|SCTP * Ether / (vlan) / outer IP|IP6 / GRE / IP|IP6 / UDP|TCP|SCTP + * Ether / (vlan) / outer IP|IP6 / IP|IP6 / UDP|TCP|SCTP * * The testpmd command line for this forward engine sets the flags * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control @@ -511,14 +541,12 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) gre_hdr = (struct simple_gre_hdr *) ((char *)l3_hdr + info.l3_len); parse_gre(gre_hdr, &info); + } else if (info.l4_proto == IPPROTO_IPIP) { + void *encap_ip_hdr; + encap_ip_hdr = (char *)l3_hdr + info.l3_len; + parse_encap_ip(encap_ip_hdr, &info); } } - info.l4_proto == IPPROTO_GRE) { - struct simple_gre_hdr *gre_hdr; - gre_hdr = (struct simple_gre_hdr *)((char *)l3_hdr + - info.l3_len); - parse_gre(gre_hdr, &info); - } /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ if (info.is_tunnel) { -- 2.1.3 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [RFC 00/16] enhance checksum offload API 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (15 preceding siblings ...) 2015-01-21 23:36 ` [dpdk-dev] [RFC 16/16] testpmd: support ipip tunnel in csum forward engine Olivier Matz @ 2015-01-21 23:41 ` Olivier MATZ 2015-01-22 10:00 ` Thomas Monjalon 2015-01-22 1:01 ` Stephen Hemminger ` (2 subsequent siblings) 19 siblings, 1 reply; 109+ messages in thread From: Olivier MATZ @ 2015-01-21 23:41 UTC (permalink / raw) To: dev [-- Attachment #1: Type: text/plain, Size: 4712 bytes --] Test done on testpmd on x86_64-native-linuxapp-gcc platform: Tester (linux) <----> DUT (DPDK) ixgbe6 port0 (i40e or ixgbe) Run testpmd on DUT: cd dpdk.org/ make install T=x86_64-native-linuxapp-gcc cd x86_64-native-linuxapp-gcc/ modprobe uio insmod kmod/igb_uio.ko python ../tools/dpdk_nic_bind.py -b igb_uio 0000:02:00.0 echo 0 > /proc/sys/kernel/randomize_va_space echo 1000 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages echo 1000 > /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages mount -t hugetlbfs none /mnt/huge ./app/testpmd -c 0x55 -n 4 -m 800 -- -i --port-topology=chained --enable-rx-cksum Disable all offload feature on Tester, and start capture: ethtool -K ixgbe6 rx off tx off tso off gso off gro off lro off ip l set ixgbe6 up tcpdump -n -e -i ixgbe6 -s 0 -w /tmp/cap We use the attached scapy script (dpdk-cksum-test.py) for testing. In each attached capture file, odd packets are generated by scapy and even ones are generated by the dpdk (except for TSO where several tx packet corresponds to one rx packet). In some conditions, the checksum cannot be calculated, for instance when inner checksum is done in hw and outer checksum in sw, or if it is not supported by hardware. Notes: - case 6 is not present for ixgbe (inner + outer) - case 5 is not present for i40e (tso) - some strange behavior to be analyzed for first packets of tso on ixgbe - ipip tunnel is not working in case 6 of i40e ---------------------------------------------- case 1) calculate checksum of out_ip (was case A in [1]) mb->l2_len = len(out_eth) mb->l3_len = len(out_ip) mb->ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CSUM set out_ip checksum to 0 in the packet Testpmd commands: stop csum parse_tunnel off 0 csum set ip hw 0 csum set tcp sw 0 csum set udp sw 0 csum set sctp sw 0 tso set 0 0 set fwd csum set verbose 1 start ---------------------------------------------- case 2) calculate checksum of out_ip and out_udp mb->l2_len = len(out_eth) mb->l3_len = len(out_ip) mb->ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CSUM | PKT_TX_UDP_CKSUM set out_ip checksum to 0 in the packet set out_udp checksum to pseudo header using rte_ipv4_phdr_cksum() Testpmd commands: stop csum parse_tunnel off 0 csum set ip hw 0 csum set tcp hw 0 csum set udp hw 0 csum set sctp hw 0 tso set 0 0 set fwd csum set verbose 1 start ---------------------------------------------- case 3) calculate checksum of in_ip mb->l2_len = len(out_eth + out_ip + out_udp + vxlan + in_eth) mb->l3_len = len(in_ip) mb->ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CSUM set in_ip checksum to 0 in the packet Testpmd commands: stop csum parse_tunnel on 0 csum set ip hw 0 csum set tcp sw 0 csum set udp sw 0 csum set sctp sw 0 csum set outer-ip sw 0 tso set 0 0 set fwd csum set verbose 1 start ---------------------------------------------- case 4) calculate checksum of in_ip and in_tcp (was case B.2 in [1]) mb->l2_len = len(out_eth + out_ip + out_udp + vxlan + in_eth) mb->l3_len = len(in_ip) mb->ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CSUM | PKT_TX_TCP_CKSUM set in_ip checksum to 0 in the packet set in_tcp checksum to pseudo header using rte_ipv4_phdr_cksum() Testpmd commands: stop csum parse_tunnel on 0 csum set ip hw 0 csum set tcp hw 0 csum set udp hw 0 csum set sctp hw 0 csum set outer-ip sw 0 tso set 0 0 set fwd csum set verbose 1 start ---------------------------------------------- case 5) segment inner TCP mb->l2_len = len(out_eth + out_ip + out_udp + vxlan + in_eth) mb->l3_len = len(in_ip) mb->l4_len = len(in_tcp) mb->ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM | PKT_TX_TCP_SEG; set in_ip checksum to 0 in the packet set in_tcp checksum to pseudo header without including the IP payload length using rte_ipv4_phdr_cksum() Testpmd commands: stop csum parse_tunnel on 0 csum set ip hw 0 csum set tcp hw 0 csum set udp hw 0 csum set sctp hw 0 csum set outer-ip sw 0 tso set 500 0 set fwd csum set verbose 1 start ---------------------------------------------- case 6) calculate checksum of out_ip, in_ip, in_tcp (was case C in [1]) mb->outer_l2_len = len(out_eth) mb->outer_l3_len = len(out_ip) mb->l2_len = len(out_udp + vxlan + in_eth) mb->l3_len = len(in_ip) mb->ol_flags |= PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IP_CKSUM | \ PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM; set out_ip checksum to 0 in the packet set in_ip checksum to 0 in the packet set in_tcp checksum to pseudo header using rte_ipv4_phdr_cksum() Testpmd commands: stop csum parse_tunnel on 0 csum set ip hw 0 csum set tcp hw 0 csum set udp hw 0 csum set sctp hw 0 csum set outer-ip hw 0 tso set 0 0 set fwd csum set verbose 1 start [-- Attachment #2: i40e_case1.cap --] [-- Type: application/vnd.tcpdump.pcap, Size: 60080 bytes --] [-- Attachment #3: i40e_case2.cap --] [-- Type: application/vnd.tcpdump.pcap, Size: 60080 bytes --] [-- Attachment #4: i40e_case3.cap --] [-- Type: application/vnd.tcpdump.pcap, Size: 60080 bytes --] [-- Attachment #5: i40e_case4.cap --] [-- Type: application/vnd.tcpdump.pcap, Size: 60080 bytes --] [-- Attachment #6: i40e_case6.cap --] [-- Type: application/vnd.tcpdump.pcap, Size: 60080 bytes --] [-- Attachment #7: ixgbe_case1.cap --] [-- Type: application/vnd.tcpdump.pcap, Size: 60080 bytes --] [-- Attachment #8: ixgbe_case2.cap --] [-- Type: application/vnd.tcpdump.pcap, Size: 60080 bytes --] [-- Attachment #9: ixgbe_case3.cap --] [-- Type: application/vnd.tcpdump.pcap, Size: 60080 bytes --] [-- Attachment #10: ixgbe_case4.cap --] [-- Type: application/vnd.tcpdump.pcap, Size: 60080 bytes --] [-- Attachment #11: ixgbe_case5.cap --] [-- Type: application/vnd.tcpdump.pcap, Size: 63856 bytes --] ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [RFC 00/16] enhance checksum offload API 2015-01-21 23:41 ` [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier MATZ @ 2015-01-22 10:00 ` Thomas Monjalon 0 siblings, 0 replies; 109+ messages in thread From: Thomas Monjalon @ 2015-01-22 10:00 UTC (permalink / raw) To: dev [-- Attachment #1: Type: text/plain, Size: 154 bytes --] 2015-01-22 00:41, Olivier MATZ: > We use the attached scapy script (dpdk-cksum-test.py) for testing. Attaching the python script which was filtered out. [-- Attachment #2: dpdk-cksum-test.py --] [-- Type: text/x-python, Size: 2407 bytes --] class VXLAN(Packet): name = 'VXLAN' fields_desc = [ FlagsField('flags', default=1 << 3, size=8, names=['R', 'R', 'R', 'R', 'I', 'R', 'R', 'R']), XBitField('reserved1', default=0x000000, size=24), BitField('vni', None, size=24), XBitField('reserved2', default=0x00, size=8), ] overload_fields = { UDP: {"sport": 4789, "dport": 4789} } def mysummary(self): return self.sprintf("VXLAN (vni=%VXLAN.vni%)") bind_layers(UDP, VXLAN, dport=4789) bind_layers(VXLAN, Ether) macdst = "00:1B:21:8E:B2:30" # test with ixgbe #macdst = "68:05:CA:26:9B:10" # test with fortvile iface = "ixgbe6" count = 1 macsrc = get_if_hwaddr(iface) def send_test_packets(hdr, iface, count): p = hdr.copy() p /= IP(src=RandIP(), dst=RandIP()) p /= TCP(flags=0x10)/Raw(RandString(1400)) # valid packet q = p.copy() sendp(q, iface=iface, count=count) # bad outer IP checksum q = p.copy() q[IP].chksum=0x1234 sendp(q, iface=iface, count=count) if q.haslayer(UDP): # bad outer UDP checksum q = p.copy() q[UDP].chksum=0x1234 sendp(q, iface=iface, count=count) # disable outer UDP checksum q = p.copy() q[UDP].chksum=0 sendp(q, iface=iface, count=count) if q[IP].payload.haslayer(IP): # bad inner IP checksum q = p.copy() q[IP].payload[IP].chksum=0x1234 sendp(q, iface=iface, count=count) # bad inner TCP checksum q = p.copy() q[IP].payload[TCP].chksum=0x1234 sendp(q, iface=iface, count=count) def do_test(): # Ether packet p = Ether(dst=macdst, src=macsrc) send_test_packets(p, iface, count) # VxLAN packet p = Ether(dst=macdst, src=macsrc)/IP(src=RandIP(), dst=RandIP()) p /= UDP(sport=4789, dport=4789) p /= VXLAN(vni=1234)/Ether(dst=macdst, src=macsrc) send_test_packets(p, iface, count) # Ethernet over GRE p = Ether(dst=macdst, src=macsrc)/IP(src=RandIP(), dst=RandIP()) p /= GRE(proto=0x6558)/Ether(dst=macdst, src=macsrc) send_test_packets(p, iface, count) # IP over GRE p = Ether(dst=macdst, src=macsrc)/IP(src=RandIP(), dst=RandIP()) p /= GRE() send_test_packets(p, iface, count) # IP over IP p = Ether(dst=macdst, src=macsrc)/IP(src=RandIP(), dst=RandIP()) send_test_packets(p, iface, count) do_test() ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [RFC 00/16] enhance checksum offload API 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (16 preceding siblings ...) 2015-01-21 23:41 ` [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier MATZ @ 2015-01-22 1:01 ` Stephen Hemminger 2015-01-23 9:52 ` Olivier MATZ 2015-01-23 7:54 ` Liu, Jijiang 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz 19 siblings, 1 reply; 109+ messages in thread From: Stephen Hemminger @ 2015-01-22 1:01 UTC (permalink / raw) To: Olivier Matz; +Cc: dev On Thu, 22 Jan 2015 00:36:19 +0100 Olivier Matz <olivier.matz@6wind.com> wrote: > The goal of this series is to clarify and simplify the mbuf offload API. > Several issues are solved: > > - simplify the definitions of PKT_TX_IP_CKSUM and PKT_TX_IPV4, each > flag has now only one meaning. No impact on the code. > > - add a feature flag for OUTER_IP_CHECKSUM (from Jijiang's patches) > > - remove the PKT_TX_UDP_TUNNEL_PKT flag: it is useless from an API point > of view. It was added because i40e need this info for some reason. We > have 3 solutions: > > - remove the flag and adapt the driver to the API (the choice I made > for this series). > > - remove the flag and stop advertising OUTER_IP_CHECKSUM in i40e > > - keep this flag, penalizing performance of drivers that do not > require the flag. It would also mean that drivers won't support > outer IP checksum for all tunnel types, but only for the tunnel > types having a flag. > > - a side effect of this API clarification is that there is only one > way for doing one operation. If the hardware has several ways to > do the same operation, a choice has to be made in the driver. > > The patch adds new tunnel types to testpmd csum forward engine. > Note: the i40e patches should be carefully checked by i40e experts. > > [1] http://dpdk.org/ml/archives/dev/2015-January/011127.html If you are doing this could you invert the meaning of the checksum flags? Right now the flags are fine for Intel hardware but are useless for devices that have less checksum support. It would work better if instead of two states: * Checksum known bad => PKT_RX_L4_CKSUM_BAD == 1 * Checksum (maybe) good => PKT_RX_L4_CKSUM_BAD == 0 The bit was changed to only flag good checksum: * Checksum known good => PKT_RX_L4_CKSUM_GOOD == 1 * Checksum status unknown => PKT_RX_L4_CKSUM_GOOD == 0 That way code code fallback to software checksum if hardware was incapable of handling the packet. It does mean packets with bad checksums get checked twice, but thats ok. ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [RFC 00/16] enhance checksum offload API 2015-01-22 1:01 ` Stephen Hemminger @ 2015-01-23 9:52 ` Olivier MATZ 0 siblings, 0 replies; 109+ messages in thread From: Olivier MATZ @ 2015-01-23 9:52 UTC (permalink / raw) To: Stephen Hemminger; +Cc: dev Hi Stephen, On 01/22/2015 02:01 AM, Stephen Hemminger wrote: > On Thu, 22 Jan 2015 00:36:19 +0100 > Olivier Matz <olivier.matz@6wind.com> wrote: > >> The goal of this series is to clarify and simplify the mbuf offload API. >> Several issues are solved: > > If you are doing this could you invert the meaning of the checksum > flags? Right now the flags are fine for Intel hardware but are useless > for devices that have less checksum support. > > It would work better if instead of two states: > * Checksum known bad => PKT_RX_L4_CKSUM_BAD == 1 > * Checksum (maybe) good => PKT_RX_L4_CKSUM_BAD == 0 > The bit was changed to only flag good checksum: > * Checksum known good => PKT_RX_L4_CKSUM_GOOD == 1 > * Checksum status unknown => PKT_RX_L4_CKSUM_GOOD == 0 > > That way code code fallback to software checksum if hardware was incapable > of handling the packet. It does mean packets with bad checksums get checked > twice, but thats ok. I agree that current rx checksum flags in dpdk could be enhanced. Your proposition is indeed already much better that what we currently have. I'm ok to submit a patch for this before the 2.0 release. However, I think we could do even better with 2 flags. The first idea is to have one bit saying "the hw verified the checksum" and a second one saying "it is good or bad". The second idea is to use flags like PKT_RX_L4_TCP or PKT_RX_L4_UDP to replace the first bit of the first idea, like it's done for IPv4. Therefore, the value of the flag PKT_RX_L4_CKSUM_GOOD should only be checked if the L4 protocol is recognized. Another thing that could be also useful for virtual driver is a way to say: "the packet integrity is correct but the checksum field in the packet may be wrong". This can happen for instance in this case: - a guest transmits on a vdev without calculating the checksums (gaining cpu time) - the host receives it, it does not check the rx checksums (because it knows the packet integrity is correct, the packet comes from memory not from a network) - then if the host wants to forward it, it has to schedule a tx checksum on a real hw. Let me know if you have any comment. However, I think this will conflicts with the packet_type feature that is proposed by Helin: http://dpdk.org/ml/archives/dev/2015-January/011156.html Regards, Olivier ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [RFC 00/16] enhance checksum offload API 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (17 preceding siblings ...) 2015-01-22 1:01 ` Stephen Hemminger @ 2015-01-23 7:54 ` Liu, Jijiang 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz 19 siblings, 0 replies; 109+ messages in thread From: Liu, Jijiang @ 2015-01-23 7:54 UTC (permalink / raw) To: Olivier Matz, dev > > - remove the PKT_TX_UDP_TUNNEL_PKT flag: it is useless from an API point > of view. It was added because i40e need this info for some reason. We > have 3 solutions: > > - remove the flag and adapt the driver to the API (the choice I made > for this series). > I'm checking the L4TUN flag with relevant guys who is responsible for FVL HW. Please waiting... ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 00/20] enhance tx checksum offload API 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz ` (18 preceding siblings ...) 2015-01-23 7:54 ` Liu, Jijiang @ 2015-01-30 13:15 ` Olivier Matz 2015-01-30 13:15 ` [dpdk-dev] [PATCH 01/20] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz ` (20 more replies) 19 siblings, 21 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:15 UTC (permalink / raw) To: dev The goal of this series is to clarify and simplify the mbuf offload API. - simplify the definitions of PKT_TX_IP_CKSUM and PKT_TX_IPV4, each flag has now only one meaning. No impact on the code. - add a feature flag for OUTER_IP_CHECKSUM (from Jijiang's patches) - remove the PKT_TX_UDP_TUNNEL_PKT flag: it is useless from an API point of view. It was added because i40e need this info for some reason. We have 3 solutions: - remove the flag and adapt the driver to the API (the choice I made for this series). - remove the flag and stop advertising OUTER_IP_CHECKSUM in i40e - keep this flag, penalizing performance of drivers that do not require the flag. It would also mean that drivers won't support outer IP checksum for all tunnel types, but only for the tunnel types having a flag. - a side effect of this API clarification is that there is only one way for doing one operation. If the hardware has several ways to do the same operation, a choice has to be made in the driver. The series also provide some enhancements and fixes related to this API rework: - new tunnel types to testpmd csum forward engine. - fixes in i40e to adapt to new api and support more tunnel types. [1] http://dpdk.org/ml/archives/dev/2015-January/011127.html Jijiang Liu (2): ethdev: add outer IP offload capability flag i40e: advertise outer IPv4 checksum capability Olivier Matz (18): mbuf: remove PKT_TX_IPV4_CSUM mbuf: enhance the API documentation of offload flags i40e: call i40e_txd_enable_checksum only for offloaded packets i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag testpmd: replace tx_checksum command by csum testpmd: move csum_show in a function testpmd: add csum parse_tunnel command testpmd: rename vxlan in outer_ip in csum commands testpmd: introduce parse_ipv* in csum fwd engine testpmd: use a structure to store offload info in csum fwd engine testpmd: introduce parse_vxlan in csum fwd engine testpmd: support gre tunnels in csum fwd engine testpmd: support ipip tunnel in csum forward engine testpmd: add a warning if outer ip cksum requested but not supported testpmd: fix TSO when using outer checksum offloads i40e: fix offloading of outer checksum for ip in ip tunnels i40e: add debug logs for tx context descriptors app/test-pmd/cmdline.c | 234 ++++++++++++++------- app/test-pmd/csumonly.c | 417 +++++++++++++++++++++++++------------- app/test-pmd/testpmd.h | 9 +- lib/librte_ether/rte_ethdev.h | 1 + lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 49 +++-- lib/librte_pmd_i40e/i40e_ethdev.c | 3 +- lib/librte_pmd_i40e/i40e_rxtx.c | 55 +++-- 8 files changed, 519 insertions(+), 250 deletions(-) -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 01/20] mbuf: remove PKT_TX_IPV4_CSUM 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz @ 2015-01-30 13:15 ` Olivier Matz 2015-01-30 13:15 ` [dpdk-dev] [PATCH 02/20] mbuf: enhance the API documentation of offload flags Olivier Matz ` (19 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:15 UTC (permalink / raw) To: dev This alias is only used in one place of i40e driver. Remove it and only keep the legacy flag PKT_TX_IP_CSUM. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_mbuf/rte_mbuf.h | 1 - lib/librte_pmd_i40e/i40e_rxtx.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 16059c6..a554247 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -142,7 +142,6 @@ extern "C" { #define PKT_TX_L4_MASK (3ULL << 52) /**< Mask for L4 cksum offload request. */ #define PKT_TX_IP_CKSUM (1ULL << 54) /**< IP cksum of TX pkt. computed by NIC. */ -#define PKT_TX_IPV4_CSUM PKT_TX_IP_CKSUM /**< Alias of PKT_TX_IP_CKSUM. */ /** Packet is IPv4 without requiring IP checksum offload. */ #define PKT_TX_IPV4 (1ULL << 55) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 2beae3c..8e9df96 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -501,7 +501,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags, << I40E_TX_DESC_LENGTH_MACLEN_SHIFT; /* Enable L3 checksum offloads */ - if (ol_flags & PKT_TX_IPV4_CSUM) { + if (ol_flags & PKT_TX_IP_CKSUM) { *td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM; *td_offset |= (l3_len >> 2) << I40E_TX_DESC_LENGTH_IPLEN_SHIFT; } else if (ol_flags & PKT_TX_IPV4) { -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 02/20] mbuf: enhance the API documentation of offload flags 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz 2015-01-30 13:15 ` [dpdk-dev] [PATCH 01/20] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz @ 2015-01-30 13:15 ` Olivier Matz 2015-01-30 13:15 ` [dpdk-dev] [PATCH 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets Olivier Matz ` (18 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:15 UTC (permalink / raw) To: dev Based on http://dpdk.org/ml/archives/dev/2015-January/011127.html Also adapt the csum forward engine code to the API. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 6 +++--- lib/librte_mbuf/rte_mbuf.h | 43 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 41711fd..4b438d1 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -183,16 +183,15 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, ipv4_hdr = l3_hdr; ipv4_hdr->hdr_checksum = 0; + ol_flags |= PKT_TX_IPV4; if (tso_segsz != 0 && l4_proto == IPPROTO_TCP) { ol_flags |= PKT_TX_IP_CKSUM; } else { if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ol_flags |= PKT_TX_IP_CKSUM; - else { + else ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); - ol_flags |= PKT_TX_IPV4; - } } } else if (ethertype == _htons(ETHER_TYPE_IPv6)) ol_flags |= PKT_TX_IPV6; @@ -261,6 +260,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr->hdr_checksum = 0; + ol_flags |= PKT_TX_OUTER_IPV4; if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ol_flags |= PKT_TX_OUTER_IP_CKSUM; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index a554247..191a42c 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -141,24 +141,53 @@ extern "C" { #define PKT_TX_UDP_CKSUM (3ULL << 52) /**< UDP cksum of TX pkt. computed by NIC. */ #define PKT_TX_L4_MASK (3ULL << 52) /**< Mask for L4 cksum offload request. */ -#define PKT_TX_IP_CKSUM (1ULL << 54) /**< IP cksum of TX pkt. computed by NIC. */ +/** + * Offload the IP checksum in the hardware. The flag PKT_TX_IPV4 should + * also be set by the application, altough a PMD will only check + * PKT_TX_IP_CKSUM. + * - set the IP checksum field in the packet to 0 + * - fill the mbuf offload information: l2_len, l3_len + */ +#define PKT_TX_IP_CKSUM (1ULL << 54) -/** Packet is IPv4 without requiring IP checksum offload. */ +/** + * Packet is IPv4. This flag must be set when using any offload feature + * (TSO, L3 or L4 checksum) to tell the NIC that the packet is an IPv4 + * packet. + */ #define PKT_TX_IPV4 (1ULL << 55) -/** Tell the NIC it's an IPv6 packet.*/ +/** + * Packet is IPv6. This flag must be set when using an offload feature + * (TSO or L4 checksum) to tell the NIC that the packet is an IPv6 + * packet. + */ #define PKT_TX_IPV6 (1ULL << 56) #define PKT_TX_VLAN_PKT (1ULL << 57) /**< TX packet is a 802.1q VLAN packet. */ -/** Outer IP checksum of TX packet, computed by NIC for tunneling packet. - * The tunnel type must also be specified, ex: PKT_TX_UDP_TUNNEL_PKT. */ +/** + * Offload the IP checksum of an external header in the hardware. The + * flag PKT_TX_OUTER_IPV4 should also be set by the application, altough + * a PMD will only check PKT_TX_IP_CKSUM. The IP checksum field in the + * packet must be set to 0. + * - set the outer IP checksum field in the packet to 0 + * - fill the mbuf offload information: outer_l2_len, outer_l3_len + */ #define PKT_TX_OUTER_IP_CKSUM (1ULL << 58) -/** Packet is outer IPv4 without requiring IP checksum offload for tunneling packet. */ +/** + * Packet outer header is IPv4. This flag must be set when using any + * outer offload feature (L3 or L4 checksum) to tell the NIC that the + * packet is an IPv4 packet. + */ #define PKT_TX_OUTER_IPV4 (1ULL << 59) -/** Tell the NIC it's an outer IPv6 packet for tunneling packet */ +/** + * Packet outer header is IPv6. This flag must be set when using any + * outer offload feature (L4 checksum) to tell the NIC that the packet + * is an IPv6 packet. + */ #define PKT_TX_OUTER_IPV6 (1ULL << 60) /* Use final bit of flags to indicate a control mbuf */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz 2015-01-30 13:15 ` [dpdk-dev] [PATCH 01/20] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz 2015-01-30 13:15 ` [dpdk-dev] [PATCH 02/20] mbuf: enhance the API documentation of offload flags Olivier Matz @ 2015-01-30 13:15 ` Olivier Matz 2015-01-30 13:15 ` [dpdk-dev] [PATCH 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag Olivier Matz ` (17 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:15 UTC (permalink / raw) To: dev >From i40e datasheet: The IP header type and its offload. In case of tunneling, the IIPT relates to the inner IP header. See also EIPT field for the outer (External) IP header offload. 00 - non IP packet or packet type is not defined by software 01 - IPv6 packet 10 - IPv4 packet with no IP checksum offload 11 - IPv4 packet with IP checksum offload Therefore it is not needed to fill the IIPT field if no offload is requested (we can keep the value to 00). For instance, the linux driver code does not set it when (skb->ip_summed != CHECKSUM_PARTIAL). We can do the same in the dpdk driver. The function i40e_txd_enable_checksum() that fills the offload registers can only be called for packets requiring an offload. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_rxtx.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 8e9df96..9acdeee 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -74,6 +74,11 @@ #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS) +#define I40E_TX_CKSUM_OFFLOAD_MASK ( \ + PKT_TX_IP_CKSUM | \ + PKT_TX_L4_MASK | \ + PKT_TX_OUTER_IP_CKSUM) + #define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \ (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM) @@ -1272,10 +1277,12 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) /* Enable checksum offloading */ cd_tunneling_params = 0; - i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, - l2_len, l3_len, outer_l2_len, - outer_l3_len, - &cd_tunneling_params); + if (ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK) { + i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, + l2_len, l3_len, outer_l2_len, + outer_l3_len, + &cd_tunneling_params); + } if (unlikely(nb_ctx)) { /* Setup TX context descriptor if required */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (2 preceding siblings ...) 2015-01-30 13:15 ` [dpdk-dev] [PATCH 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets Olivier Matz @ 2015-01-30 13:15 ` Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 05/20] mbuf: remove " Olivier Matz ` (16 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:15 UTC (permalink / raw) To: dev The definition of the flag in rte_mbuf.h was: TX packet is an UDP tunneled packet. It must be specified when using outer checksum offload (PKT_TX_OUTER_IP_CKSUM) This flag was used to tell the NIC that the offload type is UDP (I40E_TXD_CTX_UDP_TUNNELING flag). In the datasheet, it says it's required to specify the tunnel type in the register. However, some tests (see [1]) showed that it also works without this flag. Moreover, it is not explained how the hardware use this information. From a network perspective, this information is useless for calculating the outer IP checksum as it does not depend on the payload. Having this flag in the API would force the application to specify the tunnel type for something that looks only useful for this PMD. It will limit the number of possible tunnel types (we would need a flag for each tunnel type) and therefore prevent to support outer IP checksum for proprietary tunnels. Finally, if a hardware advertises "I support outer IP checksum", it must be supported for any payload types. This has been validated by [2], knowing that the ipip test case was fixed after this test report [3]. [1] http://dpdk.org/ml/archives/dev/2015-January/011380.html [2] http://dpdk.org/ml/archives/dev/2015-January/011475.html [3] http://dpdk.org/ml/archives/dev/2015-January/011610.html Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_rxtx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 9acdeee..0786255 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -482,7 +482,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags, } /* UDP tunneling packet TX checksum offload */ - if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) { + if (unlikely(ol_flags & PKT_TX_OUTER_IP_CKSUM)) { *td_offset |= (outer_l2_len >> 1) << I40E_TX_DESC_LENGTH_MACLEN_SHIFT; @@ -497,7 +497,6 @@ i40e_txd_enable_checksum(uint64_t ol_flags, /* Now set the ctx descriptor fields */ *cd_tunneling |= (outer_l3_len >> 2) << I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT | - I40E_TXD_CTX_UDP_TUNNELING | (l2_len >> 1) << I40E_TXD_CTX_QW0_NATLEN_SHIFT; @@ -1165,8 +1164,7 @@ i40e_calc_context_desc(uint64_t flags) { uint64_t mask = 0ULL; - if (flags | PKT_TX_UDP_TUNNEL_PKT) - mask |= PKT_TX_UDP_TUNNEL_PKT; + mask |= PKT_TX_OUTER_IP_CKSUM; #ifdef RTE_LIBRTE_IEEE1588 mask |= PKT_TX_IEEE1588_TMST; -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 05/20] mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (3 preceding siblings ...) 2015-01-30 13:15 ` [dpdk-dev] [PATCH 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 06/20] testpmd: replace tx_checksum command by csum Olivier Matz ` (15 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev Since previous commit, this flag is not used by any PMD, remove it from mbuf API and from csumonly (testpmd). In csumonly, the PKT_TX_OUTER_IP_CKSUM flag is already set for vxlan checksum, providing enough information to the underlying driver. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 4 ---- lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 5 +---- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 4b438d1..ca5ca39 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -255,9 +255,6 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, struct udp_hdr *udp_hdr; uint64_t ol_flags = 0; - if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) - ol_flags |= PKT_TX_UDP_TUNNEL_PKT; - if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_OUTER_IPV4; @@ -473,7 +470,6 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) { PKT_TX_UDP_CKSUM, PKT_TX_L4_MASK }, { PKT_TX_TCP_CKSUM, PKT_TX_L4_MASK }, { PKT_TX_SCTP_CKSUM, PKT_TX_L4_MASK }, - { PKT_TX_UDP_TUNNEL_PKT, PKT_TX_UDP_TUNNEL_PKT }, { PKT_TX_IPV4, PKT_TX_IPV4 }, { PKT_TX_IPV6, PKT_TX_IPV6 }, { PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM }, diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 1b14e02..2a4bc8c 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -240,7 +240,6 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask) case PKT_TX_SCTP_CKSUM: return "PKT_TX_SCTP_CKSUM"; case PKT_TX_UDP_CKSUM: return "PKT_TX_UDP_CKSUM"; case PKT_TX_IEEE1588_TMST: return "PKT_TX_IEEE1588_TMST"; - case PKT_TX_UDP_TUNNEL_PKT: return "PKT_TX_UDP_TUNNEL_PKT"; case PKT_TX_TCP_SEG: return "PKT_TX_TCP_SEG"; case PKT_TX_IPV4: return "PKT_TX_IPV4"; case PKT_TX_IPV6: return "PKT_TX_IPV6"; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 191a42c..d841caa 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -117,11 +117,8 @@ extern "C" { * and set it in the TCP header. Refer to rte_ipv4_phdr_cksum() and * rte_ipv6_phdr_cksum() that can be used as helpers. */ -#define PKT_TX_TCP_SEG (1ULL << 49) +#define PKT_TX_TCP_SEG (1ULL << 50) -/** TX packet is an UDP tunneled packet. It must be specified when using - * outer checksum offload (PKT_TX_OUTER_IP_CKSUM) */ -#define PKT_TX_UDP_TUNNEL_PKT (1ULL << 50) /**< TX packet is an UDP tunneled packet */ #define PKT_TX_IEEE1588_TMST (1ULL << 51) /**< TX IEEE1588 packet to timestamp. */ /** -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 06/20] testpmd: replace tx_checksum command by csum 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (4 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 05/20] mbuf: remove " Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 07/20] testpmd: move csum_show in a function Olivier Matz ` (14 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev Replace the "tx_checksum" command by "csum". It has several advantages: - it's more coherent with the forward engine name - it's shorter - the next commit will introduce a command that is related to the csum forward engine, but about rx side. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 70 +++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 4beb404..1aecbbb 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -316,7 +316,7 @@ static void cmd_help_long_parsed(void *parsed_result, " Disable hardware insertion of a VLAN header in" " packets sent on a port.\n\n" - "tx_cksum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n" + "csum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n" " Select hardware or software calculation of the" " checksum with when transmitting a packet using the" " csum forward engine.\n" @@ -326,7 +326,7 @@ static void cmd_help_long_parsed(void *parsed_result, " the forward engine)\n" " Please check the NIC datasheet for HW limits.\n\n" - "tx_checksum show (port_id)\n" + "csum show (port_id)\n" " Display tx checksum offload configuration\n\n" "tso set (segsize) (portid)\n" @@ -2858,8 +2858,8 @@ cmdline_parse_inst_t cmd_tx_vlan_reset = { /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ -struct cmd_tx_cksum_result { - cmdline_fixed_string_t tx_cksum; +struct cmd_csum_result { + cmdline_fixed_string_t csum; cmdline_fixed_string_t mode; cmdline_fixed_string_t proto; cmdline_fixed_string_t hwsw; @@ -2867,11 +2867,11 @@ struct cmd_tx_cksum_result { }; static void -cmd_tx_cksum_parsed(void *parsed_result, +cmd_csum_parsed(void *parsed_result, __attribute__((unused)) struct cmdline *cl, __attribute__((unused)) void *data) { - struct cmd_tx_cksum_result *res = parsed_result; + struct cmd_csum_result *res = parsed_result; int hw = 0; uint16_t ol_flags, mask = 0; struct rte_eth_dev_info dev_info; @@ -2940,49 +2940,49 @@ cmd_tx_cksum_parsed(void *parsed_result, } } -cmdline_parse_token_string_t cmd_tx_cksum_tx_cksum = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, - tx_cksum, "tx_checksum"); -cmdline_parse_token_string_t cmd_tx_cksum_mode = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_csum = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, + csum, "csum"); +cmdline_parse_token_string_t cmd_csum_mode = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, mode, "set"); -cmdline_parse_token_string_t cmd_tx_cksum_proto = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_proto = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, proto, "ip#tcp#udp#sctp#vxlan"); -cmdline_parse_token_string_t cmd_tx_cksum_hwsw = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_hwsw = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, hwsw, "hw#sw"); -cmdline_parse_token_num_t cmd_tx_cksum_portid = - TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_num_t cmd_csum_portid = + TOKEN_NUM_INITIALIZER(struct cmd_csum_result, port_id, UINT8); -cmdline_parse_inst_t cmd_tx_cksum_set = { - .f = cmd_tx_cksum_parsed, +cmdline_parse_inst_t cmd_csum_set = { + .f = cmd_csum_parsed, .data = NULL, .help_str = "enable/disable hardware calculation of L3/L4 checksum when " - "using csum forward engine: tx_cksum set ip|tcp|udp|sctp|vxlan hw|sw <port>", + "using csum forward engine: csum set ip|tcp|udp|sctp|vxlan hw|sw <port>", .tokens = { - (void *)&cmd_tx_cksum_tx_cksum, - (void *)&cmd_tx_cksum_mode, - (void *)&cmd_tx_cksum_proto, - (void *)&cmd_tx_cksum_hwsw, - (void *)&cmd_tx_cksum_portid, + (void *)&cmd_csum_csum, + (void *)&cmd_csum_mode, + (void *)&cmd_csum_proto, + (void *)&cmd_csum_hwsw, + (void *)&cmd_csum_portid, NULL, }, }; -cmdline_parse_token_string_t cmd_tx_cksum_mode_show = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_mode_show = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, mode, "show"); -cmdline_parse_inst_t cmd_tx_cksum_show = { - .f = cmd_tx_cksum_parsed, +cmdline_parse_inst_t cmd_csum_show = { + .f = cmd_csum_parsed, .data = NULL, - .help_str = "show checksum offload configuration: tx_cksum show <port>", + .help_str = "show checksum offload configuration: csum show <port>", .tokens = { - (void *)&cmd_tx_cksum_tx_cksum, - (void *)&cmd_tx_cksum_mode_show, - (void *)&cmd_tx_cksum_portid, + (void *)&cmd_csum_csum, + (void *)&cmd_csum_mode_show, + (void *)&cmd_csum_portid, NULL, }, }; @@ -8721,8 +8721,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_tx_vlan_set, (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, - (cmdline_parse_inst_t *)&cmd_tx_cksum_set, - (cmdline_parse_inst_t *)&cmd_tx_cksum_show, + (cmdline_parse_inst_t *)&cmd_csum_set, + (cmdline_parse_inst_t *)&cmd_csum_show, (cmdline_parse_inst_t *)&cmd_tso_set, (cmdline_parse_inst_t *)&cmd_tso_show, (cmdline_parse_inst_t *)&cmd_link_flow_control_set, -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 07/20] testpmd: move csum_show in a function 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (5 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 06/20] testpmd: replace tx_checksum command by csum Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 08/20] testpmd: add csum parse_tunnel command Olivier Matz ` (13 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev No functional changes in this commit, we just move the code that displays the csum forward engine configuration in a function. This makes the next commit easier to read as it will also use this function. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 82 +++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 1aecbbb..260a273 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2867,14 +2867,56 @@ struct cmd_csum_result { }; static void +csum_show(int port_id) +{ + struct rte_eth_dev_info dev_info; + uint16_t ol_flags; + + ol_flags = ports[port_id].tx_ol_flags; + printf("IP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); + printf("UDP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); + printf("TCP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); + printf("SCTP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); + printf("VxLAN checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw"); + + /* display warnings if configuration is not supported by the NIC */ + rte_eth_dev_info_get(port_id, &dev_info); + if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { + printf("Warning: hardware IP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { + printf("Warning: hardware UDP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { + printf("Warning: hardware TCP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { + printf("Warning: hardware SCTP checksum enabled but not " + "supported by port %d\n", port_id); + } + +} + +static void cmd_csum_parsed(void *parsed_result, __attribute__((unused)) struct cmdline *cl, __attribute__((unused)) void *data) { struct cmd_csum_result *res = parsed_result; int hw = 0; - uint16_t ol_flags, mask = 0; - struct rte_eth_dev_info dev_info; + uint16_t mask = 0; if (port_id_is_invalid(res->port_id)) { printf("invalid port %d\n", res->port_id); @@ -2903,41 +2945,7 @@ cmd_csum_parsed(void *parsed_result, else ports[res->port_id].tx_ol_flags &= (~mask); } - - ol_flags = ports[res->port_id].tx_ol_flags; - printf("IP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); - printf("UDP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); - printf("TCP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); - printf("SCTP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); - printf("VxLAN checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw"); - - /* display warnings if configuration is not supported by the NIC */ - rte_eth_dev_info_get(res->port_id, &dev_info); - if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { - printf("Warning: hardware IP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { - printf("Warning: hardware UDP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { - printf("Warning: hardware TCP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { - printf("Warning: hardware SCTP checksum enabled but not " - "supported by port %d\n", res->port_id); - } + csum_show(res->port_id); } cmdline_parse_token_string_t cmd_csum_csum = -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 08/20] testpmd: add csum parse_tunnel command 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (6 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 07/20] testpmd: move csum_show in a function Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 09/20] testpmd: rename vxlan in outer_ip in csum commands Olivier Matz ` (12 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev Add a new command related to csum forward engine: csum parse-tunnel (on|off) (tx_port_id) If enabled, the tunnel packets received by the csum forward engine are parsed and seen as "outer-headers/inner-headers/data". If disabled, the parsing of the csum forward engine stops at the first l4 layer. A tunnel packet is seens as "headers/data" (inner headers are included in payload). Note: the port argument is the tx_port. It's more coherent compared to all other testpmd csum flags. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/csumonly.c | 3 ++- app/test-pmd/testpmd.h | 5 +++- 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 260a273..62def61 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -326,6 +326,12 @@ static void cmd_help_long_parsed(void *parsed_result, " the forward engine)\n" " Please check the NIC datasheet for HW limits.\n\n" + "csum parse-tunnel (on|off) (tx_port_id)\n" + " If disabled, treat tunnel packets as non-tunneled" + " packets (treat inner headers as payload). The port\n" + " argument is the port used for TX in csum forward" + " engine.\n\n" + "csum show (port_id)\n" " Display tx checksum offload configuration\n\n" @@ -2873,6 +2879,8 @@ csum_show(int port_id) uint16_t ol_flags; ol_flags = ports[port_id].tx_ol_flags; + printf("Parse tunnel is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off"); printf("IP checksum offload is %s\n", (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); printf("UDP checksum offload is %s\n", @@ -2995,6 +3003,63 @@ cmdline_parse_inst_t cmd_csum_show = { }, }; +/* Enable/disable tunnel parsing */ +struct cmd_csum_tunnel_result { + cmdline_fixed_string_t csum; + cmdline_fixed_string_t parse; + cmdline_fixed_string_t onoff; + uint8_t port_id; +}; + +static void +cmd_csum_tunnel_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_csum_tunnel_result *res = parsed_result; + + if (port_id_is_invalid(res->port_id)) { + printf("invalid port %d\n", res->port_id); + return; + } + + if (!strcmp(res->onoff, "on")) + ports[res->port_id].tx_ol_flags |= + TESTPMD_TX_OFFLOAD_PARSE_TUNNEL; + else + ports[res->port_id].tx_ol_flags &= + (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL); + + csum_show(res->port_id); +} + +cmdline_parse_token_string_t cmd_csum_tunnel_csum = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + csum, "csum"); +cmdline_parse_token_string_t cmd_csum_tunnel_parse = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + parse, "parse_tunnel"); +cmdline_parse_token_string_t cmd_csum_tunnel_onoff = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + onoff, "on#off"); +cmdline_parse_token_num_t cmd_csum_tunnel_portid = + TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, + port_id, UINT8); + +cmdline_parse_inst_t cmd_csum_tunnel = { + .f = cmd_csum_tunnel_parsed, + .data = NULL, + .help_str = "enable/disable parsing of tunnels for csum engine: " + "csum parse_tunnel on|off <tx-port>", + .tokens = { + (void *)&cmd_csum_tunnel_csum, + (void *)&cmd_csum_tunnel_parse, + (void *)&cmd_csum_tunnel_onoff, + (void *)&cmd_csum_tunnel_portid, + NULL, + }, +}; + /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */ struct cmd_tso_set_result { cmdline_fixed_string_t tso; @@ -8731,6 +8796,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, (cmdline_parse_inst_t *)&cmd_csum_set, (cmdline_parse_inst_t *)&cmd_csum_show, + (cmdline_parse_inst_t *)&cmd_csum_tunnel, (cmdline_parse_inst_t *)&cmd_tso_set, (cmdline_parse_inst_t *)&cmd_tso_show, (cmdline_parse_inst_t *)&cmd_link_flow_control_set, diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index ca5ca39..858eb47 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -373,7 +373,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) l3_hdr = (char *)eth_hdr + l2_len; /* check if it's a supported tunnel (only vxlan for now) */ - if (l4_proto == IPPROTO_UDP) { + if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && + l4_proto == IPPROTO_UDP) { udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len); /* check udp destination port, 4789 is the default diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 8f5e6c7..36277de 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -127,8 +127,11 @@ struct fwd_stream { #define TESTPMD_TX_OFFLOAD_SCTP_CKSUM 0x0008 /** Offload VxLAN checksum in csum forward engine */ #define TESTPMD_TX_OFFLOAD_VXLAN_CKSUM 0x0010 +/** Parse tunnel in csum forward engine. If set, dissect tunnel headers + * of rx packets. If not set, treat inner headers as payload. */ +#define TESTPMD_TX_OFFLOAD_PARSE_TUNNEL 0x0020 /** Insert VLAN header in forward engine */ -#define TESTPMD_TX_OFFLOAD_INSERT_VLAN 0x0020 +#define TESTPMD_TX_OFFLOAD_INSERT_VLAN 0x0040 /** * The data structure associated with each port. -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 09/20] testpmd: rename vxlan in outer_ip in csum commands 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (7 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 08/20] testpmd: add csum parse_tunnel command Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 10/20] testpmd: introduce parse_ipv* in csum fwd engine Olivier Matz ` (11 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev The tx_checksum command concerns outer IP checksum, not VxLAN checksum. Actually there is no checkum in VxLAN header, there is one checksum in outer IP header, and one checksum in outer UDP header. This option only controls the outer IP checksum. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 16 ++++++++-------- app/test-pmd/csumonly.c | 25 ++++++++++++++----------- app/test-pmd/testpmd.h | 4 ++-- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 62def61..98f7a1c 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -316,12 +316,12 @@ static void cmd_help_long_parsed(void *parsed_result, " Disable hardware insertion of a VLAN header in" " packets sent on a port.\n\n" - "csum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n" + "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n" " Select hardware or software calculation of the" " checksum with when transmitting a packet using the" " csum forward engine.\n" " ip|udp|tcp|sctp always concern the inner layer.\n" - " vxlan concerns the outer IP and UDP layer (in" + " outer-ip concerns the outer IP layer (in" " case the packet is recognized as a vxlan packet by" " the forward engine)\n" " Please check the NIC datasheet for HW limits.\n\n" @@ -2889,8 +2889,8 @@ csum_show(int port_id) (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); printf("SCTP checksum offload is %s\n", (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); - printf("VxLAN checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw"); + printf("Outer-Ip checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw"); /* display warnings if configuration is not supported by the NIC */ rte_eth_dev_info_get(port_id, &dev_info); @@ -2944,8 +2944,8 @@ cmd_csum_parsed(void *parsed_result, mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM; } else if (!strcmp(res->proto, "sctp")) { mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM; - } else if (!strcmp(res->proto, "vxlan")) { - mask = TESTPMD_TX_OFFLOAD_VXLAN_CKSUM; + } else if (!strcmp(res->proto, "outer-ip")) { + mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM; } if (hw) @@ -2964,7 +2964,7 @@ cmdline_parse_token_string_t cmd_csum_mode = mode, "set"); cmdline_parse_token_string_t cmd_csum_proto = TOKEN_STRING_INITIALIZER(struct cmd_csum_result, - proto, "ip#tcp#udp#sctp#vxlan"); + proto, "ip#tcp#udp#sctp#outer-ip"); cmdline_parse_token_string_t cmd_csum_hwsw = TOKEN_STRING_INITIALIZER(struct cmd_csum_result, hwsw, "hw#sw"); @@ -2976,7 +2976,7 @@ cmdline_parse_inst_t cmd_csum_set = { .f = cmd_csum_parsed, .data = NULL, .help_str = "enable/disable hardware calculation of L3/L4 checksum when " - "using csum forward engine: csum set ip|tcp|udp|sctp|vxlan hw|sw <port>", + "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>", .tokens = { (void *)&cmd_csum_csum, (void *)&cmd_csum_mode, diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 858eb47..3921643 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -259,13 +259,16 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_OUTER_IPV4; - if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ol_flags |= PKT_TX_OUTER_IP_CKSUM; else ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); - } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) + } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ol_flags |= PKT_TX_OUTER_IPV6; + /* outer UDP checksum is always done in software as we have no + * hardware supporting it today, and no API for it. */ + udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len); /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { @@ -300,8 +303,8 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, * The testpmd command line for this forward engine sets the flags * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control * wether a checksum must be calculated in software or in hardware. The - * IP, UDP, TCP and SCTP flags always concern the inner layer. The - * VxLAN flag concerns the outer IP (if packet is recognized as a vxlan packet). + * IP, UDP, TCP and SCTP flags always concern the inner layer. The + * OUTER_IP is only useful for tunnel packets. */ static void pkt_burst_checksum_forward(struct fwd_stream *fs) @@ -432,18 +435,18 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* step 4: fill the mbuf meta data (flags and header lengths) */ if (tunnel == 1) { - if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) { + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { m->outer_l2_len = outer_l2_len; m->outer_l3_len = outer_l3_len; m->l2_len = l4_tun_len + l2_len; m->l3_len = l3_len; } else { - /* if we don't do vxlan cksum in hw, - outer checksum will be wrong because - we changed the ip, but it shows that - we can process the inner header cksum - in the nic */ + /* if there is a outer UDP cksum + processed in sw and the inner in hw, + the outer checksum will be wrong as + the payload will be modified by the + hardware */ m->l2_len = outer_l2_len + outer_l3_len + sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr) + l2_len; @@ -502,7 +505,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) "m->l4_len=%d\n", m->l2_len, m->l3_len, m->l4_len); if ((tunnel == 1) && - (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)) + (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM)) printf("tx: m->outer_l2_len=%d m->outer_l3_len=%d\n", m->outer_l2_len, m->outer_l3_len); if (tso_segsz != 0) diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 36277de..ecb7d38 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -125,8 +125,8 @@ struct fwd_stream { #define TESTPMD_TX_OFFLOAD_TCP_CKSUM 0x0004 /** Offload SCTP checksum in csum forward engine */ #define TESTPMD_TX_OFFLOAD_SCTP_CKSUM 0x0008 -/** Offload VxLAN checksum in csum forward engine */ -#define TESTPMD_TX_OFFLOAD_VXLAN_CKSUM 0x0010 +/** Offload outer IP checksum in csum forward engine for recognized tunnels */ +#define TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM 0x0010 /** Parse tunnel in csum forward engine. If set, dissect tunnel headers * of rx packets. If not set, treat inner headers as payload. */ #define TESTPMD_TX_OFFLOAD_PARSE_TUNNEL 0x0020 -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 10/20] testpmd: introduce parse_ipv* in csum fwd engine 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (8 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 09/20] testpmd: rename vxlan in outer_ip in csum commands Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 11/20] testpmd: use a structure to store offload info " Olivier Matz ` (10 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev These functions may be used to parse encapsulated layers when we will support IP over GRE tunnels. No functional change. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 51 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 3921643..b023f12 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -104,6 +104,42 @@ get_udptcp_checksum(void *l3_hdr, void *l4_hdr, uint16_t ethertype) return rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr); } +/* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */ +static void +parse_ipv4(struct ipv4_hdr *ipv4_hdr, uint16_t *l3_len, uint8_t *l4_proto, + uint16_t *l4_len) +{ + struct tcp_hdr *tcp_hdr; + + *l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; + *l4_proto = ipv4_hdr->next_proto_id; + + /* only fill l4_len for TCP, it's useful for TSO */ + if (*l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv4_hdr + *l3_len); + *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + } else + *l4_len = 0; +} + +/* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */ +static void +parse_ipv6(struct ipv6_hdr *ipv6_hdr, uint16_t *l3_len, uint8_t *l4_proto, + uint16_t *l4_len) +{ + struct tcp_hdr *tcp_hdr; + + *l3_len = sizeof(struct ipv6_hdr); + *l4_proto = ipv6_hdr->proto; + + /* only fill l4_len for TCP, it's useful for TSO */ + if (*l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv6_hdr + *l3_len); + *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + } else + *l4_len = 0; +} + /* * Parse an ethernet header to fill the ethertype, l2_len, l3_len and * ipproto. This function is able to recognize IPv4/IPv6 with one optional vlan @@ -115,7 +151,6 @@ parse_ethernet(struct ether_hdr *eth_hdr, uint16_t *ethertype, uint16_t *l2_len, { struct ipv4_hdr *ipv4_hdr; struct ipv6_hdr *ipv6_hdr; - struct tcp_hdr *tcp_hdr; *l2_len = sizeof(struct ether_hdr); *ethertype = eth_hdr->ether_type; @@ -130,26 +165,18 @@ parse_ethernet(struct ether_hdr *eth_hdr, uint16_t *ethertype, uint16_t *l2_len, switch (*ethertype) { case _htons(ETHER_TYPE_IPv4): ipv4_hdr = (struct ipv4_hdr *) ((char *)eth_hdr + *l2_len); - *l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; - *l4_proto = ipv4_hdr->next_proto_id; + parse_ipv4(ipv4_hdr, l3_len, l4_proto, l4_len); break; case _htons(ETHER_TYPE_IPv6): ipv6_hdr = (struct ipv6_hdr *) ((char *)eth_hdr + *l2_len); - *l3_len = sizeof(struct ipv6_hdr); - *l4_proto = ipv6_hdr->proto; + parse_ipv6(ipv6_hdr, l3_len, l4_proto, l4_len); break; default: + *l4_len = 0; *l3_len = 0; *l4_proto = 0; break; } - - if (*l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)eth_hdr + - *l2_len + *l3_len); - *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; - } else - *l4_len = 0; } /* modify the IPv4 or IPv4 source address of a packet */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 11/20] testpmd: use a structure to store offload info in csum fwd engine 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (9 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 10/20] testpmd: introduce parse_ipv* in csum fwd engine Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 12/20] testpmd: introduce parse_vxlan " Olivier Matz ` (9 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev To simplify the API of parse_* functions, store all the offload information for the current packet in a structure. No functional change. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 222 +++++++++++++++++++++++++----------------------- 1 file changed, 115 insertions(+), 107 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index b023f12..0b89d89 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -86,6 +86,21 @@ #define _htons(x) (x) #endif +/* structure that caches offload info for the current packet */ +struct testpmd_offload_info { + uint16_t ethertype; + uint16_t l2_len; + uint16_t l3_len; + uint16_t l4_len; + uint8_t l4_proto; + uint8_t l4_tun_len; + uint8_t is_tunnel; + uint16_t outer_ethertype; + uint16_t outer_l2_len; + uint16_t outer_l3_len; + uint16_t tso_segsz; +}; + static uint16_t get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags) { @@ -106,38 +121,36 @@ get_udptcp_checksum(void *l3_hdr, void *l4_hdr, uint16_t ethertype) /* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */ static void -parse_ipv4(struct ipv4_hdr *ipv4_hdr, uint16_t *l3_len, uint8_t *l4_proto, - uint16_t *l4_len) +parse_ipv4(struct ipv4_hdr *ipv4_hdr, struct testpmd_offload_info *info) { struct tcp_hdr *tcp_hdr; - *l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; - *l4_proto = ipv4_hdr->next_proto_id; + info->l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; + info->l4_proto = ipv4_hdr->next_proto_id; /* only fill l4_len for TCP, it's useful for TSO */ - if (*l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)ipv4_hdr + *l3_len); - *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + if (info->l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv4_hdr + info->l3_len); + info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2; } else - *l4_len = 0; + info->l4_len = 0; } /* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */ static void -parse_ipv6(struct ipv6_hdr *ipv6_hdr, uint16_t *l3_len, uint8_t *l4_proto, - uint16_t *l4_len) +parse_ipv6(struct ipv6_hdr *ipv6_hdr, struct testpmd_offload_info *info) { struct tcp_hdr *tcp_hdr; - *l3_len = sizeof(struct ipv6_hdr); - *l4_proto = ipv6_hdr->proto; + info->l3_len = sizeof(struct ipv6_hdr); + info->l4_proto = ipv6_hdr->proto; /* only fill l4_len for TCP, it's useful for TSO */ - if (*l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)ipv6_hdr + *l3_len); - *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + if (info->l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv6_hdr + info->l3_len); + info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2; } else - *l4_len = 0; + info->l4_len = 0; } /* @@ -146,35 +159,34 @@ parse_ipv6(struct ipv6_hdr *ipv6_hdr, uint16_t *l3_len, uint8_t *l4_proto, * header. The l4_len argument is only set in case of TCP (useful for TSO). */ static void -parse_ethernet(struct ether_hdr *eth_hdr, uint16_t *ethertype, uint16_t *l2_len, - uint16_t *l3_len, uint8_t *l4_proto, uint16_t *l4_len) +parse_ethernet(struct ether_hdr *eth_hdr, struct testpmd_offload_info *info) { struct ipv4_hdr *ipv4_hdr; struct ipv6_hdr *ipv6_hdr; - *l2_len = sizeof(struct ether_hdr); - *ethertype = eth_hdr->ether_type; + info->l2_len = sizeof(struct ether_hdr); + info->ethertype = eth_hdr->ether_type; - if (*ethertype == _htons(ETHER_TYPE_VLAN)) { + if (info->ethertype == _htons(ETHER_TYPE_VLAN)) { struct vlan_hdr *vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1); - *l2_len += sizeof(struct vlan_hdr); - *ethertype = vlan_hdr->eth_proto; + info->l2_len += sizeof(struct vlan_hdr); + info->ethertype = vlan_hdr->eth_proto; } - switch (*ethertype) { + switch (info->ethertype) { case _htons(ETHER_TYPE_IPv4): - ipv4_hdr = (struct ipv4_hdr *) ((char *)eth_hdr + *l2_len); - parse_ipv4(ipv4_hdr, l3_len, l4_proto, l4_len); + ipv4_hdr = (struct ipv4_hdr *) ((char *)eth_hdr + info->l2_len); + parse_ipv4(ipv4_hdr, info); break; case _htons(ETHER_TYPE_IPv6): - ipv6_hdr = (struct ipv6_hdr *) ((char *)eth_hdr + *l2_len); - parse_ipv6(ipv6_hdr, l3_len, l4_proto, l4_len); + ipv6_hdr = (struct ipv6_hdr *) ((char *)eth_hdr + info->l2_len); + parse_ipv6(ipv6_hdr, info); break; default: - *l4_len = 0; - *l3_len = 0; - *l4_proto = 0; + info->l4_len = 0; + info->l3_len = 0; + info->l4_proto = 0; break; } } @@ -197,8 +209,8 @@ change_ip_addresses(void *l3_hdr, uint16_t ethertype) /* if possible, calculate the checksum of a packet in hw or sw, * depending on the testpmd command line configuration */ static uint64_t -process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, - uint8_t l4_proto, uint16_t tso_segsz, uint16_t testpmd_ol_flags) +process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, + uint16_t testpmd_ol_flags) { struct ipv4_hdr *ipv4_hdr = l3_hdr; struct udp_hdr *udp_hdr; @@ -206,12 +218,12 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, struct sctp_hdr *sctp_hdr; uint64_t ol_flags = 0; - if (ethertype == _htons(ETHER_TYPE_IPv4)) { + if (info->ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr = l3_hdr; ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_IPV4; - if (tso_segsz != 0 && l4_proto == IPPROTO_TCP) { + if (info->tso_segsz != 0 && info->l4_proto == IPPROTO_TCP) { ol_flags |= PKT_TX_IP_CKSUM; } else { if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) @@ -220,41 +232,44 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); } - } else if (ethertype == _htons(ETHER_TYPE_IPv6)) + } else if (info->ethertype == _htons(ETHER_TYPE_IPv6)) ol_flags |= PKT_TX_IPV6; else return 0; /* packet type not supported, nothing to do */ - if (l4_proto == IPPROTO_UDP) { - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len); + if (info->l4_proto == IPPROTO_UDP) { + udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info->l3_len); /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { udp_hdr->dgram_cksum = 0; if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) { ol_flags |= PKT_TX_UDP_CKSUM; udp_hdr->dgram_cksum = get_psd_sum(l3_hdr, - ethertype, ol_flags); + info->ethertype, ol_flags); } else { udp_hdr->dgram_cksum = get_udptcp_checksum(l3_hdr, udp_hdr, - ethertype); + info->ethertype); } } - } else if (l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + l3_len); + } else if (info->l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + info->l3_len); tcp_hdr->cksum = 0; - if (tso_segsz != 0) { + if (info->tso_segsz != 0) { ol_flags |= PKT_TX_TCP_SEG; - tcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype, ol_flags); + tcp_hdr->cksum = get_psd_sum(l3_hdr, info->ethertype, + ol_flags); } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) { ol_flags |= PKT_TX_TCP_CKSUM; - tcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype, ol_flags); + tcp_hdr->cksum = get_psd_sum(l3_hdr, info->ethertype, + ol_flags); } else { tcp_hdr->cksum = - get_udptcp_checksum(l3_hdr, tcp_hdr, ethertype); + get_udptcp_checksum(l3_hdr, tcp_hdr, + info->ethertype); } - } else if (l4_proto == IPPROTO_SCTP) { - sctp_hdr = (struct sctp_hdr *)((char *)l3_hdr + l3_len); + } else if (info->l4_proto == IPPROTO_SCTP) { + sctp_hdr = (struct sctp_hdr *)((char *)l3_hdr + info->l3_len); sctp_hdr->cksum = 0; /* sctp payload must be a multiple of 4 to be * offloaded */ @@ -274,15 +289,15 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, * meaning IP + UDP). The caller already checked that it's a vxlan * packet */ static uint64_t -process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, - uint16_t outer_l3_len, uint16_t testpmd_ol_flags) +process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, +uint16_t testpmd_ol_flags) { struct ipv4_hdr *ipv4_hdr = outer_l3_hdr; struct ipv6_hdr *ipv6_hdr = outer_l3_hdr; struct udp_hdr *udp_hdr; uint64_t ol_flags = 0; - if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { + if (info->outer_ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_OUTER_IPV4; @@ -296,11 +311,11 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, /* outer UDP checksum is always done in software as we have no * hardware supporting it today, and no API for it. */ - udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len); + udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + info->outer_l3_len); /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { udp_hdr->dgram_cksum = 0; - if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) + if (info->outer_ethertype == _htons(ETHER_TYPE_IPv4)) udp_hdr->dgram_cksum = rte_ipv4_udptcp_cksum(ipv4_hdr, udp_hdr); else @@ -347,14 +362,9 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) uint16_t i; uint64_t ol_flags; uint16_t testpmd_ol_flags; - uint8_t l4_proto, l4_tun_len = 0; - uint16_t ethertype = 0, outer_ethertype = 0; - uint16_t l2_len = 0, l3_len = 0, l4_len = 0; - uint16_t outer_l2_len = 0, outer_l3_len = 0; - uint16_t tso_segsz; - int tunnel = 0; uint32_t rx_bad_ip_csum; uint32_t rx_bad_l4_csum; + struct testpmd_offload_info info; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES uint64_t start_tsc; @@ -381,13 +391,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) txp = &ports[fs->tx_port]; testpmd_ol_flags = txp->tx_ol_flags; - tso_segsz = txp->tso_segsz; + memset(&info, 0, sizeof(info)); + info.tso_segsz = txp->tso_segsz; for (i = 0; i < nb_rx; i++) { ol_flags = 0; - tunnel = 0; - l4_tun_len = 0; + info.is_tunnel = 0; m = pkts_burst[i]; /* Update the L3/L4 checksum error packet statistics */ @@ -398,49 +408,47 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) * and inner headers */ eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); - parse_ethernet(eth_hdr, ðertype, &l2_len, &l3_len, - &l4_proto, &l4_len); - l3_hdr = (char *)eth_hdr + l2_len; + parse_ethernet(eth_hdr, &info); + l3_hdr = (char *)eth_hdr + info.l2_len; /* check if it's a supported tunnel (only vxlan for now) */ if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && - l4_proto == IPPROTO_UDP) { - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len); + info.l4_proto == IPPROTO_UDP) { + udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info.l3_len); /* check udp destination port, 4789 is the default * vxlan port (rfc7348) */ if (udp_hdr->dst_port == _htons(4789)) { - l4_tun_len = ETHER_VXLAN_HLEN; - tunnel = 1; + info.l4_tun_len = ETHER_VXLAN_HLEN; + info.is_tunnel = 1; /* currently, this flag is set by i40e only if the * packet is vxlan */ } else if (m->ol_flags & (PKT_RX_TUNNEL_IPV4_HDR | PKT_RX_TUNNEL_IPV6_HDR)) - tunnel = 1; + info.is_tunnel = 1; - if (tunnel == 1) { - outer_ethertype = ethertype; - outer_l2_len = l2_len; - outer_l3_len = l3_len; + if (info.is_tunnel == 1) { + info.outer_ethertype = info.ethertype; + info.outer_l2_len = info.l2_len; + info.outer_l3_len = info.l3_len; outer_l3_hdr = l3_hdr; eth_hdr = (struct ether_hdr *)((char *)udp_hdr + sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr)); - parse_ethernet(eth_hdr, ðertype, &l2_len, - &l3_len, &l4_proto, &l4_len); - l3_hdr = (char *)eth_hdr + l2_len; + parse_ethernet(eth_hdr, &info); + l3_hdr = (char *)eth_hdr + info.l2_len; } } /* step 2: change all source IPs (v4 or v6) so we need * to recompute the chksums even if they were correct */ - change_ip_addresses(l3_hdr, ethertype); - if (tunnel == 1) - change_ip_addresses(outer_l3_hdr, outer_ethertype); + change_ip_addresses(l3_hdr, info.ethertype); + if (info.is_tunnel == 1) + change_ip_addresses(outer_l3_hdr, info.outer_ethertype); /* step 3: depending on user command line configuration, * recompute checksum either in software or flag the @@ -448,25 +456,24 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) * is configured, prepare the mbuf for TCP segmentation. */ /* process checksums of inner headers first */ - ol_flags |= process_inner_cksums(l3_hdr, ethertype, - l3_len, l4_proto, tso_segsz, testpmd_ol_flags); + ol_flags |= process_inner_cksums(l3_hdr, &info, testpmd_ol_flags); /* Then process outer headers if any. Note that the software * checksum will be wrong if one of the inner checksums is * processed in hardware. */ - if (tunnel == 1) { - ol_flags |= process_outer_cksums(outer_l3_hdr, - outer_ethertype, outer_l3_len, testpmd_ol_flags); + if (info.is_tunnel == 1) { + ol_flags |= process_outer_cksums(outer_l3_hdr, &info, + testpmd_ol_flags); } /* step 4: fill the mbuf meta data (flags and header lengths) */ - if (tunnel == 1) { + if (info.is_tunnel == 1) { if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { - m->outer_l2_len = outer_l2_len; - m->outer_l3_len = outer_l3_len; - m->l2_len = l4_tun_len + l2_len; - m->l3_len = l3_len; + m->outer_l2_len = info.outer_l2_len; + m->outer_l3_len = info.outer_l3_len; + m->l2_len = info.l4_tun_len + info.l2_len; + m->l3_len = info.l3_len; } else { /* if there is a outer UDP cksum @@ -474,21 +481,22 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) the outer checksum will be wrong as the payload will be modified by the hardware */ - m->l2_len = outer_l2_len + outer_l3_len + + m->l2_len = info.outer_l2_len + + info.outer_l3_len + sizeof(struct udp_hdr) + - sizeof(struct vxlan_hdr) + l2_len; - m->l3_len = l3_len; - m->l4_len = l4_len; + sizeof(struct vxlan_hdr) + info.l2_len; + m->l3_len = info.l3_len; + m->l4_len = info.l4_len; } } else { /* this is only useful if an offload flag is * set, but it does not hurt to fill it in any * case */ - m->l2_len = l2_len; - m->l3_len = l3_len; - m->l4_len = l4_len; + m->l2_len = info.l2_len; + m->l3_len = info.l3_len; + m->l4_len = info.l4_len; } - m->tso_segsz = tso_segsz; + m->tso_segsz = info.tso_segsz; m->ol_flags = ol_flags; /* if verbose mode is enabled, dump debug info */ @@ -515,27 +523,27 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* dump rx parsed packet info */ printf("rx: l2_len=%d ethertype=%x l3_len=%d " "l4_proto=%d l4_len=%d\n", - l2_len, rte_be_to_cpu_16(ethertype), - l3_len, l4_proto, l4_len); - if (tunnel == 1) + info.l2_len, rte_be_to_cpu_16(info.ethertype), + info.l3_len, info.l4_proto, info.l4_len); + if (info.is_tunnel == 1) printf("rx: outer_l2_len=%d outer_ethertype=%x " - "outer_l3_len=%d\n", outer_l2_len, - rte_be_to_cpu_16(outer_ethertype), - outer_l3_len); + "outer_l3_len=%d\n", info.outer_l2_len, + rte_be_to_cpu_16(info.outer_ethertype), + info.outer_l3_len); /* dump tx packet info */ if ((testpmd_ol_flags & (TESTPMD_TX_OFFLOAD_IP_CKSUM | TESTPMD_TX_OFFLOAD_UDP_CKSUM | TESTPMD_TX_OFFLOAD_TCP_CKSUM | TESTPMD_TX_OFFLOAD_SCTP_CKSUM)) || - tso_segsz != 0) + info.tso_segsz != 0) printf("tx: m->l2_len=%d m->l3_len=%d " "m->l4_len=%d\n", m->l2_len, m->l3_len, m->l4_len); - if ((tunnel == 1) && + if ((info.is_tunnel == 1) && (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM)) printf("tx: m->outer_l2_len=%d m->outer_l3_len=%d\n", m->outer_l2_len, m->outer_l3_len); - if (tso_segsz != 0) + if (info.tso_segsz != 0) printf("tx: m->tso_segsz=%d\n", m->tso_segsz); printf("tx: flags="); for (j = 0; j < sizeof(tx_flags)/sizeof(*tx_flags); j++) { -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 12/20] testpmd: introduce parse_vxlan in csum fwd engine 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (10 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 11/20] testpmd: use a structure to store offload info " Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-02-02 1:49 ` Liu, Jijiang 2015-01-30 13:16 ` [dpdk-dev] [PATCH 13/20] testpmd: support gre tunnels " Olivier Matz ` (8 subsequent siblings) 20 siblings, 1 reply; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev Move code parsing vxlan into a function. It will ease the support of GRE tunnels and IPIP tunnels in next commits. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 68 +++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 0b89d89..52af0e7 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -93,7 +93,6 @@ struct testpmd_offload_info { uint16_t l3_len; uint16_t l4_len; uint8_t l4_proto; - uint8_t l4_tun_len; uint8_t is_tunnel; uint16_t outer_ethertype; uint16_t outer_l2_len; @@ -191,6 +190,34 @@ parse_ethernet(struct ether_hdr *eth_hdr, struct testpmd_offload_info *info) } } +/* Parse a vxlan header */ +static void +parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, + uint64_t mbuf_olflags) +{ + struct ether_hdr *eth_hdr; + + /* check udp destination port, 4789 is the default vxlan port + * (rfc7348) or that the rx offload flag is set (i40e only + * currently) */ + if (udp_hdr->dst_port != _htons(4789) && + (mbuf_olflags & (PKT_RX_TUNNEL_IPV4_HDR | + PKT_RX_TUNNEL_IPV6_HDR)) != 0) + return; + + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + eth_hdr = (struct ether_hdr *)((char *)udp_hdr + + sizeof(struct udp_hdr) + + sizeof(struct vxlan_hdr)); + + parse_ethernet(eth_hdr, info); + info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */ +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -356,7 +383,6 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) struct rte_mbuf *m; struct ether_hdr *eth_hdr; void *l3_hdr = NULL, *outer_l3_hdr = NULL; /* can be IPv4 or IPv6 */ - struct udp_hdr *udp_hdr; uint16_t nb_rx; uint16_t nb_tx; uint16_t i; @@ -414,33 +440,15 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* check if it's a supported tunnel (only vxlan for now) */ if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && info.l4_proto == IPPROTO_UDP) { + struct udp_hdr *udp_hdr; udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info.l3_len); + parse_vxlan(udp_hdr, &info, m->ol_flags); + } - /* check udp destination port, 4789 is the default - * vxlan port (rfc7348) */ - if (udp_hdr->dst_port == _htons(4789)) { - info.l4_tun_len = ETHER_VXLAN_HLEN; - info.is_tunnel = 1; - - /* currently, this flag is set by i40e only if the - * packet is vxlan */ - } else if (m->ol_flags & (PKT_RX_TUNNEL_IPV4_HDR | - PKT_RX_TUNNEL_IPV6_HDR)) - info.is_tunnel = 1; - - if (info.is_tunnel == 1) { - info.outer_ethertype = info.ethertype; - info.outer_l2_len = info.l2_len; - info.outer_l3_len = info.l3_len; - outer_l3_hdr = l3_hdr; - - eth_hdr = (struct ether_hdr *)((char *)udp_hdr + - sizeof(struct udp_hdr) + - sizeof(struct vxlan_hdr)); - - parse_ethernet(eth_hdr, &info); - l3_hdr = (char *)eth_hdr + info.l2_len; - } + /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ + if (info.is_tunnel) { + outer_l3_hdr = l3_hdr; + l3_hdr = (char *)l3_hdr + info.outer_l3_len + info.l2_len; } /* step 2: change all source IPs (v4 or v6) so we need @@ -472,7 +480,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { m->outer_l2_len = info.outer_l2_len; m->outer_l3_len = info.outer_l3_len; - m->l2_len = info.l4_tun_len + info.l2_len; + m->l2_len = info.l2_len; m->l3_len = info.l3_len; } else { @@ -482,9 +490,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) the payload will be modified by the hardware */ m->l2_len = info.outer_l2_len + - info.outer_l3_len + - sizeof(struct udp_hdr) + - sizeof(struct vxlan_hdr) + info.l2_len; + info.outer_l3_len + info.l2_len; m->l3_len = info.l3_len; m->l4_len = info.l4_len; } -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH 12/20] testpmd: introduce parse_vxlan in csum fwd engine 2015-01-30 13:16 ` [dpdk-dev] [PATCH 12/20] testpmd: introduce parse_vxlan " Olivier Matz @ 2015-02-02 1:49 ` Liu, Jijiang 0 siblings, 0 replies; 109+ messages in thread From: Liu, Jijiang @ 2015-02-02 1:49 UTC (permalink / raw) To: Olivier Matz; +Cc: dev Hi, > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Friday, January 30, 2015 9:16 PM > To: dev@dpdk.org > Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; olivier.matz@6wind.com > Subject: [PATCH 12/20] testpmd: introduce parse_vxlan in csum fwd engine > > Move code parsing vxlan into a function. It will ease the support of GRE > tunnels and IPIP tunnels in next commits. > > Signed-off-by: Olivier Matz <olivier.matz@6wind.com> > --- > app/test-pmd/csumonly.c | 68 +++++++++++++++++++++++++++------------ > ---------- > 1 file changed, 37 insertions(+), 31 deletions(-) > > diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index > 0b89d89..52af0e7 100644 > --- a/app/test-pmd/csumonly.c > +++ b/app/test-pmd/csumonly.c > @@ -93,7 +93,6 @@ struct testpmd_offload_info { > uint16_t l3_len; > uint16_t l4_len; > uint8_t l4_proto; > - uint8_t l4_tun_len; > uint8_t is_tunnel; > uint16_t outer_ethertype; > uint16_t outer_l2_len; > @@ -191,6 +190,34 @@ parse_ethernet(struct ether_hdr *eth_hdr, struct > testpmd_offload_info *info) > } > } > > +/* Parse a vxlan header */ > +static void > +parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, > + uint64_t mbuf_olflags) > +{ > + struct ether_hdr *eth_hdr; > + > + /* check udp destination port, 4789 is the default vxlan port > + * (rfc7348) or that the rx offload flag is set (i40e only > + * currently) */ > + if (udp_hdr->dst_port != _htons(4789) && > + (mbuf_olflags & (PKT_RX_TUNNEL_IPV4_HDR | > + PKT_RX_TUNNEL_IPV6_HDR)) != 0) It seems that there is a bug, which is mbuf_olflags check. It should be (mbuf_olflags & (PKT_RX_TUNNEL_IPV4_HDR | PKT_RX_TUNNEL_IPV6_HDR)) == 0). > + return; > + > + info->is_tunnel = 1; > + info->outer_ethertype = info->ethertype; > + info->outer_l2_len = info->l2_len; > + info->outer_l3_len = info->l3_len; > + > + eth_hdr = (struct ether_hdr *)((char *)udp_hdr + > + sizeof(struct udp_hdr) + > + sizeof(struct vxlan_hdr)); > + > + parse_ethernet(eth_hdr, info); > + info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */ } > + > /* modify the IPv4 or IPv4 source address of a packet */ static void > change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -356,7 +383,6 > @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > struct rte_mbuf *m; > struct ether_hdr *eth_hdr; > void *l3_hdr = NULL, *outer_l3_hdr = NULL; /* can be IPv4 or IPv6 */ > - struct udp_hdr *udp_hdr; > uint16_t nb_rx; > uint16_t nb_tx; > uint16_t i; > @@ -414,33 +440,15 @@ pkt_burst_checksum_forward(struct fwd_stream > *fs) > /* check if it's a supported tunnel (only vxlan for now) */ > if ((testpmd_ol_flags & > TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && > info.l4_proto == IPPROTO_UDP) { > + struct udp_hdr *udp_hdr; > udp_hdr = (struct udp_hdr *)((char *)l3_hdr + > info.l3_len); > + parse_vxlan(udp_hdr, &info, m->ol_flags); > + } > > - /* check udp destination port, 4789 is the default > - * vxlan port (rfc7348) */ > - if (udp_hdr->dst_port == _htons(4789)) { > - info.l4_tun_len = ETHER_VXLAN_HLEN; > - info.is_tunnel = 1; > - > - /* currently, this flag is set by i40e only if the > - * packet is vxlan */ > - } else if (m->ol_flags & (PKT_RX_TUNNEL_IPV4_HDR > | > - PKT_RX_TUNNEL_IPV6_HDR)) > - info.is_tunnel = 1; > - > - if (info.is_tunnel == 1) { > - info.outer_ethertype = info.ethertype; > - info.outer_l2_len = info.l2_len; > - info.outer_l3_len = info.l3_len; > - outer_l3_hdr = l3_hdr; > - > - eth_hdr = (struct ether_hdr *)((char > *)udp_hdr + > - sizeof(struct udp_hdr) + > - sizeof(struct vxlan_hdr)); > - > - parse_ethernet(eth_hdr, &info); > - l3_hdr = (char *)eth_hdr + info.l2_len; > - } > + /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ > + if (info.is_tunnel) { > + outer_l3_hdr = l3_hdr; > + l3_hdr = (char *)l3_hdr + info.outer_l3_len + > info.l2_len; > } > > /* step 2: change all source IPs (v4 or v6) so we need @@ - > 472,7 +480,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > if (testpmd_ol_flags & > TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { > m->outer_l2_len = info.outer_l2_len; > m->outer_l3_len = info.outer_l3_len; > - m->l2_len = info.l4_tun_len + info.l2_len; > + m->l2_len = info.l2_len; > m->l3_len = info.l3_len; > } > else { > @@ -482,9 +490,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > the payload will be modified by the > hardware */ > m->l2_len = info.outer_l2_len + > - info.outer_l3_len + > - sizeof(struct udp_hdr) + > - sizeof(struct vxlan_hdr) + info.l2_len; > + info.outer_l3_len + info.l2_len; > m->l3_len = info.l3_len; > m->l4_len = info.l4_len; > } > -- > 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 13/20] testpmd: support gre tunnels in csum fwd engine 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (11 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 12/20] testpmd: introduce parse_vxlan " Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-02-02 3:04 ` Liu, Jijiang 2015-01-30 13:16 ` [dpdk-dev] [PATCH 14/20] testpmd: support ipip tunnel in csum forward engine Olivier Matz ` (7 subsequent siblings) 20 siblings, 1 reply; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev Add support for Ethernet over GRE and IP over GRE tunnels. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 6 ++-- app/test-pmd/csumonly.c | 87 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 84 insertions(+), 9 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 98f7a1c..aa5c178 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -321,9 +321,9 @@ static void cmd_help_long_parsed(void *parsed_result, " checksum with when transmitting a packet using the" " csum forward engine.\n" " ip|udp|tcp|sctp always concern the inner layer.\n" - " outer-ip concerns the outer IP layer (in" - " case the packet is recognized as a vxlan packet by" - " the forward engine)\n" + " outer-ip concerns the outer IP layer in" + " case the packet is recognized as a tunnel packet by" + " the forward engine (vxlan and gre are supported)\n" " Please check the NIC datasheet for HW limits.\n\n" "csum parse-tunnel (on|off) (tx_port_id)\n" diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 52af0e7..02c01f6 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -100,6 +100,12 @@ struct testpmd_offload_info { uint16_t tso_segsz; }; +/* simplified GRE header (flags must be 0) */ +struct simple_gre_hdr { + uint16_t flags; + uint16_t proto; +}; + static uint16_t get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags) { @@ -218,6 +224,60 @@ parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */ } +/* Parse a gre header */ +static void +parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) +{ + struct ether_hdr *eth_hdr; + struct ipv4_hdr *ipv4_hdr; + struct ipv6_hdr *ipv6_hdr; + + /* if flags != 0; it's not supported */ + if (gre_hdr->flags != 0) + return; + + if (gre_hdr->proto == _htons(ETHER_TYPE_IPv4)) { + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + ipv4_hdr = (struct ipv4_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + parse_ipv4(ipv4_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv4); + info->l2_len = 0; + + } else if (gre_hdr->proto == _htons(ETHER_TYPE_IPv6)) { + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + ipv6_hdr = (struct ipv6_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + info->ethertype = _htons(ETHER_TYPE_IPv6); + parse_ipv6(ipv6_hdr, info); + info->l2_len = 0; + + } else if (gre_hdr->proto == _htons(0x6558)) { /* ETH_P_TEB in linux */ + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + eth_hdr = (struct ether_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + parse_ethernet(eth_hdr, info); + } else + return; + + info->l2_len += sizeof(struct simple_gre_hdr); +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -368,6 +428,8 @@ uint16_t testpmd_ol_flags) * Ether / (vlan) / IP|IP6 / UDP|TCP|SCTP . * Ether / (vlan) / outer IP|IP6 / outer UDP / VxLAN / Ether / IP|IP6 / * UDP|TCP|SCTP + * Ether / (vlan) / outer IP|IP6 / GRE / Ether / IP|IP6 / UDP|TCP|SCTP + * Ether / (vlan) / outer IP|IP6 / GRE / IP|IP6 / UDP|TCP|SCTP * * The testpmd command line for this forward engine sets the flags * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control @@ -437,12 +499,25 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) parse_ethernet(eth_hdr, &info); l3_hdr = (char *)eth_hdr + info.l2_len; - /* check if it's a supported tunnel (only vxlan for now) */ - if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && - info.l4_proto == IPPROTO_UDP) { - struct udp_hdr *udp_hdr; - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info.l3_len); - parse_vxlan(udp_hdr, &info, m->ol_flags); + /* check if it's a supported tunnel */ + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) { + if (info.l4_proto == IPPROTO_UDP) { + struct udp_hdr *udp_hdr; + udp_hdr = (struct udp_hdr *)((char *)l3_hdr + + info.l3_len); + parse_vxlan(udp_hdr, &info, m->ol_flags); + } else if (info.l4_proto == IPPROTO_GRE) { + struct simple_gre_hdr *gre_hdr; + gre_hdr = (struct simple_gre_hdr *) + ((char *)l3_hdr + info.l3_len); + parse_gre(gre_hdr, &info); + } + } + info.l4_proto == IPPROTO_GRE) { + struct simple_gre_hdr *gre_hdr; + gre_hdr = (struct simple_gre_hdr *)((char *)l3_hdr + + info.l3_len); + parse_gre(gre_hdr, &info); } /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH 13/20] testpmd: support gre tunnels in csum fwd engine 2015-01-30 13:16 ` [dpdk-dev] [PATCH 13/20] testpmd: support gre tunnels " Olivier Matz @ 2015-02-02 3:04 ` Liu, Jijiang 0 siblings, 0 replies; 109+ messages in thread From: Liu, Jijiang @ 2015-02-02 3:04 UTC (permalink / raw) To: Olivier Matz; +Cc: dev Hi Olivier, > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Friday, January 30, 2015 9:16 PM > To: dev@dpdk.org > Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; olivier.matz@6wind.com > Subject: [PATCH 13/20] testpmd: support gre tunnels in csum fwd engine > > Add support for Ethernet over GRE and IP over GRE tunnels. > > Signed-off-by: Olivier Matz <olivier.matz@6wind.com> > --- > app/test-pmd/cmdline.c | 6 ++-- > app/test-pmd/csumonly.c | 87 > +++++++++++++++++++++++++++++++++++++++++++++---- > 2 files changed, 84 insertions(+), 9 deletions(-) > > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index > 98f7a1c..aa5c178 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -321,9 +321,9 @@ static void cmd_help_long_parsed(void > *parsed_result, > " checksum with when transmitting a packet using > the" > " csum forward engine.\n" > " ip|udp|tcp|sctp always concern the inner > layer.\n" > - " outer-ip concerns the outer IP layer (in" > - " case the packet is recognized as a vxlan packet by" > - " the forward engine)\n" > + " outer-ip concerns the outer IP layer in" > + " case the packet is recognized as a tunnel packet by" > + " the forward engine (vxlan and gre are > supported)\n" > " Please check the NIC datasheet for HW > limits.\n\n" > > "csum parse-tunnel (on|off) (tx_port_id)\n" > diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index > 52af0e7..02c01f6 100644 > --- a/app/test-pmd/csumonly.c > +++ b/app/test-pmd/csumonly.c > @@ -100,6 +100,12 @@ struct testpmd_offload_info { > uint16_t tso_segsz; > }; > > +/* simplified GRE header (flags must be 0) */ struct simple_gre_hdr { > + uint16_t flags; > + uint16_t proto; > +}; I suggest you to remove the comment ' flags must be 0',the reason is that we just use the header structure to check what the protocol is. It is not necessary to require the flag must be 0. > static uint16_t > get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags) { @@ - > 218,6 +224,60 @@ parse_vxlan(struct udp_hdr *udp_hdr, struct > testpmd_offload_info *info, > info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */ } > > +/* Parse a gre header */ > +static void > +parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info > +*info) { > + struct ether_hdr *eth_hdr; > + struct ipv4_hdr *ipv4_hdr; > + struct ipv6_hdr *ipv6_hdr; > + > + /* if flags != 0; it's not supported */ > + if (gre_hdr->flags != 0) > + return; I suggest you remove the check here, you can add some comments in front of this function to explain that actual NVGRE and IP over GRE is not supported now. For example, when I want to support NVGRE TX checksum offload, I will do the following change. Or you still keep it here, but anyway, I will change it later. > + > + if (gre_hdr->proto == _htons(ETHER_TYPE_IPv4)) { > + info->is_tunnel = 1; > + info->outer_ethertype = info->ethertype; > + info->outer_l2_len = info->l2_len; > + info->outer_l3_len = info->l3_len; > + > + ipv4_hdr = (struct ipv4_hdr *)((char *)gre_hdr + > + sizeof(struct simple_gre_hdr)); > + > + parse_ipv4(ipv4_hdr, info); > + info->ethertype = _htons(ETHER_TYPE_IPv4); > + info->l2_len = 0; > + > + } else if (gre_hdr->proto == _htons(ETHER_TYPE_IPv6)) { > + info->is_tunnel = 1; > + info->outer_ethertype = info->ethertype; > + info->outer_l2_len = info->l2_len; > + info->outer_l3_len = info->l3_len; > + > + ipv6_hdr = (struct ipv6_hdr *)((char *)gre_hdr + > + sizeof(struct simple_gre_hdr)); > + > + info->ethertype = _htons(ETHER_TYPE_IPv6); > + parse_ipv6(ipv6_hdr, info); > + info->l2_len = 0; > + > + } else if (gre_hdr->proto == _htons(0x6558)) { /* ETH_P_TEB in linux > */ > + info->is_tunnel = 1; > + info->outer_ethertype = info->ethertype; > + info->outer_l2_len = info->l2_len; > + info->outer_l3_len = info->l3_len; > + > + eth_hdr = (struct ether_hdr *)((char *)gre_hdr + > + sizeof(struct simple_gre_hdr)); For NVGRE: I will do some change here. eth_hdr = (struct ether_hdr *)((char *)gre_hdr + sizeof(struct nvgre_hdr)); // replace simple_gre_hdr with nvgre_hdr. > + parse_ethernet(eth_hdr, info); > + } else > + return; > + > + info->l2_len += sizeof(struct simple_gre_hdr); } > + > /* modify the IPv4 or IPv4 source address of a packet */ static void > change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -368,6 +428,8 > @@ uint16_t testpmd_ol_flags) > * Ether / (vlan) / IP|IP6 / UDP|TCP|SCTP . > * Ether / (vlan) / outer IP|IP6 / outer UDP / VxLAN / Ether / IP|IP6 / > * UDP|TCP|SCTP > + * Ether / (vlan) / outer IP|IP6 / GRE / Ether / IP|IP6 / UDP|TCP|SCTP > + * Ether / (vlan) / outer IP|IP6 / GRE / IP|IP6 / UDP|TCP|SCTP > * > * The testpmd command line for this forward engine sets the flags > * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control @@ > -437,12 +499,25 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > parse_ethernet(eth_hdr, &info); > l3_hdr = (char *)eth_hdr + info.l2_len; > > - /* check if it's a supported tunnel (only vxlan for now) */ > - if ((testpmd_ol_flags & > TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && > - info.l4_proto == IPPROTO_UDP) { > - struct udp_hdr *udp_hdr; > - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + > info.l3_len); > - parse_vxlan(udp_hdr, &info, m->ol_flags); > + /* check if it's a supported tunnel */ > + if (testpmd_ol_flags & > TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) { > + if (info.l4_proto == IPPROTO_UDP) { > + struct udp_hdr *udp_hdr; > + udp_hdr = (struct udp_hdr *)((char *)l3_hdr > + > + info.l3_len); > + parse_vxlan(udp_hdr, &info, m->ol_flags); > + } else if (info.l4_proto == IPPROTO_GRE) { > + struct simple_gre_hdr *gre_hdr; > + gre_hdr = (struct simple_gre_hdr *) > + ((char *)l3_hdr + info.l3_len); > + parse_gre(gre_hdr, &info); > + } > + } > + info.l4_proto == IPPROTO_GRE) { > + struct simple_gre_hdr *gre_hdr; > + gre_hdr = (struct simple_gre_hdr *)((char *)l3_hdr + > + info.l3_len); > + parse_gre(gre_hdr, &info); > } > > /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ > -- > 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 14/20] testpmd: support ipip tunnel in csum forward engine 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (12 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 13/20] testpmd: support gre tunnels " Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 15/20] ethdev: add outer IP offload capability flag Olivier Matz ` (6 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev Add support for IP over IP tunnels. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 2 +- app/test-pmd/csumonly.c | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index aa5c178..70ab126 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -323,7 +323,7 @@ static void cmd_help_long_parsed(void *parsed_result, " ip|udp|tcp|sctp always concern the inner layer.\n" " outer-ip concerns the outer IP layer in" " case the packet is recognized as a tunnel packet by" - " the forward engine (vxlan and gre are supported)\n" + " the forward engine (vxlan, gre and ipip are supported)\n" " Please check the NIC datasheet for HW limits.\n\n" "csum parse-tunnel (on|off) (tx_port_id)\n" diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 02c01f6..407e3b3 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -278,6 +278,35 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) info->l2_len += sizeof(struct simple_gre_hdr); } + +/* Parse an encapsulated ip or ipv6 header */ +static void +parse_encap_ip(void *encap_ip, struct testpmd_offload_info *info) +{ + struct ipv4_hdr *ipv4_hdr = encap_ip; + struct ipv6_hdr *ipv6_hdr = encap_ip; + uint8_t ip_version; + + ip_version = (ipv4_hdr->version_ihl & 0xf0) >> 4; + + if (ip_version != 4 && ip_version != 6) + return; + + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + if (ip_version == 4) { + parse_ipv4(ipv4_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv4); + } else { + parse_ipv6(ipv6_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv6); + } + info->l2_len = 0; +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -430,6 +459,7 @@ uint16_t testpmd_ol_flags) * UDP|TCP|SCTP * Ether / (vlan) / outer IP|IP6 / GRE / Ether / IP|IP6 / UDP|TCP|SCTP * Ether / (vlan) / outer IP|IP6 / GRE / IP|IP6 / UDP|TCP|SCTP + * Ether / (vlan) / outer IP|IP6 / IP|IP6 / UDP|TCP|SCTP * * The testpmd command line for this forward engine sets the flags * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control @@ -511,14 +541,12 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) gre_hdr = (struct simple_gre_hdr *) ((char *)l3_hdr + info.l3_len); parse_gre(gre_hdr, &info); + } else if (info.l4_proto == IPPROTO_IPIP) { + void *encap_ip_hdr; + encap_ip_hdr = (char *)l3_hdr + info.l3_len; + parse_encap_ip(encap_ip_hdr, &info); } } - info.l4_proto == IPPROTO_GRE) { - struct simple_gre_hdr *gre_hdr; - gre_hdr = (struct simple_gre_hdr *)((char *)l3_hdr + - info.l3_len); - parse_gre(gre_hdr, &info); - } /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ if (info.is_tunnel) { -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 15/20] ethdev: add outer IP offload capability flag 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (13 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 14/20] testpmd: support ipip tunnel in csum forward engine Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 16/20] i40e: advertise outer IPv4 checksum capability Olivier Matz ` (5 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev From: Jijiang Liu <jijiang.liu@intel.com> If the flag is advertised by a PMD, the NIC supports the outer IP checksum TX offload of tunneling packets, therefore an application can set the PKT_TX_OUTER_IP_CKSUM flag in mbufs when transmitting on this port. Signed-off-by: Jijiang Liu <jijiang.liu@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_ether/rte_ethdev.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 1200c1c..84160c3 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -916,6 +916,7 @@ struct rte_eth_conf { #define DEV_TX_OFFLOAD_SCTP_CKSUM 0x00000010 #define DEV_TX_OFFLOAD_TCP_TSO 0x00000020 #define DEV_TX_OFFLOAD_UDP_TSO 0x00000040 +#define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080 /**< Used for tunneling packet. */ struct rte_eth_dev_info { struct rte_pci_device *pci_dev; /**< Device PCI information. */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 16/20] i40e: advertise outer IPv4 checksum capability 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (14 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 15/20] ethdev: add outer IP offload capability flag Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 17/20] testpmd: add a warning if outer ip cksum requested but not supported Olivier Matz ` (4 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev From: Jijiang Liu <jijiang.liu@intel.com> Advertise the DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM flag in the PMD features. It means that the i40e PMD supports the offload of outer IP checksum when transmitting tunneling packet. Signed-off-by: Jijiang Liu <jijiang.liu@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c b/lib/librte_pmd_i40e/i40e_ethdev.c index b47a3d2..2244495 100644 --- a/lib/librte_pmd_i40e/i40e_ethdev.c +++ b/lib/librte_pmd_i40e/i40e_ethdev.c @@ -1516,7 +1516,8 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) DEV_TX_OFFLOAD_IPV4_CKSUM | DEV_TX_OFFLOAD_UDP_CKSUM | DEV_TX_OFFLOAD_TCP_CKSUM | - DEV_TX_OFFLOAD_SCTP_CKSUM; + DEV_TX_OFFLOAD_SCTP_CKSUM | + DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; dev_info->reta_size = pf->hash_lut_size; dev_info->default_rxconf = (struct rte_eth_rxconf) { -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 17/20] testpmd: add a warning if outer ip cksum requested but not supported 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (15 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 16/20] i40e: advertise outer IPv4 checksum capability Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 18/20] testpmd: fix TSO when using outer checksum offloads Olivier Matz ` (3 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 70ab126..186da7b 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2914,7 +2914,11 @@ csum_show(int port_id) printf("Warning: hardware SCTP checksum enabled but not " "supported by port %d\n", port_id); } - + if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { + printf("Warning: hardware outer IP checksum enabled but not " + "supported by port %d\n", port_id); + } } static void -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 18/20] testpmd: fix TSO when using outer checksum offloads 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (16 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 17/20] testpmd: add a warning if outer ip cksum requested but not supported Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 19/20] i40e: fix offloading of outer checksum for ip in ip tunnels Olivier Matz ` (2 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev The l4_len has also to be copied in mbuf in case we are offloading outer IP checksum. Currently, TSO + outer checksum is not supported by any driver but it will soon be supported by i40e. Pointed-out-by: Jijiang Liu <jijiang.liu@intel.com> Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 1 + 1 file changed, 1 insertion(+) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 407e3b3..56dd2f3 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -585,6 +585,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) m->outer_l3_len = info.outer_l3_len; m->l2_len = info.l2_len; m->l3_len = info.l3_len; + m->l4_len = info.l4_len; } else { /* if there is a outer UDP cksum -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 19/20] i40e: fix offloading of outer checksum for ip in ip tunnels 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (17 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 18/20] testpmd: fix TSO when using outer checksum offloads Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 20/20] i40e: add debug logs for tx context descriptors Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev When offloading the checksums of ipip tunnels, m->l2_len is set to 0 as there is no tunnel or inner l2 header. Since this is a valid value remove the test. By the way, also remove the same test with l3_len because at this point, it is expected that the software provides proper values in the mbuf. It should avoid a test in dataplane processing and therefore slightly increase performance. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_rxtx.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 0786255..3031bd7 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -471,16 +471,6 @@ i40e_txd_enable_checksum(uint64_t ol_flags, uint16_t outer_l3_len, uint32_t *cd_tunneling) { - if (!l2_len) { - PMD_DRV_LOG(DEBUG, "L2 length set to 0"); - return; - } - - if (!l3_len) { - PMD_DRV_LOG(DEBUG, "L3 length set to 0"); - return; - } - /* UDP tunneling packet TX checksum offload */ if (unlikely(ol_flags & PKT_TX_OUTER_IP_CKSUM)) { -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH 20/20] i40e: add debug logs for tx context descriptors 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (18 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 19/20] i40e: fix offloading of outer checksum for ip in ip tunnels Olivier Matz @ 2015-01-30 13:16 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-01-30 13:16 UTC (permalink / raw) To: dev This could be useful to have this values for debug purposes. Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com> Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_rxtx.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 3031bd7..349c1e5 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -1298,6 +1298,18 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) ctx_txd->l2tag2 = rte_cpu_to_le_16(cd_l2tag2); ctx_txd->type_cmd_tso_mss = rte_cpu_to_le_64(cd_type_cmd_tso_mss); + + PMD_TX_LOG(DEBUG, "mbuf: %p, TCD[%u]:\n" + "tunneling_params: %#x;\n" + "l2tag2: %#hx;\n" + "rsvd: %#hx;\n" + "type_cmd_tso_mss: %#lx;\n", + tx_pkt, tx_id, + ctx_txd->tunneling_params, + ctx_txd->l2tag2, + ctx_txd->rsvd, + ctx_txd->type_cmd_tso_mss); + txe->last_id = tx_last; tx_id = txe->next_id; txe = txn; @@ -1315,6 +1327,16 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) /* Setup TX Descriptor */ slen = m_seg->data_len; buf_dma_addr = RTE_MBUF_DATA_DMA_ADDR(m_seg); + + PMD_TX_LOG(DEBUG, "mbuf: %p, TDD[%u]:\n" + "buf_dma_addr: %#"PRIx64";\n" + "td_cmd: %#x;\n" + "td_offset: %#x;\n" + "td_len: %u;\n" + "td_tag: %#x;\n", + tx_pkt, tx_id, buf_dma_addr, + td_cmd, td_offset, slen, td_tag); + txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr); txd->cmd_type_offset_bsz = i40e_build_ctob(td_cmd, td_offset, slen, td_tag); -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz ` (19 preceding siblings ...) 2015-01-30 13:16 ` [dpdk-dev] [PATCH 20/20] i40e: add debug logs for tx context descriptors Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 01/20] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz ` (21 more replies) 20 siblings, 22 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev The goal of this series is to clarify and simplify the mbuf offload API. - simplify the definitions of PKT_TX_IP_CKSUM and PKT_TX_IPV4, each flag has now only one meaning. No impact on the code. - add a feature flag for OUTER_IP_CHECKSUM (from Jijiang's patches) - remove the PKT_TX_UDP_TUNNEL_PKT flag: it is useless from an API point of view. It was added because i40e need this info for some reason. We have 3 solutions: - remove the flag and adapt the driver to the API (the choice I made for this series). - remove the flag and stop advertising OUTER_IP_CHECKSUM in i40e - keep this flag, penalizing performance of drivers that do not require the flag. It would also mean that drivers won't support outer IP checksum for all tunnel types, but only for the tunnel types having a flag. - a side effect of this API clarification is that there is only one way for doing one operation. If the hardware has several ways to do the same operation, a choice has to be made in the driver. The series also provide some enhancements and fixes related to this API rework: - new tunnel types to testpmd csum forward engine. - fixes in i40e to adapt to new api and support more tunnel types. [1] http://dpdk.org/ml/archives/dev/2015-January/011127.html Changes in v2: - fix test of rx offload flag in parse_vlan() pointed out by Jijiang Jijiang Liu (2): ethdev: add outer IP offload capability flag i40e: advertise outer IPv4 checksum capability Olivier Matz (18): mbuf: remove PKT_TX_IPV4_CSUM mbuf: enhance the API documentation of offload flags i40e: call i40e_txd_enable_checksum only for offloaded packets i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag testpmd: replace tx_checksum command by csum testpmd: move csum_show in a function testpmd: add csum parse_tunnel command testpmd: rename vxlan in outer_ip in csum commands testpmd: introduce parse_ipv* in csum fwd engine testpmd: use a structure to store offload info in csum fwd engine testpmd: introduce parse_vxlan in csum fwd engine testpmd: support gre tunnels in csum fwd engine testpmd: support ipip tunnel in csum forward engine testpmd: add a warning if outer ip cksum requested but not supported testpmd: fix TSO when using outer checksum offloads i40e: fix offloading of outer checksum for ip in ip tunnels i40e: add debug logs for tx context descriptors app/test-pmd/cmdline.c | 234 ++++++++++++++------- app/test-pmd/csumonly.c | 417 +++++++++++++++++++++++++------------- app/test-pmd/testpmd.h | 9 +- lib/librte_ether/rte_ethdev.h | 1 + lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 49 +++-- lib/librte_pmd_i40e/i40e_ethdev.c | 3 +- lib/librte_pmd_i40e/i40e_rxtx.c | 55 +++-- 8 files changed, 519 insertions(+), 250 deletions(-) -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 01/20] mbuf: remove PKT_TX_IPV4_CSUM 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 02/20] mbuf: enhance the API documentation of offload flags Olivier Matz ` (20 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev This alias is only used in one place of i40e driver. Remove it and only keep the legacy flag PKT_TX_IP_CSUM. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_mbuf/rte_mbuf.h | 1 - lib/librte_pmd_i40e/i40e_rxtx.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 16059c6..a554247 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -142,7 +142,6 @@ extern "C" { #define PKT_TX_L4_MASK (3ULL << 52) /**< Mask for L4 cksum offload request. */ #define PKT_TX_IP_CKSUM (1ULL << 54) /**< IP cksum of TX pkt. computed by NIC. */ -#define PKT_TX_IPV4_CSUM PKT_TX_IP_CKSUM /**< Alias of PKT_TX_IP_CKSUM. */ /** Packet is IPv4 without requiring IP checksum offload. */ #define PKT_TX_IPV4 (1ULL << 55) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 2beae3c..8e9df96 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -501,7 +501,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags, << I40E_TX_DESC_LENGTH_MACLEN_SHIFT; /* Enable L3 checksum offloads */ - if (ol_flags & PKT_TX_IPV4_CSUM) { + if (ol_flags & PKT_TX_IP_CKSUM) { *td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM; *td_offset |= (l3_len >> 2) << I40E_TX_DESC_LENGTH_IPLEN_SHIFT; } else if (ol_flags & PKT_TX_IPV4) { -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 02/20] mbuf: enhance the API documentation of offload flags 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 01/20] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-10 5:38 ` Zhang, Helin 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets Olivier Matz ` (19 subsequent siblings) 21 siblings, 1 reply; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev Based on http://dpdk.org/ml/archives/dev/2015-January/011127.html Also adapt the csum forward engine code to the API. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 6 +++--- lib/librte_mbuf/rte_mbuf.h | 43 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 41711fd..4b438d1 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -183,16 +183,15 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, ipv4_hdr = l3_hdr; ipv4_hdr->hdr_checksum = 0; + ol_flags |= PKT_TX_IPV4; if (tso_segsz != 0 && l4_proto == IPPROTO_TCP) { ol_flags |= PKT_TX_IP_CKSUM; } else { if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ol_flags |= PKT_TX_IP_CKSUM; - else { + else ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); - ol_flags |= PKT_TX_IPV4; - } } } else if (ethertype == _htons(ETHER_TYPE_IPv6)) ol_flags |= PKT_TX_IPV6; @@ -261,6 +260,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr->hdr_checksum = 0; + ol_flags |= PKT_TX_OUTER_IPV4; if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ol_flags |= PKT_TX_OUTER_IP_CKSUM; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index a554247..191a42c 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -141,24 +141,53 @@ extern "C" { #define PKT_TX_UDP_CKSUM (3ULL << 52) /**< UDP cksum of TX pkt. computed by NIC. */ #define PKT_TX_L4_MASK (3ULL << 52) /**< Mask for L4 cksum offload request. */ -#define PKT_TX_IP_CKSUM (1ULL << 54) /**< IP cksum of TX pkt. computed by NIC. */ +/** + * Offload the IP checksum in the hardware. The flag PKT_TX_IPV4 should + * also be set by the application, altough a PMD will only check + * PKT_TX_IP_CKSUM. + * - set the IP checksum field in the packet to 0 + * - fill the mbuf offload information: l2_len, l3_len + */ +#define PKT_TX_IP_CKSUM (1ULL << 54) -/** Packet is IPv4 without requiring IP checksum offload. */ +/** + * Packet is IPv4. This flag must be set when using any offload feature + * (TSO, L3 or L4 checksum) to tell the NIC that the packet is an IPv4 + * packet. + */ #define PKT_TX_IPV4 (1ULL << 55) -/** Tell the NIC it's an IPv6 packet.*/ +/** + * Packet is IPv6. This flag must be set when using an offload feature + * (TSO or L4 checksum) to tell the NIC that the packet is an IPv6 + * packet. + */ #define PKT_TX_IPV6 (1ULL << 56) #define PKT_TX_VLAN_PKT (1ULL << 57) /**< TX packet is a 802.1q VLAN packet. */ -/** Outer IP checksum of TX packet, computed by NIC for tunneling packet. - * The tunnel type must also be specified, ex: PKT_TX_UDP_TUNNEL_PKT. */ +/** + * Offload the IP checksum of an external header in the hardware. The + * flag PKT_TX_OUTER_IPV4 should also be set by the application, altough + * a PMD will only check PKT_TX_IP_CKSUM. The IP checksum field in the + * packet must be set to 0. + * - set the outer IP checksum field in the packet to 0 + * - fill the mbuf offload information: outer_l2_len, outer_l3_len + */ #define PKT_TX_OUTER_IP_CKSUM (1ULL << 58) -/** Packet is outer IPv4 without requiring IP checksum offload for tunneling packet. */ +/** + * Packet outer header is IPv4. This flag must be set when using any + * outer offload feature (L3 or L4 checksum) to tell the NIC that the + * packet is an IPv4 packet. + */ #define PKT_TX_OUTER_IPV4 (1ULL << 59) -/** Tell the NIC it's an outer IPv6 packet for tunneling packet */ +/** + * Packet outer header is IPv6. This flag must be set when using any + * outer offload feature (L4 checksum) to tell the NIC that the packet + * is an IPv6 packet. + */ #define PKT_TX_OUTER_IPV6 (1ULL << 60) /* Use final bit of flags to indicate a control mbuf */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v2 02/20] mbuf: enhance the API documentation of offload flags 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 02/20] mbuf: enhance the API documentation of offload flags Olivier Matz @ 2015-02-10 5:38 ` Zhang, Helin 2015-02-10 16:54 ` Olivier MATZ 2015-02-11 7:15 ` Liu, Jijiang 0 siblings, 2 replies; 109+ messages in thread From: Zhang, Helin @ 2015-02-10 5:38 UTC (permalink / raw) To: Olivier Matz, dev > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Wednesday, February 4, 2015 5:25 PM > To: dev@dpdk.org > Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; olivier.matz@6wind.com > Subject: [PATCH v2 02/20] mbuf: enhance the API documentation of offload > flags > > Based on http://dpdk.org/ml/archives/dev/2015-January/011127.html > > Also adapt the csum forward engine code to the API. > > Signed-off-by: Olivier Matz <olivier.matz@6wind.com> > --- > app/test-pmd/csumonly.c | 6 +++--- > lib/librte_mbuf/rte_mbuf.h | 43 > ++++++++++++++++++++++++++++++++++++------- > 2 files changed, 39 insertions(+), 10 deletions(-) > > diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index > 41711fd..4b438d1 100644 > --- a/app/test-pmd/csumonly.c > +++ b/app/test-pmd/csumonly.c > @@ -183,16 +183,15 @@ process_inner_cksums(void *l3_hdr, uint16_t > ethertype, uint16_t l3_len, > ipv4_hdr = l3_hdr; > ipv4_hdr->hdr_checksum = 0; > > + ol_flags |= PKT_TX_IPV4; > if (tso_segsz != 0 && l4_proto == IPPROTO_TCP) { > ol_flags |= PKT_TX_IP_CKSUM; > } else { > if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) > ol_flags |= PKT_TX_IP_CKSUM; > - else { > + else > ipv4_hdr->hdr_checksum = > rte_ipv4_cksum(ipv4_hdr); > - ol_flags |= PKT_TX_IPV4; > - } > } > } else if (ethertype == _htons(ETHER_TYPE_IPv6)) > ol_flags |= PKT_TX_IPV6; > @@ -261,6 +260,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t > outer_ethertype, > > if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { > ipv4_hdr->hdr_checksum = 0; > + ol_flags |= PKT_TX_OUTER_IPV4; > > if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) > ol_flags |= PKT_TX_OUTER_IP_CKSUM; > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index > a554247..191a42c 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -141,24 +141,53 @@ extern "C" { > #define PKT_TX_UDP_CKSUM (3ULL << 52) /**< UDP cksum of TX pkt. > computed by NIC. */ > #define PKT_TX_L4_MASK (3ULL << 52) /**< Mask for L4 cksum > offload request. */ > > -#define PKT_TX_IP_CKSUM (1ULL << 54) /**< IP cksum of TX pkt. > computed by NIC. */ > +/** > + * Offload the IP checksum in the hardware. The flag PKT_TX_IPV4 should > + * also be set by the application, altough a PMD will only check > + * PKT_TX_IP_CKSUM. > + * - set the IP checksum field in the packet to 0 > + * - fill the mbuf offload information: l2_len, l3_len */ > +#define PKT_TX_IP_CKSUM (1ULL << 54) > > -/** Packet is IPv4 without requiring IP checksum offload. */ > +/** > + * Packet is IPv4. This flag must be set when using any offload feature > + * (TSO, L3 or L4 checksum) to tell the NIC that the packet is an IPv4 > + * packet. > + */ > #define PKT_TX_IPV4 (1ULL << 55) > > -/** Tell the NIC it's an IPv6 packet.*/ > +/** > + * Packet is IPv6. This flag must be set when using an offload feature > + * (TSO or L4 checksum) to tell the NIC that the packet is an IPv6 > + * packet. > + */ > #define PKT_TX_IPV6 (1ULL << 56) Above two macro for IPV4/IPV6 will be used for inner L3 for tunneling case, right? If yes, the annotations may need to mention that, to avoid confusing end users. Regards, Helin > > #define PKT_TX_VLAN_PKT (1ULL << 57) /**< TX packet is a 802.1q > VLAN packet. */ > > -/** Outer IP checksum of TX packet, computed by NIC for tunneling packet. > - * The tunnel type must also be specified, ex: PKT_TX_UDP_TUNNEL_PKT. */ > +/** > + * Offload the IP checksum of an external header in the hardware. The > + * flag PKT_TX_OUTER_IPV4 should also be set by the application, > +altough > + * a PMD will only check PKT_TX_IP_CKSUM. The IP checksum field in the > + * packet must be set to 0. > + * - set the outer IP checksum field in the packet to 0 > + * - fill the mbuf offload information: outer_l2_len, outer_l3_len */ > #define PKT_TX_OUTER_IP_CKSUM (1ULL << 58) > > -/** Packet is outer IPv4 without requiring IP checksum offload for tunneling > packet. */ > +/** > + * Packet outer header is IPv4. This flag must be set when using any > + * outer offload feature (L3 or L4 checksum) to tell the NIC that the > + * packet is an IPv4 packet. > + */ > #define PKT_TX_OUTER_IPV4 (1ULL << 59) > > -/** Tell the NIC it's an outer IPv6 packet for tunneling packet */ > +/** > + * Packet outer header is IPv6. This flag must be set when using any > + * outer offload feature (L4 checksum) to tell the NIC that the packet > + * is an IPv6 packet. > + */ > #define PKT_TX_OUTER_IPV6 (1ULL << 60) > > /* Use final bit of flags to indicate a control mbuf */ > -- > 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v2 02/20] mbuf: enhance the API documentation of offload flags 2015-02-10 5:38 ` Zhang, Helin @ 2015-02-10 16:54 ` Olivier MATZ 2015-02-11 7:15 ` Liu, Jijiang 1 sibling, 0 replies; 109+ messages in thread From: Olivier MATZ @ 2015-02-10 16:54 UTC (permalink / raw) To: Zhang, Helin, dev Hi Helin, On 02/10/2015 06:38 AM, Zhang, Helin wrote: >> -/** Packet is IPv4 without requiring IP checksum offload. */ >> +/** >> + * Packet is IPv4. This flag must be set when using any offload feature >> + * (TSO, L3 or L4 checksum) to tell the NIC that the packet is an IPv4 >> + * packet. >> + */ >> #define PKT_TX_IPV4 (1ULL << 55) >> >> -/** Tell the NIC it's an IPv6 packet.*/ >> +/** >> + * Packet is IPv6. This flag must be set when using an offload feature >> + * (TSO or L4 checksum) to tell the NIC that the packet is an IPv6 >> + * packet. >> + */ >> #define PKT_TX_IPV6 (1ULL << 56) > Above two macro for IPV4/IPV6 will be used for inner L3 for tunneling case, right? > If yes, the annotations may need to mention that, to avoid confusing end users. That's right, I'll clarify this in a next version. Thanks Olivier ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v2 02/20] mbuf: enhance the API documentation of offload flags 2015-02-10 5:38 ` Zhang, Helin 2015-02-10 16:54 ` Olivier MATZ @ 2015-02-11 7:15 ` Liu, Jijiang 2015-02-11 15:15 ` Olivier MATZ 1 sibling, 1 reply; 109+ messages in thread From: Liu, Jijiang @ 2015-02-11 7:15 UTC (permalink / raw) To: Olivier Matz; +Cc: dev Hi Olivier, > -----Original Message----- > From: Zhang, Helin > Sent: Tuesday, February 10, 2015 1:39 PM > To: Olivier Matz; dev@dpdk.org > Cc: Ananyev, Konstantin; Liu, Jijiang > Subject: RE: [PATCH v2 02/20] mbuf: enhance the API documentation of offload > flags > > > > > -----Original Message----- > > From: Olivier Matz [mailto:olivier.matz@6wind.com] > > Sent: Wednesday, February 4, 2015 5:25 PM > > To: dev@dpdk.org > > Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; > > olivier.matz@6wind.com > > Subject: [PATCH v2 02/20] mbuf: enhance the API documentation of > > offload flags > > > > Based on http://dpdk.org/ml/archives/dev/2015-January/011127.html > > > > Also adapt the csum forward engine code to the API. > > > > Signed-off-by: Olivier Matz <olivier.matz@6wind.com> > > --- > > app/test-pmd/csumonly.c | 6 +++--- > > lib/librte_mbuf/rte_mbuf.h | 43 > > ++++++++++++++++++++++++++++++++++++------- > > 2 files changed, 39 insertions(+), 10 deletions(-) > > > > diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index > > 41711fd..4b438d1 100644 > > --- a/app/test-pmd/csumonly.c > > +++ b/app/test-pmd/csumonly.c > > @@ -183,16 +183,15 @@ process_inner_cksums(void *l3_hdr, uint16_t > > ethertype, uint16_t l3_len, > > ipv4_hdr = l3_hdr; > > ipv4_hdr->hdr_checksum = 0; > > > > + ol_flags |= PKT_TX_IPV4; > > if (tso_segsz != 0 && l4_proto == IPPROTO_TCP) { > > ol_flags |= PKT_TX_IP_CKSUM; > > } else { > > if (testpmd_ol_flags & > TESTPMD_TX_OFFLOAD_IP_CKSUM) > > ol_flags |= PKT_TX_IP_CKSUM; > > - else { > > + else > > ipv4_hdr->hdr_checksum = > > rte_ipv4_cksum(ipv4_hdr); > > - ol_flags |= PKT_TX_IPV4; > > - } > > } > > } else if (ethertype == _htons(ETHER_TYPE_IPv6)) > > ol_flags |= PKT_TX_IPV6; > > @@ -261,6 +260,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t > > outer_ethertype, > > > > if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { > > ipv4_hdr->hdr_checksum = 0; > > + ol_flags |= PKT_TX_OUTER_IPV4; > > Look at the codes again, you should extend process_outer_cksums() to support other tunneling packet. The code changes like below, process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, uint16_t testpmd_ol_flags, uint16_t l4_proto) // add the l4_proto parameter here. ... /* outer UDP checksum is always done in software as we have no * hardware supporting it today, and no API for it. */ if (l4_proto == IPPROTO_UDP) udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + info->outer_l3_len); /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { udp_hdr->dgram_cksum = 0; if (info->outer_ethertype == _htons(ETHER_TYPE_IPv4)) udp_hdr->dgram_cksum = rte_ipv4_udptcp_cksum(ipv4_hdr, udp_hdr); else udp_hdr->dgram_cksum = rte_ipv6_udptcp_cksum(ipv6_hdr, udp_hdr); } } // nothing need to do for GRE tunneling packet now } > > if (testpmd_ol_flags & > TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) > > ol_flags |= PKT_TX_OUTER_IP_CKSUM; diff --git > > a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index > > a554247..191a42c 100644 > > --- a/lib/librte_mbuf/rte_mbuf.h > > +++ b/lib/librte_mbuf/rte_mbuf.h > > @@ -141,24 +141,53 @@ extern "C" { > > #define PKT_TX_UDP_CKSUM (3ULL << 52) /**< UDP cksum of TX pkt. > > computed by NIC. */ > > #define PKT_TX_L4_MASK (3ULL << 52) /**< Mask for L4 cksum > > offload request. */ > > > > -#define PKT_TX_IP_CKSUM (1ULL << 54) /**< IP cksum of TX pkt. > > computed by NIC. */ > > +/** > > + * Offload the IP checksum in the hardware. The flag PKT_TX_IPV4 > > +should > > + * also be set by the application, altough a PMD will only check > > + * PKT_TX_IP_CKSUM. > > + * - set the IP checksum field in the packet to 0 > > + * - fill the mbuf offload information: l2_len, l3_len */ > > +#define PKT_TX_IP_CKSUM (1ULL << 54) > > > > -/** Packet is IPv4 without requiring IP checksum offload. */ > > +/** > > + * Packet is IPv4. This flag must be set when using any offload > > +feature > > + * (TSO, L3 or L4 checksum) to tell the NIC that the packet is an > > +IPv4 > > + * packet. > > + */ > > #define PKT_TX_IPV4 (1ULL << 55) > > > > -/** Tell the NIC it's an IPv6 packet.*/ > > +/** > > + * Packet is IPv6. This flag must be set when using an offload > > +feature > > + * (TSO or L4 checksum) to tell the NIC that the packet is an IPv6 > > + * packet. > > + */ > > #define PKT_TX_IPV6 (1ULL << 56) > Above two macro for IPV4/IPV6 will be used for inner L3 for tunneling case, > right? > If yes, the annotations may need to mention that, to avoid confusing end users. > > Regards, > Helin > > > > > #define PKT_TX_VLAN_PKT (1ULL << 57) /**< TX packet is a 802.1q > > VLAN packet. */ > > > > -/** Outer IP checksum of TX packet, computed by NIC for tunneling packet. > > - * The tunnel type must also be specified, ex: > > PKT_TX_UDP_TUNNEL_PKT. */ > > +/** > > + * Offload the IP checksum of an external header in the hardware. The > > + * flag PKT_TX_OUTER_IPV4 should also be set by the application, > > +altough > > + * a PMD will only check PKT_TX_IP_CKSUM. The IP checksum field in > > +the > > + * packet must be set to 0. > > + * - set the outer IP checksum field in the packet to 0 > > + * - fill the mbuf offload information: outer_l2_len, outer_l3_len > > +*/ > > #define PKT_TX_OUTER_IP_CKSUM (1ULL << 58) > > > > -/** Packet is outer IPv4 without requiring IP checksum offload for > > tunneling packet. */ > > +/** > > + * Packet outer header is IPv4. This flag must be set when using any > > + * outer offload feature (L3 or L4 checksum) to tell the NIC that the > > + * packet is an IPv4 packet. > > + */ > > #define PKT_TX_OUTER_IPV4 (1ULL << 59) > > > > -/** Tell the NIC it's an outer IPv6 packet for tunneling packet */ > > +/** > > + * Packet outer header is IPv6. This flag must be set when using any > > + * outer offload feature (L4 checksum) to tell the NIC that the > > +packet > > + * is an IPv6 packet. > > + */ > > #define PKT_TX_OUTER_IPV6 (1ULL << 60) > > > > /* Use final bit of flags to indicate a control mbuf */ > > -- > > 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v2 02/20] mbuf: enhance the API documentation of offload flags 2015-02-11 7:15 ` Liu, Jijiang @ 2015-02-11 15:15 ` Olivier MATZ 0 siblings, 0 replies; 109+ messages in thread From: Olivier MATZ @ 2015-02-11 15:15 UTC (permalink / raw) To: Liu, Jijiang; +Cc: dev Hi Jijiang, On 02/11/2015 08:15 AM, Liu, Jijiang wrote: >>> diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index >>> 41711fd..4b438d1 100644 >>> --- a/app/test-pmd/csumonly.c >>> +++ b/app/test-pmd/csumonly.c >>> @@ -183,16 +183,15 @@ process_inner_cksums(void *l3_hdr, uint16_t >>> ethertype, uint16_t l3_len, >>> ipv4_hdr = l3_hdr; >>> ipv4_hdr->hdr_checksum = 0; >>> >>> + ol_flags |= PKT_TX_IPV4; >>> if (tso_segsz != 0 && l4_proto == IPPROTO_TCP) { >>> ol_flags |= PKT_TX_IP_CKSUM; >>> } else { >>> if (testpmd_ol_flags & >> TESTPMD_TX_OFFLOAD_IP_CKSUM) >>> ol_flags |= PKT_TX_IP_CKSUM; >>> - else { >>> + else >>> ipv4_hdr->hdr_checksum = >>> rte_ipv4_cksum(ipv4_hdr); >>> - ol_flags |= PKT_TX_IPV4; >>> - } >>> } >>> } else if (ethertype == _htons(ETHER_TYPE_IPv6)) >>> ol_flags |= PKT_TX_IPV6; >>> @@ -261,6 +260,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t >>> outer_ethertype, >>> >>> if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { >>> ipv4_hdr->hdr_checksum = 0; >>> + ol_flags |= PKT_TX_OUTER_IPV4; >>> > > Look at the codes again, you should extend process_outer_cksums() to support other tunneling packet. > > The code changes like below, > process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, > uint16_t testpmd_ol_flags, uint16_t l4_proto) // add the l4_proto parameter here. > ... > /* outer UDP checksum is always done in software as we have no > * hardware supporting it today, and no API for it. */ > if (l4_proto == IPPROTO_UDP) > udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + info->outer_l3_len); > /* do not recalculate udp cksum if it was 0 */ > if (udp_hdr->dgram_cksum != 0) { > udp_hdr->dgram_cksum = 0; > if (info->outer_ethertype == _htons(ETHER_TYPE_IPv4)) > udp_hdr->dgram_cksum = > rte_ipv4_udptcp_cksum(ipv4_hdr, udp_hdr); > else > udp_hdr->dgram_cksum = > rte_ipv6_udptcp_cksum(ipv6_hdr, udp_hdr); > } > } // nothing need to do for GRE tunneling packet now > } That's correct, I'll update the code accordingly. Thanks, Olivier ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 01/20] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 02/20] mbuf: enhance the API documentation of offload flags Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-10 6:03 ` Zhang, Helin 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag Olivier Matz ` (18 subsequent siblings) 21 siblings, 1 reply; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev >From i40e datasheet: The IP header type and its offload. In case of tunneling, the IIPT relates to the inner IP header. See also EIPT field for the outer (External) IP header offload. 00 - non IP packet or packet type is not defined by software 01 - IPv6 packet 10 - IPv4 packet with no IP checksum offload 11 - IPv4 packet with IP checksum offload Therefore it is not needed to fill the IIPT field if no offload is requested (we can keep the value to 00). For instance, the linux driver code does not set it when (skb->ip_summed != CHECKSUM_PARTIAL). We can do the same in the dpdk driver. The function i40e_txd_enable_checksum() that fills the offload registers can only be called for packets requiring an offload. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_rxtx.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 8e9df96..9acdeee 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -74,6 +74,11 @@ #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS) +#define I40E_TX_CKSUM_OFFLOAD_MASK ( \ + PKT_TX_IP_CKSUM | \ + PKT_TX_L4_MASK | \ + PKT_TX_OUTER_IP_CKSUM) + #define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \ (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM) @@ -1272,10 +1277,12 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) /* Enable checksum offloading */ cd_tunneling_params = 0; - i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, - l2_len, l3_len, outer_l2_len, - outer_l3_len, - &cd_tunneling_params); + if (ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK) { + i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, + l2_len, l3_len, outer_l2_len, + outer_l3_len, + &cd_tunneling_params); + } if (unlikely(nb_ctx)) { /* Setup TX context descriptor if required */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets Olivier Matz @ 2015-02-10 6:03 ` Zhang, Helin 2015-02-10 17:06 ` Olivier MATZ 0 siblings, 1 reply; 109+ messages in thread From: Zhang, Helin @ 2015-02-10 6:03 UTC (permalink / raw) To: Olivier Matz, dev > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Wednesday, February 4, 2015 5:25 PM > To: dev@dpdk.org > Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; olivier.matz@6wind.com > Subject: [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for > offloaded packets > > From i40e datasheet: > > The IP header type and its offload. In case of tunneling, the IIPT > relates to the inner IP header. See also EIPT field for the outer > (External) IP header offload. > > 00 - non IP packet or packet type is not defined by software > 01 - IPv6 packet > 10 - IPv4 packet with no IP checksum offload > 11 - IPv4 packet with IP checksum offload > > Therefore it is not needed to fill the IIPT field if no offload is requested (we can > keep the value to 00). For instance, the linux driver code does not set it when > (skb->ip_summed != CHECKSUM_PARTIAL). We can do the same in the dpdk > driver. > > The function i40e_txd_enable_checksum() that fills the offload registers can > only be called for packets requiring an offload. > > Signed-off-by: Olivier Matz <olivier.matz@6wind.com> > --- > lib/librte_pmd_i40e/i40e_rxtx.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c > index 8e9df96..9acdeee 100644 > --- a/lib/librte_pmd_i40e/i40e_rxtx.c > +++ b/lib/librte_pmd_i40e/i40e_rxtx.c > @@ -74,6 +74,11 @@ > > #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | > I40E_TX_DESC_CMD_RS) > > +#define I40E_TX_CKSUM_OFFLOAD_MASK ( \ > + PKT_TX_IP_CKSUM | \ > + PKT_TX_L4_MASK | \ > + PKT_TX_OUTER_IP_CKSUM) > + > #define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \ > (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM) > > @@ -1272,10 +1277,12 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf > **tx_pkts, uint16_t nb_pkts) > > /* Enable checksum offloading */ > cd_tunneling_params = 0; > - i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, > - l2_len, l3_len, outer_l2_len, > - outer_l3_len, > - &cd_tunneling_params); > + if (ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK) { likely should be added. > + i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, > + l2_len, l3_len, outer_l2_len, > + outer_l3_len, > + &cd_tunneling_params); > + } As this code changes are in fast path, performance regression test is needed. I would like to see the performance difference with or without this patch set. Hopefully nothing different. If you need any helps, just let me know. Regards, Helin > > if (unlikely(nb_ctx)) { > /* Setup TX context descriptor if required */ > -- > 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets 2015-02-10 6:03 ` Zhang, Helin @ 2015-02-10 17:06 ` Olivier MATZ 2015-02-11 5:32 ` Zhang, Helin 0 siblings, 1 reply; 109+ messages in thread From: Olivier MATZ @ 2015-02-10 17:06 UTC (permalink / raw) To: Zhang, Helin, dev Hi Helin, On 02/10/2015 07:03 AM, Zhang, Helin wrote: >> /* Enable checksum offloading */ >> cd_tunneling_params = 0; >> - i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, >> - l2_len, l3_len, outer_l2_len, >> - outer_l3_len, >> - &cd_tunneling_params); >> + if (ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK) { > likely should be added. I would say unlikely() instead. I think the non-offload case should be the default one. What do you think? >> + i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, >> + l2_len, l3_len, outer_l2_len, >> + outer_l3_len, >> + &cd_tunneling_params); >> + } > As this code changes are in fast path, performance regression test is needed. I would > like to see the performance difference with or without this patch set. Hopefully nothing > different. If you need any helps, just let me know. I'm sorry, I won't have the needed resources to bench this as I would have to setup a performance platform with i40e devices. But I'm pretty sure that the code in non-offload case would be faster with this patch as it will avoid many operations in i40e_txd_enable_checksum(). For the offload case, as we also removed the if (l2_len == 0) and if (l3_len == 0), I think there are also less tests than before my patch series. So in my opinion, adding this test does not really justify to check the performance. Regards, Olivier ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets 2015-02-10 17:06 ` Olivier MATZ @ 2015-02-11 5:32 ` Zhang, Helin 2015-02-11 17:13 ` Olivier MATZ 0 siblings, 1 reply; 109+ messages in thread From: Zhang, Helin @ 2015-02-11 5:32 UTC (permalink / raw) To: Olivier MATZ, dev > -----Original Message----- > From: Olivier MATZ [mailto:olivier.matz@6wind.com] > Sent: Wednesday, February 11, 2015 1:07 AM > To: Zhang, Helin; dev@dpdk.org > Cc: Ananyev, Konstantin; Liu, Jijiang > Subject: Re: [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for > offloaded packets > > Hi Helin, > > On 02/10/2015 07:03 AM, Zhang, Helin wrote: > >> /* Enable checksum offloading */ > >> cd_tunneling_params = 0; > >> - i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, > >> - l2_len, l3_len, outer_l2_len, > >> - outer_l3_len, > >> - &cd_tunneling_params); > >> + if (ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK) { > > likely should be added. > > I would say unlikely() instead. I think the non-offload case should be the default > one. What do you think? > > >> + i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, > >> + l2_len, l3_len, outer_l2_len, > >> + outer_l3_len, > >> + &cd_tunneling_params); > >> + } > > As this code changes are in fast path, performance regression test is > > needed. I would like to see the performance difference with or without > > this patch set. Hopefully nothing different. If you need any helps, just let me > know. > > I'm sorry, I won't have the needed resources to bench this as I would have to > setup a performance platform with i40e devices. > > But I'm pretty sure that the code in non-offload case would be faster with this > patch as it will avoid many operations in i40e_txd_enable_checksum(). > > For the offload case, as we also removed the if (l2_len == 0) and if (l3_len == 0), > I think there are also less tests than before my patch series. > > So in my opinion, adding this test does not really justify to check the > performance. As 40G is quite sensitive on cpu cycles, we'd better to avoid any performance drop during our modifying the code for fast path. Performance is what we care about too much. Based on my experiences, even minor code changes may result in big performance impact. It seems that we may need to help you on performance measurement. Regards, Helin > > Regards, > Olivier ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets 2015-02-11 5:32 ` Zhang, Helin @ 2015-02-11 17:13 ` Olivier MATZ 2015-02-13 2:25 ` Zhang, Helin 0 siblings, 1 reply; 109+ messages in thread From: Olivier MATZ @ 2015-02-11 17:13 UTC (permalink / raw) To: Zhang, Helin, dev Hi Helin, On 02/11/2015 06:32 AM, Zhang, Helin wrote: >> On 02/10/2015 07:03 AM, Zhang, Helin wrote: >>>> /* Enable checksum offloading */ >>>> cd_tunneling_params = 0; >>>> - i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, >>>> - l2_len, l3_len, outer_l2_len, >>>> - outer_l3_len, >>>> - &cd_tunneling_params); >>>> + if (ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK) { >>> likely should be added. >> >> I would say unlikely() instead. I think the non-offload case should be the default >> one. What do you think? Maybe you missed this comment. Any thoughts? >>>> + i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, >>>> + l2_len, l3_len, outer_l2_len, >>>> + outer_l3_len, >>>> + &cd_tunneling_params); >>>> + } >>> As this code changes are in fast path, performance regression test is >>> needed. I would like to see the performance difference with or without >>> this patch set. Hopefully nothing different. If you need any helps, just let me >> know. >> >> I'm sorry, I won't have the needed resources to bench this as I would have to >> setup a performance platform with i40e devices. >> >> But I'm pretty sure that the code in non-offload case would be faster with this >> patch as it will avoid many operations in i40e_txd_enable_checksum(). >> >> For the offload case, as we also removed the if (l2_len == 0) and if (l3_len == 0), >> I think there are also less tests than before my patch series. >> >> So in my opinion, adding this test does not really justify to check the >> performance. > As 40G is quite sensitive on cpu cycles, we'd better to avoid any performance drop > during our modifying the code for fast path. Performance is what we care about too > much. Based on my experiences, even minor code changes may result in big > performance impact. > It seems that we may need to help you on performance measurement. Thanks, indeed it's helpful if you can check performance non-regression. Regards, Olivier ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets 2015-02-11 17:13 ` Olivier MATZ @ 2015-02-13 2:25 ` Zhang, Helin 2015-02-13 8:41 ` Olivier MATZ 0 siblings, 1 reply; 109+ messages in thread From: Zhang, Helin @ 2015-02-13 2:25 UTC (permalink / raw) To: Olivier MATZ, dev > -----Original Message----- > From: Olivier MATZ [mailto:olivier.matz@6wind.com] > Sent: Thursday, February 12, 2015 1:14 AM > To: Zhang, Helin; dev@dpdk.org > Cc: Ananyev, Konstantin; Liu, Jijiang > Subject: Re: [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for > offloaded packets > > Hi Helin, > > On 02/11/2015 06:32 AM, Zhang, Helin wrote: > >> On 02/10/2015 07:03 AM, Zhang, Helin wrote: > >>>> /* Enable checksum offloading */ > >>>> cd_tunneling_params = 0; > >>>> - i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, > >>>> - l2_len, l3_len, outer_l2_len, > >>>> - outer_l3_len, > >>>> - &cd_tunneling_params); > >>>> + if (ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK) { > >>> likely should be added. > >> > >> I would say unlikely() instead. I think the non-offload case should > >> be the default one. What do you think? > > Maybe you missed this comment. Any thoughts? Ohh, sorry for the missing! I'd prefer to have likely, as hardware offload is preferred if there is. If you don't think so, how about to keep nothing (no likely/unlikely) as it is. > > > >>>> + i40e_txd_enable_checksum(ol_flags, &td_cmd, > &td_offset, > >>>> + l2_len, l3_len, outer_l2_len, > >>>> + outer_l3_len, > >>>> + &cd_tunneling_params); > >>>> + } > >>> As this code changes are in fast path, performance regression test > >>> is needed. I would like to see the performance difference with or > >>> without this patch set. Hopefully nothing different. If you need any > >>> helps, just let me > >> know. > >> > >> I'm sorry, I won't have the needed resources to bench this as I would > >> have to setup a performance platform with i40e devices. > >> > >> But I'm pretty sure that the code in non-offload case would be faster > >> with this patch as it will avoid many operations in > i40e_txd_enable_checksum(). > >> > >> For the offload case, as we also removed the if (l2_len == 0) and if > >> (l3_len == 0), I think there are also less tests than before my patch series. > >> > >> So in my opinion, adding this test does not really justify to check > >> the performance. > > As 40G is quite sensitive on cpu cycles, we'd better to avoid any > > performance drop during our modifying the code for fast path. > > Performance is what we care about too much. Based on my experiences, > > even minor code changes may result in big performance impact. > > It seems that we may need to help you on performance measurement. > > Thanks, indeed it's helpful if you can check performance non-regression. I have asked our validation guys here to help you on that, but might not in high priority. In addition, we all will take vocation for the coming Chinese new year. Regards, Helin > > Regards, > Olivier ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets 2015-02-13 2:25 ` Zhang, Helin @ 2015-02-13 8:41 ` Olivier MATZ 0 siblings, 0 replies; 109+ messages in thread From: Olivier MATZ @ 2015-02-13 8:41 UTC (permalink / raw) To: Zhang, Helin, dev Hi, On 02/13/2015 03:25 AM, Zhang, Helin wrote: >> On 02/11/2015 06:32 AM, Zhang, Helin wrote: >>>> On 02/10/2015 07:03 AM, Zhang, Helin wrote: >>>>>> /* Enable checksum offloading */ >>>>>> cd_tunneling_params = 0; >>>>>> - i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, >>>>>> - l2_len, l3_len, outer_l2_len, >>>>>> - outer_l3_len, >>>>>> - &cd_tunneling_params); >>>>>> + if (ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK) { >>>>> likely should be added. >>>> >>>> I would say unlikely() instead. I think the non-offload case should >>>> be the default one. What do you think? >> >> Maybe you missed this comment. Any thoughts? > Ohh, sorry for the missing! > I'd prefer to have likely, as hardware offload is preferred if there is. If you > don't think so, how about to keep nothing (no likely/unlikely) as it is. OK, I'll use likely() as you initially suggested. >>> As 40G is quite sensitive on cpu cycles, we'd better to avoid any >>> performance drop during our modifying the code for fast path. >>> Performance is what we care about too much. Based on my experiences, >>> even minor code changes may result in big performance impact. >>> It seems that we may need to help you on performance measurement. >> >> Thanks, indeed it's helpful if you can check performance non-regression. > I have asked our validation guys here to help you on that, but might not in > high priority. In addition, we all will take vocation for the coming Chinese new year. OK, it's noted Thanks, Olivier ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (2 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-10 6:40 ` Zhang, Helin 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 05/20] mbuf: remove " Olivier Matz ` (17 subsequent siblings) 21 siblings, 1 reply; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev The definition of the flag in rte_mbuf.h was: TX packet is an UDP tunneled packet. It must be specified when using outer checksum offload (PKT_TX_OUTER_IP_CKSUM) This flag was used to tell the NIC that the offload type is UDP (I40E_TXD_CTX_UDP_TUNNELING flag). In the datasheet, it says it's required to specify the tunnel type in the register. However, some tests (see [1]) showed that it also works without this flag. Moreover, it is not explained how the hardware use this information. From a network perspective, this information is useless for calculating the outer IP checksum as it does not depend on the payload. Having this flag in the API would force the application to specify the tunnel type for something that looks only useful for this PMD. It will limit the number of possible tunnel types (we would need a flag for each tunnel type) and therefore prevent to support outer IP checksum for proprietary tunnels. Finally, if a hardware advertises "I support outer IP checksum", it must be supported for any payload types. This has been validated by [2], knowing that the ipip test case was fixed after this test report [3]. [1] http://dpdk.org/ml/archives/dev/2015-January/011380.html [2] http://dpdk.org/ml/archives/dev/2015-January/011475.html [3] http://dpdk.org/ml/archives/dev/2015-January/011610.html Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_rxtx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 9acdeee..0786255 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -482,7 +482,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags, } /* UDP tunneling packet TX checksum offload */ - if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) { + if (unlikely(ol_flags & PKT_TX_OUTER_IP_CKSUM)) { *td_offset |= (outer_l2_len >> 1) << I40E_TX_DESC_LENGTH_MACLEN_SHIFT; @@ -497,7 +497,6 @@ i40e_txd_enable_checksum(uint64_t ol_flags, /* Now set the ctx descriptor fields */ *cd_tunneling |= (outer_l3_len >> 2) << I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT | - I40E_TXD_CTX_UDP_TUNNELING | (l2_len >> 1) << I40E_TXD_CTX_QW0_NATLEN_SHIFT; @@ -1165,8 +1164,7 @@ i40e_calc_context_desc(uint64_t flags) { uint64_t mask = 0ULL; - if (flags | PKT_TX_UDP_TUNNEL_PKT) - mask |= PKT_TX_UDP_TUNNEL_PKT; + mask |= PKT_TX_OUTER_IP_CKSUM; #ifdef RTE_LIBRTE_IEEE1588 mask |= PKT_TX_IEEE1588_TMST; -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v2 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag Olivier Matz @ 2015-02-10 6:40 ` Zhang, Helin 2015-02-10 17:08 ` Olivier MATZ 0 siblings, 1 reply; 109+ messages in thread From: Zhang, Helin @ 2015-02-10 6:40 UTC (permalink / raw) To: Olivier Matz, dev > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Wednesday, February 4, 2015 5:25 PM > To: dev@dpdk.org > Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; olivier.matz@6wind.com > Subject: [PATCH v2 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT > flag > > The definition of the flag in rte_mbuf.h was: > TX packet is an UDP tunneled packet. It must be specified when using > outer checksum offload (PKT_TX_OUTER_IP_CKSUM) > > This flag was used to tell the NIC that the offload type is UDP > (I40E_TXD_CTX_UDP_TUNNELING flag). In the datasheet, it says it's required > to specify the tunnel type in the register. However, some tests (see [1]) showed > that it also works without this flag. As it was clarified by the datasheet author, we should follow the datasheet finally. Setting the registers according to what we found will not ensure it is always correct, as there will be new firmware releases in the near future. I am OK to do like it at this moment, and wait for the next firmware release. > > Moreover, it is not explained how the hardware use this information. From a > network perspective, this information is useless for calculating the outer IP > checksum as it does not depend on the payload. > > Having this flag in the API would force the application to specify the tunnel type > for something that looks only useful for this PMD. It will limit the number of > possible tunnel types (we would need a flag for each tunnel type) and therefore > prevent to support outer IP checksum for proprietary tunnels. Two or more bits can be allocated later to define several enum tunnel types in the future. Standard known tunnel types and extended unknown tunnel types can be defined in it. > > Finally, if a hardware advertises "I support outer IP checksum", it must be > supported for any payload types. > > This has been validated by [2], knowing that the ipip test case was fixed after > this test report [3]. > > [1] http://dpdk.org/ml/archives/dev/2015-January/011380.html > [2] http://dpdk.org/ml/archives/dev/2015-January/011475.html > [3] http://dpdk.org/ml/archives/dev/2015-January/011610.html > > Signed-off-by: Olivier Matz <olivier.matz@6wind.com> > --- > lib/librte_pmd_i40e/i40e_rxtx.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c > index 9acdeee..0786255 100644 > --- a/lib/librte_pmd_i40e/i40e_rxtx.c > +++ b/lib/librte_pmd_i40e/i40e_rxtx.c > @@ -482,7 +482,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags, > } > > /* UDP tunneling packet TX checksum offload */ > - if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) { > + if (unlikely(ol_flags & PKT_TX_OUTER_IP_CKSUM)) { Unlikely might not be suitable anymore. Regards, Helin > > *td_offset |= (outer_l2_len >> 1) > << I40E_TX_DESC_LENGTH_MACLEN_SHIFT; @@ -497,7 > +497,6 @@ i40e_txd_enable_checksum(uint64_t ol_flags, > /* Now set the ctx descriptor fields */ > *cd_tunneling |= (outer_l3_len >> 2) << > I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT | > - I40E_TXD_CTX_UDP_TUNNELING | > (l2_len >> 1) << > I40E_TXD_CTX_QW0_NATLEN_SHIFT; > > @@ -1165,8 +1164,7 @@ i40e_calc_context_desc(uint64_t flags) { > uint64_t mask = 0ULL; > > - if (flags | PKT_TX_UDP_TUNNEL_PKT) > - mask |= PKT_TX_UDP_TUNNEL_PKT; > + mask |= PKT_TX_OUTER_IP_CKSUM; > > #ifdef RTE_LIBRTE_IEEE1588 > mask |= PKT_TX_IEEE1588_TMST; > -- > 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v2 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag 2015-02-10 6:40 ` Zhang, Helin @ 2015-02-10 17:08 ` Olivier MATZ 0 siblings, 0 replies; 109+ messages in thread From: Olivier MATZ @ 2015-02-10 17:08 UTC (permalink / raw) To: Zhang, Helin, dev Hi Helin, On 02/10/2015 07:40 AM, Zhang, Helin wrote: >> diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c >> index 9acdeee..0786255 100644 >> --- a/lib/librte_pmd_i40e/i40e_rxtx.c >> +++ b/lib/librte_pmd_i40e/i40e_rxtx.c >> @@ -482,7 +482,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags, >> } >> >> /* UDP tunneling packet TX checksum offload */ >> - if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) { >> + if (unlikely(ol_flags & PKT_TX_OUTER_IP_CKSUM)) { > Unlikely might not be suitable anymore. Right, I'll remove it. Thanks ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 05/20] mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (3 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 06/20] testpmd: replace tx_checksum command by csum Olivier Matz ` (16 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev Since previous commit, this flag is not used by any PMD, remove it from mbuf API and from csumonly (testpmd). In csumonly, the PKT_TX_OUTER_IP_CKSUM flag is already set for vxlan checksum, providing enough information to the underlying driver. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 4 ---- lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 5 +---- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 4b438d1..ca5ca39 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -255,9 +255,6 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, struct udp_hdr *udp_hdr; uint64_t ol_flags = 0; - if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) - ol_flags |= PKT_TX_UDP_TUNNEL_PKT; - if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_OUTER_IPV4; @@ -473,7 +470,6 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) { PKT_TX_UDP_CKSUM, PKT_TX_L4_MASK }, { PKT_TX_TCP_CKSUM, PKT_TX_L4_MASK }, { PKT_TX_SCTP_CKSUM, PKT_TX_L4_MASK }, - { PKT_TX_UDP_TUNNEL_PKT, PKT_TX_UDP_TUNNEL_PKT }, { PKT_TX_IPV4, PKT_TX_IPV4 }, { PKT_TX_IPV6, PKT_TX_IPV6 }, { PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM }, diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 1b14e02..2a4bc8c 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -240,7 +240,6 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask) case PKT_TX_SCTP_CKSUM: return "PKT_TX_SCTP_CKSUM"; case PKT_TX_UDP_CKSUM: return "PKT_TX_UDP_CKSUM"; case PKT_TX_IEEE1588_TMST: return "PKT_TX_IEEE1588_TMST"; - case PKT_TX_UDP_TUNNEL_PKT: return "PKT_TX_UDP_TUNNEL_PKT"; case PKT_TX_TCP_SEG: return "PKT_TX_TCP_SEG"; case PKT_TX_IPV4: return "PKT_TX_IPV4"; case PKT_TX_IPV6: return "PKT_TX_IPV6"; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 191a42c..d841caa 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -117,11 +117,8 @@ extern "C" { * and set it in the TCP header. Refer to rte_ipv4_phdr_cksum() and * rte_ipv6_phdr_cksum() that can be used as helpers. */ -#define PKT_TX_TCP_SEG (1ULL << 49) +#define PKT_TX_TCP_SEG (1ULL << 50) -/** TX packet is an UDP tunneled packet. It must be specified when using - * outer checksum offload (PKT_TX_OUTER_IP_CKSUM) */ -#define PKT_TX_UDP_TUNNEL_PKT (1ULL << 50) /**< TX packet is an UDP tunneled packet */ #define PKT_TX_IEEE1588_TMST (1ULL << 51) /**< TX IEEE1588 packet to timestamp. */ /** -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 06/20] testpmd: replace tx_checksum command by csum 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (4 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 05/20] mbuf: remove " Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 07/20] testpmd: move csum_show in a function Olivier Matz ` (15 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev Replace the "tx_checksum" command by "csum". It has several advantages: - it's more coherent with the forward engine name - it's shorter - the next commit will introduce a command that is related to the csum forward engine, but about rx side. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 70 +++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 590e427..270842f 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -317,7 +317,7 @@ static void cmd_help_long_parsed(void *parsed_result, " Disable hardware insertion of a VLAN header in" " packets sent on a port.\n\n" - "tx_cksum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n" + "csum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n" " Select hardware or software calculation of the" " checksum with when transmitting a packet using the" " csum forward engine.\n" @@ -327,7 +327,7 @@ static void cmd_help_long_parsed(void *parsed_result, " the forward engine)\n" " Please check the NIC datasheet for HW limits.\n\n" - "tx_checksum show (port_id)\n" + "csum show (port_id)\n" " Display tx checksum offload configuration\n\n" "tso set (segsize) (portid)\n" @@ -2874,8 +2874,8 @@ cmdline_parse_inst_t cmd_tx_vlan_reset = { /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ -struct cmd_tx_cksum_result { - cmdline_fixed_string_t tx_cksum; +struct cmd_csum_result { + cmdline_fixed_string_t csum; cmdline_fixed_string_t mode; cmdline_fixed_string_t proto; cmdline_fixed_string_t hwsw; @@ -2883,11 +2883,11 @@ struct cmd_tx_cksum_result { }; static void -cmd_tx_cksum_parsed(void *parsed_result, +cmd_csum_parsed(void *parsed_result, __attribute__((unused)) struct cmdline *cl, __attribute__((unused)) void *data) { - struct cmd_tx_cksum_result *res = parsed_result; + struct cmd_csum_result *res = parsed_result; int hw = 0; uint16_t ol_flags, mask = 0; struct rte_eth_dev_info dev_info; @@ -2956,49 +2956,49 @@ cmd_tx_cksum_parsed(void *parsed_result, } } -cmdline_parse_token_string_t cmd_tx_cksum_tx_cksum = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, - tx_cksum, "tx_checksum"); -cmdline_parse_token_string_t cmd_tx_cksum_mode = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_csum = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, + csum, "csum"); +cmdline_parse_token_string_t cmd_csum_mode = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, mode, "set"); -cmdline_parse_token_string_t cmd_tx_cksum_proto = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_proto = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, proto, "ip#tcp#udp#sctp#vxlan"); -cmdline_parse_token_string_t cmd_tx_cksum_hwsw = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_hwsw = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, hwsw, "hw#sw"); -cmdline_parse_token_num_t cmd_tx_cksum_portid = - TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_num_t cmd_csum_portid = + TOKEN_NUM_INITIALIZER(struct cmd_csum_result, port_id, UINT8); -cmdline_parse_inst_t cmd_tx_cksum_set = { - .f = cmd_tx_cksum_parsed, +cmdline_parse_inst_t cmd_csum_set = { + .f = cmd_csum_parsed, .data = NULL, .help_str = "enable/disable hardware calculation of L3/L4 checksum when " - "using csum forward engine: tx_cksum set ip|tcp|udp|sctp|vxlan hw|sw <port>", + "using csum forward engine: csum set ip|tcp|udp|sctp|vxlan hw|sw <port>", .tokens = { - (void *)&cmd_tx_cksum_tx_cksum, - (void *)&cmd_tx_cksum_mode, - (void *)&cmd_tx_cksum_proto, - (void *)&cmd_tx_cksum_hwsw, - (void *)&cmd_tx_cksum_portid, + (void *)&cmd_csum_csum, + (void *)&cmd_csum_mode, + (void *)&cmd_csum_proto, + (void *)&cmd_csum_hwsw, + (void *)&cmd_csum_portid, NULL, }, }; -cmdline_parse_token_string_t cmd_tx_cksum_mode_show = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_mode_show = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, mode, "show"); -cmdline_parse_inst_t cmd_tx_cksum_show = { - .f = cmd_tx_cksum_parsed, +cmdline_parse_inst_t cmd_csum_show = { + .f = cmd_csum_parsed, .data = NULL, - .help_str = "show checksum offload configuration: tx_cksum show <port>", + .help_str = "show checksum offload configuration: csum show <port>", .tokens = { - (void *)&cmd_tx_cksum_tx_cksum, - (void *)&cmd_tx_cksum_mode_show, - (void *)&cmd_tx_cksum_portid, + (void *)&cmd_csum_csum, + (void *)&cmd_csum_mode_show, + (void *)&cmd_csum_portid, NULL, }, }; @@ -9050,8 +9050,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_tx_vlan_set, (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, - (cmdline_parse_inst_t *)&cmd_tx_cksum_set, - (cmdline_parse_inst_t *)&cmd_tx_cksum_show, + (cmdline_parse_inst_t *)&cmd_csum_set, + (cmdline_parse_inst_t *)&cmd_csum_show, (cmdline_parse_inst_t *)&cmd_tso_set, (cmdline_parse_inst_t *)&cmd_tso_show, (cmdline_parse_inst_t *)&cmd_link_flow_control_set, -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 07/20] testpmd: move csum_show in a function 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (5 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 06/20] testpmd: replace tx_checksum command by csum Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 08/20] testpmd: add csum parse_tunnel command Olivier Matz ` (14 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev No functional changes in this commit, we just move the code that displays the csum forward engine configuration in a function. This makes the next commit easier to read as it will also use this function. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 82 +++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 270842f..55768f1 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2883,14 +2883,56 @@ struct cmd_csum_result { }; static void +csum_show(int port_id) +{ + struct rte_eth_dev_info dev_info; + uint16_t ol_flags; + + ol_flags = ports[port_id].tx_ol_flags; + printf("IP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); + printf("UDP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); + printf("TCP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); + printf("SCTP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); + printf("VxLAN checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw"); + + /* display warnings if configuration is not supported by the NIC */ + rte_eth_dev_info_get(port_id, &dev_info); + if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { + printf("Warning: hardware IP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { + printf("Warning: hardware UDP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { + printf("Warning: hardware TCP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { + printf("Warning: hardware SCTP checksum enabled but not " + "supported by port %d\n", port_id); + } + +} + +static void cmd_csum_parsed(void *parsed_result, __attribute__((unused)) struct cmdline *cl, __attribute__((unused)) void *data) { struct cmd_csum_result *res = parsed_result; int hw = 0; - uint16_t ol_flags, mask = 0; - struct rte_eth_dev_info dev_info; + uint16_t mask = 0; if (port_id_is_invalid(res->port_id)) { printf("invalid port %d\n", res->port_id); @@ -2919,41 +2961,7 @@ cmd_csum_parsed(void *parsed_result, else ports[res->port_id].tx_ol_flags &= (~mask); } - - ol_flags = ports[res->port_id].tx_ol_flags; - printf("IP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); - printf("UDP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); - printf("TCP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); - printf("SCTP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); - printf("VxLAN checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw"); - - /* display warnings if configuration is not supported by the NIC */ - rte_eth_dev_info_get(res->port_id, &dev_info); - if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { - printf("Warning: hardware IP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { - printf("Warning: hardware UDP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { - printf("Warning: hardware TCP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { - printf("Warning: hardware SCTP checksum enabled but not " - "supported by port %d\n", res->port_id); - } + csum_show(res->port_id); } cmdline_parse_token_string_t cmd_csum_csum = -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 08/20] testpmd: add csum parse_tunnel command 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (6 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 07/20] testpmd: move csum_show in a function Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 09/20] testpmd: rename vxlan in outer_ip in csum commands Olivier Matz ` (13 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev Add a new command related to csum forward engine: csum parse-tunnel (on|off) (tx_port_id) If enabled, the tunnel packets received by the csum forward engine are parsed and seen as "outer-headers/inner-headers/data". If disabled, the parsing of the csum forward engine stops at the first l4 layer. A tunnel packet is seens as "headers/data" (inner headers are included in payload). Note: the port argument is the tx_port. It's more coherent compared to all other testpmd csum flags. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/csumonly.c | 3 ++- app/test-pmd/testpmd.h | 5 +++- 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 55768f1..f57bf0b 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -327,6 +327,12 @@ static void cmd_help_long_parsed(void *parsed_result, " the forward engine)\n" " Please check the NIC datasheet for HW limits.\n\n" + "csum parse-tunnel (on|off) (tx_port_id)\n" + " If disabled, treat tunnel packets as non-tunneled" + " packets (treat inner headers as payload). The port\n" + " argument is the port used for TX in csum forward" + " engine.\n\n" + "csum show (port_id)\n" " Display tx checksum offload configuration\n\n" @@ -2889,6 +2895,8 @@ csum_show(int port_id) uint16_t ol_flags; ol_flags = ports[port_id].tx_ol_flags; + printf("Parse tunnel is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off"); printf("IP checksum offload is %s\n", (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); printf("UDP checksum offload is %s\n", @@ -3011,6 +3019,63 @@ cmdline_parse_inst_t cmd_csum_show = { }, }; +/* Enable/disable tunnel parsing */ +struct cmd_csum_tunnel_result { + cmdline_fixed_string_t csum; + cmdline_fixed_string_t parse; + cmdline_fixed_string_t onoff; + uint8_t port_id; +}; + +static void +cmd_csum_tunnel_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_csum_tunnel_result *res = parsed_result; + + if (port_id_is_invalid(res->port_id)) { + printf("invalid port %d\n", res->port_id); + return; + } + + if (!strcmp(res->onoff, "on")) + ports[res->port_id].tx_ol_flags |= + TESTPMD_TX_OFFLOAD_PARSE_TUNNEL; + else + ports[res->port_id].tx_ol_flags &= + (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL); + + csum_show(res->port_id); +} + +cmdline_parse_token_string_t cmd_csum_tunnel_csum = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + csum, "csum"); +cmdline_parse_token_string_t cmd_csum_tunnel_parse = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + parse, "parse_tunnel"); +cmdline_parse_token_string_t cmd_csum_tunnel_onoff = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + onoff, "on#off"); +cmdline_parse_token_num_t cmd_csum_tunnel_portid = + TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, + port_id, UINT8); + +cmdline_parse_inst_t cmd_csum_tunnel = { + .f = cmd_csum_tunnel_parsed, + .data = NULL, + .help_str = "enable/disable parsing of tunnels for csum engine: " + "csum parse_tunnel on|off <tx-port>", + .tokens = { + (void *)&cmd_csum_tunnel_csum, + (void *)&cmd_csum_tunnel_parse, + (void *)&cmd_csum_tunnel_onoff, + (void *)&cmd_csum_tunnel_portid, + NULL, + }, +}; + /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */ struct cmd_tso_set_result { cmdline_fixed_string_t tso; @@ -9060,6 +9125,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, (cmdline_parse_inst_t *)&cmd_csum_set, (cmdline_parse_inst_t *)&cmd_csum_show, + (cmdline_parse_inst_t *)&cmd_csum_tunnel, (cmdline_parse_inst_t *)&cmd_tso_set, (cmdline_parse_inst_t *)&cmd_tso_show, (cmdline_parse_inst_t *)&cmd_link_flow_control_set, diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index ca5ca39..858eb47 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -373,7 +373,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) l3_hdr = (char *)eth_hdr + l2_len; /* check if it's a supported tunnel (only vxlan for now) */ - if (l4_proto == IPPROTO_UDP) { + if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && + l4_proto == IPPROTO_UDP) { udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len); /* check udp destination port, 4789 is the default diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 8f5e6c7..36277de 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -127,8 +127,11 @@ struct fwd_stream { #define TESTPMD_TX_OFFLOAD_SCTP_CKSUM 0x0008 /** Offload VxLAN checksum in csum forward engine */ #define TESTPMD_TX_OFFLOAD_VXLAN_CKSUM 0x0010 +/** Parse tunnel in csum forward engine. If set, dissect tunnel headers + * of rx packets. If not set, treat inner headers as payload. */ +#define TESTPMD_TX_OFFLOAD_PARSE_TUNNEL 0x0020 /** Insert VLAN header in forward engine */ -#define TESTPMD_TX_OFFLOAD_INSERT_VLAN 0x0020 +#define TESTPMD_TX_OFFLOAD_INSERT_VLAN 0x0040 /** * The data structure associated with each port. -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 09/20] testpmd: rename vxlan in outer_ip in csum commands 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (7 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 08/20] testpmd: add csum parse_tunnel command Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 10/20] testpmd: introduce parse_ipv* in csum fwd engine Olivier Matz ` (12 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev The tx_checksum command concerns outer IP checksum, not VxLAN checksum. Actually there is no checkum in VxLAN header, there is one checksum in outer IP header, and one checksum in outer UDP header. This option only controls the outer IP checksum. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 16 ++++++++-------- app/test-pmd/csumonly.c | 25 ++++++++++++++----------- app/test-pmd/testpmd.h | 4 ++-- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index f57bf0b..363da9a 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -317,12 +317,12 @@ static void cmd_help_long_parsed(void *parsed_result, " Disable hardware insertion of a VLAN header in" " packets sent on a port.\n\n" - "csum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n" + "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n" " Select hardware or software calculation of the" " checksum with when transmitting a packet using the" " csum forward engine.\n" " ip|udp|tcp|sctp always concern the inner layer.\n" - " vxlan concerns the outer IP and UDP layer (in" + " outer-ip concerns the outer IP layer (in" " case the packet is recognized as a vxlan packet by" " the forward engine)\n" " Please check the NIC datasheet for HW limits.\n\n" @@ -2905,8 +2905,8 @@ csum_show(int port_id) (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); printf("SCTP checksum offload is %s\n", (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); - printf("VxLAN checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw"); + printf("Outer-Ip checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw"); /* display warnings if configuration is not supported by the NIC */ rte_eth_dev_info_get(port_id, &dev_info); @@ -2960,8 +2960,8 @@ cmd_csum_parsed(void *parsed_result, mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM; } else if (!strcmp(res->proto, "sctp")) { mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM; - } else if (!strcmp(res->proto, "vxlan")) { - mask = TESTPMD_TX_OFFLOAD_VXLAN_CKSUM; + } else if (!strcmp(res->proto, "outer-ip")) { + mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM; } if (hw) @@ -2980,7 +2980,7 @@ cmdline_parse_token_string_t cmd_csum_mode = mode, "set"); cmdline_parse_token_string_t cmd_csum_proto = TOKEN_STRING_INITIALIZER(struct cmd_csum_result, - proto, "ip#tcp#udp#sctp#vxlan"); + proto, "ip#tcp#udp#sctp#outer-ip"); cmdline_parse_token_string_t cmd_csum_hwsw = TOKEN_STRING_INITIALIZER(struct cmd_csum_result, hwsw, "hw#sw"); @@ -2992,7 +2992,7 @@ cmdline_parse_inst_t cmd_csum_set = { .f = cmd_csum_parsed, .data = NULL, .help_str = "enable/disable hardware calculation of L3/L4 checksum when " - "using csum forward engine: csum set ip|tcp|udp|sctp|vxlan hw|sw <port>", + "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>", .tokens = { (void *)&cmd_csum_csum, (void *)&cmd_csum_mode, diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 858eb47..3921643 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -259,13 +259,16 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_OUTER_IPV4; - if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ol_flags |= PKT_TX_OUTER_IP_CKSUM; else ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); - } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) + } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ol_flags |= PKT_TX_OUTER_IPV6; + /* outer UDP checksum is always done in software as we have no + * hardware supporting it today, and no API for it. */ + udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len); /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { @@ -300,8 +303,8 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, * The testpmd command line for this forward engine sets the flags * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control * wether a checksum must be calculated in software or in hardware. The - * IP, UDP, TCP and SCTP flags always concern the inner layer. The - * VxLAN flag concerns the outer IP (if packet is recognized as a vxlan packet). + * IP, UDP, TCP and SCTP flags always concern the inner layer. The + * OUTER_IP is only useful for tunnel packets. */ static void pkt_burst_checksum_forward(struct fwd_stream *fs) @@ -432,18 +435,18 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* step 4: fill the mbuf meta data (flags and header lengths) */ if (tunnel == 1) { - if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) { + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { m->outer_l2_len = outer_l2_len; m->outer_l3_len = outer_l3_len; m->l2_len = l4_tun_len + l2_len; m->l3_len = l3_len; } else { - /* if we don't do vxlan cksum in hw, - outer checksum will be wrong because - we changed the ip, but it shows that - we can process the inner header cksum - in the nic */ + /* if there is a outer UDP cksum + processed in sw and the inner in hw, + the outer checksum will be wrong as + the payload will be modified by the + hardware */ m->l2_len = outer_l2_len + outer_l3_len + sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr) + l2_len; @@ -502,7 +505,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) "m->l4_len=%d\n", m->l2_len, m->l3_len, m->l4_len); if ((tunnel == 1) && - (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)) + (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM)) printf("tx: m->outer_l2_len=%d m->outer_l3_len=%d\n", m->outer_l2_len, m->outer_l3_len); if (tso_segsz != 0) diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 36277de..ecb7d38 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -125,8 +125,8 @@ struct fwd_stream { #define TESTPMD_TX_OFFLOAD_TCP_CKSUM 0x0004 /** Offload SCTP checksum in csum forward engine */ #define TESTPMD_TX_OFFLOAD_SCTP_CKSUM 0x0008 -/** Offload VxLAN checksum in csum forward engine */ -#define TESTPMD_TX_OFFLOAD_VXLAN_CKSUM 0x0010 +/** Offload outer IP checksum in csum forward engine for recognized tunnels */ +#define TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM 0x0010 /** Parse tunnel in csum forward engine. If set, dissect tunnel headers * of rx packets. If not set, treat inner headers as payload. */ #define TESTPMD_TX_OFFLOAD_PARSE_TUNNEL 0x0020 -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 10/20] testpmd: introduce parse_ipv* in csum fwd engine 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (8 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 09/20] testpmd: rename vxlan in outer_ip in csum commands Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 11/20] testpmd: use a structure to store offload info " Olivier Matz ` (11 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev These functions may be used to parse encapsulated layers when we will support IP over GRE tunnels. No functional change. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 51 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 3921643..b023f12 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -104,6 +104,42 @@ get_udptcp_checksum(void *l3_hdr, void *l4_hdr, uint16_t ethertype) return rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr); } +/* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */ +static void +parse_ipv4(struct ipv4_hdr *ipv4_hdr, uint16_t *l3_len, uint8_t *l4_proto, + uint16_t *l4_len) +{ + struct tcp_hdr *tcp_hdr; + + *l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; + *l4_proto = ipv4_hdr->next_proto_id; + + /* only fill l4_len for TCP, it's useful for TSO */ + if (*l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv4_hdr + *l3_len); + *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + } else + *l4_len = 0; +} + +/* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */ +static void +parse_ipv6(struct ipv6_hdr *ipv6_hdr, uint16_t *l3_len, uint8_t *l4_proto, + uint16_t *l4_len) +{ + struct tcp_hdr *tcp_hdr; + + *l3_len = sizeof(struct ipv6_hdr); + *l4_proto = ipv6_hdr->proto; + + /* only fill l4_len for TCP, it's useful for TSO */ + if (*l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv6_hdr + *l3_len); + *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + } else + *l4_len = 0; +} + /* * Parse an ethernet header to fill the ethertype, l2_len, l3_len and * ipproto. This function is able to recognize IPv4/IPv6 with one optional vlan @@ -115,7 +151,6 @@ parse_ethernet(struct ether_hdr *eth_hdr, uint16_t *ethertype, uint16_t *l2_len, { struct ipv4_hdr *ipv4_hdr; struct ipv6_hdr *ipv6_hdr; - struct tcp_hdr *tcp_hdr; *l2_len = sizeof(struct ether_hdr); *ethertype = eth_hdr->ether_type; @@ -130,26 +165,18 @@ parse_ethernet(struct ether_hdr *eth_hdr, uint16_t *ethertype, uint16_t *l2_len, switch (*ethertype) { case _htons(ETHER_TYPE_IPv4): ipv4_hdr = (struct ipv4_hdr *) ((char *)eth_hdr + *l2_len); - *l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; - *l4_proto = ipv4_hdr->next_proto_id; + parse_ipv4(ipv4_hdr, l3_len, l4_proto, l4_len); break; case _htons(ETHER_TYPE_IPv6): ipv6_hdr = (struct ipv6_hdr *) ((char *)eth_hdr + *l2_len); - *l3_len = sizeof(struct ipv6_hdr); - *l4_proto = ipv6_hdr->proto; + parse_ipv6(ipv6_hdr, l3_len, l4_proto, l4_len); break; default: + *l4_len = 0; *l3_len = 0; *l4_proto = 0; break; } - - if (*l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)eth_hdr + - *l2_len + *l3_len); - *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; - } else - *l4_len = 0; } /* modify the IPv4 or IPv4 source address of a packet */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 11/20] testpmd: use a structure to store offload info in csum fwd engine 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (9 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 10/20] testpmd: introduce parse_ipv* in csum fwd engine Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 12/20] testpmd: introduce parse_vxlan " Olivier Matz ` (10 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev To simplify the API of parse_* functions, store all the offload information for the current packet in a structure. No functional change. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 222 +++++++++++++++++++++++++----------------------- 1 file changed, 115 insertions(+), 107 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index b023f12..0b89d89 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -86,6 +86,21 @@ #define _htons(x) (x) #endif +/* structure that caches offload info for the current packet */ +struct testpmd_offload_info { + uint16_t ethertype; + uint16_t l2_len; + uint16_t l3_len; + uint16_t l4_len; + uint8_t l4_proto; + uint8_t l4_tun_len; + uint8_t is_tunnel; + uint16_t outer_ethertype; + uint16_t outer_l2_len; + uint16_t outer_l3_len; + uint16_t tso_segsz; +}; + static uint16_t get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags) { @@ -106,38 +121,36 @@ get_udptcp_checksum(void *l3_hdr, void *l4_hdr, uint16_t ethertype) /* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */ static void -parse_ipv4(struct ipv4_hdr *ipv4_hdr, uint16_t *l3_len, uint8_t *l4_proto, - uint16_t *l4_len) +parse_ipv4(struct ipv4_hdr *ipv4_hdr, struct testpmd_offload_info *info) { struct tcp_hdr *tcp_hdr; - *l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; - *l4_proto = ipv4_hdr->next_proto_id; + info->l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; + info->l4_proto = ipv4_hdr->next_proto_id; /* only fill l4_len for TCP, it's useful for TSO */ - if (*l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)ipv4_hdr + *l3_len); - *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + if (info->l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv4_hdr + info->l3_len); + info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2; } else - *l4_len = 0; + info->l4_len = 0; } /* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */ static void -parse_ipv6(struct ipv6_hdr *ipv6_hdr, uint16_t *l3_len, uint8_t *l4_proto, - uint16_t *l4_len) +parse_ipv6(struct ipv6_hdr *ipv6_hdr, struct testpmd_offload_info *info) { struct tcp_hdr *tcp_hdr; - *l3_len = sizeof(struct ipv6_hdr); - *l4_proto = ipv6_hdr->proto; + info->l3_len = sizeof(struct ipv6_hdr); + info->l4_proto = ipv6_hdr->proto; /* only fill l4_len for TCP, it's useful for TSO */ - if (*l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)ipv6_hdr + *l3_len); - *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + if (info->l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv6_hdr + info->l3_len); + info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2; } else - *l4_len = 0; + info->l4_len = 0; } /* @@ -146,35 +159,34 @@ parse_ipv6(struct ipv6_hdr *ipv6_hdr, uint16_t *l3_len, uint8_t *l4_proto, * header. The l4_len argument is only set in case of TCP (useful for TSO). */ static void -parse_ethernet(struct ether_hdr *eth_hdr, uint16_t *ethertype, uint16_t *l2_len, - uint16_t *l3_len, uint8_t *l4_proto, uint16_t *l4_len) +parse_ethernet(struct ether_hdr *eth_hdr, struct testpmd_offload_info *info) { struct ipv4_hdr *ipv4_hdr; struct ipv6_hdr *ipv6_hdr; - *l2_len = sizeof(struct ether_hdr); - *ethertype = eth_hdr->ether_type; + info->l2_len = sizeof(struct ether_hdr); + info->ethertype = eth_hdr->ether_type; - if (*ethertype == _htons(ETHER_TYPE_VLAN)) { + if (info->ethertype == _htons(ETHER_TYPE_VLAN)) { struct vlan_hdr *vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1); - *l2_len += sizeof(struct vlan_hdr); - *ethertype = vlan_hdr->eth_proto; + info->l2_len += sizeof(struct vlan_hdr); + info->ethertype = vlan_hdr->eth_proto; } - switch (*ethertype) { + switch (info->ethertype) { case _htons(ETHER_TYPE_IPv4): - ipv4_hdr = (struct ipv4_hdr *) ((char *)eth_hdr + *l2_len); - parse_ipv4(ipv4_hdr, l3_len, l4_proto, l4_len); + ipv4_hdr = (struct ipv4_hdr *) ((char *)eth_hdr + info->l2_len); + parse_ipv4(ipv4_hdr, info); break; case _htons(ETHER_TYPE_IPv6): - ipv6_hdr = (struct ipv6_hdr *) ((char *)eth_hdr + *l2_len); - parse_ipv6(ipv6_hdr, l3_len, l4_proto, l4_len); + ipv6_hdr = (struct ipv6_hdr *) ((char *)eth_hdr + info->l2_len); + parse_ipv6(ipv6_hdr, info); break; default: - *l4_len = 0; - *l3_len = 0; - *l4_proto = 0; + info->l4_len = 0; + info->l3_len = 0; + info->l4_proto = 0; break; } } @@ -197,8 +209,8 @@ change_ip_addresses(void *l3_hdr, uint16_t ethertype) /* if possible, calculate the checksum of a packet in hw or sw, * depending on the testpmd command line configuration */ static uint64_t -process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, - uint8_t l4_proto, uint16_t tso_segsz, uint16_t testpmd_ol_flags) +process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, + uint16_t testpmd_ol_flags) { struct ipv4_hdr *ipv4_hdr = l3_hdr; struct udp_hdr *udp_hdr; @@ -206,12 +218,12 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, struct sctp_hdr *sctp_hdr; uint64_t ol_flags = 0; - if (ethertype == _htons(ETHER_TYPE_IPv4)) { + if (info->ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr = l3_hdr; ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_IPV4; - if (tso_segsz != 0 && l4_proto == IPPROTO_TCP) { + if (info->tso_segsz != 0 && info->l4_proto == IPPROTO_TCP) { ol_flags |= PKT_TX_IP_CKSUM; } else { if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) @@ -220,41 +232,44 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); } - } else if (ethertype == _htons(ETHER_TYPE_IPv6)) + } else if (info->ethertype == _htons(ETHER_TYPE_IPv6)) ol_flags |= PKT_TX_IPV6; else return 0; /* packet type not supported, nothing to do */ - if (l4_proto == IPPROTO_UDP) { - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len); + if (info->l4_proto == IPPROTO_UDP) { + udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info->l3_len); /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { udp_hdr->dgram_cksum = 0; if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) { ol_flags |= PKT_TX_UDP_CKSUM; udp_hdr->dgram_cksum = get_psd_sum(l3_hdr, - ethertype, ol_flags); + info->ethertype, ol_flags); } else { udp_hdr->dgram_cksum = get_udptcp_checksum(l3_hdr, udp_hdr, - ethertype); + info->ethertype); } } - } else if (l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + l3_len); + } else if (info->l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + info->l3_len); tcp_hdr->cksum = 0; - if (tso_segsz != 0) { + if (info->tso_segsz != 0) { ol_flags |= PKT_TX_TCP_SEG; - tcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype, ol_flags); + tcp_hdr->cksum = get_psd_sum(l3_hdr, info->ethertype, + ol_flags); } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) { ol_flags |= PKT_TX_TCP_CKSUM; - tcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype, ol_flags); + tcp_hdr->cksum = get_psd_sum(l3_hdr, info->ethertype, + ol_flags); } else { tcp_hdr->cksum = - get_udptcp_checksum(l3_hdr, tcp_hdr, ethertype); + get_udptcp_checksum(l3_hdr, tcp_hdr, + info->ethertype); } - } else if (l4_proto == IPPROTO_SCTP) { - sctp_hdr = (struct sctp_hdr *)((char *)l3_hdr + l3_len); + } else if (info->l4_proto == IPPROTO_SCTP) { + sctp_hdr = (struct sctp_hdr *)((char *)l3_hdr + info->l3_len); sctp_hdr->cksum = 0; /* sctp payload must be a multiple of 4 to be * offloaded */ @@ -274,15 +289,15 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, * meaning IP + UDP). The caller already checked that it's a vxlan * packet */ static uint64_t -process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, - uint16_t outer_l3_len, uint16_t testpmd_ol_flags) +process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, +uint16_t testpmd_ol_flags) { struct ipv4_hdr *ipv4_hdr = outer_l3_hdr; struct ipv6_hdr *ipv6_hdr = outer_l3_hdr; struct udp_hdr *udp_hdr; uint64_t ol_flags = 0; - if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { + if (info->outer_ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_OUTER_IPV4; @@ -296,11 +311,11 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, /* outer UDP checksum is always done in software as we have no * hardware supporting it today, and no API for it. */ - udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len); + udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + info->outer_l3_len); /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { udp_hdr->dgram_cksum = 0; - if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) + if (info->outer_ethertype == _htons(ETHER_TYPE_IPv4)) udp_hdr->dgram_cksum = rte_ipv4_udptcp_cksum(ipv4_hdr, udp_hdr); else @@ -347,14 +362,9 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) uint16_t i; uint64_t ol_flags; uint16_t testpmd_ol_flags; - uint8_t l4_proto, l4_tun_len = 0; - uint16_t ethertype = 0, outer_ethertype = 0; - uint16_t l2_len = 0, l3_len = 0, l4_len = 0; - uint16_t outer_l2_len = 0, outer_l3_len = 0; - uint16_t tso_segsz; - int tunnel = 0; uint32_t rx_bad_ip_csum; uint32_t rx_bad_l4_csum; + struct testpmd_offload_info info; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES uint64_t start_tsc; @@ -381,13 +391,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) txp = &ports[fs->tx_port]; testpmd_ol_flags = txp->tx_ol_flags; - tso_segsz = txp->tso_segsz; + memset(&info, 0, sizeof(info)); + info.tso_segsz = txp->tso_segsz; for (i = 0; i < nb_rx; i++) { ol_flags = 0; - tunnel = 0; - l4_tun_len = 0; + info.is_tunnel = 0; m = pkts_burst[i]; /* Update the L3/L4 checksum error packet statistics */ @@ -398,49 +408,47 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) * and inner headers */ eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); - parse_ethernet(eth_hdr, ðertype, &l2_len, &l3_len, - &l4_proto, &l4_len); - l3_hdr = (char *)eth_hdr + l2_len; + parse_ethernet(eth_hdr, &info); + l3_hdr = (char *)eth_hdr + info.l2_len; /* check if it's a supported tunnel (only vxlan for now) */ if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && - l4_proto == IPPROTO_UDP) { - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len); + info.l4_proto == IPPROTO_UDP) { + udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info.l3_len); /* check udp destination port, 4789 is the default * vxlan port (rfc7348) */ if (udp_hdr->dst_port == _htons(4789)) { - l4_tun_len = ETHER_VXLAN_HLEN; - tunnel = 1; + info.l4_tun_len = ETHER_VXLAN_HLEN; + info.is_tunnel = 1; /* currently, this flag is set by i40e only if the * packet is vxlan */ } else if (m->ol_flags & (PKT_RX_TUNNEL_IPV4_HDR | PKT_RX_TUNNEL_IPV6_HDR)) - tunnel = 1; + info.is_tunnel = 1; - if (tunnel == 1) { - outer_ethertype = ethertype; - outer_l2_len = l2_len; - outer_l3_len = l3_len; + if (info.is_tunnel == 1) { + info.outer_ethertype = info.ethertype; + info.outer_l2_len = info.l2_len; + info.outer_l3_len = info.l3_len; outer_l3_hdr = l3_hdr; eth_hdr = (struct ether_hdr *)((char *)udp_hdr + sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr)); - parse_ethernet(eth_hdr, ðertype, &l2_len, - &l3_len, &l4_proto, &l4_len); - l3_hdr = (char *)eth_hdr + l2_len; + parse_ethernet(eth_hdr, &info); + l3_hdr = (char *)eth_hdr + info.l2_len; } } /* step 2: change all source IPs (v4 or v6) so we need * to recompute the chksums even if they were correct */ - change_ip_addresses(l3_hdr, ethertype); - if (tunnel == 1) - change_ip_addresses(outer_l3_hdr, outer_ethertype); + change_ip_addresses(l3_hdr, info.ethertype); + if (info.is_tunnel == 1) + change_ip_addresses(outer_l3_hdr, info.outer_ethertype); /* step 3: depending on user command line configuration, * recompute checksum either in software or flag the @@ -448,25 +456,24 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) * is configured, prepare the mbuf for TCP segmentation. */ /* process checksums of inner headers first */ - ol_flags |= process_inner_cksums(l3_hdr, ethertype, - l3_len, l4_proto, tso_segsz, testpmd_ol_flags); + ol_flags |= process_inner_cksums(l3_hdr, &info, testpmd_ol_flags); /* Then process outer headers if any. Note that the software * checksum will be wrong if one of the inner checksums is * processed in hardware. */ - if (tunnel == 1) { - ol_flags |= process_outer_cksums(outer_l3_hdr, - outer_ethertype, outer_l3_len, testpmd_ol_flags); + if (info.is_tunnel == 1) { + ol_flags |= process_outer_cksums(outer_l3_hdr, &info, + testpmd_ol_flags); } /* step 4: fill the mbuf meta data (flags and header lengths) */ - if (tunnel == 1) { + if (info.is_tunnel == 1) { if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { - m->outer_l2_len = outer_l2_len; - m->outer_l3_len = outer_l3_len; - m->l2_len = l4_tun_len + l2_len; - m->l3_len = l3_len; + m->outer_l2_len = info.outer_l2_len; + m->outer_l3_len = info.outer_l3_len; + m->l2_len = info.l4_tun_len + info.l2_len; + m->l3_len = info.l3_len; } else { /* if there is a outer UDP cksum @@ -474,21 +481,22 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) the outer checksum will be wrong as the payload will be modified by the hardware */ - m->l2_len = outer_l2_len + outer_l3_len + + m->l2_len = info.outer_l2_len + + info.outer_l3_len + sizeof(struct udp_hdr) + - sizeof(struct vxlan_hdr) + l2_len; - m->l3_len = l3_len; - m->l4_len = l4_len; + sizeof(struct vxlan_hdr) + info.l2_len; + m->l3_len = info.l3_len; + m->l4_len = info.l4_len; } } else { /* this is only useful if an offload flag is * set, but it does not hurt to fill it in any * case */ - m->l2_len = l2_len; - m->l3_len = l3_len; - m->l4_len = l4_len; + m->l2_len = info.l2_len; + m->l3_len = info.l3_len; + m->l4_len = info.l4_len; } - m->tso_segsz = tso_segsz; + m->tso_segsz = info.tso_segsz; m->ol_flags = ol_flags; /* if verbose mode is enabled, dump debug info */ @@ -515,27 +523,27 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* dump rx parsed packet info */ printf("rx: l2_len=%d ethertype=%x l3_len=%d " "l4_proto=%d l4_len=%d\n", - l2_len, rte_be_to_cpu_16(ethertype), - l3_len, l4_proto, l4_len); - if (tunnel == 1) + info.l2_len, rte_be_to_cpu_16(info.ethertype), + info.l3_len, info.l4_proto, info.l4_len); + if (info.is_tunnel == 1) printf("rx: outer_l2_len=%d outer_ethertype=%x " - "outer_l3_len=%d\n", outer_l2_len, - rte_be_to_cpu_16(outer_ethertype), - outer_l3_len); + "outer_l3_len=%d\n", info.outer_l2_len, + rte_be_to_cpu_16(info.outer_ethertype), + info.outer_l3_len); /* dump tx packet info */ if ((testpmd_ol_flags & (TESTPMD_TX_OFFLOAD_IP_CKSUM | TESTPMD_TX_OFFLOAD_UDP_CKSUM | TESTPMD_TX_OFFLOAD_TCP_CKSUM | TESTPMD_TX_OFFLOAD_SCTP_CKSUM)) || - tso_segsz != 0) + info.tso_segsz != 0) printf("tx: m->l2_len=%d m->l3_len=%d " "m->l4_len=%d\n", m->l2_len, m->l3_len, m->l4_len); - if ((tunnel == 1) && + if ((info.is_tunnel == 1) && (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM)) printf("tx: m->outer_l2_len=%d m->outer_l3_len=%d\n", m->outer_l2_len, m->outer_l3_len); - if (tso_segsz != 0) + if (info.tso_segsz != 0) printf("tx: m->tso_segsz=%d\n", m->tso_segsz); printf("tx: flags="); for (j = 0; j < sizeof(tx_flags)/sizeof(*tx_flags); j++) { -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 12/20] testpmd: introduce parse_vxlan in csum fwd engine 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (10 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 11/20] testpmd: use a structure to store offload info " Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 13/20] testpmd: support gre tunnels " Olivier Matz ` (9 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev Move code parsing vxlan into a function. It will ease the support of GRE tunnels and IPIP tunnels in next commits. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 68 +++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 0b89d89..ba9049f 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -93,7 +93,6 @@ struct testpmd_offload_info { uint16_t l3_len; uint16_t l4_len; uint8_t l4_proto; - uint8_t l4_tun_len; uint8_t is_tunnel; uint16_t outer_ethertype; uint16_t outer_l2_len; @@ -191,6 +190,34 @@ parse_ethernet(struct ether_hdr *eth_hdr, struct testpmd_offload_info *info) } } +/* Parse a vxlan header */ +static void +parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, + uint64_t mbuf_olflags) +{ + struct ether_hdr *eth_hdr; + + /* check udp destination port, 4789 is the default vxlan port + * (rfc7348) or that the rx offload flag is set (i40e only + * currently) */ + if (udp_hdr->dst_port != _htons(4789) && + (mbuf_olflags & (PKT_RX_TUNNEL_IPV4_HDR | + PKT_RX_TUNNEL_IPV6_HDR)) == 0) + return; + + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + eth_hdr = (struct ether_hdr *)((char *)udp_hdr + + sizeof(struct udp_hdr) + + sizeof(struct vxlan_hdr)); + + parse_ethernet(eth_hdr, info); + info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */ +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -356,7 +383,6 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) struct rte_mbuf *m; struct ether_hdr *eth_hdr; void *l3_hdr = NULL, *outer_l3_hdr = NULL; /* can be IPv4 or IPv6 */ - struct udp_hdr *udp_hdr; uint16_t nb_rx; uint16_t nb_tx; uint16_t i; @@ -414,33 +440,15 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* check if it's a supported tunnel (only vxlan for now) */ if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && info.l4_proto == IPPROTO_UDP) { + struct udp_hdr *udp_hdr; udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info.l3_len); + parse_vxlan(udp_hdr, &info, m->ol_flags); + } - /* check udp destination port, 4789 is the default - * vxlan port (rfc7348) */ - if (udp_hdr->dst_port == _htons(4789)) { - info.l4_tun_len = ETHER_VXLAN_HLEN; - info.is_tunnel = 1; - - /* currently, this flag is set by i40e only if the - * packet is vxlan */ - } else if (m->ol_flags & (PKT_RX_TUNNEL_IPV4_HDR | - PKT_RX_TUNNEL_IPV6_HDR)) - info.is_tunnel = 1; - - if (info.is_tunnel == 1) { - info.outer_ethertype = info.ethertype; - info.outer_l2_len = info.l2_len; - info.outer_l3_len = info.l3_len; - outer_l3_hdr = l3_hdr; - - eth_hdr = (struct ether_hdr *)((char *)udp_hdr + - sizeof(struct udp_hdr) + - sizeof(struct vxlan_hdr)); - - parse_ethernet(eth_hdr, &info); - l3_hdr = (char *)eth_hdr + info.l2_len; - } + /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ + if (info.is_tunnel) { + outer_l3_hdr = l3_hdr; + l3_hdr = (char *)l3_hdr + info.outer_l3_len + info.l2_len; } /* step 2: change all source IPs (v4 or v6) so we need @@ -472,7 +480,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { m->outer_l2_len = info.outer_l2_len; m->outer_l3_len = info.outer_l3_len; - m->l2_len = info.l4_tun_len + info.l2_len; + m->l2_len = info.l2_len; m->l3_len = info.l3_len; } else { @@ -482,9 +490,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) the payload will be modified by the hardware */ m->l2_len = info.outer_l2_len + - info.outer_l3_len + - sizeof(struct udp_hdr) + - sizeof(struct vxlan_hdr) + info.l2_len; + info.outer_l3_len + info.l2_len; m->l3_len = info.l3_len; m->l4_len = info.l4_len; } -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 13/20] testpmd: support gre tunnels in csum fwd engine 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (11 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 12/20] testpmd: introduce parse_vxlan " Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 14/20] testpmd: support ipip tunnel in csum forward engine Olivier Matz ` (8 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev Add support for Ethernet over GRE and IP over GRE tunnels. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 6 ++-- app/test-pmd/csumonly.c | 87 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 84 insertions(+), 9 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 363da9a..b19869c 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -322,9 +322,9 @@ static void cmd_help_long_parsed(void *parsed_result, " checksum with when transmitting a packet using the" " csum forward engine.\n" " ip|udp|tcp|sctp always concern the inner layer.\n" - " outer-ip concerns the outer IP layer (in" - " case the packet is recognized as a vxlan packet by" - " the forward engine)\n" + " outer-ip concerns the outer IP layer in" + " case the packet is recognized as a tunnel packet by" + " the forward engine (vxlan and gre are supported)\n" " Please check the NIC datasheet for HW limits.\n\n" "csum parse-tunnel (on|off) (tx_port_id)\n" diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index ba9049f..6623704 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -100,6 +100,12 @@ struct testpmd_offload_info { uint16_t tso_segsz; }; +/* simplified GRE header (flags must be 0) */ +struct simple_gre_hdr { + uint16_t flags; + uint16_t proto; +}; + static uint16_t get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags) { @@ -218,6 +224,60 @@ parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */ } +/* Parse a gre header */ +static void +parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) +{ + struct ether_hdr *eth_hdr; + struct ipv4_hdr *ipv4_hdr; + struct ipv6_hdr *ipv6_hdr; + + /* if flags != 0; it's not supported */ + if (gre_hdr->flags != 0) + return; + + if (gre_hdr->proto == _htons(ETHER_TYPE_IPv4)) { + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + ipv4_hdr = (struct ipv4_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + parse_ipv4(ipv4_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv4); + info->l2_len = 0; + + } else if (gre_hdr->proto == _htons(ETHER_TYPE_IPv6)) { + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + ipv6_hdr = (struct ipv6_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + info->ethertype = _htons(ETHER_TYPE_IPv6); + parse_ipv6(ipv6_hdr, info); + info->l2_len = 0; + + } else if (gre_hdr->proto == _htons(0x6558)) { /* ETH_P_TEB in linux */ + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + eth_hdr = (struct ether_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + parse_ethernet(eth_hdr, info); + } else + return; + + info->l2_len += sizeof(struct simple_gre_hdr); +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -368,6 +428,8 @@ uint16_t testpmd_ol_flags) * Ether / (vlan) / IP|IP6 / UDP|TCP|SCTP . * Ether / (vlan) / outer IP|IP6 / outer UDP / VxLAN / Ether / IP|IP6 / * UDP|TCP|SCTP + * Ether / (vlan) / outer IP|IP6 / GRE / Ether / IP|IP6 / UDP|TCP|SCTP + * Ether / (vlan) / outer IP|IP6 / GRE / IP|IP6 / UDP|TCP|SCTP * * The testpmd command line for this forward engine sets the flags * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control @@ -437,12 +499,25 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) parse_ethernet(eth_hdr, &info); l3_hdr = (char *)eth_hdr + info.l2_len; - /* check if it's a supported tunnel (only vxlan for now) */ - if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && - info.l4_proto == IPPROTO_UDP) { - struct udp_hdr *udp_hdr; - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info.l3_len); - parse_vxlan(udp_hdr, &info, m->ol_flags); + /* check if it's a supported tunnel */ + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) { + if (info.l4_proto == IPPROTO_UDP) { + struct udp_hdr *udp_hdr; + udp_hdr = (struct udp_hdr *)((char *)l3_hdr + + info.l3_len); + parse_vxlan(udp_hdr, &info, m->ol_flags); + } else if (info.l4_proto == IPPROTO_GRE) { + struct simple_gre_hdr *gre_hdr; + gre_hdr = (struct simple_gre_hdr *) + ((char *)l3_hdr + info.l3_len); + parse_gre(gre_hdr, &info); + } + } + info.l4_proto == IPPROTO_GRE) { + struct simple_gre_hdr *gre_hdr; + gre_hdr = (struct simple_gre_hdr *)((char *)l3_hdr + + info.l3_len); + parse_gre(gre_hdr, &info); } /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 14/20] testpmd: support ipip tunnel in csum forward engine 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (12 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 13/20] testpmd: support gre tunnels " Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 15/20] ethdev: add outer IP offload capability flag Olivier Matz ` (7 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev Add support for IP over IP tunnels. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 2 +- app/test-pmd/csumonly.c | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index b19869c..fc08183 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -324,7 +324,7 @@ static void cmd_help_long_parsed(void *parsed_result, " ip|udp|tcp|sctp always concern the inner layer.\n" " outer-ip concerns the outer IP layer in" " case the packet is recognized as a tunnel packet by" - " the forward engine (vxlan and gre are supported)\n" + " the forward engine (vxlan, gre and ipip are supported)\n" " Please check the NIC datasheet for HW limits.\n\n" "csum parse-tunnel (on|off) (tx_port_id)\n" diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 6623704..88f7696 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -278,6 +278,35 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) info->l2_len += sizeof(struct simple_gre_hdr); } + +/* Parse an encapsulated ip or ipv6 header */ +static void +parse_encap_ip(void *encap_ip, struct testpmd_offload_info *info) +{ + struct ipv4_hdr *ipv4_hdr = encap_ip; + struct ipv6_hdr *ipv6_hdr = encap_ip; + uint8_t ip_version; + + ip_version = (ipv4_hdr->version_ihl & 0xf0) >> 4; + + if (ip_version != 4 && ip_version != 6) + return; + + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + if (ip_version == 4) { + parse_ipv4(ipv4_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv4); + } else { + parse_ipv6(ipv6_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv6); + } + info->l2_len = 0; +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -430,6 +459,7 @@ uint16_t testpmd_ol_flags) * UDP|TCP|SCTP * Ether / (vlan) / outer IP|IP6 / GRE / Ether / IP|IP6 / UDP|TCP|SCTP * Ether / (vlan) / outer IP|IP6 / GRE / IP|IP6 / UDP|TCP|SCTP + * Ether / (vlan) / outer IP|IP6 / IP|IP6 / UDP|TCP|SCTP * * The testpmd command line for this forward engine sets the flags * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control @@ -511,14 +541,12 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) gre_hdr = (struct simple_gre_hdr *) ((char *)l3_hdr + info.l3_len); parse_gre(gre_hdr, &info); + } else if (info.l4_proto == IPPROTO_IPIP) { + void *encap_ip_hdr; + encap_ip_hdr = (char *)l3_hdr + info.l3_len; + parse_encap_ip(encap_ip_hdr, &info); } } - info.l4_proto == IPPROTO_GRE) { - struct simple_gre_hdr *gre_hdr; - gre_hdr = (struct simple_gre_hdr *)((char *)l3_hdr + - info.l3_len); - parse_gre(gre_hdr, &info); - } /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ if (info.is_tunnel) { -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 15/20] ethdev: add outer IP offload capability flag 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (13 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 14/20] testpmd: support ipip tunnel in csum forward engine Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 16/20] i40e: advertise outer IPv4 checksum capability Olivier Matz ` (6 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev From: Jijiang Liu <jijiang.liu@intel.com> If the flag is advertised by a PMD, the NIC supports the outer IP checksum TX offload of tunneling packets, therefore an application can set the PKT_TX_OUTER_IP_CKSUM flag in mbufs when transmitting on this port. Signed-off-by: Jijiang Liu <jijiang.liu@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_ether/rte_ethdev.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 1200c1c..84160c3 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -916,6 +916,7 @@ struct rte_eth_conf { #define DEV_TX_OFFLOAD_SCTP_CKSUM 0x00000010 #define DEV_TX_OFFLOAD_TCP_TSO 0x00000020 #define DEV_TX_OFFLOAD_UDP_TSO 0x00000040 +#define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080 /**< Used for tunneling packet. */ struct rte_eth_dev_info { struct rte_pci_device *pci_dev; /**< Device PCI information. */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 16/20] i40e: advertise outer IPv4 checksum capability 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (14 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 15/20] ethdev: add outer IP offload capability flag Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 17/20] testpmd: add a warning if outer ip cksum requested but not supported Olivier Matz ` (5 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev From: Jijiang Liu <jijiang.liu@intel.com> Advertise the DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM flag in the PMD features. It means that the i40e PMD supports the offload of outer IP checksum when transmitting tunneling packet. Signed-off-by: Jijiang Liu <jijiang.liu@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c b/lib/librte_pmd_i40e/i40e_ethdev.c index 9fa6bec..6f385d2 100644 --- a/lib/librte_pmd_i40e/i40e_ethdev.c +++ b/lib/librte_pmd_i40e/i40e_ethdev.c @@ -1529,7 +1529,8 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) DEV_TX_OFFLOAD_IPV4_CKSUM | DEV_TX_OFFLOAD_UDP_CKSUM | DEV_TX_OFFLOAD_TCP_CKSUM | - DEV_TX_OFFLOAD_SCTP_CKSUM; + DEV_TX_OFFLOAD_SCTP_CKSUM | + DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; dev_info->reta_size = pf->hash_lut_size; dev_info->default_rxconf = (struct rte_eth_rxconf) { -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 17/20] testpmd: add a warning if outer ip cksum requested but not supported 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (15 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 16/20] i40e: advertise outer IPv4 checksum capability Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 18/20] testpmd: fix TSO when using outer checksum offloads Olivier Matz ` (4 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index fc08183..9de3e7e 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2930,7 +2930,11 @@ csum_show(int port_id) printf("Warning: hardware SCTP checksum enabled but not " "supported by port %d\n", port_id); } - + if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { + printf("Warning: hardware outer IP checksum enabled but not " + "supported by port %d\n", port_id); + } } static void -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 18/20] testpmd: fix TSO when using outer checksum offloads 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (16 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 17/20] testpmd: add a warning if outer ip cksum requested but not supported Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 19/20] i40e: fix offloading of outer checksum for ip in ip tunnels Olivier Matz ` (3 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev The l4_len has also to be copied in mbuf in case we are offloading outer IP checksum. Currently, TSO + outer checksum is not supported by any driver but it will soon be supported by i40e. Pointed-out-by: Jijiang Liu <jijiang.liu@intel.com> Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 1 + 1 file changed, 1 insertion(+) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 88f7696..5ddbaf5 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -585,6 +585,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) m->outer_l3_len = info.outer_l3_len; m->l2_len = info.l2_len; m->l3_len = info.l3_len; + m->l4_len = info.l4_len; } else { /* if there is a outer UDP cksum -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 19/20] i40e: fix offloading of outer checksum for ip in ip tunnels 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (17 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 18/20] testpmd: fix TSO when using outer checksum offloads Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 20/20] i40e: add debug logs for tx context descriptors Olivier Matz ` (2 subsequent siblings) 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev When offloading the checksums of ipip tunnels, m->l2_len is set to 0 as there is no tunnel or inner l2 header. Since this is a valid value remove the test. By the way, also remove the same test with l3_len because at this point, it is expected that the software provides proper values in the mbuf. It should avoid a test in dataplane processing and therefore slightly increase performance. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_rxtx.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 0786255..3031bd7 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -471,16 +471,6 @@ i40e_txd_enable_checksum(uint64_t ol_flags, uint16_t outer_l3_len, uint32_t *cd_tunneling) { - if (!l2_len) { - PMD_DRV_LOG(DEBUG, "L2 length set to 0"); - return; - } - - if (!l3_len) { - PMD_DRV_LOG(DEBUG, "L3 length set to 0"); - return; - } - /* UDP tunneling packet TX checksum offload */ if (unlikely(ol_flags & PKT_TX_OUTER_IP_CKSUM)) { -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v2 20/20] i40e: add debug logs for tx context descriptors 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (18 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 19/20] i40e: fix offloading of outer checksum for ip in ip tunnels Olivier Matz @ 2015-02-04 9:25 ` Olivier Matz 2015-02-09 1:10 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Liu, Jijiang 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz 21 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-04 9:25 UTC (permalink / raw) To: dev This could be useful to have this values for debug purposes. Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com> Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_rxtx.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 3031bd7..349c1e5 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -1298,6 +1298,18 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) ctx_txd->l2tag2 = rte_cpu_to_le_16(cd_l2tag2); ctx_txd->type_cmd_tso_mss = rte_cpu_to_le_64(cd_type_cmd_tso_mss); + + PMD_TX_LOG(DEBUG, "mbuf: %p, TCD[%u]:\n" + "tunneling_params: %#x;\n" + "l2tag2: %#hx;\n" + "rsvd: %#hx;\n" + "type_cmd_tso_mss: %#lx;\n", + tx_pkt, tx_id, + ctx_txd->tunneling_params, + ctx_txd->l2tag2, + ctx_txd->rsvd, + ctx_txd->type_cmd_tso_mss); + txe->last_id = tx_last; tx_id = txe->next_id; txe = txn; @@ -1315,6 +1327,16 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) /* Setup TX Descriptor */ slen = m_seg->data_len; buf_dma_addr = RTE_MBUF_DATA_DMA_ADDR(m_seg); + + PMD_TX_LOG(DEBUG, "mbuf: %p, TDD[%u]:\n" + "buf_dma_addr: %#"PRIx64";\n" + "td_cmd: %#x;\n" + "td_offset: %#x;\n" + "td_len: %u;\n" + "td_tag: %#x;\n", + tx_pkt, tx_id, buf_dma_addr, + td_cmd, td_offset, slen, td_tag); + txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr); txd->cmd_type_offset_bsz = i40e_build_ctob(td_cmd, td_offset, slen, td_tag); -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (19 preceding siblings ...) 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 20/20] i40e: add debug logs for tx context descriptors Olivier Matz @ 2015-02-09 1:10 ` Liu, Jijiang 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz 21 siblings, 0 replies; 109+ messages in thread From: Liu, Jijiang @ 2015-02-09 1:10 UTC (permalink / raw) To: Olivier Matz, dev > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Wednesday, February 04, 2015 5:25 PM > To: dev@dpdk.org > Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; olivier.matz@6wind.com > Subject: [PATCH v2 00/20] enhance tx checksum offload API > > The goal of this series is to clarify and simplify the mbuf offload API. > > - simplify the definitions of PKT_TX_IP_CKSUM and PKT_TX_IPV4, each > flag has now only one meaning. No impact on the code. > > - add a feature flag for OUTER_IP_CHECKSUM (from Jijiang's patches) > > - remove the PKT_TX_UDP_TUNNEL_PKT flag: it is useless from an API point > of view. It was added because i40e need this info for some reason. We > have 3 solutions: > > - remove the flag and adapt the driver to the API (the choice I made > for this series). > > - remove the flag and stop advertising OUTER_IP_CHECKSUM in i40e > > - keep this flag, penalizing performance of drivers that do not > require the flag. It would also mean that drivers won't support > outer IP checksum for all tunnel types, but only for the tunnel > types having a flag. This flag is removed in this patch set, the reason is that we have done some tests for validating L4 tunnel type(L4TUNT) and found checksum offload works well with L4TUNT=0 for VXLAN, MAC over GRE, ip over GRE, IP in IP(we only tested IPv4); but FVL designer suggest that we should follow FVL datasheet. Anyway, once we find the 'L4TUNT=0' is not fit for other cases, and we still need the PKT_TX_UDP_TUNNEL_PKT flag. > - a side effect of this API clarification is that there is only one > way for doing one operation. If the hardware has several ways to > do the same operation, a choice has to be made in the driver. > > The series also provide some enhancements and fixes related to this API > rework: > > - new tunnel types to testpmd csum forward engine. > - fixes in i40e to adapt to new api and support more tunnel types. > > [1] http://dpdk.org/ml/archives/dev/2015-January/011127.html > > Changes in v2: > - fix test of rx offload flag in parse_vlan() pointed out by Jijiang > > Jijiang Liu (2): > ethdev: add outer IP offload capability flag > i40e: advertise outer IPv4 checksum capability > > Olivier Matz (18): > mbuf: remove PKT_TX_IPV4_CSUM > mbuf: enhance the API documentation of offload flags > i40e: call i40e_txd_enable_checksum only for offloaded packets > i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag > mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag > testpmd: replace tx_checksum command by csum > testpmd: move csum_show in a function > testpmd: add csum parse_tunnel command > testpmd: rename vxlan in outer_ip in csum commands > testpmd: introduce parse_ipv* in csum fwd engine > testpmd: use a structure to store offload info in csum fwd engine > testpmd: introduce parse_vxlan in csum fwd engine > testpmd: support gre tunnels in csum fwd engine > testpmd: support ipip tunnel in csum forward engine > testpmd: add a warning if outer ip cksum requested but not supported > testpmd: fix TSO when using outer checksum offloads > i40e: fix offloading of outer checksum for ip in ip tunnels > i40e: add debug logs for tx context descriptors > > app/test-pmd/cmdline.c | 234 ++++++++++++++------- > app/test-pmd/csumonly.c | 417 +++++++++++++++++++++++++-------- > ----- > app/test-pmd/testpmd.h | 9 +- > lib/librte_ether/rte_ethdev.h | 1 + > lib/librte_mbuf/rte_mbuf.c | 1 - > lib/librte_mbuf/rte_mbuf.h | 49 +++-- > lib/librte_pmd_i40e/i40e_ethdev.c | 3 +- > lib/librte_pmd_i40e/i40e_rxtx.c | 55 +++-- > 8 files changed, 519 insertions(+), 250 deletions(-) > > -- > 2.1.4 Acked-by: Jijiang Liu <Jijiang.liu@intel.com> ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 00/20] enhance tx checksum offload API 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz ` (20 preceding siblings ...) 2015-02-09 1:10 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Liu, Jijiang @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 01/20] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz ` (20 more replies) 21 siblings, 21 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev The goal of this series is to clarify and simplify the mbuf offload API. - simplify the definitions of PKT_TX_IP_CKSUM and PKT_TX_IPV4, each flag has now only one meaning. No impact on the code. - add a feature flag for OUTER_IP_CHECKSUM (from Jijiang's patches) - remove the PKT_TX_UDP_TUNNEL_PKT flag: it is useless from an API point of view. It was added because i40e need this info for some reason. We have 3 solutions: - remove the flag and adapt the driver to the API (the choice I made for this series). - remove the flag and stop advertising OUTER_IP_CHECKSUM in i40e - keep this flag, penalizing performance of drivers that do not require the flag. It would also mean that drivers won't support outer IP checksum for all tunnel types, but only for the tunnel types having a flag. - a side effect of this API clarification is that there is only one way for doing one operation. If the hardware has several ways to do the same operation, a choice has to be made in the driver. The series also provide some enhancements and fixes related to this API rework: - new tunnel types to testpmd csum forward engine. - fixes in i40e to adapt to new api and support more tunnel types. [1] http://dpdk.org/ml/archives/dev/2015-January/011127.html Changes in v2: - fix test of rx offload flag in parse_vlan() pointed out by Jijiang Changes in v3: - more detailed API comments for PKT_TX_IPV4 and PKT_TX_IPV6 - do not calculate the outer UDP checksum if packet is not UDP - add a likely() in i40e - remove a unlikely() in i40e - fix a patch split issue - rebase on head Jijiang Liu (2): ethdev: add outer IP offload capability flag i40e: advertise outer IPv4 checksum capability Olivier Matz (18): mbuf: remove PKT_TX_IPV4_CSUM mbuf: enhance the API documentation of offload flags i40e: call i40e_txd_enable_checksum only for offloaded packets i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag testpmd: replace tx_checksum command by csum testpmd: move csum_show in a function testpmd: add csum parse_tunnel command testpmd: rename vxlan in outer_ip in csum commands testpmd: introduce parse_ipv* in csum fwd engine testpmd: use a structure to store offload info in csum fwd engine testpmd: introduce parse_vxlan in csum fwd engine testpmd: support gre tunnels in csum fwd engine testpmd: support ipip tunnel in csum forward engine testpmd: add a warning if outer ip cksum requested but not supported testpmd: fix TSO when using outer checksum offloads i40e: fix offloading of outer checksum for ip in ip tunnels i40e: add debug logs for tx context descriptors app/test-pmd/cmdline.c | 234 ++++++++++++++------- app/test-pmd/csumonly.c | 425 ++++++++++++++++++++++++++------------ app/test-pmd/testpmd.h | 9 +- lib/librte_ether/rte_ethdev.h | 1 + lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 51 +++-- lib/librte_pmd_i40e/i40e_ethdev.c | 3 +- lib/librte_pmd_i40e/i40e_rxtx.c | 55 +++-- 8 files changed, 529 insertions(+), 250 deletions(-) -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 01/20] mbuf: remove PKT_TX_IPV4_CSUM 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 02/20] mbuf: enhance the API documentation of offload flags Olivier Matz ` (19 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev This alias is only used in one place of i40e driver. Remove it and only keep the legacy flag PKT_TX_IP_CSUM. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_mbuf/rte_mbuf.h | 1 - lib/librte_pmd_i40e/i40e_rxtx.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 16059c6..a554247 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -142,7 +142,6 @@ extern "C" { #define PKT_TX_L4_MASK (3ULL << 52) /**< Mask for L4 cksum offload request. */ #define PKT_TX_IP_CKSUM (1ULL << 54) /**< IP cksum of TX pkt. computed by NIC. */ -#define PKT_TX_IPV4_CSUM PKT_TX_IP_CKSUM /**< Alias of PKT_TX_IP_CKSUM. */ /** Packet is IPv4 without requiring IP checksum offload. */ #define PKT_TX_IPV4 (1ULL << 55) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 2beae3c..8e9df96 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -501,7 +501,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags, << I40E_TX_DESC_LENGTH_MACLEN_SHIFT; /* Enable L3 checksum offloads */ - if (ol_flags & PKT_TX_IPV4_CSUM) { + if (ol_flags & PKT_TX_IP_CKSUM) { *td_cmd |= I40E_TX_DESC_CMD_IIPT_IPV4_CSUM; *td_offset |= (l3_len >> 2) << I40E_TX_DESC_LENGTH_IPLEN_SHIFT; } else if (ol_flags & PKT_TX_IPV4) { -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 02/20] mbuf: enhance the API documentation of offload flags 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 01/20] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets Olivier Matz ` (18 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev Based on http://dpdk.org/ml/archives/dev/2015-January/011127.html Also adapt the csum forward engine code to the API. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 6 +++--- lib/librte_mbuf/rte_mbuf.h | 45 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 41711fd..4b438d1 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -183,16 +183,15 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, ipv4_hdr = l3_hdr; ipv4_hdr->hdr_checksum = 0; + ol_flags |= PKT_TX_IPV4; if (tso_segsz != 0 && l4_proto == IPPROTO_TCP) { ol_flags |= PKT_TX_IP_CKSUM; } else { if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ol_flags |= PKT_TX_IP_CKSUM; - else { + else ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); - ol_flags |= PKT_TX_IPV4; - } } } else if (ethertype == _htons(ETHER_TYPE_IPv6)) ol_flags |= PKT_TX_IPV6; @@ -261,6 +260,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr->hdr_checksum = 0; + ol_flags |= PKT_TX_OUTER_IPV4; if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ol_flags |= PKT_TX_OUTER_IP_CKSUM; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index a554247..cefb54a 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -141,24 +141,55 @@ extern "C" { #define PKT_TX_UDP_CKSUM (3ULL << 52) /**< UDP cksum of TX pkt. computed by NIC. */ #define PKT_TX_L4_MASK (3ULL << 52) /**< Mask for L4 cksum offload request. */ -#define PKT_TX_IP_CKSUM (1ULL << 54) /**< IP cksum of TX pkt. computed by NIC. */ +/** + * Offload the IP checksum in the hardware. The flag PKT_TX_IPV4 should + * also be set by the application, although a PMD will only check + * PKT_TX_IP_CKSUM. + * - set the IP checksum field in the packet to 0 + * - fill the mbuf offload information: l2_len, l3_len + */ +#define PKT_TX_IP_CKSUM (1ULL << 54) -/** Packet is IPv4 without requiring IP checksum offload. */ +/** + * Packet is IPv4. This flag must be set when using any offload feature + * (TSO, L3 or L4 checksum) to tell the NIC that the packet is an IPv4 + * packet. If the packet is a tunneled packet, this flag is related to + * the inner headers. + */ #define PKT_TX_IPV4 (1ULL << 55) -/** Tell the NIC it's an IPv6 packet.*/ +/** + * Packet is IPv6. This flag must be set when using an offload feature + * (TSO or L4 checksum) to tell the NIC that the packet is an IPv6 + * packet. If the packet is a tunneled packet, this flag is related to + * the inner headers. + */ #define PKT_TX_IPV6 (1ULL << 56) #define PKT_TX_VLAN_PKT (1ULL << 57) /**< TX packet is a 802.1q VLAN packet. */ -/** Outer IP checksum of TX packet, computed by NIC for tunneling packet. - * The tunnel type must also be specified, ex: PKT_TX_UDP_TUNNEL_PKT. */ +/** + * Offload the IP checksum of an external header in the hardware. The + * flag PKT_TX_OUTER_IPV4 should also be set by the application, alto ugh + * a PMD will only check PKT_TX_IP_CKSUM. The IP checksum field in the + * packet must be set to 0. + * - set the outer IP checksum field in the packet to 0 + * - fill the mbuf offload information: outer_l2_len, outer_l3_len + */ #define PKT_TX_OUTER_IP_CKSUM (1ULL << 58) -/** Packet is outer IPv4 without requiring IP checksum offload for tunneling packet. */ +/** + * Packet outer header is IPv4. This flag must be set when using any + * outer offload feature (L3 or L4 checksum) to tell the NIC that the + * outer header of the tunneled packet is an IPv4 packet. + */ #define PKT_TX_OUTER_IPV4 (1ULL << 59) -/** Tell the NIC it's an outer IPv6 packet for tunneling packet */ +/** + * Packet outer header is IPv6. This flag must be set when using any + * outer offload feature (L4 checksum) to tell the NIC that the outer + * header of the tunneled packet is an IPv6 packet. + */ #define PKT_TX_OUTER_IPV6 (1ULL << 60) /* Use final bit of flags to indicate a control mbuf */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 01/20] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 02/20] mbuf: enhance the API documentation of offload flags Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag Olivier Matz ` (17 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev >From i40e datasheet: The IP header type and its offload. In case of tunneling, the IIPT relates to the inner IP header. See also EIPT field for the outer (External) IP header offload. 00 - non IP packet or packet type is not defined by software 01 - IPv6 packet 10 - IPv4 packet with no IP checksum offload 11 - IPv4 packet with IP checksum offload Therefore it is not needed to fill the IIPT field if no offload is requested (we can keep the value to 00). For instance, the linux driver code does not set it when (skb->ip_summed != CHECKSUM_PARTIAL). We can do the same in the dpdk driver. The function i40e_txd_enable_checksum() that fills the offload registers can only be called for packets requiring an offload. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_rxtx.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 8e9df96..b467461 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -74,6 +74,11 @@ #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS) +#define I40E_TX_CKSUM_OFFLOAD_MASK ( \ + PKT_TX_IP_CKSUM | \ + PKT_TX_L4_MASK | \ + PKT_TX_OUTER_IP_CKSUM) + #define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \ (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM) @@ -1272,10 +1277,12 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) /* Enable checksum offloading */ cd_tunneling_params = 0; - i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, - l2_len, l3_len, outer_l2_len, - outer_l3_len, - &cd_tunneling_params); + if (unlikely(ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK)) { + i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset, + l2_len, l3_len, outer_l2_len, + outer_l3_len, + &cd_tunneling_params); + } if (unlikely(nb_ctx)) { /* Setup TX context descriptor if required */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (2 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 05/20] mbuf: remove " Olivier Matz ` (16 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev The definition of the flag in rte_mbuf.h was: TX packet is an UDP tunneled packet. It must be specified when using outer checksum offload (PKT_TX_OUTER_IP_CKSUM) This flag was used to tell the NIC that the offload type is UDP (I40E_TXD_CTX_UDP_TUNNELING flag). In the datasheet, it says it's required to specify the tunnel type in the register. However, some tests (see [1]) showed that it also works without this flag. Moreover, it is not explained how the hardware use this information. From a network perspective, this information is useless for calculating the outer IP checksum as it does not depend on the payload. Having this flag in the API would force the application to specify the tunnel type for something that looks only useful for this PMD. It will limit the number of possible tunnel types (we would need a flag for each tunnel type) and therefore prevent to support outer IP checksum for proprietary tunnels. Finally, if a hardware advertises "I support outer IP checksum", it must be supported for any payload types. This has been validated by [2], knowing that the ipip test case was fixed after this test report [3]. [1] http://dpdk.org/ml/archives/dev/2015-January/011380.html [2] http://dpdk.org/ml/archives/dev/2015-January/011475.html [3] http://dpdk.org/ml/archives/dev/2015-January/011610.html Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_rxtx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index b467461..d7b55d8 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -482,7 +482,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags, } /* UDP tunneling packet TX checksum offload */ - if (unlikely(ol_flags & PKT_TX_UDP_TUNNEL_PKT)) { + if (unlikely(ol_flags & PKT_TX_OUTER_IP_CKSUM)) { *td_offset |= (outer_l2_len >> 1) << I40E_TX_DESC_LENGTH_MACLEN_SHIFT; @@ -497,7 +497,6 @@ i40e_txd_enable_checksum(uint64_t ol_flags, /* Now set the ctx descriptor fields */ *cd_tunneling |= (outer_l3_len >> 2) << I40E_TXD_CTX_QW0_EXT_IPLEN_SHIFT | - I40E_TXD_CTX_UDP_TUNNELING | (l2_len >> 1) << I40E_TXD_CTX_QW0_NATLEN_SHIFT; @@ -1165,8 +1164,7 @@ i40e_calc_context_desc(uint64_t flags) { uint64_t mask = 0ULL; - if (flags | PKT_TX_UDP_TUNNEL_PKT) - mask |= PKT_TX_UDP_TUNNEL_PKT; + mask |= PKT_TX_OUTER_IP_CKSUM; #ifdef RTE_LIBRTE_IEEE1588 mask |= PKT_TX_IEEE1588_TMST; -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 05/20] mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (3 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 06/20] testpmd: replace tx_checksum command by csum Olivier Matz ` (15 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev Since previous commit, this flag is not used by any PMD, remove it from mbuf API and from csumonly (testpmd). In csumonly, the PKT_TX_OUTER_IP_CKSUM flag is already set for vxlan checksum, providing enough information to the underlying driver. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 4 ---- lib/librte_mbuf/rte_mbuf.c | 1 - lib/librte_mbuf/rte_mbuf.h | 5 +---- lib/librte_pmd_i40e/i40e_rxtx.c | 2 +- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 4b438d1..ca5ca39 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -255,9 +255,6 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, struct udp_hdr *udp_hdr; uint64_t ol_flags = 0; - if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) - ol_flags |= PKT_TX_UDP_TUNNEL_PKT; - if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_OUTER_IPV4; @@ -473,7 +470,6 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) { PKT_TX_UDP_CKSUM, PKT_TX_L4_MASK }, { PKT_TX_TCP_CKSUM, PKT_TX_L4_MASK }, { PKT_TX_SCTP_CKSUM, PKT_TX_L4_MASK }, - { PKT_TX_UDP_TUNNEL_PKT, PKT_TX_UDP_TUNNEL_PKT }, { PKT_TX_IPV4, PKT_TX_IPV4 }, { PKT_TX_IPV6, PKT_TX_IPV6 }, { PKT_TX_OUTER_IP_CKSUM, PKT_TX_OUTER_IP_CKSUM }, diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 1b14e02..2a4bc8c 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -240,7 +240,6 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask) case PKT_TX_SCTP_CKSUM: return "PKT_TX_SCTP_CKSUM"; case PKT_TX_UDP_CKSUM: return "PKT_TX_UDP_CKSUM"; case PKT_TX_IEEE1588_TMST: return "PKT_TX_IEEE1588_TMST"; - case PKT_TX_UDP_TUNNEL_PKT: return "PKT_TX_UDP_TUNNEL_PKT"; case PKT_TX_TCP_SEG: return "PKT_TX_TCP_SEG"; case PKT_TX_IPV4: return "PKT_TX_IPV4"; case PKT_TX_IPV6: return "PKT_TX_IPV6"; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index cefb54a..e3008c6 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -117,11 +117,8 @@ extern "C" { * and set it in the TCP header. Refer to rte_ipv4_phdr_cksum() and * rte_ipv6_phdr_cksum() that can be used as helpers. */ -#define PKT_TX_TCP_SEG (1ULL << 49) +#define PKT_TX_TCP_SEG (1ULL << 50) -/** TX packet is an UDP tunneled packet. It must be specified when using - * outer checksum offload (PKT_TX_OUTER_IP_CKSUM) */ -#define PKT_TX_UDP_TUNNEL_PKT (1ULL << 50) /**< TX packet is an UDP tunneled packet */ #define PKT_TX_IEEE1588_TMST (1ULL << 51) /**< TX IEEE1588 packet to timestamp. */ /** diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index d7b55d8..d2f9a97 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -482,7 +482,7 @@ i40e_txd_enable_checksum(uint64_t ol_flags, } /* UDP tunneling packet TX checksum offload */ - if (unlikely(ol_flags & PKT_TX_OUTER_IP_CKSUM)) { + if (ol_flags & PKT_TX_OUTER_IP_CKSUM) { *td_offset |= (outer_l2_len >> 1) << I40E_TX_DESC_LENGTH_MACLEN_SHIFT; -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 06/20] testpmd: replace tx_checksum command by csum 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (4 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 05/20] mbuf: remove " Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 07/20] testpmd: move csum_show in a function Olivier Matz ` (14 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev Replace the "tx_checksum" command by "csum". It has several advantages: - it's more coherent with the forward engine name - it's shorter - the next commit will introduce a command that is related to the csum forward engine, but about rx side. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 70 +++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 590e427..270842f 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -317,7 +317,7 @@ static void cmd_help_long_parsed(void *parsed_result, " Disable hardware insertion of a VLAN header in" " packets sent on a port.\n\n" - "tx_cksum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n" + "csum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n" " Select hardware or software calculation of the" " checksum with when transmitting a packet using the" " csum forward engine.\n" @@ -327,7 +327,7 @@ static void cmd_help_long_parsed(void *parsed_result, " the forward engine)\n" " Please check the NIC datasheet for HW limits.\n\n" - "tx_checksum show (port_id)\n" + "csum show (port_id)\n" " Display tx checksum offload configuration\n\n" "tso set (segsize) (portid)\n" @@ -2874,8 +2874,8 @@ cmdline_parse_inst_t cmd_tx_vlan_reset = { /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ -struct cmd_tx_cksum_result { - cmdline_fixed_string_t tx_cksum; +struct cmd_csum_result { + cmdline_fixed_string_t csum; cmdline_fixed_string_t mode; cmdline_fixed_string_t proto; cmdline_fixed_string_t hwsw; @@ -2883,11 +2883,11 @@ struct cmd_tx_cksum_result { }; static void -cmd_tx_cksum_parsed(void *parsed_result, +cmd_csum_parsed(void *parsed_result, __attribute__((unused)) struct cmdline *cl, __attribute__((unused)) void *data) { - struct cmd_tx_cksum_result *res = parsed_result; + struct cmd_csum_result *res = parsed_result; int hw = 0; uint16_t ol_flags, mask = 0; struct rte_eth_dev_info dev_info; @@ -2956,49 +2956,49 @@ cmd_tx_cksum_parsed(void *parsed_result, } } -cmdline_parse_token_string_t cmd_tx_cksum_tx_cksum = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, - tx_cksum, "tx_checksum"); -cmdline_parse_token_string_t cmd_tx_cksum_mode = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_csum = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, + csum, "csum"); +cmdline_parse_token_string_t cmd_csum_mode = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, mode, "set"); -cmdline_parse_token_string_t cmd_tx_cksum_proto = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_proto = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, proto, "ip#tcp#udp#sctp#vxlan"); -cmdline_parse_token_string_t cmd_tx_cksum_hwsw = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_hwsw = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, hwsw, "hw#sw"); -cmdline_parse_token_num_t cmd_tx_cksum_portid = - TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_num_t cmd_csum_portid = + TOKEN_NUM_INITIALIZER(struct cmd_csum_result, port_id, UINT8); -cmdline_parse_inst_t cmd_tx_cksum_set = { - .f = cmd_tx_cksum_parsed, +cmdline_parse_inst_t cmd_csum_set = { + .f = cmd_csum_parsed, .data = NULL, .help_str = "enable/disable hardware calculation of L3/L4 checksum when " - "using csum forward engine: tx_cksum set ip|tcp|udp|sctp|vxlan hw|sw <port>", + "using csum forward engine: csum set ip|tcp|udp|sctp|vxlan hw|sw <port>", .tokens = { - (void *)&cmd_tx_cksum_tx_cksum, - (void *)&cmd_tx_cksum_mode, - (void *)&cmd_tx_cksum_proto, - (void *)&cmd_tx_cksum_hwsw, - (void *)&cmd_tx_cksum_portid, + (void *)&cmd_csum_csum, + (void *)&cmd_csum_mode, + (void *)&cmd_csum_proto, + (void *)&cmd_csum_hwsw, + (void *)&cmd_csum_portid, NULL, }, }; -cmdline_parse_token_string_t cmd_tx_cksum_mode_show = - TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_result, +cmdline_parse_token_string_t cmd_csum_mode_show = + TOKEN_STRING_INITIALIZER(struct cmd_csum_result, mode, "show"); -cmdline_parse_inst_t cmd_tx_cksum_show = { - .f = cmd_tx_cksum_parsed, +cmdline_parse_inst_t cmd_csum_show = { + .f = cmd_csum_parsed, .data = NULL, - .help_str = "show checksum offload configuration: tx_cksum show <port>", + .help_str = "show checksum offload configuration: csum show <port>", .tokens = { - (void *)&cmd_tx_cksum_tx_cksum, - (void *)&cmd_tx_cksum_mode_show, - (void *)&cmd_tx_cksum_portid, + (void *)&cmd_csum_csum, + (void *)&cmd_csum_mode_show, + (void *)&cmd_csum_portid, NULL, }, }; @@ -9050,8 +9050,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_tx_vlan_set, (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, - (cmdline_parse_inst_t *)&cmd_tx_cksum_set, - (cmdline_parse_inst_t *)&cmd_tx_cksum_show, + (cmdline_parse_inst_t *)&cmd_csum_set, + (cmdline_parse_inst_t *)&cmd_csum_show, (cmdline_parse_inst_t *)&cmd_tso_set, (cmdline_parse_inst_t *)&cmd_tso_show, (cmdline_parse_inst_t *)&cmd_link_flow_control_set, -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 07/20] testpmd: move csum_show in a function 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (5 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 06/20] testpmd: replace tx_checksum command by csum Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 08/20] testpmd: add csum parse_tunnel command Olivier Matz ` (13 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev No functional changes in this commit, we just move the code that displays the csum forward engine configuration in a function. This makes the next commit easier to read as it will also use this function. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 82 +++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 270842f..55768f1 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2883,14 +2883,56 @@ struct cmd_csum_result { }; static void +csum_show(int port_id) +{ + struct rte_eth_dev_info dev_info; + uint16_t ol_flags; + + ol_flags = ports[port_id].tx_ol_flags; + printf("IP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); + printf("UDP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); + printf("TCP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); + printf("SCTP checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); + printf("VxLAN checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw"); + + /* display warnings if configuration is not supported by the NIC */ + rte_eth_dev_info_get(port_id, &dev_info); + if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { + printf("Warning: hardware IP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { + printf("Warning: hardware UDP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { + printf("Warning: hardware TCP checksum enabled but not " + "supported by port %d\n", port_id); + } + if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { + printf("Warning: hardware SCTP checksum enabled but not " + "supported by port %d\n", port_id); + } + +} + +static void cmd_csum_parsed(void *parsed_result, __attribute__((unused)) struct cmdline *cl, __attribute__((unused)) void *data) { struct cmd_csum_result *res = parsed_result; int hw = 0; - uint16_t ol_flags, mask = 0; - struct rte_eth_dev_info dev_info; + uint16_t mask = 0; if (port_id_is_invalid(res->port_id)) { printf("invalid port %d\n", res->port_id); @@ -2919,41 +2961,7 @@ cmd_csum_parsed(void *parsed_result, else ports[res->port_id].tx_ol_flags &= (~mask); } - - ol_flags = ports[res->port_id].tx_ol_flags; - printf("IP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); - printf("UDP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); - printf("TCP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); - printf("SCTP checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); - printf("VxLAN checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw"); - - /* display warnings if configuration is not supported by the NIC */ - rte_eth_dev_info_get(res->port_id, &dev_info); - if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { - printf("Warning: hardware IP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { - printf("Warning: hardware UDP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { - printf("Warning: hardware TCP checksum enabled but not " - "supported by port %d\n", res->port_id); - } - if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) && - (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { - printf("Warning: hardware SCTP checksum enabled but not " - "supported by port %d\n", res->port_id); - } + csum_show(res->port_id); } cmdline_parse_token_string_t cmd_csum_csum = -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 08/20] testpmd: add csum parse_tunnel command 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (6 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 07/20] testpmd: move csum_show in a function Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 09/20] testpmd: rename vxlan in outer_ip in csum commands Olivier Matz ` (12 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev Add a new command related to csum forward engine: csum parse-tunnel (on|off) (tx_port_id) If enabled, the tunnel packets received by the csum forward engine are parsed and seen as "outer-headers/inner-headers/data". If disabled, the parsing of the csum forward engine stops at the first l4 layer. A tunnel packet is seens as "headers/data" (inner headers are included in payload). Note: the port argument is the tx_port. It's more coherent compared to all other testpmd csum flags. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/csumonly.c | 3 ++- app/test-pmd/testpmd.h | 5 +++- 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 55768f1..f57bf0b 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -327,6 +327,12 @@ static void cmd_help_long_parsed(void *parsed_result, " the forward engine)\n" " Please check the NIC datasheet for HW limits.\n\n" + "csum parse-tunnel (on|off) (tx_port_id)\n" + " If disabled, treat tunnel packets as non-tunneled" + " packets (treat inner headers as payload). The port\n" + " argument is the port used for TX in csum forward" + " engine.\n\n" + "csum show (port_id)\n" " Display tx checksum offload configuration\n\n" @@ -2889,6 +2895,8 @@ csum_show(int port_id) uint16_t ol_flags; ol_flags = ports[port_id].tx_ol_flags; + printf("Parse tunnel is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off"); printf("IP checksum offload is %s\n", (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw"); printf("UDP checksum offload is %s\n", @@ -3011,6 +3019,63 @@ cmdline_parse_inst_t cmd_csum_show = { }, }; +/* Enable/disable tunnel parsing */ +struct cmd_csum_tunnel_result { + cmdline_fixed_string_t csum; + cmdline_fixed_string_t parse; + cmdline_fixed_string_t onoff; + uint8_t port_id; +}; + +static void +cmd_csum_tunnel_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_csum_tunnel_result *res = parsed_result; + + if (port_id_is_invalid(res->port_id)) { + printf("invalid port %d\n", res->port_id); + return; + } + + if (!strcmp(res->onoff, "on")) + ports[res->port_id].tx_ol_flags |= + TESTPMD_TX_OFFLOAD_PARSE_TUNNEL; + else + ports[res->port_id].tx_ol_flags &= + (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL); + + csum_show(res->port_id); +} + +cmdline_parse_token_string_t cmd_csum_tunnel_csum = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + csum, "csum"); +cmdline_parse_token_string_t cmd_csum_tunnel_parse = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + parse, "parse_tunnel"); +cmdline_parse_token_string_t cmd_csum_tunnel_onoff = + TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, + onoff, "on#off"); +cmdline_parse_token_num_t cmd_csum_tunnel_portid = + TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, + port_id, UINT8); + +cmdline_parse_inst_t cmd_csum_tunnel = { + .f = cmd_csum_tunnel_parsed, + .data = NULL, + .help_str = "enable/disable parsing of tunnels for csum engine: " + "csum parse_tunnel on|off <tx-port>", + .tokens = { + (void *)&cmd_csum_tunnel_csum, + (void *)&cmd_csum_tunnel_parse, + (void *)&cmd_csum_tunnel_onoff, + (void *)&cmd_csum_tunnel_portid, + NULL, + }, +}; + /* *** ENABLE HARDWARE SEGMENTATION IN TX PACKETS *** */ struct cmd_tso_set_result { cmdline_fixed_string_t tso; @@ -9060,6 +9125,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, (cmdline_parse_inst_t *)&cmd_csum_set, (cmdline_parse_inst_t *)&cmd_csum_show, + (cmdline_parse_inst_t *)&cmd_csum_tunnel, (cmdline_parse_inst_t *)&cmd_tso_set, (cmdline_parse_inst_t *)&cmd_tso_show, (cmdline_parse_inst_t *)&cmd_link_flow_control_set, diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index ca5ca39..858eb47 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -373,7 +373,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) l3_hdr = (char *)eth_hdr + l2_len; /* check if it's a supported tunnel (only vxlan for now) */ - if (l4_proto == IPPROTO_UDP) { + if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && + l4_proto == IPPROTO_UDP) { udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len); /* check udp destination port, 4789 is the default diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 8f5e6c7..36277de 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -127,8 +127,11 @@ struct fwd_stream { #define TESTPMD_TX_OFFLOAD_SCTP_CKSUM 0x0008 /** Offload VxLAN checksum in csum forward engine */ #define TESTPMD_TX_OFFLOAD_VXLAN_CKSUM 0x0010 +/** Parse tunnel in csum forward engine. If set, dissect tunnel headers + * of rx packets. If not set, treat inner headers as payload. */ +#define TESTPMD_TX_OFFLOAD_PARSE_TUNNEL 0x0020 /** Insert VLAN header in forward engine */ -#define TESTPMD_TX_OFFLOAD_INSERT_VLAN 0x0020 +#define TESTPMD_TX_OFFLOAD_INSERT_VLAN 0x0040 /** * The data structure associated with each port. -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 09/20] testpmd: rename vxlan in outer_ip in csum commands 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (7 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 08/20] testpmd: add csum parse_tunnel command Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 10/20] testpmd: introduce parse_ipv* in csum fwd engine Olivier Matz ` (11 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev The tx_checksum command concerns outer IP checksum, not VxLAN checksum. Actually there is no checkum in VxLAN header, there is one checksum in outer IP header, and one checksum in outer UDP header. This option only controls the outer IP checksum. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 16 ++++++++-------- app/test-pmd/csumonly.c | 25 ++++++++++++++----------- app/test-pmd/testpmd.h | 4 ++-- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index f57bf0b..363da9a 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -317,12 +317,12 @@ static void cmd_help_long_parsed(void *parsed_result, " Disable hardware insertion of a VLAN header in" " packets sent on a port.\n\n" - "csum set (ip|udp|tcp|sctp|vxlan) (hw|sw) (port_id)\n" + "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n" " Select hardware or software calculation of the" " checksum with when transmitting a packet using the" " csum forward engine.\n" " ip|udp|tcp|sctp always concern the inner layer.\n" - " vxlan concerns the outer IP and UDP layer (in" + " outer-ip concerns the outer IP layer (in" " case the packet is recognized as a vxlan packet by" " the forward engine)\n" " Please check the NIC datasheet for HW limits.\n\n" @@ -2905,8 +2905,8 @@ csum_show(int port_id) (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); printf("SCTP checksum offload is %s\n", (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); - printf("VxLAN checksum offload is %s\n", - (ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) ? "hw" : "sw"); + printf("Outer-Ip checksum offload is %s\n", + (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw"); /* display warnings if configuration is not supported by the NIC */ rte_eth_dev_info_get(port_id, &dev_info); @@ -2960,8 +2960,8 @@ cmd_csum_parsed(void *parsed_result, mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM; } else if (!strcmp(res->proto, "sctp")) { mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM; - } else if (!strcmp(res->proto, "vxlan")) { - mask = TESTPMD_TX_OFFLOAD_VXLAN_CKSUM; + } else if (!strcmp(res->proto, "outer-ip")) { + mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM; } if (hw) @@ -2980,7 +2980,7 @@ cmdline_parse_token_string_t cmd_csum_mode = mode, "set"); cmdline_parse_token_string_t cmd_csum_proto = TOKEN_STRING_INITIALIZER(struct cmd_csum_result, - proto, "ip#tcp#udp#sctp#vxlan"); + proto, "ip#tcp#udp#sctp#outer-ip"); cmdline_parse_token_string_t cmd_csum_hwsw = TOKEN_STRING_INITIALIZER(struct cmd_csum_result, hwsw, "hw#sw"); @@ -2992,7 +2992,7 @@ cmdline_parse_inst_t cmd_csum_set = { .f = cmd_csum_parsed, .data = NULL, .help_str = "enable/disable hardware calculation of L3/L4 checksum when " - "using csum forward engine: csum set ip|tcp|udp|sctp|vxlan hw|sw <port>", + "using csum forward engine: csum set ip|tcp|udp|sctp|outer-ip hw|sw <port>", .tokens = { (void *)&cmd_csum_csum, (void *)&cmd_csum_mode, diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 858eb47..3921643 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -259,13 +259,16 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_OUTER_IPV4; - if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ol_flags |= PKT_TX_OUTER_IP_CKSUM; else ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); - } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) + } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ol_flags |= PKT_TX_OUTER_IPV6; + /* outer UDP checksum is always done in software as we have no + * hardware supporting it today, and no API for it. */ + udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len); /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { @@ -300,8 +303,8 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, * The testpmd command line for this forward engine sets the flags * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control * wether a checksum must be calculated in software or in hardware. The - * IP, UDP, TCP and SCTP flags always concern the inner layer. The - * VxLAN flag concerns the outer IP (if packet is recognized as a vxlan packet). + * IP, UDP, TCP and SCTP flags always concern the inner layer. The + * OUTER_IP is only useful for tunnel packets. */ static void pkt_burst_checksum_forward(struct fwd_stream *fs) @@ -432,18 +435,18 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* step 4: fill the mbuf meta data (flags and header lengths) */ if (tunnel == 1) { - if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) { + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { m->outer_l2_len = outer_l2_len; m->outer_l3_len = outer_l3_len; m->l2_len = l4_tun_len + l2_len; m->l3_len = l3_len; } else { - /* if we don't do vxlan cksum in hw, - outer checksum will be wrong because - we changed the ip, but it shows that - we can process the inner header cksum - in the nic */ + /* if there is a outer UDP cksum + processed in sw and the inner in hw, + the outer checksum will be wrong as + the payload will be modified by the + hardware */ m->l2_len = outer_l2_len + outer_l3_len + sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr) + l2_len; @@ -502,7 +505,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) "m->l4_len=%d\n", m->l2_len, m->l3_len, m->l4_len); if ((tunnel == 1) && - (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)) + (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM)) printf("tx: m->outer_l2_len=%d m->outer_l3_len=%d\n", m->outer_l2_len, m->outer_l3_len); if (tso_segsz != 0) diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 36277de..ecb7d38 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -125,8 +125,8 @@ struct fwd_stream { #define TESTPMD_TX_OFFLOAD_TCP_CKSUM 0x0004 /** Offload SCTP checksum in csum forward engine */ #define TESTPMD_TX_OFFLOAD_SCTP_CKSUM 0x0008 -/** Offload VxLAN checksum in csum forward engine */ -#define TESTPMD_TX_OFFLOAD_VXLAN_CKSUM 0x0010 +/** Offload outer IP checksum in csum forward engine for recognized tunnels */ +#define TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM 0x0010 /** Parse tunnel in csum forward engine. If set, dissect tunnel headers * of rx packets. If not set, treat inner headers as payload. */ #define TESTPMD_TX_OFFLOAD_PARSE_TUNNEL 0x0020 -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 10/20] testpmd: introduce parse_ipv* in csum fwd engine 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (8 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 09/20] testpmd: rename vxlan in outer_ip in csum commands Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 11/20] testpmd: use a structure to store offload info " Olivier Matz ` (10 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev These functions may be used to parse encapsulated layers when we will support IP over GRE tunnels. No functional change. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 51 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 3921643..b023f12 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -104,6 +104,42 @@ get_udptcp_checksum(void *l3_hdr, void *l4_hdr, uint16_t ethertype) return rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr); } +/* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */ +static void +parse_ipv4(struct ipv4_hdr *ipv4_hdr, uint16_t *l3_len, uint8_t *l4_proto, + uint16_t *l4_len) +{ + struct tcp_hdr *tcp_hdr; + + *l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; + *l4_proto = ipv4_hdr->next_proto_id; + + /* only fill l4_len for TCP, it's useful for TSO */ + if (*l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv4_hdr + *l3_len); + *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + } else + *l4_len = 0; +} + +/* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */ +static void +parse_ipv6(struct ipv6_hdr *ipv6_hdr, uint16_t *l3_len, uint8_t *l4_proto, + uint16_t *l4_len) +{ + struct tcp_hdr *tcp_hdr; + + *l3_len = sizeof(struct ipv6_hdr); + *l4_proto = ipv6_hdr->proto; + + /* only fill l4_len for TCP, it's useful for TSO */ + if (*l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv6_hdr + *l3_len); + *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + } else + *l4_len = 0; +} + /* * Parse an ethernet header to fill the ethertype, l2_len, l3_len and * ipproto. This function is able to recognize IPv4/IPv6 with one optional vlan @@ -115,7 +151,6 @@ parse_ethernet(struct ether_hdr *eth_hdr, uint16_t *ethertype, uint16_t *l2_len, { struct ipv4_hdr *ipv4_hdr; struct ipv6_hdr *ipv6_hdr; - struct tcp_hdr *tcp_hdr; *l2_len = sizeof(struct ether_hdr); *ethertype = eth_hdr->ether_type; @@ -130,26 +165,18 @@ parse_ethernet(struct ether_hdr *eth_hdr, uint16_t *ethertype, uint16_t *l2_len, switch (*ethertype) { case _htons(ETHER_TYPE_IPv4): ipv4_hdr = (struct ipv4_hdr *) ((char *)eth_hdr + *l2_len); - *l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; - *l4_proto = ipv4_hdr->next_proto_id; + parse_ipv4(ipv4_hdr, l3_len, l4_proto, l4_len); break; case _htons(ETHER_TYPE_IPv6): ipv6_hdr = (struct ipv6_hdr *) ((char *)eth_hdr + *l2_len); - *l3_len = sizeof(struct ipv6_hdr); - *l4_proto = ipv6_hdr->proto; + parse_ipv6(ipv6_hdr, l3_len, l4_proto, l4_len); break; default: + *l4_len = 0; *l3_len = 0; *l4_proto = 0; break; } - - if (*l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)eth_hdr + - *l2_len + *l3_len); - *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; - } else - *l4_len = 0; } /* modify the IPv4 or IPv4 source address of a packet */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 11/20] testpmd: use a structure to store offload info in csum fwd engine 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (9 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 10/20] testpmd: introduce parse_ipv* in csum fwd engine Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 12/20] testpmd: introduce parse_vxlan " Olivier Matz ` (9 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev To simplify the API of parse_* functions, store all the offload information for the current packet in a structure. No functional change. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 222 +++++++++++++++++++++++++----------------------- 1 file changed, 115 insertions(+), 107 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index b023f12..0b89d89 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -86,6 +86,21 @@ #define _htons(x) (x) #endif +/* structure that caches offload info for the current packet */ +struct testpmd_offload_info { + uint16_t ethertype; + uint16_t l2_len; + uint16_t l3_len; + uint16_t l4_len; + uint8_t l4_proto; + uint8_t l4_tun_len; + uint8_t is_tunnel; + uint16_t outer_ethertype; + uint16_t outer_l2_len; + uint16_t outer_l3_len; + uint16_t tso_segsz; +}; + static uint16_t get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags) { @@ -106,38 +121,36 @@ get_udptcp_checksum(void *l3_hdr, void *l4_hdr, uint16_t ethertype) /* Parse an IPv4 header to fill l3_len, l4_len, and l4_proto */ static void -parse_ipv4(struct ipv4_hdr *ipv4_hdr, uint16_t *l3_len, uint8_t *l4_proto, - uint16_t *l4_len) +parse_ipv4(struct ipv4_hdr *ipv4_hdr, struct testpmd_offload_info *info) { struct tcp_hdr *tcp_hdr; - *l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; - *l4_proto = ipv4_hdr->next_proto_id; + info->l3_len = (ipv4_hdr->version_ihl & 0x0f) * 4; + info->l4_proto = ipv4_hdr->next_proto_id; /* only fill l4_len for TCP, it's useful for TSO */ - if (*l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)ipv4_hdr + *l3_len); - *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + if (info->l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv4_hdr + info->l3_len); + info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2; } else - *l4_len = 0; + info->l4_len = 0; } /* Parse an IPv6 header to fill l3_len, l4_len, and l4_proto */ static void -parse_ipv6(struct ipv6_hdr *ipv6_hdr, uint16_t *l3_len, uint8_t *l4_proto, - uint16_t *l4_len) +parse_ipv6(struct ipv6_hdr *ipv6_hdr, struct testpmd_offload_info *info) { struct tcp_hdr *tcp_hdr; - *l3_len = sizeof(struct ipv6_hdr); - *l4_proto = ipv6_hdr->proto; + info->l3_len = sizeof(struct ipv6_hdr); + info->l4_proto = ipv6_hdr->proto; /* only fill l4_len for TCP, it's useful for TSO */ - if (*l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)ipv6_hdr + *l3_len); - *l4_len = (tcp_hdr->data_off & 0xf0) >> 2; + if (info->l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)ipv6_hdr + info->l3_len); + info->l4_len = (tcp_hdr->data_off & 0xf0) >> 2; } else - *l4_len = 0; + info->l4_len = 0; } /* @@ -146,35 +159,34 @@ parse_ipv6(struct ipv6_hdr *ipv6_hdr, uint16_t *l3_len, uint8_t *l4_proto, * header. The l4_len argument is only set in case of TCP (useful for TSO). */ static void -parse_ethernet(struct ether_hdr *eth_hdr, uint16_t *ethertype, uint16_t *l2_len, - uint16_t *l3_len, uint8_t *l4_proto, uint16_t *l4_len) +parse_ethernet(struct ether_hdr *eth_hdr, struct testpmd_offload_info *info) { struct ipv4_hdr *ipv4_hdr; struct ipv6_hdr *ipv6_hdr; - *l2_len = sizeof(struct ether_hdr); - *ethertype = eth_hdr->ether_type; + info->l2_len = sizeof(struct ether_hdr); + info->ethertype = eth_hdr->ether_type; - if (*ethertype == _htons(ETHER_TYPE_VLAN)) { + if (info->ethertype == _htons(ETHER_TYPE_VLAN)) { struct vlan_hdr *vlan_hdr = (struct vlan_hdr *)(eth_hdr + 1); - *l2_len += sizeof(struct vlan_hdr); - *ethertype = vlan_hdr->eth_proto; + info->l2_len += sizeof(struct vlan_hdr); + info->ethertype = vlan_hdr->eth_proto; } - switch (*ethertype) { + switch (info->ethertype) { case _htons(ETHER_TYPE_IPv4): - ipv4_hdr = (struct ipv4_hdr *) ((char *)eth_hdr + *l2_len); - parse_ipv4(ipv4_hdr, l3_len, l4_proto, l4_len); + ipv4_hdr = (struct ipv4_hdr *) ((char *)eth_hdr + info->l2_len); + parse_ipv4(ipv4_hdr, info); break; case _htons(ETHER_TYPE_IPv6): - ipv6_hdr = (struct ipv6_hdr *) ((char *)eth_hdr + *l2_len); - parse_ipv6(ipv6_hdr, l3_len, l4_proto, l4_len); + ipv6_hdr = (struct ipv6_hdr *) ((char *)eth_hdr + info->l2_len); + parse_ipv6(ipv6_hdr, info); break; default: - *l4_len = 0; - *l3_len = 0; - *l4_proto = 0; + info->l4_len = 0; + info->l3_len = 0; + info->l4_proto = 0; break; } } @@ -197,8 +209,8 @@ change_ip_addresses(void *l3_hdr, uint16_t ethertype) /* if possible, calculate the checksum of a packet in hw or sw, * depending on the testpmd command line configuration */ static uint64_t -process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, - uint8_t l4_proto, uint16_t tso_segsz, uint16_t testpmd_ol_flags) +process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, + uint16_t testpmd_ol_flags) { struct ipv4_hdr *ipv4_hdr = l3_hdr; struct udp_hdr *udp_hdr; @@ -206,12 +218,12 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, struct sctp_hdr *sctp_hdr; uint64_t ol_flags = 0; - if (ethertype == _htons(ETHER_TYPE_IPv4)) { + if (info->ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr = l3_hdr; ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_IPV4; - if (tso_segsz != 0 && l4_proto == IPPROTO_TCP) { + if (info->tso_segsz != 0 && info->l4_proto == IPPROTO_TCP) { ol_flags |= PKT_TX_IP_CKSUM; } else { if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) @@ -220,41 +232,44 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); } - } else if (ethertype == _htons(ETHER_TYPE_IPv6)) + } else if (info->ethertype == _htons(ETHER_TYPE_IPv6)) ol_flags |= PKT_TX_IPV6; else return 0; /* packet type not supported, nothing to do */ - if (l4_proto == IPPROTO_UDP) { - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len); + if (info->l4_proto == IPPROTO_UDP) { + udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info->l3_len); /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { udp_hdr->dgram_cksum = 0; if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) { ol_flags |= PKT_TX_UDP_CKSUM; udp_hdr->dgram_cksum = get_psd_sum(l3_hdr, - ethertype, ol_flags); + info->ethertype, ol_flags); } else { udp_hdr->dgram_cksum = get_udptcp_checksum(l3_hdr, udp_hdr, - ethertype); + info->ethertype); } } - } else if (l4_proto == IPPROTO_TCP) { - tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + l3_len); + } else if (info->l4_proto == IPPROTO_TCP) { + tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + info->l3_len); tcp_hdr->cksum = 0; - if (tso_segsz != 0) { + if (info->tso_segsz != 0) { ol_flags |= PKT_TX_TCP_SEG; - tcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype, ol_flags); + tcp_hdr->cksum = get_psd_sum(l3_hdr, info->ethertype, + ol_flags); } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) { ol_flags |= PKT_TX_TCP_CKSUM; - tcp_hdr->cksum = get_psd_sum(l3_hdr, ethertype, ol_flags); + tcp_hdr->cksum = get_psd_sum(l3_hdr, info->ethertype, + ol_flags); } else { tcp_hdr->cksum = - get_udptcp_checksum(l3_hdr, tcp_hdr, ethertype); + get_udptcp_checksum(l3_hdr, tcp_hdr, + info->ethertype); } - } else if (l4_proto == IPPROTO_SCTP) { - sctp_hdr = (struct sctp_hdr *)((char *)l3_hdr + l3_len); + } else if (info->l4_proto == IPPROTO_SCTP) { + sctp_hdr = (struct sctp_hdr *)((char *)l3_hdr + info->l3_len); sctp_hdr->cksum = 0; /* sctp payload must be a multiple of 4 to be * offloaded */ @@ -274,15 +289,15 @@ process_inner_cksums(void *l3_hdr, uint16_t ethertype, uint16_t l3_len, * meaning IP + UDP). The caller already checked that it's a vxlan * packet */ static uint64_t -process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, - uint16_t outer_l3_len, uint16_t testpmd_ol_flags) +process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, +uint16_t testpmd_ol_flags) { struct ipv4_hdr *ipv4_hdr = outer_l3_hdr; struct ipv6_hdr *ipv6_hdr = outer_l3_hdr; struct udp_hdr *udp_hdr; uint64_t ol_flags = 0; - if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) { + if (info->outer_ethertype == _htons(ETHER_TYPE_IPv4)) { ipv4_hdr->hdr_checksum = 0; ol_flags |= PKT_TX_OUTER_IPV4; @@ -296,11 +311,11 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, /* outer UDP checksum is always done in software as we have no * hardware supporting it today, and no API for it. */ - udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + outer_l3_len); + udp_hdr = (struct udp_hdr *)((char *)outer_l3_hdr + info->outer_l3_len); /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { udp_hdr->dgram_cksum = 0; - if (outer_ethertype == _htons(ETHER_TYPE_IPv4)) + if (info->outer_ethertype == _htons(ETHER_TYPE_IPv4)) udp_hdr->dgram_cksum = rte_ipv4_udptcp_cksum(ipv4_hdr, udp_hdr); else @@ -347,14 +362,9 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) uint16_t i; uint64_t ol_flags; uint16_t testpmd_ol_flags; - uint8_t l4_proto, l4_tun_len = 0; - uint16_t ethertype = 0, outer_ethertype = 0; - uint16_t l2_len = 0, l3_len = 0, l4_len = 0; - uint16_t outer_l2_len = 0, outer_l3_len = 0; - uint16_t tso_segsz; - int tunnel = 0; uint32_t rx_bad_ip_csum; uint32_t rx_bad_l4_csum; + struct testpmd_offload_info info; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES uint64_t start_tsc; @@ -381,13 +391,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) txp = &ports[fs->tx_port]; testpmd_ol_flags = txp->tx_ol_flags; - tso_segsz = txp->tso_segsz; + memset(&info, 0, sizeof(info)); + info.tso_segsz = txp->tso_segsz; for (i = 0; i < nb_rx; i++) { ol_flags = 0; - tunnel = 0; - l4_tun_len = 0; + info.is_tunnel = 0; m = pkts_burst[i]; /* Update the L3/L4 checksum error packet statistics */ @@ -398,49 +408,47 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) * and inner headers */ eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); - parse_ethernet(eth_hdr, ðertype, &l2_len, &l3_len, - &l4_proto, &l4_len); - l3_hdr = (char *)eth_hdr + l2_len; + parse_ethernet(eth_hdr, &info); + l3_hdr = (char *)eth_hdr + info.l2_len; /* check if it's a supported tunnel (only vxlan for now) */ if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && - l4_proto == IPPROTO_UDP) { - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + l3_len); + info.l4_proto == IPPROTO_UDP) { + udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info.l3_len); /* check udp destination port, 4789 is the default * vxlan port (rfc7348) */ if (udp_hdr->dst_port == _htons(4789)) { - l4_tun_len = ETHER_VXLAN_HLEN; - tunnel = 1; + info.l4_tun_len = ETHER_VXLAN_HLEN; + info.is_tunnel = 1; /* currently, this flag is set by i40e only if the * packet is vxlan */ } else if (m->ol_flags & (PKT_RX_TUNNEL_IPV4_HDR | PKT_RX_TUNNEL_IPV6_HDR)) - tunnel = 1; + info.is_tunnel = 1; - if (tunnel == 1) { - outer_ethertype = ethertype; - outer_l2_len = l2_len; - outer_l3_len = l3_len; + if (info.is_tunnel == 1) { + info.outer_ethertype = info.ethertype; + info.outer_l2_len = info.l2_len; + info.outer_l3_len = info.l3_len; outer_l3_hdr = l3_hdr; eth_hdr = (struct ether_hdr *)((char *)udp_hdr + sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr)); - parse_ethernet(eth_hdr, ðertype, &l2_len, - &l3_len, &l4_proto, &l4_len); - l3_hdr = (char *)eth_hdr + l2_len; + parse_ethernet(eth_hdr, &info); + l3_hdr = (char *)eth_hdr + info.l2_len; } } /* step 2: change all source IPs (v4 or v6) so we need * to recompute the chksums even if they were correct */ - change_ip_addresses(l3_hdr, ethertype); - if (tunnel == 1) - change_ip_addresses(outer_l3_hdr, outer_ethertype); + change_ip_addresses(l3_hdr, info.ethertype); + if (info.is_tunnel == 1) + change_ip_addresses(outer_l3_hdr, info.outer_ethertype); /* step 3: depending on user command line configuration, * recompute checksum either in software or flag the @@ -448,25 +456,24 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) * is configured, prepare the mbuf for TCP segmentation. */ /* process checksums of inner headers first */ - ol_flags |= process_inner_cksums(l3_hdr, ethertype, - l3_len, l4_proto, tso_segsz, testpmd_ol_flags); + ol_flags |= process_inner_cksums(l3_hdr, &info, testpmd_ol_flags); /* Then process outer headers if any. Note that the software * checksum will be wrong if one of the inner checksums is * processed in hardware. */ - if (tunnel == 1) { - ol_flags |= process_outer_cksums(outer_l3_hdr, - outer_ethertype, outer_l3_len, testpmd_ol_flags); + if (info.is_tunnel == 1) { + ol_flags |= process_outer_cksums(outer_l3_hdr, &info, + testpmd_ol_flags); } /* step 4: fill the mbuf meta data (flags and header lengths) */ - if (tunnel == 1) { + if (info.is_tunnel == 1) { if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { - m->outer_l2_len = outer_l2_len; - m->outer_l3_len = outer_l3_len; - m->l2_len = l4_tun_len + l2_len; - m->l3_len = l3_len; + m->outer_l2_len = info.outer_l2_len; + m->outer_l3_len = info.outer_l3_len; + m->l2_len = info.l4_tun_len + info.l2_len; + m->l3_len = info.l3_len; } else { /* if there is a outer UDP cksum @@ -474,21 +481,22 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) the outer checksum will be wrong as the payload will be modified by the hardware */ - m->l2_len = outer_l2_len + outer_l3_len + + m->l2_len = info.outer_l2_len + + info.outer_l3_len + sizeof(struct udp_hdr) + - sizeof(struct vxlan_hdr) + l2_len; - m->l3_len = l3_len; - m->l4_len = l4_len; + sizeof(struct vxlan_hdr) + info.l2_len; + m->l3_len = info.l3_len; + m->l4_len = info.l4_len; } } else { /* this is only useful if an offload flag is * set, but it does not hurt to fill it in any * case */ - m->l2_len = l2_len; - m->l3_len = l3_len; - m->l4_len = l4_len; + m->l2_len = info.l2_len; + m->l3_len = info.l3_len; + m->l4_len = info.l4_len; } - m->tso_segsz = tso_segsz; + m->tso_segsz = info.tso_segsz; m->ol_flags = ol_flags; /* if verbose mode is enabled, dump debug info */ @@ -515,27 +523,27 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* dump rx parsed packet info */ printf("rx: l2_len=%d ethertype=%x l3_len=%d " "l4_proto=%d l4_len=%d\n", - l2_len, rte_be_to_cpu_16(ethertype), - l3_len, l4_proto, l4_len); - if (tunnel == 1) + info.l2_len, rte_be_to_cpu_16(info.ethertype), + info.l3_len, info.l4_proto, info.l4_len); + if (info.is_tunnel == 1) printf("rx: outer_l2_len=%d outer_ethertype=%x " - "outer_l3_len=%d\n", outer_l2_len, - rte_be_to_cpu_16(outer_ethertype), - outer_l3_len); + "outer_l3_len=%d\n", info.outer_l2_len, + rte_be_to_cpu_16(info.outer_ethertype), + info.outer_l3_len); /* dump tx packet info */ if ((testpmd_ol_flags & (TESTPMD_TX_OFFLOAD_IP_CKSUM | TESTPMD_TX_OFFLOAD_UDP_CKSUM | TESTPMD_TX_OFFLOAD_TCP_CKSUM | TESTPMD_TX_OFFLOAD_SCTP_CKSUM)) || - tso_segsz != 0) + info.tso_segsz != 0) printf("tx: m->l2_len=%d m->l3_len=%d " "m->l4_len=%d\n", m->l2_len, m->l3_len, m->l4_len); - if ((tunnel == 1) && + if ((info.is_tunnel == 1) && (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM)) printf("tx: m->outer_l2_len=%d m->outer_l3_len=%d\n", m->outer_l2_len, m->outer_l3_len); - if (tso_segsz != 0) + if (info.tso_segsz != 0) printf("tx: m->tso_segsz=%d\n", m->tso_segsz); printf("tx: flags="); for (j = 0; j < sizeof(tx_flags)/sizeof(*tx_flags); j++) { -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 12/20] testpmd: introduce parse_vxlan in csum fwd engine 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (10 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 11/20] testpmd: use a structure to store offload info " Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 13/20] testpmd: support gre tunnels " Olivier Matz ` (8 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev Move code parsing vxlan into a function. It will ease the support of GRE tunnels and IPIP tunnels in next commits. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 68 +++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 0b89d89..ba9049f 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -93,7 +93,6 @@ struct testpmd_offload_info { uint16_t l3_len; uint16_t l4_len; uint8_t l4_proto; - uint8_t l4_tun_len; uint8_t is_tunnel; uint16_t outer_ethertype; uint16_t outer_l2_len; @@ -191,6 +190,34 @@ parse_ethernet(struct ether_hdr *eth_hdr, struct testpmd_offload_info *info) } } +/* Parse a vxlan header */ +static void +parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, + uint64_t mbuf_olflags) +{ + struct ether_hdr *eth_hdr; + + /* check udp destination port, 4789 is the default vxlan port + * (rfc7348) or that the rx offload flag is set (i40e only + * currently) */ + if (udp_hdr->dst_port != _htons(4789) && + (mbuf_olflags & (PKT_RX_TUNNEL_IPV4_HDR | + PKT_RX_TUNNEL_IPV6_HDR)) == 0) + return; + + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + eth_hdr = (struct ether_hdr *)((char *)udp_hdr + + sizeof(struct udp_hdr) + + sizeof(struct vxlan_hdr)); + + parse_ethernet(eth_hdr, info); + info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */ +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -356,7 +383,6 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) struct rte_mbuf *m; struct ether_hdr *eth_hdr; void *l3_hdr = NULL, *outer_l3_hdr = NULL; /* can be IPv4 or IPv6 */ - struct udp_hdr *udp_hdr; uint16_t nb_rx; uint16_t nb_tx; uint16_t i; @@ -414,33 +440,15 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) /* check if it's a supported tunnel (only vxlan for now) */ if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && info.l4_proto == IPPROTO_UDP) { + struct udp_hdr *udp_hdr; udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info.l3_len); + parse_vxlan(udp_hdr, &info, m->ol_flags); + } - /* check udp destination port, 4789 is the default - * vxlan port (rfc7348) */ - if (udp_hdr->dst_port == _htons(4789)) { - info.l4_tun_len = ETHER_VXLAN_HLEN; - info.is_tunnel = 1; - - /* currently, this flag is set by i40e only if the - * packet is vxlan */ - } else if (m->ol_flags & (PKT_RX_TUNNEL_IPV4_HDR | - PKT_RX_TUNNEL_IPV6_HDR)) - info.is_tunnel = 1; - - if (info.is_tunnel == 1) { - info.outer_ethertype = info.ethertype; - info.outer_l2_len = info.l2_len; - info.outer_l3_len = info.l3_len; - outer_l3_hdr = l3_hdr; - - eth_hdr = (struct ether_hdr *)((char *)udp_hdr + - sizeof(struct udp_hdr) + - sizeof(struct vxlan_hdr)); - - parse_ethernet(eth_hdr, &info); - l3_hdr = (char *)eth_hdr + info.l2_len; - } + /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ + if (info.is_tunnel) { + outer_l3_hdr = l3_hdr; + l3_hdr = (char *)l3_hdr + info.outer_l3_len + info.l2_len; } /* step 2: change all source IPs (v4 or v6) so we need @@ -472,7 +480,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) { m->outer_l2_len = info.outer_l2_len; m->outer_l3_len = info.outer_l3_len; - m->l2_len = info.l4_tun_len + info.l2_len; + m->l2_len = info.l2_len; m->l3_len = info.l3_len; } else { @@ -482,9 +490,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) the payload will be modified by the hardware */ m->l2_len = info.outer_l2_len + - info.outer_l3_len + - sizeof(struct udp_hdr) + - sizeof(struct vxlan_hdr) + info.l2_len; + info.outer_l3_len + info.l2_len; m->l3_len = info.l3_len; m->l4_len = info.l4_len; } -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 13/20] testpmd: support gre tunnels in csum fwd engine 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (11 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 12/20] testpmd: introduce parse_vxlan " Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 14/20] testpmd: support ipip tunnel in csum forward engine Olivier Matz ` (7 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev Add support for Ethernet over GRE and IP over GRE tunnels. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 6 ++-- app/test-pmd/csumonly.c | 91 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 87 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 363da9a..b19869c 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -322,9 +322,9 @@ static void cmd_help_long_parsed(void *parsed_result, " checksum with when transmitting a packet using the" " csum forward engine.\n" " ip|udp|tcp|sctp always concern the inner layer.\n" - " outer-ip concerns the outer IP layer (in" - " case the packet is recognized as a vxlan packet by" - " the forward engine)\n" + " outer-ip concerns the outer IP layer in" + " case the packet is recognized as a tunnel packet by" + " the forward engine (vxlan and gre are supported)\n" " Please check the NIC datasheet for HW limits.\n\n" "csum parse-tunnel (on|off) (tx_port_id)\n" diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index ba9049f..2582bf1 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -97,9 +97,16 @@ struct testpmd_offload_info { uint16_t outer_ethertype; uint16_t outer_l2_len; uint16_t outer_l3_len; + uint8_t outer_l4_proto; uint16_t tso_segsz; }; +/* simplified GRE header (flags must be 0) */ +struct simple_gre_hdr { + uint16_t flags; + uint16_t proto; +}; + static uint16_t get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags) { @@ -209,6 +216,7 @@ parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, info->outer_ethertype = info->ethertype; info->outer_l2_len = info->l2_len; info->outer_l3_len = info->l3_len; + info->outer_l4_proto = info->l4_proto; eth_hdr = (struct ether_hdr *)((char *)udp_hdr + sizeof(struct udp_hdr) + @@ -218,6 +226,63 @@ parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */ } +/* Parse a gre header */ +static void +parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) +{ + struct ether_hdr *eth_hdr; + struct ipv4_hdr *ipv4_hdr; + struct ipv6_hdr *ipv6_hdr; + + /* if flags != 0; it's not supported */ + if (gre_hdr->flags != 0) + return; + + if (gre_hdr->proto == _htons(ETHER_TYPE_IPv4)) { + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + info->outer_l4_proto = info->l4_proto; + + ipv4_hdr = (struct ipv4_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + parse_ipv4(ipv4_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv4); + info->l2_len = 0; + + } else if (gre_hdr->proto == _htons(ETHER_TYPE_IPv6)) { + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + info->outer_l4_proto = info->l4_proto; + + ipv6_hdr = (struct ipv6_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + info->ethertype = _htons(ETHER_TYPE_IPv6); + parse_ipv6(ipv6_hdr, info); + info->l2_len = 0; + + } else if (gre_hdr->proto == _htons(0x6558)) { /* ETH_P_TEB in linux */ + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + info->outer_l4_proto = info->l4_proto; + + eth_hdr = (struct ether_hdr *)((char *)gre_hdr + + sizeof(struct simple_gre_hdr)); + + parse_ethernet(eth_hdr, info); + } else + return; + + info->l2_len += sizeof(struct simple_gre_hdr); +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -317,7 +382,7 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, * packet */ static uint64_t process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, -uint16_t testpmd_ol_flags) + uint16_t testpmd_ol_flags) { struct ipv4_hdr *ipv4_hdr = outer_l3_hdr; struct ipv6_hdr *ipv6_hdr = outer_l3_hdr; @@ -335,6 +400,9 @@ uint16_t testpmd_ol_flags) } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ol_flags |= PKT_TX_OUTER_IPV6; + if (info->outer_l4_proto != IPPROTO_UDP) + return ol_flags; + /* outer UDP checksum is always done in software as we have no * hardware supporting it today, and no API for it. */ @@ -368,6 +436,8 @@ uint16_t testpmd_ol_flags) * Ether / (vlan) / IP|IP6 / UDP|TCP|SCTP . * Ether / (vlan) / outer IP|IP6 / outer UDP / VxLAN / Ether / IP|IP6 / * UDP|TCP|SCTP + * Ether / (vlan) / outer IP|IP6 / GRE / Ether / IP|IP6 / UDP|TCP|SCTP + * Ether / (vlan) / outer IP|IP6 / GRE / IP|IP6 / UDP|TCP|SCTP * * The testpmd command line for this forward engine sets the flags * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control @@ -437,12 +507,19 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) parse_ethernet(eth_hdr, &info); l3_hdr = (char *)eth_hdr + info.l2_len; - /* check if it's a supported tunnel (only vxlan for now) */ - if ((testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) && - info.l4_proto == IPPROTO_UDP) { - struct udp_hdr *udp_hdr; - udp_hdr = (struct udp_hdr *)((char *)l3_hdr + info.l3_len); - parse_vxlan(udp_hdr, &info, m->ol_flags); + /* check if it's a supported tunnel */ + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) { + if (info.l4_proto == IPPROTO_UDP) { + struct udp_hdr *udp_hdr; + udp_hdr = (struct udp_hdr *)((char *)l3_hdr + + info.l3_len); + parse_vxlan(udp_hdr, &info, m->ol_flags); + } else if (info.l4_proto == IPPROTO_GRE) { + struct simple_gre_hdr *gre_hdr; + gre_hdr = (struct simple_gre_hdr *) + ((char *)l3_hdr + info.l3_len); + parse_gre(gre_hdr, &info); + } } /* update l3_hdr and outer_l3_hdr if a tunnel was parsed */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 14/20] testpmd: support ipip tunnel in csum forward engine 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (12 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 13/20] testpmd: support gre tunnels " Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 15/20] ethdev: add outer IP offload capability flag Olivier Matz ` (6 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev Add support for IP over IP tunnels. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 2 +- app/test-pmd/csumonly.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index b19869c..fc08183 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -324,7 +324,7 @@ static void cmd_help_long_parsed(void *parsed_result, " ip|udp|tcp|sctp always concern the inner layer.\n" " outer-ip concerns the outer IP layer in" " case the packet is recognized as a tunnel packet by" - " the forward engine (vxlan and gre are supported)\n" + " the forward engine (vxlan, gre and ipip are supported)\n" " Please check the NIC datasheet for HW limits.\n\n" "csum parse-tunnel (on|off) (tx_port_id)\n" diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 2582bf1..bee652a 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -283,6 +283,35 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) info->l2_len += sizeof(struct simple_gre_hdr); } + +/* Parse an encapsulated ip or ipv6 header */ +static void +parse_encap_ip(void *encap_ip, struct testpmd_offload_info *info) +{ + struct ipv4_hdr *ipv4_hdr = encap_ip; + struct ipv6_hdr *ipv6_hdr = encap_ip; + uint8_t ip_version; + + ip_version = (ipv4_hdr->version_ihl & 0xf0) >> 4; + + if (ip_version != 4 && ip_version != 6) + return; + + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + + if (ip_version == 4) { + parse_ipv4(ipv4_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv4); + } else { + parse_ipv6(ipv6_hdr, info); + info->ethertype = _htons(ETHER_TYPE_IPv6); + } + info->l2_len = 0; +} + /* modify the IPv4 or IPv4 source address of a packet */ static void change_ip_addresses(void *l3_hdr, uint16_t ethertype) @@ -438,6 +467,7 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, * UDP|TCP|SCTP * Ether / (vlan) / outer IP|IP6 / GRE / Ether / IP|IP6 / UDP|TCP|SCTP * Ether / (vlan) / outer IP|IP6 / GRE / IP|IP6 / UDP|TCP|SCTP + * Ether / (vlan) / outer IP|IP6 / IP|IP6 / UDP|TCP|SCTP * * The testpmd command line for this forward engine sets the flags * TESTPMD_TX_OFFLOAD_* in ports[tx_port].tx_ol_flags. They control @@ -519,6 +549,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) gre_hdr = (struct simple_gre_hdr *) ((char *)l3_hdr + info.l3_len); parse_gre(gre_hdr, &info); + } else if (info.l4_proto == IPPROTO_IPIP) { + void *encap_ip_hdr; + encap_ip_hdr = (char *)l3_hdr + info.l3_len; + parse_encap_ip(encap_ip_hdr, &info); } } -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 15/20] ethdev: add outer IP offload capability flag 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (13 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 14/20] testpmd: support ipip tunnel in csum forward engine Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 16/20] i40e: advertise outer IPv4 checksum capability Olivier Matz ` (5 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev From: Jijiang Liu <jijiang.liu@intel.com> If the flag is advertised by a PMD, the NIC supports the outer IP checksum TX offload of tunneling packets, therefore an application can set the PKT_TX_OUTER_IP_CKSUM flag in mbufs when transmitting on this port. Signed-off-by: Jijiang Liu <jijiang.liu@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_ether/rte_ethdev.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 1200c1c..84160c3 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -916,6 +916,7 @@ struct rte_eth_conf { #define DEV_TX_OFFLOAD_SCTP_CKSUM 0x00000010 #define DEV_TX_OFFLOAD_TCP_TSO 0x00000020 #define DEV_TX_OFFLOAD_UDP_TSO 0x00000040 +#define DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM 0x00000080 /**< Used for tunneling packet. */ struct rte_eth_dev_info { struct rte_pci_device *pci_dev; /**< Device PCI information. */ -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 16/20] i40e: advertise outer IPv4 checksum capability 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (14 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 15/20] ethdev: add outer IP offload capability flag Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 17/20] testpmd: add a warning if outer ip cksum requested but not supported Olivier Matz ` (4 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev From: Jijiang Liu <jijiang.liu@intel.com> Advertise the DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM flag in the PMD features. It means that the i40e PMD supports the offload of outer IP checksum when transmitting tunneling packet. Signed-off-by: Jijiang Liu <jijiang.liu@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c b/lib/librte_pmd_i40e/i40e_ethdev.c index 9fa6bec..6f385d2 100644 --- a/lib/librte_pmd_i40e/i40e_ethdev.c +++ b/lib/librte_pmd_i40e/i40e_ethdev.c @@ -1529,7 +1529,8 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) DEV_TX_OFFLOAD_IPV4_CKSUM | DEV_TX_OFFLOAD_UDP_CKSUM | DEV_TX_OFFLOAD_TCP_CKSUM | - DEV_TX_OFFLOAD_SCTP_CKSUM; + DEV_TX_OFFLOAD_SCTP_CKSUM | + DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; dev_info->reta_size = pf->hash_lut_size; dev_info->default_rxconf = (struct rte_eth_rxconf) { -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 17/20] testpmd: add a warning if outer ip cksum requested but not supported 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (15 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 16/20] i40e: advertise outer IPv4 checksum capability Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 18/20] testpmd: fix TSO when using outer checksum offloads Olivier Matz ` (3 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/cmdline.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index fc08183..9de3e7e 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2930,7 +2930,11 @@ csum_show(int port_id) printf("Warning: hardware SCTP checksum enabled but not " "supported by port %d\n", port_id); } - + if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) && + (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { + printf("Warning: hardware outer IP checksum enabled but not " + "supported by port %d\n", port_id); + } } static void -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 18/20] testpmd: fix TSO when using outer checksum offloads 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (16 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 17/20] testpmd: add a warning if outer ip cksum requested but not supported Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 19/20] i40e: fix offloading of outer checksum for ip in ip tunnels Olivier Matz ` (2 subsequent siblings) 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev The l4_len has also to be copied in mbuf in case we are offloading outer IP checksum. Currently, TSO + outer checksum is not supported by any driver but it will soon be supported by i40e. Pointed-out-by: Jijiang Liu <jijiang.liu@intel.com> Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- app/test-pmd/csumonly.c | 1 + 1 file changed, 1 insertion(+) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index bee652a..0a7af79 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -593,6 +593,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) m->outer_l3_len = info.outer_l3_len; m->l2_len = info.l2_len; m->l3_len = info.l3_len; + m->l4_len = info.l4_len; } else { /* if there is a outer UDP cksum -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 19/20] i40e: fix offloading of outer checksum for ip in ip tunnels 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (17 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 18/20] testpmd: fix TSO when using outer checksum offloads Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 20/20] i40e: add debug logs for tx context descriptors Olivier Matz 2015-02-15 6:22 ` [dpdk-dev] [PATCH v3 00/20] enhance tx checksum offload API Liu, Jijiang 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev When offloading the checksums of ipip tunnels, m->l2_len is set to 0 as there is no tunnel or inner l2 header. Since this is a valid value remove the test. By the way, also remove the same test with l3_len because at this point, it is expected that the software provides proper values in the mbuf. It should avoid a test in dataplane processing and therefore slightly increase performance. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_rxtx.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index d2f9a97..546f4d1 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -471,16 +471,6 @@ i40e_txd_enable_checksum(uint64_t ol_flags, uint16_t outer_l3_len, uint32_t *cd_tunneling) { - if (!l2_len) { - PMD_DRV_LOG(DEBUG, "L2 length set to 0"); - return; - } - - if (!l3_len) { - PMD_DRV_LOG(DEBUG, "L3 length set to 0"); - return; - } - /* UDP tunneling packet TX checksum offload */ if (ol_flags & PKT_TX_OUTER_IP_CKSUM) { -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* [dpdk-dev] [PATCH v3 20/20] i40e: add debug logs for tx context descriptors 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (18 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 19/20] i40e: fix offloading of outer checksum for ip in ip tunnels Olivier Matz @ 2015-02-13 9:22 ` Olivier Matz 2015-02-15 6:22 ` [dpdk-dev] [PATCH v3 00/20] enhance tx checksum offload API Liu, Jijiang 20 siblings, 0 replies; 109+ messages in thread From: Olivier Matz @ 2015-02-13 9:22 UTC (permalink / raw) To: dev This could be useful to have this values for debug purposes. Suggested-by: Konstantin Ananyev <konstantin.ananyev@intel.com> Signed-off-by: Olivier Matz <olivier.matz@6wind.com> --- lib/librte_pmd_i40e/i40e_rxtx.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/librte_pmd_i40e/i40e_rxtx.c b/lib/librte_pmd_i40e/i40e_rxtx.c index 546f4d1..c9f1026 100644 --- a/lib/librte_pmd_i40e/i40e_rxtx.c +++ b/lib/librte_pmd_i40e/i40e_rxtx.c @@ -1298,6 +1298,18 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) ctx_txd->l2tag2 = rte_cpu_to_le_16(cd_l2tag2); ctx_txd->type_cmd_tso_mss = rte_cpu_to_le_64(cd_type_cmd_tso_mss); + + PMD_TX_LOG(DEBUG, "mbuf: %p, TCD[%u]:\n" + "tunneling_params: %#x;\n" + "l2tag2: %#hx;\n" + "rsvd: %#hx;\n" + "type_cmd_tso_mss: %#lx;\n", + tx_pkt, tx_id, + ctx_txd->tunneling_params, + ctx_txd->l2tag2, + ctx_txd->rsvd, + ctx_txd->type_cmd_tso_mss); + txe->last_id = tx_last; tx_id = txe->next_id; txe = txn; @@ -1315,6 +1327,16 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) /* Setup TX Descriptor */ slen = m_seg->data_len; buf_dma_addr = RTE_MBUF_DATA_DMA_ADDR(m_seg); + + PMD_TX_LOG(DEBUG, "mbuf: %p, TDD[%u]:\n" + "buf_dma_addr: %#"PRIx64";\n" + "td_cmd: %#x;\n" + "td_offset: %#x;\n" + "td_len: %u;\n" + "td_tag: %#x;\n", + tx_pkt, tx_id, buf_dma_addr, + td_cmd, td_offset, slen, td_tag); + txd->buffer_addr = rte_cpu_to_le_64(buf_dma_addr); txd->cmd_type_offset_bsz = i40e_build_ctob(td_cmd, td_offset, slen, td_tag); -- 2.1.4 ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v3 00/20] enhance tx checksum offload API 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz ` (19 preceding siblings ...) 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 20/20] i40e: add debug logs for tx context descriptors Olivier Matz @ 2015-02-15 6:22 ` Liu, Jijiang 2015-02-16 18:23 ` Thomas Monjalon 20 siblings, 1 reply; 109+ messages in thread From: Liu, Jijiang @ 2015-02-15 6:22 UTC (permalink / raw) To: Olivier Matz, dev > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Friday, February 13, 2015 5:23 PM > To: dev@dpdk.org > Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; olivier.matz@6wind.com > Subject: [PATCH v3 00/20] enhance tx checksum offload API > > The goal of this series is to clarify and simplify the mbuf offload API. > > - simplify the definitions of PKT_TX_IP_CKSUM and PKT_TX_IPV4, each > flag has now only one meaning. No impact on the code. > > - add a feature flag for OUTER_IP_CHECKSUM (from Jijiang's patches) > > - remove the PKT_TX_UDP_TUNNEL_PKT flag: it is useless from an API point > of view. It was added because i40e need this info for some reason. We > have 3 solutions: > > - remove the flag and adapt the driver to the API (the choice I made > for this series). > > - remove the flag and stop advertising OUTER_IP_CHECKSUM in i40e > > - keep this flag, penalizing performance of drivers that do not > require the flag. It would also mean that drivers won't support > outer IP checksum for all tunnel types, but only for the tunnel > types having a flag. > > - a side effect of this API clarification is that there is only one > way for doing one operation. If the hardware has several ways to > do the same operation, a choice has to be made in the driver. > > The series also provide some enhancements and fixes related to this API rework: > > - new tunnel types to testpmd csum forward engine. > - fixes in i40e to adapt to new api and support more tunnel types. > > [1] http://dpdk.org/ml/archives/dev/2015-January/011127.html > > Changes in v2: > - fix test of rx offload flag in parse_vlan() pointed out by Jijiang > > Changes in v3: > - more detailed API comments for PKT_TX_IPV4 and PKT_TX_IPV6 > - do not calculate the outer UDP checksum if packet is not UDP > - add a likely() in i40e > - remove a unlikely() in i40e > - fix a patch split issue > - rebase on head > > Jijiang Liu (2): > ethdev: add outer IP offload capability flag > i40e: advertise outer IPv4 checksum capability > > Olivier Matz (18): > mbuf: remove PKT_TX_IPV4_CSUM > mbuf: enhance the API documentation of offload flags > i40e: call i40e_txd_enable_checksum only for offloaded packets > i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag > mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag > testpmd: replace tx_checksum command by csum > testpmd: move csum_show in a function > testpmd: add csum parse_tunnel command > testpmd: rename vxlan in outer_ip in csum commands > testpmd: introduce parse_ipv* in csum fwd engine > testpmd: use a structure to store offload info in csum fwd engine > testpmd: introduce parse_vxlan in csum fwd engine > testpmd: support gre tunnels in csum fwd engine > testpmd: support ipip tunnel in csum forward engine > testpmd: add a warning if outer ip cksum requested but not supported > testpmd: fix TSO when using outer checksum offloads > i40e: fix offloading of outer checksum for ip in ip tunnels > i40e: add debug logs for tx context descriptors > > app/test-pmd/cmdline.c | 234 ++++++++++++++------- > app/test-pmd/csumonly.c | 425 ++++++++++++++++++++++++++--------- > --- > app/test-pmd/testpmd.h | 9 +- > lib/librte_ether/rte_ethdev.h | 1 + > lib/librte_mbuf/rte_mbuf.c | 1 - > lib/librte_mbuf/rte_mbuf.h | 51 +++-- > lib/librte_pmd_i40e/i40e_ethdev.c | 3 +- > lib/librte_pmd_i40e/i40e_rxtx.c | 55 +++-- > 8 files changed, 529 insertions(+), 250 deletions(-) > > -- > 2.1.4 Acked-by: Jijiang Liu < Jijiang.liu@intel.com> ^ permalink raw reply [flat|nested] 109+ messages in thread
* Re: [dpdk-dev] [PATCH v3 00/20] enhance tx checksum offload API 2015-02-15 6:22 ` [dpdk-dev] [PATCH v3 00/20] enhance tx checksum offload API Liu, Jijiang @ 2015-02-16 18:23 ` Thomas Monjalon 0 siblings, 0 replies; 109+ messages in thread From: Thomas Monjalon @ 2015-02-16 18:23 UTC (permalink / raw) To: Olivier Matz; +Cc: dev > > The goal of this series is to clarify and simplify the mbuf offload API. > > > > - simplify the definitions of PKT_TX_IP_CKSUM and PKT_TX_IPV4, each > > flag has now only one meaning. No impact on the code. > > > > - add a feature flag for OUTER_IP_CHECKSUM (from Jijiang's patches) > > > > - remove the PKT_TX_UDP_TUNNEL_PKT flag: it is useless from an API point > > of view. It was added because i40e need this info for some reason. We > > have 3 solutions: > > > > - remove the flag and adapt the driver to the API (the choice I made > > for this series). > > > > - remove the flag and stop advertising OUTER_IP_CHECKSUM in i40e > > > > - keep this flag, penalizing performance of drivers that do not > > require the flag. It would also mean that drivers won't support > > outer IP checksum for all tunnel types, but only for the tunnel > > types having a flag. > > > > - a side effect of this API clarification is that there is only one > > way for doing one operation. If the hardware has several ways to > > do the same operation, a choice has to be made in the driver. > > > > The series also provide some enhancements and fixes related to this API rework: > > > > - new tunnel types to testpmd csum forward engine. > > - fixes in i40e to adapt to new api and support more tunnel types. > > > > [1] http://dpdk.org/ml/archives/dev/2015-January/011127.html > > > > Changes in v2: > > - fix test of rx offload flag in parse_vlan() pointed out by Jijiang > > > > Changes in v3: > > - more detailed API comments for PKT_TX_IPV4 and PKT_TX_IPV6 > > - do not calculate the outer UDP checksum if packet is not UDP > > - add a likely() in i40e > > - remove a unlikely() in i40e > > - fix a patch split issue > > - rebase on head > > > > Jijiang Liu (2): > > ethdev: add outer IP offload capability flag > > i40e: advertise outer IPv4 checksum capability > > > > Olivier Matz (18): > > mbuf: remove PKT_TX_IPV4_CSUM > > mbuf: enhance the API documentation of offload flags > > i40e: call i40e_txd_enable_checksum only for offloaded packets > > i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag > > mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag > > testpmd: replace tx_checksum command by csum > > testpmd: move csum_show in a function > > testpmd: add csum parse_tunnel command > > testpmd: rename vxlan in outer_ip in csum commands > > testpmd: introduce parse_ipv* in csum fwd engine > > testpmd: use a structure to store offload info in csum fwd engine > > testpmd: introduce parse_vxlan in csum fwd engine > > testpmd: support gre tunnels in csum fwd engine > > testpmd: support ipip tunnel in csum forward engine > > testpmd: add a warning if outer ip cksum requested but not supported > > testpmd: fix TSO when using outer checksum offloads > > i40e: fix offloading of outer checksum for ip in ip tunnels > > i40e: add debug logs for tx context descriptors > > Acked-by: Jijiang Liu < Jijiang.liu@intel.com> Applied, thanks for making API clearer ^ permalink raw reply [flat|nested] 109+ messages in thread
end of thread, other threads:[~2015-02-16 18:23 UTC | newest] Thread overview: 109+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-01-21 23:36 [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 01/16] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 02/16] mbuf: enhance the API documentation of offload flags Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 03/16] i40e: call i40e_txd_enable_checksum only for offloaded packets Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 04/16] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag Olivier Matz 2015-01-23 8:06 ` Liu, Jijiang 2015-01-23 8:47 ` Zhang, Helin 2015-01-23 9:06 ` Olivier MATZ 2015-01-21 23:36 ` [dpdk-dev] [RFC 05/16] mbuf: remove " Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 06/16] ethdev: add outer IP offload capability flag Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 07/16] i40e: advertise outer IPv4 checksum capability Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 08/16] testpmd: replace tx_checksum command by csum Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 09/16] testpmd: move csum_show in a function Olivier Matz 2015-01-23 11:03 ` Liu, Jijiang 2015-01-23 17:53 ` Olivier MATZ 2015-01-21 23:36 ` [dpdk-dev] [RFC 10/16] testpmd: add csum parse_tunnel command Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 11/16] testpmd: rename vxlan in outer_ip in csum commands Olivier Matz 2015-01-23 11:21 ` Liu, Jijiang 2015-01-23 17:49 ` Olivier MATZ 2015-01-21 23:36 ` [dpdk-dev] [RFC 12/16] testpmd: introduce parse_ipv* in csum fwd engine Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 13/16] testpmd: use a structure to store offload info " Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 14/16] testpmd: introduce parse_vxlan " Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 15/16] testpmd: support gre tunnels " Olivier Matz 2015-01-21 23:36 ` [dpdk-dev] [RFC 16/16] testpmd: support ipip tunnel in csum forward engine Olivier Matz 2015-01-21 23:41 ` [dpdk-dev] [RFC 00/16] enhance checksum offload API Olivier MATZ 2015-01-22 10:00 ` Thomas Monjalon 2015-01-22 1:01 ` Stephen Hemminger 2015-01-23 9:52 ` Olivier MATZ 2015-01-23 7:54 ` Liu, Jijiang 2015-01-30 13:15 ` [dpdk-dev] [PATCH 00/20] enhance tx " Olivier Matz 2015-01-30 13:15 ` [dpdk-dev] [PATCH 01/20] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz 2015-01-30 13:15 ` [dpdk-dev] [PATCH 02/20] mbuf: enhance the API documentation of offload flags Olivier Matz 2015-01-30 13:15 ` [dpdk-dev] [PATCH 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets Olivier Matz 2015-01-30 13:15 ` [dpdk-dev] [PATCH 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 05/20] mbuf: remove " Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 06/20] testpmd: replace tx_checksum command by csum Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 07/20] testpmd: move csum_show in a function Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 08/20] testpmd: add csum parse_tunnel command Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 09/20] testpmd: rename vxlan in outer_ip in csum commands Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 10/20] testpmd: introduce parse_ipv* in csum fwd engine Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 11/20] testpmd: use a structure to store offload info " Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 12/20] testpmd: introduce parse_vxlan " Olivier Matz 2015-02-02 1:49 ` Liu, Jijiang 2015-01-30 13:16 ` [dpdk-dev] [PATCH 13/20] testpmd: support gre tunnels " Olivier Matz 2015-02-02 3:04 ` Liu, Jijiang 2015-01-30 13:16 ` [dpdk-dev] [PATCH 14/20] testpmd: support ipip tunnel in csum forward engine Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 15/20] ethdev: add outer IP offload capability flag Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 16/20] i40e: advertise outer IPv4 checksum capability Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 17/20] testpmd: add a warning if outer ip cksum requested but not supported Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 18/20] testpmd: fix TSO when using outer checksum offloads Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 19/20] i40e: fix offloading of outer checksum for ip in ip tunnels Olivier Matz 2015-01-30 13:16 ` [dpdk-dev] [PATCH 20/20] i40e: add debug logs for tx context descriptors Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 01/20] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 02/20] mbuf: enhance the API documentation of offload flags Olivier Matz 2015-02-10 5:38 ` Zhang, Helin 2015-02-10 16:54 ` Olivier MATZ 2015-02-11 7:15 ` Liu, Jijiang 2015-02-11 15:15 ` Olivier MATZ 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets Olivier Matz 2015-02-10 6:03 ` Zhang, Helin 2015-02-10 17:06 ` Olivier MATZ 2015-02-11 5:32 ` Zhang, Helin 2015-02-11 17:13 ` Olivier MATZ 2015-02-13 2:25 ` Zhang, Helin 2015-02-13 8:41 ` Olivier MATZ 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag Olivier Matz 2015-02-10 6:40 ` Zhang, Helin 2015-02-10 17:08 ` Olivier MATZ 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 05/20] mbuf: remove " Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 06/20] testpmd: replace tx_checksum command by csum Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 07/20] testpmd: move csum_show in a function Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 08/20] testpmd: add csum parse_tunnel command Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 09/20] testpmd: rename vxlan in outer_ip in csum commands Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 10/20] testpmd: introduce parse_ipv* in csum fwd engine Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 11/20] testpmd: use a structure to store offload info " Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 12/20] testpmd: introduce parse_vxlan " Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 13/20] testpmd: support gre tunnels " Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 14/20] testpmd: support ipip tunnel in csum forward engine Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 15/20] ethdev: add outer IP offload capability flag Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 16/20] i40e: advertise outer IPv4 checksum capability Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 17/20] testpmd: add a warning if outer ip cksum requested but not supported Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 18/20] testpmd: fix TSO when using outer checksum offloads Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 19/20] i40e: fix offloading of outer checksum for ip in ip tunnels Olivier Matz 2015-02-04 9:25 ` [dpdk-dev] [PATCH v2 20/20] i40e: add debug logs for tx context descriptors Olivier Matz 2015-02-09 1:10 ` [dpdk-dev] [PATCH v2 00/20] enhance tx checksum offload API Liu, Jijiang 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 " Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 01/20] mbuf: remove PKT_TX_IPV4_CSUM Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 02/20] mbuf: enhance the API documentation of offload flags Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 05/20] mbuf: remove " Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 06/20] testpmd: replace tx_checksum command by csum Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 07/20] testpmd: move csum_show in a function Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 08/20] testpmd: add csum parse_tunnel command Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 09/20] testpmd: rename vxlan in outer_ip in csum commands Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 10/20] testpmd: introduce parse_ipv* in csum fwd engine Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 11/20] testpmd: use a structure to store offload info " Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 12/20] testpmd: introduce parse_vxlan " Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 13/20] testpmd: support gre tunnels " Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 14/20] testpmd: support ipip tunnel in csum forward engine Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 15/20] ethdev: add outer IP offload capability flag Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 16/20] i40e: advertise outer IPv4 checksum capability Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 17/20] testpmd: add a warning if outer ip cksum requested but not supported Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 18/20] testpmd: fix TSO when using outer checksum offloads Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 19/20] i40e: fix offloading of outer checksum for ip in ip tunnels Olivier Matz 2015-02-13 9:22 ` [dpdk-dev] [PATCH v3 20/20] i40e: add debug logs for tx context descriptors Olivier Matz 2015-02-15 6:22 ` [dpdk-dev] [PATCH v3 00/20] enhance tx checksum offload API Liu, Jijiang 2015-02-16 18:23 ` Thomas Monjalon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).