Skip to contentSkip to conversation

ethdev: check consistency of per port offloads

PATCH New Wei Dai 6 participants 60 messages Feb 1, 2018 – May 14, 2018

Subsystems (2)
lore
Share & tools
lore

Wei Dai

author
#0 lore raw

PATCH 1/1 ethdev: check consistency of per port offloads

A per port offloading feature should be enabled or disabled at same time in both rte_eth_dev_configure( ) and rte_eth_rx_queue_setup( )/rte_eth_tx_queue_setup( ). This patch check if a per port offloading flag has same configuration in rte_eth_dev_configure( ) and rte_eth_rx_queue_setup( )/rte_eth_tx_queue_setup( ). This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

---
 lib/librte_ether/rte_ethdev.c | 70 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
lib/librte_ether/rte_ethdev.c +70 -0
index 78bed1a..7945890 100644
@@ -1404,6 +1404,44 @@ rte_eth_dev_is_removed(uint16_t port_id)
 	return ret;
 }
 
+/**
+* Check if the Rx/Tx queue offloading settings is valid
+* @param queue_offloads
+*   offloads input to rte_eth_rx_queue_setup( ) or rte_eth_tx_queue_setup( )
+* @param port_offloads
+*   Rx or Tx offloads input to rte_eth_dev_configure( )
+* @param queue_offload_capa
+*   rx_queue_offload_capa or tx_queue_offload_capa in struct rte_eth_dev_ifnfo
+*   got from rte_eth_dev_info_get( )
+* @param all_offload_capa
+*   rx_offload_capa or tx_offload_capa in struct rte_eth_dev_info
+*   got from rte_eth_dev_info_get( )
+*
+* @return
+*   Nonzero when per-queue offloading setting is valid
+*/
+static int
+rte_eth_check_queue_offloads(uint64_t queue_offloads,
+			     uint64_t port_offloads,
+			     uint64_t queue_offload_capa,
+			     uint64_t all_offload_capa)
+{
+	uint64_t pure_port_capa = all_offload_capa ^ queue_offload_capa;
+
+	return !((port_offloads ^ queue_offloads) & pure_port_capa);
+}
+
+static int
+rte_eth_check_rx_queue_offloads(uint64_t rx_queue_offloads,
+				const struct rte_eth_rxmode *rxmode,
+				const struct rte_eth_dev_info *dev_info)
+{
+	return rte_eth_check_queue_offloads(rx_queue_offloads,
+					    rxmode->offloads,
+					    dev_info->rx_queue_offload_capa,
+					    dev_info->rx_offload_capa);
+}
+
 int
 rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		       uint16_t nb_rx_desc, unsigned int socket_id,
@@ -1446,6 +1484,7 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 				(int) sizeof(struct rte_pktmbuf_pool_private));
 		return -ENOSPC;
 	}
+
 	mbp_buf_size = rte_pktmbuf_data_room_size(mp);
 
 	if ((mbp_buf_size - RTE_PKTMBUF_HEADROOM) < dev_info.min_rx_bufsize) {
@@ -1495,6 +1534,16 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	if (!rte_eth_check_rx_queue_offloads(local_conf.offloads,
+		&dev->data->dev_conf.rxmode, &dev_info)) {
+		RTE_PMD_DEBUG_TRACE("%p : Rx queue offloads ox%" PRIx64
+			" don't match port offloads 0x%" PRIx64
+			" or supported offloads 0x%" PRIx64,
+			(void *)dev, local_conf.offloads,
+			dev_info.rx_offload_capa);
+		return -ENOTSUP;
+	}
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1555,6 +1604,17 @@ rte_eth_convert_txq_offloads(const uint64_t tx_offloads, uint32_t *txq_flags)
 	*txq_flags = flags;
 }
 
+static int
+rte_eth_check_tx_queue_offloads(uint64_t tx_queue_offloads,
+				const struct rte_eth_txmode *txmode,
+				const struct rte_eth_dev_info *dev_info)
+{
+	return rte_eth_check_queue_offloads(tx_queue_offloads,
+					    txmode->offloads,
+					    dev_info->tx_queue_offload_capa,
+					    dev_info->tx_offload_capa);
+}
+
 int
 rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 		       uint16_t nb_tx_desc, unsigned int socket_id,
@@ -1622,6 +1682,16 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	if (!rte_eth_check_tx_queue_offloads(local_conf.offloads,
+		&dev->data->dev_conf.txmode, &dev_info)) {
+		RTE_PMD_DEBUG_TRACE("%p : Tx queue offloads ox%" PRIx64
+			" don't match port offloads 0x%" PRIx64
+			" or supported offloads 0x%" PRIx64,
+			(void *)dev, local_conf.offloads,
+			dev_info.tx_offload_capa);
+		return -ENOTSUP;
+	}
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
 }
Signature · 1 line
2.7.5
author
#1 lore raw

PATCH v2 1/1 ethdev: check Rx/Tx offloads

This patch check if a requested offloading
is supported in the device capability.
A per port offloading feature should be enabled or disabled at same time in both rte_eth_dev_configure( ) and rte_eth_rx_queue_setup( )/rte_eth_tx_queue_setup( ). This patch check if a per port offloading flag has same configuration in rte_eth_dev_configure( ) and rte_eth_rx_queue_setup( )/rte_eth_tx_queue_setup( ). This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

---
v2: add offlaods checking in rte_eth_dev_configure( ).
check if a requested offloading is supported

---
 lib/librte_ether/rte_ethdev.c | 100 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)
lib/librte_ether/rte_ethdev.c +100 -0
index 0590f0c..a04a705 100644
@@ -1152,6 +1152,27 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads "
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads "
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */
@@ -1404,6 +1425,50 @@ rte_eth_dev_is_removed(uint16_t port_id)
 	return ret;
 }
 
+/**
+* Check if the Rx/Tx queue offloading settings is valid
+* @param queue_offloads
+*   offloads input to rte_eth_rx_queue_setup( ) or rte_eth_tx_queue_setup( )
+* @param port_offloads
+*   Rx or Tx offloads input to rte_eth_dev_configure( )
+* @param queue_offload_capa
+*   rx_queue_offload_capa or tx_queue_offload_capa in struct rte_eth_dev_ifnfo
+*   got from rte_eth_dev_info_get( )
+* @param all_offload_capa
+*   rx_offload_capa or tx_offload_capa in struct rte_eth_dev_info
+*   got from rte_eth_dev_info_get( )
+*
+* @return
+*   Nonzero when per-queue offloading setting is valid
+*/
+static int
+rte_eth_check_queue_offloads(uint64_t queue_offloads,
+			     uint64_t port_offloads,
+			     uint64_t queue_offload_capa,
+			     uint64_t all_offload_capa)
+{
+	uint64_t pure_port_capa = all_offload_capa ^ queue_offload_capa;
+
+	if ((queue_offloads & all_offload_capa) != queue_offloads)
+		return 0;
+
+	if ((port_offloads ^ queue_offloads) & pure_port_capa)
+		return 0;
+
+	return 1;
+}
+
+static int
+rte_eth_check_rx_queue_offloads(uint64_t rx_queue_offloads,
+				const struct rte_eth_rxmode *rxmode,
+				const struct rte_eth_dev_info *dev_info)
+{
+	return rte_eth_check_queue_offloads(rx_queue_offloads,
+					    rxmode->offloads,
+					    dev_info->rx_queue_offload_capa,
+					    dev_info->rx_offload_capa);
+}
+
 int
 rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		       uint16_t nb_rx_desc, unsigned int socket_id,
@@ -1495,6 +1560,18 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	if (!rte_eth_check_rx_queue_offloads(local_conf.offloads,
+		&dev->data->dev_conf.rxmode, &dev_info)) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port %d : Rx queue offloads ox%"
+			PRIx64 " don't match port offloads 0x%" PRIx64
+			" or supported offloads 0x%" PRIx64 "\n",
+			port_id,
+			local_conf.offloads,
+			dev->data->dev_conf.rxmode.offloads,
+			dev_info.rx_offload_capa);
+		return -ENOTSUP;
+	}
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1555,6 +1632,17 @@ rte_eth_convert_txq_offloads(const uint64_t tx_offloads, uint32_t *txq_flags)
 	*txq_flags = flags;
 }
 
+static int
+rte_eth_check_tx_queue_offloads(uint64_t tx_queue_offloads,
+				const struct rte_eth_txmode *txmode,
+				const struct rte_eth_dev_info *dev_info)
+{
+	return rte_eth_check_queue_offloads(tx_queue_offloads,
+					    txmode->offloads,
+					    dev_info->tx_queue_offload_capa,
+					    dev_info->tx_offload_capa);
+}
+
 int
 rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 		       uint16_t nb_tx_desc, unsigned int socket_id,
@@ -1622,6 +1710,18 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	if (!rte_eth_check_tx_queue_offloads(local_conf.offloads,
+		&dev->data->dev_conf.txmode, &dev_info)) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port %d : Tx queue offloads ox%"
+			PRIx64 " don't match port offloads 0x%" PRIx64
+			" or supported offloads 0x%" PRIx64 "\n",
+			port_id,
+			local_conf.offloads,
+			dev->data->dev_conf.txmode.offloads,
+			dev_info.tx_offload_capa);
+		return -ENOTSUP;
+	}
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
 }
Signature · 1 line
2.9.5
#2 lore raw

Re: [PATCH v2] ethdev: check Rx/Tx offloads

Quoted 11 lines · Wei Dai

This patch check if a requested offloading
is supported in the device capability.
A per port offloading feature should be enabled or disabled at same time in both rte_eth_dev_configure( ) and rte_eth_rx_queue_setup( )/rte_eth_tx_queue_setup( ). This patch check if a per port offloading flag has same configuration in rte_eth_dev_configure( ) and rte_eth_rx_queue_setup( )/rte_eth_tx_queue_setup( ). This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

Quoted 2 lines

Hi Wei,

I think it is good idea to move common check to the abstraction layer as much as possible.

But for this case we are targeting an API change in rc2, I believe better wait that API change for this update.

Thanks,
ferruh

#3 lore raw

Re: [PATCH v2] ethdev: check Rx/Tx offloads

13/04/2018 19:31, Ferruh Yigit:

Quoted 12 lines · Wei Dai
Quoted 10 lines

This patch check if a requested offloading
is supported in the device capability.
A per port offloading feature should be enabled or disabled at same time in both rte_eth_dev_configure( ) and rte_eth_rx_queue_setup( )/rte_eth_tx_queue_setup( ). This patch check if a per port offloading flag has same configuration in rte_eth_dev_configure( ) and rte_eth_rx_queue_setup( )/rte_eth_tx_queue_setup( ). This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

Quoted 5 lines

I think it is good idea to move common check to the abstraction layer as much as possible.

But for this case we are targeting an API change in rc2, I believe better wait that API change for this update.

I think Wei could implement some filtering of offload flags:
If an offload is already enabled at port level, we can filter out them when enabling again at queue level.
By removing such repetition in ethdev, before calling the PMD op, the PMD does not need to bother for offloads enabled twice.

author
#4 lore raw

Re: [PATCH v2] ethdev: check Rx/Tx offloads

Thanks, Thomas and Ferruh
I think I can implement v3 for this.

Quoted 32 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Sunday, April 15, 2018 6:37 PM
To: Yigit, Ferruh <[email protected]>; Dai, Wei <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] ethdev: check Rx/Tx offloads

13/04/2018 19:31, Ferruh Yigit:

Quoted 12 lines · Wei Dai
Quoted 10 lines

This patch check if a requested offloading is supported in the device capability.
A per port offloading feature should be enabled or disabled at same time in both rte_eth_dev_configure( ) and rte_eth_rx_queue_setup( )/rte_eth_tx_queue_setup( ).
This patch check if a per port offloading flag has same configuration in rte_eth_dev_configure( ) and rte_eth_rx_queue_setup( )/rte_eth_tx_queue_setup( ). This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

Quoted 5 lines

I think it is good idea to move common check to the abstraction layer as much as possible.

But for this case we are targeting an API change in rc2, I believe better wait that API change for this update.

I think Wei could implement some filtering of offload flags:
If an offload is already enabled at port level, we can filter out them when enabling again at queue level.
By removing such repetition in ethdev, before calling the PMD op, the PMD does not need to bother for offloads enabled twice.

author
#5 lore raw

PATCH 1/1 ethdev: check Rx/Tx offloads

In reply to Wei Dai

This patch check if a requested offloading is supported in the device capability.
Any offloading is disabled by default if it is not set in rte_eth_dev_configure( ) and rte_eth_[rt]x_queue_setup(). A per port offloading can only be enabled in rte_eth_dev_configure(). If a per port offloading is sent to rte_eth_[rt]x_queue_setup( ), return error. Only per queue offloading can be sent to rte_eth_dev_configure( ). A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ). If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ).

This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

---
v3: rework according to dicision of offloading API in community

v2: add offloads checking in rte_eth_dev_configure( ).
check if a requested offloading is supported.

---
 lib/librte_ether/rte_ethdev.c | 76 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
lib/librte_ether/rte_ethdev.c +76 -0
index f0f53d4..70a7904 100644
@@ -1196,6 +1196,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offload must be within its device capability */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads "
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads "
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */
@@ -1547,6 +1569,33 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from application.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_rx_queue_setup( )\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa);
+		return -EINVAL;
+	}
+
+	/*
+	 * If a per-queue offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled on all queues and can't be disabled here.
+	 * If it is diabled in rte_eth_dev_configure( ), it can be enabled
+	 * or disabled here.
+	 * If a per-port offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled for all queues here.
+	 */
+	local_conf.offloads |= dev->data->dev_conf.rxmode.offloads;
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1681,6 +1730,33 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from applcation.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.tx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d tx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_tx_queue_setup( )\n",
+				    port_id,
+				    tx_queue_id,
+				    local_conf.offloads,
+				    dev_info.tx_queue_offload_capa);
+		return -EINVAL;
+	}
+
+	/*
+	 * If a per-queue offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled on all queues and can't be disabled here.
+	 * If it is diabled in rte_eth_dev_configure( ), it can be enabled
+	 * or disabled here.
+	 * If a per-port offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled for all queues here.
+	 */
+	local_conf.offloads |= dev->data->dev_conf.txmode.offloads;
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
 }
Signature · 1 line
2.7.5
author
#6 lore raw

PATCH v3 1/1 ethdev: check Rx/Tx offloads

In reply to Wei Dai

This patch check if a requested offloading is supported in the device capability.
Any offloading is disabled by default if it is not set in rte_eth_dev_configure( ) and rte_eth_[rt]x_queue_setup(). A per port offloading can only be enabled in rte_eth_dev_configure(). If a per port offloading is sent to rte_eth_[rt]x_queue_setup( ), return error. Only per queue offloading can be sent to rte_eth_dev_configure( ). A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ). If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ).

This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

---
v3: rework according to dicision of offloading API in community

v2: add offloads checking in rte_eth_dev_configure( ).
check if a requested offloading is supported.

---
 lib/librte_ether/rte_ethdev.c | 76 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
lib/librte_ether/rte_ethdev.c +76 -0
index f0f53d4..70a7904 100644
@@ -1196,6 +1196,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offload must be within its device capability */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads "
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads "
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */
@@ -1547,6 +1569,33 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from application.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_rx_queue_setup( )\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa);
+		return -EINVAL;
+	}
+
+	/*
+	 * If a per-queue offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled on all queues and can't be disabled here.
+	 * If it is diabled in rte_eth_dev_configure( ), it can be enabled
+	 * or disabled here.
+	 * If a per-port offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled for all queues here.
+	 */
+	local_conf.offloads |= dev->data->dev_conf.rxmode.offloads;
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1681,6 +1730,33 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from applcation.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.tx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d tx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_tx_queue_setup( )\n",
+				    port_id,
+				    tx_queue_id,
+				    local_conf.offloads,
+				    dev_info.tx_queue_offload_capa);
+		return -EINVAL;
+	}
+
+	/*
+	 * If a per-queue offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled on all queues and can't be disabled here.
+	 * If it is diabled in rte_eth_dev_configure( ), it can be enabled
+	 * or disabled here.
+	 * If a per-port offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled for all queues here.
+	 */
+	local_conf.offloads |= dev->data->dev_conf.txmode.offloads;
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
 }
Signature · 1 line
2.7.5
author
#7 lore raw

PATCH v3 1/1 ethdev: check Rx/Tx offloads

This patch check if a requested offloading is supported in the device capability.
Any offloading is disabled by default if it is not set in rte_eth_dev_configure( ) and rte_eth_[rt]x_queue_setup(). A per port offloading can only be enabled in rte_eth_dev_configure(). If a per port offloading is sent to rte_eth_[rt]x_queue_setup( ), return error. Only per queue offloading can be sent to rte_eth_dev_configure( ). A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ). If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ).

This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

---
v3: rework according to dicision of offloading API in community

v2: add offloads checking in rte_eth_dev_configure( ).
check if a requested offloading is supported.

---
 lib/librte_ether/rte_ethdev.c | 76 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
lib/librte_ether/rte_ethdev.c +76 -0
index f0f53d4..70a7904 100644
@@ -1196,6 +1196,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offload must be within its device capability */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads "
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads "
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */
@@ -1547,6 +1569,33 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from application.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_rx_queue_setup( )\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa);
+		return -EINVAL;
+	}
+
+	/*
+	 * If a per-queue offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled on all queues and can't be disabled here.
+	 * If it is diabled in rte_eth_dev_configure( ), it can be enabled
+	 * or disabled here.
+	 * If a per-port offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled for all queues here.
+	 */
+	local_conf.offloads |= dev->data->dev_conf.rxmode.offloads;
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1681,6 +1730,33 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from applcation.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.tx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d tx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_tx_queue_setup( )\n",
+				    port_id,
+				    tx_queue_id,
+				    local_conf.offloads,
+				    dev_info.tx_queue_offload_capa);
+		return -EINVAL;
+	}
+
+	/*
+	 * If a per-queue offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled on all queues and can't be disabled here.
+	 * If it is diabled in rte_eth_dev_configure( ), it can be enabled
+	 * or disabled here.
+	 * If a per-port offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled for all queues here.
+	 */
+	local_conf.offloads |= dev->data->dev_conf.txmode.offloads;
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
 }
Signature · 1 line
2.7.5
author
#8 lore raw

PATCH v4 1/1 ethdev: check Rx/Tx offloads

In reply to Wei Dai

This patch check if a requested offloading is supported in the device capability.
Any offloading is disabled by default if it is not set in rte_eth_dev_configure( ) and rte_eth_[rt]x_queue_setup(). A per port offloading can only be enabled in rte_eth_dev_configure(). If a per port offloading is sent to rte_eth_[rt]x_queue_setup( ), return error. Only per queue offloading can be sent to rte_eth_[rt]x_queue_setup( ). A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ). If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ).

This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

---
v4: fix a wrong description in git log message.

v3: rework according to dicision of offloading API in community

v2: add offloads checking in rte_eth_dev_configure( ).
check if a requested offloading is supported.

---
 lib/librte_ether/rte_ethdev.c | 76 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
lib/librte_ether/rte_ethdev.c +76 -0
index f0f53d4..70a7904 100644
@@ -1196,6 +1196,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offload must be within its device capability */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads "
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads "
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */
@@ -1547,6 +1569,33 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from application.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_rx_queue_setup( )\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa);
+		return -EINVAL;
+	}
+
+	/*
+	 * If a per-queue offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled on all queues and can't be disabled here.
+	 * If it is diabled in rte_eth_dev_configure( ), it can be enabled
+	 * or disabled here.
+	 * If a per-port offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled for all queues here.
+	 */
+	local_conf.offloads |= dev->data->dev_conf.rxmode.offloads;
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1681,6 +1730,33 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from applcation.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.tx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d tx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_tx_queue_setup( )\n",
+				    port_id,
+				    tx_queue_id,
+				    local_conf.offloads,
+				    dev_info.tx_queue_offload_capa);
+		return -EINVAL;
+	}
+
+	/*
+	 * If a per-queue offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled on all queues and can't be disabled here.
+	 * If it is diabled in rte_eth_dev_configure( ), it can be enabled
+	 * or disabled here.
+	 * If a per-port offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled for all queues here.
+	 */
+	local_conf.offloads |= dev->data->dev_conf.txmode.offloads;
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
 }
Signature · 1 line
2.7.5
#9 lore raw

Re: [PATCH v4] ethdev: check Rx/Tx offloads

Quoted 16 lines · Wei Dai

This patch check if a requested offloading is supported in the device capability.
Any offloading is disabled by default if it is not set in rte_eth_dev_configure( ) and rte_eth_[rt]x_queue_setup(). A per port offloading can only be enabled in rte_eth_dev_configure(). If a per port offloading is sent to rte_eth_[rt]x_queue_setup( ), return error. Only per queue offloading can be sent to rte_eth_[rt]x_queue_setup( ). A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ). If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ).

Quoted 2 lines

This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

Hi Wei,

For clarification, there is existing API for rc1, and there is a suggested update in API for rc2. I guess this patch is for suggested update in rc2?

Quoted 32 lines

---
v4: fix a wrong description in git log message.

v3: rework according to dicision of offloading API in community

v2: add offloads checking in rte_eth_dev_configure( ).
check if a requested offloading is supported.

---
 lib/librte_ether/rte_ethdev.c | 76 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
lib/librte_ether/rte_ethdev.c +11 -0
index f0f53d4..70a7904 100644
@@ -1196,6 +1196,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offload must be within its device capability */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads "
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1219

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +10 -0
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads "
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}

+1 having these checks here.

Quoted 14 lines
lib/librte_ether/rte_ethdev.c +7 -0
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */
@@ -1547,6 +1569,33 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from application.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1587

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +10 -0
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_rx_queue_setup( )\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa);
+		return -EINVAL;
+	}

There is a change here. If requested offload is already enabled in port level, instead of returning error, ignore it.
So this removes the restriction for apps that "only an offload from queue capabilities can be send for queue_setup() functions". This is not requirement for application as it has been before, but this is allowed for app now.

If app tried to enable a port offload in queue level that is not already enabled, it should still return error.

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1597

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +10 -0
+
+	/*
+	 * If a per-queue offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled on all queues and can't be disabled here.
+	 * If it is diabled in rte_eth_dev_configure( ), it can be enabled
+	 * or disabled here.
+	 * If a per-port offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled for all queues here.
+	 */
+	local_conf.offloads |= dev->data->dev_conf.rxmode.offloads;

I didn't get this one, why add rxmode.offloads into queue offloads?

Based on above change Thomas has an suggestion [1]:

"
In the case of offload already enabled at port level and repeated in queue setup,
ethdev can avoid passing it to the PMD queue setup function. "

So almost reverse of what you are doing, strip rxmode.offloads from local_conf.offloads for PMDs. What do you think?

[1]
https://dpdk.org/ml/archives/dev/2018-April/098956.html

#10 lore raw

Re: [PATCH v4] ethdev: check Rx/Tx offloads

Quoted 134 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Thursday, April 26, 2018 1:05 AM
To: Dai, Wei <[email protected]>; [email protected]; Zhang, Qi Z <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v4] ethdev: check Rx/Tx offloads

Quoted 16 lines · Wei Dai

This patch check if a requested offloading is supported in the device capability.
Any offloading is disabled by default if it is not set in rte_eth_dev_configure( ) and rte_eth_[rt]x_queue_setup().
A per port offloading can only be enabled in rte_eth_dev_configure(). If a per port offloading is sent to rte_eth_[rt]x_queue_setup( ), return error.
Only per queue offloading can be sent to rte_eth_[rt]x_queue_setup( ). A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ).

Quoted 2 lines

This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

Hi Wei,

For clarification, there is existing API for rc1, and there is a suggested update in API for rc2. I guess this patch is for suggested update in rc2?

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id,

Quoted 19 lines

---
v4: fix a wrong description in git log message.

v3: rework according to dicision of offloading API in community

v2: add offloads checking in rte_eth_dev_configure( ).
check if a requested offloading is supported.

---
 lib/librte_ether/rte_ethdev.c | 76
+++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
(quoted diff) +0 -0

b/lib/librte_ether/rte_ethdev.c index f0f53d4..70a7904 100644

lib/librte_ether/rte_ethdev.c +0 -0
@@ -1196,6 +1196,28 @@ rte_eth_dev_configure(uint16_t port_id,

uint16_t nb_rx_q, uint16_t nb_tx_q,

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,

Quoted 7 lines
lib/librte_ether/rte_ethdev.c +4 -0
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offload must be within its device capability */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx

offloads "

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +10 -0
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx

offloads "

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1219

Quoted 7 lines
lib/librte_ether/rte_ethdev.c +7 -0
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}

+1 having these checks here.

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

Quoted 5 lines
lib/librte_ether/rte_ethdev.c +1 -0
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */
@@ -1547,6 +1569,33 @@ rte_eth_rx_queue_setup(uint16_t port_id,

uint16_t rx_queue_id,

Quoted 9 lines
lib/librte_ether/rte_ethdev.c +6 -0
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from application.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1587

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +10 -0
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_rx_queue_setup( )\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa);
+		return -EINVAL;
+	}

There is a change here. If requested offload is already enabled in port level, instead of returning error, ignore it.
So this removes the restriction for apps that "only an offload from queue capabilities can be send for queue_setup() functions". This is not requirement for application as it has been before, but this is allowed for app now.

If app tried to enable a port offload in queue level that is not already enabled, it should still return error.

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1597

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +10 -0
+
+	/*
+	 * If a per-queue offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled on all queues and can't be disabled here.
+	 * If it is diabled in rte_eth_dev_configure( ), it can be enabled
+	 * or disabled here.
+	 * If a per-port offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled for all queues here.
+	 */
+	local_conf.offloads |= dev->data->dev_conf.rxmode.offloads;

I didn't get this one, why add rxmode.offloads into queue offloads?

Based on above change Thomas has an suggestion [1]:

Quoted 7 lines

"
In the case of offload already enabled at port level and repeated in queue setup, ethdev can avoid passing it to the PMD queue setup function. "

So almost reverse of what you are doing, strip rxmode.offloads from local_conf.offloads for PMDs. What do you think?

Should we do like below

	local_conf.offloads |= dev->data->dev_conf.rxmode.offloads;
	local_conf.offloads &= dev_info.rx_queue_offload_capa

I thinks it's better to only strip port offloads. But keep all queue offload,
since this is exact we going to configure the queue and during device start, it can simply iterate on each bit on local_conf.offloads to
turn on queue offload and don't need to worry about rxmode.offloads.

Regards
Qi.

Quoted 4 lines

[1]
https://dpdk.org/ml/archives/dev/2018-April/098956.html

#11 lore raw

Re: [PATCH v4] ethdev: check Rx/Tx offloads

26/04/2018 09:59, Zhang, Qi Z:

Quoted 141 lines
Quoted 133 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Thursday, April 26, 2018 1:05 AM
To: Dai, Wei <[email protected]>; [email protected]; Zhang, Qi Z <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v4] ethdev: check Rx/Tx offloads

Quoted 16 lines · Wei Dai

This patch check if a requested offloading is supported in the device capability.
Any offloading is disabled by default if it is not set in rte_eth_dev_configure( ) and rte_eth_[rt]x_queue_setup().
A per port offloading can only be enabled in rte_eth_dev_configure(). If a per port offloading is sent to rte_eth_[rt]x_queue_setup( ), return error.
Only per queue offloading can be sent to rte_eth_[rt]x_queue_setup( ). A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ).

Quoted 2 lines

This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

Hi Wei,

For clarification, there is existing API for rc1, and there is a suggested update in API for rc2. I guess this patch is for suggested update in rc2?

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id,

Quoted 19 lines

---
v4: fix a wrong description in git log message.

v3: rework according to dicision of offloading API in community

v2: add offloads checking in rte_eth_dev_configure( ).
check if a requested offloading is supported.

---
 lib/librte_ether/rte_ethdev.c | 76
+++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
(quoted diff) +0 -0

b/lib/librte_ether/rte_ethdev.c index f0f53d4..70a7904 100644

lib/librte_ether/rte_ethdev.c +0 -0
@@ -1196,6 +1196,28 @@ rte_eth_dev_configure(uint16_t port_id,

uint16_t nb_rx_q, uint16_t nb_tx_q,

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,

Quoted 7 lines
lib/librte_ether/rte_ethdev.c +4 -0
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offload must be within its device capability */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx

offloads "

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +10 -0
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx

offloads "

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1219

Quoted 7 lines
lib/librte_ether/rte_ethdev.c +7 -0
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}

+1 having these checks here.

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

Quoted 5 lines
lib/librte_ether/rte_ethdev.c +1 -0
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */
@@ -1547,6 +1569,33 @@ rte_eth_rx_queue_setup(uint16_t port_id,

uint16_t rx_queue_id,

Quoted 9 lines
lib/librte_ether/rte_ethdev.c +6 -0
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from application.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1587

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +10 -0
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_rx_queue_setup( )\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa);
+		return -EINVAL;
+	}

There is a change here. If requested offload is already enabled in port level, instead of returning error, ignore it.
So this removes the restriction for apps that "only an offload from queue capabilities can be send for queue_setup() functions". This is not requirement for application as it has been before, but this is allowed for app now.

If app tried to enable a port offload in queue level that is not already enabled, it should still return error.

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1597

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +10 -0
+
+	/*
+	 * If a per-queue offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled on all queues and can't be disabled here.
+	 * If it is diabled in rte_eth_dev_configure( ), it can be enabled
+	 * or disabled here.
+	 * If a per-port offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled for all queues here.
+	 */
+	local_conf.offloads |= dev->data->dev_conf.rxmode.offloads;

I didn't get this one, why add rxmode.offloads into queue offloads?

Based on above change Thomas has an suggestion [1]:

Quoted 7 lines

"
In the case of offload already enabled at port level and repeated in queue setup, ethdev can avoid passing it to the PMD queue setup function. "

So almost reverse of what you are doing, strip rxmode.offloads from local_conf.offloads for PMDs. What do you think?

Quoted 7 lines

Should we do like below

	local_conf.offloads |= dev->data->dev_conf.rxmode.offloads;
	local_conf.offloads &= dev_info.rx_queue_offload_capa

I thinks it's better to only strip port offloads. But keep all queue offload,
since this is exact we going to configure the queue and during device start, it can simply iterate on each bit on local_conf.offloads to
turn on queue offload and don't need to worry about rxmode.offloads.

No
The offloads which are already enabled at port level does not need to be enabled again at queue level.
But the PMD can decide to not configure the offload at port level for real, and configure the port offloads in every queue setups.
It is an implementation choice, and can be different per-offload. So it is simpler to filter such request for queue setups.
This way, we will be sure that all offloads, requested in queue setup PMD function, must be setup for the queue.
The PMD implementation will need to setup all the requested offloads in queue setup, plus the port offloads which were deferred to all queues.

Hope it's clear.

#12 lore raw

Re: [PATCH v4] ethdev: check Rx/Tx offloads

Quoted 163 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, April 26, 2018 4:19 PM
To: Zhang, Qi Z <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Dai, Wei <[email protected]>; [email protected]
Subject: Re: [PATCH v4] ethdev: check Rx/Tx offloads

26/04/2018 09:59, Zhang, Qi Z:

Quoted 26 lines
Quoted 26 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Thursday, April 26, 2018 1:05 AM
To: Dai, Wei <[email protected]>; [email protected]; Zhang, Qi Z <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v4] ethdev: check Rx/Tx offloads

Quoted 16 lines · Wei Dai

This patch check if a requested offloading is supported in the device capability.
Any offloading is disabled by default if it is not set in rte_eth_dev_configure( ) and rte_eth_[rt]x_queue_setup().
A per port offloading can only be enabled in rte_eth_dev_configure(). If a per port offloading is sent to rte_eth_[rt]x_queue_setup( ), return error.
Only per queue offloading can be sent to rte_eth_[rt]x_queue_setup( ). A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ).

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

Hi Wei,

For clarification, there is existing API for rc1, and there is a suggested update in API for rc2. I guess this patch is for suggested update

in rc2?

Quoted 55 lines
Quoted 55 lines

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id,

Quoted 20 lines

---
v4: fix a wrong description in git log message.

v3: rework according to dicision of offloading API in community

v2: add offloads checking in rte_eth_dev_configure( ).
check if a requested offloading is supported.

---
 lib/librte_ether/rte_ethdev.c | 76
+++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
(quoted diff) +0 -0

b/lib/librte_ether/rte_ethdev.c index f0f53d4..70a7904 100644

lib/librte_ether/rte_ethdev.c +0 -0
@@ -1196,6 +1196,28 @@ rte_eth_dev_configure(uint16_t port_id,

uint16_t nb_rx_q, uint16_t nb_tx_q,

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,

Quoted 7 lines
lib/librte_ether/rte_ethdev.c +4 -0
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offload must be within its device capability */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx

offloads "

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +10 -0
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx

offloads "

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1219

Quoted 7 lines
lib/librte_ether/rte_ethdev.c +7 -0
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}

+1 having these checks here.

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

Quoted 5 lines
lib/librte_ether/rte_ethdev.c +1 -0
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */
@@ -1547,6 +1569,33 @@ rte_eth_rx_queue_setup(uint16_t port_id,

uint16_t rx_queue_id,

Quoted 6 lines
Quoted 6 lines

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

Quoted 6 lines
lib/librte_ether/rte_ethdev.c +3 -0
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from application.
+	 * If any pure per-port offload is sent to this function, return

-EINVAL

Quoted 4 lines
Quoted 4 lines

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

Quoted 4 lines
lib/librte_ether/rte_ethdev.c +4 -0
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d

rx_queue_id=%d "

Quoted 33 lines
Quoted 33 lines

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1587

Quoted 9 lines
lib/librte_ether/rte_ethdev.c +9 -0
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_rx_queue_setup( )\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa);
+		return -EINVAL;
+	}

There is a change here. If requested offload is already enabled in port level, instead of returning error, ignore it.
So this removes the restriction for apps that "only an offload from queue capabilities can be send for queue_setup() functions". This is not requirement for application as it has been before, but this is allowed for app now.

If app tried to enable a port offload in queue level that is not already enabled, it should still return error.

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1597

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +10 -0
+
+	/*
+	 * If a per-queue offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled on all queues and can't be disabled here.
+	 * If it is diabled in rte_eth_dev_configure( ), it can be enabled
+	 * or disabled here.
+	 * If a per-port offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled for all queues here.
+	 */
+	local_conf.offloads |= dev->data->dev_conf.rxmode.offloads;

I didn't get this one, why add rxmode.offloads into queue offloads?

Quoted 5 lines
Quoted 5 lines

Based on above change Thomas has an suggestion [1]:

"
In the case of offload already enabled at port level and repeated in queue setup, ethdev can avoid passing it to the PMD queue setup

function.

Quoted 5 lines
Quoted 4 lines

"

So almost reverse of what you are doing, strip rxmode.offloads from local_conf.offloads for PMDs. What do you think?

Quoted 7 lines

Should we do like below

	local_conf.offloads |= dev->data->dev_conf.rxmode.offloads;
	local_conf.offloads &= dev_info.rx_queue_offload_capa

I thinks it's better to only strip port offloads. But keep all queue offload, since this is exact we going to configure the queue and during device start, it can simply iterate on each bit on local_conf.offloads

Quoted 8 lines

to turn on queue offload and don't need to worry about rxmode.offloads.

No
The offloads which are already enabled at port level does not need to be enabled again at queue level.
But the PMD can decide to not configure the offload at port level for real, and configure the port offloads in every queue setups.
It is an implementation choice, and can be different per-offload.

OK, got your point, that make sense.

Quoted 9 lines

So it is simpler to filter such request for queue setups. This way, we will be sure that all offloads, requested in queue setup PMD function, must be setup for the queue.
The PMD implementation will need to setup all the requested offloads in queue setup, plus the port offloads which were deferred to all queues.

Hope it's clear.

author
#13 lore raw

Re: [PATCH v4] ethdev: check Rx/Tx offloads

Thanks to Thomas, Ferruh and Zhang Qi for your feedback. I will rework v5 patch to follow your guidance.

Quoted 196 lines

-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, April 26, 2018 4:51 PM
To: Thomas Monjalon <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Dai, Wei <[email protected]>; [email protected]
Subject: RE: [PATCH v4] ethdev: check Rx/Tx offloads

Quoted 8 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, April 26, 2018 4:19 PM
To: Zhang, Qi Z <[email protected]>
Cc: Yigit, Ferruh <[email protected]>; Dai, Wei <[email protected]>; [email protected]
Subject: Re: [PATCH v4] ethdev: check Rx/Tx offloads

Quoted 19 lines

26/04/2018 09:59, Zhang, Qi Z:

Quoted 18 lines
Quoted 18 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Thursday, April 26, 2018 1:05 AM
To: Dai, Wei <[email protected]>; [email protected]; Zhang, Qi Z <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v4] ethdev: check Rx/Tx offloads

Quoted 8 lines · Wei Dai

This patch check if a requested offloading is supported in the device capability.
Any offloading is disabled by default if it is not set in rte_eth_dev_configure( ) and rte_eth_[rt]x_queue_setup(). A per port offloading can only be enabled in rte_eth_dev_configure(). If a per port offloading is sent to rte_eth_[rt]x_queue_setup( ), return error.
Only per queue offloading can be sent to

rte_eth_[rt]x_queue_setup( ).

Quoted 66 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ).

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

Hi Wei,

For clarification, there is existing API for rc1, and there is a suggested update in API for rc2. I guess this patch is for suggested update

in rc2?

Quoted 49 lines
Quoted 49 lines

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id,

Quoted 20 lines

---
v4: fix a wrong description in git log message.

v3: rework according to dicision of offloading API in community

v2: add offloads checking in rte_eth_dev_configure( ).
check if a requested offloading is supported.

---
 lib/librte_ether/rte_ethdev.c | 76
+++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
(quoted diff) +0 -0

b/lib/librte_ether/rte_ethdev.c index f0f53d4..70a7904 100644

lib/librte_ether/rte_ethdev.c +0 -0
@@ -1196,6 +1196,28 @@ rte_eth_dev_configure(uint16_t port_id,

uint16_t nb_rx_q, uint16_t nb_tx_q,

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,

Quoted 7 lines
lib/librte_ether/rte_ethdev.c +4 -0
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offload must be within its device capability */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx

offloads "

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +10 -0
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx

offloads "

lib/librte_ether/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1219

Quoted 7 lines
lib/librte_ether/rte_ethdev.c +7 -0
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}

