Hi, all,
    any comments for this patch?
    Hope for your reply.

Thanks

在 2021/3/25 19:09, Lijun Ou 写道:
Currently, upper-layer application could get queue state only
through pointers such as dev->data->tx_queue_state[queue_id],
this is not the recommended way to access it. So this patch
add get queue state when call rte_eth_rx_queue_info_get and
rte_eth_tx_queue_info_get API.

Note: The hairpin queue is not supported with above
rte_eth_*x_queue_info_get, so the queue state could be
RTE_ETH_QUEUE_STATE_STARTED or RTE_ETH_QUEUE_STATE_STOPPED.
Note: After add queue_state field, the 'struct rte_eth_rxq_info' size
remains 128B, and the 'struct rte_eth_txq_info' size remains 64B, so
it could be ABI compatible.

Signed-off-by: Chengwen Feng <fengcheng...@huawei.com>
Signed-off-by: Lijun Ou <ouli...@huawei.com>
---
V1->V2:
- move queue state defines to public file
---
  doc/guides/rel_notes/release_21_05.rst |  6 ++++++
  lib/librte_ethdev/ethdev_driver.h      |  7 -------
  lib/librte_ethdev/rte_ethdev.c         |  3 +++
  lib/librte_ethdev/rte_ethdev.h         | 11 +++++++++++
  4 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/doc/guides/rel_notes/release_21_05.rst 
b/doc/guides/rel_notes/release_21_05.rst
index 22aa80a..503daf9 100644
--- a/doc/guides/rel_notes/release_21_05.rst
+++ b/doc/guides/rel_notes/release_21_05.rst
@@ -164,6 +164,12 @@ ABI Changes
* No ABI change that would break compatibility with 20.11. +* Added new field ``queue_state`` to ``rte_eth_rxq_info`` structure
+  to provide indicated rxq queue state.
+
+* Added new field ``queue_state`` to ``rte_eth_txq_info`` structure
+  to provide indicated txq queue state.
+
Known Issues
  ------------
diff --git a/lib/librte_ethdev/ethdev_driver.h 
b/lib/librte_ethdev/ethdev_driver.h
index cdd4b43..ec5a17d 100644
--- a/lib/librte_ethdev/ethdev_driver.h
+++ b/lib/librte_ethdev/ethdev_driver.h
@@ -970,13 +970,6 @@ struct eth_dev_ops {
  };
/**
- * RX/TX queue states
- */
-#define RTE_ETH_QUEUE_STATE_STOPPED 0
-#define RTE_ETH_QUEUE_STATE_STARTED 1
-#define RTE_ETH_QUEUE_STATE_HAIRPIN 2
-
-/**
   * @internal
   * Check if the selected Rx queue is hairpin queue.
   *
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 3059aa5..fbd10b2 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -5042,6 +5042,8 @@ rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t 
queue_id,
memset(qinfo, 0, sizeof(*qinfo));
        dev->dev_ops->rxq_info_get(dev, queue_id, qinfo);
+       qinfo->queue_state = dev->data->rx_queue_state[queue_id];
+
        return 0;
  }
@@ -5082,6 +5084,7 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id, memset(qinfo, 0, sizeof(*qinfo));
        dev->dev_ops->txq_info_get(dev, queue_id, qinfo);
+       qinfo->queue_state = dev->data->tx_queue_state[queue_id];
return 0;
  }
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index efda313..4f0b1b2 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -1582,6 +1582,13 @@ struct rte_eth_dev_info {
  };
/**
+ * RX/TX queue states
+ */
+#define RTE_ETH_QUEUE_STATE_STOPPED 0
+#define RTE_ETH_QUEUE_STATE_STARTED 1
+#define RTE_ETH_QUEUE_STATE_HAIRPIN 2
+
+/**
   * Ethernet device RX queue information structure.
   * Used to retrieve information about configured queue.
   */
@@ -1591,6 +1598,8 @@ struct rte_eth_rxq_info {
        uint8_t scattered_rx;       /**< scattered packets RX supported. */
        uint16_t nb_desc;           /**< configured number of RXDs. */
        uint16_t rx_buf_size;       /**< hardware receive buffer size. */
+       /**< Queues state: STARTED(1) / STOPPED(0). */
+       uint8_t queue_state;
  } __rte_cache_min_aligned;
/**
@@ -1600,6 +1609,8 @@ struct rte_eth_rxq_info {
  struct rte_eth_txq_info {
        struct rte_eth_txconf conf; /**< queue config parameters. */
        uint16_t nb_desc;           /**< configured number of TXDs. */
+       /**< Queues state: STARTED(1) / STOPPED(0). */
+       uint8_t queue_state;
  } __rte_cache_min_aligned;
/* Generic Burst mode flag definition, values can be ORed. */

Reply via email to