[v2,2/4] ethdev: add Tx offload outer UDP checksum definition
diff mbox series

Message ID 20181002192451.19119-2-jerin.jacob@caviumnetworks.com
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • Untitled series #1650
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Jerin Jacob Oct. 2, 2018, 7:24 p.m. UTC
Introduced DEV_TX_OFFLOAD_OUTER_UDP_CKSUM offload flags and
PKT_TX_OUTER_TCP_CKSUM mbuf ol_flags to enable Tx outer UDP
checksum offload.

To use hardware Tx outer UDP checksum offload, the user needs to,

- enable following in mbuff:
a) fill outer_l2_len and outer_l3_len in mbuf
b) set the PKT_TX_OUTER_UDP_CKSUM flag
c) set the flag PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6

- configure DEV_TX_OFFLOAD_OUTER_UDP_CKSUM offload flags in slow path

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---

v2:
- Removed DEV_TX_OFFLOAD_OUTER_TCP_CKSUM and DEV_TX_OFFLOAD_OUTER_SCTP_CKSUM
as there is no realworld use case for it.
See: http://patches.dpdk.org/patch/44692/

This patch series is depended on http://patches.dpdk.org/patch/45840/

---
 app/test-pmd/config.c          | 10 ++++++++++
 doc/guides/nics/features.rst   |  6 ++++++
 lib/librte_ethdev/rte_ethdev.c |  1 +
 lib/librte_ethdev/rte_ethdev.h |  2 ++
 lib/librte_mbuf/rte_mbuf.c     |  1 +
 lib/librte_mbuf/rte_mbuf.h     |  6 +++++-
 6 files changed, 25 insertions(+), 1 deletion(-)

Comments

Andrew Rybchenko Oct. 3, 2018, 7:41 a.m. UTC | #1
On 10/2/18 10:24 PM, Jerin Jacob wrote:
> Introduced DEV_TX_OFFLOAD_OUTER_UDP_CKSUM offload flags and
> PKT_TX_OUTER_TCP_CKSUM mbuf ol_flags to enable Tx outer UDP
> checksum offload.

PKT_TX_OUTER_UDP_CKSUM, not TCP

>
> To use hardware Tx outer UDP checksum offload, the user needs to,
>
> - enable following in mbuff:


mbuf

> a) fill outer_l2_len and outer_l3_len in mbuf
> b) set the PKT_TX_OUTER_UDP_CKSUM flag
> c) set the flag PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6
>
> - configure DEV_TX_OFFLOAD_OUTER_UDP_CKSUM offload flags in slow path
>
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

The question about mbuf and ethdev changes separation is applicable here as
well. I have no strong opinion, but I think it would be good to follow.
Jerin Jacob Oct. 3, 2018, 7:58 a.m. UTC | #2
-----Original Message-----
> Date: Wed, 3 Oct 2018 10:41:33 +0300
> From: Andrew Rybchenko <arybchenko@solarflare.com>
> To: Jerin Jacob <jerin.jacob@caviumnetworks.com>, Wenzhuo Lu
>  <wenzhuo.lu@intel.com>, Jingjing Wu <jingjing.wu@intel.com>, Bernard
>  Iremonger <bernard.iremonger@intel.com>, John McNamara
>  <john.mcnamara@intel.com>, Marko Kovacevic <marko.kovacevic@intel.com>,
>  Thomas Monjalon <thomas@monjalon.net>, Ferruh Yigit
>  <ferruh.yigit@intel.com>, Olivier Matz <olivier.matz@6wind.com>
> CC: dev@dpdk.org, shahafs@mellanox.com
> Subject: Re: [dpdk-dev] [PATCH v2 2/4] ethdev: add Tx offload outer UDP
>  checksum definition
> User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
>  Thunderbird/60.0
> 
> External Email
> 
> On 10/2/18 10:24 PM, Jerin Jacob wrote:
> 
> Introduced DEV_TX_OFFLOAD_OUTER_UDP_CKSUM offload flags and
> PKT_TX_OUTER_TCP_CKSUM mbuf ol_flags to enable Tx outer UDP
> checksum offload.
> 
> PKT_TX_OUTER_UDP_CKSUM, not TCP

OK

> 
> 
> 
> 
> To use hardware Tx outer UDP checksum offload, the user needs to,
> 
> - enable following in mbuff:
> 
> 
> mbuf


OK
 
> 
> 
> a) fill outer_l2_len and outer_l3_len in mbuf
> b) set the PKT_TX_OUTER_UDP_CKSUM flag
> c) set the flag PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6
> 
> - configure DEV_TX_OFFLOAD_OUTER_UDP_CKSUM offload flags in slow path
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com><mailto:jerin.jacob@caviumnetworks.com>
> 
> The question about mbuf and ethdev changes separation is applicable here as
> well. I have no strong opinion, but I think it would be good to follow.

