[3/4] ethdev: add Rx offload outer L4 checksum definitions

Message ID 20180913134707.23698-3-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/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Jerin Jacob Sept. 13, 2018, 1:47 p.m.
Introduced DEV_RX_OFFLOAD_OUTER_UDP_CKSUM, DEV_RX_OFFLOAD_OUTER_TCP_CKSUM
and DEV_RX_OFFLOAD_OUTER_SCTP_CKSUM offload flags and

PKT_RX_EL4_CKSUM_BAD mbuf ol_flags to enable outer Rx L4 checksum
offload.

# To use hardware Rx outer L4 checksum offload, the user needs to
configure DEV_RX_OFFLOAD_OUTER_* offload flags in slowpath.

# Driver updates the PKT_RX_EL4_CKSUM_BAD mbuf ol_flag on checksum failure
similar to the outer L3 PKT_RX_EIP_CKSUM_BAD flag.

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

Comments

Shahaf Shuler Sept. 13, 2018, 5:24 p.m. | #1
Thursday, September 13, 2018 4:47 PM, Jerin Jacob:
> Subject: [dpdk-dev] [PATCH 3/4] ethdev: add Rx offload outer L4 checksum
> definitions
> 
> Introduced DEV_RX_OFFLOAD_OUTER_UDP_CKSUM,
> DEV_RX_OFFLOAD_OUTER_TCP_CKSUM and
> DEV_RX_OFFLOAD_OUTER_SCTP_CKSUM offload flags and

Out of curiosity, which TCP based tunnels you target with this current patchset? 

> 
> PKT_RX_EL4_CKSUM_BAD mbuf ol_flags to enable outer Rx L4 checksum
> offload.
> 
> # To use hardware Rx outer L4 checksum offload, the user needs to
> configure DEV_RX_OFFLOAD_OUTER_* offload flags in slowpath.
> 
> # Driver updates the PKT_RX_EL4_CKSUM_BAD mbuf ol_flag on checksum
> failure similar to the outer L3 PKT_RX_EIP_CKSUM_BAD flag.
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Jerin Jacob Sept. 14, 2018, 3:05 a.m. | #2
-----Original Message-----
> Date: Thu, 13 Sep 2018 17:24:26 +0000
> From: Shahaf Shuler <shahafs@mellanox.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>, Andrew Rybchenko <arybchenko@solarflare.com>,
>  Olivier Matz <olivier.matz@6wind.com>
> CC: "dev@dpdk.org" <dev@dpdk.org>
> Subject: RE: [dpdk-dev] [PATCH 3/4] ethdev: add Rx offload outer L4
>  checksum definitions
> 
> 
> Thursday, September 13, 2018 4:47 PM, Jerin Jacob:
> > Subject: [dpdk-dev] [PATCH 3/4] ethdev: add Rx offload outer L4 checksum
> > definitions
> >
> > Introduced DEV_RX_OFFLOAD_OUTER_UDP_CKSUM,
> > DEV_RX_OFFLOAD_OUTER_TCP_CKSUM and
> > DEV_RX_OFFLOAD_OUTER_SCTP_CKSUM offload flags and
> 
> Out of curiosity, which TCP based tunnels you target with this current patchset?

I am not aware of any _popular_/_non proprietary_  protocols except SSTP for VPN.


> 
> >
> > PKT_RX_EL4_CKSUM_BAD mbuf ol_flags to enable outer Rx L4 checksum
> > offload.
> >
> > # To use hardware Rx outer L4 checksum offload, the user needs to
> > configure DEV_RX_OFFLOAD_OUTER_* offload flags in slowpath.
> >
> > # Driver updates the PKT_RX_EL4_CKSUM_BAD mbuf ol_flag on checksum
> > failure similar to the outer L3 PKT_RX_EIP_CKSUM_BAD flag.
> >
> > Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Shahaf Shuler Sept. 16, 2018, 5:53 a.m. | #3
Friday, September 14, 2018 6:06 AM, Jerin Jacob:
> Subject: Re: [dpdk-dev] [PATCH 3/4] ethdev: add Rx offload outer L4
> checksum definitions
> 
> -----Original Message-----
> > Date: Thu, 13 Sep 2018 17:24:26 +0000
> > From: Shahaf Shuler <shahafs@mellanox.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>, Andrew Rybchenko
> > <arybchenko@solarflare.com>,  Olivier Matz <olivier.matz@6wind.com>
> > CC: "dev@dpdk.org" <dev@dpdk.org>
> > Subject: RE: [dpdk-dev] [PATCH 3/4] ethdev: add Rx offload outer L4
> > checksum definitions
> >
> >
> > Thursday, September 13, 2018 4:47 PM, Jerin Jacob:
> > > Subject: [dpdk-dev] [PATCH 3/4] ethdev: add Rx offload outer L4
> > > checksum definitions
> > >
> > > Introduced DEV_RX_OFFLOAD_OUTER_UDP_CKSUM,
> > > DEV_RX_OFFLOAD_OUTER_TCP_CKSUM and
> DEV_RX_OFFLOAD_OUTER_SCTP_CKSUM
> > > offload flags and
> >
> > Out of curiosity, which TCP based tunnels you target with this current
> patchset?
> 
> I am not aware of any _popular_/_non proprietary_  protocols except SSTP
> for VPN.

