Skip to contentSkip to conversation

ethdev: introduce protocol type based header split

RFC Superseded [email protected] 10 participants 88 messages Mar 3, 2022 – Aug 2, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

RFC 1/1 ethdev: introduce protocol type based header split

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer. This kind of splitting is useful in some use cases, such as GPU. GPU can directly process the payload part and improve the performance significantly.

Currently, Rx buffer split supports length and offset based packet split. This is not suitable for some NICs that do split based on protocol types. Tunneling makes the conversion from offset to protocol inaccurate.

This patch extends the current buffer split to support protocol based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header split type.

With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, L2/L3/L4 level header split is supported.

---
 lib/ethdev/rte_ethdev.c |  2 +-
 lib/ethdev/rte_ethdev.h | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
lib/ethdev/rte_ethdev.c +1 -1
index 70c850a2f1..d37c8f9d7e 100644
@@ -1784,7 +1784,7 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 							   &dev_info);
 			if (ret != 0)
 				return ret;
-		} else {
+		} else if (!(rx_conf->offloads & RTE_ETH_RX_OFFLOAD_HEADER_SPLIT)) {
 			RTE_ETHDEV_LOG(ERR, "No Rx segmentation offload configured\n");
 			return -EINVAL;
 		}
lib/ethdev/rte_ethdev.h +16 -1
index c2d1f9a972..6743648c22 100644
@@ -1202,7 +1202,8 @@ struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint16_t proto;
+	uint16_t reserved; /**< Reserved field. */
 };
 
 /**
@@ -1664,6 +1665,20 @@ struct rte_eth_conf {
 			     RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
 #define DEV_RX_OFFLOAD_VLAN RTE_DEPRECATED(DEV_RX_OFFLOAD_VLAN) RTE_ETH_RX_OFFLOAD_VLAN
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice.
+ * This enum indicates the header split protocol type
+ */
+enum rte_eth_rx_header_split_protocol_type {
+	RTE_ETH_RX_HEADER_SPLIT_DEFAULT = 0,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_L2,
+	RTE_ETH_RX_HEADER_SPLIT_OUTER_L2,
+	RTE_ETH_RX_HEADER_SPLIT_IP,
+	RTE_ETH_RX_HEADER_SPLIT_TCP_UDP,
+	RTE_ETH_RX_HEADER_SPLIT_SCTP
+};
+
 /*
  * If new Rx offload capabilities are defined, they also must be
  * mentioned in rte_rx_offload_names in rte_ethdev.c file.
Signature · 1 line
2.17.1
#1 lore raw

03/03/2022 07:01, [email protected]:

Quoted 46 lines

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer. This kind of splitting is useful in some use cases, such as GPU. GPU can directly process the payload part and improve the performance significantly.

Currently, Rx buffer split supports length and offset based packet split. This is not suitable for some NICs that do split based on protocol types. Tunneling makes the conversion from offset to protocol inaccurate.

This patch extends the current buffer split to support protocol based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header split type.

With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, L2/L3/L4 level header split is supported.

---
 lib/ethdev/rte_ethdev.c |  2 +-
 lib/ethdev/rte_ethdev.h | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
lib/ethdev/rte_ethdev.c +1 -1
index 70c850a2f1..d37c8f9d7e 100644
@@ -1784,7 +1784,7 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 							   &dev_info);
 			if (ret != 0)
 				return ret;
-		} else {
+		} else if (!(rx_conf->offloads & RTE_ETH_RX_OFFLOAD_HEADER_SPLIT)) {
 			RTE_ETHDEV_LOG(ERR, "No Rx segmentation offload configured\n");
 			return -EINVAL;
 		}
lib/ethdev/rte_ethdev.h +0 -0
index c2d1f9a972..6743648c22 100644

lib/ethdev/rte_ethdev.h struct rte_eth_rxseg_split { · line 1205

Quoted 5 lines
lib/ethdev/rte_ethdev.h +1 -1
@@ -1202,7 +1202,8 @@ struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint16_t proto;

If it is not explicitly documented, it cannot be accepted.

What happens if we have a non-0 proto and length/offset defined?

Quoted 2 lines
lib/ethdev/rte_ethdev.h +1 -0
+	uint16_t reserved; /**< Reserved field. */
 };

[...]

Quoted 3 lines

+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice.

This is not a structure.

lib/ethdev/rte_ethdev.h struct rte_eth_conf { · line 1680

Quoted 10 lines

+ * This enum indicates the header split protocol type
+ */

lib/ethdev/rte_ethdev.h +8 -0
+enum rte_eth_rx_header_split_protocol_type {
+	RTE_ETH_RX_HEADER_SPLIT_DEFAULT = 0,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_L2,
+	RTE_ETH_RX_HEADER_SPLIT_OUTER_L2,
+	RTE_ETH_RX_HEADER_SPLIT_IP,
+	RTE_ETH_RX_HEADER_SPLIT_TCP_UDP,
+	RTE_ETH_RX_HEADER_SPLIT_SCTP
+};

Lack of documentation.
Where the split should happen? before or after the header? What means DEFAULT?
What means IP, TCP_UDP and SCTP? Is it inner or outer?

author
#2 lore raw

Hi Thomas,

Quoted 64 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: 2022年3月3日 16:55
To: Ding, Xuan <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; [email protected]; Zhang, Qi Z <[email protected]>; Yu, Ping <[email protected]>; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; [email protected]; [email protected]
Subject: Re: [RFC] ethdev: introduce protocol type based header split

03/03/2022 07:01, [email protected]:

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t

Quoted 33 lines

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer. This kind of splitting is useful in some use cases, such as GPU. GPU can directly process the payload part and improve the performance significantly.

Currently, Rx buffer split supports length and offset based packet split. This is not suitable for some NICs that do split based on protocol types. Tunneling makes the conversion from offset to protocol inaccurate.

This patch extends the current buffer split to support protocol based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header split type.

With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, L2/L3/L4 level header split is supported.

---
 lib/ethdev/rte_ethdev.c |  2 +-
 lib/ethdev/rte_ethdev.h | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

70c850a2f1..d37c8f9d7e 100644

lib/ethdev/rte_ethdev.c +0 -0
@@ -1784,7 +1784,7 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t

rx_queue_id,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,

Quoted 5 lines
lib/ethdev/rte_ethdev.c +1 -1
 							   &dev_info);
 			if (ret != 0)
 				return ret;
-		} else {
+		} else if (!(rx_conf->offloads &

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT))

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t · line 1789

Quoted 2 lines
lib/ethdev/rte_ethdev.c +1 -0
+{
 			RTE_ETHDEV_LOG(ERR, "No Rx segmentation offload

configured\n");

lib/ethdev/rte_ethdev.h struct rte_eth_rxseg_split { · line 1202

Quoted 8 lines
lib/ethdev/rte_ethdev.c +0 -0
 			return -EINVAL;
 		}
lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0 -0

c2d1f9a972..6743648c22 100644

lib/ethdev/rte_ethdev.h +0 -0
@@ -1202,7 +1202,8 @@ struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from.

*/

Quoted 6 lines

lib/ethdev/rte_ethdev.h struct rte_eth_rxseg_split { · line 1205

Quoted 4 lines
lib/ethdev/rte_ethdev.h +1 -1
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint16_t proto;

If it is not explicitly documented, it cannot be accepted.

Thanks for your suggestion. The documentation will be enriched in next version. Let me give a brief introduction here.

Quoted 2 lines

What happens if we have a non-0 proto and length/offset defined?

As Morten said, the proto field is exclude from the length field here. For buffer split, the length/offset is needed.
For header split, the proto is needed.
As for offset field in header split, by default it is zero, it can also be configured to decide the beginning of mbuf data buffer.

In conclusion, non-0 proto indicates PMDs can do header split. Length defines PMDs can do buffer split.

Quoted 10 lines
Quoted 3 lines
lib/ethdev/rte_ethdev.h +1 -0
+	uint16_t reserved; /**< Reserved field. */
 };

[...]

Quoted 3 lines

+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice.

This is not a structure.

Quoted 12 lines

lib/ethdev/rte_ethdev.h struct rte_eth_conf { · line 1680

Quoted 9 lines

+ * This enum indicates the header split protocol type */ enum

lib/ethdev/rte_ethdev.h +8 -0
+rte_eth_rx_header_split_protocol_type {
+	RTE_ETH_RX_HEADER_SPLIT_DEFAULT = 0,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_L2,
+	RTE_ETH_RX_HEADER_SPLIT_OUTER_L2,
+	RTE_ETH_RX_HEADER_SPLIT_IP,
+	RTE_ETH_RX_HEADER_SPLIT_TCP_UDP,
+	RTE_ETH_RX_HEADER_SPLIT_SCTP
+};

Lack of documentation.
Where the split should happen? before or after the header?

When header split is configured, the split happens at the boundary of header and payload. So, after the header, before payload.

Quoted 1 line

What means DEFAULT?

DEFAULT means no header split protocol type was defined. As this time, even header split offload is configured in Rx queue, the PMD won't do header split. Actually, using NONE is more accurate.

Quoted 1 line

What means IP, TCP_UDP and SCTP? Is it inner or outer?

Since header split happens after the header, so the IP/TCP/UDP/SCTP defines the header type.
When take inner and outer into consideration, The definition should be refined here. For example:

rte_eth_rx_header_split_protocol_type {
	RTE_ETH_RX_HEADER_SPLIT_NONE = 0,
	RTE_ETH_RX_HEADER_SPLIT_MAC,
	RTE_ETH_RX_HEADER_SPLIT_IPV4,
	RTE_ETH_RX_HEADER_SPLIT_IPV6,
	RTE_ETH_RX_HEADER_SPLIT_L3,
	RTE_ETH_RX_HEADER_SPLIT_TCP,
	RTE_ETH_RX_HEADER_SPLIT_UDP,
	RTE_ETH_RX_HEADER_SPLIT_SCTP,
	RTE_ETH_RX_HEADER_SPLIT_L4,
	RTE_ETH_RX_HEADER_SPLIT_INNER_MAC,
	RTE_ETH_RX_HEADER_SPLIT_INNER_IPV4,
	RTE_ETH_RX_HEADER_SPLIT_INNER_IPV6,
	RTE_ETH_RX_HEADER_SPLIT_INNER_L3,
	RTE_ETH_RX_HEADER_SPLIT_INNER_TCP,
	RTE_ETH_RX_HEADER_SPLIT_INNER_UDP,
	RTE_ETH_RX_HEADER_SPLIT_INNER_SCTP,
	RTE_ETH_RX_HEADER_SPLIT_INNER_L4,
};

Considering some NICs don’t distinguish the L2/L3/L4 in header split, a separate L2/L3/L4 is also defined.

Thanks,
Xuan

Quoted 1 line
#3 lore raw
In reply to [email protected]

lib/ethdev/rte_ethdev.h struct rte_eth_rxseg_split { · line 1207

Quoted 12 lines · On Thu, 3 Mar 2022 06:01:36 +0000 [email protected] wrote:
lib/ethdev/rte_ethdev.h +2 -1
index c2d1f9a972..6743648c22 100644
@@ -1202,7 +1202,8 @@ struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint16_t proto;
+	uint16_t reserved; /**< Reserved field. */
 };

This feature suffers from a common bad design pattern.
You can't just start using reserved fields unless the previous versions enforced that the field was a particular value (usually zero).

There is no guarantee that application will initialize these reserved fields and now using them risks breaking the API/ABI. It looks like

rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Would have had to check in previous release.

This probably has to wait until 22.11 next API release.

#4 lore raw
Quoted 22 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Friday, March 4, 2022 12:16 AM
To: Ding, Xuan <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; [email protected]; Zhang, Qi Z <[email protected]>; Yu, Ping <[email protected]>; Wang, YuanX <[email protected]>
Subject: Re: [RFC] ethdev: introduce protocol type based header split

lib/ethdev/rte_ethdev.h struct rte_eth_rxseg_split { · line 1202

Quoted 6 lines · On Thu, 3 Mar 2022 06:01:36 +0000 [email protected] wrote:
lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0 -0

c2d1f9a972..6743648c22 100644

lib/ethdev/rte_ethdev.h +0 -0
@@ -1202,7 +1202,8 @@ struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from.

*/

Quoted 10 lines

lib/ethdev/rte_ethdev.h struct rte_eth_rxseg_split { · line 1207

Quoted 6 lines
lib/ethdev/rte_ethdev.h +2 -1
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint16_t proto;
+	uint16_t reserved; /**< Reserved field. */
 };

This feature suffers from a common bad design pattern.
You can't just start using reserved fields unless the previous versions enforced that the field was a particular value (usually zero).

Yes, agree, that's a mistake there is no document for the reserved field in the previous release, and usually, it should be zero, And I think one of the typical purposes of the reserved field is to make life easy for new feature adding without breaking ABI. So, should we just take the risk as I guess it might not be a big deal in real cases?

Thanks
Qi

Quoted 9 lines

There is no guarantee that application will initialize these reserved fields and now using them risks breaking the API/ABI. It looks like

rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Would have had to check in previous release.

This probably has to wait until 22.11 next API release.

#5 lore raw
Quoted 30 lines

From: Zhang, Qi Z [mailto:[email protected]]
Sent: Friday, 4 March 2022 10.58

Quoted 7 lines

From: Stephen Hemminger <[email protected]>
Sent: Friday, March 4, 2022 12:16 AM

lib/ethdev/rte_ethdev.h

Quoted 1 line · On Thu, 3 Mar 2022 06:01:36 +0000 [email protected] wrote:
lib/ethdev/rte_ethdev.h +0 -0

index

Quoted 5 lines

lib/ethdev/rte_ethdev.h struct rte_eth_rxseg_split { · line 1202

Quoted 5 lines

c2d1f9a972..6743648c22 100644

lib/ethdev/rte_ethdev.h +0 -0
@@ -1202,7 +1202,8 @@ struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment

from.

Quoted 2 lines

*/

Quoted 1 line
lib/ethdev/rte_ethdev.h +0 -0
 	uint16_t length; /**< Segment data length, configures split

point. */

Quoted 1 line

lib/ethdev/rte_ethdev.h struct rte_eth_rxseg_split { · line 1204

Quoted 1 line
lib/ethdev/rte_ethdev.h +0 -0
 	uint16_t offset; /**< Data offset from beginning of mbuf data

buffer. */

Quoted 7 lines

lib/ethdev/rte_ethdev.h struct rte_eth_rxseg_split { · line 1207

Quoted 4 lines
lib/ethdev/rte_ethdev.h +2 -1
-	uint32_t reserved; /**< Reserved field. */
+	uint16_t proto;
+	uint16_t reserved; /**< Reserved field. */
 };

This feature suffers from a common bad design pattern. You can't just start using reserved fields unless the previous

versions enforced

Quoted 9 lines
Quoted 1 line

that the field was a particular value (usually zero).

Yes, agree, that's a mistake there is no document for the reserved field in the previous release, and usually, it should be zero, And I think one of the typical purposes of the reserved field is to make life easy for new feature adding without breaking ABI. So, should we just take the risk as I guess it might not be a big deal in real cases?

In this specific case, I think it can be done with very low risk in real cases.

Assuming that splitting based on fixed length and protocol header parsing is mutually exclusive, the PMDs can simply ignore the "proto" field (and log a warning about it) if the length field is non-zero. This will provide backwards compatibility with applications not zeroing out the 32 bit "reserved" field.

Quoted 16 lines

Thanks
Qi

Quoted 2 lines

There is no guarantee that application will initialize these reserved

fields and

Quoted 3 lines

now using them risks breaking the API/ABI. It looks like

rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split

*rx_seg,

Quoted 4 lines

Would have had to check in previous release.

This probably has to wait until 22.11 next API release.

#6 lore raw
In reply to Zhang, Qi Z
Quoted 31 lines · Qi Z
Quoted 20 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Friday, March 4, 2022 12:16 AM
To: Ding, Xuan <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; [email protected]; Zhang, Qi Z <[email protected]>; Yu, Ping <[email protected]>; Wang, YuanX <[email protected]>
Subject: Re: [RFC] ethdev: introduce protocol type based header split

lib/ethdev/rte_ethdev.h struct rte_eth_rxseg_split { · line 1202

Quoted 6 lines · On Thu, 3 Mar 2022 06:01:36 +0000 [email protected] wrote:
lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0 -0

c2d1f9a972..6743648c22 100644

lib/ethdev/rte_ethdev.h +0 -0
@@ -1202,7 +1202,8 @@ struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from.  

*/

Quoted 10 lines

lib/ethdev/rte_ethdev.h struct rte_eth_rxseg_split { · line 1207

Quoted 6 lines
lib/ethdev/rte_ethdev.h +2 -1
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint16_t proto;
+	uint16_t reserved; /**< Reserved field. */
 };  

This feature suffers from a common bad design pattern.
You can't just start using reserved fields unless the previous versions enforced that the field was a particular value (usually zero).

Quoted 3 lines

Yes, agree, that's a mistake there is no document for the reserved field in the previous release, and usually, it should be zero, And I think one of the typical purposes of the reserved field is to make life easy for new feature adding without breaking ABI. So, should we just take the risk as I guess it might not be a big deal in real cases?

There is a cost/benefit tradeoff here. Although HW vendors would like to enable more features, it really is not that much of an impact to wait until next LTS for users.

Yes, the API/ABI rules are restrictive, but IMHO it is about learning how to handle SW upgrades in a more user friendly manner. It was hard for the Linux kernel to learn how to do this, but after 10 years they mostly have it right.

If this were a bug (especially a security bug), then the rules could be lifted.

#7 lore raw

v2 cover ethdev: introduce protocol type based header split

In reply to [email protected]

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. It is useful in some scenarios, such as GPU acceleration. The spliting will help to enable true zero copy and hence improve the performance significantly.

This patchset extends the current buffer split to support protocol based header split. When Rx queue is configured with header split feature, packets received will be directly splited into two different mempools.

Xuan Ding (3):
ethdev: introduce protocol type based header split app/testpmd: add header split configuration net/ice: support header split in Rx data path

 app/test-pmd/cmdline.c                | 117 ++++++++++++++
 app/test-pmd/testpmd.c                |   6 +-
 app/test-pmd/testpmd.h                |   2 +
 drivers/net/ice/ice_ethdev.c          |  10 +-
 drivers/net/ice/ice_rxtx.c            | 220 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 lib/ethdev/rte_ethdev.c               |  24 +--
 lib/ethdev/rte_ethdev.h               |  43 ++++-
 9 files changed, 397 insertions(+), 44 deletions(-)
Signature · 1 line
2.17.1
#8 lore raw

RFC v2 1/3 ethdev: introduce protocol type based header split

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configure buffer split based on length and offset is not suitable for NICs that do split based on header protocol types. And tunneling makes the conversion from offset to protocol impossible.

This patch extends the current buffer split to support protocol based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

For example, let's suppose we configured the Rx queue with the following segments:
seg0 - pool0
seg1 - pool1

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - pool0, udp_header
seg1 - pool1, payload

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 24 +++++++++++++----------
 lib/ethdev/rte_ethdev.h | 43 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 55 insertions(+), 12 deletions(-)
lib/ethdev/rte_ethdev.c +14 -10
index 70c850a2f1..49c8fef1c3 100644
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint16_t proto = rx_seg[seg_idx].proto;
 
 		if (mpl == NULL) {
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1692,15 +1693,17 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 					(struct rte_pktmbuf_pool_private));
 			return -ENOSPC;
 		}
-		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
-		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto == 0) {
+			offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
+			*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
 		}
 	}
 	return 0;
@@ -1778,7 +1781,8 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		rx_seg = (const struct rte_eth_rxseg_split *)rx_conf->rx_seg;
 		n_seg = rx_conf->rx_nseg;
 
-		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
+		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ||
+			rx_conf->offloads & RTE_ETH_RX_OFFLOAD_HEADER_SPLIT) {
 			ret = rte_eth_rx_queue_check_split(rx_seg, n_seg,
 							   &mbp_buf_size,
 							   &dev_info);
lib/ethdev/rte_ethdev.h +41 -2

66 lines not on this page · raw message

Signature · 1 line
2.17.1
#9 lore raw
Quoted 95 lines

-----Original Message-----
From: Ding, Xuan <[email protected]>
Sent: Tuesday, March 22, 2022 11:56 AM
To: [email protected]; Yigit, Ferruh <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Zhang, Qi Z <[email protected]>; Yu, Ping <[email protected]>; Wu, WenxuanX <[email protected]>; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>
Subject: [RFC,v2 1/3] ethdev: introduce protocol type based header split

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configure buffer split based on length and offset is not suitable for NICs that do split based on header protocol types. And tunneling makes the conversion from offset to protocol impossible.

This patch extends the current buffer split to support protocol based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

For example, let's suppose we configured the Rx queue with the following segments:
seg0 - pool0
seg1 - pool1

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - pool0, udp_header
seg1 - pool1, payload

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 24 +++++++++++++----------
lib/ethdev/rte_ethdev.h | 43
+++++++++++++++++++++++++++++++++++++++--
 2 files changed, 55 insertions(+), 12 deletions(-)
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

70c850a2f1..49c8fef1c3 100644

lib/ethdev/rte_ethdev.c +1 -0
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct
 rte_eth_rxseg_split *rx_seg,
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint16_t proto = rx_seg[seg_idx].proto;
 
 		if (mpl == NULL) {
lib/ethdev/rte_ethdev.c +3 -9
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1692,15 +1693,17 @@ rte_eth_rx_queue_check_split(const struct
 rte_eth_rxseg_split *rx_seg,
 					(struct rte_pktmbuf_pool_private));
 			return -ENOSPC;
 		}
-		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
-		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u
 (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto == 0) {
+			offset += seg_idx != 0 ? 0 :
 RTE_PKTMBUF_HEADROOM;
+			*mbp_buf_size =

rte_pktmbuf_data_room_size(mpl);

lib/ethdev/rte_ethdev.c +4 -0
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1707

Quoted 5 lines
lib/ethdev/rte_ethdev.c +4 -0
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
 		}

As the length and proto is exclusive, it better also check the length when proto!=0

.....

Quoted 10 lines
lib/ethdev/rte_ethdev.c +6 -0
@@ -1197,12 +1197,26 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *
+ * Header split is a subset of buffer split. The split happens after
+ the
+ * packet header and before the packet payload. For PMDs that do not
+ * support header split configuration by length and offset, the
+ location

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1215

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+ * of the split needs to be specified by the header protocol type.
+ While for
+ * buffer split, this field should not be configured.
+ *
+ * If RTE_ETH_RX_OFFLOAD_HEADER_SPLIT flag is set in offloads field,
+ * the PMD will split the received packets into two separate regions:
+ * - The header buffer will be allocated from the memory pool,
+ *   specified in the first array element, the second buffer, from the
+ *   pool in the second element.
+ * - The length and offset do not need to be configured in header split.

We may not necessarily ignore the offset configure for header split as there is no confliction, a driver still can support copying a split header to a specific mbuf offset And if we support offset with header split, offset boundary check can also be considered in rte_eth_rx_queue_check_split

Regards
Qi

author
#10 lore raw

Hi Qi,

Quoted 107 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Tuesday, March 22, 2022 3:14 PM
To: Ding, Xuan <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Yu, Ping <[email protected]>; Wu, WenxuanX <[email protected]>; Wang, YuanX <[email protected]>
Subject: RE: [RFC,v2 1/3] ethdev: introduce protocol type based header split

Quoted 9 lines

-----Original Message-----
From: Ding, Xuan <[email protected]>
Sent: Tuesday, March 22, 2022 11:56 AM
To: [email protected]; Yigit, Ferruh <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Zhang, Qi Z <[email protected]>; Yu, Ping <[email protected]>; Wu, WenxuanX <[email protected]>; Ding, Xuan <[email protected]>; Wang,

YuanX

Quoted 18 lines

<[email protected]>
Subject: [RFC,v2 1/3] ethdev: introduce protocol type based header split

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configure buffer split based on length and offset is not suitable for NICs that do split based on header protocol types. And tunneling makes the conversion from offset to protocol impossible.

Quoted 5 lines

This patch extends the current buffer split to support protocol based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets

into two separate regions.

Quoted 1 line

Currently, both inner and outer L2/L3/L4 level header split can be

supported.

Quoted 35 lines

For example, let's suppose we configured the Rx queue with the following
segments:
seg0 - pool0
seg1 - pool1

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - pool0, udp_header
seg1 - pool1, payload

The memory attributes for the split parts may differ either - for example the
mempool0 and mempool1 belong to dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 24 +++++++++++++----------
lib/ethdev/rte_ethdev.h | 43
+++++++++++++++++++++++++++++++++++++++--
 2 files changed, 55 insertions(+), 12 deletions(-)
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

70c850a2f1..49c8fef1c3 100644

lib/ethdev/rte_ethdev.c +0 -0
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg, struct rte_mempool *mpl = rx_seg[seg_idx].mp; uint32_t length = rx_seg[seg_idx].length; uint32_t offset = rx_seg[seg_idx].offset;
+uint16_t proto = rx_seg[seg_idx].proto;

Quoted 2 lines

if (mpl == NULL) {
RTE_ETHDEV_LOG(ERR, "null mempool pointer\n"); @@ -1692,15

+1693,17

Quoted 20 lines

@@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, (struct rte_pktmbuf_pool_private)); return -ENOSPC; } -offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM; -*mbp_buf_size = rte_pktmbuf_data_room_size(mpl); -length = length != 0 ? length :
*mbp_buf_size; -if (*mbp_buf_size < length + offset) {

lib/ethdev/rte_ethdev.c +0 -2
-RTE_ETHDEV_LOG(ERR,
-       "%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c +2 -3
-       mpl->name, *mbp_buf_size,
-       length + offset, length, offset);
-return -EINVAL;
+if (proto == 0) {
+offset += seg_idx != 0 ? 0 :

RTE_PKTMBUF_HEADROOM;
+*mbp_buf_size =
rte_pktmbuf_data_room_size(mpl);

lib/ethdev/rte_ethdev.c +3 -0
+length = length != 0 ? length : *mbp_buf_size; if (*mbp_buf_size <
+length + offset) { RTE_ETHDEV_LOG(ERR, "%s mbuf_data_room_size %u <
+%u

(segment length=%u + segment offset=%u)\n",

Quoted 8 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1707

Quoted 5 lines
lib/ethdev/rte_ethdev.c +4 -0
+mpl->name, *mbp_buf_size,
+length + offset, length, offset);
+return -EINVAL;
+}
 }

As the length and proto is exclusive, it better also check the length when proto!=0

Thanks for your comments, will fix it in next version.

Quoted 20 lines

.....

Quoted 17 lines
lib/ethdev/rte_ethdev.c +13 -0
@@ -1197,12 +1197,26 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *
+ * Header split is a subset of buffer split. The split happens after
+ the
+ * packet header and before the packet payload. For PMDs that do not
+ * support header split configuration by length and offset, the
+ location
+ * of the split needs to be specified by the header protocol type.
+ While for
+ * buffer split, this field should not be configured.
+ *
+ * If RTE_ETH_RX_OFFLOAD_HEADER_SPLIT flag is set in offloads field,
+ * the PMD will split the received packets into two separate regions:
+ * - The header buffer will be allocated from the memory pool,
Quoted 8 lines

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1215

Quoted 3 lines
lib/ethdev/rte_ethdev.c +3 -0
+ *   specified in the first array element, the second buffer, from the
+ *   pool in the second element.
+ * - The length and offset do not need to be configured in header split.

We may not necessarily ignore the offset configure for header split as there is no confliction, a driver still can support copying a split header to a specific mbuf offset And if we support offset with header split, offset boundary check can also be considered in rte_eth_rx_queue_check_split

You are right. Only length and proto is exclusive in between buffer split and header split. Will update in next version.

Thanks,
Xuan

Quoted 5 lines

Regards
Qi

#11 lore raw

RFC v2 2/3 app/testpmd: add header split configuration

In reply to [email protected]

From: Xuan Ding <[email protected]>

This patch adds header split configuration in testpmd. The header split feature is off by default. To enable header split, you need:
1. Configure Rx queue with rx_offload header split on.
2. Set the protocol type of header split.

Command for set header split protocol type:
testpmd> port config <port_id> header_split mac|ipv4|ipv6|l3|tcp|udp|sctp|

		    l4|inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|
		    inner_udp|inner_sctp|inner_l4
---
 app/test-pmd/cmdline.c | 117 +++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c |   6 ++-
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 124 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +117 -0
index b4ba8da2b0..73257ddb38 100644
@@ -866,6 +866,12 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"     Enable or disable a per port Rx offloading"
 			" on all Rx queues of a port\n\n"
 
+			"port config <port_id> header_split mac|ipv4|ipv6|l3|tcp|udp|sctp|l4|"
+			"inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|"
+			"inner_udp|inner_sctp|inner_l4\n"
+			"     Configure protocol for header split"
+			" on all Rx queues of a port\n\n"
+
 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
 			"outer_ipv4_cksum|macsec_strip|header_split|"
@@ -16352,6 +16358,116 @@ cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
 	}
 };
 
+/* config a per port header split protocol */
+struct cmd_config_per_port_headersplit_protocol_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t config;
+	uint16_t port_id;
+	cmdline_fixed_string_t headersplit;
+	cmdline_fixed_string_t protocol;
+};
+
+cmdline_parse_token_string_t cmd_config_per_port_headersplit_protocol_result_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 port, "port");
+cmdline_parse_token_string_t cmd_config_per_port_headersplit_protocol_result_config =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 config, "config");
+cmdline_parse_token_num_t cmd_config_per_port_headersplit_protocol_result_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 port_id, RTE_UINT16);
+cmdline_parse_token_string_t cmd_config_per_port_headersplit_protocol_result_headersplit =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 headersplit, "header_split");
+cmdline_parse_token_string_t cmd_config_per_port_headersplit_protocol_result_protocol =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 protocol, "mac#ipv4#ipv6#l3#tcp#udp#sctp#l4#"
+			   "inner_mac#inner_ipv4#inner_ipv6#inner_l3#inner_tcp#"
+			   "inner_udp#inner_sctp#inner_l4");
+
+static void
+cmd_config_per_port_headersplit_protocol_parsed(void *parsed_result,
+				__rte_unused struct cmdline *cl,
+				__rte_unused void *data)
+{
+	struct cmd_config_per_port_headersplit_protocol_result *res = parsed_result;
+	portid_t port_id = res->port_id;
+	struct rte_port *port = &ports[port_id];
+	uint16_t protocol;
+
+	if (port_id_is_invalid(port_id, ENABLED_WARN))
+		return;
+
+	if (port->port_status != RTE_PORT_STOPPED) {
+		fprintf(stderr,
+			"Error: Can't config offload when Port %d is not stopped\n",
+			port_id);
+		return;
+	}
+
+	if (!strcmp(res->protocol, "mac"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_MAC;
+	else if (!strcmp(res->protocol, "ipv4"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_IPV4;
+	else if (!strcmp(res->protocol, "ipv6"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_IPV6;
+	else if (!strcmp(res->protocol, "l3"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_L3;
+	else if (!strcmp(res->protocol, "tcp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_TCP;
+	else if (!strcmp(res->protocol, "udp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_UDP;
+	else if (!strcmp(res->protocol, "sctp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_SCTP;
+	else if (!strcmp(res->protocol, "l4"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_L4;
+	else if (!strcmp(res->protocol, "inner_mac"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_MAC;
+	else if (!strcmp(res->protocol, "inner_ipv4"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_IPV4;
+	else if (!strcmp(res->protocol, "inner_ipv6"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_IPV6;
+	else if (!strcmp(res->protocol, "inner_l3"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_L3;
+	else if (!strcmp(res->protocol, "inner_tcp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_TCP;
+	else if (!strcmp(res->protocol, "inner_udp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_UDP;
+	else if (!strcmp(res->protocol, "inner_sctp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_SCTP;
+	else if (!strcmp(res->protocol, "inner_l4"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_L4;
+	else {
+		fprintf(stderr, "Unknown protocol name: %s\n", res->protocol);
+		return;
+	}
+
+	rx_pkt_header_split_proto = protocol;
+
+	cmd_reconfig_device_queue(port_id, 1, 1);
+}
+
+cmdline_parse_inst_t cmd_config_per_port_headersplit_protocol = {
+	.f = cmd_config_per_port_headersplit_protocol_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> header_split mac|ipv4|ipv6|l3|tcp|udp|sctp|l4|"
+		    "inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|"
+		    "inner_udp|inner_sctp|inner_l4",
+	.tokens = {
+		(void *)&cmd_config_per_port_headersplit_protocol_result_port,
+		(void *)&cmd_config_per_port_headersplit_protocol_result_config,
+		(void *)&cmd_config_per_port_headersplit_protocol_result_port_id,
+		(void *)&cmd_config_per_port_headersplit_protocol_result_headersplit,
+		(void *)&cmd_config_per_port_headersplit_protocol_result_protocol,
+		NULL,
+	}
+};
+
 /* Enable/Disable a per queue offloading */
 struct cmd_config_per_queue_rx_offload_result {
 	cmdline_fixed_string_t port;
@@ -18070,6 +18186,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
+	(cmdline_parse_inst_t *)&cmd_config_per_port_headersplit_protocol,
 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
app/test-pmd/testpmd.c +5 -1
index 6d2e52c790..4aba8e4ac4 100644
@@ -253,6 +253,8 @@ uint8_t  tx_pkt_nb_segs = 1; /**< Number of segments in TXONLY packets */
 enum tx_pkt_split tx_pkt_split = TX_PKT_SPLIT_OFF;
 /**< Split policy for packets to TX. */
 
+uint8_t rx_pkt_header_split_proto;
+
 uint8_t txonly_multi_flow;
 /**< Whether multiple flows are generated in TXONLY mode. */
 
@@ -2568,7 +2570,8 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 	int ret;
 
 	if (rx_pkt_nb_segs <= 1 ||
-	    (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) == 0) {
+	    (((rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) == 0) &&
+	     ((rx_conf->offloads & RTE_ETH_RX_OFFLOAD_HEADER_SPLIT) == 0))) {
 		rx_conf->rx_seg = NULL;
 		rx_conf->rx_nseg = 0;
 		ret = rte_eth_rx_queue_setup(port_id, rx_queue_id,
@@ -2592,6 +2595,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		rx_seg->offset = i < rx_pkt_nb_offs ?
 				   rx_pkt_seg_offsets[i] : 0;
 		rx_seg->mp = mpx ? mpx : mp;
+		rx_seg->proto = rx_pkt_header_split_proto;
 	}
 	rx_conf->rx_nseg = rx_pkt_nb_segs;
 	rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +2 -0
index 9967825044..a9681372a4 100644
@@ -531,6 +531,8 @@ enum tx_pkt_split {
 
 extern enum tx_pkt_split tx_pkt_split;
 
+extern uint8_t rx_pkt_header_split_proto;
+
 extern uint8_t txonly_multi_flow;
 
 extern uint32_t rxq_share;
Signature · 1 line
2.17.1
#12 lore raw

RFC v2 3/3 net/ice: support header split in Rx data path

In reply to [email protected]

From: Xuan Ding <[email protected]>

This patch adds support for header split in normal Rx data paths. When the Rx queue is configured with header split for specific protocol type, packets received will be directly splited into header and payload parts. And the two parts will be put into different mempools.

Currently, header split is not supported in vectorized paths.

---
 drivers/net/ice/ice_ethdev.c          |  10 +-
 drivers/net/ice/ice_rxtx.c            | 220 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 4 files changed, 218 insertions(+), 31 deletions(-)
drivers/net/ice/ice_ethdev.c +8 -2
index 1a469afeac..c9762d810d 100644
@@ -3707,7 +3707,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 			RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 			RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |
 			RTE_ETH_RX_OFFLOAD_RSS_HASH |
-			RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+			RTE_ETH_RX_OFFLOAD_TIMESTAMP |
+			RTE_ETH_RX_OFFLOAD_HEADER_SPLIT;
 		dev_info->tx_offload_capa |=
 			RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
 			RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -3719,7 +3720,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->flow_type_rss_offloads |= ICE_RSS_OFFLOAD_ALL;
 	}
 
-	dev_info->rx_queue_offload_capa = 0;
+	dev_info->rx_queue_offload_capa = RTE_ETH_RX_OFFLOAD_HEADER_SPLIT;
 	dev_info->tx_queue_offload_capa = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->reta_size = pf->hash_lut_size;
@@ -3788,6 +3789,11 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->default_rxportconf.ring_size = ICE_BUF_SIZE_MIN;
 	dev_info->default_txportconf.ring_size = ICE_BUF_SIZE_MIN;
 
+	dev_info->rx_seg_capa.max_nseg = ICE_RX_MAX_NSEG;
+	dev_info->rx_seg_capa.multi_pools = 1;
+	dev_info->rx_seg_capa.offset_allowed = 0;
+	dev_info->rx_seg_capa.offset_align_log2 = 0;
+
 	return 0;
 }
 
drivers/net/ice/ice_rxtx.c +191 -29

356 lines not on this page · raw message

drivers/net/ice/ice_rxtx.h +16 -0
index bb18a01951..611dbc8503 100644
@@ -16,6 +16,9 @@
 #define ICE_RX_MAX_BURST 32
 #define ICE_TX_MAX_BURST 32
 
+/* Maximal number of segments to split. */
+#define ICE_RX_MAX_NSEG 2
+
 #define ICE_CHK_Q_ENA_COUNT        100
 #define ICE_CHK_Q_ENA_INTERVAL_US  100
 
@@ -43,6 +46,11 @@
 extern uint64_t ice_timestamp_dynflag;
 extern int ice_timestamp_dynfield_offset;
 
+/* Max header size can be 2K - 64 bytes */
+#define ICE_RX_HDR_BUF_SIZE    (2048 - 64)
+
+#define ICE_HEADER_SPLIT_ENA   BIT(0)
+
 typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);
 typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq);
 typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {
 	struct rte_mbuf *mbuf;
 };
 
+enum ice_rx_dtype {
+	ICE_RX_DTYPE_NO_SPLIT       = 0,
+	ICE_RX_DTYPE_HEADER_SPLIT   = 1,
+	ICE_RX_DTYPE_SPLIT_ALWAYS   = 2,
+};
+
 struct ice_rx_queue {
 	struct rte_mempool *mp; /* mbuf pool to populate RX ring */
 	volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -95,6 +109,8 @@ struct ice_rx_queue {
 	uint32_t time_high;
 	uint32_t hw_register_set;
 	const struct rte_memzone *mz;
+	struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG];
+	uint32_t rxseg_nb;
 };
 
 struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
index 8ff01046e1..db394ceca8 100644
@@ -290,6 +290,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)
 	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
 		return -1;
 
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_HEADER_SPLIT)
+		return -1;
+
 	if (rxq->offloads & ICE_RX_VECTOR_OFFLOAD)
 		return ICE_VECTOR_OFFLOAD_PATH;
 
Signature · 1 line
2.17.1
#13 lore raw

v3 cover ethdev: introduce protocol type based header split

In reply to [email protected]

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. It is useful in some scenarios, such as GPU acceleration. The spliting will help to enable true zero copy and hence improve the performance significantly.

This patchset extends the current buffer split to support protocol based header split. When Rx queue is configured with header split feature, packets received will be directly splited into two different mempools.

rfc v2->v3:
* Fix a PMD bug.
* Add rx queue header split check.
* Revise the log and doc.

rfc v1->v2:
* Add support for all header split protocol types.

Xuan Ding (3):
ethdev: introduce protocol type based header split app/testpmd: add header split configuration net/ice: support header split in Rx data path

 app/test-pmd/cmdline.c                | 117 ++++++++++++++
 app/test-pmd/testpmd.c                |   6 +-
 app/test-pmd/testpmd.h                |   2 +
 drivers/net/ice/ice_ethdev.c          |  10 +-
 drivers/net/ice/ice_rxtx.c            | 223 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 lib/ethdev/rte_ethdev.c               |  34 +++-
 lib/ethdev/rte_ethdev.h               |  48 +++++-
 9 files changed, 417 insertions(+), 42 deletions(-)
Signature · 1 line
2.17.1
#14 lore raw

RFC v3 1/3 ethdev: introduce protocol type based header split

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header protocol types. Because tunneling makes the conversion from length to protocol type impossible.

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, off0=2B
    seg1 - pool1, off1=128B

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - payload @ 128 in mbuf from pool1

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 34 ++++++++++++++++++++++-------
 lib/ethdev/rte_ethdev.h | 48 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 72 insertions(+), 10 deletions(-)
lib/ethdev/rte_ethdev.c +26 -8
index 29a3d80466..144a43588c 100644
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint16_t proto = rx_seg[seg_idx].proto;
 
 		if (mpl == NULL) {
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1694,13 +1695,29 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		}
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto == 0) {
+			/* Check buffer split. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Check header split. */
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length should be set to zero in header split\n");
+				return -EINVAL;
+			}
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u segment offset)\n",
+					mpl->name, *mbp_buf_size,
+					offset);
+				return -EINVAL;
+			}
 		}
 	}
 	return 0;
@@ -1778,7 +1795,8 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		rx_seg = (const struct rte_eth_rxseg_split *)rx_conf->rx_seg;
 		n_seg = rx_conf->rx_nseg;
 
-		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
+		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ||
+			rx_conf->offloads & RTE_ETH_RX_OFFLOAD_HEADER_SPLIT) {
 			ret = rte_eth_rx_queue_check_split(rx_seg, n_seg,
 							   &mbp_buf_size,
 							   &dev_info);
lib/ethdev/rte_ethdev.h +46 -2

71 lines not on this page · raw message

Signature · 1 line
2.17.1
Reviewed-by on v3 1/3
#15 lore raw
Quoted 75 lines

-----Original Message-----
From: Ding, Xuan <[email protected]>
Sent: Tuesday, March 29, 2022 2:50 PM
To: [email protected]; Yigit, Ferruh <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Zhang, Qi Z <[email protected]>; Yu, Ping <[email protected]>; Wu, WenxuanX <[email protected]>; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>
Subject: [RFC,v3 1/3] ethdev: introduce protocol type based header split

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header protocol types. Because tunneling makes the conversion from length to protocol type impossible.

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, off0=2B
    seg1 - pool1, off1=128B

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - payload @ 128 in mbuf from pool1

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 34 ++++++++++++++++++++++-------
lib/ethdev/rte_ethdev.h | 48
+++++++++++++++++++++++++++++++++++++++--
 2 files changed, 72 insertions(+), 10 deletions(-)
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

29a3d80466..144a43588c 100644

lib/ethdev/rte_ethdev.c +1 -0
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct
 rte_eth_rxseg_split *rx_seg,
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint16_t proto = rx_seg[seg_idx].proto;
 
 		if (mpl == NULL) {
lib/ethdev/rte_ethdev.c +0 -0
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1694,13 +1695,29 @@ rte_eth_rx_queue_check_split(const struct
 rte_eth_rxseg_split *rx_seg,
 		}
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct · line 1700

Quoted 10 lines
lib/ethdev/rte_ethdev.c +1 -7
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u
 (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto == 0) {

use RTE_ETH_RX_HEADER_SPLIT_NONE looks better?

author
#16 lore raw

Hi Qi,

Quoted 87 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Tuesday, March 29, 2022 3:56 PM
To: Ding, Xuan <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Yu, Ping <[email protected]>; Wu, WenxuanX <[email protected]>; Wang, YuanX <[email protected]>
Subject: RE: [RFC,v3 1/3] ethdev: introduce protocol type based header split

Quoted 9 lines

-----Original Message-----
From: Ding, Xuan <[email protected]>
Sent: Tuesday, March 29, 2022 2:50 PM
To: [email protected]; Yigit, Ferruh <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Zhang, Qi Z <[email protected]>; Yu, Ping <[email protected]>; Wu, WenxuanX <[email protected]>; Ding, Xuan <[email protected]>; Wang,

YuanX

Quoted 12 lines

<[email protected]>
Subject: [RFC,v3 1/3] ethdev: introduce protocol type based header split

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Quoted 3 lines

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header

protocol types.

Quoted 45 lines

Because tunneling makes the conversion from length to protocol type impossible.

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

For example, let's suppose we configured the Rx queue with the following
segments:

    seg0 - pool0, off0=2B
    seg1 - pool1, off1=128B

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - payload @ 128 in mbuf from pool1

The memory attributes for the split parts may differ either - for example the
mempool0 and mempool1 belong to dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 34 ++++++++++++++++++++++-------
lib/ethdev/rte_ethdev.h | 48
+++++++++++++++++++++++++++++++++++++++--
 2 files changed, 72 insertions(+), 10 deletions(-)
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

29a3d80466..144a43588c 100644

lib/ethdev/rte_ethdev.c +0 -0
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg, struct rte_mempool *mpl = rx_seg[seg_idx].mp; uint32_t length = rx_seg[seg_idx].length; uint32_t offset = rx_seg[seg_idx].offset;
+uint16_t proto = rx_seg[seg_idx].proto;

Quoted 2 lines

if (mpl == NULL) {
RTE_ETHDEV_LOG(ERR, "null mempool pointer\n"); @@ -1694,13

+1695,29

Quoted 13 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1698

Quoted 11 lines

@@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, } offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM; *mbp_buf_size = rte_pktmbuf_data_room_size(mpl); -length = length != 0 ? length : *mbp_buf_size; -if (*mbp_buf_size < length + offset) {

lib/ethdev/rte_ethdev.c +0 -2
-RTE_ETHDEV_LOG(ERR,
-       "%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c +1 -3
-       mpl->name, *mbp_buf_size,
-       length + offset, length, offset);
-return -EINVAL;
+if (proto == 0) {

use RTE_ETH_RX_HEADER_SPLIT_NONE looks better?

Yes, it is better to use RTE_ETH_RX_HEADER_SPLIT_NONE here. Will fix it in next version.

Thanks,
Xuan

Quoted 5 lines
#17 lore raw

RFC v3 2/3 app/testpmd: add header split configuration

In reply to [email protected]

From: Xuan Ding <[email protected]>

This patch adds header split configuration in testpmd. The header split feature is off by default. To enable header split, you need:
1. Configure Rx queue with rx_offload header split on.
2. Set the protocol type of header split.

Command for set header split protocol type:
testpmd> port config <port_id> header_split mac|ipv4|ipv6|l3|tcp|udp|sctp|

		    l4|inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|
		    inner_udp|inner_sctp|inner_l4
---
 app/test-pmd/cmdline.c | 117 +++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c |   6 ++-
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 124 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +117 -0
index 6ffea8e21a..abda81b4bc 100644
@@ -866,6 +866,12 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"     Enable or disable a per port Rx offloading"
 			" on all Rx queues of a port\n\n"
 
+			"port config <port_id> header_split mac|ipv4|ipv6|l3|tcp|udp|sctp|l4|"
+			"inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|"
+			"inner_udp|inner_sctp|inner_l4\n"
+			"     Configure protocol for header split"
+			" on all Rx queues of a port\n\n"
+
 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
 			"outer_ipv4_cksum|macsec_strip|header_split|"
@@ -16353,6 +16359,116 @@ cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
 	}
 };
 
+/* config a per port header split protocol */
+struct cmd_config_per_port_headersplit_protocol_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t config;
+	uint16_t port_id;
+	cmdline_fixed_string_t headersplit;
+	cmdline_fixed_string_t protocol;
+};
+
+cmdline_parse_token_string_t cmd_config_per_port_headersplit_protocol_result_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 port, "port");
+cmdline_parse_token_string_t cmd_config_per_port_headersplit_protocol_result_config =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 config, "config");
+cmdline_parse_token_num_t cmd_config_per_port_headersplit_protocol_result_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 port_id, RTE_UINT16);
+cmdline_parse_token_string_t cmd_config_per_port_headersplit_protocol_result_headersplit =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 headersplit, "header_split");
+cmdline_parse_token_string_t cmd_config_per_port_headersplit_protocol_result_protocol =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 protocol, "mac#ipv4#ipv6#l3#tcp#udp#sctp#l4#"
+			   "inner_mac#inner_ipv4#inner_ipv6#inner_l3#inner_tcp#"
+			   "inner_udp#inner_sctp#inner_l4");
+
+static void
+cmd_config_per_port_headersplit_protocol_parsed(void *parsed_result,
+				__rte_unused struct cmdline *cl,
+				__rte_unused void *data)
+{
+	struct cmd_config_per_port_headersplit_protocol_result *res = parsed_result;
+	portid_t port_id = res->port_id;
+	struct rte_port *port = &ports[port_id];
+	uint16_t protocol;
+
+	if (port_id_is_invalid(port_id, ENABLED_WARN))
+		return;
+
+	if (port->port_status != RTE_PORT_STOPPED) {
+		fprintf(stderr,
+			"Error: Can't config offload when Port %d is not stopped\n",
+			port_id);
+		return;
+	}
+
+	if (!strcmp(res->protocol, "mac"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_MAC;
+	else if (!strcmp(res->protocol, "ipv4"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_IPV4;
+	else if (!strcmp(res->protocol, "ipv6"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_IPV6;
+	else if (!strcmp(res->protocol, "l3"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_L3;
+	else if (!strcmp(res->protocol, "tcp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_TCP;
+	else if (!strcmp(res->protocol, "udp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_UDP;
+	else if (!strcmp(res->protocol, "sctp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_SCTP;
+	else if (!strcmp(res->protocol, "l4"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_L4;
+	else if (!strcmp(res->protocol, "inner_mac"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_MAC;
+	else if (!strcmp(res->protocol, "inner_ipv4"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_IPV4;
+	else if (!strcmp(res->protocol, "inner_ipv6"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_IPV6;
+	else if (!strcmp(res->protocol, "inner_l3"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_L3;
+	else if (!strcmp(res->protocol, "inner_tcp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_TCP;
+	else if (!strcmp(res->protocol, "inner_udp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_UDP;
+	else if (!strcmp(res->protocol, "inner_sctp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_SCTP;
+	else if (!strcmp(res->protocol, "inner_l4"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_L4;
+	else {
+		fprintf(stderr, "Unknown protocol name: %s\n", res->protocol);
+		return;
+	}
+
+	rx_pkt_header_split_proto = protocol;
+
+	cmd_reconfig_device_queue(port_id, 1, 1);
+}
+
+cmdline_parse_inst_t cmd_config_per_port_headersplit_protocol = {
+	.f = cmd_config_per_port_headersplit_protocol_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> header_split mac|ipv4|ipv6|l3|tcp|udp|sctp|l4|"
+		    "inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|"
+		    "inner_udp|inner_sctp|inner_l4",
+	.tokens = {
+		(void *)&cmd_config_per_port_headersplit_protocol_result_port,
+		(void *)&cmd_config_per_port_headersplit_protocol_result_config,
+		(void *)&cmd_config_per_port_headersplit_protocol_result_port_id,
+		(void *)&cmd_config_per_port_headersplit_protocol_result_headersplit,
+		(void *)&cmd_config_per_port_headersplit_protocol_result_protocol,
+		NULL,
+	}
+};
+
 /* Enable/Disable a per queue offloading */
 struct cmd_config_per_queue_rx_offload_result {
 	cmdline_fixed_string_t port;
@@ -18071,6 +18187,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
+	(cmdline_parse_inst_t *)&cmd_config_per_port_headersplit_protocol,
 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
app/test-pmd/testpmd.c +5 -1
index fe2ce19f99..a00fa0e236 100644
@@ -253,6 +253,8 @@ uint8_t  tx_pkt_nb_segs = 1; /**< Number of segments in TXONLY packets */
 enum tx_pkt_split tx_pkt_split = TX_PKT_SPLIT_OFF;
 /**< Split policy for packets to TX. */
 
+uint8_t rx_pkt_header_split_proto;
+
 uint8_t txonly_multi_flow;
 /**< Whether multiple flows are generated in TXONLY mode. */
 
@@ -2568,7 +2570,8 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 	int ret;
 
 	if (rx_pkt_nb_segs <= 1 ||
-	    (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) == 0) {
+	    (((rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) == 0) &&
+	     ((rx_conf->offloads & RTE_ETH_RX_OFFLOAD_HEADER_SPLIT) == 0))) {
 		rx_conf->rx_seg = NULL;
 		rx_conf->rx_nseg = 0;
 		ret = rte_eth_rx_queue_setup(port_id, rx_queue_id,
@@ -2592,6 +2595,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		rx_seg->offset = i < rx_pkt_nb_offs ?
 				   rx_pkt_seg_offsets[i] : 0;
 		rx_seg->mp = mpx ? mpx : mp;
+		rx_seg->proto = rx_pkt_header_split_proto;
 	}
 	rx_conf->rx_nseg = rx_pkt_nb_segs;
 	rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +2 -0
index 31f766c965..021e2768be 100644
@@ -557,6 +557,8 @@ enum tx_pkt_split {
 
 extern enum tx_pkt_split tx_pkt_split;
 
+extern uint8_t rx_pkt_header_split_proto;
+
 extern uint8_t txonly_multi_flow;
 
 extern uint32_t rxq_share;
Signature · 1 line
2.17.1
#18 lore raw

RFC v3 3/3 net/ice: support header split in Rx data path

In reply to [email protected]

From: Xuan Ding <[email protected]>

This patch adds support for header split in normal Rx data paths. When the Rx queue is configured with header split for specific protocol type, packets received will be directly splited into header and payload parts. And the two parts will be put into different mempools.

Currently, header split is not supported in vectorized paths.

---
 drivers/net/ice/ice_ethdev.c          |  10 +-
 drivers/net/ice/ice_rxtx.c            | 223 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 4 files changed, 221 insertions(+), 31 deletions(-)
drivers/net/ice/ice_ethdev.c +8 -2
index 13adcf90ed..cb32265dbe 100644
@@ -3713,7 +3713,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 			RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 			RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |
 			RTE_ETH_RX_OFFLOAD_RSS_HASH |
-			RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+			RTE_ETH_RX_OFFLOAD_TIMESTAMP |
+			RTE_ETH_RX_OFFLOAD_HEADER_SPLIT;
 		dev_info->tx_offload_capa |=
 			RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
 			RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -3725,7 +3726,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->flow_type_rss_offloads |= ICE_RSS_OFFLOAD_ALL;
 	}
 
-	dev_info->rx_queue_offload_capa = 0;
+	dev_info->rx_queue_offload_capa = RTE_ETH_RX_OFFLOAD_HEADER_SPLIT;
 	dev_info->tx_queue_offload_capa = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->reta_size = pf->hash_lut_size;
@@ -3794,6 +3795,11 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->default_rxportconf.ring_size = ICE_BUF_SIZE_MIN;
 	dev_info->default_txportconf.ring_size = ICE_BUF_SIZE_MIN;
 
+	dev_info->rx_seg_capa.max_nseg = ICE_RX_MAX_NSEG;
+	dev_info->rx_seg_capa.multi_pools = 1;
+	dev_info->rx_seg_capa.offset_allowed = 0;
+	dev_info->rx_seg_capa.offset_align_log2 = 0;
+
 	return 0;
 }
 
drivers/net/ice/ice_rxtx.c +194 -29

359 lines not on this page · raw message

drivers/net/ice/ice_rxtx.h +16 -0
index bb18a01951..611dbc8503 100644
@@ -16,6 +16,9 @@
 #define ICE_RX_MAX_BURST 32
 #define ICE_TX_MAX_BURST 32
 
+/* Maximal number of segments to split. */
+#define ICE_RX_MAX_NSEG 2
+
 #define ICE_CHK_Q_ENA_COUNT        100
 #define ICE_CHK_Q_ENA_INTERVAL_US  100
 
@@ -43,6 +46,11 @@
 extern uint64_t ice_timestamp_dynflag;
 extern int ice_timestamp_dynfield_offset;
 
+/* Max header size can be 2K - 64 bytes */
+#define ICE_RX_HDR_BUF_SIZE    (2048 - 64)
+
+#define ICE_HEADER_SPLIT_ENA   BIT(0)
+
 typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);
 typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq);
 typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {
 	struct rte_mbuf *mbuf;
 };
 
+enum ice_rx_dtype {
+	ICE_RX_DTYPE_NO_SPLIT       = 0,
+	ICE_RX_DTYPE_HEADER_SPLIT   = 1,
+	ICE_RX_DTYPE_SPLIT_ALWAYS   = 2,
+};
+
 struct ice_rx_queue {
 	struct rte_mempool *mp; /* mbuf pool to populate RX ring */
 	volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -95,6 +109,8 @@ struct ice_rx_queue {
 	uint32_t time_high;
 	uint32_t hw_register_set;
 	const struct rte_memzone *mz;
+	struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG];
+	uint32_t rxseg_nb;
 };
 
 struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
index 2dd2d83650..7a155a66f2 100644
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)
 	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
 		return -1;
 
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_HEADER_SPLIT)
+		return -1;
+
 	if (rxq->offloads & ICE_RX_VECTOR_OFFLOAD)
 		return ICE_VECTOR_OFFLOAD_PATH;
 
Signature · 1 line
2.17.1
#19 lore raw

v4 cover ethdev: introduce protocol type based header split

In reply to [email protected]

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.

This patchset extends the current buffer split to support protocol based header split. When Rx queue is configured with header split feature, packets received will be directly splitted into two different mempools.

v3->v4:
* Use RTE_ETH_RX_HEADER_SPLIT_NONE instead of 0.

v2->v3:
* Fix a PMD bug.
* Add rx queue header split check.
* Revise the log and doc.

v1->v2:
* Add support for all header split protocol types.

Xuan Ding (3):
ethdev: introduce protocol type based header split app/testpmd: add header split configuration net/ice: support header split in Rx data path

 app/test-pmd/cmdline.c                | 117 ++++++++++++++
 app/test-pmd/testpmd.c                |   6 +-
 app/test-pmd/testpmd.h                |   2 +
 drivers/net/ice/ice_ethdev.c          |  10 +-
 drivers/net/ice/ice_rxtx.c            | 223 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 lib/ethdev/rte_ethdev.c               |  34 +++-
 lib/ethdev/rte_ethdev.h               |  48 +++++-
 9 files changed, 417 insertions(+), 42 deletions(-)
Signature · 1 line
2.17.1
#20 lore raw

PATCH v4 1/3 ethdev: introduce protocol type based header split

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header protocol types. Because tunneling makes the conversion from length to protocol type impossible.

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, off0=2B
    seg1 - pool1, off1=128B

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - payload @ 128 in mbuf from pool1

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 34 ++++++++++++++++++++++-------
 lib/ethdev/rte_ethdev.h | 48 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 72 insertions(+), 10 deletions(-)
lib/ethdev/rte_ethdev.c +26 -8
index 29a3d80466..29adcdc2f0 100644
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint16_t proto = rx_seg[seg_idx].proto;
 
 		if (mpl == NULL) {
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1694,13 +1695,29 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		}
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto == RTE_ETH_RX_HEADER_SPLIT_NONE) {
+			/* Check buffer split. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Check header split. */
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length should be set to zero in header split\n");
+				return -EINVAL;
+			}
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u segment offset)\n",
+					mpl->name, *mbp_buf_size,
+					offset);
+				return -EINVAL;
+			}
 		}
 	}
 	return 0;
@@ -1778,7 +1795,8 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		rx_seg = (const struct rte_eth_rxseg_split *)rx_conf->rx_seg;
 		n_seg = rx_conf->rx_nseg;
 
-		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
+		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ||
+			rx_conf->offloads & RTE_ETH_RX_OFFLOAD_HEADER_SPLIT) {
 			ret = rte_eth_rx_queue_check_split(rx_seg, n_seg,
 							   &mbp_buf_size,
 							   &dev_info);
lib/ethdev/rte_ethdev.h +46 -2

71 lines not on this page · raw message

Signature · 1 line
2.17.1
#21 lore raw
Quoted 14 lines · On 4/2/22 13:41, [email protected] wrote:

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header protocol types. Because tunneling makes the conversion from length to protocol type impossible.

Quoted 7 lines

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT offload was introduced some time ago to substitute bit-field header_split in struct rte_eth_rxmode. It allows to enable header split offload with the header size controlled using split_hdr_size in the same structure.

Right now I see no single PMD which actually supports RTE_ETH_RX_OFFLOAD_HEADER_SPLIT with above definition. Many examples and test apps initialize the field to 0 explicitly. The most of drivers simply ignore split_hdr_size since the offload is not advertised, but some double-check that its value is 0.

I think that it means that the field should be removed on the next LTS, and I'd say, together with the RTE_ETH_RX_OFFLOAD_HEADER_SPLIT offload bit.

We should not redefine the offload meaning.

Quoted 5 lines

For example, let's suppose we configured the Rx queue with the following segments:

     seg0 - pool0, off0=2B
     seg1 - pool1, off1=128B

Corresponding feature is named Rx buffer split. Does it mean that protocol type based header split requires Rx buffer split feature to be supported?

Quoted 5 lines

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - payload @ 128 in mbuf from pool1

Is it always outermost UDP? Does it require both UDP over IPv4 and UDP over IPv6 to be supported? What will happen if only one is supported? How application can find out which protocol stack are supported?

Quoted 96 lines

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and external memory, respectively.

---
  lib/ethdev/rte_ethdev.c | 34 ++++++++++++++++++++++-------
  lib/ethdev/rte_ethdev.h | 48 +++++++++++++++++++++++++++++++++++++++--
  2 files changed, 72 insertions(+), 10 deletions(-)
lib/ethdev/rte_ethdev.c +26 -8
index 29a3d80466..29adcdc2f0 100644
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
  		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
  		uint32_t length = rx_seg[seg_idx].length;
  		uint32_t offset = rx_seg[seg_idx].offset;
+		uint16_t proto = rx_seg[seg_idx].proto;
 
  		if (mpl == NULL) {
  			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1694,13 +1695,29 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
  		}
  		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
  		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto == RTE_ETH_RX_HEADER_SPLIT_NONE) {
+			/* Check buffer split. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Check header split. */
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length should be set to zero in header split\n");
+				return -EINVAL;
+			}
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u segment offset)\n",
+					mpl->name, *mbp_buf_size,
+					offset);
+				return -EINVAL;
+			}
  		}
  	}
  	return 0;
@@ -1778,7 +1795,8 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
  		rx_seg = (const struct rte_eth_rxseg_split *)rx_conf->rx_seg;
  		n_seg = rx_conf->rx_nseg;
 
-		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
+		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT ||
+			rx_conf->offloads & RTE_ETH_RX_OFFLOAD_HEADER_SPLIT) {
  			ret = rte_eth_rx_queue_check_split(rx_seg, n_seg,
  							   &mbp_buf_size,
  							   &dev_info);
lib/ethdev/rte_ethdev.h +15 -0
index 04cff8ee10..e8371b98ed 100644
@@ -1197,12 +1197,31 @@ struct rte_eth_txmode {
   *     - pool from the last valid element
   *     - the buffer size from this pool
   *     - zero offset
+ *
+ * Header split is a subset of buffer split. The split happens after the
+ * packet header and before the packet payload. For PMDs that do not
+ * support header split configuration by length, the location of the split
+ * needs to be specified by the header protocol type. While for buffer split,
+ * this field should not be configured.
+ *
+ * If RTE_ETH_RX_OFFLOAD_HEADER_SPLIT flag is set in offloads field,
+ * the PMD will split the received packets into two separate regions:
+ * - The header buffer will be allocated from the memory pool,
+ *   specified in the first array element, the second buffer, from the
+ *   pool in the second element.
+ *
+ * - The lengths do not need to be configured in header split.
+ *

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1223

Quoted 10 lines
lib/ethdev/rte_ethdev.h +4 -1
+ * - The offsets from the segment description elements specify
+ *   the data offset from the buffer beginning except the first mbuf.
+ *   The first segment offset is added with RTE_PKTMBUF_HEADROOM.
   */
  struct rte_eth_rxseg_split {
  	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
  	uint16_t length; /**< Segment data length, configures split point. */
  	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint16_t proto; /**< header protocol type, configures header split point. */

I realize that you don't want to use here enum defined above to save some reserved space, but description must refer to the enum rte_eth_rx_header_split_protocol_type.

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1224

Quoted 1 line
lib/ethdev/rte_ethdev.h +1 -0
+	uint16_t reserved; /**< Reserved field. */

As far as I can see the structure is experimental. So, it should not be the problem to extend it, but it is a really good question raised by Stephen in RFC v1 discussion. Shouldn't we require that all reserved fields are initialized to zero and ignored on processing? Frankly speaking I always thought so, but failed to find the place were it is documented.

@Thomas, @David, @Ferruh?

Quoted 29 lines
lib/ethdev/rte_ethdev.h +14 -1
  };
 
  /**
@@ -1212,7 +1231,7 @@ struct rte_eth_rxseg_split {
   * A common structure used to describe Rx packet segment properties.
   */
  union rte_eth_rxseg {
-	/* The settings for buffer split offload. */
+	/* The settings for buffer split and header split offload. */
  	struct rte_eth_rxseg_split split;
  	/* The other features settings should be added here. */
  };
@@ -1664,6 +1683,31 @@ struct rte_eth_conf {
  			     RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
  #define DEV_RX_OFFLOAD_VLAN RTE_DEPRECATED(DEV_RX_OFFLOAD_VLAN) RTE_ETH_RX_OFFLOAD_VLAN
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this enum may change without prior notice.
+ * This enum indicates the header split protocol type
+ */
+enum rte_eth_rx_header_split_protocol_type {
+	RTE_ETH_RX_HEADER_SPLIT_NONE = 0,
+	RTE_ETH_RX_HEADER_SPLIT_MAC,
+	RTE_ETH_RX_HEADER_SPLIT_IPV4,
+	RTE_ETH_RX_HEADER_SPLIT_IPV6,
+	RTE_ETH_RX_HEADER_SPLIT_L3,
+	RTE_ETH_RX_HEADER_SPLIT_TCP,
+	RTE_ETH_RX_HEADER_SPLIT_UDP,

lib/ethdev/rte_ethdev.h struct rte_eth_conf { · line 1708

Quoted 10 lines
lib/ethdev/rte_ethdev.h +10 -0
+	RTE_ETH_RX_HEADER_SPLIT_SCTP,
+	RTE_ETH_RX_HEADER_SPLIT_L4,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_MAC,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_IPV4,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_IPV6,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_L3,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_TCP,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_UDP,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_SCTP,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_L4,

Enumeration members should be documented. See my question in the patch description.

Quoted 5 lines
lib/ethdev/rte_ethdev.h +2 -0
+};
+
  /*
   * If new Rx offload capabilities are defined, they also must be
   * mentioned in rte_rx_offload_names in rte_ethdev.c file.
author
#22 lore raw

Hi Andrew,

Quoted 48 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, April 7, 2022 6:48 PM
To: Wu, WenxuanX <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Yu, Ping <[email protected]>; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; [email protected]; Ferruh Yigit <[email protected]>
Subject: Re: [v4 1/3] ethdev: introduce protocol type based header split

Quoted 14 lines · On 4/2/22 13:41, [email protected] wrote:

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header protocol types. Because tunneling makes the conversion from length to protocol type impossible.

Quoted 7 lines

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT offload was introduced some time ago to substitute bit-field header_split in struct rte_eth_rxmode. It allows to enable header split offload with the header size controlled using split_hdr_size in the same structure.

Right now I see no single PMD which actually supports RTE_ETH_RX_OFFLOAD_HEADER_SPLIT with above definition.
Many examples and test apps initialize the field to 0 explicitly. The most of drivers simply ignore split_hdr_size since the offload is not advertised, but some double-check that its value is 0.

Quoted 4 lines

I think that it means that the field should be removed on the next LTS, and I'd say, together with the RTE_ETH_RX_OFFLOAD_HEADER_SPLIT offload bit.

We should not redefine the offload meaning.

Yes, you are right. No single PMD supports RTE_ETH_RX_OFFLOAD_HEADER_SPLIT now. Previously, I used this flag is to distinguish buffer split and header split. The former supports multi-segments split by length and offset.
The later supports two segments split by proto and offset.
At this level, header split is a subset of buffer split.

Since we shouldn't redefine the meaning of this offload,
I will use the RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.
The existence of tunnel needs to define a proto field in buffer split, because some PMDs do not support split based on length and offset.

Quoted 16 lines
Quoted 16 lines
Quoted 8 lines
Quoted 4 lines

For example, let's suppose we configured the Rx queue with the following segments:

     seg0 - pool0, off0=2B
     seg1 - pool1, off1=128B

Corresponding feature is named Rx buffer split.
Does it mean that protocol type based header split requires Rx buffer split feature to be supported?

Protocol type based header split does not requires Rx buffer split. In previous design, the header split and buffer split are exclusive. Because we only configure one split offload for one RX queue.

Quoted 11 lines
Quoted 5 lines

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from

pool0

Quoted 1 line

seg1 - payload @ 128 in mbuf from pool1

Is it always outermost UDP? Does it require both UDP over IPv4 and UDP over IPv6 to be supported? What will happen if only one is supported? How application can find out which protocol stack are supported?

Both inner and outer UDP are considered.
Current design does not distinguish UDP over IPv4 or IPv6. If we want to support granularity like only IPv4 or IPv6 supported, user need add more configurations.

If application want to find out which protocol stack is supported,
one way I think is to expose the protocol stack supported by the driver through dev_info. Any thoughts are welcomed :)

Quoted 122 lines
Quoted 4 lines

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and

external

Quoted 9 lines

memory, respectively.

---
  lib/ethdev/rte_ethdev.c | 34 ++++++++++++++++++++++-------
  lib/ethdev/rte_ethdev.h | 48

+++++++++++++++++++++++++++++++++++++++--

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct

Quoted 7 lines
  2 files changed, 72 insertions(+), 10 deletions(-)
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

29a3d80466..29adcdc2f0 100644

lib/ethdev/rte_ethdev.c +0 -0
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1667

Quoted 7 lines
lib/ethdev/rte_ethdev.c +1 -0
  		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
  		uint32_t length = rx_seg[seg_idx].length;
  		uint32_t offset = rx_seg[seg_idx].offset;
+		uint16_t proto = rx_seg[seg_idx].proto;
 
  		if (mpl == NULL) {
  			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");

@@ -1694,13

Quoted 1 line

+1695,29 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
  		}
  		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
  		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
lib/ethdev/rte_ethdev.c +0 -4
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 9 lines
lib/ethdev/rte_ethdev.c +6 -3
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto == RTE_ETH_RX_HEADER_SPLIT_NONE) {
+			/* Check buffer split. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 8 lines
lib/ethdev/rte_ethdev.c +8 -0
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Check header split. */
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length

should be set to zero in header split\n");

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 5 lines
lib/ethdev/rte_ethdev.c +5 -0
+				return -EINVAL;
+			}
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u

segment offset)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id,

Quoted 8 lines
lib/ethdev/rte_ethdev.c +4 -0
+					mpl->name, *mbp_buf_size,
+					offset);
+				return -EINVAL;
+			}
  		}
  	}
  	return 0;
@@ -1778,7 +1795,8 @@ rte_eth_rx_queue_setup(uint16_t port_id,

uint16_t rx_queue_id,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,

Quoted 4 lines
lib/ethdev/rte_ethdev.c +0 -1
  		rx_seg = (const struct rte_eth_rxseg_split *)rx_conf->rx_seg;
  		n_seg = rx_conf->rx_nseg;
 
-		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)

{

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, · line 1798

Quoted 1 line
lib/ethdev/rte_ethdev.c +1 -0
+		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT

||

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, · line 1799

Quoted 1 line
lib/ethdev/rte_ethdev.c +1 -0
+			rx_conf->offloads &

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT) {

Quoted 25 lines
lib/ethdev/rte_ethdev.c +0 -0
  			ret = rte_eth_rx_queue_check_split(rx_seg, n_seg,
  							   &mbp_buf_size,
  							   &dev_info);
lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0 -0

04cff8ee10..e8371b98ed 100644

lib/ethdev/rte_ethdev.h +14 -0
@@ -1197,12 +1197,31 @@ struct rte_eth_txmode {
   *     - pool from the last valid element
   *     - the buffer size from this pool
   *     - zero offset
+ *
+ * Header split is a subset of buffer split. The split happens after
+ the
+ * packet header and before the packet payload. For PMDs that do not
+ * support header split configuration by length, the location of the
+ split
+ * needs to be specified by the header protocol type. While for
+ buffer split,
+ * this field should not be configured.
+ *
+ * If RTE_ETH_RX_OFFLOAD_HEADER_SPLIT flag is set in offloads field,
+ * the PMD will split the received packets into two separate regions:
+ * - The header buffer will be allocated from the memory pool,
+ *   specified in the first array element, the second buffer, from the

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1223

Quoted 10 lines
lib/ethdev/rte_ethdev.h +7 -0
+ *   pool in the second element.
+ *
+ * - The lengths do not need to be configured in header split.
+ *
+ * - The offsets from the segment description elements specify
+ *   the data offset from the buffer beginning except the first mbuf.
+ *   The first segment offset is added with RTE_PKTMBUF_HEADROOM.
   */
  struct rte_eth_rxseg_split {
  	struct rte_mempool *mp; /**< Memory pool to allocate segment

from. */

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1225

Quoted 2 lines
lib/ethdev/rte_ethdev.h +0 -0
  	uint16_t length; /**< Segment data length, configures split point. */
  	uint16_t offset; /**< Data offset from beginning of mbuf data buffer.
Quoted 8 lines

*/

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1227

Quoted 3 lines
lib/ethdev/rte_ethdev.h +2 -1
-	uint32_t reserved; /**< Reserved field. */
+	uint16_t proto; /**< header protocol type, configures header split
+point. */

I realize that you don't want to use here enum defined above to save some reserved space, but description must refer to the enum rte_eth_rx_header_split_protocol_type.

Thanks for your suggestion, will fix it in next version.

Quoted 9 lines

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1224

Quoted 2 lines
lib/ethdev/rte_ethdev.h +1 -0
+	uint16_t reserved; /**< Reserved field. */

As far as I can see the structure is experimental. So, it should not be the problem to extend it, but it is a really good question raised by Stephen in RFC v1 discussion.
Shouldn't we require that all reserved fields are initialized to zero and ignored on processing? Frankly speaking I always thought so, but failed to find the place were it is documented.

Yes, it can be documented. By default is should be zero, and we can configure it to enable protocol type based buffer split.

Quoted 38 lines

@Thomas, @David, @Ferruh?

Quoted 13 lines
  };

/**

lib/ethdev/rte_ethdev.h +1 -1
@@ -1212,7 +1231,7 @@ struct rte_eth_rxseg_split {
   * A common structure used to describe Rx packet segment properties.
   */
  union rte_eth_rxseg {
-	/* The settings for buffer split offload. */
+	/* The settings for buffer split and header split offload. */
  	struct rte_eth_rxseg_split split;
  	/* The other features settings should be added here. */
  };

lib/ethdev/rte_ethdev.h struct rte_eth_conf { · line 1684

Quoted 2 lines
lib/ethdev/rte_ethdev.h +0 -0
@@ -1664,6 +1683,31 @@ struct rte_eth_conf {
  			     RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
  #define DEV_RX_OFFLOAD_VLAN

RTE_DEPRECATED(DEV_RX_OFFLOAD_VLAN)

Quoted 19 lines

RTE_ETH_RX_OFFLOAD_VLAN

lib/ethdev/rte_ethdev.h +17 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this enum may change without prior notice.
+ * This enum indicates the header split protocol type  */ enum
+rte_eth_rx_header_split_protocol_type {
+	RTE_ETH_RX_HEADER_SPLIT_NONE = 0,
+	RTE_ETH_RX_HEADER_SPLIT_MAC,
+	RTE_ETH_RX_HEADER_SPLIT_IPV4,
+	RTE_ETH_RX_HEADER_SPLIT_IPV6,
+	RTE_ETH_RX_HEADER_SPLIT_L3,
+	RTE_ETH_RX_HEADER_SPLIT_TCP,
+	RTE_ETH_RX_HEADER_SPLIT_UDP,
+	RTE_ETH_RX_HEADER_SPLIT_SCTP,
+	RTE_ETH_RX_HEADER_SPLIT_L4,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_MAC,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_IPV4,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_IPV6,
Quoted 8 lines

lib/ethdev/rte_ethdev.h struct rte_eth_conf { · line 1708

Quoted 5 lines
lib/ethdev/rte_ethdev.h +5 -0
+	RTE_ETH_RX_HEADER_SPLIT_INNER_L3,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_TCP,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_UDP,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_SCTP,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_L4,

Enumeration members should be documented. See my question in the patch description.

Thanks for your detailed comments, questions are answered accordingly.

Best Regards,
Xuan

Quoted 6 lines
Quoted 6 lines
lib/ethdev/rte_ethdev.h +2 -0
+};
+
  /*
   * If new Rx offload capabilities are defined, they also must be
   * mentioned in rte_rx_offload_names in rte_ethdev.c file.
#23 lore raw

Hi Xuan,

Quoted 50 lines · Xuan

Hi Andrew,

Quoted 48 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, April 7, 2022 6:48 PM
To: Wu, WenxuanX <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Yu, Ping <[email protected]>; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; [email protected]; Ferruh Yigit <[email protected]>
Subject: Re: [v4 1/3] ethdev: introduce protocol type based header split

Quoted 14 lines · On 4/2/22 13:41, [email protected] wrote:

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header protocol types. Because tunneling makes the conversion from length to protocol type impossible.

Quoted 7 lines

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT offload was introduced some time ago to substitute bit-field header_split in struct rte_eth_rxmode. It allows to enable header split offload with the header size controlled using split_hdr_size in the same structure.

Right now I see no single PMD which actually supports RTE_ETH_RX_OFFLOAD_HEADER_SPLIT with above definition.
Many examples and test apps initialize the field to 0 explicitly. The most of drivers simply ignore split_hdr_size since the offload is not advertised, but some double-check that its value is 0.

Quoted 8 lines
Quoted 4 lines

I think that it means that the field should be removed on the next LTS, and I'd say, together with the RTE_ETH_RX_OFFLOAD_HEADER_SPLIT offload bit.

We should not redefine the offload meaning.

Yes, you are right. No single PMD supports RTE_ETH_RX_OFFLOAD_HEADER_SPLIT now. Previously, I used this flag is to distinguish buffer split and header split. The former supports multi-segments split by length and offset.

offset is misleading here, since split offset is derived from segment lengths. Offset specified in segments is a different thing.

Quoted 2 lines

The later supports two segments split by proto and offset. At this level, header split is a subset of buffer split.

IMHO, generic definition of the header split should not limit it by just two segments.

Quoted 5 lines

Since we shouldn't redefine the meaning of this offload,
I will use the RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.
The existence of tunnel needs to define a proto field in buffer split, because some PMDs do not support split based on length and offset.

Not sure that I fully understand, but I'm looking forward to review v5.

Quoted 22 lines
Quoted 9 lines
Quoted 5 lines

For example, let's suppose we configured the Rx queue with the following segments:

      seg0 - pool0, off0=2B
      seg1 - pool1, off1=128B

Corresponding feature is named Rx buffer split.
Does it mean that protocol type based header split requires Rx buffer split feature to be supported?

Protocol type based header split does not requires Rx buffer split. In previous design, the header split and buffer split are exclusive. Because we only configure one split offload for one RX queue.

Quoted 8 lines
Quoted 5 lines

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from

pool0

Quoted 1 line

seg1 - payload @ 128 in mbuf from pool1

Quoted 8 lines
Quoted 3 lines

Is it always outermost UDP? Does it require both UDP over IPv4 and UDP over IPv6 to be supported? What will happen if only one is supported? How application can find out which protocol stack are supported?

Both inner and outer UDP are considered.
Current design does not distinguish UDP over IPv4 or IPv6. If we want to support granularity like only IPv4 or IPv6 supported, user need add more configurations.

You should make it clear for application how to use it. What happens if unsupported packet is received on an RxQ configured to do header split?

Quoted 4 lines

If application want to find out which protocol stack is supported,
one way I think is to expose the protocol stack supported by the driver through dev_info. Any thoughts are welcomed :)

dev_info is nice, but very heavily overloaded. We can start from dev_info and understand if it should be factored out to a separate API or it is OK to have it in dev_info if it just few simple fields.

Quoted 205 lines
Quoted 122 lines
Quoted 4 lines

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and

external

Quoted 9 lines

memory, respectively.

---
   lib/ethdev/rte_ethdev.c | 34 ++++++++++++++++++++++-------
   lib/ethdev/rte_ethdev.h | 48

+++++++++++++++++++++++++++++++++++++++--

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct

Quoted 7 lines
   2 files changed, 72 insertions(+), 10 deletions(-)
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

29a3d80466..29adcdc2f0 100644

lib/ethdev/rte_ethdev.c +0 -0
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1667

Quoted 7 lines
lib/ethdev/rte_ethdev.c +1 -0
   		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
   		uint32_t length = rx_seg[seg_idx].length;
   		uint32_t offset = rx_seg[seg_idx].offset;
+		uint16_t proto = rx_seg[seg_idx].proto;
 
   		if (mpl == NULL) {
   			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");

@@ -1694,13

Quoted 1 line

+1695,29 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
   		}
   		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
   		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
lib/ethdev/rte_ethdev.c +0 -4
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 9 lines
lib/ethdev/rte_ethdev.c +6 -3
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto == RTE_ETH_RX_HEADER_SPLIT_NONE) {
+			/* Check buffer split. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 8 lines
lib/ethdev/rte_ethdev.c +8 -0
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Check header split. */
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length

should be set to zero in header split\n");

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 5 lines
lib/ethdev/rte_ethdev.c +5 -0
+				return -EINVAL;
+			}
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u

segment offset)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id,

Quoted 8 lines
lib/ethdev/rte_ethdev.c +4 -0
+					mpl->name, *mbp_buf_size,
+					offset);
+				return -EINVAL;
+			}
   		}
   	}
   	return 0;
@@ -1778,7 +1795,8 @@ rte_eth_rx_queue_setup(uint16_t port_id,

uint16_t rx_queue_id,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,

Quoted 4 lines
lib/ethdev/rte_ethdev.c +0 -1
   		rx_seg = (const struct rte_eth_rxseg_split *)rx_conf->rx_seg;
   		n_seg = rx_conf->rx_nseg;
 
-		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)

{

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, · line 1798

Quoted 1 line
lib/ethdev/rte_ethdev.c +1 -0
+		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT

||

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, · line 1799

Quoted 1 line
lib/ethdev/rte_ethdev.c +1 -0
+			rx_conf->offloads &

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT) {

Quoted 25 lines
lib/ethdev/rte_ethdev.c +0 -0
   			ret = rte_eth_rx_queue_check_split(rx_seg, n_seg,
   							   &mbp_buf_size,
   							   &dev_info);
lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0 -0

04cff8ee10..e8371b98ed 100644

lib/ethdev/rte_ethdev.h +14 -0
@@ -1197,12 +1197,31 @@ struct rte_eth_txmode {
    *     - pool from the last valid element
    *     - the buffer size from this pool
    *     - zero offset
+ *
+ * Header split is a subset of buffer split. The split happens after
+ the
+ * packet header and before the packet payload. For PMDs that do not
+ * support header split configuration by length, the location of the
+ split
+ * needs to be specified by the header protocol type. While for
+ buffer split,
+ * this field should not be configured.
+ *
+ * If RTE_ETH_RX_OFFLOAD_HEADER_SPLIT flag is set in offloads field,
+ * the PMD will split the received packets into two separate regions:
+ * - The header buffer will be allocated from the memory pool,
+ *   specified in the first array element, the second buffer, from the

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1223

Quoted 10 lines
lib/ethdev/rte_ethdev.h +7 -0
+ *   pool in the second element.
+ *
+ * - The lengths do not need to be configured in header split.
+ *
+ * - The offsets from the segment description elements specify
+ *   the data offset from the buffer beginning except the first mbuf.
+ *   The first segment offset is added with RTE_PKTMBUF_HEADROOM.
    */
   struct rte_eth_rxseg_split {
   	struct rte_mempool *mp; /**< Memory pool to allocate segment

from. */

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1225

Quoted 2 lines
lib/ethdev/rte_ethdev.h +0 -0
   	uint16_t length; /**< Segment data length, configures split point. */
   	uint16_t offset; /**< Data offset from beginning of mbuf data buffer.
Quoted 8 lines

*/

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1227

Quoted 3 lines
lib/ethdev/rte_ethdev.h +2 -1
-	uint32_t reserved; /**< Reserved field. */
+	uint16_t proto; /**< header protocol type, configures header split
+point. */

I realize that you don't want to use here enum defined above to save some reserved space, but description must refer to the enum rte_eth_rx_header_split_protocol_type.

Thanks for your suggestion, will fix it in next version.

Quoted 9 lines

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1224

Quoted 2 lines
lib/ethdev/rte_ethdev.h +1 -0
+	uint16_t reserved; /**< Reserved field. */

As far as I can see the structure is experimental. So, it should not be the problem to extend it, but it is a really good question raised by Stephen in RFC v1 discussion.
Shouldn't we require that all reserved fields are initialized to zero and ignored on processing? Frankly speaking I always thought so, but failed to find the place were it is documented.

Yes, it can be documented. By default is should be zero, and we can configure it to enable protocol type based buffer split.

Quoted 38 lines

@Thomas, @David, @Ferruh?

Quoted 13 lines
   };
   /**
lib/ethdev/rte_ethdev.h +1 -1
@@ -1212,7 +1231,7 @@ struct rte_eth_rxseg_split {
    * A common structure used to describe Rx packet segment properties.
    */
   union rte_eth_rxseg {
-	/* The settings for buffer split offload. */
+	/* The settings for buffer split and header split offload. */
   	struct rte_eth_rxseg_split split;
   	/* The other features settings should be added here. */
   };

lib/ethdev/rte_ethdev.h struct rte_eth_conf { · line 1684

Quoted 2 lines
lib/ethdev/rte_ethdev.h +0 -0
@@ -1664,6 +1683,31 @@ struct rte_eth_conf {
   			     RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
   #define DEV_RX_OFFLOAD_VLAN

RTE_DEPRECATED(DEV_RX_OFFLOAD_VLAN)

Quoted 19 lines

RTE_ETH_RX_OFFLOAD_VLAN

lib/ethdev/rte_ethdev.h +17 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this enum may change without prior notice.
+ * This enum indicates the header split protocol type  */ enum
+rte_eth_rx_header_split_protocol_type {
+	RTE_ETH_RX_HEADER_SPLIT_NONE = 0,
+	RTE_ETH_RX_HEADER_SPLIT_MAC,
+	RTE_ETH_RX_HEADER_SPLIT_IPV4,
+	RTE_ETH_RX_HEADER_SPLIT_IPV6,
+	RTE_ETH_RX_HEADER_SPLIT_L3,
+	RTE_ETH_RX_HEADER_SPLIT_TCP,
+	RTE_ETH_RX_HEADER_SPLIT_UDP,
+	RTE_ETH_RX_HEADER_SPLIT_SCTP,
+	RTE_ETH_RX_HEADER_SPLIT_L4,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_MAC,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_IPV4,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_IPV6,
Quoted 8 lines

lib/ethdev/rte_ethdev.h struct rte_eth_conf { · line 1708

Quoted 5 lines
lib/ethdev/rte_ethdev.h +5 -0
+	RTE_ETH_RX_HEADER_SPLIT_INNER_L3,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_TCP,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_UDP,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_SCTP,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_L4,

Enumeration members should be documented. See my question in the patch description.

Thanks for your detailed comments, questions are answered accordingly.

Best Regards,
Xuan

Quoted 6 lines
Quoted 6 lines
lib/ethdev/rte_ethdev.h +2 -0
+};
+
   /*
    * If new Rx offload capabilities are defined, they also must be
    * mentioned in rte_rx_offload_names in rte_ethdev.c file.
author
#24 lore raw

Hi Andrew,

Quoted 76 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Wednesday, April 20, 2022 11:48 PM
To: Ding, Xuan <[email protected]>; Wu, WenxuanX <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Yu, Ping <[email protected]>; Wang, YuanX <[email protected]>; [email protected]; Ferruh Yigit <[email protected]>
Subject: Re: [v4 1/3] ethdev: introduce protocol type based header split

Hi Xuan,

Quoted 6 lines · Xuan

Hi Andrew,

Quoted 4 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, April 7, 2022 6:48 PM
To: Wu, WenxuanX <[email protected]>; [email protected];

Li,

Quoted 26 lines
Quoted 26 lines

Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Yu, Ping <[email protected]>; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; [email protected]; Ferruh Yigit <[email protected]>
Subject: Re: [v4 1/3] ethdev: introduce protocol type based header split

Quoted 14 lines · On 4/2/22 13:41, [email protected] wrote:

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header protocol types. Because tunneling makes the conversion from length to protocol type impossible.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT offload was introduced some time

ago

Quoted 4 lines
Quoted 4 lines

to substitute bit-field header_split in struct rte_eth_rxmode. It allows to enable header split offload with the header size controlled using split_hdr_size in the same structure.

Quoted 8 lines
Quoted 8 lines

Right now I see no single PMD which actually supports RTE_ETH_RX_OFFLOAD_HEADER_SPLIT with above definition. Many examples and test apps initialize the field to 0 explicitly. The most of drivers simply ignore split_hdr_size since the offload is not advertised, but some double-check that its value is 0.

I think that it means that the field should be removed on the next LTS, and I'd say, together with the RTE_ETH_RX_OFFLOAD_HEADER_SPLIT

offload bit.

Quoted 3 lines
Quoted 2 lines

We should not redefine the offload meaning.

Quoted 7 lines
Quoted 1 line

Yes, you are right. No single PMD supports

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT now.

Quoted 2 lines

Previously, I used this flag is to distinguish buffer split and header split. The former supports multi-segments split by length and offset.

offset is misleading here, since split offset is derived from segment lengths. Offset specified in segments is a different thing.

Yes, the length defines the segment length, and the offset defines the data offset in mbuf. The usage of length and offset are explained in the comments, but it is somewhat misleading just from name.

Quoted 6 lines
Quoted 3 lines

The later supports two segments split by proto and offset. At this level, header split is a subset of buffer split.

IMHO, generic definition of the header split should not limit it by just two segments.

Does the header split here refer to the traditional header split? If so, since you mentioned before we should not redefine the offload meaning, I will use protocol and mbuf_offset based buffer split in next version.

It is worth noting that the purpose of specifying the split location by protocol is to divide a packet into two segments. If you want to divide into multiple segments, it should still be specified by length.

Quoted 8 lines
Quoted 6 lines

Since we shouldn't redefine the meaning of this offload, I will use the RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.
The existence of tunnel needs to define a proto field in buffer split, because some PMDs do not support split based on length and offset.

Not sure that I fully understand, but I'm looking forward to review v5.

Thanks for your comments, I will send a v5, including these main changes:
1. Use protocol and mbuf_offset based buffer split instead of header split.
2. Use RTE_PTYPE* instead of enum rte_eth_rx_header_split_protocol_type.
3. Improve the description of rte_eth_rxseg_split.proto.

Your comments are welcomed. 😊

Quoted 28 lines
Quoted 28 lines
Quoted 10 lines
Quoted 6 lines

For example, let's suppose we configured the Rx queue with the following segments:

      seg0 - pool0, off0=2B
      seg1 - pool1, off1=128B

Corresponding feature is named Rx buffer split.
Does it mean that protocol type based header split requires Rx buffer split feature to be supported?

Protocol type based header split does not requires Rx buffer split. In previous design, the header split and buffer split are exclusive. Because we only configure one split offload for one RX queue.

Quoted 12 lines
Quoted 5 lines

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from

pool0

Quoted 1 line

seg1 - payload @ 128 in mbuf from pool1

Is it always outermost UDP? Does it require both UDP over IPv4 and UDP over
IPv6 to be supported? What will happen if only one is supported? How application can find out which protocol stack are supported?

Quoted 4 lines
Quoted 4 lines

Both inner and outer UDP are considered.
Current design does not distinguish UDP over IPv4 or IPv6. If we want to support granularity like only IPv4 or IPv6 supported, user need add more configurations.

Thanks for your suggestion.
I will improve the documents about the usage of proto based buffer split.

Quoted 4 lines

You should make it clear for application how to use it.
What happens if unsupported packet is received on an RxQ configured to do header split?

In fact, the buffer split and rte_flow are used in combination. It is expected that the received packets will be steering to the RXQ configured with buffer split offload. So there won't be unsupported packet received on an RXQ.

Quoted 10 lines
Quoted 4 lines

If application want to find out which protocol stack is supported, one way I think is to expose the protocol stack supported by the driver through

dev_info.

Quoted 1 line

Any thoughts are welcomed :)

dev_info is nice, but very heavily overloaded. We can start from dev_info and understand if it should be factored out to a separate API or it is OK to have it in dev_info if it just few simple fields.

I'm also thinking exposing the protocol stack by dev_info is heavy.
We can configure all the protocol stack, and driver supports
part of the stacks. For protocols driver not supported, driver can returns the error. What do you think of this design?

Regards,
Xuan

Quoted 209 lines
Quoted 209 lines
Quoted 125 lines
Quoted 5 lines

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and

external

Quoted 9 lines

memory, respectively.

---
   lib/ethdev/rte_ethdev.c | 34 ++++++++++++++++++++++-------
   lib/ethdev/rte_ethdev.h | 48

+++++++++++++++++++++++++++++++++++++++--

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct

Quoted 7 lines
   2 files changed, 72 insertions(+), 10 deletions(-)
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

29a3d80466..29adcdc2f0 100644

lib/ethdev/rte_ethdev.c +0 -0
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1667

Quoted 7 lines
lib/ethdev/rte_ethdev.c +1 -0
   		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
   		uint32_t length = rx_seg[seg_idx].length;
   		uint32_t offset = rx_seg[seg_idx].offset;
+		uint16_t proto = rx_seg[seg_idx].proto;
 
   		if (mpl == NULL) {
   			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");

@@ -1694,13

Quoted 1 line

+1695,29 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
   		}
   		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
   		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
lib/ethdev/rte_ethdev.c +0 -4
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 9 lines
lib/ethdev/rte_ethdev.c +6 -3
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto == RTE_ETH_RX_HEADER_SPLIT_NONE) {
+			/* Check buffer split. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 8 lines
lib/ethdev/rte_ethdev.c +8 -0
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Check header split. */
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length

should be set to zero in header split\n");

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 5 lines
lib/ethdev/rte_ethdev.c +5 -0
+				return -EINVAL;
+			}
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u

segment offset)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id,

Quoted 8 lines
lib/ethdev/rte_ethdev.c +4 -0
+					mpl->name, *mbp_buf_size,
+					offset);
+				return -EINVAL;
+			}
   		}
   	}
   	return 0;
@@ -1778,7 +1795,8 @@ rte_eth_rx_queue_setup(uint16_t port_id,

uint16_t rx_queue_id,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,

Quoted 4 lines
lib/ethdev/rte_ethdev.c +0 -1
   		rx_seg = (const struct rte_eth_rxseg_split *)rx_conf->rx_seg;
   		n_seg = rx_conf->rx_nseg;
 
-		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)

{

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, · line 1798

Quoted 1 line
lib/ethdev/rte_ethdev.c +1 -0
+		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT

||

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, · line 1799

Quoted 1 line
lib/ethdev/rte_ethdev.c +1 -0
+			rx_conf->offloads &

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT) {

Quoted 27 lines
lib/ethdev/rte_ethdev.c +0 -0
   			ret = rte_eth_rx_queue_check_split(rx_seg, n_seg,
   							   &mbp_buf_size,
   							   &dev_info);
lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0 -0

04cff8ee10..e8371b98ed 100644

lib/ethdev/rte_ethdev.h +16 -0
@@ -1197,12 +1197,31 @@ struct rte_eth_txmode {
    *     - pool from the last valid element
    *     - the buffer size from this pool
    *     - zero offset
+ *
+ * Header split is a subset of buffer split. The split happens
+ after the
+ * packet header and before the packet payload. For PMDs that do
+ not
+ * support header split configuration by length, the location of
+ the split
+ * needs to be specified by the header protocol type. While for
+ buffer split,
+ * this field should not be configured.
+ *
+ * If RTE_ETH_RX_OFFLOAD_HEADER_SPLIT flag is set in offloads
+ field,
+ * the PMD will split the received packets into two separate regions:
+ * - The header buffer will be allocated from the memory pool,
+ *   specified in the first array element, the second buffer, from the

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1225

Quoted 10 lines
lib/ethdev/rte_ethdev.h +7 -0
+ *   pool in the second element.
+ *
+ * - The lengths do not need to be configured in header split.
+ *
+ * - The offsets from the segment description elements specify
+ *   the data offset from the buffer beginning except the first mbuf.
+ *   The first segment offset is added with RTE_PKTMBUF_HEADROOM.
    */
   struct rte_eth_rxseg_split {
   	struct rte_mempool *mp; /**< Memory pool to allocate segment

from. */

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1227

Quoted 2 lines
lib/ethdev/rte_ethdev.h +0 -0
   	uint16_t length; /**< Segment data length, configures split point. */
   	uint16_t offset; /**< Data offset from beginning of mbuf data buffer.
Quoted 8 lines

*/

lib/ethdev/rte_ethdev.h struct rte_eth_txmode {

Quoted 3 lines
lib/ethdev/rte_ethdev.h +2 -1
-	uint32_t reserved; /**< Reserved field. */
+	uint16_t proto; /**< header protocol type, configures header split
+point. */

I realize that you don't want to use here enum defined above to save some reserved space, but description must refer to the enum rte_eth_rx_header_split_protocol_type.

Thanks for your suggestion, will fix it in next version.

Quoted 10 lines

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1224

Quoted 2 lines
lib/ethdev/rte_ethdev.h +1 -0
+	uint16_t reserved; /**< Reserved field. */

As far as I can see the structure is experimental. So, it should not be the problem to extend it, but it is a really good question raised by Stephen in RFC
v1 discussion.
Shouldn't we require that all reserved fields are initialized to zero and ignored on processing? Frankly speaking I always thought so, but failed to find the place were it is documented.

Yes, it can be documented. By default is should be zero, and we can configure it to enable protocol type based buffer split.

Quoted 38 lines

@Thomas, @David, @Ferruh?

Quoted 13 lines
   };
   /**
lib/ethdev/rte_ethdev.h +1 -1
@@ -1212,7 +1231,7 @@ struct rte_eth_rxseg_split {
    * A common structure used to describe Rx packet segment properties.
    */
   union rte_eth_rxseg {
-	/* The settings for buffer split offload. */
+	/* The settings for buffer split and header split offload. */
   	struct rte_eth_rxseg_split split;
   	/* The other features settings should be added here. */
   };

lib/ethdev/rte_ethdev.h struct rte_eth_conf { · line 1684

Quoted 2 lines
lib/ethdev/rte_ethdev.h +0 -0
@@ -1664,6 +1683,31 @@ struct rte_eth_conf {
   			     RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
   #define DEV_RX_OFFLOAD_VLAN

RTE_DEPRECATED(DEV_RX_OFFLOAD_VLAN)

Quoted 19 lines

RTE_ETH_RX_OFFLOAD_VLAN

lib/ethdev/rte_ethdev.h +17 -0
+/**
+ * @warning
+ * @b EXPERIMENTAL: this enum may change without prior notice.
+ * This enum indicates the header split protocol type  */ enum
+rte_eth_rx_header_split_protocol_type {
+	RTE_ETH_RX_HEADER_SPLIT_NONE = 0,
+	RTE_ETH_RX_HEADER_SPLIT_MAC,
+	RTE_ETH_RX_HEADER_SPLIT_IPV4,
+	RTE_ETH_RX_HEADER_SPLIT_IPV6,
+	RTE_ETH_RX_HEADER_SPLIT_L3,
+	RTE_ETH_RX_HEADER_SPLIT_TCP,
+	RTE_ETH_RX_HEADER_SPLIT_UDP,
+	RTE_ETH_RX_HEADER_SPLIT_SCTP,
+	RTE_ETH_RX_HEADER_SPLIT_L4,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_MAC,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_IPV4,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_IPV6,
Quoted 8 lines

lib/ethdev/rte_ethdev.h struct rte_eth_conf { · line 1708

Quoted 5 lines
lib/ethdev/rte_ethdev.h +5 -0
+	RTE_ETH_RX_HEADER_SPLIT_INNER_L3,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_TCP,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_UDP,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_SCTP,
+	RTE_ETH_RX_HEADER_SPLIT_INNER_L4,

Enumeration members should be documented. See my question in the patch description.

Thanks for your detailed comments, questions are answered accordingly.

Best Regards,
Xuan

Quoted 6 lines
Quoted 6 lines
lib/ethdev/rte_ethdev.h +2 -0
+};
+
   /*
    * If new Rx offload capabilities are defined, they also must be
    * mentioned in rte_rx_offload_names in rte_ethdev.c file.
#25 lore raw
In reply to Ding, Xuan

12/04/2022 18:15, Ding, Xuan:

Quoted 46 lines

From: Andrew Rybchenko <[email protected]>

Quoted 34 lines · On 4/2/22 13:41, [email protected] wrote:
Quoted 14 lines

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header protocol types. Because tunneling makes the conversion from length to protocol type impossible.

Quoted 7 lines

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT offload was introduced some time ago to substitute bit-field header_split in struct rte_eth_rxmode. It allows to enable header split offload with the header size controlled using split_hdr_size in the same structure.

Right now I see no single PMD which actually supports RTE_ETH_RX_OFFLOAD_HEADER_SPLIT with above definition.
Many examples and test apps initialize the field to 0 explicitly. The most of drivers simply ignore split_hdr_size since the offload is not advertised, but some double-check that its value is 0.

Quoted 4 lines

I think that it means that the field should be removed on the next LTS, and I'd say, together with the RTE_ETH_RX_OFFLOAD_HEADER_SPLIT offload bit.

We should not redefine the offload meaning.

Yes, you are right. No single PMD supports RTE_ETH_RX_OFFLOAD_HEADER_SPLIT now. Previously, I used this flag is to distinguish buffer split and header split. The former supports multi-segments split by length and offset.
The later supports two segments split by proto and offset.
At this level, header split is a subset of buffer split.

Quoted 4 lines

Since we shouldn't redefine the meaning of this offload,
I will use the RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.
The existence of tunnel needs to define a proto field in buffer split, because some PMDs do not support split based on length and offset.

Before doing anything, the first patch of this series should make
the current status clearer.
Example, this line does not explain what it does:
uint16_t split_hdr_size; /**< hdr buf size (header_split enabled).*/
And header_split has been removed in ab3ce1e0c193 ("ethdev: remove old offload API")

If RTE_ETH_RX_OFFLOAD_HEADER_SPLIT is not needed,
let's add a comment to start a deprecation.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

For example, let's suppose we configured the Rx queue with the following segments:

     seg0 - pool0, off0=2B
     seg1 - pool1, off1=128B
Quoted 7 lines
Quoted 3 lines

Corresponding feature is named Rx buffer split.
Does it mean that protocol type based header split requires Rx buffer split feature to be supported?

Protocol type based header split does not requires Rx buffer split. In previous design, the header split and buffer split are exclusive. Because we only configure one split offload for one RX queue.

Things must be made clear and documented.

Quoted 18 lines
Quoted 9 lines
Quoted 3 lines

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from

pool0

Quoted 1 line

seg1 - payload @ 128 in mbuf from pool1

Is it always outermost UDP? Does it require both UDP over IPv4 and UDP over IPv6 to be supported? What will happen if only one is supported? How application can find out which protocol stack are supported?

Both inner and outer UDP are considered.
Current design does not distinguish UDP over IPv4 or IPv6. If we want to support granularity like only IPv4 or IPv6 supported, user need add more configurations.

If application want to find out which protocol stack is supported,
one way I think is to expose the protocol stack supported by the driver through dev_info. Any thoughts are welcomed :)

[...]

Quoted 9 lines
Quoted 8 lines

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1224

Quoted 1 line
lib/ethdev/rte_ethdev.h +1 -0
+	uint16_t reserved; /**< Reserved field. */

As far as I can see the structure is experimental. So, it should not be the problem to extend it, but it is a really good question raised by Stephen in RFC v1 discussion.
Shouldn't we require that all reserved fields are initialized to zero and ignored on processing? Frankly speaking I always thought so, but failed to find the place were it is documented.

Quoted 4 lines

Yes, it can be documented. By default is should be zero, and we can configure it to enable protocol type based buffer split.

Quoted 1 line

@Thomas, @David, @Ferruh?

Yes that's very important to have a clear state of the reserved fields. A value must be set and documented.

author
#26 lore raw

Hi Thomas,

Quoted 79 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, April 21, 2022 6:28 PM
To: Andrew Rybchenko <[email protected]>; Wu, WenxuanX <[email protected]>; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Yu, Ping <[email protected]>; Wang, YuanX <[email protected]>; [email protected]; Ferruh Yigit <[email protected]>; Ding, Xuan <[email protected]>
Subject: Re: [v4 1/3] ethdev: introduce protocol type based header split

12/04/2022 18:15, Ding, Xuan:

Quoted 9 lines

From: Andrew Rybchenko <[email protected]>

Quoted 8 lines · On 4/2/22 13:41, [email protected] wrote:
Quoted 7 lines

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a

different buffer.

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header protocol types. Because tunneling makes the conversion from length to protocol type impossible.

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer
L2/L3/L4 level header split can be supported.

Quoted 1 line
Quoted 1 line

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT offload was introduced some

time ago

Quoted 4 lines
Quoted 4 lines

to substitute bit-field header_split in struct rte_eth_rxmode. It allows to enable header split offload with the header size controlled using split_hdr_size in the same structure.

Quoted 8 lines
Quoted 8 lines

Right now I see no single PMD which actually supports RTE_ETH_RX_OFFLOAD_HEADER_SPLIT with above definition. Many examples and test apps initialize the field to 0 explicitly. The most of drivers simply ignore split_hdr_size since the offload is not advertised, but some double-check that its value is 0.

I think that it means that the field should be removed on the next LTS, and I'd say, together with the

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT offload bit.

Quoted 4 lines
Quoted 2 lines

We should not redefine the offload meaning.

Yes, you are right. No single PMD supports

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT now.

Quoted 9 lines

Previously, I used this flag is to distinguish buffer split and header split. The former supports multi-segments split by length and offset. The later supports two segments split by proto and offset.
At this level, header split is a subset of buffer split.

Since we shouldn't redefine the meaning of this offload, I will use the RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.
The existence of tunnel needs to define a proto field in buffer split, because some PMDs do not support split based on length and offset.

Before doing anything, the first patch of this series should make the current status clearer.
Example, this line does not explain what it does:
uint16_t split_hdr_size; /**< hdr buf size (header_split enabled).*/
And header_split has been removed in ab3ce1e0c193 ("ethdev: remove old offload API")

Quoted 2 lines

If RTE_ETH_RX_OFFLOAD_HEADER_SPLIT is not needed, let's add a comment to start a deprecation.

Agree, I discussed with Andrew before that RTE_ETH_RX_OFFLOAD_HEADER_SPLIT is no longer supported by any PMDs.

I can send a separate patch of header split deprecation notice in 22.07, and start removing the code in 22.11. What do you think?

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

For example, let's suppose we configured the Rx queue with the following segments:

     seg0 - pool0, off0=2B
     seg1 - pool1, off1=128B

Corresponding feature is named Rx buffer split.
Does it mean that protocol type based header split requires Rx buffer split feature to be supported?

Quoted 5 lines
Quoted 3 lines

Protocol type based header split does not requires Rx buffer split. In previous design, the header split and buffer split are exclusive. Because we only configure one split offload for one RX queue.

Things must be made clear and documented.

Thanks for your suggestion, the documents will be improved in v5.

Quoted 33 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of

MAC_IP_UDP_PAYLOAD will be split like following:

Quoted 9 lines
Quoted 8 lines
Quoted 1 line

seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from

pool0

Quoted 1 line

seg1 - payload @ 128 in mbuf from pool1

Is it always outermost UDP? Does it require both UDP over IPv4 and UDP over
IPv6 to be supported? What will happen if only one is supported? How application can find out which protocol stack are supported?

Quoted 7 lines

Both inner and outer UDP are considered.
Current design does not distinguish UDP over IPv4 or IPv6. If we want to support granularity like only IPv4 or IPv6 supported, user need add more configurations.

If application want to find out which protocol stack is supported, one way I think is to expose the protocol stack supported by the driver through

dev_info.

Quoted 1 line

Any thoughts are welcomed :)

[...]

Quoted 10 lines
Quoted 9 lines

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1224

Quoted 1 line
lib/ethdev/rte_ethdev.h +1 -0
+	uint16_t reserved; /**< Reserved field. */

As far as I can see the structure is experimental. So, it should not be the problem to extend it, but it is a really good question raised by Stephen in RFC
v1 discussion.
Shouldn't we require that all reserved fields are initialized to zero and ignored on processing? Frankly speaking I always thought so, but failed to find the place were it is documented.

Quoted 7 lines
Quoted 4 lines

Yes, it can be documented. By default is should be zero, and we can configure it to enable protocol type based buffer split.

Quoted 1 line

@Thomas, @David, @Ferruh?

Yes that's very important to have a clear state of the reserved fields. A value must be set and documented.

Ditto, thanks for your comments. :)

Regards,
Xuan

Quoted 2 lines
#27 lore raw
In reply to [email protected]
Quoted 23 lines · On Sat, Apr 2, 2022 at 4:33 PM <[email protected]> wrote:

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header protocol types. Because tunneling makes the conversion from length to protocol type impossible.

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

Quoted 8 lines

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, off0=2B
    seg1 - pool1, off1=128B

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0

If we set rte_eth_rxseg_split::proto = RTE_ETH_RX_HEADER_SPLIT_UDP and rte_eth_rxseg_split.offset = 2,
What will be the content for seg0,
Will it be,
- offset as Starts atUDP Header
- size of segment as MAX(size of UDP header + 2, 128(as seg 1 start from128). Right? If not, Please describe

Also, I don't think we need duplate rte_eth_rx_header_split_protocol_type instead we can reuse existing RTE_PTYPE_* flags.

Quoted 5 lines

seg1 - payload @ 128 in mbuf from pool1

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and external memory, respectively.

author
#28 lore raw

Hi Jacob,

Quoted 47 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Thursday, April 7, 2022 9:27 PM
To: Wu, WenxuanX <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Andrew Rybchenko <[email protected]>; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; dpdk-dev <[email protected]>; Stephen Hemminger <[email protected]>; Morten Brørup <[email protected]>; Viacheslav Ovsiienko <[email protected]>; Yu, Ping <[email protected]>; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>
Subject: Re: [v4 1/3] ethdev: introduce protocol type based header split

Quoted 23 lines · On Sat, Apr 2, 2022 at 4:33 PM <[email protected]> wrote:

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header protocol types. Because tunneling makes the conversion from length to protocol type impossible.

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

Quoted 8 lines

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, off0=2B
    seg1 - pool1, off1=128B

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0

Quoted 5 lines

If we set rte_eth_rxseg_split::proto = RTE_ETH_RX_HEADER_SPLIT_UDP and rte_eth_rxseg_split.offset = 2, What will be the content for seg0, Will it be,
- offset as Starts atUDP Header
- size of segment as MAX(size of UDP header + 2, 128(as seg 1 start from128). Right? If not, Please describe

Proto defines the location in packet for split.
Offset defines data buffer from beginning of mbuf data buffer, it can be zero. With proto and offset configured, packets received will be split into two segments.

So in this configuration, the seg0 content is UDP header, the seg1 content is the payload. Size of seg0 is size of UDP header, size of seg1 is size of payload. rte_eth_rxseg_split.offset = 2/128 decides the mbuf offset, rather than segment size.

Quoted 4 lines

Also, I don't think we need duplate rte_eth_rx_header_split_protocol_type instead we can reuse existing RTE_PTYPE_* flags.

That's a good idea. Yes, I can use the RTE_PTYPE_* here. My only
concern is the 32-bits RTE_PTYPE_* will run out of the 32-bits reserved fields.
If this proposal is agreed, I will use RTE_PTYPE_* instead of rte_eth_rx_header_split_protocol_type.

Best Regards,
Xuan

Quoted 8 lines
Quoted 6 lines

seg1 - payload @ 128 in mbuf from pool1

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and

external

Quoted 1 line

memory, respectively.

#29 lore raw
Quoted 55 lines · Xuan

Hi Jacob,

Quoted 47 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Thursday, April 7, 2022 9:27 PM
To: Wu, WenxuanX <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Andrew Rybchenko <[email protected]>; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; dpdk-dev <[email protected]>; Stephen Hemminger <[email protected]>; Morten Brørup <[email protected]>; Viacheslav Ovsiienko <[email protected]>; Yu, Ping <[email protected]>; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>
Subject: Re: [v4 1/3] ethdev: introduce protocol type based header split

Quoted 23 lines · On Sat, Apr 2, 2022 at 4:33 PM <[email protected]> wrote:

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header protocol types. Because tunneling makes the conversion from length to protocol type impossible.

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

Quoted 8 lines

For example, let's suppose we configured the Rx queue with the following segments:

     seg0 - pool0, off0=2B
     seg1 - pool1, off1=128B

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0

Quoted 5 lines

If we set rte_eth_rxseg_split::proto = RTE_ETH_RX_HEADER_SPLIT_UDP and rte_eth_rxseg_split.offset = 2, What will be the content for seg0, Will it be,
- offset as Starts atUDP Header
- size of segment as MAX(size of UDP header + 2, 128(as seg 1 start from128). Right? If not, Please describe

Quoted 7 lines

Proto defines the location in packet for split.
Offset defines data buffer from beginning of mbuf data buffer, it can be zero. With proto and offset configured, packets received will be split into two segments.

So in this configuration, the seg0 content is UDP header, the seg1 content is the payload. Size of seg0 is size of UDP header, size of seg1 is size of payload. rte_eth_rxseg_split.offset = 2/128 decides the mbuf offset, rather than segment size.

Above discussion proves that definition of the struct rte_eth_rxseg_split is misleading. It is hard to catch from naming that length defines a maximum data amount to be copied, but office is a an offset in destination mbuf. The structure is still experimental and I think we should improve naming: offset -> mbuf_offset?

Quoted 21 lines
Quoted 5 lines

Also, I don't think we need duplate rte_eth_rx_header_split_protocol_type instead we can reuse existing RTE_PTYPE_* flags.

That's a good idea. Yes, I can use the RTE_PTYPE_* here. My only
concern is the 32-bits RTE_PTYPE_* will run out of the 32-bits reserved fields.
If this proposal is agreed, I will use RTE_PTYPE_* instead of rte_eth_rx_header_split_protocol_type.

Best Regards,
Xuan

Quoted 8 lines
Quoted 6 lines

seg1 - payload @ 128 in mbuf from pool1

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and

external

Quoted 1 line

memory, respectively.

#30 lore raw

20/04/2022 16:39, Andrew Rybchenko:

Quoted 48 lines · Xuan
Quoted 39 lines

From: Jerin Jacob <[email protected]>

Quoted 32 lines · On Sat, Apr 2, 2022 at 4:33 PM <[email protected]> wrote:
Quoted 22 lines

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header protocol types. Because tunneling makes the conversion from length to protocol type impossible.

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag RTE_ETH_RX_OFFLOAD_HEADER_SPLIT enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

Quoted 8 lines

For example, let's suppose we configured the Rx queue with the following segments:

     seg0 - pool0, off0=2B
     seg1 - pool1, off1=128B

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0

Quoted 5 lines

If we set rte_eth_rxseg_split::proto = RTE_ETH_RX_HEADER_SPLIT_UDP and rte_eth_rxseg_split.offset = 2, What will be the content for seg0, Will it be,
- offset as Starts atUDP Header
- size of segment as MAX(size of UDP header + 2, 128(as seg 1 start from128). Right? If not, Please describe

Quoted 7 lines

Proto defines the location in packet for split.
Offset defines data buffer from beginning of mbuf data buffer, it can be zero. With proto and offset configured, packets received will be split into two segments.

So in this configuration, the seg0 content is UDP header, the seg1 content is the payload. Size of seg0 is size of UDP header, size of seg1 is size of payload. rte_eth_rxseg_split.offset = 2/128 decides the mbuf offset, rather than segment size.

Quoted 6 lines

Above discussion proves that definition of the struct rte_eth_rxseg_split is misleading. It is hard to catch from naming that length defines a maximum data amount to be copied, but office is a an offset in destination mbuf. The structure is still experimental and I think we should improve naming: offset -> mbuf_offset?

I agree it is confusing.
mbuf_offset could be a better name.
length could be renamed as well. Is data_length better?

But the most important is to have a clear description
in the doxygen comment of the field.
We must specify what is the starting point and the "end" for those fields.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

Also, I don't think we need duplate rte_eth_rx_header_split_protocol_type instead we can reuse existing RTE_PTYPE_* flags.

That's a good idea. Yes, I can use the RTE_PTYPE_* here. My only
concern is the 32-bits RTE_PTYPE_* will run out of the 32-bits reserved fields.
If this proposal is agreed, I will use RTE_PTYPE_* instead of rte_eth_rx_header_split_protocol_type.

Yes I think RTE_PTYPE_* is appropriate.

author
#31 lore raw
In reply to Andrew Rybchenko

Hi Andrew,

Quoted 87 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Wednesday, April 20, 2022 10:40 PM
To: Ding, Xuan <[email protected]>; Jerin Jacob <[email protected]>; Wu, WenxuanX <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; dpdk-dev <[email protected]>; Stephen Hemminger <[email protected]>; Morten Brørup <[email protected]>; Viacheslav Ovsiienko <[email protected]>; Yu, Ping <[email protected]>; Wang, YuanX <[email protected]>
Subject: Re: [v4 1/3] ethdev: introduce protocol type based header split

Quoted 38 lines · Xuan

Hi Jacob,

Quoted 36 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Thursday, April 7, 2022 9:27 PM
To: Wu, WenxuanX <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Andrew Rybchenko <[email protected]>; Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; dpdk-dev <[email protected]>; Stephen Hemminger <[email protected]>; Morten Brørup <[email protected]>; Viacheslav Ovsiienko <[email protected]>; Yu, Ping <[email protected]>; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>
Subject: Re: [v4 1/3] ethdev: introduce protocol type based header split

Quoted 19 lines · On Sat, Apr 2, 2022 at 4:33 PM <[email protected]> wrote:

From: Xuan Ding <[email protected]>

Header split consists of splitting a received packet into two separate regions based on the packet content. The split happens after the packet header and before the packet payload. Splitting is usually between the packet header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. Although header split is a subset of buffer split, configuring buffer split based on length is not suitable for NICs that do split based on header protocol types. Because tunneling makes the conversion from length to protocol type impossible.

This patch extends the current buffer split to support protocol type and offset based header split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx offload flag

RTE_ETH_RX_OFFLOAD_HEADER_SPLIT

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

enabled and protocol type configured, PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level header split can be supported.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

For example, let's suppose we configured the Rx queue with the following segments:

     seg0 - pool0, off0=2B
     seg1 - pool1, off1=128B

With header split type configured with RTE_ETH_RX_HEADER_SPLIT_UDP, the packet consists of MAC_IP_UDP_PAYLOAD will be split like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from

pool0

Quoted 6 lines
Quoted 6 lines

If we set rte_eth_rxseg_split::proto = RTE_ETH_RX_HEADER_SPLIT_UDP and rte_eth_rxseg_split.offset = 2, What will be the content for seg0, Will it be,
- offset as Starts atUDP Header
- size of segment as MAX(size of UDP header + 2, 128(as seg 1 start

from128).

Quoted 4 lines
Quoted 1 line

Right? If not, Please describe

Proto defines the location in packet for split.
Offset defines data buffer from beginning of mbuf data buffer, it can be

zero.

Quoted 1 line

With proto and offset configured, packets received will be split into two

segments.

Quoted 2 lines

So in this configuration, the seg0 content is UDP header, the seg1 content is

the payload.

Quoted 2 lines

Size of seg0 is size of UDP header, size of seg1 is size of payload. rte_eth_rxseg_split.offset = 2/128 decides the mbuf offset, rather than

Quoted 7 lines

segment size.

Above discussion proves that definition of the struct rte_eth_rxseg_split is misleading. It is hard to catch from naming that length defines a maximum data amount to be copied, but office is a an offset in destination mbuf. The structure is still experimental and I think we should improve naming: offset -> mbuf_offset?

Yes, you are right. In rte_eth_rxseg_split structure, even the length and offset are documented, it is hard to understand just from the naming.

Thanks,
Xuan

Quoted 24 lines
Quoted 9 lines
Quoted 6 lines

Also, I don't think we need duplate rte_eth_rx_header_split_protocol_type instead we can reuse existing RTE_PTYPE_* flags.

That's a good idea. Yes, I can use the RTE_PTYPE_* here. My only concern is the 32-bits RTE_PTYPE_* will run out of the 32-bits reserved

fields.

Quoted 1 line

If this proposal is agreed, I will use RTE_PTYPE_* instead of

rte_eth_rx_header_split_protocol_type.

Quoted 12 lines

Best Regards,
Xuan

Quoted 8 lines
Quoted 6 lines

seg1 - payload @ 128 in mbuf from pool1

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and

external

Quoted 1 line

memory, respectively.

#32 lore raw

v5 cover ethdev: introduce protocol based buffer split

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

Protocol based buffer split consists of splitting a received packet into two separate regions based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.

This patchset aims to support protocol split based on current buffer split. When Rx queue is configured with RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload and corresponding protocol, packets received will be directly split into two different mempools.

v4->v5:
* Use protocol and mbuf_offset based buffer split instead of header split.
* Use RTE_PTYPE* instead of enum rte_eth_rx_header_split_protocol_type.
* Improve the description of rte_eth_rxseg_split.proto.

v3->v4:
* Use RTE_ETH_RX_HEADER_SPLIT_NONE instead of 0.

v2->v3:
* Fix a PMD bug.
* Add rx queue header split check.
* Revise the log and doc.

v1->v2:
* Add support for all header split protocol types.

Wenxuan Wu (3):
ethdev: introduce protocol type based buffer split app/testpmd: add proto based buffer split config net/ice: support proto based buf split in Rx path

 app/test-pmd/cmdline.c                | 118 ++++++++++++++
 app/test-pmd/testpmd.c                |   7 +-
 app/test-pmd/testpmd.h                |   2 +
 drivers/net/ice/ice_ethdev.c          |  10 +-
 drivers/net/ice/ice_rxtx.c            | 217 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 lib/ethdev/rte_ethdev.c               |  36 ++++-
 lib/ethdev/rte_ethdev.h               |  21 ++-
 9 files changed, 388 insertions(+), 42 deletions(-)
Signature · 1 line
2.25.1
#33 lore raw

PATCH v5 1/4 lib/ethdev: introduce protocol type based buffer split

From: Wenxuan Wu <[email protected]>

Protocol based buffer split consists of splitting a received packet into two separate regions based on its content. The split happens after the packet protocol header and before the packet payload. Splitting is usually between the packet protocol header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. protocol split is based on buffer split, configuring length of buffer split is not suitable for NICs that do split based on protocol types. Because tunneling makes the conversion from length to protocol type impossible.

This patch extends the current buffer split to support protocol and offset based buffer split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and corresponding protocol type configured. PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level protocol based buffer split can be supported.

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, off0=2B
    seg1 - pool1, off1=128B

With protocol split type configured with RTE_PTYPE_L4_UDP. The packet consists of MAC_IP_UDP_PAYLOAD will be splitted like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - payload @ 128 in mbuf from pool1

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 36 +++++++++++++++++++++++++++++-------
 lib/ethdev/rte_ethdev.h | 15 ++++++++++++++-
 2 files changed, 43 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c +29 -7
index 29a3d80466..1a2bc172ab 100644
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto = rx_seg[seg_idx].proto;
 
 		if (mpl == NULL) {
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1694,13 +1695,34 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		}
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto == 0) {
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Ensure n_seg is 2 in protocol based buffer split. */
+			if (n_seg != 2)	{
+				RTE_ETHDEV_LOG(ERR, "number of buffer split protocol segments should be 2.\n");
+				return -EINVAL;
+			}
+			/* Length and protocol are exclusive here, so make sure length is 0 in protocol
+			based buffer split. */
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length should be set to zero in buffer split\n");
+				return -EINVAL;
+			}
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+						"%s mbuf_data_room_size %u < %u segment offset)\n",
+						mpl->name, *mbp_buf_size,
+						offset);
+				return -EINVAL;
+			}
 		}
 	}
 	return 0;
lib/ethdev/rte_ethdev.h +14 -1
index 04cff8ee10..ef7f59aae6 100644
@@ -1187,6 +1187,9 @@ struct rte_eth_txmode {
  *   mbuf) the following data will be pushed to the next segment
  *   up to its own length, and so on.
  *
+ *
+ * - The proto in the elements defines the split position of received packets.
+ *
  * - If the length in the segment description element is zero
  *   the actual buffer size will be deduced from the appropriate
  *   memory pool properties.
@@ -1197,12 +1200,21 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
+ *     - The proto should not be configured in length split. Zero default.
+ *
+ * - Protocol based buffer split:
+ *     - mp, offset, proto should be configured.
+ *     - The length should not be configured in protocol split. Zero default.
+ *
  */
 struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint32_t proto; /**< Protocol of buffer split, determines protocol split point. */
 };
 
 /**
@@ -1664,6 +1676,7 @@ struct rte_eth_conf {
 			     RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
 #define DEV_RX_OFFLOAD_VLAN RTE_DEPRECATED(DEV_RX_OFFLOAD_VLAN) RTE_ETH_RX_OFFLOAD_VLAN
 
+
 /*
  * If new Rx offload capabilities are defined, they also must be
  * mentioned in rte_rx_offload_names in rte_ethdev.c file.
Signature · 1 line
2.25.1
#34 lore raw

Re: [PATCH v5 1/4] lib/ethdev: introduce protocol type based buffer split

Hello,

It seems you didn't try to address my main comment on v4:
"
Before doing anything, the first patch of this series should make
the current status clearer.
Example, this line does not explain what it does:
uint16_t split_hdr_size; /**< hdr buf size (header_split enabled).*/
And header_split has been removed in ab3ce1e0c193 ("ethdev: remove old offload API")

If RTE_ETH_RX_OFFLOAD_HEADER_SPLIT is not needed,
let's add a comment to start a deprecation.
"

Also the comment from Andrew about removing limitation to 2 packets is not addressed.

All the part about the protocols capability is missing here.

It is not encouraging.

26/04/2022 13:13, [email protected]:

Quoted 11 lines

From: Wenxuan Wu <[email protected]>

Protocol based buffer split consists of splitting a received packet into two separate regions based on its content. The split happens after the packet protocol header and before the packet payload. Splitting is usually between the packet protocol header that can be posted to a dedicated buffer and the packet payload that can be posted to a different buffer.

Currently, Rx buffer split supports length and offset based packet split. protocol split is based on buffer split, configuring length of buffer split is not suitable for NICs that do split based on protocol types.

Why? Is it impossible to support length split on Intel NIC?

Quoted 2 lines

Because tunneling makes the conversion from length to protocol type impossible.

This is not a HW issue.
I agree on the need but that a different usage than length split.

Quoted 10 lines

This patch extends the current buffer split to support protocol and offset based buffer split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and corresponding protocol type configured. PMD will split the ingress packets into two separate regions. Currently, both inner and outer L2/L3/L4 level protocol based buffer split can be supported.

For example, let's suppose we configured the Rx queue with the following segments:

Quoted 7 lines
    seg0 - pool0, off0=2B
    seg1 - pool1, off1=128B

With protocol split type configured with RTE_PTYPE_L4_UDP. The packet consists of MAC_IP_UDP_PAYLOAD will be splitted like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - payload @ 128 in mbuf from pool1

Not clear what is the calculation.

Quoted 27 lines

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 36 +++++++++++++++++++++++++++++-------
 lib/ethdev/rte_ethdev.h | 15 ++++++++++++++-
 2 files changed, 43 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c +1 -0
index 29a3d80466..1a2bc172ab 100644
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto = rx_seg[seg_idx].proto;
 
 		if (mpl == NULL) {
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1694,13 +1695,34 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		}

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1698

Quoted 10 lines
lib/ethdev/rte_ethdev.c +1 -7
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto == 0) {

Add a comment here, /* split at fixed length */

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1707

Quoted 9 lines
lib/ethdev/rte_ethdev.c +9 -0
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {

Add a comment here, /* split after specified protocol header */

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1709

Quoted 2 lines
lib/ethdev/rte_ethdev.c +2 -0
+			/* Ensure n_seg is 2 in protocol based buffer split. */
+			if (n_seg != 2)	{

(should be a space, not a tab before brace)

Why do you limit the feature to 2 segments only?

Quoted 15 lines
lib/ethdev/rte_ethdev.c +15 -0
+				RTE_ETHDEV_LOG(ERR, "number of buffer split protocol segments should be 2.\n");
+				return -EINVAL;
+			}
+			/* Length and protocol are exclusive here, so make sure length is 0 in protocol
+			based buffer split. */
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length should be set to zero in buffer split\n");
+				return -EINVAL;
+			}
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+						"%s mbuf_data_room_size %u < %u segment offset)\n",
+						mpl->name, *mbp_buf_size,
+						offset);
+				return -EINVAL;

[...]

Quoted 7 lines

+ * - The proto in the elements defines the split position of received packets.
+ *
* - If the length in the segment description element is zero
* the actual buffer size will be deduced from the appropriate
* memory pool properties.

lib/ethdev/rte_ethdev.c +0 -0
@@ -1197,12 +1200,21 @@ struct rte_eth_txmode {
  *     - pool from the last valid element

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1210

Quoted 10 lines
lib/ethdev/rte_ethdev.c +8 -0
  *     - the buffer size from this pool
  *     - zero offset
+ *
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
+ *     - The proto should not be configured in length split. Zero default.
+ *
+ * - Protocol based buffer split:
+ *     - mp, offset, proto should be configured.
+ *     - The length should not be configured in protocol split. Zero default.

What means "Zero default"?
You should just ignore the non relevant field.

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1204

Quoted 5 lines
lib/ethdev/rte_ethdev.c +0 -1
 struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */

How do you manage ABI compatibility?
Was the reserved field initialized to 0 in previous versions?

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1215

Quoted 1 line
lib/ethdev/rte_ethdev.c +1 -0
+	uint32_t proto; /**< Protocol of buffer split, determines protocol split point. */

What are the values for "proto"?

lib/ethdev/rte_ethdev.c struct rte_eth_conf { · line 1679

Quoted 5 lines
lib/ethdev/rte_ethdev.c +1 -0
@@ -1664,6 +1676,7 @@ struct rte_eth_conf {
 			     RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
 #define DEV_RX_OFFLOAD_VLAN RTE_DEPRECATED(DEV_RX_OFFLOAD_VLAN) RTE_ETH_RX_OFFLOAD_VLAN
 
+

It looks to be an useless change.

Quoted 4 lines
lib/ethdev/rte_ethdev.c +0 -0
 /*
  * If new Rx offload capabilities are defined, they also must be
  * mentioned in rte_rx_offload_names in rte_ethdev.c file.
author
#35 lore raw

RE: [PATCH v5 1/4] lib/ethdev: introduce protocol type based buffer split

Hi Thomas,

Quoted 25 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, May 18, 2022 5:12 AM
To: Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; Wu, WenxuanX <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Yu, Ping <[email protected]>
Subject: Re: [PATCH v5 1/4] lib/ethdev: introduce protocol type based buffer split

Hello,

It seems you didn't try to address my main comment on v4:
"
Before doing anything, the first patch of this series should make the current status clearer.
Example, this line does not explain what it does:
uint16_t split_hdr_size; /**< hdr buf size (header_split enabled).*/ And
header_split has been removed in ab3ce1e0c193 ("ethdev: remove old offload API")

Quoted 3 lines

If RTE_ETH_RX_OFFLOAD_HEADER_SPLIT is not needed, let's add a comment to start a deprecation.
"

Thank you for the detailed review.

First of all, I agree that header split should be deprecated.
Since it is unrelated with buffer split, I was planning to send the deprecation notice in 22.07 sometime later and start the deprecation in 22.11.

If you think it should be the first step, I will send the deprecation notice first.

Quoted 3 lines

Also the comment from Andrew about removing limitation to 2 packets is not addressed.

Secondly, it is said that the protocol based buffer split will divide the packet into two segments. Because I thought it will only be used in the split between header and payload.

In fact, protocol based buffer split can support multi-segment split. That is to say, like length-based buffer split, we define a series of protos, as the split point of protocol based buffer split. And this series of protos, like lengths, indicate the split location.

For example, a packet consists of MAC/IPV4/UDP/payload.
If we define the buffer split proto with IPV4, and UDP, the packet will be split into three segments:
seg0: MAC and IPV4 header, 34 bytes
seg1: UDP header, 8 bytes
seg2: Payload, the actual payload size

What do you think of this design?

Quoted 2 lines

All the part about the protocols capability is missing here.

Yes, I missed the protocols capability with RTE_PTYPE* now. I will update the doc with supported protocol capability in v6.

Quoted 11 lines

It is not encouraging.

26/04/2022 13:13, [email protected]:

Quoted 7 lines

From: Wenxuan Wu <[email protected]>

Protocol based buffer split consists of splitting a received packet into two separate regions based on its content. The split happens after the packet protocol header and before the packet payload. Splitting is usually between the packet protocol header that can be posted to a dedicated buffer and the packet payload that can be posted to

Quoted 7 lines

a different buffer.

Quoted 4 lines

Currently, Rx buffer split supports length and offset based packet split. protocol split is based on buffer split, configuring length of buffer split is not suitable for NICs that do split based on protocol types.

Why? Is it impossible to support length split on Intel NIC?

Yes, our NIC supports split based on protocol types. And I think there are other vendors too. The existence of tunneling results in the composition of a packet is various. Given a changeable length, it is impossible to tell the driver a fixed protocol type.

Quoted 6 lines
Quoted 3 lines

Because tunneling makes the conversion from length to protocol type impossible.

This is not a HW issue.
I agree on the need but that a different usage than length split.

I think the new usage can solve this problem, so that length split and proto split can have the same result.

Quoted 16 lines
Quoted 5 lines

This patch extends the current buffer split to support protocol and offset based buffer split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx queue offload

RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT

Quoted 1 line

enabled and corresponding protocol type configured. PMD will split the

ingress packets into two separate regions.

Quoted 8 lines

Currently, both inner and outer L2/L3/L4 level protocol based buffer split can be supported.

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, off0=2B
    seg1 - pool1, off1=128B
Quoted 6 lines
Quoted 4 lines

With protocol split type configured with RTE_PTYPE_L4_UDP. The packet consists of MAC_IP_UDP_PAYLOAD will be splitted like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - payload @ 128 in mbuf from pool1

Not clear what is the calculation.

The previous usage of protocol based split is the split between header and payload. Here for a packet composed of MAC_IP_UDP_PAYLOAD, with protocol split type RTE_PTYPE_L4_UDP configured, it means split between the UDP header and payload.
In length configuration, the proto = RTE_PTYPE_L4_UDP means length = 42B.

Quoted 39 lines
Quoted 3 lines

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and

external

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct

Quoted 16 lines

memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 36 +++++++++++++++++++++++++++++-------
 lib/ethdev/rte_ethdev.h | 15 ++++++++++++++-
 2 files changed, 43 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

29a3d80466..1a2bc172ab 100644

lib/ethdev/rte_ethdev.c +0 -0
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1667

Quoted 7 lines
lib/ethdev/rte_ethdev.c +1 -0
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto = rx_seg[seg_idx].proto;
 
 		if (mpl == NULL) {
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");

@@ -1694,13

Quoted 1 line

+1695,34 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
lib/ethdev/rte_ethdev.c +0 -4
 		}
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

Quoted 6 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1698

Quoted 4 lines
lib/ethdev/rte_ethdev.c +1 -3
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto == 0) {

Add a comment here, /* split at fixed length */

Thanks for the suggestion, will add it in next version.

Quoted 6 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 5 lines
lib/ethdev/rte_ethdev.c +4 -0
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

Quoted 7 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1707

Quoted 5 lines
lib/ethdev/rte_ethdev.c +5 -0
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {

Add a comment here, /* split after specified protocol header */

Thanks for the suggestion, will add it in next version.

Quoted 5 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1709

Quoted 3 lines
lib/ethdev/rte_ethdev.c +2 -0
+			/* Ensure n_seg is 2 in protocol based buffer split. */
+			if (n_seg != 2)	{

(should be a space, not a tab before brace)

Get it.

Quoted 2 lines

Why do you limit the feature to 2 segments only?

Please see the new usage explained above.

Quoted 33 lines

lib/ethdev/rte_ethdev.c

Quoted 2 lines
lib/ethdev/rte_ethdev.c +1 -0
+				RTE_ETHDEV_LOG(ERR, "number of buffer

split protocol segments should be 2.\n");

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 3 lines
lib/ethdev/rte_ethdev.c +3 -0
+				return -EINVAL;
+			}
+			/* Length and protocol are exclusive here, so make

sure length is 0 in protocol

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 3 lines
lib/ethdev/rte_ethdev.c +3 -0
+			based buffer split. */
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length

should be set to zero in buffer split\n");

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 5 lines
lib/ethdev/rte_ethdev.c +5 -0
+				return -EINVAL;
+			}
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+						"%s

mbuf_data_room_size %u < %u segment offset)\n",

Quoted 3 lines
lib/ethdev/rte_ethdev.c +3 -0
+						mpl->name, *mbp_buf_size,
+						offset);
+				return -EINVAL;

[...]

Quoted 12 lines

+ * - The proto in the elements defines the split position of received packets.
+ *
* - If the length in the segment description element is zero
* the actual buffer size will be deduced from the appropriate
* memory pool properties.

lib/ethdev/rte_ethdev.c +3 -0
@@ -1197,12 +1200,21 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
Quoted 8 lines

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1210

Quoted 5 lines
lib/ethdev/rte_ethdev.c +5 -0
+ *     - The proto should not be configured in length split. Zero default.
+ *
+ * - Protocol based buffer split:
+ *     - mp, offset, proto should be configured.
+ *     - The length should not be configured in protocol split. Zero default.

What means "Zero default"?
You should just ignore the non relevant field.

Yes, you are right, the none relevant field should be just ignored. I will update the doc in v6.

Quoted 11 lines

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1212

Quoted 3 lines
lib/ethdev/rte_ethdev.c +0 -0
 struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment

from. */

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1214

Quoted 2 lines
lib/ethdev/rte_ethdev.c +0 -0
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer.

*/

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1204

Quoted 1 line
lib/ethdev/rte_ethdev.c +0 -1
-	uint32_t reserved; /**< Reserved field. */

How do you manage ABI compatibility?
Was the reserved field initialized to 0 in previous versions?

I think we reached an agreement in RFC v1. There is no document for the reserved field in the previous release. And it is always initialized to zero in real cases. And now splitting based on fixed length and protocol header parsing is exclusive, we can ignore the none relevant field.

Quoted 5 lines

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1216

Quoted 3 lines
lib/ethdev/rte_ethdev.c +2 -0
+	uint32_t proto; /**< Protocol of buffer split, determines protocol
+split point. */

What are the values for "proto"?

Yes, I missed the protocol capability here, will fix it in v6.

Quoted 9 lines

lib/ethdev/rte_ethdev.c struct rte_eth_conf { · line 1676

Quoted 3 lines
lib/ethdev/rte_ethdev.c +0 -0
@@ -1664,6 +1676,7 @@ struct rte_eth_conf {
 			     RTE_ETH_RX_OFFLOAD_QINQ_STRIP)  #define

DEV_RX_OFFLOAD_VLAN

Quoted 3 lines

RTE_DEPRECATED(DEV_RX_OFFLOAD_VLAN) RTE_ETH_RX_OFFLOAD_VLAN

+

It looks to be an useless change.

Thanks for the catch, will fix it in next version.

Thanks again for your time.

Regards,
Xuan

Quoted 9 lines
Quoted 5 lines

/*
* If new Rx offload capabilities are defined, they also must be
* mentioned in rte_rx_offload_names in rte_ethdev.c file.

author
#36 lore raw

RE: [PATCH v5 1/4] lib/ethdev: introduce protocol type based buffer split

Hi,

Quoted 271 lines

-----Original Message-----
From: Ding, Xuan <[email protected]>
Sent: Thursday, May 19, 2022 10:40 PM
To: Thomas Monjalon <[email protected]>; Wang, YuanX <[email protected]>; Wu, WenxuanX <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Yu, Ping <[email protected]>
Subject: RE: [PATCH v5 1/4] lib/ethdev: introduce protocol type based buffer split

Hi Thomas,

Quoted 25 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, May 18, 2022 5:12 AM
To: Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; Wu, WenxuanX <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Yu, Ping <[email protected]>
Subject: Re: [PATCH v5 1/4] lib/ethdev: introduce protocol type based buffer split

Hello,

It seems you didn't try to address my main comment on v4:
"
Before doing anything, the first patch of this series should make the current status clearer.
Example, this line does not explain what it does:
uint16_t split_hdr_size; /**< hdr buf size (header_split
enabled).*/ And header_split has been removed in ab3ce1e0c193 ("ethdev: remove old offload API")

Quoted 1 line

If RTE_ETH_RX_OFFLOAD_HEADER_SPLIT is not needed, let's add a

comment

Quoted 2 lines

to start a deprecation.
"

Thank you for the detailed review.

First of all, I agree that header split should be deprecated. Since it is unrelated with buffer split, I was planning to send the deprecation notice in 22.07 sometime later and start the deprecation in 22.11.

If you think it should be the first step, I will send the deprecation notice first.

Quoted 3 lines

Also the comment from Andrew about removing limitation to 2 packets is not addressed.

Secondly, it is said that the protocol based buffer split will divide the packet into two segments.
Because I thought it will only be used in the split between header and payload.

In fact, protocol based buffer split can support multi-segment split. That is to say, like length-based buffer split, we define a series of protos, as the split point of protocol based buffer split. And this series of protos, like lengths, indicate the split location.

For example, a packet consists of MAC/IPV4/UDP/payload.
If we define the buffer split proto with IPV4, and UDP, the packet will be split into three segments:
seg0: MAC and IPV4 header, 34 bytes
seg1: UDP header, 8 bytes
seg2: Payload, the actual payload size

What do you think of this design?

Quoted 2 lines

All the part about the protocols capability is missing here.

Yes, I missed the protocols capability with RTE_PTYPE* now. I will update the doc with supported protocol capability in v6.

Quoted 12 lines

It is not encouraging.

26/04/2022 13:13, [email protected]:

Quoted 8 lines

From: Wenxuan Wu <[email protected]>

Protocol based buffer split consists of splitting a received packet into two separate regions based on its content. The split happens after the packet protocol header and before the packet payload. Splitting is usually between the packet protocol header that can be posted to a dedicated buffer and the packet payload that can be posted to

Quoted 7 lines

a different buffer.

Quoted 4 lines

Currently, Rx buffer split supports length and offset based packet split. protocol split is based on buffer split, configuring length of buffer split is not suitable for NICs that do split based on protocol types.

Why? Is it impossible to support length split on Intel NIC?

Yes, our NIC supports split based on protocol types. And I think there are other vendors too.
The existence of tunneling results in the composition of a packet is various. Given a changeable length, it is impossible to tell the driver a fixed protocol type.

Quoted 6 lines
Quoted 3 lines

Because tunneling makes the conversion from length to protocol type impossible.

This is not a HW issue.
I agree on the need but that a different usage than length split.

I think the new usage can solve this problem, so that length split and proto split can have the same result.

Quoted 20 lines
Quoted 5 lines

This patch extends the current buffer split to support protocol and offset based buffer split. A new proto field is introduced in the rte_eth_rxseg_split structure reserved field to specify header protocol type. With Rx queue offload

RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT

Quoted 2 lines

enabled and corresponding protocol type configured. PMD will split the

ingress packets into two separate regions.

Quoted 11 lines

Currently, both inner and outer L2/L3/L4 level protocol based buffer split can be supported.

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, off0=2B
    seg1 - pool1, off1=128B

With protocol split type configured with RTE_PTYPE_L4_UDP. The packet consists of MAC_IP_UDP_PAYLOAD will be splitted like following:
seg0 - udp header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from

pool0

Quoted 3 lines
Quoted 1 line

seg1 - payload @ 128 in mbuf from pool1

Not clear what is the calculation.

The previous usage of protocol based split is the split between header and payload.
Here for a packet composed of MAC_IP_UDP_PAYLOAD, with protocol split type RTE_PTYPE_L4_UDP configured, it means split between the UDP header and payload.
In length configuration, the proto = RTE_PTYPE_L4_UDP means length = 42B.

Quoted 39 lines
Quoted 3 lines

The memory attributes for the split parts may differ either - for example the mempool0 and mempool1 belong to dpdk memory and

external

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct

Quoted 16 lines

memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 36 +++++++++++++++++++++++++++++-------
 lib/ethdev/rte_ethdev.h | 15 ++++++++++++++-
 2 files changed, 43 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

29a3d80466..1a2bc172ab 100644

lib/ethdev/rte_ethdev.c +0 -0
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1667

Quoted 7 lines
lib/ethdev/rte_ethdev.c +1 -0
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto = rx_seg[seg_idx].proto;
 
 		if (mpl == NULL) {
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");

@@ -1694,13

Quoted 1 line

+1695,34 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
lib/ethdev/rte_ethdev.c +0 -4
 		}
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

Quoted 6 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1698

Quoted 4 lines
lib/ethdev/rte_ethdev.c +1 -3
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto == 0) {

Add a comment here, /* split at fixed length */

Thanks for the suggestion, will add it in next version.

Quoted 6 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 5 lines
lib/ethdev/rte_ethdev.c +4 -0
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

Quoted 7 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1707

Quoted 5 lines
lib/ethdev/rte_ethdev.c +5 -0
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {

Add a comment here, /* split after specified protocol header */

Thanks for the suggestion, will add it in next version.

Quoted 5 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1709

Quoted 3 lines
lib/ethdev/rte_ethdev.c +2 -0
+			/* Ensure n_seg is 2 in protocol based buffer split. */
+			if (n_seg != 2)	{

(should be a space, not a tab before brace)

Get it.

Quoted 2 lines

Why do you limit the feature to 2 segments only?

Please see the new usage explained above.

Quoted 17 lines

lib/ethdev/rte_ethdev.c

Quoted 2 lines
lib/ethdev/rte_ethdev.c +1 -0
+				RTE_ETHDEV_LOG(ERR, "number of buffer

split protocol segments should be 2.\n");

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 3 lines
lib/ethdev/rte_ethdev.c +3 -0
+				return -EINVAL;
+			}
+			/* Length and protocol are exclusive here, so make

sure length is 0 in protocol

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 3 lines
lib/ethdev/rte_ethdev.c +3 -0
+			based buffer split. */
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length

should be set to zero in buffer split\n");

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 5 lines
lib/ethdev/rte_ethdev.c +5 -0
+				return -EINVAL;
+			}
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+						"%s

mbuf_data_room_size %u < %u segment offset)\n",

Quoted 5 lines
Quoted 3 lines
lib/ethdev/rte_ethdev.c +3 -0
+						mpl->name, *mbp_buf_size,
+						offset);
+				return -EINVAL;

[...]

Quoted 1 line

+ * - The proto in the elements defines the split position of received

packets.

Quoted 11 lines
Quoted 11 lines

+ *
* - If the length in the segment description element is zero
* the actual buffer size will be deduced from the appropriate
* memory pool properties.

lib/ethdev/rte_ethdev.c +3 -0
@@ -1197,12 +1200,21 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
Quoted 8 lines

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1210

Quoted 5 lines
lib/ethdev/rte_ethdev.c +5 -0
+ *     - The proto should not be configured in length split. Zero default.
+ *
+ * - Protocol based buffer split:
+ *     - mp, offset, proto should be configured.
+ *     - The length should not be configured in protocol split. Zero default.

What means "Zero default"?
You should just ignore the non relevant field.

Quoted 2 lines

Yes, you are right, the none relevant field should be just ignored. I will update the doc in v6.

Sorry for replying myself.
After consideration, I found it is hard to just ignore the non-relevant field. Because when length and proto both exist, it is hard to decide whether it is length based buffer split or protocol based buffer split, which affects the check in rte_eth_rx_queue_check_split().

So I would like to keep the current design in v6. When choosing one mode of buffer split, the non-relevant field should not be configured.

Hope to get your feedbacks. :)

Regards,
Xuan

Quoted 54 lines
Quoted 4 lines

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1212

Quoted 4 lines
lib/ethdev/rte_ethdev.c +0 -0
 struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment
Quoted 8 lines

from. */

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1214

Quoted 2 lines
lib/ethdev/rte_ethdev.c +0 -0
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer.

*/

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1204

Quoted 1 line
lib/ethdev/rte_ethdev.c +0 -1
-	uint32_t reserved; /**< Reserved field. */

How do you manage ABI compatibility?
Was the reserved field initialized to 0 in previous versions?

I think we reached an agreement in RFC v1. There is no document for the reserved field in the previous release. And it is always initialized to zero in real cases.
And now splitting based on fixed length and protocol header parsing is exclusive, we can ignore the none relevant field.

Quoted 5 lines

lib/ethdev/rte_ethdev.c struct rte_eth_txmode { · line 1216

Quoted 3 lines
lib/ethdev/rte_ethdev.c +2 -0
+	uint32_t proto; /**< Protocol of buffer split, determines protocol
+split point. */

What are the values for "proto"?

Yes, I missed the protocol capability here, will fix it in v6.

Quoted 5 lines

lib/ethdev/rte_ethdev.c struct rte_eth_conf { · line 1676

Quoted 3 lines
lib/ethdev/rte_ethdev.c +0 -0
@@ -1664,6 +1676,7 @@ struct rte_eth_conf {
 			     RTE_ETH_RX_OFFLOAD_QINQ_STRIP)  #define

DEV_RX_OFFLOAD_VLAN

Quoted 1 line
lib/ethdev/rte_ethdev.c +0 -0
 RTE_DEPRECATED(DEV_RX_OFFLOAD_VLAN)

RTE_ETH_RX_OFFLOAD_VLAN

Quoted 4 lines

lib/ethdev/rte_ethdev.c struct rte_eth_conf { · line 1678

Quoted 2 lines
lib/ethdev/rte_ethdev.c +1 -0
+

It looks to be an useless change.

Thanks for the catch, will fix it in next version.

Thanks again for your time.

Regards,
Xuan

Quoted 9 lines
Quoted 5 lines
lib/ethdev/rte_ethdev.c +0 -0
 /*
  * If new Rx offload capabilities are defined, they also must be
  * mentioned in rte_rx_offload_names in rte_ethdev.c file.
 
#37 lore raw

PATCH v5 2/4 app/testpmd: add proto based buffer split config

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

This patch adds protocol based buffer split configuration in testpmd. The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with two mempools. e.g. --mbuf-size=2048,2048
2. Configure Rx queue with rx_offload buffer split on.
3. Set the protocol type of buffer split.

Testpmd View:
testpmd>port config <port_id> rx_offload buffer_split on testpmd>port config <port_id> buffer_split mac|ipv4|ipv6|l3|tcp|udp|sctp|

                    l4|inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|
                    inner_udp|inner_sctp|inner_l4
---
 app/test-pmd/cmdline.c | 118 +++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c |   7 +--
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 124 insertions(+), 3 deletions(-)
app/test-pmd/cmdline.c +118 -0
index 6ffea8e21a..5cd4beca95 100644
@@ -866,6 +866,12 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"     Enable or disable a per port Rx offloading"
 			" on all Rx queues of a port\n\n"
 
+			"port config <port_id> buffer_split mac|ipv4|ipv6|l3|tcp|udp|sctp|l4|"
+			"inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|"
+			"inner_udp|inner_sctp|inner_l4\n"
+			"     Configure protocol type for buffer split"
+			" on all Rx queues of a port\n\n"
+
 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
 			"outer_ipv4_cksum|macsec_strip|header_split|"
@@ -16353,6 +16359,117 @@ cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
 	}
 };
 
+/* config a per port buffer split protocol */
+struct cmd_config_per_port_buffer_split_protocol_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t config;
+	uint16_t port_id;
+	cmdline_fixed_string_t buffer_split;
+	cmdline_fixed_string_t protocol;
+};
+
+cmdline_parse_token_string_t cmd_config_per_port_buffer_split_protocol_result_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_buffer_split_protocol_result,
+		 port, "port");
+cmdline_parse_token_string_t cmd_config_per_port_buffer_split_protocol_result_config =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_buffer_split_protocol_result,
+		 config, "config");
+cmdline_parse_token_num_t cmd_config_per_port_buffer_split_protocol_result_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_config_per_port_buffer_split_protocol_result,
+		 port_id, RTE_UINT16);
+cmdline_parse_token_string_t cmd_config_per_port_buffer_split_protocol_result_buffer_split =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_buffer_split_protocol_result,
+		 buffer_split, "buffer_split");
+cmdline_parse_token_string_t cmd_config_per_port_buffer_split_protocol_result_protocol =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_buffer_split_protocol_result,
+		 protocol, "mac#ipv4#ipv6#l3#tcp#udp#sctp#l4#"
+			   "inner_mac#inner_ipv4#inner_ipv6#inner_l3#inner_tcp#"
+			   "inner_udp#inner_sctp#inner_l4");
+
+static void
+cmd_config_per_port_buffer_split_protocol_parsed(void *parsed_result,
+				__rte_unused struct cmdline *cl,
+				__rte_unused void *data)
+{
+	struct cmd_config_per_port_buffer_split_protocol_result *res = parsed_result;
+	portid_t port_id = res->port_id;
+	struct rte_port *port = &ports[port_id];
+	uint32_t protocol;
+
+	if (port_id_is_invalid(port_id, ENABLED_WARN))
+		return;
+
+	if (port->port_status != RTE_PORT_STOPPED) {
+		fprintf(stderr,
+			"Error: Can't config offload when Port %d is not stopped\n",
+			port_id);
+		return;
+	}
+
+	if (!strcmp(res->protocol, "mac"))
+		protocol = RTE_PTYPE_L2_ETHER;
+	else if (!strcmp(res->protocol, "ipv4"))
+		protocol = RTE_PTYPE_L3_IPV4;
+	else if (!strcmp(res->protocol, "ipv6"))
+		protocol = RTE_PTYPE_L3_IPV6;
+	else if (!strcmp(res->protocol, "l3"))
+		protocol = RTE_PTYPE_L3_IPV4|RTE_PTYPE_L3_IPV6;
+	else if (!strcmp(res->protocol, "tcp"))
+		protocol = RTE_PTYPE_L4_TCP;
+	else if (!strcmp(res->protocol, "udp"))
+		protocol = RTE_PTYPE_L4_UDP;
+	else if (!strcmp(res->protocol, "sctp"))
+		protocol = RTE_PTYPE_L4_SCTP;
+	else if (!strcmp(res->protocol, "l4"))
+		protocol = RTE_PTYPE_L4_TCP|RTE_PTYPE_L4_UDP|RTE_PTYPE_L4_SCTP;
+	else if (!strcmp(res->protocol, "inner_mac"))
+		protocol = RTE_PTYPE_INNER_L2_ETHER;
+	else if (!strcmp(res->protocol, "inner_ipv4"))
+		protocol = RTE_PTYPE_INNER_L3_IPV4;
+	else if (!strcmp(res->protocol, "inner_ipv6"))
+		protocol = RTE_PTYPE_INNER_L3_IPV6;
+	else if (!strcmp(res->protocol, "inner_l3"))
+		protocol = RTE_PTYPE_INNER_L3_IPV4|RTE_PTYPE_INNER_L3_IPV6;
+	else if (!strcmp(res->protocol, "inner_tcp"))
+		protocol = RTE_PTYPE_INNER_L4_TCP;
+	else if (!strcmp(res->protocol, "inner_udp"))
+		protocol = RTE_PTYPE_INNER_L4_UDP;
+	else if (!strcmp(res->protocol, "inner_sctp"))
+		protocol = RTE_PTYPE_INNER_L4_SCTP;
+	else if (!strcmp(res->protocol, "inner_l4"))
+		protocol = RTE_PTYPE_INNER_L4_TCP|RTE_PTYPE_INNER_L4_UDP|RTE_PTYPE_INNER_L4_SCTP;
+	else {
+		fprintf(stderr, "Unknown protocol name: %s\n", res->protocol);
+		return;
+	}
+
+	rx_pkt_buffer_split_proto = protocol;
+	rx_pkt_nb_segs = 2;
+
+	cmd_reconfig_device_queue(port_id, 1, 1);
+}
+
+cmdline_parse_inst_t cmd_config_per_port_buffer_split_protocol = {
+	.f = cmd_config_per_port_buffer_split_protocol_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> buffer_split mac|ipv4|ipv6|l3|tcp|udp|sctp|l4|"
+		    "inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|"
+		    "inner_udp|inner_sctp|inner_l4",
+	.tokens = {
+		(void *)&cmd_config_per_port_buffer_split_protocol_result_port,
+		(void *)&cmd_config_per_port_buffer_split_protocol_result_config,
+		(void *)&cmd_config_per_port_buffer_split_protocol_result_port_id,
+		(void *)&cmd_config_per_port_buffer_split_protocol_result_buffer_split,
+		(void *)&cmd_config_per_port_buffer_split_protocol_result_protocol,
+		NULL,
+	}
+};
+
 /* Enable/Disable a per queue offloading */
 struct cmd_config_per_queue_rx_offload_result {
 	cmdline_fixed_string_t port;
@@ -18071,6 +18188,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
+	(cmdline_parse_inst_t *)&cmd_config_per_port_buffer_split_protocol,
 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
app/test-pmd/testpmd.c +4 -3
index fe2ce19f99..bd77d6bf10 100644
@@ -253,6 +253,8 @@ uint8_t  tx_pkt_nb_segs = 1; /**< Number of segments in TXONLY packets */
 enum tx_pkt_split tx_pkt_split = TX_PKT_SPLIT_OFF;
 /**< Split policy for packets to TX. */
 
+uint32_t rx_pkt_buffer_split_proto;
+
 uint8_t txonly_multi_flow;
 /**< Whether multiple flows are generated in TXONLY mode. */
 
@@ -2586,12 +2588,11 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		mp_n = (i > mbuf_data_size_n) ? mbuf_data_size_n - 1 : i;
 		mpx = mbuf_pool_find(socket_id, mp_n);
 		/* Handle zero as mbuf data buffer size. */
-		rx_seg->length = rx_pkt_seg_lengths[i] ?
-				   rx_pkt_seg_lengths[i] :
-				   mbuf_data_size[mp_n];
+		rx_seg->length = rx_pkt_seg_lengths[i];
 		rx_seg->offset = i < rx_pkt_nb_offs ?
 				   rx_pkt_seg_offsets[i] : 0;
 		rx_seg->mp = mpx ? mpx : mp;
+		rx_seg->proto = rx_pkt_buffer_split_proto;
 	}
 	rx_conf->rx_nseg = rx_pkt_nb_segs;
 	rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +2 -0
index 31f766c965..707e1781d4 100644
@@ -557,6 +557,8 @@ enum tx_pkt_split {
 
 extern enum tx_pkt_split tx_pkt_split;
 
+extern uint32_t rx_pkt_buffer_split_proto;
+
 extern uint8_t txonly_multi_flow;
 
 extern uint32_t rxq_share;
Signature · 1 line
2.25.1
#38 lore raw

PATCH v5 3/4 net/ice: support proto based buf split in Rx path

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

This patch adds support for proto based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly splitted into protocol header and payload parts. And the two parts will be put into different mempools.

Currently, protocol based buffer split is not supported in vectorized paths.

---
 drivers/net/ice/ice_ethdev.c          |  10 +-
 drivers/net/ice/ice_rxtx.c            | 219 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 4 files changed, 216 insertions(+), 32 deletions(-)
drivers/net/ice/ice_ethdev.c +8 -2
index 73e550f5fb..ce3f49c863 100644
@@ -3713,7 +3713,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 			RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 			RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |
 			RTE_ETH_RX_OFFLOAD_RSS_HASH |
-			RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+			RTE_ETH_RX_OFFLOAD_TIMESTAMP |
+			RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT;
 		dev_info->tx_offload_capa |=
 			RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
 			RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -3725,7 +3726,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->flow_type_rss_offloads |= ICE_RSS_OFFLOAD_ALL;
 	}
 
-	dev_info->rx_queue_offload_capa = 0;
+	dev_info->rx_queue_offload_capa = RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT;
 	dev_info->tx_queue_offload_capa = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->reta_size = pf->hash_lut_size;
@@ -3794,6 +3795,11 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->default_rxportconf.ring_size = ICE_BUF_SIZE_MIN;
 	dev_info->default_txportconf.ring_size = ICE_BUF_SIZE_MIN;
 
+	dev_info->rx_seg_capa.max_nseg = ICE_RX_MAX_NSEG;
+	dev_info->rx_seg_capa.multi_pools = 1;
+	dev_info->rx_seg_capa.offset_allowed = 0;
+	dev_info->rx_seg_capa.offset_align_log2 = 0;
+
 	return 0;
 }
 
drivers/net/ice/ice_rxtx.c +189 -30

361 lines not on this page · raw message

drivers/net/ice/ice_rxtx.h +16 -0
index bb18a01951..611dbc8503 100644
@@ -16,6 +16,9 @@
 #define ICE_RX_MAX_BURST 32
 #define ICE_TX_MAX_BURST 32
 
+/* Maximal number of segments to split. */
+#define ICE_RX_MAX_NSEG 2
+
 #define ICE_CHK_Q_ENA_COUNT        100
 #define ICE_CHK_Q_ENA_INTERVAL_US  100
 
@@ -43,6 +46,11 @@
 extern uint64_t ice_timestamp_dynflag;
 extern int ice_timestamp_dynfield_offset;
 
+/* Max header size can be 2K - 64 bytes */
+#define ICE_RX_HDR_BUF_SIZE    (2048 - 64)
+
+#define ICE_HEADER_SPLIT_ENA   BIT(0)
+
 typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);
 typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq);
 typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {
 	struct rte_mbuf *mbuf;
 };
 
+enum ice_rx_dtype {
+	ICE_RX_DTYPE_NO_SPLIT       = 0,
+	ICE_RX_DTYPE_HEADER_SPLIT   = 1,
+	ICE_RX_DTYPE_SPLIT_ALWAYS   = 2,
+};
+
 struct ice_rx_queue {
 	struct rte_mempool *mp; /* mbuf pool to populate RX ring */
 	volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -95,6 +109,8 @@ struct ice_rx_queue {
 	uint32_t time_high;
 	uint32_t hw_register_set;
 	const struct rte_memzone *mz;
+	struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG];
+	uint32_t rxseg_nb;
 };
 
 struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
index 2dd2d83650..eec6ea2134 100644
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)
 	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
 		return -1;
 
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)
+		return -1;
+
 	if (rxq->offloads & ICE_RX_VECTOR_OFFLOAD)
 		return ICE_VECTOR_OFFLOAD_PATH;
 
Signature · 1 line
2.25.1
#39 lore raw

PATCH v4 2/3 app/testpmd: add header split configuration

In reply to [email protected]

From: Xuan Ding <[email protected]>

This patch adds header split configuration in testpmd. The header split feature is off by default. To enable header split, you need:
1. Configure Rx queue with rx_offload header split on.
2. Set the protocol type of header split.

Command for set header split protocol type:
testpmd> port config <port_id> header_split mac|ipv4|ipv6|l3|tcp|udp|sctp|

		    l4|inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|
		    inner_udp|inner_sctp|inner_l4
---
 app/test-pmd/cmdline.c | 117 +++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c |   6 ++-
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 124 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +117 -0
index 6ffea8e21a..abda81b4bc 100644
@@ -866,6 +866,12 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"     Enable or disable a per port Rx offloading"
 			" on all Rx queues of a port\n\n"
 
+			"port config <port_id> header_split mac|ipv4|ipv6|l3|tcp|udp|sctp|l4|"
+			"inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|"
+			"inner_udp|inner_sctp|inner_l4\n"
+			"     Configure protocol for header split"
+			" on all Rx queues of a port\n\n"
+
 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
 			"outer_ipv4_cksum|macsec_strip|header_split|"
@@ -16353,6 +16359,116 @@ cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
 	}
 };
 
+/* config a per port header split protocol */
+struct cmd_config_per_port_headersplit_protocol_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t config;
+	uint16_t port_id;
+	cmdline_fixed_string_t headersplit;
+	cmdline_fixed_string_t protocol;
+};
+
+cmdline_parse_token_string_t cmd_config_per_port_headersplit_protocol_result_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 port, "port");
+cmdline_parse_token_string_t cmd_config_per_port_headersplit_protocol_result_config =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 config, "config");
+cmdline_parse_token_num_t cmd_config_per_port_headersplit_protocol_result_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 port_id, RTE_UINT16);
+cmdline_parse_token_string_t cmd_config_per_port_headersplit_protocol_result_headersplit =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 headersplit, "header_split");
+cmdline_parse_token_string_t cmd_config_per_port_headersplit_protocol_result_protocol =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_per_port_headersplit_protocol_result,
+		 protocol, "mac#ipv4#ipv6#l3#tcp#udp#sctp#l4#"
+			   "inner_mac#inner_ipv4#inner_ipv6#inner_l3#inner_tcp#"
+			   "inner_udp#inner_sctp#inner_l4");
+
+static void
+cmd_config_per_port_headersplit_protocol_parsed(void *parsed_result,
+				__rte_unused struct cmdline *cl,
+				__rte_unused void *data)
+{
+	struct cmd_config_per_port_headersplit_protocol_result *res = parsed_result;
+	portid_t port_id = res->port_id;
+	struct rte_port *port = &ports[port_id];
+	uint16_t protocol;
+
+	if (port_id_is_invalid(port_id, ENABLED_WARN))
+		return;
+
+	if (port->port_status != RTE_PORT_STOPPED) {
+		fprintf(stderr,
+			"Error: Can't config offload when Port %d is not stopped\n",
+			port_id);
+		return;
+	}
+
+	if (!strcmp(res->protocol, "mac"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_MAC;
+	else if (!strcmp(res->protocol, "ipv4"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_IPV4;
+	else if (!strcmp(res->protocol, "ipv6"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_IPV6;
+	else if (!strcmp(res->protocol, "l3"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_L3;
+	else if (!strcmp(res->protocol, "tcp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_TCP;
+	else if (!strcmp(res->protocol, "udp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_UDP;
+	else if (!strcmp(res->protocol, "sctp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_SCTP;
+	else if (!strcmp(res->protocol, "l4"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_L4;
+	else if (!strcmp(res->protocol, "inner_mac"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_MAC;
+	else if (!strcmp(res->protocol, "inner_ipv4"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_IPV4;
+	else if (!strcmp(res->protocol, "inner_ipv6"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_IPV6;
+	else if (!strcmp(res->protocol, "inner_l3"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_L3;
+	else if (!strcmp(res->protocol, "inner_tcp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_TCP;
+	else if (!strcmp(res->protocol, "inner_udp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_UDP;
+	else if (!strcmp(res->protocol, "inner_sctp"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_SCTP;
+	else if (!strcmp(res->protocol, "inner_l4"))
+		protocol = RTE_ETH_RX_HEADER_SPLIT_INNER_L4;
+	else {
+		fprintf(stderr, "Unknown protocol name: %s\n", res->protocol);
+		return;
+	}
+
+	rx_pkt_header_split_proto = protocol;
+
+	cmd_reconfig_device_queue(port_id, 1, 1);
+}
+
+cmdline_parse_inst_t cmd_config_per_port_headersplit_protocol = {
+	.f = cmd_config_per_port_headersplit_protocol_parsed,
+	.data = NULL,
+	.help_str = "port config <port_id> header_split mac|ipv4|ipv6|l3|tcp|udp|sctp|l4|"
+		    "inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|"
+		    "inner_udp|inner_sctp|inner_l4",
+	.tokens = {
+		(void *)&cmd_config_per_port_headersplit_protocol_result_port,
+		(void *)&cmd_config_per_port_headersplit_protocol_result_config,
+		(void *)&cmd_config_per_port_headersplit_protocol_result_port_id,
+		(void *)&cmd_config_per_port_headersplit_protocol_result_headersplit,
+		(void *)&cmd_config_per_port_headersplit_protocol_result_protocol,
+		NULL,
+	}
+};
+
 /* Enable/Disable a per queue offloading */
 struct cmd_config_per_queue_rx_offload_result {
 	cmdline_fixed_string_t port;
@@ -18071,6 +18187,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
+	(cmdline_parse_inst_t *)&cmd_config_per_port_headersplit_protocol,
 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
app/test-pmd/testpmd.c +5 -1
index fe2ce19f99..a00fa0e236 100644
@@ -253,6 +253,8 @@ uint8_t  tx_pkt_nb_segs = 1; /**< Number of segments in TXONLY packets */
 enum tx_pkt_split tx_pkt_split = TX_PKT_SPLIT_OFF;
 /**< Split policy for packets to TX. */
 
+uint8_t rx_pkt_header_split_proto;
+
 uint8_t txonly_multi_flow;
 /**< Whether multiple flows are generated in TXONLY mode. */
 
@@ -2568,7 +2570,8 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 	int ret;
 
 	if (rx_pkt_nb_segs <= 1 ||
-	    (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) == 0) {
+	    (((rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) == 0) &&
+	     ((rx_conf->offloads & RTE_ETH_RX_OFFLOAD_HEADER_SPLIT) == 0))) {
 		rx_conf->rx_seg = NULL;
 		rx_conf->rx_nseg = 0;
 		ret = rte_eth_rx_queue_setup(port_id, rx_queue_id,
@@ -2592,6 +2595,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		rx_seg->offset = i < rx_pkt_nb_offs ?
 				   rx_pkt_seg_offsets[i] : 0;
 		rx_seg->mp = mpx ? mpx : mp;
+		rx_seg->proto = rx_pkt_header_split_proto;
 	}
 	rx_conf->rx_nseg = rx_pkt_nb_segs;
 	rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +2 -0
index 31f766c965..021e2768be 100644
@@ -557,6 +557,8 @@ enum tx_pkt_split {
 
 extern enum tx_pkt_split tx_pkt_split;
 
+extern uint8_t rx_pkt_header_split_proto;
+
 extern uint8_t txonly_multi_flow;
 
 extern uint32_t rxq_share;
Signature · 1 line
2.17.1
#40 lore raw

PATCH v4 3/3 net/ice: support header split in Rx data path

In reply to [email protected]

From: Xuan Ding <[email protected]>

This patch adds support for header split in normal Rx data paths. When the Rx queue is configured with header split for specific protocol type, packets received will be directly splited into header and payload parts. And the two parts will be put into different mempools.

Currently, header split is not supported in vectorized paths.

---
 drivers/net/ice/ice_ethdev.c          |  10 +-
 drivers/net/ice/ice_rxtx.c            | 223 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 4 files changed, 221 insertions(+), 31 deletions(-)
drivers/net/ice/ice_ethdev.c +8 -2
index 13adcf90ed..cb32265dbe 100644
@@ -3713,7 +3713,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 			RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 			RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |
 			RTE_ETH_RX_OFFLOAD_RSS_HASH |
-			RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+			RTE_ETH_RX_OFFLOAD_TIMESTAMP |
+			RTE_ETH_RX_OFFLOAD_HEADER_SPLIT;
 		dev_info->tx_offload_capa |=
 			RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
 			RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -3725,7 +3726,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->flow_type_rss_offloads |= ICE_RSS_OFFLOAD_ALL;
 	}
 
-	dev_info->rx_queue_offload_capa = 0;
+	dev_info->rx_queue_offload_capa = RTE_ETH_RX_OFFLOAD_HEADER_SPLIT;
 	dev_info->tx_queue_offload_capa = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->reta_size = pf->hash_lut_size;
@@ -3794,6 +3795,11 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->default_rxportconf.ring_size = ICE_BUF_SIZE_MIN;
 	dev_info->default_txportconf.ring_size = ICE_BUF_SIZE_MIN;
 
+	dev_info->rx_seg_capa.max_nseg = ICE_RX_MAX_NSEG;
+	dev_info->rx_seg_capa.multi_pools = 1;
+	dev_info->rx_seg_capa.offset_allowed = 0;
+	dev_info->rx_seg_capa.offset_align_log2 = 0;
+
 	return 0;
 }
 
drivers/net/ice/ice_rxtx.c +194 -29

359 lines not on this page · raw message

drivers/net/ice/ice_rxtx.h +16 -0
index bb18a01951..611dbc8503 100644
@@ -16,6 +16,9 @@
 #define ICE_RX_MAX_BURST 32
 #define ICE_TX_MAX_BURST 32
 
+/* Maximal number of segments to split. */
+#define ICE_RX_MAX_NSEG 2
+
 #define ICE_CHK_Q_ENA_COUNT        100
 #define ICE_CHK_Q_ENA_INTERVAL_US  100
 
@@ -43,6 +46,11 @@
 extern uint64_t ice_timestamp_dynflag;
 extern int ice_timestamp_dynfield_offset;
 
+/* Max header size can be 2K - 64 bytes */
+#define ICE_RX_HDR_BUF_SIZE    (2048 - 64)
+
+#define ICE_HEADER_SPLIT_ENA   BIT(0)
+
 typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);
 typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq);
 typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {
 	struct rte_mbuf *mbuf;
 };
 
+enum ice_rx_dtype {
+	ICE_RX_DTYPE_NO_SPLIT       = 0,
+	ICE_RX_DTYPE_HEADER_SPLIT   = 1,
+	ICE_RX_DTYPE_SPLIT_ALWAYS   = 2,
+};
+
 struct ice_rx_queue {
 	struct rte_mempool *mp; /* mbuf pool to populate RX ring */
 	volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -95,6 +109,8 @@ struct ice_rx_queue {
 	uint32_t time_high;
 	uint32_t hw_register_set;
 	const struct rte_memzone *mz;
+	struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG];
+	uint32_t rxseg_nb;
 };
 
 struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
index 2dd2d83650..7a155a66f2 100644
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)
 	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
 		return -1;
 
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_HEADER_SPLIT)
+		return -1;
+
 	if (rxq->offloads & ICE_RX_VECTOR_OFFLOAD)
 		return ICE_VECTOR_OFFLOAD_PATH;
 
Signature · 1 line
2.17.1
#41 lore raw

PATCH v6 1/1 ethdev: introduce protocol header based buffer split

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet segment configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet segment, it is almost impossible to pass a fixed protocol header to PMD. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding protocol header is configured, PMD will split the ingress packets into multiple segments.

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Both inner and outer L2/L3/L4 level protocol header split can be supported. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP, RTE_PTYPE_INNER_L4_SCTP.

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
    seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
    seg2 - pool2, off1=0B

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 40 +++++++++++++++++++++++++++++++++-------
 lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c +33 -7
index 8520aec561..20c1c246ce 100644
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;
 
 		if (mpl == NULL) {
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1694,13 +1695,38 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		}
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+			/* Split at fixed length. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Split after specified protocol header. */
+			if (proto_hdr & RTE_BUFFER_SPLIT_PROTO_HDR_MASK) {
+				RTE_ETHDEV_LOG(ERR,
+					"Protocol header %u not supported)\n",
+					proto_hdr);
+				return -EINVAL;
+			}
+
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length should be set to zero in protocol header "
+					       "based buffer split\n");
+				return -EINVAL;
+			}
+
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+						"%s mbuf_data_room_size %u < %u segment offset)\n",
+						mpl->name, *mbp_buf_size,
+						offset);
+				return -EINVAL;
+			}
 		}
 	}
 	return 0;
lib/ethdev/rte_ethdev.h +27 -1
index 04cff8ee10..0cd9dd6cc0 100644
@@ -1187,6 +1187,9 @@ struct rte_eth_txmode {
  *   mbuf) the following data will be pushed to the next segment
  *   up to its own length, and so on.
  *
+ * - The proto_hdrs in the elements define the split position of
+ *   received packets.
+ *
  * - If the length in the segment description element is zero
  *   the actual buffer size will be deduced from the appropriate
  *   memory pool properties.
@@ -1197,14 +1200,37 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
+ *     - The proto_hdr field should not be configured.
+ *
+ * - Protocol header based buffer split:
+ *     - mp, offset, proto_hdr should be configured.
+ *     - The length field should not be configured.
  */
 struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint32_t proto_hdr; /**< Inner/outer L2/L3/L4 protocol header, configures split point. */
 };
 
+/* Buffer split protocol header capability. */
+#define RTE_BUFFER_SPLIT_PROTO_HDR_MASK ( \
+	RTE_PTYPE_L2_ETHER | \
+	RTE_PTYPE_L3_IPV4 | \
+	RTE_PTYPE_L3_IPV6 | \
+	RTE_PTYPE_L4_TCP | \
+	RTE_PTYPE_L4_UDP | \
+	RTE_PTYPE_L4_SCTP | \
+	RTE_PTYPE_INNER_L2_ETHER | \
+	RTE_PTYPE_INNER_L3_IPV4 | \
+	RTE_PTYPE_INNER_L3_IPV6 | \
+	RTE_PTYPE_INNER_L4_TCP | \
+	RTE_PTYPE_INNER_L4_UDP | \
+	RTE_PTYPE_INNER_L4_SCTP)
+
 /**
  * @warning
  * @b EXPERIMENTAL: this structure may change without prior notice.
Signature · 1 line
2.17.1
#42 lore raw

v6 cover ethdev: introduce protocol based buffer split

In reply to [email protected]

From: Xuan Ding <[email protected]>

Protocol based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.

This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload and corresponding protocol, packets received will be directly split into different mempools.

v5->v6:
* The header split deprecation notice is sent.
* Refine the documents, protocol header based buffer split can actually support multi-segment split.
* Add buffer split protocol header capability.
* Fix some format issues.

v4->v5:
* Use protocol and mbuf_offset based buffer split instead of header split.
* Use RTE_PTYPE* instead of enum rte_eth_rx_header_split_protocol_type.
* Improve the description of rte_eth_rxseg_split.proto.

v3->v4:
* Use RTE_ETH_RX_HEADER_SPLIT_NONE instead of 0.

v2->v3:
* Fix a PMD bug.
* Add rx queue header split check.
* Revise the log and doc.

v1->v2:
* Add support for all header split protocol types.

Wenxuan Wu (1):
ethdev: introduce protocol header based buffer split

 lib/ethdev/rte_ethdev.c | 40 +++++++++++++++++++++++++++++++++-------
 lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 8 deletions(-)
Signature · 1 line
2.17.1
#43 lore raw

PATCH v6 1/1 ethdev: introduce protocol header based buffer split

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet segment configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet segment, it is almost impossible to pass a fixed protocol header to PMD. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding protocol header is configured, PMD will split the ingress packets into multiple segments.

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Both inner and outer L2/L3/L4 level protocol header split can be supported. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP, RTE_PTYPE_INNER_L4_SCTP.

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
    seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
    seg2 - pool2, off1=0B

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 40 +++++++++++++++++++++++++++++++++-------
 lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c +33 -7
index 8520aec561..20c1c246ce 100644
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;
 
 		if (mpl == NULL) {
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1694,13 +1695,38 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		}
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+			/* Split at fixed length. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Split after specified protocol header. */
+			if (proto_hdr & RTE_BUFFER_SPLIT_PROTO_HDR_MASK) {
+				RTE_ETHDEV_LOG(ERR,
+					"Protocol header %u not supported)\n",
+					proto_hdr);
+				return -EINVAL;
+			}
+
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length should be set to zero in protocol header "
+					       "based buffer split\n");
+				return -EINVAL;
+			}
+
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+						"%s mbuf_data_room_size %u < %u segment offset)\n",
+						mpl->name, *mbp_buf_size,
+						offset);
+				return -EINVAL;
+			}
 		}
 	}
 	return 0;
lib/ethdev/rte_ethdev.h +27 -1
index 04cff8ee10..0cd9dd6cc0 100644
@@ -1187,6 +1187,9 @@ struct rte_eth_txmode {
  *   mbuf) the following data will be pushed to the next segment
  *   up to its own length, and so on.
  *
+ * - The proto_hdrs in the elements define the split position of
+ *   received packets.
+ *
  * - If the length in the segment description element is zero
  *   the actual buffer size will be deduced from the appropriate
  *   memory pool properties.
@@ -1197,14 +1200,37 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
+ *     - The proto_hdr field should not be configured.
+ *
+ * - Protocol header based buffer split:
+ *     - mp, offset, proto_hdr should be configured.
+ *     - The length field should not be configured.
  */
 struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint32_t proto_hdr; /**< Inner/outer L2/L3/L4 protocol header, configures split point. */
 };
 
+/* Buffer split protocol header capability. */
+#define RTE_BUFFER_SPLIT_PROTO_HDR_MASK ( \
+	RTE_PTYPE_L2_ETHER | \
+	RTE_PTYPE_L3_IPV4 | \
+	RTE_PTYPE_L3_IPV6 | \
+	RTE_PTYPE_L4_TCP | \
+	RTE_PTYPE_L4_UDP | \
+	RTE_PTYPE_L4_SCTP | \
+	RTE_PTYPE_INNER_L2_ETHER | \
+	RTE_PTYPE_INNER_L3_IPV4 | \
+	RTE_PTYPE_INNER_L3_IPV6 | \
+	RTE_PTYPE_INNER_L4_TCP | \
+	RTE_PTYPE_INNER_L4_UDP | \
+	RTE_PTYPE_INNER_L4_SCTP)
+
 /**
  * @warning
  * @b EXPERIMENTAL: this structure may change without prior notice.
Signature · 1 line
2.17.1
Acked-by on v6 1/1
#44 lore raw

Re: [PATCH v6 1/1] ethdev: introduce protocol header based buffer split

Quoted 63 lines · [email protected] writes:

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet segment configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet segment, it is almost impossible to pass a fixed protocol header to PMD. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding protocol header is configured, PMD will split the ingress packets into multiple segments.

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Both inner and outer L2/L3/L4 level protocol header split can be supported. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP, RTE_PTYPE_INNER_L4_SCTP.

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
    seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
    seg2 - pool2, off1=0B

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.

Quoted 9 lines
---
 lib/ethdev/rte_ethdev.c | 40 +++++++++++++++++++++++++++++++++-------
 lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 8 deletions(-)
#45 lore raw

v7 cover ethdev: introduce protocol type based header split

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

Buffer split consists of splitting a received packet into two separate regions based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.

This patchset extends the current buffer split to support multi protocol headers split. When Rx queue is configured with buffer split feature, packets received will be directly splitted into two different mempools.

v6->v7:
*fix supported header protocol check.
*add rxhdrs commands and parameters.
v5->v6:
*Change doc and designi of struct rte_eth_rxseg_split, support multi segments protocol_hdr configuration.
v4->v5:
* Use protocol and mbuf_offset based buffer split instead of header split.
* Use RTE_PTYPE* instead of enum rte_eth_rx_header_split_protocol_type.
* Improve the description of rte_eth_rxseg_split.proto.

v3->v4:
* Use RTE_ETH_RX_HEADER_SPLIT_NONE instead of 0.

v2->v3:
* Fix a PMD bug.
* Add rx queue header split check.
* Revise the log and doc.

v1->v2:
* Add support for all header split protocol types.

Wenxuan Wu (3):
ethdev: introduce protocol header based buffer split net/ice: support buffer split in Rx path app/testpmd: add rxhdrs commands and parameters

 app/test-pmd/cmdline.c                | 127 ++++++++++++++-
 app/test-pmd/config.c                 |  81 ++++++++++
 app/test-pmd/parameters.c             |  15 +-
 app/test-pmd/testpmd.c                |   6 +-
 app/test-pmd/testpmd.h                |   6 +
 drivers/net/ice/ice_ethdev.c          |  10 +-
 drivers/net/ice/ice_rxtx.c            | 220 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 lib/ethdev/rte_ethdev.c               |  40 ++++-
 lib/ethdev/rte_ethdev.h               |  28 +++-
 11 files changed, 505 insertions(+), 47 deletions(-)
Signature · 1 line
2.25.1
#46 lore raw

PATCH v7 1/3 ethdev: introduce protocol header based buffer split

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet segment configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet segment, it is almost impossible to pass a fixed protocol header to PMD. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding protocol header is configured, PMD will split the ingress packets into multiple segments.

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Both inner and outer L2/L3/L4 level protocol header split can be supported. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP, RTE_PTYPE_INNER_L4_SCTP.

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
    seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
    seg2 - pool2, off1=0B

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 40 +++++++++++++++++++++++++++++++++-------
 lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c +33 -7
index 29a3d80466..be161ff999 100644
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;
 
 		if (mpl == NULL) {
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1694,13 +1695,38 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		}
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+			/* Split at fixed length. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Split after specified protocol header. */
+			if (proto_hdr & RTE_BUFFER_SPLIT_PROTO_HDR_MASK) {
+				RTE_ETHDEV_LOG(ERR,
+					"Protocol header %u not supported)\n",
+					proto_hdr);
+				return -EINVAL;
+			}
+
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length should be set to zero in protocol header "
+					       "based buffer split\n");
+				return -EINVAL;
+			}
+
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+						"%s mbuf_data_room_size %u < %u segment offset)\n",
+						mpl->name, *mbp_buf_size,
+						offset);
+				return -EINVAL;
+			}
 		}
 	}
 	return 0;
lib/ethdev/rte_ethdev.h +27 -1
index 04cff8ee10..0cd9dd6cc0 100644
@@ -1187,6 +1187,9 @@ struct rte_eth_txmode {
  *   mbuf) the following data will be pushed to the next segment
  *   up to its own length, and so on.
  *
+ * - The proto_hdrs in the elements define the split position of
+ *   received packets.
+ *
  * - If the length in the segment description element is zero
  *   the actual buffer size will be deduced from the appropriate
  *   memory pool properties.
@@ -1197,14 +1200,37 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
+ *     - The proto_hdr field should not be configured.
+ *
+ * - Protocol header based buffer split:
+ *     - mp, offset, proto_hdr should be configured.
+ *     - The length field should not be configured.
  */
 struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint32_t proto_hdr; /**< Inner/outer L2/L3/L4 protocol header, configures split point. */
 };
 
+/* Buffer split protocol header capability. */
+#define RTE_BUFFER_SPLIT_PROTO_HDR_MASK ( \
+	RTE_PTYPE_L2_ETHER | \
+	RTE_PTYPE_L3_IPV4 | \
+	RTE_PTYPE_L3_IPV6 | \
+	RTE_PTYPE_L4_TCP | \
+	RTE_PTYPE_L4_UDP | \
+	RTE_PTYPE_L4_SCTP | \
+	RTE_PTYPE_INNER_L2_ETHER | \
+	RTE_PTYPE_INNER_L3_IPV4 | \
+	RTE_PTYPE_INNER_L3_IPV6 | \
+	RTE_PTYPE_INNER_L4_TCP | \
+	RTE_PTYPE_INNER_L4_UDP | \
+	RTE_PTYPE_INNER_L4_SCTP)
+
 /**
  * @warning
  * @b EXPERIMENTAL: this structure may change without prior notice.
Signature · 1 line
2.25.1
#47 lore raw

PATCH v7 2/3 net/ice: support buffer split in Rx path

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

This patch adds support for proto based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly splitted into protocol header and payload parts. And the two parts will be put into different mempools.

Currently, protocol based buffer split is not supported in vectorized paths.

---
 drivers/net/ice/ice_ethdev.c          |  10 +-
 drivers/net/ice/ice_rxtx.c            | 220 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 lib/ethdev/rte_ethdev.c               |   2 +-
 5 files changed, 218 insertions(+), 33 deletions(-)
drivers/net/ice/ice_ethdev.c +8 -2
index 73e550f5fb..ce3f49c863 100644
@@ -3713,7 +3713,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 			RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 			RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |
 			RTE_ETH_RX_OFFLOAD_RSS_HASH |
-			RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+			RTE_ETH_RX_OFFLOAD_TIMESTAMP |
+			RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT;
 		dev_info->tx_offload_capa |=
 			RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
 			RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -3725,7 +3726,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->flow_type_rss_offloads |= ICE_RSS_OFFLOAD_ALL;
 	}
 
-	dev_info->rx_queue_offload_capa = 0;
+	dev_info->rx_queue_offload_capa = RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT;
 	dev_info->tx_queue_offload_capa = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->reta_size = pf->hash_lut_size;
@@ -3794,6 +3795,11 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->default_rxportconf.ring_size = ICE_BUF_SIZE_MIN;
 	dev_info->default_txportconf.ring_size = ICE_BUF_SIZE_MIN;
 
+	dev_info->rx_seg_capa.max_nseg = ICE_RX_MAX_NSEG;
+	dev_info->rx_seg_capa.multi_pools = 1;
+	dev_info->rx_seg_capa.offset_allowed = 0;
+	dev_info->rx_seg_capa.offset_align_log2 = 0;
+
 	return 0;
 }
 
drivers/net/ice/ice_rxtx.c +190 -30

362 lines not on this page · raw message

drivers/net/ice/ice_rxtx.h +16 -0
index bb18a01951..611dbc8503 100644
@@ -16,6 +16,9 @@
 #define ICE_RX_MAX_BURST 32
 #define ICE_TX_MAX_BURST 32
 
+/* Maximal number of segments to split. */
+#define ICE_RX_MAX_NSEG 2
+
 #define ICE_CHK_Q_ENA_COUNT        100
 #define ICE_CHK_Q_ENA_INTERVAL_US  100
 
@@ -43,6 +46,11 @@
 extern uint64_t ice_timestamp_dynflag;
 extern int ice_timestamp_dynfield_offset;
 
+/* Max header size can be 2K - 64 bytes */
+#define ICE_RX_HDR_BUF_SIZE    (2048 - 64)
+
+#define ICE_HEADER_SPLIT_ENA   BIT(0)
+
 typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);
 typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq);
 typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {
 	struct rte_mbuf *mbuf;
 };
 
+enum ice_rx_dtype {
+	ICE_RX_DTYPE_NO_SPLIT       = 0,
+	ICE_RX_DTYPE_HEADER_SPLIT   = 1,
+	ICE_RX_DTYPE_SPLIT_ALWAYS   = 2,
+};
+
 struct ice_rx_queue {
 	struct rte_mempool *mp; /* mbuf pool to populate RX ring */
 	volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -95,6 +109,8 @@ struct ice_rx_queue {
 	uint32_t time_high;
 	uint32_t hw_register_set;
 	const struct rte_memzone *mz;
+	struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG];
+	uint32_t rxseg_nb;
 };
 
 struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
index 2dd2d83650..eec6ea2134 100644
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)
 	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
 		return -1;
 
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)
+		return -1;
+
 	if (rxq->offloads & ICE_RX_VECTOR_OFFLOAD)
 		return ICE_VECTOR_OFFLOAD_PATH;
 
lib/ethdev/rte_ethdev.c +1 -1
index be161ff999..fbd55cdd9d 100644
@@ -1707,7 +1707,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 			}
 		} else {
 			/* Split after specified protocol header. */
-			if (proto_hdr & RTE_BUFFER_SPLIT_PROTO_HDR_MASK) {
+			if (!(proto_hdr & RTE_BUFFER_SPLIT_PROTO_HDR_MASK)) {
 				RTE_ETHDEV_LOG(ERR,
 					"Protocol header %u not supported)\n",
 					proto_hdr);
Signature · 1 line
2.25.1
#48 lore raw

PATCH v7 3/3 app/testpmd: add rxhdrs commands and parameters

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

Add command line parameter:
--rxhdrs=mac,[ipv4,udp]

Set the protocol_hdr of segments to scatter packets on receiving if split feature is engaged. And the queues with BUFFER_SPLIT flag.

Add interative mode command:
testpmd>set rxhdrs mac,ipv4,l3,tcp,udp,sctp
(protocol sequence and nb_segs should be valid)

The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with two mempools. e.g. --mbuf-size=2048,2048
2. Configure Rx queue with rx_offload buffer split on.
3. Set the protocol type of buffer split.e.g. set rxhdrs mac,ipv4 (Supported protocols: mac|ipv4|ipv6|l3|tcp|udp|sctp|l4|inner_mac|

			     inner_ipv4|inner_ipv6|inner_l3|inner_tcp|
                    	     inner_udp|inner_sctp|inner_l4)
---
 app/test-pmd/cmdline.c    | 127 +++++++++++++++++++++++++++++++++++++-
 app/test-pmd/config.c     |  81 ++++++++++++++++++++++++
 app/test-pmd/parameters.c |  15 ++++-
 app/test-pmd/testpmd.c    |   6 +-
 app/test-pmd/testpmd.h    |   6 ++
 5 files changed, 228 insertions(+), 7 deletions(-)
app/test-pmd/cmdline.c +124 -3
index 6ffea8e21a..52e98e1c06 100644
@@ -183,7 +183,7 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"show (rxq|txq) info (port_id) (queue_id)\n"
 			"    Display information for configured RX/TX queue.\n\n"
 
-			"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
+			"show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n"
 			"    Display the given configuration.\n\n"
 
 			"read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -316,6 +316,15 @@ static void cmd_help_long_parsed(void *parsed_result,
 			" Affects only the queues configured with split"
 			" offloads.\n\n"
 
+			"set rxhdrs (mac[,ipv4])*\n"
+			"	Set the protocol hdr of each segment to scatter"
+			" packets on receiving if split feature is engaged."
+			" Affects only the queues configured with split"
+			" offloads.\n\n"
+			"	Supported proto header: mac|ipv4|ipv6|l3|tcp|udp|sctp|l4|"
+			"inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|"
+			"inner_udp|inner_sctp\n"
+
 			"set txpkts (x[,y]*)\n"
 			"    Set the length of each segment of TXONLY"
 			" and optionally CSUM packets.\n\n"
@@ -3617,6 +3626,72 @@ cmdline_parse_inst_t cmd_stop = {
 	},
 };
 
+static unsigned int
+get_ptype(char *value)
+{
+	uint32_t protocol;
+	if (!strcmp(value, "mac"))
+		protocol = RTE_PTYPE_L2_ETHER;
+	else if (!strcmp(value, "ipv4"))
+		protocol = RTE_PTYPE_L3_IPV4;
+	else if (!strcmp(value, "ipv6"))
+		protocol = RTE_PTYPE_L3_IPV6;
+	else if (!strcmp(value, "l3"))
+		protocol = RTE_PTYPE_L3_IPV4|RTE_PTYPE_L3_IPV6;
+	else if (!strcmp(value, "tcp"))
+		protocol = RTE_PTYPE_L4_TCP;
+	else if (!strcmp(value, "udp"))
+		protocol = RTE_PTYPE_L4_UDP;
+	else if (!strcmp(value, "sctp"))
+		protocol = RTE_PTYPE_L4_SCTP;
+	else if (!strcmp(value, "l4"))
+		protocol = RTE_PTYPE_L4_TCP|RTE_PTYPE_L4_UDP|RTE_PTYPE_L4_SCTP;
+	else if (!strcmp(value, "inner_mac"))
+		protocol = RTE_PTYPE_INNER_L2_ETHER;
+	else if (!strcmp(value, "inner_ipv4"))
+		protocol = RTE_PTYPE_INNER_L3_IPV4;
+	else if (!strcmp(value, "inner_ipv6"))
+		protocol = RTE_PTYPE_INNER_L3_IPV6;
+	else if (!strcmp(value, "inner_l3"))
+		protocol = RTE_PTYPE_INNER_L3_IPV4|RTE_PTYPE_INNER_L3_IPV6;
+	else if (!strcmp(value, "inner_tcp"))
+		protocol = RTE_PTYPE_INNER_L4_TCP;
+	else if (!strcmp(value, "inner_udp"))
+		protocol = RTE_PTYPE_INNER_L4_UDP;
+	else if (!strcmp(value, "inner_sctp"))
+		protocol = RTE_PTYPE_INNER_L4_SCTP;
+	else {
+		fprintf(stderr, "Unknown protocol name: %s\n", value);
+		return 0;
+	}
+	return protocol;
+}
+/* *** SET RXHDRSLIST *** */
+
+unsigned int
+parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
+				unsigned int *parsed_items, int check_hdrs_sequence)
+{
+	unsigned int nb_item;
+	char *cur;
+	char *tmp;
+	nb_item = 0;
+	char *str2 = strdup(str);
+	cur = strtok_r(str2, ",", &tmp);
+	while (cur != NULL) {
+		parsed_items[nb_item] = get_ptype(cur);
+		cur = strtok_r(NULL, ",", &tmp);
+		nb_item++;
+	}
+	if (nb_item > max_items)
+		fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
+			item_name, nb_item + 1, max_items);
+	set_rx_pkt_hdrs(parsed_items, nb_item);
+	free(str2);
+	if (!check_hdrs_sequence)
+		return nb_item;
+	return nb_item;
+}
 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
 
 unsigned int
@@ -3986,6 +4061,49 @@ cmdline_parse_inst_t cmd_set_rxpkts = {
 	},
 };
 
+/* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
+struct cmd_set_rxhdrs_result {
+	cmdline_fixed_string_t cmd_keyword;
+	cmdline_fixed_string_t rxhdrs;
+	cmdline_fixed_string_t seg_hdrs;
+};
+
+static void
+cmd_set_rxhdrs_parsed(void *parsed_result,
+		      __rte_unused struct cmdline *cl,
+		      __rte_unused void *data)
+{
+	struct cmd_set_rxhdrs_result *res;
+	unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
+	unsigned int nb_segs;
+
+	res = parsed_result;
+	nb_segs = parse_hdrs_list(res->seg_hdrs, "segment hdrs",
+				  MAX_SEGS_BUFFER_SPLIT, seg_hdrs, 0);
+	if (nb_segs >= 1)
+		set_rx_pkt_hdrs(seg_hdrs, nb_segs);
+	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
+}
+cmdline_parse_token_string_t cmd_set_rxhdrs_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
+				 cmd_keyword, "set");
+cmdline_parse_token_string_t cmd_set_rxhdrs_name =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
+				 rxhdrs, "rxhdrs");
+cmdline_parse_token_string_t cmd_set_rxhdrs_seg_hdrs =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
+				 seg_hdrs, NULL);
+cmdline_parse_inst_t cmd_set_rxhdrs = {
+	.f = cmd_set_rxhdrs_parsed,
+	.data = NULL,
+	.help_str = "set rxhdrs <mac[,ipv4]*>",
+	.tokens = {
+		(void *)&cmd_set_rxhdrs_keyword,
+		(void *)&cmd_set_rxhdrs_name,
+		(void *)&cmd_set_rxhdrs_seg_hdrs,
+		NULL,
+	},
+};
 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
 
 struct cmd_set_txpkts_result {
@@ -8058,6 +8176,8 @@ static void cmd_showcfg_parsed(void *parsed_result,
 		show_rx_pkt_offsets();
 	else if (!strcmp(res->what, "rxpkts"))
 		show_rx_pkt_segments();
+	else if (!strcmp(res->what, "rxhdrs"))
+		show_rx_pkt_hdrs();
 	else if (!strcmp(res->what, "txpkts"))
 		show_tx_pkt_segments();
 	else if (!strcmp(res->what, "txtimes"))
@@ -8070,12 +8190,12 @@ cmdline_parse_token_string_t cmd_showcfg_port =
 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
 cmdline_parse_token_string_t cmd_showcfg_what =
 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
-				 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
+				 "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes");
 
 cmdline_parse_inst_t cmd_showcfg = {
 	.f = cmd_showcfg_parsed,
 	.data = NULL,
-	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
+	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes",
 	.tokens = {
 		(void *)&cmd_showcfg_show,
 		(void *)&cmd_showcfg_port,
@@ -17833,6 +17953,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_set_log,
 	(cmdline_parse_inst_t *)&cmd_set_rxoffs,
 	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
+	(cmdline_parse_inst_t *)&cmd_set_rxhdrs,
 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
app/test-pmd/config.c +81 -0

87 lines not on this page · raw message

app/test-pmd/parameters.c +14 -1
index daf6a31b2b..f86d626276 100644
@@ -161,6 +161,7 @@ usage(char* progname)
 	       " Used mainly with PCAP drivers.\n");
 	printf("  --rxoffs=X[,Y]*: set RX segment offsets for split.\n");
 	printf("  --rxpkts=X[,Y]*: set RX segment sizes to split.\n");
+	printf("  --rxhdrs=mac[,ipv4]*: set RX segment protocol to split.\n");
 	printf("  --txpkts=X[,Y]*: set TX segment sizes"
 		" or total packet length.\n");
 	printf("  --txonly-multi-flow: generate multiple flows in txonly mode\n");
@@ -673,6 +674,7 @@ launch_args_parse(int argc, char** argv)
 		{ "flow-isolate-all",	        0, 0, 0 },
 		{ "rxoffs",			1, 0, 0 },
 		{ "rxpkts",			1, 0, 0 },
+		{ "rxhdrs",			1, 0, 0 },
 		{ "txpkts",			1, 0, 0 },
 		{ "txonly-multi-flow",		0, 0, 0 },
 		{ "rxq-share",			2, 0, 0 },
@@ -1327,7 +1329,6 @@ launch_args_parse(int argc, char** argv)
 			if (!strcmp(lgopts[opt_idx].name, "rxpkts")) {
 				unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT];
 				unsigned int nb_segs;
-
 				nb_segs = parse_item_list
 						(optarg, "rxpkt segments",
 						 MAX_SEGS_BUFFER_SPLIT,
@@ -1337,6 +1338,18 @@ launch_args_parse(int argc, char** argv)
 				else
 					rte_exit(EXIT_FAILURE, "bad rxpkts\n");
 			}
+			if (!strcmp(lgopts[opt_idx].name, "rxhdrs")) {
+				unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
+				unsigned int nb_segs;
+				nb_segs = parse_hdrs_list
+						(optarg, "rxpkt segments",
+						MAX_SEGS_BUFFER_SPLIT,
+						seg_hdrs, 0);
+				if (nb_segs >= 1)
+					set_rx_pkt_hdrs(seg_hdrs, nb_segs);
+				else
+					rte_exit(EXIT_FAILURE, "bad rxpkts\n");
+			}
 			if (!strcmp(lgopts[opt_idx].name, "txpkts")) {
 				unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
 				unsigned int nb_segs;
app/test-pmd/testpmd.c +3 -3
index fe2ce19f99..77379b7aa9 100644
@@ -240,6 +240,7 @@ uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
 uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
 uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT];
 uint8_t  rx_pkt_nb_offs; /**< Number of specified offsets */
+uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT];
 
 /*
  * Configuration of packet segments used by the "txonly" processing engine.
@@ -2586,12 +2587,11 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		mp_n = (i > mbuf_data_size_n) ? mbuf_data_size_n - 1 : i;
 		mpx = mbuf_pool_find(socket_id, mp_n);
 		/* Handle zero as mbuf data buffer size. */
-		rx_seg->length = rx_pkt_seg_lengths[i] ?
-				   rx_pkt_seg_lengths[i] :
-				   mbuf_data_size[mp_n];
+		rx_seg->length = rx_pkt_seg_lengths[i];
 		rx_seg->offset = i < rx_pkt_nb_offs ?
 				   rx_pkt_seg_offsets[i] : 0;
 		rx_seg->mp = mpx ? mpx : mp;
+		rx_seg->proto_hdr = rx_pkt_hdr_protos[i];
 	}
 	rx_conf->rx_nseg = rx_pkt_nb_segs;
 	rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +6 -0
index 31f766c965..e791b9becd 100644
@@ -534,6 +534,7 @@ extern uint32_t max_rx_pkt_len;
  * Configuration of packet segments used to scatter received packets
  * if some of split features is configured.
  */
+extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT];
 extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
 extern uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
 extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT];
@@ -864,6 +865,9 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)
 unsigned int parse_item_list(const char *str, const char *item_name,
 			unsigned int max_items,
 			unsigned int *parsed_items, int check_unique_values);
+unsigned int parse_hdrs_list(const char *str, const char *item_name,
+			unsigned int max_item,
+			unsigned int *parsed_items, int check_unique_values);
 void launch_args_parse(int argc, char** argv);
 void cmdline_read_from_file(const char *filename);
 void prompt(void);
@@ -1018,6 +1022,8 @@ void set_record_core_cycles(uint8_t on_off);
 void set_record_burst_stats(uint8_t on_off);
 void set_verbose_level(uint16_t vb_level);
 void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
+void set_rx_pkt_hdrs(unsigned int *seg_protos, unsigned int nb_segs);
+void show_rx_pkt_hdrs(void);
 void show_rx_pkt_segments(void);
 void set_rx_pkt_offsets(unsigned int *seg_offsets, unsigned int nb_offs);
 void show_rx_pkt_offsets(void);
Signature · 1 line
2.25.1
#49 lore raw

v7 cover ethdev: introduce protocol type based header split

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

Buffer split consists of splitting a received packet into two separate regions based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.

This patchset extends the current buffer split to support multi protocol headers split. When Rx queue is configured with buffer split feature, packets received will be directly splitted into two different mempools.

v6->v7:
*fix supported header protocol check.
*add rxhdrs commands and parameters.
v5->v6:
*Change doc and designi of struct rte_eth_rxseg_split, support multi segments protocol_hdr configuration.
v4->v5:
* Use protocol and mbuf_offset based buffer split instead of header split.
* Use RTE_PTYPE* instead of enum rte_eth_rx_header_split_protocol_type.
* Improve the description of rte_eth_rxseg_split.proto.

v3->v4:
* Use RTE_ETH_RX_HEADER_SPLIT_NONE instead of 0.

v2->v3:
* Fix a PMD bug.
* Add rx queue header split check.
* Revise the log and doc.

v1->v2:
* Add support for all header split protocol types.

Wenxuan Wu (3):
ethdev: introduce protocol header based buffer split net/ice: support buffer split in Rx path app/testpmd: add rxhdrs commands and parameters

 app/test-pmd/cmdline.c                | 127 ++++++++++++++-
 app/test-pmd/config.c                 |  81 ++++++++++
 app/test-pmd/parameters.c             |  15 +-
 app/test-pmd/testpmd.c                |   6 +-
 app/test-pmd/testpmd.h                |   6 +
 drivers/net/ice/ice_ethdev.c          |  10 +-
 drivers/net/ice/ice_rxtx.c            | 220 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 lib/ethdev/rte_ethdev.c               |  40 ++++-
 lib/ethdev/rte_ethdev.h               |  28 +++-
 11 files changed, 505 insertions(+), 47 deletions(-)
Signature · 1 line
2.25.1
#50 lore raw

PATCH v7 1/3 ethdev: introduce protocol header based buffer split

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet segment configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet segment, it is almost impossible to pass a fixed protocol header to PMD. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding protocol header is configured, PMD will split the ingress packets into multiple segments.

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Both inner and outer L2/L3/L4 level protocol header split can be supported. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP, RTE_PTYPE_INNER_L4_SCTP.

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
    seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
    seg2 - pool2, off1=0B

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 40 +++++++++++++++++++++++++++++++++-------
 lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c +33 -7
index 29a3d80466..be161ff999 100644
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;
 
 		if (mpl == NULL) {
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1694,13 +1695,38 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		}
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+			/* Split at fixed length. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Split after specified protocol header. */
+			if (proto_hdr & RTE_BUFFER_SPLIT_PROTO_HDR_MASK) {
+				RTE_ETHDEV_LOG(ERR,
+					"Protocol header %u not supported)\n",
+					proto_hdr);
+				return -EINVAL;
+			}
+
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length should be set to zero in protocol header "
+					       "based buffer split\n");
+				return -EINVAL;
+			}
+
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+						"%s mbuf_data_room_size %u < %u segment offset)\n",
+						mpl->name, *mbp_buf_size,
+						offset);
+				return -EINVAL;
+			}
 		}
 	}
 	return 0;
lib/ethdev/rte_ethdev.h +27 -1
index 04cff8ee10..0cd9dd6cc0 100644
@@ -1187,6 +1187,9 @@ struct rte_eth_txmode {
  *   mbuf) the following data will be pushed to the next segment
  *   up to its own length, and so on.
  *
+ * - The proto_hdrs in the elements define the split position of
+ *   received packets.
+ *
  * - If the length in the segment description element is zero
  *   the actual buffer size will be deduced from the appropriate
  *   memory pool properties.
@@ -1197,14 +1200,37 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
+ *     - The proto_hdr field should not be configured.
+ *
+ * - Protocol header based buffer split:
+ *     - mp, offset, proto_hdr should be configured.
+ *     - The length field should not be configured.
  */
 struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint32_t proto_hdr; /**< Inner/outer L2/L3/L4 protocol header, configures split point. */
 };
 
+/* Buffer split protocol header capability. */
+#define RTE_BUFFER_SPLIT_PROTO_HDR_MASK ( \
+	RTE_PTYPE_L2_ETHER | \
+	RTE_PTYPE_L3_IPV4 | \
+	RTE_PTYPE_L3_IPV6 | \
+	RTE_PTYPE_L4_TCP | \
+	RTE_PTYPE_L4_UDP | \
+	RTE_PTYPE_L4_SCTP | \
+	RTE_PTYPE_INNER_L2_ETHER | \
+	RTE_PTYPE_INNER_L3_IPV4 | \
+	RTE_PTYPE_INNER_L3_IPV6 | \
+	RTE_PTYPE_INNER_L4_TCP | \
+	RTE_PTYPE_INNER_L4_UDP | \
+	RTE_PTYPE_INNER_L4_SCTP)
+
 /**
  * @warning
  * @b EXPERIMENTAL: this structure may change without prior notice.
Signature · 1 line
2.25.1
#51 lore raw

PATCH v7 2/3 net/ice: support buffer split in Rx path

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

This patch adds support for proto based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly splitted into protocol header and payload parts. And the two parts will be put into different mempools.

Currently, protocol based buffer split is not supported in vectorized paths.

---
 drivers/net/ice/ice_ethdev.c          |  10 +-
 drivers/net/ice/ice_rxtx.c            | 220 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 lib/ethdev/rte_ethdev.c               |   2 +-
 5 files changed, 218 insertions(+), 33 deletions(-)
drivers/net/ice/ice_ethdev.c +8 -2
index 73e550f5fb..ce3f49c863 100644
@@ -3713,7 +3713,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 			RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 			RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |
 			RTE_ETH_RX_OFFLOAD_RSS_HASH |
-			RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+			RTE_ETH_RX_OFFLOAD_TIMESTAMP |
+			RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT;
 		dev_info->tx_offload_capa |=
 			RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
 			RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -3725,7 +3726,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->flow_type_rss_offloads |= ICE_RSS_OFFLOAD_ALL;
 	}
 
-	dev_info->rx_queue_offload_capa = 0;
+	dev_info->rx_queue_offload_capa = RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT;
 	dev_info->tx_queue_offload_capa = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->reta_size = pf->hash_lut_size;
@@ -3794,6 +3795,11 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->default_rxportconf.ring_size = ICE_BUF_SIZE_MIN;
 	dev_info->default_txportconf.ring_size = ICE_BUF_SIZE_MIN;
 
+	dev_info->rx_seg_capa.max_nseg = ICE_RX_MAX_NSEG;
+	dev_info->rx_seg_capa.multi_pools = 1;
+	dev_info->rx_seg_capa.offset_allowed = 0;
+	dev_info->rx_seg_capa.offset_align_log2 = 0;
+
 	return 0;
 }
 
drivers/net/ice/ice_rxtx.c +190 -30

362 lines not on this page · raw message

drivers/net/ice/ice_rxtx.h +16 -0
index bb18a01951..611dbc8503 100644
@@ -16,6 +16,9 @@
 #define ICE_RX_MAX_BURST 32
 #define ICE_TX_MAX_BURST 32
 
+/* Maximal number of segments to split. */
+#define ICE_RX_MAX_NSEG 2
+
 #define ICE_CHK_Q_ENA_COUNT        100
 #define ICE_CHK_Q_ENA_INTERVAL_US  100
 
@@ -43,6 +46,11 @@
 extern uint64_t ice_timestamp_dynflag;
 extern int ice_timestamp_dynfield_offset;
 
+/* Max header size can be 2K - 64 bytes */
+#define ICE_RX_HDR_BUF_SIZE    (2048 - 64)
+
+#define ICE_HEADER_SPLIT_ENA   BIT(0)
+
 typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);
 typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq);
 typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {
 	struct rte_mbuf *mbuf;
 };
 
+enum ice_rx_dtype {
+	ICE_RX_DTYPE_NO_SPLIT       = 0,
+	ICE_RX_DTYPE_HEADER_SPLIT   = 1,
+	ICE_RX_DTYPE_SPLIT_ALWAYS   = 2,
+};
+
 struct ice_rx_queue {
 	struct rte_mempool *mp; /* mbuf pool to populate RX ring */
 	volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -95,6 +109,8 @@ struct ice_rx_queue {
 	uint32_t time_high;
 	uint32_t hw_register_set;
 	const struct rte_memzone *mz;
+	struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG];
+	uint32_t rxseg_nb;
 };
 
 struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
index 2dd2d83650..eec6ea2134 100644
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)
 	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
 		return -1;
 
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)
+		return -1;
+
 	if (rxq->offloads & ICE_RX_VECTOR_OFFLOAD)
 		return ICE_VECTOR_OFFLOAD_PATH;
 
lib/ethdev/rte_ethdev.c +1 -1
index be161ff999..fbd55cdd9d 100644
@@ -1707,7 +1707,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 			}
 		} else {
 			/* Split after specified protocol header. */
-			if (proto_hdr & RTE_BUFFER_SPLIT_PROTO_HDR_MASK) {
+			if (!(proto_hdr & RTE_BUFFER_SPLIT_PROTO_HDR_MASK)) {
 				RTE_ETHDEV_LOG(ERR,
 					"Protocol header %u not supported)\n",
 					proto_hdr);
Signature · 1 line
2.25.1
#52 lore raw

PATCH v7 3/3 app/testpmd: add rxhdrs commands and parameters

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

Add command line parameter:
--rxhdrs=mac,[ipv4,udp]

Set the protocol_hdr of segments to scatter packets on receiving if split feature is engaged. And the queues with BUFFER_SPLIT flag.

Add interative mode command:
testpmd>set rxhdrs mac,ipv4,l3,tcp,udp,sctp
(protocol sequence and nb_segs should be valid)

The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with two mempools. e.g. --mbuf-size=2048,2048
2. Configure Rx queue with rx_offload buffer split on.
3. Set the protocol type of buffer split.e.g. set rxhdrs mac,ipv4 (Supported protocols: mac|ipv4|ipv6|l3|tcp|udp|sctp|l4|inner_mac|

			     inner_ipv4|inner_ipv6|inner_l3|inner_tcp|
                    	     inner_udp|inner_sctp|inner_l4)
---
 app/test-pmd/cmdline.c    | 127 +++++++++++++++++++++++++++++++++++++-
 app/test-pmd/config.c     |  81 ++++++++++++++++++++++++
 app/test-pmd/parameters.c |  15 ++++-
 app/test-pmd/testpmd.c    |   6 +-
 app/test-pmd/testpmd.h    |   6 ++
 5 files changed, 228 insertions(+), 7 deletions(-)
app/test-pmd/cmdline.c +124 -3
index 6ffea8e21a..52e98e1c06 100644
@@ -183,7 +183,7 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"show (rxq|txq) info (port_id) (queue_id)\n"
 			"    Display information for configured RX/TX queue.\n\n"
 
-			"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
+			"show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n"
 			"    Display the given configuration.\n\n"
 
 			"read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -316,6 +316,15 @@ static void cmd_help_long_parsed(void *parsed_result,
 			" Affects only the queues configured with split"
 			" offloads.\n\n"
 
+			"set rxhdrs (mac[,ipv4])*\n"
+			"	Set the protocol hdr of each segment to scatter"
+			" packets on receiving if split feature is engaged."
+			" Affects only the queues configured with split"
+			" offloads.\n\n"
+			"	Supported proto header: mac|ipv4|ipv6|l3|tcp|udp|sctp|l4|"
+			"inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|"
+			"inner_udp|inner_sctp\n"
+
 			"set txpkts (x[,y]*)\n"
 			"    Set the length of each segment of TXONLY"
 			" and optionally CSUM packets.\n\n"
@@ -3617,6 +3626,72 @@ cmdline_parse_inst_t cmd_stop = {
 	},
 };
 
+static unsigned int
+get_ptype(char *value)
+{
+	uint32_t protocol;
+	if (!strcmp(value, "mac"))
+		protocol = RTE_PTYPE_L2_ETHER;
+	else if (!strcmp(value, "ipv4"))
+		protocol = RTE_PTYPE_L3_IPV4;
+	else if (!strcmp(value, "ipv6"))
+		protocol = RTE_PTYPE_L3_IPV6;
+	else if (!strcmp(value, "l3"))
+		protocol = RTE_PTYPE_L3_IPV4|RTE_PTYPE_L3_IPV6;
+	else if (!strcmp(value, "tcp"))
+		protocol = RTE_PTYPE_L4_TCP;
+	else if (!strcmp(value, "udp"))
+		protocol = RTE_PTYPE_L4_UDP;
+	else if (!strcmp(value, "sctp"))
+		protocol = RTE_PTYPE_L4_SCTP;
+	else if (!strcmp(value, "l4"))
+		protocol = RTE_PTYPE_L4_TCP|RTE_PTYPE_L4_UDP|RTE_PTYPE_L4_SCTP;
+	else if (!strcmp(value, "inner_mac"))
+		protocol = RTE_PTYPE_INNER_L2_ETHER;
+	else if (!strcmp(value, "inner_ipv4"))
+		protocol = RTE_PTYPE_INNER_L3_IPV4;
+	else if (!strcmp(value, "inner_ipv6"))
+		protocol = RTE_PTYPE_INNER_L3_IPV6;
+	else if (!strcmp(value, "inner_l3"))
+		protocol = RTE_PTYPE_INNER_L3_IPV4|RTE_PTYPE_INNER_L3_IPV6;
+	else if (!strcmp(value, "inner_tcp"))
+		protocol = RTE_PTYPE_INNER_L4_TCP;
+	else if (!strcmp(value, "inner_udp"))
+		protocol = RTE_PTYPE_INNER_L4_UDP;
+	else if (!strcmp(value, "inner_sctp"))
+		protocol = RTE_PTYPE_INNER_L4_SCTP;
+	else {
+		fprintf(stderr, "Unknown protocol name: %s\n", value);
+		return 0;
+	}
+	return protocol;
+}
+/* *** SET RXHDRSLIST *** */
+
+unsigned int
+parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
+				unsigned int *parsed_items, int check_hdrs_sequence)
+{
+	unsigned int nb_item;
+	char *cur;
+	char *tmp;
+	nb_item = 0;
+	char *str2 = strdup(str);
+	cur = strtok_r(str2, ",", &tmp);
+	while (cur != NULL) {
+		parsed_items[nb_item] = get_ptype(cur);
+		cur = strtok_r(NULL, ",", &tmp);
+		nb_item++;
+	}
+	if (nb_item > max_items)
+		fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
+			item_name, nb_item + 1, max_items);
+	set_rx_pkt_hdrs(parsed_items, nb_item);
+	free(str2);
+	if (!check_hdrs_sequence)
+		return nb_item;
+	return nb_item;
+}
 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
 
 unsigned int
@@ -3986,6 +4061,49 @@ cmdline_parse_inst_t cmd_set_rxpkts = {
 	},
 };
 
+/* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
+struct cmd_set_rxhdrs_result {
+	cmdline_fixed_string_t cmd_keyword;
+	cmdline_fixed_string_t rxhdrs;
+	cmdline_fixed_string_t seg_hdrs;
+};
+
+static void
+cmd_set_rxhdrs_parsed(void *parsed_result,
+		      __rte_unused struct cmdline *cl,
+		      __rte_unused void *data)
+{
+	struct cmd_set_rxhdrs_result *res;
+	unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
+	unsigned int nb_segs;
+
+	res = parsed_result;
+	nb_segs = parse_hdrs_list(res->seg_hdrs, "segment hdrs",
+				  MAX_SEGS_BUFFER_SPLIT, seg_hdrs, 0);
+	if (nb_segs >= 1)
+		set_rx_pkt_hdrs(seg_hdrs, nb_segs);
+	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
+}
+cmdline_parse_token_string_t cmd_set_rxhdrs_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
+				 cmd_keyword, "set");
+cmdline_parse_token_string_t cmd_set_rxhdrs_name =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
+				 rxhdrs, "rxhdrs");
+cmdline_parse_token_string_t cmd_set_rxhdrs_seg_hdrs =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
+				 seg_hdrs, NULL);
+cmdline_parse_inst_t cmd_set_rxhdrs = {
+	.f = cmd_set_rxhdrs_parsed,
+	.data = NULL,
+	.help_str = "set rxhdrs <mac[,ipv4]*>",
+	.tokens = {
+		(void *)&cmd_set_rxhdrs_keyword,
+		(void *)&cmd_set_rxhdrs_name,
+		(void *)&cmd_set_rxhdrs_seg_hdrs,
+		NULL,
+	},
+};
 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
 
 struct cmd_set_txpkts_result {
@@ -8058,6 +8176,8 @@ static void cmd_showcfg_parsed(void *parsed_result,
 		show_rx_pkt_offsets();
 	else if (!strcmp(res->what, "rxpkts"))
 		show_rx_pkt_segments();
+	else if (!strcmp(res->what, "rxhdrs"))
+		show_rx_pkt_hdrs();
 	else if (!strcmp(res->what, "txpkts"))
 		show_tx_pkt_segments();
 	else if (!strcmp(res->what, "txtimes"))
@@ -8070,12 +8190,12 @@ cmdline_parse_token_string_t cmd_showcfg_port =
 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
 cmdline_parse_token_string_t cmd_showcfg_what =
 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
-				 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
+				 "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes");
 
 cmdline_parse_inst_t cmd_showcfg = {
 	.f = cmd_showcfg_parsed,
 	.data = NULL,
-	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
+	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes",
 	.tokens = {
 		(void *)&cmd_showcfg_show,
 		(void *)&cmd_showcfg_port,
@@ -17833,6 +17953,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_set_log,
 	(cmdline_parse_inst_t *)&cmd_set_rxoffs,
 	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
+	(cmdline_parse_inst_t *)&cmd_set_rxhdrs,
 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
app/test-pmd/config.c +81 -0

87 lines not on this page · raw message

app/test-pmd/parameters.c +14 -1
index daf6a31b2b..f86d626276 100644
@@ -161,6 +161,7 @@ usage(char* progname)
 	       " Used mainly with PCAP drivers.\n");
 	printf("  --rxoffs=X[,Y]*: set RX segment offsets for split.\n");
 	printf("  --rxpkts=X[,Y]*: set RX segment sizes to split.\n");
+	printf("  --rxhdrs=mac[,ipv4]*: set RX segment protocol to split.\n");
 	printf("  --txpkts=X[,Y]*: set TX segment sizes"
 		" or total packet length.\n");
 	printf("  --txonly-multi-flow: generate multiple flows in txonly mode\n");
@@ -673,6 +674,7 @@ launch_args_parse(int argc, char** argv)
 		{ "flow-isolate-all",	        0, 0, 0 },
 		{ "rxoffs",			1, 0, 0 },
 		{ "rxpkts",			1, 0, 0 },
+		{ "rxhdrs",			1, 0, 0 },
 		{ "txpkts",			1, 0, 0 },
 		{ "txonly-multi-flow",		0, 0, 0 },
 		{ "rxq-share",			2, 0, 0 },
@@ -1327,7 +1329,6 @@ launch_args_parse(int argc, char** argv)
 			if (!strcmp(lgopts[opt_idx].name, "rxpkts")) {
 				unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT];
 				unsigned int nb_segs;
-
 				nb_segs = parse_item_list
 						(optarg, "rxpkt segments",
 						 MAX_SEGS_BUFFER_SPLIT,
@@ -1337,6 +1338,18 @@ launch_args_parse(int argc, char** argv)
 				else
 					rte_exit(EXIT_FAILURE, "bad rxpkts\n");
 			}
+			if (!strcmp(lgopts[opt_idx].name, "rxhdrs")) {
+				unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
+				unsigned int nb_segs;
+				nb_segs = parse_hdrs_list
+						(optarg, "rxpkt segments",
+						MAX_SEGS_BUFFER_SPLIT,
+						seg_hdrs, 0);
+				if (nb_segs >= 1)
+					set_rx_pkt_hdrs(seg_hdrs, nb_segs);
+				else
+					rte_exit(EXIT_FAILURE, "bad rxpkts\n");
+			}
 			if (!strcmp(lgopts[opt_idx].name, "txpkts")) {
 				unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
 				unsigned int nb_segs;
app/test-pmd/testpmd.c +3 -3
index fe2ce19f99..77379b7aa9 100644
@@ -240,6 +240,7 @@ uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
 uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
 uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT];
 uint8_t  rx_pkt_nb_offs; /**< Number of specified offsets */
+uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT];
 
 /*
  * Configuration of packet segments used by the "txonly" processing engine.
@@ -2586,12 +2587,11 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		mp_n = (i > mbuf_data_size_n) ? mbuf_data_size_n - 1 : i;
 		mpx = mbuf_pool_find(socket_id, mp_n);
 		/* Handle zero as mbuf data buffer size. */
-		rx_seg->length = rx_pkt_seg_lengths[i] ?
-				   rx_pkt_seg_lengths[i] :
-				   mbuf_data_size[mp_n];
+		rx_seg->length = rx_pkt_seg_lengths[i];
 		rx_seg->offset = i < rx_pkt_nb_offs ?
 				   rx_pkt_seg_offsets[i] : 0;
 		rx_seg->mp = mpx ? mpx : mp;
+		rx_seg->proto_hdr = rx_pkt_hdr_protos[i];
 	}
 	rx_conf->rx_nseg = rx_pkt_nb_segs;
 	rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +6 -0
index 31f766c965..e791b9becd 100644
@@ -534,6 +534,7 @@ extern uint32_t max_rx_pkt_len;
  * Configuration of packet segments used to scatter received packets
  * if some of split features is configured.
  */
+extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT];
 extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
 extern uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
 extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT];
@@ -864,6 +865,9 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)
 unsigned int parse_item_list(const char *str, const char *item_name,
 			unsigned int max_items,
 			unsigned int *parsed_items, int check_unique_values);
+unsigned int parse_hdrs_list(const char *str, const char *item_name,
+			unsigned int max_item,
+			unsigned int *parsed_items, int check_unique_values);
 void launch_args_parse(int argc, char** argv);
 void cmdline_read_from_file(const char *filename);
 void prompt(void);
@@ -1018,6 +1022,8 @@ void set_record_core_cycles(uint8_t on_off);
 void set_record_burst_stats(uint8_t on_off);
 void set_verbose_level(uint16_t vb_level);
 void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
+void set_rx_pkt_hdrs(unsigned int *seg_protos, unsigned int nb_segs);
+void show_rx_pkt_hdrs(void);
 void show_rx_pkt_segments(void);
 void set_rx_pkt_offsets(unsigned int *seg_offsets, unsigned int nb_offs);
 void show_rx_pkt_offsets(void);
Signature · 1 line
2.25.1
#53 lore raw

v8 cover ethdev: introduce protocol type based header split

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

Buffer split consists of splitting a received packet into two separate regions based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.

This patchset extends the current buffer split to support multi protocol headers split. When Rx queue is configured with buffer split feature, packets received will be directly splitted into two different mempools.

v6->v7:
*fix supported header protocol check.
*add rxhdrs commands and parameters.
v5->v6:
*Change doc and designi of struct rte_eth_rxseg_split, support multi segments protocol_hdr configuration.
v4->v5:
* Use protocol and mbuf_offset based buffer split instead of header split.
* Use RTE_PTYPE* instead of enum rte_eth_rx_header_split_protocol_type.
* Improve the description of rte_eth_rxseg_split.proto.

v3->v4:
* Use RTE_ETH_RX_HEADER_SPLIT_NONE instead of 0.

v2->v3:
* Fix a PMD bug.
* Add rx queue header split check.
* Revise the log and doc.

v1->v2:
* Add support for all header split protocol types.

Wenxuan Wu (3):
ethdev: introduce protocol header based buffer split net/ice: support buffer split in Rx path app/testpmd: add rxhdrs commands and parameters

 app/test-pmd/cmdline.c                | 127 ++++++++++++++-
 app/test-pmd/config.c                 |  81 ++++++++++
 app/test-pmd/parameters.c             |  15 +-
 app/test-pmd/testpmd.c                |   6 +-
 app/test-pmd/testpmd.h                |   6 +
 drivers/net/ice/ice_ethdev.c          |  10 +-
 drivers/net/ice/ice_rxtx.c            | 220 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 lib/ethdev/rte_ethdev.c               |  40 ++++-
 lib/ethdev/rte_ethdev.h               |  28 +++-
 11 files changed, 505 insertions(+), 47 deletions(-)
Signature · 1 line
2.25.1
#54 lore raw

PATCH v8 1/3 ethdev: introduce protocol hdr based buffer split

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet segment configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet segment, it is almost impossible to pass a fixed protocol header to PMD. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding protocol header is configured, PMD will split the ingress packets into multiple segments.

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Both inner and outer L2/L3/L4 level protocol header split can be supported. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP, RTE_PTYPE_INNER_L4_SCTP.

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
    seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
    seg2 - pool2, off1=0B

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 40 +++++++++++++++++++++++++++++++++-------
 lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c +33 -7
index 29a3d80466..fbd55cdd9d 100644
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;
 
 		if (mpl == NULL) {
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1694,13 +1695,38 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		}
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+			/* Split at fixed length. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Split after specified protocol header. */
+			if (!(proto_hdr & RTE_BUFFER_SPLIT_PROTO_HDR_MASK)) {
+				RTE_ETHDEV_LOG(ERR,
+					"Protocol header %u not supported)\n",
+					proto_hdr);
+				return -EINVAL;
+			}
+
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length should be set to zero in protocol header "
+					       "based buffer split\n");
+				return -EINVAL;
+			}
+
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+						"%s mbuf_data_room_size %u < %u segment offset)\n",
+						mpl->name, *mbp_buf_size,
+						offset);
+				return -EINVAL;
+			}
 		}
 	}
 	return 0;
lib/ethdev/rte_ethdev.h +27 -1
index 04cff8ee10..0cd9dd6cc0 100644
@@ -1187,6 +1187,9 @@ struct rte_eth_txmode {
  *   mbuf) the following data will be pushed to the next segment
  *   up to its own length, and so on.
  *
+ * - The proto_hdrs in the elements define the split position of
+ *   received packets.
+ *
  * - If the length in the segment description element is zero
  *   the actual buffer size will be deduced from the appropriate
  *   memory pool properties.
@@ -1197,14 +1200,37 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
+ *     - The proto_hdr field should not be configured.
+ *
+ * - Protocol header based buffer split:
+ *     - mp, offset, proto_hdr should be configured.
+ *     - The length field should not be configured.
  */
 struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint32_t proto_hdr; /**< Inner/outer L2/L3/L4 protocol header, configures split point. */
 };
 
+/* Buffer split protocol header capability. */
+#define RTE_BUFFER_SPLIT_PROTO_HDR_MASK ( \
+	RTE_PTYPE_L2_ETHER | \
+	RTE_PTYPE_L3_IPV4 | \
+	RTE_PTYPE_L3_IPV6 | \
+	RTE_PTYPE_L4_TCP | \
+	RTE_PTYPE_L4_UDP | \
+	RTE_PTYPE_L4_SCTP | \
+	RTE_PTYPE_INNER_L2_ETHER | \
+	RTE_PTYPE_INNER_L3_IPV4 | \
+	RTE_PTYPE_INNER_L3_IPV6 | \
+	RTE_PTYPE_INNER_L4_TCP | \
+	RTE_PTYPE_INNER_L4_UDP | \
+	RTE_PTYPE_INNER_L4_SCTP)
+
 /**
  * @warning
  * @b EXPERIMENTAL: this structure may change without prior notice.
Signature · 1 line
2.25.1
#55 lore raw

Re: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Is it the right one since it is listed in patchwork?

Quoted 9 lines · On 6/1/22 16:50, [email protected] wrote:

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet segment configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet

a -> an

Quoted 37 lines

segment, it is almost impossible to pass a fixed protocol header to PMD. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding protocol header is configured, PMD will split the ingress packets into multiple segments.

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Both inner and outer L2/L3/L4 level protocol header split can be supported. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP, RTE_PTYPE_INNER_L4_SCTP.

For example, let's suppose we configured the Rx queue with the following segments:

     seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
     seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
     seg2 - pool2, off1=0B
Quoted 5 lines

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

It must be defined how ICMPv4 packets will be split in such case. And how UDP over IPv6 will be split.

Quoted 48 lines

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.

---
  lib/ethdev/rte_ethdev.c | 40 +++++++++++++++++++++++++++++++++-------
  lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++-
  2 files changed, 60 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c +4 -7
index 29a3d80466..fbd55cdd9d 100644
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
  		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
  		uint32_t length = rx_seg[seg_idx].length;
  		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;
 
  		if (mpl == NULL) {
  			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1694,13 +1695,38 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
  		}
  		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
  		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+			/* Split at fixed length. */
+			length = length != 0 ? length : *mbp_buf_size;

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1710

Quoted 10 lines
lib/ethdev/rte_ethdev.c +10 -0
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Split after specified protocol header. */
+			if (!(proto_hdr & RTE_BUFFER_SPLIT_PROTO_HDR_MASK)) {

The condition looks suspicious. It will be true if proto_hdr has no single bit from the mask. I guess it is not the intent. I guess the condition should be
proto_hdr & ~RTE_BUFFER_SPLIT_PROTO_HDR_MASK
i.e. there is unsupported bits in proto_hdr

IMHO we need extra field in dev_info to report supported protocols to split on. Or a new API to get an array similar to ptype get. May be a new API is a better choice to not overload dev_info and to be more flexible in reporting.

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1713

Quoted 3 lines
lib/ethdev/rte_ethdev.c +3 -0
+				RTE_ETHDEV_LOG(ERR,
+					"Protocol header %u not supported)\n",
+					proto_hdr);

I think it would be useful to log unsupported bits only, if we say so.

Quoted 72 lines
lib/ethdev/rte_ethdev.c +16 -0
+				return -EINVAL;
+			}
+
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length should be set to zero in protocol header "
+					       "based buffer split\n");
+				return -EINVAL;
+			}
+
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+						"%s mbuf_data_room_size %u < %u segment offset)\n",
+						mpl->name, *mbp_buf_size,
+						offset);
+				return -EINVAL;
+			}
  		}
  	}
  	return 0;
lib/ethdev/rte_ethdev.h +27 -1
index 04cff8ee10..0cd9dd6cc0 100644
@@ -1187,6 +1187,9 @@ struct rte_eth_txmode {
   *   mbuf) the following data will be pushed to the next segment
   *   up to its own length, and so on.
   *
+ * - The proto_hdrs in the elements define the split position of
+ *   received packets.
+ *
   * - If the length in the segment description element is zero
   *   the actual buffer size will be deduced from the appropriate
   *   memory pool properties.
@@ -1197,14 +1200,37 @@ struct rte_eth_txmode {
   *     - pool from the last valid element
   *     - the buffer size from this pool
   *     - zero offset
+ *
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
+ *     - The proto_hdr field should not be configured.
+ *
+ * - Protocol header based buffer split:
+ *     - mp, offset, proto_hdr should be configured.
+ *     - The length field should not be configured.
   */
  struct rte_eth_rxseg_split {
  	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
  	uint16_t length; /**< Segment data length, configures split point. */
  	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint32_t proto_hdr; /**< Inner/outer L2/L3/L4 protocol header, configures split point. */
  };
 
+/* Buffer split protocol header capability. */
+#define RTE_BUFFER_SPLIT_PROTO_HDR_MASK ( \
+	RTE_PTYPE_L2_ETHER | \
+	RTE_PTYPE_L3_IPV4 | \
+	RTE_PTYPE_L3_IPV6 | \
+	RTE_PTYPE_L4_TCP | \
+	RTE_PTYPE_L4_UDP | \
+	RTE_PTYPE_L4_SCTP | \
+	RTE_PTYPE_INNER_L2_ETHER | \
+	RTE_PTYPE_INNER_L3_IPV4 | \
+	RTE_PTYPE_INNER_L3_IPV6 | \
+	RTE_PTYPE_INNER_L4_TCP | \
+	RTE_PTYPE_INNER_L4_UDP | \
+	RTE_PTYPE_INNER_L4_SCTP)
+
  /**
   * @warning
   * @b EXPERIMENTAL: this structure may change without prior notice.
author
#56 lore raw

RE: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Hi Andrew,

Quoted 12 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, June 2, 2022 9:21 PM
To: Wu, WenxuanX <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; Ray Kinsella <[email protected]>
Subject: Re: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Quoted 1 line

Is it the right one since it is listed in patchwork?

Yes, it is.

Quoted 7 lines · On 6/1/22 16:50, [email protected] wrote:
Quoted 4 lines

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet

segment

Quoted 8 lines
Quoted 6 lines

configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet

a -> an

Thanks for your catch, will fix it in next version.

Quoted 45 lines
Quoted 5 lines

segment, it is almost impossible to pass a fixed protocol header to PMD. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

Quoted 7 lines

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding

protocol

Quoted 1 line

header is configured, PMD will split the ingress packets into multiple

segments.

Quoted 4 lines

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from

*/

Quoted 8 lines

uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Quoted 6 lines

Both inner and outer L2/L3/L4 level protocol header split can be supported. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP,

RTE_PTYPE_INNER_L4_SCTP.

Quoted 10 lines

For example, let's suppose we configured the Rx queue with the following segments:

     seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
     seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
     seg2 - pool2, off1=0B

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from

Quoted 6 lines

pool0

Quoted 2 lines

seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

It must be defined how ICMPv4 packets will be split in such case. And how UDP over IPv6 will be split.

The ICMP header type is missed, I will define the expected split behavior and add it in next version, thanks for your catch.

In fact, the buffer split based on protocol header depends on the driver parsing result. As long as driver can recognize this packet type, I think there is no difference between UDP over IPV4 and UDP over IPV6?

Quoted 66 lines
Quoted 11 lines

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory,

respectively.

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct

Quoted 16 lines
---
  lib/ethdev/rte_ethdev.c | 40 +++++++++++++++++++++++++++++++++-------
  lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++-
  2 files changed, 60 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

29a3d80466..fbd55cdd9d 100644

lib/ethdev/rte_ethdev.c +0 -0
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1667

Quoted 7 lines
lib/ethdev/rte_ethdev.c +1 -0
  		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
  		uint32_t length = rx_seg[seg_idx].length;
  		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;
 
  		if (mpl == NULL) {
  			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");

@@ -1694,13

Quoted 1 line

+1695,38 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
  		}
  		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
  		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
lib/ethdev/rte_ethdev.c +0 -4
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 9 lines
lib/ethdev/rte_ethdev.c +6 -3
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+			/* Split at fixed length. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
lib/ethdev/rte_ethdev.c +7 -0
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Split after specified protocol header. */
+			if (!(proto_hdr &

RTE_BUFFER_SPLIT_PROTO_HDR_MASK)) {

Quoted 2 lines

The condition looks suspicious. It will be true if proto_hdr has no single bit from the mask. I guess it is not the intent.

Actually it is the intent... Here the mask is used to check if proto_hdr belongs to the inner/outer L2/L3/L4 capability we defined. And which proto_hdr is supported by the NIC will be checked in the PMD later.

Quoted 8 lines

I guess the condition should be
proto_hdr & ~RTE_BUFFER_SPLIT_PROTO_HDR_MASK i.e. there is
unsupported bits in proto_hdr

IMHO we need extra field in dev_info to report supported protocols to split on. Or a new API to get an array similar to ptype get.
May be a new API is a better choice to not overload dev_info and to be more flexible in reporting.

Thanks for your suggestion.
Here I hope to confirm the intent of dev_info or API to expose the supported proto_hdr of driver. Is it for the pro_hdr check in the rte_eth_rx_queue_check_split()?
If so, could we just check whether pro_hdrs configured belongs to L2/L3/L4 in lib, and check the capability in PMD? This is what the current design does.

Actually I have another question, do we need a API or dev_info to expose which buffer split the driver supports. i.e. length based or proto_hdr based. Because it requires different fields to be configured
in RX packet segment.

Hope to get your insights. :)

Quoted 7 lines

lib/ethdev/rte_ethdev.c

Quoted 3 lines
lib/ethdev/rte_ethdev.c +2 -0
+				RTE_ETHDEV_LOG(ERR,
+					"Protocol header %u not

supported)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1713

Quoted 1 line
lib/ethdev/rte_ethdev.c +1 -0
+					proto_hdr);

I think it would be useful to log unsupported bits only, if we say so.

The same as above.
Thanks again for your time.

Regards,
Xuan

Quoted 78 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 6 lines
lib/ethdev/rte_ethdev.c +5 -0
+				return -EINVAL;
+			}
+
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length

should be set to zero in protocol header "

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
lib/ethdev/rte_ethdev.c +7 -0
+					       "based buffer split\n");
+				return -EINVAL;
+			}
+
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+						"%s

mbuf_data_room_size %u < %u segment offset)\n",

Quoted 26 lines
lib/ethdev/rte_ethdev.c +4 -0
+						mpl->name, *mbp_buf_size,
+						offset);
+				return -EINVAL;
+			}
  		}
  	}
  	return 0;
lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0 -0

04cff8ee10..0cd9dd6cc0 100644

lib/ethdev/rte_ethdev.h +4 -0
@@ -1187,6 +1187,9 @@ struct rte_eth_txmode {
   *   mbuf) the following data will be pushed to the next segment
   *   up to its own length, and so on.
   *
+ * - The proto_hdrs in the elements define the split position of
+ *   received packets.
+ *
   * - If the length in the segment description element is zero
   *   the actual buffer size will be deduced from the appropriate
   *   memory pool properties.
@@ -1197,14 +1200,37 @@ struct rte_eth_txmode {
   *     - pool from the last valid element
   *     - the buffer size from this pool
   *     - zero offset
+ *

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1213

Quoted 10 lines
lib/ethdev/rte_ethdev.h +7 -0
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
+ *     - The proto_hdr field should not be configured.
+ *
+ * - Protocol header based buffer split:
+ *     - mp, offset, proto_hdr should be configured.
+ *     - The length field should not be configured.
   */
  struct rte_eth_rxseg_split {
  	struct rte_mempool *mp; /**< Memory pool to allocate segment

from. */

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1215

Quoted 2 lines
lib/ethdev/rte_ethdev.h +0 -0
  	uint16_t length; /**< Segment data length, configures split point. */
  	uint16_t offset; /**< Data offset from beginning of mbuf data buffer.

*/

Quoted 23 lines
lib/ethdev/rte_ethdev.h +17 -1
-	uint32_t reserved; /**< Reserved field. */
+	uint32_t proto_hdr; /**< Inner/outer L2/L3/L4 protocol header,
+configures split point. */
  };
 
+/* Buffer split protocol header capability. */ #define
+RTE_BUFFER_SPLIT_PROTO_HDR_MASK ( \
+	RTE_PTYPE_L2_ETHER | \
+	RTE_PTYPE_L3_IPV4 | \
+	RTE_PTYPE_L3_IPV6 | \
+	RTE_PTYPE_L4_TCP | \
+	RTE_PTYPE_L4_UDP | \
+	RTE_PTYPE_L4_SCTP | \
+	RTE_PTYPE_INNER_L2_ETHER | \
+	RTE_PTYPE_INNER_L3_IPV4 | \
+	RTE_PTYPE_INNER_L3_IPV6 | \
+	RTE_PTYPE_INNER_L4_TCP | \
+	RTE_PTYPE_INNER_L4_UDP | \
+	RTE_PTYPE_INNER_L4_SCTP)
+
  /**
   * @warning
   * @b EXPERIMENTAL: this structure may change without prior notice.
#57 lore raw

Re: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Quoted 88 lines · Xuan

Hi Andrew,

Quoted 12 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, June 2, 2022 9:21 PM
To: Wu, WenxuanX <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; Ray Kinsella <[email protected]>
Subject: Re: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Quoted 1 line

Is it the right one since it is listed in patchwork?

Yes, it is.

Quoted 7 lines · On 6/1/22 16:50, [email protected] wrote:
Quoted 4 lines

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet

segment

Quoted 8 lines
Quoted 6 lines

configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet

a -> an

Thanks for your catch, will fix it in next version.

Quoted 45 lines
Quoted 5 lines

segment, it is almost impossible to pass a fixed protocol header to PMD. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

Quoted 7 lines

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding

protocol

Quoted 1 line

header is configured, PMD will split the ingress packets into multiple

segments.

Quoted 4 lines

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from

*/

Quoted 8 lines

uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Quoted 6 lines

Both inner and outer L2/L3/L4 level protocol header split can be supported. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP,

RTE_PTYPE_INNER_L4_SCTP.

Quoted 10 lines

For example, let's suppose we configured the Rx queue with the following segments:

      seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
      seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
      seg2 - pool2, off1=0B

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from

Quoted 6 lines

pool0

Quoted 2 lines

seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

It must be defined how ICMPv4 packets will be split in such case. And how UDP over IPv6 will be split.

Quoted 6 lines

The ICMP header type is missed, I will define the expected split behavior and add it in next version, thanks for your catch.

In fact, the buffer split based on protocol header depends on the driver parsing result. As long as driver can recognize this packet type, I think there is no difference between UDP over IPV4 and UDP over IPV6?

We can bind it to ptypes recognized by the HW+driver, but I can easily imagine the case when HW has no means to report recognized packet type (i.e. ptype get returns empty list), but still could split on it.
Also, nobody guarantees that there is no different in UDP over IPv4 vs IPv6 recognition and split. IPv6 could have a number of extension headers which could be not that trivial to hop in HW. So, HW could recognize IPv6, but not protocols after it.
Also it is very interesting question how to define protocol split for IPv6 plus extension headers. Where to stop?

Quoted 67 lines
Quoted 67 lines
Quoted 9 lines

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

Quoted 3 lines

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory,

respectively.

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct

Quoted 16 lines
---
   lib/ethdev/rte_ethdev.c | 40 +++++++++++++++++++++++++++++++++-------
   lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++-
   2 files changed, 60 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

29a3d80466..fbd55cdd9d 100644

lib/ethdev/rte_ethdev.c +0 -0
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1667

Quoted 7 lines
lib/ethdev/rte_ethdev.c +1 -0
   		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
   		uint32_t length = rx_seg[seg_idx].length;
   		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;
 
   		if (mpl == NULL) {
   			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");

@@ -1694,13

Quoted 1 line

+1695,38 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
   		}
   		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
   		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
lib/ethdev/rte_ethdev.c +0 -4
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 9 lines
lib/ethdev/rte_ethdev.c +6 -3
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+			/* Split at fixed length. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
lib/ethdev/rte_ethdev.c +7 -0
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Split after specified protocol header. */
+			if (!(proto_hdr &

RTE_BUFFER_SPLIT_PROTO_HDR_MASK)) {

Quoted 6 lines
Quoted 2 lines

The condition looks suspicious. It will be true if proto_hdr has no single bit from the mask. I guess it is not the intent.

Actually it is the intent... Here the mask is used to check if proto_hdr belongs to the inner/outer L2/L3/L4 capability we defined. And which proto_hdr is supported by the NIC will be checked in the PMD later.

Frankly speaking I see no value in such incomplete check if we still rely on driver. I simply see no reason to oblige the driver to support one of these protocols.

Quoted 10 lines
Quoted 9 lines

I guess the condition should be
proto_hdr & ~RTE_BUFFER_SPLIT_PROTO_HDR_MASK i.e. there is
unsupported bits in proto_hdr

IMHO we need extra field in dev_info to report supported protocols to split on. Or a new API to get an array similar to ptype get.
May be a new API is a better choice to not overload dev_info and to be more flexible in reporting.

Quoted 5 lines

Thanks for your suggestion.
Here I hope to confirm the intent of dev_info or API to expose the supported proto_hdr of driver. Is it for the pro_hdr check in the rte_eth_rx_queue_check_split()?
If so, could we just check whether pro_hdrs configured belongs to L2/L3/L4 in lib, and check the capability in PMD? This is what the current design does.

Look. Application needs to know what to expect from eth device. It should know which protocols it can split on. Of course we can enforce application to use try-fail approach which would make sense if we have dedicated API to request Rx buffer split, but since it is done via Rx queue configuration, it could be tricky for application to realize which part of the configuration is wrong. It could simply result in a too many retries with different configuration.

I.e. the information should be used by ethdev to validate request and the information should be ued by the application to understand what is supported.

Quoted 4 lines

Actually I have another question, do we need a API or dev_info to expose which buffer split the driver supports. i.e. length based or proto_hdr based. Because it requires different fields to be configured
in RX packet segment.

See above. If dedicated API return -ENOTSUP or empty set of supported protocols to split on, the answer is clear.

Quoted 16 lines

Hope to get your insights. :)

Quoted 7 lines

lib/ethdev/rte_ethdev.c

Quoted 3 lines
lib/ethdev/rte_ethdev.c +2 -0
+				RTE_ETHDEV_LOG(ERR,
+					"Protocol header %u not

supported)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1713

Quoted 1 line
lib/ethdev/rte_ethdev.c +1 -0
+					proto_hdr);

I think it would be useful to log unsupported bits only, if we say so.

The same as above.
Thanks again for your time.

Regards,
Xuan

author
#58 lore raw

RE: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Hi Andrew,

Quoted 83 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Saturday, June 4, 2022 10:26 PM
To: Ding, Xuan <[email protected]>; Wu, WenxuanX <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Wang, YuanX <[email protected]>; Ray Kinsella <[email protected]>
Subject: Re: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Quoted 6 lines · Xuan

Hi Andrew,

Quoted 4 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, June 2, 2022 9:21 PM
To: Wu, WenxuanX <[email protected]>; [email protected];

Li,

Quoted 9 lines
Quoted 9 lines

Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; Ray Kinsella <[email protected]>
Subject: Re: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Quoted 10 lines
Quoted 1 line

Is it the right one since it is listed in patchwork?

Yes, it is.

Quoted 6 lines · On 6/1/22 16:50, [email protected] wrote:
Quoted 4 lines

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx

packet

Quoted 42 lines
Quoted 9 lines

segment

Quoted 6 lines

configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet

a -> an

Thanks for your catch, will fix it in next version.

Quoted 30 lines
Quoted 5 lines

segment, it is almost impossible to pass a fixed protocol header to PMD. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

Quoted 7 lines

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding

protocol

Quoted 2 lines

header is configured, PMD will split the ingress packets into multiple

segments.

Quoted 5 lines

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate
segment from

*/

Quoted 8 lines

uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Quoted 27 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Both inner and outer L2/L3/L4 level protocol header split can be

supported.

Quoted 25 lines
Quoted 16 lines
Quoted 5 lines

Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP,

RTE_PTYPE_INNER_L4_SCTP.

Quoted 10 lines

For example, let's suppose we configured the Rx queue with the following segments:

      seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
      seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
      seg2 - pool2, off1=0B

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from

Quoted 6 lines

pool0

Quoted 2 lines

seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

It must be defined how ICMPv4 packets will be split in such case. And how UDP over IPv6 will be split.

The ICMP header type is missed, I will define the expected split behavior and add it in next version, thanks for your catch.

I have a question here. Since ICMP packets are mainly used to check the connectivity of network, is it necessary for us to split ICMP packets? And I found there is no RTE_PTYPE for ICMP.

Quoted 9 lines
Quoted 2 lines

In fact, the buffer split based on protocol header depends on the driver

parsing result.

Quoted 2 lines

As long as driver can recognize this packet type, I think there is no difference between UDP over IPV4 and UDP over IPV6?

We can bind it to ptypes recognized by the HW+driver, but I can easily imagine the case when HW has no means to report recognized packet type (i.e. ptype get returns empty list), but still could split on it.

Get your point. But if one ptype cannot be recognized by HW+driver, is it still necessary for us to do the split? The main purpose of buffer split is to split header and payload. Although we add split for various protocol headers now, we should focus the ptype can be recognized.

Quoted 6 lines

Also, nobody guarantees that there is no different in UDP over IPv4 vs IPv6 recognition and split. IPv6 could have a number of extension headers which could be not that trivial to hop in HW. So, HW could recognize IPv6, but not protocols after it.
Also it is very interesting question how to define protocol split for IPv6 plus extension headers. Where to stop?

The extension header you mentioned is indeed an interesting question. On our device, the stop would be the end of extension header. The same as above, the main purpose of buffers split is for header and payload. Even rte_flow, we don't list all of the extension headers. So we can't cope with all the IPV6 extension headers.

For IPV6 extension headers, what if we treat the IPV6 header and extension header as one layer? Because 99% of cases will not require a separate extension header.

Hope to get your insights.

Quoted 69 lines
Quoted 15 lines
Quoted 15 lines
Quoted 10 lines

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

Quoted 3 lines

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory,

respectively.

Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
---
   lib/ethdev/rte_ethdev.c | 40 +++++++++++++++++++++++++++++++++---

----

Quoted 46 lines
Quoted 46 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct

Quoted 8 lines
   lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++-
   2 files changed, 60 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

29a3d80466..fbd55cdd9d 100644

lib/ethdev/rte_ethdev.c +0 -0
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1667

Quoted 7 lines
lib/ethdev/rte_ethdev.c +1 -0
   		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
   		uint32_t length = rx_seg[seg_idx].length;
   		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;
 
   		if (mpl == NULL) {
   			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");

@@ -1694,13

Quoted 1 line

+1695,38 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
   		}
   		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
   		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
lib/ethdev/rte_ethdev.c +0 -4
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 9 lines
lib/ethdev/rte_ethdev.c +6 -3
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+			/* Split at fixed length. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
lib/ethdev/rte_ethdev.c +7 -0
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Split after specified protocol header. */
+			if (!(proto_hdr &

RTE_BUFFER_SPLIT_PROTO_HDR_MASK)) {

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

The condition looks suspicious. It will be true if proto_hdr has no single bit from the mask. I guess it is not the intent.

Actually it is the intent... Here the mask is used to check if proto_hdr belongs to the inner/outer L2/L3/L4 capability we defined. And which proto_hdr is supported by the NIC will be checked in the PMD

later.

Need to correct here. You are right, I made a bug in previous implementation.

Quoted 4 lines

Frankly speaking I see no value in such incomplete check if we still rely on driver. I simply see no reason to oblige the driver to support one of these protocols.

With API, we can get the driver's capabilities first, and do the check in ethdev later. In this way, we can finish the checks in once. Please see v9.

Quoted 19 lines
Quoted 6 lines
Quoted 6 lines

I guess the condition should be
proto_hdr & ~RTE_BUFFER_SPLIT_PROTO_HDR_MASK i.e. there is
unsupported bits in proto_hdr

Quoted 7 lines
Quoted 4 lines

IMHO we need extra field in dev_info to report supported protocols to split on. Or a new API to get an array similar to ptype get. May be a new API is a better choice to not overload dev_info and to be more flexible in reporting.

Thanks for your suggestion.
Here I hope to confirm the intent of dev_info or API to expose the

supported proto_hdr of driver.

Quoted 3 lines

Is it for the pro_hdr check in the rte_eth_rx_queue_check_split()? If so, could we just check whether pro_hdrs configured belongs to L2/L3/L4 in lib, and check the capability in PMD? This is what the current

design does.

Quoted 7 lines

Look. Application needs to know what to expect from eth device. It should know which protocols it can split on. Of course we can enforce application to use try-fail approach which would make sense if we have dedicated API to request Rx buffer split, but since it is done via Rx queue configuration, it could be tricky for application to realize which part of the configuration is wrong. It could simply result in a too many retries with different configuration.

Agree. To avoid the unnecessary try-fails, I will add a new API in dev_ops, please see v9.

Quoted 6 lines

I.e. the information should be used by ethdev to validate request and the information should be ued by the application to understand what is supported.

Quoted 1 line
Quoted 7 lines
Quoted 1 line

Actually I have another question, do we need a API or dev_info to expose

which buffer split the driver supports.

Quoted 2 lines

i.e. length based or proto_hdr based. Because it requires different fields to be configured in RX packet segment.

See above. If dedicated API return -ENOTSUP or empty set of supported protocols to split on, the answer is clear.

Get your point. I totally agree with your idea of a new API. Through the API, the logic will look like:
ret = rte_get_supported_buffer_split_proto();
if (ret == -ENOTSUP)
Check length based buffer split
else
Checked proto based buffer split

We don't need to care about the irrelevant fields in respective buffer split anymore.

BTW, could you help to review the deprecation notice for header split? If it gets acked, I will start the deprecation in 22.11.

Thanks,
Xuan

Quoted 17 lines
Quoted 17 lines

Hope to get your insights. :)

Quoted 7 lines

lib/ethdev/rte_ethdev.c

Quoted 3 lines
lib/ethdev/rte_ethdev.c +2 -0
+				RTE_ETHDEV_LOG(ERR,
+					"Protocol header %u not

supported)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1713

Quoted 1 line
lib/ethdev/rte_ethdev.c +1 -0
+					proto_hdr);

I think it would be useful to log unsupported bits only, if we say so.

The same as above.
Thanks again for your time.

Regards,
Xuan

#59 lore raw

Re: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Quoted 110 lines · Xuan

Hi Andrew,

Quoted 108 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Saturday, June 4, 2022 10:26 PM
To: Ding, Xuan <[email protected]>; Wu, WenxuanX <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Wang, YuanX <[email protected]>; Ray Kinsella <[email protected]>
Subject: Re: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Quoted 6 lines · Xuan

Hi Andrew,

Quoted 4 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, June 2, 2022 9:21 PM
To: Wu, WenxuanX <[email protected]>; [email protected];

Li,

Quoted 9 lines
Quoted 9 lines

Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; Ray Kinsella <[email protected]>
Subject: Re: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Quoted 10 lines
Quoted 1 line

Is it the right one since it is listed in patchwork?

Yes, it is.

Quoted 6 lines · On 6/1/22 16:50, [email protected] wrote:
Quoted 4 lines

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx

packet

Quoted 4 lines
Quoted 4 lines

segment

Quoted 3 lines

configured, PMD will be able to split the received packets into multiple segments.

Quoted 39 lines
Quoted 5 lines
Quoted 3 lines

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet

a -> an

Thanks for your catch, will fix it in next version.

Quoted 31 lines
Quoted 5 lines

segment, it is almost impossible to pass a fixed protocol header to PMD. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

Quoted 7 lines

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding

protocol

Quoted 2 lines

header is configured, PMD will split the ingress packets into multiple

segments.

Quoted 5 lines

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate
segment from

*/

Quoted 9 lines

uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Both inner and outer L2/L3/L4 level protocol header split can be

supported.

Quoted 23 lines
Quoted 22 lines
Quoted 5 lines

Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP,

RTE_PTYPE_INNER_L4_SCTP.

Quoted 10 lines

For example, let's suppose we configured the Rx queue with the following segments:

       seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
       seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
       seg2 - pool2, off1=0B

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from

pool0

Quoted 2 lines

seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

It must be defined how ICMPv4 packets will be split in such case. And how UDP over IPv6 will be split.

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

The ICMP header type is missed, I will define the expected split behavior and add it in next version, thanks for your catch.

I have a question here. Since ICMP packets are mainly used to check the connectivity of network, is it necessary for us to split ICMP packets? And I found there is no RTE_PTYPE for ICMP.

I'm not saying that we should split on ICMP. I'm just saying that we must define the behaviour when happens for packets which do not match split specification. Does it split on longest match and everything else is put in (which?) last buffer? E.g. we configure split on ETH-IPv4-TCP. What does happen with ETH-IPv4-UDP? ETH-IPv6?

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

In fact, the buffer split based on protocol header depends on the driver

parsing result.

Quoted 2 lines

As long as driver can recognize this packet type, I think there is no difference between UDP over IPV4 and UDP over IPV6?

Quoted 7 lines
Quoted 3 lines

We can bind it to ptypes recognized by the HW+driver, but I can easily imagine the case when HW has no means to report recognized packet type (i.e. ptype get returns empty list), but still could split on it.

Get your point. But if one ptype cannot be recognized by HW+driver, is it still necessary for us to do the split? The main purpose of buffer split is to split header and payload. Although we add split for various protocol headers now, we should focus the ptype can be recognized.

Recognition and reporting is a separate things. It could be recognized, but it can have no means to report it to the driver. ptype_get is about reporting.

Quoted 8 lines
Quoted 7 lines

Also, nobody guarantees that there is no different in UDP over IPv4 vs IPv6 recognition and split. IPv6 could have a number of extension headers which could be not that trivial to hop in HW. So, HW could recognize IPv6, but not protocols after it.
Also it is very interesting question how to define protocol split for IPv6 plus extension headers. Where to stop?

Quoted 5 lines

The extension header you mentioned is indeed an interesting question. On our device, the stop would be the end of extension header. The same as above, the main purpose of buffers split is for header and payload. Even rte_flow, we don't list all of the extension headers. So we can't cope with all the IPV6 extension headers.

Again, we must define the behaviour. Application needs to know what to expect.

Quoted 4 lines

For IPV6 extension headers, what if we treat the IPV6 header and extension header as one layer? Because 99% of cases will not require a separate extension header.

I'd like to highlight that it is not "an extension header". It is 'extension headers' (plural). I'm not sure that we can say that in order to split on IPv6 HW must support *all* (even future) extension headers.

Quoted 2 lines

Hope to get your insights.

Unfortunately I have no solutions. Just questions to be answered...

Quoted 140 lines
Quoted 70 lines
Quoted 16 lines
Quoted 16 lines
Quoted 11 lines

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

Quoted 3 lines

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory,

respectively.

Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
---
    lib/ethdev/rte_ethdev.c | 40 +++++++++++++++++++++++++++++++++---

----

Quoted 46 lines
Quoted 46 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct

Quoted 8 lines
    lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++-
    2 files changed, 60 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

29a3d80466..fbd55cdd9d 100644

lib/ethdev/rte_ethdev.c +0 -0
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1667

Quoted 7 lines
lib/ethdev/rte_ethdev.c +1 -0
    		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
    		uint32_t length = rx_seg[seg_idx].length;
    		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;
 
    		if (mpl == NULL) {
    			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");

@@ -1694,13

Quoted 1 line

+1695,38 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
    		}
    		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
    		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
lib/ethdev/rte_ethdev.c +0 -4
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 9 lines
lib/ethdev/rte_ethdev.c +6 -3
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+			/* Split at fixed length. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
lib/ethdev/rte_ethdev.c +7 -0
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Split after specified protocol header. */
+			if (!(proto_hdr &

RTE_BUFFER_SPLIT_PROTO_HDR_MASK)) {

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

The condition looks suspicious. It will be true if proto_hdr has no single bit from the mask. I guess it is not the intent.

Actually it is the intent... Here the mask is used to check if proto_hdr belongs to the inner/outer L2/L3/L4 capability we defined. And which proto_hdr is supported by the NIC will be checked in the PMD

later.

Need to correct here. You are right, I made a bug in previous implementation.

Quoted 4 lines

Frankly speaking I see no value in such incomplete check if we still rely on driver. I simply see no reason to oblige the driver to support one of these protocols.

With API, we can get the driver's capabilities first, and do the check in ethdev later. In this way, we can finish the checks in once. Please see v9.

Quoted 19 lines
Quoted 6 lines
Quoted 6 lines

I guess the condition should be
proto_hdr & ~RTE_BUFFER_SPLIT_PROTO_HDR_MASK i.e. there is
unsupported bits in proto_hdr

Quoted 7 lines
Quoted 4 lines

IMHO we need extra field in dev_info to report supported protocols to split on. Or a new API to get an array similar to ptype get. May be a new API is a better choice to not overload dev_info and to be more flexible in reporting.

Thanks for your suggestion.
Here I hope to confirm the intent of dev_info or API to expose the

supported proto_hdr of driver.

Quoted 3 lines

Is it for the pro_hdr check in the rte_eth_rx_queue_check_split()? If so, could we just check whether pro_hdrs configured belongs to L2/L3/L4 in lib, and check the capability in PMD? This is what the current

design does.

Quoted 7 lines

Look. Application needs to know what to expect from eth device. It should know which protocols it can split on. Of course we can enforce application to use try-fail approach which would make sense if we have dedicated API to request Rx buffer split, but since it is done via Rx queue configuration, it could be tricky for application to realize which part of the configuration is wrong. It could simply result in a too many retries with different configuration.

Agree. To avoid the unnecessary try-fails, I will add a new API in dev_ops, please see v9.

Quoted 6 lines

I.e. the information should be used by ethdev to validate request and the information should be ued by the application to understand what is supported.

Quoted 1 line
Quoted 7 lines
Quoted 1 line

Actually I have another question, do we need a API or dev_info to expose

which buffer split the driver supports.

Quoted 2 lines

i.e. length based or proto_hdr based. Because it requires different fields to be configured in RX packet segment.

See above. If dedicated API return -ENOTSUP or empty set of supported protocols to split on, the answer is clear.

Get your point. I totally agree with your idea of a new API. Through the API, the logic will look like:
ret = rte_get_supported_buffer_split_proto();
if (ret == -ENOTSUP)
Check length based buffer split
else
Checked proto based buffer split

Quoted 5 lines

We don't need to care about the irrelevant fields in respective buffer split anymore.

BTW, could you help to review the deprecation notice for header split? If it gets acked, I will start the deprecation in 22.11.

Since the feature is definitely dead. I'd use faster track. Deprecate in 22.07 and remove in 22.11.

Quoted 21 lines

Thanks,
Xuan

Quoted 17 lines
Quoted 17 lines

Hope to get your insights. :)

Quoted 7 lines

lib/ethdev/rte_ethdev.c

Quoted 3 lines
lib/ethdev/rte_ethdev.c +2 -0
+				RTE_ETHDEV_LOG(ERR,
+					"Protocol header %u not

supported)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1713

Quoted 1 line
lib/ethdev/rte_ethdev.c +1 -0
+					proto_hdr);

I think it would be useful to log unsupported bits only, if we say so.

The same as above.
Thanks again for your time.

Regards,
Xuan

author
#60 lore raw

RE: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Hi Andrew,

Sorry for the late response, please see replies inline.

Quoted 138 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Tuesday, June 7, 2022 6:49 PM
To: Ding, Xuan <[email protected]>; Wu, WenxuanX <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Wang, YuanX <[email protected]>; Ray Kinsella <[email protected]>
Subject: Re: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Quoted 12 lines · Xuan

Hi Andrew,

Quoted 10 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Saturday, June 4, 2022 10:26 PM
To: Ding, Xuan <[email protected]>; Wu, WenxuanX <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Wang, YuanX

<[email protected]>;

Quoted 11 lines
Quoted 11 lines

Ray Kinsella <[email protected]>
Subject: Re: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Quoted 6 lines · Xuan

Hi Andrew,

Quoted 4 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, June 2, 2022 9:21 PM
To: Wu, WenxuanX <[email protected]>;

[email protected];

Quoted 3 lines
Quoted 3 lines

Li,

Quoted 2 lines
Quoted 2 lines

Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang,

Yuying

Quoted 26 lines
Quoted 26 lines
Quoted 7 lines
Quoted 7 lines

<[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; Ray Kinsella <[email protected]>
Subject: Re: [PATCH v8 1/3] ethdev: introduce protocol hdr based buffer split

Quoted 10 lines
Quoted 1 line

Is it the right one since it is listed in patchwork?

Yes, it is.

Quoted 6 lines · On 6/1/22 16:50, [email protected] wrote:
Quoted 4 lines

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx

packet

Quoted 8 lines
Quoted 8 lines

segment

Quoted 6 lines

configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

a -> an

Thanks for your catch, will fix it in next version.

Quoted 2 lines
Quoted 2 lines

segment, it is almost impossible to pass a fixed protocol header to

PMD.

Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 10 lines

Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding

protocol

Quoted 2 lines

header is configured, PMD will split the ingress packets into multiple

segments.

Quoted 5 lines

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate
segment from

*/

Quoted 8 lines

uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Both inner and outer L2/L3/L4 level protocol header split can be

supported.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP,

RTE_PTYPE_INNER_L2_ETHER,

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines

RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6,
RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP,

RTE_PTYPE_INNER_L4_SCTP.

Quoted 7 lines

For example, let's suppose we configured the Rx queue with the following segments:

       seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
       seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
       seg2 - pool2, off1=0B
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf

from

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

pool0

Quoted 2 lines

seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

It must be defined how ICMPv4 packets will be split in such case. And how UDP over IPv6 will be split.

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

The ICMP header type is missed, I will define the expected split behavior and add it in next version, thanks for your catch.

I have a question here. Since ICMP packets are mainly used to check the connectivity of network, is it necessary for us to split ICMP packets? And I found there is no RTE_PTYPE for ICMP.

Quoted 5 lines

I'm not saying that we should split on ICMP. I'm just saying that we must define the behaviour when happens for packets which do not match split specification. Does it split on longest match and everything else is put in (which?) last buffer? E.g. we configure split on ETH-IPv4-TCP. What does happen with ETH-IPv4-UDP? ETH-IPv6?

Get your point. Firstly, our device only supports to split the packets into two segments, So there will be an exact match for the configured protocol header. Back to this question, for the set of proto_hdrs configured, it can have two behaviors:
1. The aggressive way is to split on longest match you mentioned, E.g. we configure split on ETH-IPV4-TCP, when receives ETH-IPV4-UDP or ETH-IPV6, it can also split on ETH-IPV4 or ETH.
2. A more conservative way is to split only when the packets meet the protocol headers in the RX packet segment. In the above situation, it will not do split for ETH-IPV4-UDP and ETH-IPV6.

I prefer the second behavior, because the split is usually for the inner most header and payload, if it does not meet, the rest of the headers have no actual value. What do you think?

Quoted 29 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

In fact, the buffer split based on protocol header depends on the driver

parsing result.

Quoted 2 lines

As long as driver can recognize this packet type, I think there is no difference between UDP over IPV4 and UDP over IPV6?

Quoted 7 lines
Quoted 3 lines

We can bind it to ptypes recognized by the HW+driver, but I can easily imagine the case when HW has no means to report recognized packet type (i.e. ptype get returns empty list), but still could split on it.

Get your point. But if one ptype cannot be recognized by HW+driver, is it still necessary for us to do the split? The main purpose of buffer split is to split header and payload. Although we add split for various

protocol headers now, we should focus the ptype can be recognized.

Recognition and reporting is a separate things. It could be recognized, but it can have no means to report it to the driver. ptype_get is about reporting.

Quoted 9 lines
Quoted 8 lines

Also, nobody guarantees that there is no different in UDP over IPv4 vs
IPv6 recognition and split. IPv6 could have a number of extension headers which could be not that trivial to hop in HW. So, HW could recognize IPv6, but not protocols after it.
Also it is very interesting question how to define protocol split for IPv6 plus extension headers. Where to stop?

Quoted 8 lines
Quoted 5 lines

The extension header you mentioned is indeed an interesting question. On our device, the stop would be the end of extension header. The same as above, the main purpose of buffers split is for header and payload. Even rte_flow, we don't list all of the extension headers. So we can't cope with all the IPV6 extension headers.

Again, we must define the behaviour. Application needs to know what to expect.

Now I understand the behavior needs to defined clearly for application. Application need a clear expectation for each function call.

Quoted 9 lines
Quoted 5 lines

For IPV6 extension headers, what if we treat the IPV6 header and extension header as one layer? Because 99% of cases will not require a separate extension header.

I'd like to highlight that it is not "an extension header". It is 'extension headers' (plural). I'm not sure that we can say that in order to split on IPv6 HW must support *all* (even future) extension headers.

Yes, I'm also referring to extension headers(plural) here.

Whether it's one or more layers of headers for IPV6, as long as the driver can recognize the end of the IPV6 extension header, we split the IPV6 header once. E.g. For ETH-IPV6-IPV6 extension-UDP-payload, we split it to ETH-IPV6-IPV6-extension, UDP and payload with Rx segment RTE_PTYPE_IPV6, RTE_PTYPE_UDP configured.

This is the behavior I hope to define for IPV6 extension(also our device's behavior). We don't specify the IPV6 extension header in the RX segment. If IPV6 split is configured, the IPV6 and extension header(if have) will be tread as a layer.

Quoted 156 lines
Quoted 3 lines

Hope to get your insights.

Unfortunately I have no solutions. Just questions to be answered...

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be

configured.

Quoted 27 lines
Quoted 27 lines
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines

For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory,

respectively.

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
---
    lib/ethdev/rte_ethdev.c | 40

+++++++++++++++++++++++++++++++++---

----

Quoted 9 lines
Quoted 9 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct

Quoted 8 lines
    lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++-
    2 files changed, 60 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c +0 -0
index 29a3d80466..fbd55cdd9d 100644
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
lib/ethdev/rte_ethdev.c +1 -0
    		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
    		uint32_t length = rx_seg[seg_idx].length;
    		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;
 
    		if (mpl == NULL) {
    			RTE_ETHDEV_LOG(ERR, "null mempool

pointer\n");

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

@@ -1694,13

Quoted 1 line

+1695,38 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

Quoted 2 lines
    		}
    		offset += seg_idx != 0 ? 0 :

RTE_PKTMBUF_HEADROOM;

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 5 lines
    		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
lib/ethdev/rte_ethdev.c +0 -4
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 9 lines
lib/ethdev/rte_ethdev.c +6 -3
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+			/* Split at fixed length. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s

mbuf_data_room_size %u < %u

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,

Quoted 7 lines
lib/ethdev/rte_ethdev.c +7 -0
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Split after specified protocol header. */
+			if (!(proto_hdr &

RTE_BUFFER_SPLIT_PROTO_HDR_MASK)) {

The condition looks suspicious. It will be true if proto_hdr has no single bit from the mask. I guess it is not the intent.

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

Actually it is the intent... Here the mask is used to check if proto_hdr belongs to the inner/outer L2/L3/L4 capability we defined. And which proto_hdr is supported by the NIC will be checked in the PMD

later.

Need to correct here. You are right, I made a bug in previous

implementation.

Quoted 7 lines
Quoted 5 lines

Frankly speaking I see no value in such incomplete check if we still rely on driver. I simply see no reason to oblige the driver to support one of these protocols.

With API, we can get the driver's capabilities first, and do the check in

ethdev later.

Quoted 56 lines

In this way, we can finish the checks in once. Please see v9.

Quoted 20 lines
Quoted 6 lines
Quoted 6 lines

I guess the condition should be
proto_hdr & ~RTE_BUFFER_SPLIT_PROTO_HDR_MASK i.e. there is
unsupported bits in proto_hdr

Quoted 7 lines
Quoted 4 lines

IMHO we need extra field in dev_info to report supported protocols to split on. Or a new API to get an array similar to ptype get. May be a new API is a better choice to not overload dev_info and to be more flexible in reporting.

Thanks for your suggestion.
Here I hope to confirm the intent of dev_info or API to expose the

supported proto_hdr of driver.

Quoted 4 lines

Is it for the pro_hdr check in the rte_eth_rx_queue_check_split()? If so, could we just check whether pro_hdrs configured belongs to L2/L3/L4 in lib, and check the capability in PMD? This is what the current

design does.

Quoted 7 lines

Look. Application needs to know what to expect from eth device. It should know which protocols it can split on. Of course we can enforce application to use try-fail approach which would make sense if we have dedicated API to request Rx buffer split, but since it is done via Rx queue configuration, it could be tricky for application to realize which part of the configuration is wrong. It could simply result in a too many retries with different configuration.

Agree. To avoid the unnecessary try-fails, I will add a new API in dev_ops, please see v9.

Quoted 6 lines

I.e. the information should be used by ethdev to validate request and the information should be ued by the application to understand what is supported.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

Actually I have another question, do we need a API or dev_info to expose

which buffer split the driver supports.

Quoted 2 lines

i.e. length based or proto_hdr based. Because it requires different fields to be configured in RX packet segment.

See above. If dedicated API return -ENOTSUP or empty set of supported protocols to split on, the answer is clear.

Get your point. I totally agree with your idea of a new API. Through the API, the logic will look like:
ret = rte_get_supported_buffer_split_proto();
if (ret == -ENOTSUP)
Check length based buffer split
else
Checked proto based buffer split

Quoted 8 lines
Quoted 5 lines

We don't need to care about the irrelevant fields in respective buffer split anymore.

BTW, could you help to review the deprecation notice for header split? If it gets acked, I will start the deprecation in 22.11.

Since the feature is definitely dead. I'd use faster track. Deprecate in 22.07 and remove in 22.11.

Does this mean I don't need to do the remove work? I'm also willing to help. A deprecation notice has been sent in 22.07.
http://patchwork.dpdk.org/project/dpdk/patch/[email protected]/

Thanks,
Xuan

Quoted 22 lines
Quoted 22 lines

Thanks,
Xuan

Quoted 17 lines
Quoted 17 lines

Hope to get your insights. :)

Quoted 7 lines

lib/ethdev/rte_ethdev.c

Quoted 3 lines
lib/ethdev/rte_ethdev.c +2 -0
+				RTE_ETHDEV_LOG(ERR,
+					"Protocol header %u not

supported)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1713

Quoted 1 line
lib/ethdev/rte_ethdev.c +1 -0
+					proto_hdr);

I think it would be useful to log unsupported bits only, if we say so.

The same as above.
Thanks again for your time.

Regards,
Xuan

#61 lore raw

PATCH v8 1/3 ethdev: introduce protocol header based buffer split

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet segment configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet segment, it is almost impossible to pass a fixed protocol header to PMD. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding protocol header is configured, PMD will split the ingress packets into multiple segments.

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Both inner and outer L2/L3/L4 level protocol header split can be supported. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP, RTE_PTYPE_INNER_L4_SCTP.

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
    seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
    seg2 - pool2, off1=0B

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 40 +++++++++++++++++++++++++++++++++-------
 lib/ethdev/rte_ethdev.h | 28 +++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 8 deletions(-)
lib/ethdev/rte_ethdev.c +33 -7
index 29a3d80466..fbd55cdd9d 100644
@@ -1661,6 +1661,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;
 
 		if (mpl == NULL) {
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1694,13 +1695,38 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		}
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+		if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+			/* Split at fixed length. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else {
+			/* Split after specified protocol header. */
+			if (!(proto_hdr & RTE_BUFFER_SPLIT_PROTO_HDR_MASK)) {
+				RTE_ETHDEV_LOG(ERR,
+					"Protocol header %u not supported)\n",
+					proto_hdr);
+				return -EINVAL;
+			}
+
+			if (length != 0) {
+				RTE_ETHDEV_LOG(ERR, "segment length should be set to zero in protocol header "
+					       "based buffer split\n");
+				return -EINVAL;
+			}
+
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+						"%s mbuf_data_room_size %u < %u segment offset)\n",
+						mpl->name, *mbp_buf_size,
+						offset);
+				return -EINVAL;
+			}
 		}
 	}
 	return 0;
lib/ethdev/rte_ethdev.h +27 -1
index 04cff8ee10..0cd9dd6cc0 100644
@@ -1187,6 +1187,9 @@ struct rte_eth_txmode {
  *   mbuf) the following data will be pushed to the next segment
  *   up to its own length, and so on.
  *
+ * - The proto_hdrs in the elements define the split position of
+ *   received packets.
+ *
  * - If the length in the segment description element is zero
  *   the actual buffer size will be deduced from the appropriate
  *   memory pool properties.
@@ -1197,14 +1200,37 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
+ *     - The proto_hdr field should not be configured.
+ *
+ * - Protocol header based buffer split:
+ *     - mp, offset, proto_hdr should be configured.
+ *     - The length field should not be configured.
  */
 struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	uint32_t proto_hdr; /**< Inner/outer L2/L3/L4 protocol header, configures split point. */
 };
 
+/* Buffer split protocol header capability. */
+#define RTE_BUFFER_SPLIT_PROTO_HDR_MASK ( \
+	RTE_PTYPE_L2_ETHER | \
+	RTE_PTYPE_L3_IPV4 | \
+	RTE_PTYPE_L3_IPV6 | \
+	RTE_PTYPE_L4_TCP | \
+	RTE_PTYPE_L4_UDP | \
+	RTE_PTYPE_L4_SCTP | \
+	RTE_PTYPE_INNER_L2_ETHER | \
+	RTE_PTYPE_INNER_L3_IPV4 | \
+	RTE_PTYPE_INNER_L3_IPV6 | \
+	RTE_PTYPE_INNER_L4_TCP | \
+	RTE_PTYPE_INNER_L4_UDP | \
+	RTE_PTYPE_INNER_L4_SCTP)
+
 /**
  * @warning
  * @b EXPERIMENTAL: this structure may change without prior notice.
Signature · 1 line
2.25.1
#62 lore raw

Re: [PATCH v8 1/3] ethdev: introduce protocol header based buffer split

There are two v8 1/3 patches in my mailbox. Which one is the right one?

Quoted 68 lines · On 6/1/22 16:50, [email protected] wrote:

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet segment configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet segment, it is almost impossible to pass a fixed protocol header to PMD. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding protocol header is configured, PMD will split the ingress packets into multiple segments.

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Both inner and outer L2/L3/L4 level protocol header split can be supported. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP, RTE_PTYPE_INNER_L4_SCTP.

For example, let's suppose we configured the Rx queue with the following segments:

     seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
     seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
     seg2 - pool2, off1=0B

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.

[snip]

author
#63 lore raw

RE: [PATCH v8 1/3] ethdev: introduce protocol header based buffer split

Hi Andrew,

Quoted 13 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, June 2, 2022 9:21 PM
To: Wu, WenxuanX <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; Ray Kinsella <[email protected]>
Subject: Re: [PATCH v8 1/3] ethdev: introduce protocol header based buffer split

Quoted 1 line

There are two v8 1/3 patches in my mailbox. Which one is the right one?

Yes, you are right, the second one is the latest one, sorry for the inconvenience.

Thanks,
Xuan

Quoted 80 lines · On 6/1/22 16:50, [email protected] wrote:
Quoted 4 lines

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet

segment

Quoted 6 lines

configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given a arbitrarily variable length in Rx packet segment, it is almost impossible to pass a fixed protocol

header to PMD.

Quoted 10 lines

Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding

protocol

Quoted 1 line

header is configured, PMD will split the ingress packets into multiple

segments.

Quoted 4 lines

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from

*/

Quoted 8 lines

uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

Quoted 6 lines

Both inner and outer L2/L3/L4 level protocol header split can be supported. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP,

RTE_PTYPE_INNER_L4_SCTP.

Quoted 10 lines

For example, let's suppose we configured the Rx queue with the following segments:

     seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
     seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
     seg2 - pool2, off1=0B

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from

pool0

Quoted 10 lines

seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

Now buffet split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

Quoted 3 lines

The split limitations imposed by underlying PMD is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory,

respectively.

Quoted 6 lines

[snip]

#64 lore raw

PATCH v8 2/3 net/ice: support buffer split in Rx path

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

This patch adds support for proto based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly splitted into protocol header and payload parts. And the two parts will be put into different mempools.

Currently, protocol based buffer split is not supported in vectorized paths.

---
 drivers/net/ice/ice_ethdev.c          |  10 +-
 drivers/net/ice/ice_rxtx.c            | 220 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 4 files changed, 217 insertions(+), 32 deletions(-)
drivers/net/ice/ice_ethdev.c +8 -2
index 73e550f5fb..ce3f49c863 100644
@@ -3713,7 +3713,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 			RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 			RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |
 			RTE_ETH_RX_OFFLOAD_RSS_HASH |
-			RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+			RTE_ETH_RX_OFFLOAD_TIMESTAMP |
+			RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT;
 		dev_info->tx_offload_capa |=
 			RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
 			RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -3725,7 +3726,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->flow_type_rss_offloads |= ICE_RSS_OFFLOAD_ALL;
 	}
 
-	dev_info->rx_queue_offload_capa = 0;
+	dev_info->rx_queue_offload_capa = RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT;
 	dev_info->tx_queue_offload_capa = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->reta_size = pf->hash_lut_size;
@@ -3794,6 +3795,11 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->default_rxportconf.ring_size = ICE_BUF_SIZE_MIN;
 	dev_info->default_txportconf.ring_size = ICE_BUF_SIZE_MIN;
 
+	dev_info->rx_seg_capa.max_nseg = ICE_RX_MAX_NSEG;
+	dev_info->rx_seg_capa.multi_pools = 1;
+	dev_info->rx_seg_capa.offset_allowed = 0;
+	dev_info->rx_seg_capa.offset_align_log2 = 0;
+
 	return 0;
 }
 
drivers/net/ice/ice_rxtx.c +190 -30

362 lines not on this page · raw message

drivers/net/ice/ice_rxtx.h +16 -0
index bb18a01951..611dbc8503 100644
@@ -16,6 +16,9 @@
 #define ICE_RX_MAX_BURST 32
 #define ICE_TX_MAX_BURST 32
 
+/* Maximal number of segments to split. */
+#define ICE_RX_MAX_NSEG 2
+
 #define ICE_CHK_Q_ENA_COUNT        100
 #define ICE_CHK_Q_ENA_INTERVAL_US  100
 
@@ -43,6 +46,11 @@
 extern uint64_t ice_timestamp_dynflag;
 extern int ice_timestamp_dynfield_offset;
 
+/* Max header size can be 2K - 64 bytes */
+#define ICE_RX_HDR_BUF_SIZE    (2048 - 64)
+
+#define ICE_HEADER_SPLIT_ENA   BIT(0)
+
 typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);
 typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq);
 typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {
 	struct rte_mbuf *mbuf;
 };
 
+enum ice_rx_dtype {
+	ICE_RX_DTYPE_NO_SPLIT       = 0,
+	ICE_RX_DTYPE_HEADER_SPLIT   = 1,
+	ICE_RX_DTYPE_SPLIT_ALWAYS   = 2,
+};
+
 struct ice_rx_queue {
 	struct rte_mempool *mp; /* mbuf pool to populate RX ring */
 	volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -95,6 +109,8 @@ struct ice_rx_queue {
 	uint32_t time_high;
 	uint32_t hw_register_set;
 	const struct rte_memzone *mz;
+	struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG];
+	uint32_t rxseg_nb;
 };
 
 struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
index 2dd2d83650..eec6ea2134 100644
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)
 	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
 		return -1;
 
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)
+		return -1;
+
 	if (rxq->offloads & ICE_RX_VECTOR_OFFLOAD)
 		return ICE_VECTOR_OFFLOAD_PATH;
 
Signature · 1 line
2.25.1
#65 lore raw

PATCH v8 3/3 app/testpmd: add rxhdrs commands and parameters

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

Add command line parameter:
--rxhdrs=mac,[ipv4,udp]

Set the protocol_hdr of segments to scatter packets on receiving if split feature is engaged. And the queues with BUFFER_SPLIT flag.

Add interative mode command:
testpmd>set rxhdrs mac,ipv4,l3,tcp,udp,sctp
(protocol sequence and nb_segs should be valid)

The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with two mempools. e.g. --mbuf-size=2048,2048
2. Configure Rx queue with rx_offload buffer split on.
3. Set the protocol type of buffer split.e.g. set rxhdrs mac,ipv4 (Supported protocols: mac|ipv4|ipv6|l3|tcp|udp|sctp|l4|inner_mac|

			     inner_ipv4|inner_ipv6|inner_l3|inner_tcp|
                    	     inner_udp|inner_sctp|inner_l4)
---
 app/test-pmd/cmdline.c    | 127 +++++++++++++++++++++++++++++++++++++-
 app/test-pmd/config.c     |  81 ++++++++++++++++++++++++
 app/test-pmd/parameters.c |  15 ++++-
 app/test-pmd/testpmd.c    |   6 +-
 app/test-pmd/testpmd.h    |   6 ++
 5 files changed, 228 insertions(+), 7 deletions(-)
app/test-pmd/cmdline.c +124 -3
index 6ffea8e21a..52e98e1c06 100644
@@ -183,7 +183,7 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"show (rxq|txq) info (port_id) (queue_id)\n"
 			"    Display information for configured RX/TX queue.\n\n"
 
-			"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
+			"show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n"
 			"    Display the given configuration.\n\n"
 
 			"read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -316,6 +316,15 @@ static void cmd_help_long_parsed(void *parsed_result,
 			" Affects only the queues configured with split"
 			" offloads.\n\n"
 
+			"set rxhdrs (mac[,ipv4])*\n"
+			"	Set the protocol hdr of each segment to scatter"
+			" packets on receiving if split feature is engaged."
+			" Affects only the queues configured with split"
+			" offloads.\n\n"
+			"	Supported proto header: mac|ipv4|ipv6|l3|tcp|udp|sctp|l4|"
+			"inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|"
+			"inner_udp|inner_sctp\n"
+
 			"set txpkts (x[,y]*)\n"
 			"    Set the length of each segment of TXONLY"
 			" and optionally CSUM packets.\n\n"
@@ -3617,6 +3626,72 @@ cmdline_parse_inst_t cmd_stop = {
 	},
 };
 
+static unsigned int
+get_ptype(char *value)
+{
+	uint32_t protocol;
+	if (!strcmp(value, "mac"))
+		protocol = RTE_PTYPE_L2_ETHER;
+	else if (!strcmp(value, "ipv4"))
+		protocol = RTE_PTYPE_L3_IPV4;
+	else if (!strcmp(value, "ipv6"))
+		protocol = RTE_PTYPE_L3_IPV6;
+	else if (!strcmp(value, "l3"))
+		protocol = RTE_PTYPE_L3_IPV4|RTE_PTYPE_L3_IPV6;
+	else if (!strcmp(value, "tcp"))
+		protocol = RTE_PTYPE_L4_TCP;
+	else if (!strcmp(value, "udp"))
+		protocol = RTE_PTYPE_L4_UDP;
+	else if (!strcmp(value, "sctp"))
+		protocol = RTE_PTYPE_L4_SCTP;
+	else if (!strcmp(value, "l4"))
+		protocol = RTE_PTYPE_L4_TCP|RTE_PTYPE_L4_UDP|RTE_PTYPE_L4_SCTP;
+	else if (!strcmp(value, "inner_mac"))
+		protocol = RTE_PTYPE_INNER_L2_ETHER;
+	else if (!strcmp(value, "inner_ipv4"))
+		protocol = RTE_PTYPE_INNER_L3_IPV4;
+	else if (!strcmp(value, "inner_ipv6"))
+		protocol = RTE_PTYPE_INNER_L3_IPV6;
+	else if (!strcmp(value, "inner_l3"))
+		protocol = RTE_PTYPE_INNER_L3_IPV4|RTE_PTYPE_INNER_L3_IPV6;
+	else if (!strcmp(value, "inner_tcp"))
+		protocol = RTE_PTYPE_INNER_L4_TCP;
+	else if (!strcmp(value, "inner_udp"))
+		protocol = RTE_PTYPE_INNER_L4_UDP;
+	else if (!strcmp(value, "inner_sctp"))
+		protocol = RTE_PTYPE_INNER_L4_SCTP;
+	else {
+		fprintf(stderr, "Unknown protocol name: %s\n", value);
+		return 0;
+	}
+	return protocol;
+}
+/* *** SET RXHDRSLIST *** */
+
+unsigned int
+parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
+				unsigned int *parsed_items, int check_hdrs_sequence)
+{
+	unsigned int nb_item;
+	char *cur;
+	char *tmp;
+	nb_item = 0;
+	char *str2 = strdup(str);
+	cur = strtok_r(str2, ",", &tmp);
+	while (cur != NULL) {
+		parsed_items[nb_item] = get_ptype(cur);
+		cur = strtok_r(NULL, ",", &tmp);
+		nb_item++;
+	}
+	if (nb_item > max_items)
+		fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
+			item_name, nb_item + 1, max_items);
+	set_rx_pkt_hdrs(parsed_items, nb_item);
+	free(str2);
+	if (!check_hdrs_sequence)
+		return nb_item;
+	return nb_item;
+}
 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
 
 unsigned int
@@ -3986,6 +4061,49 @@ cmdline_parse_inst_t cmd_set_rxpkts = {
 	},
 };
 
+/* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
+struct cmd_set_rxhdrs_result {
+	cmdline_fixed_string_t cmd_keyword;
+	cmdline_fixed_string_t rxhdrs;
+	cmdline_fixed_string_t seg_hdrs;
+};
+
+static void
+cmd_set_rxhdrs_parsed(void *parsed_result,
+		      __rte_unused struct cmdline *cl,
+		      __rte_unused void *data)
+{
+	struct cmd_set_rxhdrs_result *res;
+	unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
+	unsigned int nb_segs;
+
+	res = parsed_result;
+	nb_segs = parse_hdrs_list(res->seg_hdrs, "segment hdrs",
+				  MAX_SEGS_BUFFER_SPLIT, seg_hdrs, 0);
+	if (nb_segs >= 1)
+		set_rx_pkt_hdrs(seg_hdrs, nb_segs);
+	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
+}
+cmdline_parse_token_string_t cmd_set_rxhdrs_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
+				 cmd_keyword, "set");
+cmdline_parse_token_string_t cmd_set_rxhdrs_name =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
+				 rxhdrs, "rxhdrs");
+cmdline_parse_token_string_t cmd_set_rxhdrs_seg_hdrs =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
+				 seg_hdrs, NULL);
+cmdline_parse_inst_t cmd_set_rxhdrs = {
+	.f = cmd_set_rxhdrs_parsed,
+	.data = NULL,
+	.help_str = "set rxhdrs <mac[,ipv4]*>",
+	.tokens = {
+		(void *)&cmd_set_rxhdrs_keyword,
+		(void *)&cmd_set_rxhdrs_name,
+		(void *)&cmd_set_rxhdrs_seg_hdrs,
+		NULL,
+	},
+};
 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
 
 struct cmd_set_txpkts_result {
@@ -8058,6 +8176,8 @@ static void cmd_showcfg_parsed(void *parsed_result,
 		show_rx_pkt_offsets();
 	else if (!strcmp(res->what, "rxpkts"))
 		show_rx_pkt_segments();
+	else if (!strcmp(res->what, "rxhdrs"))
+		show_rx_pkt_hdrs();
 	else if (!strcmp(res->what, "txpkts"))
 		show_tx_pkt_segments();
 	else if (!strcmp(res->what, "txtimes"))
@@ -8070,12 +8190,12 @@ cmdline_parse_token_string_t cmd_showcfg_port =
 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
 cmdline_parse_token_string_t cmd_showcfg_what =
 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
-				 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
+				 "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes");
 
 cmdline_parse_inst_t cmd_showcfg = {
 	.f = cmd_showcfg_parsed,
 	.data = NULL,
-	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
+	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes",
 	.tokens = {
 		(void *)&cmd_showcfg_show,
 		(void *)&cmd_showcfg_port,
@@ -17833,6 +17953,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_set_log,
 	(cmdline_parse_inst_t *)&cmd_set_rxoffs,
 	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
+	(cmdline_parse_inst_t *)&cmd_set_rxhdrs,
 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
app/test-pmd/config.c +81 -0

87 lines not on this page · raw message

app/test-pmd/parameters.c +14 -1
index daf6a31b2b..f86d626276 100644
@@ -161,6 +161,7 @@ usage(char* progname)
 	       " Used mainly with PCAP drivers.\n");
 	printf("  --rxoffs=X[,Y]*: set RX segment offsets for split.\n");
 	printf("  --rxpkts=X[,Y]*: set RX segment sizes to split.\n");
+	printf("  --rxhdrs=mac[,ipv4]*: set RX segment protocol to split.\n");
 	printf("  --txpkts=X[,Y]*: set TX segment sizes"
 		" or total packet length.\n");
 	printf("  --txonly-multi-flow: generate multiple flows in txonly mode\n");
@@ -673,6 +674,7 @@ launch_args_parse(int argc, char** argv)
 		{ "flow-isolate-all",	        0, 0, 0 },
 		{ "rxoffs",			1, 0, 0 },
 		{ "rxpkts",			1, 0, 0 },
+		{ "rxhdrs",			1, 0, 0 },
 		{ "txpkts",			1, 0, 0 },
 		{ "txonly-multi-flow",		0, 0, 0 },
 		{ "rxq-share",			2, 0, 0 },
@@ -1327,7 +1329,6 @@ launch_args_parse(int argc, char** argv)
 			if (!strcmp(lgopts[opt_idx].name, "rxpkts")) {
 				unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT];
 				unsigned int nb_segs;
-
 				nb_segs = parse_item_list
 						(optarg, "rxpkt segments",
 						 MAX_SEGS_BUFFER_SPLIT,
@@ -1337,6 +1338,18 @@ launch_args_parse(int argc, char** argv)
 				else
 					rte_exit(EXIT_FAILURE, "bad rxpkts\n");
 			}
+			if (!strcmp(lgopts[opt_idx].name, "rxhdrs")) {
+				unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
+				unsigned int nb_segs;
+				nb_segs = parse_hdrs_list
+						(optarg, "rxpkt segments",
+						MAX_SEGS_BUFFER_SPLIT,
+						seg_hdrs, 0);
+				if (nb_segs >= 1)
+					set_rx_pkt_hdrs(seg_hdrs, nb_segs);
+				else
+					rte_exit(EXIT_FAILURE, "bad rxpkts\n");
+			}
 			if (!strcmp(lgopts[opt_idx].name, "txpkts")) {
 				unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
 				unsigned int nb_segs;
app/test-pmd/testpmd.c +3 -3
index fe2ce19f99..77379b7aa9 100644
@@ -240,6 +240,7 @@ uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
 uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
 uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT];
 uint8_t  rx_pkt_nb_offs; /**< Number of specified offsets */
+uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT];
 
 /*
  * Configuration of packet segments used by the "txonly" processing engine.
@@ -2586,12 +2587,11 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		mp_n = (i > mbuf_data_size_n) ? mbuf_data_size_n - 1 : i;
 		mpx = mbuf_pool_find(socket_id, mp_n);
 		/* Handle zero as mbuf data buffer size. */
-		rx_seg->length = rx_pkt_seg_lengths[i] ?
-				   rx_pkt_seg_lengths[i] :
-				   mbuf_data_size[mp_n];
+		rx_seg->length = rx_pkt_seg_lengths[i];
 		rx_seg->offset = i < rx_pkt_nb_offs ?
 				   rx_pkt_seg_offsets[i] : 0;
 		rx_seg->mp = mpx ? mpx : mp;
+		rx_seg->proto_hdr = rx_pkt_hdr_protos[i];
 	}
 	rx_conf->rx_nseg = rx_pkt_nb_segs;
 	rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +6 -0
index 31f766c965..e791b9becd 100644
@@ -534,6 +534,7 @@ extern uint32_t max_rx_pkt_len;
  * Configuration of packet segments used to scatter received packets
  * if some of split features is configured.
  */
+extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT];
 extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
 extern uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
 extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT];
@@ -864,6 +865,9 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)
 unsigned int parse_item_list(const char *str, const char *item_name,
 			unsigned int max_items,
 			unsigned int *parsed_items, int check_unique_values);
+unsigned int parse_hdrs_list(const char *str, const char *item_name,
+			unsigned int max_item,
+			unsigned int *parsed_items, int check_unique_values);
 void launch_args_parse(int argc, char** argv);
 void cmdline_read_from_file(const char *filename);
 void prompt(void);
@@ -1018,6 +1022,8 @@ void set_record_core_cycles(uint8_t on_off);
 void set_record_burst_stats(uint8_t on_off);
 void set_verbose_level(uint16_t vb_level);
 void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
+void set_rx_pkt_hdrs(unsigned int *seg_protos, unsigned int nb_segs);
+void show_rx_pkt_hdrs(void);
 void show_rx_pkt_segments(void);
 void set_rx_pkt_offsets(unsigned int *seg_offsets, unsigned int nb_offs);
 void show_rx_pkt_offsets(void);
Signature · 1 line
2.25.1
#66 lore raw
In reply to [email protected]
Quoted 3 lines · On 6/1/22 16:50, [email protected] wrote:

From: Wenxuan Wu <[email protected]>

Buffer split consists of splitting a received packet into two separate

'two' is misleading above. Buffer split supports many segments.

Quoted 1 line

regions based on the packet content.

As far as I know buffer split is not based on packet content.

Quoted 7 lines

It is useful in some scenarios,
such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.

This patchset extends the current buffer split to support multi protocol headers split. When Rx queue is configured with buffer split feature, packets received will be directly splitted into two different mempools.

v8?

Quoted 41 lines

v6->v7:
*fix supported header protocol check.
*add rxhdrs commands and parameters.
v5->v6:
*Change doc and designi of struct rte_eth_rxseg_split, support multi segments protocol_hdr configuration.
v4->v5:
* Use protocol and mbuf_offset based buffer split instead of header split.
* Use RTE_PTYPE* instead of enum rte_eth_rx_header_split_protocol_type.
* Improve the description of rte_eth_rxseg_split.proto.

v3->v4:
* Use RTE_ETH_RX_HEADER_SPLIT_NONE instead of 0.

v2->v3:
* Fix a PMD bug.
* Add rx queue header split check.
* Revise the log and doc.

v1->v2:
* Add support for all header split protocol types.

Wenxuan Wu (3):
ethdev: introduce protocol header based buffer split net/ice: support buffer split in Rx path app/testpmd: add rxhdrs commands and parameters

  app/test-pmd/cmdline.c                | 127 ++++++++++++++-
  app/test-pmd/config.c                 |  81 ++++++++++
  app/test-pmd/parameters.c             |  15 +-
  app/test-pmd/testpmd.c                |   6 +-
  app/test-pmd/testpmd.h                |   6 +
  drivers/net/ice/ice_ethdev.c          |  10 +-
  drivers/net/ice/ice_rxtx.c            | 220 ++++++++++++++++++++++----
  drivers/net/ice/ice_rxtx.h            |  16 ++
  drivers/net/ice/ice_rxtx_vec_common.h |   3 +
  lib/ethdev/rte_ethdev.c               |  40 ++++-
  lib/ethdev/rte_ethdev.h               |  28 +++-
  11 files changed, 505 insertions(+), 47 deletions(-)
#67 lore raw

v9 cover add an api to support proto based buffer split

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

Protocol type based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.

This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload and corresponding protocol, packets received will be directly split into different mempools.

v8->v9:
* Introduce a new api rte_eth_supported_hdrs_get to retrieve supported ptypes mask of a pmd to split.
* Fix header protocol split check.
* Support header protocol configuration of rxhdrs by default, e.g. ipv4, ipv6, mac, inner_mac, outer_mac, l3, l4.
* Refine doc.

v7->v8:
* Refine ethdev doc.
* Fix header protocol split check.

v6->v7:
* Fix supported header protocol check.
* Add rxhdrs commands and parameters.

v5->v6:
* The header split deprecation notice is sent.
* Refine the documents, protocol header based buffer split can actually support multi-segment split.
* Add buffer split protocol header capability.
* Fix some format issues.

v4->v5:
* Use protocol and mbuf_offset based buffer split instead of header split.
* Use RTE_PTYPE* instead of enum rte_eth_rx_header_split_protocol_type.
* Improve the description of rte_eth_rxseg_split.proto.

v3->v4:
* Use RTE_ETH_RX_HEADER_SPLIT_NONE instead of 0.

v2->v3:
* Fix a PMD bug.
* Add rx queue header split check.
* Revise the log and doc.

v1->v2:
* Add support for all header split protocol types.

Wenxuan Wu (4):
ethdev: introduce protocol header API
ethdev: introduce protocol hdr based buffer split app/testpmd: add rxhdrs commands and parameters net/ice: support buffer split in Rx path

 app/test-pmd/cmdline.c                 | 133 ++++++++++++++-
 app/test-pmd/config.c                  |  75 +++++++++
 app/test-pmd/parameters.c              |  15 +-
 app/test-pmd/testpmd.c                 |   6 +-
 app/test-pmd/testpmd.h                 |   6 +
 doc/guides/rel_notes/release_22_07.rst |   2 +
 drivers/net/ice/ice_ethdev.c           |  38 ++++-
 drivers/net/ice/ice_rxtx.c             | 220 +++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h             |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h  |   3 +
 lib/ethdev/ethdev_driver.h             |  18 ++
 lib/ethdev/rte_ethdev.c                |  61 +++++--
 lib/ethdev/rte_ethdev.h                |  36 +++-
 lib/ethdev/version.map                 |   3 +
 14 files changed, 582 insertions(+), 50 deletions(-)
Signature · 1 line
2.25.1
#68 lore raw

PATCH v9 1/4 ethdev: introduce protocol header API

From: Wenxuan Wu <[email protected]>

This patch added new ethdev API to retrieve supported protocol header mask of a PMD, which helps to configure protocol header based buffer split.

---
 doc/guides/rel_notes/release_22_07.rst |  2 ++
 lib/ethdev/ethdev_driver.h             | 18 +++++++++++++++
 lib/ethdev/rte_ethdev.c                | 31 +++++++++++++++++---------
 lib/ethdev/rte_ethdev.h                | 22 ++++++++++++++++++
 lib/ethdev/version.map                 |  3 +++
 5 files changed, 65 insertions(+), 11 deletions(-)
doc/guides/rel_notes/release_22_07.rst +2 -0
index 42a5f2d990..a9b8ed3494 100644
@@ -54,7 +54,9 @@ New Features
      This section is a comment. Do not overwrite or remove it.
      Also, make sure to start the actual text at the margin.
      =======================================================
+* **Added new ethdev API for PMD to get buffer split supported protocol types.**
 
+  Added ``rte_eth_supported_hdrs_get()``, to get supported header protocol mask of a PMD to split.
 
 Removed Items
 -------------
lib/ethdev/ethdev_driver.h +18 -0
index 69d9dc21d8..7b19842582 100644
@@ -1054,6 +1054,21 @@ typedef int (*eth_ip_reassembly_conf_get_t)(struct rte_eth_dev *dev,
 typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,
 		const struct rte_eth_ip_reassembly_params *conf);
 
+/**
+ * @internal
+ * Get supported protocol flags of a PMD to split.
+ *
+ * @param dev
+ *   ethdev handle of port.
+ *
+ * @param[out]  ptype mask
+ *   supported ptype mask of a PMD.
+ *
+ * @return
+ *   Negative errno value on error, zero on success.
+ */
+typedef int (*eth_buffer_split_hdr_ptype_get_t)(struct rte_eth_dev *dev, uint32_t *ptype);
+
 /**
  * @internal
  * Dump private info from device to a file.
@@ -1281,6 +1296,9 @@ struct eth_dev_ops {
 	/** Set IP reassembly configuration */
 	eth_ip_reassembly_conf_set_t ip_reassembly_conf_set;
 
+	/** Get supported ptypes to split */
+	eth_buffer_split_hdr_ptype_get_t hdrs_supported_ptypes_get;
+
 	/** Dump private info from device */
 	eth_dev_priv_dump_t eth_dev_priv_dump;
 };
lib/ethdev/rte_ethdev.c +20 -11
index 29a3d80466..e1f2a0ffe3 100644
@@ -1636,9 +1636,10 @@ rte_eth_dev_is_removed(uint16_t port_id)
 }
 
 static int
-rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
-			     uint16_t n_seg, uint32_t *mbp_buf_size,
-			     const struct rte_eth_dev_info *dev_info)
+rte_eth_rx_queue_check_split(uint16_t port_id,
+				const struct rte_eth_rxseg_split *rx_seg,
+				int16_t n_seg, uint32_t *mbp_buf_size,
+			    const struct rte_eth_dev_info *dev_info)
 {
 	const struct rte_eth_rxseg_capa *seg_capa = &dev_info->rx_seg_capa;
 	struct rte_mempool *mp_first;
@@ -1694,13 +1695,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
 		}
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+
 		}
 	}
 	return 0;
@@ -1779,7 +1774,7 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		n_seg = rx_conf->rx_nseg;
 
 		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
-			ret = rte_eth_rx_queue_check_split(rx_seg, n_seg,
+			ret = rte_eth_rx_queue_check_split(port_id, rx_seg, n_seg,
 							   &mbp_buf_size,
 							   &dev_info);
 			if (ret != 0)
@@ -5844,6 +5839,20 @@ rte_eth_ip_reassembly_conf_set(uint16_t port_id,
 		       (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf));
 }
 
+int
+rte_eth_supported_hdrs_get(uint16_t port_id, uint32_t *ptypes)
+{
+	struct rte_eth_dev *dev;
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->hdrs_supported_ptypes_get,
+				-ENOTSUP);
+
+	return eth_err(port_id,
+		       (*dev->dev_ops->hdrs_supported_ptypes_get)(dev, ptypes));
+}
+
 int
 rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)
 {
lib/ethdev/rte_ethdev.h +22 -0
index 04cff8ee10..72cac1518e 100644
@@ -6152,6 +6152,28 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,
 	return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
 }
 
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get supported header protocols to split supported by PMD.
+ * The API will return error if the device is not valid.
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param ptype
+ *   Supported protocol headers of driver.
+ * @return
+ *   - (-ENOTSUP) if header protocol is not supported by device.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EIO) if device is removed.
+ *   - (0) on success.
+ */
+__rte_experimental
+int rte_eth_supported_hdrs_get(uint16_t port_id,
+		uint32_t *ptype);
+
 #ifdef __cplusplus
 }
 #endif
lib/ethdev/version.map +3 -0
index 20391ab29e..7705c0364a 100644
@@ -279,6 +279,9 @@ EXPERIMENTAL {
 	rte_flow_async_action_handle_create;
 	rte_flow_async_action_handle_destroy;
 	rte_flow_async_action_handle_update;
+
+	# added in 22.07
+	rte_eth_supported_hdrs_get;
 };
 
 INTERNAL {
Signature · 1 line
2.25.1
#69 lore raw

Re: [PATCH v9 1/4] ethdev: introduce protocol header API

13/06/2022 12:25, [email protected]:

Quoted 6 lines

From: Wenxuan Wu <[email protected]>

This patch added new ethdev API to retrieve supported protocol header mask of a PMD, which helps to configure protocol header based buffer split.

Quoted 12 lines

---
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get supported header protocols to split supported by PMD.
+ * The API will return error if the device is not valid.
+ *
+ * @param port_id
+ * The port identifier of the device.
+ * @param ptype
+ * Supported protocol headers of driver.

It doesn't say where to find the types.
Please give the prefix.

lib/ethdev/rte_ethdev.h rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id, · line 6175

Quoted 9 lines

+ * @return

+ *   - (-ENOTSUP) if header protocol is not supported by device.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EIO) if device is removed.
+ *   - (0) on success.

+ */

lib/ethdev/rte_ethdev.h +3 -0
+__rte_experimental
+int rte_eth_supported_hdrs_get(uint16_t port_id,
+		uint32_t *ptype);

The function name is not precise enough.
There should be the word "split" in its name.

#70 lore raw

RE: [PATCH v9 1/4] ethdev: introduce protocol header API

Hi Thomas,

Sorry so long to response your email.

Quoted 31 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, July 7, 2022 5:05 PM
To: Wu, WenxuanX <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v9 1/4] ethdev: introduce protocol header API

13/06/2022 12:25, [email protected]:

Quoted 6 lines

From: Wenxuan Wu <[email protected]>

This patch added new ethdev API to retrieve supported protocol header mask of a PMD, which helps to configure protocol header based buffer split.

Quoted 12 lines

---
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get supported header protocols to split supported by PMD.
+ * The API will return error if the device is not valid.
+ *
+ * @param port_id
+ * The port identifier of the device.
+ * @param ptype
+ * Supported protocol headers of driver.

Quoted 2 lines

It doesn't say where to find the types.
Please give the prefix.

Sorry I didn't catch your point, are you referring the ptype should be composed of RTE_PTYPE_*? Could you explain it in more detail?

Quoted 13 lines

lib/ethdev/rte_ethdev.h rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id, · line 6175

Quoted 10 lines

+ * @return

+ *   - (-ENOTSUP) if header protocol is not supported by device.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EIO) if device is removed.
+ *   - (0) on success.

+ */

lib/ethdev/rte_ethdev.h +3 -0
+__rte_experimental
+int rte_eth_supported_hdrs_get(uint16_t port_id,
+		uint32_t *ptype);

The function name is not precise enough.
There should be the word "split" in its name.

Thanks for the suggestion, it will be revised in the next version.

Thanks,
Yuan

Quoted 1 line
#71 lore raw

Re: [PATCH v9 1/4] ethdev: introduce protocol header API

01/08/2022 09:09, Wang, YuanX:

Quoted 25 lines

Hi Thomas,

Sorry so long to response your email.

From: Thomas Monjalon <[email protected]>

Quoted 20 lines

13/06/2022 12:25, [email protected]:

Quoted 18 lines

From: Wenxuan Wu <[email protected]>

This patch added new ethdev API to retrieve supported protocol header mask of a PMD, which helps to configure protocol header based buffer split.

---
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get supported header protocols to split supported by PMD.
+ * The API will return error if the device is not valid.
+ *
+ * @param port_id
+ * The port identifier of the device.
+ * @param ptype
+ * Supported protocol headers of driver.

Quoted 5 lines
Quoted 2 lines

It doesn't say where to find the types.
Please give the prefix.

Sorry I didn't catch your point, are you referring the ptype should be composed of RTE_PTYPE_*? Could you explain it in more detail?

Yes just give to the user the required info to use the function. If ptype must be composed with RTE_PTYPE_*, it must be said.

Thanks

#72 lore raw

RE: [PATCH v9 1/4] ethdev: introduce protocol header API

Hi Thomas,

Quoted 42 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, August 1, 2022 6:01 PM
To: Wang, YuanX <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]; Wu, WenxuanX <[email protected]>; Ding, Xuan <[email protected]>
Subject: Re: [PATCH v9 1/4] ethdev: introduce protocol header API

01/08/2022 09:09, Wang, YuanX:

Quoted 10 lines

Hi Thomas,

Sorry so long to response your email.

From: Thomas Monjalon <[email protected]>

Quoted 5 lines

13/06/2022 12:25, [email protected]:

Quoted 4 lines

From: Wenxuan Wu <[email protected]>

This patch added new ethdev API to retrieve supported protocol header mask of a PMD, which helps to configure protocol header based

buffer split.

Quoted 18 lines
Quoted 17 lines
Quoted 14 lines

---
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get supported header protocols to split supported by PMD.
+ * The API will return error if the device is not valid.
+ *
+ * @param port_id
+ * The port identifier of the device.
+ * @param ptype
+ * Supported protocol headers of driver.

It doesn't say where to find the types.
Please give the prefix.

Quoted 6 lines
Quoted 1 line

Sorry I didn't catch your point, are you referring the ptype should be

composed of RTE_PTYPE_*?

Quoted 1 line

Could you explain it in more detail?

Yes just give to the user the required info to use the function. If ptype must be composed with RTE_PTYPE_*, it must be said.

Thanks for your explanation, will fix in the next version.

Thanks,
Yuan

Quoted 3 lines

Thanks

#73 lore raw

Re: [PATCH v9 1/4] ethdev: introduce protocol header API

In reply to [email protected]
Quoted 3 lines · On 6/13/22 13:25, [email protected] wrote:

From: Wenxuan Wu <[email protected]>

This patch added new ethdev API to retrieve supported protocol header mask

This patch added -> Add

Quoted 1 line

of a PMD, which helps to configure protocol header based buffer split.

I'd like to see motivation why single mask is considered sufficient. I.e. why don't we follow ptypes approach which is move flexible, but a bit more complicated.

Looking at RTE_PTYPE_* defines carefully it looks like below API simply cannot provide information that we can split after TCP or UDP.

Quoted 2 lines

[snip]

lib/ethdev/ethdev_driver.h struct eth_dev_ops { · line 1301

Quoted 10 lines

/**
* @internal
* Dump private info from device to a file.

lib/ethdev/ethdev_driver.h +3 -0
@@ -1281,6 +1296,9 @@ struct eth_dev_ops {
  	/** Set IP reassembly configuration */
  	eth_ip_reassembly_conf_set_t ip_reassembly_conf_set;
 
+	/** Get supported ptypes to split */
+	eth_buffer_split_hdr_ptype_get_t hdrs_supported_ptypes_get;
+

It is better to be consistent with naming. I.e. just cut prefix "eth_" and suffix "_t".

Also the type name sounds like it get current split configuration, not supported one.

Quoted 22 lines
lib/ethdev/ethdev_driver.h +0 -0
  	/** Dump private info from device */
  	eth_dev_priv_dump_t eth_dev_priv_dump;
  };
lib/ethdev/rte_ethdev.c +4 -3
index 29a3d80466..e1f2a0ffe3 100644
@@ -1636,9 +1636,10 @@ rte_eth_dev_is_removed(uint16_t port_id)
  }
 
  static int
-rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
-			     uint16_t n_seg, uint32_t *mbp_buf_size,
-			     const struct rte_eth_dev_info *dev_info)
+rte_eth_rx_queue_check_split(uint16_t port_id,
+				const struct rte_eth_rxseg_split *rx_seg,
+				int16_t n_seg, uint32_t *mbp_buf_size,
+			    const struct rte_eth_dev_info *dev_info)
  {
  	const struct rte_eth_rxseg_capa *seg_capa = &dev_info->rx_seg_capa;
  	struct rte_mempool *mp_first;

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1698

Quoted 5 lines
lib/ethdev/rte_ethdev.c +0 -2
@@ -1694,13 +1695,7 @@ rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
  		}
  		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
  		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {

I don't understand why the check goes away completely.

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1698

Quoted 6 lines
lib/ethdev/rte_ethdev.c +1 -5
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+

Unnecessary empty line

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1699

Quoted 1 line
lib/ethdev/rte_ethdev.c +0 -0
  		}

Shouldn't the curly bracket go away as well together with its 'if'

Quoted 12 lines
lib/ethdev/rte_ethdev.c +1 -1
  	}
  	return 0;
@@ -1779,7 +1774,7 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
  		n_seg = rx_conf->rx_nseg;
 
  		if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
-			ret = rte_eth_rx_queue_check_split(rx_seg, n_seg,
+			ret = rte_eth_rx_queue_check_split(port_id, rx_seg, n_seg,
  							   &mbp_buf_size,
  							   &dev_info);
  			if (ret != 0)

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id, · line 5847

Quoted 9 lines
lib/ethdev/rte_ethdev.c +6 -0
@@ -5844,6 +5839,20 @@ rte_eth_ip_reassembly_conf_set(uint16_t port_id,
  		       (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf));
  }
 
+int
+rte_eth_supported_hdrs_get(uint16_t port_id, uint32_t *ptypes)
+{
+	struct rte_eth_dev *dev;
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];

ptypes must be checked vs NULL

Quoted 16 lines
lib/ethdev/rte_ethdev.c +8 -0
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->hdrs_supported_ptypes_get,
+				-ENOTSUP);
+
+	return eth_err(port_id,
+		       (*dev->dev_ops->hdrs_supported_ptypes_get)(dev, ptypes));
+}
+
  int
  rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)
  {
lib/ethdev/rte_ethdev.h +0 -0
index 04cff8ee10..72cac1518e 100644

lib/ethdev/rte_ethdev.h rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id, · line 6160

Quoted 9 lines
lib/ethdev/rte_ethdev.h +6 -0
@@ -6152,6 +6152,28 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id,
  	return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
  }
 
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get supported header protocols to split supported by PMD.

"supported" twice above.
Get supported header protocols to split on Rx.

lib/ethdev/rte_ethdev.h rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id, · line 6161

Quoted 1 line
lib/ethdev/rte_ethdev.h +1 -0
+ * The API will return error if the device is not valid.

Above sentence is obvious and does not add any value. Please, remove.

lib/ethdev/rte_ethdev.h rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id, · line 6165

Quoted 4 lines
lib/ethdev/rte_ethdev.h +4 -0
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param ptype

Why do you use out annotation for the callback description and does not use it here?

lib/ethdev/rte_ethdev.h rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id, · line 6169

Quoted 4 lines
lib/ethdev/rte_ethdev.h +4 -0
+ *   Supported protocol headers of driver.
+ * @return
+ *   - (-ENOTSUP) if header protocol is not supported by device.
+ *   - (-ENODEV) if *port_id* invalid.

EINVAL in the case of invalid ptypes argument

Quoted 15 lines
lib/ethdev/rte_ethdev.h +7 -0
+ *   - (-EIO) if device is removed.
+ *   - (0) on success.
+ */
+__rte_experimental
+int rte_eth_supported_hdrs_get(uint16_t port_id,
+		uint32_t *ptype);
+
  #ifdef __cplusplus
  }
  #endif
lib/ethdev/version.map +0 -0
index 20391ab29e..7705c0364a 100644

lib/ethdev/version.map EXPERIMENTAL { · line 283

Quoted 5 lines
lib/ethdev/version.map +2 -0
@@ -279,6 +279,9 @@ EXPERIMENTAL {
  	rte_flow_async_action_handle_create;
  	rte_flow_async_action_handle_destroy;
  	rte_flow_async_action_handle_update;
+
+	# added in 22.07

It hopefully will be in 22.11

Quoted 4 lines
lib/ethdev/version.map +1 -0
+	rte_eth_supported_hdrs_get;
  };
 
  INTERNAL {
#74 lore raw

RE: [PATCH v9 1/4] ethdev: introduce protocol header API

Hi Andrew,

Apologies for the delay in getting back to you.

Quoted 11 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Friday, July 8, 2022 11:01 PM
To: Wu, WenxuanX <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v9 1/4] ethdev: introduce protocol header API

Quoted 7 lines
Quoted 4 lines · On 6/13/22 13:25, [email protected] wrote:

From: Wenxuan Wu <[email protected]>

This patch added new ethdev API to retrieve supported protocol header mask

This patch added -> Add

Thanks for your catch, will fix in the next version.

Quoted 9 lines
Quoted 2 lines

of a PMD, which helps to configure protocol header based buffer split.

I'd like to see motivation why single mask is considered sufficient. I.e. why don't we follow ptypes approach which is move flexible, but a bit more complicated.

Looking at RTE_PTYPE_* defines carefully it looks like below API simply cannot provide information that we can split after TCP or UDP.

As Xuan replied in the patch 2, we think maybe RTE_PTYPE_* is enough. Any insights are welcome.

Quoted 20 lines
Quoted 3 lines

[snip]

lib/ethdev/ethdev_driver.h struct eth_dev_ops { · line 1301

Quoted 10 lines

/**
* @internal
* Dump private info from device to a file.

lib/ethdev/ethdev_driver.h +3 -0
@@ -1281,6 +1296,9 @@ struct eth_dev_ops {
  	/** Set IP reassembly configuration */
  	eth_ip_reassembly_conf_set_t ip_reassembly_conf_set;
 
+	/** Get supported ptypes to split */
+	eth_buffer_split_hdr_ptype_get_t hdrs_supported_ptypes_get;
+

It is better to be consistent with naming. I.e. just cut prefix "eth_" and suffix "_t".

Quoted 2 lines

Also the type name sounds like it get current split configuration, not supported one.

Thank you for your suggestion, will fix in the next version.

Quoted 25 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct

Quoted 24 lines
lib/ethdev/ethdev_driver.h +0 -0
  	/** Dump private info from device */
  	eth_dev_priv_dump_t eth_dev_priv_dump;
  };
lib/ethdev/rte_ethdev.c index renamed from lib/ethdev/rte_ethdev.c +0 -0

29a3d80466..e1f2a0ffe3 100644

lib/ethdev/rte_ethdev.c +4 -3
@@ -1636,9 +1636,10 @@ rte_eth_dev_is_removed(uint16_t port_id)
  }
 
  static int
-rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg,
-			     uint16_t n_seg, uint32_t *mbp_buf_size,
-			     const struct rte_eth_dev_info *dev_info)
+rte_eth_rx_queue_check_split(uint16_t port_id,
+				const struct rte_eth_rxseg_split *rx_seg,
+				int16_t n_seg, uint32_t *mbp_buf_size,
+			    const struct rte_eth_dev_info *dev_info)
  {
  	const struct rte_eth_rxseg_capa *seg_capa = &dev_info-
 rx_seg_capa;

struct rte_mempool *mp_first;

lib/ethdev/rte_ethdev.c +0 -0
@@ -1694,13 +1695,7 @@ rte_eth_rx_queue_check_split(const struct

rte_eth_rxseg_split *rx_seg,

Quoted 7 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1698

Quoted 5 lines
lib/ethdev/rte_ethdev.c +0 -2
  		}
  		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
  		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-		length = length != 0 ? length : *mbp_buf_size;
-		if (*mbp_buf_size < length + offset) {

I don't understand why the check goes away completely.

Thanks for your catch, it should be in the patch 2, will fix in the next version.

Quoted 11 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct · line 1700

Quoted 3 lines
lib/ethdev/rte_ethdev.c +0 -2
-			RTE_ETHDEV_LOG(ERR,
-				       "%s mbuf_data_room_size %u < %u

(segment length=%u + segment offset=%u)\n",

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct rte_eth_rxseg_split *rx_seg, · line 1698

Quoted 4 lines
lib/ethdev/rte_ethdev.c +1 -3
-				       mpl->name, *mbp_buf_size,
-				       length + offset, length, offset);
-			return -EINVAL;
+

Unnecessary empty line

Quoted 3 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_check_split(const struct · line 1699

Quoted 1 line
lib/ethdev/rte_ethdev.c +0 -0
  		}

Shouldn't the curly bracket go away as well together with its 'if'

Thanks for your catch, will fix in the next version.

Quoted 20 lines

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id,

Quoted 4 lines
lib/ethdev/rte_ethdev.c +0 -0
  	}
  	return 0;
@@ -1779,7 +1774,7 @@ rte_eth_rx_queue_setup(uint16_t port_id,

uint16_t rx_queue_id,

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,

Quoted 3 lines
lib/ethdev/rte_ethdev.c +0 -0
  		n_seg = rx_conf->rx_nseg;
 
  		if (rx_conf->offloads &

RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {

lib/ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, · line 1777

Quoted 2 lines
lib/ethdev/rte_ethdev.c +1 -1
-			ret = rte_eth_rx_queue_check_split(rx_seg, n_seg,
+			ret = rte_eth_rx_queue_check_split(port_id, rx_seg,

n_seg,

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t

Quoted 4 lines
lib/ethdev/rte_ethdev.c +0 -0
  							   &mbp_buf_size,
  							   &dev_info);
  			if (ret != 0)
@@ -5844,6 +5839,20 @@ rte_eth_ip_reassembly_conf_set(uint16_t

port_id,

Quoted 3 lines
lib/ethdev/rte_ethdev.c +0 -0
  		       (*dev->dev_ops->ip_reassembly_conf_set)(dev, conf));
  }
 
Quoted 7 lines

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id, · line 5847

Quoted 5 lines
lib/ethdev/rte_ethdev.c +5 -0
+int
+rte_eth_supported_hdrs_get(uint16_t port_id, uint32_t *ptypes) {
+	struct rte_eth_dev *dev;
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];

ptypes must be checked vs NULL

Thanks for your catch, will fix in the next version.

Quoted 22 lines

lib/ethdev/rte_ethdev.c rte_eth_ip_reassembly_conf_set(uint16_t port_id,

Quoted 8 lines
lib/ethdev/rte_ethdev.c +6 -0
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-
 hdrs_supported_ptypes_get,
+				-ENOTSUP);
+
+	return eth_err(port_id,
+		       (*dev->dev_ops->hdrs_supported_ptypes_get)(dev,

ptypes)); }

lib/ethdev/rte_ethdev.h rte_eth_tx_buffer(uint16_t port_id, uint16_t

Quoted 9 lines
lib/ethdev/rte_ethdev.c +1 -0
+
  int
  rte_eth_dev_priv_dump(uint16_t port_id, FILE *file)
  {
lib/ethdev/rte_ethdev.h index renamed from lib/ethdev/rte_ethdev.h +0 -0

04cff8ee10..72cac1518e 100644

lib/ethdev/rte_ethdev.h +0 -0
@@ -6152,6 +6152,28 @@ rte_eth_tx_buffer(uint16_t port_id, uint16_t

queue_id,

Quoted 3 lines
lib/ethdev/rte_ethdev.h +0 -0
  	return rte_eth_tx_buffer_flush(port_id, queue_id, buffer);
  }
 
Quoted 9 lines

lib/ethdev/rte_ethdev.h rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id, · line 6160

Quoted 6 lines
lib/ethdev/rte_ethdev.h +6 -0
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get supported header protocols to split supported by PMD.

"supported" twice above.
Get supported header protocols to split on Rx.

Thank you for your suggestion, will fix in the next version.

Quoted 5 lines

lib/ethdev/rte_ethdev.h rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id, · line 6161

Quoted 2 lines
lib/ethdev/rte_ethdev.h +1 -0
+ * The API will return error if the device is not valid.

Above sentence is obvious and does not add any value. Please, remove.

Quoted 7 lines

lib/ethdev/rte_ethdev.h rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id, · line 6165

Quoted 4 lines
lib/ethdev/rte_ethdev.h +4 -0
+ *
+ * @param port_id
+ *   The port identifier of the device.
+ * @param ptype

Why do you use out annotation for the callback description and does not use it here?

Thank you for your suggestion, will fix in the next version.

Quoted 7 lines

lib/ethdev/rte_ethdev.h rte_eth_tx_buffer(uint16_t port_id, uint16_t queue_id, · line 6169

Quoted 5 lines
lib/ethdev/rte_ethdev.h +4 -0
+ *   Supported protocol headers of driver.
+ * @return
+ *   - (-ENOTSUP) if header protocol is not supported by device.
+ *   - (-ENODEV) if *port_id* invalid.

EINVAL in the case of invalid ptypes argument

Thank you for your suggestion, will fix in the next version.

Quoted 15 lines
Quoted 15 lines
lib/ethdev/rte_ethdev.h +7 -0
+ *   - (-EIO) if device is removed.
+ *   - (0) on success.
+ */
+__rte_experimental
+int rte_eth_supported_hdrs_get(uint16_t port_id,
+		uint32_t *ptype);
+
  #ifdef __cplusplus
  }
  #endif
lib/ethdev/version.map index renamed from lib/ethdev/version.map +0 -0

20391ab29e..7705c0364a 100644

lib/ethdev/version.map +0 -0
Quoted 8 lines

lib/ethdev/version.map EXPERIMENTAL { · line 283

Quoted 6 lines
lib/ethdev/version.map +2 -0
@@ -279,6 +279,9 @@ EXPERIMENTAL {
  	rte_flow_async_action_handle_create;
  	rte_flow_async_action_handle_destroy;
  	rte_flow_async_action_handle_update;
+
+	# added in 22.07

It hopefully will be in 22.11

Sure, it should be targeted for 22.11.

Thanks,
Yuan

Quoted 5 lines
Quoted 5 lines
lib/ethdev/version.map +1 -0
+	rte_eth_supported_hdrs_get;
  };
 
  INTERNAL {
#75 lore raw

PATCH v9 2/4 ethdev: introduce protocol hdr based buffer split

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet segment configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given an arbitrarily variable length in Rx packet segment, it is almost impossible to pass a fixed protocol header to driver. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding protocol header is configured, driver will split the ingress packets into multiple segments.

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */
};

If both inner and outer L2/L3/L4 level protocol header split can be supported by a PMD. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP, RTE_PTYPE_INNER_L4_SCTP.

For example, let's suppose we configured the Rx queue with the following segments:

    seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
    seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
    seg2 - pool2, off1=0B

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

The split limitations imposed by underlying driver is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.

---
 lib/ethdev/rte_ethdev.c | 32 +++++++++++++++++++++++++++++++-
 lib/ethdev/rte_ethdev.h | 14 +++++++++++++-
 2 files changed, 44 insertions(+), 2 deletions(-)
lib/ethdev/rte_ethdev.c +31 -1
index e1f2a0ffe3..b89e30296f 100644
@@ -1662,6 +1662,7 @@ rte_eth_rx_queue_check_split(uint16_t port_id,
 		struct rte_mempool *mpl = rx_seg[seg_idx].mp;
 		uint32_t length = rx_seg[seg_idx].length;
 		uint32_t offset = rx_seg[seg_idx].offset;
+		uint32_t proto_hdr = rx_seg[seg_idx].proto_hdr;
 
 		if (mpl == NULL) {
 			RTE_ETHDEV_LOG(ERR, "null mempool pointer\n");
@@ -1695,7 +1696,36 @@ rte_eth_rx_queue_check_split(uint16_t port_id,
 		}
 		offset += seg_idx != 0 ? 0 : RTE_PKTMBUF_HEADROOM;
 		*mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
-
+		uint32_t ptypes_mask;
+		int ret = rte_eth_supported_hdrs_get(port_id, &ptypes_mask);
+
+		if (ret == ENOTSUP || ptypes_mask == RTE_PTYPE_UNKNOWN) {
+			/* Split at fixed length. */
+			length = length != 0 ? length : *mbp_buf_size;
+			if (*mbp_buf_size < length + offset) {
+				RTE_ETHDEV_LOG(ERR,
+					"%s mbuf_data_room_size %u < %u (segment length=%u + segment offset=%u)\n",
+					mpl->name, *mbp_buf_size,
+					length + offset, length, offset);
+				return -EINVAL;
+			}
+		} else if (ret == 0) {
+			/* Split after specified protocol header. */
+			if (proto_hdr & ~ptypes_mask) {
+				RTE_ETHDEV_LOG(ERR,
+					"Protocol header 0x%x is not supported.\n",
+					proto_hdr & ~ptypes_mask);
+				return -EINVAL;
+			}
+			if (*mbp_buf_size < offset) {
+				RTE_ETHDEV_LOG(ERR,
+						"%s mbuf_data_room_size %u < %u segment offset)\n",
+						mpl->name, *mbp_buf_size,
+						offset);
+				return -EINVAL;
+			}
+		} else {
+			return ret;
 		}
 	}
 	return 0;
lib/ethdev/rte_ethdev.h +13 -1
index 72cac1518e..7df40f9f9b 100644
@@ -1176,6 +1176,9 @@ struct rte_eth_txmode {
  *   specified in the first array element, the second buffer, from the
  *   pool in the second element, and so on.
  *
+ * - The proto_hdrs in the elements define the split position of
+ *   received packets.
+ *
  * - The offsets from the segment description elements specify
  *   the data offset from the buffer beginning except the first mbuf.
  *   The first segment offset is added with RTE_PKTMBUF_HEADROOM.
@@ -1197,12 +1200,21 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
+ *     - The proto_hdr field should not be configured.
+ *
+ * - Protocol header based buffer split:
+ *     - mp, offset, proto_hdr should be configured.
+ *     - The length field should not be configured.
  */
 struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	/**< Supported ptypes mask of a specific pmd, configures split point. */
+	uint32_t proto_hdr;
 };
 
 /**
Signature · 1 line
2.25.1
#76 lore raw

Re: [PATCH v9 2/4] ethdev: introduce protocol hdr based buffer split

13/06/2022 12:25, [email protected]:

Quoted 21 lines
lib/ethdev/rte_ethdev.h +8 -0
@@ -1176,6 +1176,9 @@ struct rte_eth_txmode {
  *   specified in the first array element, the second buffer, from the
  *   pool in the second element, and so on.
  *
+ * - The proto_hdrs in the elements define the split position of
+ *   received packets.
+ *
  * - The offsets from the segment description elements specify
  *   the data offset from the buffer beginning except the first mbuf.
  *   The first segment offset is added with RTE_PKTMBUF_HEADROOM.
@@ -1197,12 +1200,21 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
+ *     - The proto_hdr field should not be configured.
+ *

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1216

Quoted 10 lines
lib/ethdev/rte_ethdev.h +4 -1
+ * - Protocol header based buffer split:
+ *     - mp, offset, proto_hdr should be configured.
+ *     - The length field should not be configured.
  */
 struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
-	uint32_t reserved; /**< Reserved field. */
+	/**< Supported ptypes mask of a specific pmd, configures split point. */

The doxygen syntax is wrong: remove the "<" which is for post-comment.

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1218

Quoted 2 lines
lib/ethdev/rte_ethdev.h +1 -0
+	uint32_t proto_hdr;
 };

How do we know it is a length or buffer split?
Is it based on checking some 0 value?

author
#77 lore raw

RE: [PATCH v9 2/4] ethdev: introduce protocol hdr based buffer split

Hi Thomas,

Quoted 42 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, July 7, 2022 5:08 PM
To: Wu, WenxuanX <[email protected]>
Cc: [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]; Wu, WenxuanX <[email protected]>; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; Ray Kinsella <[email protected]>
Subject: Re: [PATCH v9 2/4] ethdev: introduce protocol hdr based buffer split

13/06/2022 12:25, [email protected]:

Quoted 17 lines
lib/ethdev/rte_ethdev.h +4 -0
@@ -1176,6 +1176,9 @@ struct rte_eth_txmode {
  *   specified in the first array element, the second buffer, from the
  *   pool in the second element, and so on.
  *
+ * - The proto_hdrs in the elements define the split position of
+ *   received packets.
+ *
  * - The offsets from the segment description elements specify
  *   the data offset from the buffer beginning except the first mbuf.
  *   The first segment offset is added with RTE_PKTMBUF_HEADROOM.
@@ -1197,12 +1200,21 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1213

Quoted 10 lines
lib/ethdev/rte_ethdev.h +7 -0
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
+ *     - The proto_hdr field should not be configured.
+ *
+ * - Protocol header based buffer split:
+ *     - mp, offset, proto_hdr should be configured.
+ *     - The length field should not be configured.
  */
 struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment

from. */

Quoted 8 lines

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1215

Quoted 2 lines
lib/ethdev/rte_ethdev.h +0 -0
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer.

*/

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1216

Quoted 2 lines
lib/ethdev/rte_ethdev.h +1 -1
-	uint32_t reserved; /**< Reserved field. */
+	/**< Supported ptypes mask of a specific pmd, configures split point.

*/

The doxygen syntax is wrong: remove the "<" which is for post-comment.

Thanks for your catch.

Quoted 6 lines

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1218

Quoted 3 lines
lib/ethdev/rte_ethdev.h +1 -0
+	uint32_t proto_hdr;
 };

How do we know it is a length or buffer split?
Is it based on checking some 0 value?

Yes, as Andrew suggests, we introduced the API rte_eth_supported_hdrs_get() in v9. It will report the driver supported protocol headers to be split.
If the API returns ENOTSUP, it means driver supports length based buffer split.

Of course, no matter what kind of buffer split it is, we need to check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT first.

Thanks,
Xuan

Quoted 1 line
#78 lore raw

Re: [PATCH v9 2/4] ethdev: introduce protocol hdr based buffer split

11/07/2022 11:54, Ding, Xuan:

Quoted 48 lines

From: Thomas Monjalon <[email protected]>

Quoted 29 lines

13/06/2022 12:25, [email protected]:

Quoted 17 lines
lib/ethdev/rte_ethdev.h +4 -0
@@ -1176,6 +1176,9 @@ struct rte_eth_txmode {
  *   specified in the first array element, the second buffer, from the
  *   pool in the second element, and so on.
  *
+ * - The proto_hdrs in the elements define the split position of
+ *   received packets.
+ *
  * - The offsets from the segment description elements specify
  *   the data offset from the buffer beginning except the first mbuf.
  *   The first segment offset is added with RTE_PKTMBUF_HEADROOM.
@@ -1197,12 +1200,21 @@ struct rte_eth_txmode {
  *     - pool from the last valid element
  *     - the buffer size from this pool
  *     - zero offset
+ *

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1213

Quoted 10 lines
lib/ethdev/rte_ethdev.h +7 -0
+ * - Length based buffer split:
+ *     - mp, length, offset should be configured.
+ *     - The proto_hdr field should not be configured.
+ *
+ * - Protocol header based buffer split:
+ *     - mp, offset, proto_hdr should be configured.
+ *     - The length field should not be configured.
  */
 struct rte_eth_rxseg_split {
 	struct rte_mempool *mp; /**< Memory pool to allocate segment

from. */

Quoted 8 lines

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1215

Quoted 2 lines
lib/ethdev/rte_ethdev.h +0 -0
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer.

*/

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1216

Quoted 2 lines
lib/ethdev/rte_ethdev.h +1 -1
-	uint32_t reserved; /**< Reserved field. */
+	/**< Supported ptypes mask of a specific pmd, configures split point.

*/

The doxygen syntax is wrong: remove the "<" which is for post-comment.

Thanks for your catch.

Quoted 6 lines

lib/ethdev/rte_ethdev.h struct rte_eth_txmode { · line 1218

Quoted 3 lines
lib/ethdev/rte_ethdev.h +1 -0
+	uint32_t proto_hdr;
 };

How do we know it is a length or buffer split?
Is it based on checking some 0 value?

Quoted 6 lines

Yes, as Andrew suggests, we introduced the API rte_eth_supported_hdrs_get() in v9. It will report the driver supported protocol headers to be split.
If the API returns ENOTSUP, it means driver supports length based buffer split.

Of course, no matter what kind of buffer split it is, we need to check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT first.

So you need to talk about RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in the comment of this struct.

#79 lore raw

Re: [PATCH v9 2/4] ethdev: introduce protocol hdr based buffer split

In reply to [email protected]
Quoted 24 lines · On 6/13/22 13:25, [email protected] wrote:

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet segment configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given an arbitrarily variable length in Rx packet segment, it is almost impossible to pass a fixed protocol header to driver. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding protocol header is configured, driver will split the ingress packets into multiple segments.

struct rte_eth_rxseg_split {

Quoted 7 lines

struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */

There is a big problem here that using RTE_PTYPE_* defines I can't request split after either TCP or UDP header.

Quoted 8 lines
     };

If both inner and outer L2/L3/L4 level protocol header split can be supported by a PMD. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP, RTE_PTYPE_INNER_L4_UDP, RTE_PTYPE_INNER_L4_SCTP.

I think there is no point to list above defines here if it is not the only supported defines.

Quoted 7 lines

For example, let's suppose we configured the Rx queue with the following segments:

     seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
     seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
     seg2 - pool2, off1=0B
Quoted 5 lines

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

Sorry, but I still see no definition what should happen with, for example, ARP packet with above config.

Quoted 17 lines

Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

The split limitations imposed by underlying driver is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.

Quoted 4 lines
---
  lib/ethdev/rte_ethdev.c | 32 +++++++++++++++++++++++++++++++-
  lib/ethdev/rte_ethdev.h | 14 +++++++++++++-
  2 files changed, 44 insertions(+), 2 deletions(-)

Do we need a dedicated feature in doc/guides/nics/features.rst? Or should be just update buffer split to refer to a new supported header split API and callback?

Also the feature definitely deserves entry in the release notes.

[snip]

author
#80 lore raw

RE: [PATCH v9 2/4] ethdev: introduce protocol hdr based buffer split

Hi Andrew,

Quoted 47 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: 2022年7月8日 23:01
To: Wu, WenxuanX <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; Ray Kinsella <[email protected]>
Subject: Re: [PATCH v9 2/4] ethdev: introduce protocol hdr based buffer split

Quoted 4 lines · On 6/13/22 13:25, [email protected] wrote:

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet

segment

Quoted 9 lines

configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given an arbitrarily variable length in Rx packet segment, it is almost impossible to pass a fixed protocol header to driver. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

Quoted 8 lines

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding protocol header is configured, driver will split the ingress packets into multiple

segments.

Quoted 10 lines

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */

Quoted 2 lines

There is a big problem here that using RTE_PTYPE_* defines I can't request split after either TCP or UDP header.

Sorry, for some reason I missed your reply.

Current RTE_PTYPE_* list all the tunnel and L2/L3/L4 protocol headers (both outer and inner). Do you mean that we should support higher layer protocols after L4?

I think tunnel and L2/L3/L4 protocol headers are enough. In DPDK, we don't parse higher level protocols after L4. And the higher layer protocols are richer, we can't list all of them. What do you think?

Quoted 9 lines
Quoted 9 lines
     };

If both inner and outer L2/L3/L4 level protocol header split can be supported by a PMD. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP,

Quoted 4 lines

RTE_PTYPE_INNER_L4_UDP, RTE_PTYPE_INNER_L4_SCTP.

I think there is no point to list above defines here if it is not the only supported defines.

Yes, since we use a API to return the protocol header driver supported to split, there is no need to list the incomplete RTE_PTYPE* here. Please see next version.

Quoted 8 lines
Quoted 8 lines

For example, let's suppose we configured the Rx queue with the following segments:

     seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
     seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
     seg2 - pool2, off1=0B
Quoted 8 lines
Quoted 5 lines

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

Sorry, but I still see no definition what should happen with, for example, ARP packet with above config.

Thanks, because the following reply was not answered in v8, the definition has not been added in v9 yet.

"
Our NIC only supports to split the packets into two segments,
so there will be an exact match for the only one protocol header configured. Back to this question, for the set of proto_hdrs configured, it can have two behaviors:
1. The aggressive way is to split on longest match you mentioned, E.g. we configure split on ETH-IPV4-TCP, when receives ETH-IPV4-UDP or ETH-IPV6, it can also split on ETH-IPV4 or ETH.
2. A more conservative way is to split only when the packets meet the all protocol headers in the Rx packet segment. In the above situation, it will not do split for ETH-IPV4-UDP and ETH-IPV6.

I prefer the second behavior, because the split is usually for the inner most header and payload, if it does not meet, the rest of the headers have no actual value. "

Hope to get your insights.
And we will update the doc to define the behavior in next version.

Quoted 23 lines
Quoted 18 lines

Now buffer split can be configured in two modes. For length based buffer split, the mp, length, offset field in Rx packet segment should be configured, while the proto_hdr field should not be configured. For protocol header based buffer split, the mp, offset, proto_hdr field in Rx packet segment should be configured, while the length field should not be configured.

The split limitations imposed by underlying driver is reported in the rte_eth_dev_info->rx_seg_capa field. The memory attributes for the split parts may differ either, dpdk memory and external memory, respectively.

Quoted 4 lines
---
  lib/ethdev/rte_ethdev.c | 32 +++++++++++++++++++++++++++++++-
  lib/ethdev/rte_ethdev.h | 14 +++++++++++++-
  2 files changed, 44 insertions(+), 2 deletions(-)
Quoted 5 lines

Do we need a dedicated feature in doc/guides/nics/features.rst?
Or should be just update buffer split to refer to a new supported header split API and callback?

Also the feature definitely deserves entry in the release notes.

Regarding the newly introduced protocol based buffer split, it is definitely worth a doc update. The reason why we didn't do it before is because it is under discussion.

Before we send a new version, we will put more efforts to clean current patch to make doc more comprehensive and easier to understand.

Thanks,
Xuan

Quoted 2 lines

[snip]

#81 lore raw

Re: [PATCH v9 2/4] ethdev: introduce protocol hdr based buffer split

Quoted 54 lines · Xuan

Hi Andrew,

Quoted 47 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: 2022年7月8日 23:01
To: Wu, WenxuanX <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; Ray Kinsella <[email protected]>
Subject: Re: [PATCH v9 2/4] ethdev: introduce protocol hdr based buffer split

Quoted 4 lines · On 6/13/22 13:25, [email protected] wrote:

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx packet

segment

Quoted 9 lines

configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given an arbitrarily variable length in Rx packet segment, it is almost impossible to pass a fixed protocol header to driver. Besides, the existence of tunneling results in the composition of a packet is various, which makes the situation even worse.

Quoted 8 lines

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding protocol header is configured, driver will split the ingress packets into multiple

segments.

Quoted 10 lines

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */

Quoted 2 lines

There is a big problem here that using RTE_PTYPE_* defines I can't request split after either TCP or UDP header.

Sorry, for some reason I missed your reply.

Quoted 7 lines

Current RTE_PTYPE_* list all the tunnel and L2/L3/L4 protocol headers (both outer and inner). Do you mean that we should support higher layer protocols after L4?

I think tunnel and L2/L3/L4 protocol headers are enough. In DPDK, we don't parse higher level protocols after L4. And the higher layer protocols are richer, we can't list all of them. What do you think?

It looks like you don't get my point. You simply cannot say:
RTE_PTYPE_L4_TCP | RTE_PTYPE_L4_UDP since it is numerically equal to RTE_PTYPE_L4_FRAG. May be the design limitation is acceptable. I have no strong opinion, but it must be clear for all that the limitation exists.

Quoted 48 lines
Quoted 9 lines
Quoted 9 lines
      };

If both inner and outer L2/L3/L4 level protocol header split can be supported by a PMD. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP,

Quoted 4 lines

RTE_PTYPE_INNER_L4_UDP, RTE_PTYPE_INNER_L4_SCTP.

I think there is no point to list above defines here if it is not the only supported defines.

Yes, since we use a API to return the protocol header driver supported to split, there is no need to list the incomplete RTE_PTYPE* here. Please see next version.

Quoted 8 lines
Quoted 8 lines

For example, let's suppose we configured the Rx queue with the following segments:

      seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
      seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
      seg2 - pool2, off1=0B
Quoted 8 lines
Quoted 5 lines

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

Sorry, but I still see no definition what should happen with, for example, ARP packet with above config.

Thanks, because the following reply was not answered in v8, the definition has not been added in v9 yet.

"
Our NIC only supports to split the packets into two segments,
so there will be an exact match for the only one protocol header configured. Back to this question, for the set of proto_hdrs configured, it can have two behaviors:
1. The aggressive way is to split on longest match you mentioned, E.g. we configure split on ETH-IPV4-TCP, when receives ETH-IPV4-UDP or ETH-IPV6, it can also split on ETH-IPV4 or ETH.
2. A more conservative way is to split only when the packets meet the all protocol headers in the Rx packet segment. In the above situation, it will not do split for ETH-IPV4-UDP and ETH-IPV6.

Quoted 6 lines

I prefer the second behavior, because the split is usually for the inner most header and payload, if it does not meet, the rest of the headers have no actual value. "

Hope to get your insights.
And we will update the doc to define the behavior in next version.

I'm OK with (2) as well. Please, define it in the documentation. Also it must be clear which segment/mempool is used if a packet is not split.

author
#82 lore raw

RE: [PATCH v9 2/4] ethdev: introduce protocol hdr based buffer split

Hi,

Quoted 83 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, August 1, 2022 10:28 PM
To: Ding, Xuan <[email protected]>
Cc: [email protected]; [email protected]; Wang, YuanX <[email protected]>; Ray Kinsella <[email protected]>; Wu, WenxuanX <[email protected]>; [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v9 2/4] ethdev: introduce protocol hdr based buffer split

Quoted 6 lines · Xuan

Hi Andrew,

Quoted 4 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: 2022年7月8日 23:01
To: Wu, WenxuanX <[email protected]>; [email protected];

Li,

Quoted 9 lines
Quoted 9 lines

Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Ding, Xuan <[email protected]>; Wang, YuanX <[email protected]>; Ray Kinsella <[email protected]>
Subject: Re: [PATCH v9 2/4] ethdev: introduce protocol hdr based buffer split

Quoted 5 lines
Quoted 5 lines · On 6/13/22 13:25, [email protected] wrote:
Quoted 4 lines

From: Wenxuan Wu <[email protected]>

Currently, Rx buffer split supports length based split. With Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT enabled and Rx

packet

Quoted 9 lines
Quoted 9 lines

segment

Quoted 8 lines

configured, PMD will be able to split the received packets into multiple segments.

However, length based buffer split is not suitable for NICs that do split based on protocol headers. Given an arbitrarily variable length in Rx packet segment, it is almost impossible to pass a fixed protocol header to driver. Besides, the existence of tunneling results in the composition of a packet is various, which makes the

situation even worse.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

This patch extends current buffer split to support protocol header based buffer split. A new proto_hdr field is introduced in the reserved field of rte_eth_rxseg_split structure to specify protocol header. The proto_hdr field defines the split position of packet, splitting will always happens after the protocol header defined in the Rx packet segment. When Rx queue offload RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT is enabled and corresponding protocol header is configured, driver will split the ingress packets into multiple

Quoted 5 lines
Quoted 5 lines

segments.

Quoted 4 lines

struct rte_eth_rxseg_split {

struct rte_mempool *mp; /* memory pools to allocate segment

from */

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

uint16_t length; /* segment maximal data length,
configures "split point" */
uint16_t offset; /* data offset from beginning
of mbuf data buffer */
uint32_t proto_hdr; /* inner/outer L2/L3/L4 protocol header,
configures "split point" */

Quoted 6 lines
Quoted 2 lines

There is a big problem here that using RTE_PTYPE_* defines I can't request split after either TCP or UDP header.

Sorry, for some reason I missed your reply.

Current RTE_PTYPE_* list all the tunnel and L2/L3/L4 protocol headers

(both outer and inner).

Quoted 6 lines

Do you mean that we should support higher layer protocols after L4?

I think tunnel and L2/L3/L4 protocol headers are enough. In DPDK, we don't parse higher level protocols after L4. And the higher layer protocols are richer, we can't list all of them. What do you think?

Quoted 4 lines

It looks like you don't get my point. You simply cannot say:
RTE_PTYPE_L4_TCP | RTE_PTYPE_L4_UDP since it is numerically equal to RTE_PTYPE_L4_FRAG. May be the design limitation is acceptable.
I have no strong opinion, but it must be clear for all that the limitation exists.

Thanks for your correction.
Similarly, RTE_PTYPE_INNER_L4_TCP and RTE_PTYPE_INNER_L4_UDP also exists this situation.

I will try to solve this limitation by following ptypes_get approach.

Quoted 54 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

      };

If both inner and outer L2/L3/L4 level protocol header split can be supported by a PMD. Corresponding protocol header capability is RTE_PTYPE_L2_ETHER, RTE_PTYPE_L3_IPV4, RTE_PTYPE_L3_IPV6, RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_INNER_L2_ETHER, RTE_PTYPE_INNER_L3_IPV4, RTE_PTYPE_INNER_L3_IPV6, RTE_PTYPE_INNER_L4_TCP,

Quoted 7 lines
Quoted 4 lines

RTE_PTYPE_INNER_L4_UDP, RTE_PTYPE_INNER_L4_SCTP.

I think there is no point to list above defines here if it is not the only supported defines.

Yes, since we use a API to return the protocol header driver supported to split, there is no need to list the incomplete RTE_PTYPE* here. Please

see next version.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

For example, let's suppose we configured the Rx queue with the following segments:

      seg0 - pool0, proto_hdr0=RTE_PTYPE_L3_IPV4, off0=2B
      seg1 - pool1, proto_hdr1=RTE_PTYPE_L4_UDP, off1=128B
      seg2 - pool2, off1=0B
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

The packet consists of MAC_IPV4_UDP_PAYLOAD will be split like following:
seg0 - ipv4 header @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from

pool0

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

seg1 - udp header @ 128 in mbuf from pool1
seg2 - payload @ 0 in mbuf from pool2

Sorry, but I still see no definition what should happen with, for example, ARP packet with above config.

Quoted 7 lines

Thanks, because the following reply was not answered in v8, the definition has not been added in v9 yet.

"
Our NIC only supports to split the packets into two segments, so there will be an exact match for the only one protocol header configured. Back to this question, for the set of proto_hdrs configured, it can have two

behaviors:

Quoted 9 lines

1. The aggressive way is to split on longest match you mentioned, E.g. we configure split on ETH-IPV4-TCP, when receives ETH-IPV4-UDP or ETH-IPV6, it can also split on ETH-IPV4 or ETH.
2. A more conservative way is to split only when the packets meet the all protocol headers in the Rx packet segment. In the above situation, it will not do split for ETH-IPV4-UDP and ETH-IPV6.

I prefer the second behavior, because the split is usually for the inner most header and payload, if it does not meet, the rest of the headers

Quoted 8 lines

have no actual value.

Quoted 4 lines

"

Hope to get your insights.
And we will update the doc to define the behavior in next version.

I'm OK with (2) as well. Please, define it in the documentation. Also it must be clear which segment/mempool is used if a packet is not split.

Get your point. Will fix it in next version.

Thanks,
Xuan

#83 lore raw

PATCH v9 3/4 app/testpmd: add rxhdrs commands and parameters

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

Add command line parameter:
--rxhdrs=mac,[ipv4,udp]

Set the protocol_hdr of segments to scatter packets on receiving if split feature is engaged. And the queues with BUFFER_SPLIT flag.

Add interactive mode command:
testpmd>set rxhdrs mac,ipv4,l3,tcp,udp,sctp
(protocol sequence should be valid)

The protocol split feature is off by default. To enable protocol split, you need:
1. Start testpmd with two mempools. E.g. --mbuf-size=2048,2048
2. Configure Rx queue with rx_offload buffer split on.
3. Set the protocol type of buffer split. E.g. set rxhdrs mac,ipv4

	(default protocols of testpmd : mac|icmp|ipv4|ipv6|l3|tcp|udp|
				sctp|l4|inner_mac|inner_ipv4|inner_ipv6|
				inner_l3|inner_tcp|inner_udp|inner_sctp|
				inner_l4)

Above protocols can be configured in testpmd. But the configuration can only be applied when it is supported by specific pmd.

---
 app/test-pmd/cmdline.c    | 133 +++++++++++++++++++++++++++++++++++++-
 app/test-pmd/config.c     |  75 +++++++++++++++++++++
 app/test-pmd/parameters.c |  15 ++++-
 app/test-pmd/testpmd.c    |   6 +-
 app/test-pmd/testpmd.h    |   6 ++
 5 files changed, 229 insertions(+), 6 deletions(-)
app/test-pmd/cmdline.c +130 -3
index 6ffea8e21a..474235bc91 100644
@@ -183,7 +183,7 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"show (rxq|txq) info (port_id) (queue_id)\n"
 			"    Display information for configured RX/TX queue.\n\n"
 
-			"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
+			"show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n"
 			"    Display the given configuration.\n\n"
 
 			"read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -316,6 +316,15 @@ static void cmd_help_long_parsed(void *parsed_result,
 			" Affects only the queues configured with split"
 			" offloads.\n\n"
 
+			"set rxhdrs (mac[,ipv4])*\n"
+			"	Set the protocol hdr of each segment to scatter"
+			" packets on receiving if split feature is engaged."
+			" Affects only the queues configured with split"
+			" offloads.\n\n"
+			"	Supported proto header: mac|ipv4||qinq|gre|ipv6|l3|tcp|udp|sctp|l4|"
+			"inner_mac|inner_ipv4|inner_ipv6|inner_l3|inner_tcp|"
+			"inner_udp|inner_sctp\n"
+
 			"set txpkts (x[,y]*)\n"
 			"    Set the length of each segment of TXONLY"
 			" and optionally CSUM packets.\n\n"
@@ -3617,6 +3626,78 @@ cmdline_parse_inst_t cmd_stop = {
 	},
 };
 
+static unsigned int
+get_ptype(char *value)
+{
+	uint32_t protocol;
+	if (!strcmp(value, "mac"))
+		protocol = RTE_PTYPE_L2_ETHER;
+	else if (!strcmp(value, "ipv4"))
+		protocol = RTE_PTYPE_L3_IPV4;
+	else if (!strcmp(value, "ipv6"))
+		protocol = RTE_PTYPE_L3_IPV6;
+	else if (!strcmp(value, "l3"))
+		protocol = RTE_PTYPE_L3_IPV4|RTE_PTYPE_L3_IPV6;
+	else if (!strcmp(value, "tcp"))
+		protocol = RTE_PTYPE_L4_TCP;
+	else if (!strcmp(value, "udp"))
+		protocol = RTE_PTYPE_L4_UDP;
+	else if (!strcmp(value, "sctp"))
+		protocol = RTE_PTYPE_L4_SCTP;
+	else if (!strcmp(value, "l4"))
+		protocol = RTE_PTYPE_L4_TCP|RTE_PTYPE_L4_UDP|RTE_PTYPE_L4_SCTP;
+	else if (!strcmp(value, "inner_mac"))
+		protocol = RTE_PTYPE_INNER_L2_ETHER;
+	else if (!strcmp(value, "inner_ipv4"))
+		protocol = RTE_PTYPE_INNER_L3_IPV4;
+	else if (!strcmp(value, "inner_ipv6"))
+		protocol = RTE_PTYPE_INNER_L3_IPV6;
+	else if (!strcmp(value, "inner_l3"))
+		protocol = RTE_PTYPE_INNER_L3_IPV4|RTE_PTYPE_INNER_L3_IPV6;
+	else if (!strcmp(value, "inner_tcp"))
+		protocol = RTE_PTYPE_INNER_L4_TCP;
+	else if (!strcmp(value, "inner_udp"))
+		protocol = RTE_PTYPE_INNER_L4_UDP;
+	else if (!strcmp(value, "inner_sctp"))
+		protocol = RTE_PTYPE_INNER_L4_SCTP;
+	else if (!strcmp(value, "unknown"))
+		protocol = RTE_PTYPE_UNKNOWN;
+	else if (!strcmp(value, "gre"))
+		protocol = RTE_PTYPE_TUNNEL_GRE;
+	else if (!strcmp(value, "qinq"))
+		protocol = RTE_PTYPE_L2_ETHER_QINQ;
+	else {
+		fprintf(stderr, "Unsupported protocol name: %s\n", value);
+		return 0;
+	}
+	return protocol;
+}
+/* *** SET RXHDRSLIST *** */
+
+unsigned int
+parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
+				unsigned int *parsed_items, int check_hdrs_sequence)
+{
+	unsigned int nb_item;
+	char *cur;
+	char *tmp;
+	nb_item = 0;
+	char *str2 = strdup(str);
+	cur = strtok_r(str2, ",", &tmp);
+	while (cur != NULL) {
+		parsed_items[nb_item] = get_ptype(cur);
+		cur = strtok_r(NULL, ",", &tmp);
+		nb_item++;
+	}
+	if (nb_item > max_items)
+		fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
+			item_name, nb_item + 1, max_items);
+	set_rx_pkt_hdrs(parsed_items, nb_item);
+	free(str2);
+	if (!check_hdrs_sequence)
+		return nb_item;
+	return nb_item;
+}
 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
 
 unsigned int
@@ -3986,6 +4067,49 @@ cmdline_parse_inst_t cmd_set_rxpkts = {
 	},
 };
 
+/* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
+struct cmd_set_rxhdrs_result {
+	cmdline_fixed_string_t cmd_keyword;
+	cmdline_fixed_string_t rxhdrs;
+	cmdline_fixed_string_t seg_hdrs;
+};
+
+static void
+cmd_set_rxhdrs_parsed(void *parsed_result,
+		      __rte_unused struct cmdline *cl,
+		      __rte_unused void *data)
+{
+	struct cmd_set_rxhdrs_result *res;
+	unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
+	unsigned int nb_segs;
+
+	res = parsed_result;
+	nb_segs = parse_hdrs_list(res->seg_hdrs, "segment hdrs",
+				  MAX_SEGS_BUFFER_SPLIT, seg_hdrs, 0);
+	if (nb_segs >= 1)
+		set_rx_pkt_hdrs(seg_hdrs, nb_segs);
+	cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
+}
+cmdline_parse_token_string_t cmd_set_rxhdrs_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
+				 cmd_keyword, "set");
+cmdline_parse_token_string_t cmd_set_rxhdrs_name =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
+				 rxhdrs, "rxhdrs");
+cmdline_parse_token_string_t cmd_set_rxhdrs_seg_hdrs =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
+				 seg_hdrs, NULL);
+cmdline_parse_inst_t cmd_set_rxhdrs = {
+	.f = cmd_set_rxhdrs_parsed,
+	.data = NULL,
+	.help_str = "set rxhdrs <mac[,ipv4]*>",
+	.tokens = {
+		(void *)&cmd_set_rxhdrs_keyword,
+		(void *)&cmd_set_rxhdrs_name,
+		(void *)&cmd_set_rxhdrs_seg_hdrs,
+		NULL,
+	},
+};
 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
 
 struct cmd_set_txpkts_result {
@@ -8058,6 +8182,8 @@ static void cmd_showcfg_parsed(void *parsed_result,
 		show_rx_pkt_offsets();
 	else if (!strcmp(res->what, "rxpkts"))
 		show_rx_pkt_segments();
+	else if (!strcmp(res->what, "rxhdrs"))
+		show_rx_pkt_hdrs();
 	else if (!strcmp(res->what, "txpkts"))
 		show_tx_pkt_segments();
 	else if (!strcmp(res->what, "txtimes"))
@@ -8070,12 +8196,12 @@ cmdline_parse_token_string_t cmd_showcfg_port =
 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
 cmdline_parse_token_string_t cmd_showcfg_what =
 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
-				 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
+				 "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes");
 
 cmdline_parse_inst_t cmd_showcfg = {
 	.f = cmd_showcfg_parsed,
 	.data = NULL,
-	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
+	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes",
 	.tokens = {
 		(void *)&cmd_showcfg_show,
 		(void *)&cmd_showcfg_port,
@@ -17833,6 +17959,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_set_log,
 	(cmdline_parse_inst_t *)&cmd_set_rxoffs,
 	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
+	(cmdline_parse_inst_t *)&cmd_set_rxhdrs,
 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
 	(cmdline_parse_inst_t *)&cmd_set_txtimes,
app/test-pmd/config.c +75 -0

81 lines not on this page · raw message

app/test-pmd/parameters.c +14 -1
index daf6a31b2b..f86d626276 100644
@@ -161,6 +161,7 @@ usage(char* progname)
 	       " Used mainly with PCAP drivers.\n");
 	printf("  --rxoffs=X[,Y]*: set RX segment offsets for split.\n");
 	printf("  --rxpkts=X[,Y]*: set RX segment sizes to split.\n");
+	printf("  --rxhdrs=mac[,ipv4]*: set RX segment protocol to split.\n");
 	printf("  --txpkts=X[,Y]*: set TX segment sizes"
 		" or total packet length.\n");
 	printf("  --txonly-multi-flow: generate multiple flows in txonly mode\n");
@@ -673,6 +674,7 @@ launch_args_parse(int argc, char** argv)
 		{ "flow-isolate-all",	        0, 0, 0 },
 		{ "rxoffs",			1, 0, 0 },
 		{ "rxpkts",			1, 0, 0 },
+		{ "rxhdrs",			1, 0, 0 },
 		{ "txpkts",			1, 0, 0 },
 		{ "txonly-multi-flow",		0, 0, 0 },
 		{ "rxq-share",			2, 0, 0 },
@@ -1327,7 +1329,6 @@ launch_args_parse(int argc, char** argv)
 			if (!strcmp(lgopts[opt_idx].name, "rxpkts")) {
 				unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT];
 				unsigned int nb_segs;
-
 				nb_segs = parse_item_list
 						(optarg, "rxpkt segments",
 						 MAX_SEGS_BUFFER_SPLIT,
@@ -1337,6 +1338,18 @@ launch_args_parse(int argc, char** argv)
 				else
 					rte_exit(EXIT_FAILURE, "bad rxpkts\n");
 			}
+			if (!strcmp(lgopts[opt_idx].name, "rxhdrs")) {
+				unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
+				unsigned int nb_segs;
+				nb_segs = parse_hdrs_list
+						(optarg, "rxpkt segments",
+						MAX_SEGS_BUFFER_SPLIT,
+						seg_hdrs, 0);
+				if (nb_segs >= 1)
+					set_rx_pkt_hdrs(seg_hdrs, nb_segs);
+				else
+					rte_exit(EXIT_FAILURE, "bad rxpkts\n");
+			}
 			if (!strcmp(lgopts[opt_idx].name, "txpkts")) {
 				unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
 				unsigned int nb_segs;
app/test-pmd/testpmd.c +4 -2
index fe2ce19f99..ef679c70be 100644
@@ -240,6 +240,7 @@ uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
 uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
 uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT];
 uint8_t  rx_pkt_nb_offs; /**< Number of specified offsets */
+uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT];
 
 /*
  * Configuration of packet segments used by the "txonly" processing engine.
@@ -2587,11 +2588,12 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		mpx = mbuf_pool_find(socket_id, mp_n);
 		/* Handle zero as mbuf data buffer size. */
 		rx_seg->length = rx_pkt_seg_lengths[i] ?
-				   rx_pkt_seg_lengths[i] :
-				   mbuf_data_size[mp_n];
+					rx_pkt_seg_lengths[i] :
+					mbuf_data_size[mp_n];
 		rx_seg->offset = i < rx_pkt_nb_offs ?
 				   rx_pkt_seg_offsets[i] : 0;
 		rx_seg->mp = mpx ? mpx : mp;
+		rx_seg->proto_hdr = rx_pkt_hdr_protos[i];
 	}
 	rx_conf->rx_nseg = rx_pkt_nb_segs;
 	rx_conf->rx_seg = rx_useg;
app/test-pmd/testpmd.h +6 -0
index 31f766c965..e791b9becd 100644
@@ -534,6 +534,7 @@ extern uint32_t max_rx_pkt_len;
  * Configuration of packet segments used to scatter received packets
  * if some of split features is configured.
  */
+extern uint32_t rx_pkt_hdr_protos[MAX_SEGS_BUFFER_SPLIT];
 extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
 extern uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
 extern uint16_t rx_pkt_seg_offsets[MAX_SEGS_BUFFER_SPLIT];
@@ -864,6 +865,9 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx)
 unsigned int parse_item_list(const char *str, const char *item_name,
 			unsigned int max_items,
 			unsigned int *parsed_items, int check_unique_values);
+unsigned int parse_hdrs_list(const char *str, const char *item_name,
+			unsigned int max_item,
+			unsigned int *parsed_items, int check_unique_values);
 void launch_args_parse(int argc, char** argv);
 void cmdline_read_from_file(const char *filename);
 void prompt(void);
@@ -1018,6 +1022,8 @@ void set_record_core_cycles(uint8_t on_off);
 void set_record_burst_stats(uint8_t on_off);
 void set_verbose_level(uint16_t vb_level);
 void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
+void set_rx_pkt_hdrs(unsigned int *seg_protos, unsigned int nb_segs);
+void show_rx_pkt_hdrs(void);
 void show_rx_pkt_segments(void);
 void set_rx_pkt_offsets(unsigned int *seg_offsets, unsigned int nb_offs);
 void show_rx_pkt_offsets(void);
Signature · 1 line
2.25.1
#84 lore raw

PATCH v9 4/4 net/ice: support buffer split in Rx path

In reply to [email protected]

From: Wenxuan Wu <[email protected]>

This patch adds support for protocol based buffer split in normal Rx data paths. When the Rx queue is configured with specific protocol type, packets received will be directly split into protocol header and payload parts limitation of ice pmd. And the two parts will be put into different mempools.

Currently, protocol based buffer split is not supported in vectorized paths.

A new api ice_get_supported_split_hdrs() has been introduced, it will return the supported header protocols of ice PMD to app for splitting.

---
 drivers/net/ice/ice_ethdev.c          |  38 ++++-
 drivers/net/ice/ice_rxtx.c            | 220 ++++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h            |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h |   3 +
 4 files changed, 245 insertions(+), 32 deletions(-)
drivers/net/ice/ice_ethdev.c +36 -2
index 73e550f5fb..dcd4ad2eb4 100644
@@ -169,6 +169,8 @@ static int ice_timesync_read_time(struct rte_eth_dev *dev,
 static int ice_timesync_write_time(struct rte_eth_dev *dev,
 				   const struct timespec *timestamp);
 static int ice_timesync_disable(struct rte_eth_dev *dev);
+static int ice_get_supported_split_hdrs(struct rte_eth_dev *dev,
+					uint32_t *ptypes);
 
 static const struct rte_pci_id pci_id_ice_map[] = {
 	{ RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E823L_BACKPLANE) },
@@ -267,6 +269,7 @@ static const struct eth_dev_ops ice_eth_dev_ops = {
 	.timesync_read_time           = ice_timesync_read_time,
 	.timesync_write_time          = ice_timesync_write_time,
 	.timesync_disable             = ice_timesync_disable,
+	.hdrs_supported_ptypes_get    = ice_get_supported_split_hdrs,
 };
 
 /* store statistics names and its offset in stats structure */
@@ -3713,7 +3716,8 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 			RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 			RTE_ETH_RX_OFFLOAD_VLAN_EXTEND |
 			RTE_ETH_RX_OFFLOAD_RSS_HASH |
-			RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+			RTE_ETH_RX_OFFLOAD_TIMESTAMP |
+			RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT;
 		dev_info->tx_offload_capa |=
 			RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
 			RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
@@ -3725,7 +3729,7 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		dev_info->flow_type_rss_offloads |= ICE_RSS_OFFLOAD_ALL;
 	}
 
-	dev_info->rx_queue_offload_capa = 0;
+	dev_info->rx_queue_offload_capa = RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT;
 	dev_info->tx_queue_offload_capa = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
 
 	dev_info->reta_size = pf->hash_lut_size;
@@ -3794,6 +3798,11 @@ ice_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->default_rxportconf.ring_size = ICE_BUF_SIZE_MIN;
 	dev_info->default_txportconf.ring_size = ICE_BUF_SIZE_MIN;
 
+	dev_info->rx_seg_capa.max_nseg = ICE_RX_MAX_NSEG;
+	dev_info->rx_seg_capa.multi_pools = 1;
+	dev_info->rx_seg_capa.offset_allowed = 0;
+	dev_info->rx_seg_capa.offset_align_log2 = 0;
+
 	return 0;
 }
 
@@ -5840,6 +5849,31 @@ ice_timesync_disable(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+ice_get_supported_split_hdrs(struct rte_eth_dev *dev, uint32_t *ptypes)
+{
+	if (!dev)
+		return -EINVAL;
+/* Buffer split protocol header capability. */
+#define RTE_BUFFER_SPLIT_PROTO_HDR_MASK ( \
+	RTE_PTYPE_L2_ETHER | \
+	RTE_PTYPE_L3_IPV4 | \
+	RTE_PTYPE_L3_IPV6 | \
+	RTE_PTYPE_L4_TCP | \
+	RTE_PTYPE_L4_UDP | \
+	RTE_PTYPE_L4_SCTP | \
+	RTE_PTYPE_INNER_L2_ETHER | \
+	RTE_PTYPE_INNER_L3_IPV4 | \
+	RTE_PTYPE_INNER_L3_IPV6 | \
+	RTE_PTYPE_INNER_L4_TCP | \
+	RTE_PTYPE_INNER_L4_UDP | \
+	RTE_PTYPE_INNER_L4_SCTP)
+
+	*ptypes = RTE_BUFFER_SPLIT_PROTO_HDR_MASK;
+
+	return 0;
+}
+
 static int
 ice_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	      struct rte_pci_device *pci_dev)
drivers/net/ice/ice_rxtx.c +190 -30

362 lines not on this page · raw message

drivers/net/ice/ice_rxtx.h +16 -0
index bb18a01951..611dbc8503 100644
@@ -16,6 +16,9 @@
 #define ICE_RX_MAX_BURST 32
 #define ICE_TX_MAX_BURST 32
 
+/* Maximal number of segments to split. */
+#define ICE_RX_MAX_NSEG 2
+
 #define ICE_CHK_Q_ENA_COUNT        100
 #define ICE_CHK_Q_ENA_INTERVAL_US  100
 
@@ -43,6 +46,11 @@
 extern uint64_t ice_timestamp_dynflag;
 extern int ice_timestamp_dynfield_offset;
 
+/* Max header size can be 2K - 64 bytes */
+#define ICE_RX_HDR_BUF_SIZE    (2048 - 64)
+
+#define ICE_HEADER_SPLIT_ENA   BIT(0)
+
 typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);
 typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq);
 typedef void (*ice_rxd_to_pkt_fields_t)(struct ice_rx_queue *rxq,
@@ -53,6 +61,12 @@ struct ice_rx_entry {
 	struct rte_mbuf *mbuf;
 };
 
+enum ice_rx_dtype {
+	ICE_RX_DTYPE_NO_SPLIT       = 0,
+	ICE_RX_DTYPE_HEADER_SPLIT   = 1,
+	ICE_RX_DTYPE_SPLIT_ALWAYS   = 2,
+};
+
 struct ice_rx_queue {
 	struct rte_mempool *mp; /* mbuf pool to populate RX ring */
 	volatile union ice_rx_flex_desc *rx_ring;/* RX ring virtual address */
@@ -95,6 +109,8 @@ struct ice_rx_queue {
 	uint32_t time_high;
 	uint32_t hw_register_set;
 	const struct rte_memzone *mz;
+	struct rte_eth_rxseg_split rxseg[ICE_RX_MAX_NSEG];
+	uint32_t rxseg_nb;
 };
 
 struct ice_tx_entry {
drivers/net/ice/ice_rxtx_vec_common.h +3 -0
index 2dd2d83650..eec6ea2134 100644
@@ -291,6 +291,9 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)
 	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
 		return -1;
 
+	if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)
+		return -1;
+
 	if (rxq->offloads & ICE_RX_VECTOR_OFFLOAD)
 		return ICE_VECTOR_OFFLOAD_PATH;
 
Signature · 1 line
2.25.1
author
#85 lore raw

RE: [PATCH v9 0/4] add an api to support proto based buffer split

In reply to [email protected]

Hi Andrew,

Quoted 19 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Monday, June 13, 2022 6:26 PM
To: [email protected]; [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; Singh, Aman Deep <[email protected]>; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]
Cc: [email protected]; Wu, WenxuanX <[email protected]>
Subject: [PATCH v9 0/4] add an api to support proto based buffer split

From: Wenxuan Wu <[email protected]>

Protocol type based buffer split consists of splitting a received packet into several separate segments based on the packet content. It is useful in some scenarios, such as GPU acceleration. The splitting will help to enable true zero copy and hence improve the performance significantly.

Quoted 4 lines

This patchset aims to support protocol header split based on current buffer split. When Rx queue is configured with RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload and corresponding protocol, packets received will be directly split into different mempools.

This protocol based buffer split patch series have been updated to v9. Sincerely thank you for the effort you put into this series.

Hope to know your considerations about this series now.
Do you think is it possible to get in 22.07? Or there are still some critical gaps need to be solved? Because we don't hope the same thing happens in 22.11.

Thanks very much.

Regards,
Xuan

Quoted 64 lines

v8->v9:
* Introduce a new api rte_eth_supported_hdrs_get to retrieve supported ptypes mask of a pmd to split.
* Fix header protocol split check.
* Support header protocol configuration of rxhdrs by default, e.g. ipv4, ipv6, mac, inner_mac, outer_mac, l3, l4.
* Refine doc.

v7->v8:
* Refine ethdev doc.
* Fix header protocol split check.

v6->v7:
* Fix supported header protocol check.
* Add rxhdrs commands and parameters.

v5->v6:
* The header split deprecation notice is sent.
* Refine the documents, protocol header based buffer split can actually support multi-segment split.
* Add buffer split protocol header capability.
* Fix some format issues.

v4->v5:
* Use protocol and mbuf_offset based buffer split instead of header split.
* Use RTE_PTYPE* instead of enum rte_eth_rx_header_split_protocol_type.
* Improve the description of rte_eth_rxseg_split.proto.

v3->v4:
* Use RTE_ETH_RX_HEADER_SPLIT_NONE instead of 0.

v2->v3:
* Fix a PMD bug.
* Add rx queue header split check.
* Revise the log and doc.

v1->v2:
* Add support for all header split protocol types.

Wenxuan Wu (4):
ethdev: introduce protocol header API
ethdev: introduce protocol hdr based buffer split app/testpmd: add rxhdrs commands and parameters net/ice: support buffer split in Rx path

 app/test-pmd/cmdline.c                 | 133 ++++++++++++++-
 app/test-pmd/config.c                  |  75 +++++++++
 app/test-pmd/parameters.c              |  15 +-
 app/test-pmd/testpmd.c                 |   6 +-
 app/test-pmd/testpmd.h                 |   6 +
 doc/guides/rel_notes/release_22_07.rst |   2 +
 drivers/net/ice/ice_ethdev.c           |  38 ++++-
 drivers/net/ice/ice_rxtx.c             | 220 +++++++++++++++++++++----
 drivers/net/ice/ice_rxtx.h             |  16 ++
 drivers/net/ice/ice_rxtx_vec_common.h  |   3 +
 lib/ethdev/ethdev_driver.h             |  18 ++
 lib/ethdev/rte_ethdev.c                |  61 +++++--
 lib/ethdev/rte_ethdev.h                |  36 +++-
 lib/ethdev/version.map                 |   3 +
 14 files changed, 582 insertions(+), 50 deletions(-)

--
2.25.1

#86 lore raw

Re: [PATCH v9 0/4] add an api to support proto based buffer split

21/06/2022 10:56, Ding, Xuan:

Quoted 6 lines

This protocol based buffer split patch series have been updated to v9. Sincerely thank you for the effort you put into this series.

Hope to know your considerations about this series now.
Do you think is it possible to get in 22.07? Or there are still some critical gaps need to be solved? Because we don't hope the same thing happens in 22.11.

My quick comment, I think you must better care about all details. Precise explanations are very important.
It is more encouraging to review when we see the author tried hard to avoid any confusion or approximation.

author
#87 lore raw

RE: [PATCH v9 0/4] add an api to support proto based buffer split

Hi,

Quoted 19 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, July 7, 2022 5:10 PM
To: Wu, WenxuanX <[email protected]>; Ding, Xuan <[email protected]>
Cc: [email protected]; [email protected]; Li, Xiaoyun <[email protected]>; [email protected]; [email protected]; Zhang, Yuying <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]; Zhang, Qi Z <[email protected]>; Richardson, Bruce <[email protected]>; Mcnamara, John <[email protected]>
Subject: Re: [PATCH v9 0/4] add an api to support proto based buffer split

21/06/2022 10:56, Ding, Xuan:

Quoted 5 lines

This protocol based buffer split patch series have been updated to v9. Sincerely thank you for the effort you put into this series.

Hope to know your considerations about this series now.
Do you think is it possible to get in 22.07? Or there are still some critical

Quoted 7 lines

gaps need to be solved?

Quoted 1 line

Because we don't hope the same thing happens in 22.11.

My quick comment, I think you must better care about all details. Precise explanations are very important.
It is more encouraging to review when we see the author tried hard to avoid any confusion or approximation.

Thanks a lot to all the reviewers for the effort on this series.
So far, although we tried to make the explanation or documentation detailed, there must have some places that are not clearly explained or the doc is not good enough.

We will do more self-checks and try to refine where it might not be clear. Your comments are welcome.

Regards,
Xuan

Quoted 2 lines