I don't have strong opinion on this. If there are no other objection, I
will split the patch further as mbuf and ethdev as you pointed out.
Ferruh Yigit Oct. 3, 2018, 8:02 a.m. UTC | #3
On 10/3/2018 8:58 AM, Jerin Jacob wrote:
> -----Original Message-----
>> Date: Wed, 3 Oct 2018 10:41:33 +0300
>> From: Andrew Rybchenko <arybchenko@solarflare.com>
>> To: Jerin Jacob <jerin.jacob@caviumnetworks.com>, Wenzhuo Lu
>>  <wenzhuo.lu@intel.com>, Jingjing Wu <jingjing.wu@intel.com>, Bernard
>>  Iremonger <bernard.iremonger@intel.com>, John McNamara
>>  <john.mcnamara@intel.com>, Marko Kovacevic <marko.kovacevic@intel.com>,
>>  Thomas Monjalon <thomas@monjalon.net>, Ferruh Yigit
>>  <ferruh.yigit@intel.com>, Olivier Matz <olivier.matz@6wind.com>
>> CC: dev@dpdk.org, shahafs@mellanox.com
>> Subject: Re: [dpdk-dev] [PATCH v2 2/4] ethdev: add Tx offload outer UDP
>>  checksum definition
>> User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
>>  Thunderbird/60.0
>>
>> External Email
>>
>> On 10/2/18 10:24 PM, Jerin Jacob wrote:
>>
>> Introduced DEV_TX_OFFLOAD_OUTER_UDP_CKSUM offload flags and
>> PKT_TX_OUTER_TCP_CKSUM mbuf ol_flags to enable Tx outer UDP
>> checksum offload.
>>
>> PKT_TX_OUTER_UDP_CKSUM, not TCP
> 
> OK
> 
>>
>>
>>
>>
>> To use hardware Tx outer UDP checksum offload, the user needs to,
>>
>> - enable following in mbuff:
>>
>>
>> mbuf
> 
> 
> OK
>  
>>
>>
>> a) fill outer_l2_len and outer_l3_len in mbuf
>> b) set the PKT_TX_OUTER_UDP_CKSUM flag
>> c) set the flag PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6
>>
>> - configure DEV_TX_OFFLOAD_OUTER_UDP_CKSUM offload flags in slow path
>>
>> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com><mailto:jerin.jacob@caviumnetworks.com>
>>
>> The question about mbuf and ethdev changes separation is applicable here as
>> well. I have no strong opinion, but I think it would be good to follow.
> 
> I don't have strong opinion on this. If there are no other objection, I
> will split the patch further as mbuf and ethdev as you pointed out.

Since they are logically related, it make sense to have them together to me.
Thomas Monjalon Oct. 3, 2018, 8:36 a.m. UTC | #4
03/10/2018 10:02, Ferruh Yigit:
> On 10/3/2018 8:58 AM, Jerin Jacob wrote:
> > From: Andrew Rybchenko <arybchenko@solarflare.com>
> >> The question about mbuf and ethdev changes separation is applicable here as
> >> well. I have no strong opinion, but I think it would be good to follow.
> > 
> > I don't have strong opinion on this. If there are no other objection, I
> > will split the patch further as mbuf and ethdev as you pointed out.
> 
> Since they are logically related, it make sense to have them together to me.

+1 for keeping ethdev/mbuf together.
No problem applying such mbuf change in dpdk-next-net.
Iremonger, Bernard Oct. 3, 2018, 10:52 a.m. UTC | #5
Hi Jerin,

> -----Original Message-----
> From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com]
> Sent: Tuesday, October 2, 2018 8:25 PM
> To: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Iremonger, Bernard <bernard.iremonger@intel.com>;
> Mcnamara, John <john.mcnamara@intel.com>; Kovacevic, Marko
> <marko.kovacevic@intel.com>; Thomas Monjalon <thomas@monjalon.net>;
> Yigit, Ferruh <ferruh.yigit@intel.com>; Andrew Rybchenko
> <arybchenko@solarflare.com>; Olivier Matz <olivier.matz@6wind.com>
> Cc: dev@dpdk.org; shahafs@mellanox.com; Jerin Jacob
> <jerin.jacob@caviumnetworks.com>
> Subject: [dpdk-dev] [PATCH v2 2/4] ethdev: add Tx offload outer UDP checksum
> definition
> 
> Introduced DEV_TX_OFFLOAD_OUTER_UDP_CKSUM offload flags and
> PKT_TX_OUTER_TCP_CKSUM mbuf ol_flags to enable Tx outer UDP checksum
> offload.
> 
> To use hardware Tx outer UDP checksum offload, the user needs to,
> 
> - enable following in mbuff:
> a) fill outer_l2_len and outer_l3_len in mbuf
> b) set the PKT_TX_OUTER_UDP_CKSUM flag
> c) set the flag PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6
> 
> - configure DEV_TX_OFFLOAD_OUTER_UDP_CKSUM offload flags in slow path
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
> 
> v2:
> - Removed DEV_TX_OFFLOAD_OUTER_TCP_CKSUM and
> DEV_TX_OFFLOAD_OUTER_SCTP_CKSUM as there is no realworld use case for
> it.
> See: http://patches.dpdk.org/patch/44692/
> 
> This patch series is depended on http://patches.dpdk.org/patch/45840/
> 
> ---
>  app/test-pmd/config.c          | 10 ++++++++++
>  doc/guides/nics/features.rst   |  6 ++++++
>  lib/librte_ethdev/rte_ethdev.c |  1 +
>  lib/librte_ethdev/rte_ethdev.h |  2 ++
>  lib/librte_mbuf/rte_mbuf.c     |  1 +
>  lib/librte_mbuf/rte_mbuf.h     |  6 +++++-
>  6 files changed, 25 insertions(+), 1 deletion(-)
> 
<snip>
This patch fails to apply to the latest master branch, a rebase may be needed.