And your device can support such protocol inner and outer checksum check?
From what I see the inner packet of SSTP is encrypted by SSL.

So for outer and inner checksum validation device will need to:
1. compute the outer TCP checksum
2. if valid decrypt the inner PPP packet
3. compute the PPP checksum.
Jerin Jacob Sept. 16, 2018, 9:32 a.m. | #4
-----Original Message-----
> Date: Sun, 16 Sep 2018 05:53:30 +0000
> From: Shahaf Shuler <shahafs@mellanox.com>
> To: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> CC: 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>, Andrew Rybchenko <arybchenko@solarflare.com>,
>  Olivier Matz <olivier.matz@6wind.com>, "dev@dpdk.org" <dev@dpdk.org>
> Subject: RE: [dpdk-dev] [PATCH 3/4] ethdev: add Rx offload outer L4
>  checksum definitions
> 
> Friday, September 14, 2018 6:06 AM, Jerin Jacob:
> > Subject: Re: [dpdk-dev] [PATCH 3/4] ethdev: add Rx offload outer L4
> > checksum definitions
> >
> > -----Original Message-----
> > > Date: Thu, 13 Sep 2018 17:24:26 +0000
> > > From: Shahaf Shuler <shahafs@mellanox.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>, Andrew Rybchenko
> > > <arybchenko@solarflare.com>,  Olivier Matz <olivier.matz@6wind.com>
> > > CC: "dev@dpdk.org" <dev@dpdk.org>
> > > Subject: RE: [dpdk-dev] [PATCH 3/4] ethdev: add Rx offload outer L4
> > > checksum definitions
> > >
> > >
> > > Thursday, September 13, 2018 4:47 PM, Jerin Jacob:
> > > > Subject: [dpdk-dev] [PATCH 3/4] ethdev: add Rx offload outer L4
> > > > checksum definitions
> > > >
> > > > Introduced DEV_RX_OFFLOAD_OUTER_UDP_CKSUM,
> > > > DEV_RX_OFFLOAD_OUTER_TCP_CKSUM and
> > DEV_RX_OFFLOAD_OUTER_SCTP_CKSUM
> > > > offload flags and
> > >
> > > Out of curiosity, which TCP based tunnels you target with this current
> > patchset?
> >
> > I am not aware of any _popular_/_non proprietary_  protocols except SSTP
> > for VPN.
> 
> And your device can support such protocol inner and outer checksum check?

Yes for TCP/UDP/SCTP.

> From what I see the inner packet of SSTP is encrypted by SSL.
> 
> So for outer and inner checksum validation device will need to:
> 1. compute the outer TCP checksum
> 2. if valid decrypt the inner PPP packet
> 3. compute the PPP checksum.

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index c4ed8d474..92a177e29 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -594,6 +594,33 @@  port_offload_cap_display(portid_t port_id)
 			printf("off\n");
 	}
 