+1 having these checks here.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t

Quoted 5 lines
lib/librte_ether/rte_ethdev.c +1 -0
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */
@@ -1547,6 +1569,33 @@ rte_eth_rx_queue_setup(uint16_t

port_id,

Quoted 66 lines
Quoted 8 lines
Quoted 8 lines

uint16_t rx_queue_id,

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

Quoted 7 lines
lib/librte_ether/rte_ethdev.c +4 -0
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from application.
+	 * If any pure per-port offload is sent to this function,
+return

-EINVAL

Quoted 4 lines
Quoted 4 lines

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

Quoted 4 lines
lib/librte_ether/rte_ethdev.c +4 -0
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d

rx_queue_id=%d "

Quoted 33 lines
Quoted 33 lines

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1587

Quoted 9 lines
lib/librte_ether/rte_ethdev.c +9 -0
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_rx_queue_setup( )\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa);
+		return -EINVAL;
+	}

There is a change here. If requested offload is already enabled in port level, instead of returning error, ignore it.
So this removes the restriction for apps that "only an offload from queue capabilities can be send for queue_setup() functions". This is not requirement for application as it has been before, but this is allowed for app now.

If app tried to enable a port offload in queue level that is not already enabled, it should still return error.

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1597

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +10 -0
+
+	/*
+	 * If a per-queue offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled on all queues and can't be disabled here.
+	 * If it is diabled in rte_eth_dev_configure( ), it can be enabled
+	 * or disabled here.
+	 * If a per-port offload is enabled in rte_eth_dev_configure( ),
+	 * it is also enabled for all queues here.
+	 */
+	local_conf.offloads |= dev->data->dev_conf.rxmode.offloads;

I didn't get this one, why add rxmode.offloads into queue offloads?

Quoted 5 lines
Quoted 5 lines

Based on above change Thomas has an suggestion [1]:

"
In the case of offload already enabled at port level and repeated in queue setup, ethdev can avoid passing it to the PMD queue setup

function.

Quoted 5 lines
Quoted 4 lines

"

So almost reverse of what you are doing, strip rxmode.offloads from local_conf.offloads for PMDs. What do you think?

Quoted 8 lines

Should we do like below

	local_conf.offloads |= dev->data->dev_conf.rxmode.offloads;
	local_conf.offloads &= dev_info.rx_queue_offload_capa

I thinks it's better to only strip port offloads. But keep all queue offload, since this is exact we going to configure the queue and during device start, it can simply iterate on each bit on local_conf.offloads

Quoted 8 lines

to turn on queue offload and don't need to worry about rxmode.offloads.

No
The offloads which are already enabled at port level does not need to be enabled again at queue level.
But the PMD can decide to not configure the offload at port level for real, and configure the port offloads in every queue setups. It is an implementation choice, and can be different per-offload.

OK, got your point, that make sense.

Quoted 9 lines

So it is simpler to filter such request for queue setups. This way, we will be sure that all offloads, requested in queue setup PMD function, must be setup for the queue.
The PMD implementation will need to setup all the requested offloads in queue setup, plus the port offloads which were deferred to all queues.

Hope it's clear.

author
#14 lore raw

PATCH v5 1/1 ethdev: check Rx/Tx offloads

In reply to Wei Dai

This patch check if a requested offloading is supported in the device capability.
Any offloading is disabled by default if it is not set in rte_eth_dev_configure( ) and rte_eth_[rt]x_queue_setup(). A per port offloading can only be enabled in rte_eth_dev_configure(). If a per port offloading is sent to rte_eth_[rt]x_queue_setup( ), return error. Only per queue offloading can be sent to rte_eth_[rt]x_queue_setup( ). A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ). If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ).

This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

---
 lib/librte_ether/rte_ethdev.c | 56 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
lib/librte_ether/rte_ethdev.c +56 -0
index f0f53d4..5485f47 100644
@@ -1196,6 +1196,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offload must be within its device capability */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads "
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads "
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */
@@ -1547,6 +1569,23 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from application.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_rx_queue_setup( )\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa);
+		return -EINVAL;
+	}
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1681,6 +1720,23 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from applcation.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.tx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d tx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_tx_queue_setup( )\n",
+				    port_id,
+				    tx_queue_id,
+				    local_conf.offloads,
+				    dev_info.tx_queue_offload_capa);
+		return -EINVAL;
+	}
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
 }
Signature · 1 line
2.7.5
#15 lore raw

Re: [PATCH v5] ethdev: check Rx/Tx offloads

Quoted 58 lines · Wei Dai

This patch check if a requested offloading is supported in the device capability.
Any offloading is disabled by default if it is not set in rte_eth_dev_configure( ) and rte_eth_[rt]x_queue_setup(). A per port offloading can only be enabled in rte_eth_dev_configure(). If a per port offloading is sent to rte_eth_[rt]x_queue_setup( ), return error. Only per queue offloading can be sent to rte_eth_[rt]x_queue_setup( ). A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ). If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ).

This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

---
 lib/librte_ether/rte_ethdev.c | 56 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
lib/librte_ether/rte_ethdev.c +22 -0
index f0f53d4..5485f47 100644
@@ -1196,6 +1196,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offload must be within its device capability */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads "
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads "
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1574

Quoted 6 lines
lib/librte_ether/rte_ethdev.c +3 -0
@@ -1547,6 +1569,23 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from application.
+	 * If any pure per-port offload is sent to this function, return -EINVAL

This comment doesn't match below check, below doesn't check pure per-port offload

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1587

Quoted 12 lines
lib/librte_ether/rte_ethdev.c +12 -0
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {> +		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_rx_queue_setup( )\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa);
+		return -EINVAL;
+	}

Lets add one more check and consider this for rc1, later we can update checks for suggested API in rc2.

Check to add (this is for existing API)
If a pure per-port update enabled configure, it should be enabled in queue_setup() as well.

Quoted 29 lines
lib/librte_ether/rte_ethdev.c +18 -0
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1681,6 +1720,23 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from applcation.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.tx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d tx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_tx_queue_setup( )\n",
+				    port_id,
+				    tx_queue_id,
+				    local_conf.offloads,
+				    dev_info.tx_queue_offload_capa);
+		return -EINVAL;
+	}
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
 }
#16 lore raw

Re: [PATCH v5] ethdev: check Rx/Tx offloads

26/04/2018 17:50, Ferruh Yigit:

Quoted 2 lines

Lets add one more check and consider this for rc1, later we can update checks for suggested API in rc2.

I don't think checks are required for RC1.
Can we take time to properly settle it in RC2?

#17 lore raw

Re: [PATCH v5] ethdev: check Rx/Tx offloads

Quoted 6 lines · Thomas Monjalon

26/04/2018 17:50, Ferruh Yigit:

Quoted 2 lines

Lets add one more check and consider this for rc1, later we can update checks for suggested API in rc2.

I don't think checks are required for RC1.
Can we take time to properly settle it in RC2?

That is OK, I am always having a hesitation about the target of this patch, if it is trying to implement existing one or suggested one, that is the reason.

Let me update my comment for suggested API change.

#18 lore raw

Re: [PATCH v5] ethdev: check Rx/Tx offloads

In reply to Ferruh Yigit
Quoted 84 lines · Ferruh Yigit
Quoted 58 lines · Wei Dai

This patch check if a requested offloading is supported in the device capability.
Any offloading is disabled by default if it is not set in rte_eth_dev_configure( ) and rte_eth_[rt]x_queue_setup(). A per port offloading can only be enabled in rte_eth_dev_configure(). If a per port offloading is sent to rte_eth_[rt]x_queue_setup( ), return error. Only per queue offloading can be sent to rte_eth_[rt]x_queue_setup( ). A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ). If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ).

This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

---
 lib/librte_ether/rte_ethdev.c | 56 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
lib/librte_ether/rte_ethdev.c +22 -0
index f0f53d4..5485f47 100644
@@ -1196,6 +1196,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offload must be within its device capability */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads "
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads "
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1574

Quoted 6 lines
lib/librte_ether/rte_ethdev.c +3 -0
@@ -1547,6 +1569,23 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from application.
+	 * If any pure per-port offload is sent to this function, return -EINVAL

This comment doesn't match below check, below doesn't check pure per-port offload

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1587

Quoted 12 lines
lib/librte_ether/rte_ethdev.c +12 -0
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {> +		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_rx_queue_setup( )\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa);
+		return -EINVAL;
+	}

Lets add one more check and consider this for rc1, later we can update checks for suggested API in rc2.

Quoted 3 lines

Check to add (this is for existing API)
If a pure per-port update enabled configure, it should be enabled in queue_setup() as well.

According comment from Thomas, lets target directly rc2, new API. For that I think we still need an update to this patch.

In previous version of this patch there was a comment to strip port_offloads from requested offloads before passing vales to PMD.
Just to highlight not strip port_capability, but port_offloads set by configure()

The logic is if an offload set in configure(), both port level offload or queue level offload, no need to duplicate it for PMD.

Quoted 32 lines
Quoted 31 lines
lib/librte_ether/rte_ethdev.c +18 -0
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1681,6 +1720,23 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from applcation.
+	 * If any pure per-port offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.tx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d tx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in rte_eth_tx_queue_setup( )\n",
+				    port_id,
+				    tx_queue_id,
+				    local_conf.offloads,
+				    dev_info.tx_queue_offload_capa);
+		return -EINVAL;
+	}
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
 }
author
#19 lore raw

PATCH v6 1/1 ethdev: check Rx/Tx offloads

In reply to Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup().

Quoted 1 line

From application, a pure per-port offloading can only be enabled in

rte_eth_dev_configure().
Only supported per queue offloading can be sent to rte_eth_[rt]x_queue_setup( ). A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ). If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ).

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

---
v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 lib/librte_ether/rte_ethdev.c | 70 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
lib/librte_ether/rte_ethdev.c +70 -0
index f0f53d4..39a0f0e 100644
@@ -1196,6 +1196,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offload must be within its device capability */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads "
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads "
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capability 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
 	/*
 	 * Setup new number of RX/TX queues and reconfigure device.
 	 */
@@ -1547,6 +1569,30 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from application.
+	 * If any other offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * If an offload has already been enabled in rte_eth_dev_configure(),
+	 * there is no need to enable it again in queue level.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1681,6 +1727,30 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from applcation.
+	 * If any other offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.tx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d tx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    tx_queue_id,
+				    local_conf.offloads,
+				    dev_info.tx_queue_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * If an offload has already be enabled in rte_eth_dev_configure,
+	 * there is no need to enable it in queue level again
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.txmode.offloads;
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
 }
Signature · 1 line
2.7.5
#20 lore raw

Re: [PATCH v6] ethdev: check Rx/Tx offloads

Quoted 16 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup().
From application, a pure per-port offloading can only be enabled in rte_eth_dev_configure().
Only supported per queue offloading can be sent to rte_eth_[rt]x_queue_setup( ). A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ).
If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ).

Quoted 2 lines

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

Hi Wei, Thomas,

There are a few comments below but there is another concern, this change will break existing checks in PMDs.
Perhaps this check, PMD updates and update to document API change should go in one patch, what do you think?

Quoted 20 lines

---
v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

<...>

Quoted 11 lines
lib/librte_ether/rte_ethdev.c +7 -0
@@ -1547,6 +1569,30 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from application.
+	 * If any other offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d "

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1588

Quoted 10 lines
lib/librte_ether/rte_ethdev.c +10 -0
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}

Application will be allowed to provide queue or port offload in setup, only error case should be if application request a port level offload that is not already enabled in configure()

Also similar check in configure() required, to be sure app is not requesting offload beyond device capability (port + queue)

lib/librte_ether/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1594

Quoted 6 lines
lib/librte_ether/rte_ethdev.c +6 -0
+
+	/*
+	 * If an offload has already been enabled in rte_eth_dev_configure(),
+	 * there is no need to enable it again in queue level.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;

This is OK, with above check PMD will only observe new queue offload request.

Quoted 35 lines
lib/librte_ether/rte_ethdev.c +24 -0
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1681,6 +1727,30 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	/*
+	 * Only per-queue offload can be enabled from applcation.
+	 * If any other offload is sent to this function, return -EINVAL
+	 */
+	if ((local_conf.offloads & dev_info.tx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d tx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    tx_queue_id,
+				    local_conf.offloads,
+				    dev_info.tx_queue_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * If an offload has already be enabled in rte_eth_dev_configure,
+	 * there is no need to enable it in queue level again
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.txmode.offloads;
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
 }
author
#21 lore raw

PATCH v7 1/1 ethdev: check Rx/Tx offloads

In reply to Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).

Quoted 1 line

From application, a pure per-port offloading can't be enabled on

any queue if it hasn't been enabled in rte_eth_dev_configure( ). If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those offloadings only enabled for the queue but not enabled in rte_eth_dev_configure( ) and they are certain per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

