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 74B08A034C; Thu, 18 Aug 2022 11:37:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 281B840694; Thu, 18 Aug 2022 11:37:50 +0200 (CEST) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 946F240156 for ; Thu, 18 Aug 2022 11:37:49 +0200 (CEST) Received: from dkrd2.smartsharesys.local ([192.168.4.12]) by smartserver.smartsharesystems.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 18 Aug 2022 11:37:48 +0200 From: =?UTF-8?q?Morten=20Br=C3=B8rup?= To: thomas@monjalon.net, ferruh.yigit@xilinx.com, andrew.rybchenko@oktetlabs.ru Cc: dev@dpdk.org, =?UTF-8?q?Morten=20Br=C3=B8rup?= Subject: [PATCH] ethdev: rte_eth_rx_queue_count is a dataplane function Date: Thu, 18 Aug 2022 11:37:44 +0200 Message-Id: <20220818093744.76157-1-mb@smartsharesystems.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-OriginalArrivalTime: 18 Aug 2022 09:37:48.0030 (UTC) FILETIME=[2D5691E0:01D8B2E6] 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 Applications may use rte_eth_rx_queue_count() in the RX stage of the dataplane, so only check the function parameters if built with RTE_ETHDEV_DEBUG_RX. Signed-off-by: Morten Brørup --- lib/ethdev/rte_ethdev.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index de9e970d4d..8d5d9b42bf 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -5681,6 +5681,10 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id, /** * Get the number of used descriptors of a Rx queue * + * Since it's a dataplane 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 Ethernet device. * @param queue_id @@ -5688,8 +5692,8 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id, * @return * The number of used descriptors in the specific queue, or: * - (-ENODEV) if *port_id* is invalid. - * (-EINVAL) if *queue_id* is invalid - * (-ENOTSUP) if the device does not support this function + * - (-EINVAL) if *queue_id* is invalid + * - (-ENOTSUP) if the device does not support this function */ static inline int rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id) @@ -5697,6 +5701,7 @@ rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id) struct rte_eth_fp_ops *p; void *qd; +#ifdef RTE_ETHDEV_DEBUG_RX if (port_id >= RTE_MAX_ETHPORTS || queue_id >= RTE_MAX_QUEUES_PER_PORT) { RTE_ETHDEV_LOG(ERR, @@ -5704,16 +5709,19 @@ rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id) port_id, queue_id); return -EINVAL; } +#endif /* fetch pointer to queue data */ p = &rte_eth_fp_ops[port_id]; qd = p->rxq.data[queue_id]; +#ifdef RTE_ETHDEV_DEBUG_RX RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); - RTE_FUNC_PTR_OR_ERR_RET(*p->rx_queue_count, -ENOTSUP); if (qd == NULL) return -EINVAL; +#endif + RTE_FUNC_PTR_OR_ERR_RET(*p->rx_queue_count, -ENOTSUP); return (int)(*p->rx_queue_count)(qd); } -- 2.17.1