[v4,1/2] ethdev: add API to check if queue is valid

Message ID 20230602075211.3628165-2-huangdengdui@huawei.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series add Rx/Tx queue ID check API and use it to fix a bug |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing warning apply patch failure

Commit Message

Dengdui Huang June 2, 2023, 7:52 a.m. UTC
  The API rte_eth_dev_is_valid_rxq/txq which
is used to check if Rx/Tx queue is valid.
If the queue has been setup, it is considered valid.

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
---
 doc/guides/rel_notes/release_23_07.rst |  6 ++++
 lib/ethdev/rte_ethdev.c                | 22 +++++++++++++++
 lib/ethdev/rte_ethdev.h                | 38 ++++++++++++++++++++++++++
 lib/ethdev/version.map                 |  2 ++
 4 files changed, 68 insertions(+)
  

Comments

Ferruh Yigit June 2, 2023, 12:47 p.m. UTC | #1
On 6/2/2023 8:52 AM, Dengdui Huang wrote:
> The API rte_eth_dev_is_valid_rxq/txq which
> is used to check if Rx/Tx queue is valid.
> If the queue has been setup, it is considered valid.
> 
> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
> ---
>  doc/guides/rel_notes/release_23_07.rst |  6 ++++
>  lib/ethdev/rte_ethdev.c                | 22 +++++++++++++++
>  lib/ethdev/rte_ethdev.h                | 38 ++++++++++++++++++++++++++
>  lib/ethdev/version.map                 |  2 ++
>  4 files changed, 68 insertions(+)
> 
> diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst
> index 0d3cada5d0..1332fa3a5a 100644
> --- a/doc/guides/rel_notes/release_23_07.rst
> +++ b/doc/guides/rel_notes/release_23_07.rst
> @@ -83,6 +83,12 @@ New Features
>    for new capability registers, large passthrough BAR and some
>    performance enhancements for UPT.
>  
> +* **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 is valid. If the queue has been setup,
> +  it is considered valid.
> +
>  

Can you please move the release note update to up, before rte_flow
updates, the expected order is documented in section comment.

