diff mbox series

[RFC,v2,7/8] test/virtual_pmd: support queue start/stop

Message ID 20210716142800.3853651-7-ferruh.yigit@intel.com (mailing list archive)
State Deferred
Delegated to: Thomas Monjalon
Headers show
Series [RFC,v2,1/8] test/virtual_pmd: clean rings on close | expand

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Ferruh Yigit July 16, 2021, 2:27 p.m. UTC
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 app/test/virtual_pmd.c | 52 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
diff mbox series

Patch

diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 27c8501b96a7..4b8318cf39dd 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -35,11 +35,35 @@  struct virtual_ethdev_queue {
 	struct rte_eth_rxconf rx_conf;
 };
 
+static int
+virtual_ethdev_rx_queue_start(struct rte_eth_dev *eth_dev, uint16_t queue_id)
+{
+	eth_dev->data->rx_queue_state[queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
+
+	return 0;
+}
+
+static int
+virtual_ethdev_tx_queue_start(struct rte_eth_dev *eth_dev, uint16_t queue_id)
+{
+	eth_dev->data->tx_queue_state[queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
+
+	return 0;
+}
+
 static int
 virtual_ethdev_start_success(struct rte_eth_dev *eth_dev)
 {
+	int i;
+
 	eth_dev->data->dev_started = 1;
 
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
+		virtual_ethdev_rx_queue_start(eth_dev, i);
+
+	for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
+		virtual_ethdev_tx_queue_start(eth_dev, i);
+
 	return 0;
 }
 
@@ -50,10 +74,34 @@  virtual_ethdev_start_fail(struct rte_eth_dev *eth_dev)
 
 	return -1;
 }
+
+static int
+virtual_ethdev_rx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t queue_id)
+{
+	eth_dev->data->rx_queue_state[queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+
+	return 0;
+}
+
+static int
+virtual_ethdev_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t queue_id)
+{
+	eth_dev->data->tx_queue_state[queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+
+	return 0;
+}
+
 static int  virtual_ethdev_stop(struct rte_eth_dev *eth_dev)
 {
 	void *pkt = NULL;
 	struct virtual_ethdev_private *prv = eth_dev->data->dev_private;
+	int i;
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
+		virtual_ethdev_rx_queue_stop(eth_dev, i);
+
+	for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
+		virtual_ethdev_tx_queue_stop(eth_dev, i);
 
 	eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
 	eth_dev->data->dev_started = 0;
@@ -271,6 +319,10 @@  static const struct eth_dev_ops virtual_ethdev_default_dev_ops = {
 	.dev_stop = virtual_ethdev_stop,
 	.dev_close = virtual_ethdev_close,
 	.dev_infos_get = virtual_ethdev_info_get,
+	.rx_queue_start = virtual_ethdev_rx_queue_start,
+	.tx_queue_start = virtual_ethdev_tx_queue_start,
+	.rx_queue_stop = virtual_ethdev_rx_queue_stop,
+	.tx_queue_stop = virtual_ethdev_tx_queue_stop,
 	.rx_queue_setup = virtual_ethdev_rx_queue_setup_success,
 	.tx_queue_setup = virtual_ethdev_tx_queue_setup_success,
 	.rxq_info_get = virtual_ethdev_rx_info_get,