Skip to contentSkip to conversation

ethdev: support Rx data discard

RFC PATCH Superseded Gregory Etelson 4 participants 11 messages Jan 4 – Jan 20

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ethdev: support Rx data discard

In some cases application does not need to receive entire packet from port hardware.
If application could fetch required data only and safely discard the rest of Rx packet data, that could improve port performance by reducing PCI bandwidth.

The RTE_ETH_DEV_DISCARD_RX_DATA device capability flag notifies that a port hardware supports Rx data discard.

---
 lib/ethdev/rte_ethdev.h | 2 ++
 1 file changed, 2 insertions(+)
lib/ethdev/rte_ethdev.h +2 -0
index a66c2abbdb..10938ddad3 100644
@@ -2170,6 +2170,8 @@ struct rte_eth_dev_owner {
  * PMDs filling the queue xstats themselves should not set this flag
  */
 #define RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS RTE_BIT32(6)
+/** Device supports Rx data discard */
+#define RTE_ETH_DEV_DISCARD_RX_DATA RTE_BIT32(7)
 /**@}*/
 
 /**
Signature · 1 line
2.51.0
#1 lore raw
Quoted 19 lines · On Sun, 4 Jan 2026 15:13:01 +0200 Gregory Etelson <[email protected]> wrote:

In some cases application does not need to receive entire packet from port hardware.
If application could fetch required data only and safely discard the rest of Rx packet data, that could improve port performance by reducing PCI bandwidth.

The RTE_ETH_DEV_DISCARD_RX_DATA device capability flag notifies that a port hardware supports Rx data discard.

---
 lib/ethdev/rte_ethdev.h | 2 ++
 1 file changed, 2 insertions(+)
lib/ethdev/rte_ethdev.h +0 -0
index a66c2abbdb..10938ddad3 100644

lib/ethdev/rte_ethdev.h struct rte_eth_dev_owner { · line 2177

Quoted 8 lines
lib/ethdev/rte_ethdev.h +2 -0
@@ -2170,6 +2170,8 @@ struct rte_eth_dev_owner {
  * PMDs filling the queue xstats themselves should not set this flag
  */
 #define RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS RTE_BIT32(6)
+/** Device supports Rx data discard */
+#define RTE_ETH_DEV_DISCARD_RX_DATA RTE_BIT32(7)
 /**@}*/
 
 /**

Just because HW can do a feature doesn't mean that DPDK has to support it. There needs to be more justification.

Why not use a flow rule?

#2 lore raw

RFC PATCH v2 1/1 ethdev: support selective Rx data

In reply to Gregory Etelson

In some cases application does not need to receive entire packet from port hardware.
If application could receive required Rx data only and safely discard the rest of Rx packet data, that could improve port performance by reducing PCI bandwidth and application memory consumption.

Selective Rx data allows application to receive
only pre-configured packet segments and discard the rest. For example:
- Deliver the first N bytes only.
- Deliver the last N bytes only.
- Deliver N1 bytes from offest Off1 and N2 bytes from offset Off2.

Selective Rx data is implemented on-top of the existing Rx BUFFER_SPLIT functionality:
- The rte_eth_rxseg_split will use the NULL mempool for data segments that should be discarded.
- PMD will not create MBUF segments if no data was read.

For example: Deliver Ethernet header only

Rx queue segments configuration:

struct rte_eth_rxseg_split split[2] = {
    {
        .mp = <some mempool>,
        .length = sizeof(struct rte_ether_hdr)
    },
    {
        .mp = NULL, /* discard data */
        .length = <MTU>
    }
};

Received MBUF configuration:
mbuf[0].pkt_len = <original packet length>; mbuf[0].data_len = sizeof(struct rte_ether_hdr); mbuf[0].next = NULL; /* The next segment did not deliver data */

A PMD activates the selective Rx data capability by setting the rte_eth_rxseg_capa.selective_read bit.

---
 lib/ethdev/rte_ethdev.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/ethdev/rte_ethdev.h +6 -1
