Skip to contentSkip to conversation

net/mana: set the correct queue state

PATCH Applied [email protected] 4 participants 9 messages Jul 7, 2023 – Oct 16, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mana: set the correct queue state

From: Long Li <[email protected]>

Set the queue state when queue is started/stopped

---
 drivers/net/mana/rx.c | 15 +++++++++++++++
 drivers/net/mana/tx.c | 13 +++++++++++++
 2 files changed, 28 insertions(+)
drivers/net/mana/rx.c +15 -0
index 220b372b15..1047ac1743 100644
@@ -131,6 +131,10 @@ mana_stop_rx_queues(struct rte_eth_dev *dev)
 	struct mana_priv *priv = dev->data->dev_private;
 	int ret, i;
 
+	for (i = 0; i < priv->num_queues; i++)
+		if (dev->data->rx_queue_state[i] == RTE_ETH_QUEUE_STATE_STOPPED)
+			return -EINVAL;
+
 	if (priv->rwq_qp) {
 		ret = ibv_destroy_qp(priv->rwq_qp);
 		if (ret)
@@ -187,7 +191,10 @@ mana_stop_rx_queues(struct rte_eth_dev *dev)
 
 		memset(&rxq->gdma_rq, 0, sizeof(rxq->gdma_rq));
 		memset(&rxq->gdma_cq, 0, sizeof(rxq->gdma_cq));
+
+		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
 	}
+
 	return 0;
 }
 
@@ -199,6 +206,11 @@ mana_start_rx_queues(struct rte_eth_dev *dev)
 	struct ibv_wq *ind_tbl[priv->num_queues];
 
 	DRV_LOG(INFO, "start rx queues");
+
+	for (i = 0; i < priv->num_queues; i++)
+		if (dev->data->rx_queue_state[i] == RTE_ETH_QUEUE_STATE_STARTED)
+			return -EINVAL;
+
 	for (i = 0; i < priv->num_queues; i++) {
 		struct mana_rxq *rxq = dev->data->rx_queues[i];
 		struct ibv_wq_init_attr wq_attr = {};
@@ -373,6 +385,9 @@ mana_start_rx_queues(struct rte_eth_dev *dev)
 			goto fail;
 	}
 
+	for (i = 0; i < priv->num_queues; i++)
+		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
+
 	return 0;
 
 fail:
drivers/net/mana/tx.c +13 -0
index 5947efbe8d..eb4b60cc10 100644
@@ -15,6 +15,10 @@ mana_stop_tx_queues(struct rte_eth_dev *dev)
 	struct mana_priv *priv = dev->data->dev_private;
 	int i, ret;
 
+	for (i = 0; i < priv->num_queues; i++)
+		if (dev->data->tx_queue_state[i] == RTE_ETH_QUEUE_STATE_STOPPED)
+			return -EINVAL;
+
 	for (i = 0; i < priv->num_queues; i++) {
 		struct mana_txq *txq = dev->data->tx_queues[i];
 
@@ -51,6 +55,8 @@ mana_stop_tx_queues(struct rte_eth_dev *dev)
 
 		memset(&txq->gdma_sq, 0, sizeof(txq->gdma_sq));
 		memset(&txq->gdma_cq, 0, sizeof(txq->gdma_cq));
+
+		dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
 	}
 
 	return 0;
@@ -63,6 +69,11 @@ mana_start_tx_queues(struct rte_eth_dev *dev)
 	int ret, i;
 
 	/* start TX queues */
+
+	for (i = 0; i < priv->num_queues; i++)
+		if (dev->data->tx_queue_state[i] == RTE_ETH_QUEUE_STATE_STARTED)
+			return -EINVAL;
+
 	for (i = 0; i < priv->num_queues; i++) {
 		struct mana_txq *txq;
 		struct ibv_qp_init_attr qp_attr = { 0 };
@@ -142,6 +153,8 @@ mana_start_tx_queues(struct rte_eth_dev *dev)
 			txq->gdma_cq.id, txq->gdma_cq.buffer,
 			txq->gdma_cq.count, txq->gdma_cq.size,
 			txq->gdma_cq.head);
+
+		dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
 	}
 
 	return 0;
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/1 net/netvsc: set the correct queue state

From: Long Li <[email protected]>

Set the queue state when queue is started/stopped.

---
 drivers/net/netvsc/hn_ethdev.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/net/netvsc/hn_ethdev.c +14 -1
index d0bbc0a4c0..0c15f9f826 100644
@@ -1017,6 +1017,11 @@ hn_dev_start(struct rte_eth_dev *dev)
 	if (error == 0)
 		hn_dev_link_update(dev, 0);
 
+	for (int i = 0; i < hv->num_queues; i++) {
+		dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
+		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
 	return error;
 }
 