>  Removed Items
>  -------------
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index d46e74504e..a134928c8a 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -771,6 +771,28 @@ eth_dev_validate_tx_queue(const struct rte_eth_dev *dev, uint16_t tx_queue_id)
>  	return 0;
>  }
>  
> +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];
> +
> +	return eth_dev_validate_rx_queue(dev, queue_id);
> +}
> +
> +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];
> +
> +	return eth_dev_validate_tx_queue(dev, queue_id);
> +}
> +
>  int
>  rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id)
>  {
> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
> index 9932413c33..4ef803c244 100644
> --- a/lib/ethdev/rte_ethdev.h
> +++ b/lib/ethdev/rte_ethdev.h
> @@ -2666,6 +2666,44 @@ 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 is valid. If the queue has been setup,
> + * it is considered 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 valid.

s/valid/invalid ?

> + *   - -EINVAL: if queue is out of range or not been setup.

"if queue_id is out of range or queue is not been setup" ?

> + *   - 0 if Rx queue 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 is valid. If the queue has been setup,
> + * it is considered 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 valid.

s/valid/invalid ?

> + *   - -EINVAL: if queue is out of range or not been setup.

"if queue_id is out of range or queue is not been setup" ?

> + *   - 0 if Tx queue 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 9d418091ef..3aa6bce156 100644
> --- a/lib/ethdev/version.map
> +++ b/lib/ethdev/version.map
> @@ -309,6 +309,8 @@ EXPERIMENTAL {
>  	rte_flow_async_action_list_handle_destroy;
>  	rte_flow_async_action_list_handle_query_update;
>  	rte_flow_async_actions_update;
> +	rte_eth_dev_is_valid_rxq;
> +	rte_eth_dev_is_valid_txq;

Can you please sort '23.07' block alphabetically?

>  };
>  
>  INTERNAL {
  
Dengdui Huang June 5, 2023, 1:24 a.m. UTC | #2
On 2023/6/2 20:47, Ferruh Yigit wrote:
> On 6/2/2023 8:52 AM, Dengdui Huang wrote:
>> The API rte_eth_dev_is_valid_rxq/txq which
>> is used to check if Rx/Tx queue is valid.
>> If the queue has been setup, it is considered valid.
>>
>> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
>> ---
>>  doc/guides/rel_notes/release_23_07.rst |  6 ++++
>>  lib/ethdev/rte_ethdev.c                | 22 +++++++++++++++
>>  lib/ethdev/rte_ethdev.h                | 38 ++++++++++++++++++++++++++
>>  lib/ethdev/version.map                 |  2 ++
>>  4 files changed, 68 insertions(+)
>>
>> diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst
>> index 0d3cada5d0..1332fa3a5a 100644
>> --- a/doc/guides/rel_notes/release_23_07.rst
>> +++ b/doc/guides/rel_notes/release_23_07.rst
>> @@ -83,6 +83,12 @@ New Features
>>    for new capability registers, large passthrough BAR and some
>>    performance enhancements for UPT.
>>  
>> +* **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 is valid. If the queue has been setup,
>> +  it is considered valid.
>> +
>>  
> 
> Can you please move the release note update to up, before rte_flow
> updates, the expected order is documented in section comment.
> 
>>  Removed Items
>>  -------------
>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
>> index d46e74504e..a134928c8a 100644
>> --- a/lib/ethdev/rte_ethdev.c
>> +++ b/lib/ethdev/rte_ethdev.c
>> @@ -771,6 +771,28 @@ eth_dev_validate_tx_queue(const struct rte_eth_dev *dev, uint16_t tx_queue_id)
>>  	return 0;
>>  }
>>  
>> +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];
>> +
>> +	return eth_dev_validate_rx_queue(dev, queue_id);
>> +}
>> +
>> +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];
>> +
>> +	return eth_dev_validate_tx_queue(dev, queue_id);
>> +}
>> +
>>  int
>>  rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id)
>>  {
>> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
>> index 9932413c33..4ef803c244 100644
>> --- a/lib/ethdev/rte_ethdev.h
>> +++ b/lib/ethdev/rte_ethdev.h
>> @@ -2666,6 +2666,44 @@ 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 is valid. If the queue has been setup,
>> + * it is considered 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 valid.
> 
> s/valid/invalid ?
> 
>> + *   - -EINVAL: if queue is out of range or not been setup.
> 
> "if queue_id is out of range or queue is not been setup" ?
> 
>> + *   - 0 if Rx queue 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 is valid. If the queue has been setup,
>> + * it is considered 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 valid.
> 
> s/valid/invalid ?
> 
>> + *   - -EINVAL: if queue is out of range or not been setup.
> 
> "if queue_id is out of range or queue is not been setup" ?
> 
>> + *   - 0 if Tx queue 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 9d418091ef..3aa6bce156 100644
>> --- a/lib/ethdev/version.map
>> +++ b/lib/ethdev/version.map
>> @@ -309,6 +309,8 @@ EXPERIMENTAL {
>>  	rte_flow_async_action_list_handle_destroy;
>>  	rte_flow_async_action_list_handle_query_update;
>>  	rte_flow_async_actions_update;
>> +	rte_eth_dev_is_valid_rxq;
>> +	rte_eth_dev_is_valid_txq;
> 
> Can you please sort '23.07' block alphabetically?
> 
>>  };
>>  
>>  INTERNAL {
> 
Hi Ferruh,
Thanks for your review, I will do in v5.
  

Patch

diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst
index 0d3cada5d0..1332fa3a5a 100644
--- a/doc/guides/rel_notes/release_23_07.rst
+++ b/doc/guides/rel_notes/release_23_07.rst
@@ -83,6 +83,12 @@  New Features
   for new capability registers, large passthrough BAR and some
   performance enhancements for UPT.
 
+* **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 is valid. If the queue has been setup,
+  it is considered valid.
+
 
 Removed Items
 -------------
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index d46e74504e..a134928c8a 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -771,6 +771,28 @@  eth_dev_validate_tx_queue(const struct rte_eth_dev *dev, uint16_t tx_queue_id)
 	return 0;
 }
 
+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];
+
+	return eth_dev_validate_rx_queue(dev, queue_id);
+}
+
+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];
+
+	return eth_dev_validate_tx_queue(dev, queue_id);
+}
+
 int
 rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id)
 {
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 9932413c33..4ef803c244 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -2666,6 +2666,44 @@  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 is valid. If the queue has been setup,
+ * it is considered 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 valid.
+ *   - -EINVAL: if queue is out of range or not been setup.
+ *   - 0 if Rx queue 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 is valid. If the queue has been setup,
+ * it is considered 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 valid.
+ *   - -EINVAL: if queue is out of range or not been setup.
+ *   - 0 if Tx queue 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 9d418091ef..3aa6bce156 100644
--- a/lib/ethdev/version.map
+++ b/lib/ethdev/version.map
@@ -309,6 +309,8 @@  EXPERIMENTAL {
 	rte_flow_async_action_list_handle_destroy;
 	rte_flow_async_action_list_handle_query_update;
 	rte_flow_async_actions_update;
+	rte_eth_dev_is_valid_rxq;
+	rte_eth_dev_is_valid_txq;
 };
 
 INTERNAL {