The DPDK framework reports the queue state, which is stored in
dev->data->tx_queue_state and dev->data->rx_queue_state. The
state is maintained by the driver. Users may determine whether
a queue participates in packet forwarding based on the state.
Therefore, the driver needs to modify the queue state in time
according to the actual situation.

Fixes: 9ad9ff476cac ("ethdev: add queue state in queried queue information")
Cc: sta...@dpdk.org

Signed-off-by: Jie Hai <haij...@huawei.com>
---
 drivers/net/vhost/rte_eth_vhost.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/vhost/rte_eth_vhost.c 
b/drivers/net/vhost/rte_eth_vhost.c
index 8d37ec977545..d53b8c2cd1fc 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -1135,6 +1135,7 @@ eth_dev_start(struct rte_eth_dev *eth_dev)
 {
        struct pmd_internal *internal = eth_dev->data->dev_private;
        struct rte_eth_conf *dev_conf = &eth_dev->data->dev_conf;
+       uint16_t i;
 
        eth_vhost_uninstall_intr(eth_dev);
        if (dev_conf->intr_conf.rxq && eth_vhost_install_intr(eth_dev) < 0) {
@@ -1150,6 +1151,11 @@ eth_dev_start(struct rte_eth_dev *eth_dev)
        rte_atomic32_set(&internal->started, 1);
        update_queuing_status(eth_dev, false);
 
+       for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
+               eth_dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
+       for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
+               eth_dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
+
        return 0;
 }
 
@@ -1157,11 +1163,17 @@ static int
 eth_dev_stop(struct rte_eth_dev *dev)
 {
        struct pmd_internal *internal = dev->data->dev_private;
+       uint16_t i;
 
        dev->data->dev_started = 0;
        rte_atomic32_set(&internal->started, 0);
        update_queuing_status(dev, true);
 
+       for (i = 0; i < dev->data->nb_rx_queues; i++)
+               dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
+       for (i = 0; i < dev->data->nb_tx_queues; i++)
+               dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
+
        return 0;
 }
 
-- 
2.30.0

Reply via email to