Regards,

Bernard.

Patch
diff mbox series

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index d53c527e5..5d9745ae5 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -773,6 +773,16 @@  port_offload_cap_display(portid_t port_id)
 		else
 			printf("off\n");
 	}
+
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) {
+		printf("TX Outer UDP checksum:               ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
 }
 
 int
diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst
index 2c2959e0b..1390e9668 100644
--- a/doc/guides/nics/features.rst
+++ b/doc/guides/nics/features.rst
@@ -640,8 +640,14 @@  Inner L4 checksum
 Supports inner packet L4 checksum.
 
 * **[uses]     rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_OUTER_UDP_CKSUM``.
+* **[uses]     rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_OUTER_UDP_CKSUM``.
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_OUTER_IPV4`` | ``PKT_TX_OUTER_IPV6``.
+  ``mbuf.ol_flags:PKT_TX_OUTER_UDP_CKSUM``.
+* **[uses]     mbuf**: ``mbuf.outer_l2_len``, ``mbuf.outer_l3_len``.
 * **[provides] mbuf**: ``mbuf.ol_flags:PKT_RX_EL4_CKSUM_BAD``.
 * **[provides] rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_OUTER_UDP_CKSUM``,
+  ``tx_offload_capa,tx_queue_offload_capa:DEV_TX_OFFLOAD_OUTER_UDP_CKSUM``.
+
 
 .. _nic_features_packet_type_parsing:
 
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index a630c4fda..bb48b5a0f 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -159,6 +159,7 @@  static const struct {
 	RTE_TX_OFFLOAD_BIT2STR(SECURITY),
 	RTE_TX_OFFLOAD_BIT2STR(UDP_TNL_TSO),
 	RTE_TX_OFFLOAD_BIT2STR(IP_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(OUTER_UDP_CKSUM),
 };
 
 #undef RTE_TX_OFFLOAD_BIT2STR
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 821d371c3..79d0bb1ed 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -944,6 +944,8 @@  struct rte_eth_conf {
  * for tunnel TSO.
  */
 #define DEV_TX_OFFLOAD_IP_TNL_TSO       0x00080000
+/** Device supports outer UDP checksum */
+#define DEV_TX_OFFLOAD_OUTER_UDP_CKSUM  0x00100000
 
 #define RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP 0x00000001
 /**< Device supports Rx queue setup after device started*/
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 022e92b3c..9db4317ef 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -437,6 +437,7 @@  rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 		  "PKT_TX_TUNNEL_NONE" },
 		{ PKT_TX_MACSEC, PKT_TX_MACSEC, NULL },
 		{ PKT_TX_SEC_OFFLOAD, PKT_TX_SEC_OFFLOAD, NULL },
+		{ PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_UDP_CKSUM, NULL },
 	};
 	const char *name;
 	unsigned int i;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 5c03e98b3..0a2de50ca 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -184,6 +184,9 @@  extern "C" {
 
 /* add new TX flags here */
 
+/**< Outer UDP cksum of TX pkt. computed by NIC. */
+#define PKT_TX_OUTER_UDP_CKSUM     (1ULL << 41)
+
 /**
  * UDP Fragmentation Offload flag. This flag is used for enabling UDP
  * fragmentation in SW or in HW. When use UFO, mbuf->tso_segsz is used
@@ -351,7 +354,8 @@  extern "C" {
 		PKT_TX_TUNNEL_MASK |	 \
 		PKT_TX_MACSEC |		 \
 		PKT_TX_SEC_OFFLOAD |	\
-		PKT_TX_UDP_SEG)
+		PKT_TX_UDP_SEG |	\
+		PKT_TX_OUTER_UDP_CKSUM)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.