---
v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer. Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 lib/librte_ethdev/rte_ethdev.c | 150 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 150 insertions(+)
lib/librte_ethdev/rte_ethdev.c +150 -0
index e560524..0ad05eb 100644
@@ -1139,6 +1139,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offloading must be within its device capabilities */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads "
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads "
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
 	/* Check that device supports requested rss hash functions. */
 	if ((dev_info.flow_type_rss_offloads |
 	     dev_conf->rx_adv_conf.rss_conf.rss_hf) !=
@@ -1414,6 +1436,8 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 	struct rte_eth_dev_info dev_info;
 	struct rte_eth_rxconf local_conf;
 	void **rxq;
+	uint64_t pure_port_offload_capa;
+	uint64_t only_enabled_for_queue;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
@@ -1504,6 +1528,68 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * The requested offloadings by application for this queue
+	 * can be per-queue type or per-port type. and
+	 * they must be within the device offloading capabilities.
+	 */
+	if ((local_conf.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * A pure per-port offloading can't be enabled for any queue
+	 * if it hasn't been enabled in rte_eth_dev_configure( ).
+	 *
+	 * Following pure_port_offload_capa is the capabilities which
+	 * can't be enabled on some queue while disabled on other queue.
+	 * pure_port_offload_capa must be enabled or disabled on all
+	 * queues at same time.
+	 *
+	 * Following only_enabled_for_queue is the offloadings which
+	 * are enabled for this queue but hasn't been enabled in
+	 * rte_eth_dev_configure( ).
+	 */
+	pure_port_offload_capa = dev_info.rx_offload_capa ^
+				 dev_info.rx_queue_offload_capa;
+	only_enabled_for_queue = (local_conf.offloads ^
+		dev->data->dev_conf.rxmode.offloads) & local_conf.offloads;
+	if (only_enabled_for_queue & pure_port_offload_capa) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d, only "
+				    "enabled offload 0x%" PRIx64 "for this "
+				    "queue haven't been enabled in "
+				    "dev_configure( ), they are within "
+				    "pure per-port capabilities 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    rx_queue_id,
+				    only_enabled_for_queue,
+				    pure_port_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1549,6 +1635,8 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 	struct rte_eth_dev_info dev_info;
 	struct rte_eth_txconf local_conf;
 	void **txq;
+	uint64_t pure_port_offload_capa;
+	uint64_t only_enabled_for_queue;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
@@ -1612,6 +1700,68 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	/*
+	 * The requested offloadings by application for this queue
+	 * can be per-queue type or per-port type. and
+	 * they must be within the device offloading capabilities.
+	 */
+	if ((local_conf.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d tx_queue_id=%d "
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    tx_queue_id,
+				    local_conf.offloads,
+				    dev_info.tx_queue_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * A pure per-port offloading can't be enabled for any queue
+	 * if it hasn't been enabled in rte_eth_dev_configure( ).
+	 *
+	 * Following pure_port_offload_capa is the capabilities which
+	 * can't be enabled on some queue while disabled on other queue.
+	 * pure_port_offload_capa must be enabled or disabled on all
+	 * queues at same time.
+	 *
+	 * Following only_enabled_for_queue is the offloadings which
+	 * are enabled for this queue but hasn't been enabled in
+	 * rte_eth_dev_configure( ).
+	 */
+	pure_port_offload_capa = dev_info.tx_offload_capa ^
+				 dev_info.tx_queue_offload_capa;
+	only_enabled_for_queue = (local_conf.offloads ^
+		dev->data->dev_conf.txmode.offloads) & local_conf.offloads;
+	if (only_enabled_for_queue & pure_port_offload_capa) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d tx_queue_id=%d, only "
+				    "enabled offload 0x%" PRIx64 "for this "
+				    "queue haven't been enabled in "
+				    "dev_configure( ), they are within "
+				    "pure per-port capabilities 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    tx_queue_id,
+				    only_enabled_for_queue,
+				    pure_port_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.txmode.offloads;
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
 }
Signature · 1 line
2.7.5
Acked-by on v7 1/1
#22 lore raw

Re: [PATCH v7] ethdev: check Rx/Tx offloads

Quoted 16 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
From application, a pure per-port offloading can't be enabled on any queue if it hasn't been enabled in rte_eth_dev_configure( ). If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those offloadings only enabled for the queue but not enabled in rte_eth_dev_configure( ) and they are certain per-queue type.

Quoted 5 lines

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

As mentioned in prev version, getting only this patch breaks the applications because of existing checks in the PMDs.

Hi Wei,

If you have bandwidth, can you update PMDs to remove their existing offload checks in this patch?

PMDs needs to be updated for:
1- Remove existing offload verify checks
2- Update offload configure logic based on new values

(1) can be part of this patch. But PMD maintainers should send update for (2) if a change required.

#23 lore raw

Re: [PATCH v7] ethdev: check Rx/Tx offloads

Quoted 35 lines · Ferruh Yigit
Quoted 16 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
From application, a pure per-port offloading can't be enabled on any queue if it hasn't been enabled in rte_eth_dev_configure( ). If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those offloadings only enabled for the queue but not enabled in rte_eth_dev_configure( ) and they are certain per-queue type.

Quoted 5 lines

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

As mentioned in prev version, getting only this patch breaks the applications because of existing checks in the PMDs.

Hi Wei,

If you have bandwidth, can you update PMDs to remove their existing offload checks in this patch?

Quoted 6 lines

PMDs needs to be updated for:
1- Remove existing offload verify checks
2- Update offload configure logic based on new values

(1) can be part of this patch. But PMD maintainers should send update for (2) if a change required.

cc'ed Shahaf, specially for (2) one.

#24 lore raw

Re: [PATCH v7] ethdev: check Rx/Tx offloads

In reply to Wei Dai

Hi Ferruh, Dai,

Quoted 66 lines

Subject: [dpdk-dev] [PATCH v7] ethdev: check Rx/Tx offloads

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf-

Quoted 1 line

offloads to rte_eth_[rt]x_queue_setup( ).

From application, a pure per-port offloading can't be enabled on any queue if it hasn't been enabled in rte_eth_dev_configure( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those offloadings only enabled for the queue but not enabled in rte_eth_dev_configure( ) and they are certain per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

---
v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer.
Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 lib/librte_ethdev/rte_ethdev.c | 150
+++++++++++++++++++++++++++++++++++++++++
 1 file changed, 150 insertions(+)
lib/librte_ethdev/rte_ethdev.c +4 -0
index e560524..0ad05eb 100644
@@ -1139,6 +1139,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t
 nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offloading must be within its device capabilities */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx

offloads "

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1151

Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6 -0
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;

While I am OK with such behavior, we should be more careful not to get into the same issue as in [1]. There are PMD which don't report the capabilities correctly however do expect to have the offload configured.

All I am saying it is worth a check and cautious decision if it is right to include this one w/o prior application notice and at such late RC of the release.

Quoted 67 lines
lib/librte_ethdev/rte_ethdev.c +4 -0
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx

offloads "

lib/librte_ethdev/rte_ethdev.c +8 -0
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
 	/* Check that device supports requested rss hash functions. */
 	if ((dev_info.flow_type_rss_offloads |
 	     dev_conf->rx_adv_conf.rss_conf.rss_hf) != @@ -1414,6 +1436,8

@@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,

lib/librte_ethdev/rte_ethdev.c +10 -0
 	struct rte_eth_dev_info dev_info;
 	struct rte_eth_rxconf local_conf;
 	void **rxq;
+	uint64_t pure_port_offload_capa;
+	uint64_t only_enabled_for_queue;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
@@ -1504,6 +1528,68 @@ rte_eth_rx_queue_setup(uint16_t port_id,
 uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * The requested offloadings by application for this queue
+	 * can be per-queue type or per-port type. and
+	 * they must be within the device offloading capabilities.
+	 */
+	if ((local_conf.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d

rx_queue_id=%d "

lib/librte_ethdev/rte_ethdev.c +28 -0
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * A pure per-port offloading can't be enabled for any queue
+	 * if it hasn't been enabled in rte_eth_dev_configure( ).
+	 *
+	 * Following pure_port_offload_capa is the capabilities which
+	 * can't be enabled on some queue while disabled on other queue.
+	 * pure_port_offload_capa must be enabled or disabled on all
+	 * queues at same time.
+	 *
+	 * Following only_enabled_for_queue is the offloadings which
+	 * are enabled for this queue but hasn't been enabled in
+	 * rte_eth_dev_configure( ).
+	 */
+	pure_port_offload_capa = dev_info.rx_offload_capa ^
+				 dev_info.rx_queue_offload_capa;
+	only_enabled_for_queue = (local_conf.offloads ^
+		dev->data->dev_conf.rxmode.offloads) &
Quoted 1 line

local_conf.offloads;

It looks like above logic could be a lot simpler.

How about:
local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads; // keep only the added offloads on top of the port ones if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
local_conf.offloads) { //check if added offloads are part of the queue offload capa
ERROR...

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1572

Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +2 -0
+	if (only_enabled_for_queue & pure_port_offload_capa) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d

rx_queue_id=%d, only "

lib/librte_ethdev/rte_ethdev.c +4 -0
+				    "enabled offload 0x%" PRIx64 "for this "
+				    "queue haven't been enabled in "
+				    "dev_configure( ), they are within "
+				    "pure per-port capabilities 0x%" PRIx64

Need to re-work this error message. The user doesn't know what are "pure per-port capabilities"

Quoted 76 lines
lib/librte_ethdev/rte_ethdev.c +20 -0
+				    " in %s\n",
+				    port_id,
+				    rx_queue_id,
+				    only_enabled_for_queue,
+				    pure_port_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id,

nb_rx_desc,

lib/librte_ethdev/rte_ethdev.c +10 -0
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1549,6 +1635,8 @@ rte_eth_tx_queue_setup(uint16_t port_id,
 uint16_t tx_queue_id,
 	struct rte_eth_dev_info dev_info;
 	struct rte_eth_txconf local_conf;
 	void **txq;
+	uint64_t pure_port_offload_capa;
+	uint64_t only_enabled_for_queue;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
@@ -1612,6 +1700,68 @@ rte_eth_tx_queue_setup(uint16_t port_id,
 uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	/*
+	 * The requested offloadings by application for this queue
+	 * can be per-queue type or per-port type. and
+	 * they must be within the device offloading capabilities.
+	 */
+	if ((local_conf.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d

tx_queue_id=%d "

lib/librte_ethdev/rte_ethdev.c +28 -0
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    tx_queue_id,
+				    local_conf.offloads,
+				    dev_info.tx_queue_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * A pure per-port offloading can't be enabled for any queue
+	 * if it hasn't been enabled in rte_eth_dev_configure( ).
+	 *
+	 * Following pure_port_offload_capa is the capabilities which
+	 * can't be enabled on some queue while disabled on other queue.
+	 * pure_port_offload_capa must be enabled or disabled on all
+	 * queues at same time.
+	 *
+	 * Following only_enabled_for_queue is the offloadings which
+	 * are enabled for this queue but hasn't been enabled in
+	 * rte_eth_dev_configure( ).
+	 */
+	pure_port_offload_capa = dev_info.tx_offload_capa ^
+				 dev_info.tx_queue_offload_capa;
+	only_enabled_for_queue = (local_conf.offloads ^
+		dev->data->dev_conf.txmode.offloads) &
Quoted 1 line

local_conf.offloads;

Same comments as in the Rx part.

Quoted 30 lines
lib/librte_ethdev/rte_ethdev.c +2 -0
+	if (only_enabled_for_queue & pure_port_offload_capa) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d

tx_queue_id=%d, only "

lib/librte_ethdev/rte_ethdev.c +24 -1
+				    "enabled offload 0x%" PRIx64 "for this "
+				    "queue haven't been enabled in "
+				    "dev_configure( ), they are within "
+				    "pure per-port capabilities 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    tx_queue_id,
+				    only_enabled_for_queue,
+				    pure_port_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.txmode.offloads;
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));  }
--
Quoted 1 line

2.7.5

As for Ferruh's comment

Quoted 9 lines

PMDs needs to be updated for:
1- Remove existing offload verify checks
2- Update offload configure logic based on new values

(1) can be part of this patch. But PMD maintainers should send update for (2) if a change required.

cc'ed Shahaf, specially for (2) one.

I think PMD maintainers can help with that. If it will be integrated enough time before the release Mellanox PMDs can be converted by us.

[1]
http://dpdk.org/dev/patchwork/patch/38645/

author
#25 lore raw

Re: [PATCH v7] ethdev: check Rx/Tx offloads

Thanks to Shuler and Ferruh for your feedback and guidance.

PMD at least has these 2 options with this patch:
a). If PMD doesn't want to make much more changes, it still can do "[rt]x_conf->offloads |= dev->data->dev_conf.rxmode.offloads;"
in the beginning of its specific queue_setup( ) and just remove offload checking (although the checking always pass now) and all others keep same. In this way, PMDs still comply with the offload APIs defined in 17.11.
b). PMD also can use the info that only new added queue-level offloads in the input argument [rt]x_conf->offloads to make some
optimization or other code changes. It may be more efficient than a).

As Ferruh said, only this patch and without relevant change in PMD will cause application broken,
I will submit v8 patch which will include this patch for ethdev and code changes in PMDs with above option a and document update. I'd like include all these changes in only one patch to avoid application failure if some patches are not applied and some are applied. PMD maintainers call go on with option b)

Shuler's suggestion to simplify the new added offloads in queue_setup( ) is better. I will adopt it in my v8 patch.

Quoted 315 lines

-----Original Message-----
From: Shahaf Shuler [mailto:[email protected]]
Sent: Sunday, May 6, 2018 3:00 AM
To: Dai, Wei <[email protected]>; Thomas Monjalon <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH v7] ethdev: check Rx/Tx offloads

Hi Ferruh, Dai,

Quoted 67 lines

Subject: [dpdk-dev] [PATCH v7] ethdev: check Rx/Tx offloads

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf-

Quoted 1 line

offloads to rte_eth_[rt]x_queue_setup( ).

From application, a pure per-port offloading can't be enabled on any queue if it hasn't been enabled in rte_eth_dev_configure( ). If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ). The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those offloadings only enabled for the queue but not enabled in rte_eth_dev_configure( ) and they are certain per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

---
v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer.
Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 lib/librte_ethdev/rte_ethdev.c | 150
+++++++++++++++++++++++++++++++++++++++++
 1 file changed, 150 insertions(+)
(quoted diff) +0 -0

b/lib/librte_ethdev/rte_ethdev.c index e560524..0ad05eb 100644

lib/librte_ethdev/rte_ethdev.c +4 -0
@@ -1139,6 +1139,28 @@ rte_eth_dev_configure(uint16_t port_id,
 uint16_t nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offloading must be within its device capabilities */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx

offloads "

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1151

Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6 -0
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;

While I am OK with such behavior, we should be more careful not to get into the same issue as in [1].
There are PMD which don't report the capabilities correctly however do expect to have the offload configured.

All I am saying it is worth a check and cautious decision if it is right to include this one w/o prior application notice and at such late RC of the release.

Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +4 -0
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx

offloads "

lib/librte_ethdev/rte_ethdev.c +1 -0
+				    "0x%" PRIx64 " doesn't match Tx offloads "

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +7 -0
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
 	/* Check that device supports requested rss hash functions. */
 	if ((dev_info.flow_type_rss_offloads |
 	     dev_conf->rx_adv_conf.rss_conf.rss_hf) != @@ -1414,6 +1436,8

@@

Quoted 51 lines

rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,

lib/librte_ethdev/rte_ethdev.c +10 -0
 	struct rte_eth_dev_info dev_info;
 	struct rte_eth_rxconf local_conf;
 	void **rxq;
+	uint64_t pure_port_offload_capa;
+	uint64_t only_enabled_for_queue;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
@@ -1504,6 +1528,68 @@ rte_eth_rx_queue_setup(uint16_t port_id,
 uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * The requested offloadings by application for this queue
+	 * can be per-queue type or per-port type. and
+	 * they must be within the device offloading capabilities.
+	 */
+	if ((local_conf.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d

rx_queue_id=%d "

lib/librte_ethdev/rte_ethdev.c +28 -0
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * A pure per-port offloading can't be enabled for any queue
+	 * if it hasn't been enabled in rte_eth_dev_configure( ).
+	 *
+	 * Following pure_port_offload_capa is the capabilities which
+	 * can't be enabled on some queue while disabled on other queue.
+	 * pure_port_offload_capa must be enabled or disabled on all
+	 * queues at same time.
+	 *
+	 * Following only_enabled_for_queue is the offloadings which
+	 * are enabled for this queue but hasn't been enabled in
+	 * rte_eth_dev_configure( ).
+	 */
+	pure_port_offload_capa = dev_info.rx_offload_capa ^
+				 dev_info.rx_queue_offload_capa;
+	only_enabled_for_queue = (local_conf.offloads ^
+		dev->data->dev_conf.rxmode.offloads) &
Quoted 1 line

local_conf.offloads;

It looks like above logic could be a lot simpler.

How about:
local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads; // keep only the added offloads on top of the port ones if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
local_conf.offloads) { //check if added offloads are part of the queue
offload capa

	ERROR...

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1572

Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +2 -0
+	if (only_enabled_for_queue & pure_port_offload_capa) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d

rx_queue_id=%d, only "

lib/librte_ethdev/rte_ethdev.c +4 -0
+				    "enabled offload 0x%" PRIx64 "for this "
+				    "queue haven't been enabled in "
+				    "dev_configure( ), they are within "
+				    "pure per-port capabilities 0x%" PRIx64

Need to re-work this error message. The user doesn't know what are "pure per-port capabilities"

Quoted 75 lines
lib/librte_ethdev/rte_ethdev.c +30 -0
+				    " in %s\n",
+				    port_id,
+				    rx_queue_id,
+				    only_enabled_for_queue,
+				    pure_port_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1549,6 +1635,8 @@ rte_eth_tx_queue_setup(uint16_t port_id,
 uint16_t tx_queue_id,
 	struct rte_eth_dev_info dev_info;
 	struct rte_eth_txconf local_conf;
 	void **txq;
+	uint64_t pure_port_offload_capa;
+	uint64_t only_enabled_for_queue;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
@@ -1612,6 +1700,68 @@ rte_eth_tx_queue_setup(uint16_t port_id,
 uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	/*
+	 * The requested offloadings by application for this queue
+	 * can be per-queue type or per-port type. and
+	 * they must be within the device offloading capabilities.
+	 */
+	if ((local_conf.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d

tx_queue_id=%d "

lib/librte_ethdev/rte_ethdev.c +28 -0
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    tx_queue_id,
+				    local_conf.offloads,
+				    dev_info.tx_queue_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * A pure per-port offloading can't be enabled for any queue
+	 * if it hasn't been enabled in rte_eth_dev_configure( ).
+	 *
+	 * Following pure_port_offload_capa is the capabilities which
+	 * can't be enabled on some queue while disabled on other queue.
+	 * pure_port_offload_capa must be enabled or disabled on all
+	 * queues at same time.
+	 *
+	 * Following only_enabled_for_queue is the offloadings which
+	 * are enabled for this queue but hasn't been enabled in
+	 * rte_eth_dev_configure( ).
+	 */
+	pure_port_offload_capa = dev_info.tx_offload_capa ^
+				 dev_info.tx_queue_offload_capa;
+	only_enabled_for_queue = (local_conf.offloads ^
+		dev->data->dev_conf.txmode.offloads) &
Quoted 1 line

local_conf.offloads;

Same comments as in the Rx part.

Quoted 30 lines
lib/librte_ethdev/rte_ethdev.c +2 -0
+	if (only_enabled_for_queue & pure_port_offload_capa) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d

tx_queue_id=%d, only "

lib/librte_ethdev/rte_ethdev.c +24 -1
+				    "enabled offload 0x%" PRIx64 "for this "
+				    "queue haven't been enabled in "
+				    "dev_configure( ), they are within "
+				    "pure per-port capabilities 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    tx_queue_id,
+				    only_enabled_for_queue,
+				    pure_port_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.txmode.offloads;
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));  }
--
Quoted 1 line

2.7.5

As for Ferruh's comment

Quoted 9 lines

PMDs needs to be updated for:
1- Remove existing offload verify checks
2- Update offload configure logic based on new values

(1) can be part of this patch. But PMD maintainers should send update for (2) if a change required.

cc'ed Shahaf, specially for (2) one.

I think PMD maintainers can help with that. If it will be integrated enough time before the release Mellanox PMDs can be converted by us.

[1]
http://dpdk.org/dev/patchwork/patch/38645/

#26 lore raw

Re: [PATCH v7] ethdev: check Rx/Tx offloads

In reply to Shahaf Shuler
Quoted 77 lines · Shahaf Shuler

Hi Ferruh, Dai,

Quoted 66 lines

Subject: [dpdk-dev] [PATCH v7] ethdev: check Rx/Tx offloads

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf-

Quoted 1 line

offloads to rte_eth_[rt]x_queue_setup( ).

From application, a pure per-port offloading can't be enabled on any queue if it hasn't been enabled in rte_eth_dev_configure( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those offloadings only enabled for the queue but not enabled in rte_eth_dev_configure( ) and they are certain per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

---
v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer.
Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 lib/librte_ethdev/rte_ethdev.c | 150
+++++++++++++++++++++++++++++++++++++++++
 1 file changed, 150 insertions(+)
lib/librte_ethdev/rte_ethdev.c +4 -0
index e560524..0ad05eb 100644
@@ -1139,6 +1139,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t
 nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
+	/* Any requested offloading must be within its device capabilities */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx

offloads "

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1151

Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6 -0
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;

While I am OK with such behavior, we should be more careful not to get into the same issue as in [1]. There are PMD which don't report the capabilities correctly however do expect to have the offload configured.

Quoted 1 line

All I am saying it is worth a check and cautious decision if it is right to include this one w/o prior application notice and at such late RC of the release.

This is valid concern. I think this is better than [1] which was less clear than this check but yes still a concern.

Quoted 72 lines
Quoted 68 lines
lib/librte_ethdev/rte_ethdev.c +4 -0
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx

offloads "

lib/librte_ethdev/rte_ethdev.c +8 -0
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
 	/* Check that device supports requested rss hash functions. */
 	if ((dev_info.flow_type_rss_offloads |
 	     dev_conf->rx_adv_conf.rss_conf.rss_hf) != @@ -1414,6 +1436,8

@@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,

lib/librte_ethdev/rte_ethdev.c +10 -0
 	struct rte_eth_dev_info dev_info;
 	struct rte_eth_rxconf local_conf;
 	void **rxq;
+	uint64_t pure_port_offload_capa;
+	uint64_t only_enabled_for_queue;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
@@ -1504,6 +1528,68 @@ rte_eth_rx_queue_setup(uint16_t port_id,
 uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * The requested offloadings by application for this queue
+	 * can be per-queue type or per-port type. and
+	 * they must be within the device offloading capabilities.
+	 */
+	if ((local_conf.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d

rx_queue_id=%d "

lib/librte_ethdev/rte_ethdev.c +28 -0
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    rx_queue_id,
+				    local_conf.offloads,
+				    dev_info.rx_queue_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * A pure per-port offloading can't be enabled for any queue
+	 * if it hasn't been enabled in rte_eth_dev_configure( ).
+	 *
+	 * Following pure_port_offload_capa is the capabilities which
+	 * can't be enabled on some queue while disabled on other queue.
+	 * pure_port_offload_capa must be enabled or disabled on all
+	 * queues at same time.
+	 *
+	 * Following only_enabled_for_queue is the offloadings which
+	 * are enabled for this queue but hasn't been enabled in
+	 * rte_eth_dev_configure( ).
+	 */
+	pure_port_offload_capa = dev_info.rx_offload_capa ^
+				 dev_info.rx_queue_offload_capa;
+	only_enabled_for_queue = (local_conf.offloads ^
+		dev->data->dev_conf.rxmode.offloads) &
Quoted 1 line

local_conf.offloads;

It looks like above logic could be a lot simpler.

Quoted 5 lines

How about:
local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads; // keep only the added offloads on top of the port ones if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
local_conf.offloads) { //check if added offloads are part of the queue offload capa
ERROR...

+1

Quoted 11 lines

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1572

Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c +2 -0
+	if (only_enabled_for_queue & pure_port_offload_capa) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d

rx_queue_id=%d, only "

lib/librte_ethdev/rte_ethdev.c +4 -0
+				    "enabled offload 0x%" PRIx64 "for this "
+				    "queue haven't been enabled in "
+				    "dev_configure( ), they are within "
+				    "pure per-port capabilities 0x%" PRIx64

Need to re-work this error message. The user doesn't know what are "pure per-port capabilities"

+1

Quoted 120 lines
Quoted 77 lines
lib/librte_ethdev/rte_ethdev.c +20 -0
+				    " in %s\n",
+				    port_id,
+				    rx_queue_id,
+				    only_enabled_for_queue,
+				    pure_port_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id,

nb_rx_desc,

lib/librte_ethdev/rte_ethdev.c +10 -0
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1549,6 +1635,8 @@ rte_eth_tx_queue_setup(uint16_t port_id,
 uint16_t tx_queue_id,
 	struct rte_eth_dev_info dev_info;
 	struct rte_eth_txconf local_conf;
 	void **txq;
+	uint64_t pure_port_offload_capa;
+	uint64_t only_enabled_for_queue;
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
@@ -1612,6 +1700,68 @@ rte_eth_tx_queue_setup(uint16_t port_id,
 uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	/*
+	 * The requested offloadings by application for this queue
+	 * can be per-queue type or per-port type. and
+	 * they must be within the device offloading capabilities.
+	 */
+	if ((local_conf.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.offloads) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d

tx_queue_id=%d "

lib/librte_ethdev/rte_ethdev.c +28 -0
+				    "Requested offload 0x%" PRIx64 "doesn't "
+				    "match per-queue capability 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    tx_queue_id,
+				    local_conf.offloads,
+				    dev_info.tx_queue_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * A pure per-port offloading can't be enabled for any queue
+	 * if it hasn't been enabled in rte_eth_dev_configure( ).
+	 *
+	 * Following pure_port_offload_capa is the capabilities which
+	 * can't be enabled on some queue while disabled on other queue.
+	 * pure_port_offload_capa must be enabled or disabled on all
+	 * queues at same time.
+	 *
+	 * Following only_enabled_for_queue is the offloadings which
+	 * are enabled for this queue but hasn't been enabled in
+	 * rte_eth_dev_configure( ).
+	 */
+	pure_port_offload_capa = dev_info.tx_offload_capa ^
+				 dev_info.tx_queue_offload_capa;
+	only_enabled_for_queue = (local_conf.offloads ^
+		dev->data->dev_conf.txmode.offloads) &
Quoted 1 line

local_conf.offloads;

Same comments as in the Rx part.

Quoted 30 lines
lib/librte_ethdev/rte_ethdev.c +2 -0
+	if (only_enabled_for_queue & pure_port_offload_capa) {
+		RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d

tx_queue_id=%d, only "

lib/librte_ethdev/rte_ethdev.c +24 -1
+				    "enabled offload 0x%" PRIx64 "for this "
+				    "queue haven't been enabled in "
+				    "dev_configure( ), they are within "
+				    "pure per-port capabilities 0x%" PRIx64
+				    " in %s\n",
+				    port_id,
+				    tx_queue_id,
+				    only_enabled_for_queue,
+				    pure_port_offload_capa,
+				    __func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.txmode.offloads;
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));  }
--
Quoted 1 line

2.7.5

As for Ferruh's comment

Quoted 5 lines

PMDs needs to be updated for:
1- Remove existing offload verify checks
2- Update offload configure logic based on new values

Quoted 7 lines
Quoted 4 lines

(1) can be part of this patch. But PMD maintainers should send update for (2) if a change required.

cc'ed Shahaf, specially for (2) one.

I think PMD maintainers can help with that. If it will be integrated enough time before the release Mellanox PMDs can be converted by us.

Thanks.
As far as I can see in v8 Wei is adding some code [2] to keep same input for the PMD to not break the logic in PMD. But later PMD can be updated for better support of new offload input to the PMD.

[2]
+ uint64_t offloads = conf->offloads |
+ dev->data->dev_conf.rxmode.offloads;

Quoted 7 lines

[1]
http://dpdk.org/dev/patchwork/patch/38645/

author
#27 lore raw

PATCH v8 1/1 ethdev: check Rx/Tx offloads

In reply to Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise return error.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

---
v8:
Revise PMD codes to comply with offload API in v7
update document

v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer. Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 doc/guides/prog_guide/poll_mode_drv.rst |  26 +++--
 doc/guides/rel_notes/release_18_05.rst  |   8 ++
 drivers/net/avf/avf_rxtx.c              |   5 +-
 drivers/net/bnxt/bnxt_ethdev.c          |  17 ----
 drivers/net/cxgbe/cxgbe_ethdev.c        |  50 +---------
 drivers/net/dpaa/dpaa_ethdev.c          |  16 ----
 drivers/net/dpaa2/dpaa2_ethdev.c        |  16 ----
 drivers/net/e1000/em_ethdev.c           |  19 ----
 drivers/net/e1000/em_rxtx.c             |  64 ++-----------
 drivers/net/e1000/igb_rxtx.c            |  64 ++-----------
 drivers/net/ena/ena_ethdev.c            |  65 +------------
 drivers/net/failsafe/failsafe_ops.c     |  81 ----------------
 drivers/net/fm10k/fm10k_ethdev.c        |  82 ++--------------
 drivers/net/i40e/i40e_rxtx.c            |  58 ++----------
 drivers/net/ixgbe/ixgbe_ethdev.c        |  38 --------
 drivers/net/ixgbe/ixgbe_rxtx.c          |  66 ++-----------
 drivers/net/mlx4/mlx4_rxq.c             |  43 ++-------
 drivers/net/mlx4/mlx4_txq.c             |  42 ++------
 drivers/net/mlx5/mlx5_ethdev.c          |  22 -----
 drivers/net/mlx5/mlx5_rxq.c             |  50 ++--------
 drivers/net/mlx5/mlx5_txq.c             |  44 +--------
 drivers/net/mvpp2/mrvl_ethdev.c         |  97 +------------------
 drivers/net/nfp/nfp_net.c               | 163 --------------------------------
 drivers/net/octeontx/octeontx_ethdev.c  |  72 +-------------
 drivers/net/sfc/sfc_ethdev.c            |   9 +-
 drivers/net/sfc/sfc_rx.c                |  42 ++------
 drivers/net/sfc/sfc_rx.h                |   3 +-
 drivers/net/sfc/sfc_tx.c                |  42 ++------
 drivers/net/sfc/sfc_tx.h                |   3 +-
 drivers/net/tap/rte_eth_tap.c           |  88 ++---------------
 drivers/net/thunderx/nicvf_ethdev.c     |  70 ++------------
 drivers/net/virtio/virtio_rxtx.c        |   9 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c    |  16 ----
 drivers/net/vmxnet3/vmxnet3_rxtx.c      |   8 +-
 lib/librte_ethdev/rte_ethdev.c          |  88 +++++++++++++++++
 35 files changed, 240 insertions(+), 1346 deletions(-)
doc/guides/prog_guide/poll_mode_drv.rst +20 -6
index 09a93ba..56483fb 100644
@@ -297,16 +297,30 @@ Per-Port and Per-Queue Offloads
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 In the DPDK offload API, offloads are divided into per-port and per-queue offloads.
+A per-queue offloading can be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offloading must be enabled or disabled on all queues at the same time.
+A per-port offloading can be enabled or disabled on all queues at the same time.
+It is certain that both per-queue and pure per-port offloading are per-port type.
 The different offloads capabilities can be queried using ``rte_eth_dev_info_get()``.
+The dev_info->[rt]x_queue_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.
+The dev_info->[rt]x_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.
 Supported offloads can be either per-port or per-queue.
 
 Offloads are enabled using the existing ``DEV_TX_OFFLOAD_*`` or ``DEV_RX_OFFLOAD_*`` flags.
-Per-port offload configuration is set using ``rte_eth_dev_configure``.
-Per-queue offload configuration is set using ``rte_eth_rx_queue_setup`` and ``rte_eth_tx_queue_setup``.
-To enable per-port offload, the offload should be set on both device configuration and queue setup.
-In case of a mixed configuration the queue setup shall return with an error.
-To enable per-queue offload, the offload can be set only on the queue setup.
-Offloads which are not enabled are disabled by default.
+Any requested offloading by application must be within the device capabilities.
+Any offloading is disabled by default if it is not set in the parameter
+dev_conf->[rt]xmode.offloads to ``rte_eth_dev_configure( )`` and
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )``.
+If any offloading is enabled in ``rte_eth_dev_configure( )`` by application,
+it is enabled on all queues no matter whether it is per-queue or
+per-port type and no matter whether it is set or cleared in
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )``.
+If a per-queue offloading hasn't been enabled in ``rte_eth_dev_configure( )``,
+it can be enabled or disabled in ``rte_eth_[rt]x_queue_setup( )`` for individual queue.
+A new added offloads in [rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )`` input by application
+is the one which hasn't been enabled in ``rte_eth_dev_configure( )`` and is requested to be enabled
+in ``rte_eth_[rt]x_queue_setup( )``, it must be per-queue type, otherwise return error.
 
 For an application to use the Tx offloads API it should set the ``ETH_TXQ_FLAGS_IGNORE`` flag in the ``txq_flags`` field located in ``rte_eth_txconf`` struct.
 In such cases it is not required to set other flags in ``txq_flags``.
doc/guides/rel_notes/release_18_05.rst +8 -0
index 0ae61e8..637e684 100644
@@ -303,6 +303,14 @@ API Changes
   * ``rte_flow_create()`` API count action now requires the ``struct rte_flow_action_count``.
   * ``rte_flow_query()`` API parameter changed from action type to action structure.
 
+* **ethdev: changes to offload API**
+
+   A pure per-port offloading isn't requested to be repeated in [rt]x_conf->offloads to
+   ``rte_eth_[rt]x_queue_setup( )``. Now any offloading enabled in ``rte_eth_dev_configure( )``
+   can't be disabled by ``rte_eth_[rt]x_queue_setup( )``. Any new added offloading which has
+   not been enabled in ``rte_eth_dev_configure( )`` and is requested to be enabled in
+   ``rte_eth_[rt]x_queue_setup( )`` must be per-queue type, otherwise return error.
+
 
 ABI Changes
 -----------
drivers/net/avf/avf_rxtx.c +4 -1
index 1824ed7..e03a136 100644
@@ -435,9 +435,12 @@ avf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	uint32_t ring_size;
 	uint16_t tx_rs_thresh, tx_free_thresh;
 	uint16_t i, base, bsf, tc_mapping;
+	uint64_t offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+
 	if (nb_desc % AVF_ALIGN_RING_DESC != 0 ||
 	    nb_desc > AVF_MAX_RING_DESC ||
 	    nb_desc < AVF_MIN_RING_DESC) {
@@ -474,7 +477,7 @@ avf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->free_thresh = tx_free_thresh;
 	txq->queue_id = queue_idx;
 	txq->port_id = dev->data->port_id;
-	txq->offloads = tx_conf->offloads;
+	txq->offloads = offloads;
 	txq->tx_deferred_start = tx_conf->tx_deferred_start;
 
 	/* Allocate software ring */
drivers/net/bnxt/bnxt_ethdev.c +0 -17
index 348129d..d00b99f 100644
@@ -500,25 +500,8 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
 static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
-	uint64_t tx_offloads = eth_dev->data->dev_conf.txmode.offloads;
 	uint64_t rx_offloads = eth_dev->data->dev_conf.rxmode.offloads;
 
-	if (tx_offloads != (tx_offloads & BNXT_DEV_TX_OFFLOAD_SUPPORT)) {
-		PMD_DRV_LOG
-			(ERR,
-			 "Tx offloads requested 0x%" PRIx64 " supported 0x%x\n",
-			 tx_offloads, BNXT_DEV_TX_OFFLOAD_SUPPORT);
-		return -ENOTSUP;
-	}
-
-	if (rx_offloads != (rx_offloads & BNXT_DEV_RX_OFFLOAD_SUPPORT)) {
-		PMD_DRV_LOG
-			(ERR,
-			 "Rx offloads requested 0x%" PRIx64 " supported 0x%x\n",
-			    rx_offloads, BNXT_DEV_RX_OFFLOAD_SUPPORT);
-		return -ENOTSUP;
-	}
-
 	bp->rx_queues = (void *)eth_dev->data->rx_queues;
 	bp->tx_queues = (void *)eth_dev->data->tx_queues;
 
drivers/net/cxgbe/cxgbe_ethdev.c +5 -45

86 lines not on this page · raw message

drivers/net/dpaa/dpaa_ethdev.c +0 -16
index 6bf8c15..199afdd 100644
@@ -176,14 +176,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* Rx offloads validation */
-	if (~(dev_rx_offloads_sup | dev_rx_offloads_nodis) & rx_offloads) {
-		DPAA_PMD_ERR(
-		"Rx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			rx_offloads,
-			dev_rx_offloads_sup | dev_rx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_rx_offloads_nodis & ~rx_offloads) {
 		DPAA_PMD_WARN(
 		"Rx offloads non configurable - requested 0x%" PRIx64
@@ -192,14 +184,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
 	}
 
 	/* Tx offloads validation */
-	if (~(dev_tx_offloads_sup | dev_tx_offloads_nodis) & tx_offloads) {
-		DPAA_PMD_ERR(
-		"Tx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			tx_offloads,
-			dev_tx_offloads_sup | dev_tx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_tx_offloads_nodis & ~tx_offloads) {
 		DPAA_PMD_WARN(
 		"Tx offloads non configurable - requested 0x%" PRIx64
drivers/net/dpaa2/dpaa2_ethdev.c +0 -16
index c304b82..de8d83a 100644
@@ -309,14 +309,6 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* Rx offloads validation */
-	if (~(dev_rx_offloads_sup | dev_rx_offloads_nodis) & rx_offloads) {
-		DPAA2_PMD_ERR(
-		"Rx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			rx_offloads,
-			dev_rx_offloads_sup | dev_rx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_rx_offloads_nodis & ~rx_offloads) {
 		DPAA2_PMD_WARN(
 		"Rx offloads non configurable - requested 0x%" PRIx64
@@ -325,14 +317,6 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 	}
 
 	/* Tx offloads validation */
-	if (~(dev_tx_offloads_sup | dev_tx_offloads_nodis) & tx_offloads) {
-		DPAA2_PMD_ERR(
-		"Tx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			tx_offloads,
-			dev_tx_offloads_sup | dev_tx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_tx_offloads_nodis & ~tx_offloads) {
 		DPAA2_PMD_WARN(
 		"Tx offloads non configurable - requested 0x%" PRIx64
drivers/net/e1000/em_ethdev.c +0 -19
index 694a624..4e890ad 100644
@@ -454,29 +454,10 @@ eth_em_configure(struct rte_eth_dev *dev)
 {
 	struct e1000_interrupt *intr =
 		E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 
 	PMD_INIT_FUNC_TRACE();
 	intr->flags |= E1000_FLAG_NEED_LINK_UPDATE;
 
-	eth_em_infos_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	PMD_INIT_FUNC_TRACE();
 
 	return 0;
drivers/net/e1000/em_rxtx.c +6 -58

106 lines not on this page · raw message

drivers/net/e1000/igb_rxtx.c +6 -58

102 lines not on this page · raw message

drivers/net/ena/ena_ethdev.c +4 -61

113 lines not on this page · raw message

drivers/net/failsafe/failsafe_ops.c +0 -81

115 lines not on this page · raw message

drivers/net/fm10k/fm10k_ethdev.c +8 -74

135 lines not on this page · raw message

drivers/net/i40e/i40e_rxtx.c +6 -52

96 lines not on this page · raw message

drivers/net/ixgbe/ixgbe_ethdev.c +0 -38
index 91179e9..320ab21 100644
@@ -2365,9 +2365,6 @@ ixgbe_dev_configure(struct rte_eth_dev *dev)
 		IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
 	struct ixgbe_adapter *adapter =
 		(struct ixgbe_adapter *)dev->data->dev_private;
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 	int ret;
 
 	PMD_INIT_FUNC_TRACE();
@@ -2379,22 +2376,6 @@ ixgbe_dev_configure(struct rte_eth_dev *dev)
 		return ret;
 	}
 
-	ixgbe_dev_info_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	/* set flag to update link status after init */
 	intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
 
@@ -4965,29 +4946,10 @@ ixgbevf_dev_configure(struct rte_eth_dev *dev)
 	struct rte_eth_conf *conf = &dev->data->dev_conf;
 	struct ixgbe_adapter *adapter =
 			(struct ixgbe_adapter *)dev->data->dev_private;
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 
 	PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
 		     dev->data->port_id);
 
-	ixgbevf_dev_info_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	/*
 	 * VF has no ability to enable/disable HW CRC
 	 * Keep the persistent behavior the same as Host PF
drivers/net/ixgbe/ixgbe_rxtx.c +6 -60

110 lines not on this page · raw message

drivers/net/mlx4/mlx4_rxq.c +8 -35

77 lines not on this page · raw message

drivers/net/mlx4/mlx4_txq.c +6 -36

66 lines not on this page · raw message

drivers/net/mlx5/mlx5_ethdev.c +0 -22
index 746b94f..df369cd 100644
@@ -330,30 +330,8 @@ mlx5_dev_configure(struct rte_eth_dev *dev)
 	unsigned int reta_idx_n;
 	const uint8_t use_app_rss_key =
 		!!dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key;
-	uint64_t supp_tx_offloads = mlx5_get_tx_port_offloads(dev);
-	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
-	uint64_t supp_rx_offloads =
-		(mlx5_get_rx_port_offloads() |
-		 mlx5_get_rx_queue_offloads(dev));
-	uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
 	int ret = 0;
 
-	if ((tx_offloads & supp_tx_offloads) != tx_offloads) {
-		DRV_LOG(ERR,
-			"port %u some Tx offloads are not supported requested"
-			" 0x%" PRIx64 " supported 0x%" PRIx64,
-			dev->data->port_id, tx_offloads, supp_tx_offloads);
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
-	if ((rx_offloads & supp_rx_offloads) != rx_offloads) {
-		DRV_LOG(ERR,
-			"port %u some Rx offloads are not supported requested"
-			" 0x%" PRIx64 " supported 0x%" PRIx64,
-			dev->data->port_id, rx_offloads, supp_rx_offloads);
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
 	if (use_app_rss_key &&
 	    (dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len !=
 	     rss_hash_default_key_len)) {
drivers/net/mlx5/mlx5_rxq.c +7 -43

82 lines not on this page · raw message

drivers/net/mlx5/mlx5_txq.c +2 -42

62 lines not on this page · raw message

drivers/net/mvpp2/mrvl_ethdev.c +3 -94

139 lines not on this page · raw message

drivers/net/nfp/nfp_net.c +0 -163

196 lines not on this page · raw message

drivers/net/octeontx/octeontx_ethdev.c +5 -67

117 lines not on this page · raw message

drivers/net/sfc/sfc_ethdev.c +7 -2
index e42d553..fc2b254 100644
@@ -413,14 +413,16 @@ sfc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	int rc;
+	uint64_t offloads;
 
 	sfc_log_init(sa, "RxQ=%u nb_rx_desc=%u socket_id=%u",
 		     rx_queue_id, nb_rx_desc, socket_id);
 
 	sfc_adapter_lock(sa);
 
+	offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
 	rc = sfc_rx_qinit(sa, rx_queue_id, nb_rx_desc, socket_id,
-			  rx_conf, mb_pool);
+			  rx_conf, mb_pool, offloads);
 	if (rc != 0)
 		goto fail_rx_qinit;
 
@@ -469,13 +471,16 @@ sfc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	int rc;
+	uint64_t offloads;
 
 	sfc_log_init(sa, "TxQ = %u, nb_tx_desc = %u, socket_id = %u",
 		     tx_queue_id, nb_tx_desc, socket_id);
 
 	sfc_adapter_lock(sa);
 
-	rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id, tx_conf);
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+	rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id,
+			  tx_conf, offloads);
 	if (rc != 0)
 		goto fail_tx_qinit;
 
drivers/net/sfc/sfc_rx.c +9 -33

86 lines not on this page · raw message

drivers/net/sfc/sfc_rx.h +2 -1
index 3fba7d8..2898fe5 100644
@@ -138,7 +138,8 @@ void sfc_rx_stop(struct sfc_adapter *sa);
 int sfc_rx_qinit(struct sfc_adapter *sa, unsigned int rx_queue_id,
 		 uint16_t nb_rx_desc, unsigned int socket_id,
 		 const struct rte_eth_rxconf *rx_conf,
-		 struct rte_mempool *mb_pool);
+		 struct rte_mempool *mb_pool,
+		 uint64_t offloads);
 void sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
drivers/net/sfc/sfc_tx.c +9 -33

83 lines not on this page · raw message

drivers/net/sfc/sfc_tx.h +2 -1
index c2e5f13..d2b2c4d 100644
@@ -121,7 +121,8 @@ void sfc_tx_close(struct sfc_adapter *sa);
 
 int sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 		 uint16_t nb_tx_desc, unsigned int socket_id,
-		 const struct rte_eth_txconf *tx_conf);
+		 const struct rte_eth_txconf *tx_conf,
+		 uint64_t offloads);
 void sfc_tx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 
 void sfc_tx_qflush_done(struct sfc_txq *txq);
drivers/net/tap/rte_eth_tap.c +8 -80

123 lines not on this page · raw message

drivers/net/thunderx/nicvf_ethdev.c +8 -62

122 lines not on this page · raw message

drivers/net/virtio/virtio_rxtx.c +2 -7
index a8aa87b..92fab21 100644
@@ -385,10 +385,9 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
 			uint16_t queue_idx,
 			uint16_t nb_desc,
 			unsigned int socket_id __rte_unused,
-			const struct rte_eth_rxconf *rx_conf,
+			const struct rte_eth_rxconf *rx_conf __rte_unused,
 			struct rte_mempool *mp)
 {
-	const struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 	uint16_t vtpci_queue_idx = 2 * queue_idx + VTNET_SQ_RQ_QUEUE_IDX;
 	struct virtio_hw *hw = dev->data->dev_private;
 	struct virtqueue *vq = hw->vqs[vtpci_queue_idx];
@@ -408,10 +407,6 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
 			"Cannot allocate mbufs for rx virtqueue");
 	}
 
-	if ((rx_conf->offloads ^ rxmode->offloads) &
-	    VIRTIO_PMD_PER_DEVICE_RX_OFFLOADS)
-		return -EINVAL;
-
 	dev->data->rx_queues[queue_idx] = rxvq;
 
 	return 0;
@@ -504,7 +499,7 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	PMD_INIT_FUNC_TRACE();
 
 	/* cannot use simple rxtx funcs with multisegs or offloads */
-	if (tx_conf->offloads)
+	if (dev->data->dev_conf.txmode.offloads)
 		hw->use_simple_tx = 0;
 
 	if (nb_desc == 0 || nb_desc > vq->vq_nentries)
drivers/net/vmxnet3/vmxnet3_ethdev.c +0 -16
index c850241..ba932ff 100644
@@ -393,25 +393,9 @@ vmxnet3_dev_configure(struct rte_eth_dev *dev)
 	const struct rte_memzone *mz;
 	struct vmxnet3_hw *hw = dev->data->dev_private;
 	size_t size;
-	uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
-	if ((rx_offloads & VMXNET3_RX_OFFLOAD_CAP) != rx_offloads) {
-		RTE_LOG(ERR, PMD, "Requested RX offloads 0x%" PRIx64
-			" do not match supported 0x%" PRIx64,
-			rx_offloads, (uint64_t)VMXNET3_RX_OFFLOAD_CAP);
-		return -ENOTSUP;
-	}
-
-	if ((tx_offloads & VMXNET3_TX_OFFLOAD_CAP) != tx_offloads) {
-		RTE_LOG(ERR, PMD, "Requested TX offloads 0x%" PRIx64
-			" do not match supported 0x%" PRIx64,
-			tx_offloads, (uint64_t)VMXNET3_TX_OFFLOAD_CAP);
-		return -ENOTSUP;
-	}
-
 	if (dev->data->nb_tx_queues > VMXNET3_MAX_TX_QUEUES ||
 	    dev->data->nb_rx_queues > VMXNET3_MAX_RX_QUEUES) {
 		PMD_INIT_LOG(ERR, "ERROR: Number of queues not supported");
drivers/net/vmxnet3/vmxnet3_rxtx.c +1 -7
index f6e2d98..cf85f3d 100644
@@ -1013,7 +1013,7 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
 			   uint16_t queue_idx,
 			   uint16_t nb_desc,
 			   unsigned int socket_id,
-			   const struct rte_eth_txconf *tx_conf)
+			   const struct rte_eth_txconf *tx_conf __rte_unused)
 {
 	struct vmxnet3_hw *hw = dev->data->dev_private;
 	const struct rte_memzone *mz;
@@ -1025,12 +1025,6 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
 
 	PMD_INIT_FUNC_TRACE();
 
-	if ((tx_conf->txq_flags & ETH_TXQ_FLAGS_NOXSUMSCTP) !=
-	    ETH_TXQ_FLAGS_NOXSUMSCTP) {
-		PMD_INIT_LOG(ERR, "SCTP checksum offload not supported");
-		return -EINVAL;
-	}
-
 	txq = rte_zmalloc("ethdev_tx_queue", sizeof(struct vmxnet3_tx_queue),
 			  RTE_CACHE_LINE_SIZE);
 	if (txq == NULL) {
lib/librte_ethdev/rte_ethdev.c +88 -0

106 lines not on this page · raw message

Signature · 1 line
2.7.5
#28 lore raw

Re: [PATCH v8] ethdev: check Rx/Tx offloads

On 05/08/2018 01:05 PM, Wei Dai wrote:

[...]

Quoted 8 lines

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

It looks like I've missed why PMDs should be updated to add device offloads to per-queue offloads. Cannot it be done on ethdev layer? PMD still can find out which offloads were enabled on device level by checking [rt]xmode->offlaods.

Quoted 3 lines

[...]

#29 lore raw

Re: [PATCH v8] ethdev: check Rx/Tx offloads

Quoted 13 lines · Andrew Rybchenko

On 05/08/2018 01:05 PM, Wei Dai wrote:

[...]

Quoted 8 lines

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

Quoted 5 lines

It looks like I've missed why PMDs should be updated to add device offloads to per-queue offloads. Cannot it be done on ethdev layer? PMD still can find out which offloads were enabled on device level by checking [rt]xmode->offlaods.

The stripping [rt]xconf->offloads part added into ethdev layer. This changed the input set to the PMDs.

Above coded added to keep the input same for the PMDs. Expectation is later PMD update its code to use new input and remove this update.

Quoted 7 lines
Quoted 4 lines

[...]

#30 lore raw

Re: [PATCH v8] ethdev: check Rx/Tx offloads

Quoted 18 lines · Ferruh Yigit
Quoted 12 lines · Andrew Rybchenko

On 05/08/2018 01:05 PM, Wei Dai wrote:

[...]

Quoted 8 lines

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

Quoted 5 lines

It looks like I've missed why PMDs should be updated to add device offloads to per-queue offloads. Cannot it be done on ethdev layer? PMD still can find out which offloads were enabled on device level by checking [rt]xmode->offlaods.

Quoted 5 lines

The stripping [rt]xconf->offloads part added into ethdev layer. This changed the input set to the PMDs.

Above coded added to keep the input same for the PMDs. Expectation is later PMD update its code to use new input and remove this update.

Thanks Ferruh. I read code too fast and lost it from my view. I'll provide more review notes related to net/sfc.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

[...]

#31 lore raw

Re: [PATCH v8] ethdev: check Rx/Tx offloads

In reply to Wei Dai
Quoted 40 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise return error.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

[...]

Quoted 6 lines
drivers/net/sfc/sfc_ethdev.c +0 -0
index e42d553..fc2b254 100644
@@ -413,14 +413,16 @@ sfc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
  {

drivers/net/sfc/sfc_ethdev.c sfc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, · line 423

Quoted 10 lines
drivers/net/sfc/sfc_ethdev.c +2 -0
  	struct sfc_adapter *sa = dev->data->dev_private;
  	int rc;
+	uint64_t offloads;
 
  	sfc_log_init(sa, "RxQ=%u nb_rx_desc=%u socket_id=%u",
  		     rx_queue_id, nb_rx_desc, socket_id);
 
  	sfc_adapter_lock(sa);
 
+	offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;

I'd prefer to see it inside sfc_rx_qinit() function. It would allow to avoid sfc_rx_qinit() function prototype changes.

Quoted 9 lines
drivers/net/sfc/sfc_ethdev.c +1 -1
  	rc = sfc_rx_qinit(sa, rx_queue_id, nb_rx_desc, socket_id,
-			  rx_conf, mb_pool);
+			  rx_conf, mb_pool, offloads);
  	if (rc != 0)
  		goto fail_rx_qinit;
 
@@ -469,13 +471,16 @@ sfc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
  {
  	struct sfc_adapter *sa = dev->data->dev_private;

drivers/net/sfc/sfc_ethdev.c sfc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, · line 481

Quoted 10 lines
drivers/net/sfc/sfc_ethdev.c +2 -1
  	int rc;
+	uint64_t offloads;
 
  	sfc_log_init(sa, "TxQ = %u, nb_tx_desc = %u, socket_id = %u",
  		     tx_queue_id, nb_tx_desc, socket_id);
 
  	sfc_adapter_lock(sa);
 
-	rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id, tx_conf);
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;

Same as above.

drivers/net/sfc/sfc_ethdev.c sfc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, · line 485

Quoted 4 lines
drivers/net/sfc/sfc_ethdev.c +2 -0
+	rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id,
+			  tx_conf, offloads);
  	if (rc != 0)
  		goto fail_tx_qinit;

[...]

It looks like device level offloads are checked on ethdev layer now. So, I think check in sfc_rx_check_mode() and sfc_tx_check_mode() may be removed as well (see offloads_rejected).
I think it will make functions sfc_rx_log_offloads() and sfc_tx_log_offloads() unused and these functions should be removed.

author
#32 lore raw

Re: [PATCH v8] ethdev: check Rx/Tx offloads

Hi, Andrew
See my in-line comments as below.

From: Andrew Rybchenko [mailto:[email protected]]
Sent: Tuesday, May 8, 2018 7:37 PM
To: Dai, Wei <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]; Doherty, Declan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Lu, Wenzhuo <[email protected]>; Ananyev, Konstantin <[email protected]>; Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>; Wang, Xiao W <[email protected]>; Wu, Jingjing <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Bie, Tiwei <[email protected]>; Legacy, Allain (Wind River) <[email protected]>; Peters, Matt (Wind River) <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; Singh, Jasvinder <[email protected]>; Dumitrescu, Cristian <[email protected]>
Cc: [email protected]; Ivan Malov <[email protected]>
Subject: Re: [PATCH v8] ethdev: check Rx/Tx offloads

On 05/08/2018 01:05 PM, Wei Dai wrote:
This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise return error.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

[...]

drivers/net/sfc/sfc_ethdev.c +2 -0
index e42d553..fc2b254 100644
@@ -413,14 +413,16 @@ sfc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	int rc;
+	uint64_t offloads;
 
 	sfc_log_init(sa, "RxQ=%u nb_rx_desc=%u socket_id=%u",
 		     rx_queue_id, nb_rx_desc, socket_id);
 
 	sfc_adapter_lock(sa);
 
+	offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
 

I'd prefer to see it inside sfc_rx_qinit() function. It would allow to avoid sfc_rx_qinit() function prototype changes.
[Wei: As rx_conf is a const argument in sfc_rx_queue_setup( ), rx_conf->offloads can't be updated.
If sfc_rx_qinit( ) function prototype keep unchanged, the dev->data can be deduced from the
1st argument sa . Andrew, if my code works well, can it be kept here, you can change it later in your separate patch, OK ? ]

rc = sfc_rx_qinit(sa, rx_queue_id, nb_rx_desc, socket_id,
- rx_conf, mb_pool);
+ rx_conf, mb_pool, offloads);
if (rc != 0)
goto fail_rx_qinit;

@@ -469,13 +471,16 @@ sfc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
{
struct sfc_adapter *sa = dev->data->dev_private;
int rc;
+ uint64_t offloads;

sfc_log_init(sa, "TxQ = %u, nb_tx_desc = %u, socket_id = %u",
tx_queue_id, nb_tx_desc, socket_id);

sfc_adapter_lock(sa);

- rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id, tx_conf);
+ offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;

Same as above.

+ rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id,
+ tx_conf, offloads);
if (rc != 0)
goto fail_tx_qinit;

[...]

It looks like device level offloads are checked on ethdev layer now.
So, I think check in sfc_rx_check_mode () and sfc_tx_check_mode()
may be removed as well (see offloads_rejected).
I think it will make functions sfc_rx_log_offloads() and
sfc_tx_log_offloads() unused and these functions should be removed.
[Wei: sorry, I miss the sf_[rt]x_check_mode( ). Yes, offloads_rejected in this function checking can be removed.
But as this patch is a big one, I'd like it keep as it is if it works well. And I'd like you remove such checking or
do other changes in your own patch]
[Wei: by the way, your mail is HTML format, I am afraid it is missed from mail archives.]

Reviewed-by on v8 1/1
#33 lore raw

Re: [PATCH v8] ethdev: check Rx/Tx offloads

In reply to Wei Dai
Quoted 97 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise return error.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

---
v8:
Revise PMD codes to comply with offload API in v7
update document

v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer. Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 doc/guides/prog_guide/poll_mode_drv.rst |  26 +++--
 doc/guides/rel_notes/release_18_05.rst  |   8 ++
 drivers/net/avf/avf_rxtx.c              |   5 +-
 drivers/net/bnxt/bnxt_ethdev.c          |  17 ----
 drivers/net/cxgbe/cxgbe_ethdev.c        |  50 +---------
 drivers/net/dpaa/dpaa_ethdev.c          |  16 ----
 drivers/net/dpaa2/dpaa2_ethdev.c        |  16 ----
 drivers/net/e1000/em_ethdev.c           |  19 ----
 drivers/net/e1000/em_rxtx.c             |  64 ++-----------
 drivers/net/e1000/igb_rxtx.c            |  64 ++-----------
 drivers/net/ena/ena_ethdev.c            |  65 +------------
 drivers/net/failsafe/failsafe_ops.c     |  81 ----------------
 drivers/net/fm10k/fm10k_ethdev.c        |  82 ++--------------
 drivers/net/i40e/i40e_rxtx.c            |  58 ++----------
 drivers/net/ixgbe/ixgbe_ethdev.c        |  38 --------
 drivers/net/ixgbe/ixgbe_rxtx.c          |  66 ++-----------
 drivers/net/mlx4/mlx4_rxq.c             |  43 ++-------
 drivers/net/mlx4/mlx4_txq.c             |  42 ++------
 drivers/net/mlx5/mlx5_ethdev.c          |  22 -----
 drivers/net/mlx5/mlx5_rxq.c             |  50 ++--------
 drivers/net/mlx5/mlx5_txq.c             |  44 +--------
 drivers/net/mvpp2/mrvl_ethdev.c         |  97 +------------------
 drivers/net/nfp/nfp_net.c               | 163 --------------------------------
 drivers/net/octeontx/octeontx_ethdev.c  |  72 +-------------
 drivers/net/sfc/sfc_ethdev.c            |   9 +-
 drivers/net/sfc/sfc_rx.c                |  42 ++------
 drivers/net/sfc/sfc_rx.h                |   3 +-
 drivers/net/sfc/sfc_tx.c                |  42 ++------
Quoted 8 lines
 drivers/net/sfc/sfc_tx.h                |   3 +-
 drivers/net/tap/rte_eth_tap.c           |  88 ++---------------
 drivers/net/thunderx/nicvf_ethdev.c     |  70 ++------------
 drivers/net/virtio/virtio_rxtx.c        |   9 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c    |  16 ----
 drivers/net/vmxnet3/vmxnet3_rxtx.c      |   8 +-
 lib/librte_ethdev/rte_ethdev.c          |  88 +++++++++++++++++
 35 files changed, 240 insertions(+), 1346 deletions(-)

Hi Wei,

Thanks for this patch. Lets wait one more day for PMD owners to test the patch, if there is no objection patch targets rc3 which is a few days away.

author
#34 lore raw

Re: [PATCH v8] ethdev: check Rx/Tx offloads

Quoted 141 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, May 8, 2018 8:13 PM
To: Dai, Wei <[email protected]>; [email protected]; Doherty, Declan <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Lu, Wenzhuo <[email protected]>; Ananyev, Konstantin <[email protected]>; Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>; Wang, Xiao W <[email protected]>; Wu, Jingjing <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Bie, Tiwei <[email protected]>; Legacy, Allain (Wind River) <[email protected]>; Peters, Matt (Wind River) <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; Singh, Jasvinder <[email protected]>; Dumitrescu, Cristian <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v8] ethdev: check Rx/Tx offloads

Quoted 82 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise return error.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

---
v8:
Revise PMD codes to comply with offload API in v7 update document

v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer.
Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 doc/guides/prog_guide/poll_mode_drv.rst |  26 +++--
 doc/guides/rel_notes/release_18_05.rst  |   8 ++
 drivers/net/avf/avf_rxtx.c              |   5 +-
 drivers/net/bnxt/bnxt_ethdev.c          |  17 ----
 drivers/net/cxgbe/cxgbe_ethdev.c        |  50 +---------
 drivers/net/dpaa/dpaa_ethdev.c          |  16 ----
 drivers/net/dpaa2/dpaa2_ethdev.c        |  16 ----
 drivers/net/e1000/em_ethdev.c           |  19 ----
 drivers/net/e1000/em_rxtx.c             |  64 ++-----------
 drivers/net/e1000/igb_rxtx.c            |  64 ++-----------
 drivers/net/ena/ena_ethdev.c            |  65 +------------
 drivers/net/failsafe/failsafe_ops.c     |  81 ----------------
 drivers/net/fm10k/fm10k_ethdev.c        |  82 ++--------------
 drivers/net/i40e/i40e_rxtx.c            |  58 ++----------
 drivers/net/ixgbe/ixgbe_ethdev.c        |  38 --------
Quoted 8 lines
 drivers/net/ixgbe/ixgbe_rxtx.c          |  66 ++-----------
 drivers/net/mlx4/mlx4_rxq.c             |  43 ++-------
 drivers/net/mlx4/mlx4_txq.c             |  42 ++------
 drivers/net/mlx5/mlx5_ethdev.c          |  22 -----
 drivers/net/mlx5/mlx5_rxq.c             |  50 ++--------
 drivers/net/mlx5/mlx5_txq.c             |  44 +--------
 drivers/net/mvpp2/mrvl_ethdev.c         |  97 +------------------
 drivers/net/nfp/nfp_net.c               | 163

--------------------------------

Quoted 5 lines
 drivers/net/octeontx/octeontx_ethdev.c  |  72 +-------------
 drivers/net/sfc/sfc_ethdev.c            |   9 +-
 drivers/net/sfc/sfc_rx.c                |  42 ++------
 drivers/net/sfc/sfc_rx.h                |   3 +-
 drivers/net/sfc/sfc_tx.c                |  42 ++------
Quoted 8 lines
 drivers/net/sfc/sfc_tx.h                |   3 +-
 drivers/net/tap/rte_eth_tap.c           |  88 ++---------------
 drivers/net/thunderx/nicvf_ethdev.c     |  70 ++------------
 drivers/net/virtio/virtio_rxtx.c        |   9 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c    |  16 ----
 drivers/net/vmxnet3/vmxnet3_rxtx.c      |   8 +-
 lib/librte_ethdev/rte_ethdev.c          |  88 +++++++++++++++++
 35 files changed, 240 insertions(+), 1346 deletions(-)
Quoted 7 lines

Hi Wei,

Thanks for this patch. Lets wait one more day for PMD owners to test the patch, if there is no objection patch targets rc3 which is a few days away.

This patch is created on base of 18.05-rc2.
So it may fail to be applied to some -next repositories.

author
#35 lore raw

PATCH v9 1/1 ethdev: new Rx/Tx offloads API

In reply to Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise triger an error log.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

---
v9:
replace RTE_PMD_DEBUG_TRACE with ethdev_log(ERR, in ethdev to avoid failure of application which hasn't been completely converted to new offload API.

v8:
Revise PMD codes to comply with offload API in v7
update document

v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer. Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 doc/guides/prog_guide/poll_mode_drv.rst |  26 +++--
 doc/guides/rel_notes/release_18_05.rst  |   8 ++
 drivers/net/avf/avf_rxtx.c              |   5 +-
 drivers/net/bnxt/bnxt_ethdev.c          |  17 ----
 drivers/net/cxgbe/cxgbe_ethdev.c        |  50 +---------
 drivers/net/dpaa/dpaa_ethdev.c          |  16 ----
 drivers/net/dpaa2/dpaa2_ethdev.c        |  16 ----
 drivers/net/e1000/em_ethdev.c           |  19 ----
 drivers/net/e1000/em_rxtx.c             |  64 ++-----------
 drivers/net/e1000/igb_rxtx.c            |  64 ++-----------
 drivers/net/ena/ena_ethdev.c            |  65 +------------
 drivers/net/failsafe/failsafe_ops.c     |  81 ----------------
 drivers/net/fm10k/fm10k_ethdev.c        |  82 ++--------------
 drivers/net/i40e/i40e_rxtx.c            |  58 ++----------
 drivers/net/ixgbe/ixgbe_ethdev.c        |  38 --------
 drivers/net/ixgbe/ixgbe_rxtx.c          |  66 ++-----------
 drivers/net/mlx4/mlx4_rxq.c             |  43 ++-------
 drivers/net/mlx4/mlx4_txq.c             |  42 ++------
 drivers/net/mlx5/mlx5_ethdev.c          |  22 -----
 drivers/net/mlx5/mlx5_rxq.c             |  50 ++--------
 drivers/net/mlx5/mlx5_txq.c             |  44 +--------
 drivers/net/mvpp2/mrvl_ethdev.c         |  97 +------------------
 drivers/net/nfp/nfp_net.c               | 163 --------------------------------
 drivers/net/octeontx/octeontx_ethdev.c  |  72 +-------------
 drivers/net/sfc/sfc_ethdev.c            |   9 +-
 drivers/net/sfc/sfc_rx.c                |  42 ++------
 drivers/net/sfc/sfc_rx.h                |   3 +-
 drivers/net/sfc/sfc_tx.c                |  42 ++------
 drivers/net/sfc/sfc_tx.h                |   3 +-
 drivers/net/tap/rte_eth_tap.c           |  88 ++---------------
 drivers/net/thunderx/nicvf_ethdev.c     |  70 ++------------
 drivers/net/virtio/virtio_rxtx.c        |   9 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c    |  16 ----
 drivers/net/vmxnet3/vmxnet3_rxtx.c      |   8 +-
 lib/librte_ethdev/rte_ethdev.c          |  86 +++++++++++++++++
 35 files changed, 238 insertions(+), 1346 deletions(-)
doc/guides/prog_guide/poll_mode_drv.rst +20 -6
index 09a93ba..56483fb 100644
@@ -297,16 +297,30 @@ Per-Port and Per-Queue Offloads
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 In the DPDK offload API, offloads are divided into per-port and per-queue offloads.
+A per-queue offloading can be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offloading must be enabled or disabled on all queues at the same time.
+A per-port offloading can be enabled or disabled on all queues at the same time.
+It is certain that both per-queue and pure per-port offloading are per-port type.
 The different offloads capabilities can be queried using ``rte_eth_dev_info_get()``.
+The dev_info->[rt]x_queue_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.
+The dev_info->[rt]x_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.
 Supported offloads can be either per-port or per-queue.
 
 Offloads are enabled using the existing ``DEV_TX_OFFLOAD_*`` or ``DEV_RX_OFFLOAD_*`` flags.
-Per-port offload configuration is set using ``rte_eth_dev_configure``.
-Per-queue offload configuration is set using ``rte_eth_rx_queue_setup`` and ``rte_eth_tx_queue_setup``.
-To enable per-port offload, the offload should be set on both device configuration and queue setup.
-In case of a mixed configuration the queue setup shall return with an error.
-To enable per-queue offload, the offload can be set only on the queue setup.
-Offloads which are not enabled are disabled by default.
+Any requested offloading by application must be within the device capabilities.
+Any offloading is disabled by default if it is not set in the parameter
+dev_conf->[rt]xmode.offloads to ``rte_eth_dev_configure( )`` and
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )``.
+If any offloading is enabled in ``rte_eth_dev_configure( )`` by application,
+it is enabled on all queues no matter whether it is per-queue or
+per-port type and no matter whether it is set or cleared in
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )``.
+If a per-queue offloading hasn't been enabled in ``rte_eth_dev_configure( )``,
+it can be enabled or disabled in ``rte_eth_[rt]x_queue_setup( )`` for individual queue.
+A new added offloads in [rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )`` input by application
+is the one which hasn't been enabled in ``rte_eth_dev_configure( )`` and is requested to be enabled
+in ``rte_eth_[rt]x_queue_setup( )``, it must be per-queue type, otherwise return error.
 
 For an application to use the Tx offloads API it should set the ``ETH_TXQ_FLAGS_IGNORE`` flag in the ``txq_flags`` field located in ``rte_eth_txconf`` struct.
 In such cases it is not required to set other flags in ``txq_flags``.
doc/guides/rel_notes/release_18_05.rst +8 -0
index 0ae61e8..637e684 100644
@@ -303,6 +303,14 @@ API Changes
   * ``rte_flow_create()`` API count action now requires the ``struct rte_flow_action_count``.
   * ``rte_flow_query()`` API parameter changed from action type to action structure.
 
+* **ethdev: changes to offload API**
+
+   A pure per-port offloading isn't requested to be repeated in [rt]x_conf->offloads to
+   ``rte_eth_[rt]x_queue_setup( )``. Now any offloading enabled in ``rte_eth_dev_configure( )``
+   can't be disabled by ``rte_eth_[rt]x_queue_setup( )``. Any new added offloading which has
+   not been enabled in ``rte_eth_dev_configure( )`` and is requested to be enabled in
+   ``rte_eth_[rt]x_queue_setup( )`` must be per-queue type, otherwise return error.
+
 
 ABI Changes
 -----------
drivers/net/avf/avf_rxtx.c +4 -1
index 1824ed7..e03a136 100644
@@ -435,9 +435,12 @@ avf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	uint32_t ring_size;
 	uint16_t tx_rs_thresh, tx_free_thresh;
 	uint16_t i, base, bsf, tc_mapping;
+	uint64_t offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+
 	if (nb_desc % AVF_ALIGN_RING_DESC != 0 ||
 	    nb_desc > AVF_MAX_RING_DESC ||
 	    nb_desc < AVF_MIN_RING_DESC) {
@@ -474,7 +477,7 @@ avf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->free_thresh = tx_free_thresh;
 	txq->queue_id = queue_idx;
 	txq->port_id = dev->data->port_id;
-	txq->offloads = tx_conf->offloads;
+	txq->offloads = offloads;
 	txq->tx_deferred_start = tx_conf->tx_deferred_start;
 
 	/* Allocate software ring */
drivers/net/bnxt/bnxt_ethdev.c +0 -17
index 348129d..d00b99f 100644
@@ -500,25 +500,8 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
 static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
-	uint64_t tx_offloads = eth_dev->data->dev_conf.txmode.offloads;
 	uint64_t rx_offloads = eth_dev->data->dev_conf.rxmode.offloads;
 
-	if (tx_offloads != (tx_offloads & BNXT_DEV_TX_OFFLOAD_SUPPORT)) {
-		PMD_DRV_LOG
-			(ERR,
-			 "Tx offloads requested 0x%" PRIx64 " supported 0x%x\n",
-			 tx_offloads, BNXT_DEV_TX_OFFLOAD_SUPPORT);
-		return -ENOTSUP;
-	}
-
-	if (rx_offloads != (rx_offloads & BNXT_DEV_RX_OFFLOAD_SUPPORT)) {
-		PMD_DRV_LOG
-			(ERR,
-			 "Rx offloads requested 0x%" PRIx64 " supported 0x%x\n",
-			    rx_offloads, BNXT_DEV_RX_OFFLOAD_SUPPORT);
-		return -ENOTSUP;
-	}
-
 	bp->rx_queues = (void *)eth_dev->data->rx_queues;
 	bp->tx_queues = (void *)eth_dev->data->tx_queues;
 
drivers/net/cxgbe/cxgbe_ethdev.c +5 -45

86 lines not on this page · raw message

drivers/net/dpaa/dpaa_ethdev.c +0 -16
index 6bf8c15..199afdd 100644
@@ -176,14 +176,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* Rx offloads validation */
-	if (~(dev_rx_offloads_sup | dev_rx_offloads_nodis) & rx_offloads) {
-		DPAA_PMD_ERR(
-		"Rx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			rx_offloads,
-			dev_rx_offloads_sup | dev_rx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_rx_offloads_nodis & ~rx_offloads) {
 		DPAA_PMD_WARN(
 		"Rx offloads non configurable - requested 0x%" PRIx64
@@ -192,14 +184,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
 	}
 
 	/* Tx offloads validation */
-	if (~(dev_tx_offloads_sup | dev_tx_offloads_nodis) & tx_offloads) {
-		DPAA_PMD_ERR(
-		"Tx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			tx_offloads,
-			dev_tx_offloads_sup | dev_tx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_tx_offloads_nodis & ~tx_offloads) {
 		DPAA_PMD_WARN(
 		"Tx offloads non configurable - requested 0x%" PRIx64
drivers/net/dpaa2/dpaa2_ethdev.c +0 -16
index c304b82..de8d83a 100644
@@ -309,14 +309,6 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* Rx offloads validation */
-	if (~(dev_rx_offloads_sup | dev_rx_offloads_nodis) & rx_offloads) {
-		DPAA2_PMD_ERR(
-		"Rx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			rx_offloads,
-			dev_rx_offloads_sup | dev_rx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_rx_offloads_nodis & ~rx_offloads) {
 		DPAA2_PMD_WARN(
 		"Rx offloads non configurable - requested 0x%" PRIx64
@@ -325,14 +317,6 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 	}
 
 	/* Tx offloads validation */
-	if (~(dev_tx_offloads_sup | dev_tx_offloads_nodis) & tx_offloads) {
-		DPAA2_PMD_ERR(
-		"Tx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			tx_offloads,
-			dev_tx_offloads_sup | dev_tx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_tx_offloads_nodis & ~tx_offloads) {
 		DPAA2_PMD_WARN(
 		"Tx offloads non configurable - requested 0x%" PRIx64
drivers/net/e1000/em_ethdev.c +0 -19
index 694a624..4e890ad 100644
@@ -454,29 +454,10 @@ eth_em_configure(struct rte_eth_dev *dev)
 {
 	struct e1000_interrupt *intr =
 		E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 
 	PMD_INIT_FUNC_TRACE();
 	intr->flags |= E1000_FLAG_NEED_LINK_UPDATE;
 
-	eth_em_infos_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	PMD_INIT_FUNC_TRACE();
 
 	return 0;
drivers/net/e1000/em_rxtx.c +6 -58

106 lines not on this page · raw message

drivers/net/e1000/igb_rxtx.c +6 -58

102 lines not on this page · raw message

drivers/net/ena/ena_ethdev.c +4 -61

113 lines not on this page · raw message

drivers/net/failsafe/failsafe_ops.c +0 -81

115 lines not on this page · raw message

drivers/net/fm10k/fm10k_ethdev.c +8 -74

135 lines not on this page · raw message

drivers/net/i40e/i40e_rxtx.c +6 -52

96 lines not on this page · raw message

drivers/net/ixgbe/ixgbe_ethdev.c +0 -38
index 91179e9..320ab21 100644
@@ -2365,9 +2365,6 @@ ixgbe_dev_configure(struct rte_eth_dev *dev)
 		IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
 	struct ixgbe_adapter *adapter =
 		(struct ixgbe_adapter *)dev->data->dev_private;
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 	int ret;
 
 	PMD_INIT_FUNC_TRACE();
@@ -2379,22 +2376,6 @@ ixgbe_dev_configure(struct rte_eth_dev *dev)
 		return ret;
 	}
 
-	ixgbe_dev_info_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	/* set flag to update link status after init */
 	intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
 
@@ -4965,29 +4946,10 @@ ixgbevf_dev_configure(struct rte_eth_dev *dev)
 	struct rte_eth_conf *conf = &dev->data->dev_conf;
 	struct ixgbe_adapter *adapter =
 			(struct ixgbe_adapter *)dev->data->dev_private;
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 
 	PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
 		     dev->data->port_id);
 
-	ixgbevf_dev_info_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	/*
 	 * VF has no ability to enable/disable HW CRC
 	 * Keep the persistent behavior the same as Host PF
drivers/net/ixgbe/ixgbe_rxtx.c +6 -60

110 lines not on this page · raw message

drivers/net/mlx4/mlx4_rxq.c +8 -35

77 lines not on this page · raw message

drivers/net/mlx4/mlx4_txq.c +6 -36

66 lines not on this page · raw message

drivers/net/mlx5/mlx5_ethdev.c +0 -22
index 746b94f..df369cd 100644
@@ -330,30 +330,8 @@ mlx5_dev_configure(struct rte_eth_dev *dev)
 	unsigned int reta_idx_n;
 	const uint8_t use_app_rss_key =
 		!!dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key;
-	uint64_t supp_tx_offloads = mlx5_get_tx_port_offloads(dev);
-	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
-	uint64_t supp_rx_offloads =
-		(mlx5_get_rx_port_offloads() |
-		 mlx5_get_rx_queue_offloads(dev));
-	uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
 	int ret = 0;
 
-	if ((tx_offloads & supp_tx_offloads) != tx_offloads) {
-		DRV_LOG(ERR,
-			"port %u some Tx offloads are not supported requested"
-			" 0x%" PRIx64 " supported 0x%" PRIx64,
-			dev->data->port_id, tx_offloads, supp_tx_offloads);
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
-	if ((rx_offloads & supp_rx_offloads) != rx_offloads) {
-		DRV_LOG(ERR,
-			"port %u some Rx offloads are not supported requested"
-			" 0x%" PRIx64 " supported 0x%" PRIx64,
-			dev->data->port_id, rx_offloads, supp_rx_offloads);
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
 	if (use_app_rss_key &&
 	    (dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len !=
 	     rss_hash_default_key_len)) {
drivers/net/mlx5/mlx5_rxq.c +7 -43

82 lines not on this page · raw message

drivers/net/mlx5/mlx5_txq.c +2 -42

62 lines not on this page · raw message

drivers/net/mvpp2/mrvl_ethdev.c +3 -94

139 lines not on this page · raw message

drivers/net/nfp/nfp_net.c +0 -163

196 lines not on this page · raw message

drivers/net/octeontx/octeontx_ethdev.c +5 -67

117 lines not on this page · raw message

drivers/net/sfc/sfc_ethdev.c +7 -2
index e42d553..fc2b254 100644
@@ -413,14 +413,16 @@ sfc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	int rc;
+	uint64_t offloads;
 
 	sfc_log_init(sa, "RxQ=%u nb_rx_desc=%u socket_id=%u",
 		     rx_queue_id, nb_rx_desc, socket_id);
 
 	sfc_adapter_lock(sa);
 
+	offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
 	rc = sfc_rx_qinit(sa, rx_queue_id, nb_rx_desc, socket_id,
-			  rx_conf, mb_pool);
+			  rx_conf, mb_pool, offloads);
 	if (rc != 0)
 		goto fail_rx_qinit;
 
@@ -469,13 +471,16 @@ sfc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	int rc;
+	uint64_t offloads;
 
 	sfc_log_init(sa, "TxQ = %u, nb_tx_desc = %u, socket_id = %u",
 		     tx_queue_id, nb_tx_desc, socket_id);
 
 	sfc_adapter_lock(sa);
 
-	rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id, tx_conf);
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+	rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id,
+			  tx_conf, offloads);
 	if (rc != 0)
 		goto fail_tx_qinit;
 
drivers/net/sfc/sfc_rx.c +9 -33

86 lines not on this page · raw message

drivers/net/sfc/sfc_rx.h +2 -1
index 3fba7d8..2898fe5 100644
@@ -138,7 +138,8 @@ void sfc_rx_stop(struct sfc_adapter *sa);
 int sfc_rx_qinit(struct sfc_adapter *sa, unsigned int rx_queue_id,
 		 uint16_t nb_rx_desc, unsigned int socket_id,
 		 const struct rte_eth_rxconf *rx_conf,
-		 struct rte_mempool *mb_pool);
+		 struct rte_mempool *mb_pool,
+		 uint64_t offloads);
 void sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
drivers/net/sfc/sfc_tx.c +9 -33

83 lines not on this page · raw message

drivers/net/sfc/sfc_tx.h +2 -1
index c2e5f13..d2b2c4d 100644
@@ -121,7 +121,8 @@ void sfc_tx_close(struct sfc_adapter *sa);
 
 int sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 		 uint16_t nb_tx_desc, unsigned int socket_id,
-		 const struct rte_eth_txconf *tx_conf);
+		 const struct rte_eth_txconf *tx_conf,
+		 uint64_t offloads);
 void sfc_tx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 
 void sfc_tx_qflush_done(struct sfc_txq *txq);
drivers/net/tap/rte_eth_tap.c +8 -80

123 lines not on this page · raw message

drivers/net/thunderx/nicvf_ethdev.c +8 -62

122 lines not on this page · raw message

drivers/net/virtio/virtio_rxtx.c +2 -7
index a8aa87b..92fab21 100644
@@ -385,10 +385,9 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
 			uint16_t queue_idx,
 			uint16_t nb_desc,
 			unsigned int socket_id __rte_unused,
-			const struct rte_eth_rxconf *rx_conf,
+			const struct rte_eth_rxconf *rx_conf __rte_unused,
 			struct rte_mempool *mp)
 {
-	const struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 	uint16_t vtpci_queue_idx = 2 * queue_idx + VTNET_SQ_RQ_QUEUE_IDX;
 	struct virtio_hw *hw = dev->data->dev_private;
 	struct virtqueue *vq = hw->vqs[vtpci_queue_idx];
@@ -408,10 +407,6 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
 			"Cannot allocate mbufs for rx virtqueue");
 	}
 
-	if ((rx_conf->offloads ^ rxmode->offloads) &
-	    VIRTIO_PMD_PER_DEVICE_RX_OFFLOADS)
-		return -EINVAL;
-
 	dev->data->rx_queues[queue_idx] = rxvq;
 
 	return 0;
@@ -504,7 +499,7 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	PMD_INIT_FUNC_TRACE();
 
 	/* cannot use simple rxtx funcs with multisegs or offloads */
-	if (tx_conf->offloads)
+	if (dev->data->dev_conf.txmode.offloads)
 		hw->use_simple_tx = 0;
 
 	if (nb_desc == 0 || nb_desc > vq->vq_nentries)
drivers/net/vmxnet3/vmxnet3_ethdev.c +0 -16
index c850241..ba932ff 100644
@@ -393,25 +393,9 @@ vmxnet3_dev_configure(struct rte_eth_dev *dev)
 	const struct rte_memzone *mz;
 	struct vmxnet3_hw *hw = dev->data->dev_private;
 	size_t size;
-	uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
-	if ((rx_offloads & VMXNET3_RX_OFFLOAD_CAP) != rx_offloads) {
-		RTE_LOG(ERR, PMD, "Requested RX offloads 0x%" PRIx64
-			" do not match supported 0x%" PRIx64,
-			rx_offloads, (uint64_t)VMXNET3_RX_OFFLOAD_CAP);
-		return -ENOTSUP;
-	}
-
-	if ((tx_offloads & VMXNET3_TX_OFFLOAD_CAP) != tx_offloads) {
-		RTE_LOG(ERR, PMD, "Requested TX offloads 0x%" PRIx64
-			" do not match supported 0x%" PRIx64,
-			tx_offloads, (uint64_t)VMXNET3_TX_OFFLOAD_CAP);
-		return -ENOTSUP;
-	}
-
 	if (dev->data->nb_tx_queues > VMXNET3_MAX_TX_QUEUES ||
 	    dev->data->nb_rx_queues > VMXNET3_MAX_RX_QUEUES) {
 		PMD_INIT_LOG(ERR, "ERROR: Number of queues not supported");
drivers/net/vmxnet3/vmxnet3_rxtx.c +1 -7
index f6e2d98..cf85f3d 100644
@@ -1013,7 +1013,7 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
 			   uint16_t queue_idx,
 			   uint16_t nb_desc,
 			   unsigned int socket_id,
-			   const struct rte_eth_txconf *tx_conf)
+			   const struct rte_eth_txconf *tx_conf __rte_unused)
 {
 	struct vmxnet3_hw *hw = dev->data->dev_private;
 	const struct rte_memzone *mz;
@@ -1025,12 +1025,6 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
 
 	PMD_INIT_FUNC_TRACE();
 
-	if ((tx_conf->txq_flags & ETH_TXQ_FLAGS_NOXSUMSCTP) !=
-	    ETH_TXQ_FLAGS_NOXSUMSCTP) {
-		PMD_INIT_LOG(ERR, "SCTP checksum offload not supported");
-		return -EINVAL;
-	}
-
 	txq = rte_zmalloc("ethdev_tx_queue", sizeof(struct vmxnet3_tx_queue),
 			  RTE_CACHE_LINE_SIZE);
 	if (txq == NULL) {
lib/librte_ethdev/rte_ethdev.c +86 -0

104 lines not on this page · raw message

Signature · 1 line
2.7.5
author
#36 lore raw

PATCH v10 1/1 ethdev: new Rx/Tx offloads API

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise triger an error log.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

---
v10:
sorry, miss the code change, fix the buidling error

v9:
replace RTE_PMD_DEBUG_TRACE with ethdev_log(ERR, in ethdev to avoid failure of application which hasn't been completely converted to new offload API.

v8:
Revise PMD codes to comply with offload API in v7
update document

v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer. Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 doc/guides/prog_guide/poll_mode_drv.rst |  26 +++--
 doc/guides/rel_notes/release_18_05.rst  |   8 ++
 drivers/net/avf/avf_rxtx.c              |   5 +-
 drivers/net/bnxt/bnxt_ethdev.c          |  17 ----
 drivers/net/cxgbe/cxgbe_ethdev.c        |  50 +---------
 drivers/net/dpaa/dpaa_ethdev.c          |  16 ----
 drivers/net/dpaa2/dpaa2_ethdev.c        |  16 ----
 drivers/net/e1000/em_ethdev.c           |  19 ----
 drivers/net/e1000/em_rxtx.c             |  64 ++-----------
 drivers/net/e1000/igb_rxtx.c            |  64 ++-----------
 drivers/net/ena/ena_ethdev.c            |  65 +------------
 drivers/net/failsafe/failsafe_ops.c     |  81 ----------------
 drivers/net/fm10k/fm10k_ethdev.c        |  82 ++--------------
 drivers/net/i40e/i40e_rxtx.c            |  58 ++----------
 drivers/net/ixgbe/ixgbe_ethdev.c        |  38 --------
 drivers/net/ixgbe/ixgbe_rxtx.c          |  66 ++-----------
 drivers/net/mlx4/mlx4_rxq.c             |  43 ++-------
 drivers/net/mlx4/mlx4_txq.c             |  42 ++------
 drivers/net/mlx5/mlx5_ethdev.c          |  22 -----
 drivers/net/mlx5/mlx5_rxq.c             |  50 ++--------
 drivers/net/mlx5/mlx5_txq.c             |  44 +--------
 drivers/net/mvpp2/mrvl_ethdev.c         |  97 +------------------
 drivers/net/nfp/nfp_net.c               | 163 --------------------------------
 drivers/net/octeontx/octeontx_ethdev.c  |  72 +-------------
 drivers/net/sfc/sfc_ethdev.c            |   9 +-
 drivers/net/sfc/sfc_rx.c                |  42 ++------
 drivers/net/sfc/sfc_rx.h                |   3 +-
 drivers/net/sfc/sfc_tx.c                |  42 ++------
 drivers/net/sfc/sfc_tx.h                |   3 +-
 drivers/net/tap/rte_eth_tap.c           |  88 ++---------------
 drivers/net/thunderx/nicvf_ethdev.c     |  70 ++------------
 drivers/net/virtio/virtio_rxtx.c        |   9 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c    |  16 ----
 drivers/net/vmxnet3/vmxnet3_rxtx.c      |   8 +-
 lib/librte_ethdev/rte_ethdev.c          |  86 +++++++++++++++++
 35 files changed, 238 insertions(+), 1346 deletions(-)
doc/guides/prog_guide/poll_mode_drv.rst +20 -6
index 09a93ba..56483fb 100644
@@ -297,16 +297,30 @@ Per-Port and Per-Queue Offloads
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 In the DPDK offload API, offloads are divided into per-port and per-queue offloads.
+A per-queue offloading can be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offloading must be enabled or disabled on all queues at the same time.
+A per-port offloading can be enabled or disabled on all queues at the same time.
+It is certain that both per-queue and pure per-port offloading are per-port type.
 The different offloads capabilities can be queried using ``rte_eth_dev_info_get()``.
+The dev_info->[rt]x_queue_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.
+The dev_info->[rt]x_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.
 Supported offloads can be either per-port or per-queue.
 
 Offloads are enabled using the existing ``DEV_TX_OFFLOAD_*`` or ``DEV_RX_OFFLOAD_*`` flags.
-Per-port offload configuration is set using ``rte_eth_dev_configure``.
-Per-queue offload configuration is set using ``rte_eth_rx_queue_setup`` and ``rte_eth_tx_queue_setup``.
-To enable per-port offload, the offload should be set on both device configuration and queue setup.
-In case of a mixed configuration the queue setup shall return with an error.
-To enable per-queue offload, the offload can be set only on the queue setup.
-Offloads which are not enabled are disabled by default.
+Any requested offloading by application must be within the device capabilities.
+Any offloading is disabled by default if it is not set in the parameter
+dev_conf->[rt]xmode.offloads to ``rte_eth_dev_configure( )`` and
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )``.
+If any offloading is enabled in ``rte_eth_dev_configure( )`` by application,
+it is enabled on all queues no matter whether it is per-queue or
+per-port type and no matter whether it is set or cleared in
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )``.
+If a per-queue offloading hasn't been enabled in ``rte_eth_dev_configure( )``,
+it can be enabled or disabled in ``rte_eth_[rt]x_queue_setup( )`` for individual queue.
+A new added offloads in [rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )`` input by application
+is the one which hasn't been enabled in ``rte_eth_dev_configure( )`` and is requested to be enabled
+in ``rte_eth_[rt]x_queue_setup( )``, it must be per-queue type, otherwise return error.
 
 For an application to use the Tx offloads API it should set the ``ETH_TXQ_FLAGS_IGNORE`` flag in the ``txq_flags`` field located in ``rte_eth_txconf`` struct.
 In such cases it is not required to set other flags in ``txq_flags``.
doc/guides/rel_notes/release_18_05.rst +8 -0
index 0ae61e8..637e684 100644
@@ -303,6 +303,14 @@ API Changes
   * ``rte_flow_create()`` API count action now requires the ``struct rte_flow_action_count``.
   * ``rte_flow_query()`` API parameter changed from action type to action structure.
 
+* **ethdev: changes to offload API**
+
+   A pure per-port offloading isn't requested to be repeated in [rt]x_conf->offloads to
+   ``rte_eth_[rt]x_queue_setup( )``. Now any offloading enabled in ``rte_eth_dev_configure( )``
+   can't be disabled by ``rte_eth_[rt]x_queue_setup( )``. Any new added offloading which has
+   not been enabled in ``rte_eth_dev_configure( )`` and is requested to be enabled in
+   ``rte_eth_[rt]x_queue_setup( )`` must be per-queue type, otherwise return error.
+
 
 ABI Changes
 -----------
drivers/net/avf/avf_rxtx.c +4 -1
index 1824ed7..e03a136 100644
@@ -435,9 +435,12 @@ avf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	uint32_t ring_size;
 	uint16_t tx_rs_thresh, tx_free_thresh;
 	uint16_t i, base, bsf, tc_mapping;
+	uint64_t offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+
 	if (nb_desc % AVF_ALIGN_RING_DESC != 0 ||
 	    nb_desc > AVF_MAX_RING_DESC ||
 	    nb_desc < AVF_MIN_RING_DESC) {
@@ -474,7 +477,7 @@ avf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->free_thresh = tx_free_thresh;
 	txq->queue_id = queue_idx;
 	txq->port_id = dev->data->port_id;
-	txq->offloads = tx_conf->offloads;
+	txq->offloads = offloads;
 	txq->tx_deferred_start = tx_conf->tx_deferred_start;
 
 	/* Allocate software ring */
drivers/net/bnxt/bnxt_ethdev.c +0 -17
index 348129d..d00b99f 100644
@@ -500,25 +500,8 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
 static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
-	uint64_t tx_offloads = eth_dev->data->dev_conf.txmode.offloads;
 	uint64_t rx_offloads = eth_dev->data->dev_conf.rxmode.offloads;
 
-	if (tx_offloads != (tx_offloads & BNXT_DEV_TX_OFFLOAD_SUPPORT)) {
-		PMD_DRV_LOG
-			(ERR,
-			 "Tx offloads requested 0x%" PRIx64 " supported 0x%x\n",
-			 tx_offloads, BNXT_DEV_TX_OFFLOAD_SUPPORT);
-		return -ENOTSUP;
-	}
-
-	if (rx_offloads != (rx_offloads & BNXT_DEV_RX_OFFLOAD_SUPPORT)) {
-		PMD_DRV_LOG
-			(ERR,
-			 "Rx offloads requested 0x%" PRIx64 " supported 0x%x\n",
-			    rx_offloads, BNXT_DEV_RX_OFFLOAD_SUPPORT);
-		return -ENOTSUP;
-	}
-
 	bp->rx_queues = (void *)eth_dev->data->rx_queues;
 	bp->tx_queues = (void *)eth_dev->data->tx_queues;
 
drivers/net/cxgbe/cxgbe_ethdev.c +5 -45

86 lines not on this page · raw message

drivers/net/dpaa/dpaa_ethdev.c +0 -16
index 6bf8c15..199afdd 100644
@@ -176,14 +176,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* Rx offloads validation */
-	if (~(dev_rx_offloads_sup | dev_rx_offloads_nodis) & rx_offloads) {
-		DPAA_PMD_ERR(
-		"Rx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			rx_offloads,
-			dev_rx_offloads_sup | dev_rx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_rx_offloads_nodis & ~rx_offloads) {
 		DPAA_PMD_WARN(
 		"Rx offloads non configurable - requested 0x%" PRIx64
@@ -192,14 +184,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
 	}
 
 	/* Tx offloads validation */
-	if (~(dev_tx_offloads_sup | dev_tx_offloads_nodis) & tx_offloads) {
-		DPAA_PMD_ERR(
-		"Tx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			tx_offloads,
-			dev_tx_offloads_sup | dev_tx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_tx_offloads_nodis & ~tx_offloads) {
 		DPAA_PMD_WARN(
 		"Tx offloads non configurable - requested 0x%" PRIx64
drivers/net/dpaa2/dpaa2_ethdev.c +0 -16
index c304b82..de8d83a 100644
@@ -309,14 +309,6 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* Rx offloads validation */
-	if (~(dev_rx_offloads_sup | dev_rx_offloads_nodis) & rx_offloads) {
-		DPAA2_PMD_ERR(
-		"Rx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			rx_offloads,
-			dev_rx_offloads_sup | dev_rx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_rx_offloads_nodis & ~rx_offloads) {
 		DPAA2_PMD_WARN(
 		"Rx offloads non configurable - requested 0x%" PRIx64
@@ -325,14 +317,6 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 	}
 
 	/* Tx offloads validation */
-	if (~(dev_tx_offloads_sup | dev_tx_offloads_nodis) & tx_offloads) {
-		DPAA2_PMD_ERR(
-		"Tx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			tx_offloads,
-			dev_tx_offloads_sup | dev_tx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_tx_offloads_nodis & ~tx_offloads) {
 		DPAA2_PMD_WARN(
 		"Tx offloads non configurable - requested 0x%" PRIx64
drivers/net/e1000/em_ethdev.c +0 -19
index 694a624..4e890ad 100644
@@ -454,29 +454,10 @@ eth_em_configure(struct rte_eth_dev *dev)
 {
 	struct e1000_interrupt *intr =
 		E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 
 	PMD_INIT_FUNC_TRACE();
 	intr->flags |= E1000_FLAG_NEED_LINK_UPDATE;
 
-	eth_em_infos_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	PMD_INIT_FUNC_TRACE();
 
 	return 0;
drivers/net/e1000/em_rxtx.c +6 -58

106 lines not on this page · raw message

drivers/net/e1000/igb_rxtx.c +6 -58

102 lines not on this page · raw message

drivers/net/ena/ena_ethdev.c +4 -61

113 lines not on this page · raw message

drivers/net/failsafe/failsafe_ops.c +0 -81

115 lines not on this page · raw message

drivers/net/fm10k/fm10k_ethdev.c +8 -74

135 lines not on this page · raw message

drivers/net/i40e/i40e_rxtx.c +6 -52

96 lines not on this page · raw message

drivers/net/ixgbe/ixgbe_ethdev.c +0 -38
index 91179e9..320ab21 100644
@@ -2365,9 +2365,6 @@ ixgbe_dev_configure(struct rte_eth_dev *dev)
 		IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
 	struct ixgbe_adapter *adapter =
 		(struct ixgbe_adapter *)dev->data->dev_private;
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 	int ret;
 
 	PMD_INIT_FUNC_TRACE();
@@ -2379,22 +2376,6 @@ ixgbe_dev_configure(struct rte_eth_dev *dev)
 		return ret;
 	}
 
-	ixgbe_dev_info_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	/* set flag to update link status after init */
 	intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
 
@@ -4965,29 +4946,10 @@ ixgbevf_dev_configure(struct rte_eth_dev *dev)
 	struct rte_eth_conf *conf = &dev->data->dev_conf;
 	struct ixgbe_adapter *adapter =
 			(struct ixgbe_adapter *)dev->data->dev_private;
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 
 	PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
 		     dev->data->port_id);
 
-	ixgbevf_dev_info_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	/*
 	 * VF has no ability to enable/disable HW CRC
 	 * Keep the persistent behavior the same as Host PF
drivers/net/ixgbe/ixgbe_rxtx.c +6 -60

110 lines not on this page · raw message

drivers/net/mlx4/mlx4_rxq.c +8 -35

77 lines not on this page · raw message

drivers/net/mlx4/mlx4_txq.c +6 -36

66 lines not on this page · raw message

drivers/net/mlx5/mlx5_ethdev.c +0 -22
index 746b94f..df369cd 100644
@@ -330,30 +330,8 @@ mlx5_dev_configure(struct rte_eth_dev *dev)
 	unsigned int reta_idx_n;
 	const uint8_t use_app_rss_key =
 		!!dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key;
-	uint64_t supp_tx_offloads = mlx5_get_tx_port_offloads(dev);
-	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
-	uint64_t supp_rx_offloads =
-		(mlx5_get_rx_port_offloads() |
-		 mlx5_get_rx_queue_offloads(dev));
-	uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
 	int ret = 0;
 
-	if ((tx_offloads & supp_tx_offloads) != tx_offloads) {
-		DRV_LOG(ERR,
-			"port %u some Tx offloads are not supported requested"
-			" 0x%" PRIx64 " supported 0x%" PRIx64,
-			dev->data->port_id, tx_offloads, supp_tx_offloads);
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
-	if ((rx_offloads & supp_rx_offloads) != rx_offloads) {
-		DRV_LOG(ERR,
-			"port %u some Rx offloads are not supported requested"
-			" 0x%" PRIx64 " supported 0x%" PRIx64,
-			dev->data->port_id, rx_offloads, supp_rx_offloads);
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
 	if (use_app_rss_key &&
 	    (dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len !=
 	     rss_hash_default_key_len)) {
drivers/net/mlx5/mlx5_rxq.c +7 -43

82 lines not on this page · raw message

drivers/net/mlx5/mlx5_txq.c +2 -42

62 lines not on this page · raw message

drivers/net/mvpp2/mrvl_ethdev.c +3 -94

139 lines not on this page · raw message

drivers/net/nfp/nfp_net.c +0 -163

196 lines not on this page · raw message

drivers/net/octeontx/octeontx_ethdev.c +5 -67

117 lines not on this page · raw message

drivers/net/sfc/sfc_ethdev.c +7 -2
index e42d553..fc2b254 100644
@@ -413,14 +413,16 @@ sfc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	int rc;
+	uint64_t offloads;
 
 	sfc_log_init(sa, "RxQ=%u nb_rx_desc=%u socket_id=%u",
 		     rx_queue_id, nb_rx_desc, socket_id);
 
 	sfc_adapter_lock(sa);
 
+	offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
 	rc = sfc_rx_qinit(sa, rx_queue_id, nb_rx_desc, socket_id,
-			  rx_conf, mb_pool);
+			  rx_conf, mb_pool, offloads);
 	if (rc != 0)
 		goto fail_rx_qinit;
 
@@ -469,13 +471,16 @@ sfc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	int rc;
+	uint64_t offloads;
 
 	sfc_log_init(sa, "TxQ = %u, nb_tx_desc = %u, socket_id = %u",
 		     tx_queue_id, nb_tx_desc, socket_id);
 
 	sfc_adapter_lock(sa);
 
-	rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id, tx_conf);
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+	rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id,
+			  tx_conf, offloads);
 	if (rc != 0)
 		goto fail_tx_qinit;
 
drivers/net/sfc/sfc_rx.c +9 -33

86 lines not on this page · raw message

drivers/net/sfc/sfc_rx.h +2 -1
index 3fba7d8..2898fe5 100644
@@ -138,7 +138,8 @@ void sfc_rx_stop(struct sfc_adapter *sa);
 int sfc_rx_qinit(struct sfc_adapter *sa, unsigned int rx_queue_id,
 		 uint16_t nb_rx_desc, unsigned int socket_id,
 		 const struct rte_eth_rxconf *rx_conf,
-		 struct rte_mempool *mb_pool);
+		 struct rte_mempool *mb_pool,
+		 uint64_t offloads);
 void sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
drivers/net/sfc/sfc_tx.c +9 -33

83 lines not on this page · raw message

drivers/net/sfc/sfc_tx.h +2 -1
index c2e5f13..d2b2c4d 100644
@@ -121,7 +121,8 @@ void sfc_tx_close(struct sfc_adapter *sa);
 
 int sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 		 uint16_t nb_tx_desc, unsigned int socket_id,
-		 const struct rte_eth_txconf *tx_conf);
+		 const struct rte_eth_txconf *tx_conf,
+		 uint64_t offloads);
 void sfc_tx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 
 void sfc_tx_qflush_done(struct sfc_txq *txq);
drivers/net/tap/rte_eth_tap.c +8 -80

123 lines not on this page · raw message

drivers/net/thunderx/nicvf_ethdev.c +8 -62

122 lines not on this page · raw message

drivers/net/virtio/virtio_rxtx.c +2 -7
index a8aa87b..92fab21 100644
@@ -385,10 +385,9 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
 			uint16_t queue_idx,
 			uint16_t nb_desc,
 			unsigned int socket_id __rte_unused,
-			const struct rte_eth_rxconf *rx_conf,
+			const struct rte_eth_rxconf *rx_conf __rte_unused,
 			struct rte_mempool *mp)
 {
-	const struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 	uint16_t vtpci_queue_idx = 2 * queue_idx + VTNET_SQ_RQ_QUEUE_IDX;
 	struct virtio_hw *hw = dev->data->dev_private;
 	struct virtqueue *vq = hw->vqs[vtpci_queue_idx];
@@ -408,10 +407,6 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
 			"Cannot allocate mbufs for rx virtqueue");
 	}
 
-	if ((rx_conf->offloads ^ rxmode->offloads) &
-	    VIRTIO_PMD_PER_DEVICE_RX_OFFLOADS)
-		return -EINVAL;
-
 	dev->data->rx_queues[queue_idx] = rxvq;
 
 	return 0;
@@ -504,7 +499,7 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	PMD_INIT_FUNC_TRACE();
 
 	/* cannot use simple rxtx funcs with multisegs or offloads */
-	if (tx_conf->offloads)
+	if (dev->data->dev_conf.txmode.offloads)
 		hw->use_simple_tx = 0;
 
 	if (nb_desc == 0 || nb_desc > vq->vq_nentries)
drivers/net/vmxnet3/vmxnet3_ethdev.c +0 -16
index c850241..ba932ff 100644
@@ -393,25 +393,9 @@ vmxnet3_dev_configure(struct rte_eth_dev *dev)
 	const struct rte_memzone *mz;
 	struct vmxnet3_hw *hw = dev->data->dev_private;
 	size_t size;
-	uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
-	if ((rx_offloads & VMXNET3_RX_OFFLOAD_CAP) != rx_offloads) {
-		RTE_LOG(ERR, PMD, "Requested RX offloads 0x%" PRIx64
-			" do not match supported 0x%" PRIx64,
-			rx_offloads, (uint64_t)VMXNET3_RX_OFFLOAD_CAP);
-		return -ENOTSUP;
-	}
-
-	if ((tx_offloads & VMXNET3_TX_OFFLOAD_CAP) != tx_offloads) {
-		RTE_LOG(ERR, PMD, "Requested TX offloads 0x%" PRIx64
-			" do not match supported 0x%" PRIx64,
-			tx_offloads, (uint64_t)VMXNET3_TX_OFFLOAD_CAP);
-		return -ENOTSUP;
-	}
-
 	if (dev->data->nb_tx_queues > VMXNET3_MAX_TX_QUEUES ||
 	    dev->data->nb_rx_queues > VMXNET3_MAX_RX_QUEUES) {
 		PMD_INIT_LOG(ERR, "ERROR: Number of queues not supported");
drivers/net/vmxnet3/vmxnet3_rxtx.c +1 -7
index f6e2d98..cf85f3d 100644
@@ -1013,7 +1013,7 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
 			   uint16_t queue_idx,
 			   uint16_t nb_desc,
 			   unsigned int socket_id,
-			   const struct rte_eth_txconf *tx_conf)
+			   const struct rte_eth_txconf *tx_conf __rte_unused)
 {
 	struct vmxnet3_hw *hw = dev->data->dev_private;
 	const struct rte_memzone *mz;
@@ -1025,12 +1025,6 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
 
 	PMD_INIT_FUNC_TRACE();
 
-	if ((tx_conf->txq_flags & ETH_TXQ_FLAGS_NOXSUMSCTP) !=
-	    ETH_TXQ_FLAGS_NOXSUMSCTP) {
-		PMD_INIT_LOG(ERR, "SCTP checksum offload not supported");
-		return -EINVAL;
-	}
-
 	txq = rte_zmalloc("ethdev_tx_queue", sizeof(struct vmxnet3_tx_queue),
 			  RTE_CACHE_LINE_SIZE);
 	if (txq == NULL) {
lib/librte_ethdev/rte_ethdev.c +86 -0

104 lines not on this page · raw message

Signature · 1 line
2.7.5
Applied
#37 lore raw

Re: [PATCH v10] ethdev: new Rx/Tx offloads API

Quoted 37 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise triger an error log.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

Quoted 3 lines

Applied to dpdk-next-net/master, thanks.

Hi Thomas,

I remember you have mentioned you will have some comments on doxygen, I get the patch into next-net so that it can be tested, we can squash doc updates later.

#38 lore raw

Re: [PATCH v10] ethdev: new Rx/Tx offloads API

In reply to Wei Dai

Hi,

I am checking if this patch comply with goals discussed in the survey:

	http://dpdk.org/ml/archives/dev/2018-March/094459.html

- Allow "forgetting" port offloads in queue offloads setup.

- An offload enabled at port level, cannot be disabled at queue level.

- Every queue capabilities must be reported as port capabilities.

- A capability should be reported at queue level
only if it can be enabled on queue when it is disabled on port level.

I think some items must be updated in doxygen comments of rte_ethdev.h. Please could you try to do a v11 for doxygen? I will review it quickly.

Examples:

- in queue offloads:
"No need to repeat flags already enabled at port level.
A flag enabled at port level, cannot be disabled at queue level."

- in port capabilities: "(include per-queue capabilities)"

More comments below, thanks.

10/05/2018 02:56, Wei Dai:

Quoted 11 lines

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in

Quoted 8 lines

ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise triger an error log.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

Good summary.
Please forget the whitespace inside the parens.

Quoted 2 lines

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

Good

doc/guides/prog_guide/poll_mode_drv.rst Per-Port and Per-Queue Offloads · line 303

Quoted 10 lines
doc/guides/prog_guide/poll_mode_drv.rst +4 -0
@@ -297,16 +297,30 @@ Per-Port and Per-Queue Offloads
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 In the DPDK offload API, offloads are divided into per-port and per-queue offloads.
+A per-queue offloading can be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offloading must be enabled or disabled on all queues at the same time.
+A per-port offloading can be enabled or disabled on all queues at the same time.

What is the difference between pure per-port and per-port here?

doc/guides/prog_guide/poll_mode_drv.rst Per-Port and Per-Queue Offloads · line 304

Quoted 1 line
doc/guides/prog_guide/poll_mode_drv.rst +1 -0
+It is certain that both per-queue and pure per-port offloading are per-port type.

I don't understand this sentence.

doc/guides/prog_guide/poll_mode_drv.rst Per-Port and Per-Queue Offloads · line 307

Quoted 3 lines
doc/guides/prog_guide/poll_mode_drv.rst +2 -0
 The different offloads capabilities can be queried using ``rte_eth_dev_info_get()``.
+The dev_info->[rt]x_queue_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.
+The dev_info->[rt]x_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.

Yes

doc/guides/prog_guide/poll_mode_drv.rst Per-Port and Per-Queue Offloads · line 311

Quoted 1 line
doc/guides/prog_guide/poll_mode_drv.rst +1 -0
+Any requested offloading by application must be within the device capabilities.

Yes

doc/guides/prog_guide/poll_mode_drv.rst Per-Port and Per-Queue Offloads · line 312

Quoted 1 line
doc/guides/prog_guide/poll_mode_drv.rst +1 -0
+Any offloading is disabled by default if it is not set in the parameter

Yes

doc/guides/prog_guide/poll_mode_drv.rst Per-Port and Per-Queue Offloads · line 320

Quoted 8 lines
doc/guides/prog_guide/poll_mode_drv.rst +8 -0
+dev_conf->[rt]xmode.offloads to ``rte_eth_dev_configure( )`` and
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )``.
+If any offloading is enabled in ``rte_eth_dev_configure( )`` by application,
+it is enabled on all queues no matter whether it is per-queue or
+per-port type and no matter whether it is set or cleared in
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )``.
+If a per-queue offloading hasn't been enabled in ``rte_eth_dev_configure( )``,
+it can be enabled or disabled in ``rte_eth_[rt]x_queue_setup( )`` for individual queue.

Yes

doc/guides/prog_guide/poll_mode_drv.rst Per-Port and Per-Queue Offloads · line 323

Quoted 3 lines
doc/guides/prog_guide/poll_mode_drv.rst +3 -0
+A new added offloads in [rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )`` input by application
+is the one which hasn't been enabled in ``rte_eth_dev_configure( )`` and is requested to be enabled
+in ``rte_eth_[rt]x_queue_setup( )``, it must be per-queue type, otherwise return error.

Yes

doc/guides/rel_notes/release_18_05.rst API Changes · line 306

Quoted 3 lines
doc/guides/rel_notes/release_18_05.rst +1 -0
+* **ethdev: changes to offload API**

No need of bold formatting of title in API changes.

Quoted 6 lines
doc/guides/rel_notes/release_18_05.rst +6 -0
+
+   A pure per-port offloading isn't requested to be repeated in [rt]x_conf->offloads to
+   ``rte_eth_[rt]x_queue_setup( )``. Now any offloading enabled in ``rte_eth_dev_configure( )``
+   can't be disabled by ``rte_eth_[rt]x_queue_setup( )``. Any new added offloading which has
+   not been enabled in ``rte_eth_dev_configure( )`` and is requested to be enabled in
+   ``rte_eth_[rt]x_queue_setup( )`` must be per-queue type, otherwise return error.
author
#39 lore raw

Re: [PATCH v10] ethdev: new Rx/Tx offloads API

Hi, Thomas
Thanks for your feedback and guidance.

Quoted 57 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, May 10, 2018 10:36 AM
To: Dai, Wei <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v10] ethdev: new Rx/Tx offloads API

Hi,

I am checking if this patch comply with goals discussed in the survey:

	http://dpdk.org/ml/archives/dev/2018-March/094459.html

- Allow "forgetting" port offloads in queue offloads setup.

- An offload enabled at port level, cannot be disabled at queue level.

- Every queue capabilities must be reported as port capabilities.

- A capability should be reported at queue level
only if it can be enabled on queue when it is disabled on port level.

I think some items must be updated in doxygen comments of rte_ethdev.h. Please could you try to do a v11 for doxygen? I will review it quickly.

Examples:

- in queue offloads:
"No need to repeat flags already enabled at port level.
A flag enabled at port level, cannot be disabled at queue level."

- in port capabilities: "(include per-queue capabilities)"

More comments below, thanks.

10/05/2018 02:56, Wei Dai:

Quoted 11 lines

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in

Quoted 8 lines

ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise triger an error log.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

Quoted 2 lines

Good summary.
Please forget the whitespace inside the parens.

I will remove whitespaces inside the parens.

Quoted 15 lines
Quoted 3 lines

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

Good

Quoted 6 lines
doc/guides/prog_guide/poll_mode_drv.rst +0 -0
@@ -297,16 +297,30 @@ Per-Port and Per-Queue Offloads

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

In the DPDK offload API, offloads are divided into per-port and per-queue

offloads.

Quoted 1 line

+A per-queue offloading can be enabled on a queue and disabled on

another queue at the same time.

Quoted 9 lines
Quoted 1 line

+A pure per-port offloading can't be enabled on a queue and disabled on

another queue at the same time.

Quoted 1 line

+A pure per-port offloading must be enabled or disabled on all queues at

the same time.

Quoted 1 line

+A per-port offloading can be enabled or disabled on all queues at the

same time.

What is the difference between pure per-port and per-port here?

Can I add following words to explain more:
A pure per-port offloads are those supported by device but not per-queue type. A supported offload can be per-queue or pure per-port, but can't be both types at same device.
Any offloadings are per-port type as it can be enabled or disabled on all queues at the same time.

Quoted 5 lines
Quoted 1 line

+It is certain that both per-queue and pure per-port offloading are per-port

type.

I don't understand this sentence.

Explained above, I just want to divide all offloading into two distinct types:
Per-queue and pure per-port.
And per-queue + pure per-port = per-port.

Quoted 38 lines
Quoted 1 line

The different offloads capabilities can be queried using

``rte_eth_dev_info_get()``.

Quoted 1 line

+The dev_info->[rt]x_queue_offload_capa returned from

``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.

Quoted 1 line

+The dev_info->[rt]x_offload_capa returned from

``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.

Yes

Quoted 1 line

+Any requested offloading by application must be within the device

capabilities.

Yes

doc/guides/prog_guide/poll_mode_drv.rst

Quoted 2 lines
doc/guides/prog_guide/poll_mode_drv.rst +2 -0
+Any offloading is disabled by default if it is not set in the
+parameter

Yes

doc/guides/prog_guide/poll_mode_drv.rst

Quoted 8 lines
doc/guides/prog_guide/poll_mode_drv.rst +8 -0
+dev_conf->[rt]xmode.offloads to ``rte_eth_dev_configure( )`` and
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )``.
+If any offloading is enabled in ``rte_eth_dev_configure( )`` by
+application, it is enabled on all queues no matter whether it is
+per-queue or per-port type and no matter whether it is set or cleared
+in [rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )``.
+If a per-queue offloading hasn't been enabled in
+``rte_eth_dev_configure( )``, it can be enabled or disabled in

``rte_eth_[rt]x_queue_setup( )`` for individual queue.

Yes

doc/guides/prog_guide/poll_mode_drv.rst

Quoted 3 lines
doc/guides/prog_guide/poll_mode_drv.rst +3 -0
+A new added offloads in [rt]x_conf->offloads to
+``rte_eth_[rt]x_queue_setup( )`` input by application is the one
+which hasn't been enabled in ``rte_eth_dev_configure( )`` and is requested

to be enabled in ``rte_eth_[rt]x_queue_setup( )``, it must be per-queue type, otherwise return error.

Quoted 9 lines

Yes

doc/guides/rel_notes/release_18_05.rst API Changes · line 306

Quoted 3 lines
doc/guides/rel_notes/release_18_05.rst +1 -0
+* **ethdev: changes to offload API**

No need of bold formatting of title in API changes.

Will revise it as you guide.

Quoted 14 lines

doc/guides/rel_notes/release_18_05.rst

Quoted 2 lines
doc/guides/rel_notes/release_18_05.rst +2 -0
+
+   A pure per-port offloading isn't requested to be repeated in

[rt]x_conf->offloads to

Quoted 1 line

+ ``rte_eth_[rt]x_queue_setup( )``. Now any offloading enabled in

``rte_eth_dev_configure( )``

Quoted 1 line

+ can't be disabled by ``rte_eth_[rt]x_queue_setup( )``. Any new added

offloading which has

Quoted 1 line

+ not been enabled in ``rte_eth_dev_configure( )`` and is requested to

be enabled in

Quoted 1 line

+ ``rte_eth_[rt]x_queue_setup( )`` must be per-queue type, otherwise

return error.

#40 lore raw

Re: [PATCH v10] ethdev: new Rx/Tx offloads API

In reply to Wei Dai
Quoted 49 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise triger an error log.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

---
v10:
sorry, miss the code change, fix the buidling error

v9:
replace RTE_PMD_DEBUG_TRACE with ethdev_log(ERR, in ethdev to avoid failure of application which hasn't been completely converted to new offload API.

[...]

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +0 -0
index e560524..5baa2aa 100644
@@ -1139,6 +1139,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
  							ETHER_MAX_LEN;
  	}
 

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1151

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	/* Any requested offloading must be within its device capabilities */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		ethdev_log(ERR, "ethdev port_id=%d requested Rx offloads "
+				"0x%" PRIx64 " doesn't match Rx offloads "
+				"capabilities 0x%" PRIx64 " in %s( )\n",
+				port_id,
+				local_conf.rxmode.offloads,
+				dev_info.rx_offload_capa,
+				__func__);

Why is return -EINVAL removed here?
If application is not updated to use offloads, offloads is 0 and everything is OK. If application is updated to use offloads, its behaviour must be consistent. Same below for Tx device offloads.

Quoted 39 lines
lib/librte_ethdev/rte_ethdev.c +32 -0
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		ethdev_log(ERR, "ethdev port_id=%d requested Tx offloads "
+				"0x%" PRIx64 " doesn't match Tx offloads "
+				"capabilities 0x%" PRIx64 " in %s( )\n",
+				port_id,
+				local_conf.txmode.offloads,
+				dev_info.tx_offload_capa,
+				__func__);
+	}
+
  	/* Check that device supports requested rss hash functions. */
  	if ((dev_info.flow_type_rss_offloads |
  	     dev_conf->rx_adv_conf.rss_conf.rss_hf) !=
@@ -1504,6 +1526,38 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
  						    &local_conf.offloads);
  	}
 
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
+	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) !=

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1558

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	     local_conf.offloads) {
+		ethdev_log(ERR, "Ethdev port_id=%d rx_queue_id=%d, new "
+				"added offloads 0x%" PRIx64 " must be "
+				"within pre-queue offload capabilities 0x%"
+				PRIx64 " in %s( )\n",
+				port_id,
+				rx_queue_id,
+				local_conf.offloads,
+				dev_info.rx_queue_offload_capa,
+				__func__);

May be it is really a good tradeoff to remove error return here. Ideally it would be nice to see explanation here why.

Quoted 44 lines
lib/librte_ethdev/rte_ethdev.c +34 -0
+	}
+
  	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
  					      socket_id, &local_conf, mp);
  	if (!ret) {
@@ -1612,6 +1666,38 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
  					  &local_conf.offloads);
  	}
 
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.txmode.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.tx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		ethdev_log(ERR, "Ethdev port_id=%d tx_queue_id=%d, new "
+				"added offloads 0x%" PRIx64 " must be "
+				"within pre-queue offload capabilities 0x%"
+				PRIx64 " in %s( )\n",
+				port_id,
+				tx_queue_id,
+				local_conf.offloads,
+				dev_info.tx_queue_offload_capa,
+				__func__);
+	}
+
  	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
  		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
  }
#41 lore raw

Re: [PATCH v10] ethdev: new Rx/Tx offloads API

Quoted 61 lines · Andrew Rybchenko
Quoted 49 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise triger an error log.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

---
v10:
sorry, miss the code change, fix the buidling error

v9:
replace RTE_PMD_DEBUG_TRACE with ethdev_log(ERR, in ethdev to avoid failure of application which hasn't been completely converted to new offload API.

[...]

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +0 -0
index e560524..5baa2aa 100644
@@ -1139,6 +1139,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 							ETHER_MAX_LEN;
 	}
 
Quoted 15 lines

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1151

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	/* Any requested offloading must be within its device capabilities */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		ethdev_log(ERR, "ethdev port_id=%d requested Rx offloads "
+				"0x%" PRIx64 " doesn't match Rx offloads "
+				"capabilities 0x%" PRIx64 " in %s( )\n",
+				port_id,
+				local_conf.rxmode.offloads,
+				dev_info.rx_offload_capa,
+				__func__);

Why is return -EINVAL removed here?
If application is not updated to use offloads, offloads is 0 and everything is OK. If application is updated to use offloads, its behaviour must be consistent. Same below for Tx device offloads.

To be cautious to not break apps for the cases we have missed. For example testpmd was giving error with virtual PMDs because of CRC_STRIP, it is easy to fix testpmd but other applications too may have similar problem.

Overall agree that error should be return, for this release it will only print error log, next release we can add return back. Next release applications will be switched to new offloading API so they will already need to be updated, and hopefully that change will be before rc stage.

Quoted 99 lines
Quoted 40 lines
lib/librte_ethdev/rte_ethdev.c +32 -0
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		ethdev_log(ERR, "ethdev port_id=%d requested Tx offloads "
+				"0x%" PRIx64 " doesn't match Tx offloads "
+				"capabilities 0x%" PRIx64 " in %s( )\n",
+				port_id,
+				local_conf.txmode.offloads,
+				dev_info.tx_offload_capa,
+				__func__);
+	}
+
 	/* Check that device supports requested rss hash functions. */
 	if ((dev_info.flow_type_rss_offloads |
 	     dev_conf->rx_adv_conf.rss_conf.rss_hf) !=
@@ -1504,6 +1526,38 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 						    &local_conf.offloads);
 	}
 
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
+	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) !=

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1558

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	     local_conf.offloads) {
+		ethdev_log(ERR, "Ethdev port_id=%d rx_queue_id=%d, new "
+				"added offloads 0x%" PRIx64 " must be "
+				"within pre-queue offload capabilities 0x%"
+				PRIx64 " in %s( )\n",
+				port_id,
+				rx_queue_id,
+				local_conf.offloads,
+				dev_info.rx_queue_offload_capa,
+				__func__);

May be it is really a good tradeoff to remove error return here. Ideally it would be nice to see explanation here why.

Quoted 44 lines
lib/librte_ethdev/rte_ethdev.c +34 -0
+	}
+
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
 					      socket_id, &local_conf, mp);
 	if (!ret) {
@@ -1612,6 +1666,38 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 					  &local_conf.offloads);
 	}
 
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.txmode.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.tx_queue_offload_capa) !=
+	     local_conf.offloads) {
+		ethdev_log(ERR, "Ethdev port_id=%d tx_queue_id=%d, new "
+				"added offloads 0x%" PRIx64 " must be "
+				"within pre-queue offload capabilities 0x%"
+				PRIx64 " in %s( )\n",
+				port_id,
+				tx_queue_id,
+				local_conf.offloads,
+				dev_info.tx_queue_offload_capa,
+				__func__);
+	}
+
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
 		       tx_queue_id, nb_tx_desc, socket_id, &local_conf));
 }
author
#42 lore raw

PATCH v11 1/1 ethdev: new Rx/Tx offloads API

In reply to Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure() and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup().
If any offloading is enabled in rte_eth_dev_configure() by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup().
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure(), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup().
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure() and is reuqested to be enabled in rte_eth_[rt]x_queue_setup(), it must be per-queue type, otherwise trigger an error log.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup() function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get().

In the beginning of [rt]x_queue_setup() of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

---
v11:
This patch set is based on 18.05-rc2 .
document update according to feedback
revise rte_ethdev.h for doxygen

v10:
sorry, miss the code change, fix the buidling error

v9:
replace RTE_PMD_DEBUG_TRACE with ethdev_log(ERR, in ethdev to avoid failure of application which hasn't been completely converted to new offload API.

v8:
Revise PMD codes to comply with offload API in v7
update document

v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer. Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 doc/guides/prog_guide/poll_mode_drv.rst |  28 ++++--
 doc/guides/rel_notes/release_18_05.rst  |   8 ++
 drivers/net/avf/avf_rxtx.c              |   5 +-
 drivers/net/bnxt/bnxt_ethdev.c          |  17 ----
 drivers/net/cxgbe/cxgbe_ethdev.c        |  50 +---------
 drivers/net/dpaa/dpaa_ethdev.c          |  16 ----
 drivers/net/dpaa2/dpaa2_ethdev.c        |  16 ----
 drivers/net/e1000/em_ethdev.c           |  19 ----
 drivers/net/e1000/em_rxtx.c             |  64 ++-----------
 drivers/net/e1000/igb_rxtx.c            |  64 ++-----------
 drivers/net/ena/ena_ethdev.c            |  65 +------------
 drivers/net/failsafe/failsafe_ops.c     |  81 ----------------
 drivers/net/fm10k/fm10k_ethdev.c        |  82 ++--------------
 drivers/net/i40e/i40e_rxtx.c            |  58 ++----------
 drivers/net/ixgbe/ixgbe_ethdev.c        |  38 --------
 drivers/net/ixgbe/ixgbe_rxtx.c          |  66 ++-----------
 drivers/net/mlx4/mlx4_rxq.c             |  43 ++-------
 drivers/net/mlx4/mlx4_txq.c             |  42 ++------
 drivers/net/mlx5/mlx5_ethdev.c          |  22 -----
 drivers/net/mlx5/mlx5_rxq.c             |  50 ++--------
 drivers/net/mlx5/mlx5_txq.c             |  44 +--------
 drivers/net/mvpp2/mrvl_ethdev.c         |  97 +------------------
 drivers/net/nfp/nfp_net.c               | 163 --------------------------------
 drivers/net/octeontx/octeontx_ethdev.c  |  72 +-------------
 drivers/net/sfc/sfc_ethdev.c            |   9 +-
 drivers/net/sfc/sfc_rx.c                |  42 ++------
 drivers/net/sfc/sfc_rx.h                |   3 +-
 drivers/net/sfc/sfc_tx.c                |  42 ++------
 drivers/net/sfc/sfc_tx.h                |   3 +-
 drivers/net/tap/rte_eth_tap.c           |  88 ++---------------
 drivers/net/thunderx/nicvf_ethdev.c     |  70 ++------------
 drivers/net/virtio/virtio_rxtx.c        |   9 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c    |  16 ----
 drivers/net/vmxnet3/vmxnet3_rxtx.c      |   8 +-
 lib/librte_ethdev/rte_ethdev.c          |  86 +++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h          |  20 +++-
 36 files changed, 257 insertions(+), 1349 deletions(-)
doc/guides/prog_guide/poll_mode_drv.rst +22 -6
index 09a93ba..bbb85f0 100644
@@ -297,16 +297,32 @@ Per-Port and Per-Queue Offloads
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 In the DPDK offload API, offloads are divided into per-port and per-queue offloads.
+A per-queue offloading can be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offload is the one supported by device but not per-queue type.
+A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offloading must be enabled or disabled on all queues at the same time.
+Any offloading is per-queue or pure per-port type, but can't be both types at same devices.
+A per-port offloading can be enabled or disabled on all queues at the same time.
+It is certain that both per-queue and pure per-port offloading are per-port type.
 The different offloads capabilities can be queried using ``rte_eth_dev_info_get()``.
+The dev_info->[rt]x_queue_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.
+The dev_info->[rt]x_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.
 Supported offloads can be either per-port or per-queue.
 
 Offloads are enabled using the existing ``DEV_TX_OFFLOAD_*`` or ``DEV_RX_OFFLOAD_*`` flags.
-Per-port offload configuration is set using ``rte_eth_dev_configure``.
-Per-queue offload configuration is set using ``rte_eth_rx_queue_setup`` and ``rte_eth_tx_queue_setup``.
-To enable per-port offload, the offload should be set on both device configuration and queue setup.
-In case of a mixed configuration the queue setup shall return with an error.
-To enable per-queue offload, the offload can be set only on the queue setup.
-Offloads which are not enabled are disabled by default.
+Any requested offloading by application must be within the device capabilities.
+Any offloading is disabled by default if it is not set in the parameter
+dev_conf->[rt]xmode.offloads to ``rte_eth_dev_configure()`` and
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup()``.
+If any offloading is enabled in ``rte_eth_dev_configure()`` by application,
+it is enabled on all queues no matter whether it is per-queue or
+per-port type and no matter whether it is set or cleared in
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup()``.
+If a per-queue offloading hasn't been enabled in ``rte_eth_dev_configure()``,
+it can be enabled or disabled in ``rte_eth_[rt]x_queue_setup()`` for individual queue.
+A new added offloads in [rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup()`` input by application
+is the one which hasn't been enabled in ``rte_eth_dev_configure()`` and is requested to be enabled
+in ``rte_eth_[rt]x_queue_setup()``, it must be per-queue type, otherwise trigger an error log.
 
 For an application to use the Tx offloads API it should set the ``ETH_TXQ_FLAGS_IGNORE`` flag in the ``txq_flags`` field located in ``rte_eth_txconf`` struct.
 In such cases it is not required to set other flags in ``txq_flags``.
doc/guides/rel_notes/release_18_05.rst +8 -0
index 0ae61e8..716e9f4 100644
@@ -303,6 +303,14 @@ API Changes
   * ``rte_flow_create()`` API count action now requires the ``struct rte_flow_action_count``.
   * ``rte_flow_query()`` API parameter changed from action type to action structure.
 
+* ethdev: changes to offload API
+
+   A pure per-port offloading isn't requested to be repeated in [rt]x_conf->offloads to
+   ``rte_eth_[rt]x_queue_setup()``. Now any offloading enabled in ``rte_eth_dev_configure()``
+   can't be disabled by ``rte_eth_[rt]x_queue_setup()``. Any new added offloading which has
+   not been enabled in ``rte_eth_dev_configure()`` and is requested to be enabled in
+   ``rte_eth_[rt]x_queue_setup()`` must be per-queue type, otherwise trigger an error log.
+
 
 ABI Changes
 -----------
drivers/net/avf/avf_rxtx.c +4 -1
index 1824ed7..e03a136 100644
@@ -435,9 +435,12 @@ avf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	uint32_t ring_size;
 	uint16_t tx_rs_thresh, tx_free_thresh;
 	uint16_t i, base, bsf, tc_mapping;
+	uint64_t offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+
 	if (nb_desc % AVF_ALIGN_RING_DESC != 0 ||
 	    nb_desc > AVF_MAX_RING_DESC ||
 	    nb_desc < AVF_MIN_RING_DESC) {
@@ -474,7 +477,7 @@ avf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->free_thresh = tx_free_thresh;
 	txq->queue_id = queue_idx;
 	txq->port_id = dev->data->port_id;
-	txq->offloads = tx_conf->offloads;
+	txq->offloads = offloads;
 	txq->tx_deferred_start = tx_conf->tx_deferred_start;
 
 	/* Allocate software ring */
drivers/net/bnxt/bnxt_ethdev.c +0 -17
index 348129d..d00b99f 100644
@@ -500,25 +500,8 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
 static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
-	uint64_t tx_offloads = eth_dev->data->dev_conf.txmode.offloads;
 	uint64_t rx_offloads = eth_dev->data->dev_conf.rxmode.offloads;
 
-	if (tx_offloads != (tx_offloads & BNXT_DEV_TX_OFFLOAD_SUPPORT)) {
-		PMD_DRV_LOG
-			(ERR,
-			 "Tx offloads requested 0x%" PRIx64 " supported 0x%x\n",
-			 tx_offloads, BNXT_DEV_TX_OFFLOAD_SUPPORT);
-		return -ENOTSUP;
-	}
-
-	if (rx_offloads != (rx_offloads & BNXT_DEV_RX_OFFLOAD_SUPPORT)) {
-		PMD_DRV_LOG
-			(ERR,
-			 "Rx offloads requested 0x%" PRIx64 " supported 0x%x\n",
-			    rx_offloads, BNXT_DEV_RX_OFFLOAD_SUPPORT);
-		return -ENOTSUP;
-	}
-
 	bp->rx_queues = (void *)eth_dev->data->rx_queues;
 	bp->tx_queues = (void *)eth_dev->data->tx_queues;
 
drivers/net/cxgbe/cxgbe_ethdev.c +5 -45

86 lines not on this page · raw message

drivers/net/dpaa/dpaa_ethdev.c +0 -16
index 6bf8c15..199afdd 100644
@@ -176,14 +176,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* Rx offloads validation */
-	if (~(dev_rx_offloads_sup | dev_rx_offloads_nodis) & rx_offloads) {
-		DPAA_PMD_ERR(
-		"Rx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			rx_offloads,
-			dev_rx_offloads_sup | dev_rx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_rx_offloads_nodis & ~rx_offloads) {
 		DPAA_PMD_WARN(
 		"Rx offloads non configurable - requested 0x%" PRIx64
@@ -192,14 +184,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
 	}
 
 	/* Tx offloads validation */
-	if (~(dev_tx_offloads_sup | dev_tx_offloads_nodis) & tx_offloads) {
-		DPAA_PMD_ERR(
-		"Tx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			tx_offloads,
-			dev_tx_offloads_sup | dev_tx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_tx_offloads_nodis & ~tx_offloads) {
 		DPAA_PMD_WARN(
 		"Tx offloads non configurable - requested 0x%" PRIx64
drivers/net/dpaa2/dpaa2_ethdev.c +0 -16
index c304b82..de8d83a 100644
@@ -309,14 +309,6 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* Rx offloads validation */
-	if (~(dev_rx_offloads_sup | dev_rx_offloads_nodis) & rx_offloads) {
-		DPAA2_PMD_ERR(
-		"Rx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			rx_offloads,
-			dev_rx_offloads_sup | dev_rx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_rx_offloads_nodis & ~rx_offloads) {
 		DPAA2_PMD_WARN(
 		"Rx offloads non configurable - requested 0x%" PRIx64
@@ -325,14 +317,6 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 	}
 
 	/* Tx offloads validation */
-	if (~(dev_tx_offloads_sup | dev_tx_offloads_nodis) & tx_offloads) {
-		DPAA2_PMD_ERR(
-		"Tx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			tx_offloads,
-			dev_tx_offloads_sup | dev_tx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_tx_offloads_nodis & ~tx_offloads) {
 		DPAA2_PMD_WARN(
 		"Tx offloads non configurable - requested 0x%" PRIx64
drivers/net/e1000/em_ethdev.c +0 -19
index 694a624..4e890ad 100644
@@ -454,29 +454,10 @@ eth_em_configure(struct rte_eth_dev *dev)
 {
 	struct e1000_interrupt *intr =
 		E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 
 	PMD_INIT_FUNC_TRACE();
 	intr->flags |= E1000_FLAG_NEED_LINK_UPDATE;
 
-	eth_em_infos_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	PMD_INIT_FUNC_TRACE();
 
 	return 0;
drivers/net/e1000/em_rxtx.c +6 -58

106 lines not on this page · raw message

drivers/net/e1000/igb_rxtx.c +6 -58

102 lines not on this page · raw message

drivers/net/ena/ena_ethdev.c +4 -61

113 lines not on this page · raw message

drivers/net/failsafe/failsafe_ops.c +0 -81

115 lines not on this page · raw message

drivers/net/fm10k/fm10k_ethdev.c +8 -74

135 lines not on this page · raw message

drivers/net/i40e/i40e_rxtx.c +6 -52

96 lines not on this page · raw message

drivers/net/ixgbe/ixgbe_ethdev.c +0 -38
index 91179e9..320ab21 100644
@@ -2365,9 +2365,6 @@ ixgbe_dev_configure(struct rte_eth_dev *dev)
 		IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
 	struct ixgbe_adapter *adapter =
 		(struct ixgbe_adapter *)dev->data->dev_private;
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 	int ret;
 
 	PMD_INIT_FUNC_TRACE();
@@ -2379,22 +2376,6 @@ ixgbe_dev_configure(struct rte_eth_dev *dev)
 		return ret;
 	}
 
-	ixgbe_dev_info_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	/* set flag to update link status after init */
 	intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
 
@@ -4965,29 +4946,10 @@ ixgbevf_dev_configure(struct rte_eth_dev *dev)
 	struct rte_eth_conf *conf = &dev->data->dev_conf;
 	struct ixgbe_adapter *adapter =
 			(struct ixgbe_adapter *)dev->data->dev_private;
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 
 	PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
 		     dev->data->port_id);
 
-	ixgbevf_dev_info_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	/*
 	 * VF has no ability to enable/disable HW CRC
 	 * Keep the persistent behavior the same as Host PF
drivers/net/ixgbe/ixgbe_rxtx.c +6 -60

110 lines not on this page · raw message

drivers/net/mlx4/mlx4_rxq.c +8 -35

77 lines not on this page · raw message

drivers/net/mlx4/mlx4_txq.c +6 -36

66 lines not on this page · raw message

drivers/net/mlx5/mlx5_ethdev.c +0 -22
index 746b94f..df369cd 100644
@@ -330,30 +330,8 @@ mlx5_dev_configure(struct rte_eth_dev *dev)
 	unsigned int reta_idx_n;
 	const uint8_t use_app_rss_key =
 		!!dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key;
-	uint64_t supp_tx_offloads = mlx5_get_tx_port_offloads(dev);
-	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
-	uint64_t supp_rx_offloads =
-		(mlx5_get_rx_port_offloads() |
-		 mlx5_get_rx_queue_offloads(dev));
-	uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
 	int ret = 0;
 
-	if ((tx_offloads & supp_tx_offloads) != tx_offloads) {
-		DRV_LOG(ERR,
-			"port %u some Tx offloads are not supported requested"
-			" 0x%" PRIx64 " supported 0x%" PRIx64,
-			dev->data->port_id, tx_offloads, supp_tx_offloads);
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
-	if ((rx_offloads & supp_rx_offloads) != rx_offloads) {
-		DRV_LOG(ERR,
-			"port %u some Rx offloads are not supported requested"
-			" 0x%" PRIx64 " supported 0x%" PRIx64,
-			dev->data->port_id, rx_offloads, supp_rx_offloads);
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
 	if (use_app_rss_key &&
 	    (dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len !=
 	     rss_hash_default_key_len)) {
drivers/net/mlx5/mlx5_rxq.c +7 -43

82 lines not on this page · raw message

drivers/net/mlx5/mlx5_txq.c +2 -42

62 lines not on this page · raw message

drivers/net/mvpp2/mrvl_ethdev.c +3 -94

139 lines not on this page · raw message

drivers/net/nfp/nfp_net.c +0 -163

196 lines not on this page · raw message

drivers/net/octeontx/octeontx_ethdev.c +5 -67

117 lines not on this page · raw message

drivers/net/sfc/sfc_ethdev.c +7 -2
index e42d553..fc2b254 100644
@@ -413,14 +413,16 @@ sfc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	int rc;
+	uint64_t offloads;
 
 	sfc_log_init(sa, "RxQ=%u nb_rx_desc=%u socket_id=%u",
 		     rx_queue_id, nb_rx_desc, socket_id);
 
 	sfc_adapter_lock(sa);
 
+	offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
 	rc = sfc_rx_qinit(sa, rx_queue_id, nb_rx_desc, socket_id,
-			  rx_conf, mb_pool);
+			  rx_conf, mb_pool, offloads);
 	if (rc != 0)
 		goto fail_rx_qinit;
 
@@ -469,13 +471,16 @@ sfc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	int rc;
+	uint64_t offloads;
 
 	sfc_log_init(sa, "TxQ = %u, nb_tx_desc = %u, socket_id = %u",
 		     tx_queue_id, nb_tx_desc, socket_id);
 
 	sfc_adapter_lock(sa);
 
-	rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id, tx_conf);
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+	rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id,
+			  tx_conf, offloads);
 	if (rc != 0)
 		goto fail_tx_qinit;
 
drivers/net/sfc/sfc_rx.c +9 -33

86 lines not on this page · raw message

drivers/net/sfc/sfc_rx.h +2 -1
index 3fba7d8..2898fe5 100644
@@ -138,7 +138,8 @@ void sfc_rx_stop(struct sfc_adapter *sa);
 int sfc_rx_qinit(struct sfc_adapter *sa, unsigned int rx_queue_id,
 		 uint16_t nb_rx_desc, unsigned int socket_id,
 		 const struct rte_eth_rxconf *rx_conf,
-		 struct rte_mempool *mb_pool);
+		 struct rte_mempool *mb_pool,
+		 uint64_t offloads);
 void sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
drivers/net/sfc/sfc_tx.c +9 -33

83 lines not on this page · raw message

drivers/net/sfc/sfc_tx.h +2 -1
index c2e5f13..d2b2c4d 100644
@@ -121,7 +121,8 @@ void sfc_tx_close(struct sfc_adapter *sa);
 
 int sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 		 uint16_t nb_tx_desc, unsigned int socket_id,
-		 const struct rte_eth_txconf *tx_conf);
+		 const struct rte_eth_txconf *tx_conf,
+		 uint64_t offloads);
 void sfc_tx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 
 void sfc_tx_qflush_done(struct sfc_txq *txq);
drivers/net/tap/rte_eth_tap.c +8 -80

123 lines not on this page · raw message

drivers/net/thunderx/nicvf_ethdev.c +8 -62

122 lines not on this page · raw message

drivers/net/virtio/virtio_rxtx.c +2 -7
index a8aa87b..92fab21 100644
@@ -385,10 +385,9 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
 			uint16_t queue_idx,
 			uint16_t nb_desc,
 			unsigned int socket_id __rte_unused,
-			const struct rte_eth_rxconf *rx_conf,
+			const struct rte_eth_rxconf *rx_conf __rte_unused,
 			struct rte_mempool *mp)
 {
-	const struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 	uint16_t vtpci_queue_idx = 2 * queue_idx + VTNET_SQ_RQ_QUEUE_IDX;
 	struct virtio_hw *hw = dev->data->dev_private;
 	struct virtqueue *vq = hw->vqs[vtpci_queue_idx];
@@ -408,10 +407,6 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
 			"Cannot allocate mbufs for rx virtqueue");
 	}
 
-	if ((rx_conf->offloads ^ rxmode->offloads) &
-	    VIRTIO_PMD_PER_DEVICE_RX_OFFLOADS)
-		return -EINVAL;
-
 	dev->data->rx_queues[queue_idx] = rxvq;
 
 	return 0;
@@ -504,7 +499,7 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	PMD_INIT_FUNC_TRACE();
 
 	/* cannot use simple rxtx funcs with multisegs or offloads */
-	if (tx_conf->offloads)
+	if (dev->data->dev_conf.txmode.offloads)
 		hw->use_simple_tx = 0;
 
 	if (nb_desc == 0 || nb_desc > vq->vq_nentries)
drivers/net/vmxnet3/vmxnet3_ethdev.c +0 -16
index c850241..ba932ff 100644
@@ -393,25 +393,9 @@ vmxnet3_dev_configure(struct rte_eth_dev *dev)
 	const struct rte_memzone *mz;
 	struct vmxnet3_hw *hw = dev->data->dev_private;
 	size_t size;
-	uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
-	if ((rx_offloads & VMXNET3_RX_OFFLOAD_CAP) != rx_offloads) {
-		RTE_LOG(ERR, PMD, "Requested RX offloads 0x%" PRIx64
-			" do not match supported 0x%" PRIx64,
-			rx_offloads, (uint64_t)VMXNET3_RX_OFFLOAD_CAP);
-		return -ENOTSUP;
-	}
-
-	if ((tx_offloads & VMXNET3_TX_OFFLOAD_CAP) != tx_offloads) {
-		RTE_LOG(ERR, PMD, "Requested TX offloads 0x%" PRIx64
-			" do not match supported 0x%" PRIx64,
-			tx_offloads, (uint64_t)VMXNET3_TX_OFFLOAD_CAP);
-		return -ENOTSUP;
-	}
-
 	if (dev->data->nb_tx_queues > VMXNET3_MAX_TX_QUEUES ||
 	    dev->data->nb_rx_queues > VMXNET3_MAX_RX_QUEUES) {
 		PMD_INIT_LOG(ERR, "ERROR: Number of queues not supported");
drivers/net/vmxnet3/vmxnet3_rxtx.c +1 -7
index f6e2d98..cf85f3d 100644
@@ -1013,7 +1013,7 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
 			   uint16_t queue_idx,
 			   uint16_t nb_desc,
 			   unsigned int socket_id,
-			   const struct rte_eth_txconf *tx_conf)
+			   const struct rte_eth_txconf *tx_conf __rte_unused)
 {
 	struct vmxnet3_hw *hw = dev->data->dev_private;
 	const struct rte_memzone *mz;
@@ -1025,12 +1025,6 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
 
 	PMD_INIT_FUNC_TRACE();
 
-	if ((tx_conf->txq_flags & ETH_TXQ_FLAGS_NOXSUMSCTP) !=
-	    ETH_TXQ_FLAGS_NOXSUMSCTP) {
-		PMD_INIT_LOG(ERR, "SCTP checksum offload not supported");
-		return -EINVAL;
-	}
-
 	txq = rte_zmalloc("ethdev_tx_queue", sizeof(struct vmxnet3_tx_queue),
 			  RTE_CACHE_LINE_SIZE);
 	if (txq == NULL) {
lib/librte_ethdev/rte_ethdev.c +86 -0

104 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +17 -3
index 7ccf4ba..56eca2c 100644
@@ -1067,9 +1067,9 @@ struct rte_eth_dev_info {
 	uint16_t max_vfs; /**< Maximum number of VFs. */
 	uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
 	uint64_t rx_offload_capa;
-	/**< Device per port RX offload capabilities. */
+	/**< All RX offload capabilities including all per queue ones */
 	uint64_t tx_offload_capa;
-	/**< Device per port TX offload capabilities. */
+	/**< All TX offload capabilities.including all per-queue ones */
 	uint64_t rx_queue_offload_capa;
 	/**< Device per queue RX offload capabilities. */
 	uint64_t tx_queue_offload_capa;
@@ -1546,6 +1546,13 @@ const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload);
  *        The Rx offload bitfield API is obsolete and will be deprecated.
  *        Applications should set the ignore_bitfield_offloads bit on *rxmode*
  *        structure and use offloads field to set per-port offloads instead.
+ *     -  Any offloading set in eth_conf->[rt]xmode.offloads must be within
+ *        the [rt]x_offload_capa returned from rte_eth_dev_infos_get().
+ *        Any type of device supported offloading set in the input argument
+ *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
+ *        on all [RT]x queues and it can't be disabled no matter whether
+ *        it is cleared or set in the input argument [rt]x_conf->offloads
+*         to rte_eth_[rt]x_queue_setup().
  *     - the Receive Side Scaling (RSS) configuration when using multiple RX
  *         queues per port.
  *
@@ -1602,6 +1609,10 @@ rte_eth_dev_is_removed(uint16_t port_id);
  *   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.
  * @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.
@@ -1660,7 +1671,10 @@ int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
  *     should set it to ETH_TXQ_FLAGS_IGNORE and use
  *     the offloads field below.
  *   - The *offloads* member contains Tx offloads to be enabled.
- *     Offloads which are not set cannot be used on the datapath.
+ *     If an offloading set in tx_conf->offloads
+ *     hasn't been set in the input argument eth_conf->txmode.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.
  *
  *     Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
  *     the transmit function to use default values.
Signature · 1 line
2.7.5
author
#43 lore raw

PATCH v12 1/1 ethdev: new Rx/Tx offloads API

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure() and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup().
If any offloading is enabled in rte_eth_dev_configure() by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup().
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure(), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup().
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure() and is reuqested to be enabled in rte_eth_[rt]x_queue_setup(), it must be per-queue type, otherwise trigger an error log.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup() function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get().

In the beginning of [rt]x_queue_setup() of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

---
v12:
fix coding style warning

v11:
This patch set is based on 18.05-rc2 .
document update according to feedback
revise rte_ethdev.h for doxygen

v10:
sorry, miss the code change, fix the buidling error

v9:
replace RTE_PMD_DEBUG_TRACE with ethdev_log(ERR, in ethdev to avoid failure of application which hasn't been completely converted to new offload API.

v8:
Revise PMD codes to comply with offload API in v7
update document

v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer. Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 doc/guides/prog_guide/poll_mode_drv.rst |  28 ++++--
 doc/guides/rel_notes/release_18_05.rst  |   8 ++
 drivers/net/avf/avf_rxtx.c              |   5 +-
 drivers/net/bnxt/bnxt_ethdev.c          |  17 ----
 drivers/net/cxgbe/cxgbe_ethdev.c        |  50 +---------
 drivers/net/dpaa/dpaa_ethdev.c          |  16 ----
 drivers/net/dpaa2/dpaa2_ethdev.c        |  16 ----
 drivers/net/e1000/em_ethdev.c           |  19 ----
 drivers/net/e1000/em_rxtx.c             |  64 ++-----------
 drivers/net/e1000/igb_rxtx.c            |  64 ++-----------
 drivers/net/ena/ena_ethdev.c            |  65 +------------
 drivers/net/failsafe/failsafe_ops.c     |  81 ----------------
 drivers/net/fm10k/fm10k_ethdev.c        |  82 ++--------------
 drivers/net/i40e/i40e_rxtx.c            |  58 ++----------
 drivers/net/ixgbe/ixgbe_ethdev.c        |  38 --------
 drivers/net/ixgbe/ixgbe_rxtx.c          |  66 ++-----------
 drivers/net/mlx4/mlx4_rxq.c             |  43 ++-------
 drivers/net/mlx4/mlx4_txq.c             |  42 ++------
 drivers/net/mlx5/mlx5_ethdev.c          |  22 -----
 drivers/net/mlx5/mlx5_rxq.c             |  50 ++--------
 drivers/net/mlx5/mlx5_txq.c             |  44 +--------
 drivers/net/mvpp2/mrvl_ethdev.c         |  97 +------------------
 drivers/net/nfp/nfp_net.c               | 163 --------------------------------
 drivers/net/octeontx/octeontx_ethdev.c  |  72 +-------------
 drivers/net/sfc/sfc_ethdev.c            |   9 +-
 drivers/net/sfc/sfc_rx.c                |  42 ++------
 drivers/net/sfc/sfc_rx.h                |   3 +-
 drivers/net/sfc/sfc_tx.c                |  42 ++------
 drivers/net/sfc/sfc_tx.h                |   3 +-
 drivers/net/tap/rte_eth_tap.c           |  88 ++---------------
 drivers/net/thunderx/nicvf_ethdev.c     |  70 ++------------
 drivers/net/virtio/virtio_rxtx.c        |   9 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c    |  16 ----
 drivers/net/vmxnet3/vmxnet3_rxtx.c      |   8 +-
 lib/librte_ethdev/rte_ethdev.c          |  86 +++++++++++++++++
 lib/librte_ethdev/rte_ethdev.h          |  20 +++-
 36 files changed, 257 insertions(+), 1349 deletions(-)
doc/guides/prog_guide/poll_mode_drv.rst +22 -6
index 09a93ba..bbb85f0 100644
@@ -297,16 +297,32 @@ Per-Port and Per-Queue Offloads
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 In the DPDK offload API, offloads are divided into per-port and per-queue offloads.
+A per-queue offloading can be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offload is the one supported by device but not per-queue type.
+A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offloading must be enabled or disabled on all queues at the same time.
+Any offloading is per-queue or pure per-port type, but can't be both types at same devices.
+A per-port offloading can be enabled or disabled on all queues at the same time.
+It is certain that both per-queue and pure per-port offloading are per-port type.
 The different offloads capabilities can be queried using ``rte_eth_dev_info_get()``.
+The dev_info->[rt]x_queue_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.
+The dev_info->[rt]x_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.
 Supported offloads can be either per-port or per-queue.
 
 Offloads are enabled using the existing ``DEV_TX_OFFLOAD_*`` or ``DEV_RX_OFFLOAD_*`` flags.
-Per-port offload configuration is set using ``rte_eth_dev_configure``.
-Per-queue offload configuration is set using ``rte_eth_rx_queue_setup`` and ``rte_eth_tx_queue_setup``.
-To enable per-port offload, the offload should be set on both device configuration and queue setup.
-In case of a mixed configuration the queue setup shall return with an error.
-To enable per-queue offload, the offload can be set only on the queue setup.
-Offloads which are not enabled are disabled by default.
+Any requested offloading by application must be within the device capabilities.
+Any offloading is disabled by default if it is not set in the parameter
+dev_conf->[rt]xmode.offloads to ``rte_eth_dev_configure()`` and
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup()``.
+If any offloading is enabled in ``rte_eth_dev_configure()`` by application,
+it is enabled on all queues no matter whether it is per-queue or
+per-port type and no matter whether it is set or cleared in
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup()``.
+If a per-queue offloading hasn't been enabled in ``rte_eth_dev_configure()``,
+it can be enabled or disabled in ``rte_eth_[rt]x_queue_setup()`` for individual queue.
+A new added offloads in [rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup()`` input by application
+is the one which hasn't been enabled in ``rte_eth_dev_configure()`` and is requested to be enabled
+in ``rte_eth_[rt]x_queue_setup()``, it must be per-queue type, otherwise trigger an error log.
 
 For an application to use the Tx offloads API it should set the ``ETH_TXQ_FLAGS_IGNORE`` flag in the ``txq_flags`` field located in ``rte_eth_txconf`` struct.
 In such cases it is not required to set other flags in ``txq_flags``.
doc/guides/rel_notes/release_18_05.rst +8 -0
index 0ae61e8..716e9f4 100644
@@ -303,6 +303,14 @@ API Changes
   * ``rte_flow_create()`` API count action now requires the ``struct rte_flow_action_count``.
   * ``rte_flow_query()`` API parameter changed from action type to action structure.
 
+* ethdev: changes to offload API
+
+   A pure per-port offloading isn't requested to be repeated in [rt]x_conf->offloads to
+   ``rte_eth_[rt]x_queue_setup()``. Now any offloading enabled in ``rte_eth_dev_configure()``
+   can't be disabled by ``rte_eth_[rt]x_queue_setup()``. Any new added offloading which has
+   not been enabled in ``rte_eth_dev_configure()`` and is requested to be enabled in
+   ``rte_eth_[rt]x_queue_setup()`` must be per-queue type, otherwise trigger an error log.
+
 
 ABI Changes
 -----------
drivers/net/avf/avf_rxtx.c +4 -1
index 1824ed7..e03a136 100644
@@ -435,9 +435,12 @@ avf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	uint32_t ring_size;
 	uint16_t tx_rs_thresh, tx_free_thresh;
 	uint16_t i, base, bsf, tc_mapping;
+	uint64_t offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+
 	if (nb_desc % AVF_ALIGN_RING_DESC != 0 ||
 	    nb_desc > AVF_MAX_RING_DESC ||
 	    nb_desc < AVF_MIN_RING_DESC) {
@@ -474,7 +477,7 @@ avf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->free_thresh = tx_free_thresh;
 	txq->queue_id = queue_idx;
 	txq->port_id = dev->data->port_id;
-	txq->offloads = tx_conf->offloads;
+	txq->offloads = offloads;
 	txq->tx_deferred_start = tx_conf->tx_deferred_start;
 
 	/* Allocate software ring */
drivers/net/bnxt/bnxt_ethdev.c +0 -17
index 348129d..d00b99f 100644
@@ -500,25 +500,8 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
 static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
-	uint64_t tx_offloads = eth_dev->data->dev_conf.txmode.offloads;
 	uint64_t rx_offloads = eth_dev->data->dev_conf.rxmode.offloads;
 
-	if (tx_offloads != (tx_offloads & BNXT_DEV_TX_OFFLOAD_SUPPORT)) {
-		PMD_DRV_LOG
-			(ERR,
-			 "Tx offloads requested 0x%" PRIx64 " supported 0x%x\n",
-			 tx_offloads, BNXT_DEV_TX_OFFLOAD_SUPPORT);
-		return -ENOTSUP;
-	}
-
-	if (rx_offloads != (rx_offloads & BNXT_DEV_RX_OFFLOAD_SUPPORT)) {
-		PMD_DRV_LOG
-			(ERR,
-			 "Rx offloads requested 0x%" PRIx64 " supported 0x%x\n",
-			    rx_offloads, BNXT_DEV_RX_OFFLOAD_SUPPORT);
-		return -ENOTSUP;
-	}
-
 	bp->rx_queues = (void *)eth_dev->data->rx_queues;
 	bp->tx_queues = (void *)eth_dev->data->tx_queues;
 
drivers/net/cxgbe/cxgbe_ethdev.c +5 -45

86 lines not on this page · raw message

drivers/net/dpaa/dpaa_ethdev.c +0 -16
index 6bf8c15..199afdd 100644
@@ -176,14 +176,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* Rx offloads validation */
-	if (~(dev_rx_offloads_sup | dev_rx_offloads_nodis) & rx_offloads) {
-		DPAA_PMD_ERR(
-		"Rx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			rx_offloads,
-			dev_rx_offloads_sup | dev_rx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_rx_offloads_nodis & ~rx_offloads) {
 		DPAA_PMD_WARN(
 		"Rx offloads non configurable - requested 0x%" PRIx64
@@ -192,14 +184,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
 	}
 
 	/* Tx offloads validation */
-	if (~(dev_tx_offloads_sup | dev_tx_offloads_nodis) & tx_offloads) {
-		DPAA_PMD_ERR(
-		"Tx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			tx_offloads,
-			dev_tx_offloads_sup | dev_tx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_tx_offloads_nodis & ~tx_offloads) {
 		DPAA_PMD_WARN(
 		"Tx offloads non configurable - requested 0x%" PRIx64
drivers/net/dpaa2/dpaa2_ethdev.c +0 -16
index c304b82..de8d83a 100644
@@ -309,14 +309,6 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* Rx offloads validation */
-	if (~(dev_rx_offloads_sup | dev_rx_offloads_nodis) & rx_offloads) {
-		DPAA2_PMD_ERR(
-		"Rx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			rx_offloads,
-			dev_rx_offloads_sup | dev_rx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_rx_offloads_nodis & ~rx_offloads) {
 		DPAA2_PMD_WARN(
 		"Rx offloads non configurable - requested 0x%" PRIx64
@@ -325,14 +317,6 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 	}
 
 	/* Tx offloads validation */
-	if (~(dev_tx_offloads_sup | dev_tx_offloads_nodis) & tx_offloads) {
-		DPAA2_PMD_ERR(
-		"Tx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			tx_offloads,
-			dev_tx_offloads_sup | dev_tx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_tx_offloads_nodis & ~tx_offloads) {
 		DPAA2_PMD_WARN(
 		"Tx offloads non configurable - requested 0x%" PRIx64
drivers/net/e1000/em_ethdev.c +0 -19
index 694a624..4e890ad 100644
@@ -454,29 +454,10 @@ eth_em_configure(struct rte_eth_dev *dev)
 {
 	struct e1000_interrupt *intr =
 		E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 
 	PMD_INIT_FUNC_TRACE();
 	intr->flags |= E1000_FLAG_NEED_LINK_UPDATE;
 
-	eth_em_infos_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	PMD_INIT_FUNC_TRACE();
 
 	return 0;
drivers/net/e1000/em_rxtx.c +6 -58

106 lines not on this page · raw message

drivers/net/e1000/igb_rxtx.c +6 -58

102 lines not on this page · raw message

drivers/net/ena/ena_ethdev.c +4 -61

113 lines not on this page · raw message

drivers/net/failsafe/failsafe_ops.c +0 -81

115 lines not on this page · raw message

drivers/net/fm10k/fm10k_ethdev.c +8 -74

135 lines not on this page · raw message

drivers/net/i40e/i40e_rxtx.c +6 -52

96 lines not on this page · raw message

drivers/net/ixgbe/ixgbe_ethdev.c +0 -38
index 91179e9..320ab21 100644
@@ -2365,9 +2365,6 @@ ixgbe_dev_configure(struct rte_eth_dev *dev)
 		IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
 	struct ixgbe_adapter *adapter =
 		(struct ixgbe_adapter *)dev->data->dev_private;
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 	int ret;
 
 	PMD_INIT_FUNC_TRACE();
@@ -2379,22 +2376,6 @@ ixgbe_dev_configure(struct rte_eth_dev *dev)
 		return ret;
 	}
 
-	ixgbe_dev_info_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	/* set flag to update link status after init */
 	intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
 
@@ -4965,29 +4946,10 @@ ixgbevf_dev_configure(struct rte_eth_dev *dev)
 	struct rte_eth_conf *conf = &dev->data->dev_conf;
 	struct ixgbe_adapter *adapter =
 			(struct ixgbe_adapter *)dev->data->dev_private;
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 
 	PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
 		     dev->data->port_id);
 
-	ixgbevf_dev_info_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	/*
 	 * VF has no ability to enable/disable HW CRC
 	 * Keep the persistent behavior the same as Host PF
drivers/net/ixgbe/ixgbe_rxtx.c +6 -60

110 lines not on this page · raw message

drivers/net/mlx4/mlx4_rxq.c +8 -35

77 lines not on this page · raw message

drivers/net/mlx4/mlx4_txq.c +6 -36

66 lines not on this page · raw message

drivers/net/mlx5/mlx5_ethdev.c +0 -22
index 746b94f..df369cd 100644
@@ -330,30 +330,8 @@ mlx5_dev_configure(struct rte_eth_dev *dev)
 	unsigned int reta_idx_n;
 	const uint8_t use_app_rss_key =
 		!!dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key;
-	uint64_t supp_tx_offloads = mlx5_get_tx_port_offloads(dev);
-	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
-	uint64_t supp_rx_offloads =
-		(mlx5_get_rx_port_offloads() |
-		 mlx5_get_rx_queue_offloads(dev));
-	uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
 	int ret = 0;
 
-	if ((tx_offloads & supp_tx_offloads) != tx_offloads) {
-		DRV_LOG(ERR,
-			"port %u some Tx offloads are not supported requested"
-			" 0x%" PRIx64 " supported 0x%" PRIx64,
-			dev->data->port_id, tx_offloads, supp_tx_offloads);
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
-	if ((rx_offloads & supp_rx_offloads) != rx_offloads) {
-		DRV_LOG(ERR,
-			"port %u some Rx offloads are not supported requested"
-			" 0x%" PRIx64 " supported 0x%" PRIx64,
-			dev->data->port_id, rx_offloads, supp_rx_offloads);
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
 	if (use_app_rss_key &&
 	    (dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len !=
 	     rss_hash_default_key_len)) {
drivers/net/mlx5/mlx5_rxq.c +7 -43

82 lines not on this page · raw message

drivers/net/mlx5/mlx5_txq.c +2 -42

62 lines not on this page · raw message

drivers/net/mvpp2/mrvl_ethdev.c +3 -94

139 lines not on this page · raw message

drivers/net/nfp/nfp_net.c +0 -163

196 lines not on this page · raw message

drivers/net/octeontx/octeontx_ethdev.c +5 -67

117 lines not on this page · raw message

drivers/net/sfc/sfc_ethdev.c +7 -2
index e42d553..fc2b254 100644
@@ -413,14 +413,16 @@ sfc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	int rc;
+	uint64_t offloads;
 
 	sfc_log_init(sa, "RxQ=%u nb_rx_desc=%u socket_id=%u",
 		     rx_queue_id, nb_rx_desc, socket_id);
 
 	sfc_adapter_lock(sa);
 
+	offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
 	rc = sfc_rx_qinit(sa, rx_queue_id, nb_rx_desc, socket_id,
-			  rx_conf, mb_pool);
+			  rx_conf, mb_pool, offloads);
 	if (rc != 0)
 		goto fail_rx_qinit;
 
@@ -469,13 +471,16 @@ sfc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	int rc;
+	uint64_t offloads;
 
 	sfc_log_init(sa, "TxQ = %u, nb_tx_desc = %u, socket_id = %u",
 		     tx_queue_id, nb_tx_desc, socket_id);
 
 	sfc_adapter_lock(sa);
 
-	rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id, tx_conf);
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+	rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id,
+			  tx_conf, offloads);
 	if (rc != 0)
 		goto fail_tx_qinit;
 
drivers/net/sfc/sfc_rx.c +9 -33

86 lines not on this page · raw message

drivers/net/sfc/sfc_rx.h +2 -1
index 3fba7d8..2898fe5 100644
@@ -138,7 +138,8 @@ void sfc_rx_stop(struct sfc_adapter *sa);
 int sfc_rx_qinit(struct sfc_adapter *sa, unsigned int rx_queue_id,
 		 uint16_t nb_rx_desc, unsigned int socket_id,
 		 const struct rte_eth_rxconf *rx_conf,
-		 struct rte_mempool *mb_pool);
+		 struct rte_mempool *mb_pool,
+		 uint64_t offloads);
 void sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
drivers/net/sfc/sfc_tx.c +9 -33

83 lines not on this page · raw message

drivers/net/sfc/sfc_tx.h +2 -1
index c2e5f13..d2b2c4d 100644
@@ -121,7 +121,8 @@ void sfc_tx_close(struct sfc_adapter *sa);
 
 int sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 		 uint16_t nb_tx_desc, unsigned int socket_id,
-		 const struct rte_eth_txconf *tx_conf);
+		 const struct rte_eth_txconf *tx_conf,
+		 uint64_t offloads);
 void sfc_tx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 
 void sfc_tx_qflush_done(struct sfc_txq *txq);
drivers/net/tap/rte_eth_tap.c +8 -80

123 lines not on this page · raw message

drivers/net/thunderx/nicvf_ethdev.c +8 -62

122 lines not on this page · raw message

drivers/net/virtio/virtio_rxtx.c +2 -7
index a8aa87b..92fab21 100644
@@ -385,10 +385,9 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
 			uint16_t queue_idx,
 			uint16_t nb_desc,
 			unsigned int socket_id __rte_unused,
-			const struct rte_eth_rxconf *rx_conf,
+			const struct rte_eth_rxconf *rx_conf __rte_unused,
 			struct rte_mempool *mp)
 {
-	const struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 	uint16_t vtpci_queue_idx = 2 * queue_idx + VTNET_SQ_RQ_QUEUE_IDX;
 	struct virtio_hw *hw = dev->data->dev_private;
 	struct virtqueue *vq = hw->vqs[vtpci_queue_idx];
@@ -408,10 +407,6 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
 			"Cannot allocate mbufs for rx virtqueue");
 	}
 
-	if ((rx_conf->offloads ^ rxmode->offloads) &
-	    VIRTIO_PMD_PER_DEVICE_RX_OFFLOADS)
-		return -EINVAL;
-
 	dev->data->rx_queues[queue_idx] = rxvq;
 
 	return 0;
@@ -504,7 +499,7 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	PMD_INIT_FUNC_TRACE();
 
 	/* cannot use simple rxtx funcs with multisegs or offloads */
-	if (tx_conf->offloads)
+	if (dev->data->dev_conf.txmode.offloads)
 		hw->use_simple_tx = 0;
 
 	if (nb_desc == 0 || nb_desc > vq->vq_nentries)
drivers/net/vmxnet3/vmxnet3_ethdev.c +0 -16
index c850241..ba932ff 100644
@@ -393,25 +393,9 @@ vmxnet3_dev_configure(struct rte_eth_dev *dev)
 	const struct rte_memzone *mz;
 	struct vmxnet3_hw *hw = dev->data->dev_private;
 	size_t size;
-	uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
-	if ((rx_offloads & VMXNET3_RX_OFFLOAD_CAP) != rx_offloads) {
-		RTE_LOG(ERR, PMD, "Requested RX offloads 0x%" PRIx64
-			" do not match supported 0x%" PRIx64,
-			rx_offloads, (uint64_t)VMXNET3_RX_OFFLOAD_CAP);
-		return -ENOTSUP;
-	}
-
-	if ((tx_offloads & VMXNET3_TX_OFFLOAD_CAP) != tx_offloads) {
-		RTE_LOG(ERR, PMD, "Requested TX offloads 0x%" PRIx64
-			" do not match supported 0x%" PRIx64,
-			tx_offloads, (uint64_t)VMXNET3_TX_OFFLOAD_CAP);
-		return -ENOTSUP;
-	}
-
 	if (dev->data->nb_tx_queues > VMXNET3_MAX_TX_QUEUES ||
 	    dev->data->nb_rx_queues > VMXNET3_MAX_RX_QUEUES) {
 		PMD_INIT_LOG(ERR, "ERROR: Number of queues not supported");
drivers/net/vmxnet3/vmxnet3_rxtx.c +1 -7
index f6e2d98..cf85f3d 100644
@@ -1013,7 +1013,7 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
 			   uint16_t queue_idx,
 			   uint16_t nb_desc,
 			   unsigned int socket_id,
-			   const struct rte_eth_txconf *tx_conf)
+			   const struct rte_eth_txconf *tx_conf __rte_unused)
 {
 	struct vmxnet3_hw *hw = dev->data->dev_private;
 	const struct rte_memzone *mz;
@@ -1025,12 +1025,6 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
 
 	PMD_INIT_FUNC_TRACE();
 
-	if ((tx_conf->txq_flags & ETH_TXQ_FLAGS_NOXSUMSCTP) !=
-	    ETH_TXQ_FLAGS_NOXSUMSCTP) {
-		PMD_INIT_LOG(ERR, "SCTP checksum offload not supported");
-		return -EINVAL;
-	}
-
 	txq = rte_zmalloc("ethdev_tx_queue", sizeof(struct vmxnet3_tx_queue),
 			  RTE_CACHE_LINE_SIZE);
 	if (txq == NULL) {
lib/librte_ethdev/rte_ethdev.c +86 -0

104 lines not on this page · raw message

lib/librte_ethdev/rte_ethdev.h +17 -3
index 7ccf4ba..e719442 100644
@@ -1067,9 +1067,9 @@ struct rte_eth_dev_info {
 	uint16_t max_vfs; /**< Maximum number of VFs. */
 	uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
 	uint64_t rx_offload_capa;
-	/**< Device per port RX offload capabilities. */
+	/**< All RX offload capabilities including all per queue ones */
 	uint64_t tx_offload_capa;
-	/**< Device per port TX offload capabilities. */
+	/**< All TX offload capabilities.including all per-queue ones */
 	uint64_t rx_queue_offload_capa;
 	/**< Device per queue RX offload capabilities. */
 	uint64_t tx_queue_offload_capa;
@@ -1546,6 +1546,13 @@ const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload);
  *        The Rx offload bitfield API is obsolete and will be deprecated.
  *        Applications should set the ignore_bitfield_offloads bit on *rxmode*
  *        structure and use offloads field to set per-port offloads instead.
+ *     -  Any offloading set in eth_conf->[rt]xmode.offloads must be within
+ *        the [rt]x_offload_capa returned from rte_eth_dev_infos_get().
+ *        Any type of device supported offloading set in the input argument
+ *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
+ *        on all [RT]x queues and it can't be disabled no matter whether
+ *        it is cleared or set in the input argument [rt]x_conf->offloads
+ *        to rte_eth_[rt]x_queue_setup().
  *     - the Receive Side Scaling (RSS) configuration when using multiple RX
  *         queues per port.
  *
@@ -1602,6 +1609,10 @@ rte_eth_dev_is_removed(uint16_t port_id);
  *   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.
  * @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.
@@ -1660,7 +1671,10 @@ int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
  *     should set it to ETH_TXQ_FLAGS_IGNORE and use
  *     the offloads field below.
  *   - The *offloads* member contains Tx offloads to be enabled.
- *     Offloads which are not set cannot be used on the datapath.
+ *     If an offloading set in tx_conf->offloads
+ *     hasn't been set in the input argument eth_conf->txmode.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.
  *
  *     Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
  *     the transmit function to use default values.
Signature · 1 line
2.7.5
#44 lore raw

Re: [PATCH v12] ethdev: new Rx/Tx offloads API

Hi,

A first general comment: a lot of spaces are still inside parens. You can grep '( )'.

10/05/2018 13:56, Wei Dai:

doc/guides/prog_guide/poll_mode_drv.rst Per-Port and Per-Queue Offloads · line 301

Quoted 4 lines
doc/guides/prog_guide/poll_mode_drv.rst +2 -0
+A per-queue offloading can be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offload is the one supported by device but not per-queue type.

Another way to say it: pure per-port offloads are not directly advertised but are the port offloads capabilities minus the queue capabilities. port capabilities = pure per-port capabilities + queue capabilities

doc/guides/prog_guide/poll_mode_drv.rst Per-Port and Per-Queue Offloads · line 305

Quoted 4 lines
doc/guides/prog_guide/poll_mode_drv.rst +4 -0
+A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offloading must be enabled or disabled on all queues at the same time.
+Any offloading is per-queue or pure per-port type, but can't be both types at same devices.
+A per-port offloading can be enabled or disabled on all queues at the same time.

This sentence is useless: it says any offload can be setup for the whole port.

Quoted 1 line

+It is certain that both per-queue and pure per-port offloading are per-port type.

This sentence is confusing. I cannot understand it.

doc/guides/prog_guide/poll_mode_drv.rst Per-Port and Per-Queue Offloads · line 309

Quoted 3 lines

The different offloads capabilities can be queried using ``rte_eth_dev_info_get()``.

doc/guides/prog_guide/poll_mode_drv.rst +2 -0
+The dev_info->[rt]x_queue_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.
+The dev_info->[rt]x_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.

If you want to stick with pure per-port wording, you should say [rt]x_offload_capa is the port capabilities (including pure per-port and per-queue).

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1151

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	/* Any requested offloading must be within its device capabilities */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		ethdev_log(ERR, "ethdev port_id=%d requested Rx offloads "
+				"0x%" PRIx64 " doesn't match Rx offloads "
+				"capabilities 0x%" PRIx64 " in %s( )\n",
+				port_id,
+				local_conf.rxmode.offloads,
+				dev_info.rx_offload_capa,
+				__func__);

We could have a comment saying that an error will be returned in next version.

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1161

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		ethdev_log(ERR, "ethdev port_id=%d requested Tx offloads "
+				"0x%" PRIx64 " doesn't match Tx offloads "
+				"capabilities 0x%" PRIx64 " in %s( )\n",
+				port_id,
+				local_conf.txmode.offloads,
+				dev_info.tx_offload_capa,
+				__func__);

idem

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1536

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.c +9 -0
+	}
 
 
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.

I think the last sentence is useless.

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +12 -0
+	 */
+	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) !=

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1558

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	     local_conf.offloads) {
+		ethdev_log(ERR, "Ethdev port_id=%d rx_queue_id=%d, new "
+				"added offloads 0x%" PRIx64 " must be "
+				"within pre-queue offload capabilities 0x%"
+				PRIx64 " in %s( )\n",
+				port_id,
+				rx_queue_id,
+				local_conf.offloads,
+				dev_info.rx_queue_offload_capa,
+				__func__);

idem, we can have a comment about error in next version

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1070

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +1 -0
+	}
lib/librte_ethdev/rte_ethdev.h +1 -1
 	uint64_t rx_offload_capa;
-	/**< Device per port RX offload capabilities. */
+	/**< All RX offload capabilities including all per queue ones */

OK
per queue -> per-queue

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1072

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.h +1 -1
 	uint64_t tx_offload_capa;
-	/**< Device per port TX offload capabilities. */
+	/**< All TX offload capabilities.including all per-queue ones */

Typo: there is a dot instead of space.

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1074

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +0 -0
 	uint64_t rx_queue_offload_capa;
 	/**< Device per queue RX offload capabilities. */

Here you should add more comments:
No need to repeat flags already enabled at port level. A flag enabled at port level, cannot be disabled at queue level.

Quoted 2 lines

+ * - Any offloading set in eth_conf->[rt]xmode.offloads must be within
+ * the [rt]x_offload_capa returned from rte_eth_dev_infos_get().

OK

Quoted 5 lines
+ *        Any type of device supported offloading set in the input argument
+ *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
+ *        on all [RT]x queues and it can't be disabled no matter whether
+ *        it is cleared or set in the input argument [rt]x_conf->offloads
+ *        to rte_eth_[rt]x_queue_setup().

last part can be simpler: cannot be disabled in queue setup. "[RT]x queues" can be simply "queues".

Quoted 4 lines
+ *   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.

OK
Another wording:
The offloads not advertised in queue capabilities, and not already enabled at port level, are rejected.

#45 lore raw

Re: [PATCH v12] ethdev: new Rx/Tx offloads API

Wei Dai,
Do you agree with my comments?
Could we have a wording patch to squash in RC3?

10/05/2018 23:39, Thomas Monjalon:

Quoted 152 lines

Hi,

A first general comment: a lot of spaces are still inside parens. You can grep '( )'.

10/05/2018 13:56, Wei Dai:

doc/guides/prog_guide/poll_mode_drv.rst Per-Port and Per-Queue Offloads · line 301

Quoted 4 lines
doc/guides/prog_guide/poll_mode_drv.rst +2 -0
+A per-queue offloading can be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offload is the one supported by device but not per-queue type.

Another way to say it: pure per-port offloads are not directly advertised but are the port offloads capabilities minus the queue capabilities. port capabilities = pure per-port capabilities + queue capabilities

doc/guides/prog_guide/poll_mode_drv.rst Per-Port and Per-Queue Offloads · line 305

Quoted 4 lines
doc/guides/prog_guide/poll_mode_drv.rst +4 -0
+A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offloading must be enabled or disabled on all queues at the same time.
+Any offloading is per-queue or pure per-port type, but can't be both types at same devices.
+A per-port offloading can be enabled or disabled on all queues at the same time.

This sentence is useless: it says any offload can be setup for the whole port.

Quoted 1 line

+It is certain that both per-queue and pure per-port offloading are per-port type.

This sentence is confusing. I cannot understand it.

doc/guides/prog_guide/poll_mode_drv.rst Per-Port and Per-Queue Offloads · line 309

Quoted 3 lines

The different offloads capabilities can be queried using ``rte_eth_dev_info_get()``.

doc/guides/prog_guide/poll_mode_drv.rst +2 -0
+The dev_info->[rt]x_queue_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.
+The dev_info->[rt]x_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.

If you want to stick with pure per-port wording, you should say [rt]x_offload_capa is the port capabilities (including pure per-port and per-queue).

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1151

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	/* Any requested offloading must be within its device capabilities */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		ethdev_log(ERR, "ethdev port_id=%d requested Rx offloads "
+				"0x%" PRIx64 " doesn't match Rx offloads "
+				"capabilities 0x%" PRIx64 " in %s( )\n",
+				port_id,
+				local_conf.rxmode.offloads,
+				dev_info.rx_offload_capa,
+				__func__);

We could have a comment saying that an error will be returned in next version.

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1161

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		ethdev_log(ERR, "ethdev port_id=%d requested Tx offloads "
+				"0x%" PRIx64 " doesn't match Tx offloads "
+				"capabilities 0x%" PRIx64 " in %s( )\n",
+				port_id,
+				local_conf.txmode.offloads,
+				dev_info.tx_offload_capa,
+				__func__);

idem

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1536

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.c +9 -0
+	}
 
 
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.

I think the last sentence is useless.

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +12 -0
+	 */
+	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) !=

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1558

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	     local_conf.offloads) {
+		ethdev_log(ERR, "Ethdev port_id=%d rx_queue_id=%d, new "
+				"added offloads 0x%" PRIx64 " must be "
+				"within pre-queue offload capabilities 0x%"
+				PRIx64 " in %s( )\n",
+				port_id,
+				rx_queue_id,
+				local_conf.offloads,
+				dev_info.rx_queue_offload_capa,
+				__func__);

idem, we can have a comment about error in next version

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1070

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +1 -0
+	}
lib/librte_ethdev/rte_ethdev.h +1 -1
 	uint64_t rx_offload_capa;
-	/**< Device per port RX offload capabilities. */
+	/**< All RX offload capabilities including all per queue ones */

OK
per queue -> per-queue

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1072

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.h +1 -1
 	uint64_t tx_offload_capa;
-	/**< Device per port TX offload capabilities. */
+	/**< All TX offload capabilities.including all per-queue ones */

Typo: there is a dot instead of space.

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1074

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +0 -0
 	uint64_t rx_queue_offload_capa;
 	/**< Device per queue RX offload capabilities. */

Here you should add more comments:
No need to repeat flags already enabled at port level. A flag enabled at port level, cannot be disabled at queue level.

Quoted 2 lines

+ * - Any offloading set in eth_conf->[rt]xmode.offloads must be within
+ * the [rt]x_offload_capa returned from rte_eth_dev_infos_get().

OK

Quoted 5 lines
+ *        Any type of device supported offloading set in the input argument
+ *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
+ *        on all [RT]x queues and it can't be disabled no matter whether
+ *        it is cleared or set in the input argument [rt]x_conf->offloads
+ *        to rte_eth_[rt]x_queue_setup().

last part can be simpler: cannot be disabled in queue setup. "[RT]x queues" can be simply "queues".

Quoted 4 lines
+ *   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.

OK
Another wording:
The offloads not advertised in queue capabilities, and not already enabled at port level, are rejected.

author
#46 lore raw

Re: [PATCH v12] ethdev: new Rx/Tx offloads API

Hi, Thomas & Ferruh
Thanks for your feedback.
I agree with your comments and I am working on the latest commit of the repo dpdk-next-net. I will submit a new patch to adopt your suggestion.
Please wait for a while ...

Quoted 192 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, May 14, 2018 4:37 PM
To: Dai, Wei <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v12] ethdev: new Rx/Tx offloads API

Wei Dai,
Do you agree with my comments?
Could we have a wording patch to squash in RC3?

10/05/2018 23:39, Thomas Monjalon:

Quoted 9 lines

Hi,

A first general comment: a lot of spaces are still inside parens. You can grep '( )'.

10/05/2018 13:56, Wei Dai:

doc/guides/prog_guide/poll_mode_drv.rst

Quoted 3 lines
doc/guides/prog_guide/poll_mode_drv.rst +1 -0
+A per-queue offloading can be enabled on a queue and disabled on

another queue at the same time.

Quoted 1 line
Quoted 1 line

+A pure per-port offload is the one supported by device but not

per-queue type.

Quoted 3 lines

Another way to say it: pure per-port offloads are not directly advertised but are the port offloads capabilities minus the queue

capabilities.

Quoted 3 lines

port capabilities = pure per-port capabilities + queue capabilities

Quoted 1 line

+A pure per-port offloading can't be enabled on a queue and disabled on

another queue at the same time.

Quoted 1 line
Quoted 1 line

+A pure per-port offloading must be enabled or disabled on all queues at

the same time.

Quoted 1 line
Quoted 1 line

+Any offloading is per-queue or pure per-port type, but can't be both

types at same devices.

Quoted 1 line
Quoted 1 line

+A per-port offloading can be enabled or disabled on all queues at the

same time.

Quoted 2 lines

This sentence is useless: it says any offload can be setup for the whole

port.

Quoted 2 lines
Quoted 2 lines

+It is certain that both per-queue and pure per-port offloading are

per-port type.

Quoted 5 lines

This sentence is confusing. I cannot understand it.

Quoted 1 line

The different offloads capabilities can be queried using

``rte_eth_dev_info_get()``.

Quoted 1 line
Quoted 1 line

+The dev_info->[rt]x_queue_offload_capa returned from

``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.

Quoted 1 line
Quoted 1 line

+The dev_info->[rt]x_offload_capa returned from

``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.

Quoted 3 lines

If you want to stick with pure per-port wording, you should say [rt]x_offload_capa is the port capabilities (including pure per-port and

per-queue).

Quoted 5 lines

lib/librte_ethdev/rte_ethdev.c

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +1 -0
+	/* Any requested offloading must be within its device capabilities

*/

Quoted 11 lines

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1151

Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c +9 -0
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		ethdev_log(ERR, "ethdev port_id=%d requested Rx offloads "
+				"0x%" PRIx64 " doesn't match Rx offloads "
+				"capabilities 0x%" PRIx64 " in %s( )\n",
+				port_id,
+				local_conf.rxmode.offloads,
+				dev_info.rx_offload_capa,
+				__func__);

We could have a comment saying that an error will be returned in next

version.

Quoted 71 lines

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, · line 1161

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		ethdev_log(ERR, "ethdev port_id=%d requested Tx offloads "
+				"0x%" PRIx64 " doesn't match Tx offloads "
+				"capabilities 0x%" PRIx64 " in %s( )\n",
+				port_id,
+				local_conf.txmode.offloads,
+				dev_info.tx_offload_capa,
+				__func__);

idem

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1536

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.c +9 -0
+	}
 
 
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.

I think the last sentence is useless.

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +12 -0
+	 */
+	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) !=

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1558

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	     local_conf.offloads) {
+		ethdev_log(ERR, "Ethdev port_id=%d rx_queue_id=%d, new "
+				"added offloads 0x%" PRIx64 " must be "
+				"within pre-queue offload capabilities 0x%"
+				PRIx64 " in %s( )\n",
+				port_id,
+				rx_queue_id,
+				local_conf.offloads,
+				dev_info.rx_queue_offload_capa,
+				__func__);

idem, we can have a comment about error in next version

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1070

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +1 -0
+	}
lib/librte_ethdev/rte_ethdev.h +1 -1
 	uint64_t rx_offload_capa;
-	/**< Device per port RX offload capabilities. */
+	/**< All RX offload capabilities including all per queue ones */

OK
per queue -> per-queue

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1072

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.h +1 -1
 	uint64_t tx_offload_capa;
-	/**< Device per port TX offload capabilities. */
+	/**< All TX offload capabilities.including all per-queue ones */

Typo: there is a dot instead of space.

Quoted 9 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1074

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +0 -0
 	uint64_t rx_queue_offload_capa;
 	/**< Device per queue RX offload capabilities. */

Here you should add more comments:
No need to repeat flags already enabled at port level. A flag enabled at port level, cannot be disabled at queue level.

Quoted 1 line

+ * - Any offloading set in eth_conf->[rt]xmode.offloads must be

within

Quoted 1 line
Quoted 1 line

+ * the [rt]x_offload_capa returned from

rte_eth_dev_infos_get().

Quoted 4 lines

OK

Quoted 1 line

+ * Any type of device supported offloading set in the input

argument

Quoted 1 line
Quoted 1 line

+ * eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is

enabled

Quoted 1 line
Quoted 1 line

+ * on all [RT]x queues and it can't be disabled no matter

whether

Quoted 1 line
Quoted 1 line

+ * it is cleared or set in the input argument

[rt]x_conf->offloads

Quoted 9 lines
Quoted 1 line

+ * to rte_eth_[rt]x_queue_setup().

last part can be simpler: cannot be disabled in queue setup. "[RT]x queues" can be simply "queues".

Quoted 3 lines
+ *   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

Quoted 6 lines
Quoted 1 line

+ * per-queue type and it is enabled for the queue.

OK
Another wording:
The offloads not advertised in queue capabilities, and not already enabled at port level, are rejected.

#47 lore raw

Re: [PATCH v12] ethdev: new Rx/Tx offloads API

In reply to Wei Dai
Quoted 37 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure() and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup().
If any offloading is enabled in rte_eth_dev_configure() by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup().
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure(), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup().
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure() and is reuqested to be enabled in rte_eth_[rt]x_queue_setup(), it must be per-queue type, otherwise trigger an error log.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup() function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get().

In the beginning of [rt]x_queue_setup() of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

Quoted 3 lines

In next-net replaced this one (v12) with existing v10.

Applied John's comments on doc.
Squashed sfc patches.

For next version of the patch can you please either get the patch from next-net and update it or make incremental changes to on top of next-net which can be squashed later into this patch.

Thanks,
ferruh

author
#48 lore raw

PATCH v13 1/1 ethdev: new Rx/Tx offloads API

In reply to Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure() and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup().
If any offloading is enabled in rte_eth_dev_configure() by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup().
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure(), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup().
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure() and is reuqested to be enabled in rte_eth_[rt]x_queue_setup(), it must be per-queue type, otherwise trigger an error log.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup() function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get().

In the beginning of [rt]x_queue_setup() of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

---
v13:
only rework on v12 according to feedback.
This version is based on commit dc33238da4be ("app/testpmd: check if CRC strip offload supported") in the repo dpdk-next-net.

v12:
fix coding style warning

v11:
This patch set is based on 18.05-rc2 .
document update according to feedback
revise rte_ethdev.h for doxygen

v10:
sorry, miss the code change, fix the buidling error

v9:
replace RTE_PMD_DEBUG_TRACE with ethdev_log(ERR, in ethdev to avoid failure of application which hasn't been completely converted to new offload API.

v8:
Revise PMD codes to comply with offload API in v7
update document

v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer. Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 doc/guides/prog_guide/poll_mode_drv.rst |  6 +++---
 lib/librte_ethdev/rte_ethdev.c          | 22 ++++++++++++----------
 lib/librte_ethdev/rte_ethdev.h          | 17 ++++++++++-------
 3 files changed, 25 insertions(+), 20 deletions(-)
doc/guides/prog_guide/poll_mode_drv.rst +3 -3
index f4e0bcd..daa858d 100644
@@ -303,12 +303,12 @@ In the DPDK offload API, offloads are divided into per-port and per-queue offloa
 * A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
 * A pure per-port offloading must be enabled or disabled on all queues at the same time.
 * Any offloading is per-queue or pure per-port type, but can't be both types at same devices.
-* A per-port offloading can be enabled or disabled on all queues at the same time.
-* It is certain that both per-queue and pure per-port offloading are per-port type.
+* Port capabilities = pre-queue capabilities + pure per-port capabilities.
+* Any supported offloading can be enabled on all queues.
 
 The different offloads capabilities can be queried using ``rte_eth_dev_info_get()``.
 The ``dev_info->[rt]x_queue_offload_capa`` returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.
-The ``dev_info->[rt]x_offload_capa`` returned from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.
+The ``dev_info->[rt]x_offload_capa`` returned from ``rte_eth_dev_info_get()`` includes all pure per-port and per-queue offloading capabilities.
 Supported offloads can be either per-port or per-queue.
 
 Offloads are enabled using the existing ``DEV_TX_OFFLOAD_*`` or ``DEV_RX_OFFLOAD_*`` flags.
lib/librte_ethdev/rte_ethdev.c +12 -10
index 3528ba1..b3ed821 100644
@@ -1166,21 +1166,23 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	     local_conf.rxmode.offloads) {
 		ethdev_log(ERR, "ethdev port_id=%d requested Rx offloads "
 				"0x%" PRIx64 " doesn't match Rx offloads "
-				"capabilities 0x%" PRIx64 " in %s( )\n",
+				"capabilities 0x%" PRIx64 " in %s()\n",
 				port_id,
 				local_conf.rxmode.offloads,
 				dev_info.rx_offload_capa,
 				__func__);
+		/* Will return -EINVAL in the next release */
 	}
 	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
 	     local_conf.txmode.offloads) {
 		ethdev_log(ERR, "ethdev port_id=%d requested Tx offloads "
 				"0x%" PRIx64 " doesn't match Tx offloads "
-				"capabilities 0x%" PRIx64 " in %s( )\n",
+				"capabilities 0x%" PRIx64 " in %s()\n",
 				port_id,
 				local_conf.txmode.offloads,
 				dev_info.tx_offload_capa,
 				__func__);
+		/* Will return -EINVAL in the next release */
 	}
 
 	/* Check that device supports requested rss hash functions. */
@@ -1556,29 +1558,29 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 	 * 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.
-	 * The underlying PMD must be aware of this point.
 	 */
 	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.
+	 * 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( ).
+	 * enabled in rte_eth_dev_configure().
 	 */
 	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
 	     local_conf.offloads) {
 		ethdev_log(ERR, "Ethdev port_id=%d rx_queue_id=%d, new "
 				"added offloads 0x%" PRIx64 " must be "
 				"within pre-queue offload capabilities 0x%"
-				PRIx64 " in %s( )\n",
+				PRIx64 " in %s()\n",
 				port_id,
 				rx_queue_id,
 				local_conf.offloads,
 				dev_info.rx_queue_offload_capa,
 				__func__);
+		/* Will return -EINVAL in the next release */
 	}
 
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
@@ -1721,29 +1723,29 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 	 * 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.
-	 * The underlying PMD must be aware of this point.
 	 */
 	local_conf.offloads &= ~dev->data->dev_conf.txmode.offloads;
 
 	/*
 	 * New added offloadings for this queue are those not enabled in
-	 * rte_eth_dev_configure( ) and they must be per-queue type.
+	 * 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( ).
+	 * enabled in rte_eth_dev_configure().
 	 */
 	if ((local_conf.offloads & dev_info.tx_queue_offload_capa) !=
 	     local_conf.offloads) {
 		ethdev_log(ERR, "Ethdev port_id=%d tx_queue_id=%d, new "
 				"added offloads 0x%" PRIx64 " must be "
 				"within pre-queue offload capabilities 0x%"
-				PRIx64 " in %s( )\n",
+				PRIx64 " in %s()\n",
 				port_id,
 				tx_queue_id,
 				local_conf.offloads,
 				dev_info.tx_queue_offload_capa,
 				__func__);
+		/* Will return -EINVAL in the next release */
 	}
 
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
lib/librte_ethdev/rte_ethdev.h +10 -7
index 78e12bf..3a7428e 100644
@@ -1067,13 +1067,18 @@ struct rte_eth_dev_info {
 	uint16_t max_vfs; /**< Maximum number of VFs. */
 	uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
 	uint64_t rx_offload_capa;
-	/**< All RX offload capabilities including all per queue ones */
+	/**<
+	 * All RX offload capabilities including all per-queue ones.
+	 * Any flag in [rt]x_offload_capa and [rt]x_queue_offload_capa
+	 * of this structure needn't be repeated in rte_eth_[rt]x_queue_setup().
+	 * A flag enabled at port level can't be disabled at queue level.
+	 */
 	uint64_t tx_offload_capa;
-	/**< All TX offload capabilities.including all per-queue ones */
+	/**< All TX offload capabilities including all per-queue ones */
 	uint64_t rx_queue_offload_capa;
-	/**< Device per queue RX offload capabilities. */
+	/**< Device per-queue RX offload capabilities. */
 	uint64_t tx_queue_offload_capa;
-	/**< Device per queue TX offload capabilities. */
+	/**< Device per-queue TX offload capabilities. */
 	uint16_t reta_size;
 	/**< Device redirection table size, the total number of entries. */
 	uint8_t hash_key_size; /**< Hash key size in bytes */
@@ -1554,9 +1559,7 @@ const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload);
  *        the [rt]x_offload_capa returned from rte_eth_dev_infos_get().
  *        Any type of device supported offloading set in the input argument
  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
- *        on all [RT]x queues and it can't be disabled no matter whether
- *        it is cleared or set in the input argument [rt]x_conf->offloads
- *        to rte_eth_[rt]x_queue_setup().
+ *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup().
  *     - the Receive Side Scaling (RSS) configuration when using multiple RX
  *         queues per port.
  *
Signature · 1 line
2.7.5
#49 lore raw

Re: [PATCH v13] ethdev: new Rx/Tx offloads API

14/05/2018 14:00, Wei Dai:

doc/guides/prog_guide/poll_mode_drv.rst In the DPDK offload API, offloads are divided into per-port and per-queue offloa · line 306

Quoted 9 lines
doc/guides/prog_guide/poll_mode_drv.rst +1 -2
@@ -303,12 +303,12 @@ In the DPDK offload API, offloads are divided into per-port and per-queue offloa
 * A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
 * A pure per-port offloading must be enabled or disabled on all queues at the same time.
 * Any offloading is per-queue or pure per-port type, but can't be both types at same devices.
-* A per-port offloading can be enabled or disabled on all queues at the same time.
-* It is certain that both per-queue and pure per-port offloading are per-port type.
+* Port capabilities = pre-queue capabilities + pure per-port capabilities.

s/pre/per/

doc/guides/prog_guide/poll_mode_drv.rst In the DPDK offload API, offloads are divided into per-port and per-queue offloa · line 311

Quoted 6 lines
doc/guides/prog_guide/poll_mode_drv.rst +2 -1
+* Any supported offloading can be enabled on all queues.
 
 The different offloads capabilities can be queried using ``rte_eth_dev_info_get()``.
 The ``dev_info->[rt]x_queue_offload_capa`` returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.
-The ``dev_info->[rt]x_offload_capa`` returned from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.
+The ``dev_info->[rt]x_offload_capa`` returned from ``rte_eth_dev_info_get()`` includes all pure per-port and per-queue offloading capabilities.

OK

doc/guides/prog_guide/poll_mode_drv.rst rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1561

Quoted 6 lines
doc/guides/prog_guide/poll_mode_drv.rst +0 -1
@@ -1556,29 +1558,29 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 	 * 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.
-	 * The underlying PMD must be aware of this point.
 	 */

OK

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1073

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.h +4 -1
@@ -1067,13 +1067,18 @@ struct rte_eth_dev_info {
 	uint16_t max_vfs; /**< Maximum number of VFs. */
 	uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
 	uint64_t rx_offload_capa;
-	/**< All RX offload capabilities including all per queue ones */
+	/**<
+	 * All RX offload capabilities including all per-queue ones.
+	 * Any flag in [rt]x_offload_capa and [rt]x_queue_offload_capa
+	 * of this structure needn't be repeated in rte_eth_[rt]x_queue_setup().

It is confusing. Better to remove this sentence about queue_setup in port capa comment.

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1074

Quoted 1 line
lib/librte_ethdev/rte_ethdev.h +1 -0
+	 * A flag enabled at port level can't be disabled at queue level.

This one too: it is a comment about port capa, not queue setup.

lib/librte_ethdev/rte_ethdev.h const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload); · line 1562

Quoted 8 lines
lib/librte_ethdev/rte_ethdev.h +1 -3
@@ -1554,9 +1559,7 @@ const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload);
  *        the [rt]x_offload_capa returned from rte_eth_dev_infos_get().
  *        Any type of device supported offloading set in the input argument
  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
- *        on all [RT]x queues and it can't be disabled no matter whether
- *        it is cleared or set in the input argument [rt]x_conf->offloads
- *        to rte_eth_[rt]x_queue_setup().
+ *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup().

OK

Missing: we must explain the "no repeat need" and
"no disable port offload on queue" constraint.
In the last review, I was suggesting such sentences:
No need to repeat flags already enabled at port level. A flag enabled at port level, cannot be disabled at queue level.
I think it should go in queue setup comments.

Opinion?

author
#50 lore raw

Re: [PATCH v13] ethdev: new Rx/Tx offloads API

Hi, Thomas
Thanks for your quick feedback.

Quoted 18 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, May 14, 2018 8:54 PM
To: Dai, Wei <[email protected]>
Cc: [email protected]; Yigit, Ferruh <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v13] ethdev: new Rx/Tx offloads API

14/05/2018 14:00, Wei Dai:

Quoted 5 lines
doc/guides/prog_guide/poll_mode_drv.rst +0 -0
@@ -303,12 +303,12 @@ In the DPDK offload API, offloads are divided

into per-port and per-queue offloa
* A pure per-port offloading can't be enabled on a queue and disabled on

another queue at the same time.

Quoted 1 line

* A pure per-port offloading must be enabled or disabled on all queues at

the same time.

Quoted 1 line

* Any offloading is per-queue or pure per-port type, but can't be both

Quoted 8 lines

types at same devices.

Quoted 1 line

-* A per-port offloading can be enabled or disabled on all queues at the

same time.

Quoted 1 line

-* It is certain that both per-queue and pure per-port offloading are

per-port type.

Quoted 1 line

+* Port capabilities = pre-queue capabilities + pure per-port capabilities.

s/pre/per/

Sorry for the typo error.

Quoted 43 lines
Quoted 4 lines

+* Any supported offloading can be enabled on all queues.

The different offloads capabilities can be queried using

``rte_eth_dev_info_get()``.

Quoted 1 line

The ``dev_info->[rt]x_queue_offload_capa`` returned from

``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.

Quoted 1 line

-The ``dev_info->[rt]x_offload_capa`` returned from

``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.

Quoted 1 line

+The ``dev_info->[rt]x_offload_capa`` returned from

``rte_eth_dev_info_get()`` includes all pure per-port and per-queue offloading capabilities.

OK

doc/guides/prog_guide/poll_mode_drv.rst rte_eth_rx_queue_setup(uint16_t port_id,

Quoted 1 line
doc/guides/prog_guide/poll_mode_drv.rst +0 -0
@@ -1556,29 +1558,29 @@ rte_eth_rx_queue_setup(uint16_t port_id,

uint16_t rx_queue_id,

doc/guides/prog_guide/poll_mode_drv.rst rte_eth_rx_queue_setup(uint16_t port_id, · line 1561

Quoted 5 lines
doc/guides/prog_guide/poll_mode_drv.rst +0 -1
 	 * 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.
-	 * The underlying PMD must be aware of this point.
 	 */

OK

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1073

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.h +4 -1
@@ -1067,13 +1067,18 @@ struct rte_eth_dev_info {
 	uint16_t max_vfs; /**< Maximum number of VFs. */
 	uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
 	uint64_t rx_offload_capa;
-	/**< All RX offload capabilities including all per queue ones */
+	/**<
+	 * All RX offload capabilities including all per-queue ones.
+	 * Any flag in [rt]x_offload_capa and [rt]x_queue_offload_capa
+	 * of this structure needn't be repeated in rte_eth_[rt]x_queue_setup().

It is confusing. Better to remove this sentence about queue_setup in port capa comment.

Quoted 4 lines

lib/librte_ethdev/rte_ethdev.h struct rte_eth_dev_info { · line 1074

Quoted 1 line
lib/librte_ethdev/rte_ethdev.h +1 -0
+	 * A flag enabled at port level can't be disabled at queue level.

This one too: it is a comment about port capa, not queue setup.

Sorry, I think I have a mistake about your feedback on v12. Will remove above 2 sentences.

Quoted 18 lines

lib/librte_ethdev/rte_ethdev.h const char * __rte_experimental

Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +0 -0
@@ -1554,9 +1559,7 @@ const char * __rte_experimental

rte_eth_dev_tx_offload_name(uint64_t offload);

lib/librte_ethdev/rte_ethdev.h const char * __rte_experimental · line 1559

Quoted 1 line
lib/librte_ethdev/rte_ethdev.h +0 -0
  *        the [rt]x_offload_capa returned from

rte_eth_dev_infos_get().

lib/librte_ethdev/rte_ethdev.h const char * __rte_experimental · line 1560

Quoted 1 line
lib/librte_ethdev/rte_ethdev.h +0 -0
  *        Any type of device supported offloading set in the input

argument

lib/librte_ethdev/rte_ethdev.h const char * __rte_experimental · line 1561

Quoted 1 line
lib/librte_ethdev/rte_ethdev.h +0 -0
  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is

enabled

lib/librte_ethdev/rte_ethdev.h const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload);

Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +1 -3
- *        on all [RT]x queues and it can't be disabled no matter whether
- *        it is cleared or set in the input argument [rt]x_conf->offloads
- *        to rte_eth_[rt]x_queue_setup().
+ *        on all queues and it can't be disabled in

rte_eth_[rt]x_queue_setup().

OK

Quoted 9 lines

Missing: we must explain the "no repeat need" and "no disable port offload on queue" constraint.
In the last review, I was suggesting such sentences:
No need to repeat flags already enabled at port level. A flag enabled at port level, cannot be disabled at queue level.
I think it should go in queue setup comments.

Opinion?

Will add this in the comments of queue_setup( ) in rte_ethdev.h

author
#51 lore raw

PATCH v14 1/1 ethdev: new Rx/Tx offloads API

In reply to Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure() and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup().
If any offloading is enabled in rte_eth_dev_configure() by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup().
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure(), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup().
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure() and is reuqested to be enabled in rte_eth_[rt]x_queue_setup(), it must be per-queue type, otherwise trigger an error log.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup() function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get().

In the beginning of [rt]x_queue_setup() of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

---
v14:
rework on v13 according to feedback.
This v14 is also based on commit dc33238da4be ("app/testpmd: check if CRC strip offload supported") in the repo dpdk-next-net.

v13:
only rework on v12 according to feedback.
This version is based on commit dc33238da4be ("app/testpmd: check if CRC strip offload supported") in the repo dpdk-next-net.

v12:
fix coding style warning

v11:
This patch set is based on 18.05-rc2 .
document update according to feedback
revise rte_ethdev.h for doxygen

v10:
sorry, miss the code change, fix the buidling error

v9:
replace RTE_PMD_DEBUG_TRACE with ethdev_log(ERR, in ethdev to avoid failure of application which hasn't been completely converted to new offload API.

v8:
Revise PMD codes to comply with offload API in v7
update document

v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer. Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 doc/guides/prog_guide/poll_mode_drv.rst |  6 +++---
 lib/librte_ethdev/rte_ethdev.c          | 22 ++++++++++++----------
 lib/librte_ethdev/rte_ethdev.h          | 18 +++++++++++-------
 3 files changed, 26 insertions(+), 20 deletions(-)
doc/guides/prog_guide/poll_mode_drv.rst +3 -3
index f4e0bcd..af82352 100644
@@ -303,12 +303,12 @@ In the DPDK offload API, offloads are divided into per-port and per-queue offloa
 * A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
 * A pure per-port offloading must be enabled or disabled on all queues at the same time.
 * Any offloading is per-queue or pure per-port type, but can't be both types at same devices.
-* A per-port offloading can be enabled or disabled on all queues at the same time.
-* It is certain that both per-queue and pure per-port offloading are per-port type.
+* Port capabilities = per-queue capabilities + pure per-port capabilities.
+* Any supported offloading can be enabled on all queues.
 
 The different offloads capabilities can be queried using ``rte_eth_dev_info_get()``.
 The ``dev_info->[rt]x_queue_offload_capa`` returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.
-The ``dev_info->[rt]x_offload_capa`` returned from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.
+The ``dev_info->[rt]x_offload_capa`` returned from ``rte_eth_dev_info_get()`` includes all pure per-port and per-queue offloading capabilities.
 Supported offloads can be either per-port or per-queue.
 
 Offloads are enabled using the existing ``DEV_TX_OFFLOAD_*`` or ``DEV_RX_OFFLOAD_*`` flags.
lib/librte_ethdev/rte_ethdev.c +12 -10
index 3528ba1..b3ed821 100644
@@ -1166,21 +1166,23 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	     local_conf.rxmode.offloads) {
 		ethdev_log(ERR, "ethdev port_id=%d requested Rx offloads "
 				"0x%" PRIx64 " doesn't match Rx offloads "
-				"capabilities 0x%" PRIx64 " in %s( )\n",
+				"capabilities 0x%" PRIx64 " in %s()\n",
 				port_id,
 				local_conf.rxmode.offloads,
 				dev_info.rx_offload_capa,
 				__func__);
+		/* Will return -EINVAL in the next release */
 	}
 	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
 	     local_conf.txmode.offloads) {
 		ethdev_log(ERR, "ethdev port_id=%d requested Tx offloads "
 				"0x%" PRIx64 " doesn't match Tx offloads "
-				"capabilities 0x%" PRIx64 " in %s( )\n",
+				"capabilities 0x%" PRIx64 " in %s()\n",
 				port_id,
 				local_conf.txmode.offloads,
 				dev_info.tx_offload_capa,
 				__func__);
+		/* Will return -EINVAL in the next release */
 	}
 
 	/* Check that device supports requested rss hash functions. */
@@ -1556,29 +1558,29 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 	 * 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.
-	 * The underlying PMD must be aware of this point.
 	 */
 	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.
+	 * 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( ).
+	 * enabled in rte_eth_dev_configure().
 	 */
 	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
 	     local_conf.offloads) {
 		ethdev_log(ERR, "Ethdev port_id=%d rx_queue_id=%d, new "
 				"added offloads 0x%" PRIx64 " must be "
 				"within pre-queue offload capabilities 0x%"
-				PRIx64 " in %s( )\n",
+				PRIx64 " in %s()\n",
 				port_id,
 				rx_queue_id,
 				local_conf.offloads,
 				dev_info.rx_queue_offload_capa,
 				__func__);
+		/* Will return -EINVAL in the next release */
 	}
 
 	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
@@ -1721,29 +1723,29 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 	 * 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.
-	 * The underlying PMD must be aware of this point.
 	 */
 	local_conf.offloads &= ~dev->data->dev_conf.txmode.offloads;
 
 	/*
 	 * New added offloadings for this queue are those not enabled in
-	 * rte_eth_dev_configure( ) and they must be per-queue type.
+	 * 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( ).
+	 * enabled in rte_eth_dev_configure().
 	 */
 	if ((local_conf.offloads & dev_info.tx_queue_offload_capa) !=
 	     local_conf.offloads) {
 		ethdev_log(ERR, "Ethdev port_id=%d tx_queue_id=%d, new "
 				"added offloads 0x%" PRIx64 " must be "
 				"within pre-queue offload capabilities 0x%"
-				PRIx64 " in %s( )\n",
+				PRIx64 " in %s()\n",
 				port_id,
 				tx_queue_id,
 				local_conf.offloads,
 				dev_info.tx_queue_offload_capa,
 				__func__);
+		/* Will return -EINVAL in the next release */
 	}
 
 	return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev,
lib/librte_ethdev/rte_ethdev.h +11 -7
index 78e12bf..6bef181 100644
@@ -1067,13 +1067,13 @@ struct rte_eth_dev_info {
 	uint16_t max_vfs; /**< Maximum number of VFs. */
 	uint16_t max_vmdq_pools; /**< Maximum number of VMDq pools. */
 	uint64_t rx_offload_capa;
-	/**< All RX offload capabilities including all per queue ones */
+	/**< All RX offload capabilities including all per-queue ones */
 	uint64_t tx_offload_capa;
-	/**< All TX offload capabilities.including all per-queue ones */
+	/**< All TX offload capabilities including all per-queue ones */
 	uint64_t rx_queue_offload_capa;
-	/**< Device per queue RX offload capabilities. */
+	/**< Device per-queue RX offload capabilities. */
 	uint64_t tx_queue_offload_capa;
-	/**< Device per queue TX offload capabilities. */
+	/**< Device per-queue TX offload capabilities. */
 	uint16_t reta_size;
 	/**< Device redirection table size, the total number of entries. */
 	uint8_t hash_key_size; /**< Hash key size in bytes */
@@ -1554,9 +1554,7 @@ const char * __rte_experimental rte_eth_dev_tx_offload_name(uint64_t offload);
  *        the [rt]x_offload_capa returned from rte_eth_dev_infos_get().
  *        Any type of device supported offloading set in the input argument
  *        eth_conf->[rt]xmode.offloads to rte_eth_dev_configure() is enabled
- *        on all [RT]x queues and it can't be disabled no matter whether
- *        it is cleared or set in the input argument [rt]x_conf->offloads
- *        to rte_eth_[rt]x_queue_setup().
+ *        on all queues and it can't be disabled in rte_eth_[rt]x_queue_setup().
  *     - the Receive Side Scaling (RSS) configuration when using multiple RX
  *         queues per port.
  *
@@ -1617,6 +1615,9 @@ rte_eth_dev_is_removed(uint16_t port_id);
  *   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 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.
@@ -1679,6 +1680,9 @@ int rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
  *     hasn't been set in the input argument eth_conf->txmode.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 tx_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.
  *
  *     Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces
  *     the transmit function to use default values.
Signature · 1 line
2.7.5
Acked-by on v14 1/1
#52 lore raw

Re: [PATCH v14] ethdev: new Rx/Tx offloads API

14/05/2018 15:20, Wei Dai:

Quoted 3 lines

[...]

Quoted 6 lines
  *   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.

OK

Thanks a lot Wei!

#53 lore raw

Re: [PATCH v14] ethdev: new Rx/Tx offloads API

Quoted 13 lines · Thomas Monjalon

14/05/2018 15:20, Wei Dai:

Quoted 3 lines

[...]

Quoted 6 lines
  *   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.
Quoted 3 lines

OK

Squashed into relevant commit in next-net, thanks.

Quoted 4 lines

Thanks a lot Wei!

#54 lore raw

Re: [PATCH v10] ethdev: new Rx/Tx offloads API

In reply to Wei Dai
Quoted 70 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise triger an error log.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

---
v10:
sorry, miss the code change, fix the buidling error

v9:
replace RTE_PMD_DEBUG_TRACE with ethdev_log(ERR, in ethdev to avoid failure of application which hasn't been completely converted to new offload API.

v8:
Revise PMD codes to comply with offload API in v7
update document

v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer. Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

Quoted 8 lines

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 doc/guides/prog_guide/poll_mode_drv.rst |  26 +++--

Following are the documentation update suggestions by John [1], since the new version is sent I will apply applicable ones into that new commit before merge.

[1]

(quoted diff) +0 -0

b/doc/guides/prog_guide/poll_mode_drv.rst
index bbb85f0..bd66e64 100644

doc/guides/prog_guide/poll_mode_drv.rst +0 -0
@@ -296,33 +296,37 @@ described in the mbuf API documentation and in the in

:ref:`Mbuf Library
Per-Port and Per-Queue Offloads
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-In the DPDK offload API, offloads are divided into per-port and per-queue offloads. -A per-queue offloading can be enabled on a queue and disabled on another queue at the same time.
-A pure per-port offload is the one supported by device but not per-queue type. -A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
-A pure per-port offloading must be enabled or disabled on all queues at the same time.
-Any offloading is per-queue or pure per-port type, but can't be both types at same devices.
-A per-port offloading can be enabled or disabled on all queues at the same time. -It is certain that both per-queue and pure per-port offloading are per-port type. +In the DPDK offload API, offloads are divided into per-port and per-queue offloads as follows:
+
+* A per-queue offloading can be enabled on a queue and disabled on another queue at the same time.
+* A pure per-port offload is the one supported by device but not per-queue type. +* A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
+* A pure per-port offloading must be enabled or disabled on all queues at the same time.
+* Any offloading is per-queue or pure per-port type, but can't be both types at same devices.
+* A per-port offloading can be enabled or disabled on all queues at the same time. +* It is certain that both per-queue and pure per-port offloading are per-port type. +
The different offloads capabilities can be queried using
``rte_eth_dev_info_get()``.
-The dev_info->[rt]x_queue_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.
-The dev_info->[rt]x_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.
+The ``dev_info->[rt]x_queue_offload_capa`` returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities. +The ``dev_info->[rt]x_offload_capa returned`` from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.
Supported offloads can be either per-port or per-queue.

Offloads are enabled using the existing ``DEV_TX_OFFLOAD_*`` or
``DEV_RX_OFFLOAD_*`` flags.
-Any requested offloading by application must be within the device capabilities. +Any requested offloading by an application must be within the device capabilities.
Any offloading is disabled by default if it is not set in the parameter
-dev_conf->[rt]xmode.offloads to ``rte_eth_dev_configure()`` and -[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup()``.
-If any offloading is enabled in ``rte_eth_dev_configure()`` by application, +``dev_conf->[rt]xmode.offloads`` to ``rte_eth_dev_configure()`` and +``[rt]x_conf->offloads`` to ``rte_eth_[rt]x_queue_setup()``.
+
+If any offloading is enabled in ``rte_eth_dev_configure()`` by an application,
it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in
-[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup()``. +``[rt]x_conf->offloads`` to ``rte_eth_[rt]x_queue_setup()``.
+
If a per-queue offloading hasn't been enabled in ``rte_eth_dev_configure()``, it can be enabled or disabled in ``rte_eth_[rt]x_queue_setup()`` for individual
queue.
-A new added offloads in [rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup()`` input by application
+A newly added offload in ``[rt]x_conf->offloads`` to ``rte_eth_[rt]x_queue_setup()`` input by an application
is the one which hasn't been enabled in ``rte_eth_dev_configure()`` and is
requested to be enabled
-in ``rte_eth_[rt]x_queue_setup()``, it must be per-queue type, otherwise trigger an error log.
+in ``rte_eth_[rt]x_queue_setup()``. It must be per-queue type, otherwise trigger an error log.

For an application to use the Tx offloads API it should set the
``ETH_TXQ_FLAGS_IGNORE`` flag in the ``txq_flags`` field located in ``rte_eth_txconf`` struct.
In such cases it is not required to set other flags in ``txq_flags``.

(quoted diff) +0 -0

b/doc/guides/prog_guide/poll_mode_drv.rst
index bbb85f0..bd66e64 100644

doc/guides/prog_guide/poll_mode_drv.rst +0 -0
@@ -296,33 +296,37 @@ described in the mbuf API documentation and in the in

:ref:`Mbuf Library
Per-Port and Per-Queue Offloads
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-In the DPDK offload API, offloads are divided into per-port and per-queue offloads. -A per-queue offloading can be enabled on a queue and disabled on another queue at the same time.
-A pure per-port offload is the one supported by device but not per-queue type. -A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
-A pure per-port offloading must be enabled or disabled on all queues at the same time.
-Any offloading is per-queue or pure per-port type, but can't be both types at same devices.
-A per-port offloading can be enabled or disabled on all queues at the same time. -It is certain that both per-queue and pure per-port offloading are per-port type. +In the DPDK offload API, offloads are divided into per-port and per-queue offloads as follows:
+
+* A per-queue offloading can be enabled on a queue and disabled on another queue at the same time.
+* A pure per-port offload is the one supported by device but not per-queue type. +* A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
+* A pure per-port offloading must be enabled or disabled on all queues at the same time.
+* Any offloading is per-queue or pure per-port type, but can't be both types at same devices.
+* A per-port offloading can be enabled or disabled on all queues at the same time. +* It is certain that both per-queue and pure per-port offloading are per-port type. +
The different offloads capabilities can be queried using
``rte_eth_dev_info_get()``.
-The dev_info->[rt]x_queue_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.
-The dev_info->[rt]x_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.
+The ``dev_info->[rt]x_queue_offload_capa`` returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities. +The ``dev_info->[rt]x_offload_capa returned`` from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.
Supported offloads can be either per-port or per-queue.

Offloads are enabled using the existing ``DEV_TX_OFFLOAD_*`` or
``DEV_RX_OFFLOAD_*`` flags.
-Any requested offloading by application must be within the device capabilities. +Any requested offloading by an application must be within the device capabilities.
Any offloading is disabled by default if it is not set in the parameter
-dev_conf->[rt]xmode.offloads to ``rte_eth_dev_configure()`` and -[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup()``.
-If any offloading is enabled in ``rte_eth_dev_configure()`` by application, +``dev_conf->[rt]xmode.offloads`` to ``rte_eth_dev_configure()`` and +``[rt]x_conf->offloads`` to ``rte_eth_[rt]x_queue_setup()``.
+
+If any offloading is enabled in ``rte_eth_dev_configure()`` by an application,
it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in
-[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup()``. +``[rt]x_conf->offloads`` to ``rte_eth_[rt]x_queue_setup()``.
+
If a per-queue offloading hasn't been enabled in ``rte_eth_dev_configure()``, it can be enabled or disabled in ``rte_eth_[rt]x_queue_setup()`` for individual
queue.
-A new added offloads in [rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup()`` input by application
+A newly added offload in ``[rt]x_conf->offloads`` to ``rte_eth_[rt]x_queue_setup()`` input by an application
is the one which hasn't been enabled in ``rte_eth_dev_configure()`` and is
requested to be enabled
-in ``rte_eth_[rt]x_queue_setup()``, it must be per-queue type, otherwise trigger an error log.
+in ``rte_eth_[rt]x_queue_setup()``. It must be per-queue type, otherwise trigger an error log.

For an application to use the Tx offloads API it should set the
``ETH_TXQ_FLAGS_IGNORE`` flag in the ``txq_flags`` field located in ``rte_eth_txconf`` struct.
In such cases it is not required to set other flags in ``txq_flags``.

author
#55 lore raw

PATCH v8 1/1 ethdev: check Rx/Tx offloads

In reply to Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise return error.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

---
v8:
Revise PMD codes to comply with offload API in v7
update document

v7:
Give the maximum freedom for upper application, only minimal checking is performed in ethdev layer. Only requested specific pure per-queue offloadings are input to underlying PMD.

v6:
No need enable an offload in queue_setup( ) if it has already been enabled in dev_configure( )

v5:
keep offload settings sent to PMD same as those from application

v4:
fix a wrong description in git log message.

v3:
rework according to dicision of offloading API in community

v2:
add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported.

---
 doc/guides/prog_guide/poll_mode_drv.rst |  26 +++--
 doc/guides/rel_notes/release_18_05.rst  |   8 ++
 drivers/net/avf/avf_rxtx.c              |   5 +-
 drivers/net/bnxt/bnxt_ethdev.c          |  17 ----
 drivers/net/cxgbe/cxgbe_ethdev.c        |  50 +---------
 drivers/net/dpaa/dpaa_ethdev.c          |  16 ----
 drivers/net/dpaa2/dpaa2_ethdev.c        |  16 ----
 drivers/net/e1000/em_ethdev.c           |  19 ----
 drivers/net/e1000/em_rxtx.c             |  64 ++-----------
 drivers/net/e1000/igb_rxtx.c            |  64 ++-----------
 drivers/net/ena/ena_ethdev.c            |  65 +------------
 drivers/net/failsafe/failsafe_ops.c     |  81 ----------------
 drivers/net/fm10k/fm10k_ethdev.c        |  82 ++--------------
 drivers/net/i40e/i40e_rxtx.c            |  58 ++----------
 drivers/net/ixgbe/ixgbe_ethdev.c        |  38 --------
 drivers/net/ixgbe/ixgbe_rxtx.c          |  66 ++-----------
 drivers/net/mlx4/mlx4_rxq.c             |  43 ++-------
 drivers/net/mlx4/mlx4_txq.c             |  42 ++------
 drivers/net/mlx5/mlx5_ethdev.c          |  22 -----
 drivers/net/mlx5/mlx5_rxq.c             |  50 ++--------
 drivers/net/mlx5/mlx5_txq.c             |  44 +--------
 drivers/net/mvpp2/mrvl_ethdev.c         |  97 +------------------
 drivers/net/nfp/nfp_net.c               | 163 --------------------------------
 drivers/net/octeontx/octeontx_ethdev.c  |  72 +-------------
 drivers/net/sfc/sfc_ethdev.c            |   9 +-
 drivers/net/sfc/sfc_rx.c                |  42 ++------
 drivers/net/sfc/sfc_rx.h                |   3 +-
 drivers/net/sfc/sfc_tx.c                |  42 ++------
 drivers/net/sfc/sfc_tx.h                |   3 +-
 drivers/net/tap/rte_eth_tap.c           |  88 ++---------------
 drivers/net/thunderx/nicvf_ethdev.c     |  70 ++------------
 drivers/net/virtio/virtio_rxtx.c        |   9 +-
 drivers/net/vmxnet3/vmxnet3_ethdev.c    |  16 ----
 drivers/net/vmxnet3/vmxnet3_rxtx.c      |   8 +-
 lib/librte_ethdev/rte_ethdev.c          |  88 +++++++++++++++++
 35 files changed, 240 insertions(+), 1346 deletions(-)
doc/guides/prog_guide/poll_mode_drv.rst +20 -6
index 09a93ba..56483fb 100644
@@ -297,16 +297,30 @@ Per-Port and Per-Queue Offloads
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 In the DPDK offload API, offloads are divided into per-port and per-queue offloads.
+A per-queue offloading can be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offloading can't be enabled on a queue and disabled on another queue at the same time.
+A pure per-port offloading must be enabled or disabled on all queues at the same time.
+A per-port offloading can be enabled or disabled on all queues at the same time.
+It is certain that both per-queue and pure per-port offloading are per-port type.
 The different offloads capabilities can be queried using ``rte_eth_dev_info_get()``.
+The dev_info->[rt]x_queue_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-queue offloading capabilities.
+The dev_info->[rt]x_offload_capa returned from ``rte_eth_dev_info_get()`` includes all per-port and per-queue offloading capabilities.
 Supported offloads can be either per-port or per-queue.
 
 Offloads are enabled using the existing ``DEV_TX_OFFLOAD_*`` or ``DEV_RX_OFFLOAD_*`` flags.
-Per-port offload configuration is set using ``rte_eth_dev_configure``.
-Per-queue offload configuration is set using ``rte_eth_rx_queue_setup`` and ``rte_eth_tx_queue_setup``.
-To enable per-port offload, the offload should be set on both device configuration and queue setup.
-In case of a mixed configuration the queue setup shall return with an error.
-To enable per-queue offload, the offload can be set only on the queue setup.
-Offloads which are not enabled are disabled by default.
+Any requested offloading by application must be within the device capabilities.
+Any offloading is disabled by default if it is not set in the parameter
+dev_conf->[rt]xmode.offloads to ``rte_eth_dev_configure( )`` and
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )``.
+If any offloading is enabled in ``rte_eth_dev_configure( )`` by application,
+it is enabled on all queues no matter whether it is per-queue or
+per-port type and no matter whether it is set or cleared in
+[rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )``.
+If a per-queue offloading hasn't been enabled in ``rte_eth_dev_configure( )``,
+it can be enabled or disabled in ``rte_eth_[rt]x_queue_setup( )`` for individual queue.
+A new added offloads in [rt]x_conf->offloads to ``rte_eth_[rt]x_queue_setup( )`` input by application
+is the one which hasn't been enabled in ``rte_eth_dev_configure( )`` and is requested to be enabled
+in ``rte_eth_[rt]x_queue_setup( )``, it must be per-queue type, otherwise return error.
 
 For an application to use the Tx offloads API it should set the ``ETH_TXQ_FLAGS_IGNORE`` flag in the ``txq_flags`` field located in ``rte_eth_txconf`` struct.
 In such cases it is not required to set other flags in ``txq_flags``.
doc/guides/rel_notes/release_18_05.rst +8 -0
index 0ae61e8..637e684 100644
@@ -303,6 +303,14 @@ API Changes
   * ``rte_flow_create()`` API count action now requires the ``struct rte_flow_action_count``.
   * ``rte_flow_query()`` API parameter changed from action type to action structure.
 
+* **ethdev: changes to offload API**
+
+   A pure per-port offloading isn't requested to be repeated in [rt]x_conf->offloads to
+   ``rte_eth_[rt]x_queue_setup( )``. Now any offloading enabled in ``rte_eth_dev_configure( )``
+   can't be disabled by ``rte_eth_[rt]x_queue_setup( )``. Any new added offloading which has
+   not been enabled in ``rte_eth_dev_configure( )`` and is requested to be enabled in
+   ``rte_eth_[rt]x_queue_setup( )`` must be per-queue type, otherwise return error.
+
 
 ABI Changes
 -----------
drivers/net/avf/avf_rxtx.c +4 -1
index 1824ed7..e03a136 100644
@@ -435,9 +435,12 @@ avf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	uint32_t ring_size;
 	uint16_t tx_rs_thresh, tx_free_thresh;
 	uint16_t i, base, bsf, tc_mapping;
+	uint64_t offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+
 	if (nb_desc % AVF_ALIGN_RING_DESC != 0 ||
 	    nb_desc > AVF_MAX_RING_DESC ||
 	    nb_desc < AVF_MIN_RING_DESC) {
@@ -474,7 +477,7 @@ avf_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	txq->free_thresh = tx_free_thresh;
 	txq->queue_id = queue_idx;
 	txq->port_id = dev->data->port_id;
-	txq->offloads = tx_conf->offloads;
+	txq->offloads = offloads;
 	txq->tx_deferred_start = tx_conf->tx_deferred_start;
 
 	/* Allocate software ring */
drivers/net/bnxt/bnxt_ethdev.c +0 -17
index 348129d..d00b99f 100644
@@ -500,25 +500,8 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
 static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
-	uint64_t tx_offloads = eth_dev->data->dev_conf.txmode.offloads;
 	uint64_t rx_offloads = eth_dev->data->dev_conf.rxmode.offloads;
 
-	if (tx_offloads != (tx_offloads & BNXT_DEV_TX_OFFLOAD_SUPPORT)) {
-		PMD_DRV_LOG
-			(ERR,
-			 "Tx offloads requested 0x%" PRIx64 " supported 0x%x\n",
-			 tx_offloads, BNXT_DEV_TX_OFFLOAD_SUPPORT);
-		return -ENOTSUP;
-	}
-
-	if (rx_offloads != (rx_offloads & BNXT_DEV_RX_OFFLOAD_SUPPORT)) {
-		PMD_DRV_LOG
-			(ERR,
-			 "Rx offloads requested 0x%" PRIx64 " supported 0x%x\n",
-			    rx_offloads, BNXT_DEV_RX_OFFLOAD_SUPPORT);
-		return -ENOTSUP;
-	}
-
 	bp->rx_queues = (void *)eth_dev->data->rx_queues;
 	bp->tx_queues = (void *)eth_dev->data->tx_queues;
 
drivers/net/cxgbe/cxgbe_ethdev.c +5 -45

86 lines not on this page · raw message

drivers/net/dpaa/dpaa_ethdev.c +0 -16
index 6bf8c15..199afdd 100644
@@ -176,14 +176,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* Rx offloads validation */
-	if (~(dev_rx_offloads_sup | dev_rx_offloads_nodis) & rx_offloads) {
-		DPAA_PMD_ERR(
-		"Rx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			rx_offloads,
-			dev_rx_offloads_sup | dev_rx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_rx_offloads_nodis & ~rx_offloads) {
 		DPAA_PMD_WARN(
 		"Rx offloads non configurable - requested 0x%" PRIx64
@@ -192,14 +184,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
 	}
 
 	/* Tx offloads validation */
-	if (~(dev_tx_offloads_sup | dev_tx_offloads_nodis) & tx_offloads) {
-		DPAA_PMD_ERR(
-		"Tx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			tx_offloads,
-			dev_tx_offloads_sup | dev_tx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_tx_offloads_nodis & ~tx_offloads) {
 		DPAA_PMD_WARN(
 		"Tx offloads non configurable - requested 0x%" PRIx64
drivers/net/dpaa2/dpaa2_ethdev.c +0 -16
index c304b82..de8d83a 100644
@@ -309,14 +309,6 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* Rx offloads validation */
-	if (~(dev_rx_offloads_sup | dev_rx_offloads_nodis) & rx_offloads) {
-		DPAA2_PMD_ERR(
-		"Rx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			rx_offloads,
-			dev_rx_offloads_sup | dev_rx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_rx_offloads_nodis & ~rx_offloads) {
 		DPAA2_PMD_WARN(
 		"Rx offloads non configurable - requested 0x%" PRIx64
@@ -325,14 +317,6 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 	}
 
 	/* Tx offloads validation */
-	if (~(dev_tx_offloads_sup | dev_tx_offloads_nodis) & tx_offloads) {
-		DPAA2_PMD_ERR(
-		"Tx offloads non supported - requested 0x%" PRIx64
-		" supported 0x%" PRIx64,
-			tx_offloads,
-			dev_tx_offloads_sup | dev_tx_offloads_nodis);
-		return -ENOTSUP;
-	}
 	if (dev_tx_offloads_nodis & ~tx_offloads) {
 		DPAA2_PMD_WARN(
 		"Tx offloads non configurable - requested 0x%" PRIx64
drivers/net/e1000/em_ethdev.c +0 -19
index 694a624..4e890ad 100644
@@ -454,29 +454,10 @@ eth_em_configure(struct rte_eth_dev *dev)
 {
 	struct e1000_interrupt *intr =
 		E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 
 	PMD_INIT_FUNC_TRACE();
 	intr->flags |= E1000_FLAG_NEED_LINK_UPDATE;
 
-	eth_em_infos_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	PMD_INIT_FUNC_TRACE();
 
 	return 0;
drivers/net/e1000/em_rxtx.c +6 -58

106 lines not on this page · raw message

drivers/net/e1000/igb_rxtx.c +6 -58

102 lines not on this page · raw message

drivers/net/ena/ena_ethdev.c +4 -61

113 lines not on this page · raw message

drivers/net/failsafe/failsafe_ops.c +0 -81

115 lines not on this page · raw message

drivers/net/fm10k/fm10k_ethdev.c +8 -74

135 lines not on this page · raw message

drivers/net/i40e/i40e_rxtx.c +6 -52

96 lines not on this page · raw message

drivers/net/ixgbe/ixgbe_ethdev.c +0 -38
index 91179e9..320ab21 100644
@@ -2365,9 +2365,6 @@ ixgbe_dev_configure(struct rte_eth_dev *dev)
 		IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
 	struct ixgbe_adapter *adapter =
 		(struct ixgbe_adapter *)dev->data->dev_private;
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 	int ret;
 
 	PMD_INIT_FUNC_TRACE();
@@ -2379,22 +2376,6 @@ ixgbe_dev_configure(struct rte_eth_dev *dev)
 		return ret;
 	}
 
-	ixgbe_dev_info_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	/* set flag to update link status after init */
 	intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
 
@@ -4965,29 +4946,10 @@ ixgbevf_dev_configure(struct rte_eth_dev *dev)
 	struct rte_eth_conf *conf = &dev->data->dev_conf;
 	struct ixgbe_adapter *adapter =
 			(struct ixgbe_adapter *)dev->data->dev_private;
-	struct rte_eth_dev_info dev_info;
-	uint64_t rx_offloads;
-	uint64_t tx_offloads;
 
 	PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
 		     dev->data->port_id);
 
-	ixgbevf_dev_info_get(dev, &dev_info);
-	rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	if ((rx_offloads & dev_info.rx_offload_capa) != rx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Rx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    rx_offloads, dev_info.rx_offload_capa);
-		return -ENOTSUP;
-	}
-	tx_offloads = dev->data->dev_conf.txmode.offloads;
-	if ((tx_offloads & dev_info.tx_offload_capa) != tx_offloads) {
-		PMD_DRV_LOG(ERR, "Some Tx offloads are not supported "
-			    "requested 0x%" PRIx64 " supported 0x%" PRIx64,
-			    tx_offloads, dev_info.tx_offload_capa);
-		return -ENOTSUP;
-	}
-
 	/*
 	 * VF has no ability to enable/disable HW CRC
 	 * Keep the persistent behavior the same as Host PF
drivers/net/ixgbe/ixgbe_rxtx.c +6 -60

110 lines not on this page · raw message

drivers/net/mlx4/mlx4_rxq.c +8 -35

77 lines not on this page · raw message

drivers/net/mlx4/mlx4_txq.c +6 -36

66 lines not on this page · raw message

drivers/net/mlx5/mlx5_ethdev.c +0 -22
index 746b94f..df369cd 100644
@@ -330,30 +330,8 @@ mlx5_dev_configure(struct rte_eth_dev *dev)
 	unsigned int reta_idx_n;
 	const uint8_t use_app_rss_key =
 		!!dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key;
-	uint64_t supp_tx_offloads = mlx5_get_tx_port_offloads(dev);
-	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
-	uint64_t supp_rx_offloads =
-		(mlx5_get_rx_port_offloads() |
-		 mlx5_get_rx_queue_offloads(dev));
-	uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
 	int ret = 0;
 
-	if ((tx_offloads & supp_tx_offloads) != tx_offloads) {
-		DRV_LOG(ERR,
-			"port %u some Tx offloads are not supported requested"
-			" 0x%" PRIx64 " supported 0x%" PRIx64,
-			dev->data->port_id, tx_offloads, supp_tx_offloads);
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
-	if ((rx_offloads & supp_rx_offloads) != rx_offloads) {
-		DRV_LOG(ERR,
-			"port %u some Rx offloads are not supported requested"
-			" 0x%" PRIx64 " supported 0x%" PRIx64,
-			dev->data->port_id, rx_offloads, supp_rx_offloads);
-		rte_errno = ENOTSUP;
-		return -rte_errno;
-	}
 	if (use_app_rss_key &&
 	    (dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len !=
 	     rss_hash_default_key_len)) {
drivers/net/mlx5/mlx5_rxq.c +7 -43

82 lines not on this page · raw message

drivers/net/mlx5/mlx5_txq.c +2 -42

62 lines not on this page · raw message

drivers/net/mvpp2/mrvl_ethdev.c +3 -94

139 lines not on this page · raw message

drivers/net/nfp/nfp_net.c +0 -163

196 lines not on this page · raw message

drivers/net/octeontx/octeontx_ethdev.c +5 -67

117 lines not on this page · raw message

drivers/net/sfc/sfc_ethdev.c +7 -2
index e42d553..fc2b254 100644
@@ -413,14 +413,16 @@ sfc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	int rc;
+	uint64_t offloads;
 
 	sfc_log_init(sa, "RxQ=%u nb_rx_desc=%u socket_id=%u",
 		     rx_queue_id, nb_rx_desc, socket_id);
 
 	sfc_adapter_lock(sa);
 
+	offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
 	rc = sfc_rx_qinit(sa, rx_queue_id, nb_rx_desc, socket_id,
-			  rx_conf, mb_pool);
+			  rx_conf, mb_pool, offloads);
 	if (rc != 0)
 		goto fail_rx_qinit;
 
@@ -469,13 +471,16 @@ sfc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	int rc;
+	uint64_t offloads;
 
 	sfc_log_init(sa, "TxQ = %u, nb_tx_desc = %u, socket_id = %u",
 		     tx_queue_id, nb_tx_desc, socket_id);
 
 	sfc_adapter_lock(sa);
 
-	rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id, tx_conf);
+	offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
+	rc = sfc_tx_qinit(sa, tx_queue_id, nb_tx_desc, socket_id,
+			  tx_conf, offloads);
 	if (rc != 0)
 		goto fail_tx_qinit;
 
drivers/net/sfc/sfc_rx.c +9 -33

86 lines not on this page · raw message

drivers/net/sfc/sfc_rx.h +2 -1
index 3fba7d8..2898fe5 100644
@@ -138,7 +138,8 @@ void sfc_rx_stop(struct sfc_adapter *sa);
 int sfc_rx_qinit(struct sfc_adapter *sa, unsigned int rx_queue_id,
 		 uint16_t nb_rx_desc, unsigned int socket_id,
 		 const struct rte_eth_rxconf *rx_conf,
-		 struct rte_mempool *mb_pool);
+		 struct rte_mempool *mb_pool,
+		 uint64_t offloads);
 void sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
drivers/net/sfc/sfc_tx.c +9 -33

83 lines not on this page · raw message

drivers/net/sfc/sfc_tx.h +2 -1
index c2e5f13..d2b2c4d 100644
@@ -121,7 +121,8 @@ void sfc_tx_close(struct sfc_adapter *sa);
 
 int sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 		 uint16_t nb_tx_desc, unsigned int socket_id,
-		 const struct rte_eth_txconf *tx_conf);
+		 const struct rte_eth_txconf *tx_conf,
+		 uint64_t offloads);
 void sfc_tx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 
 void sfc_tx_qflush_done(struct sfc_txq *txq);
drivers/net/tap/rte_eth_tap.c +8 -80

123 lines not on this page · raw message

drivers/net/thunderx/nicvf_ethdev.c +8 -62

122 lines not on this page · raw message

drivers/net/virtio/virtio_rxtx.c +2 -7
index a8aa87b..92fab21 100644
@@ -385,10 +385,9 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
 			uint16_t queue_idx,
 			uint16_t nb_desc,
 			unsigned int socket_id __rte_unused,
-			const struct rte_eth_rxconf *rx_conf,
+			const struct rte_eth_rxconf *rx_conf __rte_unused,
 			struct rte_mempool *mp)
 {
-	const struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
 	uint16_t vtpci_queue_idx = 2 * queue_idx + VTNET_SQ_RQ_QUEUE_IDX;
 	struct virtio_hw *hw = dev->data->dev_private;
 	struct virtqueue *vq = hw->vqs[vtpci_queue_idx];
@@ -408,10 +407,6 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
 			"Cannot allocate mbufs for rx virtqueue");
 	}
 
-	if ((rx_conf->offloads ^ rxmode->offloads) &
-	    VIRTIO_PMD_PER_DEVICE_RX_OFFLOADS)
-		return -EINVAL;
-
 	dev->data->rx_queues[queue_idx] = rxvq;
 
 	return 0;
@@ -504,7 +499,7 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	PMD_INIT_FUNC_TRACE();
 
 	/* cannot use simple rxtx funcs with multisegs or offloads */
-	if (tx_conf->offloads)
+	if (dev->data->dev_conf.txmode.offloads)
 		hw->use_simple_tx = 0;
 
 	if (nb_desc == 0 || nb_desc > vq->vq_nentries)
drivers/net/vmxnet3/vmxnet3_ethdev.c +0 -16
index c850241..ba932ff 100644
@@ -393,25 +393,9 @@ vmxnet3_dev_configure(struct rte_eth_dev *dev)
 	const struct rte_memzone *mz;
 	struct vmxnet3_hw *hw = dev->data->dev_private;
 	size_t size;
-	uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads;
-	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
 
 	PMD_INIT_FUNC_TRACE();
 
-	if ((rx_offloads & VMXNET3_RX_OFFLOAD_CAP) != rx_offloads) {
-		RTE_LOG(ERR, PMD, "Requested RX offloads 0x%" PRIx64
-			" do not match supported 0x%" PRIx64,
-			rx_offloads, (uint64_t)VMXNET3_RX_OFFLOAD_CAP);
-		return -ENOTSUP;
-	}
-
-	if ((tx_offloads & VMXNET3_TX_OFFLOAD_CAP) != tx_offloads) {
-		RTE_LOG(ERR, PMD, "Requested TX offloads 0x%" PRIx64
-			" do not match supported 0x%" PRIx64,
-			tx_offloads, (uint64_t)VMXNET3_TX_OFFLOAD_CAP);
-		return -ENOTSUP;
-	}
-
 	if (dev->data->nb_tx_queues > VMXNET3_MAX_TX_QUEUES ||
 	    dev->data->nb_rx_queues > VMXNET3_MAX_RX_QUEUES) {
 		PMD_INIT_LOG(ERR, "ERROR: Number of queues not supported");
drivers/net/vmxnet3/vmxnet3_rxtx.c +1 -7
index f6e2d98..cf85f3d 100644
@@ -1013,7 +1013,7 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
 			   uint16_t queue_idx,
 			   uint16_t nb_desc,
 			   unsigned int socket_id,
-			   const struct rte_eth_txconf *tx_conf)
+			   const struct rte_eth_txconf *tx_conf __rte_unused)
 {
 	struct vmxnet3_hw *hw = dev->data->dev_private;
 	const struct rte_memzone *mz;
@@ -1025,12 +1025,6 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
 
 	PMD_INIT_FUNC_TRACE();
 
-	if ((tx_conf->txq_flags & ETH_TXQ_FLAGS_NOXSUMSCTP) !=
-	    ETH_TXQ_FLAGS_NOXSUMSCTP) {
-		PMD_INIT_LOG(ERR, "SCTP checksum offload not supported");
-		return -EINVAL;
-	}
-
 	txq = rte_zmalloc("ethdev_tx_queue", sizeof(struct vmxnet3_tx_queue),
 			  RTE_CACHE_LINE_SIZE);
 	if (txq == NULL) {
lib/librte_ethdev/rte_ethdev.c +88 -0

106 lines not on this page · raw message

Signature · 1 line
2.7.5
#56 lore raw

Re: [PATCH v8] ethdev: check Rx/Tx offloads

Quoted 40 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise return error.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

[...]

Quoted 37 lines
lib/librte_ethdev/rte_ethdev.c +22 -0
index e560524..523a07b 100644
@@ -1139,6 +1139,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
  							ETHER_MAX_LEN;
  	}
 
+	/* Any requested offloading must be within its device capabilities */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads "
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads "
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
  	/* Check that device supports requested rss hash functions. */
  	if ((dev_info.flow_type_rss_offloads |
  	     dev_conf->rx_adv_conf.rss_conf.rss_hf) !=
@@ -1504,6 +1526,39 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
  						    &local_conf.offloads);
  	}
 

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1538

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;

In fact it has a problem with MULTI_SEG.
It is a new offload which was introduced to substitute NOMULTISEG TxQ flag. If PMD reports the offload on device level, but application does not use the new interface and request the offload on queue level using txq_flags (absent NOMULTISEG flag). As the result below check fails. Sounds like it requires dedicated code to handle it. Anything else?

Quoted 26 lines
lib/librte_ethdev/rte_ethdev.c +23 -0
+
+	/*
+	 * 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_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d, new "
+				    "added offloads 0x" PRIx64 " must be "
+				    "within pre-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;
+	}
+
  	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
  					      socket_id, &local_conf, mp);
  	if (!ret) {

[...]

author
#57 lore raw

Re: [PATCH v8] ethdev: check Rx/Tx offloads

Quoted 104 lines

-----Original Message-----
From: Andrew Rybchenko [mailto:[email protected]]
Sent: Wednesday, May 9, 2018 1:52 AM
To: Dai, Wei <[email protected]>; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]; Zhang, Qi Z <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v8] ethdev: check Rx/Tx offloads

Quoted 39 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise return error.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

[...]

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id,

Quoted 5 lines
(quoted diff) +0 -0

b/lib/librte_ethdev/rte_ethdev.c index e560524..523a07b 100644

lib/librte_ethdev/rte_ethdev.c +0 -0
@@ -1139,6 +1139,28 @@ rte_eth_dev_configure(uint16_t port_id,

uint16_t nb_rx_q, uint16_t nb_tx_q,

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,

Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +4 -0
  							ETHER_MAX_LEN;
  	}
 
+	/* Any requested offloading must be within its device capabilities */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx

offloads "

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx

offloads "

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,

Quoted 11 lines
lib/librte_ethdev/rte_ethdev.c +8 -0
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
  	/* Check that device supports requested rss hash functions. */
  	if ((dev_info.flow_type_rss_offloads |
  	     dev_conf->rx_adv_conf.rss_conf.rss_hf) != @@ -1504,6

+1526,39

Quoted 4 lines

@@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
&local_conf.offloads);
}

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1538

Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10 -0
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;
Quoted 8 lines

In fact it has a problem with MULTI_SEG.
It is a new offload which was introduced to substitute NOMULTISEG TxQ flag.
If PMD reports the offload on device level, but application does not use the new interface and request the offload on queue level using txq_flags (absent NOMULTISEG flag). As the result below check fails.
Sounds like it requires dedicated code to handle it. Anything else?

Indeed, the Tx offload API before 17.11 looks per-queue level as offloading is enabled by the argument to rte_eth_tx_queue_setup( ) for each tx queue. Each tx queue can have different input offloading argument tx_conf->txq_flags, But some underlying PMD has limitation that different txq_flags are not permitted. So tx offload API before 17.11 can't reflect the device capabilities. The new offload API can tell application what is the correct way to use tx offloading to reduce the confusion for application.
Application developer should be aware of the version of DPDK library. They can revise codes for the check failure according to the error message.

Quoted 30 lines

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

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +12 -0
+
+	/*
+	 * 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_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d,

new "

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

Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +11 -0
+				    "added offloads 0x" PRIx64 " must be "
+				    "within pre-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;
+	}
+
  	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id,

nb_rx_desc,

Quoted 2 lines
  					      socket_id, &local_conf, mp);
  	if (!ret) {

[...]

#58 lore raw

Re: [PATCH v8] ethdev: check Rx/Tx offloads

In reply to Andrew Rybchenko
Quoted 90 lines · Andrew Rybchenko
Quoted 40 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise return error.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

[...]

Quoted 46 lines
lib/librte_ethdev/rte_ethdev.c +31 -0
index e560524..523a07b 100644
@@ -1139,6 +1139,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
  							ETHER_MAX_LEN;
  	}
 
+	/* Any requested offloading must be within its device capabilities */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads "
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads "
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
  	/* Check that device supports requested rss hash functions. */
  	if ((dev_info.flow_type_rss_offloads |
  	     dev_conf->rx_adv_conf.rss_conf.rss_hf) !=
@@ -1504,6 +1526,39 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
  						    &local_conf.offloads);
  	}
 
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1538

Quoted 1 line
lib/librte_ethdev/rte_ethdev.c +1 -0
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;

In fact it has a problem with MULTI_SEG.
It is a new offload which was introduced to substitute NOMULTISEG TxQ flag. If PMD reports the offload on device level, but application does not use the new interface and request the offload on queue level using txq_flags (absent NOMULTISEG flag). As the result below check fails. Sounds like it requires dedicated code to handle it. Anything else?

Old applications don't set Tx offloads on configure() at all. But they set them in tx_queue_setup().
For the PMDs that support only port offloads old applications will fail in tx_queue_setup(), if I don't miss anything.

I suggest keeping the log but remove the error return until all applications switch to new offloading API which should be on next release. What do you think?

btw, the log macro "RTE_PMD_DEBUG_TRACE" is in ERR log type but it controlled by CONFIG_RTE_LIBRTE_ETHDEV_DEBUG config option which is disabled by default. So by default we don't get the error log but the error only. I suggest switching to new dynamic logging ethdev_log()

Quoted 30 lines
Quoted 27 lines
lib/librte_ethdev/rte_ethdev.c +23 -0
+
+	/*
+	 * 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_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d, new "
+				    "added offloads 0x" PRIx64 " must be "
+				    "within pre-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;
+	}
+
  	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
  					      socket_id, &local_conf, mp);
  	if (!ret) {

[...]

#59 lore raw

Re: [PATCH v8] ethdev: check Rx/Tx offloads

Quoted 100 lines · Ferruh Yigit
Quoted 90 lines · Andrew Rybchenko
Quoted 40 lines · Wei Dai

This patch check if a input requested offloading is valid or not. Any reuqested offloading must be supported in the device capabilities. Any offloading is disabled by default if it is not set in the parameter dev_conf->[rt]xmode.offloads to rte_eth_dev_configure( ) and [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If any offloading is enabled in rte_eth_dev_configure( ) by application, it is enabled on all queues no matter whether it is per-queue or per-port type and no matter whether it is set or cleared in [rt]x_conf->offloads to rte_eth_[rt]x_queue_setup( ).
If a per-queue offloading hasn't be enabled in rte_eth_dev_configure( ), it can be enabled or disabled for individual queue in ret_eth_[rt]x_queue_setup( ).
A new added offloading is the one which hasn't been enabled in rte_eth_dev_configure( ) and is reuqested to be enabled in rte_eth_[rt]x_queue_setup( ), it must be per-queue type, otherwise return error.
The underlying PMD must be aware that the requested offloadings to PMD specific queue_setup( ) function only carries those new added offloadings of per-queue type.

This patch can make above such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD.

This patch assumes that all PMDs in 18.05-rc2 have already converted to offload API defined in 17.11 . It also assumes that all PMDs can return correct offloading capabilities in rte_eth_dev_infos_get( ).

In the beginning of [rt]x_queue_setup( ) of underlying PMD, add offloads = [rt]xconf->offloads | dev->data->dev_conf.[rt]xmode.offloads; to keep same as offload API defined in 17.11 to avoid upper application broken due to offload API change.
PMD can use the info that input [rt]xconf->offloads only carry the new added per-queue offloads to do some optimization or some code change on base of this patch.

[...]

Quoted 46 lines
lib/librte_ethdev/rte_ethdev.c +31 -0
index e560524..523a07b 100644
@@ -1139,6 +1139,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
  							ETHER_MAX_LEN;
  	}
 
+	/* Any requested offloading must be within its device capabilities */
+	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
+	     local_conf.rxmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads "
+				    "0x%" PRIx64 " doesn't match Rx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.rxmode.offloads,
+				    dev_info.rx_offload_capa);
+		return -EINVAL;
+	}
+	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
+	     local_conf.txmode.offloads) {
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads "
+				    "0x%" PRIx64 " doesn't match Tx offloads "
+				    "capabilities 0x%" PRIx64 "\n",
+				    port_id,
+				    local_conf.txmode.offloads,
+				    dev_info.tx_offload_capa);
+		return -EINVAL;
+	}
+
  	/* Check that device supports requested rss hash functions. */
  	if ((dev_info.flow_type_rss_offloads |
  	     dev_conf->rx_adv_conf.rss_conf.rss_hf) !=
@@ -1504,6 +1526,39 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
  						    &local_conf.offloads);
  	}
 
+	/*
+	 * 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.
+	 * The underlying PMD must be aware of this point.
+	 */
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.c rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, · line 1538

Quoted 1 line
lib/librte_ethdev/rte_ethdev.c +1 -0
+	local_conf.offloads &= ~dev->data->dev_conf.rxmode.offloads;

In fact it has a problem with MULTI_SEG.
It is a new offload which was introduced to substitute NOMULTISEG TxQ flag. If PMD reports the offload on device level, but application does not use the new interface and request the offload on queue level using txq_flags (absent NOMULTISEG flag). As the result below check fails. Sounds like it requires dedicated code to handle it. Anything else?

Quoted 7 lines

Old applications don't set Tx offloads on configure() at all. But they set them in tx_queue_setup().
For the PMDs that support only port offloads old applications will fail in tx_queue_setup(), if I don't miss anything.

I suggest keeping the log but remove the error return until all applications switch to new offloading API which should be on next release. What do you think?

Also virtual devices will give an error with this because of current testpmd implementation [1].

We may hit similar unexpected issues, as Shahaf voiced same concern.

What do you think removing error return from all three locations, rte_eth_dev_configure(), rte_eth_rx_queue_setup(), rte_eth_tx_queue_setup() and just keep error log, for this release? Next release we will already update the application interface, can add error returns next release.

[1]
https://dpdk.org/dev/patchwork/patch/39643/

Quoted 39 lines

btw, the log macro "RTE_PMD_DEBUG_TRACE" is in ERR log type but it controlled by CONFIG_RTE_LIBRTE_ETHDEV_DEBUG config option which is disabled by default. So by default we don't get the error log but the error only. I suggest switching to new dynamic logging ethdev_log()

Quoted 30 lines
Quoted 27 lines
lib/librte_ethdev/rte_ethdev.c +23 -0
+
+	/*
+	 * 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_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d, new "
+				    "added offloads 0x" PRIx64 " must be "
+				    "within pre-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;
+	}
+
  	ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
  					      socket_id, &local_conf, mp);
  	if (!ret) {

[...]