[v2,2/2] ethdev: fix some functions are available in the new event
Checks
Commit Message
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 <lihuisong@huawei.com>
---
lib/ethdev/rte_ethdev.c | 14 +++++++++++---
lib/ethdev/rte_ethdev.h | 3 ++-
2 files changed, 13 insertions(+), 4 deletions(-)
Comments
16/01/2025 12:40, Huisong Li:
> 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 <lihuisong@huawei.com>
[...]
> /** 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.
I would add "the" before "application".
With this minor change,
Acked-by: Thomas Monjalon <thomas@monjalon.net>
在 2025/1/16 23:18, Thomas Monjalon 写道:
> 16/01/2025 12:40, Huisong Li:
>> 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 <lihuisong@huawei.com>
> [...]
>> /** 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.
> I would add "the" before "application".
>
> With this minor change,
> Acked-by: Thomas Monjalon <thomas@monjalon.net>
Ack
>
>
> .
@@ -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;
@@ -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 */