[dpdk-dev] [RFC] ethdev: support Tx queue free descriptor query

Bruce Richardson bruce.richardson at intel.com
Mon Jan 8 11:54:20 CET 2024


On Tue, Dec 19, 2023 at 10:59:48PM +0530, jerinj at marvell.com wrote:
> From: Jerin Jacob <jerinj at marvell.com>
> 
> Introduce a new API to retrieve the number of available free descriptors
> in a Tx queue. Applications can leverage this API in the fast path to
> inspect the Tx queue occupancy and take appropriate actions based on the
> available free descriptors.
> 
> A notable use case could be implementing Random Early Discard (RED)
> in software based on Tx queue occupancy.
> 
> Signed-off-by: Jerin Jacob <jerinj at marvell.com>
> ---

Hi Jerin,

while I don't strongly object to this patch, I wonder if it encourages
sub-optimal code implementations. To determine the number of free
descriptors in a ring, the driver in many cases will need to do a scan of
the descriptor ring to see how many are free/used. However, I suspect that
in most cases we will see something like the following being done:

    count = rte_eth_rx_free_count();
    if (count > X) {
        /* Do something */
    }

For instances like this, scanning the entire ring is wasteful of resources.
Instead it would be better to just check the descriptor at position X
explicitly. Going to the trouble of checking the exact descriptor count is
unnecessary in this case.

Out of interest, are you aware of a case where an app would need to know
exactly the number of free descriptors, and where the result would not be
just compared to one or more threshold values? Do we see cases where it
would be used in a computation, perhaps?

/Bruce


More information about the dev mailing list