Skip to contentSkip to conversation

virtio-net: unbreak vq resizing if vq coalescing is not supported

PATCH In review Heng Qi 2 participants 4 messages Aug 1, 2024 – Aug 2, 2024

Subsystems (4)
lore
Share & tools
lore

Heng Qi

author
#0 lore raw

v4 cover virtio-net: unbreak vq resizing if vq coalescing is not supported

Currently, if the driver does not negotiate the vq coalescing feature but supports vq resize, the vq resize action, which could have been successfully executed, is interrupted due to the failure in configuring the vq coalescing parameters. This issue needs to be fixed.

Changelog
=========
v3->v4:
- Add a comment for patch[2/2].

v2->v3:
- Break out the feature check and the fix into separate patches.

v1->v2:
- Rephrase the subject.
- Put the feature check inside the virtnet_send_{r,t}x_ctrl_coal_vq_cmd.

Heng Qi (2):
virtio-net: check feature before configuring the vq coalescing command
virtio-net: unbreak vq resizing when coalescing is not negotiated

 drivers/net/virtio_net.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
Signature · 1 line
2.32.0.3.g01195cf9f
author
#1 lore raw

PATCH v4 1/2 virtio-net: check feature before configuring the vq coalescing command

Virtio spec says:

The driver MUST have negotiated the VIRTIO_NET_F_VQ_NOTF_COAL feature when issuing commands VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET and VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET.

So we add the feature negotiation check to virtnet_send_{r,t}x_ctrl_coal_vq_cmd as a basis for the next bugfix patch.

---
v2->v3:
- Break out the feature check and the fix into separate patches.

 drivers/net/virtio_net.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/virtio_net.c +6 -0
index 0383a3e136d6..b1176be8fcfd 100644
@@ -3658,6 +3658,9 @@ static int virtnet_send_rx_ctrl_coal_vq_cmd(struct virtnet_info *vi,
 {
 	int err;
 
+	if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_VQ_NOTF_COAL))
+		return -EOPNOTSUPP;
+
 	err = virtnet_send_ctrl_coal_vq_cmd(vi, rxq2vq(queue),
 					    max_usecs, max_packets);
 	if (err)
@@ -3675,6 +3678,9 @@ static int virtnet_send_tx_ctrl_coal_vq_cmd(struct virtnet_info *vi,
 {
 	int err;
 
+	if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_VQ_NOTF_COAL))
+		return -EOPNOTSUPP;
+
 	err = virtnet_send_ctrl_coal_vq_cmd(vi, txq2vq(queue),
 					    max_usecs, max_packets);
 	if (err)
Signature · 1 line
2.32.0.3.g01195cf9f
Acked-by on v4 1/2
#2 lore raw

Re: [PATCH net v4 1/2] virtio-net: check feature before configuring the vq coalescing command

Quoted 7 lines · Heng Qi

Virtio spec says:

The driver MUST have negotiated the VIRTIO_NET_F_VQ_NOTF_COAL feature when issuing commands VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET and VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET.

Quoted 6 lines

So we add the feature negotiation check to virtnet_send_{r,t}x_ctrl_coal_vq_cmd as a basis for the next bugfix patch.

---

Thanks

author
#3 lore raw

PATCH v4 2/2 virtio-net: unbreak vq resizing when coalescing is not negotiated

In reply to Heng Qi

Don't break the resize action if the vq coalescing feature named VIRTIO_NET_F_VQ_NOTF_COAL is not negotiated.

Fixes f61fe5f081cf ("virtio-net: fix the vq coalescing setting for vq resize")

---
v3->v4:
- Add a comment.

v2->v3:
- Break out the feature check and the fix into separate patches.

v1->v2:
- Rephrase the subject.
- Put the feature check inside the virtnet_send_{r,t}x_ctrl_coal_vq_cmd().

 drivers/net/virtio_net.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/virtio_net.c +6 -2
index b1176be8fcfd..3f10c72743e9 100644
@@ -3749,7 +3749,11 @@ static int virtnet_set_ringparam(struct net_device *dev,
 			err = virtnet_send_tx_ctrl_coal_vq_cmd(vi, i,
 							       vi->intr_coal_tx.max_usecs,
 							       vi->intr_coal_tx.max_packets);
-			if (err)
+
+			/* Don't break the tx resize action if the vq coalescing is not
+			 * supported. The same is true for rx resize below.
+			 */
+			if (err && err != -EOPNOTSUPP)
 				return err;
 		}
 
@@ -3764,7 +3768,7 @@ static int virtnet_set_ringparam(struct net_device *dev,
 							       vi->intr_coal_rx.max_usecs,
 							       vi->intr_coal_rx.max_packets);
 			mutex_unlock(&vi->rq[i].dim_lock);
-			if (err)
+			if (err && err != -EOPNOTSUPP)
 				return err;
 		}
 	}
Signature · 1 line
2.32.0.3.g01195cf9f