* [PATCH v1 0/2] ethdev: clarify something about new event
@ 2025-01-15 3:41 Huisong Li
2025-01-15 3:41 ` [PATCH v1 1/2] ethdev: clarify do not something in the " Huisong Li
` (2 more replies)
0 siblings, 3 replies; 17+ messages in thread
From: Huisong Li @ 2025-01-15 3:41 UTC (permalink / raw)
To: dev; +Cc: thomas, stephen, liuyonglong, lihuisong
I've had some issues when I add the verification of the port id in the
event callback, which are discussed in another patch series[1]. So this
series clarify something about RTE_ETH_EVENT_NEW based on the previous
discussion.
[1] https://patches.dpdk.org/project/dpdk/cover/20250113025521.32703-1-lihuisong@huawei.com/
Huisong Li (2):
ethdev: clarify do not something in the new event
ethdev: fix some APIs can be used in the new event
lib/ethdev/rte_ethdev.c | 14 +++++++++++---
lib/ethdev/rte_ethdev.h | 9 ++++++++-
2 files changed, 19 insertions(+), 4 deletions(-)
--
2.22.0
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v1 1/2] ethdev: clarify do not something in the new event
2025-01-15 3:41 [PATCH v1 0/2] ethdev: clarify something about new event Huisong Li
@ 2025-01-15 3:41 ` Huisong Li
2025-01-15 11:31 ` Thomas Monjalon
2025-01-15 3:41 ` [PATCH v1 2/2] ethdev: fix some APIs can be used " Huisong Li
2025-01-16 11:40 ` [PATCH v2 0/2] ethdev: clarify something about " Huisong Li
2 siblings, 1 reply; 17+ messages in thread
From: Huisong Li @ 2025-01-15 3:41 UTC (permalink / raw)
To: dev; +Cc: thomas, stephen, liuyonglong, lihuisong
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.
Actually, when application receive a new event from one port, the port is
not fully probed and is just in allocated state. Application doesn't need
to verify the validity of the port id because it is definitely valid.
What's more, application shouldn't do something like configuring this port
or querying some information of this port by ethdev ops.
Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
lib/ethdev/rte_ethdev.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 1f71cad244..e2021f0f12 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -4128,7 +4128,14 @@ 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 */
+ /** Port is probed and application's event callback will be called.
+ * In this moment, the port is not fully probed and is just in allocated
+ * state. When application receive this event, application doesn't need
+ * to verify the validity of the port id because it is definitely valid.
+ * What's more, application shouldn't do something like configuring this
+ * port or querying some information of this port by ethdev ops.
+ */
+ 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 */
--
2.22.0
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v1 2/2] ethdev: fix some APIs can be used in the new event
2025-01-15 3:41 [PATCH v1 0/2] ethdev: clarify something about new event Huisong Li
2025-01-15 3:41 ` [PATCH v1 1/2] ethdev: clarify do not something in the " Huisong Li
@ 2025-01-15 3:41 ` Huisong Li
2025-01-15 11:36 ` Thomas Monjalon
2025-01-16 11:40 ` [PATCH v2 0/2] ethdev: clarify something about " Huisong Li
2 siblings, 1 reply; 17+ messages in thread
From: Huisong Li @ 2025-01-15 3:41 UTC (permalink / raw)
To: dev; +Cc: thomas, stephen, liuyonglong, lihuisong
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
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v1 1/2] ethdev: clarify do not something in the new event
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-16 6:16 ` lihuisong (C)
0 siblings, 1 reply; 17+ messages in thread
From: Thomas Monjalon @ 2025-01-15 11:31 UTC (permalink / raw)
To: Huisong Li; +Cc: dev, stephen, liuyonglong
15/01/2025 04:41, Huisong Li:
> 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.
>
> Actually, when application receive a new event from one port, the port is
> not fully probed and is just in allocated state. Application doesn't need
> to verify the validity of the port id because it is definitely valid.
> What's more, application shouldn't do something like configuring this port
> or querying some information of this port by ethdev ops.
>
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> ---
> lib/ethdev/rte_ethdev.h | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
> index 1f71cad244..e2021f0f12 100644
> --- a/lib/ethdev/rte_ethdev.h
> +++ b/lib/ethdev/rte_ethdev.h
> @@ -4128,7 +4128,14 @@ 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 */
> + /** Port is probed and application's event callback will be called.
We are not going to say that the callback is called for each event :)
> + * In this moment, the port is not fully probed and is just in allocated
> + * state. When application receive this event, application doesn't need
It is not a real state.
> + * to verify the validity of the port id because it is definitely valid.
> + * What's more, application shouldn't do something like configuring this
> + * port or querying some information of this port by ethdev ops.
> + */
Let me try shorter:
"
The port is being probed, i.e. allocated and not yet available.
It is too early to check validity, infos, or configuring the port.
"
What do you think? Anything missing?
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v1 2/2] ethdev: fix some APIs can be used in the new event
2025-01-15 3:41 ` [PATCH v1 2/2] ethdev: fix some APIs can be used " Huisong Li
@ 2025-01-15 11:36 ` Thomas Monjalon
2025-01-16 6:14 ` lihuisong (C)
0 siblings, 1 reply; 17+ messages in thread
From: Thomas Monjalon @ 2025-01-15 11:36 UTC (permalink / raw)
To: dev, Huisong Li; +Cc: stephen, liuyonglong, lihuisong
15/01/2025 04:41, Huisong Li:
> 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.
You should be more explicit:
"during probing, before it becomes generally available and considered as valid".
Should we add these functions in the comment for RTE_ETH_EVENT_NEW?
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v1 2/2] ethdev: fix some APIs can be used in the new event
2025-01-15 11:36 ` Thomas Monjalon
@ 2025-01-16 6:14 ` lihuisong (C)
2025-01-16 9:09 ` Thomas Monjalon
0 siblings, 1 reply; 17+ messages in thread
From: lihuisong (C) @ 2025-01-16 6:14 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: stephen, liuyonglong, dev
在 2025/1/15 19:36, Thomas Monjalon 写道:
> 15/01/2025 04:41, Huisong Li:
>> 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.
> You should be more explicit:
> "during probing, before it becomes generally available and considered as valid".
"During probing, before the port becomes generally available, its socket
id and owner id can be considered as valid."
How about say it like this?
>
> Should we add these functions in the comment for RTE_ETH_EVENT_NEW?
Ack
>
>
> .
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v1 1/2] ethdev: clarify do not something in the new event
2025-01-15 11:31 ` Thomas Monjalon
@ 2025-01-16 6:16 ` lihuisong (C)
2025-01-16 9:15 ` Thomas Monjalon
0 siblings, 1 reply; 17+ messages in thread
From: lihuisong (C) @ 2025-01-16 6:16 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev, stephen, liuyonglong
在 2025/1/15 19:31, Thomas Monjalon 写道:
> 15/01/2025 04:41, Huisong Li:
>> 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.
>>
>> Actually, when application receive a new event from one port, the port is
>> not fully probed and is just in allocated state. Application doesn't need
>> to verify the validity of the port id because it is definitely valid.
>> What's more, application shouldn't do something like configuring this port
>> or querying some information of this port by ethdev ops.
>>
>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>> ---
>> lib/ethdev/rte_ethdev.h | 9 ++++++++-
>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
>> index 1f71cad244..e2021f0f12 100644
>> --- a/lib/ethdev/rte_ethdev.h
>> +++ b/lib/ethdev/rte_ethdev.h
>> @@ -4128,7 +4128,14 @@ 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 */
>> + /** Port is probed and application's event callback will be called.
> We are not going to say that the callback is called for each event :)
>
>> + * In this moment, the port is not fully probed and is just in allocated
>> + * state. When application receive this event, application doesn't need
> It is not a real state.
>
>> + * to verify the validity of the port id because it is definitely valid.
>> + * What's more, application shouldn't do something like configuring this
>> + * port or querying some information of this port by ethdev ops.
>> + */
> Let me try shorter:
> "
> The port is being probed, i.e. allocated and not yet available.
> It is too early to check validity, infos, or configuring the port.
> "
"
The port is being probed, i.e. allocated and not yet available.
It is too early to check validity, query infos, or configure the port.
But the socket id and owner id related to this port can be considered as
valid.
"
How about use above comments?
>
>
> .
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v1 2/2] ethdev: fix some APIs can be used in the new event
2025-01-16 6:14 ` lihuisong (C)
@ 2025-01-16 9:09 ` Thomas Monjalon
2025-01-16 9:35 ` lihuisong (C)
0 siblings, 1 reply; 17+ messages in thread
From: Thomas Monjalon @ 2025-01-16 9:09 UTC (permalink / raw)
To: lihuisong (C); +Cc: stephen, liuyonglong, dev
16/01/2025 07:14, lihuisong (C):
> 在 2025/1/15 19:36, Thomas Monjalon 写道:
> > 15/01/2025 04:41, Huisong Li:
> >> 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.
> > You should be more explicit:
> > "during probing, before it becomes generally available and considered as valid".
> "During probing, before the port becomes generally available, its socket
> id and owner id can be considered as valid."
> How about say it like this?
I prefer when you give the function names, it is more explicit.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v1 1/2] ethdev: clarify do not something in the new event
2025-01-16 6:16 ` lihuisong (C)
@ 2025-01-16 9:15 ` Thomas Monjalon
2025-01-16 9:35 ` lihuisong (C)
0 siblings, 1 reply; 17+ messages in thread
From: Thomas Monjalon @ 2025-01-16 9:15 UTC (permalink / raw)
To: lihuisong (C); +Cc: dev, stephen, liuyonglong
16/01/2025 07:16, lihuisong (C):
>
> 在 2025/1/15 19:31, Thomas Monjalon 写道:
> > 15/01/2025 04:41, Huisong Li:
> >> 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.
> >>
> >> Actually, when application receive a new event from one port, the port is
> >> not fully probed and is just in allocated state. Application doesn't need
> >> to verify the validity of the port id because it is definitely valid.
> >> What's more, application shouldn't do something like configuring this port
> >> or querying some information of this port by ethdev ops.
> >>
> >> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> >> ---
> >> lib/ethdev/rte_ethdev.h | 9 ++++++++-
> >> 1 file changed, 8 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
> >> index 1f71cad244..e2021f0f12 100644
> >> --- a/lib/ethdev/rte_ethdev.h
> >> +++ b/lib/ethdev/rte_ethdev.h
> >> @@ -4128,7 +4128,14 @@ 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 */
> >> + /** Port is probed and application's event callback will be called.
> > We are not going to say that the callback is called for each event :)
> >
> >> + * In this moment, the port is not fully probed and is just in allocated
> >> + * state. When application receive this event, application doesn't need
> > It is not a real state.
> >
> >> + * to verify the validity of the port id because it is definitely valid.
> >> + * What's more, application shouldn't do something like configuring this
> >> + * port or querying some information of this port by ethdev ops.
> >> + */
> > Let me try shorter:
> > "
> > The port is being probed, i.e. allocated and not yet available.
> > It is too early to check validity, infos, or configuring the port.
> > "
> "
> The port is being probed, i.e. allocated and not yet available.
> It is too early to check validity, query infos, or configure the port.
> But the socket id and owner id related to this port can be considered as
> valid.
> "
> How about use above comments?
The last sentence should be in patch 2.
And I am not sure about saying they are valid.
It is more accurate to say that the functions for socket id and owner id are available.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v1 1/2] ethdev: clarify do not something in the new event
2025-01-16 9:15 ` Thomas Monjalon
@ 2025-01-16 9:35 ` lihuisong (C)
0 siblings, 0 replies; 17+ messages in thread
From: lihuisong (C) @ 2025-01-16 9:35 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev, stephen, liuyonglong
在 2025/1/16 17:15, Thomas Monjalon 写道:
> 16/01/2025 07:16, lihuisong (C):
>> 在 2025/1/15 19:31, Thomas Monjalon 写道:
>>> 15/01/2025 04:41, Huisong Li:
>>>> 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.
>>>>
>>>> Actually, when application receive a new event from one port, the port is
>>>> not fully probed and is just in allocated state. Application doesn't need
>>>> to verify the validity of the port id because it is definitely valid.
>>>> What's more, application shouldn't do something like configuring this port
>>>> or querying some information of this port by ethdev ops.
>>>>
>>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>>> ---
>>>> lib/ethdev/rte_ethdev.h | 9 ++++++++-
>>>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
>>>> index 1f71cad244..e2021f0f12 100644
>>>> --- a/lib/ethdev/rte_ethdev.h
>>>> +++ b/lib/ethdev/rte_ethdev.h
>>>> @@ -4128,7 +4128,14 @@ 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 */
>>>> + /** Port is probed and application's event callback will be called.
>>> We are not going to say that the callback is called for each event :)
>>>
>>>> + * In this moment, the port is not fully probed and is just in allocated
>>>> + * state. When application receive this event, application doesn't need
>>> It is not a real state.
>>>
>>>> + * to verify the validity of the port id because it is definitely valid.
>>>> + * What's more, application shouldn't do something like configuring this
>>>> + * port or querying some information of this port by ethdev ops.
>>>> + */
>>> Let me try shorter:
>>> "
>>> The port is being probed, i.e. allocated and not yet available.
>>> It is too early to check validity, infos, or configuring the port.
>>> "
>> "
>> The port is being probed, i.e. allocated and not yet available.
>> It is too early to check validity, query infos, or configure the port.
>> But the socket id and owner id related to this port can be considered as
>> valid.
>> "
>> How about use above comments?
> The last sentence should be in patch 2.
> And I am not sure about saying they are valid.
> It is more accurate to say that the functions for socket id and owner id are available.
Ack
>
>
> .
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v1 2/2] ethdev: fix some APIs can be used in the new event
2025-01-16 9:09 ` Thomas Monjalon
@ 2025-01-16 9:35 ` lihuisong (C)
0 siblings, 0 replies; 17+ messages in thread
From: lihuisong (C) @ 2025-01-16 9:35 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: stephen, liuyonglong, dev
在 2025/1/16 17:09, Thomas Monjalon 写道:
> 16/01/2025 07:14, lihuisong (C):
>> 在 2025/1/15 19:36, Thomas Monjalon 写道:
>>> 15/01/2025 04:41, Huisong Li:
>>>> 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.
>>> You should be more explicit:
>>> "during probing, before it becomes generally available and considered as valid".
>> "During probing, before the port becomes generally available, its socket
>> id and owner id can be considered as valid."
>> How about say it like this?
> I prefer when you give the function names, it is more explicit.
ok
>
>
>
> .
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 0/2] ethdev: clarify something about new event
2025-01-15 3:41 [PATCH v1 0/2] ethdev: clarify something about new event Huisong Li
2025-01-15 3:41 ` [PATCH v1 1/2] ethdev: clarify do not something in the " Huisong Li
2025-01-15 3:41 ` [PATCH v1 2/2] ethdev: fix some APIs can be used " Huisong Li
@ 2025-01-16 11:40 ` Huisong Li
2025-01-16 11:40 ` [PATCH v2 1/2] ethdev: clarify something about the " Huisong Li
2025-01-16 11:40 ` [PATCH v2 2/2] ethdev: fix some functions are available in " Huisong Li
2 siblings, 2 replies; 17+ messages in thread
From: Huisong Li @ 2025-01-16 11:40 UTC (permalink / raw)
To: dev; +Cc: thomas, stephen, liuyonglong, lihuisong
I've had some issues when I add the verification of the port id in the
event callback, which are discussed in another patch series[1]. So this
series clarify something about RTE_ETH_EVENT_NEW based on the previous
discussion.
[1] https://patches.dpdk.org/project/dpdk/cover/20250113025521.32703-1-lihuisong@huawei.com/
---
-v2: fix some descriptions as Thomas suggested.
Huisong Li (2):
ethdev: clarify something about the new event
ethdev: fix some functions are available in the new event
lib/ethdev/rte_ethdev.c | 14 +++++++++++---
lib/ethdev/rte_ethdev.h | 7 ++++++-
2 files changed, 17 insertions(+), 4 deletions(-)
--
2.22.0
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 1/2] ethdev: clarify something about the new event
2025-01-16 11:40 ` [PATCH v2 0/2] ethdev: clarify something about " Huisong Li
@ 2025-01-16 11:40 ` Huisong Li
2025-01-16 15:17 ` Thomas Monjalon
2025-01-16 18:31 ` Stephen Hemminger
2025-01-16 11:40 ` [PATCH v2 2/2] ethdev: fix some functions are available in " Huisong Li
1 sibling, 2 replies; 17+ messages in thread
From: Huisong Li @ 2025-01-16 11:40 UTC (permalink / raw)
To: dev; +Cc: thomas, stephen, liuyonglong, lihuisong
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 <lihuisong@huawei.com>
---
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 */
--
2.22.0
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 2/2] ethdev: fix some functions are available in the new event
2025-01-16 11:40 ` [PATCH v2 0/2] ethdev: clarify something about " Huisong Li
2025-01-16 11:40 ` [PATCH v2 1/2] ethdev: clarify something about the " Huisong Li
@ 2025-01-16 11:40 ` Huisong Li
2025-01-16 15:18 ` Thomas Monjalon
1 sibling, 1 reply; 17+ messages in thread
From: Huisong Li @ 2025-01-16 11:40 UTC (permalink / raw)
To: dev; +Cc: thomas, stephen, liuyonglong, lihuisong
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(-)
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 */
--
2.22.0
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 1/2] ethdev: clarify something about the new event
2025-01-16 11:40 ` [PATCH v2 1/2] ethdev: clarify something about the " Huisong Li
@ 2025-01-16 15:17 ` Thomas Monjalon
2025-01-16 18:31 ` Stephen Hemminger
1 sibling, 0 replies; 17+ messages in thread
From: Thomas Monjalon @ 2025-01-16 15:17 UTC (permalink / raw)
To: Huisong Li; +Cc: dev, stephen, liuyonglong
16/01/2025 12:40, Huisong Li:
> 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 <lihuisong@huawei.com>
> ---
> - 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,
Acked-by: Thomas Monjalon <thomas@monjalon.net>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 2/2] ethdev: fix some functions are available in the new event
2025-01-16 11:40 ` [PATCH v2 2/2] ethdev: fix some functions are available in " Huisong Li
@ 2025-01-16 15:18 ` Thomas Monjalon
0 siblings, 0 replies; 17+ messages in thread
From: Thomas Monjalon @ 2025-01-16 15:18 UTC (permalink / raw)
To: Huisong Li; +Cc: dev, stephen, liuyonglong
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>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 1/2] ethdev: clarify something about the new event
2025-01-16 11:40 ` [PATCH v2 1/2] ethdev: clarify something about the " Huisong Li
2025-01-16 15:17 ` Thomas Monjalon
@ 2025-01-16 18:31 ` Stephen Hemminger
1 sibling, 0 replies; 17+ messages in thread
From: Stephen Hemminger @ 2025-01-16 18:31 UTC (permalink / raw)
To: Huisong Li; +Cc: dev, thomas, liuyonglong
On Thu, 16 Jan 2025 19:40:33 +0800
Huisong Li <lihuisong@huawei.com> wrote:
> 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 <lihuisong@huawei.com>
> ---
> 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 */
All the comments in event_type need some editing to make them more
readable. It is good style when having a list to make sure that
each item in a list agrees in terms of wording, verb tense,
capitalization, description, etc.
This can be addressed by a later patch, ideally by looking
at the resulting API doc and fixing the source to match.
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2025-01-16 18:31 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-15 3:41 [PATCH v1 0/2] ethdev: clarify something about new event 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-16 6:16 ` lihuisong (C)
2025-01-16 9:15 ` Thomas Monjalon
2025-01-16 9:35 ` lihuisong (C)
2025-01-15 3:41 ` [PATCH v1 2/2] ethdev: fix some APIs can be used " Huisong Li
2025-01-15 11:36 ` Thomas Monjalon
2025-01-16 6:14 ` lihuisong (C)
2025-01-16 9:09 ` Thomas Monjalon
2025-01-16 9:35 ` lihuisong (C)
2025-01-16 11:40 ` [PATCH v2 0/2] ethdev: clarify something about " Huisong Li
2025-01-16 11:40 ` [PATCH v2 1/2] ethdev: clarify something about the " Huisong Li
2025-01-16 15:17 ` Thomas Monjalon
2025-01-16 18:31 ` Stephen Hemminger
2025-01-16 11:40 ` [PATCH v2 2/2] ethdev: fix some functions are available in " Huisong Li
2025-01-16 15:18 ` Thomas Monjalon
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).