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 2EE9342B71; Mon, 22 May 2023 15:10:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 70D0D42D36; Mon, 22 May 2023 15:09:54 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id BE47540EE5 for ; Mon, 22 May 2023 15:09:50 +0200 (CEST) Received: from dggpeml500011.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QPyQN5w7DzLpQD; Mon, 22 May 2023 21:06:52 +0800 (CST) Received: from localhost.huawei.com (10.50.163.32) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 22 May 2023 21:09:48 +0800 From: Dengdui Huang To: CC: , , , , , , , , , Subject: [PATCH v2 1/2] ethdev: add API to check queue ID validity Date: Mon, 22 May 2023 21:09:46 +0800 Message-ID: <20230522130947.345390-2-huangdengdui@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230522130947.345390-1-huangdengdui@huawei.com> References: <20230516110021.1801443-1-huangdengdui@huawei.com> <20230522130947.345390-1-huangdengdui@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500011.china.huawei.com (7.185.36.84) X-CFilter-Loop: Reflected 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 The API rte_eth_dev_is_valid_rxq/txq checks the port ID validity and then the Rx/Tx queue ID is valid. Signed-off-by: Dengdui Huang --- doc/guides/rel_notes/release_23_07.rst | 5 ++++ lib/ethdev/rte_ethdev.c | 30 +++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 36 ++++++++++++++++++++++++++ lib/ethdev/version.map | 4 +++ 4 files changed, 75 insertions(+) diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst index a9b1293689..19e645156f 100644 --- a/doc/guides/rel_notes/release_23_07.rst +++ b/doc/guides/rel_notes/release_23_07.rst @@ -56,6 +56,11 @@ New Features ======================================================= +* **Added ethdev Rx/Tx queue id check API.** + + Added ethdev Rx/Tx queue id check API which provides functions + for check if Rx/Tx queue id is valid. + Removed Items ------------- diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 4d03255683..3d85218127 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -407,6 +407,36 @@ rte_eth_dev_is_valid_port(uint16_t port_id) return is_valid; } +int +rte_eth_dev_is_valid_rxq(uint16_t port_id, uint16_t queue_id) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + + if (queue_id >= dev->data->nb_rx_queues || + dev->data->rx_queues[queue_id] == NULL) + return -EINVAL; + + return 0; +} + +int +rte_eth_dev_is_valid_txq(uint16_t port_id, uint16_t queue_id) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + + if (queue_id >= dev->data->nb_tx_queues || + dev->data->tx_queues[queue_id] == NULL) + return -EINVAL; + + return 0; +} + static int eth_is_valid_owner_id(uint64_t owner_id) { diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 99fe9e238b..abda95b27f 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -2665,6 +2665,42 @@ int rte_eth_dev_socket_id(uint16_t port_id); */ int rte_eth_dev_is_valid_port(uint16_t port_id); +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice + * + * Check if Rx queue ID is valid. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id + * The index of the receive queue. + * @return + * - -ENODEV: if *port_id* is invalid. + * - -EINVAL: if queue is out of range or not been setup. + * - 0 if queue ID is valid. + */ +__rte_experimental +int rte_eth_dev_is_valid_rxq(uint16_t port_id, uint16_t queue_id); + +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice + * + * Check if Tx queue ID is valid. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id + * The index of the transmit queue. + * @return + * - -ENODEV: if *port_id* is invalid. + * - -EINVAL: if queue is out of range or not been setup. + * - 0 if Tx queue ID is valid. + */ +__rte_experimental +int rte_eth_dev_is_valid_txq(uint16_t port_id, uint16_t queue_id); + /** * Start specified Rx queue of a port. It is used when rx_deferred_start * flag of the specified queue is true. diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 357d1a88c0..d8797310d2 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -299,6 +299,10 @@ EXPERIMENTAL { rte_flow_action_handle_query_update; rte_flow_async_action_handle_query_update; rte_flow_async_create_by_index; + + # added in 23.07 + rte_eth_dev_is_valid_rxq; + rte_eth_dev_is_valid_txq; }; INTERNAL { -- 2.33.0