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 03EBE43894; Thu, 11 Jan 2024 17:17:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7BB5B40269; Thu, 11 Jan 2024 17:17:30 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 8C77740266 for ; Thu, 11 Jan 2024 17:17:29 +0100 (CET) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 99DAA5A; Thu, 11 Jan 2024 19:17:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 99DAA5A DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1704989847; bh=zeHqk9oCO5KJ03dXI+xoszQBqkXM30tESOP3lh5ExZE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=aJMT2MfW/XAe0AQ4LboQ0DEERcLW4FR/wysk04ilNAH13aCxE+GThvydV3/6X/+gY fGVHjsZg59kyj72uupfD6uNSF2E6C+nq36qF1doLJCrfuFsxubBt8Py3wnnGPmydsK byFfI4rQd2axz0shxu7UjJjBbzB8wam/2VIiCTPA= Message-ID: Date: Thu, 11 Jan 2024 19:17:27 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [dpdk-dev] [v1] ethdev: support Tx queue used count Content-Language: en-US To: jerinj@marvell.com, dev@dpdk.org, Thomas Monjalon , Ferruh Yigit Cc: ferruh.yigit@xilinx.com, ajit.khaparde@broadcom.com, aboyer@pensando.io, beilei.xing@intel.com, bruce.richardson@intel.com, chas3@att.com, chenbo.xia@intel.com, ciara.loftus@intel.com, dsinghrawat@marvell.com, ed.czeck@atomicrules.com, evgenys@amazon.com, grive@u256.net, g.singh@nxp.com, zhouguoyang@huawei.com, haiyue.wang@intel.com, hkalra@marvell.com, heinrich.kuhn@corigine.com, hemant.agrawal@nxp.com, hyonkim@cisco.com, igorch@amazon.com, irusskikh@marvell.com, jgrajcia@cisco.com, jasvinder.singh@intel.com, jianwang@trustnetic.com, jiawenwu@trustnetic.com, jingjing.wu@intel.com, johndale@cisco.com, john.miller@atomicrules.com, linville@tuxdriver.com, keith.wiles@intel.com, kirankumark@marvell.com, oulijun@huawei.com, lironh@marvell.com, longli@microsoft.com, mw@semihalf.com, spinler@cesnet.cz, matan@nvidia.com, matt.peters@windriver.com, maxime.coquelin@redhat.com, mk@semihalf.com, humin29@huawei.com, pnalla@marvell.com, ndabilpuram@marvell.com, qiming.yang@intel.com, qi.z.zhang@intel.com, radhac@marvell.com, rahul.lakkireddy@chelsio.com, rmody@marvell.com, rosen.xu@intel.com, sachin.saxena@oss.nxp.com, skoteshwar@marvell.com, shshaikh@marvell.com, shaibran@amazon.com, shepard.siegel@atomicrules.com, asomalap@amd.com, somnath.kotur@broadcom.com, sthemmin@microsoft.com, steven.webster@windriver.com, skori@marvell.com, mtetsuyah@gmail.com, vburru@marvell.com, viacheslavo@nvidia.com, xiao.w.wang@intel.com, cloud.wangxiaoyun@huawei.com, yisen.zhuang@huawei.com, yongwang@vmware.com, xuanziyang2@huawei.com, cristian.dumitrescu@intel.com References: <20231219172948.3909749-1-jerinj@marvell.com> <20240111151745.3800170-1-jerinj@marvell.com> From: Andrew Rybchenko Organization: OKTET Labs In-Reply-To: <20240111151745.3800170-1-jerinj@marvell.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 1/11/24 18:17, jerinj@marvell.com wrote: > From: Jerin Jacob > > 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 with few nits below Reviewed-by: Andrew Rybchenko [snip] > diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst > index f7d9980849..0d5a8733fc 100644 > --- a/doc/guides/nics/features.rst > +++ b/doc/guides/nics/features.rst > @@ -962,6 +962,16 @@ management (see :doc:`../prog_guide/power_man` for more details). > > * **[implements] eth_dev_ops**: ``get_monitor_addr`` > > +.. _nic_features_tx_queue_used_count: I'd stick to shorter version _nic_features_tx_queue_count to match API naming and feature title below. > + > +Tx queue count > +-------------- > + > +Supports to get the number of used descriptors of a Tx queue. > + > +* **[implements] eth_dev_ops**: ``tx_queue_count``. > +* **[related] API**: ``rte_eth_tx_queue_count()``. > + > .. _nic_features_other: > > Other dev ops not represented by a Feature [snip] > diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h > index 21e3a21903..af59da9652 100644 > --- a/lib/ethdev/rte_ethdev.h > +++ b/lib/ethdev/rte_ethdev.h > @@ -6803,6 +6803,80 @@ rte_eth_recycle_mbufs(uint16_t rx_port_id, uint16_t rx_queue_id, > __rte_experimental > int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, uint32_t *ptypes, int num); > > +/** > + * @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 > + * tx_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 tx_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 tx_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; > + rte_eth_trace_tx_queue_count(port_id, tx_queue_id, rc); > + return rc; > + } > + > + rc = -EINVAL; Since it is a debug, IMHO it is better to keep the code simple and init rc in two below if bodies separately rather than relying on shared init here. > + if (tx_queue_id >= RTE_MAX_QUEUES_PER_PORT) { > + RTE_ETHDEV_LOG_LINE(ERR, "Invalid Tx queue_id=%u for port_id=%u", > + tx_queue_id, port_id); > + rte_eth_trace_tx_queue_count(port_id, tx_queue_id, rc); > + return rc; > + } > +#endif > + > + /* Fetch pointer to Tx queue data */ > + fops = &rte_eth_fp_ops[port_id]; > + qd = fops->txq.data[tx_queue_id]; > + > +#ifdef RTE_ETHDEV_DEBUG_TX > + if (qd == NULL) { > + RTE_ETHDEV_LOG_LINE(ERR, "Invalid Tx queue_id=%u for port_id=%u", > + tx_queue_id, port_id); > + rte_eth_trace_tx_queue_count(port_id, tx_queue_id, rc); > + return rc; > + } > +#endif > + if (fops->tx_queue_count == NULL) Don't we need trace here? (no strong opinion, just trying to understand why it is missing here) > + return -ENOTSUP; > + > + rc = fops->tx_queue_count(qd); > + rte_eth_trace_tx_queue_count(port_id, tx_queue_id, rc); > + > + return rc; > +} > #ifdef __cplusplus > } > #endif [snip]