index a66c2abbdb..bc456bb6d7 100644
@@ -1121,7 +1121,11 @@ struct rte_eth_txmode {
  *   The rest will be put into the last valid pool.
  */
 struct rte_eth_rxseg_split {
-	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
+	/**
+	 * Memory pool to allocate segment from.
+	 * NULL means skipped segment in selective Rx data. @see selective_read.
+	 */
+	struct rte_mempool *mp;
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
 	/**
@@ -1757,6 +1761,7 @@ struct rte_eth_rxseg_capa {
 	__extension__
 	uint32_t multi_pools:1; /**< Supports receiving to multiple pools.*/
 	uint32_t offset_allowed:1; /**< Supports buffer offsets. */
+	uint32_t selective_read:1; /**< Supports selective read. */
 	uint32_t offset_align_log2:4; /**< Required offset alignment. */
 	uint16_t max_nseg; /**< Maximum amount of segments to split. */
 	uint16_t reserved; /**< Reserved field. */
Signature · 1 line
2.51.0
#3 lore raw

Re: [RFC PATCH v2] ethdev: support selective Rx data

05/01/2026 17:51, Gregory Etelson:

lib/ethdev/rte_ethdev.h struct rte_eth_rxseg_capa { · line 1767

Quoted 8 lines
lib/ethdev/rte_ethdev.h +1 -0
@@ -1757,6 +1761,7 @@ struct rte_eth_rxseg_capa {
 	__extension__
 	uint32_t multi_pools:1; /**< Supports receiving to multiple pools.*/
 	uint32_t offset_allowed:1; /**< Supports buffer offsets. */
+	uint32_t selective_read:1; /**< Supports selective read. */
 	uint32_t offset_align_log2:4; /**< Required offset alignment. */
 	uint16_t max_nseg; /**< Maximum amount of segments to split. */
 	uint16_t reserved; /**< Reserved field. */

Adding a field in the middle in an ABI breakage.
If the ABI checker is smart enough, it should be OK to move the 1-bit field at the end of the bit-fields.
If we still have an error, we may add an exception to devtools/libabigail.abignore

#4 lore raw

RFC PATCH v3 1/1 ethdev: support selective Rx data

In reply to Gregory Etelson

In some cases application does not need to receive entire packet from port hardware.
If application could receive required Rx data only and safely discard the rest of Rx packet data, that could improve port performance by reducing PCI bandwidth and application memory consumption.

Selective Rx data allows application to receive
only pre-configured packet segments and discard the rest. For example:
- Deliver the first N bytes only.
- Deliver the last N bytes only.
- Deliver N1 bytes from offset Off1 and N2 bytes from offset Off2.

Selective Rx data is implemented on-top of the existing Rx BUFFER_SPLIT functionality:
- The rte_eth_rxseg_split will use the NULL mempool for data segments that should be discarded.
- PMD will not create MBUF segments if no data was read.

For example: Deliver Ethernet header only

Rx queue segments configuration:

struct rte_eth_rxseg_split split[2] = {
    {
        .mp = <some mempool>,
        .length = sizeof(struct rte_ether_hdr)
    },
    {
        .mp = NULL, /* discard data */
        .length = <MTU>
    }
};

Received MBUF configuration:
mbuf[0].pkt_len = <original packet length>; mbuf[0].data_len = sizeof(struct rte_ether_hdr); mbuf[0].next = NULL; /* The next segment did not deliver data */

A PMD activates the selective Rx data capability by setting the rte_eth_rxseg_capa.selective_read bit.

---
v3: Change the selective_read bit location.

---
 lib/ethdev/rte_ethdev.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/ethdev/rte_ethdev.h +6 -1
index a66c2abbdb..84769d3d26 100644
@@ -1121,7 +1121,11 @@ struct rte_eth_txmode {
  *   The rest will be put into the last valid pool.
  */
 struct rte_eth_rxseg_split {
-	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
+	/**
+	 * Memory pool to allocate segment from.
+	 * NULL means skipped segment in selective Rx data. @see selective_read.
+	 */
+	struct rte_mempool *mp;
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
 	/**
@@ -1758,6 +1762,7 @@ struct rte_eth_rxseg_capa {
 	uint32_t multi_pools:1; /**< Supports receiving to multiple pools.*/
 	uint32_t offset_allowed:1; /**< Supports buffer offsets. */
 	uint32_t offset_align_log2:4; /**< Required offset alignment. */
+	uint32_t selective_read:1; /**< Supports selective read. */
 	uint16_t max_nseg; /**< Maximum amount of segments to split. */
 	uint16_t reserved; /**< Reserved field. */
 };
Signature · 1 line
2.51.0
#5 lore raw

Re: [RFC PATCH v3] ethdev: support selective Rx data

Quoted 66 lines · On Tue, 6 Jan 2026 17:45:54 +0200 Gregory Etelson <[email protected]> wrote:

In some cases application does not need to receive entire packet from port hardware.
If application could receive required Rx data only and safely discard the rest of Rx packet data, that could improve port performance by reducing PCI bandwidth and application memory consumption.

Selective Rx data allows application to receive
only pre-configured packet segments and discard the rest. For example:
- Deliver the first N bytes only.
- Deliver the last N bytes only.
- Deliver N1 bytes from offset Off1 and N2 bytes from offset Off2.

Selective Rx data is implemented on-top of the existing Rx BUFFER_SPLIT functionality:
- The rte_eth_rxseg_split will use the NULL mempool for data segments that should be discarded.
- PMD will not create MBUF segments if no data was read.

For example: Deliver Ethernet header only

Rx queue segments configuration:

struct rte_eth_rxseg_split split[2] = {
    {
        .mp = <some mempool>,
        .length = sizeof(struct rte_ether_hdr)
    },
    {
        .mp = NULL, /* discard data */
        .length = <MTU>
    }
};

Received MBUF configuration:
mbuf[0].pkt_len = <original packet length>; mbuf[0].data_len = sizeof(struct rte_ether_hdr); mbuf[0].next = NULL; /* The next segment did not deliver data */

A PMD activates the selective Rx data capability by setting the rte_eth_rxseg_capa.selective_read bit.

---
v3: Change the selective_read bit location.

---
 lib/ethdev/rte_ethdev.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/ethdev/rte_ethdev.h +5 -1
index a66c2abbdb..84769d3d26 100644
@@ -1121,7 +1121,11 @@ struct rte_eth_txmode {
  *   The rest will be put into the last valid pool.
  */
 struct rte_eth_rxseg_split {
-	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
+	/**
+	 * Memory pool to allocate segment from.
+	 * NULL means skipped segment in selective Rx data. @see selective_read.
+	 */
+	struct rte_mempool *mp;
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
 	/**

lib/ethdev/rte_ethdev.h struct rte_eth_rxseg_capa { · line 1768

Quoted 7 lines
lib/ethdev/rte_ethdev.h +1 -0
@@ -1758,6 +1762,7 @@ struct rte_eth_rxseg_capa {
 	uint32_t multi_pools:1; /**< Supports receiving to multiple pools.*/
 	uint32_t offset_allowed:1; /**< Supports buffer offsets. */
 	uint32_t offset_align_log2:4; /**< Required offset alignment. */
+	uint32_t selective_read:1; /**< Supports selective read. */
 	uint16_t max_nseg; /**< Maximum amount of segments to split. */
 	uint16_t reserved; /**< Reserved field. */
 };

Will need testpmd extension and a driver (ideally multiple) that support it.

#6 lore raw

Re: [RFC PATCH v3] ethdev: support selective Rx data

Hello Stephen,

Quoted 7 lines
Quoted 7 lines

In some cases application does not need to receive entire packet from port hardware.
If application could receive required Rx data only and safely discard the rest of Rx packet data, that could improve port performance by reducing PCI bandwidth and application memory consumption.

[ snip ]

Quoted 3 lines

Will need testpmd extension and a driver (ideally multiple) that support it.

Ethdev library, MLX5 PMD and testpmd patches with the selective Rx data read implemetnation will be proveded after the RFC acceptence.

Additional PMD implementations depend on HW support to safely discard Rx data.

Regards,
Gregory

#7 lore raw

Re: [RFC PATCH v3] ethdev: support selective Rx data

In reply to Gregory Etelson
Quoted 2 lines · Gregory Etelson

In some cases application does not need to receive entire packet from port hardware.

Which scenarios need to be used? What is the behavior when LRO(TCP packet aggregation is performed by hardware) is enabled?

Quoted 71 lines

If application could receive required Rx data only and safely discard the rest of Rx packet data, that could improve port performance by reducing PCI bandwidth and application memory consumption.

Selective Rx data allows application to receive
only pre-configured packet segments and discard the rest. For example:
- Deliver the first N bytes only.
- Deliver the last N bytes only.
- Deliver N1 bytes from offset Off1 and N2 bytes from offset Off2.

Selective Rx data is implemented on-top of the existing Rx BUFFER_SPLIT functionality:
- The rte_eth_rxseg_split will use the NULL mempool for data segments that should be discarded.
- PMD will not create MBUF segments if no data was read.

For example: Deliver Ethernet header only

Rx queue segments configuration:

struct rte_eth_rxseg_split split[2] = {
    {
        .mp = <some mempool>,
        .length = sizeof(struct rte_ether_hdr)
    },
    {
        .mp = NULL, /* discard data */
        .length = <MTU>
    }
};

Received MBUF configuration:
mbuf[0].pkt_len = <original packet length>; mbuf[0].data_len = sizeof(struct rte_ether_hdr); mbuf[0].next = NULL; /* The next segment did not deliver data */

A PMD activates the selective Rx data capability by setting the rte_eth_rxseg_capa.selective_read bit.

---
v3: Change the selective_read bit location.

---
 lib/ethdev/rte_ethdev.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
lib/ethdev/rte_ethdev.h +6 -1
index a66c2abbdb..84769d3d26 100644
@@ -1121,7 +1121,11 @@ struct rte_eth_txmode {
  *   The rest will be put into the last valid pool.
  */
 struct rte_eth_rxseg_split {
-	struct rte_mempool *mp; /**< Memory pool to allocate segment from. */
+	/**
+	 * Memory pool to allocate segment from.
+	 * NULL means skipped segment in selective Rx data. @see selective_read.
+	 */
+	struct rte_mempool *mp;
 	uint16_t length; /**< Segment data length, configures split point. */
 	uint16_t offset; /**< Data offset from beginning of mbuf data buffer. */
 	/**
@@ -1758,6 +1762,7 @@ struct rte_eth_rxseg_capa {
 	uint32_t multi_pools:1; /**< Supports receiving to multiple pools.*/
 	uint32_t offset_allowed:1; /**< Supports buffer offsets. */
 	uint32_t offset_align_log2:4; /**< Required offset alignment. */
+	uint32_t selective_read:1; /**< Supports selective read. */
 	uint16_t max_nseg; /**< Maximum amount of segments to split. */
 	uint16_t reserved; /**< Reserved field. */
 };
#8 lore raw

Re: [RFC PATCH v3] ethdev: support selective Rx data

Hello,

Quoted 4 lines
Quoted 2 lines

In some cases application does not need to receive entire packet from port hardware.

Which scenarios need to be used?

A typical use case for the selective Rx data read can be the SAMPLE flow action.
In that scenario, Rx queue that receives sampled packet copy can be configured to deliver to application partial packet data.

Quoted 3 lines

What is the behavior when
LRO(TCP packet aggregation is performed by hardware) is enabled?

The selective Rx data read is applied to MBUF layout that will be delivered to an application. That functionality comes after all HW Rx offloads.

Regards,
Gregory

#9 lore raw

Re: [RFC PATCH v3] ethdev: support selective Rx data

Quoted 11 lines · Gregory

Hello,

Quoted 4 lines
Quoted 2 lines

In some cases application does not need to receive entire packet from port hardware.

Which scenarios need to be used?

A typical use case for the selective Rx data read can be the SAMPLE flow action. In that scenario, Rx queue that receives sampled packet copy can be configured to deliver to application partial packet data.

Quoted 7 lines
Quoted 3 lines

What is the behavior when
LRO(TCP packet aggregation is performed by hardware) is enabled?

The selective Rx data read is applied to MBUF layout that will be delivered to an application.
That functionality comes after all HW Rx offloads.

What is the intended behavior in the selective case. Is there any mechanism for application to see original length?

#10 lore raw

Re: [RFC PATCH v3] ethdev: support selective Rx data

Hello Stephen,

[snip]

Quoted 4 lines

What is the intended behavior in the selective case. Is there any mechanism for application to see original length?

The original packet length is delivered to application in the first mbuf.pkt_len field.

If the selective Rx read was activated, Rx burst will assemble mbufs chain that matches the queue split configuration.
For example, consider application that needs to check out IPv4 header and the last 512 bytes if packet length was 8000 bytes.

1 Application defines selective read split for Rx queue 5:
- The first segment reads Ethernet and IPv4 headers.
- The second segment skips packet data in range [34 + 1, 8000-512-1].
- The third segment reads the last 512 bytes.

2 Application creates flow rule that matches IPv4 packets with total length 8000 and forward them to Rx queue 5.

3 PMD rx_burst operations for Rx queue 5:
- Read the first 34 bytes into mbuf A
- Discard next 7453 Rx data bytes
- Read the last 512 Bytes into mbuf B
- Return chain A->B

The application knows how to treat mbuf received from Rx queue 5, because it created data split for that Rx queue.