From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5325F43894; Thu, 11 Jan 2024 17:20:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D489D40269; Thu, 11 Jan 2024 17:20:25 +0100 (CET) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 99D3A40266 for ; Thu, 11 Jan 2024 17:20:24 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id 32C5C20B43; Thu, 11 Jan 2024 17:20:24 +0100 (CET) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [dpdk-dev] [v1] ethdev: support Tx queue used count X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Thu, 11 Jan 2024 17:20:21 +0100 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F12B@smartserver.smartshare.dk> In-Reply-To: <20240111151745.3800170-1-jerinj@marvell.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [dpdk-dev] [v1] ethdev: support Tx queue used count Thread-Index: AdpEo1jxkOT5RIjUSdGmEVoXikz8yQAAxhOw References: <20231219172948.3909749-1-jerinj@marvell.com> <20240111151745.3800170-1-jerinj@marvell.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: , , "Thomas Monjalon" , "Ferruh Yigit" , "Andrew Rybchenko" Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > From: jerinj@marvell.com [mailto:jerinj@marvell.com] > Sent: Thursday, 11 January 2024 16.18 >=20 > From: Jerin Jacob >=20 > 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. >=20 > A notable use case could be implementing Random Early Discard (RED) > in software based on Tx queue occupancy. >=20 > Signed-off-by: Jerin Jacob > --- 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 =3D -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.: /** * @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 >=3D RTE_MAX_ETHPORTS || = !rte_eth_dev_is_valid_port(port_id)) { RTE_ETHDEV_LOG_LINE(ERR, "Invalid port_id=3D%u", port_id); rc =3D -ENODEV; goto out; } if (queue_id >=3D RTE_MAX_QUEUES_PER_PORT) { RTE_ETHDEV_LOG_LINE(ERR, "Invalid queue_id=3D%u for port_id=3D%u", queue_id, port_id); rc =3D -EINVAL; goto out; } #endif /* Fetch pointer to Tx queue data */ fops =3D &rte_eth_fp_ops[port_id]; qd =3D fops->txq.data[queue_id]; #ifdef RTE_ETHDEV_DEBUG_TX if (qd =3D=3D NULL) { RTE_ETHDEV_LOG_LINE(ERR, "Invalid queue_id=3D%u for port_id=3D%u", queue_id, port_id); rc =3D -EINVAL; goto out; } #endif if (fops->tx_queue_count =3D=3D NULL) { rc =3D -ENOTSUP; goto out; } rc =3D 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=F8rup