+	if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_OUTER_UDP_CKSUM) {
+		printf("RX Outer UDP checksum:               ");
+		if (ports[port_id].dev_conf.rxmode.offloads &
+		    DEV_RX_OFFLOAD_OUTER_UDP_CKSUM)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
+	if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_OUTER_TCP_CKSUM) {
+		printf("RX Outer TCP checksum:               ");
+		if (ports[port_id].dev_conf.rxmode.offloads &
+		    DEV_RX_OFFLOAD_OUTER_TCP_CKSUM)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
+	if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_OUTER_SCTP_CKSUM) {
+		printf("RX Outer SCTP checksum:               ");
+		if (ports[port_id].dev_conf.rxmode.offloads &
+		    DEV_RX_OFFLOAD_OUTER_SCTP_CKSUM)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
 	if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TCP_LRO) {
 		printf("Large receive offload:         ");
 		if (ports[port_id].dev_conf.rxmode.offloads &
diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst
index a98356a16..68420d196 100644
--- a/doc/guides/nics/features.rst
+++ b/doc/guides/nics/features.rst
@@ -638,6 +638,9 @@  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``.
+* **[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``,
 
 .. _nic_features_packet_type_parsing:
 
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index d91870e90..547132a8c 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -128,6 +128,9 @@  static const struct {
 	RTE_RX_OFFLOAD_BIT2STR(SECURITY),
 	RTE_RX_OFFLOAD_BIT2STR(KEEP_CRC),
 	RTE_RX_OFFLOAD_BIT2STR(SCTP_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(OUTER_UDP_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(OUTER_TCP_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(OUTER_SCTP_CKSUM),
 };
 
 #undef RTE_RX_OFFLOAD_BIT2STR
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index adbe936a4..4665bd6f7 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -901,6 +901,10 @@  struct rte_eth_conf {
  */
 #define DEV_RX_OFFLOAD_KEEP_CRC		0x00010000
 #define DEV_RX_OFFLOAD_SCTP_CKSUM	0x00020000
+#define DEV_RX_OFFLOAD_OUTER_UDP_CKSUM	0x00040000
+#define DEV_RX_OFFLOAD_OUTER_TCP_CKSUM	0x00080000
+#define DEV_RX_OFFLOAD_OUTER_SCTP_CKSUM	0x00100000
+
 #define DEV_RX_OFFLOAD_CHECKSUM (DEV_RX_OFFLOAD_IPV4_CKSUM | \
 				 DEV_RX_OFFLOAD_UDP_CKSUM | \
 				 DEV_RX_OFFLOAD_TCP_CKSUM)
@@ -908,6 +912,11 @@  struct rte_eth_conf {
 			     DEV_RX_OFFLOAD_VLAN_FILTER | \
 			     DEV_RX_OFFLOAD_VLAN_EXTEND)
 
+#define DEV_RX_OFFLOAD_OUTER_CHECKSUM (DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM | \
+				DEV_RX_OFFLOAD_OUTER_UDP_CKSUM | \
+				DEV_RX_OFFLOAD_OUTER_TCP_CKSUM | \
+				DEV_RX_OFFLOAD_OUTER_SCTP_CKSUM)
+
 /*
  * If new Rx offload capabilities are defined, they also must be
  * mentioned in rte_rx_offload_names in rte_ethdev.c file.
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index e714c5a59..022e92b3c 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -301,6 +301,7 @@  const char *rte_get_rx_ol_flag_name(uint64_t mask)
 	case PKT_RX_TIMESTAMP: return "PKT_RX_TIMESTAMP";
 	case PKT_RX_SEC_OFFLOAD: return "PKT_RX_SEC_OFFLOAD";
 	case PKT_RX_SEC_OFFLOAD_FAILED: return "PKT_RX_SEC_OFFLOAD_FAILED";
+	case PKT_RX_EL4_CKSUM_BAD: return "PKT_RX_EL4_CKSUM_BAD";
 	default: return NULL;
 	}
 }
@@ -339,6 +340,7 @@  rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 		{ PKT_RX_SEC_OFFLOAD, PKT_RX_SEC_OFFLOAD, NULL },
 		{ PKT_RX_SEC_OFFLOAD_FAILED, PKT_RX_SEC_OFFLOAD_FAILED, NULL },
 		{ PKT_RX_QINQ, PKT_RX_QINQ, NULL },
+		{ PKT_RX_EL4_CKSUM_BAD, PKT_RX_EL4_CKSUM_BAD, NULL },
 	};
 	const char *name;
 	unsigned int i;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 6a5dbbc8f..80989483b 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -177,6 +177,9 @@  extern "C" {
  */
 #define PKT_RX_QINQ          (1ULL << 20)
 
+/**< External/Outer Layer4 header checksum error. */
+#define PKT_RX_EL4_CKSUM_BAD (1ULL << 21)
+
 /* add new RX flags here */
 
 /* add new TX flags here */