[dpdk-dev] [v1] ethdev: support Tx queue used count
Jerin Jacob
jerinjacobk at gmail.com
Fri Jan 12 07:59:32 CET 2024
On Thu, Jan 11, 2024 at 9:50 PM Morten Brørup <mb at smartsharesystems.com> wrote:
>
> > From: jerinj at marvell.com [mailto:jerinj at marvell.com]
> > Sent: Thursday, 11 January 2024 16.18
> >
> > From: Jerin Jacob <jerinj at marvell.com>
> >
> > Introduce a new API to retrieve the number of used 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>
> > ---
>
> Generally looks good.
>
> Only some minor suggestions/comments regarding rte_eth_tx_queue_count():
>
> uint16_t tx_queue_id -> uint16_t queue_id
> Everywhere, also in rte_ethdev_trace_fp.h.
>
> Similarly in the log messages:
> "Invalid Tx queue_id" -> "Invalid queue_id"
>
> I don't like that rc = -EINVAL is reused instead of set explicitly for each error case.
>
> Also, the return value -ENOTSUP is not traced.
>
> Consider using an "out" label for a common return path to include trace, e.g.:
I actually like "out" label scheme. General not seen ethdev
implementation functions.
I will include above suggestion in v2.
>
> /**
> * @warning
> * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
> *
> * Get the number of used descriptors of a Tx queue
> *
> * This function retrieves the number of used descriptors of a transmit queue.
> * Applications can use this API in the fast path to inspect Tx queue occupancy and take
> * appropriate actions based on the available free descriptors.
> * An example action could be implementing the Random Early Discard (RED).
> *
> * Since it's a fast-path function, no check is performed on port_id and
> * queue_id. The caller must therefore ensure that the port is enabled
> * and the queue is configured and running.
> *
> * @param port_id
> * The port identifier of the device.
> * @param queue_id
> * The index of the transmit queue.
> * The value must be in the range [0, nb_tx_queue - 1] previously supplied
> * to rte_eth_dev_configure().
> * @return
> * The number of used descriptors in the specific queue, or:
> * - (-ENODEV) if *port_id* is invalid. Enabled only when RTE_ETHDEV_DEBUG_TX is enabled
> * - (-EINVAL) if *queue_id* is invalid. Enabled only when RTE_ETHDEV_DEBUG_TX is enabled
> * - (-ENOTSUP) if the device does not support this function.
> *
> * @note This function is designed for fast-path use.
> */
> __rte_experimental
> static inline int
> rte_eth_tx_queue_count(uint16_t port_id, uint16_t queue_id)
> {
> struct rte_eth_fp_ops *fops;
> void *qd;
> int rc;
>
> #ifdef RTE_ETHDEV_DEBUG_TX
> if (port_id >= RTE_MAX_ETHPORTS || !rte_eth_dev_is_valid_port(port_id)) {
> RTE_ETHDEV_LOG_LINE(ERR, "Invalid port_id=%u", port_id);
> rc = -ENODEV;
> goto out;
> }
>
> if (queue_id >= RTE_MAX_QUEUES_PER_PORT) {
> RTE_ETHDEV_LOG_LINE(ERR, "Invalid queue_id=%u for port_id=%u",
> queue_id, port_id);
> rc = -EINVAL;
> goto out;
> }
> #endif
>
> /* Fetch pointer to Tx queue data */
> fops = &rte_eth_fp_ops[port_id];
> qd = fops->txq.data[queue_id];
>
> #ifdef RTE_ETHDEV_DEBUG_TX
> if (qd == NULL) {
> RTE_ETHDEV_LOG_LINE(ERR, "Invalid queue_id=%u for port_id=%u",
> queue_id, port_id);
> rc = -EINVAL;
> goto out;
> }
> #endif
> if (fops->tx_queue_count == NULL) {
> rc = -ENOTSUP;
> goto out;
> }
>
> rc = fops->tx_queue_count(qd);
>
> out:
> rte_eth_trace_tx_queue_count(port_id, queue_id, rc);
>
> return rc;
> }
>
>
> With or without suggested changes:
>
> Acked-by: Morten Brørup <mb at smartsharesystems.com>
>
More information about the dev
mailing list