* [PATCH] ethdev: Reject conflicting TX offloads configuration
@ 2025-07-31 9:07 Morten Brørup
2025-07-31 9:24 ` Bruce Richardson
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Morten Brørup @ 2025-07-31 9:07 UTC (permalink / raw)
To: dev, Thomas Monjalon, Andrew Rybchenko
Cc: Ivan Malov, Konstantin Ananyev, Morten Brørup
When an ethdev port is configured for fast mbuf release, the driver can
use a TX burst function relying on the fast mbuf release preconditions.
Thus, also configuring this port or a queue on the port for transmitting
segmented packets is prohibited.
Checks for these conflicting configurations have been added to the ethdev
library, so the drivers don't have to implement them.
Also, the descriptions of the RX and TX offloads have been improved, to
reflect that they are not only for device capability reporting, but also
for device and queue configuration purposes.
Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
---
lib/ethdev/rte_ethdev.c | 38 ++++++++++++++++++++++++++++++++++++++
lib/ethdev/rte_ethdev.h | 20 ++++++++++----------
2 files changed, 48 insertions(+), 10 deletions(-)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index dd7c00bc94..6570517711 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1531,6 +1531,18 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
goto rollback;
}
+ /* MBUF_FAST_FREE preconditions conflict with MULTI_SEGS support. */
+ if ((dev_conf->txmode.offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
+ (dev_conf->txmode.offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)) {
+ RTE_ETHDEV_LOG_LINE(ERR,
+ "Ethdev port_id=%d Tx offload %s conflicts with Tx offload %s",
+ port_id,
+ rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MULTI_SEGS),
+ rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE));
+ ret = -EINVAL;
+ goto rollback;
+ }
+
dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf =
rte_eth_rss_hf_refine(dev_conf->rx_adv_conf.rss_conf.rss_hf);
@@ -2709,6 +2721,32 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
return -EINVAL;
}
+ /*
+ * If the driver uses a Tx function with MBUF_FAST_FREE preconditions,
+ * per-queue MULTI_SEGS support is not possible.
+ */
+ if ((dev->data->dev_conf.txmode.offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
+ (local_conf.offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)) {
+ RTE_ETHDEV_LOG_LINE(ERR,
+ "Ethdev port_id=%d tx_queue_id=%d, Tx offload %s conflicts with per-port Tx offload %s",
+ port_id, tx_queue_id,
+ rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MULTI_SEGS),
+ rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE));
+ return -EINVAL;
+ }
+ /*
+ * If the driver uses a Tx function with MULTI_SEGS support,
+ * runtime support for per-queue MBUF_FAST_FREE optimization depends on the driver.
+ */
+ if ((dev->data->dev_conf.txmode.offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS) &&
+ (local_conf.offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE))
+ RTE_ETHDEV_LOG_LINE(DEBUG,
+ "Ethdev port_id=%d tx_queue_id=%d, Tx offload %s potential conflict with per-port Tx offload %s, "
+ "runtime support depends on the driver",
+ port_id, tx_queue_id,
+ rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE),
+ rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MULTI_SEGS));
+
rte_ethdev_trace_txq_setup(port_id, tx_queue_id, nb_tx_desc, tx_conf);
return eth_err(port_id, dev->dev_ops->tx_queue_setup(dev,
tx_queue_id, nb_tx_desc, socket_id, &local_conf));
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index f9fb6ae549..760a1d2675 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -1550,7 +1550,7 @@ struct rte_eth_conf {
};
/**
- * Rx offload capabilities of a device.
+ * Rx offload capabilities/configuration of a device or queue.
*/
#define RTE_ETH_RX_OFFLOAD_VLAN_STRIP RTE_BIT64(0)
#define RTE_ETH_RX_OFFLOAD_IPV4_CKSUM RTE_BIT64(1)
@@ -1585,12 +1585,12 @@ struct rte_eth_conf {
RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
/*
- * If new Rx offload capabilities are defined, they also must be
+ * If new Rx offloads are defined, they also must be
* mentioned in rte_rx_offload_names in rte_ethdev.c file.
*/
/**
- * Tx offload capabilities of a device.
+ * Tx offload capabilities/configuration of a device or queue.
*/
#define RTE_ETH_TX_OFFLOAD_VLAN_INSERT RTE_BIT64(0)
#define RTE_ETH_TX_OFFLOAD_IPV4_CKSUM RTE_BIT64(1)
@@ -1611,10 +1611,10 @@ struct rte_eth_conf {
* Tx queue without SW lock.
*/
#define RTE_ETH_TX_OFFLOAD_MT_LOCKFREE RTE_BIT64(14)
-/** Device supports multi segment send. */
+/** Multi segment send. */
#define RTE_ETH_TX_OFFLOAD_MULTI_SEGS RTE_BIT64(15)
/**
- * Device supports optimization for fast release of mbufs.
+ * Optimization for fast release of mbufs.
* When set application must guarantee that per-queue all mbufs come from the same mempool,
* are direct, have refcnt=1, next=NULL and nb_segs=1, as done by rte_pktmbuf_prefree_seg().
*
@@ -1623,27 +1623,27 @@ struct rte_eth_conf {
#define RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE RTE_BIT64(16)
#define RTE_ETH_TX_OFFLOAD_SECURITY RTE_BIT64(17)
/**
- * Device supports generic UDP tunneled packet TSO.
+ * Generic UDP tunneled packet TSO.
* Application must set RTE_MBUF_F_TX_TUNNEL_UDP and other mbuf fields required
* for tunnel TSO.
*/
#define RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO RTE_BIT64(18)
/**
- * Device supports generic IP tunneled packet TSO.
+ * Generic IP tunneled packet TSO.
* Application must set RTE_MBUF_F_TX_TUNNEL_IP and other mbuf fields required
* for tunnel TSO.
*/
#define RTE_ETH_TX_OFFLOAD_IP_TNL_TSO RTE_BIT64(19)
-/** Device supports outer UDP checksum */
+/** Outer UDP checksum. Used for tunneling packet. */
#define RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM RTE_BIT64(20)
/**
- * Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
+ * Send on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
* if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags.
* The mbuf field and flag are registered when the offload is configured.
*/
#define RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP RTE_BIT64(21)
/*
- * If new Tx offload capabilities are defined, they also must be
+ * If new Tx offloads are defined, they also must be
* mentioned in rte_tx_offload_names in rte_ethdev.c file.
*/
--
2.43.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] ethdev: Reject conflicting TX offloads configuration
2025-07-31 9:07 [PATCH] ethdev: Reject conflicting TX offloads configuration Morten Brørup
@ 2025-07-31 9:24 ` Bruce Richardson
2025-07-31 10:07 ` Andrew Rybchenko
2025-07-31 9:27 ` Ivan Malov
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Bruce Richardson @ 2025-07-31 9:24 UTC (permalink / raw)
To: Morten Brørup
Cc: dev, Thomas Monjalon, Andrew Rybchenko, Ivan Malov, Konstantin Ananyev
On Thu, Jul 31, 2025 at 09:07:31AM +0000, Morten Brørup wrote:
> When an ethdev port is configured for fast mbuf release, the driver can
> use a TX burst function relying on the fast mbuf release preconditions.
> Thus, also configuring this port or a queue on the port for transmitting
> segmented packets is prohibited.
> Checks for these conflicting configurations have been added to the ethdev
> library, so the drivers don't have to implement them.
>
> Also, the descriptions of the RX and TX offloads have been improved, to
> reflect that they are not only for device capability reporting, but also
> for device and queue configuration purposes.
>
> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> ---
Maybe split into two patches, so the offload descriptions are separate from
the conflict checks.
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] ethdev: Reject conflicting TX offloads configuration
2025-07-31 9:07 [PATCH] ethdev: Reject conflicting TX offloads configuration Morten Brørup
2025-07-31 9:24 ` Bruce Richardson
@ 2025-07-31 9:27 ` Ivan Malov
2025-07-31 9:34 ` Morten Brørup
2025-07-31 11:32 ` Konstantin Ananyev
2025-07-31 12:56 ` [PATCH v2 1/3] testpmd: Do not enable mbuf fast release TX offload by default Morten Brørup
3 siblings, 1 reply; 10+ messages in thread
From: Ivan Malov @ 2025-07-31 9:27 UTC (permalink / raw)
To: Morten Brørup
Cc: dev, Thomas Monjalon, Andrew Rybchenko, Konstantin Ananyev
[-- Attachment #1: Type: text/plain, Size: 6681 bytes --]
Hi Morten,
On Thu, 31 Jul 2025, Morten Brørup wrote:
> When an ethdev port is configured for fast mbuf release, the driver can
> use a TX burst function relying on the fast mbuf release preconditions.
> Thus, also configuring this port or a queue on the port for transmitting
> segmented packets is prohibited.
> Checks for these conflicting configurations have been added to the ethdev
> library, so the drivers don't have to implement them.
>
> Also, the descriptions of the RX and TX offloads have been improved, to
> reflect that they are not only for device capability reporting, but also
> for device and queue configuration purposes.
>
> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> ---
> lib/ethdev/rte_ethdev.c | 38 ++++++++++++++++++++++++++++++++++++++
> lib/ethdev/rte_ethdev.h | 20 ++++++++++----------
> 2 files changed, 48 insertions(+), 10 deletions(-)
>
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index dd7c00bc94..6570517711 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -1531,6 +1531,18 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
> goto rollback;
> }
>
> + /* MBUF_FAST_FREE preconditions conflict with MULTI_SEGS support. */
> + if ((dev_conf->txmode.offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
> + (dev_conf->txmode.offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)) {
> + RTE_ETHDEV_LOG_LINE(ERR,
> + "Ethdev port_id=%d Tx offload %s conflicts with Tx offload %s",
Is it required to spell 'Ethdev ' at start of the line? It was my impression
that 'ethdev' would be printed anyway by [1] (the '# t' part). Am I wrong?
[1] https://github.com/DPDK/dpdk/blob/b222395561638f89562e4ef42e1eabf2d6db43dd/lib/log/rte_log.h#L334
Thank you.
> + port_id,
> + rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MULTI_SEGS),
> + rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE));
> + ret = -EINVAL;
> + goto rollback;
> + }
> +
> dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf =
> rte_eth_rss_hf_refine(dev_conf->rx_adv_conf.rss_conf.rss_hf);
>
> @@ -2709,6 +2721,32 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
> return -EINVAL;
> }
>
> + /*
> + * If the driver uses a Tx function with MBUF_FAST_FREE preconditions,
> + * per-queue MULTI_SEGS support is not possible.
> + */
> + if ((dev->data->dev_conf.txmode.offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
> + (local_conf.offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)) {
> + RTE_ETHDEV_LOG_LINE(ERR,
> + "Ethdev port_id=%d tx_queue_id=%d, Tx offload %s conflicts with per-port Tx offload %s",
> + port_id, tx_queue_id,
> + rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MULTI_SEGS),
> + rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE));
> + return -EINVAL;
> + }
> + /*
> + * If the driver uses a Tx function with MULTI_SEGS support,
> + * runtime support for per-queue MBUF_FAST_FREE optimization depends on the driver.
> + */
> + if ((dev->data->dev_conf.txmode.offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS) &&
> + (local_conf.offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE))
> + RTE_ETHDEV_LOG_LINE(DEBUG,
> + "Ethdev port_id=%d tx_queue_id=%d, Tx offload %s potential conflict with per-port Tx offload %s, "
> + "runtime support depends on the driver",
> + port_id, tx_queue_id,
> + rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE),
> + rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MULTI_SEGS));
> +
> rte_ethdev_trace_txq_setup(port_id, tx_queue_id, nb_tx_desc, tx_conf);
> return eth_err(port_id, dev->dev_ops->tx_queue_setup(dev,
> tx_queue_id, nb_tx_desc, socket_id, &local_conf));
> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
> index f9fb6ae549..760a1d2675 100644
> --- a/lib/ethdev/rte_ethdev.h
> +++ b/lib/ethdev/rte_ethdev.h
> @@ -1550,7 +1550,7 @@ struct rte_eth_conf {
> };
>
> /**
> - * Rx offload capabilities of a device.
> + * Rx offload capabilities/configuration of a device or queue.
> */
> #define RTE_ETH_RX_OFFLOAD_VLAN_STRIP RTE_BIT64(0)
> #define RTE_ETH_RX_OFFLOAD_IPV4_CKSUM RTE_BIT64(1)
> @@ -1585,12 +1585,12 @@ struct rte_eth_conf {
> RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
>
> /*
> - * If new Rx offload capabilities are defined, they also must be
> + * If new Rx offloads are defined, they also must be
> * mentioned in rte_rx_offload_names in rte_ethdev.c file.
> */
>
> /**
> - * Tx offload capabilities of a device.
> + * Tx offload capabilities/configuration of a device or queue.
> */
> #define RTE_ETH_TX_OFFLOAD_VLAN_INSERT RTE_BIT64(0)
> #define RTE_ETH_TX_OFFLOAD_IPV4_CKSUM RTE_BIT64(1)
> @@ -1611,10 +1611,10 @@ struct rte_eth_conf {
> * Tx queue without SW lock.
> */
> #define RTE_ETH_TX_OFFLOAD_MT_LOCKFREE RTE_BIT64(14)
> -/** Device supports multi segment send. */
> +/** Multi segment send. */
> #define RTE_ETH_TX_OFFLOAD_MULTI_SEGS RTE_BIT64(15)
> /**
> - * Device supports optimization for fast release of mbufs.
> + * Optimization for fast release of mbufs.
> * When set application must guarantee that per-queue all mbufs come from the same mempool,
> * are direct, have refcnt=1, next=NULL and nb_segs=1, as done by rte_pktmbuf_prefree_seg().
> *
> @@ -1623,27 +1623,27 @@ struct rte_eth_conf {
> #define RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE RTE_BIT64(16)
> #define RTE_ETH_TX_OFFLOAD_SECURITY RTE_BIT64(17)
> /**
> - * Device supports generic UDP tunneled packet TSO.
> + * Generic UDP tunneled packet TSO.
> * Application must set RTE_MBUF_F_TX_TUNNEL_UDP and other mbuf fields required
> * for tunnel TSO.
> */
> #define RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO RTE_BIT64(18)
> /**
> - * Device supports generic IP tunneled packet TSO.
> + * Generic IP tunneled packet TSO.
> * Application must set RTE_MBUF_F_TX_TUNNEL_IP and other mbuf fields required
> * for tunnel TSO.
> */
> #define RTE_ETH_TX_OFFLOAD_IP_TNL_TSO RTE_BIT64(19)
> -/** Device supports outer UDP checksum */
> +/** Outer UDP checksum. Used for tunneling packet. */
> #define RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM RTE_BIT64(20)
> /**
> - * Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
> + * Send on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
> * if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags.
> * The mbuf field and flag are registered when the offload is configured.
> */
> #define RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP RTE_BIT64(21)
> /*
> - * If new Tx offload capabilities are defined, they also must be
> + * If new Tx offloads are defined, they also must be
> * mentioned in rte_tx_offload_names in rte_ethdev.c file.
> */
>
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH] ethdev: Reject conflicting TX offloads configuration
2025-07-31 9:27 ` Ivan Malov
@ 2025-07-31 9:34 ` Morten Brørup
0 siblings, 0 replies; 10+ messages in thread
From: Morten Brørup @ 2025-07-31 9:34 UTC (permalink / raw)
To: Ivan Malov; +Cc: dev, Thomas Monjalon, Andrew Rybchenko, Konstantin Ananyev
> From: Ivan Malov [mailto:ivan.malov@arknetworks.am]
> Sent: Thursday, 31 July 2025 11.28
>
> Hi Morten,
>
> On Thu, 31 Jul 2025, Morten Brørup wrote:
>
> > + RTE_ETHDEV_LOG_LINE(ERR,
> > + "Ethdev port_id=%d Tx offload %s conflicts with Tx offload
> %s",
>
> Is it required to spell 'Ethdev ' at start of the line? It was my impression
> that 'ethdev' would be printed anyway by [1] (the '# t' part). Am I wrong?
>
> [1]
> https://github.com/DPDK/dpdk/blob/b222395561638f89562e4ef42e1eabf2d6db43dd/lib
> /log/rte_log.h#L334
You are right, but all the other RTE_ETHDEV_LOG_LINE() in rte_eth_dev_configure() do it, so I did it too.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] ethdev: Reject conflicting TX offloads configuration
2025-07-31 9:24 ` Bruce Richardson
@ 2025-07-31 10:07 ` Andrew Rybchenko
0 siblings, 0 replies; 10+ messages in thread
From: Andrew Rybchenko @ 2025-07-31 10:07 UTC (permalink / raw)
To: Bruce Richardson, Morten Brørup
Cc: dev, Thomas Monjalon, Ivan Malov, Konstantin Ananyev
On 7/31/25 12:24, Bruce Richardson wrote:
> On Thu, Jul 31, 2025 at 09:07:31AM +0000, Morten Brørup wrote:
>> When an ethdev port is configured for fast mbuf release, the driver can
>> use a TX burst function relying on the fast mbuf release preconditions.
>> Thus, also configuring this port or a queue on the port for transmitting
>> segmented packets is prohibited.
>> Checks for these conflicting configurations have been added to the ethdev
>> library, so the drivers don't have to implement them.
>>
>> Also, the descriptions of the RX and TX offloads have been improved, to
>> reflect that they are not only for device capability reporting, but also
>> for device and queue configuration purposes.
>>
>> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
>> ---
>
> Maybe split into two patches, so the offload descriptions are separate from
> the conflict checks.
+1
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH] ethdev: Reject conflicting TX offloads configuration
2025-07-31 9:07 [PATCH] ethdev: Reject conflicting TX offloads configuration Morten Brørup
2025-07-31 9:24 ` Bruce Richardson
2025-07-31 9:27 ` Ivan Malov
@ 2025-07-31 11:32 ` Konstantin Ananyev
2025-07-31 12:56 ` [PATCH v2 1/3] testpmd: Do not enable mbuf fast release TX offload by default Morten Brørup
3 siblings, 0 replies; 10+ messages in thread
From: Konstantin Ananyev @ 2025-07-31 11:32 UTC (permalink / raw)
To: Morten Brørup, dev, Thomas Monjalon, Andrew Rybchenko; +Cc: Ivan Malov
> When an ethdev port is configured for fast mbuf release, the driver can
> use a TX burst function relying on the fast mbuf release preconditions.
> Thus, also configuring this port or a queue on the port for transmitting
> segmented packets is prohibited.
> Checks for these conflicting configurations have been added to the ethdev
> library, so the drivers don't have to implement them.
>
> Also, the descriptions of the RX and TX offloads have been improved, to
> reflect that they are not only for device capability reporting, but also
> for device and queue configuration purposes.
>
> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> ---
> lib/ethdev/rte_ethdev.c | 38 ++++++++++++++++++++++++++++++++++++++
> lib/ethdev/rte_ethdev.h | 20 ++++++++++----------
> 2 files changed, 48 insertions(+), 10 deletions(-)
>
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index dd7c00bc94..6570517711 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -1531,6 +1531,18 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
> goto rollback;
> }
>
> + /* MBUF_FAST_FREE preconditions conflict with MULTI_SEGS support. */
> + if ((dev_conf->txmode.offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
> + (dev_conf->txmode.offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)) {
> + RTE_ETHDEV_LOG_LINE(ERR,
> + "Ethdev port_id=%d Tx offload %s conflicts with Tx offload %s",
> + port_id,
> + rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MULTI_SEGS),
> + rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE));
> + ret = -EINVAL;
> + goto rollback;
> + }
> +
> dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf =
> rte_eth_rss_hf_refine(dev_conf->rx_adv_conf.rss_conf.rss_hf);
>
> @@ -2709,6 +2721,32 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
> return -EINVAL;
> }
>
> + /*
> + * If the driver uses a Tx function with MBUF_FAST_FREE preconditions,
> + * per-queue MULTI_SEGS support is not possible.
> + */
> + if ((dev->data->dev_conf.txmode.offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
> + (local_conf.offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)) {
> + RTE_ETHDEV_LOG_LINE(ERR,
> + "Ethdev port_id=%d tx_queue_id=%d, Tx offload %s conflicts with per-port Tx offload %s",
> + port_id, tx_queue_id,
> + rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MULTI_SEGS),
> + rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE));
> + return -EINVAL;
> + }
> + /*
> + * If the driver uses a Tx function with MULTI_SEGS support,
> + * runtime support for per-queue MBUF_FAST_FREE optimization depends on the driver.
> + */
> + if ((dev->data->dev_conf.txmode.offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS) &&
> + (local_conf.offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE))
> + RTE_ETHDEV_LOG_LINE(DEBUG,
> + "Ethdev port_id=%d tx_queue_id=%d, Tx offload %s potential conflict with per-port Tx offload %s, "
> + "runtime support depends on the driver",
> + port_id, tx_queue_id,
> + rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE),
> + rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MULTI_SEGS));
> +
> rte_ethdev_trace_txq_setup(port_id, tx_queue_id, nb_tx_desc, tx_conf);
> return eth_err(port_id, dev->dev_ops->tx_queue_setup(dev,
> tx_queue_id, nb_tx_desc, socket_id, &local_conf));
> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
> index f9fb6ae549..760a1d2675 100644
> --- a/lib/ethdev/rte_ethdev.h
> +++ b/lib/ethdev/rte_ethdev.h
> @@ -1550,7 +1550,7 @@ struct rte_eth_conf {
> };
>
> /**
> - * Rx offload capabilities of a device.
> + * Rx offload capabilities/configuration of a device or queue.
> */
> #define RTE_ETH_RX_OFFLOAD_VLAN_STRIP RTE_BIT64(0)
> #define RTE_ETH_RX_OFFLOAD_IPV4_CKSUM RTE_BIT64(1)
> @@ -1585,12 +1585,12 @@ struct rte_eth_conf {
> RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
>
> /*
> - * If new Rx offload capabilities are defined, they also must be
> + * If new Rx offloads are defined, they also must be
> * mentioned in rte_rx_offload_names in rte_ethdev.c file.
> */
>
> /**
> - * Tx offload capabilities of a device.
> + * Tx offload capabilities/configuration of a device or queue.
> */
> #define RTE_ETH_TX_OFFLOAD_VLAN_INSERT RTE_BIT64(0)
> #define RTE_ETH_TX_OFFLOAD_IPV4_CKSUM RTE_BIT64(1)
> @@ -1611,10 +1611,10 @@ struct rte_eth_conf {
> * Tx queue without SW lock.
> */
> #define RTE_ETH_TX_OFFLOAD_MT_LOCKFREE RTE_BIT64(14)
> -/** Device supports multi segment send. */
> +/** Multi segment send. */
> #define RTE_ETH_TX_OFFLOAD_MULTI_SEGS RTE_BIT64(15)
> /**
> - * Device supports optimization for fast release of mbufs.
> + * Optimization for fast release of mbufs.
> * When set application must guarantee that per-queue all mbufs come from the same mempool,
> * are direct, have refcnt=1, next=NULL and nb_segs=1, as done by rte_pktmbuf_prefree_seg().
> *
> @@ -1623,27 +1623,27 @@ struct rte_eth_conf {
> #define RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE RTE_BIT64(16)
> #define RTE_ETH_TX_OFFLOAD_SECURITY RTE_BIT64(17)
> /**
> - * Device supports generic UDP tunneled packet TSO.
> + * Generic UDP tunneled packet TSO.
> * Application must set RTE_MBUF_F_TX_TUNNEL_UDP and other mbuf fields required
> * for tunnel TSO.
> */
> #define RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO RTE_BIT64(18)
> /**
> - * Device supports generic IP tunneled packet TSO.
> + * Generic IP tunneled packet TSO.
> * Application must set RTE_MBUF_F_TX_TUNNEL_IP and other mbuf fields required
> * for tunnel TSO.
> */
> #define RTE_ETH_TX_OFFLOAD_IP_TNL_TSO RTE_BIT64(19)
> -/** Device supports outer UDP checksum */
> +/** Outer UDP checksum. Used for tunneling packet. */
> #define RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM RTE_BIT64(20)
> /**
> - * Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
> + * Send on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
> * if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags.
> * The mbuf field and flag are registered when the offload is configured.
> */
> #define RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP RTE_BIT64(21)
> /*
> - * If new Tx offload capabilities are defined, they also must be
> + * If new Tx offloads are defined, they also must be
> * mentioned in rte_tx_offload_names in rte_ethdev.c file.
> */
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/3] testpmd: Do not enable mbuf fast release TX offload by default
2025-07-31 9:07 [PATCH] ethdev: Reject conflicting TX offloads configuration Morten Brørup
` (2 preceding siblings ...)
2025-07-31 11:32 ` Konstantin Ananyev
@ 2025-07-31 12:56 ` Morten Brørup
2025-07-31 12:56 ` [PATCH v2 2/3] ethdev: Improve descriptions of RX and TX offloads Morten Brørup
2025-07-31 12:56 ` [PATCH v2 3/3] ethdev: Reject conflicting TX offloads configuration Morten Brørup
3 siblings, 2 replies; 10+ messages in thread
From: Morten Brørup @ 2025-07-31 12:56 UTC (permalink / raw)
To: dev, Aman Singh, Thomas Monjalon, Andrew Rybchenko
Cc: Ivan Malov, Konstantin Ananyev, Morten Brørup
Enabling some offload by default may conflict with a manually configured
offload.
Specifically, the mbuf fast release TX offload, which conflicts with multi
segment packet TX offload, was enabled by default.
Therefore, mbuf fast release TX offload (the only TX offload which was
enabled by default) is not enabled by default anymore.
Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
---
app/test-pmd/testpmd.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index bb88555328..f00eae3992 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -490,9 +490,7 @@ lcoreid_t latencystats_lcore_id = -1;
*/
struct rte_eth_rxmode rx_mode;
-struct rte_eth_txmode tx_mode = {
- .offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
-};
+struct rte_eth_txmode tx_mode;
volatile int test_done = 1; /* stop packet forwarding when set to 1. */
@@ -1592,10 +1590,6 @@ init_config_port_offloads(portid_t pid, uint32_t socket_id)
if (ret != 0)
rte_exit(EXIT_FAILURE, "rte_eth_dev_info_get() failed\n");
- if (!(port->dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE))
- port->dev_conf.txmode.offloads &=
- ~RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
-
/* Apply Rx offloads configuration */
for (i = 0; i < port->dev_info.max_rx_queues; i++)
port->rxq[i].conf.offloads = port->dev_conf.rxmode.offloads;
@@ -2857,9 +2851,6 @@ update_bonding_port_dev_conf(portid_t bond_pid)
return;
}
- if (port->dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)
- port->dev_conf.txmode.offloads |=
- RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
/* Apply Tx offloads configuration */
for (i = 0; i < port->dev_info.max_tx_queues; i++)
port->txq[i].conf.offloads = port->dev_conf.txmode.offloads;
--
2.43.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 2/3] ethdev: Improve descriptions of RX and TX offloads
2025-07-31 12:56 ` [PATCH v2 1/3] testpmd: Do not enable mbuf fast release TX offload by default Morten Brørup
@ 2025-07-31 12:56 ` Morten Brørup
2025-07-31 12:56 ` [PATCH v2 3/3] ethdev: Reject conflicting TX offloads configuration Morten Brørup
1 sibling, 0 replies; 10+ messages in thread
From: Morten Brørup @ 2025-07-31 12:56 UTC (permalink / raw)
To: dev, Aman Singh, Thomas Monjalon, Andrew Rybchenko
Cc: Ivan Malov, Konstantin Ananyev, Morten Brørup, Bruce Richardson
The descriptions of the RX and TX offloads have been improved, to
reflect that they are not only for device capability reporting, but
also for device and queue configuration purposes.
Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
---
lib/ethdev/rte_ethdev.h | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index f9fb6ae549..760a1d2675 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -1550,7 +1550,7 @@ struct rte_eth_conf {
};
/**
- * Rx offload capabilities of a device.
+ * Rx offload capabilities/configuration of a device or queue.
*/
#define RTE_ETH_RX_OFFLOAD_VLAN_STRIP RTE_BIT64(0)
#define RTE_ETH_RX_OFFLOAD_IPV4_CKSUM RTE_BIT64(1)
@@ -1585,12 +1585,12 @@ struct rte_eth_conf {
RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
/*
- * If new Rx offload capabilities are defined, they also must be
+ * If new Rx offloads are defined, they also must be
* mentioned in rte_rx_offload_names in rte_ethdev.c file.
*/
/**
- * Tx offload capabilities of a device.
+ * Tx offload capabilities/configuration of a device or queue.
*/
#define RTE_ETH_TX_OFFLOAD_VLAN_INSERT RTE_BIT64(0)
#define RTE_ETH_TX_OFFLOAD_IPV4_CKSUM RTE_BIT64(1)
@@ -1611,10 +1611,10 @@ struct rte_eth_conf {
* Tx queue without SW lock.
*/
#define RTE_ETH_TX_OFFLOAD_MT_LOCKFREE RTE_BIT64(14)
-/** Device supports multi segment send. */
+/** Multi segment send. */
#define RTE_ETH_TX_OFFLOAD_MULTI_SEGS RTE_BIT64(15)
/**
- * Device supports optimization for fast release of mbufs.
+ * Optimization for fast release of mbufs.
* When set application must guarantee that per-queue all mbufs come from the same mempool,
* are direct, have refcnt=1, next=NULL and nb_segs=1, as done by rte_pktmbuf_prefree_seg().
*
@@ -1623,27 +1623,27 @@ struct rte_eth_conf {
#define RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE RTE_BIT64(16)
#define RTE_ETH_TX_OFFLOAD_SECURITY RTE_BIT64(17)
/**
- * Device supports generic UDP tunneled packet TSO.
+ * Generic UDP tunneled packet TSO.
* Application must set RTE_MBUF_F_TX_TUNNEL_UDP and other mbuf fields required
* for tunnel TSO.
*/
#define RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO RTE_BIT64(18)
/**
- * Device supports generic IP tunneled packet TSO.
+ * Generic IP tunneled packet TSO.
* Application must set RTE_MBUF_F_TX_TUNNEL_IP and other mbuf fields required
* for tunnel TSO.
*/
#define RTE_ETH_TX_OFFLOAD_IP_TNL_TSO RTE_BIT64(19)
-/** Device supports outer UDP checksum */
+/** Outer UDP checksum. Used for tunneling packet. */
#define RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM RTE_BIT64(20)
/**
- * Device sends on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
+ * Send on time read from RTE_MBUF_DYNFIELD_TIMESTAMP_NAME
* if RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME is set in ol_flags.
* The mbuf field and flag are registered when the offload is configured.
*/
#define RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP RTE_BIT64(21)
/*
- * If new Tx offload capabilities are defined, they also must be
+ * If new Tx offloads are defined, they also must be
* mentioned in rte_tx_offload_names in rte_ethdev.c file.
*/
--
2.43.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 3/3] ethdev: Reject conflicting TX offloads configuration
2025-07-31 12:56 ` [PATCH v2 1/3] testpmd: Do not enable mbuf fast release TX offload by default Morten Brørup
2025-07-31 12:56 ` [PATCH v2 2/3] ethdev: Improve descriptions of RX and TX offloads Morten Brørup
@ 2025-07-31 12:56 ` Morten Brørup
2025-08-01 1:09 ` zhoumin
1 sibling, 1 reply; 10+ messages in thread
From: Morten Brørup @ 2025-07-31 12:56 UTC (permalink / raw)
To: dev, Aman Singh, Thomas Monjalon, Andrew Rybchenko
Cc: Ivan Malov, Konstantin Ananyev, Morten Brørup, Bruce Richardson
When an ethdev port is configured for fast mbuf release, the driver can
use a TX burst function relying on the fast mbuf release preconditions.
Thus, also configuring this port or a queue on the port for transmitting
segmented packets is prohibited.
Checks for these conflicting configurations have been added to the ethdev
library, so the drivers don't have to implement them.
Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
---
lib/ethdev/rte_ethdev.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index dd7c00bc94..6570517711 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1531,6 +1531,18 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
goto rollback;
}
+ /* MBUF_FAST_FREE preconditions conflict with MULTI_SEGS support. */
+ if ((dev_conf->txmode.offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
+ (dev_conf->txmode.offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)) {
+ RTE_ETHDEV_LOG_LINE(ERR,
+ "Ethdev port_id=%d Tx offload %s conflicts with Tx offload %s",
+ port_id,
+ rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MULTI_SEGS),
+ rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE));
+ ret = -EINVAL;
+ goto rollback;
+ }
+
dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf =
rte_eth_rss_hf_refine(dev_conf->rx_adv_conf.rss_conf.rss_hf);
@@ -2709,6 +2721,32 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
return -EINVAL;
}
+ /*
+ * If the driver uses a Tx function with MBUF_FAST_FREE preconditions,
+ * per-queue MULTI_SEGS support is not possible.
+ */
+ if ((dev->data->dev_conf.txmode.offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
+ (local_conf.offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)) {
+ RTE_ETHDEV_LOG_LINE(ERR,
+ "Ethdev port_id=%d tx_queue_id=%d, Tx offload %s conflicts with per-port Tx offload %s",
+ port_id, tx_queue_id,
+ rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MULTI_SEGS),
+ rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE));
+ return -EINVAL;
+ }
+ /*
+ * If the driver uses a Tx function with MULTI_SEGS support,
+ * runtime support for per-queue MBUF_FAST_FREE optimization depends on the driver.
+ */
+ if ((dev->data->dev_conf.txmode.offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS) &&
+ (local_conf.offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE))
+ RTE_ETHDEV_LOG_LINE(DEBUG,
+ "Ethdev port_id=%d tx_queue_id=%d, Tx offload %s potential conflict with per-port Tx offload %s, "
+ "runtime support depends on the driver",
+ port_id, tx_queue_id,
+ rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE),
+ rte_eth_dev_tx_offload_name(RTE_ETH_TX_OFFLOAD_MULTI_SEGS));
+
rte_ethdev_trace_txq_setup(port_id, tx_queue_id, nb_tx_desc, tx_conf);
return eth_err(port_id, dev->dev_ops->tx_queue_setup(dev,
tx_queue_id, nb_tx_desc, socket_id, &local_conf));
--
2.43.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 3/3] ethdev: Reject conflicting TX offloads configuration
2025-07-31 12:56 ` [PATCH v2 3/3] ethdev: Reject conflicting TX offloads configuration Morten Brørup
@ 2025-08-01 1:09 ` zhoumin
0 siblings, 0 replies; 10+ messages in thread
From: zhoumin @ 2025-08-01 1:09 UTC (permalink / raw)
To: dev
Recheck-request: loongarch-unit-testing
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-08-01 1:09 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-31 9:07 [PATCH] ethdev: Reject conflicting TX offloads configuration Morten Brørup
2025-07-31 9:24 ` Bruce Richardson
2025-07-31 10:07 ` Andrew Rybchenko
2025-07-31 9:27 ` Ivan Malov
2025-07-31 9:34 ` Morten Brørup
2025-07-31 11:32 ` Konstantin Ananyev
2025-07-31 12:56 ` [PATCH v2 1/3] testpmd: Do not enable mbuf fast release TX offload by default Morten Brørup
2025-07-31 12:56 ` [PATCH v2 2/3] ethdev: Improve descriptions of RX and TX offloads Morten Brørup
2025-07-31 12:56 ` [PATCH v2 3/3] ethdev: Reject conflicting TX offloads configuration Morten Brørup
2025-08-01 1:09 ` zhoumin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).