enhance checksum offload API
cover enhance checksum offload API
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(-)
Signature · 1 line
2.1.3
A message that is not in the archive (sent off-list or not yet received): 1421883395-27235-1-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
RFC 1/16 mbuf: remove PKT_TX_IPV4_CSUM
This alias is only used in one place of i40e driver. Remove it and only keep the legacy flag PKT_TX_IP_CSUM.
--- lib/librte_mbuf/rte_mbuf.h | 1 - lib/librte_pmd_i40e/i40e_rxtx.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
lib/librte_mbuf/rte_mbuf.h +0 -1
@@ -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)
lib/librte_pmd_i40e/i40e_rxtx.c +1 -1
@@ -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 ) {
Signature · 1 line
2.1.3
RFC 2/16 mbuf: enhance the API documentation of offload flags
In reply to a message not in the archiveBased on http://dpdk.org/ml/archives/dev/2015-January/011127.html
Also adapt the csum forward engine code to the API.
--- app/test-pmd/csumonly.c | 6 +++--- lib/librte_mbuf/rte_mbuf.h | 43 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 10 deletions(-)
app/test-pmd/csumonly.c +3 -3
@@ -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 ;
lib/librte_mbuf/rte_mbuf.h +36 -7
60 lines not on this page · raw message
Signature · 1 line
2.1.3
RFC 3/16 i40e: call i40e_txd_enable_checksum only for offloaded packets
In reply to a message not in the archiveQuoted 1 line
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.
--- lib/librte_pmd_i40e/i40e_rxtx.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
lib/librte_pmd_i40e/i40e_rxtx.c +11 -4
@@ -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 */
Signature · 1 line
2.1.3
RFC 4/16 i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag
In reply to a message not in the archiveThe 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
--- lib/librte_pmd_i40e/i40e_rxtx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/librte_pmd_i40e/i40e_rxtx.c +2 -4
@@ -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 ;
Signature · 1 line
2.1.3
A message that is not in the archive (sent off-list or not yet received): 1421883395-27235-5-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
Re: [RFC 04/16] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag
Hi,
Quoted 40 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Thursday, January 22, 2015 7:36 AM
To: [email protected]
Cc: [email protected]; Ananyev, Konstantin; Liu, Jijiang
Subject: [RFC 04/16] i40e: remove the use ofPKT_TX_UDP_TUNNEL_PKTflagThe definition of the flag in
rte_mbuf.hwas:
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_TUNNELINGflag). 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 <[email protected]>--- lib/librte_pmd_i40e/i40e_rxtx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)lib/librte_pmd_i40e/i40e_rxtx.c +0
-0
lib/librte_pmd_i40e/i40e_rxtx.c i40e_txd_enable_checksum(uint64_t ol_flags, · line 485
Quoted 5 lines
lib/librte_pmd_i40e/i40e_rxtx.c +1
-1@@ -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?
Quoted 24 lines
lib/librte_pmd_i40e/i40e_rxtx.c +1
-4*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
A message that is not in the archive (sent off-list or not yet received): 1ED644BD7E0A5F4091CF203DAFB8E4CC01DB631A-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org
Re: [RFC 04/16] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag
Hi guys
Quoted 61 lines
-----Original Message-----
From: Liu, Jijiang
Sent: Friday, January 23, 2015 4:06 PM
To: Olivier Matz; Zhang, Helin
Cc: Ananyev, Konstantin; [email protected]
Subject: RE: [RFC 04/16] i40e: remove the use ofPKT_TX_UDP_TUNNEL_PKTflagHi,
Quoted 17 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Thursday, January 22, 2015 7:36 AM
To: [email protected]
Cc: [email protected]; Ananyev, Konstantin; Liu, Jijiang
Subject: [RFC 04/16] i40e: remove the use ofPKT_TX_UDP_TUNNEL_PKT
flagThe definition of the flag in
rte_mbuf.hwas:
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_TUNNELINGflag). 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.Quoted 8 lines
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.
Quoted 16 lines
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 <[email protected]>--- lib/librte_pmd_i40e/i40e_rxtx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/lib/librte_pmd_i40e/i40e_rxtx.cindex 9acdeee..0786255 100644lib/librte_pmd_i40e/i40e_rxtx.c i40e_txd_enable_checksum(uint64_t ol_flags, · line 485
Quoted 5 lines
lib/librte_pmd_i40e/i40e_rxtx.c +1
-1@@ -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.
Quoted 5 lines
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.
Quoted 27 lines
lib/librte_pmd_i40e/i40e_rxtx.c i40e_txd_enable_checksum(uint64_t ol_flags, · line 487
Quoted 4 lines
lib/librte_pmd_i40e/i40e_rxtx.c +0
-0*td_offset |= (outer_l2_len >>1 ) << I40E_TX_DESC_LENGTH_MACLEN_SHIFT; @@ -497,7+497,6 @@
Quoted 22 lines
lib/librte_pmd_i40e/i40e_rxtx.c +0
-0i40e_txd_enable_checksum(uint64_t ol_flags,lib/librte_pmd_i40e/i40e_rxtx.c +1
-4/* 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
A message that is not in the archive (sent off-list or not yet received): F35DEAC7BCE34641BA9FAC6BCA4A12E70A7ECFC1-0J0gbvR4kTg/[email protected]
Re: [RFC 04/16] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag
Hi Helin,
Quoted 18 lines · Helin
Quoted 18 lines
lib/librte_pmd_i40e/i40e_rxtx.c i40e_txd_enable_checksum(uint64_t ol_flags, · line 485
Quoted 10 lines
(quoted diff) +0
-0
b/lib/librte_pmd_i40e/i40e_rxtx.cindex 9acdeee..0786255 100644lib/librte_pmd_i40e/i40e_rxtx.c +1
-1@@ -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.
Quoted 6 lines
Quoted 1 line
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]
Quoted 1 line
4. Outer IP (hw csum) + inner IP (sw csum) + L4 (sw csum)
case 1 in [1]
Quoted 3 lines
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]
Quoted 1 line
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
RFC 5/16 mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag
In reply to a message not in the archiveSince 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.
--- 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(-)
app/test-pmd/csumonly.c +0 -4
@@ -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 },
lib/librte_mbuf/rte_mbuf.c +0 -1
@@ -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" ;
lib/librte_mbuf/rte_mbuf.h +1 -4
@@ -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. */ /**
Signature · 1 line
2.1.3
RFC 6/16 ethdev: add outer IP offload capability flag
In reply to a message not in the archiveFrom: Jijiang Liu <[email protected]>
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.
--- lib/librte_ether/rte_ethdev.h | 1 + 1 file changed, 1 insertion(+)
lib/librte_ether/rte_ethdev.h +1 -0
@@ -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. */
Signature · 1 line
2.1.3
RFC 7/16 i40e: advertise outer IPv4 checksum capability
In reply to a message not in the archiveFrom: Jijiang Liu <[email protected]>
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.
--- lib/librte_pmd_i40e/i40e_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/librte_pmd_i40e/i40e_ethdev.c +2 -1
@@ -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 ) {
Signature · 1 line
2.1.3
RFC 8/16 testpmd: replace tx_checksum command by csum
In reply to a message not in the archiveReplace 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.
--- app/test-pmd/cmdline.c | 70 +++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-)
app/test-pmd/cmdline.c +35 -35
@@ -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,
Signature · 1 line
2.1.3
RFC 9/16 testpmd: move csum_show in a function
In reply to a message not in the archiveNo 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.
--- app/test-pmd/cmdline.c | 82 +++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 37 deletions(-)
app/test-pmd/cmdline.c +45 -37
@@ -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 =
Signature · 1 line
2.1.3
A message that is not in the archive (sent off-list or not yet received): 1421883395-27235-10-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
Re: [RFC 09/16] testpmd: move csum_show in a function
Hi,
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Thursday, January 22, 2015 7:36 AM
To: [email protected]
Cc: [email protected]; 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.
--- app/test-pmd/cmdline.c | 82 +++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 37 deletions(-)
app/test-pmd/cmdline.c +39 -0
@@ -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
A message that is not in the archive (sent off-list or not yet received): 1ED644BD7E0A5F4091CF203DAFB8E4CC01DB63D6-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org
Re: [RFC 09/16] testpmd: move csum_show in a function
Hi Jijiang,
Quoted 23 lines · Jijiang
app/test-pmd/cmdline.c +22
-0+/* 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); + }
Quoted 1 line
The
ESTPMD_TX_OFFLOAD_OUTER_IP_CKSUMcheck 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
RFC 10/16 testpmd: add csum parse_tunnel command
In reply to a message not in the archiveAdd 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).
--- 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(-)
app/test-pmd/cmdline.c +64 -0
@@ -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,
app/test-pmd/csumonly.c +2 -1
@@ -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
app/test-pmd/testpmd.h +4 -1
@@ -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.
Signature · 1 line
2.1.3
RFC 11/16 testpmd: rename vxlan in outer_ip in csum commands
In reply to a message not in the archiveThe 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.
--- 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(-)
app/test-pmd/cmdline.c +8 -8
@@ -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,
app/test-pmd/csumonly.c +14 -11
@@ -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 )
app/test-pmd/testpmd.h +2 -2
@@ -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
Signature · 1 line
2.1.3
A message that is not in the archive (sent off-list or not yet received): 1421883395-27235-12-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
Re: [RFC 11/16] testpmd: rename vxlan in outer_ip in csum commands
Hi,
Quoted 132 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Thursday, January 22, 2015 7:37 AM
To: [email protected]
Cc: [email protected]; Ananyev, Konstantin; Liu, Jijiang
Subject: [RFC 11/16] testpmd: rename vxlan inouter_ipin csum commandsThe
tx_checksumcommand 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 <[email protected]>--- 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(-)app/test-pmd/cmdline.c index renamed from app/test-pmd/cmdline.c +0
-01d294bc..451c728 100644
app/test-pmd/cmdline.c +1
-1@@ -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"
app/test-pmd/cmdline.c +3
-3" 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" );app/test-pmd/cmdline.c +0
-0/* 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,app/test-pmd/cmdline.c +3
-3mask =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 checksumwhen "
app/test-pmd/cmdline.c +0
-1- "using csum forward engine: csum set ip|tcp|udp|sctp|vxlanhw|sw <port>",
app/test-pmd/cmdline.c +1
-0+ "using csum forward engine: csum set ip|tcp|udp|sctp|outer-iphw|sw
+<port>",app/test-pmd/cmdline.c +0
-0.tokens = { (void *)&cmd_csum_csum, (void *)&cmd_csum_mode,app/test-pmd/csumonly.c index renamed from app/test-pmd/csumonly.c +0
-0858eb47..3921643 100644
app/test-pmd/csumonly.c +5
-2@@ -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. */ +app/test-pmd/csumonly.c +2
-2udp_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_touter_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)app/test-pmd/csumonly.c +0
-1/* step 4: fill the mbuf meta data (flags and header lengths) */ if (tunnel ==1 ) { - if (testpmd_ol_flags &
TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) {app/test-pmd/csumonly.c +1
-0+ if (testpmd_ol_flags &
TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) {
app/test-pmd/csumonly.c pkt_burst_checksum_forward(struct fwd_stream *fs) · line 442
Quoted 4 lines
app/test-pmd/csumonly.c +0
-0m->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.
Quoted 45 lines
app/test-pmd/csumonly.c +5
-5}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)app/test-pmd/csumonly.c +0
-1"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))app/test-pmd/csumonly.c +1
-0+ (testpmd_ol_flags &
TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
printf("tx: m->outer_l2_len=%d m-Quoted 1 line
outer_l3_len=%d\n",
app/test-pmd/csumonly.c +0
-0m->outer_l2_len, m->outer_l3_len);if (tso_segsz !=0 )app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0
-036277de..ecb7d38 100644
app/test-pmd/testpmd.h +2
-2@@ -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_TUNNEL0x0020
--
2.1.3
A message that is not in the archive (sent off-list or not yet received): 1ED644BD7E0A5F4091CF203DAFB8E4CC01DB6402-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org
Re: [RFC 11/16] testpmd: rename vxlan in outer_ip in csum commands
Hi Jijiang,
Quoted 5 lines · Jijiang
Quoted 5 lines
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) */
Quoted 11 lines
app/test-pmd/csumonly.c pkt_burst_checksum_forward(struct fwd_stream *fs) · line 442
Quoted 9 lines
(quoted diff) +0
-1if (tunnel == 1) { - if (testpmd_ol_flags &
TESTPMD_TX_OFFLOAD_VXLAN_CKSUM) {(quoted diff) +1
-0+ if (testpmd_ol_flags &
TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) {app/test-pmd/csumonly.c +0
-0m->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_lenhere.
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
RFC 12/16 testpmd: introduce parse_ipv* in csum fwd engine
In reply to a message not in the archiveThese functions may be used to parse encapsulated layers when we will support IP over GRE tunnels.
No functional change.
--- app/test-pmd/csumonly.c | 51 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-)
app/test-pmd/csumonly.c +39 -12
@@ -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 */
Signature · 1 line
2.1.3
RFC 13/16 testpmd: use a structure to store offload info in csum fwd engine
In reply to a message not in the archiveTo simplify the API of parse_* functions, store all the offload information for the current packet in a structure.
No functional change.
--- app/test-pmd/csumonly.c | 222 +++++++++++++++++++++++++----------------------- 1 file changed, 115 insertions(+), 107 deletions(-)
app/test-pmd/csumonly.c +115 -107
@@ -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++) {
Signature · 1 line
2.1.3
RFC 14/16 testpmd: introduce parse_vxlan in csum fwd engine
In reply to a message not in the archiveMove code parsing vxlan into a function. It will ease the support of GRE tunnels and IPIP tunnels in next commits.
--- app/test-pmd/csumonly.c | 68 +++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 31 deletions(-)
app/test-pmd/csumonly.c +37 -31
@@ -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; }
Signature · 1 line
2.1.3
RFC 15/16 testpmd: support gre tunnels in csum fwd engine
In reply to a message not in the archiveAdd support for Ethernet over GRE and IP over GRE tunnels.
--- app/test-pmd/cmdline.c | 6 ++-- app/test-pmd/csumonly.c | 87 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 84 insertions(+), 9 deletions(-)
app/test-pmd/cmdline.c +3 -3
@@ -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"
app/test-pmd/csumonly.c +81 -6
111 lines not on this page · raw message
Signature · 1 line
2.1.3
RFC 16/16 testpmd: support ipip tunnel in csum forward engine
In reply to a message not in the archiveAdd support for IP over IP tunnels.
--- app/test-pmd/cmdline.c | 2 +- app/test-pmd/csumonly.c | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-)
app/test-pmd/cmdline.c +1 -1
@@ -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"
app/test-pmd/csumonly.c +34 -6
@@ -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) {
Signature · 1 line
2.1.3
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
A message that is not in the archive (sent off-list or not yet received): [email protected]
2015-01-22 00:41, Olivier MATZ:
Quoted 1 line
We use the attached scapy script (
dpdk-cksum-test.py) for testing.
Attaching the python script which was filtered out.
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()
Quoted 22 lines · On Thu, 22 Jan 2015 00:36:19 +0100 Olivier Matz…
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_CKSUMandPKT_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_PKTflag: 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_CHECKSUMin 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.
Quoted 8 lines
- 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.
Hi Stephen,
Quoted 17 lines · Stephen Hemminger
Quoted 2 lines · On Thu, 22 Jan 2015 00:36:19 +0100 Olivier Matz…
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
Quoted 3 lines
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
Quoted 10 lines
- remove the
PKT_TX_UDP_TUNNEL_PKTflag: 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...
cover enhance tx checksum offload API
In reply to a message not in the archiveThe 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(-)
Signature · 1 line
2.1.4
A message that is not in the archive (sent off-list or not yet received): 1422623775-8050-1-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
PATCH 1/20 mbuf: remove PKT_TX_IPV4_CSUM
This alias is only used in one place of i40e driver. Remove it and only keep the legacy flag PKT_TX_IP_CSUM.
--- lib/librte_mbuf/rte_mbuf.h | 1 - lib/librte_pmd_i40e/i40e_rxtx.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
lib/librte_mbuf/rte_mbuf.h +0 -1
@@ -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)
lib/librte_pmd_i40e/i40e_rxtx.c +1 -1
@@ -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 ) {
Signature · 1 line
2.1.4
PATCH 2/20 mbuf: enhance the API documentation of offload flags
In reply to a message not in the archiveBased on http://dpdk.org/ml/archives/dev/2015-January/011127.html
Also adapt the csum forward engine code to the API.
--- app/test-pmd/csumonly.c | 6 +++--- lib/librte_mbuf/rte_mbuf.h | 43 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 10 deletions(-)
app/test-pmd/csumonly.c +3 -3
@@ -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 ;
lib/librte_mbuf/rte_mbuf.h +36 -7
60 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 3/20 i40e: call i40e_txd_enable_checksum only for offloaded packets
In reply to a message not in the archiveQuoted 1 line
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.
--- lib/librte_pmd_i40e/i40e_rxtx.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
lib/librte_pmd_i40e/i40e_rxtx.c +11 -4
@@ -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 */
Signature · 1 line
2.1.4
PATCH 4/20 i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag
In reply to a message not in the archiveThe 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
--- lib/librte_pmd_i40e/i40e_rxtx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/librte_pmd_i40e/i40e_rxtx.c +2 -4
@@ -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 ;
Signature · 1 line
2.1.4
PATCH 5/20 mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag
In reply to a message not in the archiveSince 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.
--- 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(-)
app/test-pmd/csumonly.c +0 -4
@@ -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 },
lib/librte_mbuf/rte_mbuf.c +0 -1
@@ -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" ;
lib/librte_mbuf/rte_mbuf.h +1 -4
@@ -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. */ /**
Signature · 1 line
2.1.4
PATCH 6/20 testpmd: replace tx_checksum command by csum
In reply to a message not in the archiveReplace 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.
--- app/test-pmd/cmdline.c | 70 +++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-)
app/test-pmd/cmdline.c +35 -35
@@ -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,
Signature · 1 line
2.1.4
PATCH 7/20 testpmd: move csum_show in a function
In reply to a message not in the archiveNo 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.
--- app/test-pmd/cmdline.c | 82 +++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 37 deletions(-)
app/test-pmd/cmdline.c +45 -37
@@ -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 =
Signature · 1 line
2.1.4
PATCH 8/20 testpmd: add csum parse_tunnel command
In reply to a message not in the archiveAdd 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.
--- 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(-)
app/test-pmd/cmdline.c +66 -0
@@ -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,
app/test-pmd/csumonly.c +2 -1
@@ -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
app/test-pmd/testpmd.h +4 -1
@@ -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.
Signature · 1 line
2.1.4
PATCH 9/20 testpmd: rename vxlan in outer_ip in csum commands
In reply to a message not in the archiveThe 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.
--- 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(-)
app/test-pmd/cmdline.c +8 -8
@@ -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,
app/test-pmd/csumonly.c +14 -11
@@ -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 )
app/test-pmd/testpmd.h +2 -2
@@ -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
Signature · 1 line
2.1.4
PATCH 10/20 testpmd: introduce parse_ipv* in csum fwd engine
In reply to a message not in the archiveThese functions may be used to parse encapsulated layers when we will support IP over GRE tunnels.
No functional change.
--- app/test-pmd/csumonly.c | 51 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-)
app/test-pmd/csumonly.c +39 -12
@@ -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 */
Signature · 1 line
2.1.4
PATCH 11/20 testpmd: use a structure to store offload info in csum fwd engine
In reply to a message not in the archiveTo simplify the API of parse_* functions, store all the offload information for the current packet in a structure.
No functional change.
--- app/test-pmd/csumonly.c | 222 +++++++++++++++++++++++++----------------------- 1 file changed, 115 insertions(+), 107 deletions(-)
app/test-pmd/csumonly.c +115 -107
@@ -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++) {
Signature · 1 line
2.1.4
PATCH 12/20 testpmd: introduce parse_vxlan in csum fwd engine
In reply to a message not in the archiveMove code parsing vxlan into a function. It will ease the support of GRE tunnels and IPIP tunnels in next commits.
--- app/test-pmd/csumonly.c | 68 +++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 31 deletions(-)
app/test-pmd/csumonly.c +37 -31
@@ -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; }
Signature · 1 line
2.1.4
A message that is not in the archive (sent off-list or not yet received): 1422623775-8050-13-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
Re: [PATCH 12/20] testpmd: introduce parse_vxlan in csum fwd engine
Hi,
Quoted 36 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Friday, January 30, 2015 9:16 PM
To: [email protected]
Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; [email protected]
Subject: [PATCH 12/20] testpmd: introduceparse_vxlanin csum fwd engineMove 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 <[email protected]>--- app/test-pmd/csumonly.c | 68 +++++++++++++++++++++++++++------------ ---------- 1 file changed, 37 insertions(+), 31 deletions(-)app/test-pmd/csumonly.c index renamed from app/test-pmd/csumonly.c +0
-00b89d89..52af0e7 100644
app/test-pmd/csumonly.c +3
-1@@ -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,
app/test-pmd/csumonly.c parse_ethernet(struct ether_hdr *eth_hdr, struct · line 206
Quoted 10 lines
app/test-pmd/csumonly.c +10
-0+ 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).
Quoted 94 lines
app/test-pmd/csumonly.c +14
-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)app/test-pmd/csumonly.c +0
-1struct 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) &&app/test-pmd/csumonly.c +1
-0info.l4_proto == IPPROTO_UDP) { +struct udp_hdr *udp_hdr; udp_hdr = (struct udp_hdr *)((char *)l3_hdr +info.l3_len);
app/test-pmd/csumonly.c +2
-9+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|
app/test-pmd/csumonly.c +0
-10- 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 +
app/test-pmd/csumonly.c +4
-6-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;
app/test-pmd/csumonly.c +0
-0}/* 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) {app/test-pmd/csumonly.c +2
-5m->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
A message that is not in the archive (sent off-list or not yet received): 1ED644BD7E0A5F4091CF203DAFB8E4CC01DC963B-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org
Re: [PATCH 12/20] testpmd: introduce parse_vxlan in csum fwd engine
Hi Jijiang,
Quoted 17 lines · Jijiang
app/test-pmd/csumonly.c parse_ethernet(struct ether_hdr *eth_hdr, struct testpmd_offload_info *info) · line 205
Quoted 13 lines
app/test-pmd/csumonly.c +13
-0+/* 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_olflagscheck. It should be
(mbuf_olflags& (PKT_RX_TUNNEL_IPV4_HDR|
Quoted 1 line
PKT_RX_TUNNEL_IPV6_HDR)) == 0).
That's correct. Thank you for checking this carefully. I'll fix this in a v2 patch.
Regards,
Olivier
PATCH 13/20 testpmd: support gre tunnels in csum fwd engine
In reply to a message not in the archiveAdd support for Ethernet over GRE and IP over GRE tunnels.
--- app/test-pmd/cmdline.c | 6 ++-- app/test-pmd/csumonly.c | 87 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 84 insertions(+), 9 deletions(-)
app/test-pmd/cmdline.c +3 -3
@@ -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"
app/test-pmd/csumonly.c +81 -6
111 lines not on this page · raw message
Signature · 1 line
2.1.4
A message that is not in the archive (sent off-list or not yet received): 1422623775-8050-14-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
Re: [PATCH 13/20] testpmd: support gre tunnels in csum fwd engine
Hi Olivier,
Quoted 43 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Friday, January 30, 2015 9:16 PM
To: [email protected]
Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; [email protected]
Subject: [PATCH 13/20] testpmd: support gre tunnels in csum fwd engineAdd support for Ethernet over GRE and IP over GRE tunnels.
Signed-off-by Olivier Matz <[email protected]>--- app/test-pmd/cmdline.c | 6 ++-- app/test-pmd/csumonly.c | 87 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 84 insertions(+), 9 deletions(-)app/test-pmd/cmdline.c index renamed from app/test-pmd/cmdline.c +0
-098f7a1c..aa5c178 100644
app/test-pmd/cmdline.c +0
-0@@ -321,9 +321,9 @@ static void cmd_help_long_parsed(void *parsed_result, " checksum with when transmitting a packet usingthe"
app/test-pmd/cmdline.c +0
-0" csum forward engine.\n" " ip|udp|tcp|sctp always concern the innerlayer.\n"
app/test-pmd/cmdline.c +3
-3-" 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 aresupported)\n"
" Please check the NIC datasheet for HW
limits.\n\n"app/test-pmd/cmdline.c +0
-0"csum parse-tunnel (on|off) (tx_port_id)\n" app/test-pmd/csumonly.c index renamed from app/test-pmd/csumonly.c +0
-052af0e7..02c01f6 100644
app/test-pmd/csumonly.c struct testpmd_offload_info { · line 106
Quoted 7 lines
app/test-pmd/csumonly.c +4
-0@@ -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.
Quoted 7 lines
app/test-pmd/csumonly.c +0
-0static 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, structtestpmd_offload_info*info,app/test-pmd/csumonly.c +1
-0info->l2_len +=ETHER_VXLAN_HLEN ;/* add udp + vxlan */ } +/* Parse a gre header */
app/test-pmd/csumonly.c parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, · line 237
Quoted 10 lines
app/test-pmd/csumonly.c +10
-0+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.
Quoted 29 lines
app/test-pmd/csumonly.c +28
-0+ +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 */
app/test-pmd/csumonly.c parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, · line 272
Quoted 7 lines
app/test-pmd/csumonly.c +7
-0+ 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.
Quoted 55 lines
app/test-pmd/csumonly.c +6
-0+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_ttestpmd_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)app/test-pmd/csumonly.c +0
-2parse_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) &&app/test-pmd/csumonly.c +0
-3- info.l4_proto == IPPROTO_UDP) { -struct udp_hdr *udp_hdr; - udp_hdr = (struct udp_hdr *)((char *)l3_hdr +info.l3_len);
app/test-pmd/csumonly.c +2
-1-parse_vxlan (udp_hdr, &info, m->ol_flags); +/* check if it's a supported tunnel */ + if (testpmd_ol_flags &
TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) {app/test-pmd/csumonly.c +18
-1+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
A message that is not in the archive (sent off-list or not yet received): 1ED644BD7E0A5F4091CF203DAFB8E4CC01DC9728-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org
Re: [PATCH 13/20] testpmd: support gre tunnels in csum fwd engine
Hi Jijiang,
Quoted 6 lines · Jijiang
app/test-pmd/csumonly.c struct testpmd_offload_info { · line 107
Quoted 4 lines
app/test-pmd/csumonly.c +4
-0+/* 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.
The signification of this comment is that the only supported header in the parse_gre() function is the header without optional fields (checksum, offset, key, ...). These fields are not present when flags is set to 0.
Quoted 58 lines
Quoted 8 lines
static
uint16_t
get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags){ @@ -
218,6 +224,60 @@ parse_vxlan(structudp_hdr*udp_hdr, structtestpmd_offload_info*info,app/test-pmd/csumonly.c +1
-0info->l2_len +=ETHER_VXLAN_HLEN ;/* add udp + vxlan */ } +/* Parse a gre header */ app/test-pmd/csumonly.c parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, · line 237
Quoted 10 lines
app/test-pmd/csumonly.c +10
-0+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.
Quoted 33 lines
app/test-pmd/csumonly.c +28
-0+ +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 */
app/test-pmd/csumonly.c +4
-0+ info->is_tunnel =1 ; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len;
Quoted 9 lines
app/test-pmd/csumonly.c parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, · line 272
Quoted 3 lines
app/test-pmd/csumonly.c +3
-0+ + eth_hdr = (struct ether_hdr *)((char *)gre_hdr + +sizeof (struct simple_gre_hdr ));For NVGRE:
I will do some change here.eth_hdr= (structether_hdr*)((char *)gre_hdr +
sizeof(struct nvgre_hdr)); // replacesimple_gre_hdrwithnvgre_hdr.
I think replacing gre_hdr by nvgre_hdr here would break the gre. If we want to support NVGRE, I think we should check the value of gre_hdr->flags to determine the length of the gre header.
I'm not a NVGRE expert, but from what I've seen NVGRE is just a GRE header with the key flag present.
Regards,
Olivier
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 13/20] testpmd: support gre tunnels in csum fwd engine
Hi Olivier,
Quoted 96 lines
-----Original Message-----
From: Olivier MATZ [mailto:[email protected]]
Sent: Monday, February 2, 2015 8:55 PM
To: Liu, Jijiang
Cc: Ananyev, Konstantin; Zhang, Helin; [email protected]
Subject: Re: [PATCH 13/20] testpmd: support gre tunnels in csum fwd engineHi Jijiang,
Quoted 5 lines · Jijiang
app/test-pmd/csumonly.c struct testpmd_offload_info { · line 107
Quoted 4 lines
app/test-pmd/csumonly.c +4
-0+/* 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.
Quoted 1 line
It is not necessary to require the flag must be 0.
The signification of this comment is that the only supported header in the
parse_gre()function is the header without optional fields (checksum, offset, key, ...). These fields are not present when flags is set to 0.Quoted 8 lines
Quoted 8 lines
static
uint16_t
get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags){
@@ -
218,6 +224,60 @@ parse_vxlan(structudp_hdr*udp_hdr, structtestpmd_offload_info*info,
info->l2_len+=ETHER_VXLAN_HLEN; /* add udp + vxlan */ }Quoted 13 lines
app/test-pmd/csumonly.c parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, · line 237
Quoted 12 lines
app/test-pmd/csumonly.c +12
-0+/* 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.
Quoted 2 lines
For example, when I want to support NVGRE TX checksum offload, I will do the
following change.
Quoted 38 lines
Or you still keep it here, but anyway, I will change it later.
Quoted 34 lines
app/test-pmd/csumonly.c +29
-0+ +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 */
app/test-pmd/csumonly.c +4
-0+ info->is_tunnel =1 ; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len;Quoted 8 lines
app/test-pmd/csumonly.c parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info, · line 272
Quoted 3 lines
app/test-pmd/csumonly.c +3
-0+ + eth_hdr = (struct ether_hdr *)((char *)gre_hdr + +sizeof (struct simple_gre_hdr ));For NVGRE:
I will do some change here.eth_hdr= (structether_hdr*)((char *)gre_hdr +
sizeof(struct nvgre_hdr)); // replacesimple_gre_hdrwith
nvgre_hdr.Quoted 1 line
Quoted 6 lines
I think replacing
gre_hdrbynvgre_hdrhere would break the gre. If we want to support NVGRE, I think we should check the value of gre_hdr-Quoted 1 line
flags to determine the length of the gre header.
I'm not a NVGRE expert, but from what I've seen NVGRE is just a GRE header with the key flag present.
NVGRE frame format in section 3.2
http://datatracker.ietf.org/doc/draft-sridharan-virtualization-nvgre/?include_text=1
When gre_hdr->proto = htons (0x6558), which means this is NVGRE protocol( MAC over GRE), the key flag must be present, so gre_hdr->flags != 0.
Anyway, the following check should be removed when we support NVGRE TX checksum offload later, or it will failed.
/* if flags != 0; it's not supported */
if (gre_hdr->flags != 0)
return;Quoted 2 lines
Regards,
Olivier
A message that is not in the archive (sent off-list or not yet received): 1ED644BD7E0A5F4091CF203DAFB8E4CC01DCAA13-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org
Re: [PATCH 13/20] testpmd: support gre tunnels in csum fwd engine
Hi Jijiang,
Quoted 17 lines · Jijiang
Quoted 7 lines
Quoted 4 lines
For NVGRE:
I will do some change here.eth_hdr= (structether_hdr*)((char *)gre_hdr +
sizeof(struct nvgre_hdr)); // replacesimple_gre_hdrwith
nvgre_hdr.Quoted 1 line
Quoted 6 lines
I think replacing
gre_hdrbynvgre_hdrhere would break the gre. If we want to support NVGRE, I think we should check the value of gre_hdr-Quoted 1 line
flags to determine the length of the gre header.
I'm not a NVGRE expert, but from what I've seen NVGRE is just a GRE header with the key flag present.
NVGRE frame format in section 3.2
http://datatracker.ietf.org/doc/draft-sridharan-virtualization-nvgre/?include_text=1
Quoted 7 lines
When
gre_hdr->proto= htons (0x6558), which means this is NVGRE protocol( MAC over GRE), the key flag must be present, sogre_hdr->flags!= 0.Anyway, the following check should be removed when we support NVGRE TX checksum offload later, or it will failed.
/* if flags != 0; it's not supported */ if (gre_hdr->flags != 0) return;
Yes, what I'm saying is that we need to replace it by something like:
gre_len = sizeof(*gre); /* replaces "if (gre->flags != 0)" */ if ((gre->flags & UNSUPPORTED_FLAGS) != 0) return; if (gre->flags & KEY) gre_len += 4;
If the key flag is mandatory in key flag is mandatory in case of Ethernet over GRE, this should be checked after.
Regards,
Olivier
PATCH 14/20 testpmd: support ipip tunnel in csum forward engine
In reply to a message not in the archiveAdd support for IP over IP tunnels.
--- app/test-pmd/cmdline.c | 2 +- app/test-pmd/csumonly.c | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-)
app/test-pmd/cmdline.c +1 -1
@@ -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"
app/test-pmd/csumonly.c +34 -6
@@ -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) {
Signature · 1 line
2.1.4
PATCH 15/20 ethdev: add outer IP offload capability flag
In reply to a message not in the archiveFrom: Jijiang Liu <[email protected]>
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.
--- lib/librte_ether/rte_ethdev.h | 1 + 1 file changed, 1 insertion(+)
lib/librte_ether/rte_ethdev.h +1 -0
@@ -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. */
Signature · 1 line
2.1.4
PATCH 16/20 i40e: advertise outer IPv4 checksum capability
In reply to a message not in the archiveFrom: Jijiang Liu <[email protected]>
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.
--- lib/librte_pmd_i40e/i40e_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/librte_pmd_i40e/i40e_ethdev.c +2 -1
@@ -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 ) {
Signature · 1 line
2.1.4
PATCH 17/20 testpmd: add a warning if outer ip cksum requested but not supported
In reply to a message not in the archive--- app/test-pmd/cmdline.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +5 -1
@@ -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
Signature · 1 line
2.1.4
PATCH 18/20 testpmd: fix TSO when using outer checksum offloads
In reply to a message not in the archiveThe 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.
--- app/test-pmd/csumonly.c | 1 + 1 file changed, 1 insertion(+)
app/test-pmd/csumonly.c +1 -0
@@ -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
Signature · 1 line
2.1.4
PATCH 19/20 i40e: fix offloading of outer checksum for ip in ip tunnels
In reply to a message not in the archiveWhen 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.
--- lib/librte_pmd_i40e/i40e_rxtx.c | 10 ---------- 1 file changed, 10 deletions(-)
lib/librte_pmd_i40e/i40e_rxtx.c +0 -10
@@ -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 )) {
Signature · 1 line
2.1.4
PATCH 20/20 i40e: add debug logs for tx context descriptors
In reply to a message not in the archiveThis could be useful to have this values for debug purposes.
--- lib/librte_pmd_i40e/i40e_rxtx.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
lib/librte_pmd_i40e/i40e_rxtx.c +22 -0
@@ -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);
Signature · 1 line
2.1.4
v2 cover enhance tx checksum offload API
In reply to a message not in the archiveThe 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(-)
Signature · 1 line
2.1.4
A message that is not in the archive (sent off-list or not yet received): 1423041925-26956-1-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
PATCH v2 1/20 mbuf: remove PKT_TX_IPV4_CSUM
This alias is only used in one place of i40e driver. Remove it and only keep the legacy flag PKT_TX_IP_CSUM.
--- lib/librte_mbuf/rte_mbuf.h | 1 - lib/librte_pmd_i40e/i40e_rxtx.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
lib/librte_mbuf/rte_mbuf.h +0 -1
@@ -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)
lib/librte_pmd_i40e/i40e_rxtx.c +1 -1
@@ -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 ) {
Signature · 1 line
2.1.4
PATCH v2 2/20 mbuf: enhance the API documentation of offload flags
In reply to a message not in the archiveBased on http://dpdk.org/ml/archives/dev/2015-January/011127.html
Also adapt the csum forward engine code to the API.
--- app/test-pmd/csumonly.c | 6 +++--- lib/librte_mbuf/rte_mbuf.h | 43 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 10 deletions(-)
app/test-pmd/csumonly.c +3 -3
@@ -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 ;
lib/librte_mbuf/rte_mbuf.h +36 -7
60 lines not on this page · raw message
Signature · 1 line
2.1.4
A message that is not in the archive (sent off-list or not yet received): 1423041925-26956-3-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
Re: [PATCH v2 02/20] mbuf: enhance the API documentation of offload flags
Quoted 79 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Wednesday, February 4, 2015 5:25 PM
To: [email protected]
Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; [email protected]
Subject: [PATCH v2 02/20] mbuf: enhance the API documentation of offload flagsBased 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 <[email protected]>--- app/test-pmd/csumonly.c | 6 +++--- lib/librte_mbuf/rte_mbuf.h | 43 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 10 deletions(-)app/test-pmd/csumonly.c index renamed from app/test-pmd/csumonly.c +0
-041711fd..4b438d1 100644
app/test-pmd/csumonly.c +2
-3@@ -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))app/test-pmd/csumonly.c +1
-0ol_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 )app/test-pmd/csumonly.c +0
-0ol_flags |=PKT_TX_OUTER_IP_CKSUM ;lib/librte_mbuf/rte_mbuf.h index renamed from lib/librte_mbuf/rte_mbuf.h +0
-0a554247..191a42c 100644
lib/librte_mbuf/rte_mbuf.h +0
-0@@ -141,24 +141,53 @@ extern "C" {#define PKT_TX_UDP_CKSUM (3ULL << 52)/**< UDP cksum of TX pkt. computed by NIC. */
#definePKT_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. */lib/librte_mbuf/rte_mbuf.h +11
-1+/** +* 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.
lib/librte_mbuf/rte_mbuf.h extern "C" { · line 165
Quoted 10 lines
lib/librte_mbuf/rte_mbuf.h +6
-1+*/ #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
Quoted 36 lines
#define
PKT_TX_VLAN_PKT(1ULL << 57) /**< TX packet is a 802.1q
VLAN packet. */lib/librte_mbuf/rte_mbuf.h +8
-3-/** 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. */
lib/librte_mbuf/rte_mbuf.h +10
-2+/** +* 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
A message that is not in the archive (sent off-list or not yet received): F35DEAC7BCE34641BA9FAC6BCA4A12E70A806563-0J0gbvR4kTg/[email protected]
Re: [PATCH v2 02/20] mbuf: enhance the API documentation of offload flags
Hi Helin,
Quoted 8 lines · Helin
Quoted 8 lines
lib/librte_mbuf/rte_mbuf.h +5
-1-/** 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)
Quoted 9 lines
lib/librte_mbuf/rte_mbuf.h extern "C" { · line 165
Quoted 7 lines
lib/librte_mbuf/rte_mbuf.h +5
-1-/** 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
Re: [PATCH v2 02/20] mbuf: enhance the API documentation of offload flags
In reply to a message not in the archiveHi Olivier,
Quoted 58 lines
-----Original Message-----
From: Zhang, Helin
Sent: Tuesday, February 10, 2015 1:39 PM
To: Olivier Matz; [email protected]
Cc: Ananyev, Konstantin; Liu, Jijiang
Subject: RE: [PATCH v2 02/20] mbuf: enhance the API documentation of offload flagsQuoted 25 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Wednesday, February 4, 2015 5:25 PM
To: [email protected]
Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; [email protected]
Subject: [PATCH v2 02/20] mbuf: enhance the API documentation of offload flagsBased 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 <[email protected]>--- app/test-pmd/csumonly.c | 6 +++--- lib/librte_mbuf/rte_mbuf.h | 43 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 10 deletions(-)app/test-pmd/csumonly.c index renamed from app/test-pmd/csumonly.c +0
-041711fd..4b438d1 100644
app/test-pmd/csumonly.c process_inner_cksums(void *l3_hdr, uint16_t · line 191
Quoted 9 lines
app/test-pmd/csumonly.c +1
-0@@ -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)Quoted 13 lines
app/test-pmd/csumonly.c +1
-3ol_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))app/test-pmd/csumonly.c +0
-0ol_flags |=PKT_TX_IPV6 ;@@ -261,6 +260,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype,
Quoted 4 lines
app/test-pmd/csumonly.c process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, · line 264
Quoted 4 lines
app/test-pmd/csumonly.c +1
-0if (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
}Quoted 89 lines
app/test-pmd/csumonly.c process_outer_cksums(void *outer_l3_hdr, uint16_t · line 266
Quoted 1 line
app/test-pmd/csumonly.c +0
-0if (testpmd_ol_flags &
TESTPMD_TX_OFFLOAD_VXLAN_CKSUM)Quoted 30 lines
ol_flags|=PKT_TX_OUTER_IP_CKSUM; diff --gita/lib/librte_mbuf/rte_mbuf.hb/lib/librte_mbuf/rte_mbuf.hindex a554247..191a42c 100644lib/librte_mbuf/rte_mbuf.h +0
-0@@ -141,24 +141,53 @@ extern "C" {#define PKT_TX_UDP_CKSUM (3ULL << 52)/**< UDP cksum of TX pkt. computed by NIC. */
#definePKT_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. */lib/librte_mbuf/rte_mbuf.h +15
-1+/** +* 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. +*/ lib/librte_mbuf/rte_mbuf.h extern "C" { · line 165
Quoted 10 lines
lib/librte_mbuf/rte_mbuf.h +6
-1#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,
HelinQuoted 40 lines
#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. */lib/librte_mbuf/rte_mbuf.h +10
-1+/** +* 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. */
lib/librte_mbuf/rte_mbuf.h +11
-2+/** +* 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
A message that is not in the archive (sent off-list or not yet received): 1ED644BD7E0A5F4091CF203DAFB8E4CC01DDA2CF-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org
Re: [PATCH v2 02/20] mbuf: enhance the API documentation of offload flags
Hi Jijiang,
Quoted 39 lines · Jijiang
Quoted 28 lines
Quoted 5 lines
app/test-pmd/csumonly.c index renamed from app/test-pmd/csumonly.c +0
-041711fd..4b438d1 100644
app/test-pmd/csumonly.c process_inner_cksums(void *l3_hdr, uint16_t · line 191
Quoted 9 lines
app/test-pmd/csumonly.c +1
-0@@ -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)Quoted 13 lines
app/test-pmd/csumonly.c +1
-3ol_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;app/test-pmd/csumonly.c +0
-0@@ -261,6 +260,7 @@ process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype,Quoted 4 lines
app/test-pmd/csumonly.c process_outer_cksums(void *outer_l3_hdr, uint16_t outer_ethertype, · line 264
Quoted 4 lines
app/test-pmd/csumonly.c +1
-0if (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, structtestpmd_offload_info*info,uint16_ttestpmd_ol_flags,uint16_tl4_proto) // add thel4_protoparameter here.
...
Quoted 16 lines
/* 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
PATCH v2 3/20 i40e: call i40e_txd_enable_checksum only for offloaded packets
In reply to a message not in the archiveQuoted 1 line
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.
--- lib/librte_pmd_i40e/i40e_rxtx.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
lib/librte_pmd_i40e/i40e_rxtx.c +11 -4
@@ -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 */
Signature · 1 line
2.1.4
A message that is not in the archive (sent off-list or not yet received): 1423041925-26956-4-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
Re: [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets
Quoted 52 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Wednesday, February 4, 2015 5:25 PM
To: [email protected]
Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; [email protected]
Subject: [PATCH v2 03/20] i40e: calli40e_txd_enable_checksumonly for offloaded packetsFrom 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 offloadTherefore 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 <[email protected]>--- lib/librte_pmd_i40e/i40e_rxtx.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)lib/librte_pmd_i40e/i40e_rxtx.c +5
-0@@ -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)
lib/librte_pmd_i40e/i40e_rxtx.c i40e_xmit_pkts(void *tx_queue, struct rte_mbuf · line 1281
Quoted 9 lines
lib/librte_pmd_i40e/i40e_rxtx.c +1
-4@@ -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.
lib/librte_pmd_i40e/i40e_rxtx.c i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) · line 1285
Quoted 5 lines
lib/librte_pmd_i40e/i40e_rxtx.c +5
-0+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
Quoted 5 lines
lib/librte_pmd_i40e/i40e_rxtx.c +0
-1if (unlikely (nb_ctx)) {/* Setup TX context descriptor if required */ --2.1.4
A message that is not in the archive (sent off-list or not yet received): F35DEAC7BCE34641BA9FAC6BCA4A12E70A8065D4-0J0gbvR4kTg/[email protected]
Re: [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets
Hi Helin,
Quoted 8 lines · Helin
lib/librte_pmd_i40e/i40e_rxtx.c i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) · line 1280
Quoted 7 lines
/* Enable checksum offloading */ cd_tunneling_params = 0;lib/librte_pmd_i40e/i40e_rxtx.c +1
-4-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?
Quoted 8 lines
lib/librte_pmd_i40e/i40e_rxtx.c i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) · line 1285
Quoted 5 lines
lib/librte_pmd_i40e/i40e_rxtx.c +5
-0+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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets
Quoted 38 lines
-----Original Message-----
From: Olivier MATZ [mailto:[email protected]]
Sent: Wednesday, February 11, 2015 1:07 AM
To: Zhang, Helin; [email protected]
Cc: Ananyev, Konstantin; Liu, Jijiang
Subject: Re: [PATCH v2 03/20] i40e: calli40e_txd_enable_checksumonly for offloaded packetsHi Helin,
Quoted 8 lines · Helin
lib/librte_pmd_i40e/i40e_rxtx.c i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) · line 1280
Quoted 7 lines
/* Enable checksum offloading */ cd_tunneling_params = 0;lib/librte_pmd_i40e/i40e_rxtx.c +1
-4-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?Quoted 8 lines
lib/librte_pmd_i40e/i40e_rxtx.c i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) · line 1285
Quoted 5 lines
lib/librte_pmd_i40e/i40e_rxtx.c +5
-0+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.
Quoted 8 lines
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
Quoted 3 lines
Regards,
Olivier
A message that is not in the archive (sent off-list or not yet received): F35DEAC7BCE34641BA9FAC6BCA4A12E70A806F1F-0J0gbvR4kTg/[email protected]
Re: [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets
Hi Helin,
Quoted 10 lines · Helin
Quoted 10 lines · Helin
Quoted 8 lines
Review
Quoted 7 lines
/* Enable checksum offloading */ cd_tunneling_params = 0;(quoted diff) +1
-4- 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.
Quoted 2 lines
Quoted 2 lines
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?
Quoted 19 lines
Quoted 19 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ 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.
Quoted 7 lines
Quoted 2 lines
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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets
Quoted 23 lines
-----Original Message-----
From: Olivier MATZ [mailto:[email protected]]
Sent: Thursday, February 12, 2015 1:14 AM
To: Zhang, Helin; [email protected]
Cc: Ananyev, Konstantin; Liu, Jijiang
Subject: Re: [PATCH v2 03/20] i40e: calli40e_txd_enable_checksumonly for offloaded packetsHi Helin,
Quoted 10 lines · Helin
Quoted 10 lines · Helin
Quoted 8 lines
Review
Quoted 7 lines
/* Enable checksum offloading */ cd_tunneling_params = 0;(quoted diff) +1
-4- 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.
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
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.
Quoted 26 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +1
-0+ i40e_txd_enable_checksum(ol_flags, &td_cmd,
&td_offset,Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ 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
Quoted 7 lines
Quoted 7 lines
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().Quoted 6 lines
Quoted 6 lines
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.
Quoted 7 lines
Quoted 5 lines
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
Quoted 3 lines
Regards,
Olivier
A message that is not in the archive (sent off-list or not yet received): F35DEAC7BCE34641BA9FAC6BCA4A12E70A807E67-0J0gbvR4kTg/[email protected]
Re: [PATCH v2 03/20] i40e: call i40e_txd_enable_checksum only for offloaded packets
Hi,
Quoted 11 lines · Helin
Quoted 11 lines · Helin
Quoted 10 lines
Quoted 10 lines · Helin
Quoted 8 lines
Review
Quoted 7 lines
/* Enable checksum offloading */ cd_tunneling_params = 0;(quoted diff) +1
-4- 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.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
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.
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
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
PATCH v2 4/20 i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag
In reply to a message not in the archiveThe 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
--- lib/librte_pmd_i40e/i40e_rxtx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/librte_pmd_i40e/i40e_rxtx.c +2 -4
@@ -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 ;
Signature · 1 line
2.1.4
A message that is not in the archive (sent off-list or not yet received): 1423041925-26956-5-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
Re: [PATCH v2 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag
Quoted 10 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Wednesday, February 4, 2015 5:25 PM
To: [email protected]
Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; [email protected]
Subject: [PATCH v2 04/20] i40e: remove the use ofPKT_TX_UDP_TUNNEL_PKTflag
Quoted 8 lines
The definition of the flag in
rte_mbuf.hwas:
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_TUNNELINGflag). 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.
Quoted 9 lines
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.
Quoted 21 lines
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.htmlSigned-off-by Olivier Matz <[email protected]>--- lib/librte_pmd_i40e/i40e_rxtx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)lib/librte_pmd_i40e/i40e_rxtx.c +0
-0
lib/librte_pmd_i40e/i40e_rxtx.c i40e_txd_enable_checksum(uint64_t ol_flags, · line 485
Quoted 5 lines
lib/librte_pmd_i40e/i40e_rxtx.c +1
-1@@ -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
Quoted 22 lines
lib/librte_pmd_i40e/i40e_rxtx.c +2
-4*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
A message that is not in the archive (sent off-list or not yet received): F35DEAC7BCE34641BA9FAC6BCA4A12E70A806631-0J0gbvR4kTg/[email protected]
Re: [PATCH v2 04/20] i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag
Hi Helin,
Quoted 11 lines · Helin
lib/librte_pmd_i40e/i40e_rxtx.c i40e_txd_enable_checksum(uint64_t ol_flags, · line 485
Quoted 10 lines
lib/librte_pmd_i40e/i40e_rxtx.c +1
-1@@ -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
PATCH v2 5/20 mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag
In reply to a message not in the archiveSince 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.
--- 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(-)
app/test-pmd/csumonly.c +0 -4
@@ -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 },
lib/librte_mbuf/rte_mbuf.c +0 -1
@@ -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" ;
lib/librte_mbuf/rte_mbuf.h +1 -4
@@ -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. */ /**
Signature · 1 line
2.1.4
PATCH v2 6/20 testpmd: replace tx_checksum command by csum
In reply to a message not in the archiveReplace 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.
--- app/test-pmd/cmdline.c | 70 +++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-)
app/test-pmd/cmdline.c +35 -35
@@ -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,
Signature · 1 line
2.1.4
PATCH v2 7/20 testpmd: move csum_show in a function
In reply to a message not in the archiveNo 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.
--- app/test-pmd/cmdline.c | 82 +++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 37 deletions(-)
app/test-pmd/cmdline.c +45 -37
@@ -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 =
Signature · 1 line
2.1.4
PATCH v2 8/20 testpmd: add csum parse_tunnel command
In reply to a message not in the archiveAdd 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.
--- 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(-)
app/test-pmd/cmdline.c +66 -0
@@ -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,
app/test-pmd/csumonly.c +2 -1
@@ -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
app/test-pmd/testpmd.h +4 -1
@@ -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.
Signature · 1 line
2.1.4
PATCH v2 9/20 testpmd: rename vxlan in outer_ip in csum commands
In reply to a message not in the archiveThe 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.
--- 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(-)
app/test-pmd/cmdline.c +8 -8
@@ -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,
app/test-pmd/csumonly.c +14 -11
@@ -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 )
app/test-pmd/testpmd.h +2 -2
@@ -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
Signature · 1 line
2.1.4
PATCH v2 10/20 testpmd: introduce parse_ipv* in csum fwd engine
In reply to a message not in the archiveThese functions may be used to parse encapsulated layers when we will support IP over GRE tunnels.
No functional change.
--- app/test-pmd/csumonly.c | 51 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-)
app/test-pmd/csumonly.c +39 -12
@@ -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 */
Signature · 1 line
2.1.4
PATCH v2 11/20 testpmd: use a structure to store offload info in csum fwd engine
In reply to a message not in the archiveTo simplify the API of parse_* functions, store all the offload information for the current packet in a structure.
No functional change.
--- app/test-pmd/csumonly.c | 222 +++++++++++++++++++++++++----------------------- 1 file changed, 115 insertions(+), 107 deletions(-)
app/test-pmd/csumonly.c +115 -107
@@ -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++) {
Signature · 1 line
2.1.4
PATCH v2 12/20 testpmd: introduce parse_vxlan in csum fwd engine
In reply to a message not in the archiveMove code parsing vxlan into a function. It will ease the support of GRE tunnels and IPIP tunnels in next commits.
--- app/test-pmd/csumonly.c | 68 +++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 31 deletions(-)
app/test-pmd/csumonly.c +37 -31
@@ -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; }
Signature · 1 line
2.1.4
PATCH v2 13/20 testpmd: support gre tunnels in csum fwd engine
In reply to a message not in the archiveAdd support for Ethernet over GRE and IP over GRE tunnels.
--- app/test-pmd/cmdline.c | 6 ++-- app/test-pmd/csumonly.c | 87 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 84 insertions(+), 9 deletions(-)
app/test-pmd/cmdline.c +3 -3
@@ -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"
app/test-pmd/csumonly.c +81 -6
111 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 14/20 testpmd: support ipip tunnel in csum forward engine
In reply to a message not in the archiveAdd support for IP over IP tunnels.
--- app/test-pmd/cmdline.c | 2 +- app/test-pmd/csumonly.c | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-)
app/test-pmd/cmdline.c +1 -1
@@ -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"
app/test-pmd/csumonly.c +34 -6
@@ -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) {
Signature · 1 line
2.1.4
PATCH v2 15/20 ethdev: add outer IP offload capability flag
In reply to a message not in the archiveFrom: Jijiang Liu <[email protected]>
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.
--- lib/librte_ether/rte_ethdev.h | 1 + 1 file changed, 1 insertion(+)
lib/librte_ether/rte_ethdev.h +1 -0
@@ -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. */
Signature · 1 line
2.1.4
PATCH v2 16/20 i40e: advertise outer IPv4 checksum capability
In reply to a message not in the archiveFrom: Jijiang Liu <[email protected]>
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.
--- lib/librte_pmd_i40e/i40e_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/librte_pmd_i40e/i40e_ethdev.c +2 -1
@@ -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 ) {
Signature · 1 line
2.1.4
PATCH v2 17/20 testpmd: add a warning if outer ip cksum requested but not supported
In reply to a message not in the archive--- app/test-pmd/cmdline.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +5 -1
@@ -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
Signature · 1 line
2.1.4
PATCH v2 18/20 testpmd: fix TSO when using outer checksum offloads
In reply to a message not in the archiveThe 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.
--- app/test-pmd/csumonly.c | 1 + 1 file changed, 1 insertion(+)
app/test-pmd/csumonly.c +1 -0
@@ -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
Signature · 1 line
2.1.4
PATCH v2 19/20 i40e: fix offloading of outer checksum for ip in ip tunnels
In reply to a message not in the archiveWhen 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.
--- lib/librte_pmd_i40e/i40e_rxtx.c | 10 ---------- 1 file changed, 10 deletions(-)
lib/librte_pmd_i40e/i40e_rxtx.c +0 -10
@@ -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 )) {
Signature · 1 line
2.1.4
PATCH v2 20/20 i40e: add debug logs for tx context descriptors
In reply to a message not in the archiveThis could be useful to have this values for debug purposes.
--- lib/librte_pmd_i40e/i40e_rxtx.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
lib/librte_pmd_i40e/i40e_rxtx.c +22 -0
@@ -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);
Signature · 1 line
2.1.4
Liu, Jijiang
Acked-byRe: [PATCH v2 00/20] enhance tx checksum offload API
In reply to a message not in the archiveQuoted 23 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Wednesday, February 04, 2015 5:25 PM
To: [email protected]
Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; [email protected]
Subject: [PATCH v2 00/20] enhance tx checksum offload APIThe goal of this series is to clarify and simplify the mbuf offload API.
- simplify the definitions of
PKT_TX_IP_CKSUMandPKT_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_PKTflag: 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).
Quoted 6 lines
- remove the flag and stop advertising
OUTER_IP_CHECKSUMin 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.
Quoted 50 lines
- 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 inparse_vlan()pointed out by JijiangJijiang Liu (2):
ethdev: add outer IP offload capability flag
i40e: advertise outer IPv4 checksum capabilityOlivier Matz (18):
mbuf: removePKT_TX_IPV4_CSUM
mbuf: enhance the API documentation of offload flags
i40e: calli40e_txd_enable_checksumonly for offloaded packets
i40e: remove the use ofPKT_TX_UDP_TUNNEL_PKTflag
mbuf: removePKT_TX_UDP_TUNNEL_PKTflag
testpmd: replacetx_checksumcommand by csum
testpmd: movecsum_showin a function
testpmd: add csumparse_tunnelcommand
testpmd: rename vxlan inouter_ipin csum commands
testpmd: introduce parse_ipv* in csum fwd engine
testpmd: use a structure to store offload info in csum fwd engine
testpmd: introduceparse_vxlanin 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 descriptorsapp/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(-)
Quoted 2 lines
--
2.1.4
v3 cover enhance tx checksum offload API
In reply to a message not in the archiveThe 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(-)
Signature · 1 line
2.1.4
A message that is not in the archive (sent off-list or not yet received): 1423819371-24222-1-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
PATCH v3 1/20 mbuf: remove PKT_TX_IPV4_CSUM
This alias is only used in one place of i40e driver. Remove it and only keep the legacy flag PKT_TX_IP_CSUM.
--- lib/librte_mbuf/rte_mbuf.h | 1 - lib/librte_pmd_i40e/i40e_rxtx.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
lib/librte_mbuf/rte_mbuf.h +0 -1
@@ -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)
lib/librte_pmd_i40e/i40e_rxtx.c +1 -1
@@ -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 ) {
Signature · 1 line
2.1.4
PATCH v3 2/20 mbuf: enhance the API documentation of offload flags
In reply to a message not in the archiveBased on http://dpdk.org/ml/archives/dev/2015-January/011127.html
Also adapt the csum forward engine code to the API.
--- app/test-pmd/csumonly.c | 6 +++--- lib/librte_mbuf/rte_mbuf.h | 45 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 10 deletions(-)
app/test-pmd/csumonly.c +3 -3
@@ -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 ;
lib/librte_mbuf/rte_mbuf.h +38 -7
62 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v3 3/20 i40e: call i40e_txd_enable_checksum only for offloaded packets
In reply to a message not in the archiveQuoted 1 line
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.
--- lib/librte_pmd_i40e/i40e_rxtx.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
lib/librte_pmd_i40e/i40e_rxtx.c +11 -4
@@ -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 */
Signature · 1 line
2.1.4
PATCH v3 4/20 i40e: remove the use of PKT_TX_UDP_TUNNEL_PKT flag
In reply to a message not in the archiveThe 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
--- lib/librte_pmd_i40e/i40e_rxtx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/librte_pmd_i40e/i40e_rxtx.c +2 -4
@@ -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 ;
Signature · 1 line
2.1.4
PATCH v3 5/20 mbuf: remove PKT_TX_UDP_TUNNEL_PKT flag
In reply to a message not in the archiveSince 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.
--- 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(-)
app/test-pmd/csumonly.c +0 -4
@@ -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 },
lib/librte_mbuf/rte_mbuf.c +0 -1
@@ -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" ;
lib/librte_mbuf/rte_mbuf.h +1 -4
@@ -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. */ /**
lib/librte_pmd_i40e/i40e_rxtx.c +1 -1
@@ -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 ;
Signature · 1 line
2.1.4
PATCH v3 6/20 testpmd: replace tx_checksum command by csum
In reply to a message not in the archiveReplace 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.
--- app/test-pmd/cmdline.c | 70 +++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-)
app/test-pmd/cmdline.c +35 -35
@@ -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,
Signature · 1 line
2.1.4
PATCH v3 7/20 testpmd: move csum_show in a function
In reply to a message not in the archiveNo 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.
--- app/test-pmd/cmdline.c | 82 +++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 37 deletions(-)
app/test-pmd/cmdline.c +45 -37
@@ -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 =
Signature · 1 line
2.1.4
PATCH v3 8/20 testpmd: add csum parse_tunnel command
In reply to a message not in the archiveAdd 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.
--- 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(-)
app/test-pmd/cmdline.c +66 -0
@@ -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,
app/test-pmd/csumonly.c +2 -1
@@ -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
app/test-pmd/testpmd.h +4 -1
@@ -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.
Signature · 1 line
2.1.4
PATCH v3 9/20 testpmd: rename vxlan in outer_ip in csum commands
In reply to a message not in the archiveThe 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.
--- 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(-)
app/test-pmd/cmdline.c +8 -8
@@ -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,
app/test-pmd/csumonly.c +14 -11
@@ -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 )
app/test-pmd/testpmd.h +2 -2
@@ -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
Signature · 1 line
2.1.4
PATCH v3 10/20 testpmd: introduce parse_ipv* in csum fwd engine
In reply to a message not in the archiveThese functions may be used to parse encapsulated layers when we will support IP over GRE tunnels.
No functional change.
--- app/test-pmd/csumonly.c | 51 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-)
app/test-pmd/csumonly.c +39 -12
@@ -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 */
Signature · 1 line
2.1.4
PATCH v3 11/20 testpmd: use a structure to store offload info in csum fwd engine
In reply to a message not in the archiveTo simplify the API of parse_* functions, store all the offload information for the current packet in a structure.
No functional change.
--- app/test-pmd/csumonly.c | 222 +++++++++++++++++++++++++----------------------- 1 file changed, 115 insertions(+), 107 deletions(-)
app/test-pmd/csumonly.c +115 -107
@@ -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++) {
Signature · 1 line
2.1.4
PATCH v3 12/20 testpmd: introduce parse_vxlan in csum fwd engine
In reply to a message not in the archiveMove code parsing vxlan into a function. It will ease the support of GRE tunnels and IPIP tunnels in next commits.
--- app/test-pmd/csumonly.c | 68 +++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 31 deletions(-)
app/test-pmd/csumonly.c +37 -31
@@ -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; }
Signature · 1 line
2.1.4
PATCH v3 13/20 testpmd: support gre tunnels in csum fwd engine
In reply to a message not in the archiveAdd support for Ethernet over GRE and IP over GRE tunnels.
--- app/test-pmd/cmdline.c | 6 ++-- app/test-pmd/csumonly.c | 91 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 87 insertions(+), 10 deletions(-)
app/test-pmd/cmdline.c +3 -3
@@ -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"
app/test-pmd/csumonly.c +84 -7
136 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v3 14/20 testpmd: support ipip tunnel in csum forward engine
In reply to a message not in the archiveAdd support for IP over IP tunnels.
--- app/test-pmd/cmdline.c | 2 +- app/test-pmd/csumonly.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +1 -1
@@ -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"
app/test-pmd/csumonly.c +34 -0
@@ -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); } }
Signature · 1 line
2.1.4
PATCH v3 15/20 ethdev: add outer IP offload capability flag
In reply to a message not in the archiveFrom: Jijiang Liu <[email protected]>
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.
--- lib/librte_ether/rte_ethdev.h | 1 + 1 file changed, 1 insertion(+)
lib/librte_ether/rte_ethdev.h +1 -0
@@ -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. */
Signature · 1 line
2.1.4
PATCH v3 16/20 i40e: advertise outer IPv4 checksum capability
In reply to a message not in the archiveFrom: Jijiang Liu <[email protected]>
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.
--- lib/librte_pmd_i40e/i40e_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/librte_pmd_i40e/i40e_ethdev.c +2 -1
@@ -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 ) {
Signature · 1 line
2.1.4
PATCH v3 17/20 testpmd: add a warning if outer ip cksum requested but not supported
In reply to a message not in the archive--- app/test-pmd/cmdline.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +5 -1
@@ -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
Signature · 1 line
2.1.4
PATCH v3 18/20 testpmd: fix TSO when using outer checksum offloads
In reply to a message not in the archiveThe 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.
--- app/test-pmd/csumonly.c | 1 + 1 file changed, 1 insertion(+)
app/test-pmd/csumonly.c +1 -0
@@ -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
Signature · 1 line
2.1.4
PATCH v3 19/20 i40e: fix offloading of outer checksum for ip in ip tunnels
In reply to a message not in the archiveWhen 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.
--- lib/librte_pmd_i40e/i40e_rxtx.c | 10 ---------- 1 file changed, 10 deletions(-)
lib/librte_pmd_i40e/i40e_rxtx.c +0 -10
@@ -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 ) {
Signature · 1 line
2.1.4
PATCH v3 20/20 i40e: add debug logs for tx context descriptors
In reply to a message not in the archiveThis could be useful to have this values for debug purposes.
--- lib/librte_pmd_i40e/i40e_rxtx.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
lib/librte_pmd_i40e/i40e_rxtx.c +22 -0
@@ -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);
Signature · 1 line
2.1.4
Liu, Jijiang
Acked-byRe: [PATCH v3 00/20] enhance tx checksum offload API
In reply to a message not in the archiveQuoted 87 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Friday, February 13, 2015 5:23 PM
To: [email protected]
Cc: Ananyev, Konstantin; Liu, Jijiang; Zhang, Helin; [email protected]
Subject: [PATCH v3 00/20] enhance tx checksum offload APIThe goal of this series is to clarify and simplify the mbuf offload API.
- simplify the definitions of
PKT_TX_IP_CKSUMandPKT_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_PKTflag: 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_CHECKSUMin 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 inparse_vlan()pointed out by JijiangChanges in v3:
- more detailed API comments forPKT_TX_IPV4andPKT_TX_IPV6
- do not calculate the outer UDP checksum if packet is not UDP
- add alikely()in i40e
- remove aunlikely()in i40e
- fix a patch split issue
- rebase on headJijiang Liu (2):
ethdev: add outer IP offload capability flag
i40e: advertise outer IPv4 checksum capabilityOlivier Matz (18):
mbuf: removePKT_TX_IPV4_CSUM
mbuf: enhance the API documentation of offload flags
i40e: calli40e_txd_enable_checksumonly for offloaded packets
i40e: remove the use ofPKT_TX_UDP_TUNNEL_PKTflag
mbuf: removePKT_TX_UDP_TUNNEL_PKTflag
testpmd: replacetx_checksumcommand by csum
testpmd: movecsum_showin a function
testpmd: add csumparse_tunnelcommand
testpmd: rename vxlan inouter_ipin csum commands
testpmd: introduce parse_ipv* in csum fwd engine
testpmd: use a structure to store offload info in csum fwd engine
testpmd: introduceparse_vxlanin 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 descriptorsapp/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(-)
Quoted 2 lines
--
2.1.4
A message that is not in the archive (sent off-list or not yet received): 1ED644BD7E0A5F4091CF203DAFB8E4CC01DDC8F1-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org
Thomas Monjalon
AppliedRe: [PATCH v3 00/20] enhance tx checksum offload API
Quoted 67 lines
Quoted 58 lines
The goal of this series is to clarify and simplify the mbuf offload API.
- simplify the definitions of
PKT_TX_IP_CKSUMandPKT_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_PKTflag: 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_CHECKSUMin 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 inparse_vlan()pointed out by JijiangChanges in v3:
- more detailed API comments forPKT_TX_IPV4andPKT_TX_IPV6
- do not calculate the outer UDP checksum if packet is not UDP
- add alikely()in i40e
- remove aunlikely()in i40e
- fix a patch split issue
- rebase on headJijiang Liu (2):
ethdev: add outer IP offload capability flag
i40e: advertise outer IPv4 checksum capabilityOlivier Matz (18):
mbuf: removePKT_TX_IPV4_CSUM
mbuf: enhance the API documentation of offload flags
i40e: calli40e_txd_enable_checksumonly for offloaded packets
i40e: remove the use ofPKT_TX_UDP_TUNNEL_PKTflag
mbuf: removePKT_TX_UDP_TUNNEL_PKTflag
testpmd: replacetx_checksumcommand by csum
testpmd: movecsum_showin a function
testpmd: add csumparse_tunnelcommand
testpmd: rename vxlan inouter_ipin csum commands
testpmd: introduce parse_ipv* in csum fwd engineQuoted 8 lines
testpmd: use a structure to store offload info in csum fwd engine
testpmd: introduceparse_vxlanin 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
Quoted 1 line
Acked-by Jijiang Liu < [email protected]>
Applied, thanks for making API clearer