[v2,1/2] ethdev: add API to check queue ID validity

Message ID 20230522130947.345390-2-huangdengdui@huawei.com (mailing list archive)
State Superseded, archived
Headers
Series add API and use it to fix a bug |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

Dengdui Huang May 22, 2023, 1:09 p.m. UTC
  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 <huangdengdui@huawei.com>
---
 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(+)
  

Comments

Andrew Rybchenko May 22, 2023, 1:58 p.m. UTC | #1
On 5/22/23 16:09, Dengdui Huang wrote:
> The API rte_eth_dev_is_valid_rxq/txq checks
> the port ID validity and then the Rx/Tx queue ID is valid.

What is valid Tx/Rx queue? It depends on on caller
expectations. Some functions are satisfied with just
check vs configured number of queues. Some require
the queue to be setup. May be some should require
the queue to be started.

So, I suggest to avoid term "valid" and be more precise
here and API naming.

> 
> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
> ---
>   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

id -> ID

> +  for check if Rx/Tx queue id is valid.

id -> ID

> +

It should be two empty lines here and just one above.

>   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)

We already have internal eth_dev_validate_tx_queue(). Shouldn't
it be used here?

Also, some functions check that queues array is not NULL.
If the the is excessive after queue number check, it
should be consistent everywhere and corresponding check
of the array pointer vs NULL should be removed in a separate
cleanup patch. If the check is required in some corner cases
(I hope no), it should be here as well.

> +		return -EINVAL;
> +
> +	return 0;
> +}

[snip]
  
Dengdui Huang May 24, 2023, 7:38 a.m. UTC | #2
On 2023/5/22 21:58, Andrew Rybchenko wrote:
> On 5/22/23 16:09, Dengdui Huang wrote:
>> The API rte_eth_dev_is_valid_rxq/txq checks
>> the port ID validity and then the Rx/Tx queue ID is valid.
> 
> What is valid Tx/Rx queue? It depends on on caller
> expectations. Some functions are satisfied with just
> check vs configured number of queues. Some require
> the queue to be setup. May be some should require
> the queue to be started.
> 
> So, I suggest to avoid term "valid" and be more precise
> here and API naming.
> 
Hi Andrew,
Thanks for your review, Accepted and fixed in v3.
>>
>> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
>> ---
>>   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
> 
> id -> ID
> 
>> +  for check if Rx/Tx queue id is valid.
> 
> id -> ID
> 
>> +
> 
> It should be two empty lines here and just one above.
> 
Thanks, will fix in v3
>>   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)
> 
> We already have internal eth_dev_validate_tx_queue(). Shouldn't
> it be used here?
> 
Thanks, will do in v3.
> Also, some functions check that queues array is not NULL.
> If the the is excessive after queue number check, it
> should be consistent everywhere and corresponding check
> of the array pointer vs NULL should be removed in a separate
> cleanup patch. If the check is required in some corner cases
> (I hope no), it should be here as well.
> 
I cannot understand what you mean by that.
>> +        return -EINVAL;
>> +
>> +    return 0;
>> +}
> 
> [snip]
>
  
Andrew Rybchenko May 24, 2023, 9:03 a.m. UTC | #3
On 5/24/23 10:38, huangdengdui wrote:
> On 2023/5/22 21:58, Andrew Rybchenko wrote:
>> On 5/22/23 16:09, Dengdui Huang wrote:
>>> The API rte_eth_dev_is_valid_rxq/txq checks
>>> the port ID validity and then the Rx/Tx queue ID is valid.
>>
>> What is valid Tx/Rx queue? It depends on on caller
>> expectations. Some functions are satisfied with just
>> check vs configured number of queues. Some require
>> the queue to be setup. May be some should require
>> the queue to be started.
>>
>> So, I suggest to avoid term "valid" and be more precise
>> here and API naming.
>>
> Hi Andrew,
> Thanks for your review, Accepted and fixed in v3.
>>>
>>> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
>>> ---
>>>    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
>>
>> id -> ID
>>
>>> +  for check if Rx/Tx queue id is valid.
>>
>> id -> ID
>>
>>> +
>>
>> It should be two empty lines here and just one above.
>>
> Thanks, will fix in v3
>>>    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)
>>
>> We already have internal eth_dev_validate_tx_queue(). Shouldn't
>> it be used here?
>>
> Thanks, will do in v3.
>> Also, some functions check that queues array is not NULL.
>> If the the is excessive after queue number check, it
>> should be consistent everywhere and corresponding check
>> of the array pointer vs NULL should be removed in a separate
>> cleanup patch. If the check is required in some corner cases
>> (I hope no), it should be here as well.

