Skip to contentSkip to conversation

net/virtio: fix incorrect avail desc id

PATCH Applied [email protected] 2 participants 3 messages Oct 21, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/virtio: fix incorrect avail desc id

From: Xuan Ding <[email protected]>

Vhost will update desc’s Buffer ID advance to next used descriptor when VIRTIO_F_IN_ORDER feature negotiated. When virtio reuses the descriptor, the Buffer ID should be restored even VIRTQ_DESC_F_INDIRECT feature negotiated.

Fixes b473061b0e1d ("net/virtio: fix indirect descriptors in packed datapaths")
---
 drivers/net/virtio/virtqueue.h | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/virtio/virtqueue.h +3 -0
index d0c48ca415..5259a6f814 100644
@@ -709,6 +709,9 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie,
 			RTE_PTR_DIFF(&txr[idx].tx_packed_indir, txr);
 		start_dp[idx].len   = (seg_num + 1) *
 			sizeof(struct vring_packed_desc);
+		/* Packed descriptor id needs to be restored when inorder. */
+		if (in_order)
+			start_dp[idx].id = idx;
 		/* reset flags for indirect desc */
 		head_flags = VRING_DESC_F_INDIRECT;
 		head_flags |= vq->vq_packed.cached_flags;
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · On 10/21/21 16:25, [email protected] wrote:

From: Xuan Ding <[email protected]>

Vhost will update desc’s Buffer ID advance to next used descriptor when VIRTIO_F_IN_ORDER feature negotiated. When virtio reuses the descriptor, the Buffer ID should be restored even VIRTQ_DESC_F_INDIRECT feature negotiated.

Fixes b473061b0e1d ("net/virtio: fix indirect descriptors in packed datapaths")
---
  drivers/net/virtio/virtqueue.h | 3 +++
  1 file changed, 3 insertions(+)
drivers/net/virtio/virtqueue.h +0 -0
index d0c48ca415..5259a6f814 100644

drivers/net/virtio/virtqueue.h virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie, · line 717

Quoted 9 lines
drivers/net/virtio/virtqueue.h +3 -0
@@ -709,6 +709,9 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie,
  			RTE_PTR_DIFF(&txr[idx].tx_packed_indir, txr);
  		start_dp[idx].len   = (seg_num + 1) *
  			sizeof(struct vring_packed_desc);
+		/* Packed descriptor id needs to be restored when inorder. */
+		if (in_order)
+			start_dp[idx].id = idx;
  		/* reset flags for indirect desc */
  		head_flags = VRING_DESC_F_INDIRECT;
  		head_flags |= vq->vq_packed.cached_flags;

Thanks,
Maxime

#2 lore raw
In reply to [email protected]
Quoted 23 lines · On 10/21/21 16:25, [email protected] wrote:

From: Xuan Ding <[email protected]>

Vhost will update desc’s Buffer ID advance to next used descriptor when VIRTIO_F_IN_ORDER feature negotiated. When virtio reuses the descriptor, the Buffer ID should be restored even VIRTQ_DESC_F_INDIRECT feature negotiated.

Fixes b473061b0e1d ("net/virtio: fix indirect descriptors in packed datapaths")
---
  drivers/net/virtio/virtqueue.h | 3 +++
  1 file changed, 3 insertions(+)
drivers/net/virtio/virtqueue.h +0 -0
index d0c48ca415..5259a6f814 100644

drivers/net/virtio/virtqueue.h virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie, · line 717

Quoted 9 lines
drivers/net/virtio/virtqueue.h +3 -0
@@ -709,6 +709,9 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie,
  			RTE_PTR_DIFF(&txr[idx].tx_packed_indir, txr);
  		start_dp[idx].len   = (seg_num + 1) *
  			sizeof(struct vring_packed_desc);
+		/* Packed descriptor id needs to be restored when inorder. */
+		if (in_order)
+			start_dp[idx].id = idx;
  		/* reset flags for indirect desc */
  		head_flags = VRING_DESC_F_INDIRECT;
  		head_flags |= vq->vq_packed.cached_flags;

Applied to dpdk-next-virtio/main.

Thanks,
Maxime