[4/4] ethdev: add Tx offload outer L4 checksum definitions
diff mbox series

Message ID 20180913134707.23698-4-jerin.jacob@caviumnetworks.com
State Not Applicable, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • [1/4] ethdev: add SCTP Rx checksum offload support
Related show

Checks

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

Commit Message

Jerin Jacob Sept. 13, 2018, 1:47 p.m. UTC
Introduced DEV_TX_OFFLOAD_OUTER_UDP_CKSUM, DEV_TX_OFFLOAD_OUTER_TCP_CKSUM
and DEV_TX_OFFLOAD_OUTER_SCTP_CKSUM offload flags and

PKT_TX_OUTER_L4_NO_CKSUM, PKT_TX_OUTER_TCP_CKSUM, PKT_TX_OUTER_SCTP_CKSUM
and PKT_TX_OUTER_UDP_CKSUM mbuf ol_flags to enable Tx outer L4 checksum
offload.

To use hardware Tx outer L4 checksum offload, the user needs to.
# enable following in mbuff:
- fill outer_l2_len and outer_l3_len in mbuf
- set the flags PKT_TX_OUTER_TCP_CKSUM, PKT_TX_OUTER_SCTP_CKSUM or
PKT_TX_OUTER_UDP_CKSUM
- set the flag PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6

# configure DEV_TX_OFFLOAD_OUTER_* offload flags in slow path.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 app/test-pmd/config.c          | 27 +++++++++++++++++++++++++++
 doc/guides/nics/features.rst   |  6 ++++++
 lib/librte_ethdev/rte_ethdev.c |  3 +++
 lib/librte_ethdev/rte_ethdev.h |  6 ++++++
 lib/librte_mbuf/rte_mbuf.c     |  5 +++++
 lib/librte_mbuf/rte_mbuf.h     | 23 ++++++++++++++++++++++-
 6 files changed, 69 insertions(+), 1 deletion(-)

Comments

Ferruh Yigit Oct. 1, 2018, 1:45 p.m. UTC | #1
On 9/13/2018 2:47 PM, Jerin Jacob wrote:
> Introduced DEV_TX_OFFLOAD_OUTER_UDP_CKSUM, DEV_TX_OFFLOAD_OUTER_TCP_CKSUM
> and DEV_TX_OFFLOAD_OUTER_SCTP_CKSUM offload flags and
> 
> PKT_TX_OUTER_L4_NO_CKSUM, PKT_TX_OUTER_TCP_CKSUM, PKT_TX_OUTER_SCTP_CKSUM
> and PKT_TX_OUTER_UDP_CKSUM mbuf ol_flags to enable Tx outer L4 checksum
> offload.
> 
> To use hardware Tx outer L4 checksum offload, the user needs to.
> # enable following in mbuff:
> - fill outer_l2_len and outer_l3_len in mbuf
> - set the flags PKT_TX_OUTER_TCP_CKSUM, PKT_TX_OUTER_SCTP_CKSUM or
> PKT_TX_OUTER_UDP_CKSUM
> - set the flag PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6
> 
> # configure DEV_TX_OFFLOAD_OUTER_* offload flags in slow path.
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
>  app/test-pmd/config.c          | 27 +++++++++++++++++++++++++++
>  doc/guides/nics/features.rst   |  6 ++++++
>  lib/librte_ethdev/rte_ethdev.c |  3 +++
>  lib/librte_ethdev/rte_ethdev.h |  6 ++++++
>  lib/librte_mbuf/rte_mbuf.c     |  5 +++++
>  lib/librte_mbuf/rte_mbuf.h     | 23 ++++++++++++++++++++++-
>  6 files changed, 69 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index 92a177e29..85f832bf0 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -773,6 +773,33 @@ 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");
> +	}
> +
> +	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_TCP_CKSUM) {
> +		printf("TX Outer TCP checksum:               ");
> +		if (ports[port_id].dev_conf.txmode.offloads &
> +		    DEV_TX_OFFLOAD_OUTER_TCP_CKSUM)
> +			printf("on\n");
> +		else
> +			printf("off\n");
> +	}
> +
> +	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_SCTP_CKSUM) {
> +		printf("TX Outer SCTP checksum:               ");
> +		if (ports[port_id].dev_conf.txmode.offloads &
> +		    DEV_TX_OFFLOAD_OUTER_SCTP_CKSUM)
> +			printf("on\n");
> +		else
> +			printf("off\n");
> +	}
>  }