dev->data->rx_queues != NULL ???

>>
> I cannot understand what you mean by that.
>>> +        return -EINVAL;
>>> +
>>> +    return 0;
>>> +}
>>
>> [snip]
>>
  
Ferruh Yigit May 31, 2023, 4:31 p.m. UTC | #4
On 5/22/2023 2:58 PM, Andrew Rybchenko wrote:
> On 5/22/23 16:09, Dengdui Huang wrote:
>> The API rte_eth_dev_is_valid_rxq/txq checks
>> the port ID validity and then the Rx/Tx queue ID is valid.
> 
> What is valid Tx/Rx queue? It depends on on caller
> expectations. Some functions are satisfied with just
> check vs configured number of queues. Some require
> the queue to be setup. May be some should require
> the queue to be started.
> 
> So, I suggest to avoid term "valid" and be more precise
> here and API naming.
> 

I understand the concern 'valid' keyword, but we already have an API as
'rte_eth_dev_is_valid_port()', which does similar checks,

so 'rte_eth_dev_is_valid_rxq()' & 'rte_eth_dev_is_valid_txq()' looks
consistent with it.

v3 has API names, 'rte_eth_dev_rxq_avail()' & 'rte_eth_dev_txq_avail()',
I am not sure about these naming too, it feels like queues are valid but
it maybe in available and not available states.


@Andrew, do you have any suggestion on the API naming?
If not I am for going with rte_eth_dev_is_valid_rxq()' &
'rte_eth_dev_is_valid_txq()' mainly because of existing
'rte_eth_dev_is_valid_port()' API.

Perhaps we can elaborate what 'valid' means in API documentation to help
users.

>>
>> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
>> ---
>>   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
> 
> id -> ID
> 
>> +  for check if Rx/Tx queue id is valid.
> 
> id -> ID
> 
>> +
> 
> It should be two empty lines here and just one above.
> 
>>   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)
> 
> We already have internal eth_dev_validate_tx_queue(). Shouldn't
> it be used here?
> 
> Also, some functions check that queues array is not NULL.
> If the the is excessive after queue number check, it
> should be consistent everywhere and corresponding check
> of the array pointer vs NULL should be removed in a separate
> cleanup patch. If the check is required in some corner cases
> (I hope no), it should be here as well.
> 
>> +        return -EINVAL;
>> +
>> +    return 0;
>> +}
> 
> [snip]
>
  
Ferruh Yigit June 1, 2023, 10:13 p.m. UTC | #5
On 5/31/2023 5:31 PM, Ferruh Yigit wrote:
> On 5/22/2023 2:58 PM, Andrew Rybchenko wrote:
>> On 5/22/23 16:09, Dengdui Huang wrote:
>>> The API rte_eth_dev_is_valid_rxq/txq checks
>>> the port ID validity and then the Rx/Tx queue ID is valid.
>>
>> What is valid Tx/Rx queue? It depends on on caller
>> expectations. Some functions are satisfied with just
>> check vs configured number of queues. Some require
>> the queue to be setup. May be some should require
>> the queue to be started.
>>
>> So, I suggest to avoid term "valid" and be more precise
>> here and API naming.
>>
> 
> I understand the concern 'valid' keyword, but we already have an API as
> 'rte_eth_dev_is_valid_port()', which does similar checks,
> 
> so 'rte_eth_dev_is_valid_rxq()' & 'rte_eth_dev_is_valid_txq()' looks
> consistent with it.
> 
> v3 has API names, 'rte_eth_dev_rxq_avail()' & 'rte_eth_dev_txq_avail()',
> I am not sure about these naming too, it feels like queues are valid but
> it maybe in available and not available states.
> 
> 
> @Andrew, do you have any suggestion on the API naming?
> If not I am for going with rte_eth_dev_is_valid_rxq()' &
> 'rte_eth_dev_is_valid_txq()' mainly because of existing
> 'rte_eth_dev_is_valid_port()' API.
> 
> Perhaps we can elaborate what 'valid' means in API documentation to help
> users.
> 

