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/virtio/virtio_ethdev.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 2c23f1c00e25..3ab56ef769c9 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -2417,6 +2417,11 @@ virtio_dev_start(struct rte_eth_dev *dev)
        set_rxtx_funcs(dev);
        hw->started = 1;
 
+       for (i = 0; i < dev->data->nb_rx_queues; i++)
+               dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
+       for (i = 0; i < dev->data->nb_tx_queues; i++)
+               dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
+
        /* Initialize Link state */
        virtio_dev_link_update(dev, 0);
 
@@ -2506,6 +2511,7 @@ virtio_dev_stop(struct rte_eth_dev *dev)
        struct virtio_hw *hw = dev->data->dev_private;
        struct rte_eth_link link;
        struct rte_eth_intr_conf *intr_conf = &dev->data->dev_conf.intr_conf;
+       uint16_t i;
 
        PMD_INIT_LOG(DEBUG, "stop");
        dev->data->dev_started = 0;
@@ -2533,6 +2539,11 @@ virtio_dev_stop(struct rte_eth_dev *dev)
 out_unlock:
        rte_spinlock_unlock(&hw->state_lock);
 
+       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