There is also "csum show", "csum set" functions, can you please check that too?
And I am not sure why those functions seems only concerned about Tx csum offloads.
Jerin Jacob Oct. 2, 2018, 9:52 a.m. UTC | #2
-----Original Message-----
> Date: Mon, 1 Oct 2018 14:45:39 +0100
> From: Ferruh Yigit <ferruh.yigit@intel.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>, Andrew Rybchenko
>  <arybchenko@solarflare.com>, Olivier Matz <olivier.matz@6wind.com>
> CC: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 4/4] ethdev: add Tx offload outer L4
>  checksum definitions
> User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101
>  Thunderbird/52.9.1
> 
> On 9/13/2018 2:47 PM, Jerin Jacob wrote:
> > Introduced DEV_TX_OFFLOAD_OUTER_UDP_CKSUM, DEV_TX_OFFLOAD_OUTER_TCP_CKSUM
> > and DEV_TX_OFFLOAD_OUTER_SCTP_CKSUM offload flags and
> >
> > PKT_TX_OUTER_L4_NO_CKSUM, PKT_TX_OUTER_TCP_CKSUM, PKT_TX_OUTER_SCTP_CKSUM
> > and PKT_TX_OUTER_UDP_CKSUM mbuf ol_flags to enable Tx outer L4 checksum
> > offload.
> >
> > To use hardware Tx outer L4 checksum offload, the user needs to.
> > # enable following in mbuff:
> > - fill outer_l2_len and outer_l3_len in mbuf
> > - set the flags PKT_TX_OUTER_TCP_CKSUM, PKT_TX_OUTER_SCTP_CKSUM or
> > PKT_TX_OUTER_UDP_CKSUM
> > - set the flag PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6
> >
> > # configure DEV_TX_OFFLOAD_OUTER_* offload flags in slow path.
> >
> > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> > ---
> >  app/test-pmd/config.c          | 27 +++++++++++++++++++++++++++
> >  doc/guides/nics/features.rst   |  6 ++++++
> >  lib/librte_ethdev/rte_ethdev.c |  3 +++
> >  lib/librte_ethdev/rte_ethdev.h |  6 ++++++
> >  lib/librte_mbuf/rte_mbuf.c     |  5 +++++
> >  lib/librte_mbuf/rte_mbuf.h     | 23 ++++++++++++++++++++++-
> >  6 files changed, 69 insertions(+), 1 deletion(-)
> >
> > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> > index 92a177e29..85f832bf0 100644
> > --- a/app/test-pmd/config.c
> > +++ b/app/test-pmd/config.c
> > @@ -773,6 +773,33 @@ 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");
> > +     }
> > +
> > +     if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_TCP_CKSUM) {
> > +             printf("TX Outer TCP checksum:               ");
> > +             if (ports[port_id].dev_conf.txmode.offloads &
> > +                 DEV_TX_OFFLOAD_OUTER_TCP_CKSUM)
> > +                     printf("on\n");
> > +             else
> > +                     printf("off\n");
> > +     }
> > +
> > +     if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_SCTP_CKSUM) {
> > +             printf("TX Outer SCTP checksum:               ");
> > +             if (ports[port_id].dev_conf.txmode.offloads &
> > +                 DEV_TX_OFFLOAD_OUTER_SCTP_CKSUM)
> > +                     printf("on\n");
> > +             else
> > +                     printf("off\n");
> > +     }
> >  }
> 
> There is also "csum show", "csum set" functions, can you please check that too?

+ Shahaf

I checked the details. It is for "csumonly.c" forward engine to select
various Tx checksum in HW or SW(provide fallback SW implementation) for
testing purpose.

If I need to implement this support for this release, I will reduce the
scope to DEV_TX_OFFLOAD_OUTER_UDP_CKSUM and
DEV_RX_OFFLOAD_OUTER_UDP_CKSUM.

