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 D181A4389C; Fri, 12 Jan 2024 08:00:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8E3B54028C; Fri, 12 Jan 2024 08:00:00 +0100 (CET) Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) by mails.dpdk.org (Postfix) with ESMTP id 2CC024025E for ; Fri, 12 Jan 2024 07:59:59 +0100 (CET) Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-427a3887483so38365751cf.3 for ; Thu, 11 Jan 2024 22:59:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705042798; x=1705647598; 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=7FQDbI84PONNo0K4aImKvUN15Vre16duDP9CYXh4+eg=; b=K8tvqLN9C6I1npgJhHt9gir1wfOj2xtiqnosag2AYFknEtzqW0cfLcIUtcnsWvwfJl vmUaviGswiWJ8BXEbfrJRLkcl4uMD2eqPISxvJ6VuBvf5S1vYaSraIjs6VffDkU/lLU+ bhMk0VlmCxTbLz9agLE80xm/GNHe6dHkcTn7snUNp1SSn5Ov73jd8C4yrWA1fdYyeada X/2hdL8fVkeYbHyFHwR0QWNKrMJIO0jmf6v0VO3+4fJdVqmP3Cz3E7NZLDE+YAZJ+qvL MmS89yx/izZPpAUXS24QbWmq1k/rQxxocL6BpeFRMLsauQVXeYIYeQtyuKu4ybAaqeAY I+ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705042798; x=1705647598; 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=7FQDbI84PONNo0K4aImKvUN15Vre16duDP9CYXh4+eg=; b=QEzKr+cwplPG90hbQSkYq2CW5Co0+sV0HagoP3x/8ymQFB6EQtXMWtsAGEIBTLlveX RQFD5+7v59IqGaZN3g3o7fZ6TECRssix25xdpd/u53P+jRCMMxGl9VXUMgWKmvYcsVL5 urQDqpUxhCGMMHH5JyILKDfQlCbHTxD3yqcTFYJQmfgJhnnZKmR2ZhYGMkIfUWIXS9dS QL2KQ/UuyzyVOx++jgHaTctniX7NbZXcyU6V6PVbg99FiDWUlkG2VjLdbHku87Db/kTm LD81jBY1wjzvBh6sX22OXzvCK2b9cYY0dJKuUoBIPQcx88DnNWFQikHkPwcXilI+C/BM k/Uw== X-Gm-Message-State: AOJu0Yzzs42iYv8pBiDRl8jyF4lCQirFC/esvTPbgt2xudh5KZjED27/ TvZLdBLDqgJoIm2767scpQroGO8CKQmOvb/L6k8= X-Google-Smtp-Source: AGHT+IF0LIcL9UQDUvznor+Tkmd84oa5qivkEQf2skd6yUsbxnlLUxzw3xDqm5V3imcfREw9HuOdtYWxex1Cn6DXqPQ= X-Received: by 2002:a05:622a:90:b0:429:cac3:7399 with SMTP id o16-20020a05622a009000b00429cac37399mr1187327qtw.129.1705042798406; Thu, 11 Jan 2024 22:59:58 -0800 (PST) MIME-Version: 1.0 References: <20231219172948.3909749-1-jerinj@marvell.com> <20240111151745.3800170-1-jerinj@marvell.com> <98CBD80474FA8B44BF855DF32C47DC35E9F12B@smartserver.smartshare.dk> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F12B@smartserver.smartshare.dk> From: Jerin Jacob Date: Fri, 12 Jan 2024 12:29:32 +0530 Message-ID: Subject: Re: [dpdk-dev] [v1] ethdev: support Tx queue used count To: =?UTF-8?Q?Morten_Br=C3=B8rup?= Cc: jerinj@marvell.com, dev@dpdk.org, Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , 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:50=E2=80=AFPM Morten Br=C3=B8rup wrote: > > > From: jerinj@marvell.com [mailto:jerinj@marvell.com] > > Sent: Thursday, 11 January 2024 16.18 > > > > 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 > > --- > > 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.: 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 not= ice > * > * Get the number of used descriptors of a Tx queue > * > * This function retrieves the number of used descriptors of a transmit q= ueue. > * Applications can use this API in the fast path to inspect Tx queue occ= upancy 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 suppl= ied > * 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_DE= BUG_TX is enabled > * - (-EINVAL) if *queue_id* is invalid. Enabled only when RTE_ETHDEV_D= EBUG_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(p= ort_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=C3=B8rup >