Skip to contentSkip to conversation

ethdev: introduce Rx buffer split

RFC In review Slava Ovsiienko 10 participants 172 messages Aug 17, 2020 – Oct 19, 2020 Network drivers Page 1 of 3

lore
Share & tools
lore
#0 lore raw

RFC 1/1 ethdev: introduce Rx buffer split

From 7f7052d8b85ff3ff7011bd844b6d3169c6e51923 Mon Sep 17 00:00:00 2001
From: Viacheslav Ovsiienko <[email protected]>
Date: Mon, 17 Aug 2020 16:57:43 +0000
Subject: [RFC] ethdev: introduce Rx buffer split

The DPDK datapath in the transmit direction is very flexible. An application can build the multisegment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended infoirmation how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length */ uint16_t offset; /* data offset from beginning of mbuf data buffer */ uint32_t reserved; /* reserved field */
};

The new routine rte_eth_rx_queue_setup_ex() is introduced to setup the given Rx queue using the new extended Rx packet segment description:

int
rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)

This routine presents the two new parameters:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf
n_seg - number of elements in the array

The new offload flag DEV_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup_ex() routine application should check DEV_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will allocate the first mbuf from the pool specified in the first segment descriptor and puts the data staring at specified offeset in the allocated mbuf data buffer. If packet length exceeds the specified segment length the next mbuf will be allocated according to the next segment descriptor (if any) and data will be put in its data buffer at specified offset and not exceeding specified length. If there is no next descriptor the next mbuf will be allocated and filled in the same way (from the same pool and with the same buffer offset/length) as the current one.

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

    seg0 - pool0, len0=14B, off0=RTE_PKTMBUF_HEADROOM
    seg1 - pool1, len1=20B, off1=0B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B long @ 0 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B @ 0 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload DEV_RX_OFFLOAD_SCATTER must be present and configured to support new buffer spllit feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

Also, the proposed segment description might be used to specify Rx packet split for some other features. For example, provide the way to specify the extra memory pool for the Header Split feature of some Intel PMD.

---
 lib/librte_ethdev/rte_ethdev.c      | 166 ++++++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h      |  15 ++++
 lib/librte_ethdev/rte_ethdev_core.h |  10 +++
 3 files changed, 191 insertions(+)
lib/librte_ethdev/rte_ethdev.c +166 -0
index 7858ad5..638e42d 100644
@@ -1933,6 +1933,172 @@ struct rte_eth_dev *
 }
 
 int
+rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
+			  uint16_t nb_rx_desc, unsigned int socket_id,
+			  const struct rte_eth_rxconf *rx_conf,
+			  const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)
+{
+	int ret;
+	uint16_t seg_idx;
+	uint32_t mbp_buf_size;
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info;
+	struct rte_eth_rxconf local_conf;
+	void **rxq;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+
+	dev = &rte_eth_devices[port_id];
+	if (rx_queue_id >= dev->data->nb_rx_queues) {
+		RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", rx_queue_id);
+		return -EINVAL;
+	}
+
+	if (rx_seg == NULL) {
+		RTE_ETHDEV_LOG(ERR, "Invalid null description pointer\n");
+		return -EINVAL;
+	}
+
+	if (n_seg == 0) {
+		RTE_ETHDEV_LOG(ERR, "Invalid zero description number\n");
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup_ex, -ENOTSUP);
+
+	/*
+	 * Check the size of the mbuf data buffer.
+	 * This value must be provided in the private data of the memory pool.
+	 * First check that the memory pool has a valid private data.
+	 */
+	ret = rte_eth_dev_info_get(port_id, &dev_info);
+	if (ret != 0)
+		return ret;
+
+	for (seg_idx = 0; seg_idx < n_seg; seg_idx++) {
+		struct rte_mempool *mp = rx_seg[seg_idx].mp;
+
+		if (mp->private_data_size < sizeof(struct rte_pktmbuf_pool_private)) {
+			RTE_ETHDEV_LOG(ERR, "%s private_data_size %d < %d\n",
+				mp->name, (int)mp->private_data_size,
+				(int)sizeof(struct rte_pktmbuf_pool_private));
+			return -ENOSPC;
+		}
+
+		mbp_buf_size = rte_pktmbuf_data_room_size(mp);
+		if (mbp_buf_size < rx_seg[seg_idx].length + rx_seg[seg_idx].offset) {
+			RTE_ETHDEV_LOG(ERR,
+				"%s mbuf_data_room_size %d < %d"
+				" (segment length=%d + segment offset=%d)\n",
+				mp->name, (int)mbp_buf_size,
+				(int)(rx_seg[seg_idx].length + rx_seg[seg_idx].offset),
+				(int)rx_seg[seg_idx].length,
+				(int)rx_seg[seg_idx].offset);
+			return -EINVAL;
+		}
+	}
+
+	/* Use default specified by driver, if nb_rx_desc is zero */
+	if (nb_rx_desc == 0) {
+		nb_rx_desc = dev_info.default_rxportconf.ring_size;
+		/* If driver default is also zero, fall back on EAL default */
+		if (nb_rx_desc == 0)
+			nb_rx_desc = RTE_ETH_DEV_FALLBACK_RX_RINGSIZE;
+	}
+
+	if (nb_rx_desc > dev_info.rx_desc_lim.nb_max ||
+			nb_rx_desc < dev_info.rx_desc_lim.nb_min ||
+			nb_rx_desc % dev_info.rx_desc_lim.nb_align != 0) {
+
+		RTE_ETHDEV_LOG(ERR,
+			"Invalid value for nb_rx_desc(=%hu), should be: <= %hu, >= %hu, and a product of %hu\n",
+			nb_rx_desc, dev_info.rx_desc_lim.nb_max,
+			dev_info.rx_desc_lim.nb_min,
+			dev_info.rx_desc_lim.nb_align);
+		return -EINVAL;
+	}
+
+	if (dev->data->dev_started &&
+		!(dev_info.dev_capa &
+			RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP))
+		return -EBUSY;
+
+	if (dev->data->dev_started &&
+		(dev->data->rx_queue_state[rx_queue_id] !=
+			RTE_ETH_QUEUE_STATE_STOPPED))
+		return -EBUSY;
+
+	rxq = dev->data->rx_queues;
+	if (rxq[rx_queue_id]) {
+		RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release,
+					-ENOTSUP);
+		(*dev->dev_ops->rx_queue_release)(rxq[rx_queue_id]);
+		rxq[rx_queue_id] = NULL;
+	}
+
+	if (rx_conf == NULL)
+		rx_conf = &dev_info.default_rxconf;
+
+	local_conf = *rx_conf;
+
+	/*
+	 * If an offloading has already been enabled in
+	 * rte_eth_dev_configure(), it has been enabled on all queues,
+	 * so there is no need to enable it in this queue again.
+	 * The local_conf.offloads input to underlying PMD only carries
+	 * those offloadings which are only enabled on this queue and
+	 * not enabled on all queues.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;
+
+	/*
+	 * New added offloadings for this queue are those not enabled in
+	 * rte_eth_dev_configure() and they must be per-queue type.
+	 * A pure per-port offloading can't be enabled on a queue while
+	 * disabled on another queue. A pure per-port offloading can't
+	 * be enabled for any queue as new added one if it hasn't been
+	 * enabled in rte_eth_dev_configure().
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_ETHDEV_LOG(ERR,
+			"Ethdev port_id=%d rx_queue_id=%d, new added offloads 0x%"PRIx64" must be "
+			"within per-queue offload capabilities 0x%"PRIx64" in %s()\n",
+			port_id, rx_queue_id, local_conf.offloads,
+			dev_info.rx_queue_offload_capa,
+			__func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * If LRO is enabled, check that the maximum aggregated packet
+	 * size is supported by the configured device.
+	 */
+	if (local_conf.offloads & DEV_RX_OFFLOAD_TCP_LRO) {
+		if (dev->data->dev_conf.rxmode.max_lro_pkt_size == 0)
+			dev->data->dev_conf.rxmode.max_lro_pkt_size =
+				dev->data->dev_conf.rxmode.max_rx_pkt_len;
+		int ret = check_lro_pkt_size(port_id,
+				dev->data->dev_conf.rxmode.max_lro_pkt_size,
+				dev->data->dev_conf.rxmode.max_rx_pkt_len,
+				dev_info.max_lro_pkt_size);
+		if (ret != 0)
+			return ret;
+	}
+
+	ret = (*dev->dev_ops->rx_queue_setup_ex)(dev, rx_queue_id, nb_rx_desc,
+						 socket_id, &local_conf,
+						 rx_seg, n_seg);
+	if (!ret) {
+		if (!dev->data->min_rx_buf_size ||
+		    dev->data->min_rx_buf_size > mbp_buf_size)
+			dev->data->min_rx_buf_size = mbp_buf_size;
+	}
+
+	return eth_err(port_id, ret);
+}
+
+int
 rte_eth_rx_hairpin_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 			       uint16_t nb_rx_desc,
 			       const struct rte_eth_hairpin_conf *conf)
lib/librte_ethdev/rte_ethdev.h +15 -0
index 70295d7..701264a 100644
@@ -938,6 +938,16 @@ struct rte_eth_txmode {
 };
 
 /**
+ * A structure used to configure an RX packet segment to split.
+ */
+struct rte_eth_rxseg {
+	struct rte_mempool *mp; /**< Memory pools to allocate segment from */
+	uint16_t length; /**< Segment maximal data length */
+	uint16_t offset; /**< Data offset from beggining of mbuf data buffer */
+	uint32_t reserved; /**< Reserved field */
+};
+
+/**
  * A structure used to configure an RX ring of an Ethernet port.
  */
 struct rte_eth_rxconf {
@@ -1988,6 +1998,11 @@ int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		const struct rte_eth_rxconf *rx_conf,
 		struct rte_mempool *mb_pool);
 
+int rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
+		uint16_t nb_rx_desc, unsigned int socket_id,
+		const struct rte_eth_rxconf *rx_conf,
+		const struct rte_eth_rxseg *rx_seg, uint16_t n_seg);
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
lib/librte_ethdev/rte_ethdev_core.h +10 -0
index 32407dd..27018de 100644
@@ -265,6 +265,15 @@ typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
 				    struct rte_mempool *mb_pool);
 /**< @internal Set up a receive queue of an Ethernet device. */
 
+typedef int (*eth_rx_queue_setup_ex_t)(struct rte_eth_dev *dev,
+				       uint16_t rx_queue_id,
+				       uint16_t nb_rx_desc,
+				       unsigned int socket_id,
+				       const struct rte_eth_rxconf *rx_conf,
+				       const struct rte_eth_rxseg *rx_seg,
+				       uint16_t n_seg);
+/**< @internal Set up a receive queue of an Ethernet device. */
+
 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
 				    uint16_t tx_queue_id,
 				    uint16_t nb_tx_desc,
@@ -659,6 +668,7 @@ struct eth_dev_ops {
 	eth_queue_start_t          tx_queue_start;/**< Start TX for a queue. */
 	eth_queue_stop_t           tx_queue_stop; /**< Stop TX for a queue. */
 	eth_rx_queue_setup_t       rx_queue_setup;/**< Set up device RX queue. */
+	eth_rx_queue_setup_ex_t    rx_queue_setup_ex;/**< Set up device RX queue. */
 	eth_queue_release_t        rx_queue_release; /**< Release RX queue. */
 	eth_rx_queue_count_t       rx_queue_count;
 	/**< Get the number of used RX descriptors. */
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 11 lines · Slava Ovsiienko
Quoted 1 line

From 7f7052d8b85ff3ff7011bd844b6d3169c6e51923 Mon Sep 17 00:00:00 2001

From: Viacheslav Ovsiienko <[email protected]>
Date: Mon, 17 Aug 2020 16:57:43 +0000
Subject: [RFC] ethdev: introduce Rx buffer split

The DPDK datapath in the transmit direction is very flexible. An application can build the multisegment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

Quoted 5 lines

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended infoirmation how to split the packets being received.

infoirmation -> information

Quoted 34 lines

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length */ uint16_t offset; /* data offset from beginning of mbuf data buffer */ uint32_t reserved; /* reserved field */
};

The new routine rte_eth_rx_queue_setup_ex() is introduced to setup the given Rx queue using the new extended Rx packet segment description:

int
rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf,
const struct rte_eth_rxseg *rx_seg,
uint16_t n_seg)

This routine presents the two new parameters:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf
n_seg - number of elements in the array

The new offload flag DEV_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup_ex() routine application should check DEV_RX_OFFLOAD_BUFFER_SPLIT flag.

Quoted 5 lines

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will allocate the first mbuf from the pool specified in the first segment descriptor and puts the data staring at specified offeset in the allocated mbuf data

offeset -> offset

Quoted 20 lines

buffer. If packet length exceeds the specified segment length the next mbuf will be allocated according to the next segment descriptor (if any) and data will be put in its data buffer at specified offset and not exceeding specified length. If there is no next descriptor the next mbuf will be allocated and filled in the same way (from the same pool and with the same buffer offset/length) as the current one.

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

     seg0 - pool0, len0=14B, off0=RTE_PKTMBUF_HEADROOM
     seg1 - pool1, len1=20B, off1=0B
     seg2 - pool2, len2=20B, off2=0B
     seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B long @ 0 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

Quoted 7 lines

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B @ 0 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The behaviour is logical, but what to do if HW can't do it, i.e. use the last segment many times. Should it reject configuration if provided segments are insufficient to fit MTU packet? How to report the limitation?
(I'm still trying to convince that SCATTER and BUFFER_SPLIT should be independent).

Quoted 3 lines

The offload DEV_RX_OFFLOAD_SCATTER must be present and configured to support new buffer spllit feature (if n_seg

spllit -> split

Quoted 193 lines

is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

Also, the proposed segment description might be used to specify Rx packet split for some other features. For example, provide the way to specify the extra memory pool for the Header Split feature of some Intel PMD.

---
  lib/librte_ethdev/rte_ethdev.c      | 166 ++++++++++++++++++++++++++++++++++++
  lib/librte_ethdev/rte_ethdev.h      |  15 ++++
  lib/librte_ethdev/rte_ethdev_core.h |  10 +++
  3 files changed, 191 insertions(+)
lib/librte_ethdev/rte_ethdev.c +159 -0
index 7858ad5..638e42d 100644
@@ -1933,6 +1933,172 @@ struct rte_eth_dev *
  }
 
  int
+rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
+			  uint16_t nb_rx_desc, unsigned int socket_id,
+			  const struct rte_eth_rxconf *rx_conf,
+			  const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)
+{
+	int ret;
+	uint16_t seg_idx;
+	uint32_t mbp_buf_size;
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info;
+	struct rte_eth_rxconf local_conf;
+	void **rxq;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+
+	dev = &rte_eth_devices[port_id];
+	if (rx_queue_id >= dev->data->nb_rx_queues) {
+		RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", rx_queue_id);
+		return -EINVAL;
+	}
+
+	if (rx_seg == NULL) {
+		RTE_ETHDEV_LOG(ERR, "Invalid null description pointer\n");
+		return -EINVAL;
+	}
+
+	if (n_seg == 0) {
+		RTE_ETHDEV_LOG(ERR, "Invalid zero description number\n");
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup_ex, -ENOTSUP);
+
+	/*
+	 * Check the size of the mbuf data buffer.
+	 * This value must be provided in the private data of the memory pool.
+	 * First check that the memory pool has a valid private data.
+	 */
+	ret = rte_eth_dev_info_get(port_id, &dev_info);
+	if (ret != 0)
+		return ret;
+
+	for (seg_idx = 0; seg_idx < n_seg; seg_idx++) {
+		struct rte_mempool *mp = rx_seg[seg_idx].mp;
+
+		if (mp->private_data_size < sizeof(struct rte_pktmbuf_pool_private)) {
+			RTE_ETHDEV_LOG(ERR, "%s private_data_size %d < %d\n",
+				mp->name, (int)mp->private_data_size,
+				(int)sizeof(struct rte_pktmbuf_pool_private));
+			return -ENOSPC;
+		}
+
+		mbp_buf_size = rte_pktmbuf_data_room_size(mp);
+		if (mbp_buf_size < rx_seg[seg_idx].length + rx_seg[seg_idx].offset) {
+			RTE_ETHDEV_LOG(ERR,
+				"%s mbuf_data_room_size %d < %d"
+				" (segment length=%d + segment offset=%d)\n",
+				mp->name, (int)mbp_buf_size,
+				(int)(rx_seg[seg_idx].length + rx_seg[seg_idx].offset),
+				(int)rx_seg[seg_idx].length,
+				(int)rx_seg[seg_idx].offset);
+			return -EINVAL;
+		}
+	}
+
+	/* Use default specified by driver, if nb_rx_desc is zero */
+	if (nb_rx_desc == 0) {
+		nb_rx_desc = dev_info.default_rxportconf.ring_size;
+		/* If driver default is also zero, fall back on EAL default */
+		if (nb_rx_desc == 0)
+			nb_rx_desc = RTE_ETH_DEV_FALLBACK_RX_RINGSIZE;
+	}
+
+	if (nb_rx_desc > dev_info.rx_desc_lim.nb_max ||
+			nb_rx_desc < dev_info.rx_desc_lim.nb_min ||
+			nb_rx_desc % dev_info.rx_desc_lim.nb_align != 0) {
+
+		RTE_ETHDEV_LOG(ERR,
+			"Invalid value for nb_rx_desc(=%hu), should be: <= %hu, >= %hu, and a product of %hu\n",
+			nb_rx_desc, dev_info.rx_desc_lim.nb_max,
+			dev_info.rx_desc_lim.nb_min,
+			dev_info.rx_desc_lim.nb_align);
+		return -EINVAL;
+	}
+
+	if (dev->data->dev_started &&
+		!(dev_info.dev_capa &
+			RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP))
+		return -EBUSY;
+
+	if (dev->data->dev_started &&
+		(dev->data->rx_queue_state[rx_queue_id] !=
+			RTE_ETH_QUEUE_STATE_STOPPED))
+		return -EBUSY;
+
+	rxq = dev->data->rx_queues;
+	if (rxq[rx_queue_id]) {
+		RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release,
+					-ENOTSUP);
+		(*dev->dev_ops->rx_queue_release)(rxq[rx_queue_id]);
+		rxq[rx_queue_id] = NULL;
+	}
+
+	if (rx_conf == NULL)
+		rx_conf = &dev_info.default_rxconf;
+
+	local_conf = *rx_conf;
+
+	/*
+	 * If an offloading has already been enabled in
+	 * rte_eth_dev_configure(), it has been enabled on all queues,
+	 * so there is no need to enable it in this queue again.
+	 * The local_conf.offloads input to underlying PMD only carries
+	 * those offloadings which are only enabled on this queue and
+	 * not enabled on all queues.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;
+
+	/*
+	 * New added offloadings for this queue are those not enabled in
+	 * rte_eth_dev_configure() and they must be per-queue type.
+	 * A pure per-port offloading can't be enabled on a queue while
+	 * disabled on another queue. A pure per-port offloading can't
+	 * be enabled for any queue as new added one if it hasn't been
+	 * enabled in rte_eth_dev_configure().
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_ETHDEV_LOG(ERR,
+			"Ethdev port_id=%d rx_queue_id=%d, new added offloads 0x%"PRIx64" must be "
+			"within per-queue offload capabilities 0x%"PRIx64" in %s()\n",
+			port_id, rx_queue_id, local_conf.offloads,
+			dev_info.rx_queue_offload_capa,
+			__func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * If LRO is enabled, check that the maximum aggregated packet
+	 * size is supported by the configured device.
+	 */
+	if (local_conf.offloads & DEV_RX_OFFLOAD_TCP_LRO) {
+		if (dev->data->dev_conf.rxmode.max_lro_pkt_size == 0)
+			dev->data->dev_conf.rxmode.max_lro_pkt_size =
+				dev->data->dev_conf.rxmode.max_rx_pkt_len;
+		int ret = check_lro_pkt_size(port_id,
+				dev->data->dev_conf.rxmode.max_lro_pkt_size,
+				dev->data->dev_conf.rxmode.max_rx_pkt_len,
+				dev_info.max_lro_pkt_size);
+		if (ret != 0)
+			return ret;
+	}
+
+	ret = (*dev->dev_ops->rx_queue_setup_ex)(dev, rx_queue_id, nb_rx_desc,
+						 socket_id, &local_conf,
+						 rx_seg, n_seg);
+	if (!ret) {
+		if (!dev->data->min_rx_buf_size ||
+		    dev->data->min_rx_buf_size > mbp_buf_size)

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2104

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +7 -0
+			dev->data->min_rx_buf_size = mbp_buf_size;
+	}
+
+	return eth_err(port_id, ret);
+}
+
+int
  rte_eth_rx_hairpin_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
  			       uint16_t nb_rx_desc,
  			       const struct rte_eth_hairpin_conf *conf)

I dislike the idea to introduce new device operation. rte_eth_rxconf has reserved space and BUFFER_SPLIT offload will mean that PMD looks at the split configuration location there.

Above duplication is simply not acceptable, but even if we factor our shared code into helper function, I still see no point to introduce new device operation.

[snip]

#2 lore raw

Hi, Andrew

Thank you for the comments, please see my replies below.

Quoted 11 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, September 17, 2020 19:55
To: Slava Ovsiienko <[email protected]>; [email protected]
Cc: Thomas Monjalon <[email protected]>; [email protected]; [email protected]; Shahaf Shuler <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Asaf Penso <[email protected]>
Subject: Re: [dpdk-dev] [RFC] ethdev: introduce Rx buffer split

[snip]

Quoted 21 lines
Quoted 13 lines

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

     seg0 - pool0, len0=14B, off0=RTE_PKTMBUF_HEADROOM
     seg1 - pool1, len1=20B, off1=0B
     seg2 - pool2, len2=20B, off2=0B
     seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B long @ 0 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

Quoted 7 lines

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B @ 0 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

Quoted 5 lines

The behaviour is logical, but what to do if HW can't do it, i.e. use the last segment many times. Should it reject configuration if provided segments are insufficient to fit MTU packet? How to report the limitation? (I'm still trying to convince that SCATTER and BUFFER_SPLIT should be independent).

BUFFER_SPLIT is rather the way to tune SCATTER. Currently scattering happens on unconditional mbuf data buffer boundaries (we have reserved HEAD space in the first mbuf and fill this one to the buffer end, the next mbuf buffers might be filled completely). BUFFER_SPLIT provides the way to specify the desired points to split packet, not just blindly follow buffer boundaries. There is the check inplemented in common part if each split segment fits the mbuf allocated from appropriate pool. PMD should do extra check internally whether it supports the requested split settings, if not - call will be rejected.

[snip]

Quoted 5 lines

I dislike the idea to introduce new device operation. rte_eth_rxconf has reserved space and BUFFER_SPLIT offload will mean that PMD looks at the split configuration location there.

We considered the approach of pushing split setting to the rxconf structure.
[http://patches.dpdk.org/patch/75205/]
But it seems there are some issues:

- the split configuration description requires the variable length array (due to variations in number of segments), so rte_eth_rxconf structure would have the variable length (not nice, IMO).

We could push pointers to the array of rte_eth_rxseg, but we would lost the single structure (and contiguous memory) simplicity, this approach has no advantages over the specifying the split configuration as parameters of setup_ex().

- it would introduces the ambiguity, rte_eth_rx_queue_setup() specifies the single mbuf pool as parameter. What should we do with it? Set to NULL? Treat as the first pool? I would prefer to specify all split segments in uniform fashion, i.e. as array or rte_eth_rxseg structures (and it can be easily updated with some extra segment attributes if needed). So, in my opinion, we should remove/replace the pool parameter in rx_queue_setup (by introducing new func).

- specifying the new extended setup roiutine has an advantage that we should not update any PMDs code in part of existing implementations of rte_eth_rx_queue_setup().

If PMD supports BUFFER_SPLIT (or other related feature) it just should provide rte_eth_rx_queue_setup_ex() and check the DEV_RX_OFFLOAD_BUFFER_SPLIT (or HEADER_SPLIT, or ever feature) it supports. The common code does not check the feature flags - it is on PMDs' own. In order to configure PMD to perfrom arbitrary desired Rx spliting the application should check DEV_RX_OFFLOAD_BUFFER_SPLIT in port capabilites, if found - set DEV_RX_OFFLOAD_BUFFER_SPLIT in configuration and call rte_eth_rx_queue_setup_ex(). And this approach can be followed for any other split related feature.

With best regards, Slava

#3 lore raw

Hi Slava,

I'm sorry for late reply. See my notes below.

Quoted 45 lines · Slava Ovsiienko

Hi, Andrew

Thank you for the comments, please see my replies below.

Quoted 11 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, September 17, 2020 19:55
To: Slava Ovsiienko <[email protected]>; [email protected]
Cc: Thomas Monjalon <[email protected]>; [email protected]; [email protected]; Shahaf Shuler <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Asaf Penso <[email protected]>
Subject: Re: [dpdk-dev] [RFC] ethdev: introduce Rx buffer split

[snip]

Quoted 21 lines
Quoted 13 lines

For example, let's suppose we configured the Rx queue with the following segments:
seg0 - pool0, len0=14B, off0=RTE_PKTMBUF_HEADROOM seg1 - pool1, len1=20B, off1=0B
seg2 - pool2, len2=20B, off2=0B
seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B long @ 0 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

Quoted 7 lines

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B @ 0 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

Quoted 7 lines

The behaviour is logical, but what to do if HW can't do it, i.e. use the last
segment many times. Should it reject configuration if provided segments are
insufficient to fit MTU packet? How to report the limitation? (I'm still trying to convince that SCATTER and BUFFER_SPLIT should be independent).

Quoted 10 lines

BUFFER_SPLIT is rather the way to tune SCATTER. Currently scattering happens on unconditional mbuf data buffer boundaries (we have reserved HEAD space in the first mbuf and fill this one to the buffer end, the next mbuf buffers might be filled completely). BUFFER_SPLIT provides the way to specify the desired points to split packet, not just blindly follow buffer boundaries. There is the check inplemented in common part if each split segment fits the mbuf allocated from appropriate pool. PMD should do extra check internally whether it supports the requested split settings, if not - call will be rejected.

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Quoted 16 lines

[snip]

Quoted 5 lines

I dislike the idea to introduce new device operation. rte_eth_rxconf has reserved space and BUFFER_SPLIT offload will mean that PMD looks at the split configuration location there.

We considered the approach of pushing split setting to the rxconf structure.
[http://patches.dpdk.org/patch/75205/]
But it seems there are some issues:

- the split configuration description requires the variable length array (due
to variations in number of segments), so rte_eth_rxconf structure would have the variable length (not nice, IMO).

Quoted 5 lines

We could push pointers to the array of rte_eth_rxseg, but we would lost the single structure (and contiguous memory) simplicity, this approach has no advantages over the specifying the split configuration as parameters of setup_ex().

I think it has a huge advantage to avoid extra device operation.

Quoted 9 lines

- it would introduces the ambiguity, rte_eth_rx_queue_setup() specifies the single
mbuf pool as parameter. What should we do with it? Set to NULL? Treat as the first pool? I would prefer to specify all split segments in uniform fashion, i.e. as array or rte_eth_rxseg structures (and it can be easily updated with some extra segment attributes if needed). So, in my opinion, we should remove/replace the pool parameter in rx_queue_setup (by introducing new func).

I'm trying to resolve the ambiguity as described above (see BUFFER_SPLIT vs SCATTER). Use the pointer for tail segments with respect to SCATTER capability.

Quoted 4 lines

- specifying the new extended setup roiutine has an advantage that we should
not update any PMDs code in part of existing implementations of rte_eth_rx_queue_setup().

It is not required since it is controlled by the new offload flags. If the offload is not supported, the new field is invisible for PMD (it simply ignores).

Quoted 15 lines

If PMD supports BUFFER_SPLIT (or other related feature) it just should provide
rte_eth_rx_queue_setup_ex() and check the DEV_RX_OFFLOAD_BUFFER_SPLIT (or HEADER_SPLIT, or ever feature) it supports. The common code does not check the feature flags - it is on PMDs' own. In order to configure PMD
to perfrom arbitrary desired Rx spliting the application should check DEV_RX_OFFLOAD_BUFFER_SPLIT in port capabilites, if found - set DEV_RX_OFFLOAD_BUFFER_SPLIT in configuration and call rte_eth_rx_queue_setup_ex().
And this approach can be followed for any other split related feature.

With best regards, Slava

#4 lore raw

Hi, Andrew

Thank you for the comments.

We have two approaches how to specify multiple segments to split Rx packets:
1. update queue configuration structure
2. introduce new rx_queue_setup_ex() routine with extra parameters.

For [1] my only actual dislike is that we would have multiple places to specify the pool - in rx_queue_setup() and in the config structure. So, we should implement some checking (if we have offload flag set we should check whether mp parameter is NULL and segment descriptions array pointer/size is provided, if no offload flag set - we must check the description array is empty).

Quoted 2 lines

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Yes, it would be very nice to hear extra opinions. Do we think the providing of extra API function is worse than extending existing structure, introducing some conditional ambiguity and complicating the parameter compliance check?

Now I'm updating the existing version on the patch based on rx_queue_ex() and then could prepare the version for configuration structure, it is not a problem - approaches are very similar, we just should choose the most relevant one.

With best regards, Slava

Quoted 147 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 12, 2020 11:45
To: Slava Ovsiienko <[email protected]>; [email protected]
Cc: Thomas Monjalon <[email protected]>; [email protected]; [email protected]; Shahaf Shuler <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Asaf Penso <[email protected]>
Subject: Re: [dpdk-dev] [RFC] ethdev: introduce Rx buffer split

Hi Slava,

I'm sorry for late reply. See my notes below.

Quoted 11 lines · Slava Ovsiienko

Hi, Andrew

Thank you for the comments, please see my replies below.

Quoted 7 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, September 17, 2020 19:55
To: Slava Ovsiienko <[email protected]>; [email protected]
Cc: Thomas Monjalon <[email protected]>; [email protected]; [email protected]; Shahaf Shuler <[email protected]>; [email protected];

[email protected];

Quoted 1 line
Quoted 1 line

[email protected]; [email protected]; Asaf

Penso

Quoted 32 lines
Quoted 3 lines

<[email protected]>
Subject: Re: [dpdk-dev] [RFC] ethdev: introduce Rx buffer split

[snip]

Quoted 21 lines
Quoted 13 lines

For example, let's suppose we configured the Rx queue with the following segments:
seg0 - pool0, len0=14B, off0=RTE_PKTMBUF_HEADROOM seg1 - pool1, len1=20B, off1=0B
seg2 - pool2, len2=20B, off2=0B
seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B long @ 0 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

Quoted 7 lines

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B @ 0 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

Quoted 6 lines

The behaviour is logical, but what to do if HW can't do it, i.e. use the last segment many times. Should it reject configuration if provided segments are insufficient to fit MTU packet? How to report the limitation?
(I'm still trying to convince that SCATTER and BUFFER_SPLIT should be independent).

Quoted 7 lines

BUFFER_SPLIT is rather the way to tune SCATTER. Currently scattering happens on unconditional mbuf data buffer boundaries (we have reserved HEAD space in the first mbuf and fill this one to the buffer end, the next mbuf buffers might be filled completely). BUFFER_SPLIT provides the way to specify the desired points to split packet, not just blindly follow buffer boundaries. There is the check inplemented in common part if each split segment fits the mbuf allocated from

appropriate pool.

Quoted 3 lines

PMD should do extra check internally whether it supports the requested split settings, if not - call will be rejected.

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Quoted 9 lines

[snip]

Quoted 5 lines

I dislike the idea to introduce new device operation. rte_eth_rxconf has reserved space and BUFFER_SPLIT offload will mean that PMD looks at the split configuration location there.

We considered the approach of pushing split setting to the rxconf structure.

[https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatc

Quoted 1 line

hes.dpdk.org%2Fpatch%2F75205%2F&amp;data=02%7C01%7Cviacheslavo% 40nvidi

Quoted 1 line

a.com%7C97a49cb62028432610ea08d86e8b3283%7C43083d15727340c1b7 db39efd9c

Quoted 1 line

cc17a%7C0%7C0%7C637380891414182285&amp;sdata=liII5DHGlJAL8wEwV Vika79tp

Quoted 12 lines

8R9faTZ0lXrlfvQGZE%3D&amp;reserved=0]
But it seems there are some issues:

- the split configuration description requires the variable length array (due to variations in number of segments), so rte_eth_rxconf structure would have the variable length (not nice, IMO).

We could push pointers to the array of rte_eth_rxseg, but we would lost the single structure (and contiguous memory) simplicity, this approach has no advantages over the specifying the split configuration as parameters of setup_ex().

I think it has a huge advantage to avoid extra device operation.

Quoted 8 lines

- it would introduces the ambiguity, rte_eth_rx_queue_setup() specifies the single mbuf pool as parameter. What should we do with it? Set to NULL? Treat as the first pool? I would prefer to specify all split segments in uniform fashion, i.e. as array or rte_eth_rxseg structures (and it can be easily updated with some extra segment attributes if needed). So, in my opinion, we should remove/replace the pool parameter in rx_queue_setup (by introducing new func).

I'm trying to resolve the ambiguity as described above (see BUFFER_SPLIT vs SCATTER). Use the pointer for tail segments with respect to SCATTER capability.

Quoted 3 lines

- specifying the new extended setup roiutine has an advantage that we should not update any PMDs code in part of existing implementations of rte_eth_rx_queue_setup().

It is not required since it is controlled by the new offload flags. If the offload is not supported, the new field is invisible for PMD (it simply ignores).

Quoted 4 lines

If PMD supports BUFFER_SPLIT (or other related feature) it just should provide
rte_eth_rx_queue_setup_ex() and check the

DEV_RX_OFFLOAD_BUFFER_SPLIT

Quoted 10 lines

(or HEADER_SPLIT, or ever feature) it supports. The common code does not check the feature flags - it is on PMDs' own. In order to configure PMD to perfrom arbitrary desired Rx spliting the application should check DEV_RX_OFFLOAD_BUFFER_SPLIT in port capabilites, if found
- set DEV_RX_OFFLOAD_BUFFER_SPLIT in configuration and call rte_eth_rx_queue_setup_ex().
And this approach can be followed for any other split related feature.

With best regards, Slava

#5 lore raw

12/10/2020 11:56, Slava Ovsiienko:

Quoted 14 lines

Hi, Andrew

Thank you for the comments.

We have two approaches how to specify multiple segments to split Rx packets:
1. update queue configuration structure
2. introduce new rx_queue_setup_ex() routine with extra parameters.

For [1] my only actual dislike is that we would have multiple places to specify the pool - in rx_queue_setup() and in the config structure. So, we should implement some checking (if we have offload flag set we should check whether mp parameter is NULL and segment descriptions array pointer/size is provided, if no offload flag set - we must check the description array is empty).

Quoted 7 lines
Quoted 2 lines

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Yes, it would be very nice to hear extra opinions. Do we think the providing of extra API function is worse than extending existing structure, introducing some conditional ambiguity and complicating the parameter compliance check?

Let's try listing pros and cons of each approach, so we can conclude.

1/ update queue config struct

1.1 pro: keep same queue setup function 1.2 con: two mempool pointers (struct or function) 1.3 con: variable size of segment description array

2/ new queue setup function

2.1 con: two functions for queue setup
2.2 pro: mempool pointer is not redundant
2.3 pro: segment description array size defined by the caller

What else I'm missing?

#6 lore raw
Quoted 34 lines

12/10/2020 11:56, Slava Ovsiienko:

Quoted 14 lines

Hi, Andrew

Thank you for the comments.

We have two approaches how to specify multiple segments to split Rx packets:
1. update queue configuration structure
2. introduce new rx_queue_setup_ex() routine with extra parameters.

For [1] my only actual dislike is that we would have multiple places to specify the pool - in rx_queue_setup() and in the config structure. So, we should implement some checking (if we have offload flag set we should check whether mp parameter is NULL and segment descriptions array pointer/size is provided, if no offload flag set - we must check the description array is empty).

Quoted 7 lines
Quoted 2 lines

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Yes, it would be very nice to hear extra opinions. Do we think the providing of extra API function is worse than extending existing structure, introducing some conditional ambiguity and complicating the parameter compliance check?

Let's try listing pros and cons of each approach, so we can conclude.

1/ update queue config struct

1.1 pro: keep same queue setup function 1.2 con: two mempool pointers (struct or function) 1.3 con: variable size of segment description array

Quoted 8 lines

2/ new queue setup function

2.1 con: two functions for queue setup
2.2 pro: mempool pointer is not redundant
2.3 pro: segment description array size defined by the caller

What else I'm missing?

My 2 cents: can we make new (_ex) function to work for both original config (1 mp for all sizes, no split) and for new config (multiple mp, split allowed)?
Then in future (21.11?) we can either get rid of original one, or even make it a wrapper around all one?
Konstantin

#7 lore raw
Quoted 56 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Monday, October 12, 2020 18:28
To: NBU-Contact-Thomas Monjalon <[email protected]>; Andrew Rybchenko <[email protected]>; Yigit, Ferruh <[email protected]>; Slava Ovsiienko <[email protected]>
Cc: [email protected]; [email protected]; Shahaf Shuler <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Asaf Penso <[email protected]>
Subject: RE: [dpdk-dev] [RFC] ethdev: introduce Rx buffer split

Quoted 7 lines

12/10/2020 11:56, Slava Ovsiienko:

Quoted 5 lines

Hi, Andrew

Thank you for the comments.

We have two approaches how to specify multiple segments to split Rx

packets:

Quoted 8 lines
Quoted 8 lines

1. update queue configuration structure 2. introduce new rx_queue_setup_ex() routine with extra parameters.

For [1] my only actual dislike is that we would have multiple places to specify the pool - in rx_queue_setup() and in the config structure. So, we should implement some checking (if we have offload flag set we should check whether mp parameter is NULL and segment descriptions array pointer/size is provided, if no offload flag set - we must

check the description array is empty).

Quoted 23 lines
Quoted 8 lines
Quoted 3 lines

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Yes, it would be very nice to hear extra opinions. Do we think the providing of extra API function is worse than extending existing structure, introducing some conditional ambiguity and complicating the parameter compliance check?

Let's try listing pros and cons of each approach, so we can conclude.

1/ update queue config struct

1.1 pro: keep same queue setup function 1.2 con: two mempool pointers (struct or function) 1.3 con: variable size of segment description array

2/ new queue setup function

2.1 con: two functions for queue setup
2.2 pro: mempool pointer is not redundant
2.3 pro: segment description array size defined by the caller

Quoted 8 lines
Quoted 2 lines

What else I'm missing?

My 2 cents: can we make new (_ex) function to work for both original config (1 mp for all sizes, no split) and for new config (multiple mp, split allowed)? Then in future (21.11?) we can either get rid of original one, or even make it a wrapper around all one?
Konstantin

Yes, actually the mlx5 PMD implementation follows this approach - specifying the segment description array with the only element and zero size/offset provides exactly the same configuration as existing rte_eth_rx_queue_setup().

Currently I'm detailing the description (how HEAD_ROOM is handled, what happens if array is shorter the the buffer chain for segment of maximal size, the zero segment size means follow the value deduced from the pool and so on).

So, may we consider this point as one more "pro" to setup_ex approach ? 😊

With best regards, Slava

#8 lore raw
Quoted 70 lines
Quoted 56 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Monday, October 12, 2020 18:28
To: NBU-Contact-Thomas Monjalon <[email protected]>; Andrew Rybchenko <[email protected]>; Yigit, Ferruh <[email protected]>; Slava Ovsiienko <[email protected]>
Cc: [email protected]; [email protected]; Shahaf Shuler <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Asaf Penso <[email protected]>
Subject: RE: [dpdk-dev] [RFC] ethdev: introduce Rx buffer split

Quoted 7 lines

12/10/2020 11:56, Slava Ovsiienko:

Quoted 5 lines

Hi, Andrew

Thank you for the comments.

We have two approaches how to specify multiple segments to split Rx

packets:

Quoted 8 lines
Quoted 8 lines

1. update queue configuration structure 2. introduce new rx_queue_setup_ex() routine with extra parameters.

For [1] my only actual dislike is that we would have multiple places to specify the pool - in rx_queue_setup() and in the config structure. So, we should implement some checking (if we have offload flag set we should check whether mp parameter is NULL and segment descriptions array pointer/size is provided, if no offload flag set - we must

check the description array is empty).

Quoted 23 lines
Quoted 8 lines
Quoted 3 lines

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Yes, it would be very nice to hear extra opinions. Do we think the providing of extra API function is worse than extending existing structure, introducing some conditional ambiguity and complicating the parameter compliance check?

Let's try listing pros and cons of each approach, so we can conclude.

1/ update queue config struct

1.1 pro: keep same queue setup function 1.2 con: two mempool pointers (struct or function) 1.3 con: variable size of segment description array

2/ new queue setup function

2.1 con: two functions for queue setup
2.2 pro: mempool pointer is not redundant
2.3 pro: segment description array size defined by the caller

Quoted 8 lines
Quoted 2 lines

What else I'm missing?

My 2 cents: can we make new (_ex) function to work for both original config (1 mp for all sizes, no split) and for new config (multiple mp, split allowed)? Then in future (21.11?) we can either get rid of original one, or even make it a wrapper around all one?
Konstantin

Yes, actually the mlx5 PMD implementation follows this approach - specifying the segment description array with the only element and zero size/offset provides exactly the same configuration as existing rte_eth_rx_queue_setup().

Quoted 6 lines

Currently I'm detailing the description (how HEAD_ROOM is handled, what happens if array is shorter the the buffer chain for segment of maximal size, the zero segment size means follow the value deduced from the pool and so on).

So, may we consider this point as one more "pro" to setup_ex approach ? 😊

From my perspective, yes.
It is sort of more gradual approach.
I expect it would be experimental function for some time,
so we'll have time to try it, adjust, fix, etc without breaking original one.

#9 lore raw
Quoted 93 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Monday, October 12, 2020 18:56
To: Slava Ovsiienko <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Andrew Rybchenko <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]; [email protected]; Shahaf Shuler <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Asaf Penso <[email protected]>
Subject: RE: [dpdk-dev] [RFC] ethdev: introduce Rx buffer split

Quoted 9 lines
Quoted 9 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Monday, October 12, 2020 18:28
To: NBU-Contact-Thomas Monjalon <[email protected]>; Andrew Rybchenko <[email protected]>; Yigit, Ferruh <[email protected]>; Slava Ovsiienko <[email protected]>
Cc: [email protected]; [email protected]; Shahaf Shuler <[email protected]>; [email protected];

[email protected];

Quoted 1 line
Quoted 1 line

[email protected]; [email protected]; Asaf

Penso

Quoted 47 lines
Quoted 47 lines

<[email protected]>
Subject: RE: [dpdk-dev] [RFC] ethdev: introduce Rx buffer split

Quoted 8 lines

12/10/2020 11:56, Slava Ovsiienko:

Quoted 6 lines

Hi, Andrew

Thank you for the comments.

We have two approaches how to specify multiple segments to split Rx

packets:

Quoted 9 lines
Quoted 9 lines

1. update queue configuration structure 2. introduce new rx_queue_setup_ex() routine with extra parameters.

For [1] my only actual dislike is that we would have multiple places to specify the pool - in rx_queue_setup() and in the config structure. So, we should implement some checking (if we have offload flag set we should check whether mp parameter is NULL and segment descriptions array pointer/size is provided, if no offload flag set - we must

check the description array is empty).

Quoted 23 lines
Quoted 8 lines
Quoted 3 lines

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Yes, it would be very nice to hear extra opinions. Do we think the providing of extra API function is worse than extending existing structure, introducing some conditional ambiguity and complicating the parameter compliance check?

Let's try listing pros and cons of each approach, so we can conclude.

1/ update queue config struct

1.1 pro: keep same queue setup function 1.2 con: two mempool pointers (struct or function) 1.3 con: variable size of segment description array

2/ new queue setup function

2.1 con: two functions for queue setup
2.2 pro: mempool pointer is not redundant
2.3 pro: segment description array size defined by the caller

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

What else I'm missing?

My 2 cents: can we make new (_ex) function to work for both original config
(1 mp for all sizes, no split) and for new config (multiple mp, split

allowed)?

Quoted 4 lines
Quoted 3 lines

Then in future (21.11?) we can either get rid of original one, or even make it a wrapper around all one?
Konstantin

Quoted 8 lines

Yes, actually the mlx5 PMD implementation follows this approach - specifying the segment description array with the only element and zero size/offset provides exactly the same configuration as existing rte_eth_rx_queue_setup().

Currently I'm detailing the description (how HEAD_ROOM is handled, what happens if array is shorter the the buffer chain for segment of maximal size, the zero segment size means follow the value deduced from

the pool and so on).

Quoted 1 line
Quoted 9 lines
Quoted 3 lines

So, may we consider this point as one more "pro" to setup_ex approach ? 😊

From my perspective, yes.
It is sort of more gradual approach.
I expect it would be experimental function for some time, so we'll have time to try it, adjust, fix, etc without breaking original one.

Thank you for providing your opinion (whatever).
Yes, function will be marked as experimental.

With best regards, Slava

#10 lore raw
In reply to Ananyev, Konstantin

12/10/2020 17:56, Ananyev, Konstantin:

Quoted 54 lines
Quoted 54 lines

From: Ananyev, Konstantin <[email protected]>

Quoted 35 lines
Quoted 2 lines

12/10/2020 11:56, Slava Ovsiienko:

Quoted 1 line

We have two approaches how to specify multiple segments to split Rx

packets:

Quoted 8 lines
Quoted 8 lines

1. update queue configuration structure 2. introduce new rx_queue_setup_ex() routine with extra parameters.

For [1] my only actual dislike is that we would have multiple places to specify the pool - in rx_queue_setup() and in the config structure. So, we should implement some checking (if we have offload flag set we should check whether mp parameter is NULL and segment descriptions array pointer/size is provided, if no offload flag set - we must

check the description array is empty).

Quoted 23 lines
Quoted 8 lines
Quoted 3 lines

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Yes, it would be very nice to hear extra opinions. Do we think the providing of extra API function is worse than extending existing structure, introducing some conditional ambiguity and complicating the parameter compliance check?

Let's try listing pros and cons of each approach, so we can conclude.

1/ update queue config struct

1.1 pro: keep same queue setup function 1.2 con: two mempool pointers (struct or function) 1.3 con: variable size of segment description array

2/ new queue setup function

2.1 con: two functions for queue setup
2.2 pro: mempool pointer is not redundant
2.3 pro: segment description array size defined by the caller

Quoted 8 lines
Quoted 2 lines

What else I'm missing?

My 2 cents: can we make new (_ex) function to work for both original config (1 mp for all sizes, no split) and for new config (multiple mp, split allowed)? Then in future (21.11?) we can either get rid of original one, or even make it a wrapper around all one?
Konstantin

Yes, actually the mlx5 PMD implementation follows this approach - specifying the segment description array with the only element and zero size/offset provides exactly the same configuration as existing rte_eth_rx_queue_setup().

Currently I'm detailing the description (how HEAD_ROOM is handled, what happens if array is shorter the the buffer chain for segment of maximal size, the zero segment size means follow the value deduced from the pool and so on).

Quoted 6 lines
Quoted 1 line

So, may we consider this point as one more "pro" to setup_ex approach ? 😊

From my perspective, yes.
It is sort of more gradual approach.
I expect it would be experimental function for some time,
so we'll have time to try it, adjust, fix, etc without breaking original one.

I like the wrapper idea.
Is it possible to call rte_eth_rx_queue_setup_ex()
from rte_eth_rx_queue_setup() using a rte_eth_rxseg object on the stack?

#11 lore raw
In reply to Thomas Monjalon
Quoted 23 lines · Thomas Monjalon

12/10/2020 11:56, Slava Ovsiienko:

Quoted 14 lines

Hi, Andrew

Thank you for the comments.

We have two approaches how to specify multiple segments to split Rx packets:
1. update queue configuration structure
2. introduce new rx_queue_setup_ex() routine with extra parameters.

For [1] my only actual dislike is that we would have multiple places to specify the pool - in rx_queue_setup() and in the config structure. So, we should implement some checking (if we have offload flag set we should check whether mp parameter is NULL and segment descriptions array pointer/size is provided, if no offload flag set - we must check the description array is empty).

Quoted 7 lines
Quoted 2 lines

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Yes, it would be very nice to hear extra opinions. Do we think the providing of extra API function is worse than extending existing structure, introducing some conditional ambiguity and complicating the parameter compliance check?

Quoted 5 lines

Let's try listing pros and cons of each approach, so we can conclude.

1/ update queue config struct

1.1 pro: keep same queue setup function

pro: no code duplication

Quoted 6 lines

1.2 con: two mempool pointers (struct or function) 1.3 con: variable size of segment description array

2/ new queue setup function

2.1 con: two functions for queue setup

con: code duplication or refactoring of existing stable code

Quoted 5 lines

2.2 pro: mempool pointer is not redundant
2.3 pro: segment description array size defined by the caller

What else I'm missing?

#12 lore raw
Quoted 45 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 12, 2020 19:04
To: NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; Slava Ovsiienko <[email protected]>
Cc: [email protected]; [email protected]; Shahaf Shuler <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Asaf Penso <[email protected]>
Subject: Re: [dpdk-dev] [RFC] ethdev: introduce Rx buffer split

Quoted 6 lines · Thomas Monjalon

12/10/2020 11:56, Slava Ovsiienko:

Quoted 5 lines

Hi, Andrew

Thank you for the comments.

We have two approaches how to specify multiple segments to split Rx

packets:

Quoted 8 lines
Quoted 8 lines

1. update queue configuration structure 2. introduce new rx_queue_setup_ex() routine with extra parameters.

For [1] my only actual dislike is that we would have multiple places to specify the pool - in rx_queue_setup() and in the config structure. So, we should implement some checking (if we have offload flag set we should check whether mp parameter is NULL and segment descriptions array pointer/size is provided, if no offload flag set - we must

check the description array is empty).

Quoted 9 lines
Quoted 8 lines
Quoted 3 lines

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Yes, it would be very nice to hear extra opinions. Do we think the providing of extra API function is worse than extending existing structure, introducing some conditional ambiguity and complicating the parameter compliance check?

Quoted 5 lines

Let's try listing pros and cons of each approach, so we can conclude.

1/ update queue config struct

1.1 pro: keep same queue setup function

pro: no code duplication

Quoted 8 lines
Quoted 6 lines

1.2 con: two mempool pointers (struct or function) 1.3 con: variable size of segment description array

2/ new queue setup function

2.1 con: two functions for queue setup

con: code duplication or refactoring of existing stable code

- no refactoring of existing rte_eth_rx_queue_setup() - it is kept intact
- yes, there is some duplication in rte_eth_rxseg_queue_setup, but the large part of code is new - there is very specific check for the split buffer parameters.
- no code duplication at PMD level - both ways go to the same internal routine
- PMD code must be refactored anyway, no con/pro for this point - updated PMD rx queue setup must handle the new split format, no way to drop it.

Quoted 6 lines
Quoted 6 lines

2.2 pro: mempool pointer is not redundant
2.3 pro: segment description array size defined by the caller

What else I'm missing?

With best regards, Slava

#13 lore raw
In reply to Slava Ovsiienko
Quoted 14 lines · Slava Ovsiienko

Hi, Andrew

Thank you for the comments.

We have two approaches how to specify multiple segments to split Rx packets:
1. update queue configuration structure
2. introduce new rx_queue_setup_ex() routine with extra parameters.

For [1] my only actual dislike is that we would have multiple places to specify the pool - in rx_queue_setup() and in the config structure. So, we should implement some checking (if we have offload flag set we should check whether mp parameter is NULL and segment descriptions array pointer/size is provided, if no offload flag set - we must check the description array is empty).

Quoted 8 lines
Quoted 2 lines

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Yes, it would be very nice to hear extra opinions. Do we think the providing of extra API function is worse than extending existing structure, introducing some conditional ambiguity and complicating the parameter compliance check?

I think decision was given with the deprecation notice which already says ``rte_eth_rxconf`` will be updated for this.

With new API, we need to create a new dev_ops too, not sure about creating a new dev_ops for a single PMD.

For the PMD that supports this feature will need two dev_ops that is fairly close to each other, as Andrew mentioned this is a duplication.

And from user perspective two setup functions with overlaps can be confusing.

+1 to having single setup function but update the config, and I can see v5 sent this way, I will check it.

Quoted 155 lines

Now I'm updating the existing version on the patch based on rx_queue_ex() and then could prepare the version for configuration structure, it is not a problem - approaches are very similar, we just should choose the most relevant one.

With best regards, Slava

Quoted 147 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 12, 2020 11:45
To: Slava Ovsiienko <[email protected]>; [email protected]
Cc: Thomas Monjalon <[email protected]>; [email protected]; [email protected]; Shahaf Shuler <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Asaf Penso <[email protected]>
Subject: Re: [dpdk-dev] [RFC] ethdev: introduce Rx buffer split

Hi Slava,

I'm sorry for late reply. See my notes below.

Quoted 11 lines · Slava Ovsiienko

Hi, Andrew

Thank you for the comments, please see my replies below.

Quoted 7 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, September 17, 2020 19:55
To: Slava Ovsiienko <[email protected]>; [email protected]
Cc: Thomas Monjalon <[email protected]>; [email protected]; [email protected]; Shahaf Shuler <[email protected]>; [email protected];

[email protected];

Quoted 1 line
Quoted 1 line

[email protected]; [email protected]; Asaf

Penso

Quoted 32 lines
Quoted 3 lines

<[email protected]>
Subject: Re: [dpdk-dev] [RFC] ethdev: introduce Rx buffer split

[snip]

Quoted 21 lines
Quoted 13 lines

For example, let's suppose we configured the Rx queue with the following segments:
seg0 - pool0, len0=14B, off0=RTE_PKTMBUF_HEADROOM seg1 - pool1, len1=20B, off1=0B
seg2 - pool2, len2=20B, off2=0B
seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B long @ 0 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

Quoted 7 lines

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B @ 0 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

Quoted 6 lines

The behaviour is logical, but what to do if HW can't do it, i.e. use the last segment many times. Should it reject configuration if provided segments are insufficient to fit MTU packet? How to report the limitation?
(I'm still trying to convince that SCATTER and BUFFER_SPLIT should be independent).

Quoted 7 lines

BUFFER_SPLIT is rather the way to tune SCATTER. Currently scattering happens on unconditional mbuf data buffer boundaries (we have reserved HEAD space in the first mbuf and fill this one to the buffer end, the next mbuf buffers might be filled completely). BUFFER_SPLIT provides the way to specify the desired points to split packet, not just blindly follow buffer boundaries. There is the check inplemented in common part if each split segment fits the mbuf allocated from

appropriate pool.

Quoted 3 lines

PMD should do extra check internally whether it supports the requested split settings, if not - call will be rejected.

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Quoted 9 lines

[snip]

Quoted 5 lines

I dislike the idea to introduce new device operation. rte_eth_rxconf has reserved space and BUFFER_SPLIT offload will mean that PMD looks at the split configuration location there.

We considered the approach of pushing split setting to the rxconf structure.

[https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatc

Quoted 1 line

hes.dpdk.org%2Fpatch%2F75205%2F&amp;data=02%7C01%7Cviacheslavo% 40nvidi

Quoted 1 line

a.com%7C97a49cb62028432610ea08d86e8b3283%7C43083d15727340c1b7 db39efd9c

Quoted 1 line

cc17a%7C0%7C0%7C637380891414182285&amp;sdata=liII5DHGlJAL8wEwV Vika79tp

Quoted 12 lines

8R9faTZ0lXrlfvQGZE%3D&amp;reserved=0]
But it seems there are some issues:

- the split configuration description requires the variable length array (due to variations in number of segments), so rte_eth_rxconf structure would have the variable length (not nice, IMO).

We could push pointers to the array of rte_eth_rxseg, but we would lost the single structure (and contiguous memory) simplicity, this approach has no advantages over the specifying the split configuration as parameters of setup_ex().

I think it has a huge advantage to avoid extra device operation.

Quoted 8 lines

- it would introduces the ambiguity, rte_eth_rx_queue_setup() specifies the single mbuf pool as parameter. What should we do with it? Set to NULL? Treat as the first pool? I would prefer to specify all split segments in uniform fashion, i.e. as array or rte_eth_rxseg structures (and it can be easily updated with some extra segment attributes if needed). So, in my opinion, we should remove/replace the pool parameter in rx_queue_setup (by introducing new func).

I'm trying to resolve the ambiguity as described above (see BUFFER_SPLIT vs SCATTER). Use the pointer for tail segments with respect to SCATTER capability.

Quoted 3 lines

- specifying the new extended setup roiutine has an advantage that we should not update any PMDs code in part of existing implementations of rte_eth_rx_queue_setup().

It is not required since it is controlled by the new offload flags. If the offload is not supported, the new field is invisible for PMD (it simply ignores).

Quoted 4 lines

If PMD supports BUFFER_SPLIT (or other related feature) it just should provide
rte_eth_rx_queue_setup_ex() and check the

DEV_RX_OFFLOAD_BUFFER_SPLIT

Quoted 10 lines

(or HEADER_SPLIT, or ever feature) it supports. The common code does not check the feature flags - it is on PMDs' own. In order to configure PMD to perfrom arbitrary desired Rx spliting the application should check DEV_RX_OFFLOAD_BUFFER_SPLIT in port capabilites, if found
- set DEV_RX_OFFLOAD_BUFFER_SPLIT in configuration and call rte_eth_rx_queue_setup_ex().
And this approach can be followed for any other split related feature.

With best regards, Slava

#14 lore raw

13/10/2020 23:59, Ferruh Yigit:

Quoted 19 lines · Slava Ovsiienko
Quoted 10 lines

We have two approaches how to specify multiple segments to split Rx packets:
1. update queue configuration structure
2. introduce new rx_queue_setup_ex() routine with extra parameters.

For [1] my only actual dislike is that we would have multiple places to specify the pool - in rx_queue_setup() and in the config structure. So, we should implement some checking (if we have offload flag set we should check whether mp parameter is NULL and segment descriptions array pointer/size is provided, if no offload flag set - we must check the description array is empty).

Quoted 7 lines
Quoted 2 lines

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Yes, it would be very nice to hear extra opinions. Do we think the providing of extra API function is worse than extending existing structure, introducing some conditional ambiguity and complicating the parameter compliance check?

Quoted 5 lines

I think decision was given with the deprecation notice which already says ``rte_eth_rxconf`` will be updated for this.

With new API, we need to create a new dev_ops too, not sure about creating a new dev_ops for a single PMD.

You should not view it as a feature for a single PMD. Yes, as always, it starts with only one PMD implementing the API, but I really think this feature is generic and multiple NICs will be able to support this offload.

Quoted 15 lines

For the PMD that supports this feature will need two dev_ops that is fairly close to each other, as Andrew mentioned this is a duplication.

And from user perspective two setup functions with overlaps can be confusing.

+1 to having single setup function but update the config, and I can see v5 sent this way, I will check it.

Quoted 6 lines

Now I'm updating the existing version on the patch based on rx_queue_ex() and then could prepare the version for configuration structure, it is not a problem - approaches are very similar, we just should choose the most relevant one.

With best regards, Slava

#15 lore raw
In reply to Ferruh Yigit
Quoted 39 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 14, 2020 0:59
To: Slava Ovsiienko <[email protected]>; Andrew Rybchenko <[email protected]>; [email protected]
Cc: Thomas Monjalon <[email protected]>; [email protected]; Shahaf Shuler <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Asaf Penso <[email protected]>; Konstantin Ananyev <[email protected]>
Subject: Re: [dpdk-dev] [RFC] ethdev: introduce Rx buffer split

Quoted 5 lines · Slava Ovsiienko

Hi, Andrew

Thank you for the comments.

We have two approaches how to specify multiple segments to split Rx

packets:

Quoted 8 lines

1. update queue configuration structure 2. introduce new rx_queue_setup_ex() routine with extra parameters.

For [1] my only actual dislike is that we would have multiple places to specify the pool - in rx_queue_setup() and in the config structure. So, we should implement some checking (if we have offload flag set we should check whether mp parameter is NULL and segment descriptions array pointer/size is provided, if no offload flag set - we must check the

description array is empty).

Quoted 9 lines
Quoted 3 lines

@Thomas, @Ferruh: I'd like to hear what other ethdev maintainers think about it.

Yes, it would be very nice to hear extra opinions. Do we think the providing of extra API function is worse than extending existing structure, introducing some conditional ambiguity and complicating the parameter compliance check?

Quoted 5 lines

I think decision was given with the deprecation notice which already says ``rte_eth_rxconf`` will be updated for this.

With new API, we need to create a new dev_ops too, not sure about creating a new dev_ops for a single PMD.

I would rather consider the feature as generic one, not as for "single PMD". Currently DPDK does not provide any flexibility about Rx buffer and applications just have no way to control Rx buffer(s) attributes. I suppose the split is not very specific to mlx5, it is very likely the hardware of many other vendors should be capable to perform the same things.

Quoted 10 lines

For the PMD that supports this feature will need two dev_ops that is fairly close to each other, as Andrew mentioned this is a duplication.

And from user perspective two setup functions with overlaps can be confusing.

+1 to having single setup function but update the config, and I can see +v5 sent
this way, I will check it.

OK, got it, thank you very much for the opinion, let's move in this way.
v5 with reverted (back to deprecation notice) approach is sent, I will address the comments.

With best regards, Slaa

#16 lore raw

cover ethdev: introduce Rx buffer split

In reply to Slava Ovsiienko

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length */ uint16_t offset; /* data offset from beginning of mbuf data buffer */ uint32_t reserved; /* reserved field */
};

The new routine rte_eth_rx_queue_setup_ex() is introduced to setup the given Rx queue using the new extended Rx packet segment description:

int
rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)

This routine presents the two new parameters:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf
n_seg - number of elements in the array

The new offload flag DEV_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup_ex() routine application should check DEV_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will allocate the first mbuf from the pool specified in the first segment descriptor and puts the data staring at specified offset in the allocated mbuf data buffer. If packet length exceeds the specified segment length the next mbuf will be allocated according to the next segment descriptor (if any) and data will be put in its data buffer at specified offset and not exceeding specified length. If there is no next descriptor the next mbuf will be allocated and filled in the same way (from the same pool and with the same buffer offset/length) as the current one.

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

    seg0 - pool0, len0=14B, off0=RTE_PKTMBUF_HEADROOM
    seg1 - pool1, len1=20B, off1=0B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B long @ 0 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B @ 0 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload DEV_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

Also, the proposed segment description might be used to specify Rx packet split for some other features. For example, provide the way to specify the extra memory pool for the Header Split feature of some Intel PMD.

[RFC]: http://patches.dpdk.org/patch/75582/
Related deprecation note (revoked): http://patches.dpdk.org/patch/75205/

Viacheslav Ovsiienko (5):
ethdev: introduce Rx buffer split app/testpmd: add multiple pools per core creation app/testpmd: add buffer split offload configuration app/testpmd: add rxpkts commands and parameters app/testpmd: add extended Rx queue setup

 app/test-pmd/bpf_cmd.c                      |   4 +-
 app/test-pmd/cmdline.c                      |  96 ++++++++++++----
 app/test-pmd/config.c                       |  63 +++++++++-
 app/test-pmd/parameters.c                   |  39 ++++++-
 app/test-pmd/testpmd.c                      | 108 ++++++++++++-----
 app/test-pmd/testpmd.h                      |  41 ++++++-
 doc/guides/nics/features.rst                |  15 +++
 doc/guides/rel_notes/release_20_11.rst      |   6 +
 doc/guides/testpmd_app_ug/run_app.rst       |  16 ++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  21 +++-
 lib/librte_ethdev/rte_ethdev.c              | 172 ++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h              |  16 +++
 lib/librte_ethdev/rte_ethdev_driver.h       |  10 ++
 13 files changed, 535 insertions(+), 72 deletions(-)
Signature · 1 line
1.8.3.1
#17 lore raw

PATCH 1/5 ethdev: introduce Rx buffer split

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length */ uint16_t offset; /* data offset from beginning of mbuf data buffer */ uint32_t reserved; /* reserved field */
};

The new routine rte_eth_rx_queue_setup_ex() is introduced to setup the given Rx queue using the new extended Rx packet segment description:

int
rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)

This routine presents the two new parameters:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf
n_seg - number of elements in the array

The new offload flag DEV_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup_ex() routine application should check DEV_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will allocate the first mbuf from the pool specified in the first segment descriptor and puts the data staring at specified offset in the allocated mbuf data buffer. If packet length exceeds the specified segment length the next mbuf will be allocated according to the next segment descriptor (if any) and data will be put in its data buffer at specified offset and not exceeding specified length. If there is no next descriptor the next mbuf will be allocated and filled in the same way (from the same pool and with the same buffer offset/length) as the current one.

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

    seg0 - pool0, len0=14B, off0=RTE_PKTMBUF_HEADROOM
    seg1 - pool1, len1=20B, off1=0B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B long @ 0 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B @ 0 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload DEV_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

Also, the proposed segment description might be used to specify Rx packet split for some other features. For example, provide the way to specify the extra memory pool for the Header Split feature of some Intel PMD.

---
 doc/guides/nics/features.rst           |  15 +++
 doc/guides/rel_notes/release_20_11.rst |   6 ++
 lib/librte_ethdev/rte_ethdev.c         | 172 +++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h         |  16 +++
 lib/librte_ethdev/rte_ethdev_driver.h  |  10 ++
 5 files changed, 219 insertions(+)
doc/guides/nics/features.rst +15 -0
index dd8c955..ac9dfd7 100644
@@ -185,6 +185,21 @@ Supports receiving segmented mbufs.
 * **[related]    eth_dev_ops**: ``rx_pkt_burst``.
 
 
+.. _nic_features_buffer_split:
+
+Buffer Split on Rx
+------------
+
+Scatters the packets being received on specified boundaries to segmented mbufs.
+
+* **[uses]       rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[implements] datapath**: ``Buffer Split functionality``.
+* **[implements] rte_eth_dev_data**: ``buffer_split``.
+* **[provides]   rte_eth_dev_info**: ``rx_offload_capa:DEV_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[provides]   eth_dev_ops**: ``rxq_info_get:buffer_split``.
+* **[related] API**: ``rte_eth_rx_queue_setup_ex()``.
+
+
 .. _nic_features_lro:
 
 LRO
doc/guides/rel_notes/release_20_11.rst +6 -0
index 4bcf220..8da5cc9 100644
@@ -55,6 +55,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Introduced extended buffer description for receiving.**
+
+  * Added extended Rx queue setup routine
+  * Added description for Rx segment sizes
+  * Added capability to specify the memory pool for each segment
+
 * **Updated Cisco enic driver.**
 
   * Added support for VF representors with single-queue Tx/Rx and flow API
lib/librte_ethdev/rte_ethdev.c +172 -0

184 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +16 -0
index 645a186..553900b 100644
@@ -970,6 +970,16 @@ struct rte_eth_txmode {
 };
 
 /**
+ * A structure used to configure an RX packet segment to split.
+ */
+struct rte_eth_rxseg {
+	struct rte_mempool *mp; /**< Memory pools to allocate segment from */
+	uint16_t length; /**< Segment maximal data length */
+	uint16_t offset; /**< Data offset from beggining of mbuf data buffer */
+	uint32_t reserved; /**< Reserved field */
+};
+
+/**
  * A structure used to configure an RX ring of an Ethernet port.
  */
 struct rte_eth_rxconf {
@@ -1260,6 +1270,7 @@ struct rte_eth_conf {
 #define DEV_RX_OFFLOAD_SCTP_CKSUM	0x00020000
 #define DEV_RX_OFFLOAD_OUTER_UDP_CKSUM  0x00040000
 #define DEV_RX_OFFLOAD_RSS_HASH		0x00080000
+#define DEV_RX_OFFLOAD_BUFFER_SPLIT     0x00100000
 
 #define DEV_RX_OFFLOAD_CHECKSUM (DEV_RX_OFFLOAD_IPV4_CKSUM | \
 				 DEV_RX_OFFLOAD_UDP_CKSUM | \
@@ -2020,6 +2031,11 @@ int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		const struct rte_eth_rxconf *rx_conf,
 		struct rte_mempool *mb_pool);
 
+int rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
+		uint16_t nb_rx_desc, unsigned int socket_id,
+		const struct rte_eth_rxconf *rx_conf,
+		const struct rte_eth_rxseg *rx_seg, uint16_t n_seg);
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
lib/librte_ethdev/rte_ethdev_driver.h +10 -0
index 04ac8e9..de4d7de 100644
@@ -264,6 +264,15 @@ typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
 				    struct rte_mempool *mb_pool);
 /**< @internal Set up a receive queue of an Ethernet device. */
 
+typedef int (*eth_rx_queue_setup_ex_t)(struct rte_eth_dev *dev,
+				       uint16_t rx_queue_id,
+				       uint16_t nb_rx_desc,
+				       unsigned int socket_id,
+				       const struct rte_eth_rxconf *rx_conf,
+				       const struct rte_eth_rxseg *rx_seg,
+				       uint16_t n_seg);
+/**< @internal extended Set up a receive queue of an Ethernet device. */
+
 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
 				    uint16_t tx_queue_id,
 				    uint16_t nb_tx_desc,
@@ -630,6 +639,7 @@ struct eth_dev_ops {
 	eth_queue_start_t          tx_queue_start;/**< Start TX for a queue. */
 	eth_queue_stop_t           tx_queue_stop; /**< Stop TX for a queue. */
 	eth_rx_queue_setup_t       rx_queue_setup;/**< Set up device RX queue. */
+	eth_rx_queue_setup_ex_t    rx_queue_setup_ex;/**< Extended RX setup. */
 	eth_queue_release_t        rx_queue_release; /**< Release RX queue. */
 
 	eth_rx_enable_intr_t       rx_queue_intr_enable;  /**< Enable Rx queue interrupt. */
Signature · 1 line
1.8.3.1
#18 lore raw

PATCH 2/5 app/testpmd: add multiple pools per core creation

In reply to Viacheslav Ovsiienko

The command line parameter --mbuf-size is updated, it can handle the multiple values like the following:

--mbuf-size=2176,512,768,4096

specifying the creation the extra memory pools with the requested mbuf data buffer sizes. If some buffer split feature is engaged the extra memory pools can be used to configure the Rx queues with rte_the_dev_rx_queue_setup_ex().

The extra pools are created with requested sizes, and pool names are assigned with appended index: mbuf_pool_socket_%socket_%index. Index zero is used to specify the first mandatory pool to maintain compatibility with existing code.

---
 app/test-pmd/bpf_cmd.c                |  4 +--
 app/test-pmd/cmdline.c                |  2 +-
 app/test-pmd/config.c                 |  6 ++--
 app/test-pmd/parameters.c             | 24 +++++++++----
 app/test-pmd/testpmd.c                | 63 +++++++++++++++++++----------------
 app/test-pmd/testpmd.h                | 24 ++++++++++---
 doc/guides/testpmd_app_ug/run_app.rst |  7 ++--
 7 files changed, 83 insertions(+), 47 deletions(-)
app/test-pmd/bpf_cmd.c +2 -2
index 0f984cc..d8bb7ca 100644
@@ -69,7 +69,7 @@ struct cmd_bpf_ld_result {
 
 	*flags = RTE_BPF_ETH_F_NONE;
 	arg->type = RTE_BPF_ARG_PTR;
-	arg->size = mbuf_data_size;
+	arg->size = mbuf_data_size[0];
 
 	for (i = 0; str[i] != 0; i++) {
 		v = toupper(str[i]);
@@ -78,7 +78,7 @@ struct cmd_bpf_ld_result {
 		else if (v == 'M') {
 			arg->type = RTE_BPF_ARG_PTR_MBUF;
 			arg->size = sizeof(struct rte_mbuf);
-			arg->buf_size = mbuf_data_size;
+			arg->buf_size = mbuf_data_size[0];
 		} else if (v == '-')
 			continue;
 		else
app/test-pmd/cmdline.c +1 -1
index 08e123f..3f57182 100644
@@ -2898,7 +2898,7 @@ struct cmd_setup_rxtx_queue {
 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
 			socket_id = port->socket_id;
 
-		mp = mbuf_pool_find(socket_id);
+		mp = mbuf_pool_find(socket_id, 0);
 		if (mp == NULL) {
 			printf("Failed to setup RX queue: "
 				"No mempool allocation"
app/test-pmd/config.c +3 -3
index 17a6efe..7048288 100644
@@ -625,7 +625,7 @@ static int bus_match_all(const struct rte_bus *bus, const void *data)
 	printf("\nConnect to socket: %u", port->socket_id);
 
 	if (port_numa[port_id] != NUMA_NO_CONFIG) {
-		mp = mbuf_pool_find(port_numa[port_id]);
+		mp = mbuf_pool_find(port_numa[port_id], 0);
 		if (mp)
 			printf("\nmemory allocation on the socket: %d",
 							port_numa[port_id]);
@@ -3124,9 +3124,9 @@ struct igb_ring_desc_16_bytes {
 	 */
 	tx_pkt_len = 0;
 	for (i = 0; i < nb_segs; i++) {
-		if (seg_lengths[i] > (unsigned) mbuf_data_size) {
+		if (seg_lengths[i] > mbuf_data_size[0]) {
 			printf("length[%u]=%u > mbuf_data_size=%u - give up\n",
-			       i, seg_lengths[i], (unsigned) mbuf_data_size);
+			       i, seg_lengths[i], mbuf_data_size[0]);
 			return;
 		}
 		tx_pkt_len = (uint16_t)(tx_pkt_len + seg_lengths[i]);
app/test-pmd/parameters.c +18 -6
index 1ead595..1f40d73 100644
@@ -106,7 +106,9 @@
 	       "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n");
 	printf("  --socket-num=N: set socket from which all memory is allocated "
 	       "in NUMA mode.\n");
-	printf("  --mbuf-size=N: set the data size of mbuf to N bytes.\n");
+	printf("  --mbuf-size=N,[N1[,..Nn]: set the data size of mbuf to "
+	       "N bytes. If multiple numbers are specified the extra pools "
+	       "will be created to receive with packet split features\n");
 	printf("  --total-num-mbufs=N: set the number of mbufs to be allocated "
 	       "in mbuf pools.\n");
 	printf("  --max-pkt-len=N: set the maximum size of packet to N bytes.\n");
@@ -890,12 +892,22 @@
 				}
 			}
 			if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
-				n = atoi(optarg);
-				if (n > 0 && n <= 0xFFFF)
-					mbuf_data_size = (uint16_t) n;
-				else
+				unsigned int mb_sz[MAX_SEGS_BUFFER_SPLIT];
+				unsigned int nb_segs, i;
+
+				nb_segs = parse_item_list(optarg, "mbuf-size",
+					MAX_SEGS_BUFFER_SPLIT, mb_sz, 0);
+				if (nb_segs <= 0)
 					rte_exit(EXIT_FAILURE,
-						 "mbuf-size should be > 0 and < 65536\n");
+						 "bad mbuf-size\n");
+				for (i = 0; i < nb_segs; i++) {
+					if (mb_sz[i] <= 0 || mb_sz[i] > 0xFFFF)
+						rte_exit(EXIT_FAILURE,
+							 "mbuf-size should be "
+							 "> 0 and < 65536\n");
+					mbuf_data_size[i] = (uint16_t) mb_sz[i];
+				}
+				mbuf_data_size_n = nb_segs;
 			}
 			if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) {
 				n = atoi(optarg);
app/test-pmd/testpmd.c +35 -28

145 lines not on this page · raw message

app/test-pmd/testpmd.h +19 -5
index c7e7e41..e5cdd12 100644
@@ -42,6 +42,13 @@
  */
 #define RTE_MAX_SEGS_PER_PKT 255 /**< nb_segs is a 8-bit unsigned char. */
 
+/*
+ * The maximum number of segments per packet is used to configure
+ * buffer split feature, also specifies the maximum amount of
+ * optional Rx pools to allocate mbufs to split.
+ */
+#define MAX_SEGS_BUFFER_SPLIT 8 /**< nb_segs is a 8-bit unsigned char. */
+
 #define MAX_PKT_BURST 512
 #define DEF_PKT_BURST 32
 
@@ -393,7 +400,9 @@ struct queue_stats_mappings {
 extern uint8_t dcb_config;
 extern uint8_t dcb_test;
 
-extern uint16_t mbuf_data_size; /**< Mbuf data space size. */
+extern uint32_t mbuf_data_size_n;
+extern uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT];
+/**< Mbuf data space size. */
 extern uint32_t param_total_num_mbufs;
 
 extern uint16_t stats_period;
@@ -604,17 +613,22 @@ struct mplsoudp_decap_conf {
 
 /* Mbuf Pools */
 static inline void
-mbuf_poolname_build(unsigned int sock_id, char* mp_name, int name_size)
+mbuf_poolname_build(unsigned int sock_id, char *mp_name,
+		    int name_size, unsigned int idx)
 {
-	snprintf(mp_name, name_size, "mbuf_pool_socket_%u", sock_id);
+	if (!idx)
+		snprintf(mp_name, name_size, "mbuf_pool_socket_%u", sock_id);
+	else
+		snprintf(mp_name, name_size, "mbuf_pool_socket_%u_%u",
+			 sock_id, idx);
 }
 
 static inline struct rte_mempool *
-mbuf_pool_find(unsigned int sock_id)
+mbuf_pool_find(unsigned int sock_id, unsigned int idx)
 {
 	char pool_name[RTE_MEMPOOL_NAMESIZE];
 
-	mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name));
+	mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name), idx);
 	return rte_mempool_lookup((const char *)pool_name);
 }
 
doc/guides/testpmd_app_ug/run_app.rst +5 -2
index e2539f6..2d5a263 100644
@@ -107,9 +107,12 @@ The command line options are:
     Set the socket from which all memory is allocated in NUMA mode,
     where 0 <= N < number of sockets on the board.
 
-*   ``--mbuf-size=N``
+*   ``--mbuf-size=N[,N1[,...Nn]``
 
-    Set the data size of the mbufs used to N bytes, where N < 65536. The default value is 2048.
+    Set the data size of the mbufs used to N bytes, where N < 65536.
+    The default value is 2048. If multiple mbuf-size values are specified the
+    extra memory pools will be created for allocating mbufs to receive packets
+    with buffer splittling features.
 
 *   ``--total-num-mbufs=N``
 
Signature · 1 line
1.8.3.1
#19 lore raw

PATCH 3/5 app/testpmd: add buffer split offload configuration

In reply to Viacheslav Ovsiienko

This patch add support for DEV_RX_OFFLOAD_BUFFER_SPLIT providing per queue configuration for this offload.

---
 app/test-pmd/cmdline.c | 21 +++++++++++----------
 app/test-pmd/config.c  |  9 +++++++++
 2 files changed, 20 insertions(+), 10 deletions(-)
app/test-pmd/cmdline.c +11 -10
index 3f57182..24ca56a 100644
@@ -874,16 +874,16 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"port config <port_id> rx_offload vlan_strip|"
 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
 			"outer_ipv4_cksum|macsec_strip|header_split|"
-			"vlan_filter|vlan_extend|jumbo_frame|"
-			"scatter|timestamp|security|keep_crc on|off\n"
+			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
+			"buffer_split|timestamp|security|keep_crc on|off\n"
 			"     Enable or disable a per port Rx offloading"
 			" 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|"
-			"vlan_filter|vlan_extend|jumbo_frame|"
-			"scatter|timestamp|security|keep_crc on|off\n"
+			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
+			"buffer_split|timestamp|security|keep_crc on|off\n"
 			"    Enable or disable a per queue Rx offloading"
 			" only on a specific Rx queue\n\n"
 
@@ -18399,7 +18399,8 @@ struct cmd_config_per_port_rx_offload_result {
 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
-			   "scatter#timestamp#security#keep_crc#rss_hash");
+			   "scatter#buffer_split#timestamp#security#"
+			   "keep_crc#rss_hash");
 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
 	TOKEN_STRING_INITIALIZER
 		(struct cmd_config_per_port_rx_offload_result,
@@ -18479,8 +18480,8 @@ struct cmd_config_per_port_rx_offload_result {
 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
-		    "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
-		    "on|off",
+		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
+		    "keep_crc|rss_hash on|off",
 	.tokens = {
 		(void *)&cmd_config_per_port_rx_offload_result_port,
 		(void *)&cmd_config_per_port_rx_offload_result_config,
@@ -18529,7 +18530,7 @@ struct cmd_config_per_queue_rx_offload_result {
 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
-			   "scatter#timestamp#security#keep_crc");
+			   "scatter#buffer_split#timestamp#security#keep_crc");
 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
 	TOKEN_STRING_INITIALIZER
 		(struct cmd_config_per_queue_rx_offload_result,
@@ -18585,8 +18586,8 @@ struct cmd_config_per_queue_rx_offload_result {
 		    "vlan_strip|ipv4_cksum|"
 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
-		    "jumbo_frame|scatter|timestamp|security|keep_crc "
-		    "on|off",
+		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
+		    "keep_crc on|off",
 	.tokens = {
 		(void *)&cmd_config_per_queue_rx_offload_result_port,
 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
app/test-pmd/config.c +9 -0
index 7048288..395ea6b 100644
@@ -1027,6 +1027,15 @@ static int bus_match_all(const struct rte_bus *bus, const void *data)
 			printf("off\n");
 	}
 
+	if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_BUFFER_SPLIT) {
+		printf("RX offload buffer split:       ");
+		if (ports[port_id].dev_conf.rxmode.offloads &
+		    DEV_RX_OFFLOAD_BUFFER_SPLIT)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VLAN_INSERT) {
 		printf("VLAN insert:                   ");
 		if (ports[port_id].dev_conf.txmode.offloads &
Signature · 1 line
1.8.3.1
#20 lore raw

PATCH 4/5 app/testpmd: add rxpkts commands and parameters

In reply to Viacheslav Ovsiienko

Add command line parameter:

--rxpkts=X[,Y]

Sets the length of segments to scatter packets on receiving if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only).

Add interactive mode command:

testpmd> set txpkts (x[,y]*)

Where x[,y]* represents a CSV list of values, without white space.

Sets the length of segments to scatter packets on receiving if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only). Optionally the multiple memory pools can be specified with --mbuf-size command line parameter and the mbufs to receive will be allocated sequentially from these extra memory pools.

---
 app/test-pmd/cmdline.c                      | 61 +++++++++++++++++++++++++++--
 app/test-pmd/config.c                       | 48 ++++++++++++++++++++++-
 app/test-pmd/parameters.c                   | 15 +++++++
 app/test-pmd/testpmd.c                      |  7 ++++
 app/test-pmd/testpmd.h                      | 11 +++++-
 doc/guides/testpmd_app_ug/run_app.rst       |  9 +++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 21 +++++++++-
 7 files changed, 165 insertions(+), 7 deletions(-)
app/test-pmd/cmdline.c +58 -3
index 24ca56a..e0ac76e 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|txpkts)\n"
+			"show config (rxtx|cores|fwd|rxpkts|txpkts)\n"
 			"    Display the given configuration.\n\n"
 
 			"read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -288,6 +288,12 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"    Set the transmit delay time and number of retries,"
 			" effective when retry is enabled.\n\n"
 
+			"set rxpkts (x[,y]*)\n"
+			"    Set the length of each segment to scatter"
+			" packets on receiving if split feature is engaged."
+			" Affects only the queues configured with split"
+			" offloads.\n\n"
+
 			"set txpkts (x[,y]*)\n"
 			"    Set the length of each segment of TXONLY"
 			" and optionally CSUM packets.\n\n"
@@ -3880,6 +3886,52 @@ struct cmd_set_log_result {
 	},
 };
 
+/* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
+
+struct cmd_set_rxpkts_result {
+	cmdline_fixed_string_t cmd_keyword;
+	cmdline_fixed_string_t rxpkts;
+	cmdline_fixed_string_t seg_lengths;
+};
+
+static void
+cmd_set_rxpkts_parsed(void *parsed_result,
+		      __rte_unused struct cmdline *cl,
+		      __rte_unused void *data)
+{
+	struct cmd_set_rxpkts_result *res;
+	unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+	unsigned int nb_segs;
+
+	res = parsed_result;
+	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
+				  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
+	if (nb_segs > 0)
+		set_rx_pkt_segments(seg_lengths, nb_segs);
+}
+
+cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 cmd_keyword, "set");
+cmdline_parse_token_string_t cmd_set_rxpkts_name =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 rxpkts, "rxpkts");
+cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 seg_lengths, NULL);
+
+cmdline_parse_inst_t cmd_set_rxpkts = {
+	.f = cmd_set_rxpkts_parsed,
+	.data = NULL,
+	.help_str = "set rxpkts <len0[,len1]*>",
+	.tokens = {
+		(void *)&cmd_set_rxpkts_keyword,
+		(void *)&cmd_set_rxpkts_name,
+		(void *)&cmd_set_rxpkts_lengths,
+		NULL,
+	},
+};
+
 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
 
 struct cmd_set_txpkts_result {
@@ -7499,6 +7551,8 @@ static void cmd_showcfg_parsed(void *parsed_result,
 		fwd_lcores_config_display();
 	else if (!strcmp(res->what, "fwd"))
 		pkt_fwd_config_display(&cur_fwd_config);
+	else if (!strcmp(res->what, "rxpkts"))
+		show_rx_pkt_segments();
 	else if (!strcmp(res->what, "txpkts"))
 		show_tx_pkt_segments();
 	else if (!strcmp(res->what, "txtimes"))
@@ -7511,12 +7565,12 @@ static void cmd_showcfg_parsed(void *parsed_result,
 	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#txpkts#txtimes");
+				 "rxtx#cores#fwd#rxpkts#txpkts#txtimes");
 
 cmdline_parse_inst_t cmd_showcfg = {
 	.f = cmd_showcfg_parsed,
 	.data = NULL,
-	.help_str = "show config rxtx|cores|fwd|txpkts|txtimes",
+	.help_str = "show config rxtx|cores|fwd|rxpkts|txpkts|txtimes",
 	.tokens = {
 		(void *)&cmd_showcfg_show,
 		(void *)&cmd_showcfg_port,
@@ -19569,6 +19623,7 @@ struct cmd_showport_macs_result {
 	(cmdline_parse_inst_t *)&cmd_reset,
 	(cmdline_parse_inst_t *)&cmd_set_numbers,
 	(cmdline_parse_inst_t *)&cmd_set_log,
+	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
 	(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 +46 -2

62 lines not on this page · raw message

app/test-pmd/parameters.c +15 -0
index 1f40d73..99f0223 100644
@@ -184,6 +184,7 @@
 	       "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
 	printf("  --no-flush-rx: Don't flush RX streams before forwarding."
 	       " Used mainly with PCAP drivers.\n");
+	printf("  --rxpkts=X[,Y]*: set RX segment sizes 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");
@@ -661,6 +662,7 @@
 		{ "rx-queue-stats-mapping",	1, 0, 0 },
 		{ "no-flush-rx",	0, 0, 0 },
 		{ "flow-isolate-all",	        0, 0, 0 },
+		{ "rxpkts",			1, 0, 0 },
 		{ "txpkts",			1, 0, 0 },
 		{ "txonly-multi-flow",		0, 0, 0 },
 		{ "disable-link-check",		0, 0, 0 },
@@ -1270,6 +1272,19 @@
 						 "invalid RX queue statistics mapping config entered\n");
 				}
 			}
+			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,
+						 seg_len, 0);
+				if (nb_segs > 0)
+					set_rx_pkt_segments(seg_len, 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 +7 -0
index f5060ee..3c88ca7 100644
@@ -210,6 +210,13 @@ struct fwd_engine * fwd_engines[] = {
 uint8_t f_quit;
 
 /*
+ * Configuration of packet segments used to scatter received packets
+ * if some of split features is configured.
+ */
+uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
+
+/*
  * Configuration of packet segments used by the "txonly" processing engine.
  */
 uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN; /**< TXONLY packet length. */
app/test-pmd/testpmd.h +10 -1
index e5cdd12..0576b7c 100644
@@ -420,6 +420,13 @@ struct queue_stats_mappings {
 extern struct rte_fdir_conf fdir_conf;
 
 /*
+ * Configuration of packet segments used to scatter received packets
+ * if some of split features is configured.
+ */
+extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+extern uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
+
+/*
  * Configuration of packet segments used by the "txonly" processing engine.
  */
 #define TXONLY_DEF_PACKET_LEN 64
@@ -815,7 +822,9 @@ void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
 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_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs);
+void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
+void show_rx_pkt_segments(void);
+void set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
 void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
doc/guides/testpmd_app_ug/run_app.rst +9 -0
index 2d5a263..9286281 100644
@@ -361,6 +361,15 @@ The command line options are:
 
     Don't flush the RX streams before starting forwarding. Used mainly with the PCAP PMD.
 
+*   ``--rxpkts=X[,Y]``
+
+    Set the length of segments to scatter packets on receiving if split
+    feature is engaged. Affects only the queues configured
+    with split offloads (currently BUFFER_SPLIT is supported only).
+    Optionally the multiple memory pools can be specified with --mbuf-size
+    command line parameter and the mbufs to receive will be allocated
+    sequentially from these extra memory pools.
+
 *   ``--txpkts=X[,Y]``
 
     Set TX segment sizes or total packet length. Valid for ``tx-only``
doc/guides/testpmd_app_ug/testpmd_funcs.rst +20 -1
index 7f067af..0466920 100644
@@ -273,7 +273,7 @@ show config
 Displays the configuration of the application.
 The configuration comes from the command-line, the runtime or the application defaults::
 
-   testpmd> show config (rxtx|cores|fwd|txpkts|txtimes)
+   testpmd> show config (rxtx|cores|fwd|rxpkts|txpkts|txtimes)
 
 The available information categories are:
 
@@ -283,6 +283,8 @@ The available information categories are:
 
 * ``fwd``: Packet forwarding configuration.
 
+* ``rxpkts``: Packets to RX split configuration.
+
 * ``txpkts``: Packets to TX configuration.
 
 * ``txtimes``: Burst time pattern for Tx only mode.
@@ -760,6 +762,23 @@ When retry is enabled, the transmit delay time and number of retries can also be
 
    testpmd> set burst tx delay (microseconds) retry (num)
 
+set rxpkts
+~~~~~~~~~~
+
+Set the length of segments to scatter packets on receiving if split
+feature is engaged. Affects only the queues configured with split offloads
+(currently BUFFER_SPLIT is supported only). Optionally the multiple memory
+pools can be specified with --mbuf-size command line parameter and the mbufs
+to receive will be allocated sequentially from these extra memory pools (the
+mbuf for the first segment is allocated from the first pool, the second one
+from the second pool, and so on, if segment number is greater then pool's the
+mbuf for remaining segments will be allocated from the last valid pool).
+
+   testpmd> set rxpkts (x[,y]*)
+
+Where x[,y]* represents a CSV list of values, without white space. Zero value
+means to use the corresponding memory pool data buffer size.
+
 set txpkts
 ~~~~~~~~~~
 
Signature · 1 line
1.8.3.1
#21 lore raw

PATCH 5/5 app/testpmd: add extended Rx queue setup

In reply to Viacheslav Ovsiienko

If Rx queue is configured with split feature the extended setup with specified segment sizes and pool will be performed.

---
 app/test-pmd/cmdline.c | 12 ++++++------
 app/test-pmd/testpmd.c | 38 ++++++++++++++++++++++++++++++++++++--
 app/test-pmd/testpmd.h |  6 ++++++
 3 files changed, 48 insertions(+), 8 deletions(-)
app/test-pmd/cmdline.c +6 -6
index e0ac76e..1c65499 100644
@@ -2912,12 +2912,12 @@ struct cmd_setup_rxtx_queue {
 				rxring_numa[res->portid]);
 			return;
 		}
-		ret = rte_eth_rx_queue_setup(res->portid,
-					     res->qid,
-					     port->nb_rx_desc[res->qid],
-					     socket_id,
-					     &port->rx_conf[res->qid],
-					     mp);
+		ret = rx_queue_setup(res->portid,
+				     res->qid,
+				     port->nb_rx_desc[res->qid],
+				     socket_id,
+				     &port->rx_conf[res->qid],
+				     mp);
 		if (ret)
 			printf("Failed to setup RX queue\n");
 	} else {
app/test-pmd/testpmd.c +36 -2
index 3c88ca7..cd17cb0 100644
@@ -2412,6 +2412,40 @@ struct extmem_param {
 	return 0;
 }
 
+/* Configure the Rx with optional split. */
+int
+rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+	       uint16_t nb_rx_desc, unsigned int socket_id,
+	       const struct rte_eth_rxconf *rx_conf,
+	       struct rte_mempool *mp)
+{
+	struct rte_eth_rxseg rx_seg[MAX_SEGS_BUFFER_SPLIT] = {};
+	unsigned int i, mp_n;
+
+	if (rx_pkt_nb_segs <= 1 ||
+	    (rx_conf->offloads & DEV_RX_OFFLOAD_BUFFER_SPLIT) == 0)
+		return rte_eth_rx_queue_setup(port_id, rx_queue_id,
+					      nb_rx_desc, socket_id,
+					      rx_conf, mp);
+	for (i = 0; i < rx_pkt_nb_segs; i++) {
+		struct rte_mempool *mpx;
+		/*
+		 * Use last valid pool for the segments with number
+		 * exceeding the pool index.
+		 */
+		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[i].length = rx_pkt_seg_lengths[i] ?
+				   rx_pkt_seg_lengths[i] :
+				   mbuf_data_size[mp_n];
+		rx_seg[i].mp = mpx ? mpx : mp;
+	}
+	return rte_eth_rx_queue_setup_ex(port_id, rx_queue_id,
+					 nb_rx_desc, socket_id, rx_conf,
+					 rx_seg, rx_pkt_nb_segs);
+}
+
 int
 start_port(portid_t pid)
 {
@@ -2520,7 +2554,7 @@ struct extmem_param {
 						return -1;
 					}
 
-					diag = rte_eth_rx_queue_setup(pi, qi,
+					diag = rx_queue_setup(pi, qi,
 					     port->nb_rx_desc[qi],
 					     rxring_numa[pi],
 					     &(port->rx_conf[qi]),
@@ -2536,7 +2570,7 @@ struct extmem_param {
 							port->socket_id);
 						return -1;
 					}
-					diag = rte_eth_rx_queue_setup(pi, qi,
+					diag = rx_queue_setup(pi, qi,
 					     port->nb_rx_desc[qi],
 					     port->socket_id,
 					     &(port->rx_conf[qi]),
app/test-pmd/testpmd.h +6 -0
index 0576b7c..1953c11 100644
@@ -869,6 +869,12 @@ void port_rss_reta_info(portid_t port_id,
 
 void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on);
 
+int
+rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+	       uint16_t nb_rx_desc, unsigned int socket_id,
+	       const struct rte_eth_rxconf *rx_conf,
+	       struct rte_mempool *mp);
+
 int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate);
 int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate,
 				uint64_t q_msk);
Signature · 1 line
1.8.3.1
#22 lore raw

v2 cover ethdev: introduce Rx buffer split

In reply to Slava Ovsiienko

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length */ uint16_t offset; /* data offset from beginning of mbuf data buffer */ uint32_t reserved; /* reserved field */
};

The new routine rte_eth_rx_queue_setup_ex() is introduced to setup the given Rx queue using the new extended Rx packet segment description:

int
rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)

This routine presents the two new parameters:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf
n_seg - number of elements in the array

The new offload flag DEV_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup_ex() routine application should check DEV_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will allocate the first mbuf from the pool specified in the first segment descriptor and puts the data staring at specified offset in the allocated mbuf data buffer. If packet length exceeds the specified segment length the next mbuf will be allocated according to the next segment descriptor (if any) and data will be put in its data buffer at specified offset and not exceeding specified length. If there is no next descriptor the next mbuf will be allocated and filled in the same way (from the same pool and with the same buffer offset/length) as the current one.

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

    seg0 - pool0, len0=14B, off0=RTE_PKTMBUF_HEADROOM
    seg1 - pool1, len1=20B, off1=0B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B long @ 0 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B @ 0 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload DEV_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

Also, the proposed segment description might be used to specify Rx packet split for some other features. For example, provide the way to specify the extra memory pool for the Header Split feature of some Intel PMD.

---
[RFC]: http://patches.dpdk.org/patch/75582/
Related deprecation note (revoked): http://patches.dpdk.org/patch/75205/

v1: http://patches.dpdk.org/patch/79594/
v2: add feature supoport to mlx5 PMD

Viacheslav Ovsiienko (9):
ethdev: introduce Rx buffer split app/testpmd: add multiple pools per core creation app/testpmd: add buffer split offload configuration app/testpmd: add rxpkts commands and parameters app/testpmd: add extended Rx queue setup net/mlx5: add extended Rx queue setup routine net/mlx5: configure Rx queue to support split net/mlx5: register multiple pool for Rx queue net/mlx5: update Rx datapath to support split

 app/test-pmd/bpf_cmd.c                      |   4 +-
 app/test-pmd/cmdline.c                      |  96 +++++++++++---
 app/test-pmd/config.c                       |  63 ++++++++-
 app/test-pmd/parameters.c                   |  39 +++++-
 app/test-pmd/testpmd.c                      | 108 +++++++++++-----
 app/test-pmd/testpmd.h                      |  41 +++++-
 doc/guides/nics/features.rst                |  15 +++
 doc/guides/rel_notes/release_20_11.rst      |   6 +
 doc/guides/testpmd_app_ug/run_app.rst       |  16 ++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  21 ++-
 drivers/net/mlx5/linux/mlx5_os.c            |   2 +
 drivers/net/mlx5/mlx5.h                     |   3 +
 drivers/net/mlx5/mlx5_mr.c                  |   3 +
 drivers/net/mlx5/mlx5_rxq.c                 | 194 +++++++++++++++++++++++-----
 drivers/net/mlx5/mlx5_rxtx.c                |   3 +-
 drivers/net/mlx5/mlx5_rxtx.h                |  10 +-
 drivers/net/mlx5/mlx5_trigger.c             |  20 +--
 lib/librte_ethdev/rte_ethdev.c              | 174 +++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h              |  16 +++
 lib/librte_ethdev/rte_ethdev_driver.h       |  10 ++
 20 files changed, 733 insertions(+), 111 deletions(-)
Signature · 1 line
1.8.3.1
#23 lore raw

PATCH v2 1/9 ethdev: introduce Rx buffer split

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length */ uint16_t offset; /* data offset from beginning of mbuf data buffer */ uint32_t reserved; /* reserved field */
};

The new routine rte_eth_rx_queue_setup_ex() is introduced to setup the given Rx queue using the new extended Rx packet segment description:

int
rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)

This routine presents the two new parameters:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf
n_seg - number of elements in the array

The new offload flag DEV_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup_ex() routine application should check DEV_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will allocate the first mbuf from the pool specified in the first segment descriptor and puts the data staring at specified offset in the allocated mbuf data buffer. If packet length exceeds the specified segment length the next mbuf will be allocated according to the next segment descriptor (if any) and data will be put in its data buffer at specified offset and not exceeding specified length. If there is no next descriptor the next mbuf will be allocated and filled in the same way (from the same pool and with the same buffer offset/length) as the current one.

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

    seg0 - pool0, len0=14B, off0=RTE_PKTMBUF_HEADROOM
    seg1 - pool1, len1=20B, off1=0B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B long @ 0 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B @ 0 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload DEV_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

Also, the proposed segment description might be used to specify Rx packet split for some other features. For example, provide the way to specify the extra memory pool for the Header Split feature of some Intel PMD.

---
 doc/guides/nics/features.rst           |  15 +++
 doc/guides/rel_notes/release_20_11.rst |   6 ++
 lib/librte_ethdev/rte_ethdev.c         | 174 +++++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h         |  16 +++
 lib/librte_ethdev/rte_ethdev_driver.h  |  10 ++
 5 files changed, 221 insertions(+)
doc/guides/nics/features.rst +15 -0
index dd8c955..ac9dfd7 100644
@@ -185,6 +185,21 @@ Supports receiving segmented mbufs.
 * **[related]    eth_dev_ops**: ``rx_pkt_burst``.
 
 
+.. _nic_features_buffer_split:
+
+Buffer Split on Rx
+------------
+
+Scatters the packets being received on specified boundaries to segmented mbufs.
+
+* **[uses]       rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[implements] datapath**: ``Buffer Split functionality``.
+* **[implements] rte_eth_dev_data**: ``buffer_split``.
+* **[provides]   rte_eth_dev_info**: ``rx_offload_capa:DEV_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[provides]   eth_dev_ops**: ``rxq_info_get:buffer_split``.
+* **[related] API**: ``rte_eth_rx_queue_setup_ex()``.
+
+
 .. _nic_features_lro:
 
 LRO
doc/guides/rel_notes/release_20_11.rst +6 -0
index 4bcf220..8da5cc9 100644
@@ -55,6 +55,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Introduced extended buffer description for receiving.**
+
+  * Added extended Rx queue setup routine
+  * Added description for Rx segment sizes
+  * Added capability to specify the memory pool for each segment
+
 * **Updated Cisco enic driver.**
 
   * Added support for VF representors with single-queue Tx/Rx and flow API
lib/librte_ethdev/rte_ethdev.c +174 -0

186 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +16 -0
index 645a186..553900b 100644
@@ -970,6 +970,16 @@ struct rte_eth_txmode {
 };
 
 /**
+ * A structure used to configure an RX packet segment to split.
+ */
+struct rte_eth_rxseg {
+	struct rte_mempool *mp; /**< Memory pools to allocate segment from */
+	uint16_t length; /**< Segment maximal data length */
+	uint16_t offset; /**< Data offset from beggining of mbuf data buffer */
+	uint32_t reserved; /**< Reserved field */
+};
+
+/**
  * A structure used to configure an RX ring of an Ethernet port.
  */
 struct rte_eth_rxconf {
@@ -1260,6 +1270,7 @@ struct rte_eth_conf {
 #define DEV_RX_OFFLOAD_SCTP_CKSUM	0x00020000
 #define DEV_RX_OFFLOAD_OUTER_UDP_CKSUM  0x00040000
 #define DEV_RX_OFFLOAD_RSS_HASH		0x00080000
+#define DEV_RX_OFFLOAD_BUFFER_SPLIT     0x00100000
 
 #define DEV_RX_OFFLOAD_CHECKSUM (DEV_RX_OFFLOAD_IPV4_CKSUM | \
 				 DEV_RX_OFFLOAD_UDP_CKSUM | \
@@ -2020,6 +2031,11 @@ int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		const struct rte_eth_rxconf *rx_conf,
 		struct rte_mempool *mb_pool);
 
+int rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
+		uint16_t nb_rx_desc, unsigned int socket_id,
+		const struct rte_eth_rxconf *rx_conf,
+		const struct rte_eth_rxseg *rx_seg, uint16_t n_seg);
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
lib/librte_ethdev/rte_ethdev_driver.h +10 -0
index 04ac8e9..de4d7de 100644
@@ -264,6 +264,15 @@ typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
 				    struct rte_mempool *mb_pool);
 /**< @internal Set up a receive queue of an Ethernet device. */
 
+typedef int (*eth_rx_queue_setup_ex_t)(struct rte_eth_dev *dev,
+				       uint16_t rx_queue_id,
+				       uint16_t nb_rx_desc,
+				       unsigned int socket_id,
+				       const struct rte_eth_rxconf *rx_conf,
+				       const struct rte_eth_rxseg *rx_seg,
+				       uint16_t n_seg);
+/**< @internal extended Set up a receive queue of an Ethernet device. */
+
 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
 				    uint16_t tx_queue_id,
 				    uint16_t nb_tx_desc,
@@ -630,6 +639,7 @@ struct eth_dev_ops {
 	eth_queue_start_t          tx_queue_start;/**< Start TX for a queue. */
 	eth_queue_stop_t           tx_queue_stop; /**< Stop TX for a queue. */
 	eth_rx_queue_setup_t       rx_queue_setup;/**< Set up device RX queue. */
+	eth_rx_queue_setup_ex_t    rx_queue_setup_ex;/**< Extended RX setup. */
 	eth_queue_release_t        rx_queue_release; /**< Release RX queue. */
 
 	eth_rx_enable_intr_t       rx_queue_intr_enable;  /**< Enable Rx queue interrupt. */
Signature · 1 line
1.8.3.1
#24 lore raw

07/10/2020 17:06, Viacheslav Ovsiienko:

Quoted 12 lines

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

Quoted 6 lines

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length */

The "length" parameter is configuring a split point. Worth to note in the comment I think.

Quoted 1 line

uint16_t offset; /* data offset from beginning of mbuf data buffer */

Is it replacing RTE_PKTMBUF_HEADROOM?

Quoted 7 lines

uint32_t reserved; /* reserved field */
};

The new routine rte_eth_rx_queue_setup_ex() is introduced to setup the given Rx queue using the new extended Rx packet segment description:

Quoted 6 lines

int
rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)

An alternative name for this function:
rte_eth_rxseg_queue_setup

Quoted 5 lines

This routine presents the two new parameters:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf
n_seg - number of elements in the array

Not clear why we need an array.
I suggest writing here that each segment of the same packet can have different properties, the array representing the full packet.

Quoted 1 line

The new offload flag DEV_RX_OFFLOAD_BUFFER_SPLIT in device

The name should start with RTE_ prefix.

Quoted 54 lines

capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup_ex() routine application should check DEV_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will allocate the first mbuf from the pool specified in the first segment descriptor and puts the data staring at specified offset in the allocated mbuf data buffer. If packet length exceeds the specified segment length the next mbuf will be allocated according to the next segment descriptor (if any) and data will be put in its data buffer at specified offset and not exceeding specified length. If there is no next descriptor the next mbuf will be allocated and filled in the same way (from the same pool and with the same buffer offset/length) as the current one.

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

    seg0 - pool0, len0=14B, off0=RTE_PKTMBUF_HEADROOM
    seg1 - pool1, len1=20B, off1=0B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B long @ 0 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B @ 0 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload DEV_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

Quoted 4 lines

Also, the proposed segment description might be used to specify Rx packet split for some other features. For example, provide the way to specify the extra memory pool for the Header Split feature of some Intel PMD.

I don't understand what you are referring in this last paragraph. I think explanation above is enough to demonstrate the flexibility.

Quoted 1 line

Thank you, I like this feature.
More minor comments below.

[...]

Quoted 1 line

+* **Introduced extended buffer description for receiving.**

Rewording:
Introduced extended setup of Rx queue

doc/guides/rel_notes/release_20_11.rst New Features · line 61

Quoted 2 lines
doc/guides/rel_notes/release_20_11.rst +2 -0
+  * Added extended Rx queue setup routine
+  * Added description for Rx segment sizes

not only "sizes", but also offset and mempool.

Quoted 1 line

+ * Added capability to specify the memory pool for each segment

This one can be merged with the above, or offset should be added.

[...]
The doxygen comment is missing here.

lib/librte_ethdev/rte_ethdev.h int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 2037

Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+int rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
+		uint16_t nb_rx_desc, unsigned int socket_id,
+		const struct rte_eth_rxconf *rx_conf,
+		const struct rte_eth_rxseg *rx_seg, uint16_t n_seg);

This new function should be experimental and it should be added to the .map file.

#25 lore raw

Hi, Thomas

Thank you for the comments, please, see my answers below.

Quoted 26 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, October 12, 2020 1:18
To: Slava Ovsiienko <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 1/9] ethdev: introduce Rx buffer split

07/10/2020 17:06, Viacheslav Ovsiienko:

Quoted 15 lines

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

Quoted 6 lines
Quoted 3 lines

struct rte_eth_rxseg {
struct rte_mempool *mp; /* memory pools to allocate segment from */ uint16_t length; /* segment maximal data length */

The "length" parameter is configuring a split point. Worth to note in the comment I think.

OK, got it.

Quoted 6 lines
Quoted 3 lines

uint16_t offset; /* data offset from beginning of mbuf data buffer
*/

Is it replacing RTE_PKTMBUF_HEADROOM?

Actually adding to HEAD_ROOM. We should keep HEAD_ROOM intact,
so actual data offset in the firtst mbuf must be the sum HEAD_ROOM + offset. mlx5 PMD Imlementation follows this approach, documentation will be updated in v3.

Quoted 13 lines
Quoted 6 lines
    uint32_t reserved; /* reserved field */ };

The new routine rte_eth_rx_queue_setup_ex() is introduced to setup the given Rx queue using the new extended Rx packet segment description:

Quoted 6 lines

int
rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)

Quoted 2 lines

An alternative name for this function:
rte_eth_rxseg_queue_setup

M-m-m... Routine name follows patter object_verb:
rx_queue is an object, setup is an action.
rxseg_queue is not an object.
What about "rte_eth_rx_queue_setup_seg"?

Quoted 10 lines
Quoted 6 lines

This routine presents the two new parameters:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf
n_seg - number of elements in the array

Not clear why we need an array.
I suggest writing here that each segment of the same packet can have different properties, the array representing the full packet.

OK, will write.

Quoted 4 lines
Quoted 2 lines

The new offload flag DEV_RX_OFFLOAD_BUFFER_SPLIT in device

The name should start with RTE_ prefix.

It is an existing pattern for DEV_RX_OFFLOAD_xxxx, no RTE_ for the case.

Quoted 53 lines
Quoted 38 lines

capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup_ex() routine application should check DEV_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will allocate the first mbuf from the pool specified in the first segment descriptor and puts the data staring at specified offset in the allocated mbuf data buffer. If packet length exceeds the specified segment length the next mbuf will be allocated according to the next segment descriptor (if any) and data will be put in its data buffer at specified offset and not exceeding specified length. If there is no next descriptor the next mbuf will be allocated and filled in the same way (from the same pool and with the same buffer offset/length) as the current one.

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

    seg0 - pool0, len0=14B, off0=RTE_PKTMBUF_HEADROOM
    seg1 - pool1, len1=20B, off1=0B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B long @ 0 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM in mbuf from pool0 seg1 - 20B @ 0 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

Quoted 1 line

The offload DEV_RX_OFFLOAD_SCATTER must be present and configured

to

Quoted 13 lines

support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

Quoted 8 lines
Quoted 4 lines

Also, the proposed segment description might be used to specify Rx packet split for some other features. For example, provide the way to specify the extra memory pool for the Header Split feature of some Intel PMD.

I don't understand what you are referring in this last paragraph. I think explanation above is enough to demonstrate the flexibility.

Just noted the segment description is common thing and could be promoted to be used in some other features.

Quoted 10 lines
Quoted 1 line

Thank you, I like this feature.
More minor comments below.

[...]

Quoted 1 line

+* **Introduced extended buffer description for receiving.**

Rewording:
Introduced extended setup of Rx queue

OK, sounds better.

Quoted 5 lines

doc/guides/rel_notes/release_20_11.rst New Features · line 61

Quoted 4 lines
doc/guides/rel_notes/release_20_11.rst +2 -0
+  * Added extended Rx queue setup routine
+  * Added description for Rx segment sizes
Quoted 8 lines

not only "sizes", but also offset and mempool.

Quoted 1 line

+ * Added capability to specify the memory pool for each segment

This one can be merged with the above, or offset should be added.

[...]
The doxygen comment is missing here.

Yes, thank you. Also noted that, updating.

Quoted 9 lines

lib/librte_ethdev/rte_ethdev.h int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 2037

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.h +4 -0
+int rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
+		uint16_t nb_rx_desc, unsigned int socket_id,
+		const struct rte_eth_rxconf *rx_conf,
+		const struct rte_eth_rxseg *rx_seg, uint16_t n_seg);

This new function should be experimental and it should be added to the .map file.

OK.

With best regards, Slava

#26 lore raw

12/10/2020 11:40, Slava Ovsiienko:

Quoted 8 lines

From: Thomas Monjalon <[email protected]>

Quoted 7 lines
Quoted 6 lines

int
rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)

Quoted 6 lines
Quoted 2 lines

An alternative name for this function:
rte_eth_rxseg_queue_setup

M-m-m... Routine name follows patter object_verb:
rx_queue is an object, setup is an action.
rxseg_queue is not an object.
What about "rte_eth_rx_queue_setup_seg"?

rte_eth_rxseg is the name of the struct,
so it looks natural to me to keep it as prefix (object name).

[...]

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

The new offload flag DEV_RX_OFFLOAD_BUFFER_SPLIT in device

The name should start with RTE_ prefix.

It is an existing pattern for DEV_RX_OFFLOAD_xxxx, no RTE_ for the case.

It is a wrong pattern which must be fixed. Please start fresh with the right prefix for new ones. Thinking twice, it should be:
RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT

[...]

Quoted 10 lines
Quoted 8 lines
Quoted 4 lines

Also, the proposed segment description might be used to specify Rx packet split for some other features. For example, provide the way to specify the extra memory pool for the Header Split feature of some Intel PMD.

I don't understand what you are referring in this last paragraph. I think explanation above is enough to demonstrate the flexibility.

Just noted the segment description is common thing and could be promoted to be used in some other features.

I think it is not needed. And giving Intel as an example is arbitrary.

#27 lore raw

PATCH v2 2/9 app/testpmd: add multiple pools per core creation

In reply to Viacheslav Ovsiienko

The command line parameter --mbuf-size is updated, it can handle the multiple values like the following:

--mbuf-size=2176,512,768,4096

specifying the creation the extra memory pools with the requested mbuf data buffer sizes. If some buffer split feature is engaged the extra memory pools can be used to configure the Rx queues with rte_the_dev_rx_queue_setup_ex().

The extra pools are created with requested sizes, and pool names are assigned with appended index: mbuf_pool_socket_%socket_%index. Index zero is used to specify the first mandatory pool to maintain compatibility with existing code.

---
 app/test-pmd/bpf_cmd.c                |  4 +--
 app/test-pmd/cmdline.c                |  2 +-
 app/test-pmd/config.c                 |  6 ++--
 app/test-pmd/parameters.c             | 24 +++++++++----
 app/test-pmd/testpmd.c                | 63 +++++++++++++++++++----------------
 app/test-pmd/testpmd.h                | 24 ++++++++++---
 doc/guides/testpmd_app_ug/run_app.rst |  7 ++--
 7 files changed, 83 insertions(+), 47 deletions(-)
app/test-pmd/bpf_cmd.c +2 -2
index 0f984cc..d8bb7ca 100644
@@ -69,7 +69,7 @@ struct cmd_bpf_ld_result {
 
 	*flags = RTE_BPF_ETH_F_NONE;
 	arg->type = RTE_BPF_ARG_PTR;
-	arg->size = mbuf_data_size;
+	arg->size = mbuf_data_size[0];
 
 	for (i = 0; str[i] != 0; i++) {
 		v = toupper(str[i]);
@@ -78,7 +78,7 @@ struct cmd_bpf_ld_result {
 		else if (v == 'M') {
 			arg->type = RTE_BPF_ARG_PTR_MBUF;
 			arg->size = sizeof(struct rte_mbuf);
-			arg->buf_size = mbuf_data_size;
+			arg->buf_size = mbuf_data_size[0];
 		} else if (v == '-')
 			continue;
 		else
app/test-pmd/cmdline.c +1 -1
index 08e123f..3f57182 100644
@@ -2898,7 +2898,7 @@ struct cmd_setup_rxtx_queue {
 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
 			socket_id = port->socket_id;
 
-		mp = mbuf_pool_find(socket_id);
+		mp = mbuf_pool_find(socket_id, 0);
 		if (mp == NULL) {
 			printf("Failed to setup RX queue: "
 				"No mempool allocation"
app/test-pmd/config.c +3 -3
index 17a6efe..7048288 100644
@@ -625,7 +625,7 @@ static int bus_match_all(const struct rte_bus *bus, const void *data)
 	printf("\nConnect to socket: %u", port->socket_id);
 
 	if (port_numa[port_id] != NUMA_NO_CONFIG) {
-		mp = mbuf_pool_find(port_numa[port_id]);
+		mp = mbuf_pool_find(port_numa[port_id], 0);
 		if (mp)
 			printf("\nmemory allocation on the socket: %d",
 							port_numa[port_id]);
@@ -3124,9 +3124,9 @@ struct igb_ring_desc_16_bytes {
 	 */
 	tx_pkt_len = 0;
 	for (i = 0; i < nb_segs; i++) {
-		if (seg_lengths[i] > (unsigned) mbuf_data_size) {
+		if (seg_lengths[i] > mbuf_data_size[0]) {
 			printf("length[%u]=%u > mbuf_data_size=%u - give up\n",
-			       i, seg_lengths[i], (unsigned) mbuf_data_size);
+			       i, seg_lengths[i], mbuf_data_size[0]);
 			return;
 		}
 		tx_pkt_len = (uint16_t)(tx_pkt_len + seg_lengths[i]);
app/test-pmd/parameters.c +18 -6
index 1ead595..1f40d73 100644
@@ -106,7 +106,9 @@
 	       "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n");
 	printf("  --socket-num=N: set socket from which all memory is allocated "
 	       "in NUMA mode.\n");
-	printf("  --mbuf-size=N: set the data size of mbuf to N bytes.\n");
+	printf("  --mbuf-size=N,[N1[,..Nn]: set the data size of mbuf to "
+	       "N bytes. If multiple numbers are specified the extra pools "
+	       "will be created to receive with packet split features\n");
 	printf("  --total-num-mbufs=N: set the number of mbufs to be allocated "
 	       "in mbuf pools.\n");
 	printf("  --max-pkt-len=N: set the maximum size of packet to N bytes.\n");
@@ -890,12 +892,22 @@
 				}
 			}
 			if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
-				n = atoi(optarg);
-				if (n > 0 && n <= 0xFFFF)
-					mbuf_data_size = (uint16_t) n;
-				else
+				unsigned int mb_sz[MAX_SEGS_BUFFER_SPLIT];
+				unsigned int nb_segs, i;
+
+				nb_segs = parse_item_list(optarg, "mbuf-size",
+					MAX_SEGS_BUFFER_SPLIT, mb_sz, 0);
+				if (nb_segs <= 0)
 					rte_exit(EXIT_FAILURE,
-						 "mbuf-size should be > 0 and < 65536\n");
+						 "bad mbuf-size\n");
+				for (i = 0; i < nb_segs; i++) {
+					if (mb_sz[i] <= 0 || mb_sz[i] > 0xFFFF)
+						rte_exit(EXIT_FAILURE,
+							 "mbuf-size should be "
+							 "> 0 and < 65536\n");
+					mbuf_data_size[i] = (uint16_t) mb_sz[i];
+				}
+				mbuf_data_size_n = nb_segs;
 			}
 			if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) {
 				n = atoi(optarg);
app/test-pmd/testpmd.c +35 -28

145 lines not on this page · raw message

app/test-pmd/testpmd.h +19 -5
index c7e7e41..e5cdd12 100644
@@ -42,6 +42,13 @@
  */
 #define RTE_MAX_SEGS_PER_PKT 255 /**< nb_segs is a 8-bit unsigned char. */
 
+/*
+ * The maximum number of segments per packet is used to configure
+ * buffer split feature, also specifies the maximum amount of
+ * optional Rx pools to allocate mbufs to split.
+ */
+#define MAX_SEGS_BUFFER_SPLIT 8 /**< nb_segs is a 8-bit unsigned char. */
+
 #define MAX_PKT_BURST 512
 #define DEF_PKT_BURST 32
 
@@ -393,7 +400,9 @@ struct queue_stats_mappings {
 extern uint8_t dcb_config;
 extern uint8_t dcb_test;
 
-extern uint16_t mbuf_data_size; /**< Mbuf data space size. */
+extern uint32_t mbuf_data_size_n;
+extern uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT];
+/**< Mbuf data space size. */
 extern uint32_t param_total_num_mbufs;
 
 extern uint16_t stats_period;
@@ -604,17 +613,22 @@ struct mplsoudp_decap_conf {
 
 /* Mbuf Pools */
 static inline void
-mbuf_poolname_build(unsigned int sock_id, char* mp_name, int name_size)
+mbuf_poolname_build(unsigned int sock_id, char *mp_name,
+		    int name_size, unsigned int idx)
 {
-	snprintf(mp_name, name_size, "mbuf_pool_socket_%u", sock_id);
+	if (!idx)
+		snprintf(mp_name, name_size, "mbuf_pool_socket_%u", sock_id);
+	else
+		snprintf(mp_name, name_size, "mbuf_pool_socket_%u_%u",
+			 sock_id, idx);
 }
 
 static inline struct rte_mempool *
-mbuf_pool_find(unsigned int sock_id)
+mbuf_pool_find(unsigned int sock_id, unsigned int idx)
 {
 	char pool_name[RTE_MEMPOOL_NAMESIZE];
 
-	mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name));
+	mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name), idx);
 	return rte_mempool_lookup((const char *)pool_name);
 }
 
doc/guides/testpmd_app_ug/run_app.rst +5 -2
index e2539f6..2d5a263 100644
@@ -107,9 +107,12 @@ The command line options are:
     Set the socket from which all memory is allocated in NUMA mode,
     where 0 <= N < number of sockets on the board.
 
-*   ``--mbuf-size=N``
+*   ``--mbuf-size=N[,N1[,...Nn]``
 
-    Set the data size of the mbufs used to N bytes, where N < 65536. The default value is 2048.
+    Set the data size of the mbufs used to N bytes, where N < 65536.
+    The default value is 2048. If multiple mbuf-size values are specified the
+    extra memory pools will be created for allocating mbufs to receive packets
+    with buffer splittling features.
 
 *   ``--total-num-mbufs=N``
 
Signature · 1 line
1.8.3.1
#28 lore raw

PATCH v2 3/9 app/testpmd: add buffer split offload configuration

In reply to Viacheslav Ovsiienko

This patch add support for DEV_RX_OFFLOAD_BUFFER_SPLIT providing per queue configuration for this offload.

---
 app/test-pmd/cmdline.c | 21 +++++++++++----------
 app/test-pmd/config.c  |  9 +++++++++
 2 files changed, 20 insertions(+), 10 deletions(-)
app/test-pmd/cmdline.c +11 -10
index 3f57182..24ca56a 100644
@@ -874,16 +874,16 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"port config <port_id> rx_offload vlan_strip|"
 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
 			"outer_ipv4_cksum|macsec_strip|header_split|"
-			"vlan_filter|vlan_extend|jumbo_frame|"
-			"scatter|timestamp|security|keep_crc on|off\n"
+			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
+			"buffer_split|timestamp|security|keep_crc on|off\n"
 			"     Enable or disable a per port Rx offloading"
 			" 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|"
-			"vlan_filter|vlan_extend|jumbo_frame|"
-			"scatter|timestamp|security|keep_crc on|off\n"
+			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
+			"buffer_split|timestamp|security|keep_crc on|off\n"
 			"    Enable or disable a per queue Rx offloading"
 			" only on a specific Rx queue\n\n"
 
@@ -18399,7 +18399,8 @@ struct cmd_config_per_port_rx_offload_result {
 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
-			   "scatter#timestamp#security#keep_crc#rss_hash");
+			   "scatter#buffer_split#timestamp#security#"
+			   "keep_crc#rss_hash");
 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
 	TOKEN_STRING_INITIALIZER
 		(struct cmd_config_per_port_rx_offload_result,
@@ -18479,8 +18480,8 @@ struct cmd_config_per_port_rx_offload_result {
 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
-		    "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
-		    "on|off",
+		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
+		    "keep_crc|rss_hash on|off",
 	.tokens = {
 		(void *)&cmd_config_per_port_rx_offload_result_port,
 		(void *)&cmd_config_per_port_rx_offload_result_config,
@@ -18529,7 +18530,7 @@ struct cmd_config_per_queue_rx_offload_result {
 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
-			   "scatter#timestamp#security#keep_crc");
+			   "scatter#buffer_split#timestamp#security#keep_crc");
 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
 	TOKEN_STRING_INITIALIZER
 		(struct cmd_config_per_queue_rx_offload_result,
@@ -18585,8 +18586,8 @@ struct cmd_config_per_queue_rx_offload_result {
 		    "vlan_strip|ipv4_cksum|"
 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
-		    "jumbo_frame|scatter|timestamp|security|keep_crc "
-		    "on|off",
+		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
+		    "keep_crc on|off",
 	.tokens = {
 		(void *)&cmd_config_per_queue_rx_offload_result_port,
 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
app/test-pmd/config.c +9 -0
index 7048288..395ea6b 100644
@@ -1027,6 +1027,15 @@ static int bus_match_all(const struct rte_bus *bus, const void *data)
 			printf("off\n");
 	}
 
+	if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_BUFFER_SPLIT) {
+		printf("RX offload buffer split:       ");
+		if (ports[port_id].dev_conf.rxmode.offloads &
+		    DEV_RX_OFFLOAD_BUFFER_SPLIT)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VLAN_INSERT) {
 		printf("VLAN insert:                   ");
 		if (ports[port_id].dev_conf.txmode.offloads &
Signature · 1 line
1.8.3.1
#29 lore raw

PATCH v2 4/9 app/testpmd: add rxpkts commands and parameters

In reply to Viacheslav Ovsiienko

Add command line parameter:

--rxpkts=X[,Y]

Sets the length of segments to scatter packets on receiving if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only).

Add interactive mode command:

testpmd> set txpkts (x[,y]*)

Where x[,y]* represents a CSV list of values, without white space.

Sets the length of segments to scatter packets on receiving if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only). Optionally the multiple memory pools can be specified with --mbuf-size command line parameter and the mbufs to receive will be allocated sequentially from these extra memory pools.

---
 app/test-pmd/cmdline.c                      | 61 +++++++++++++++++++++++++++--
 app/test-pmd/config.c                       | 48 ++++++++++++++++++++++-
 app/test-pmd/parameters.c                   | 15 +++++++
 app/test-pmd/testpmd.c                      |  7 ++++
 app/test-pmd/testpmd.h                      | 11 +++++-
 doc/guides/testpmd_app_ug/run_app.rst       |  9 +++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 21 +++++++++-
 7 files changed, 165 insertions(+), 7 deletions(-)
app/test-pmd/cmdline.c +58 -3
index 24ca56a..e0ac76e 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|txpkts)\n"
+			"show config (rxtx|cores|fwd|rxpkts|txpkts)\n"
 			"    Display the given configuration.\n\n"
 
 			"read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -288,6 +288,12 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"    Set the transmit delay time and number of retries,"
 			" effective when retry is enabled.\n\n"
 
+			"set rxpkts (x[,y]*)\n"
+			"    Set the length of each segment to scatter"
+			" packets on receiving if split feature is engaged."
+			" Affects only the queues configured with split"
+			" offloads.\n\n"
+
 			"set txpkts (x[,y]*)\n"
 			"    Set the length of each segment of TXONLY"
 			" and optionally CSUM packets.\n\n"
@@ -3880,6 +3886,52 @@ struct cmd_set_log_result {
 	},
 };
 
+/* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
+
+struct cmd_set_rxpkts_result {
+	cmdline_fixed_string_t cmd_keyword;
+	cmdline_fixed_string_t rxpkts;
+	cmdline_fixed_string_t seg_lengths;
+};
+
+static void
+cmd_set_rxpkts_parsed(void *parsed_result,
+		      __rte_unused struct cmdline *cl,
+		      __rte_unused void *data)
+{
+	struct cmd_set_rxpkts_result *res;
+	unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+	unsigned int nb_segs;
+
+	res = parsed_result;
+	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
+				  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
+	if (nb_segs > 0)
+		set_rx_pkt_segments(seg_lengths, nb_segs);
+}
+
+cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 cmd_keyword, "set");
+cmdline_parse_token_string_t cmd_set_rxpkts_name =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 rxpkts, "rxpkts");
+cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 seg_lengths, NULL);
+
+cmdline_parse_inst_t cmd_set_rxpkts = {
+	.f = cmd_set_rxpkts_parsed,
+	.data = NULL,
+	.help_str = "set rxpkts <len0[,len1]*>",
+	.tokens = {
+		(void *)&cmd_set_rxpkts_keyword,
+		(void *)&cmd_set_rxpkts_name,
+		(void *)&cmd_set_rxpkts_lengths,
+		NULL,
+	},
+};
+
 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
 
 struct cmd_set_txpkts_result {
@@ -7499,6 +7551,8 @@ static void cmd_showcfg_parsed(void *parsed_result,
 		fwd_lcores_config_display();
 	else if (!strcmp(res->what, "fwd"))
 		pkt_fwd_config_display(&cur_fwd_config);
+	else if (!strcmp(res->what, "rxpkts"))
+		show_rx_pkt_segments();
 	else if (!strcmp(res->what, "txpkts"))
 		show_tx_pkt_segments();
 	else if (!strcmp(res->what, "txtimes"))
@@ -7511,12 +7565,12 @@ static void cmd_showcfg_parsed(void *parsed_result,
 	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#txpkts#txtimes");
+				 "rxtx#cores#fwd#rxpkts#txpkts#txtimes");
 
 cmdline_parse_inst_t cmd_showcfg = {
 	.f = cmd_showcfg_parsed,
 	.data = NULL,
-	.help_str = "show config rxtx|cores|fwd|txpkts|txtimes",
+	.help_str = "show config rxtx|cores|fwd|rxpkts|txpkts|txtimes",
 	.tokens = {
 		(void *)&cmd_showcfg_show,
 		(void *)&cmd_showcfg_port,
@@ -19569,6 +19623,7 @@ struct cmd_showport_macs_result {
 	(cmdline_parse_inst_t *)&cmd_reset,
 	(cmdline_parse_inst_t *)&cmd_set_numbers,
 	(cmdline_parse_inst_t *)&cmd_set_log,
+	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
 	(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 +46 -2

62 lines not on this page · raw message

app/test-pmd/parameters.c +15 -0
index 1f40d73..99f0223 100644
@@ -184,6 +184,7 @@
 	       "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
 	printf("  --no-flush-rx: Don't flush RX streams before forwarding."
 	       " Used mainly with PCAP drivers.\n");
+	printf("  --rxpkts=X[,Y]*: set RX segment sizes 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");
@@ -661,6 +662,7 @@
 		{ "rx-queue-stats-mapping",	1, 0, 0 },
 		{ "no-flush-rx",	0, 0, 0 },
 		{ "flow-isolate-all",	        0, 0, 0 },
+		{ "rxpkts",			1, 0, 0 },
 		{ "txpkts",			1, 0, 0 },
 		{ "txonly-multi-flow",		0, 0, 0 },
 		{ "disable-link-check",		0, 0, 0 },
@@ -1270,6 +1272,19 @@
 						 "invalid RX queue statistics mapping config entered\n");
 				}
 			}
+			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,
+						 seg_len, 0);
+				if (nb_segs > 0)
+					set_rx_pkt_segments(seg_len, 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 +7 -0
index f5060ee..3c88ca7 100644
@@ -210,6 +210,13 @@ struct fwd_engine * fwd_engines[] = {
 uint8_t f_quit;
 
 /*
+ * Configuration of packet segments used to scatter received packets
+ * if some of split features is configured.
+ */
+uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
+
+/*
  * Configuration of packet segments used by the "txonly" processing engine.
  */
 uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN; /**< TXONLY packet length. */
app/test-pmd/testpmd.h +10 -1
index e5cdd12..0576b7c 100644
@@ -420,6 +420,13 @@ struct queue_stats_mappings {
 extern struct rte_fdir_conf fdir_conf;
 
 /*
+ * Configuration of packet segments used to scatter received packets
+ * if some of split features is configured.
+ */
+extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+extern uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
+
+/*
  * Configuration of packet segments used by the "txonly" processing engine.
  */
 #define TXONLY_DEF_PACKET_LEN 64
@@ -815,7 +822,9 @@ void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
 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_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs);
+void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
+void show_rx_pkt_segments(void);
+void set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
 void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
doc/guides/testpmd_app_ug/run_app.rst +9 -0
index 2d5a263..9286281 100644
@@ -361,6 +361,15 @@ The command line options are:
 
     Don't flush the RX streams before starting forwarding. Used mainly with the PCAP PMD.
 
+*   ``--rxpkts=X[,Y]``
+
+    Set the length of segments to scatter packets on receiving if split
+    feature is engaged. Affects only the queues configured
+    with split offloads (currently BUFFER_SPLIT is supported only).
+    Optionally the multiple memory pools can be specified with --mbuf-size
+    command line parameter and the mbufs to receive will be allocated
+    sequentially from these extra memory pools.
+
 *   ``--txpkts=X[,Y]``
 
     Set TX segment sizes or total packet length. Valid for ``tx-only``
doc/guides/testpmd_app_ug/testpmd_funcs.rst +20 -1
index 7f067af..0466920 100644
@@ -273,7 +273,7 @@ show config
 Displays the configuration of the application.
 The configuration comes from the command-line, the runtime or the application defaults::
 
-   testpmd> show config (rxtx|cores|fwd|txpkts|txtimes)
+   testpmd> show config (rxtx|cores|fwd|rxpkts|txpkts|txtimes)
 
 The available information categories are:
 
@@ -283,6 +283,8 @@ The available information categories are:
 
 * ``fwd``: Packet forwarding configuration.
 
+* ``rxpkts``: Packets to RX split configuration.
+
 * ``txpkts``: Packets to TX configuration.
 
 * ``txtimes``: Burst time pattern for Tx only mode.
@@ -760,6 +762,23 @@ When retry is enabled, the transmit delay time and number of retries can also be
 
    testpmd> set burst tx delay (microseconds) retry (num)
 
+set rxpkts
+~~~~~~~~~~
+
+Set the length of segments to scatter packets on receiving if split
+feature is engaged. Affects only the queues configured with split offloads
+(currently BUFFER_SPLIT is supported only). Optionally the multiple memory
+pools can be specified with --mbuf-size command line parameter and the mbufs
+to receive will be allocated sequentially from these extra memory pools (the
+mbuf for the first segment is allocated from the first pool, the second one
+from the second pool, and so on, if segment number is greater then pool's the
+mbuf for remaining segments will be allocated from the last valid pool).
+
+   testpmd> set rxpkts (x[,y]*)
+
+Where x[,y]* represents a CSV list of values, without white space. Zero value
+means to use the corresponding memory pool data buffer size.
+
 set txpkts
 ~~~~~~~~~~
 
Signature · 1 line
1.8.3.1
#30 lore raw

PATCH v2 5/9 app/testpmd: add extended Rx queue setup

In reply to Viacheslav Ovsiienko

If Rx queue is configured with split feature the extended setup with specified segment sizes and pool will be performed.

---
 app/test-pmd/cmdline.c | 12 ++++++------
 app/test-pmd/testpmd.c | 38 ++++++++++++++++++++++++++++++++++++--
 app/test-pmd/testpmd.h |  6 ++++++
 3 files changed, 48 insertions(+), 8 deletions(-)
app/test-pmd/cmdline.c +6 -6
index e0ac76e..1c65499 100644
@@ -2912,12 +2912,12 @@ struct cmd_setup_rxtx_queue {
 				rxring_numa[res->portid]);
 			return;
 		}
-		ret = rte_eth_rx_queue_setup(res->portid,
-					     res->qid,
-					     port->nb_rx_desc[res->qid],
-					     socket_id,
-					     &port->rx_conf[res->qid],
-					     mp);
+		ret = rx_queue_setup(res->portid,
+				     res->qid,
+				     port->nb_rx_desc[res->qid],
+				     socket_id,
+				     &port->rx_conf[res->qid],
+				     mp);
 		if (ret)
 			printf("Failed to setup RX queue\n");
 	} else {
app/test-pmd/testpmd.c +36 -2
index 3c88ca7..cd17cb0 100644
@@ -2412,6 +2412,40 @@ struct extmem_param {
 	return 0;
 }
 
+/* Configure the Rx with optional split. */
+int
+rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+	       uint16_t nb_rx_desc, unsigned int socket_id,
+	       const struct rte_eth_rxconf *rx_conf,
+	       struct rte_mempool *mp)
+{
+	struct rte_eth_rxseg rx_seg[MAX_SEGS_BUFFER_SPLIT] = {};
+	unsigned int i, mp_n;
+
+	if (rx_pkt_nb_segs <= 1 ||
+	    (rx_conf->offloads & DEV_RX_OFFLOAD_BUFFER_SPLIT) == 0)
+		return rte_eth_rx_queue_setup(port_id, rx_queue_id,
+					      nb_rx_desc, socket_id,
+					      rx_conf, mp);
+	for (i = 0; i < rx_pkt_nb_segs; i++) {
+		struct rte_mempool *mpx;
+		/*
+		 * Use last valid pool for the segments with number
+		 * exceeding the pool index.
+		 */
+		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[i].length = rx_pkt_seg_lengths[i] ?
+				   rx_pkt_seg_lengths[i] :
+				   mbuf_data_size[mp_n];
+		rx_seg[i].mp = mpx ? mpx : mp;
+	}
+	return rte_eth_rx_queue_setup_ex(port_id, rx_queue_id,
+					 nb_rx_desc, socket_id, rx_conf,
+					 rx_seg, rx_pkt_nb_segs);
+}
+
 int
 start_port(portid_t pid)
 {
@@ -2520,7 +2554,7 @@ struct extmem_param {
 						return -1;
 					}
 
-					diag = rte_eth_rx_queue_setup(pi, qi,
+					diag = rx_queue_setup(pi, qi,
 					     port->nb_rx_desc[qi],
 					     rxring_numa[pi],
 					     &(port->rx_conf[qi]),
@@ -2536,7 +2570,7 @@ struct extmem_param {
 							port->socket_id);
 						return -1;
 					}
-					diag = rte_eth_rx_queue_setup(pi, qi,
+					diag = rx_queue_setup(pi, qi,
 					     port->nb_rx_desc[qi],
 					     port->socket_id,
 					     &(port->rx_conf[qi]),
app/test-pmd/testpmd.h +6 -0
index 0576b7c..1953c11 100644
@@ -869,6 +869,12 @@ void port_rss_reta_info(portid_t port_id,
 
 void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on);
 
+int
+rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+	       uint16_t nb_rx_desc, unsigned int socket_id,
+	       const struct rte_eth_rxconf *rx_conf,
+	       struct rte_mempool *mp);
+
 int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate);
 int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate,
 				uint64_t q_msk);
Signature · 1 line
1.8.3.1
#31 lore raw

PATCH v2 6/9 net/mlx5: add extended Rx queue setup routine

In reply to Viacheslav Ovsiienko

The routine to provide Rx queue setup with specifying extended receiving buffer description is added. It allows application to specify desired segment lengths, data position offsets in the buffer and dedicated memory pool for each segment.

---
 drivers/net/mlx5/linux/mlx5_os.c |  2 +
 drivers/net/mlx5/mlx5.h          |  3 ++
 drivers/net/mlx5/mlx5_rxq.c      | 91 +++++++++++++++++++++++++++++++++++-----
 drivers/net/mlx5/mlx5_rxtx.h     | 10 ++++-
 4 files changed, 95 insertions(+), 11 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +2 -0
index 81a2e99..11826c3 100644
@@ -2417,6 +2417,7 @@
 	.dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
 	.vlan_filter_set = mlx5_vlan_filter_set,
 	.rx_queue_setup = mlx5_rx_queue_setup,
+	.rx_queue_setup_ex = mlx5_rx_queue_setup_ex,
 	.rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
 	.tx_queue_setup = mlx5_tx_queue_setup,
 	.tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
@@ -2500,6 +2501,7 @@
 	.dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
 	.vlan_filter_set = mlx5_vlan_filter_set,
 	.rx_queue_setup = mlx5_rx_queue_setup,
+	.rx_queue_setup_ex = mlx5_rx_queue_setup_ex,
 	.rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
 	.tx_queue_setup = mlx5_tx_queue_setup,
 	.tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
drivers/net/mlx5/mlx5.h +3 -0
index 0907506..606f6c6 100644
@@ -162,6 +162,9 @@ struct mlx5_stats_ctrl {
 /* Maximal size of aggregated LRO packet. */
 #define MLX5_MAX_LRO_SIZE (UINT8_MAX * MLX5_LRO_SEG_CHUNK_SIZE)
 
+/* Maximal number of segments to split. */
+#define MLX5_MAX_RXQ_NSEG (1u << MLX5_MAX_LOG_RQ_SEGS)
+
 /* LRO configurations structure. */
 struct mlx5_lro_config {
 	uint32_t supported:1; /* Whether LRO is supported. */
drivers/net/mlx5/mlx5_rxq.c +81 -10

144 lines not on this page · raw message

drivers/net/mlx5/mlx5_rxtx.h +9 -1
index 6876c1b..949a0ba 100644
@@ -150,6 +150,9 @@ struct mlx5_rxq_data {
 	rte_spinlock_t *uar_lock_cq;
 	/* CQ (UAR) access lock required for 32bit implementations */
 #endif
+	struct rte_eth_rxseg rxseg[MLX5_MAX_RXQ_NSEG];
+	/* Buffer split segment descriptions - sizes, offsets, pools. */
+	uint32_t rxseg_n; /* Number of split segment descriptions. */
 	uint32_t tunnel; /* Tunnel information. */
 	uint64_t flow_meta_mask;
 	int32_t flow_meta_offset;
@@ -344,6 +347,10 @@ struct mlx5_txq_ctrl {
 int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 			unsigned int socket, const struct rte_eth_rxconf *conf,
 			struct rte_mempool *mp);
+int mlx5_rx_queue_setup_ex
+	(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
+	 unsigned int socket, const struct rte_eth_rxconf *conf,
+	 const struct rte_eth_rxseg *rx_seg, uint16_t n_seg);
 int mlx5_rx_hairpin_queue_setup
 	(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 	 const struct rte_eth_hairpin_conf *hairpin_conf);
@@ -356,7 +363,8 @@ int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx,
 				   uint16_t desc, unsigned int socket,
 				   const struct rte_eth_rxconf *conf,
-				   struct rte_mempool *mp);
+				   const struct rte_eth_rxseg *rx_seg,
+				   uint16_t n_seg);
 struct mlx5_rxq_ctrl *mlx5_rxq_hairpin_new
 	(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 	 const struct rte_eth_hairpin_conf *hairpin_conf);
Signature · 1 line
1.8.3.1
#32 lore raw

PATCH v2 7/9 net/mlx5: configure Rx queue to support split

In reply to Viacheslav Ovsiienko

The scatter-gather elements should be configured accordingly to support the buffer split feature. The application provides the desired settings for the segments at the beginning of the packets and PMD pads the buffer chain (if needed) with attributes of last specified segment to accommodate the packet of maximal length.

There are some limitations are implied. The MPRQ feature should be disengaged if split is requested, due to MPRQ neither supports pushing data to the dedicated pools nor follows the flexible buffer sizes. The vectorized rx_burst routines does not support the scattering (these ones are extremely simplified and work over the single segment only) and can't handle split as well.

---
 drivers/net/mlx5/mlx5_rxq.c | 94 ++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 80 insertions(+), 14 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +80 -14
index 24a247c..44be6df 100644
@@ -1417,7 +1417,8 @@ struct mlx5_rxq_ctrl *
 	uint64_t offloads = conf->offloads |
 			   dev->data->dev_conf.rxmode.offloads;
 	unsigned int lro_on_queue = !!(offloads & DEV_RX_OFFLOAD_TCP_LRO);
-	const int mprq_en = mlx5_check_mprq_support(dev) > 0 && n_seg == 1;
+	const int mprq_en = mlx5_check_mprq_support(dev) > 0 && n_seg == 1 &&
+			    !rx_seg[0].offset && !rx_seg[0].length;
 	unsigned int max_rx_pkt_len = lro_on_queue ?
 			dev->data->dev_conf.rxmode.max_lro_pkt_size :
 			dev->data->dev_conf.rxmode.max_rx_pkt_len;
@@ -1425,22 +1426,87 @@ struct mlx5_rxq_ctrl *
 							RTE_PKTMBUF_HEADROOM;
 	unsigned int max_lro_size = 0;
 	unsigned int first_mb_free_size = mb_len - RTE_PKTMBUF_HEADROOM;
+	const struct rte_eth_rxseg *qs_seg = rx_seg;
+	unsigned int tail_len;
 
-	if (non_scatter_min_mbuf_size > mb_len && !(offloads &
-						    DEV_RX_OFFLOAD_SCATTER)) {
+	tmpl = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, sizeof(*tmpl) +
+			   desc_n * sizeof(struct rte_mbuf *), 0, socket);
+	if (!tmpl) {
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+	MLX5_ASSERT(n_seg && n_seg <= MLX5_MAX_RXQ_NSEG);
+	/*
+	 * Build the array of actual buffer offsets and lengths.
+	 * Pad with the buffers from the last memory pool if
+	 * needed to handle max size packets, replace zero length
+	 * with the buffer length from the pool.
+	 */
+	tail_len = max_rx_pkt_len;
+	do {
+		struct rte_eth_rxseg *hw_seg =
+					&tmpl->rxq.rxseg[tmpl->rxq.rxseg_n];
+		uint32_t buf_len = rte_pktmbuf_data_room_size(qs_seg->mp);
+		uint32_t offset, seg_len;
+
+		/*
+		 * For the buffers beyond descriptions offset is zero,
+		 * the first buffer contains head room.
+		 */
+		offset = (tmpl->rxq.rxseg_n >= n_seg ? 0 : qs_seg->offset) +
+			 (tmpl->rxq.rxseg_n ? 0 : RTE_PKTMBUF_HEADROOM);
+		/*
+		 * For the buffers beyond descriptions the length is
+		 * pool buffer length, zero lengths are replaced with
+		 * pool buffer length either.
+		 */
+		seg_len = tmpl->rxq.rxseg_n >= n_seg ? buf_len :
+			  qs_seg->length ? qs_seg->length : (buf_len - offset);
+		/* Check is done in long int, now overflows. */
+		if (buf_len < seg_len + offset) {
+			DRV_LOG(ERR, "port %u Rx queue %u: Split offset/length "
+				     "%u/%u can't be satisfied",
+				     dev->data->port_id, idx,
+				     qs_seg->length, qs_seg->offset);
+			rte_errno = EINVAL;
+			goto error;
+		}
+		if (seg_len > tail_len)
+			seg_len = buf_len - offset;
+		if (++tmpl->rxq.rxseg_n > MLX5_MAX_RXQ_NSEG) {
+			DRV_LOG(ERR,
+				"port %u too many SGEs (%u) needed to handle"
+				" requested maximum packet size %u, the maximum"
+				" supported are %u", dev->data->port_id,
+				tmpl->rxq.rxseg_n, max_rx_pkt_len,
+				MLX5_MAX_RXQ_NSEG);
+			rte_errno = ENOTSUP;
+			goto error;
+		}
+		/* Build the actual scattering element in the queue object. */
+		hw_seg->mp = qs_seg->mp;
+		MLX5_ASSERT(offset <= UINT16_MAX);
+		MLX5_ASSERT(seg_len <= UINT16_MAX);
+		hw_seg->offset = (uint16_t)offset;
+		hw_seg->length = (uint16_t)seg_len;
+		/*
+		 * Advance the segment descriptor, the padding is the based
+		 * on the atrtributes of the last descriptor.
+		 */
+		if (tmpl->rxq.rxseg_n < n_seg)
+			qs_seg++;
+		tail_len -= RTE_MIN(tail_len, seg_len);
+	} while (tail_len || !rte_is_power_of_2(tmpl->rxq.rxseg_n));
+	MLX5_ASSERT(tmpl->rxq.rxseg_n &&
+		    tmpl->rxq.rxseg_n <= MLX5_MAX_RXQ_NSEG);
+	if (tmpl->rxq.rxseg_n > 1 && !(offloads & DEV_RX_OFFLOAD_SCATTER)) {
 		DRV_LOG(ERR, "port %u Rx queue %u: Scatter offload is not"
 			" configured and no enough mbuf space(%u) to contain "
 			"the maximum RX packet length(%u) with head-room(%u)",
 			dev->data->port_id, idx, mb_len, max_rx_pkt_len,
 			RTE_PKTMBUF_HEADROOM);
 		rte_errno = ENOSPC;
-		return NULL;
-	}
-	tmpl = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, sizeof(*tmpl) +
-			   desc_n * sizeof(struct rte_mbuf *), 0, socket);
-	if (!tmpl) {
-		rte_errno = ENOMEM;
-		return NULL;
+		goto error;
 	}
 	tmpl->type = MLX5_RXQ_TYPE_STANDARD;
 	if (mlx5_mr_btree_init(&tmpl->rxq.mr_ctrl.cache_bh,
@@ -1467,7 +1533,7 @@ struct mlx5_rxq_ctrl *
 	 *  - The number of descs is more than the number of strides.
 	 *  - max_rx_pkt_len plus overhead is less than the max size
 	 *    of a stride or mprq_stride_size is specified by a user.
-	 *    Need to nake sure that there are enough stides to encap
+	 *    Need to make sure that there are enough stides to encap
 	 *    the maximum packet size in case mprq_stride_size is set.
 	 *  Otherwise, enable Rx scatter if necessary.
 	 */
@@ -1497,11 +1563,11 @@ struct mlx5_rxq_ctrl *
 			" strd_num_n = %u, strd_sz_n = %u",
 			dev->data->port_id, idx,
 			tmpl->rxq.strd_num_n, tmpl->rxq.strd_sz_n);
-	} else if (max_rx_pkt_len <= first_mb_free_size) {
+	} else if (tmpl->rxq.rxseg_n == 1) {
+		MLX5_ASSERT(max_rx_pkt_len <= first_mb_free_size);
 		tmpl->rxq.sges_n = 0;
 		max_lro_size = max_rx_pkt_len;
 	} else if (offloads & DEV_RX_OFFLOAD_SCATTER) {
-		unsigned int size = non_scatter_min_mbuf_size;
 		unsigned int sges_n;
 
 		if (lro_on_queue && first_mb_free_size <
@@ -1516,7 +1582,7 @@ struct mlx5_rxq_ctrl *
 		 * Determine the number of SGEs needed for a full packet
 		 * and round it to the next power of two.
 		 */
-		sges_n = log2above((size / mb_len) + !!(size % mb_len));
+		sges_n = log2above(tmpl->rxq.rxseg_n);
 		if (sges_n > MLX5_MAX_LOG_RQ_SEGS) {
 			DRV_LOG(ERR,
 				"port %u too many SGEs (%u) needed to handle"
Signature · 1 line
1.8.3.1
#33 lore raw

PATCH v2 8/9 net/mlx5: register multiple pool for Rx queue

In reply to Viacheslav Ovsiienko

The split feature for receiving packets was added to the mlx5 PMD, now Rx queue can receive the data to the buffers belonging to the different pools and the memory of all the involved pool must be registered for DMA operations in order to allow hardware to store the data.

---
 drivers/net/mlx5/mlx5_mr.c      |  3 +++
 drivers/net/mlx5/mlx5_trigger.c | 20 ++++++++++++--------
 2 files changed, 15 insertions(+), 8 deletions(-)
drivers/net/mlx5/mlx5_mr.c +3 -0
index dbcf0aa..c308ecc 100644
@@ -536,6 +536,9 @@ struct mr_update_mp_data {
 		.ret = 0,
 	};
 
+	DRV_LOG(DEBUG, "Port %u Rx queue registering mp %s "
+		       "having %u chunks.", dev->data->port_id,
+		       mp->name, mp->nb_mem_chunks);
 	rte_mempool_mem_iter(mp, mlx5_mr_update_mp_cb, &data);
 	if (data.ret < 0 && rte_errno == ENXIO) {
 		/* Mempool may have externally allocated memory. */
drivers/net/mlx5/mlx5_trigger.c +12 -8
index 0f4d031..e25a2b7 100644
@@ -123,18 +123,22 @@
 		dev->data->port_id, priv->sh->device_attr.max_sge);
 	for (i = 0; i != priv->rxqs_n; ++i) {
 		struct mlx5_rxq_ctrl *rxq_ctrl = mlx5_rxq_get(dev, i);
-		struct rte_mempool *mp;
 
 		if (!rxq_ctrl)
 			continue;
 		if (rxq_ctrl->type == MLX5_RXQ_TYPE_STANDARD) {
-			/* Pre-register Rx mempool. */
-			mp = mlx5_rxq_mprq_enabled(&rxq_ctrl->rxq) ?
-			     rxq_ctrl->rxq.mprq_mp : rxq_ctrl->rxq.mp;
-			DRV_LOG(DEBUG, "Port %u Rx queue %u registering mp %s"
-				" having %u chunks.", dev->data->port_id,
-				rxq_ctrl->rxq.idx, mp->name, mp->nb_mem_chunks);
-			mlx5_mr_update_mp(dev, &rxq_ctrl->rxq.mr_ctrl, mp);
+			/* Pre-register Rx mempools. */
+			if (mlx5_rxq_mprq_enabled(&rxq_ctrl->rxq)) {
+				mlx5_mr_update_mp(dev, &rxq_ctrl->rxq.mr_ctrl,
+						  rxq_ctrl->rxq.mprq_mp);
+			} else {
+				uint32_t s;
+
+				for (s = 0; s < rxq_ctrl->rxq.rxseg_n; s++)
+					mlx5_mr_update_mp
+						(dev, &rxq_ctrl->rxq.mr_ctrl,
+						rxq_ctrl->rxq.rxseg[s].mp);
+			}
 			ret = rxq_alloc_elts(rxq_ctrl);
 			if (ret)
 				goto error;
Signature · 1 line
1.8.3.1
#34 lore raw

PATCH v2 9/9 net/mlx5: update Rx datapath to support split

In reply to Viacheslav Ovsiienko

Only the regular rx_burst routine is updated to support split, because the vectorized ones does not support scatter and MPRQ does not support split at all.

---
 drivers/net/mlx5/mlx5_rxq.c  | 11 +++++------
 drivers/net/mlx5/mlx5_rxtx.c |  3 ++-
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +5 -6
index 44be6df..5a035cc 100644
@@ -210,9 +210,10 @@
 
 	/* Iterate on segments. */
 	for (i = 0; (i != elts_n); ++i) {
+		struct rte_eth_rxseg *seg = &rxq_ctrl->rxq.rxseg[i % sges_n];
 		struct rte_mbuf *buf;
 
-		buf = rte_pktmbuf_alloc(rxq_ctrl->rxq.mp);
+		buf = rte_pktmbuf_alloc(seg->mp);
 		if (buf == NULL) {
 			DRV_LOG(ERR, "port %u empty mbuf pool",
 				PORT_ID(rxq_ctrl->priv));
@@ -225,12 +226,10 @@
 		MLX5_ASSERT(rte_pktmbuf_data_len(buf) == 0);
 		MLX5_ASSERT(rte_pktmbuf_pkt_len(buf) == 0);
 		MLX5_ASSERT(!buf->next);
-		/* Only the first segment keeps headroom. */
-		if (i % sges_n)
-			SET_DATA_OFF(buf, 0);
+		SET_DATA_OFF(buf, seg->offset);
 		PORT(buf) = rxq_ctrl->rxq.port_id;
-		DATA_LEN(buf) = rte_pktmbuf_tailroom(buf);
-		PKT_LEN(buf) = DATA_LEN(buf);
+		DATA_LEN(buf) = seg->length;
+		PKT_LEN(buf) = seg->length;
 		NB_SEGS(buf) = 1;
 		(*rxq_ctrl->rxq.elts)[i] = buf;
 	}
drivers/net/mlx5/mlx5_rxtx.c +2 -1
index 101555e..ad4da09 100644
@@ -1430,7 +1430,8 @@ enum mlx5_txcmp_code {
 		rte_prefetch0(seg);
 		rte_prefetch0(cqe);
 		rte_prefetch0(wqe);
-		rep = rte_mbuf_raw_alloc(rxq->mp);
+		/* Allocate the buf from the same pool. */
+		rep = rte_mbuf_raw_alloc(seg->pool);
 		if (unlikely(rep == NULL)) {
 			++rxq->stats.rx_nombuf;
 			if (!pkt) {
Signature · 1 line
1.8.3.1
#35 lore raw

v3 cover ethdev: introduce Rx buffer split

In reply to Slava Ovsiienko

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
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 reserved; /* reserved field */
};

The new routine rte_eth_rxseg_queue_setup_ex() is introduced to setup the given Rx queue using the new extended Rx packet segment description:

int
rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)

This routine presents the two new parameters:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf. This array allows to specify the different settings for each segment in individual fashion.
n_seg - number of elements in the array

The new offload flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup_ex() routine application should check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will split the received packets into multiple segments according to the specification in the description array:

- the first network buffer will be allocated from the memory pool, specified in the first segment description element, the second network buffer - from the pool in the second segment description element and so on. If there is no enough elements to describe the buffer for entire packet of maximal length the pool from the last valid element will be used to allocate the buffers from for the rest of segments

- the offsets from the segment description elements will provide the data offset from the buffer beginning except the first mbuf - for this one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual offset from the buffer beginning. If there is no enough elements to describe the buffer for entire packet of maximal length the offsets for the rest of segment will be supposed to be zero.

- the data length being received to each segment is limited by the length specified in the segment description element. The data receiving starts with filling up the first mbuf data buffer, if the specified maximal segment length is reached and there are data remaining (packet is longer than buffer in the first mbuf) the following data will be pushed to the next segment up to its own maximal length. If the first two segments is not enough to store all the packet remaining data the next (third) segment will be engaged and so on. If the length in the segment description element is zero the actual buffer size will be deduced from the appropriate memory pool properties. If there is no enough elements to describe the buffer for entire packet of maximal length the buffer size will be deduced from the pool of the last valid element for the remaining segments.

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B long @ 128 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B @ 128 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload RTE_ETH_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

---
[RFC]: http://patches.dpdk.org/patch/75582/
Related deprecation note (revoked): http://patches.dpdk.org/patch/75205/

v1: http://patches.dpdk.org/patch/79594/
v2: http://patches.dpdk.org/patch/79893/
- add feature support to mlx5 PMD

v3: - rte_eth_rx_queue_setup_ex is renamed to rte_eth_rxseg_queue_setup
- DEV_RX_OFFLOAD_BUFFER_SPLIT is renamed to RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT
- commit message update
- documentaion provided
- release notes update

Viacheslav Ovsiienko (9):
ethdev: introduce Rx buffer split app/testpmd: add multiple pools per core creation app/testpmd: add buffer split offload configuration app/testpmd: add rxpkts commands and parameters app/testpmd: add extended Rx queue setup net/mlx5: add extended Rx queue setup routine net/mlx5: configure Rx queue to support split net/mlx5: register multiple pool for Rx queue net/mlx5: update Rx datapath to support split

 app/test-pmd/bpf_cmd.c                      |   4 +-
 app/test-pmd/cmdline.c                      |  96 +++++++++++---
 app/test-pmd/config.c                       |  63 ++++++++-
 app/test-pmd/parameters.c                   |  39 +++++-
 app/test-pmd/testpmd.c                      | 108 +++++++++++-----
 app/test-pmd/testpmd.h                      |  41 +++++-
 doc/guides/nics/features.rst                |  15 +++
 doc/guides/rel_notes/release_20_11.rst      |   6 +
 doc/guides/testpmd_app_ug/run_app.rst       |  16 ++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  21 ++-
 drivers/net/mlx5/linux/mlx5_os.c            |   2 +
 drivers/net/mlx5/mlx5.h                     |   3 +
 drivers/net/mlx5/mlx5_mr.c                  |   3 +
 drivers/net/mlx5/mlx5_rxq.c                 | 194 +++++++++++++++++++++++-----
 drivers/net/mlx5/mlx5_rxtx.c                |   3 +-
 drivers/net/mlx5/mlx5_rxtx.h                |  10 +-
 drivers/net/mlx5/mlx5_trigger.c             |  20 +--
 lib/librte_ethdev/rte_ethdev.c              | 178 +++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h              | 107 +++++++++++++++
 lib/librte_ethdev/rte_ethdev_driver.h       |  10 ++
 lib/librte_ethdev/rte_ethdev_version.map    |   1 +
 21 files changed, 829 insertions(+), 111 deletions(-)
Signature · 1 line
1.8.3.1
#36 lore raw

PATCH v3 1/9 ethdev: introduce Rx buffer split

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
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 reserved; /* reserved field */
};

The new routine rte_eth_rxseg_queue_setup_ex() is introduced to setup the given Rx queue using the new extended Rx packet segment description:

int
rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)

This routine presents the two new parameters:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf. This array allows to specify the different settings for each segment in individual fashion.
n_seg - number of elements in the array

The new offload flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup_ex() routine application should check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will split the received packets into multiple segments according to the specification in the description array:

- the first network buffer will be allocated from the memory pool, specified in the first segment description element, the second network buffer - from the pool in the second segment description element and so on. If there is no enough elements to describe the buffer for entire packet of maximal length the pool from the last valid element will be used to allocate the buffers from for the rest of segments

- the offsets from the segment description elements will provide the data offset from the buffer beginning except the first mbuf - for this one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual offset from the buffer beginning. If there is no enough elements to describe the buffer for entire packet of maximal length the offsets for the rest of segment will be supposed to be zero.

- the data length being received to each segment is limited by the length specified in the segment description element. The data receiving starts with filling up the first mbuf data buffer, if the specified maximal segment length is reached and there are data remaining (packet is longer than buffer in the first mbuf) the following data will be pushed to the next segment up to its own maximal length. If the first two segments is not enough to store all the packet remaining data the next (third) segment will be engaged and so on. If the length in the segment description element is zero the actual buffer size will be deduced from the appropriate memory pool properties. If there is no enough elements to describe the buffer for entire packet of maximal length the buffer size will be deduced from the pool of the last valid element for the remaining segments.

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B long @ 128 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B @ 128 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload RTE_ETH_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

---
 doc/guides/nics/features.rst             |  15 +++
 doc/guides/rel_notes/release_20_11.rst   |   6 ++
 lib/librte_ethdev/rte_ethdev.c           | 178 +++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 107 +++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_driver.h    |  10 ++
 lib/librte_ethdev/rte_ethdev_version.map |   1 +
 6 files changed, 317 insertions(+)
doc/guides/nics/features.rst +15 -0
index dd8c955..21b91db 100644
@@ -185,6 +185,21 @@ Supports receiving segmented mbufs.
 * **[related]    eth_dev_ops**: ``rx_pkt_burst``.
 
 
+.. _nic_features_buffer_split:
+
+Buffer Split on Rx
+------------
+
+Scatters the packets being received on specified boundaries to segmented mbufs.
+
+* **[uses]       rte_eth_rxconf,rte_eth_rxmode**: ``offloads:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[implements] datapath**: ``Buffer Split functionality``.
+* **[implements] rte_eth_dev_data**: ``buffer_split``.
+* **[provides]   rte_eth_dev_info**: ``rx_offload_capa:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[provides]   eth_dev_ops**: ``rxq_info_get:buffer_split``.
+* **[related] API**: ``rte_eth_rxseg_queue_setup()``.
+
+
 .. _nic_features_lro:
 
 LRO
doc/guides/rel_notes/release_20_11.rst +6 -0
index 2cec9dd..d87247a 100644
@@ -60,6 +60,12 @@ New Features
   Added the FEC API which provides functions for query FEC capabilities and
   current FEC mode from device. Also, API for configuring FEC mode is also provided.
 
+* **Introduced extended buffer description for receiving.**
+
+  Added the extended Rx queue setup routine providing the individual
+  descriptions for each Rx segment with maximal size, buffer offset and memory
+  pool to allocate data buffers from.
+
 * **Updated Broadcom bnxt driver.**
 
   Updated the Broadcom bnxt driver with new features and improvements, including:
lib/librte_ethdev/rte_ethdev.c +178 -0

199 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +107 -0

125 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_driver.h +10 -0
index 35cc4fb..5dee210 100644
@@ -264,6 +264,15 @@ typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
 				    struct rte_mempool *mb_pool);
 /**< @internal Set up a receive queue of an Ethernet device. */
 
+typedef int (*eth_rxseg_queue_setup_t)(struct rte_eth_dev *dev,
+				       uint16_t rx_queue_id,
+				       uint16_t nb_rx_desc,
+				       unsigned int socket_id,
+				       const struct rte_eth_rxconf *rx_conf,
+				       const struct rte_eth_rxseg *rx_seg,
+				       uint16_t n_seg);
+/**< @internal extended Set up a receive queue of an Ethernet device. */
+
 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
 				    uint16_t tx_queue_id,
 				    uint16_t nb_tx_desc,
@@ -711,6 +720,7 @@ struct eth_dev_ops {
 	eth_queue_start_t          tx_queue_start;/**< Start TX for a queue. */
 	eth_queue_stop_t           tx_queue_stop; /**< Stop TX for a queue. */
 	eth_rx_queue_setup_t       rx_queue_setup;/**< Set up device RX queue. */
+	eth_rxseg_queue_setup_t    rxseg_queue_setup;/**< Extended RX setup. */
 	eth_queue_release_t        rx_queue_release; /**< Release RX queue. */
 
 	eth_rx_enable_intr_t       rx_queue_intr_enable;  /**< Enable Rx queue interrupt. */
lib/librte_ethdev/rte_ethdev_version.map +1 -0
index f8a0945..d4b9849 100644
@@ -195,6 +195,7 @@ EXPERIMENTAL {
 	rte_flow_get_aged_flows;
 
 	# Marked as experimental in 20.11
+	rte_eth_rxseg_queue_setup;
 	rte_tm_capabilities_get;
 	rte_tm_get_number_of_leaf_nodes;
 	rte_tm_hierarchy_commit;
Signature · 1 line
1.8.3.1
#37 lore raw
Quoted 202 lines · Viacheslav Ovsiienko

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
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 reserved; /* reserved field */
};

The new routine rte_eth_rxseg_queue_setup_ex() is introduced to setup the given Rx queue using the new extended Rx packet segment description:

int
rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)

This routine presents the two new parameters:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf. This array allows to specify the different settings for each segment in individual fashion.
n_seg - number of elements in the array

The new offload flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup_ex() routine application should check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will split the received packets into multiple segments according to the specification in the description array:

- the first network buffer will be allocated from the memory pool, specified in the first segment description element, the second network buffer - from the pool in the second segment description element and so on. If there is no enough elements to describe the buffer for entire packet of maximal length the pool from the last valid element will be used to allocate the buffers from for the rest of segments

- the offsets from the segment description elements will provide the data offset from the buffer beginning except the first mbuf - for this one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual offset from the buffer beginning. If there is no enough elements to describe the buffer for entire packet of maximal length the offsets for the rest of segment will be supposed to be zero.

- the data length being received to each segment is limited by the length specified in the segment description element. The data receiving starts with filling up the first mbuf data buffer, if the specified maximal segment length is reached and there are data remaining (packet is longer than buffer in the first mbuf) the following data will be pushed to the next segment up to its own maximal length. If the first two segments is not enough to store all the packet remaining data the next (third) segment will be engaged and so on. If the length in the segment description element is zero the actual buffer size will be deduced from the appropriate memory pool properties. If there is no enough elements to describe the buffer for entire packet of maximal length the buffer size will be deduced from the pool of the last valid element for the remaining segments.

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B long @ 128 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B @ 128 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload RTE_ETH_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

---
 doc/guides/nics/features.rst             |  15 +++
 doc/guides/rel_notes/release_20_11.rst   |   6 ++
 lib/librte_ethdev/rte_ethdev.c           | 178 +++++++++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 107 +++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_driver.h    |  10 ++
 lib/librte_ethdev/rte_ethdev_version.map |   1 +
 6 files changed, 317 insertions(+)
doc/guides/nics/features.rst +15 -0
index dd8c955..21b91db 100644
@@ -185,6 +185,21 @@ Supports receiving segmented mbufs.
 * **[related]    eth_dev_ops**: ``rx_pkt_burst``.
 
 
+.. _nic_features_buffer_split:
+
+Buffer Split on Rx
+------------
+
+Scatters the packets being received on specified boundaries to segmented mbufs.
+
+* **[uses]       rte_eth_rxconf,rte_eth_rxmode**: ``offloads:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[implements] datapath**: ``Buffer Split functionality``.
+* **[implements] rte_eth_dev_data**: ``buffer_split``.
+* **[provides]   rte_eth_dev_info**: ``rx_offload_capa:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[provides]   eth_dev_ops**: ``rxq_info_get:buffer_split``.
+* **[related] API**: ``rte_eth_rxseg_queue_setup()``.
+
+
 .. _nic_features_lro:
 
 LRO
doc/guides/rel_notes/release_20_11.rst +6 -0
index 2cec9dd..d87247a 100644
@@ -60,6 +60,12 @@ New Features
   Added the FEC API which provides functions for query FEC capabilities and
   current FEC mode from device. Also, API for configuring FEC mode is also provided.
 
+* **Introduced extended buffer description for receiving.**
+
+  Added the extended Rx queue setup routine providing the individual
+  descriptions for each Rx segment with maximal size, buffer offset and memory
+  pool to allocate data buffers from.
+
 * **Updated Broadcom bnxt driver.**
 
   Updated the Broadcom bnxt driver with new features and improvements, including:
lib/librte_ethdev/rte_ethdev.c +5 -0
index 59beb8a..3a55567 100644
@@ -105,6 +105,9 @@ struct rte_eth_xstats_name_off {
 #define RTE_RX_OFFLOAD_BIT2STR(_name)	\
 	{ DEV_RX_OFFLOAD_##_name, #_name }
 
+#define RTE_ETH_RX_OFFLOAD_BIT2STR(_name)	\
+	{ RTE_ETH_RX_OFFLOAD_##_name, #_name }
+
 static const struct {
 	uint64_t offload;
 	const char *name;
@@ -128,9 +131,11 @@ struct rte_eth_xstats_name_off {
 	RTE_RX_OFFLOAD_BIT2STR(SCTP_CKSUM),
 	RTE_RX_OFFLOAD_BIT2STR(OUTER_UDP_CKSUM),
 	RTE_RX_OFFLOAD_BIT2STR(RSS_HASH),
+	RTE_ETH_RX_OFFLOAD_BIT2STR(BUFFER_SPLIT),
 };
 
 #undef RTE_RX_OFFLOAD_BIT2STR
+#undef RTE_ETH_RX_OFFLOAD_BIT2STR
 
 #define RTE_TX_OFFLOAD_BIT2STR(_name)	\
 	{ DEV_TX_OFFLOAD_##_name, #_name }
@@ -1920,6 +1925,179 @@ struct rte_eth_dev *
 }

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1935

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
 
 int
+rte_eth_rxseg_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+			  uint16_t nb_rx_desc, unsigned int socket_id,
+			  const struct rte_eth_rxconf *rx_conf,
+			  const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)
+{
+	int ret;
+	uint16_t seg_idx;
+	uint32_t mbp_buf_size;

<start-of-dup>

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1947

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +12 -0
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info;
+	struct rte_eth_rxconf local_conf;
+	void **rxq;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+
+	dev = &rte_eth_devices[port_id];
+	if (rx_queue_id >= dev->data->nb_rx_queues) {
+		RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", rx_queue_id);
+		return -EINVAL;
+	}

<end-of-dup>

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1960

Quoted 13 lines
lib/librte_ethdev/rte_ethdev.c +13 -0
+
+	if (rx_seg == NULL) {
+		RTE_ETHDEV_LOG(ERR, "Invalid null description pointer\n");
+		return -EINVAL;
+	}
+
+	if (n_seg == 0) {
+		RTE_ETHDEV_LOG(ERR, "Invalid zero description number\n");
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rxseg_queue_setup, -ENOTSUP);
+

<start-of-dup>

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1968

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+	/*
+	 * Check the size of the mbuf data buffer.
+	 * This value must be provided in the private data of the memory pool.
+	 * First check that the memory pool has a valid private data.
+	 */
+	ret = rte_eth_dev_info_get(port_id, &dev_info);
+	if (ret != 0)
+		return ret;

<end-of-dup>

Quoted 19 lines
lib/librte_ethdev/rte_ethdev.c +19 -0
+
+	for (seg_idx = 0; seg_idx < n_seg; seg_idx++) {
+		struct rte_mempool *mp = rx_seg[seg_idx].mp;
+
+		if (mp->private_data_size <
+				sizeof(struct rte_pktmbuf_pool_private)) {
+			RTE_ETHDEV_LOG(ERR, "%s private_data_size %d < %d\n",
+				mp->name, (int)mp->private_data_size,
+				(int)sizeof(struct rte_pktmbuf_pool_private));
+			return -ENOSPC;
+		}
+
+		mbp_buf_size = rte_pktmbuf_data_room_size(mp);
+		if (mbp_buf_size < rx_seg[seg_idx].length +
+				   rx_seg[seg_idx].offset +
+				   (seg_idx ? 0 :
+				    (uint32_t)RTE_PKTMBUF_HEADROOM)) {
+			RTE_ETHDEV_LOG(ERR,
+				"%s mbuf_data_room_size %d < %d"

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1997

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+				" (segment length=%d + segment offset=%d)\n",
+				mp->name, (int)mbp_buf_size,
+				(int)(rx_seg[seg_idx].length +
+				      rx_seg[seg_idx].offset),
+				(int)rx_seg[seg_idx].length,
+				(int)rx_seg[seg_idx].offset);
+			return -EINVAL;
+		}
+	}
+

<start-of-huge-dup>

Quoted 79 lines
lib/librte_ethdev/rte_ethdev.c +79 -0
+	/* Use default specified by driver, if nb_rx_desc is zero */
+	if (nb_rx_desc == 0) {
+		nb_rx_desc = dev_info.default_rxportconf.ring_size;
+		/* If driver default is also zero, fall back on EAL default */
+		if (nb_rx_desc == 0)
+			nb_rx_desc = RTE_ETH_DEV_FALLBACK_RX_RINGSIZE;
+	}
+
+	if (nb_rx_desc > dev_info.rx_desc_lim.nb_max ||
+			nb_rx_desc < dev_info.rx_desc_lim.nb_min ||
+			nb_rx_desc % dev_info.rx_desc_lim.nb_align != 0) {
+
+		RTE_ETHDEV_LOG(ERR,
+			"Invalid value for nb_rx_desc(=%hu), should be: "
+			"<= %hu, >= %hu, and a product of %hu\n",
+			nb_rx_desc, dev_info.rx_desc_lim.nb_max,
+			dev_info.rx_desc_lim.nb_min,
+			dev_info.rx_desc_lim.nb_align);
+		return -EINVAL;
+	}
+
+	if (dev->data->dev_started &&
+		!(dev_info.dev_capa &
+			RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP))
+		return -EBUSY;
+
+	if (dev->data->dev_started &&
+		(dev->data->rx_queue_state[rx_queue_id] !=
+			RTE_ETH_QUEUE_STATE_STOPPED))
+		return -EBUSY;
+
+	rxq = dev->data->rx_queues;
+	if (rxq[rx_queue_id]) {
+		RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release,
+					-ENOTSUP);
+		(*dev->dev_ops->rx_queue_release)(rxq[rx_queue_id]);
+		rxq[rx_queue_id] = NULL;
+	}
+
+	if (rx_conf == NULL)
+		rx_conf = &dev_info.default_rxconf;
+
+	local_conf = *rx_conf;
+
+	/*
+	 * If an offloading has already been enabled in
+	 * rte_eth_dev_configure(), it has been enabled on all queues,
+	 * so there is no need to enable it in this queue again.
+	 * The local_conf.offloads input to underlying PMD only carries
+	 * those offloadings which are only enabled on this queue and
+	 * not enabled on all queues.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;
+
+	/*
+	 * New added offloadings for this queue are those not enabled in
+	 * rte_eth_dev_configure() and they must be per-queue type.
+	 * A pure per-port offloading can't be enabled on a queue while
+	 * disabled on another queue. A pure per-port offloading can't
+	 * be enabled for any queue as new added one if it hasn't been
+	 * enabled in rte_eth_dev_configure().
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_ETHDEV_LOG(ERR,
+			"Ethdev port_id=%d rx_queue_id=%d, new added offloads"
+			" 0x%"PRIx64" must be within per-queue offload"
+			" capabilities 0x%"PRIx64" in %s()\n",
+			port_id, rx_queue_id, local_conf.offloads,
+			dev_info.rx_queue_offload_capa,
+			__func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * If LRO is enabled, check that the maximum aggregated packet
+	 * size is supported by the configured device.
+	 */
+	if (local_conf.offloads & DEV_RX_OFFLOAD_TCP_LRO) {

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2086

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+		if (dev->data->dev_conf.rxmode.max_lro_pkt_size == 0)
+			dev->data->dev_conf.rxmode.max_lro_pkt_size =
+				dev->data->dev_conf.rxmode.max_rx_pkt_len;
+		int ret = check_lro_pkt_size(port_id,
+				dev->data->dev_conf.rxmode.max_lro_pkt_size,
+				dev->data->dev_conf.rxmode.max_rx_pkt_len,
+				dev_info.max_lro_pkt_size);
+		if (ret != 0)
+			return ret;
+	}

<end-of-huge-dup>

IMO It is not acceptable to duplication so much code. It is simply unmaintainable.

NACK

Quoted 190 lines
lib/librte_ethdev/rte_ethdev.c +14 -0
+
+	ret = (*dev->dev_ops->rxseg_queue_setup)(dev, rx_queue_id, nb_rx_desc,
+						 socket_id, &local_conf,
+						 rx_seg, n_seg);
+	if (!ret) {
+		if (!dev->data->min_rx_buf_size ||
+		    dev->data->min_rx_buf_size > mbp_buf_size)
+			dev->data->min_rx_buf_size = mbp_buf_size;
+	}
+
+	return eth_err(port_id, ret);
+}
+
+int
 rte_eth_rx_hairpin_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 			       uint16_t nb_rx_desc,
 			       const struct rte_eth_hairpin_conf *conf)
lib/librte_ethdev/rte_ethdev.h +107 -0
index 3a31f94..bbf25c8 100644
@@ -970,6 +970,16 @@ struct rte_eth_txmode {
 };
 
 /**
+ * A structure used to configure an RX packet segment to split.
+ */
+struct rte_eth_rxseg {
+	struct rte_mempool *mp; /**< Memory pools 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 */
+};
+
+/**
  * A structure used to configure an RX ring of an Ethernet port.
  */
 struct rte_eth_rxconf {
@@ -1260,6 +1270,7 @@ struct rte_eth_conf {
 #define DEV_RX_OFFLOAD_SCTP_CKSUM	0x00020000
 #define DEV_RX_OFFLOAD_OUTER_UDP_CKSUM  0x00040000
 #define DEV_RX_OFFLOAD_RSS_HASH		0x00080000
+#define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT 0x00100000
 
 #define DEV_RX_OFFLOAD_CHECKSUM (DEV_RX_OFFLOAD_IPV4_CKSUM | \
 				 DEV_RX_OFFLOAD_UDP_CKSUM | \
@@ -2037,6 +2048,102 @@ int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		uint16_t nb_rx_desc, unsigned int socket_id,
 		const struct rte_eth_rxconf *rx_conf,
 		struct rte_mempool *mb_pool);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Allocate and set up a receive queue for an Ethernet device
+ * with specifying receiving segments parameters.
+ *
+ * The function allocates a contiguous block of memory for *nb_rx_desc*
+ * receive descriptors from a memory zone associated with *socket_id*.
+ * The descriptors might be divided into groups by PMD to receive the data
+ * into multi-segment packet presented by the chain of mbufs.
+ *
+ * Each descriptor within the group is initialized accordingly with
+ * the network buffers allocated from the specified memory pool and with
+ * specified buffer offset and maximal segment length.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param rx_queue_id
+ *   The index of the receive queue to set up.
+ *   The value must be in the range [0, nb_rx_queue - 1] previously supplied
+ *   to rte_eth_dev_configure().
+ * @param nb_rx_desc
+ *   The number of receive descriptors to allocate for the receive ring.
+ * @param socket_id
+ *   The *socket_id* argument is the socket identifier in case of NUMA.
+ *   The value can be *SOCKET_ID_ANY* if there is no NUMA constraint for
+ *   the DMA memory allocated for the receive descriptors of the ring.
+ * @param rx_conf
+ *   The pointer to the configuration data to be used for the receive queue.
+ *   NULL value is allowed, in which case default RX configuration
+ *   will be used.
+ *   The *rx_conf* structure contains an *rx_thresh* structure with the values
+ *   of the Prefetch, Host, and Write-Back threshold registers of the receive
+ *   ring.
+ *   In addition it contains the hardware offloads features to activate using
+ *   the DEV_RX_OFFLOAD_* flags.
+ *   If an offloading set in rx_conf->offloads
+ *   hasn't been set in the input argument eth_conf->rxmode.offloads
+ *   to rte_eth_dev_configure(), it is a new added offloading, it must be
+ *   per-queue type and it is enabled for the queue.
+ *   No need to repeat any bit in rx_conf->offloads which has already been
+ *   enabled in rte_eth_dev_configure() at port level. An offloading enabled
+ *   at port level can't be disabled at queue level.
+ * @param rx_seg
+ *   The pointer to the array of segment descriptions, each element describes
+ *   the memory pool, maximal segment data length, initial data offset from
+ *   the beginning of data buffer in mbuf. This allow to specify the dedicated
+ *   properties for each segment in the receiving buffer - pool, buffer
+ *   offset, maximal segment size. If RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload
+ *   flag is configured the PMD will split the received packets into multiple
+ *   segments according to the specification in the description array:
+ *   - the first network buffer will be allocated from the memory pool,
+ *     specified in the first segment description element, the second
+ *     network buffer - from the pool in the second segment description
+ *     element and so on. If there is no enough elements to describe
+ *     the buffer for entire packet of maximal length the pool from the last
+ *     valid element will be used to allocate the buffers from for the rest
+ *     of segments.
+ *   - the offsets from the segment description elements will provide the
+ *     data offset from the buffer beginning except the first mbuf - for this
+ *     one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual
+ *     offset from the buffer beginning. If there is no enough elements
+ *     to describe the buffer for entire packet of maximal length the offsets
+ *     for the rest of segment will be supposed to be zero.
+ *   - the data length being received to each segment is limited by the
+ *     length specified in the segment description element. The data receiving
+ *     starts with filling up the first mbuf data buffer, if the specified
+ *     maximal segment length is reached and there are data remaining
+ *     (packet is longer than buffer in the first mbuf) the following data
+ *     will be pushed to the next segment up to its own length. If the first
+ *     two segments is not enough to store all the packet data the next
+ *     (third) segment will be engaged and so on. If the length in the segment
+ *     description element is zero the actual buffer size will be deduced
+ *     from the appropriate memory pool properties. If there is no enough
+ *     elements to describe the buffer for entire packet of maximal length
+ *     the buffer size will be deduced from the pool of the last valid
+ *     element for the all remaining segments.
+ * @param n_seg
+ *   The number of elements in the segment description array.
+ * @return
+ *   - 0: Success, receive queue correctly set up.
+ *   - -EIO: if device is removed.
+ *   - -EINVAL: The segment descriptors array is empty (pointer to is null or
+ *      zero number of elements) or the size of network buffers which can be
+ *      allocated from this memory pool does not fit the various buffer sizes
+ *      allowed by the device controller.
+ *   - -ENOMEM: Unable to allocate the receive ring descriptors or to
+ *      allocate network memory buffers from the memory pool when
+ *      initializing receive descriptors.
+ */
+__rte_experimental
+int rte_eth_rxseg_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+		uint16_t nb_rx_desc, unsigned int socket_id,
+		const struct rte_eth_rxconf *rx_conf,
+		const struct rte_eth_rxseg *rx_seg, uint16_t n_seg);
 
 /**
  * @warning
lib/librte_ethdev/rte_ethdev_driver.h +10 -0
index 35cc4fb..5dee210 100644
@@ -264,6 +264,15 @@ typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
 				    struct rte_mempool *mb_pool);
 /**< @internal Set up a receive queue of an Ethernet device. */
 
+typedef int (*eth_rxseg_queue_setup_t)(struct rte_eth_dev *dev,
+				       uint16_t rx_queue_id,
+				       uint16_t nb_rx_desc,
+				       unsigned int socket_id,
+				       const struct rte_eth_rxconf *rx_conf,
+				       const struct rte_eth_rxseg *rx_seg,
+				       uint16_t n_seg);
+/**< @internal extended Set up a receive queue of an Ethernet device. */
+
 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
 				    uint16_t tx_queue_id,
 				    uint16_t nb_tx_desc,
@@ -711,6 +720,7 @@ struct eth_dev_ops {
 	eth_queue_start_t          tx_queue_start;/**< Start TX for a queue. */
 	eth_queue_stop_t           tx_queue_stop; /**< Stop TX for a queue. */
 	eth_rx_queue_setup_t       rx_queue_setup;/**< Set up device RX queue. */
+	eth_rxseg_queue_setup_t    rxseg_queue_setup;/**< Extended RX setup. */
 	eth_queue_release_t        rx_queue_release; /**< Release RX queue. */
 
 	eth_rx_enable_intr_t       rx_queue_intr_enable;  /**< Enable Rx queue interrupt. */
lib/librte_ethdev/rte_ethdev_version.map +1 -0
index f8a0945..d4b9849 100644
@@ -195,6 +195,7 @@ EXPERIMENTAL {
 	rte_flow_get_aged_flows;
 
 	# Marked as experimental in 20.11
+	rte_eth_rxseg_queue_setup;
 	rte_tm_capabilities_get;
 	rte_tm_get_number_of_leaf_nodes;
 	rte_tm_hierarchy_commit;
#38 lore raw

12/10/2020 18:38, Andrew Rybchenko:

Quoted 179 lines · Viacheslav Ovsiienko

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1935

Quoted 9 lines

int

lib/librte_ethdev/rte_ethdev.c +8 -0
+rte_eth_rxseg_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+			  uint16_t nb_rx_desc, unsigned int socket_id,
+			  const struct rte_eth_rxconf *rx_conf,
+			  const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)
+{
+	int ret;
+	uint16_t seg_idx;
+	uint32_t mbp_buf_size;

<start-of-dup>

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1947

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +12 -0
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info;
+	struct rte_eth_rxconf local_conf;
+	void **rxq;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+
+	dev = &rte_eth_devices[port_id];
+	if (rx_queue_id >= dev->data->nb_rx_queues) {
+		RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", rx_queue_id);
+		return -EINVAL;
+	}

<end-of-dup>

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1960

Quoted 13 lines
lib/librte_ethdev/rte_ethdev.c +13 -0
+
+	if (rx_seg == NULL) {
+		RTE_ETHDEV_LOG(ERR, "Invalid null description pointer\n");
+		return -EINVAL;
+	}
+
+	if (n_seg == 0) {
+		RTE_ETHDEV_LOG(ERR, "Invalid zero description number\n");
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rxseg_queue_setup, -ENOTSUP);
+

<start-of-dup>

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1968

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+	/*
+	 * Check the size of the mbuf data buffer.
+	 * This value must be provided in the private data of the memory pool.
+	 * First check that the memory pool has a valid private data.
+	 */
+	ret = rte_eth_dev_info_get(port_id, &dev_info);
+	if (ret != 0)
+		return ret;

<end-of-dup>

Quoted 19 lines
lib/librte_ethdev/rte_ethdev.c +19 -0
+
+	for (seg_idx = 0; seg_idx < n_seg; seg_idx++) {
+		struct rte_mempool *mp = rx_seg[seg_idx].mp;
+
+		if (mp->private_data_size <
+				sizeof(struct rte_pktmbuf_pool_private)) {
+			RTE_ETHDEV_LOG(ERR, "%s private_data_size %d < %d\n",
+				mp->name, (int)mp->private_data_size,
+				(int)sizeof(struct rte_pktmbuf_pool_private));
+			return -ENOSPC;
+		}
+
+		mbp_buf_size = rte_pktmbuf_data_room_size(mp);
+		if (mbp_buf_size < rx_seg[seg_idx].length +
+				   rx_seg[seg_idx].offset +
+				   (seg_idx ? 0 :
+				    (uint32_t)RTE_PKTMBUF_HEADROOM)) {
+			RTE_ETHDEV_LOG(ERR,
+				"%s mbuf_data_room_size %d < %d"

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1997

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+				" (segment length=%d + segment offset=%d)\n",
+				mp->name, (int)mbp_buf_size,
+				(int)(rx_seg[seg_idx].length +
+				      rx_seg[seg_idx].offset),
+				(int)rx_seg[seg_idx].length,
+				(int)rx_seg[seg_idx].offset);
+			return -EINVAL;
+		}
+	}
+

<start-of-huge-dup>

Quoted 79 lines
lib/librte_ethdev/rte_ethdev.c +79 -0
+	/* Use default specified by driver, if nb_rx_desc is zero */
+	if (nb_rx_desc == 0) {
+		nb_rx_desc = dev_info.default_rxportconf.ring_size;
+		/* If driver default is also zero, fall back on EAL default */
+		if (nb_rx_desc == 0)
+			nb_rx_desc = RTE_ETH_DEV_FALLBACK_RX_RINGSIZE;
+	}
+
+	if (nb_rx_desc > dev_info.rx_desc_lim.nb_max ||
+			nb_rx_desc < dev_info.rx_desc_lim.nb_min ||
+			nb_rx_desc % dev_info.rx_desc_lim.nb_align != 0) {
+
+		RTE_ETHDEV_LOG(ERR,
+			"Invalid value for nb_rx_desc(=%hu), should be: "
+			"<= %hu, >= %hu, and a product of %hu\n",
+			nb_rx_desc, dev_info.rx_desc_lim.nb_max,
+			dev_info.rx_desc_lim.nb_min,
+			dev_info.rx_desc_lim.nb_align);
+		return -EINVAL;
+	}
+
+	if (dev->data->dev_started &&
+		!(dev_info.dev_capa &
+			RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP))
+		return -EBUSY;
+
+	if (dev->data->dev_started &&
+		(dev->data->rx_queue_state[rx_queue_id] !=
+			RTE_ETH_QUEUE_STATE_STOPPED))
+		return -EBUSY;
+
+	rxq = dev->data->rx_queues;
+	if (rxq[rx_queue_id]) {
+		RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release,
+					-ENOTSUP);
+		(*dev->dev_ops->rx_queue_release)(rxq[rx_queue_id]);
+		rxq[rx_queue_id] = NULL;
+	}
+
+	if (rx_conf == NULL)
+		rx_conf = &dev_info.default_rxconf;
+
+	local_conf = *rx_conf;
+
+	/*
+	 * If an offloading has already been enabled in
+	 * rte_eth_dev_configure(), it has been enabled on all queues,
+	 * so there is no need to enable it in this queue again.
+	 * The local_conf.offloads input to underlying PMD only carries
+	 * those offloadings which are only enabled on this queue and
+	 * not enabled on all queues.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;
+
+	/*
+	 * New added offloadings for this queue are those not enabled in
+	 * rte_eth_dev_configure() and they must be per-queue type.
+	 * A pure per-port offloading can't be enabled on a queue while
+	 * disabled on another queue. A pure per-port offloading can't
+	 * be enabled for any queue as new added one if it hasn't been
+	 * enabled in rte_eth_dev_configure().
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_ETHDEV_LOG(ERR,
+			"Ethdev port_id=%d rx_queue_id=%d, new added offloads"
+			" 0x%"PRIx64" must be within per-queue offload"
+			" capabilities 0x%"PRIx64" in %s()\n",
+			port_id, rx_queue_id, local_conf.offloads,
+			dev_info.rx_queue_offload_capa,
+			__func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * If LRO is enabled, check that the maximum aggregated packet
+	 * size is supported by the configured device.
+	 */
+	if (local_conf.offloads & DEV_RX_OFFLOAD_TCP_LRO) {

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2086

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+		if (dev->data->dev_conf.rxmode.max_lro_pkt_size == 0)
+			dev->data->dev_conf.rxmode.max_lro_pkt_size =
+				dev->data->dev_conf.rxmode.max_rx_pkt_len;
+		int ret = check_lro_pkt_size(port_id,
+				dev->data->dev_conf.rxmode.max_lro_pkt_size,
+				dev->data->dev_conf.rxmode.max_rx_pkt_len,
+				dev_info.max_lro_pkt_size);
+		if (ret != 0)
+			return ret;
+	}

<end-of-huge-dup>

Quoted 4 lines

IMO It is not acceptable to duplication so much code. It is simply unmaintainable.

NACK

Can it be solved by making rte_eth_rx_queue_setup() a wrapper on top of this new rte_eth_rxseg_queue_setup() ?

#39 lore raw
Quoted 180 lines · Thomas Monjalon

12/10/2020 18:38, Andrew Rybchenko:

Quoted 179 lines · Viacheslav Ovsiienko

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1935

Quoted 9 lines

int

lib/librte_ethdev/rte_ethdev.c +8 -0
+rte_eth_rxseg_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+			  uint16_t nb_rx_desc, unsigned int socket_id,
+			  const struct rte_eth_rxconf *rx_conf,
+			  const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)
+{
+	int ret;
+	uint16_t seg_idx;
+	uint32_t mbp_buf_size;

<start-of-dup>

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1947

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +12 -0
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info;
+	struct rte_eth_rxconf local_conf;
+	void **rxq;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+
+	dev = &rte_eth_devices[port_id];
+	if (rx_queue_id >= dev->data->nb_rx_queues) {
+		RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", rx_queue_id);
+		return -EINVAL;
+	}

<end-of-dup>

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1960

Quoted 13 lines
lib/librte_ethdev/rte_ethdev.c +13 -0
+
+	if (rx_seg == NULL) {
+		RTE_ETHDEV_LOG(ERR, "Invalid null description pointer\n");
+		return -EINVAL;
+	}
+
+	if (n_seg == 0) {
+		RTE_ETHDEV_LOG(ERR, "Invalid zero description number\n");
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rxseg_queue_setup, -ENOTSUP);
+

<start-of-dup>

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1968

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+	/*
+	 * Check the size of the mbuf data buffer.
+	 * This value must be provided in the private data of the memory pool.
+	 * First check that the memory pool has a valid private data.
+	 */
+	ret = rte_eth_dev_info_get(port_id, &dev_info);
+	if (ret != 0)
+		return ret;

<end-of-dup>

Quoted 19 lines
lib/librte_ethdev/rte_ethdev.c +19 -0
+
+	for (seg_idx = 0; seg_idx < n_seg; seg_idx++) {
+		struct rte_mempool *mp = rx_seg[seg_idx].mp;
+
+		if (mp->private_data_size <
+				sizeof(struct rte_pktmbuf_pool_private)) {
+			RTE_ETHDEV_LOG(ERR, "%s private_data_size %d < %d\n",
+				mp->name, (int)mp->private_data_size,
+				(int)sizeof(struct rte_pktmbuf_pool_private));
+			return -ENOSPC;
+		}
+
+		mbp_buf_size = rte_pktmbuf_data_room_size(mp);
+		if (mbp_buf_size < rx_seg[seg_idx].length +
+				   rx_seg[seg_idx].offset +
+				   (seg_idx ? 0 :
+				    (uint32_t)RTE_PKTMBUF_HEADROOM)) {
+			RTE_ETHDEV_LOG(ERR,
+				"%s mbuf_data_room_size %d < %d"

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1997

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+				" (segment length=%d + segment offset=%d)\n",
+				mp->name, (int)mbp_buf_size,
+				(int)(rx_seg[seg_idx].length +
+				      rx_seg[seg_idx].offset),
+				(int)rx_seg[seg_idx].length,
+				(int)rx_seg[seg_idx].offset);
+			return -EINVAL;
+		}
+	}
+

<start-of-huge-dup>

Quoted 79 lines
lib/librte_ethdev/rte_ethdev.c +79 -0
+	/* Use default specified by driver, if nb_rx_desc is zero */
+	if (nb_rx_desc == 0) {
+		nb_rx_desc = dev_info.default_rxportconf.ring_size;
+		/* If driver default is also zero, fall back on EAL default */
+		if (nb_rx_desc == 0)
+			nb_rx_desc = RTE_ETH_DEV_FALLBACK_RX_RINGSIZE;
+	}
+
+	if (nb_rx_desc > dev_info.rx_desc_lim.nb_max ||
+			nb_rx_desc < dev_info.rx_desc_lim.nb_min ||
+			nb_rx_desc % dev_info.rx_desc_lim.nb_align != 0) {
+
+		RTE_ETHDEV_LOG(ERR,
+			"Invalid value for nb_rx_desc(=%hu), should be: "
+			"<= %hu, >= %hu, and a product of %hu\n",
+			nb_rx_desc, dev_info.rx_desc_lim.nb_max,
+			dev_info.rx_desc_lim.nb_min,
+			dev_info.rx_desc_lim.nb_align);
+		return -EINVAL;
+	}
+
+	if (dev->data->dev_started &&
+		!(dev_info.dev_capa &
+			RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP))
+		return -EBUSY;
+
+	if (dev->data->dev_started &&
+		(dev->data->rx_queue_state[rx_queue_id] !=
+			RTE_ETH_QUEUE_STATE_STOPPED))
+		return -EBUSY;
+
+	rxq = dev->data->rx_queues;
+	if (rxq[rx_queue_id]) {
+		RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release,
+					-ENOTSUP);
+		(*dev->dev_ops->rx_queue_release)(rxq[rx_queue_id]);
+		rxq[rx_queue_id] = NULL;
+	}
+
+	if (rx_conf == NULL)
+		rx_conf = &dev_info.default_rxconf;
+
+	local_conf = *rx_conf;
+
+	/*
+	 * If an offloading has already been enabled in
+	 * rte_eth_dev_configure(), it has been enabled on all queues,
+	 * so there is no need to enable it in this queue again.
+	 * The local_conf.offloads input to underlying PMD only carries
+	 * those offloadings which are only enabled on this queue and
+	 * not enabled on all queues.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;
+
+	/*
+	 * New added offloadings for this queue are those not enabled in
+	 * rte_eth_dev_configure() and they must be per-queue type.
+	 * A pure per-port offloading can't be enabled on a queue while
+	 * disabled on another queue. A pure per-port offloading can't
+	 * be enabled for any queue as new added one if it hasn't been
+	 * enabled in rte_eth_dev_configure().
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_ETHDEV_LOG(ERR,
+			"Ethdev port_id=%d rx_queue_id=%d, new added offloads"
+			" 0x%"PRIx64" must be within per-queue offload"
+			" capabilities 0x%"PRIx64" in %s()\n",
+			port_id, rx_queue_id, local_conf.offloads,
+			dev_info.rx_queue_offload_capa,
+			__func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * If LRO is enabled, check that the maximum aggregated packet
+	 * size is supported by the configured device.
+	 */
+	if (local_conf.offloads & DEV_RX_OFFLOAD_TCP_LRO) {

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2086

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+		if (dev->data->dev_conf.rxmode.max_lro_pkt_size == 0)
+			dev->data->dev_conf.rxmode.max_lro_pkt_size =
+				dev->data->dev_conf.rxmode.max_rx_pkt_len;
+		int ret = check_lro_pkt_size(port_id,
+				dev->data->dev_conf.rxmode.max_lro_pkt_size,
+				dev->data->dev_conf.rxmode.max_rx_pkt_len,
+				dev_info.max_lro_pkt_size);
+		if (ret != 0)
+			return ret;
+	}

<end-of-huge-dup>

Quoted 8 lines
Quoted 4 lines

IMO It is not acceptable to duplication so much code. It is simply unmaintainable.

NACK

Can it be solved by making rte_eth_rx_queue_setup() a wrapper on top of this new rte_eth_rxseg_queue_setup() ?

Could be, but strictly speaking it will break arguments validation order and error reporting in various cases. So, refactoring is required to keep it consistent.

#40 lore raw

Hi, Andrew

You are right - the code duplication of rte_eth_rx_queue_setup() code was large and it did not look well indeed.

I've updated the code, now rte_eth_rx_queue_setup() and rte_eth_rxseg_queue_setup() share the underlying internal routine __rte_eth_rx_queue_setup().

Of course, there is some refactoring, but it is merely straightforward, and I hope you will find it acceptable, please see the v4 of the patchset.

As I said, I do not see the decision-making con or pro for the case. Anyway, if we decide to move the segment descriptions to the config struct - there is just small step remaining over existing code to implement you that approach.

With best regards, Slava

Quoted 215 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, October 12, 2020 20:11
To: NBU-Contact-Thomas Monjalon <[email protected]>; Slava Ovsiienko <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v3 1/9] ethdev: introduce Rx buffer split

Quoted 13 lines · Thomas Monjalon

12/10/2020 18:38, Andrew Rybchenko:

Quoted 12 lines · Viacheslav Ovsiienko

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1935

Quoted 8 lines

int

lib/librte_ethdev/rte_ethdev.c +7 -0
+rte_eth_rxseg_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+			  uint16_t nb_rx_desc, unsigned int socket_id,
+			  const struct rte_eth_rxconf *rx_conf,
+			  const struct rte_eth_rxseg *rx_seg, uint16_t n_seg) {
+	int ret;
+	uint16_t seg_idx;
+	uint32_t mbp_buf_size;

<start-of-dup>

Quoted 10 lines
Quoted 10 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info;
+	struct rte_eth_rxconf local_conf;
+	void **rxq;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+
+	dev = &rte_eth_devices[port_id];
+	if (rx_queue_id >= dev->data->nb_rx_queues) {
+		RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n",

rx_queue_id);

Quoted 5 lines
Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+		return -EINVAL;
+	}

<end-of-dup>

Quoted 8 lines
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+
+	if (rx_seg == NULL) {
+		RTE_ETHDEV_LOG(ERR, "Invalid null description pointer\n");
+		return -EINVAL;
+	}
+
+	if (n_seg == 0) {
+		RTE_ETHDEV_LOG(ERR, "Invalid zero description

number\n");

Quoted 9 lines
Quoted 9 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2036

Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6 -0
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rxseg_queue_setup,
+-ENOTSUP);
+

<start-of-dup>

Quoted 3 lines
Quoted 3 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.c +3 -0
+	/*
+	 * Check the size of the mbuf data buffer.
+	 * This value must be provided in the private data of the memory

pool.

Quoted 8 lines
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1968

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +5 -0
+	 * First check that the memory pool has a valid private data.
+	 */
+	ret = rte_eth_dev_info_get(port_id, &dev_info);
+	if (ret != 0)
+		return ret;

<end-of-dup>

Quoted 7 lines
Quoted 7 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +7 -0
+
+	for (seg_idx = 0; seg_idx < n_seg; seg_idx++) {
+		struct rte_mempool *mp = rx_seg[seg_idx].mp;
+
+		if (mp->private_data_size <
+				sizeof(struct rte_pktmbuf_pool_private)) {
+			RTE_ETHDEV_LOG(ERR, "%s private_data_size %d <

%d\n",

Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+				mp->name, (int)mp->private_data_size,
+				(int)sizeof(struct

rte_pktmbuf_pool_private));

Quoted 11 lines
Quoted 11 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.c +11 -0
+			return -ENOSPC;
+		}
+
+		mbp_buf_size = rte_pktmbuf_data_room_size(mp);
+		if (mbp_buf_size < rx_seg[seg_idx].length +
+				   rx_seg[seg_idx].offset +
+				   (seg_idx ? 0 :
+				    (uint32_t)RTE_PKTMBUF_HEADROOM)) {
+			RTE_ETHDEV_LOG(ERR,
+				"%s mbuf_data_room_size %d < %d"
+				" (segment length=%d + segment

offset=%d)\n",

Quoted 12 lines
Quoted 12 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1997

Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c +9 -0
+				mp->name, (int)mbp_buf_size,
+				(int)(rx_seg[seg_idx].length +
+				      rx_seg[seg_idx].offset),
+				(int)rx_seg[seg_idx].length,
+				(int)rx_seg[seg_idx].offset);
+			return -EINVAL;
+		}
+	}
+

<start-of-huge-dup>

Quoted 6 lines
Quoted 6 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6 -0
+	/* Use default specified by driver, if nb_rx_desc is zero */
+	if (nb_rx_desc == 0) {
+		nb_rx_desc = dev_info.default_rxportconf.ring_size;
+		/* If driver default is also zero, fall back on EAL default */
+		if (nb_rx_desc == 0)
+			nb_rx_desc =

RTE_ETH_DEV_FALLBACK_RX_RINGSIZE;

Quoted 53 lines
Quoted 20 lines
Quoted 20 lines
lib/librte_ethdev/rte_ethdev.c +20 -0
+	}
+
+	if (nb_rx_desc > dev_info.rx_desc_lim.nb_max ||
+			nb_rx_desc < dev_info.rx_desc_lim.nb_min ||
+			nb_rx_desc % dev_info.rx_desc_lim.nb_align != 0) {
+
+		RTE_ETHDEV_LOG(ERR,
+			"Invalid value for nb_rx_desc(=%hu), should be: "
+			"<= %hu, >= %hu, and a product of %hu\n",
+			nb_rx_desc, dev_info.rx_desc_lim.nb_max,
+			dev_info.rx_desc_lim.nb_min,
+			dev_info.rx_desc_lim.nb_align);
+		return -EINVAL;
+	}
+
+	if (dev->data->dev_started &&
+		!(dev_info.dev_capa &
+			RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP))
+		return -EBUSY;
+
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+	if (dev->data->dev_started &&
+		(dev->data->rx_queue_state[rx_queue_id] !=
+			RTE_ETH_QUEUE_STATE_STOPPED))
+		return -EBUSY;
+
+	rxq = dev->data->rx_queues;
+	if (rxq[rx_queue_id]) {
+		RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-

rx_queue_release,

Quoted 24 lines
Quoted 24 lines
lib/librte_ethdev/rte_ethdev.c +24 -0
+					-ENOTSUP);
+		(*dev->dev_ops->rx_queue_release)(rxq[rx_queue_id]);
+		rxq[rx_queue_id] = NULL;
+	}
+
+	if (rx_conf == NULL)
+		rx_conf = &dev_info.default_rxconf;
+
+	local_conf = *rx_conf;
+
+	/*
+	 * If an offloading has already been enabled in
+	 * rte_eth_dev_configure(), it has been enabled on all queues,
+	 * so there is no need to enable it in this queue again.
+	 * The local_conf.offloads input to underlying PMD only carries
+	 * those offloadings which are only enabled on this queue and
+	 * not enabled on all queues.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;
+
+	/*
+	 * New added offloadings for this queue are those not enabled in
+	 * rte_eth_dev_configure() and they must be per-queue type.
+	 * A pure per-port offloading can't be enabled on a queue while
Quoted 8 lines
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+	 * disabled on another queue. A pure per-port offloading can't
+	 * be enabled for any queue as new added one if it hasn't been
+	 * enabled in rte_eth_dev_configure().
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_ETHDEV_LOG(ERR,
+			"Ethdev port_id=%d rx_queue_id=%d, new added

offloads"

Quoted 29 lines
Quoted 8 lines
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+			" 0x%"PRIx64" must be within per-queue offload"
+			" capabilities 0x%"PRIx64" in %s()\n",
+			port_id, rx_queue_id, local_conf.offloads,
+			dev_info.rx_queue_offload_capa,
+			__func__);
+		return -EINVAL;
+	}
+
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+	/*
+	 * If LRO is enabled, check that the maximum aggregated packet
+	 * size is supported by the configured device.
+	 */
+	if (local_conf.offloads & DEV_RX_OFFLOAD_TCP_LRO) {
+		if (dev->data->dev_conf.rxmode.max_lro_pkt_size == 0)
+			dev->data->dev_conf.rxmode.max_lro_pkt_size =
+				dev->data-

dev_conf.rxmode.max_rx_pkt_len;

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+		int ret = check_lro_pkt_size(port_id,
+				dev->data-

dev_conf.rxmode.max_lro_pkt_size,

Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+				dev->data-

dev_conf.rxmode.max_rx_pkt_len,

Quoted 7 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2086

Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +4 -0
+				dev_info.max_lro_pkt_size);
+		if (ret != 0)
+			return ret;
+	}

<end-of-huge-dup>

Quoted 8 lines
Quoted 4 lines

IMO It is not acceptable to duplication so much code. It is simply unmaintainable.

NACK

Can it be solved by making rte_eth_rx_queue_setup() a wrapper on top of this new rte_eth_rxseg_queue_setup() ?

Could be, but strictly speaking it will break arguments validation order and error reporting in various cases.
So, refactoring is required to keep it consistent.

#41 lore raw
In reply to Thomas Monjalon
Quoted 202 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, October 12, 2020 20:03
To: Slava Ovsiienko <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v3 1/9] ethdev: introduce Rx buffer split

12/10/2020 18:38, Andrew Rybchenko:

Quoted 12 lines · Viacheslav Ovsiienko

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1935

Quoted 8 lines

int

lib/librte_ethdev/rte_ethdev.c +7 -0
+rte_eth_rxseg_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+			  uint16_t nb_rx_desc, unsigned int socket_id,
+			  const struct rte_eth_rxconf *rx_conf,
+			  const struct rte_eth_rxseg *rx_seg, uint16_t n_seg) {
+	int ret;
+	uint16_t seg_idx;
+	uint32_t mbp_buf_size;

<start-of-dup>

Quoted 10 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info;
+	struct rte_eth_rxconf local_conf;
+	void **rxq;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+
+	dev = &rte_eth_devices[port_id];
+	if (rx_queue_id >= dev->data->nb_rx_queues) {
+		RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n",

rx_queue_id);

Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+		return -EINVAL;
+	}

<end-of-dup>

Quoted 8 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+
+	if (rx_seg == NULL) {
+		RTE_ETHDEV_LOG(ERR, "Invalid null description pointer\n");
+		return -EINVAL;
+	}
+
+	if (n_seg == 0) {
+		RTE_ETHDEV_LOG(ERR, "Invalid zero description

number\n");

Quoted 9 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2036

Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6 -0
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rxseg_queue_setup,
+-ENOTSUP);
+

<start-of-dup>

Quoted 3 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.c +3 -0
+	/*
+	 * Check the size of the mbuf data buffer.
+	 * This value must be provided in the private data of the memory

pool.

Quoted 8 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1968

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +5 -0
+	 * First check that the memory pool has a valid private data.
+	 */
+	ret = rte_eth_dev_info_get(port_id, &dev_info);
+	if (ret != 0)
+		return ret;

<end-of-dup>

Quoted 7 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +7 -0
+
+	for (seg_idx = 0; seg_idx < n_seg; seg_idx++) {
+		struct rte_mempool *mp = rx_seg[seg_idx].mp;
+
+		if (mp->private_data_size <
+				sizeof(struct rte_pktmbuf_pool_private)) {
+			RTE_ETHDEV_LOG(ERR, "%s private_data_size %d <

%d\n",

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+				mp->name, (int)mp->private_data_size,
+				(int)sizeof(struct

rte_pktmbuf_pool_private));

Quoted 11 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.c +11 -0
+			return -ENOSPC;
+		}
+
+		mbp_buf_size = rte_pktmbuf_data_room_size(mp);
+		if (mbp_buf_size < rx_seg[seg_idx].length +
+				   rx_seg[seg_idx].offset +
+				   (seg_idx ? 0 :
+				    (uint32_t)RTE_PKTMBUF_HEADROOM)) {
+			RTE_ETHDEV_LOG(ERR,
+				"%s mbuf_data_room_size %d < %d"
+				" (segment length=%d + segment

offset=%d)\n",

Quoted 12 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1997

Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c +9 -0
+				mp->name, (int)mbp_buf_size,
+				(int)(rx_seg[seg_idx].length +
+				      rx_seg[seg_idx].offset),
+				(int)rx_seg[seg_idx].length,
+				(int)rx_seg[seg_idx].offset);
+			return -EINVAL;
+		}
+	}
+

<start-of-huge-dup>

Quoted 6 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6 -0
+	/* Use default specified by driver, if nb_rx_desc is zero */
+	if (nb_rx_desc == 0) {
+		nb_rx_desc = dev_info.default_rxportconf.ring_size;
+		/* If driver default is also zero, fall back on EAL default */
+		if (nb_rx_desc == 0)
+			nb_rx_desc =

RTE_ETH_DEV_FALLBACK_RX_RINGSIZE;

Quoted 53 lines
Quoted 18 lines
lib/librte_ethdev/rte_ethdev.c +18 -0
+	}
+
+	if (nb_rx_desc > dev_info.rx_desc_lim.nb_max ||
+			nb_rx_desc < dev_info.rx_desc_lim.nb_min ||
+			nb_rx_desc % dev_info.rx_desc_lim.nb_align != 0) {
+
+		RTE_ETHDEV_LOG(ERR,
+			"Invalid value for nb_rx_desc(=%hu), should be: "
+			"<= %hu, >= %hu, and a product of %hu\n",
+			nb_rx_desc, dev_info.rx_desc_lim.nb_max,
+			dev_info.rx_desc_lim.nb_min,
+			dev_info.rx_desc_lim.nb_align);
+		return -EINVAL;
+	}
+
+	if (dev->data->dev_started &&
+		!(dev_info.dev_capa &
+			RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP))

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+		return -EBUSY;
+
+	if (dev->data->dev_started &&
+		(dev->data->rx_queue_state[rx_queue_id] !=
+			RTE_ETH_QUEUE_STATE_STOPPED))
+		return -EBUSY;
+
+	rxq = dev->data->rx_queues;
+	if (rxq[rx_queue_id]) {
+		RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-

rx_queue_release,

Quoted 24 lines
lib/librte_ethdev/rte_ethdev.c +24 -0
+					-ENOTSUP);
+		(*dev->dev_ops->rx_queue_release)(rxq[rx_queue_id]);
+		rxq[rx_queue_id] = NULL;
+	}
+
+	if (rx_conf == NULL)
+		rx_conf = &dev_info.default_rxconf;
+
+	local_conf = *rx_conf;
+
+	/*
+	 * If an offloading has already been enabled in
+	 * rte_eth_dev_configure(), it has been enabled on all queues,
+	 * so there is no need to enable it in this queue again.
+	 * The local_conf.offloads input to underlying PMD only carries
+	 * those offloadings which are only enabled on this queue and
+	 * not enabled on all queues.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;
+
+	/*
+	 * New added offloadings for this queue are those not enabled in
+	 * rte_eth_dev_configure() and they must be per-queue type.
+	 * A pure per-port offloading can't be enabled on a queue while
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+	 * disabled on another queue. A pure per-port offloading can't
+	 * be enabled for any queue as new added one if it hasn't been
+	 * enabled in rte_eth_dev_configure().
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_ETHDEV_LOG(ERR,
+			"Ethdev port_id=%d rx_queue_id=%d, new added

offloads"

Quoted 29 lines
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6 -0
+			" 0x%"PRIx64" must be within per-queue offload"
+			" capabilities 0x%"PRIx64" in %s()\n",
+			port_id, rx_queue_id, local_conf.offloads,
+			dev_info.rx_queue_offload_capa,
+			__func__);
+		return -EINVAL;

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	}
+
+	/*
+	 * If LRO is enabled, check that the maximum aggregated packet
+	 * size is supported by the configured device.
+	 */
+	if (local_conf.offloads & DEV_RX_OFFLOAD_TCP_LRO) {
+		if (dev->data->dev_conf.rxmode.max_lro_pkt_size == 0)
+			dev->data->dev_conf.rxmode.max_lro_pkt_size =
+				dev->data-

dev_conf.rxmode.max_rx_pkt_len;

Review

Quoted 2 lines
(quoted diff) +2 -0
+		int ret = check_lro_pkt_size(port_id,
+				dev->data-

dev_conf.rxmode.max_lro_pkt_size,

Review

Quoted 1 line
(quoted diff) +1 -0
+				dev->data-

dev_conf.rxmode.max_rx_pkt_len,

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2086

Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +4 -0
+				dev_info.max_lro_pkt_size);
+		if (ret != 0)
+			return ret;
+	}

<end-of-huge-dup>

Quoted 8 lines
Quoted 4 lines

IMO It is not acceptable to duplication so much code. It is simply unmaintainable.

NACK

Can it be solved by making rte_eth_rx_queue_setup() a wrapper on top of this new rte_eth_rxseg_queue_setup() ?

It would be the code refactoring. The more simple solution - provide the subroutine to perform the common part of parameters check.

It seems there are no strong decision-making pro's and con's for these two approaches. As I said - from my side the main concern of including segment descriptions into config structure is introducing ambiguity of some kind. But, if we decide to switch to this approach - will handle.

With best regards, Slava

#42 lore raw

PATCH v3 2/9 app/testpmd: add multiple pools per core creation

In reply to Viacheslav Ovsiienko

The command line parameter --mbuf-size is updated, it can handle the multiple values like the following:

--mbuf-size=2176,512,768,4096

specifying the creation the extra memory pools with the requested mbuf data buffer sizes. If some buffer split feature is engaged the extra memory pools can be used to configure the Rx queues with rte_the_dev_rx_queue_setup_ex().

The extra pools are created with requested sizes, and pool names are assigned with appended index: mbuf_pool_socket_%socket_%index. Index zero is used to specify the first mandatory pool to maintain compatibility with existing code.

---
 app/test-pmd/bpf_cmd.c                |  4 +--
 app/test-pmd/cmdline.c                |  2 +-
 app/test-pmd/config.c                 |  6 ++--
 app/test-pmd/parameters.c             | 24 +++++++++----
 app/test-pmd/testpmd.c                | 63 +++++++++++++++++++----------------
 app/test-pmd/testpmd.h                | 24 ++++++++++---
 doc/guides/testpmd_app_ug/run_app.rst |  7 ++--
 7 files changed, 83 insertions(+), 47 deletions(-)
app/test-pmd/bpf_cmd.c +2 -2
index 16e3c3b..0a1a178 100644
@@ -69,7 +69,7 @@ struct cmd_bpf_ld_result {
 
 	*flags = RTE_BPF_ETH_F_NONE;
 	arg->type = RTE_BPF_ARG_PTR;
-	arg->size = mbuf_data_size;
+	arg->size = mbuf_data_size[0];
 
 	for (i = 0; str[i] != 0; i++) {
 		v = toupper(str[i]);
@@ -78,7 +78,7 @@ struct cmd_bpf_ld_result {
 		else if (v == 'M') {
 			arg->type = RTE_BPF_ARG_PTR_MBUF;
 			arg->size = sizeof(struct rte_mbuf);
-			arg->buf_size = mbuf_data_size;
+			arg->buf_size = mbuf_data_size[0];
 		} else if (v == '-')
 			continue;
 		else
app/test-pmd/cmdline.c +1 -1
index 273fb1a..a585cf0 100644
@@ -2907,7 +2907,7 @@ struct cmd_setup_rxtx_queue {
 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
 			socket_id = port->socket_id;
 
-		mp = mbuf_pool_find(socket_id);
+		mp = mbuf_pool_find(socket_id, 0);
 		if (mp == NULL) {
 			printf("Failed to setup RX queue: "
 				"No mempool allocation"
app/test-pmd/config.c +3 -3
index 8ccd989..4405abc 100644
@@ -647,7 +647,7 @@ static int bus_match_all(const struct rte_bus *bus, const void *data)
 	printf("\nConnect to socket: %u", port->socket_id);
 
 	if (port_numa[port_id] != NUMA_NO_CONFIG) {
-		mp = mbuf_pool_find(port_numa[port_id]);
+		mp = mbuf_pool_find(port_numa[port_id], 0);
 		if (mp)
 			printf("\nmemory allocation on the socket: %d",
 							port_numa[port_id]);
@@ -3309,9 +3309,9 @@ struct igb_ring_desc_16_bytes {
 	 */
 	tx_pkt_len = 0;
 	for (i = 0; i < nb_segs; i++) {
-		if (seg_lengths[i] > (unsigned) mbuf_data_size) {
+		if (seg_lengths[i] > mbuf_data_size[0]) {
 			printf("length[%u]=%u > mbuf_data_size=%u - give up\n",
-			       i, seg_lengths[i], (unsigned) mbuf_data_size);
+			       i, seg_lengths[i], mbuf_data_size[0]);
 			return;
 		}
 		tx_pkt_len = (uint16_t)(tx_pkt_len + seg_lengths[i]);
app/test-pmd/parameters.c +18 -6
index 1ead595..1f40d73 100644
@@ -106,7 +106,9 @@
 	       "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n");
 	printf("  --socket-num=N: set socket from which all memory is allocated "
 	       "in NUMA mode.\n");
-	printf("  --mbuf-size=N: set the data size of mbuf to N bytes.\n");
+	printf("  --mbuf-size=N,[N1[,..Nn]: set the data size of mbuf to "
+	       "N bytes. If multiple numbers are specified the extra pools "
+	       "will be created to receive with packet split features\n");
 	printf("  --total-num-mbufs=N: set the number of mbufs to be allocated "
 	       "in mbuf pools.\n");
 	printf("  --max-pkt-len=N: set the maximum size of packet to N bytes.\n");
@@ -890,12 +892,22 @@
 				}
 			}
 			if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
-				n = atoi(optarg);
-				if (n > 0 && n <= 0xFFFF)
-					mbuf_data_size = (uint16_t) n;
-				else
+				unsigned int mb_sz[MAX_SEGS_BUFFER_SPLIT];
+				unsigned int nb_segs, i;
+
+				nb_segs = parse_item_list(optarg, "mbuf-size",
+					MAX_SEGS_BUFFER_SPLIT, mb_sz, 0);
+				if (nb_segs <= 0)
 					rte_exit(EXIT_FAILURE,
-						 "mbuf-size should be > 0 and < 65536\n");
+						 "bad mbuf-size\n");
+				for (i = 0; i < nb_segs; i++) {
+					if (mb_sz[i] <= 0 || mb_sz[i] > 0xFFFF)
+						rte_exit(EXIT_FAILURE,
+							 "mbuf-size should be "
+							 "> 0 and < 65536\n");
+					mbuf_data_size[i] = (uint16_t) mb_sz[i];
+				}
+				mbuf_data_size_n = nb_segs;
 			}
 			if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) {
 				n = atoi(optarg);
app/test-pmd/testpmd.c +35 -28

145 lines not on this page · raw message

app/test-pmd/testpmd.h +19 -5
index 227b694..e56a89c 100644
@@ -42,6 +42,13 @@
  */
 #define RTE_MAX_SEGS_PER_PKT 255 /**< nb_segs is a 8-bit unsigned char. */
 
+/*
+ * The maximum number of segments per packet is used to configure
+ * buffer split feature, also specifies the maximum amount of
+ * optional Rx pools to allocate mbufs to split.
+ */
+#define MAX_SEGS_BUFFER_SPLIT 8 /**< nb_segs is a 8-bit unsigned char. */
+
 #define MAX_PKT_BURST 512
 #define DEF_PKT_BURST 32
 
@@ -393,7 +400,9 @@ struct queue_stats_mappings {
 extern uint8_t dcb_config;
 extern uint8_t dcb_test;
 
-extern uint16_t mbuf_data_size; /**< Mbuf data space size. */
+extern uint32_t mbuf_data_size_n;
+extern uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT];
+/**< Mbuf data space size. */
 extern uint32_t param_total_num_mbufs;
 
 extern uint16_t stats_period;
@@ -604,17 +613,22 @@ struct mplsoudp_decap_conf {
 
 /* Mbuf Pools */
 static inline void
-mbuf_poolname_build(unsigned int sock_id, char* mp_name, int name_size)
+mbuf_poolname_build(unsigned int sock_id, char *mp_name,
+		    int name_size, unsigned int idx)
 {
-	snprintf(mp_name, name_size, "mbuf_pool_socket_%u", sock_id);
+	if (!idx)
+		snprintf(mp_name, name_size, "mbuf_pool_socket_%u", sock_id);
+	else
+		snprintf(mp_name, name_size, "mbuf_pool_socket_%u_%u",
+			 sock_id, idx);
 }
 
 static inline struct rte_mempool *
-mbuf_pool_find(unsigned int sock_id)
+mbuf_pool_find(unsigned int sock_id, unsigned int idx)
 {
 	char pool_name[RTE_MEMPOOL_NAMESIZE];
 
-	mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name));
+	mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name), idx);
 	return rte_mempool_lookup((const char *)pool_name);
 }
 
doc/guides/testpmd_app_ug/run_app.rst +5 -2
index e2539f6..2d5a263 100644
@@ -107,9 +107,12 @@ The command line options are:
     Set the socket from which all memory is allocated in NUMA mode,
     where 0 <= N < number of sockets on the board.
 
-*   ``--mbuf-size=N``
+*   ``--mbuf-size=N[,N1[,...Nn]``
 
-    Set the data size of the mbufs used to N bytes, where N < 65536. The default value is 2048.
+    Set the data size of the mbufs used to N bytes, where N < 65536.
+    The default value is 2048. If multiple mbuf-size values are specified the
+    extra memory pools will be created for allocating mbufs to receive packets
+    with buffer splittling features.
 
 *   ``--total-num-mbufs=N``
 
Signature · 1 line
1.8.3.1
#43 lore raw

PATCH v3 3/9 app/testpmd: add buffer split offload configuration

In reply to Viacheslav Ovsiienko

This patch add support for RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT providing per queue configuration for this offload.

---
 app/test-pmd/cmdline.c | 21 +++++++++++----------
 app/test-pmd/config.c  |  9 +++++++++
 2 files changed, 20 insertions(+), 10 deletions(-)
app/test-pmd/cmdline.c +11 -10
index a585cf0..fa71039 100644
@@ -883,16 +883,16 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"port config <port_id> rx_offload vlan_strip|"
 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
 			"outer_ipv4_cksum|macsec_strip|header_split|"
-			"vlan_filter|vlan_extend|jumbo_frame|"
-			"scatter|timestamp|security|keep_crc on|off\n"
+			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
+			"buffer_split|timestamp|security|keep_crc on|off\n"
 			"     Enable or disable a per port Rx offloading"
 			" 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|"
-			"vlan_filter|vlan_extend|jumbo_frame|"
-			"scatter|timestamp|security|keep_crc on|off\n"
+			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
+			"buffer_split|timestamp|security|keep_crc on|off\n"
 			"    Enable or disable a per queue Rx offloading"
 			" only on a specific Rx queue\n\n"
 
@@ -18417,7 +18417,8 @@ struct cmd_config_per_port_rx_offload_result {
 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
-			   "scatter#timestamp#security#keep_crc#rss_hash");
+			   "scatter#buffer_split#timestamp#security#"
+			   "keep_crc#rss_hash");
 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
 	TOKEN_STRING_INITIALIZER
 		(struct cmd_config_per_port_rx_offload_result,
@@ -18497,8 +18498,8 @@ struct cmd_config_per_port_rx_offload_result {
 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
-		    "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
-		    "on|off",
+		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
+		    "keep_crc|rss_hash on|off",
 	.tokens = {
 		(void *)&cmd_config_per_port_rx_offload_result_port,
 		(void *)&cmd_config_per_port_rx_offload_result_config,
@@ -18547,7 +18548,7 @@ struct cmd_config_per_queue_rx_offload_result {
 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
-			   "scatter#timestamp#security#keep_crc");
+			   "scatter#buffer_split#timestamp#security#keep_crc");
 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
 	TOKEN_STRING_INITIALIZER
 		(struct cmd_config_per_queue_rx_offload_result,
@@ -18603,8 +18604,8 @@ struct cmd_config_per_queue_rx_offload_result {
 		    "vlan_strip|ipv4_cksum|"
 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
-		    "jumbo_frame|scatter|timestamp|security|keep_crc "
-		    "on|off",
+		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
+		    "keep_crc on|off",
 	.tokens = {
 		(void *)&cmd_config_per_queue_rx_offload_result_port,
 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
app/test-pmd/config.c +9 -0
index 4405abc..6af8ea9 100644
@@ -1049,6 +1049,15 @@ static int bus_match_all(const struct rte_bus *bus, const void *data)
 			printf("off\n");
 	}
 
+	if (dev_info.rx_offload_capa & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
+		printf("RX offload buffer split:       ");
+		if (ports[port_id].dev_conf.rxmode.offloads &
+		    RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VLAN_INSERT) {
 		printf("VLAN insert:                   ");
 		if (ports[port_id].dev_conf.txmode.offloads &
Signature · 1 line
1.8.3.1
#44 lore raw

PATCH v3 4/9 app/testpmd: add rxpkts commands and parameters

In reply to Viacheslav Ovsiienko

Add command line parameter:

--rxpkts=X[,Y]

Sets the length of segments to scatter packets on receiving if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only).

Add interactive mode command:

testpmd> set txpkts (x[,y]*)

Where x[,y]* represents a CSV list of values, without white space.

Sets the length of segments to scatter packets on receiving if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only). Optionally the multiple memory pools can be specified with --mbuf-size command line parameter and the mbufs to receive will be allocated sequentially from these extra memory pools.

---
 app/test-pmd/cmdline.c                      | 61 +++++++++++++++++++++++++++--
 app/test-pmd/config.c                       | 48 ++++++++++++++++++++++-
 app/test-pmd/parameters.c                   | 15 +++++++
 app/test-pmd/testpmd.c                      |  7 ++++
 app/test-pmd/testpmd.h                      | 11 +++++-
 doc/guides/testpmd_app_ug/run_app.rst       |  9 +++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 21 +++++++++-
 7 files changed, 165 insertions(+), 7 deletions(-)
app/test-pmd/cmdline.c +58 -3
index fa71039..d8dba54 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|txpkts)\n"
+			"show config (rxtx|cores|fwd|rxpkts|txpkts)\n"
 			"    Display the given configuration.\n\n"
 
 			"read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -294,6 +294,12 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"    Set the transmit delay time and number of retries,"
 			" effective when retry is enabled.\n\n"
 
+			"set rxpkts (x[,y]*)\n"
+			"    Set the length of each segment to scatter"
+			" packets on receiving if split feature is engaged."
+			" Affects only the queues configured with split"
+			" offloads.\n\n"
+
 			"set txpkts (x[,y]*)\n"
 			"    Set the length of each segment of TXONLY"
 			" and optionally CSUM packets.\n\n"
@@ -3889,6 +3895,52 @@ struct cmd_set_log_result {
 	},
 };
 
+/* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
+
+struct cmd_set_rxpkts_result {
+	cmdline_fixed_string_t cmd_keyword;
+	cmdline_fixed_string_t rxpkts;
+	cmdline_fixed_string_t seg_lengths;
+};
+
+static void
+cmd_set_rxpkts_parsed(void *parsed_result,
+		      __rte_unused struct cmdline *cl,
+		      __rte_unused void *data)
+{
+	struct cmd_set_rxpkts_result *res;
+	unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+	unsigned int nb_segs;
+
+	res = parsed_result;
+	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
+				  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
+	if (nb_segs > 0)
+		set_rx_pkt_segments(seg_lengths, nb_segs);
+}
+
+cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 cmd_keyword, "set");
+cmdline_parse_token_string_t cmd_set_rxpkts_name =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 rxpkts, "rxpkts");
+cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 seg_lengths, NULL);
+
+cmdline_parse_inst_t cmd_set_rxpkts = {
+	.f = cmd_set_rxpkts_parsed,
+	.data = NULL,
+	.help_str = "set rxpkts <len0[,len1]*>",
+	.tokens = {
+		(void *)&cmd_set_rxpkts_keyword,
+		(void *)&cmd_set_rxpkts_name,
+		(void *)&cmd_set_rxpkts_lengths,
+		NULL,
+	},
+};
+
 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
 
 struct cmd_set_txpkts_result {
@@ -7517,6 +7569,8 @@ static void cmd_showcfg_parsed(void *parsed_result,
 		fwd_lcores_config_display();
 	else if (!strcmp(res->what, "fwd"))
 		pkt_fwd_config_display(&cur_fwd_config);
+	else if (!strcmp(res->what, "rxpkts"))
+		show_rx_pkt_segments();
 	else if (!strcmp(res->what, "txpkts"))
 		show_tx_pkt_segments();
 	else if (!strcmp(res->what, "txtimes"))
@@ -7529,12 +7583,12 @@ static void cmd_showcfg_parsed(void *parsed_result,
 	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#txpkts#txtimes");
+				 "rxtx#cores#fwd#rxpkts#txpkts#txtimes");
 
 cmdline_parse_inst_t cmd_showcfg = {
 	.f = cmd_showcfg_parsed,
 	.data = NULL,
-	.help_str = "show config rxtx|cores|fwd|txpkts|txtimes",
+	.help_str = "show config rxtx|cores|fwd|rxpkts|txpkts|txtimes",
 	.tokens = {
 		(void *)&cmd_showcfg_show,
 		(void *)&cmd_showcfg_port,
@@ -19807,6 +19861,7 @@ struct cmd_showport_macs_result {
 	(cmdline_parse_inst_t *)&cmd_reset,
 	(cmdline_parse_inst_t *)&cmd_set_numbers,
 	(cmdline_parse_inst_t *)&cmd_set_log,
+	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
 	(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 +46 -2

62 lines not on this page · raw message

app/test-pmd/parameters.c +15 -0
index 1f40d73..99f0223 100644
@@ -184,6 +184,7 @@
 	       "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
 	printf("  --no-flush-rx: Don't flush RX streams before forwarding."
 	       " Used mainly with PCAP drivers.\n");
+	printf("  --rxpkts=X[,Y]*: set RX segment sizes 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");
@@ -661,6 +662,7 @@
 		{ "rx-queue-stats-mapping",	1, 0, 0 },
 		{ "no-flush-rx",	0, 0, 0 },
 		{ "flow-isolate-all",	        0, 0, 0 },
+		{ "rxpkts",			1, 0, 0 },
 		{ "txpkts",			1, 0, 0 },
 		{ "txonly-multi-flow",		0, 0, 0 },
 		{ "disable-link-check",		0, 0, 0 },
@@ -1270,6 +1272,19 @@
 						 "invalid RX queue statistics mapping config entered\n");
 				}
 			}
+			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,
+						 seg_len, 0);
+				if (nb_segs > 0)
+					set_rx_pkt_segments(seg_len, 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 +7 -0
index ec66060..8e1c502 100644
@@ -210,6 +210,13 @@ struct fwd_engine * fwd_engines[] = {
 uint8_t f_quit;
 
 /*
+ * Configuration of packet segments used to scatter received packets
+ * if some of split features is configured.
+ */
+uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
+
+/*
  * Configuration of packet segments used by the "txonly" processing engine.
  */
 uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN; /**< TXONLY packet length. */
app/test-pmd/testpmd.h +10 -1
index e56a89c..5f8928e 100644
@@ -420,6 +420,13 @@ struct queue_stats_mappings {
 extern struct rte_fdir_conf fdir_conf;
 
 /*
+ * Configuration of packet segments used to scatter received packets
+ * if some of split features is configured.
+ */
+extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+extern uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
+
+/*
  * Configuration of packet segments used by the "txonly" processing engine.
  */
 #define TXONLY_DEF_PACKET_LEN 64
@@ -815,7 +822,9 @@ void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
 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_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs);
+void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
+void show_rx_pkt_segments(void);
+void set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
 void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
doc/guides/testpmd_app_ug/run_app.rst +9 -0
index 2d5a263..9286281 100644
@@ -361,6 +361,15 @@ The command line options are:
 
     Don't flush the RX streams before starting forwarding. Used mainly with the PCAP PMD.
 
+*   ``--rxpkts=X[,Y]``
+
+    Set the length of segments to scatter packets on receiving if split
+    feature is engaged. Affects only the queues configured
+    with split offloads (currently BUFFER_SPLIT is supported only).
+    Optionally the multiple memory pools can be specified with --mbuf-size
+    command line parameter and the mbufs to receive will be allocated
+    sequentially from these extra memory pools.
+
 *   ``--txpkts=X[,Y]``
 
     Set TX segment sizes or total packet length. Valid for ``tx-only``
doc/guides/testpmd_app_ug/testpmd_funcs.rst +20 -1
index 12268bc..529470a 100644
@@ -273,7 +273,7 @@ show config
 Displays the configuration of the application.
 The configuration comes from the command-line, the runtime or the application defaults::
 
-   testpmd> show config (rxtx|cores|fwd|txpkts|txtimes)
+   testpmd> show config (rxtx|cores|fwd|rxpkts|txpkts|txtimes)
 
 The available information categories are:
 
@@ -283,6 +283,8 @@ The available information categories are:
 
 * ``fwd``: Packet forwarding configuration.
 
+* ``rxpkts``: Packets to RX split configuration.
+
 * ``txpkts``: Packets to TX configuration.
 
 * ``txtimes``: Burst time pattern for Tx only mode.
@@ -774,6 +776,23 @@ When retry is enabled, the transmit delay time and number of retries can also be
 
    testpmd> set burst tx delay (microseconds) retry (num)
 
+set rxpkts
+~~~~~~~~~~
+
+Set the length of segments to scatter packets on receiving if split
+feature is engaged. Affects only the queues configured with split offloads
+(currently BUFFER_SPLIT is supported only). Optionally the multiple memory
+pools can be specified with --mbuf-size command line parameter and the mbufs
+to receive will be allocated sequentially from these extra memory pools (the
+mbuf for the first segment is allocated from the first pool, the second one
+from the second pool, and so on, if segment number is greater then pool's the
+mbuf for remaining segments will be allocated from the last valid pool).
+
+   testpmd> set rxpkts (x[,y]*)
+
+Where x[,y]* represents a CSV list of values, without white space. Zero value
+means to use the corresponding memory pool data buffer size.
+
 set txpkts
 ~~~~~~~~~~
 
Signature · 1 line
1.8.3.1
#45 lore raw

PATCH v3 5/9 app/testpmd: add extended Rx queue setup

In reply to Viacheslav Ovsiienko

If Rx queue is configured with split feature the extended setup with specified segment sizes and pool will be performed.

---
 app/test-pmd/cmdline.c | 12 ++++++------
 app/test-pmd/testpmd.c | 38 ++++++++++++++++++++++++++++++++++++--
 app/test-pmd/testpmd.h |  6 ++++++
 3 files changed, 48 insertions(+), 8 deletions(-)
app/test-pmd/cmdline.c +6 -6
index d8dba54..cf99f66 100644
@@ -2921,12 +2921,12 @@ struct cmd_setup_rxtx_queue {
 				rxring_numa[res->portid]);
 			return;
 		}
-		ret = rte_eth_rx_queue_setup(res->portid,
-					     res->qid,
-					     port->nb_rx_desc[res->qid],
-					     socket_id,
-					     &port->rx_conf[res->qid],
-					     mp);
+		ret = rx_queue_setup(res->portid,
+				     res->qid,
+				     port->nb_rx_desc[res->qid],
+				     socket_id,
+				     &port->rx_conf[res->qid],
+				     mp);
 		if (ret)
 			printf("Failed to setup RX queue\n");
 	} else {
app/test-pmd/testpmd.c +36 -2
index 8e1c502..960fb67 100644
@@ -2412,6 +2412,40 @@ struct extmem_param {
 	return 0;
 }
 
+/* Configure the Rx with optional split. */
+int
+rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+	       uint16_t nb_rx_desc, unsigned int socket_id,
+	       const struct rte_eth_rxconf *rx_conf,
+	       struct rte_mempool *mp)
+{
+	struct rte_eth_rxseg rx_seg[MAX_SEGS_BUFFER_SPLIT] = {};
+	unsigned int i, mp_n;
+
+	if (rx_pkt_nb_segs <= 1 ||
+	    (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) == 0)
+		return rte_eth_rx_queue_setup(port_id, rx_queue_id,
+					      nb_rx_desc, socket_id,
+					      rx_conf, mp);
+	for (i = 0; i < rx_pkt_nb_segs; i++) {
+		struct rte_mempool *mpx;
+		/*
+		 * Use last valid pool for the segments with number
+		 * exceeding the pool index.
+		 */
+		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[i].length = rx_pkt_seg_lengths[i] ?
+				   rx_pkt_seg_lengths[i] :
+				   mbuf_data_size[mp_n];
+		rx_seg[i].mp = mpx ? mpx : mp;
+	}
+	return rte_eth_rxseg_queue_setup(port_id, rx_queue_id,
+					 nb_rx_desc, socket_id, rx_conf,
+					 rx_seg, rx_pkt_nb_segs);
+}
+
 int
 start_port(portid_t pid)
 {
@@ -2520,7 +2554,7 @@ struct extmem_param {
 						return -1;
 					}
 
-					diag = rte_eth_rx_queue_setup(pi, qi,
+					diag = rx_queue_setup(pi, qi,
 					     port->nb_rx_desc[qi],
 					     rxring_numa[pi],
 					     &(port->rx_conf[qi]),
@@ -2536,7 +2570,7 @@ struct extmem_param {
 							port->socket_id);
 						return -1;
 					}
-					diag = rte_eth_rx_queue_setup(pi, qi,
+					diag = rx_queue_setup(pi, qi,
 					     port->nb_rx_desc[qi],
 					     port->socket_id,
 					     &(port->rx_conf[qi]),
app/test-pmd/testpmd.h +6 -0
index 5f8928e..b7611be 100644
@@ -871,6 +871,12 @@ void port_rss_reta_info(portid_t port_id,
 
 void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on);
 
+int
+rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+	       uint16_t nb_rx_desc, unsigned int socket_id,
+	       const struct rte_eth_rxconf *rx_conf,
+	       struct rte_mempool *mp);
+
 int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate);
 int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate,
 				uint64_t q_msk);
Signature · 1 line
1.8.3.1
#46 lore raw

PATCH v3 6/9 net/mlx5: add extended Rx queue setup routine

In reply to Viacheslav Ovsiienko

The routine to provide Rx queue setup with specifying extended receiving buffer description is added. It allows application to specify desired segment lengths, data position offsets in the buffer and dedicated memory pool for each segment.

---
 drivers/net/mlx5/linux/mlx5_os.c |  2 +
 drivers/net/mlx5/mlx5.h          |  3 ++
 drivers/net/mlx5/mlx5_rxq.c      | 91 +++++++++++++++++++++++++++++++++++-----
 drivers/net/mlx5/mlx5_rxtx.h     | 10 ++++-
 4 files changed, 95 insertions(+), 11 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +2 -0
index 487714f..0e85489 100644
@@ -2495,6 +2495,7 @@
 	.dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
 	.vlan_filter_set = mlx5_vlan_filter_set,
 	.rx_queue_setup = mlx5_rx_queue_setup,
+	.rxseg_queue_setup = mlx5_rxseg_queue_setup,
 	.rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
 	.tx_queue_setup = mlx5_tx_queue_setup,
 	.tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
@@ -2578,6 +2579,7 @@
 	.dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
 	.vlan_filter_set = mlx5_vlan_filter_set,
 	.rx_queue_setup = mlx5_rx_queue_setup,
+	.rxseg_queue_setup = mlx5_rxseg_queue_setup,
 	.rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
 	.tx_queue_setup = mlx5_tx_queue_setup,
 	.tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
drivers/net/mlx5/mlx5.h +3 -0
index 87d3c15..bfc0812 100644
@@ -162,6 +162,9 @@ struct mlx5_stats_ctrl {
 /* Maximal size of aggregated LRO packet. */
 #define MLX5_MAX_LRO_SIZE (UINT8_MAX * MLX5_LRO_SEG_CHUNK_SIZE)
 
+/* Maximal number of segments to split. */
+#define MLX5_MAX_RXQ_NSEG (1u << MLX5_MAX_LOG_RQ_SEGS)
+
 /* LRO configurations structure. */
 struct mlx5_lro_config {
 	uint32_t supported:1; /* Whether LRO is supported. */
drivers/net/mlx5/mlx5_rxq.c +81 -10

144 lines not on this page · raw message

drivers/net/mlx5/mlx5_rxtx.h +9 -1
index 674296e..f103a30 100644
@@ -150,6 +150,9 @@ struct mlx5_rxq_data {
 	rte_spinlock_t *uar_lock_cq;
 	/* CQ (UAR) access lock required for 32bit implementations */
 #endif
+	struct rte_eth_rxseg rxseg[MLX5_MAX_RXQ_NSEG];
+	/* Buffer split segment descriptions - sizes, offsets, pools. */
+	uint32_t rxseg_n; /* Number of split segment descriptions. */
 	uint32_t tunnel; /* Tunnel information. */
 	uint64_t flow_meta_mask;
 	int32_t flow_meta_offset;
@@ -304,6 +307,10 @@ struct mlx5_txq_ctrl {
 int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 			unsigned int socket, const struct rte_eth_rxconf *conf,
 			struct rte_mempool *mp);
+int mlx5_rxseg_queue_setup
+	(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
+	 unsigned int socket, const struct rte_eth_rxconf *conf,
+	 const struct rte_eth_rxseg *rx_seg, uint16_t n_seg);
 int mlx5_rx_hairpin_queue_setup
 	(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 	 const struct rte_eth_hairpin_conf *hairpin_conf);
@@ -316,7 +323,8 @@ int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx,
 				   uint16_t desc, unsigned int socket,
 				   const struct rte_eth_rxconf *conf,
-				   struct rte_mempool *mp);
+				   const struct rte_eth_rxseg *rx_seg,
+				   uint16_t n_seg);
 struct mlx5_rxq_ctrl *mlx5_rxq_hairpin_new
 	(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 	 const struct rte_eth_hairpin_conf *hairpin_conf);
Signature · 1 line
1.8.3.1
#47 lore raw

PATCH v3 7/9 net/mlx5: configure Rx queue to support split

In reply to Viacheslav Ovsiienko

The scatter-gather elements should be configured accordingly to support the buffer split feature. The application provides the desired settings for the segments at the beginning of the packets and PMD pads the buffer chain (if needed) with attributes of last specified segment to accommodate the packet of maximal length.

There are some limitations are implied. The MPRQ feature should be disengaged if split is requested, due to MPRQ neither supports pushing data to the dedicated pools nor follows the flexible buffer sizes. The vectorized rx_burst routines does not support the scattering (these ones are extremely simplified and work over the single segment only) and can't handle split as well.

---
 drivers/net/mlx5/mlx5_rxq.c | 94 ++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 80 insertions(+), 14 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +80 -14
index 42818d8..4ec4677 100644
@@ -1417,7 +1417,8 @@ struct mlx5_rxq_ctrl *
 	uint64_t offloads = conf->offloads |
 			   dev->data->dev_conf.rxmode.offloads;
 	unsigned int lro_on_queue = !!(offloads & DEV_RX_OFFLOAD_TCP_LRO);
-	const int mprq_en = mlx5_check_mprq_support(dev) > 0 && n_seg == 1;
+	const int mprq_en = mlx5_check_mprq_support(dev) > 0 && n_seg == 1 &&
+			    !rx_seg[0].offset && !rx_seg[0].length;
 	unsigned int max_rx_pkt_len = lro_on_queue ?
 			dev->data->dev_conf.rxmode.max_lro_pkt_size :
 			dev->data->dev_conf.rxmode.max_rx_pkt_len;
@@ -1425,22 +1426,87 @@ struct mlx5_rxq_ctrl *
 							RTE_PKTMBUF_HEADROOM;
 	unsigned int max_lro_size = 0;
 	unsigned int first_mb_free_size = mb_len - RTE_PKTMBUF_HEADROOM;
+	const struct rte_eth_rxseg *qs_seg = rx_seg;
+	unsigned int tail_len;
 
-	if (non_scatter_min_mbuf_size > mb_len && !(offloads &
-						    DEV_RX_OFFLOAD_SCATTER)) {
+	tmpl = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, sizeof(*tmpl) +
+			   desc_n * sizeof(struct rte_mbuf *), 0, socket);
+	if (!tmpl) {
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+	MLX5_ASSERT(n_seg && n_seg <= MLX5_MAX_RXQ_NSEG);
+	/*
+	 * Build the array of actual buffer offsets and lengths.
+	 * Pad with the buffers from the last memory pool if
+	 * needed to handle max size packets, replace zero length
+	 * with the buffer length from the pool.
+	 */
+	tail_len = max_rx_pkt_len;
+	do {
+		struct rte_eth_rxseg *hw_seg =
+					&tmpl->rxq.rxseg[tmpl->rxq.rxseg_n];
+		uint32_t buf_len = rte_pktmbuf_data_room_size(qs_seg->mp);
+		uint32_t offset, seg_len;
+
+		/*
+		 * For the buffers beyond descriptions offset is zero,
+		 * the first buffer contains head room.
+		 */
+		offset = (tmpl->rxq.rxseg_n >= n_seg ? 0 : qs_seg->offset) +
+			 (tmpl->rxq.rxseg_n ? 0 : RTE_PKTMBUF_HEADROOM);
+		/*
+		 * For the buffers beyond descriptions the length is
+		 * pool buffer length, zero lengths are replaced with
+		 * pool buffer length either.
+		 */
+		seg_len = tmpl->rxq.rxseg_n >= n_seg ? buf_len :
+			  qs_seg->length ? qs_seg->length : (buf_len - offset);
+		/* Check is done in long int, now overflows. */
+		if (buf_len < seg_len + offset) {
+			DRV_LOG(ERR, "port %u Rx queue %u: Split offset/length "
+				     "%u/%u can't be satisfied",
+				     dev->data->port_id, idx,
+				     qs_seg->length, qs_seg->offset);
+			rte_errno = EINVAL;
+			goto error;
+		}
+		if (seg_len > tail_len)
+			seg_len = buf_len - offset;
+		if (++tmpl->rxq.rxseg_n > MLX5_MAX_RXQ_NSEG) {
+			DRV_LOG(ERR,
+				"port %u too many SGEs (%u) needed to handle"
+				" requested maximum packet size %u, the maximum"
+				" supported are %u", dev->data->port_id,
+				tmpl->rxq.rxseg_n, max_rx_pkt_len,
+				MLX5_MAX_RXQ_NSEG);
+			rte_errno = ENOTSUP;
+			goto error;
+		}
+		/* Build the actual scattering element in the queue object. */
+		hw_seg->mp = qs_seg->mp;
+		MLX5_ASSERT(offset <= UINT16_MAX);
+		MLX5_ASSERT(seg_len <= UINT16_MAX);
+		hw_seg->offset = (uint16_t)offset;
+		hw_seg->length = (uint16_t)seg_len;
+		/*
+		 * Advance the segment descriptor, the padding is the based
+		 * on the attributes of the last descriptor.
+		 */
+		if (tmpl->rxq.rxseg_n < n_seg)
+			qs_seg++;
+		tail_len -= RTE_MIN(tail_len, seg_len);
+	} while (tail_len || !rte_is_power_of_2(tmpl->rxq.rxseg_n));
+	MLX5_ASSERT(tmpl->rxq.rxseg_n &&
+		    tmpl->rxq.rxseg_n <= MLX5_MAX_RXQ_NSEG);
+	if (tmpl->rxq.rxseg_n > 1 && !(offloads & DEV_RX_OFFLOAD_SCATTER)) {
 		DRV_LOG(ERR, "port %u Rx queue %u: Scatter offload is not"
 			" configured and no enough mbuf space(%u) to contain "
 			"the maximum RX packet length(%u) with head-room(%u)",
 			dev->data->port_id, idx, mb_len, max_rx_pkt_len,
 			RTE_PKTMBUF_HEADROOM);
 		rte_errno = ENOSPC;
-		return NULL;
-	}
-	tmpl = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, sizeof(*tmpl) +
-			   desc_n * sizeof(struct rte_mbuf *), 0, socket);
-	if (!tmpl) {
-		rte_errno = ENOMEM;
-		return NULL;
+		goto error;
 	}
 	tmpl->type = MLX5_RXQ_TYPE_STANDARD;
 	if (mlx5_mr_btree_init(&tmpl->rxq.mr_ctrl.cache_bh,
@@ -1467,7 +1533,7 @@ struct mlx5_rxq_ctrl *
 	 *  - The number of descs is more than the number of strides.
 	 *  - max_rx_pkt_len plus overhead is less than the max size
 	 *    of a stride or mprq_stride_size is specified by a user.
-	 *    Need to nake sure that there are enough stides to encap
+	 *    Need to make sure that there are enough stides to encap
 	 *    the maximum packet size in case mprq_stride_size is set.
 	 *  Otherwise, enable Rx scatter if necessary.
 	 */
@@ -1497,11 +1563,11 @@ struct mlx5_rxq_ctrl *
 			" strd_num_n = %u, strd_sz_n = %u",
 			dev->data->port_id, idx,
 			tmpl->rxq.strd_num_n, tmpl->rxq.strd_sz_n);
-	} else if (max_rx_pkt_len <= first_mb_free_size) {
+	} else if (tmpl->rxq.rxseg_n == 1) {
+		MLX5_ASSERT(max_rx_pkt_len <= first_mb_free_size);
 		tmpl->rxq.sges_n = 0;
 		max_lro_size = max_rx_pkt_len;
 	} else if (offloads & DEV_RX_OFFLOAD_SCATTER) {
-		unsigned int size = non_scatter_min_mbuf_size;
 		unsigned int sges_n;
 
 		if (lro_on_queue && first_mb_free_size <
@@ -1516,7 +1582,7 @@ struct mlx5_rxq_ctrl *
 		 * Determine the number of SGEs needed for a full packet
 		 * and round it to the next power of two.
 		 */
-		sges_n = log2above((size / mb_len) + !!(size % mb_len));
+		sges_n = log2above(tmpl->rxq.rxseg_n);
 		if (sges_n > MLX5_MAX_LOG_RQ_SEGS) {
 			DRV_LOG(ERR,
 				"port %u too many SGEs (%u) needed to handle"
Signature · 1 line
1.8.3.1
#48 lore raw

PATCH v3 8/9 net/mlx5: register multiple pool for Rx queue

In reply to Viacheslav Ovsiienko

The split feature for receiving packets was added to the mlx5 PMD, now Rx queue can receive the data to the buffers belonging to the different pools and the memory of all the involved pool must be registered for DMA operations in order to allow hardware to store the data.

---
 drivers/net/mlx5/mlx5_mr.c      |  3 +++
 drivers/net/mlx5/mlx5_trigger.c | 20 ++++++++++++--------
 2 files changed, 15 insertions(+), 8 deletions(-)
drivers/net/mlx5/mlx5_mr.c +3 -0
index dbcf0aa..c308ecc 100644
@@ -536,6 +536,9 @@ struct mr_update_mp_data {
 		.ret = 0,
 	};
 
+	DRV_LOG(DEBUG, "Port %u Rx queue registering mp %s "
+		       "having %u chunks.", dev->data->port_id,
+		       mp->name, mp->nb_mem_chunks);
 	rte_mempool_mem_iter(mp, mlx5_mr_update_mp_cb, &data);
 	if (data.ret < 0 && rte_errno == ENXIO) {
 		/* Mempool may have externally allocated memory. */
drivers/net/mlx5/mlx5_trigger.c +12 -8
index e72e5fb..643e10f 100644
@@ -145,18 +145,22 @@
 		dev->data->port_id, priv->sh->device_attr.max_sge);
 	for (i = 0; i != priv->rxqs_n; ++i) {
 		struct mlx5_rxq_ctrl *rxq_ctrl = mlx5_rxq_get(dev, i);
-		struct rte_mempool *mp;
 
 		if (!rxq_ctrl)
 			continue;
 		if (rxq_ctrl->type == MLX5_RXQ_TYPE_STANDARD) {
-			/* Pre-register Rx mempool. */
-			mp = mlx5_rxq_mprq_enabled(&rxq_ctrl->rxq) ?
-			     rxq_ctrl->rxq.mprq_mp : rxq_ctrl->rxq.mp;
-			DRV_LOG(DEBUG, "Port %u Rx queue %u registering mp %s"
-				" having %u chunks.", dev->data->port_id,
-				rxq_ctrl->rxq.idx, mp->name, mp->nb_mem_chunks);
-			mlx5_mr_update_mp(dev, &rxq_ctrl->rxq.mr_ctrl, mp);
+			/* Pre-register Rx mempools. */
+			if (mlx5_rxq_mprq_enabled(&rxq_ctrl->rxq)) {
+				mlx5_mr_update_mp(dev, &rxq_ctrl->rxq.mr_ctrl,
+						  rxq_ctrl->rxq.mprq_mp);
+			} else {
+				uint32_t s;
+
+				for (s = 0; s < rxq_ctrl->rxq.rxseg_n; s++)
+					mlx5_mr_update_mp
+						(dev, &rxq_ctrl->rxq.mr_ctrl,
+						rxq_ctrl->rxq.rxseg[s].mp);
+			}
 			ret = rxq_alloc_elts(rxq_ctrl);
 			if (ret)
 				goto error;
Signature · 1 line
1.8.3.1
#49 lore raw

PATCH v3 9/9 net/mlx5: update Rx datapath to support split

In reply to Viacheslav Ovsiienko

Only the regular rx_burst routine is updated to support split, because the vectorized ones does not support scatter and MPRQ does not support split at all.

---
 drivers/net/mlx5/mlx5_rxq.c  | 11 +++++------
 drivers/net/mlx5/mlx5_rxtx.c |  3 ++-
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +5 -6
index 4ec4677..2ebb265 100644
@@ -210,9 +210,10 @@
 
 	/* Iterate on segments. */
 	for (i = 0; (i != elts_n); ++i) {
+		struct rte_eth_rxseg *seg = &rxq_ctrl->rxq.rxseg[i % sges_n];
 		struct rte_mbuf *buf;
 
-		buf = rte_pktmbuf_alloc(rxq_ctrl->rxq.mp);
+		buf = rte_pktmbuf_alloc(seg->mp);
 		if (buf == NULL) {
 			DRV_LOG(ERR, "port %u empty mbuf pool",
 				PORT_ID(rxq_ctrl->priv));
@@ -225,12 +226,10 @@
 		MLX5_ASSERT(rte_pktmbuf_data_len(buf) == 0);
 		MLX5_ASSERT(rte_pktmbuf_pkt_len(buf) == 0);
 		MLX5_ASSERT(!buf->next);
-		/* Only the first segment keeps headroom. */
-		if (i % sges_n)
-			SET_DATA_OFF(buf, 0);
+		SET_DATA_OFF(buf, seg->offset);
 		PORT(buf) = rxq_ctrl->rxq.port_id;
-		DATA_LEN(buf) = rte_pktmbuf_tailroom(buf);
-		PKT_LEN(buf) = DATA_LEN(buf);
+		DATA_LEN(buf) = seg->length;
+		PKT_LEN(buf) = seg->length;
 		NB_SEGS(buf) = 1;
 		(*rxq_ctrl->rxq.elts)[i] = buf;
 	}
drivers/net/mlx5/mlx5_rxtx.c +2 -1
index b530ff4..dd84249 100644
@@ -1334,7 +1334,8 @@ enum mlx5_txcmp_code {
 		rte_prefetch0(seg);
 		rte_prefetch0(cqe);
 		rte_prefetch0(wqe);
-		rep = rte_mbuf_raw_alloc(rxq->mp);
+		/* Allocate the buf from the same pool. */
+		rep = rte_mbuf_raw_alloc(seg->pool);
 		if (unlikely(rep == NULL)) {
 			++rxq->stats.rx_nombuf;
 			if (!pkt) {
Signature · 1 line
1.8.3.1
#50 lore raw

v4 cover ethdev: introduce Rx buffer split

In reply to Slava Ovsiienko

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
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 reserved; /* reserved field */
};

The new routine rte_eth_rxseg_queue_setup_ex() is introduced to setup the given Rx queue using the new extended Rx packet segment description:

int
rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)

This routine presents the two new parameters:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf. This array allows to specify the different settings for each segment in individual fashion.
n_seg - number of elements in the array

The new offload flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup_ex() routine application should check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will split the received packets into multiple segments according to the specification in the description array:

- the first network buffer will be allocated from the memory pool, specified in the first segment description element, the second network buffer - from the pool in the second segment description element and so on. If there is no enough elements to describe the buffer for entire packet of maximal length the pool from the last valid element will be used to allocate the buffers from for the rest of segments

- the offsets from the segment description elements will provide the data offset from the buffer beginning except the first mbuf - for this one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual offset from the buffer beginning. If there is no enough elements to describe the buffer for entire packet of maximal length the offsets for the rest of segment will be supposed to be zero.

- the data length being received to each segment is limited by the length specified in the segment description element. The data receiving starts with filling up the first mbuf data buffer, if the specified maximal segment length is reached and there are data remaining (packet is longer than buffer in the first mbuf) the following data will be pushed to the next segment up to its own maximal length. If the first two segments is not enough to store all the packet remaining data the next (third) segment will be engaged and so on. If the length in the segment description element is zero the actual buffer size will be deduced from the appropriate memory pool properties. If there is no enough elements to describe the buffer for entire packet of maximal length the buffer size will be deduced from the pool of the last valid element for the remaining segments.

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B long @ 128 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B @ 128 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload RTE_ETH_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

---
v1: http://patches.dpdk.org/patch/79594/
v2: http://patches.dpdk.org/patch/79893/
- add feature support to mlx5 PMD

v3: http://patches.dpdk.org/patch/80389/
- rte_eth_rx_queue_setup_ex is renamed to rte_eth_rxseg_queue_setup
- DEV_RX_OFFLOAD_BUFFER_SPLIT is renamed to RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT
- commit message update
- documentaion provided
- release notes update
- minor bug fixes in testpmd related part

v4: - common part of rx_queue_setup/rxseg_queue_setup

Viacheslav Ovsiienko (9):
ethdev: introduce Rx buffer split app/testpmd: add multiple pools per core creation app/testpmd: add buffer split offload configuration app/testpmd: add rxpkts commands and parameters app/testpmd: add extended Rx queue setup net/mlx5: add extended Rx queue setup routine net/mlx5: configure Rx queue to support split net/mlx5: register multiple pool for Rx queue net/mlx5: update Rx datapath to support split

 app/test-pmd/bpf_cmd.c                      |   4 +-
 app/test-pmd/cmdline.c                      |  96 +++++++++++---
 app/test-pmd/config.c                       |  63 ++++++++-
 app/test-pmd/parameters.c                   |  39 +++++-
 app/test-pmd/testpmd.c                      | 108 +++++++++++-----
 app/test-pmd/testpmd.h                      |  41 +++++-
 doc/guides/nics/features.rst                |  15 +++
 doc/guides/rel_notes/release_20_11.rst      |   6 +
 doc/guides/testpmd_app_ug/run_app.rst       |  16 ++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  21 ++-
 drivers/net/mlx5/linux/mlx5_os.c            |   2 +
 drivers/net/mlx5/mlx5.h                     |   3 +
 drivers/net/mlx5/mlx5_mr.c                  |   3 +
 drivers/net/mlx5/mlx5_rxq.c                 | 194 +++++++++++++++++++++++-----
 drivers/net/mlx5/mlx5_rxtx.c                |   3 +-
 drivers/net/mlx5/mlx5_rxtx.h                |  10 +-
 drivers/net/mlx5/mlx5_trigger.c             |  20 +--
 lib/librte_ethdev/ethdev_trace_points.c     |   3 +
 lib/librte_ethdev/rte_ethdev.c              | 133 +++++++++++++++----
 lib/librte_ethdev/rte_ethdev.h              | 107 +++++++++++++++
 lib/librte_ethdev/rte_ethdev_driver.h       |  10 ++
 lib/librte_ethdev/rte_ethdev_trace.h        |  19 +++
 lib/librte_ethdev/rte_ethdev_version.map    |   3 +
 23 files changed, 780 insertions(+), 139 deletions(-)
Signature · 1 line
1.8.3.1
#51 lore raw

PATCH v4 1/9 ethdev: introduce Rx buffer split

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
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 reserved; /* reserved field */
};

The new routine rte_eth_rxseg_queue_setup_ex() is introduced to setup the given Rx queue using the new extended Rx packet segment description:

int
rte_eth_rx_queue_setup_ex(uint16_t port_id, uint16_t rx_queue_id,
uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, const struct rte_eth_rxseg *rx_seg, uint16_t n_seg)

This routine presents the two new parameters:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf. This array allows to specify the different settings for each segment in individual fashion.
n_seg - number of elements in the array

The new offload flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup_ex() routine application should check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will split the received packets into multiple segments according to the specification in the description array:

- the first network buffer will be allocated from the memory pool, specified in the first segment description element, the second network buffer - from the pool in the second segment description element and so on. If there is no enough elements to describe the buffer for entire packet of maximal length the pool from the last valid element will be used to allocate the buffers from for the rest of segments

- the offsets from the segment description elements will provide the data offset from the buffer beginning except the first mbuf - for this one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual offset from the buffer beginning. If there is no enough elements to describe the buffer for entire packet of maximal length the offsets for the rest of segment will be supposed to be zero.

- the data length being received to each segment is limited by the length specified in the segment description element. The data receiving starts with filling up the first mbuf data buffer, if the specified maximal segment length is reached and there are data remaining (packet is longer than buffer in the first mbuf) the following data will be pushed to the next segment up to its own maximal length. If the first two segments is not enough to store all the packet remaining data the next (third) segment will be engaged and so on. If the length in the segment description element is zero the actual buffer size will be deduced from the appropriate memory pool properties. If there is no enough elements to describe the buffer for entire packet of maximal length the buffer size will be deduced from the pool of the last valid element for the remaining segments.

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B long @ 128 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B @ 128 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload RTE_ETH_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

---
 doc/guides/nics/features.rst             |  15 ++++
 doc/guides/rel_notes/release_20_11.rst   |   6 ++
 lib/librte_ethdev/ethdev_trace_points.c  |   3 +
 lib/librte_ethdev/rte_ethdev.c           | 133 ++++++++++++++++++++++++-------
 lib/librte_ethdev/rte_ethdev.h           | 107 +++++++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_driver.h    |  10 +++
 lib/librte_ethdev/rte_ethdev_trace.h     |  19 +++++
 lib/librte_ethdev/rte_ethdev_version.map |   3 +
 8 files changed, 268 insertions(+), 28 deletions(-)
doc/guides/nics/features.rst +15 -0
index dd8c955..21b91db 100644
@@ -185,6 +185,21 @@ Supports receiving segmented mbufs.
 * **[related]    eth_dev_ops**: ``rx_pkt_burst``.
 
 
+.. _nic_features_buffer_split:
+
+Buffer Split on Rx
+------------
+
+Scatters the packets being received on specified boundaries to segmented mbufs.
+
+* **[uses]       rte_eth_rxconf,rte_eth_rxmode**: ``offloads:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[implements] datapath**: ``Buffer Split functionality``.
+* **[implements] rte_eth_dev_data**: ``buffer_split``.
+* **[provides]   rte_eth_dev_info**: ``rx_offload_capa:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[provides]   eth_dev_ops**: ``rxq_info_get:buffer_split``.
+* **[related] API**: ``rte_eth_rxseg_queue_setup()``.
+
+
 .. _nic_features_lro:
 
 LRO
doc/guides/rel_notes/release_20_11.rst +6 -0
index bcc0fc2..06a35c1 100644
@@ -60,6 +60,12 @@ New Features
   Added the FEC API which provides functions for query FEC capabilities and
   current FEC mode from device. Also, API for configuring FEC mode is also provided.
 
+* **Introduced extended buffer description for receiving.**
+
+  Added the extended Rx queue setup routine providing the individual
+  descriptions for each Rx segment with maximal size, buffer offset and memory
+  pool to allocate data buffers from.
+
 * **Updated Broadcom bnxt driver.**
 
   Updated the Broadcom bnxt driver with new features and improvements, including:
lib/librte_ethdev/ethdev_trace_points.c +3 -0
index 2919409..0ec8fc4 100644
@@ -12,6 +12,9 @@
 RTE_TRACE_POINT_REGISTER(rte_ethdev_trace_rxq_setup,
 	lib.ethdev.rxq.setup)
 
+RTE_TRACE_POINT_REGISTER(rte_ethdev_trace_rxq_seg_setup,
+	lib.ethdev.rxq.setup)
+
 RTE_TRACE_POINT_REGISTER(rte_ethdev_trace_txq_setup,
 	lib.ethdev.txq.setup)
 
lib/librte_ethdev/rte_ethdev.c +105 -28

187 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +107 -0

125 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_driver.h +10 -0
index 35cc4fb..5dee210 100644
@@ -264,6 +264,15 @@ typedef int (*eth_rx_queue_setup_t)(struct rte_eth_dev *dev,
 				    struct rte_mempool *mb_pool);
 /**< @internal Set up a receive queue of an Ethernet device. */
 
+typedef int (*eth_rxseg_queue_setup_t)(struct rte_eth_dev *dev,
+				       uint16_t rx_queue_id,
+				       uint16_t nb_rx_desc,
+				       unsigned int socket_id,
+				       const struct rte_eth_rxconf *rx_conf,
+				       const struct rte_eth_rxseg *rx_seg,
+				       uint16_t n_seg);
+/**< @internal extended Set up a receive queue of an Ethernet device. */
+
 typedef int (*eth_tx_queue_setup_t)(struct rte_eth_dev *dev,
 				    uint16_t tx_queue_id,
 				    uint16_t nb_tx_desc,
@@ -711,6 +720,7 @@ struct eth_dev_ops {
 	eth_queue_start_t          tx_queue_start;/**< Start TX for a queue. */
 	eth_queue_stop_t           tx_queue_stop; /**< Stop TX for a queue. */
 	eth_rx_queue_setup_t       rx_queue_setup;/**< Set up device RX queue. */
+	eth_rxseg_queue_setup_t    rxseg_queue_setup;/**< Extended RX setup. */
 	eth_queue_release_t        rx_queue_release; /**< Release RX queue. */
 
 	eth_rx_enable_intr_t       rx_queue_intr_enable;  /**< Enable Rx queue interrupt. */
lib/librte_ethdev/rte_ethdev_trace.h +19 -0
index 16f5bf2..7341ae9 100644
@@ -55,6 +55,25 @@
 )
 
 RTE_TRACE_POINT(
+	rte_ethdev_trace_rxq_seg_setup,
+	RTE_TRACE_POINT_ARGS(uint16_t port_id, uint16_t rx_queue_id,
+		uint16_t nb_rx_desc, const struct rte_eth_rxconf *rx_conf,
+		const struct rte_eth_rxseg *rx_seg, uint16_t n_seg, int rc),
+	rte_trace_point_emit_u16(port_id);
+	rte_trace_point_emit_u16(rx_queue_id);
+	rte_trace_point_emit_u16(nb_rx_desc);
+	rte_trace_point_emit_u8(rx_conf->rx_thresh.pthresh);
+	rte_trace_point_emit_u8(rx_conf->rx_thresh.hthresh);
+	rte_trace_point_emit_u8(rx_conf->rx_thresh.wthresh);
+	rte_trace_point_emit_u8(rx_conf->rx_drop_en);
+	rte_trace_point_emit_u8(rx_conf->rx_deferred_start);
+	rte_trace_point_emit_u64(rx_conf->offloads);
+	rte_trace_point_emit_ptr(rx_seg);
+	rte_trace_point_emit_u16(n_seg);
+	rte_trace_point_emit_int(rc);
+)
+
+RTE_TRACE_POINT(
 	rte_ethdev_trace_txq_setup,
 	RTE_TRACE_POINT_ARGS(uint16_t port_id, uint16_t tx_queue_id,
 		uint16_t nb_tx_desc, const struct rte_eth_txconf *tx_conf),
lib/librte_ethdev/rte_ethdev_version.map +3 -0
index f8a0945..848438b 100644
@@ -195,6 +195,7 @@ EXPERIMENTAL {
 	rte_flow_get_aged_flows;
 
 	# Marked as experimental in 20.11
+	rte_eth_rxseg_queue_setup;
 	rte_tm_capabilities_get;
 	rte_tm_get_number_of_leaf_nodes;
 	rte_tm_hierarchy_commit;
@@ -232,6 +233,8 @@ EXPERIMENTAL {
 	rte_eth_fec_get_capability;
 	rte_eth_fec_get;
 	rte_eth_fec_set;
+	__rte_ethdev_trace_rxq_seg_setup;
+
 };
 
 INTERNAL {
Signature · 1 line
1.8.3.1
#52 lore raw

PATCH v4 2/9 app/testpmd: add multiple pools per core creation

In reply to Viacheslav Ovsiienko

The command line parameter --mbuf-size is updated, it can handle the multiple values like the following:

--mbuf-size=2176,512,768,4096

specifying the creation the extra memory pools with the requested mbuf data buffer sizes. If some buffer split feature is engaged the extra memory pools can be used to configure the Rx queues with rte_the_dev_rx_queue_setup_ex().

The extra pools are created with requested sizes, and pool names are assigned with appended index: mbuf_pool_socket_%socket_%index. Index zero is used to specify the first mandatory pool to maintain compatibility with existing code.

---
 app/test-pmd/bpf_cmd.c                |  4 +--
 app/test-pmd/cmdline.c                |  2 +-
 app/test-pmd/config.c                 |  6 ++--
 app/test-pmd/parameters.c             | 24 +++++++++----
 app/test-pmd/testpmd.c                | 63 +++++++++++++++++++----------------
 app/test-pmd/testpmd.h                | 24 ++++++++++---
 doc/guides/testpmd_app_ug/run_app.rst |  7 ++--
 7 files changed, 83 insertions(+), 47 deletions(-)
app/test-pmd/bpf_cmd.c +2 -2
index 16e3c3b..0a1a178 100644
@@ -69,7 +69,7 @@ struct cmd_bpf_ld_result {
 
 	*flags = RTE_BPF_ETH_F_NONE;
 	arg->type = RTE_BPF_ARG_PTR;
-	arg->size = mbuf_data_size;
+	arg->size = mbuf_data_size[0];
 
 	for (i = 0; str[i] != 0; i++) {
 		v = toupper(str[i]);
@@ -78,7 +78,7 @@ struct cmd_bpf_ld_result {
 		else if (v == 'M') {
 			arg->type = RTE_BPF_ARG_PTR_MBUF;
 			arg->size = sizeof(struct rte_mbuf);
-			arg->buf_size = mbuf_data_size;
+			arg->buf_size = mbuf_data_size[0];
 		} else if (v == '-')
 			continue;
 		else
app/test-pmd/cmdline.c +1 -1
index 273fb1a..a585cf0 100644
@@ -2907,7 +2907,7 @@ struct cmd_setup_rxtx_queue {
 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
 			socket_id = port->socket_id;
 
-		mp = mbuf_pool_find(socket_id);
+		mp = mbuf_pool_find(socket_id, 0);
 		if (mp == NULL) {
 			printf("Failed to setup RX queue: "
 				"No mempool allocation"
app/test-pmd/config.c +3 -3
index d4be694..5f501f6 100644
@@ -690,7 +690,7 @@ static int bus_match_all(const struct rte_bus *bus, const void *data)
 	printf("\nConnect to socket: %u", port->socket_id);
 
 	if (port_numa[port_id] != NUMA_NO_CONFIG) {
-		mp = mbuf_pool_find(port_numa[port_id]);
+		mp = mbuf_pool_find(port_numa[port_id], 0);
 		if (mp)
 			printf("\nmemory allocation on the socket: %d",
 							port_numa[port_id]);
@@ -3352,9 +3352,9 @@ struct igb_ring_desc_16_bytes {
 	 */
 	tx_pkt_len = 0;
 	for (i = 0; i < nb_segs; i++) {
-		if (seg_lengths[i] > (unsigned) mbuf_data_size) {
+		if (seg_lengths[i] > mbuf_data_size[0]) {
 			printf("length[%u]=%u > mbuf_data_size=%u - give up\n",
-			       i, seg_lengths[i], (unsigned) mbuf_data_size);
+			       i, seg_lengths[i], mbuf_data_size[0]);
 			return;
 		}
 		tx_pkt_len = (uint16_t)(tx_pkt_len + seg_lengths[i]);
app/test-pmd/parameters.c +18 -6
index 15ce8c1..4db4987 100644
@@ -106,7 +106,9 @@
 	       "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n");
 	printf("  --socket-num=N: set socket from which all memory is allocated "
 	       "in NUMA mode.\n");
-	printf("  --mbuf-size=N: set the data size of mbuf to N bytes.\n");
+	printf("  --mbuf-size=N,[N1[,..Nn]: set the data size of mbuf to "
+	       "N bytes. If multiple numbers are specified the extra pools "
+	       "will be created to receive with packet split features\n");
 	printf("  --total-num-mbufs=N: set the number of mbufs to be allocated "
 	       "in mbuf pools.\n");
 	printf("  --max-pkt-len=N: set the maximum size of packet to N bytes.\n");
@@ -892,12 +894,22 @@
 				}
 			}
 			if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
-				n = atoi(optarg);
-				if (n > 0 && n <= 0xFFFF)
-					mbuf_data_size = (uint16_t) n;
-				else
+				unsigned int mb_sz[MAX_SEGS_BUFFER_SPLIT];
+				unsigned int nb_segs, i;
+
+				nb_segs = parse_item_list(optarg, "mbuf-size",
+					MAX_SEGS_BUFFER_SPLIT, mb_sz, 0);
+				if (nb_segs <= 0)
 					rte_exit(EXIT_FAILURE,
-						 "mbuf-size should be > 0 and < 65536\n");
+						 "bad mbuf-size\n");
+				for (i = 0; i < nb_segs; i++) {
+					if (mb_sz[i] <= 0 || mb_sz[i] > 0xFFFF)
+						rte_exit(EXIT_FAILURE,
+							 "mbuf-size should be "
+							 "> 0 and < 65536\n");
+					mbuf_data_size[i] = (uint16_t) mb_sz[i];
+				}
+				mbuf_data_size_n = nb_segs;
 			}
 			if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) {
 				n = atoi(optarg);
app/test-pmd/testpmd.c +35 -28

145 lines not on this page · raw message

app/test-pmd/testpmd.h +19 -5
index 9a29d7a..b42d710 100644
@@ -42,6 +42,13 @@
  */
 #define RTE_MAX_SEGS_PER_PKT 255 /**< nb_segs is a 8-bit unsigned char. */
 
+/*
+ * The maximum number of segments per packet is used to configure
+ * buffer split feature, also specifies the maximum amount of
+ * optional Rx pools to allocate mbufs to split.
+ */
+#define MAX_SEGS_BUFFER_SPLIT 8 /**< nb_segs is a 8-bit unsigned char. */
+
 #define MAX_PKT_BURST 512
 #define DEF_PKT_BURST 32
 
@@ -393,7 +400,9 @@ struct queue_stats_mappings {
 extern uint8_t dcb_config;
 extern uint8_t dcb_test;
 
-extern uint16_t mbuf_data_size; /**< Mbuf data space size. */
+extern uint32_t mbuf_data_size_n;
+extern uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT];
+/**< Mbuf data space size. */
 extern uint32_t param_total_num_mbufs;
 
 extern uint16_t stats_period;
@@ -605,17 +614,22 @@ struct mplsoudp_decap_conf {
 
 /* Mbuf Pools */
 static inline void
-mbuf_poolname_build(unsigned int sock_id, char* mp_name, int name_size)
+mbuf_poolname_build(unsigned int sock_id, char *mp_name,
+		    int name_size, unsigned int idx)
 {
-	snprintf(mp_name, name_size, "mbuf_pool_socket_%u", sock_id);
+	if (!idx)
+		snprintf(mp_name, name_size, "mbuf_pool_socket_%u", sock_id);
+	else
+		snprintf(mp_name, name_size, "mbuf_pool_socket_%u_%u",
+			 sock_id, idx);
 }
 
 static inline struct rte_mempool *
-mbuf_pool_find(unsigned int sock_id)
+mbuf_pool_find(unsigned int sock_id, unsigned int idx)
 {
 	char pool_name[RTE_MEMPOOL_NAMESIZE];
 
-	mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name));
+	mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name), idx);
 	return rte_mempool_lookup((const char *)pool_name);
 }
 
doc/guides/testpmd_app_ug/run_app.rst +5 -2
index ec085c2..1eb0a10 100644
@@ -107,9 +107,12 @@ The command line options are:
     Set the socket from which all memory is allocated in NUMA mode,
     where 0 <= N < number of sockets on the board.
 
-*   ``--mbuf-size=N``
+*   ``--mbuf-size=N[,N1[,...Nn]``
 
-    Set the data size of the mbufs used to N bytes, where N < 65536. The default value is 2048.
+    Set the data size of the mbufs used to N bytes, where N < 65536.
+    The default value is 2048. If multiple mbuf-size values are specified the
+    extra memory pools will be created for allocating mbufs to receive packets
+    with buffer splittling features.
 
 *   ``--total-num-mbufs=N``
 
Signature · 1 line
1.8.3.1
#53 lore raw

PATCH v4 3/9 app/testpmd: add buffer split offload configuration

In reply to Viacheslav Ovsiienko

This patch add support for RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT providing per queue configuration for this offload.

---
 app/test-pmd/cmdline.c | 21 +++++++++++----------
 app/test-pmd/config.c  |  9 +++++++++
 2 files changed, 20 insertions(+), 10 deletions(-)
app/test-pmd/cmdline.c +11 -10
index a585cf0..fa71039 100644
@@ -883,16 +883,16 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"port config <port_id> rx_offload vlan_strip|"
 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
 			"outer_ipv4_cksum|macsec_strip|header_split|"
-			"vlan_filter|vlan_extend|jumbo_frame|"
-			"scatter|timestamp|security|keep_crc on|off\n"
+			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
+			"buffer_split|timestamp|security|keep_crc on|off\n"
 			"     Enable or disable a per port Rx offloading"
 			" 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|"
-			"vlan_filter|vlan_extend|jumbo_frame|"
-			"scatter|timestamp|security|keep_crc on|off\n"
+			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
+			"buffer_split|timestamp|security|keep_crc on|off\n"
 			"    Enable or disable a per queue Rx offloading"
 			" only on a specific Rx queue\n\n"
 
@@ -18417,7 +18417,8 @@ struct cmd_config_per_port_rx_offload_result {
 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
-			   "scatter#timestamp#security#keep_crc#rss_hash");
+			   "scatter#buffer_split#timestamp#security#"
+			   "keep_crc#rss_hash");
 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
 	TOKEN_STRING_INITIALIZER
 		(struct cmd_config_per_port_rx_offload_result,
@@ -18497,8 +18498,8 @@ struct cmd_config_per_port_rx_offload_result {
 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
-		    "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
-		    "on|off",
+		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
+		    "keep_crc|rss_hash on|off",
 	.tokens = {
 		(void *)&cmd_config_per_port_rx_offload_result_port,
 		(void *)&cmd_config_per_port_rx_offload_result_config,
@@ -18547,7 +18548,7 @@ struct cmd_config_per_queue_rx_offload_result {
 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
-			   "scatter#timestamp#security#keep_crc");
+			   "scatter#buffer_split#timestamp#security#keep_crc");
 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
 	TOKEN_STRING_INITIALIZER
 		(struct cmd_config_per_queue_rx_offload_result,
@@ -18603,8 +18604,8 @@ struct cmd_config_per_queue_rx_offload_result {
 		    "vlan_strip|ipv4_cksum|"
 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
-		    "jumbo_frame|scatter|timestamp|security|keep_crc "
-		    "on|off",
+		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
+		    "keep_crc on|off",
 	.tokens = {
 		(void *)&cmd_config_per_queue_rx_offload_result_port,
 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
app/test-pmd/config.c +9 -0
index 5f501f6..7126d91 100644
@@ -1092,6 +1092,15 @@ static int bus_match_all(const struct rte_bus *bus, const void *data)
 			printf("off\n");
 	}
 
+	if (dev_info.rx_offload_capa & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
+		printf("RX offload buffer split:       ");
+		if (ports[port_id].dev_conf.rxmode.offloads &
+		    RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VLAN_INSERT) {
 		printf("VLAN insert:                   ");
 		if (ports[port_id].dev_conf.txmode.offloads &
Signature · 1 line
1.8.3.1
#54 lore raw

PATCH v4 4/9 app/testpmd: add rxpkts commands and parameters

In reply to Viacheslav Ovsiienko

Add command line parameter:

--rxpkts=X[,Y]

Sets the length of segments to scatter packets on receiving if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only).

Add interactive mode command:

testpmd> set txpkts (x[,y]*)

Where x[,y]* represents a CSV list of values, without white space.

Sets the length of segments to scatter packets on receiving if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only). Optionally the multiple memory pools can be specified with --mbuf-size command line parameter and the mbufs to receive will be allocated sequentially from these extra memory pools.

---
 app/test-pmd/cmdline.c                      | 61 +++++++++++++++++++++++++++--
 app/test-pmd/config.c                       | 48 ++++++++++++++++++++++-
 app/test-pmd/parameters.c                   | 15 +++++++
 app/test-pmd/testpmd.c                      |  7 ++++
 app/test-pmd/testpmd.h                      | 11 +++++-
 doc/guides/testpmd_app_ug/run_app.rst       |  9 +++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 21 +++++++++-
 7 files changed, 165 insertions(+), 7 deletions(-)
app/test-pmd/cmdline.c +58 -3
index fa71039..d8dba54 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|txpkts)\n"
+			"show config (rxtx|cores|fwd|rxpkts|txpkts)\n"
 			"    Display the given configuration.\n\n"
 
 			"read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -294,6 +294,12 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"    Set the transmit delay time and number of retries,"
 			" effective when retry is enabled.\n\n"
 
+			"set rxpkts (x[,y]*)\n"
+			"    Set the length of each segment to scatter"
+			" packets on receiving if split feature is engaged."
+			" Affects only the queues configured with split"
+			" offloads.\n\n"
+
 			"set txpkts (x[,y]*)\n"
 			"    Set the length of each segment of TXONLY"
 			" and optionally CSUM packets.\n\n"
@@ -3889,6 +3895,52 @@ struct cmd_set_log_result {
 	},
 };
 
+/* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
+
+struct cmd_set_rxpkts_result {
+	cmdline_fixed_string_t cmd_keyword;
+	cmdline_fixed_string_t rxpkts;
+	cmdline_fixed_string_t seg_lengths;
+};
+
+static void
+cmd_set_rxpkts_parsed(void *parsed_result,
+		      __rte_unused struct cmdline *cl,
+		      __rte_unused void *data)
+{
+	struct cmd_set_rxpkts_result *res;
+	unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+	unsigned int nb_segs;
+
+	res = parsed_result;
+	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
+				  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
+	if (nb_segs > 0)
+		set_rx_pkt_segments(seg_lengths, nb_segs);
+}
+
+cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 cmd_keyword, "set");
+cmdline_parse_token_string_t cmd_set_rxpkts_name =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 rxpkts, "rxpkts");
+cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 seg_lengths, NULL);
+
+cmdline_parse_inst_t cmd_set_rxpkts = {
+	.f = cmd_set_rxpkts_parsed,
+	.data = NULL,
+	.help_str = "set rxpkts <len0[,len1]*>",
+	.tokens = {
+		(void *)&cmd_set_rxpkts_keyword,
+		(void *)&cmd_set_rxpkts_name,
+		(void *)&cmd_set_rxpkts_lengths,
+		NULL,
+	},
+};
+
 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
 
 struct cmd_set_txpkts_result {
@@ -7517,6 +7569,8 @@ static void cmd_showcfg_parsed(void *parsed_result,
 		fwd_lcores_config_display();
 	else if (!strcmp(res->what, "fwd"))
 		pkt_fwd_config_display(&cur_fwd_config);
+	else if (!strcmp(res->what, "rxpkts"))
+		show_rx_pkt_segments();
 	else if (!strcmp(res->what, "txpkts"))
 		show_tx_pkt_segments();
 	else if (!strcmp(res->what, "txtimes"))
@@ -7529,12 +7583,12 @@ static void cmd_showcfg_parsed(void *parsed_result,
 	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#txpkts#txtimes");
+				 "rxtx#cores#fwd#rxpkts#txpkts#txtimes");
 
 cmdline_parse_inst_t cmd_showcfg = {
 	.f = cmd_showcfg_parsed,
 	.data = NULL,
-	.help_str = "show config rxtx|cores|fwd|txpkts|txtimes",
+	.help_str = "show config rxtx|cores|fwd|rxpkts|txpkts|txtimes",
 	.tokens = {
 		(void *)&cmd_showcfg_show,
 		(void *)&cmd_showcfg_port,
@@ -19807,6 +19861,7 @@ struct cmd_showport_macs_result {
 	(cmdline_parse_inst_t *)&cmd_reset,
 	(cmdline_parse_inst_t *)&cmd_set_numbers,
 	(cmdline_parse_inst_t *)&cmd_set_log,
+	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
 	(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 +46 -2

62 lines not on this page · raw message

app/test-pmd/parameters.c +15 -0
index 4db4987..e4e3635 100644
@@ -184,6 +184,7 @@
 	       "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
 	printf("  --no-flush-rx: Don't flush RX streams before forwarding."
 	       " Used mainly with PCAP drivers.\n");
+	printf("  --rxpkts=X[,Y]*: set RX segment sizes 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");
@@ -662,6 +663,7 @@
 		{ "rx-queue-stats-mapping",	1, 0, 0 },
 		{ "no-flush-rx",	0, 0, 0 },
 		{ "flow-isolate-all",	        0, 0, 0 },
+		{ "rxpkts",			1, 0, 0 },
 		{ "txpkts",			1, 0, 0 },
 		{ "txonly-multi-flow",		0, 0, 0 },
 		{ "disable-link-check",		0, 0, 0 },
@@ -1272,6 +1274,19 @@
 						 "invalid RX queue statistics mapping config entered\n");
 				}
 			}
+			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,
+						 seg_len, 0);
+				if (nb_segs > 0)
+					set_rx_pkt_segments(seg_len, 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 +7 -0
index 7e6ef80..f88c1e2 100644
@@ -210,6 +210,13 @@ struct fwd_engine * fwd_engines[] = {
 uint8_t f_quit;
 
 /*
+ * Configuration of packet segments used to scatter received packets
+ * if some of split features is configured.
+ */
+uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
+
+/*
  * Configuration of packet segments used by the "txonly" processing engine.
  */
 uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN; /**< TXONLY packet length. */
app/test-pmd/testpmd.h +10 -1
index b42d710..8e5ba6a 100644
@@ -420,6 +420,13 @@ struct queue_stats_mappings {
 extern struct rte_fdir_conf fdir_conf;
 
 /*
+ * Configuration of packet segments used to scatter received packets
+ * if some of split features is configured.
+ */
+extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+extern uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
+
+/*
  * Configuration of packet segments used by the "txonly" processing engine.
  */
 #define TXONLY_DEF_PACKET_LEN 64
@@ -816,7 +823,9 @@ void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
 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_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs);
+void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
+void show_rx_pkt_segments(void);
+void set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
 void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
doc/guides/testpmd_app_ug/run_app.rst +9 -0
index 1eb0a10..463b76c 100644
@@ -361,6 +361,15 @@ The command line options are:
 
     Don't flush the RX streams before starting forwarding. Used mainly with the PCAP PMD.
 
+*   ``--rxpkts=X[,Y]``
+
+    Set the length of segments to scatter packets on receiving if split
+    feature is engaged. Affects only the queues configured
+    with split offloads (currently BUFFER_SPLIT is supported only).
+    Optionally the multiple memory pools can be specified with --mbuf-size
+    command line parameter and the mbufs to receive will be allocated
+    sequentially from these extra memory pools.
+
 *   ``--txpkts=X[,Y]``
 
     Set TX segment sizes or total packet length. Valid for ``tx-only``
doc/guides/testpmd_app_ug/testpmd_funcs.rst +20 -1
index 795c739..ff88762 100644
@@ -273,7 +273,7 @@ show config
 Displays the configuration of the application.
 The configuration comes from the command-line, the runtime or the application defaults::
 
-   testpmd> show config (rxtx|cores|fwd|txpkts|txtimes)
+   testpmd> show config (rxtx|cores|fwd|rxpkts|txpkts|txtimes)
 
 The available information categories are:
 
@@ -283,6 +283,8 @@ The available information categories are:
 
 * ``fwd``: Packet forwarding configuration.
 
+* ``rxpkts``: Packets to RX split configuration.
+
 * ``txpkts``: Packets to TX configuration.
 
 * ``txtimes``: Burst time pattern for Tx only mode.
@@ -774,6 +776,23 @@ When retry is enabled, the transmit delay time and number of retries can also be
 
    testpmd> set burst tx delay (microseconds) retry (num)
 
+set rxpkts
+~~~~~~~~~~
+
+Set the length of segments to scatter packets on receiving if split
+feature is engaged. Affects only the queues configured with split offloads
+(currently BUFFER_SPLIT is supported only). Optionally the multiple memory
+pools can be specified with --mbuf-size command line parameter and the mbufs
+to receive will be allocated sequentially from these extra memory pools (the
+mbuf for the first segment is allocated from the first pool, the second one
+from the second pool, and so on, if segment number is greater then pool's the
+mbuf for remaining segments will be allocated from the last valid pool).
+
+   testpmd> set rxpkts (x[,y]*)
+
+Where x[,y]* represents a CSV list of values, without white space. Zero value
+means to use the corresponding memory pool data buffer size.
+
 set txpkts
 ~~~~~~~~~~
 
Signature · 1 line
1.8.3.1
#55 lore raw

PATCH v4 5/9 app/testpmd: add extended Rx queue setup

In reply to Viacheslav Ovsiienko

If Rx queue is configured with split feature the extended setup with specified segment sizes and pool will be performed.

---
 app/test-pmd/cmdline.c | 12 ++++++------
 app/test-pmd/testpmd.c | 38 ++++++++++++++++++++++++++++++++++++--
 app/test-pmd/testpmd.h |  6 ++++++
 3 files changed, 48 insertions(+), 8 deletions(-)
app/test-pmd/cmdline.c +6 -6
index d8dba54..cf99f66 100644
@@ -2921,12 +2921,12 @@ struct cmd_setup_rxtx_queue {
 				rxring_numa[res->portid]);
 			return;
 		}
-		ret = rte_eth_rx_queue_setup(res->portid,
-					     res->qid,
-					     port->nb_rx_desc[res->qid],
-					     socket_id,
-					     &port->rx_conf[res->qid],
-					     mp);
+		ret = rx_queue_setup(res->portid,
+				     res->qid,
+				     port->nb_rx_desc[res->qid],
+				     socket_id,
+				     &port->rx_conf[res->qid],
+				     mp);
 		if (ret)
 			printf("Failed to setup RX queue\n");
 	} else {
app/test-pmd/testpmd.c +36 -2
index f88c1e2..8cc265e 100644
@@ -2412,6 +2412,40 @@ struct extmem_param {
 	return 0;
 }
 
+/* Configure the Rx with optional split. */
+int
+rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+	       uint16_t nb_rx_desc, unsigned int socket_id,
+	       const struct rte_eth_rxconf *rx_conf,
+	       struct rte_mempool *mp)
+{
+	struct rte_eth_rxseg rx_seg[MAX_SEGS_BUFFER_SPLIT] = {};
+	unsigned int i, mp_n;
+
+	if (rx_pkt_nb_segs <= 1 ||
+	    (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) == 0)
+		return rte_eth_rx_queue_setup(port_id, rx_queue_id,
+					      nb_rx_desc, socket_id,
+					      rx_conf, mp);
+	for (i = 0; i < rx_pkt_nb_segs; i++) {
+		struct rte_mempool *mpx;
+		/*
+		 * Use last valid pool for the segments with number
+		 * exceeding the pool index.
+		 */
+		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[i].length = rx_pkt_seg_lengths[i] ?
+				   rx_pkt_seg_lengths[i] :
+				   mbuf_data_size[mp_n];
+		rx_seg[i].mp = mpx ? mpx : mp;
+	}
+	return rte_eth_rxseg_queue_setup(port_id, rx_queue_id,
+					 nb_rx_desc, socket_id, rx_conf,
+					 rx_seg, rx_pkt_nb_segs);
+}
+
 int
 start_port(portid_t pid)
 {
@@ -2520,7 +2554,7 @@ struct extmem_param {
 						return -1;
 					}
 
-					diag = rte_eth_rx_queue_setup(pi, qi,
+					diag = rx_queue_setup(pi, qi,
 					     port->nb_rx_desc[qi],
 					     rxring_numa[pi],
 					     &(port->rx_conf[qi]),
@@ -2536,7 +2570,7 @@ struct extmem_param {
 							port->socket_id);
 						return -1;
 					}
-					diag = rte_eth_rx_queue_setup(pi, qi,
+					diag = rx_queue_setup(pi, qi,
 					     port->nb_rx_desc[qi],
 					     port->socket_id,
 					     &(port->rx_conf[qi]),
app/test-pmd/testpmd.h +6 -0
index 8e5ba6a..5cef419 100644
@@ -872,6 +872,12 @@ void port_rss_reta_info(portid_t port_id,
 
 void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on);
 
+int
+rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+	       uint16_t nb_rx_desc, unsigned int socket_id,
+	       const struct rte_eth_rxconf *rx_conf,
+	       struct rte_mempool *mp);
+
 int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate);
 int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate,
 				uint64_t q_msk);
Signature · 1 line
1.8.3.1
#56 lore raw

PATCH v4 6/9 net/mlx5: add extended Rx queue setup routine

In reply to Viacheslav Ovsiienko

The routine to provide Rx queue setup with specifying extended receiving buffer description is added. It allows application to specify desired segment lengths, data position offsets in the buffer and dedicated memory pool for each segment.

---
 drivers/net/mlx5/linux/mlx5_os.c |  2 +
 drivers/net/mlx5/mlx5.h          |  3 ++
 drivers/net/mlx5/mlx5_rxq.c      | 91 +++++++++++++++++++++++++++++++++++-----
 drivers/net/mlx5/mlx5_rxtx.h     | 10 ++++-
 4 files changed, 95 insertions(+), 11 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +2 -0
index 487714f..0e85489 100644
@@ -2495,6 +2495,7 @@
 	.dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
 	.vlan_filter_set = mlx5_vlan_filter_set,
 	.rx_queue_setup = mlx5_rx_queue_setup,
+	.rxseg_queue_setup = mlx5_rxseg_queue_setup,
 	.rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
 	.tx_queue_setup = mlx5_tx_queue_setup,
 	.tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
@@ -2578,6 +2579,7 @@
 	.dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
 	.vlan_filter_set = mlx5_vlan_filter_set,
 	.rx_queue_setup = mlx5_rx_queue_setup,
+	.rxseg_queue_setup = mlx5_rxseg_queue_setup,
 	.rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
 	.tx_queue_setup = mlx5_tx_queue_setup,
 	.tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
drivers/net/mlx5/mlx5.h +3 -0
index 87d3c15..bfc0812 100644
@@ -162,6 +162,9 @@ struct mlx5_stats_ctrl {
 /* Maximal size of aggregated LRO packet. */
 #define MLX5_MAX_LRO_SIZE (UINT8_MAX * MLX5_LRO_SEG_CHUNK_SIZE)
 
+/* Maximal number of segments to split. */
+#define MLX5_MAX_RXQ_NSEG (1u << MLX5_MAX_LOG_RQ_SEGS)
+
 /* LRO configurations structure. */
 struct mlx5_lro_config {
 	uint32_t supported:1; /* Whether LRO is supported. */
drivers/net/mlx5/mlx5_rxq.c +81 -10

144 lines not on this page · raw message

drivers/net/mlx5/mlx5_rxtx.h +9 -1
index 674296e..f103a30 100644
@@ -150,6 +150,9 @@ struct mlx5_rxq_data {
 	rte_spinlock_t *uar_lock_cq;
 	/* CQ (UAR) access lock required for 32bit implementations */
 #endif
+	struct rte_eth_rxseg rxseg[MLX5_MAX_RXQ_NSEG];
+	/* Buffer split segment descriptions - sizes, offsets, pools. */
+	uint32_t rxseg_n; /* Number of split segment descriptions. */
 	uint32_t tunnel; /* Tunnel information. */
 	uint64_t flow_meta_mask;
 	int32_t flow_meta_offset;
@@ -304,6 +307,10 @@ struct mlx5_txq_ctrl {
 int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 			unsigned int socket, const struct rte_eth_rxconf *conf,
 			struct rte_mempool *mp);
+int mlx5_rxseg_queue_setup
+	(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
+	 unsigned int socket, const struct rte_eth_rxconf *conf,
+	 const struct rte_eth_rxseg *rx_seg, uint16_t n_seg);
 int mlx5_rx_hairpin_queue_setup
 	(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 	 const struct rte_eth_hairpin_conf *hairpin_conf);
@@ -316,7 +323,8 @@ int mlx5_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 struct mlx5_rxq_ctrl *mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx,
 				   uint16_t desc, unsigned int socket,
 				   const struct rte_eth_rxconf *conf,
-				   struct rte_mempool *mp);
+				   const struct rte_eth_rxseg *rx_seg,
+				   uint16_t n_seg);
 struct mlx5_rxq_ctrl *mlx5_rxq_hairpin_new
 	(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
 	 const struct rte_eth_hairpin_conf *hairpin_conf);
Signature · 1 line
1.8.3.1
#57 lore raw

PATCH v4 7/9 net/mlx5: configure Rx queue to support split

In reply to Viacheslav Ovsiienko

The scatter-gather elements should be configured accordingly to support the buffer split feature. The application provides the desired settings for the segments at the beginning of the packets and PMD pads the buffer chain (if needed) with attributes of last specified segment to accommodate the packet of maximal length.

There are some limitations are implied. The MPRQ feature should be disengaged if split is requested, due to MPRQ neither supports pushing data to the dedicated pools nor follows the flexible buffer sizes. The vectorized rx_burst routines does not support the scattering (these ones are extremely simplified and work over the single segment only) and can't handle split as well.

---
 drivers/net/mlx5/mlx5_rxq.c | 94 ++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 80 insertions(+), 14 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +80 -14
index 42818d8..4ec4677 100644
@@ -1417,7 +1417,8 @@ struct mlx5_rxq_ctrl *
 	uint64_t offloads = conf->offloads |
 			   dev->data->dev_conf.rxmode.offloads;
 	unsigned int lro_on_queue = !!(offloads & DEV_RX_OFFLOAD_TCP_LRO);
-	const int mprq_en = mlx5_check_mprq_support(dev) > 0 && n_seg == 1;
+	const int mprq_en = mlx5_check_mprq_support(dev) > 0 && n_seg == 1 &&
+			    !rx_seg[0].offset && !rx_seg[0].length;
 	unsigned int max_rx_pkt_len = lro_on_queue ?
 			dev->data->dev_conf.rxmode.max_lro_pkt_size :
 			dev->data->dev_conf.rxmode.max_rx_pkt_len;
@@ -1425,22 +1426,87 @@ struct mlx5_rxq_ctrl *
 							RTE_PKTMBUF_HEADROOM;
 	unsigned int max_lro_size = 0;
 	unsigned int first_mb_free_size = mb_len - RTE_PKTMBUF_HEADROOM;
+	const struct rte_eth_rxseg *qs_seg = rx_seg;
+	unsigned int tail_len;
 
-	if (non_scatter_min_mbuf_size > mb_len && !(offloads &
-						    DEV_RX_OFFLOAD_SCATTER)) {
+	tmpl = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, sizeof(*tmpl) +
+			   desc_n * sizeof(struct rte_mbuf *), 0, socket);
+	if (!tmpl) {
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+	MLX5_ASSERT(n_seg && n_seg <= MLX5_MAX_RXQ_NSEG);
+	/*
+	 * Build the array of actual buffer offsets and lengths.
+	 * Pad with the buffers from the last memory pool if
+	 * needed to handle max size packets, replace zero length
+	 * with the buffer length from the pool.
+	 */
+	tail_len = max_rx_pkt_len;
+	do {
+		struct rte_eth_rxseg *hw_seg =
+					&tmpl->rxq.rxseg[tmpl->rxq.rxseg_n];
+		uint32_t buf_len = rte_pktmbuf_data_room_size(qs_seg->mp);
+		uint32_t offset, seg_len;
+
+		/*
+		 * For the buffers beyond descriptions offset is zero,
+		 * the first buffer contains head room.
+		 */
+		offset = (tmpl->rxq.rxseg_n >= n_seg ? 0 : qs_seg->offset) +
+			 (tmpl->rxq.rxseg_n ? 0 : RTE_PKTMBUF_HEADROOM);
+		/*
+		 * For the buffers beyond descriptions the length is
+		 * pool buffer length, zero lengths are replaced with
+		 * pool buffer length either.
+		 */
+		seg_len = tmpl->rxq.rxseg_n >= n_seg ? buf_len :
+			  qs_seg->length ? qs_seg->length : (buf_len - offset);
+		/* Check is done in long int, now overflows. */
+		if (buf_len < seg_len + offset) {
+			DRV_LOG(ERR, "port %u Rx queue %u: Split offset/length "
+				     "%u/%u can't be satisfied",
+				     dev->data->port_id, idx,
+				     qs_seg->length, qs_seg->offset);
+			rte_errno = EINVAL;
+			goto error;
+		}
+		if (seg_len > tail_len)
+			seg_len = buf_len - offset;
+		if (++tmpl->rxq.rxseg_n > MLX5_MAX_RXQ_NSEG) {
+			DRV_LOG(ERR,
+				"port %u too many SGEs (%u) needed to handle"
+				" requested maximum packet size %u, the maximum"
+				" supported are %u", dev->data->port_id,
+				tmpl->rxq.rxseg_n, max_rx_pkt_len,
+				MLX5_MAX_RXQ_NSEG);
+			rte_errno = ENOTSUP;
+			goto error;
+		}
+		/* Build the actual scattering element in the queue object. */
+		hw_seg->mp = qs_seg->mp;
+		MLX5_ASSERT(offset <= UINT16_MAX);
+		MLX5_ASSERT(seg_len <= UINT16_MAX);
+		hw_seg->offset = (uint16_t)offset;
+		hw_seg->length = (uint16_t)seg_len;
+		/*
+		 * Advance the segment descriptor, the padding is the based
+		 * on the attributes of the last descriptor.
+		 */
+		if (tmpl->rxq.rxseg_n < n_seg)
+			qs_seg++;
+		tail_len -= RTE_MIN(tail_len, seg_len);
+	} while (tail_len || !rte_is_power_of_2(tmpl->rxq.rxseg_n));
+	MLX5_ASSERT(tmpl->rxq.rxseg_n &&
+		    tmpl->rxq.rxseg_n <= MLX5_MAX_RXQ_NSEG);
+	if (tmpl->rxq.rxseg_n > 1 && !(offloads & DEV_RX_OFFLOAD_SCATTER)) {
 		DRV_LOG(ERR, "port %u Rx queue %u: Scatter offload is not"
 			" configured and no enough mbuf space(%u) to contain "
 			"the maximum RX packet length(%u) with head-room(%u)",
 			dev->data->port_id, idx, mb_len, max_rx_pkt_len,
 			RTE_PKTMBUF_HEADROOM);
 		rte_errno = ENOSPC;
-		return NULL;
-	}
-	tmpl = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, sizeof(*tmpl) +
-			   desc_n * sizeof(struct rte_mbuf *), 0, socket);
-	if (!tmpl) {
-		rte_errno = ENOMEM;
-		return NULL;
+		goto error;
 	}
 	tmpl->type = MLX5_RXQ_TYPE_STANDARD;
 	if (mlx5_mr_btree_init(&tmpl->rxq.mr_ctrl.cache_bh,
@@ -1467,7 +1533,7 @@ struct mlx5_rxq_ctrl *
 	 *  - The number of descs is more than the number of strides.
 	 *  - max_rx_pkt_len plus overhead is less than the max size
 	 *    of a stride or mprq_stride_size is specified by a user.
-	 *    Need to nake sure that there are enough stides to encap
+	 *    Need to make sure that there are enough stides to encap
 	 *    the maximum packet size in case mprq_stride_size is set.
 	 *  Otherwise, enable Rx scatter if necessary.
 	 */
@@ -1497,11 +1563,11 @@ struct mlx5_rxq_ctrl *
 			" strd_num_n = %u, strd_sz_n = %u",
 			dev->data->port_id, idx,
 			tmpl->rxq.strd_num_n, tmpl->rxq.strd_sz_n);
-	} else if (max_rx_pkt_len <= first_mb_free_size) {
+	} else if (tmpl->rxq.rxseg_n == 1) {
+		MLX5_ASSERT(max_rx_pkt_len <= first_mb_free_size);
 		tmpl->rxq.sges_n = 0;
 		max_lro_size = max_rx_pkt_len;
 	} else if (offloads & DEV_RX_OFFLOAD_SCATTER) {
-		unsigned int size = non_scatter_min_mbuf_size;
 		unsigned int sges_n;
 
 		if (lro_on_queue && first_mb_free_size <
@@ -1516,7 +1582,7 @@ struct mlx5_rxq_ctrl *
 		 * Determine the number of SGEs needed for a full packet
 		 * and round it to the next power of two.
 		 */
-		sges_n = log2above((size / mb_len) + !!(size % mb_len));
+		sges_n = log2above(tmpl->rxq.rxseg_n);
 		if (sges_n > MLX5_MAX_LOG_RQ_SEGS) {
 			DRV_LOG(ERR,
 				"port %u too many SGEs (%u) needed to handle"
Signature · 1 line
1.8.3.1
#58 lore raw

PATCH v4 8/9 net/mlx5: register multiple pool for Rx queue

In reply to Viacheslav Ovsiienko

The split feature for receiving packets was added to the mlx5 PMD, now Rx queue can receive the data to the buffers belonging to the different pools and the memory of all the involved pool must be registered for DMA operations in order to allow hardware to store the data.

---
 drivers/net/mlx5/mlx5_mr.c      |  3 +++
 drivers/net/mlx5/mlx5_trigger.c | 20 ++++++++++++--------
 2 files changed, 15 insertions(+), 8 deletions(-)
drivers/net/mlx5/mlx5_mr.c +3 -0
index dbcf0aa..c308ecc 100644
@@ -536,6 +536,9 @@ struct mr_update_mp_data {
 		.ret = 0,
 	};
 
+	DRV_LOG(DEBUG, "Port %u Rx queue registering mp %s "
+		       "having %u chunks.", dev->data->port_id,
+		       mp->name, mp->nb_mem_chunks);
 	rte_mempool_mem_iter(mp, mlx5_mr_update_mp_cb, &data);
 	if (data.ret < 0 && rte_errno == ENXIO) {
 		/* Mempool may have externally allocated memory. */
drivers/net/mlx5/mlx5_trigger.c +12 -8
index e72e5fb..643e10f 100644
@@ -145,18 +145,22 @@
 		dev->data->port_id, priv->sh->device_attr.max_sge);
 	for (i = 0; i != priv->rxqs_n; ++i) {
 		struct mlx5_rxq_ctrl *rxq_ctrl = mlx5_rxq_get(dev, i);
-		struct rte_mempool *mp;
 
 		if (!rxq_ctrl)
 			continue;
 		if (rxq_ctrl->type == MLX5_RXQ_TYPE_STANDARD) {
-			/* Pre-register Rx mempool. */
-			mp = mlx5_rxq_mprq_enabled(&rxq_ctrl->rxq) ?
-			     rxq_ctrl->rxq.mprq_mp : rxq_ctrl->rxq.mp;
-			DRV_LOG(DEBUG, "Port %u Rx queue %u registering mp %s"
-				" having %u chunks.", dev->data->port_id,
-				rxq_ctrl->rxq.idx, mp->name, mp->nb_mem_chunks);
-			mlx5_mr_update_mp(dev, &rxq_ctrl->rxq.mr_ctrl, mp);
+			/* Pre-register Rx mempools. */
+			if (mlx5_rxq_mprq_enabled(&rxq_ctrl->rxq)) {
+				mlx5_mr_update_mp(dev, &rxq_ctrl->rxq.mr_ctrl,
+						  rxq_ctrl->rxq.mprq_mp);
+			} else {
+				uint32_t s;
+
+				for (s = 0; s < rxq_ctrl->rxq.rxseg_n; s++)
+					mlx5_mr_update_mp
+						(dev, &rxq_ctrl->rxq.mr_ctrl,
+						rxq_ctrl->rxq.rxseg[s].mp);
+			}
 			ret = rxq_alloc_elts(rxq_ctrl);
 			if (ret)
 				goto error;
Signature · 1 line
1.8.3.1
#59 lore raw

PATCH v4 9/9 net/mlx5: update Rx datapath to support split

In reply to Viacheslav Ovsiienko

Only the regular rx_burst routine is updated to support split, because the vectorized ones does not support scatter and MPRQ does not support split at all.

---
 drivers/net/mlx5/mlx5_rxq.c  | 11 +++++------
 drivers/net/mlx5/mlx5_rxtx.c |  3 ++-
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/mlx5/mlx5_rxq.c +5 -6
index 4ec4677..2ebb265 100644
@@ -210,9 +210,10 @@
 
 	/* Iterate on segments. */
 	for (i = 0; (i != elts_n); ++i) {
+		struct rte_eth_rxseg *seg = &rxq_ctrl->rxq.rxseg[i % sges_n];
 		struct rte_mbuf *buf;
 
-		buf = rte_pktmbuf_alloc(rxq_ctrl->rxq.mp);
+		buf = rte_pktmbuf_alloc(seg->mp);
 		if (buf == NULL) {
 			DRV_LOG(ERR, "port %u empty mbuf pool",
 				PORT_ID(rxq_ctrl->priv));
@@ -225,12 +226,10 @@
 		MLX5_ASSERT(rte_pktmbuf_data_len(buf) == 0);
 		MLX5_ASSERT(rte_pktmbuf_pkt_len(buf) == 0);
 		MLX5_ASSERT(!buf->next);
-		/* Only the first segment keeps headroom. */
-		if (i % sges_n)
-			SET_DATA_OFF(buf, 0);
+		SET_DATA_OFF(buf, seg->offset);
 		PORT(buf) = rxq_ctrl->rxq.port_id;
-		DATA_LEN(buf) = rte_pktmbuf_tailroom(buf);
-		PKT_LEN(buf) = DATA_LEN(buf);
+		DATA_LEN(buf) = seg->length;
+		PKT_LEN(buf) = seg->length;
 		NB_SEGS(buf) = 1;
 		(*rxq_ctrl->rxq.elts)[i] = buf;
 	}
drivers/net/mlx5/mlx5_rxtx.c +2 -1
index b530ff4..dd84249 100644
@@ -1334,7 +1334,8 @@ enum mlx5_txcmp_code {
 		rte_prefetch0(seg);
 		rte_prefetch0(cqe);
 		rte_prefetch0(wqe);
-		rep = rte_mbuf_raw_alloc(rxq->mp);
+		/* Allocate the buf from the same pool. */
+		rep = rte_mbuf_raw_alloc(seg->pool);
 		if (unlikely(rep == NULL)) {
 			++rxq->stats.rx_nombuf;
 			if (!pkt) {
Signature · 1 line
1.8.3.1
#60 lore raw

v5 cover ethdev: introduce Rx buffer split

In reply to Slava Ovsiienko

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
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 reserved; /* reserved field */
};

The segment descriptions are added to the rte_eth_rxconf structure:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf. This array allows to specify the different settings for each segment in individual fashion.
n_seg - number of elements in the array

If the extended segment descriptions is provided with these new fields the mp parameter of the rte_eth_rx_queue_setup must be specified as NULL to avoid ambiguity.

The new offload flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup() routine application should check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will split the received packets into multiple segments according to the specification in the description array:

- the first network buffer will be allocated from the memory pool, specified in the first segment description element, the second network buffer - from the pool in the second segment description element and so on. If there is no enough elements to describe the buffer for entire packet of maximal length the pool from the last valid element will be used to allocate the buffers from for the rest of segments

- the offsets from the segment description elements will provide the data offset from the buffer beginning except the first mbuf - for this one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual offset from the buffer beginning. If there is no enough elements to describe the buffer for entire packet of maximal length the offsets for the rest of segment will be supposed to be zero.

- the data length being received to each segment is limited by the length specified in the segment description element. The data receiving starts with filling up the first mbuf data buffer, if the specified maximal segment length is reached and there are data remaining (packet is longer than buffer in the first mbuf) the following data will be pushed to the next segment up to its own maximal length. If the first two segments is not enough to store all the packet remaining data the next (third) segment will be engaged and so on. If the length in the segment description element is zero the actual buffer size will be deduced from the appropriate memory pool properties. If there is no enough elements to describe the buffer for entire packet of maximal length the buffer size will be deduced from the pool of the last valid element for the remaining segments.

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B long @ 128 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B @ 128 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload RTE_ETH_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

---
v1: http://patches.dpdk.org/patch/79594/
v2: http://patches.dpdk.org/patch/79893/
- add feature support to mlx5 PMD

v3: http://patches.dpdk.org/patch/80389/
- rte_eth_rx_queue_setup_ex is renamed to rte_eth_rxseg_queue_setup
- DEV_RX_OFFLOAD_BUFFER_SPLIT is renamed to RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT
- commit message update
- documentaion provided
- release notes update
- minor bug fixes in testpmd related part

v4: http://patches.dpdk.org/patch/80401/
- common part of rx_queue_setup/rxseg_queue_setup

v5: - refactored to approach of providing split configuration
in the rte_eth_rxconf structure instead of introducing the new API routine
- added support for rxoffs command to testpmd to provide segment offsets for complete testing of split configurations
- patchset is split into two parts - PMD part will be presented as separate series

Viacheslav Ovsiienko (6):
ethdev: introduce Rx buffer split app/testpmd: add multiple pools per core creation app/testpmd: add buffer split offload configuration app/testpmd: add rxpkts commands and parameters app/testpmd: add rxoffs commands and parameters app/testpmd: add extended Rx queue setup

 app/test-pmd/bpf_cmd.c                      |   4 +-
 app/test-pmd/cmdline.c                      | 151 ++++++++++++++++++++++++----
 app/test-pmd/config.c                       | 107 +++++++++++++++++++-
 app/test-pmd/parameters.c                   |  54 ++++++++--
 app/test-pmd/testpmd.c                      | 120 ++++++++++++++++------
 app/test-pmd/testpmd.h                      |  44 ++++++--
 doc/guides/nics/features.rst                |  15 +++
 doc/guides/rel_notes/release_20_11.rst      |   9 ++
 doc/guides/testpmd_app_ug/run_app.rst       |  22 +++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  36 ++++++-
 lib/librte_ethdev/rte_ethdev.c              |  95 +++++++++++++----
 lib/librte_ethdev/rte_ethdev.h              |  58 ++++++++++-
 lib/librte_ethdev/rte_ethdev_version.map    |   1 +
 13 files changed, 621 insertions(+), 95 deletions(-)
Signature · 1 line
1.8.3.1
#61 lore raw

PATCH v5 1/6 ethdev: introduce Rx buffer split

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
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 reserved; /* reserved field */
};

The segment descriptions are added to the rte_eth_rxconf structure:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf. This array allows to specify the different settings for each segment in individual fashion.
n_seg - number of elements in the array

If the extended segment descriptions is provided with these new fields the mp parameter of the rte_eth_rx_queue_setup must be specified as NULL to avoid ambiguity.

The new offload flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup() routine application should check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will split the received packets into multiple segments according to the specification in the description array:

- the first network buffer will be allocated from the memory pool, specified in the first segment description element, the second network buffer - from the pool in the second segment description element and so on. If there is no enough elements to describe the buffer for entire packet of maximal length the pool from the last valid element will be used to allocate the buffers from for the rest of segments

- the offsets from the segment description elements will provide the data offset from the buffer beginning except the first mbuf - for this one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual offset from the buffer beginning. If there is no enough elements to describe the buffer for entire packet of maximal length the offsets for the rest of segment will be supposed to be zero.

- the data length being received to each segment is limited by the length specified in the segment description element. The data receiving starts with filling up the first mbuf data buffer, if the specified maximal segment length is reached and there are data remaining (packet is longer than buffer in the first mbuf) the following data will be pushed to the next segment up to its own maximal length. If the first two segments is not enough to store all the packet remaining data the next (third) segment will be engaged and so on. If the length in the segment description element is zero the actual buffer size will be deduced from the appropriate memory pool properties. If there is no enough elements to describe the buffer for entire packet of maximal length the buffer size will be deduced from the pool of the last valid element for the remaining segments.

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B long @ 128 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B @ 128 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload RTE_ETH_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

---
 doc/guides/nics/features.rst             | 15 +++++
 doc/guides/rel_notes/release_20_11.rst   |  9 +++
 lib/librte_ethdev/rte_ethdev.c           | 95 ++++++++++++++++++++++++--------
 lib/librte_ethdev/rte_ethdev.h           | 58 ++++++++++++++++++-
 lib/librte_ethdev/rte_ethdev_version.map |  1 +
 5 files changed, 155 insertions(+), 23 deletions(-)
doc/guides/nics/features.rst +15 -0
index dd8c955..a45a9e8 100644
@@ -185,6 +185,21 @@ Supports receiving segmented mbufs.
 * **[related]    eth_dev_ops**: ``rx_pkt_burst``.
 
 
+.. _nic_features_buffer_split:
+
+Buffer Split on Rx
+------------------
+
+Scatters the packets being received on specified boundaries to segmented mbufs.
+
+* **[uses]       rte_eth_rxconf,rte_eth_rxmode**: ``offloads:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[implements] datapath**: ``Buffer Split functionality``.
+* **[implements] rte_eth_dev_data**: ``buffer_split``.
+* **[provides]   rte_eth_dev_info**: ``rx_offload_capa:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[provides]   eth_dev_ops**: ``rxq_info_get:buffer_split``.
+* **[related] API**: ``rte_eth_rx_queue_setup()``.
+
+
 .. _nic_features_lro:
 
 LRO
doc/guides/rel_notes/release_20_11.rst +9 -0
index bcc0fc2..f67ec62 100644
@@ -60,6 +60,12 @@ New Features
   Added the FEC API which provides functions for query FEC capabilities and
   current FEC mode from device. Also, API for configuring FEC mode is also provided.
 
+* **Introduced extended buffer description for receiving.**
+
+  Added the extended Rx queue setup routine providing the individual
+  descriptions for each Rx segment with maximal size, buffer offset and memory
+  pool to allocate data buffers from.
+
 * **Updated Broadcom bnxt driver.**
 
   Updated the Broadcom bnxt driver with new features and improvements, including:
@@ -253,6 +259,9 @@ API Changes
   As the data of ``uint8_t`` will be truncated when queue number under
   a TC is greater than 256.
 
+* ethdev: Added fields rx_seg and rx_nseg to rte_eth_rxconf structure
+  to provide extended description of the receiving buffer.
+
 * vhost: Moved vDPA APIs from experimental to stable.
 
 * rawdev: Added a structure size parameter to the functions
lib/librte_ethdev/rte_ethdev.c +73 -22

142 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +57 -1

88 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev_version.map +1 -0
index f8a0945..25f7cee 100644
@@ -232,6 +232,7 @@ EXPERIMENTAL {
 	rte_eth_fec_get_capability;
 	rte_eth_fec_get;
 	rte_eth_fec_set;
+
 };
 
 INTERNAL {
Signature · 1 line
1.8.3.1
#62 lore raw
Quoted 114 lines · Viacheslav Ovsiienko

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
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 reserved; /* reserved field */
};

The segment descriptions are added to the rte_eth_rxconf structure:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf.
This array allows to specify the different settings for each segment in individual fashion.
n_seg - number of elements in the array

If the extended segment descriptions is provided with these new fields the mp parameter of the rte_eth_rx_queue_setup must be specified as NULL to avoid ambiguity.

The new offload flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup() routine application should check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will split the received packets into multiple segments according to the specification in the description array:

- the first network buffer will be allocated from the memory pool, specified in the first segment description element, the second network buffer - from the pool in the second segment description element and so on. If there is no enough elements to describe the buffer for entire packet of maximal length the pool from the last valid element will be used to allocate the buffers from for the rest of segments

- the offsets from the segment description elements will provide the data offset from the buffer beginning except the first mbuf - for this one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual offset from the buffer beginning. If there is no enough elements to describe the buffer for entire packet of maximal length the offsets for the rest of segment will be supposed to be zero.

- the data length being received to each segment is limited by the length specified in the segment description element. The data receiving starts with filling up the first mbuf data buffer, if the specified maximal segment length is reached and there are data remaining (packet is longer than buffer in the first mbuf) the following data will be pushed to the next segment up to its own maximal length. If the first two segments is not enough to store all the packet remaining data the next (third) segment will be engaged and so on. If the length in the segment description element is zero the actual buffer size will be deduced from the appropriate memory pool properties. If there is no enough elements to describe the buffer for entire packet of maximal length the buffer size will be deduced from the pool of the last valid element for the remaining segments.

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

     seg0 - pool0, len0=14B, off0=2
     seg1 - pool1, len1=20B, off1=128B
     seg2 - pool2, len2=20B, off2=0B
     seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B long @ 128 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B @ 128 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload RTE_ETH_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

Quoted 7 lines
---
  doc/guides/nics/features.rst             | 15 +++++
  doc/guides/rel_notes/release_20_11.rst   |  9 +++
  lib/librte_ethdev/rte_ethdev.c           | 95 ++++++++++++++++++++++++--------
  lib/librte_ethdev/rte_ethdev.h           | 58 ++++++++++++++++++-
  lib/librte_ethdev/rte_ethdev_version.map |  1 +

Can you please update deprecation notice too, to remove the notice?

Quoted 8 lines
  5 files changed, 155 insertions(+), 23 deletions(-)
doc/guides/nics/features.rst +0 -0
index dd8c955..a45a9e8 100644
@@ -185,6 +185,21 @@ Supports receiving segmented mbufs.
  * **[related]    eth_dev_ops**: ``rx_pkt_burst``.

doc/guides/nics/features.rst Supports receiving segmented mbufs. · line 195

Quoted 10 lines
doc/guides/nics/features.rst +8 -0
 
 
+.. _nic_features_buffer_split:
+
+Buffer Split on Rx
+------------------
+
+Scatters the packets being received on specified boundaries to segmented mbufs.
+
+* **[uses]       rte_eth_rxconf,rte_eth_rxmode**: ``offloads:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.

uses 'rx_seg and rx_nseg' from 'rte_eth_rxconf', perhaps it can be another line.

doc/guides/nics/features.rst Supports receiving segmented mbufs. · line 197

Quoted 2 lines
doc/guides/nics/features.rst +2 -0
+* **[implements] datapath**: ``Buffer Split functionality``.
+* **[implements] rte_eth_dev_data**: ``buffer_split``.

What is implemented here?

doc/guides/nics/features.rst Supports receiving segmented mbufs. · line 199

Quoted 2 lines
doc/guides/nics/features.rst +2 -0
+* **[provides]   rte_eth_dev_info**: ``rx_offload_capa:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[provides]   eth_dev_ops**: ``rxq_info_get:buffer_split``.

Is this correct?

Quoted 11 lines
doc/guides/nics/features.rst +3 -0
+* **[related] API**: ``rte_eth_rx_queue_setup()``.
+
+
  .. _nic_features_lro:
 
  LRO
doc/guides/rel_notes/release_20_11.rst +0 -0
index bcc0fc2..f67ec62 100644

doc/guides/rel_notes/release_20_11.rst New Features · line 65

Quoted 6 lines
doc/guides/rel_notes/release_20_11.rst +3 -0
@@ -60,6 +60,12 @@ New Features
    Added the FEC API which provides functions for query FEC capabilities and
    current FEC mode from device. Also, API for configuring FEC mode is also provided.
 
+* **Introduced extended buffer description for receiving.**
+
+  Added the extended Rx queue setup routine providing the individual

This looks wrong with last version.

Quoted 69 lines
doc/guides/rel_notes/release_20_11.rst +6 -0
+  descriptions for each Rx segment with maximal size, buffer offset and memory
+  pool to allocate data buffers from.
+
  * **Updated Broadcom bnxt driver.**
 
    Updated the Broadcom bnxt driver with new features and improvements, including:
@@ -253,6 +259,9 @@ API Changes
    As the data of ``uint8_t`` will be truncated when queue number under
    a TC is greater than 256.
 
+* ethdev: Added fields rx_seg and rx_nseg to rte_eth_rxconf structure
+  to provide extended description of the receiving buffer.
+
  * vhost: Moved vDPA APIs from experimental to stable.
 
  * rawdev: Added a structure size parameter to the functions
lib/librte_ethdev/rte_ethdev.c +10 -5
index 892c246..7b64a6e 100644
@@ -105,6 +105,9 @@ struct rte_eth_xstats_name_off {
  #define RTE_RX_OFFLOAD_BIT2STR(_name)	\
  	{ DEV_RX_OFFLOAD_##_name, #_name }
 
+#define RTE_ETH_RX_OFFLOAD_BIT2STR(_name)	\
+	{ RTE_ETH_RX_OFFLOAD_##_name, #_name }
+
  static const struct {
  	uint64_t offload;
  	const char *name;
@@ -128,9 +131,11 @@ struct rte_eth_xstats_name_off {
  	RTE_RX_OFFLOAD_BIT2STR(SCTP_CKSUM),
  	RTE_RX_OFFLOAD_BIT2STR(OUTER_UDP_CKSUM),
  	RTE_RX_OFFLOAD_BIT2STR(RSS_HASH),
+	RTE_ETH_RX_OFFLOAD_BIT2STR(BUFFER_SPLIT),
  };
 
  #undef RTE_RX_OFFLOAD_BIT2STR
+#undef RTE_ETH_RX_OFFLOAD_BIT2STR
 
  #define RTE_TX_OFFLOAD_BIT2STR(_name)	\
  	{ DEV_TX_OFFLOAD_##_name, #_name }
@@ -1770,10 +1775,14 @@ struct rte_eth_dev *
  		       struct rte_mempool *mp)
  {
  	int ret;
+	uint16_t seg_idx;
  	uint32_t mbp_buf_size;
  	struct rte_eth_dev *dev;
  	struct rte_eth_dev_info dev_info;
  	struct rte_eth_rxconf local_conf;
+	const struct rte_eth_rxseg *rx_seg;
+	struct rte_eth_rxseg seg_single = { .mp = mp};
+	uint16_t n_seg;
  	void **rxq;
 
  	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
@@ -1784,13 +1793,32 @@ struct rte_eth_dev *
  		return -EINVAL;
  	}
 
-	if (mp == NULL) {
-		RTE_ETHDEV_LOG(ERR, "Invalid null mempool pointer\n");
-		return -EINVAL;
-	}
-
  	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP);
 
+	rx_seg = rx_conf->rx_seg;

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1808

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	n_seg = rx_conf->rx_nseg;
+	if (rx_seg == NULL) {
+		/* Exclude ambiguities about segment descrtiptions. */
+		if (n_seg) {
+			RTE_ETHDEV_LOG(ERR,
+				       "Non empty array with null pointer\n");
+			return -EINVAL;
+		}
+		rx_seg = &seg_single;
+		n_seg = 1;

Why setting 'rx_seg' & 'n_seg'? Why not leaving them NULL and 0 when not used? This was PMD can do NULL/0 check and can know they are not used.

I think better to do a "if (mp == NULL)" check here, both 'rx_seg' & 'mp' should not be NULL.

Quoted 56 lines
lib/librte_ethdev/rte_ethdev.c +33 -15
+	} else {
+		if (n_seg == 0) {
+			RTE_ETHDEV_LOG(ERR,
+				       "Invalid zero descriptions number\n");
+			return -EINVAL;
+		}
+		if (mp) {
+			RTE_ETHDEV_LOG(ERR,
+				       "Memory pool duplicated definition\n");
+			return -EINVAL;
+		}
+	}
+
  	/*
  	 * Check the size of the mbuf data buffer.
  	 * This value must be provided in the private data of the memory pool.
@@ -1800,23 +1828,48 @@ struct rte_eth_dev *
  	if (ret != 0)
  		return ret;
 
-	if (mp->private_data_size < sizeof(struct rte_pktmbuf_pool_private)) {
-		RTE_ETHDEV_LOG(ERR, "%s private_data_size %d < %d\n",
-			mp->name, (int)mp->private_data_size,
-			(int)sizeof(struct rte_pktmbuf_pool_private));
-		return -ENOSPC;
-	}
-	mbp_buf_size = rte_pktmbuf_data_room_size(mp);
+	for (seg_idx = 0; seg_idx < n_seg; seg_idx++) {
+		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 head_room = seg_idx ? 0 : RTE_PKTMBUF_HEADROOM;
 
-	if (mbp_buf_size < dev_info.min_rx_bufsize + RTE_PKTMBUF_HEADROOM) {
-		RTE_ETHDEV_LOG(ERR,
-			"%s mbuf_data_room_size %d < %d (RTE_PKTMBUF_HEADROOM=%d + min_rx_bufsize(dev)=%d)\n",
-			mp->name, (int)mbp_buf_size,
-			(int)(RTE_PKTMBUF_HEADROOM + dev_info.min_rx_bufsize),
-			(int)RTE_PKTMBUF_HEADROOM,
-			(int)dev_info.min_rx_bufsize);
-		return -EINVAL;
+		if (mpl == NULL) {
+			RTE_ETHDEV_LOG(ERR, "Invalid null mempool pointer\n");
+			return -EINVAL;
+		}
+
+		if (mpl->private_data_size <
+				sizeof(struct rte_pktmbuf_pool_private)) {
+			RTE_ETHDEV_LOG(ERR, "%s private_data_size %d < %d\n",
+				mpl->name, (int)mpl->private_data_size,
+				(int)sizeof(struct rte_pktmbuf_pool_private));
+			return -ENOSPC;
+		}
+
+		mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
+		length = length ? length : (mbp_buf_size - head_room);

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1861

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +9 -0
+		if (mbp_buf_size < length + offset + head_room) {
+			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;
+		}
  	}
+	/* Check the minimal buffer size for the single segment only. */

This is the main branch, what do you think moving the comment to the beggining of above for loop and add a comment about testing the multiple segment.

Btw, I have a concern that this single/multi segment can cause a confusion with multi segment packets. Can something else, like "split package" can be used instead of segment?

Quoted 15 lines
lib/librte_ethdev/rte_ethdev.c +11 -0
+	if (mp && (mbp_buf_size < dev_info.min_rx_bufsize +
+				  RTE_PKTMBUF_HEADROOM)) {
+		RTE_ETHDEV_LOG(ERR,
+			       "%s mbuf_data_room_size %u < %u "
+			       "(RTE_PKTMBUF_HEADROOM=%u + "
+			       "min_rx_bufsize(dev)=%u)\n",
+			       mp->name, mbp_buf_size,
+			       RTE_PKTMBUF_HEADROOM + dev_info.min_rx_bufsize,
+			       RTE_PKTMBUF_HEADROOM, dev_info.min_rx_bufsize);
+			return -EINVAL;
+		}
 
  	/* Use default specified by driver, if nb_rx_desc is zero */
  	if (nb_rx_desc == 0) {

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1918

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +0 -2
@@ -1914,8 +1967,6 @@ struct rte_eth_dev *
  			dev->data->min_rx_buf_size = mbp_buf_size;
  	}
 
-	rte_ethdev_trace_rxq_setup(port_id, rx_queue_id, nb_rx_desc, mp,
-		rx_conf, ret);

Is this removed intentionally?

Quoted 28 lines
lib/librte_ethdev/rte_ethdev.c +0 -0
  	return eth_err(port_id, ret);
  }
 
lib/librte_ethdev/rte_ethdev.h +10 -0
index 5bcfbb8..9cf0a03 100644
@@ -970,6 +970,16 @@ struct rte_eth_txmode {
  };
 
  /**
+ * A structure used to configure an RX packet segment to split.
+ */
+struct rte_eth_rxseg {
+	struct rte_mempool *mp; /**< Memory pools 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 */
+};
+
+/**
   * A structure used to configure an RX ring of an Ethernet port.
   */
  struct rte_eth_rxconf {
@@ -977,13 +987,23 @@ struct rte_eth_rxconf {
  	uint16_t rx_free_thresh; /**< Drives the freeing of RX descriptors. */
  	uint8_t rx_drop_en; /**< Drop packets if no descriptors are available. */
  	uint8_t rx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */

lib/librte_ethdev/rte_ethdev.h struct rte_eth_rxconf { · line 999

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+	uint16_t rx_nseg; /**< Number of descriptions in rx_seg array. */
+	/**
+	 * The pointer to the array of segment descriptions, each element
+	 * describes the memory pool, maximal segment data length, initial
+	 * data offset from the beginning of data buffer in mbuf. This allow
+	 * to specify the dedicated properties for each segment in the receiving
+	 * buffer - pool, buffer offset, maximal segment size. The number of
+	 * segment descriptions in the array is specified by the rx_nseg
+	 * field.
+	 */

What do you think providing a short description here, and move above comment to abice "struct rte_eth_rxseg" struct?

lib/librte_ethdev/rte_ethdev.h struct rte_eth_rxconf { · line 986

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.h +1 -1
+	struct rte_eth_rxseg *rx_seg;
  	/**
  	 * Per-queue Rx offloads to be set using DEV_RX_OFFLOAD_* flags.
  	 * Only offloads set on rx_queue_offload_capa or rx_offload_capa
  	 * fields on rte_eth_dev_info structure are allowed to be set.
  	 */
  	uint64_t offloads;
-

unrelated

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.h +1 -0
  	uint64_t reserved_64s[2]; /**< Reserved for future fields */
  	void *reserved_ptrs[2];   /**< Reserved for future fields */
  };
@@ -1260,6 +1280,7 @@ struct rte_eth_conf {
  #define DEV_RX_OFFLOAD_SCTP_CKSUM	0x00020000
  #define DEV_RX_OFFLOAD_OUTER_UDP_CKSUM  0x00040000
  #define DEV_RX_OFFLOAD_RSS_HASH		0x00080000
+#define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT 0x00100000
 
  #define DEV_RX_OFFLOAD_CHECKSUM (DEV_RX_OFFLOAD_IPV4_CKSUM | \
  				 DEV_RX_OFFLOAD_UDP_CKSUM | \

lib/librte_ethdev/rte_ethdev.h int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue, · line 2050

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.h +0 -0
@@ -2027,6 +2048,41 @@ int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue,
   *   No need to repeat any bit in rx_conf->offloads which has already been
   *   enabled in rte_eth_dev_configure() at port level. An offloading enabled
   *   at port level can't be disabled at queue level.

Can it be possible to put a kind of marker here, like "@rx_seg & @rx_nseg", to clarify what are you talking about.

Quoted 25 lines
lib/librte_ethdev/rte_ethdev.h +25 -0
+ *   The configuration structure also contains the pointer to the array
+ *   of the receiving buffer segment descriptions, each element describes
+ *   the memory pool, maximal segment data length, initial data offset from
+ *   the beginning of data buffer in mbuf. This allow to specify the dedicated
+ *   properties for each segment in the receiving buffer - pool, buffer
+ *   offset, maximal segment size. If RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload
+ *   flag is configured the PMD will split the received packets into multiple
+ *   segments according to the specification in the description array:
+ *   - the first network buffer will be allocated from the memory pool,
+ *     specified in the first segment description element, the second
+ *     network buffer - from the pool in the second segment description
+ *     element and so on. If there is no enough elements to describe
+ *     the buffer for entire packet of maximal length the pool from the last
+ *     valid element will be used to allocate the buffers from for the rest
+ *     of segments.
+ *   - the offsets from the segment description elements will provide the
+ *     data offset from the buffer beginning except the first mbuf - for this
+ *     one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual
+ *     offset from the buffer beginning. If there is no enough elements
+ *     to describe the buffer for entire packet of maximal length the offsets
+ *     for the rest of segment will be supposed to be zero.
+ *   - the data length being received to each segment is limited by the
+ *     length specified in the segment description element. The data receiving
+ *     starts with filling up the first mbuf data buffer, if the specified
+ *     maximal segment length is reached and there are data remaining

lib/librte_ethdev/rte_ethdev.h int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue, · line 2085

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+ *     (packet is longer than buffer in the first mbuf) the following data
+ *     will be pushed to the next segment up to its own length. If the first
+ *     two segments is not enough to store all the packet data the next
+ *     (third) segment will be engaged and so on. If the length in the segment
+ *     description element is zero the actual buffer size will be deduced
+ *     from the appropriate memory pool properties. If there is no enough
+ *     elements to describe the buffer for entire packet of maximal length
+ *     the buffer size will be deduced from the pool of the last valid
+ *     element for the all remaining segments.
+ *

I think as a first thing the comment should clarify that if @rx_seg provided 'mb_pool' should be NULL, and if split Rx feature is not used "@rx_seg & @rx_nseg" should be NULL and 0.

Also above is too wordy, it is hard to follow. Like "@rx_seg & @rx_nseg" are only taken into account if application provides 'RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT' offload should be clearer to see, etc. Can you try to simplify it, perhpas moving some of above comments to the "struct rte_eth_rxseg" can work?

lib/librte_ethdev/rte_ethdev_version.map EXPERIMENTAL { · line 235

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.h +0 -0
   * @param mb_pool
   *   The pointer to the memory pool from which to allocate *rte_mbuf* network
   *   memory buffers to populate each descriptor of the receive ring.
lib/librte_ethdev/rte_ethdev_version.map +1 -0
index f8a0945..25f7cee 100644
@@ -232,6 +232,7 @@ EXPERIMENTAL {
  	rte_eth_fec_get_capability;
  	rte_eth_fec_get;
  	rte_eth_fec_set;
+

unrelated

#63 lore raw

Hi Slava,

After reviewing this version and comparing with v4, I think having the configuration in rxconf (like in this patch) is a better choice.

Few comments below.

Quoted 211 lines · Ferruh Yigit
Quoted 114 lines · Viacheslav Ovsiienko

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
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 reserved; /* reserved field */
};

The segment descriptions are added to the rte_eth_rxconf structure:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf.
This array allows to specify the different settings for each segment in individual fashion.
n_seg - number of elements in the array

If the extended segment descriptions is provided with these new fields the mp parameter of the rte_eth_rx_queue_setup must be specified as NULL to avoid ambiguity.

The new offload flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup() routine application should check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new routine the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will split the received packets into multiple segments according to the specification in the description array:

- the first network buffer will be allocated from the memory pool, specified in the first segment description element, the second network buffer - from the pool in the second segment description element and so on. If there is no enough elements to describe the buffer for entire packet of maximal length the pool from the last valid element will be used to allocate the buffers from for the rest of segments

- the offsets from the segment description elements will provide the data offset from the buffer beginning except the first mbuf - for this one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual offset from the buffer beginning. If there is no enough elements to describe the buffer for entire packet of maximal length the offsets for the rest of segment will be supposed to be zero.

- the data length being received to each segment is limited by the length specified in the segment description element. The data receiving starts with filling up the first mbuf data buffer, if the specified maximal segment length is reached and there are data remaining (packet is longer than buffer in the first mbuf) the following data will be pushed to the next segment up to its own maximal length. If the first two segments is not enough to store all the packet remaining data the next (third) segment will be engaged and so on. If the length in the segment description element is zero the actual buffer size will be deduced from the appropriate memory pool properties. If there is no enough elements to describe the buffer for entire packet of maximal length the buffer size will be deduced from the pool of the last valid element for the remaining segments.

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

     seg0 - pool0, len0=14B, off0=2
     seg1 - pool1, len1=20B, off1=128B
     seg2 - pool2, len2=20B, off2=0B
     seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B long @ 128 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B @ 128 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload RTE_ETH_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if n_seg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

Quoted 7 lines
---
  doc/guides/nics/features.rst             | 15 +++++
  doc/guides/rel_notes/release_20_11.rst   |  9 +++
  lib/librte_ethdev/rte_ethdev.c           | 95 ++++++++++++++++++++++++--------
  lib/librte_ethdev/rte_ethdev.h           | 58 ++++++++++++++++++-
  lib/librte_ethdev/rte_ethdev_version.map |  1 +

Can you please update deprecation notice too, to remove the notice?

Quoted 7 lines
  5 files changed, 155 insertions(+), 23 deletions(-)
doc/guides/nics/features.rst +0 -0
index dd8c955..a45a9e8 100644

doc/guides/nics/features.rst Supports receiving segmented mbufs. · line 193

Quoted 9 lines
doc/guides/nics/features.rst +8 -0
@@ -185,6 +185,21 @@ Supports receiving segmented mbufs.
  * **[related]    eth_dev_ops**: ``rx_pkt_burst``.
+.. _nic_features_buffer_split:
+
+Buffer Split on Rx
+------------------
+
+Scatters the packets being received on specified boundaries to segmented mbufs.
+
+* **[uses]       rte_eth_rxconf,rte_eth_rxmode**: ``offloads:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.

uses 'rx_seg and rx_nseg' from 'rte_eth_rxconf', perhaps it can be another line.

doc/guides/nics/features.rst Supports receiving segmented mbufs. · line 197

Quoted 2 lines
doc/guides/nics/features.rst +2 -0
+* **[implements] datapath**: ``Buffer Split functionality``.
+* **[implements] rte_eth_dev_data**: ``buffer_split``.

What is implemented here?

doc/guides/nics/features.rst Supports receiving segmented mbufs. · line 199

Quoted 2 lines
doc/guides/nics/features.rst +2 -0
+* **[provides]   rte_eth_dev_info**: ``rx_offload_capa:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[provides]   eth_dev_ops**: ``rxq_info_get:buffer_split``.

Is this correct?

Quoted 10 lines
doc/guides/nics/features.rst +3 -0
+* **[related] API**: ``rte_eth_rx_queue_setup()``.
+
+
  .. _nic_features_lro:
  LRO
doc/guides/rel_notes/release_20_11.rst +0 -0
index bcc0fc2..f67ec62 100644

doc/guides/rel_notes/release_20_11.rst New Features · line 64

Quoted 5 lines
doc/guides/rel_notes/release_20_11.rst +3 -0
@@ -60,6 +60,12 @@ New Features
    Added the FEC API which provides functions for query FEC capabilities and
    current FEC mode from device. Also, API for configuring FEC mode is also provided.
+* **Introduced extended buffer description for receiving.**
+
+  Added the extended Rx queue setup routine providing the individual

This looks wrong with last version.

Quoted 39 lines
doc/guides/rel_notes/release_20_11.rst +6 -0
+  descriptions for each Rx segment with maximal size, buffer offset and memory
+  pool to allocate data buffers from.
+
  * **Updated Broadcom bnxt driver.**
    Updated the Broadcom bnxt driver with new features and improvements, including:
@@ -253,6 +259,9 @@ API Changes
    As the data of ``uint8_t`` will be truncated when queue number under
    a TC is greater than 256.
+* ethdev: Added fields rx_seg and rx_nseg to rte_eth_rxconf structure
+  to provide extended description of the receiving buffer.
+
  * vhost: Moved vDPA APIs from experimental to stable.
  * rawdev: Added a structure size parameter to the functions
lib/librte_ethdev/rte_ethdev.c +5 -0
index 892c246..7b64a6e 100644
@@ -105,6 +105,9 @@ struct rte_eth_xstats_name_off {
  #define RTE_RX_OFFLOAD_BIT2STR(_name)	\
  	{ DEV_RX_OFFLOAD_##_name, #_name }
+#define RTE_ETH_RX_OFFLOAD_BIT2STR(_name)	\
+	{ RTE_ETH_RX_OFFLOAD_##_name, #_name }
+
  static const struct {
  	uint64_t offload;
  	const char *name;
@@ -128,9 +131,11 @@ struct rte_eth_xstats_name_off {
  	RTE_RX_OFFLOAD_BIT2STR(SCTP_CKSUM),
  	RTE_RX_OFFLOAD_BIT2STR(OUTER_UDP_CKSUM),
  	RTE_RX_OFFLOAD_BIT2STR(RSS_HASH),
+	RTE_ETH_RX_OFFLOAD_BIT2STR(BUFFER_SPLIT),
  };
  #undef RTE_RX_OFFLOAD_BIT2STR
+#undef RTE_ETH_RX_OFFLOAD_BIT2STR
  #define RTE_TX_OFFLOAD_BIT2STR(_name)	\
  	{ DEV_TX_OFFLOAD_##_name, #_name }
@@ -1770,10 +1775,14 @@ struct rte_eth_dev *
  		       struct rte_mempool *mp)
  {
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1784

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +3 -0
  	int ret;
+	uint16_t seg_idx;
  	uint32_t mbp_buf_size;
  	struct rte_eth_dev *dev;
  	struct rte_eth_dev_info dev_info;
  	struct rte_eth_rxconf local_conf;
+	const struct rte_eth_rxseg *rx_seg;
+	struct rte_eth_rxseg seg_single = { .mp = mp};

missing space

Quoted 18 lines
Quoted 18 lines
lib/librte_ethdev/rte_ethdev.c +7 -5
+	uint16_t n_seg;
  	void **rxq;
  	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
@@ -1784,13 +1793,32 @@ struct rte_eth_dev *
  		return -EINVAL;
  	}
-	if (mp == NULL) {
-		RTE_ETHDEV_LOG(ERR, "Invalid null mempool pointer\n");
-		return -EINVAL;
-	}
-
  	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP);
+	rx_seg = rx_conf->rx_seg;
+	n_seg = rx_conf->rx_nseg;
+	if (rx_seg == NULL) {
+		/* Exclude ambiguities about segment descrtiptions. */
+		if (n_seg) {
+			RTE_ETHDEV_LOG(ERR,
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1808

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +5 -0
+				       "Non empty array with null pointer\n");
+			return -EINVAL;
+		}
+		rx_seg = &seg_single;
+		n_seg = 1;

Why setting 'rx_seg' & 'n_seg'? Why not leaving them NULL and 0 when not used? This was PMD can do NULL/0 check and can know they are not used.

I think they are just set locally to factorize the checks below, but I agree it is questionnable: it seems the only check which is really factorized is about private_data_size.

Quoted 2 lines

I think better to do a "if (mp == NULL)" check here, both 'rx_seg' & 'mp' should not be NULL.

Agree, something like this looks more simple:

	if (mp == NULL) {
		if (n_seg == 0 || rx_seg == NULL)
			RTE_ETHDEV_LOG(ERR, "...");
	} else {
		if (n_seg != 0 || rx_seg != NULL)
			RTE_ETHDEV_LOG(ERR, "...");
		rx_seg = &seg_single;
		n_seg = 1;
	}
Quoted 47 lines
Quoted 47 lines
lib/librte_ethdev/rte_ethdev.c +26 -15
+	} else {
+		if (n_seg == 0) {
+			RTE_ETHDEV_LOG(ERR,
+				       "Invalid zero descriptions number\n");
+			return -EINVAL;
+		}
+		if (mp) {
+			RTE_ETHDEV_LOG(ERR,
+				       "Memory pool duplicated definition\n");
+			return -EINVAL;
+		}
+	}
+
  	/*
  	 * Check the size of the mbuf data buffer.
  	 * This value must be provided in the private data of the memory pool.
@@ -1800,23 +1828,48 @@ struct rte_eth_dev *
  	if (ret != 0)
  		return ret;
-	if (mp->private_data_size < sizeof(struct rte_pktmbuf_pool_private)) {
-		RTE_ETHDEV_LOG(ERR, "%s private_data_size %d < %d\n",
-			mp->name, (int)mp->private_data_size,
-			(int)sizeof(struct rte_pktmbuf_pool_private));
-		return -ENOSPC;
-	}
-	mbp_buf_size = rte_pktmbuf_data_room_size(mp);
+	for (seg_idx = 0; seg_idx < n_seg; seg_idx++) {
+		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 head_room = seg_idx ? 0 : RTE_PKTMBUF_HEADROOM;
-	if (mbp_buf_size < dev_info.min_rx_bufsize + RTE_PKTMBUF_HEADROOM) {
-		RTE_ETHDEV_LOG(ERR,
-			"%s mbuf_data_room_size %d < %d (RTE_PKTMBUF_HEADROOM=%d + min_rx_bufsize(dev)=%d)\n",
-			mp->name, (int)mbp_buf_size,
-			(int)(RTE_PKTMBUF_HEADROOM + dev_info.min_rx_bufsize),
-			(int)RTE_PKTMBUF_HEADROOM,
-			(int)dev_info.min_rx_bufsize);
-		return -EINVAL;
+		if (mpl == NULL) {
+			RTE_ETHDEV_LOG(ERR, "Invalid null mempool pointer\n");
+			return -EINVAL;
+		}
+
+		if (mpl->private_data_size <
+				sizeof(struct rte_pktmbuf_pool_private)) {
+			RTE_ETHDEV_LOG(ERR, "%s private_data_size %d < %d\n",
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1852

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+				mpl->name, (int)mpl->private_data_size,
+				(int)sizeof(struct rte_pktmbuf_pool_private));
+			return -ENOSPC;
+		}
+
+		mbp_buf_size = rte_pktmbuf_data_room_size(mpl);
+		length = length ? length : (mbp_buf_size - head_room);
+		if (mbp_buf_size < length + offset + head_room) {

Is length == 0 allowed? Or is it to handle the case where mp != NULL? Is the test needed in that case? It seems it is equivalent to do "if (offset > 0)".

Wouldn't it be better to check mp like this?

	if (mp == NULL) {
		if (mbp_buf_size < length + offset + head_room)
			...error...
	}
Quoted 18 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1861

Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+			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;
+		}
  	}
+	/* Check the minimal buffer size for the single segment only. */

This is the main branch, what do you think moving the comment to the beggining of above for loop and add a comment about testing the multiple segment.

Btw, I have a concern that this single/multi segment can cause a confusion with multi segment packets. Can something else, like "split package" can be used instead of segment?

Quoted 11 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1872

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.c +11 -0
+	if (mp && (mbp_buf_size < dev_info.min_rx_bufsize +
+				  RTE_PKTMBUF_HEADROOM)) {
+		RTE_ETHDEV_LOG(ERR,
+			       "%s mbuf_data_room_size %u < %u "
+			       "(RTE_PKTMBUF_HEADROOM=%u + "
+			       "min_rx_bufsize(dev)=%u)\n",
+			       mp->name, mbp_buf_size,
+			       RTE_PKTMBUF_HEADROOM + dev_info.min_rx_bufsize,
+			       RTE_PKTMBUF_HEADROOM, dev_info.min_rx_bufsize);
+			return -EINVAL;
+		}

The "}" is not indented correctly

Quoted 10 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1917

Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +0 -2
  	/* Use default specified by driver, if nb_rx_desc is zero */
  	if (nb_rx_desc == 0) {
@@ -1914,8 +1967,6 @@ struct rte_eth_dev *
  			dev->data->min_rx_buf_size = mbp_buf_size;
  	}
-	rte_ethdev_trace_rxq_setup(port_id, rx_queue_id, nb_rx_desc, mp,
-		rx_conf, ret);

Is this removed intentionally?

Quoted 13 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_txmode { · line 975

Quoted 13 lines
lib/librte_ethdev/rte_ethdev.c +0 -0
  	return eth_err(port_id, ret);
  }
lib/librte_ethdev/rte_ethdev.h +4 -0
index 5bcfbb8..9cf0a03 100644
@@ -970,6 +970,16 @@ struct rte_eth_txmode {
  };
  /**
+ * A structure used to configure an RX packet segment to split.
+ */
+struct rte_eth_rxseg {
+	struct rte_mempool *mp; /**< Memory pools to allocate segment from */

pools -> pool

Quoted 3 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_txmode { · line 979

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.h +3 -0
+	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 */

To allow future additions to the structure, should the reserved field always be set to 0? If yes, maybe it should be specified here and checked in rte_eth_rx_queue_setup().

Some "." missing at the end of comments.

Quoted 7 lines
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.h +3 -0
+};
+
+/**
   * A structure used to configure an RX ring of an Ethernet port.
   */
  struct rte_eth_rxconf {
@@ -977,13 +987,23 @@ struct rte_eth_rxconf {
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_rxconf { · line 994

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.h +5 -0
  	uint16_t rx_free_thresh; /**< Drives the freeing of RX descriptors. */
  	uint8_t rx_drop_en; /**< Drop packets if no descriptors are available. */
  	uint8_t rx_deferred_start; /**< Do not start queue with rte_eth_dev_start(). */
+	uint16_t rx_nseg; /**< Number of descriptions in rx_seg array. */
+	/**
+	 * The pointer to the array of segment descriptions, each element
+	 * describes the memory pool, maximal segment data length, initial
+	 * data offset from the beginning of data buffer in mbuf. This allow

allow -> allows
or maybe "This allows to specify" -> "This specifies"

Quoted 8 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_rxconf { · line 999

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.h +5 -0
+	 * to specify the dedicated properties for each segment in the receiving
+	 * buffer - pool, buffer offset, maximal segment size. The number of
+	 * segment descriptions in the array is specified by the rx_nseg
+	 * field.
+	 */

What do you think providing a short description here, and move above comment to abice "struct rte_eth_rxseg" struct?

+1

Quoted 90 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_rxconf { · line 986

Quoted 9 lines
lib/librte_ethdev/rte_ethdev.h +1 -1
+	struct rte_eth_rxseg *rx_seg;
  	/**
  	 * Per-queue Rx offloads to be set using DEV_RX_OFFLOAD_* flags.
  	 * Only offloads set on rx_queue_offload_capa or rx_offload_capa
  	 * fields on rte_eth_dev_info structure are allowed to be set.
  	 */
  	uint64_t offloads;
-

unrelated

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.h +1 -0
  	uint64_t reserved_64s[2]; /**< Reserved for future fields */
  	void *reserved_ptrs[2];   /**< Reserved for future fields */
  };
@@ -1260,6 +1280,7 @@ struct rte_eth_conf {
  #define DEV_RX_OFFLOAD_SCTP_CKSUM	0x00020000
  #define DEV_RX_OFFLOAD_OUTER_UDP_CKSUM  0x00040000
  #define DEV_RX_OFFLOAD_RSS_HASH		0x00080000
+#define RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT 0x00100000
  #define DEV_RX_OFFLOAD_CHECKSUM (DEV_RX_OFFLOAD_IPV4_CKSUM | \
  				 DEV_RX_OFFLOAD_UDP_CKSUM | \

lib/librte_ethdev/rte_ethdev.h int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue, · line 2050

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.h +0 -0
@@ -2027,6 +2048,41 @@ int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue,
   *   No need to repeat any bit in rx_conf->offloads which has already been
   *   enabled in rte_eth_dev_configure() at port level. An offloading enabled
   *   at port level can't be disabled at queue level.

Can it be possible to put a kind of marker here, like "@rx_seg & @rx_nseg", to clarify what are you talking about.

Quoted 25 lines
lib/librte_ethdev/rte_ethdev.h +25 -0
+ *   The configuration structure also contains the pointer to the array
+ *   of the receiving buffer segment descriptions, each element describes
+ *   the memory pool, maximal segment data length, initial data offset from
+ *   the beginning of data buffer in mbuf. This allow to specify the dedicated
+ *   properties for each segment in the receiving buffer - pool, buffer
+ *   offset, maximal segment size. If RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT offload
+ *   flag is configured the PMD will split the received packets into multiple
+ *   segments according to the specification in the description array:
+ *   - the first network buffer will be allocated from the memory pool,
+ *     specified in the first segment description element, the second
+ *     network buffer - from the pool in the second segment description
+ *     element and so on. If there is no enough elements to describe
+ *     the buffer for entire packet of maximal length the pool from the last
+ *     valid element will be used to allocate the buffers from for the rest
+ *     of segments.
+ *   - the offsets from the segment description elements will provide the
+ *     data offset from the buffer beginning except the first mbuf - for this
+ *     one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual
+ *     offset from the buffer beginning. If there is no enough elements
+ *     to describe the buffer for entire packet of maximal length the offsets
+ *     for the rest of segment will be supposed to be zero.
+ *   - the data length being received to each segment is limited by the
+ *     length specified in the segment description element. The data receiving
+ *     starts with filling up the first mbuf data buffer, if the specified
+ *     maximal segment length is reached and there are data remaining

lib/librte_ethdev/rte_ethdev.h int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue, · line 2085

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10 -0
+ *     (packet is longer than buffer in the first mbuf) the following data
+ *     will be pushed to the next segment up to its own length. If the first
+ *     two segments is not enough to store all the packet data the next
+ *     (third) segment will be engaged and so on. If the length in the segment
+ *     description element is zero the actual buffer size will be deduced
+ *     from the appropriate memory pool properties. If there is no enough
+ *     elements to describe the buffer for entire packet of maximal length
+ *     the buffer size will be deduced from the pool of the last valid
+ *     element for the all remaining segments.
+ *

I think as a first thing the comment should clarify that if @rx_seg provided 'mb_pool' should be NULL, and if split Rx feature is not used "@rx_seg & @rx_nseg" should be NULL and 0.

Also above is too wordy, it is hard to follow. Like "@rx_seg & @rx_nseg" are only taken into account if application provides 'RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT' offload should be clearer to see, etc. Can you try to simplify it, perhpas moving some of above comments to the "struct rte_eth_rxseg" can work?

lib/librte_ethdev/rte_ethdev_version.map EXPERIMENTAL { · line 235

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.h +0 -0
   * @param mb_pool
   *   The pointer to the memory pool from which to allocate *rte_mbuf* network
   *   memory buffers to populate each descriptor of the receive ring.
lib/librte_ethdev/rte_ethdev_version.map +1 -0
index f8a0945..25f7cee 100644
@@ -232,6 +232,7 @@ EXPERIMENTAL {
  	rte_eth_fec_get_capability;
  	rte_eth_fec_get;
  	rte_eth_fec_set;
+

unrelated

#64 lore raw
In reply to Ferruh Yigit

Hi, Ferruh

Quoted 10 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 14, 2020 1:34
To: Slava Ovsiienko <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v5 1/6] ethdev: introduce Rx buffer split

[..snip..]

Quoted 3 lines

Can you please update deprecation notice too, to remove the notice?

Yes, I missed the point, thank you for noticing.

Quoted 9 lines
Quoted 6 lines
  5 files changed, 155 insertions(+), 23 deletions(-)
(quoted diff) +0 -0

b/doc/guides/nics/features.rst index dd8c955..a45a9e8 100644 --- a/doc/guides/nics/features.rst
+* **[implements] rte_eth_dev_data**: ``buffer_split``.

What is implemented here?

none, removed.

Quoted 5 lines
Quoted 1 line

+* **[provides] rte_eth_dev_info**:

``rx_offload_capa:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.

Quoted 1 line

+* **[provides] eth_dev_ops**: ``rxq_info_get:buffer_split``.

Is this correct?

Yes, the dedicated rx_burst routine supporting buffer split might be engaged by PMD and might be reported via rxq_info_get().

Quoted 6 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1808

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.c +2 -0
+		rx_seg = &seg_single;
+		n_seg = 1;

Why setting 'rx_seg' & 'n_seg'? Why not leaving them NULL and 0 when not used?
This was PMD can do NULL/0 check and can know they are not used.

Refactored, single pool (legacy) and new extended config check are separated into dedicated branches.

Quoted 5 lines

lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 1918

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.c +0 -2
-	rte_ethdev_trace_rxq_setup(port_id, rx_queue_id, nb_rx_desc, mp,
-		rx_conf, ret);

Is this removed intentionally?

Missed statement, reverted back.

[..snip..]
Comments and descriptions rearranged and updated according to the comments, v6 is coming.

With best regards, Slava

#65 lore raw

PATCH v5 2/6 app/testpmd: add multiple pools per core creation

In reply to Viacheslav Ovsiienko

The command line parameter --mbuf-size is updated, it can handle the multiple values like the following:

--mbuf-size=2176,512,768,4096

specifying the creation the extra memory pools with the requested mbuf data buffer sizes. If some buffer split feature is engaged the extra memory pools can be used to configure the Rx queues with rte_the_dev_rx_queue_setup_ex().

The extra pools are created with requested sizes, and pool names are assigned with appended index: mbuf_pool_socket_%socket_%index. Index zero is used to specify the first mandatory pool to maintain compatibility with existing code.

---
 app/test-pmd/bpf_cmd.c                |  4 +--
 app/test-pmd/cmdline.c                |  2 +-
 app/test-pmd/config.c                 |  6 ++--
 app/test-pmd/parameters.c             | 24 +++++++++----
 app/test-pmd/testpmd.c                | 63 +++++++++++++++++++----------------
 app/test-pmd/testpmd.h                | 24 ++++++++++---
 doc/guides/testpmd_app_ug/run_app.rst |  7 ++--
 7 files changed, 83 insertions(+), 47 deletions(-)
app/test-pmd/bpf_cmd.c +2 -2
index 16e3c3b..0a1a178 100644
@@ -69,7 +69,7 @@ struct cmd_bpf_ld_result {
 
 	*flags = RTE_BPF_ETH_F_NONE;
 	arg->type = RTE_BPF_ARG_PTR;
-	arg->size = mbuf_data_size;
+	arg->size = mbuf_data_size[0];
 
 	for (i = 0; str[i] != 0; i++) {
 		v = toupper(str[i]);
@@ -78,7 +78,7 @@ struct cmd_bpf_ld_result {
 		else if (v == 'M') {
 			arg->type = RTE_BPF_ARG_PTR_MBUF;
 			arg->size = sizeof(struct rte_mbuf);
-			arg->buf_size = mbuf_data_size;
+			arg->buf_size = mbuf_data_size[0];
 		} else if (v == '-')
 			continue;
 		else
app/test-pmd/cmdline.c +1 -1
index 273fb1a..a585cf0 100644
@@ -2907,7 +2907,7 @@ struct cmd_setup_rxtx_queue {
 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
 			socket_id = port->socket_id;
 
-		mp = mbuf_pool_find(socket_id);
+		mp = mbuf_pool_find(socket_id, 0);
 		if (mp == NULL) {
 			printf("Failed to setup RX queue: "
 				"No mempool allocation"
app/test-pmd/config.c +3 -3
index d4be694..5f501f6 100644
@@ -690,7 +690,7 @@ static int bus_match_all(const struct rte_bus *bus, const void *data)
 	printf("\nConnect to socket: %u", port->socket_id);
 
 	if (port_numa[port_id] != NUMA_NO_CONFIG) {
-		mp = mbuf_pool_find(port_numa[port_id]);
+		mp = mbuf_pool_find(port_numa[port_id], 0);
 		if (mp)
 			printf("\nmemory allocation on the socket: %d",
 							port_numa[port_id]);
@@ -3352,9 +3352,9 @@ struct igb_ring_desc_16_bytes {
 	 */
 	tx_pkt_len = 0;
 	for (i = 0; i < nb_segs; i++) {
-		if (seg_lengths[i] > (unsigned) mbuf_data_size) {
+		if (seg_lengths[i] > mbuf_data_size[0]) {
 			printf("length[%u]=%u > mbuf_data_size=%u - give up\n",
-			       i, seg_lengths[i], (unsigned) mbuf_data_size);
+			       i, seg_lengths[i], mbuf_data_size[0]);
 			return;
 		}
 		tx_pkt_len = (uint16_t)(tx_pkt_len + seg_lengths[i]);
app/test-pmd/parameters.c +18 -6
index 15ce8c1..4db4987 100644
@@ -106,7 +106,9 @@
 	       "(flag: 1 for RX; 2 for TX; 3 for RX and TX).\n");
 	printf("  --socket-num=N: set socket from which all memory is allocated "
 	       "in NUMA mode.\n");
-	printf("  --mbuf-size=N: set the data size of mbuf to N bytes.\n");
+	printf("  --mbuf-size=N,[N1[,..Nn]: set the data size of mbuf to "
+	       "N bytes. If multiple numbers are specified the extra pools "
+	       "will be created to receive with packet split features\n");
 	printf("  --total-num-mbufs=N: set the number of mbufs to be allocated "
 	       "in mbuf pools.\n");
 	printf("  --max-pkt-len=N: set the maximum size of packet to N bytes.\n");
@@ -892,12 +894,22 @@
 				}
 			}
 			if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) {
-				n = atoi(optarg);
-				if (n > 0 && n <= 0xFFFF)
-					mbuf_data_size = (uint16_t) n;
-				else
+				unsigned int mb_sz[MAX_SEGS_BUFFER_SPLIT];
+				unsigned int nb_segs, i;
+
+				nb_segs = parse_item_list(optarg, "mbuf-size",
+					MAX_SEGS_BUFFER_SPLIT, mb_sz, 0);
+				if (nb_segs <= 0)
 					rte_exit(EXIT_FAILURE,
-						 "mbuf-size should be > 0 and < 65536\n");
+						 "bad mbuf-size\n");
+				for (i = 0; i < nb_segs; i++) {
+					if (mb_sz[i] <= 0 || mb_sz[i] > 0xFFFF)
+						rte_exit(EXIT_FAILURE,
+							 "mbuf-size should be "
+							 "> 0 and < 65536\n");
+					mbuf_data_size[i] = (uint16_t) mb_sz[i];
+				}
+				mbuf_data_size_n = nb_segs;
 			}
 			if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) {
 				n = atoi(optarg);
app/test-pmd/testpmd.c +35 -28

145 lines not on this page · raw message

app/test-pmd/testpmd.h +19 -5
index 9a29d7a..b42d710 100644
@@ -42,6 +42,13 @@
  */
 #define RTE_MAX_SEGS_PER_PKT 255 /**< nb_segs is a 8-bit unsigned char. */
 
+/*
+ * The maximum number of segments per packet is used to configure
+ * buffer split feature, also specifies the maximum amount of
+ * optional Rx pools to allocate mbufs to split.
+ */
+#define MAX_SEGS_BUFFER_SPLIT 8 /**< nb_segs is a 8-bit unsigned char. */
+
 #define MAX_PKT_BURST 512
 #define DEF_PKT_BURST 32
 
@@ -393,7 +400,9 @@ struct queue_stats_mappings {
 extern uint8_t dcb_config;
 extern uint8_t dcb_test;
 
-extern uint16_t mbuf_data_size; /**< Mbuf data space size. */
+extern uint32_t mbuf_data_size_n;
+extern uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT];
+/**< Mbuf data space size. */
 extern uint32_t param_total_num_mbufs;
 
 extern uint16_t stats_period;
@@ -605,17 +614,22 @@ struct mplsoudp_decap_conf {
 
 /* Mbuf Pools */
 static inline void
-mbuf_poolname_build(unsigned int sock_id, char* mp_name, int name_size)
+mbuf_poolname_build(unsigned int sock_id, char *mp_name,
+		    int name_size, unsigned int idx)
 {
-	snprintf(mp_name, name_size, "mbuf_pool_socket_%u", sock_id);
+	if (!idx)
+		snprintf(mp_name, name_size, "mbuf_pool_socket_%u", sock_id);
+	else
+		snprintf(mp_name, name_size, "mbuf_pool_socket_%u_%u",
+			 sock_id, idx);
 }
 
 static inline struct rte_mempool *
-mbuf_pool_find(unsigned int sock_id)
+mbuf_pool_find(unsigned int sock_id, unsigned int idx)
 {
 	char pool_name[RTE_MEMPOOL_NAMESIZE];
 
-	mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name));
+	mbuf_poolname_build(sock_id, pool_name, sizeof(pool_name), idx);
 	return rte_mempool_lookup((const char *)pool_name);
 }
 
doc/guides/testpmd_app_ug/run_app.rst +5 -2
index ec085c2..1eb0a10 100644
@@ -107,9 +107,12 @@ The command line options are:
     Set the socket from which all memory is allocated in NUMA mode,
     where 0 <= N < number of sockets on the board.
 
-*   ``--mbuf-size=N``
+*   ``--mbuf-size=N[,N1[,...Nn]``
 
-    Set the data size of the mbufs used to N bytes, where N < 65536. The default value is 2048.
+    Set the data size of the mbufs used to N bytes, where N < 65536.
+    The default value is 2048. If multiple mbuf-size values are specified the
+    extra memory pools will be created for allocating mbufs to receive packets
+    with buffer splittling features.
 
 *   ``--total-num-mbufs=N``
 
Signature · 1 line
1.8.3.1
#66 lore raw

PATCH v5 3/6 app/testpmd: add buffer split offload configuration

In reply to Viacheslav Ovsiienko

This patch add support for RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT providing per queue configuration for this offload.

---
 app/test-pmd/cmdline.c | 21 +++++++++++----------
 app/test-pmd/config.c  |  9 +++++++++
 2 files changed, 20 insertions(+), 10 deletions(-)
app/test-pmd/cmdline.c +11 -10
index a585cf0..fa71039 100644
@@ -883,16 +883,16 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"port config <port_id> rx_offload vlan_strip|"
 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
 			"outer_ipv4_cksum|macsec_strip|header_split|"
-			"vlan_filter|vlan_extend|jumbo_frame|"
-			"scatter|timestamp|security|keep_crc on|off\n"
+			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
+			"buffer_split|timestamp|security|keep_crc on|off\n"
 			"     Enable or disable a per port Rx offloading"
 			" 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|"
-			"vlan_filter|vlan_extend|jumbo_frame|"
-			"scatter|timestamp|security|keep_crc on|off\n"
+			"vlan_filter|vlan_extend|jumbo_frame|scatter|"
+			"buffer_split|timestamp|security|keep_crc on|off\n"
 			"    Enable or disable a per queue Rx offloading"
 			" only on a specific Rx queue\n\n"
 
@@ -18417,7 +18417,8 @@ struct cmd_config_per_port_rx_offload_result {
 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
-			   "scatter#timestamp#security#keep_crc#rss_hash");
+			   "scatter#buffer_split#timestamp#security#"
+			   "keep_crc#rss_hash");
 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
 	TOKEN_STRING_INITIALIZER
 		(struct cmd_config_per_port_rx_offload_result,
@@ -18497,8 +18498,8 @@ struct cmd_config_per_port_rx_offload_result {
 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
-		    "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
-		    "on|off",
+		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
+		    "keep_crc|rss_hash on|off",
 	.tokens = {
 		(void *)&cmd_config_per_port_rx_offload_result_port,
 		(void *)&cmd_config_per_port_rx_offload_result_config,
@@ -18547,7 +18548,7 @@ struct cmd_config_per_queue_rx_offload_result {
 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
-			   "scatter#timestamp#security#keep_crc");
+			   "scatter#buffer_split#timestamp#security#keep_crc");
 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
 	TOKEN_STRING_INITIALIZER
 		(struct cmd_config_per_queue_rx_offload_result,
@@ -18603,8 +18604,8 @@ struct cmd_config_per_queue_rx_offload_result {
 		    "vlan_strip|ipv4_cksum|"
 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
-		    "jumbo_frame|scatter|timestamp|security|keep_crc "
-		    "on|off",
+		    "jumbo_frame|scatter|buffer_split|timestamp|security|"
+		    "keep_crc on|off",
 	.tokens = {
 		(void *)&cmd_config_per_queue_rx_offload_result_port,
 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
app/test-pmd/config.c +9 -0
index 5f501f6..7126d91 100644
@@ -1092,6 +1092,15 @@ static int bus_match_all(const struct rte_bus *bus, const void *data)
 			printf("off\n");
 	}
 
+	if (dev_info.rx_offload_capa & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
+		printf("RX offload buffer split:       ");
+		if (ports[port_id].dev_conf.rxmode.offloads &
+		    RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)
+			printf("on\n");
+		else
+			printf("off\n");
+	}
+
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VLAN_INSERT) {
 		printf("VLAN insert:                   ");
 		if (ports[port_id].dev_conf.txmode.offloads &
Signature · 1 line
1.8.3.1
#67 lore raw

PATCH v5 4/6 app/testpmd: add rxpkts commands and parameters

In reply to Viacheslav Ovsiienko

Add command line parameter:

--rxpkts=X[,Y]

Sets the length of segments to scatter packets on receiving if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only).

Add interactive mode command:

testpmd> set rxpkts (x[,y]*)

Where x[,y]* represents a CSV list of values, without white space.

Sets the length of segments to scatter packets on receiving if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only). Optionally the multiple memory pools can be specified with --mbuf-size command line parameter and the mbufs to receive will be allocated sequentially from these extra memory pools.

---
 app/test-pmd/cmdline.c                      | 61 +++++++++++++++++++++++++++--
 app/test-pmd/config.c                       | 48 ++++++++++++++++++++++-
 app/test-pmd/parameters.c                   | 15 +++++++
 app/test-pmd/testpmd.c                      |  7 ++++
 app/test-pmd/testpmd.h                      | 11 +++++-
 doc/guides/testpmd_app_ug/run_app.rst       |  9 +++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 21 +++++++++-
 7 files changed, 165 insertions(+), 7 deletions(-)
app/test-pmd/cmdline.c +58 -3
index fa71039..d8dba54 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|txpkts)\n"
+			"show config (rxtx|cores|fwd|rxpkts|txpkts)\n"
 			"    Display the given configuration.\n\n"
 
 			"read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -294,6 +294,12 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"    Set the transmit delay time and number of retries,"
 			" effective when retry is enabled.\n\n"
 
+			"set rxpkts (x[,y]*)\n"
+			"    Set the length of each segment to scatter"
+			" packets on receiving if split feature is engaged."
+			" Affects only the queues configured with split"
+			" offloads.\n\n"
+
 			"set txpkts (x[,y]*)\n"
 			"    Set the length of each segment of TXONLY"
 			" and optionally CSUM packets.\n\n"
@@ -3889,6 +3895,52 @@ struct cmd_set_log_result {
 	},
 };
 
+/* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
+
+struct cmd_set_rxpkts_result {
+	cmdline_fixed_string_t cmd_keyword;
+	cmdline_fixed_string_t rxpkts;
+	cmdline_fixed_string_t seg_lengths;
+};
+
+static void
+cmd_set_rxpkts_parsed(void *parsed_result,
+		      __rte_unused struct cmdline *cl,
+		      __rte_unused void *data)
+{
+	struct cmd_set_rxpkts_result *res;
+	unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+	unsigned int nb_segs;
+
+	res = parsed_result;
+	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
+				  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
+	if (nb_segs > 0)
+		set_rx_pkt_segments(seg_lengths, nb_segs);
+}
+
+cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 cmd_keyword, "set");
+cmdline_parse_token_string_t cmd_set_rxpkts_name =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 rxpkts, "rxpkts");
+cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
+				 seg_lengths, NULL);
+
+cmdline_parse_inst_t cmd_set_rxpkts = {
+	.f = cmd_set_rxpkts_parsed,
+	.data = NULL,
+	.help_str = "set rxpkts <len0[,len1]*>",
+	.tokens = {
+		(void *)&cmd_set_rxpkts_keyword,
+		(void *)&cmd_set_rxpkts_name,
+		(void *)&cmd_set_rxpkts_lengths,
+		NULL,
+	},
+};
+
 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
 
 struct cmd_set_txpkts_result {
@@ -7517,6 +7569,8 @@ static void cmd_showcfg_parsed(void *parsed_result,
 		fwd_lcores_config_display();
 	else if (!strcmp(res->what, "fwd"))
 		pkt_fwd_config_display(&cur_fwd_config);
+	else if (!strcmp(res->what, "rxpkts"))
+		show_rx_pkt_segments();
 	else if (!strcmp(res->what, "txpkts"))
 		show_tx_pkt_segments();
 	else if (!strcmp(res->what, "txtimes"))
@@ -7529,12 +7583,12 @@ static void cmd_showcfg_parsed(void *parsed_result,
 	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#txpkts#txtimes");
+				 "rxtx#cores#fwd#rxpkts#txpkts#txtimes");
 
 cmdline_parse_inst_t cmd_showcfg = {
 	.f = cmd_showcfg_parsed,
 	.data = NULL,
-	.help_str = "show config rxtx|cores|fwd|txpkts|txtimes",
+	.help_str = "show config rxtx|cores|fwd|rxpkts|txpkts|txtimes",
 	.tokens = {
 		(void *)&cmd_showcfg_show,
 		(void *)&cmd_showcfg_port,
@@ -19807,6 +19861,7 @@ struct cmd_showport_macs_result {
 	(cmdline_parse_inst_t *)&cmd_reset,
 	(cmdline_parse_inst_t *)&cmd_set_numbers,
 	(cmdline_parse_inst_t *)&cmd_set_log,
+	(cmdline_parse_inst_t *)&cmd_set_rxpkts,
 	(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 +46 -2

62 lines not on this page · raw message

app/test-pmd/parameters.c +15 -0
index 4db4987..e4e3635 100644
@@ -184,6 +184,7 @@
 	       "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
 	printf("  --no-flush-rx: Don't flush RX streams before forwarding."
 	       " Used mainly with PCAP drivers.\n");
+	printf("  --rxpkts=X[,Y]*: set RX segment sizes 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");
@@ -662,6 +663,7 @@
 		{ "rx-queue-stats-mapping",	1, 0, 0 },
 		{ "no-flush-rx",	0, 0, 0 },
 		{ "flow-isolate-all",	        0, 0, 0 },
+		{ "rxpkts",			1, 0, 0 },
 		{ "txpkts",			1, 0, 0 },
 		{ "txonly-multi-flow",		0, 0, 0 },
 		{ "disable-link-check",		0, 0, 0 },
@@ -1272,6 +1274,19 @@
 						 "invalid RX queue statistics mapping config entered\n");
 				}
 			}
+			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,
+						 seg_len, 0);
+				if (nb_segs > 0)
+					set_rx_pkt_segments(seg_len, 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 +7 -0
index 7e6ef80..f88c1e2 100644
@@ -210,6 +210,13 @@ struct fwd_engine * fwd_engines[] = {
 uint8_t f_quit;
 
 /*
+ * Configuration of packet segments used to scatter received packets
+ * if some of split features is configured.
+ */
+uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
+
+/*
  * Configuration of packet segments used by the "txonly" processing engine.
  */
 uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN; /**< TXONLY packet length. */
app/test-pmd/testpmd.h +10 -1
index b42d710..8e5ba6a 100644
@@ -420,6 +420,13 @@ struct queue_stats_mappings {
 extern struct rte_fdir_conf fdir_conf;
 
 /*
+ * Configuration of packet segments used to scatter received packets
+ * if some of split features is configured.
+ */
+extern uint16_t rx_pkt_seg_lengths[MAX_SEGS_BUFFER_SPLIT];
+extern uint8_t  rx_pkt_nb_segs; /**< Number of segments to split */
+
+/*
  * Configuration of packet segments used by the "txonly" processing engine.
  */
 #define TXONLY_DEF_PACKET_LEN 64
@@ -816,7 +823,9 @@ void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
 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_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs);
+void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
+void show_rx_pkt_segments(void);
+void set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
 void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
 void show_tx_pkt_times(void);
doc/guides/testpmd_app_ug/run_app.rst +9 -0
index 1eb0a10..463b76c 100644
@@ -361,6 +361,15 @@ The command line options are:
 
     Don't flush the RX streams before starting forwarding. Used mainly with the PCAP PMD.
 
+*   ``--rxpkts=X[,Y]``
+
+    Set the length of segments to scatter packets on receiving if split
+    feature is engaged. Affects only the queues configured
+    with split offloads (currently BUFFER_SPLIT is supported only).
+    Optionally the multiple memory pools can be specified with --mbuf-size
+    command line parameter and the mbufs to receive will be allocated
+    sequentially from these extra memory pools.
+
 *   ``--txpkts=X[,Y]``
 
     Set TX segment sizes or total packet length. Valid for ``tx-only``
doc/guides/testpmd_app_ug/testpmd_funcs.rst +20 -1
index 795c739..ff88762 100644
@@ -273,7 +273,7 @@ show config
 Displays the configuration of the application.
 The configuration comes from the command-line, the runtime or the application defaults::
 
-   testpmd> show config (rxtx|cores|fwd|txpkts|txtimes)
+   testpmd> show config (rxtx|cores|fwd|rxpkts|txpkts|txtimes)
 
 The available information categories are:
 
@@ -283,6 +283,8 @@ The available information categories are:
 
 * ``fwd``: Packet forwarding configuration.
 
+* ``rxpkts``: Packets to RX split configuration.
+
 * ``txpkts``: Packets to TX configuration.
 
 * ``txtimes``: Burst time pattern for Tx only mode.
@@ -774,6 +776,23 @@ When retry is enabled, the transmit delay time and number of retries can also be
 
    testpmd> set burst tx delay (microseconds) retry (num)
 
+set rxpkts
+~~~~~~~~~~
+
+Set the length of segments to scatter packets on receiving if split
+feature is engaged. Affects only the queues configured with split offloads
+(currently BUFFER_SPLIT is supported only). Optionally the multiple memory
+pools can be specified with --mbuf-size command line parameter and the mbufs
+to receive will be allocated sequentially from these extra memory pools (the
+mbuf for the first segment is allocated from the first pool, the second one
+from the second pool, and so on, if segment number is greater then pool's the
+mbuf for remaining segments will be allocated from the last valid pool).
+
+   testpmd> set rxpkts (x[,y]*)
+
+Where x[,y]* represents a CSV list of values, without white space. Zero value
+means to use the corresponding memory pool data buffer size.
+
 set txpkts
 ~~~~~~~~~~
 
Signature · 1 line
1.8.3.1
#68 lore raw

PATCH v5 5/6 app/testpmd: add rxoffs commands and parameters

In reply to Viacheslav Ovsiienko

Add command line parameter:

--rxoffs=X[,Y]

Sets the offsets of packet segments from the beginning of the receiving buffer if split feature is engaged. Affects only the queues configured with split offloads (currently BUFFER_SPLIT is supported only).

Add interactive mode command, providing the same:

testpmd> set rxoffs (x[,y]*)

Where x[,y]* represents a CSV list of values, without white space.

---
 app/test-pmd/cmdline.c                      | 61 +++++++++++++++++++++++++++--
 app/test-pmd/config.c                       | 44 +++++++++++++++++++++
 app/test-pmd/parameters.c                   | 15 +++++++
 app/test-pmd/testpmd.c                      |  2 +
 app/test-pmd/testpmd.h                      |  4 ++
 doc/guides/testpmd_app_ug/run_app.rst       |  6 +++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 17 +++++++-
 7 files changed, 145 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +58 -3
index d8dba54..7182bba 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|rxpkts|txpkts)\n"
+			"show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
 			"    Display the given configuration.\n\n"
 
 			"read rxd (port_id) (queue_id) (rxd_id)\n"
@@ -294,6 +294,12 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"    Set the transmit delay time and number of retries,"
 			" effective when retry is enabled.\n\n"
 
+			"set rxoffs (x[,y]*)\n"
+			"    Set the offset of each packet segment on"
+			" receiving if split feature is engaged."
+			" Affects only the queues configured with split"
+			" offloads.\n\n"
+
 			"set rxpkts (x[,y]*)\n"
 			"    Set the length of each segment to scatter"
 			" packets on receiving if split feature is engaged."
@@ -3895,6 +3901,52 @@ struct cmd_set_log_result {
 	},
 };
 
+/* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
+
+struct cmd_set_rxoffs_result {
+	cmdline_fixed_string_t cmd_keyword;
+	cmdline_fixed_string_t rxoffs;
+	cmdline_fixed_string_t seg_offsets;
+};
+
+static void
+cmd_set_rxoffs_parsed(void *parsed_result,
+		      __rte_unused struct cmdline *cl,
+		      __rte_unused void *data)
+{
+	struct cmd_set_rxoffs_result *res;
+	unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
+	unsigned int nb_segs;
+
+	res = parsed_result;
+	nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
+				  MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
+	if (nb_segs > 0)
+		set_rx_pkt_offsets(seg_offsets, nb_segs);
+}
+
+cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
+				 cmd_keyword, "set");
+cmdline_parse_token_string_t cmd_set_rxoffs_name =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
+				 rxoffs, "rxoffs");
+cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
+				 seg_offsets, NULL);
+
+cmdline_parse_inst_t cmd_set_rxoffs = {
+	.f = cmd_set_rxoffs_parsed,
+	.data = NULL,
+	.help_str = "set rxoffs <len0[,len1]*>",
+	.tokens = {
+		(void *)&cmd_set_rxoffs_keyword,
+		(void *)&cmd_set_rxoffs_name,
+		(void *)&cmd_set_rxoffs_offsets,
+		NULL,
+	},
+};
+
 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
 
 struct cmd_set_rxpkts_result {
@@ -7569,6 +7621,8 @@ static void cmd_showcfg_parsed(void *parsed_result,
 		fwd_lcores_config_display();
 	else if (!strcmp(res->what, "fwd"))
 		pkt_fwd_config_display(&cur_fwd_config);
+	else if (!strcmp(res->what, "rxoffs"))
+		show_rx_pkt_offsets();
 	else if (!strcmp(res->what, "rxpkts"))
 		show_rx_pkt_segments();
 	else if (!strcmp(res->what, "txpkts"))
@@ -7583,12 +7637,12 @@ static void cmd_showcfg_parsed(void *parsed_result,
 	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#rxpkts#txpkts#txtimes");
+				 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
 
 cmdline_parse_inst_t cmd_showcfg = {
 	.f = cmd_showcfg_parsed,
 	.data = NULL,
-	.help_str = "show config rxtx|cores|fwd|rxpkts|txpkts|txtimes",
+	.help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
 	.tokens = {
 		(void *)&cmd_showcfg_show,
 		(void *)&cmd_showcfg_port,
@@ -19861,6 +19915,7 @@ struct cmd_showport_macs_result {
 	(cmdline_parse_inst_t *)&cmd_reset,
 	(cmdline_parse_inst_t *)&cmd_set_numbers,
 	(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_txpkts,
 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
app/test-pmd/config.c +44 -0

50 lines not on this page · raw message

app/test-pmd/parameters.c +15 -0
index e4e3635..2298ba5 100644
@@ -184,6 +184,7 @@
 	       "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1);
 	printf("  --no-flush-rx: Don't flush RX streams before forwarding."
 	       " 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("  --txpkts=X[,Y]*: set TX segment sizes"
 		" or total packet length.\n");
@@ -663,6 +664,7 @@
 		{ "rx-queue-stats-mapping",	1, 0, 0 },
 		{ "no-flush-rx",	0, 0, 0 },
 		{ "flow-isolate-all",	        0, 0, 0 },
+		{ "rxoffs",			1, 0, 0 },
 		{ "rxpkts",			1, 0, 0 },
 		{ "txpkts",			1, 0, 0 },
 		{ "txonly-multi-flow",		0, 0, 0 },
@@ -1274,6 +1276,19 @@
 						 "invalid RX queue statistics mapping config entered\n");
 				}
 			}
+			if (!strcmp(lgopts[opt_idx].name, "rxoffs")) {
+				unsigned int seg_off[MAX_SEGS_BUFFER_SPLIT];
+				unsigned int nb_offs;
+
+				nb_offs = parse_item_list
+						(optarg, "rxpkt offsets",
+						 MAX_SEGS_BUFFER_SPLIT,
+						 seg_off, 0);
+				if (nb_offs > 0)
+					set_rx_pkt_offsets(seg_off, nb_offs);
+				else
+					rte_exit(EXIT_FAILURE, "bad rxoffs\n");
+			}
 			if (!strcmp(lgopts[opt_idx].name, "rxpkts")) {
 				unsigned int seg_len[MAX_SEGS_BUFFER_SPLIT];
 				unsigned int nb_segs;
app/test-pmd/testpmd.c +2 -0
index f88c1e2..580178d 100644
@@ -215,6 +215,8 @@ struct fwd_engine * fwd_engines[] = {
  */
 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 */
 
 /*
  * Configuration of packet segments used by the "txonly" processing engine.
app/test-pmd/testpmd.h +4 -0
index 8e5ba6a..fc56b60 100644
@@ -425,6 +425,8 @@ struct queue_stats_mappings {
  */
 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];
+extern uint8_t  rx_pkt_nb_offs; /**< Number of specified offsets */
 
 /*
  * Configuration of packet segments used by the "txonly" processing engine.
@@ -825,6 +827,8 @@ void vlan_tpid_set(portid_t port_id, enum rte_vlan_type vlan_type,
 void set_verbose_level(uint16_t vb_level);
 void set_rx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
 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);
 void set_tx_pkt_segments(unsigned int *seg_lengths, unsigned int nb_segs);
 void show_tx_pkt_segments(void);
 void set_tx_pkt_times(unsigned int *tx_times);
doc/guides/testpmd_app_ug/run_app.rst +6 -0
index 463b76c..9b0a84a 100644
@@ -361,6 +361,12 @@ The command line options are:
 
     Don't flush the RX streams before starting forwarding. Used mainly with the PCAP PMD.
 
+*   ``--rxoffs=X[,Y]``
+
+    Set the offsets of packet segments on receiving if split
+    feature is engaged. Affects only the queues configured
+    with split offloads (currently BUFFER_SPLIT is supported only).
+
 *   ``--rxpkts=X[,Y]``
 
     Set the length of segments to scatter packets on receiving if split
doc/guides/testpmd_app_ug/testpmd_funcs.rst +16 -1
index ff88762..c99d887 100644
@@ -273,7 +273,7 @@ show config
 Displays the configuration of the application.
 The configuration comes from the command-line, the runtime or the application defaults::
 
-   testpmd> show config (rxtx|cores|fwd|rxpkts|txpkts|txtimes)
+   testpmd> show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes)
 
 The available information categories are:
 
@@ -283,6 +283,8 @@ The available information categories are:
 
 * ``fwd``: Packet forwarding configuration.
 
+* ``rxoffs``: Packet offsets for RX split.
+
 * ``rxpkts``: Packets to RX split configuration.
 
 * ``txpkts``: Packets to TX configuration.
@@ -776,6 +778,19 @@ When retry is enabled, the transmit delay time and number of retries can also be
 
    testpmd> set burst tx delay (microseconds) retry (num)
 
+set rxoffs
+~~~~~~~~~~
+
+Set the offsets of segments relating to the data buffer beginning on receiving
+if split feature is engaged. Affects only the queues configured with split
+offloads (currently BUFFER_SPLIT is supported only).
+
+   testpmd> set rxoffs (x[,y]*)
+
+Where x[,y]* represents a CSV list of values, without white space. If the list
+of offsets is shorter than the list of segments the zero offsets will be used
+for the remaining segments.
+
 set rxpkts
 ~~~~~~~~~~
 
Signature · 1 line
1.8.3.1
#69 lore raw

PATCH v5 6/6 app/testpmd: add extended Rx queue setup

In reply to Viacheslav Ovsiienko

If Rx queue is configured with split feature the extended setup with specified segment sizes and pool will be performed.

---
 app/test-pmd/cmdline.c | 12 ++++++------
 app/test-pmd/testpmd.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
 app/test-pmd/testpmd.h |  5 +++++
 3 files changed, 57 insertions(+), 8 deletions(-)
app/test-pmd/cmdline.c +6 -6
index 7182bba..204221f 100644
@@ -2927,12 +2927,12 @@ struct cmd_setup_rxtx_queue {
 				rxring_numa[res->portid]);
 			return;
 		}
-		ret = rte_eth_rx_queue_setup(res->portid,
-					     res->qid,
-					     port->nb_rx_desc[res->qid],
-					     socket_id,
-					     &port->rx_conf[res->qid],
-					     mp);
+		ret = rx_queue_setup(res->portid,
+				     res->qid,
+				     port->nb_rx_desc[res->qid],
+				     socket_id,
+				     &port->rx_conf[res->qid],
+				     mp);
 		if (ret)
 			printf("Failed to setup RX queue\n");
 	} else {
app/test-pmd/testpmd.c +46 -2

66 lines not on this page · raw message

app/test-pmd/testpmd.h +5 -0
index fc56b60..af654ea 100644
@@ -876,6 +876,11 @@ void port_rss_reta_info(portid_t port_id,
 
 void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on);
 
+int
+rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
+	       uint16_t nb_rx_desc, unsigned int socket_id,
+	       struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp);
+
 int set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate);
 int set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate,
 				uint64_t q_msk);
Signature · 1 line
1.8.3.1
#70 lore raw

v6 cover ethdev: introduce Rx buffer split

In reply to Slava Ovsiienko

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
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 reserved; /* reserved field */
};

The segment descriptions are added to the rte_eth_rxconf structure:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf. This array allows to specify the different settings for each segment in individual fashion.
rx_nseg - number of elements in the array

If the extended segment descriptions is provided with these new fields the mp parameter of the rte_eth_rx_queue_setup must be specified as NULL to avoid ambiguity.

There are two options to specifiy Rx buffer configuration:
- mp is not NULL, rx_conf.rx_seg is NULL, rx_conf.rx_nseg is zero, it is compatible configuraion, follows existing implementation, provides single pool and no description for segment sizes and offsets.
- mp is NULL, rx_conf.rx_seg is not NULL, rx_conf.rx_nseg is not zero, it provides the extended configuration, individually for each segment.

The new offload flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup() routine application should check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new settings the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will split the received packets into multiple segments according to the specification in the description array:

- the first network buffer will be allocated from the memory pool, specified in the first segment description element, the second network buffer - from the pool in the second segment description element and so on. If there is no enough elements to describe the buffer for entire packet of maximal length the pool from the last valid element will be used to allocate the buffers from for the rest of segments

- the offsets from the segment description elements will provide the data offset from the buffer beginning except the first mbuf - for this one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual offset from the buffer beginning. If there is no enough elements to describe the buffer for entire packet of maximal length the offsets for the rest of segment will be supposed to be zero.

- the data length being received to each segment is limited by the length specified in the segment description element. The data receiving starts with filling up the first mbuf data buffer, if the specified maximal segment length is reached and there are data remaining (packet is longer than buffer in the first mbuf) the following data will be pushed to the next segment up to its own maximal length. If the first two segments is not enough to store all the packet remaining data the next (third) segment will be engaged and so on. If the length in the segment description element is zero the actual buffer size will be deduced from the appropriate memory pool properties. If there is no enough elements to describe the buffer for entire packet of maximal length the buffer size will be deduced from the pool of the last valid element for the remaining segments.

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B long @ 128 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B @ 128 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload RTE_ETH_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if rx_nseg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

---
v1: http://patches.dpdk.org/patch/79594/
v2: http://patches.dpdk.org/patch/79893/
- add feature support to mlx5 PMD

v3: http://patches.dpdk.org/patch/80389/
- rte_eth_rx_queue_setup_ex is renamed to rte_eth_rxseg_queue_setup
- DEV_RX_OFFLOAD_BUFFER_SPLIT is renamed to RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT
- commit message update
- documentaion provided
- release notes update
- minor bug fixes in testpmd related part

v4: http://patches.dpdk.org/patch/80401/
- common part of rx_queue_setup/rxseg_queue_setup

v5: http://patches.dpdk.org/patch/80609/
- refactored to approach of providing split configuration in the rte_eth_rxconf structure instead of introducing the new API routine
- added support for rxoffs command to testpmd to provide segment offsets for complete testing of split configurations
- patchset is split into two parts - PMD part will be presented as separate series

v6: - wordy comments rephrased
- typos fixed
- rte_eth_rx_queue_setup configuration check isolated for two main options
- the rest of comments addressed

Viacheslav Ovsiienko (6):
ethdev: introduce Rx buffer split app/testpmd: add multiple pools per core creation app/testpmd: add buffer split offload configuration app/testpmd: add rxpkts commands and parameters app/testpmd: add rxoffs commands and parameters app/testpmd: add extended Rx queue setup

 app/test-pmd/bpf_cmd.c                      |   4 +-
 app/test-pmd/cmdline.c                      | 151 ++++++++++++++++++++++++----
 app/test-pmd/config.c                       | 107 +++++++++++++++++++-
 app/test-pmd/parameters.c                   |  54 ++++++++--
 app/test-pmd/testpmd.c                      | 120 ++++++++++++++++------
 app/test-pmd/testpmd.h                      |  44 ++++++--
 doc/guides/nics/features.rst                |  15 +++
 doc/guides/rel_notes/deprecation.rst        |   5 -
 doc/guides/rel_notes/release_20_11.rst      |   9 ++
 doc/guides/testpmd_app_ug/run_app.rst       |  22 +++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  36 ++++++-
 lib/librte_ethdev/rte_ethdev.c              | 111 +++++++++++++++-----
 lib/librte_ethdev/rte_ethdev.h              |  62 +++++++++++-
 13 files changed, 637 insertions(+), 103 deletions(-)
Signature · 1 line
1.8.3.1
#71 lore raw

PATCH v6 1/6 ethdev: introduce Rx buffer split

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
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 reserved; /* reserved field */
};

The segment descriptions are added to the rte_eth_rxconf structure:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf. This array allows to specify the different settings for each segment in individual fashion.
rx_nseg - number of elements in the array

If the extended segment descriptions is provided with these new fields the mp parameter of the rte_eth_rx_queue_setup must be specified as NULL to avoid ambiguity.

There are two options to specifiy Rx buffer configuration:
- mp is not NULL, rx_conf.rx_seg is NULL, rx_conf.rx_nseg is zero, it is compatible configuraion, follows existing implementation, provides single pool and no description for segment sizes and offsets.
- mp is NULL, rx_conf.rx_seg is not NULL, rx_conf.rx_nseg is not zero, it provides the extended configuration, individually for each segment.

The new offload flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup() routine application should check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new settings the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will split the received packets into multiple segments according to the specification in the description array:

- the first network buffer will be allocated from the memory pool, specified in the first segment description element, the second network buffer - from the pool in the second segment description element and so on. If there is no enough elements to describe the buffer for entire packet of maximal length the pool from the last valid element will be used to allocate the buffers from for the rest of segments

- the offsets from the segment description elements will provide the data offset from the buffer beginning except the first mbuf - for this one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual offset from the buffer beginning. If there is no enough elements to describe the buffer for entire packet of maximal length the offsets for the rest of segment will be supposed to be zero.

- the data length being received to each segment is limited by the length specified in the segment description element. The data receiving starts with filling up the first mbuf data buffer, if the specified maximal segment length is reached and there are data remaining (packet is longer than buffer in the first mbuf) the following data will be pushed to the next segment up to its own maximal length. If the first two segments is not enough to store all the packet remaining data the next (third) segment will be engaged and so on. If the length in the segment description element is zero the actual buffer size will be deduced from the appropriate memory pool properties. If there is no enough elements to describe the buffer for entire packet of maximal length the buffer size will be deduced from the pool of the last valid element for the remaining segments.

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B long @ 128 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B @ 128 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload RTE_ETH_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if rx_nseg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

---
 doc/guides/nics/features.rst           |  15 +++++
 doc/guides/rel_notes/deprecation.rst   |   5 --
 doc/guides/rel_notes/release_20_11.rst |   9 +++
 lib/librte_ethdev/rte_ethdev.c         | 111 +++++++++++++++++++++++++--------
 lib/librte_ethdev/rte_ethdev.h         |  62 +++++++++++++++++-
 5 files changed, 171 insertions(+), 31 deletions(-)
doc/guides/nics/features.rst +15 -0
index dd8c955..832ea3b 100644
@@ -185,6 +185,21 @@ Supports receiving segmented mbufs.
 * **[related]    eth_dev_ops**: ``rx_pkt_burst``.
 
 
+.. _nic_features_buffer_split:
+
+Buffer Split on Rx
+------------------
+
+Scatters the packets being received on specified boundaries to segmented mbufs.
+
+* **[uses]       rte_eth_rxconf,rte_eth_rxmode**: ``offloads:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[uses]       rte_eth_rxconf**: ``rx_conf.rx_seg, rx_conf.rx_nseg``.
+* **[implements] datapath**: ``Buffer Split functionality``.
+* **[provides]   rte_eth_dev_info**: ``rx_offload_capa:RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT``.
+* **[provides]   eth_dev_ops**: ``rxq_info_get:buffer_split``.
+* **[related] API**: ``rte_eth_rx_queue_setup()``.
+
+
 .. _nic_features_lro:
 
 LRO
doc/guides/rel_notes/deprecation.rst +0 -5
index 584e720..232cd54 100644
@@ -138,11 +138,6 @@ Deprecation Notices
   In 19.11 PMDs will still update the field even when the offload is not
   enabled.
 
-* ethdev: Add new fields to ``rte_eth_rxconf`` to configure the receiving
-  queues to split ingress packets into multiple segments according to the
-  specified lengths into the buffers allocated from the specified
-  memory pools. The backward compatibility to existing API is preserved.
-
 * ethdev: ``rx_descriptor_done`` dev_ops and ``rte_eth_rx_descriptor_done``
   will be removed in 21.11.
   Existing ``rte_eth_rx_descriptor_status`` and ``rte_eth_tx_descriptor_status``
doc/guides/rel_notes/release_20_11.rst +9 -0
index bcc0fc2..bcc2479 100644
@@ -60,6 +60,12 @@ New Features
   Added the FEC API which provides functions for query FEC capabilities and
   current FEC mode from device. Also, API for configuring FEC mode is also provided.
 
+* **Introduced extended buffer description for receiving.**
+
+  Added the extended Rx buffer description for Rx queue setup routine
+  providing the individual settings for each Rx segment with maximal size,
+  buffer offset and memory pool to allocate data buffers from.
+
 * **Updated Broadcom bnxt driver.**
 
   Updated the Broadcom bnxt driver with new features and improvements, including:
@@ -253,6 +259,9 @@ API Changes
   As the data of ``uint8_t`` will be truncated when queue number under
   a TC is greater than 256.
 
+* ethdev: Added fields rx_seg and rx_nseg to rte_eth_rxconf structure
+  to provide extended description of the receiving buffer.
+
 * vhost: Moved vDPA APIs from experimental to stable.
 
 * rawdev: Added a structure size parameter to the functions
lib/librte_ethdev/rte_ethdev.c +86 -25

139 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +61 -1

88 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#72 lore raw
Quoted 88 lines · Viacheslav Ovsiienko

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
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 reserved; /* reserved field */
};

The segment descriptions are added to the rte_eth_rxconf structure:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf. This array allows to specify the different settings for each segment in individual fashion.
rx_nseg - number of elements in the array

If the extended segment descriptions is provided with these new fields the mp parameter of the rte_eth_rx_queue_setup must be specified as NULL to avoid ambiguity.

There are two options to specifiy Rx buffer configuration:
- mp is not NULL, rx_conf.rx_seg is NULL, rx_conf.rx_nseg is zero, it is compatible configuraion, follows existing implementation, provides single pool and no description for segment sizes and offsets.
- mp is NULL, rx_conf.rx_seg is not NULL, rx_conf.rx_nseg is not zero, it provides the extended configuration, individually for each segment.

The new offload flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup() routine application should check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new settings the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will split the received packets into multiple segments according to the specification in the description array:

- the first network buffer will be allocated from the memory pool, specified in the first segment description element, the second network buffer - from the pool in the second segment description element and so on. If there is no enough elements to describe the buffer for entire packet of maximal length the pool from the last valid element will be used to allocate the buffers from for the rest of segments

- the offsets from the segment description elements will provide the data offset from the buffer beginning except the first mbuf - for this one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual offset from the buffer beginning. If there is no enough elements to describe the buffer for entire packet of maximal length the offsets for the rest of segment will be supposed to be zero.

- the data length being received to each segment is limited by the length specified in the segment description element. The data receiving starts with filling up the first mbuf data buffer, if the specified maximal segment length is reached and there are data remaining (packet is longer than buffer in the first mbuf) the following data will be pushed to the next segment up to its own maximal length. If the first two segments is not enough to store all the packet remaining data the next (third) segment will be engaged and so on. If the length in the segment description element is zero the actual buffer size will be deduced from the appropriate memory pool properties. If there is no enough elements to describe the buffer for entire packet of maximal length the buffer size will be deduced from the pool of the last valid element for the remaining segments.

Quoted 6 lines

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

Sorry for chime in late. This API lookout looks good to me.
But, I am wondering how the application can know the capability or "limits" of struct rte_eth_rxseg structure for the specific PMD. The other descriptor limit, it's being exposed with struct rte_eth_dev_info::rx_desc_lim;
If PMD can support a specific pattern rather than returning the blanket error, the application should know the limit.
IMO, it is better to add
struct rte_eth_rxseg *rxsegs;
unint16_t nb_max_rxsegs
in rte_eth_dev_info structure to express the capablity.
Where the en and offset can define the max offset.

Thoughts?

#73 lore raw

Hi, Jerin

Quoted 22 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Wednesday, October 14, 2020 21:57
To: Slava Ovsiienko <[email protected]>
Cc: dpdk-dev <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Stephen Hemminger <[email protected]>; Ferruh Yigit <[email protected]>; Olivier Matz <[email protected]>; Maxime Coquelin <[email protected]>; David Marchand <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [PATCH v6 1/6] ethdev: introduce Rx buffer split

Quoted 7 lines · Viacheslav Ovsiienko

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

[..snip..]

Quoted 20 lines
Quoted 6 lines

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

Sorry for chime in late. This API lookout looks good to me.
But, I am wondering how the application can know the capability or "limits" of struct rte_eth_rxseg structure for the specific PMD. The other descriptor limit, it's being exposed with struct rte_eth_dev_info::rx_desc_lim; If PMD can support a specific pattern rather than returning the blanket error, the application should know the limit.
IMO, it is better to add
struct rte_eth_rxseg *rxsegs;
unint16_t nb_max_rxsegs
in rte_eth_dev_info structure to express the capablity.
Where the en and offset can define the max offset.

Quoted 1 line

Thoughts?

Moreover, there might be implied a lot of various limitations - offsets might be not supported at all or have some requirements for alignment, the similar requirements might be applied to segment size (say, ask for some granularity). Currently it is not obvious how to report all nuances, and it is supposed the limitations of this kind must be documented in PMD chapter. As for mlx5 - it has no special limitations besides common requirements to the regular segments.

One more point - the split feature might be considered as just one of possible cases of using these segment descriptions, other features might impose other (unknown for now) limitations. If we see some of the features of such kind or other PMDs adopts the split feature - we'll try to find the common root and consider the way how to report it.

With best regards, Slava

#74 lore raw
Quoted 2 lines · Slava Ovsiienko

Hi, Jerin

Hi Slava,

Quoted 46 lines
Quoted 23 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Wednesday, October 14, 2020 21:57
To: Slava Ovsiienko <[email protected]>
Cc: dpdk-dev <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Stephen Hemminger <[email protected]>; Ferruh Yigit <[email protected]>; Olivier Matz <[email protected]>; Maxime Coquelin <[email protected]>; David Marchand <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [PATCH v6 1/6] ethdev: introduce Rx buffer split

Quoted 7 lines · Viacheslav Ovsiienko

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

[..snip..]

Quoted 20 lines
Quoted 6 lines

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

Sorry for chime in late. This API lookout looks good to me.
But, I am wondering how the application can know the capability or "limits" of struct rte_eth_rxseg structure for the specific PMD. The other descriptor limit, it's being exposed with struct rte_eth_dev_info::rx_desc_lim; If PMD can support a specific pattern rather than returning the blanket error, the application should know the limit.
IMO, it is better to add
struct rte_eth_rxseg *rxsegs;
unint16_t nb_max_rxsegs
in rte_eth_dev_info structure to express the capablity.
Where the en and offset can define the max offset.

Quoted 7 lines
Quoted 1 line

Thoughts?

Moreover, there might be implied a lot of various limitations - offsets might be not supported at all or have some requirements for alignment, the similar requirements might be applied to segment size (say, ask for some granularity). Currently it is not obvious how to report all nuances, and it is supposed the limitations of this kind must be documented in PMD chapter. As for mlx5 - it has no special limitations besides common requirements to the regular segments.

Reporting the limitation in the documentation will not help for the generic applications.

Quoted 5 lines

One more point - the split feature might be considered as just one of possible cases of using these segment descriptions, other features might impose other (unknown for now) limitations. If we see some of the features of such kind or other PMDs adopts the split feature - we'll try to find the common root and consider the way how to report it.

My only concern with that approach will be ABI break again if something needs to exposed over rte_eth_dev_info().
IMO, if we featured needs to completed only when its capabilities are exposed in a programmatic manner.
As of mlx5, if there not limitation then info rte_eth_dev_info::rxsegs[x].len, offset etc as UINT16_MAX so that application is aware of the state.

Quoted 3 lines

With best regards, Slava

#75 lore raw
Quoted 55 lines · Jerin Jacob
Quoted 2 lines · Slava Ovsiienko

Hi, Jerin

Hi Slava,

Quoted 48 lines
Quoted 23 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Wednesday, October 14, 2020 21:57
To: Slava Ovsiienko <[email protected]>
Cc: dpdk-dev <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Stephen Hemminger <[email protected]>; Ferruh Yigit <[email protected]>; Olivier Matz <[email protected]>; Maxime Coquelin <[email protected]>; David Marchand <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [PATCH v6 1/6] ethdev: introduce Rx buffer split

Quoted 7 lines · Viacheslav Ovsiienko

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

[..snip..]

Quoted 21 lines
Quoted 6 lines

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

Sorry for chime in late. This API lookout looks good to me.
But, I am wondering how the application can know the capability or "limits" of struct rte_eth_rxseg structure for the specific PMD. The other descriptor limit, it's being exposed with struct rte_eth_dev_info::rx_desc_lim; If PMD can support a specific pattern rather than returning the blanket error, the application should know the limit.
IMO, it is better to add
struct rte_eth_rxseg *rxsegs;
unint16_t nb_max_rxsegs
in rte_eth_dev_info structure to express the capablity.
Where the en and offset can define the max offset.

Thoughts?

Quoted 12 lines
Quoted 5 lines

Moreover, there might be implied a lot of various limitations - offsets might be not supported at all or have some requirements for alignment, the similar requirements might be applied to segment size (say, ask for some granularity). Currently it is not obvious how to report all nuances, and it is supposed the limitations of this kind must be documented in PMD chapter. As for mlx5 - it has no special limitations besides common requirements to the regular segments.

Reporting the limitation in the documentation will not help for the generic applications.

Quoted 3 lines

One more point - the split feature might be considered as just one of possible cases of using these segment descriptions, other features might impose other (unknown for now) limitations.

Also , I agree that w will have multiple use cases with segment descriptors. In order to make it future proof on the API definion is better to have from:
struct rte_eth_rxseg {
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. */
};
something lime below:

struct rte_eth_rxseg {
    enum rte_eth_rxseg_mode mode ;
    union {
               struct rte_eth_rxseg_mode xxx {
                              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. */
             }
}

Another mode, Marvell PMD has it(I believe Intel also) i.e When we say:

seg0 - pool0, len0=2000B, off0=0
seg1 - pool1, len1=2001B, off1=0

packet size up to, 2000B goes to pool 0 and if is >=2001 goes to pool1. I think, it is better to have mode param in rte_eth_rxseg for avoiding ABI changes.(Just like clean rte_flow APIs)

Quoted 14 lines
Quoted 2 lines

If we see some of the features of such kind or other PMDs adopts the split feature - we'll try to find the common root and consider the way how to report it.

My only concern with that approach will be ABI break again if something needs to exposed over rte_eth_dev_info().
IMO, if we featured needs to completed only when its capabilities are exposed in a programmatic manner.
As of mlx5, if there not limitation then info rte_eth_dev_info::rxsegs[x].len, offset etc as UINT16_MAX so that application is aware of the state.

Quoted 3 lines

With best regards, Slava

#76 lore raw

Hi, Jerin

Quoted 13 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Thursday, October 15, 2020 13:28
To: Slava Ovsiienko <[email protected]>
Cc: dpdk-dev <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Stephen Hemminger <[email protected]>; Ferruh Yigit <[email protected]>; Olivier Matz <[email protected]>; Maxime Coquelin <[email protected]>; David Marchand <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [PATCH v6 1/6] ethdev: introduce Rx buffer split

[..snip..]

Quoted 6 lines
struct rte_eth_rxseg {
    enum rte_eth_rxseg_mode mode ;
    union {
               struct rte_eth_rxseg_mode xxx {
                              struct rte_mempool *mp; /**< Memory pool to allocate
Quoted 8 lines

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. */
             }
}

There is an array of rte_eth_rxseg. It would introduce multiple "enum rte_eth_rxseg_mode mode" and would cause some ambiguity. About mode selection - please, see below.
Union seems to be good idea, let's adopt.

Quoted 9 lines

Another mode, Marvell PMD has it(I believe Intel also) i.e When we say:

seg0 - pool0, len0=2000B, off0=0
seg1 - pool1, len1=2001B, off1=0

packet size up to, 2000B goes to pool 0 and if is >=2001 goes to pool1. I think, it is better to have mode param in rte_eth_rxseg for avoiding ABI changes.(Just like clean rte_flow APIs)

It is supposed to choose with RTE_ETH_RX_OFFLOAD_xxx flags.
For packet sorting it should be something like this RTE_ETH_RX_OFFLOAD_SORT. PMD reports it supports the feature, the flag is set in rx_conf->offloads and rxseg structure is interpreted according to these flags.

Please, note, there is intentionally no check for RTE_ETH_RX_OFFLOAD_xxx in rte_eth_dev_rx_queue_setup() - it should be done on PMD side.

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

If we see some of the features of such kind or other PMDs adopts the split feature - we'll try to find the common root and consider the way how

to report it.

Quoted 3 lines

My only concern with that approach will be ABI break again if something needs to exposed over rte_eth_dev_info().

Let's reserve the pointer to struct rte_eth_rxseg_limitations in the rte_eth_dev_info to avoid ABI break?

With best regards, Slava

#77 lore raw
Quoted 32 lines · Slava Ovsiienko

Hi, Jerin

Quoted 13 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Thursday, October 15, 2020 13:28
To: Slava Ovsiienko <[email protected]>
Cc: dpdk-dev <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Stephen Hemminger <[email protected]>; Ferruh Yigit <[email protected]>; Olivier Matz <[email protected]>; Maxime Coquelin <[email protected]>; David Marchand <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [PATCH v6 1/6] ethdev: introduce Rx buffer split

[..snip..]

Quoted 6 lines
struct rte_eth_rxseg {
    enum rte_eth_rxseg_mode mode ;
    union {
               struct rte_eth_rxseg_mode xxx {
                              struct rte_mempool *mp; /**< Memory pool to allocate
Quoted 8 lines

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. */
             }
}
Quoted 3 lines

There is an array of rte_eth_rxseg. It would introduce multiple "enum rte_eth_rxseg_mode mode" and would cause some ambiguity. About mode selection - please, see below.
Union seems to be good idea, let's adopt.

Ack. Let's take the only union concept.

Quoted 7 lines
Quoted 7 lines

Another mode, Marvell PMD has it(I believe Intel also) i.e When we say:

seg0 - pool0, len0=2000B, off0=0
seg1 - pool1, len1=2001B, off1=0

Quoted 8 lines
Quoted 3 lines

packet size up to, 2000B goes to pool 0 and if is >=2001 goes to pool1. I think, it is better to have mode param in rte_eth_rxseg for avoiding ABI changes.(Just like clean rte_flow APIs)

It is supposed to choose with RTE_ETH_RX_OFFLOAD_xxx flags.
For packet sorting it should be something like this RTE_ETH_RX_OFFLOAD_SORT. PMD reports it supports the feature, the flag is set in rx_conf->offloads and rxseg structure is interpreted according to these flags.

Works for me.

Quoted 7 lines

Please, note, there is intentionally no check for RTE_ETH_RX_OFFLOAD_xxx in rte_eth_dev_rx_queue_setup() - it should be done on PMD side.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

If we see some of the features of such kind or other PMDs adopts the split feature - we'll try to find the common root and consider the way how

Quoted 7 lines
Quoted 4 lines

to report it.

Quoted 3 lines

My only concern with that approach will be ABI break again if something needs to exposed over rte_eth_dev_info().

Let's reserve the pointer to struct rte_eth_rxseg_limitations in the rte_eth_dev_info to avoid ABI break?

Works for me. If we add an additional reserved field.

Due to RC1 time constraint, I am OK to leave it as a reserved filed and fill meat when it is required if other ethdev maintainers are OK.
I will be required for feature complete.

Quoted 2 lines

With best regards, Slava

#78 lore raw

On 10/15/2020 12:26 PM, Jerin Jacob wrote:

<...>

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

If we see some of the features of such kind or other PMDs adopts the split feature - we'll try to find the common root and consider the way how

to report it.

Quoted 3 lines

My only concern with that approach will be ABI break again if something needs to exposed over rte_eth_dev_info().

Quoted 9 lines
Quoted 2 lines

Let's reserve the pointer to struct rte_eth_rxseg_limitations in the rte_eth_dev_info to avoid ABI break?

Works for me. If we add an additional reserved field.

Due to RC1 time constraint, I am OK to leave it as a reserved filed and fill meat when it is required if other ethdev maintainers are OK.
I will be required for feature complete.

Sounds good to me.

#79 lore raw
Quoted 28 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, October 15, 2020 14:37
To: Jerin Jacob <[email protected]>; Slava Ovsiienko <[email protected]>
Cc: dpdk-dev <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Stephen Hemminger <[email protected]>; Olivier Matz <[email protected]>; Maxime Coquelin <[email protected]>; David Marchand <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [PATCH v6 1/6] ethdev: introduce Rx buffer split

On 10/15/2020 12:26 PM, Jerin Jacob wrote:

<...>

Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

If we see some of the features of such kind or other PMDs adopts the split feature - we'll try to find the common root and consider the way how

to report it.

Quoted 3 lines

My only concern with that approach will be ABI break again if something needs to exposed over rte_eth_dev_info().

Let's reserve the pointer to struct rte_eth_rxseg_limitations in the rte_eth_dev_info to avoid ABI break?

Quoted 8 lines
Quoted 6 lines

Works for me. If we add an additional reserved field.

Due to RC1 time constraint, I am OK to leave it as a reserved filed and fill meat when it is required if other ethdev maintainers are OK. I will be required for feature complete.

Sounds good to me.

OK, let's introduce the pointer in the rte_eth_dev_info and define struct rte_eth_rxseg_limitations as experimental. Will it be allowed to update this one later (after 20.11)? Is ABI break is allowed for the case?

With best regards, Slava

#80 lore raw

15/10/2020 13:49, Slava Ovsiienko:

Quoted 24 lines

From: Ferruh Yigit <[email protected]>

Quoted 23 lines · Jerin Jacob

<...>

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

If we see some of the features of such kind or other PMDs adopts the split feature - we'll try to find the common root and consider the way how

to report it.

Quoted 3 lines

My only concern with that approach will be ABI break again if something needs to exposed over rte_eth_dev_info().

Quoted 9 lines
Quoted 2 lines

Let's reserve the pointer to struct rte_eth_rxseg_limitations in the rte_eth_dev_info to avoid ABI break?

Works for me. If we add an additional reserved field.

Due to RC1 time constraint, I am OK to leave it as a reserved filed and fill meat when it is required if other ethdev maintainers are OK. I will be required for feature complete.

Sounds good to me.

OK for me.

Quoted 4 lines

OK, let's introduce the pointer in the rte_eth_dev_info and define struct rte_eth_rxseg_limitations as experimental. Will it be allowed to update this one later (after 20.11)? Is ABI break is allowed for the case?

If it is experimental, you can change it at anytime.

Ideally, we could try to have a first version of the limitations during 20.11-rc2.

#81 lore raw
Quoted 19 lines · Thomas Monjalon

15/10/2020 13:49, Slava Ovsiienko:

Quoted 18 lines

From: Ferruh Yigit <[email protected]>

Quoted 17 lines · Jerin Jacob

<...>

Quoted 13 lines
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

If we see some of the features of such kind or other PMDs adopts the split feature - we'll try to find the common root and consider the way how

to report it.

Quoted 3 lines

My only concern with that approach will be ABI break again if something needs to exposed over rte_eth_dev_info().

Let's reserve the pointer to struct rte_eth_rxseg_limitations in the rte_eth_dev_info to avoid ABI break?

Works for me. If we add an additional reserved field.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

Due to RC1 time constraint, I am OK to leave it as a reserved filed and fill meat when it is required if other ethdev maintainers are OK. I will be required for feature complete.

Sounds good to me.

OK for me.

OK as well, but I dislike the idea with pointer in dev_info. It sounds like it breaks existing practice.
We should either reserve enough space or simply add dedicated API call to report Rx seg capabilities.

Quoted 10 lines
Quoted 5 lines

OK, let's introduce the pointer in the rte_eth_dev_info and define struct rte_eth_rxseg_limitations as experimental. Will it be allowed to update this one later (after 20.11)? Is ABI break is allowed for the case?

If it is experimental, you can change it at anytime.

Ideally, we could try to have a first version of the limitations during 20.11-rc2.

Yes, please.

#82 lore raw
Quoted 38 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, October 15, 2020 16:07
To: NBU-Contact-Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Jerin Jacob <[email protected]>; Slava Ovsiienko <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: dpdk-dev <[email protected]>; Stephen Hemminger <[email protected]>; Olivier Matz <[email protected]>; Maxime Coquelin <[email protected]>; David Marchand <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 1/6] ethdev: introduce Rx buffer split

Quoted 24 lines · Thomas Monjalon

15/10/2020 13:49, Slava Ovsiienko:

Quoted 23 lines

From: Ferruh Yigit <[email protected]>

Quoted 22 lines · Jerin Jacob

<...>

Quoted 17 lines
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

If we see some of the features of such kind or other PMDs adopts the split feature - we'll try to find the common root and consider the way how

to report it.

Quoted 3 lines

My only concern with that approach will be ABI break again if something needs to exposed over rte_eth_dev_info().

Let's reserve the pointer to struct rte_eth_rxseg_limitations in the rte_eth_dev_info to avoid ABI break?

Works for me. If we add an additional reserved field.

Due to RC1 time constraint, I am OK to leave it as a reserved filed and fill meat when it is required if other ethdev maintainers are OK. I will be required for feature complete.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

Sounds good to me.

OK for me.

OK as well, but I dislike the idea with pointer in dev_info. It sounds like it breaks existing practice.

Moreover, if we are going to have multiple features using Rx segmentation we should provide multiple structures with limitations - at least, one per feature.

Quoted 3 lines

We should either reserve enough space or simply add dedicated API call to report Rx seg capabilities.

It seems we are trying to embrace everything in very generic way 😊
Just curious - how did we managed to survive without limitations on Tx direction? No one told us how many segments PMD supports on Tx, what is the limitations for offsets and alignments, it seems there is no limits for tx segment size at all. How could it happen? Tx limitations do not exist? Just no one cared about the Tx limitations?

As for Rx limitations - there are no reasonable ones for now. We'll invent the way to report the limitations (and it seems to be unbalanced - we should provide the same to Tx), the next step is to provide at least one PMD using that, and in this way to make mlx5 PMD to report silly values - "I have no reasonable limitations beyond meaningful buffer size under pool_buf_size/UINT16_MAX)".

IMO, If some HW does not support arbitrary split (suppose, it is not common case, most of HW is very flexible about specifying Rx buffers) the BUFFER_SPLIT feature should not be advertised at all, because it would be not very useful - application is intended to work over specific protocol, it knows where it wants to set split point (defined by packet format). Hence, application is not so interested about offsets, alignments, etc - it just checks whether PMD provides requested split points or not.

That's why just simple documenting was initially intended, there are just no a lot of limitations expected, likewise Tx direction shows that.

Yes, generally speaking, there are no doubts it would be nice to report the limitations, but:
- not expected to have many (documenting can the few exceptions)
- no nice way is found how to report - pointer? API?
- complicated to present for various features (variable size array, multiple features)
- not known which limitations are actually needed, just some theoretical ones

So, we see the large white area, should we invent something not well-defined to cover one, or let's wait for actual request to check limitations that can't be handled by documenting and internal PMD checking/validation?

With best regards, Slava

#83 lore raw
In reply to Andrew Rybchenko

Hi,

Evening update:
- addressed code comments
- provided the union of segmentation description with dedicated feature structures according Jerin's proposal
- added the reporting of split limitation

With best regards, Slava

Quoted 59 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, October 15, 2020 16:07
To: NBU-Contact-Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Jerin Jacob <[email protected]>; Slava Ovsiienko <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: dpdk-dev <[email protected]>; Stephen Hemminger <[email protected]>; Olivier Matz <[email protected]>; Maxime Coquelin <[email protected]>; David Marchand <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 1/6] ethdev: introduce Rx buffer split

Quoted 19 lines · Thomas Monjalon

15/10/2020 13:49, Slava Ovsiienko:

Quoted 18 lines

From: Ferruh Yigit <[email protected]>

Quoted 17 lines · Jerin Jacob

<...>

Quoted 13 lines
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

If we see some of the features of such kind or other PMDs adopts the split feature - we'll try to find the common root and consider the way how

to report it.

Quoted 3 lines

My only concern with that approach will be ABI break again if something needs to exposed over rte_eth_dev_info().

Let's reserve the pointer to struct rte_eth_rxseg_limitations in the rte_eth_dev_info to avoid ABI break?

Works for me. If we add an additional reserved field.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

Due to RC1 time constraint, I am OK to leave it as a reserved filed and fill meat when it is required if other ethdev maintainers are OK. I will be required for feature complete.

Sounds good to me.

OK for me.

OK as well, but I dislike the idea with pointer in dev_info. It sounds like it breaks existing practice.
We should either reserve enough space or simply add dedicated API call to report Rx seg capabilities.

Quoted 10 lines
Quoted 5 lines

OK, let's introduce the pointer in the rte_eth_dev_info and define struct rte_eth_rxseg_limitations as experimental.
Will it be allowed to update this one later (after 20.11)? Is ABI break is allowed for the case?

If it is experimental, you can change it at anytime.

Ideally, we could try to have a first version of the limitations during 20.11-rc2.

Yes, please.

#84 lore raw
In reply to Slava Ovsiienko
Quoted 55 lines · Slava Ovsiienko

Hi, Jerin

Quoted 22 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Wednesday, October 14, 2020 21:57
To: Slava Ovsiienko <[email protected]>
Cc: dpdk-dev <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Stephen Hemminger <[email protected]>; Ferruh Yigit <[email protected]>; Olivier Matz <[email protected]>; Maxime Coquelin <[email protected]>; David Marchand <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [PATCH v6 1/6] ethdev: introduce Rx buffer split

Quoted 7 lines · Viacheslav Ovsiienko

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

[..snip..]

Quoted 20 lines
Quoted 6 lines

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

Sorry for chime in late. This API lookout looks good to me.
But, I am wondering how the application can know the capability or "limits" of struct rte_eth_rxseg structure for the specific PMD. The other descriptor limit, it's being exposed with struct rte_eth_dev_info::rx_desc_lim; If PMD can support a specific pattern rather than returning the blanket error, the application should know the limit.
IMO, it is better to add
struct rte_eth_rxseg *rxsegs;
unint16_t nb_max_rxsegs
in rte_eth_dev_info structure to express the capablity.
Where the en and offset can define the max offset.

Quoted 1 line

Thoughts?

Moreover, there might be implied a lot of various limitations - offsets might be not supported at all or have some requirements for alignment, the similar requirements might be applied to segment size (say, ask for some granularity). Currently it is not obvious how to report all nuances, and it is supposed the limitations of this kind must be documented in PMD chapter. As for mlx5 - it has no special limitations besides common requirements to the regular segments.

Quoted 4 lines

One more point - the split feature might be considered as just one of possible cases of using these segment descriptions, other features might impose other (unknown for now) limitations. If we see some of the features of such kind or other PMDs adopts the split feature - we'll try to find the common root and consider the way how to report it.

At least there are few simple limitations which are easy to express:
1. Maximum number of segments
2. Possibility to use the last segment many times if required (I was suggesting to use scatter for it, but you rejected the idea - may be time to reconsider :) )
3. Maximum offset
Frankly speaking I'm not sure why it cannot be handled on PMD level (i.e. provide descriptors with offset taken into account or guarantee that HW mempool objects initialized correctly with required headroom). May be in some corner cases when the same HW mempool is shared by various segments with different offset requirements.
4. Offset alignment
5. Maximum/minimum length of a segment
6. Length alignment

I realize that 3, 4 and 5 could be per segment number. If it is really that complex, report common denominator which is guaranteed to work. If we have no checks on ethdev layer, application can ignore it if it knows better.

#85 lore raw

Hi, Andrew

Quoted 75 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, October 15, 2020 12:49
To: Slava Ovsiienko <[email protected]>; Jerin Jacob <[email protected]>
Cc: dpdk-dev <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Stephen Hemminger <[email protected]>; Ferruh Yigit <[email protected]>; Olivier Matz <[email protected]>; Maxime Coquelin <[email protected]>; David Marchand <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 1/6] ethdev: introduce Rx buffer split

Quoted 18 lines · Slava Ovsiienko

Hi, Jerin

Quoted 16 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Wednesday, October 14, 2020 21:57
To: Slava Ovsiienko <[email protected]>
Cc: dpdk-dev <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Stephen Hemminger <[email protected]>; Ferruh Yigit <[email protected]>; Olivier Matz <[email protected]>; Maxime Coquelin <[email protected]>; David Marchand <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [PATCH v6 1/6] ethdev: introduce Rx buffer split

Quoted 1 line · Viacheslav Ovsiienko
Quoted 23 lines
Quoted 6 lines
Quoted 6 lines

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

[..snip..]

Quoted 14 lines
Quoted 6 lines

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

Sorry for chime in late. This API lookout looks good to me. But, I am wondering how the application can know the capability or "limits" of struct rte_eth_rxseg structure for the specific PMD. The other descriptor limit, it's being exposed with struct rte_eth_dev_info::rx_desc_lim; If PMD can support a specific pattern rather than returning the blanket error, the application should know the

limit.

Quoted 6 lines
Quoted 6 lines

IMO, it is better to add
struct rte_eth_rxseg *rxsegs;
unint16_t nb_max_rxsegs
in rte_eth_dev_info structure to express the capablity. Where the en and offset can define the max offset.

Quoted 7 lines
Quoted 1 line

Thoughts?

Moreover, there might be implied a lot of various limitations - offsets might be not supported at all or have some requirements for alignment, the similar requirements might be applied to segment size (say, ask for some granularity). Currently it is not obvious how to report all nuances, and it is supposed the limitations of this kind must be

documented in PMD chapter. As for mlx5 - it has no special limitations besides common requirements to the regular segments.

Quoted 3 lines

One more point - the split feature might be considered as just one of possible cases of using these segment descriptions, other features might

Quoted 8 lines

impose other (unknown for now) limitations.

Quoted 2 lines

If we see some of the features of such kind or other PMDs adopts the split feature - we'll try to find the common root and consider the way how to

report it.

At least there are few simple limitations which are easy to express:
1. Maximum number of segments

We have scatter capability and we do not report the maximal number of segments, it is on PMD own. We could add the field to the rte_eth_dev_info, but not sure whether we have something special to report there even for mlx5 case.

Quoted 3 lines

2. Possibility to use the last segment many times if required (I was suggesting to use scatter for it, but you rejected the idea - may be time to reconsider :) )

Mmm, sorry I do not follow, it might be I did not understand/missed your idea. Some of the last segment attributes are used multiple times to scatter the rest of the data in fashion very close to the existing scattering approach - at least, pool and buffer size from this pool are used. The beginning of the packet scattered according to the new descriptions, the rest of the packet - according to the existing regular scattering with pool settings from the last segment description.

3. Maximum offset

Quoted 6 lines

Frankly speaking I'm not sure why it cannot be handled on PMD level (i.e. provide descriptors with offset taken into account or guarantee that HW mempool objects initialized correctly with required headroom). May be in some corner cases when the same HW mempool is shared by various segments with different offset requirements.

HW offsets are beyond the feature scope, the offsets in the segment description is supposed to be added to the native pool offsets (if any).

Quoted 3 lines

4. Offset alignment
5. Maximum/minimum length of a segment
6. Length alignment

In which form? Mask of lsbs ? 0 means no limitations ?

Quoted 5 lines

I realize that 3, 4 and 5 could be per segment number.
If it is really that complex, report common denominator which is guaranteed to work. If we have no checks on ethdev layer, application can ignore it if it knows better.

Currently it is not clear at all what kind of limitations should be reported, we could include all of mentioned/proposed ones, and no one will report there - mlx5 has no any reasonable limitations to report for now.

Should we reserve some pointer field in the rte_eth_dev_info to report
the limitations? (Limitation description should contain variable size array, depending on the number of segments, so pointer seems to be appropriate).
It would allow us to avoid ABI break, and present the limitation structure once it is defined.

With best regards, Slava

#86 lore raw
Quoted 80 lines · Slava Ovsiienko

Hi, Andrew

Quoted 78 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, October 15, 2020 12:49
To: Slava Ovsiienko <[email protected]>; Jerin Jacob <[email protected]>
Cc: dpdk-dev <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Stephen Hemminger <[email protected]>; Ferruh Yigit <[email protected]>; Olivier Matz <[email protected]>; Maxime Coquelin <[email protected]>; David Marchand <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 1/6] ethdev: introduce Rx buffer split

Quoted 18 lines · Slava Ovsiienko

Hi, Jerin

Quoted 16 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Wednesday, October 14, 2020 21:57
To: Slava Ovsiienko <[email protected]>
Cc: dpdk-dev <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Stephen Hemminger <[email protected]>; Ferruh Yigit <[email protected]>; Olivier Matz <[email protected]>; Maxime Coquelin <[email protected]>; David Marchand <[email protected]>; Andrew Rybchenko <[email protected]>
Subject: Re: [PATCH v6 1/6] ethdev: introduce Rx buffer split

Quoted 1 line · Viacheslav Ovsiienko
Quoted 23 lines
Quoted 6 lines
Quoted 6 lines

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

[..snip..]

Quoted 14 lines
Quoted 6 lines

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

Sorry for chime in late. This API lookout looks good to me. But, I am wondering how the application can know the capability or "limits" of struct rte_eth_rxseg structure for the specific PMD. The other descriptor limit, it's being exposed with struct rte_eth_dev_info::rx_desc_lim; If PMD can support a specific pattern rather than returning the blanket error, the application should know the

limit.

Quoted 6 lines
Quoted 6 lines

IMO, it is better to add
struct rte_eth_rxseg *rxsegs;
unint16_t nb_max_rxsegs
in rte_eth_dev_info structure to express the capablity. Where the en and offset can define the max offset.

Quoted 7 lines
Quoted 1 line

Thoughts?

Moreover, there might be implied a lot of various limitations - offsets might be not supported at all or have some requirements for alignment, the similar requirements might be applied to segment size (say, ask for some granularity). Currently it is not obvious how to report all nuances, and it is supposed the limitations of this kind must be

documented in PMD chapter. As for mlx5 - it has no special limitations besides common requirements to the regular segments.

Quoted 3 lines

One more point - the split feature might be considered as just one of possible cases of using these segment descriptions, other features might

impose other (unknown for now) limitations.

Quoted 2 lines

If we see some of the features of such kind or other PMDs adopts the split feature - we'll try to find the common root and consider the way how to

Quoted 8 lines
Quoted 5 lines

report it.

At least there are few simple limitations which are easy to express:
1. Maximum number of segments

We have scatter capability and we do not report the maximal number of segments, it is on PMD own. We could add the field to the rte_eth_dev_info, but not sure whether we have something special to report there even for mlx5 case.

There is always a limitation in programming and HW. Nothing is unlimited. Limits could be high, but still exist. Number of descriptors? Width of field in HW interface? Maximum length of the config message to HW?
All above could limit it directly or indirectly.

Quoted 11 lines
Quoted 3 lines

2. Possibility to use the last segment many times if required (I was suggesting to use scatter for it, but you rejected the idea - may be time to reconsider :) )

Mmm, sorry I do not follow, it might be I did not understand/missed your idea. Some of the last segment attributes are used multiple times to scatter the rest of the data in fashion very close to the existing scattering approach - at least, pool and buffer size from this pool are used. The beginning of the packet scattered according to the new descriptions, the rest of the packet - according to the existing regular scattering with pool settings from the last segment description.

I believe that the possibility to split into a fixed segments (BUFFER_SPLIT) and possibility to use a mempool (just mp or last segment) many times if a packet does not fit (SCATTER) it is *different* features.
I can easily imagine HW which could do BUFFER_SPLIT to fixed segments, but cannot use the last segment many times (i.e. no classical SCATTER).

Quoted 11 lines

3. Maximum offset

Quoted 6 lines

Frankly speaking I'm not sure why it cannot be handled on PMD level (i.e. provide descriptors with offset taken into account or guarantee that HW mempool objects initialized correctly with required headroom). May be in some corner cases when the same HW mempool is shared by various segments with different offset requirements.

HW offsets are beyond the feature scope, the offsets in the segment description is supposed to be added to the native pool offsets (if any).

Are you saying that offsets are not passed to HW and just handled by PMD to provide correct IOVA addresses to put data to? If so, it is an implementation detail which is specific to mlx5. If so, no specific limitations except data room, size and offset consistency.
But it could be passed to a HW and it could be, for example, just 8 bits for the value.

Quoted 5 lines
Quoted 4 lines

4. Offset alignment
5. Maximum/minimum length of a segment
6. Length alignment

In which form? Mask of lsbs ? 0 means no limitations ?

log2, i.e. 0 => 1 (no limitations) 1 => 2 (even only), 6 => 64 (64-byte cache line aligned) etc.

Quoted 7 lines
Quoted 6 lines

I realize that 3, 4 and 5 could be per segment number.
If it is really that complex, report common denominator which is guaranteed to work. If we have no checks on ethdev layer, application can ignore it if it knows better.

Quoted 8 lines

Currently it is not clear at all what kind of limitations should be reported, we could include all of mentioned/proposed ones, and no one will report there - mlx5 has no any reasonable limitations to report for now.

Should we reserve some pointer field in the rte_eth_dev_info to report
the limitations? (Limitation description should contain variable size array, depending on the number of segments, so pointer seems to be appropriate).
It would allow us to avoid ABI break, and present the limitation structure once it is defined.

I will let other ethdev maintainers to make a decision here. My vote would be to report limitations mentioned above. It looks like Jerin is also interested in limitations reporting. Not sure if my form looks OK or no.

#87 lore raw

Hi, Andrew

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

At least there are few simple limitations which are easy to express:
1. Maximum number of segments

We have scatter capability and we do not report the maximal number of segments, it is on PMD own. We could add the field to the rte_eth_dev_info, but not sure whether we have something special to report

Quoted 7 lines

there even for mlx5 case.

There is always a limitation in programming and HW. Nothing is unlimited. Limits could be high, but still exist.
Number of descriptors? Width of field in HW interface? Maximum length of the config message to HW?
All above could limit it directly or indirectly.

None of above is applicable to mlx5 buffer split feature - it just adjusts the Rx buffer pointers and segment sizes, no anything beyond generic limitation - the queue descriptor numbers and mbuf buffer size. Suppose the most of HW by other vendors is capable to support buffer split feature with similar generic limitations.

Quoted 14 lines
Quoted 6 lines
Quoted 4 lines

2. Possibility to use the last segment many times if required (I was suggesting to use scatter for it, but you rejected the idea - may be time to reconsider :) )

Mmm, sorry I do not follow, it might be I did not understand/missed your

idea.

Quoted 6 lines

Some of the last segment attributes are used multiple times to scatter the rest of the data in fashion very close to the existing scattering approach - at least, pool and buffer size from this pool are used. The beginning of the packet scattered according to the new descriptions, the rest of the packet - according to the existing regular scattering with pool settings from the last segment description.

Quoted 3 lines

I believe that the possibility to split into a fixed segments (BUFFER_SPLIT) and possibility to use a mempool (just mp or last segment) many times if a packet does not fit (SCATTER) it is *different* features.

Sorry, what do you mean "use mempool many times"? Allocate multiple mbufs from the same mempool and build the chain of them?

We have SCATTER offload and many PMDs advertise that.
Scattering is actually the split, the split happens on some well-defined points to the mbufs from the same pool. BUFFER_SPLIT just extends SCATTER capabilities by providing the split point arbitrary settings and multiple pools.

Quoted 2 lines

I can easily imagine HW which could do BUFFER_SPLIT to fixed segments, but cannot use the last segment many times (i.e. no classical SCATTER).

Sorry, what do you mean "BUFFER_SPLIT to fixed segments" ?
This new offload BUFFER_SPLIT is intended to push data to flexible segments, potentially allocated from the different pools. The HW can be constrained with pool number (say it supports some pool alloc/free hardware accelerator for single pool only), in this case it will not be able to support BUFFER_SPLIT in multiple pool config, but using the single pool does not arise the problem.

It seems I missed something, could you, please, provide an example,
how would you like to see the usage last segment many times for BUFFER_SPLIT? How the packet should be split, in mbufs with what (last segment inherited) attributes?

Quoted 13 lines
Quoted 10 lines

3. Maximum offset

Quoted 6 lines

Frankly speaking I'm not sure why it cannot be handled on PMD level (i.e. provide descriptors with offset taken into account or guarantee that HW mempool objects initialized correctly with required headroom). May be in some corner cases when the same HW mempool is shared by various segments with different offset requirements.

Quoted 2 lines

HW offsets are beyond the feature scope, the offsets in the segment description is supposed to be added to the native pool offsets (if any).

Quoted 6 lines

Are you saying that offsets are not passed to HW and just handled by PMD to provide correct IOVA addresses to put data to? If so, it is an implementation detail which is specific to mlx5. If so, no specific limitations except data room, size and offset consistency.
But it could be passed to a HW and it could be, for example, just 8 bits for the value.

Yes, it could. But there should be other vendors be involved, not known for now who is going to support BUFFER_SPLIT and in which way. We should not invent some theoretical limitations and merge the dead code. And, please note - Tx segmentation has been living for 10 years successfully without any limitations, no one cares about, there is no any request to report. Likewise is expected for Rx.

Quoted 9 lines
Quoted 5 lines
Quoted 4 lines

4. Offset alignment
5. Maximum/minimum length of a segment 6. Length alignment

In which form? Mask of lsbs ? 0 means no limitations ?

log2, i.e. 0 => 1 (no limitations) 1 => 2 (even only), 6 => 64 (64-byte cache line aligned) etc.

Yes, possible option.

Quoted 15 lines
Quoted 7 lines
Quoted 6 lines

I realize that 3, 4 and 5 could be per segment number.
If it is really that complex, report common denominator which is guaranteed to work. If we have no checks on ethdev layer, application can ignore it if it knows better

Quoted 8 lines

Currently it is not clear at all what kind of limitations should be reported, we could include all of mentioned/proposed ones, and no one will report there -
mlx5 has no any reasonable limitations to report for now.

Should we reserve some pointer field in the rte_eth_dev_info to report the limitations? (Limitation description should contain variable size array, depending on the number of segments, so pointer seems to be

Quoted 8 lines

appropriate).

Quoted 1 line

It would allow us to avoid ABI break, and present the limitation structure

once it is defined.

I will let other ethdev maintainers to make a decision here.
My vote would be to report limitations mentioned above.
It looks like Jerin is also interested in limitations reporting. Not sure if my form looks OK or no.

For now I tend to think we could reserve some pointer for BUFFER_SPLIT limitations and that's it. Reporting some silly generic limitations from mlx5 means introducing the dead code in my opinion. If we'll see the actual request from applications to check and handle limitations (actually applications are very limited in this matter - they expect the split point to be set at very strong defined place of the packet format).

Acked-by on v6 1/6
#88 lore raw
In reply to Viacheslav Ovsiienko

14/10/2020 20:11, Viacheslav Ovsiienko:

Quoted 123 lines

The DPDK datapath in the transmit direction is very flexible. An application can build the multi-segment packet and manages almost all data aspects - the memory pools where segments are allocated from, the segment lengths, the memory attributes like external buffers, registered for DMA, etc.

In the receiving direction, the datapath is much less flexible, an application can only specify the memory pool to configure the receiving queue and nothing more. In order to extend receiving datapath capabilities it is proposed to add the way to provide extended information how to split the packets being received.

The following structure is introduced to specify the Rx packet segment:

struct rte_eth_rxseg {
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 reserved; /* reserved field */
};

The segment descriptions are added to the rte_eth_rxconf structure:
rx_seg - pointer the array of segment descriptions, each element
describes the memory pool, maximal data length, initial data offset from the beginning of data buffer in mbuf. This array allows to specify the different settings for each segment in individual fashion.
rx_nseg - number of elements in the array

If the extended segment descriptions is provided with these new fields the mp parameter of the rte_eth_rx_queue_setup must be specified as NULL to avoid ambiguity.

There are two options to specifiy Rx buffer configuration:
- mp is not NULL, rx_conf.rx_seg is NULL, rx_conf.rx_nseg is zero, it is compatible configuraion, follows existing implementation, provides single pool and no description for segment sizes and offsets.
- mp is NULL, rx_conf.rx_seg is not NULL, rx_conf.rx_nseg is not zero, it provides the extended configuration, individually for each segment.

The new offload flag RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT in device capabilities is introduced to present the way for PMD to report to application about supporting Rx packet split to configurable segments. Prior invoking the rte_eth_rx_queue_setup() routine application should check RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT flag.

If the Rx queue is configured with new settings the packets being received will be split into multiple segments pushed to the mbufs with specified attributes. The PMD will split the received packets into multiple segments according to the specification in the description array:

- the first network buffer will be allocated from the memory pool, specified in the first segment description element, the second network buffer - from the pool in the second segment description element and so on. If there is no enough elements to describe the buffer for entire packet of maximal length the pool from the last valid element will be used to allocate the buffers from for the rest of segments

- the offsets from the segment description elements will provide the data offset from the buffer beginning except the first mbuf - for this one the offset is added to the RTE_PKTMBUF_HEADROOM to get actual offset from the buffer beginning. If there is no enough elements to describe the buffer for entire packet of maximal length the offsets for the rest of segment will be supposed to be zero.

- the data length being received to each segment is limited by the length specified in the segment description element. The data receiving starts with filling up the first mbuf data buffer, if the specified maximal segment length is reached and there are data remaining (packet is longer than buffer in the first mbuf) the following data will be pushed to the next segment up to its own maximal length. If the first two segments is not enough to store all the packet remaining data the next (third) segment will be engaged and so on. If the length in the segment description element is zero the actual buffer size will be deduced from the appropriate memory pool properties. If there is no enough elements to describe the buffer for entire packet of maximal length the buffer size will be deduced from the pool of the last valid element for the remaining segments.

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

    seg0 - pool0, len0=14B, off0=2
    seg1 - pool1, len1=20B, off1=128B
    seg2 - pool2, len2=20B, off2=0B
    seg3 - pool3, len3=512B, off3=0B

The packet 46 bytes long will look like the following:
seg0 - 14B long @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B long @ 128 in mbuf from pool1
seg2 - 12B long @ 0 in mbuf from pool2

The packet 1500 bytes long will look like the following:
seg0 - 14B @ RTE_PKTMBUF_HEADROOM + 2 in mbuf from pool0 seg1 - 20B @ 128 in mbuf from pool1
seg2 - 20B @ 0 in mbuf from pool2
seg3 - 512B @ 0 in mbuf from pool3
seg4 - 512B @ 0 in mbuf from pool3
seg5 - 422B @ 0 in mbuf from pool3

The offload RTE_ETH_RX_OFFLOAD_SCATTER must be present and configured to support new buffer split feature (if rx_nseg is greater than one).

The new approach would allow splitting the ingress packets into multiple parts pushed to the memory with different attributes. For example, the packet headers can be pushed to the embedded data buffers within mbufs and the application data into the external buffers attached to mbufs allocated from the different memory pools. The memory attributes for the split parts may differ either - for example the application data may be pushed into the external memory located on the dedicated physical device, say GPU or NVMe. This would improve the DPDK receiving datapath flexibility with preserving compatibility with existing API.

Quoted 1 line

A large part of this commit log can be dropped because redundant with the doxygen comments.