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 42BAC4389C; Fri, 12 Jan 2024 07:56:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C2F24028C; Fri, 12 Jan 2024 07:56:57 +0100 (CET) Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by mails.dpdk.org (Postfix) with ESMTP id 4C55F4025E for ; Fri, 12 Jan 2024 07:56:55 +0100 (CET) Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-42998e38716so24888411cf.0 for ; Thu, 11 Jan 2024 22:56:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705042614; x=1705647414; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OPAXFITBgMx/x5/Fm1BUIEXFnDQ7SsNZ3+uIJurt8g4=; b=kxgJl35P0Poiblj9xVdwoWcmlz6gUEMJ6yh1croenI7TUceIDkLZ95GLFX0Ty2EZh0 K6PoLCxEYMiRsIrGmTBeDF3AyjmMiGGmu4WMoEJBswkAb3/MABYtqOH6IG4d+V1+HbR/ xH8czPgTe4WdvUDZE19KZmVLXX4bskYzVWbEILHmS9pe/7m3IrNXjj9ioPOowQEk0W6h CoPkMq4OQmAi3h9WXl+PhLJtrg3xW8nhHWOx5wBPsHcPvmQxQ3XFgHzhrNr2Ob9eYlIN Xk73ixTWyI5rCuPuCvUSBuonOoG7jyePYfugb6/wkmNmSsbzKr+Ja1WL78v3+l2uUGqn EPNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705042614; x=1705647414; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OPAXFITBgMx/x5/Fm1BUIEXFnDQ7SsNZ3+uIJurt8g4=; b=PFKqaaHRVz4E4c0zhUpeFfbj7uSOdPv83wstPU76pZYo1kTFy9DGUeY7hTUbtJzxQC LRLvqr3rODONHRrBfZGMo1wlTXHD/Yjvt2OkvYfQTWD3nSRVw5sSkMVhoVarYP6gJnIV 4aHaDJTvsmupt7Fv0qyceSbaQOLgBcith5oYXK+wR5YQXT/jRqDP6fDsAHhJhS2TfQGC FRlKcJvdXAQo53WNy8vvB5uhxwsIuUcvLiHDZA7sab+j8tUIlX1zeBJwOIYOH0Qsuns8 T9V5eNBPO85Eld14EmicSxP3Hl0pZG4AxB3u0MrGp3+7els7bVzaEbzrOhmQTZaUzgYC rS6Q== X-Gm-Message-State: AOJu0YwQgMg5iAqN10m2AzNYY7qNga/IUyeTgmdSpbj22sxY3aqeelEJ 7GrGfa/qM8QSqSxoUW7BVpRihsYry2OBef9miDI= X-Google-Smtp-Source: AGHT+IHpELM1/Y9cQe1sZHNDRECx+yafKvxEgTWys/FiWhZbvJrp/rUKijT5pJ8In2HUB6tsl//DaEgm8et1rbnDIJw= X-Received: by 2002:ac8:5751:0:b0:429:a99b:1834 with SMTP id 17-20020ac85751000000b00429a99b1834mr973769qtx.20.1705042614460; Thu, 11 Jan 2024 22:56:54 -0800 (PST) MIME-Version: 1.0 References: <20231219172948.3909749-1-jerinj@marvell.com> <20240111151745.3800170-1-jerinj@marvell.com> In-Reply-To: From: Jerin Jacob Date: Fri, 12 Jan 2024 12:26:27 +0530 Message-ID: Subject: Re: [dpdk-dev] [v1] ethdev: support Tx queue used count To: Andrew Rybchenko Cc: jerinj@marvell.com, dev@dpdk.org, Thomas Monjalon , Ferruh Yigit , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Thu, Jan 11, 2024 at 9:47=E2=80=AFPM Andrew Rybchenko wrote: > > 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 th= e > > 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.rs= t > > 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. Ack and change in v2. > > + > > +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, uint1= 6_t rx_queue_id, > > __rte_experimental > > int rte_eth_buffer_split_get_supported_hdr_ptypes(uint16_t port_id, u= int32_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 transmi= t 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 (R= ED). > > + * > > + * Since it's a fast-path function, no check is performed on port_id a= nd > > + * tx_queue_id. The caller must therefore ensure that the port is enab= led > > + * 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 su= pplied > > + * 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_ETHDE= V_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 >=3D RTE_MAX_ETHPORTS || !rte_eth_dev_is_valid_port(p= ort_id)) { > > + RTE_ETHDEV_LOG_LINE(ERR, "Invalid port_id=3D%u", port_id)= ; > > + rc =3D -ENODEV; > > + rte_eth_trace_tx_queue_count(port_id, tx_queue_id, rc); > > + return rc; > > + } > > + > > + rc =3D -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. Ack and change in v2. > > > + if (tx_queue_id >=3D RTE_MAX_QUEUES_PER_PORT) { > > + RTE_ETHDEV_LOG_LINE(ERR, "Invalid Tx queue_id=3D%u for po= rt_id=3D%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 =3D &rte_eth_fp_ops[port_id]; > > + qd =3D fops->txq.data[tx_queue_id]; > > + > > +#ifdef RTE_ETHDEV_DEBUG_TX > > + if (qd =3D=3D NULL) { > > + RTE_ETHDEV_LOG_LINE(ERR, "Invalid Tx queue_id=3D%u for po= rt_id=3D%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 =3D=3D NULL) > > Don't we need trace here? (no strong opinion, just trying to understand > why it is missing here) It is missed by mistake. will fix in v2. > > > + return -ENOTSUP; > > + > > + rc =3D fops->tx_queue_count(qd); > > + rte_eth_trace_tx_queue_count(port_id, tx_queue_id, rc); > > + > > + return rc; > > +} > > #ifdef __cplusplus > > } > > #endif > > [snip] >