Skip to contentSkip to conversation

net/virtio: fix incorrect slots number when indirect feature on

PATCH Applied Marvin Liu 2 participants 3 messages Jan 20, 2022 – Feb 8, 2022 Network drivers

lore
Share & tools
lore

Marvin Liu

author
#0 lore raw

PATCH 1/1 net/virtio: fix incorrect slots number when indirect feature on

Virtio driver only occupies one slot for enqueuing chained mbufs when indirect feature is on. Required slots calculation should depend on indirect feature status at the end.

Fixes 0eaf7fc2fe8e ("net/virtio: separate AVX Rx/Tx")
drivers/net/virtio/virtio_rxtx_packed.h +1 -2
index d5c259a1f6..536112983c 100644
@@ -125,13 +125,12 @@ virtqueue_enqueue_single_packed_vec(struct virtnet_tx *txvq,
 	 * any_layout => number of segments
 	 * default    => number of segments + 1
 	 */
-	slots = use_indirect ? 1 : (txm->nb_segs + !can_push);
 	can_push = rte_mbuf_refcnt_read(txm) == 1 &&
 		   RTE_MBUF_DIRECT(txm) &&
 		   txm->nb_segs == 1 &&
 		   rte_pktmbuf_headroom(txm) >= hdr_size;
 
-	slots = txm->nb_segs + !can_push;
+	slots = use_indirect ? 1 : (txm->nb_segs + !can_push);
 	need = slots - vq->vq_free_cnt;
 
 	/* Positive value indicates it need free vring descriptors */
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Marvin Liu

Virtio driver only occupies one slot for enqueuing chained mbufs when indirect feature is on. Required slots calculation should depend on indirect feature status at the end.

Fixes 0eaf7fc2fe8e ("net/virtio: separate AVX Rx/Tx")
drivers/net/virtio/virtio_rxtx_packed.h +0 -1
index d5c259a1f6..536112983c 100644
@@ -125,13 +125,12 @@ virtqueue_enqueue_single_packed_vec(struct virtnet_tx *txvq,
  	 * any_layout => number of segments
  	 * default    => number of segments + 1
  	 */
-	slots = use_indirect ? 1 : (txm->nb_segs + !can_push);

drivers/net/virtio/virtio_rxtx_packed.h virtqueue_enqueue_single_packed_vec(struct virtnet_tx *txvq, · line 136

Quoted 10 lines
drivers/net/virtio/virtio_rxtx_packed.h +1 -1
  	can_push = rte_mbuf_refcnt_read(txm) == 1 &&
  		   RTE_MBUF_DIRECT(txm) &&
  		   txm->nb_segs == 1 &&
  		   rte_pktmbuf_headroom(txm) >= hdr_size;
 
-	slots = txm->nb_segs + !can_push;
+	slots = use_indirect ? 1 : (txm->nb_segs + !can_push);
  	need = slots - vq->vq_free_cnt;
 
  	/* Positive value indicates it need free vring descriptors */

Thanks,
Maxime

#2 lore raw
In reply to Marvin Liu
Quoted 18 lines · Marvin Liu

Virtio driver only occupies one slot for enqueuing chained mbufs when indirect feature is on. Required slots calculation should depend on indirect feature status at the end.

Fixes 0eaf7fc2fe8e ("net/virtio: separate AVX Rx/Tx")
drivers/net/virtio/virtio_rxtx_packed.h +0 -1
index d5c259a1f6..536112983c 100644
@@ -125,13 +125,12 @@ virtqueue_enqueue_single_packed_vec(struct virtnet_tx *txvq,
  	 * any_layout => number of segments
  	 * default    => number of segments + 1
  	 */
-	slots = use_indirect ? 1 : (txm->nb_segs + !can_push);

drivers/net/virtio/virtio_rxtx_packed.h virtqueue_enqueue_single_packed_vec(struct virtnet_tx *txvq, · line 136

Quoted 10 lines
drivers/net/virtio/virtio_rxtx_packed.h +1 -1
  	can_push = rte_mbuf_refcnt_read(txm) == 1 &&
  		   RTE_MBUF_DIRECT(txm) &&
  		   txm->nb_segs == 1 &&
  		   rte_pktmbuf_headroom(txm) >= hdr_size;
 
-	slots = txm->nb_segs + !can_push;
+	slots = use_indirect ? 1 : (txm->nb_segs + !can_push);
  	need = slots - vq->vq_free_cnt;
 
  	/* Positive value indicates it need free vring descriptors */

Applied to dpdk-next-virtio/main.

Thanks,
Maxime