@@ -1024,13 +1029,21 @@ static int
 hn_dev_stop(struct rte_eth_dev *dev)
 {
 	struct hn_data *hv = dev->data->dev_private;
+	int ret;
 
 	PMD_INIT_FUNC_TRACE();
 	dev->data->dev_started = 0;
 
 	rte_dev_event_callback_unregister(NULL, netvsc_hotadd_callback, hv);
 	hn_rndis_set_rxfilter(hv, 0);
-	return hn_vf_stop(dev);
+	ret = hn_vf_stop(dev);
+
+	for (int i = 0; i < hv->num_queues; i++) {
+		dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
+		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return ret;
 }
 
 static int
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#2 lore raw

Re: [PATCH] net/netvsc: set the correct queue state

Quoted 8 lines · On Fri, 7 Jul 2023 11:53:16 -0700 [email protected] wrote:

From: Long Li <[email protected]>

Set the queue state when queue is started/stopped.

---
 drivers/net/netvsc/hn_ethdev.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Interesting that not all drivers do this.

The ones not doing it.
af_packet
af_xdp
avp
axgbe
bnx2x
bonding
dpaa
dpaa2
e1000
ena
enetfec
gve
hinic
igc
ipn3ke
kni
liquidio
mana
memif
mlx4
netvsc
nfp
null
octeon_ep
pfe
ring
softnic
vdev_netvsc
vhost
virtio
vmxnet3

#3 lore raw

RE: [PATCH] net/netvsc: set the correct queue state

Quoted 42 lines

Subject: Re: [PATCH] net/netvsc: set the correct queue state

Quoted 8 lines · On Fri, 7 Jul 2023 11:53:16 -0700 [email protected] wrote:

From: Long Li <[email protected]>

Set the queue state when queue is started/stopped.

---
 drivers/net/netvsc/hn_ethdev.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Interesting that not all drivers do this.

The ones not doing it.
af_packet
af_xdp
avp
axgbe
bnx2x
bonding
dpaa
dpaa2
e1000
ena
enetfec
gve
hinic
igc
ipn3ke
kni
liquidio
mana
memif
mlx4
netvsc
nfp
null

Quoted 8 lines

octeon_ep
pfe
ring
softnic
vdev_netvsc
vhost
virtio
vmxnet3

Testpmd added the check for stopped queues:
3c4426db54 app/testpmd: do not poll stopped queues

To pass testpmd, PMD needs to set queue state.

#4 lore raw

Re: [PATCH] net/netvsc: set the correct queue state

Quoted 51 lines · On Fri, 7 Jul 2023 20:43:51 +0000 Long Li <[email protected]> wrote:
Quoted 42 lines

Subject: Re: [PATCH] net/netvsc: set the correct queue state

Quoted 8 lines · On Fri, 7 Jul 2023 11:53:16 -0700 [email protected] wrote:

From: Long Li <[email protected]>

Set the queue state when queue is started/stopped.

---
 drivers/net/netvsc/hn_ethdev.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)  

Interesting that not all drivers do this.

The ones not doing it.
af_packet
af_xdp
avp
axgbe
bnx2x
bonding
dpaa
dpaa2
e1000
ena
enetfec
gve
hinic
igc
ipn3ke
kni
liquidio
mana
memif
mlx4
netvsc
nfp
null

Quoted 8 lines

octeon_ep
pfe
ring
softnic
vdev_netvsc
vhost
virtio
vmxnet3

Quoted 4 lines

Testpmd added the check for stopped queues:
3c4426db54 app/testpmd: do not poll stopped queues

To pass testpmd, PMD needs to set queue state.

So there are 20 drivers broken by that change!
Sounds like it needs to be reverted.

#5 lore raw

Re: [PATCH] net/netvsc: set the correct queue state

Quoted 54 lines · Stephen Hemminger
Quoted 51 lines · On Fri, 7 Jul 2023 20:43:51 +0000 Long Li <[email protected]> wrote:
Quoted 50 lines

Subject: Re: [PATCH] net/netvsc: set the correct queue state

Quoted 8 lines · On Fri, 7 Jul 2023 11:53:16 -0700 [email protected] wrote:

From: Long Li <[email protected]>

Set the queue state when queue is started/stopped.

---
 drivers/net/netvsc/hn_ethdev.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)  

Interesting that not all drivers do this.

The ones not doing it.
af_packet
af_xdp
avp
axgbe
bnx2x
bonding
dpaa
dpaa2
e1000
ena
enetfec
gve
hinic
igc
ipn3ke
kni
liquidio
mana
memif
mlx4
netvsc
nfp
null
octeon_ep
pfe
ring
softnic
vdev_netvsc
vhost
virtio
vmxnet3

Quoted 8 lines
Quoted 4 lines

Testpmd added the check for stopped queues:
3c4426db54 app/testpmd: do not poll stopped queues

To pass testpmd, PMD needs to set queue state.

So there are 20 drivers broken by that change!
Sounds like it needs to be reverted.

testpmd change is already reverted in the next-net, but planned to merge it back in next release, and we need driver changes in next release.

#6 lore raw

PATCH v2 1/1 net/netvsc: set the correct queue state

In reply to [email protected]

From: Long Li <[email protected]>

Set the queue state when queue is started/stopped.

---
Change since v1:
Fixed the following building error
error: 'for' loop initial declarations are only allowed in C99 mode

 drivers/net/netvsc/hn_ethdev.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/net/netvsc/hn_ethdev.c +15 -2
index d0bbc0a4c0..a6a51088b8 100644
@@ -990,7 +990,7 @@ static int
 hn_dev_start(struct rte_eth_dev *dev)
 {
 	struct hn_data *hv = dev->data->dev_private;
-	int error;
+	int i, error;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -1017,6 +1017,11 @@ hn_dev_start(struct rte_eth_dev *dev)
 	if (error == 0)
 		hn_dev_link_update(dev, 0);
 
+	for (i = 0; i < hv->num_queues; i++) {
+		dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
+		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
+	}
+
 	return error;
 }
 
@@ -1024,13 +1029,21 @@ static int
 hn_dev_stop(struct rte_eth_dev *dev)
 {
 	struct hn_data *hv = dev->data->dev_private;
+	int i, ret;
 
 	PMD_INIT_FUNC_TRACE();
 	dev->data->dev_started = 0;
 
 	rte_dev_event_callback_unregister(NULL, netvsc_hotadd_callback, hv);
 	hn_rndis_set_rxfilter(hv, 0);
-	return hn_vf_stop(dev);
+	ret = hn_vf_stop(dev);
+
+	for (i = 0; i < hv->num_queues; i++) {
+		dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
+		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
+	return ret;
 }
 
 static int
Signature · 1 line
2.34.1