From: Huisong Li <lihuisong@huawei.com>
To: <dev@dpdk.org>
Cc: <thomas@monjalon.net>, <stephen@networkplumber.org>,
<liuyonglong@huawei.com>, <lihuisong@huawei.com>
Subject: [PATCH v1 2/2] ethdev: fix some APIs can be used in the new event
Date: Wed, 15 Jan 2025 11:41:10 +0800 [thread overview]
Message-ID: <20250115034110.15245-3-lihuisong@huawei.com> (raw)
In-Reply-To: <20250115034110.15245-1-lihuisong@huawei.com>
The rte_eth_dev_socket_id() and rte_eth_dev_owner_*() can be used after
allocating an ethdev. So this patch relaxes the conditions for using them.
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 <lihuisong@huawei.com>
---
lib/ethdev/rte_ethdev.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 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;
--
2.22.0
next prev parent reply other threads:[~2025-01-15 3:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 3:41 [PATCH v1 0/2] ethdev: clarify something about " Huisong Li
2025-01-15 3:41 ` [PATCH v1 1/2] ethdev: clarify do not something in the " Huisong Li
2025-01-15 11:31 ` Thomas Monjalon
2025-01-15 3:41 ` Huisong Li [this message]
2025-01-15 11:36 ` [PATCH v1 2/2] ethdev: fix some APIs can be used " Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250115034110.15245-3-lihuisong@huawei.com \
--to=lihuisong@huawei.com \
--cc=dev@dpdk.org \
--cc=liuyonglong@huawei.com \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).