From patchwork Thu Jan 16 11:40:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lihuisong (C)" X-Patchwork-Id: 150141 X-Patchwork-Delegate: stephen@networkplumber.org Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D4E9446096; Thu, 16 Jan 2025 12:52:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D878640666; Thu, 16 Jan 2025 12:52:34 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 704324042C for ; Thu, 16 Jan 2025 12:52:32 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4YYh5P5GL7zrSR7; Thu, 16 Jan 2025 19:50:49 +0800 (CST) Received: from dggemv711-chm.china.huawei.com (unknown [10.1.198.66]) by mail.maildlp.com (Postfix) with ESMTPS id B9BC1180105; Thu, 16 Jan 2025 19:52:29 +0800 (CST) Received: from kwepemn100009.china.huawei.com (7.202.194.112) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 16 Jan 2025 19:52:29 +0800 Received: from localhost.localdomain (10.28.79.22) by kwepemn100009.china.huawei.com (7.202.194.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 16 Jan 2025 19:52:29 +0800 From: Huisong Li To: CC: , , , Subject: [PATCH v2 1/2] ethdev: clarify something about the new event Date: Thu, 16 Jan 2025 19:40:33 +0800 Message-ID: <20250116114034.9858-2-lihuisong@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20250116114034.9858-1-lihuisong@huawei.com> References: <20250115034110.15245-1-lihuisong@huawei.com> <20250116114034.9858-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemn100009.china.huawei.com (7.202.194.112) 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 If application verify the validity of the port id or configure this port in the new event callback, application may happen to the port id is invalid. In case of similar confusion, this patch have to clarify something about RTE_ETH_EVENT_NEW in code. Signed-off-by: Huisong Li Acked-by: Thomas Monjalon --- lib/ethdev/rte_ethdev.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 1f71cad244..ee7197aa97 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -4128,7 +4128,11 @@ enum rte_eth_event_type { RTE_ETH_EVENT_VF_MBOX, /**< message from the VF received by PF */ RTE_ETH_EVENT_MACSEC, /**< MACsec offload related event */ RTE_ETH_EVENT_INTR_RMV, /**< device removal event */ - RTE_ETH_EVENT_NEW, /**< port is probed */ + /** The port is being probed, i.e. allocated and not yet available. + * It is too early to check validity, query infos, and configure + * the port. + */ + RTE_ETH_EVENT_NEW, RTE_ETH_EVENT_DESTROY, /**< port is released */ RTE_ETH_EVENT_IPSEC, /**< IPsec offload related event */ RTE_ETH_EVENT_FLOW_AGED,/**< New aged-out flows is detected */ From patchwork Thu Jan 16 11:40:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lihuisong (C)" X-Patchwork-Id: 150142 X-Patchwork-Delegate: stephen@networkplumber.org Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4D3FA46096; Thu, 16 Jan 2025 12:52:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E0B5F40672; Thu, 16 Jan 2025 12:52:35 +0100 (CET) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id 6AE7D402C2 for ; Thu, 16 Jan 2025 12:52:32 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4YYh3d6Z4cz1V4xV; Thu, 16 Jan 2025 19:49:17 +0800 (CST) Received: from dggemv704-chm.china.huawei.com (unknown [10.3.19.47]) by mail.maildlp.com (Postfix) with ESMTPS id 2BAED180214; Thu, 16 Jan 2025 19:52:30 +0800 (CST) Received: from kwepemn100009.china.huawei.com (7.202.194.112) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 16 Jan 2025 19:52:29 +0800 Received: from localhost.localdomain (10.28.79.22) by kwepemn100009.china.huawei.com (7.202.194.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 16 Jan 2025 19:52:29 +0800 From: Huisong Li To: CC: , , , Subject: [PATCH v2 2/2] ethdev: fix some functions are available in the new event Date: Thu, 16 Jan 2025 19:40:34 +0800 Message-ID: <20250116114034.9858-3-lihuisong@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20250116114034.9858-1-lihuisong@huawei.com> References: <20250115034110.15245-1-lihuisong@huawei.com> <20250116114034.9858-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.28.79.22] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemn100009.china.huawei.com (7.202.194.112) 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 During probing, before the port becomes generally available, the rte_eth_dev_socket_id() and rte_eth_dev_owner_*() are available to application. Fixes: 7dcd73e37965 ("drivers/bus: set device NUMA node to unknown by default") Fixes: 53ef1b34776b ("ethdev: add sanity checks in control APIs") Cc: stable@dpdk.org Signed-off-by: Huisong Li Acked-by: Thomas Monjalon --- lib/ethdev/rte_ethdev.c | 14 +++++++++++--- lib/ethdev/rte_ethdev.h | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 6413c54e3b..9cfb397cee 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -600,9 +600,10 @@ rte_eth_dev_owner_get(const uint16_t port_id, struct rte_eth_dev_owner *owner) struct rte_eth_dev *ethdev; int ret; - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); - ethdev = &rte_eth_devices[port_id]; + if (port_id >= RTE_MAX_ETHPORTS) + return -ENODEV; + ethdev = &rte_eth_devices[port_id]; if (!eth_dev_is_allocated(ethdev)) { RTE_ETHDEV_LOG_LINE(ERR, "Port ID %"PRIu16" is not allocated", port_id); @@ -635,8 +636,15 @@ int rte_eth_dev_socket_id(uint16_t port_id) { int socket_id = SOCKET_ID_ANY; + struct rte_eth_dev *ethdev; - if (!rte_eth_dev_is_valid_port(port_id)) { + if (port_id >= RTE_MAX_ETHPORTS) { + rte_errno = EINVAL; + return socket_id; + } + + ethdev = &rte_eth_devices[port_id]; + if (!eth_dev_is_allocated(ethdev)) { rte_errno = EINVAL; } else { socket_id = rte_eth_devices[port_id].data->numa_node; diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index ee7197aa97..0b6d65880a 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -4130,7 +4130,8 @@ enum rte_eth_event_type { RTE_ETH_EVENT_INTR_RMV, /**< device removal event */ /** The port is being probed, i.e. allocated and not yet available. * It is too early to check validity, query infos, and configure - * the port. + * the port. But some functions, like rte_eth_dev_socket_id() and + * rte_eth_dev_owner_*() are available to application. */ RTE_ETH_EVENT_NEW, RTE_ETH_EVENT_DESTROY, /**< port is released */