Since there is NO real world non encrypted TCP/SCTP based tunnel
protocols(Based on http://patches.dpdk.org/patch/44692/ discussions)
I will limit the offload definition only to DEV_?X_OFFLOAD_OUTER_UDP_CKSUM and
associated test code in "csumonly.c" forward engine in v2.

Thoughts?

I will split 1/4 and 2/4 as separate patch series and and rework 3/4 and
4/4 as separate series to make forward progress.


> And I am not sure why those functions seems only concerned about Tx csum offloads.

It does check for errors in Rx checksum too. See rx_bad_ip_csum,
rx_bad_l4_csum

Patch
diff mbox series

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 92a177e29..85f832bf0 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -773,6 +773,33 @@  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");
+	}
+
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_TCP_CKSUM) {
+		printf("TX Outer TCP checksum:               ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_OUTER_TCP_CKSUM)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
+	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_SCTP_CKSUM) {
+		printf("TX Outer SCTP checksum:               ");
+		if (ports[port_id].dev_conf.txmode.offloads &
+		    DEV_TX_OFFLOAD_OUTER_SCTP_CKSUM)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
 }
 
 int
diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst
index 68420d196..884dbd7a5 100644
--- a/doc/guides/nics/features.rst
+++ b/doc/guides/nics/features.rst
@@ -639,8 +639,14 @@  Inner L4 checksum
 Supports inner packet L4 checksum.
 
 * **[uses]     rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_OUTER_UDP_CKSUM,DEV_RX_OFFLOAD_OUTER_TCP_CKSUM,DEV_RX_OFFLOAD_OUTER_SCTP_CKSUM``.
+* **[uses]     rte_eth_txconf,rte_eth_txmode**: ``offloads:DEV_TX_OFFLOAD_OUTER_UDP_CKSUM,DEV_TX_OFFLOAD_OUTER_TCP_CKSUM,DEV_TX_OFFLOAD_OUTER_SCTP_CKSUM``.
+* **[uses]     mbuf**: ``mbuf.ol_flags:PKT_TX_OUTER_IPV4`` | ``PKT_TX_OUTER_IPV6``.
+  ``mbuf.ol_flags:PKT_TX_OUTER_L4_NO_CKSUM`` | ``PKT_TX_OUTER_TCP_CKSUM`` |
+  ``PKT_TX_OUTER_SCTP_CKSUM`` | ``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,DEV_RX_OFFLOAD_OUTER_TCP_CKSUM,DEV_RX_OFFLOAD_OUTER_SCTP_CKSUM``,
+  ``tx_offload_capa,tx_queue_offload_capa:DEV_TX_OFFLOAD_OUTER_UDP_CKSUM,DEV_TX_OFFLOAD_OUTER_TCP_CKSUM,DEV_TX_OFFLOAD_OUTER_SCTP_CKSUM``.
 
 .. _nic_features_packet_type_parsing:
 
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 547132a8c..6cc5ad055 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -160,6 +160,9 @@  static const struct {
 	RTE_TX_OFFLOAD_BIT2STR(MULTI_SEGS),
 	RTE_TX_OFFLOAD_BIT2STR(MBUF_FAST_FREE),
 	RTE_TX_OFFLOAD_BIT2STR(SECURITY),
+	RTE_TX_OFFLOAD_BIT2STR(OUTER_UDP_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(OUTER_TCP_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(OUTER_SCTP_CKSUM),
 };
 
 #undef RTE_TX_OFFLOAD_BIT2STR
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 4665bd6f7..a5b33a27f 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -963,6 +963,12 @@  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
+/** Device supports outer TCP checksum */
+#define DEV_TX_OFFLOAD_OUTER_TCP_CKSUM  0x00200000
+/** Device supports outer SCTP checksum */
+#define DEV_TX_OFFLOAD_OUTER_SCTP_CKSUM 0x00400000
 
 #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..af14d9273 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -437,6 +437,11 @@  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_TCP_CKSUM, PKT_TX_OUTER_L4_MASK, NULL },
+		{ PKT_TX_OUTER_SCTP_CKSUM, PKT_TX_OUTER_L4_MASK, NULL },
+		{ PKT_TX_OUTER_UDP_CKSUM, PKT_TX_OUTER_L4_MASK, NULL },
+		{ PKT_TX_OUTER_L4_NO_CKSUM, PKT_TX_OUTER_L4_MASK,
+		"PKT_TX_OUTER_L4_NO_CKSUM" },
 	};
 	const char *name;
 	unsigned int i;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 80989483b..541521d7d 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -184,6 +184,26 @@  extern "C" {
 
 /* add new TX flags here */
 
+/**
+ * Bits 40+41 used for outer L4 packet type with checksum enabled: 00: Reserved,
+ * 01: Outer TCP checksum, 10: Outer SCTP checksum, 11: Outer UDP checksum.
+ * To use hardware outer L4 checksum offload, the user needs to:
+ *  - fill outer_l2_len and outer_l3_len in mbuf
+ *  - set the flags PKT_TX_OUTER_TCP_CKSUM, PKT_TX_OUTER_SCTP_CKSUM or
+ *  PKT_TX_OUTER_UDP_CKSUM
+ *  - set the flag PKT_TX_OUTER_IPV4 or PKT_TX_OUTER_IPV6
+ */
+#define PKT_TX_OUTER_L4_NO_CKSUM   (0ULL << 40)
+/**< Disable Outer L4 cksum of TX pkt. */
+#define PKT_TX_OUTER_TCP_CKSUM     (1ULL << 40)
+/**< Outer TCP cksum of TX pkt. computed by NIC. */
+#define PKT_TX_OUTER_SCTP_CKSUM    (2ULL << 40)
+/**< Outer SCTP cksum of TX pkt. computed by NIC. */
+#define PKT_TX_OUTER_UDP_CKSUM     (3ULL << 40)
+/**< Outer UDP cksum of TX pkt. computed by NIC. */
+#define PKT_TX_OUTER_L4_MASK       (3ULL << 40)
+/**< Mask for Outer L4 cksum offload request. */
+
 /**
  * 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
@@ -347,7 +367,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_L4_MASK)
 
 /**
  * Mbuf having an external buffer attached. shinfo in mbuf must be filled.