Hi Dengdui,

It looks like there is no better suggestion, lets not block this patch
more and continue with
'rte_eth_dev_is_valid_rxq()' & 'rte_eth_dev_is_valid_txq()' API names.

Can you please send a v4, with changes in v3 but API names as above, and
more description in the API documentation for what 'valid' means?


>>>
>>> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
>>> ---
>>>   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
>>
>> id -> ID
>>
>>> +  for check if Rx/Tx queue id is valid.
>>
>> id -> ID
>>
>>> +
>>
>> It should be two empty lines here and just one above.
>>
>>>   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)
>>
>> We already have internal eth_dev_validate_tx_queue(). Shouldn't
>> it be used here?
>>
>> Also, some functions check that queues array is not NULL.
>> If the the is excessive after queue number check, it
>> should be consistent everywhere and corresponding check
>> of the array pointer vs NULL should be removed in a separate
>> cleanup patch. If the check is required in some corner cases
>> (I hope no), it should be here as well.
>>
>>> +        return -EINVAL;
>>> +
>>> +    return 0;
>>> +}
>>
>> [snip]
>>
>
  
Dengdui Huang June 2, 2023, 1:36 a.m. UTC | #6
On 2023/6/2 6:13, Ferruh Yigit wrote:
> On 5/31/2023 5:31 PM, Ferruh Yigit wrote:
>> On 5/22/2023 2:58 PM, Andrew Rybchenko wrote:
>>> On 5/22/23 16:09, Dengdui Huang wrote:
>>>> The API rte_eth_dev_is_valid_rxq/txq checks
>>>> the port ID validity and then the Rx/Tx queue ID is valid.
>>>
>>> What is valid Tx/Rx queue? It depends on on caller
>>> expectations. Some functions are satisfied with just
>>> check vs configured number of queues. Some require
>>> the queue to be setup. May be some should require
>>> the queue to be started.
>>>
>>> So, I suggest to avoid term "valid" and be more precise
>>> here and API naming.
>>>
>>
>> I understand the concern 'valid' keyword, but we already have an API as
>> 'rte_eth_dev_is_valid_port()', which does similar checks,
>>
>> so 'rte_eth_dev_is_valid_rxq()' & 'rte_eth_dev_is_valid_txq()' looks
>> consistent with it.
>>
>> v3 has API names, 'rte_eth_dev_rxq_avail()' & 'rte_eth_dev_txq_avail()',
>> I am not sure about these naming too, it feels like queues are valid but
>> it maybe in available and not available states.
>>
>>
>> @Andrew, do you have any suggestion on the API naming?
>> If not I am for going with rte_eth_dev_is_valid_rxq()' &
>> 'rte_eth_dev_is_valid_txq()' mainly because of existing
>> 'rte_eth_dev_is_valid_port()' API.
>>
>> Perhaps we can elaborate what 'valid' means in API documentation to help
>> users.
>>
> 
> Hi Dengdui,
> 
> It looks like there is no better suggestion, lets not block this patch
> more and continue with
> 'rte_eth_dev_is_valid_rxq()' & 'rte_eth_dev_is_valid_txq()' API names.
> 
> Can you please send a v4, with changes in v3 but API names as above, and
> more description in the API documentation for what 'valid' means?
> Hi Ferruh,
Thanks for your review, I will do in v4.
> 
>>>>
>>>> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
>>>> ---
>>>>   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
>>>
>>> id -> ID
>>>
>>>> +  for check if Rx/Tx queue id is valid.
>>>
>>> id -> ID
>>>
>>>> +
>>>
>>> It should be two empty lines here and just one above.
>>>
>>>>   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)
>>>
>>> We already have internal eth_dev_validate_tx_queue(). Shouldn't
>>> it be used here?
>>>
>>> Also, some functions check that queues array is not NULL.
>>> If the the is excessive after queue number check, it
>>> should be consistent everywhere and corresponding check
>>> of the array pointer vs NULL should be removed in a separate
>>> cleanup patch. If the check is required in some corner cases
>>> (I hope no), it should be here as well.
>>>
>>>> +        return -EINVAL;
>>>> +
>>>> +    return 0;
>>>> +}
>>>
>>> [snip]
>>>
>>
>
  

Patch

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 {