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

Message ID 20220120122218.25027-1-yong.liu@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series net/virtio: fix incorrect slots number when indirect feature on |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance fail Performance Testing issues
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Marvin Liu Jan. 20, 2022, 12:22 p.m. UTC
  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")
Cc: stable@dpdk.org

Signed-off-by: Marvin Liu <yong.liu@intel.com>
  

Comments

Maxime Coquelin Feb. 1, 2022, 8:53 a.m. UTC | #1
On 1/20/22 13:22, Marvin Liu wrote:
> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Marvin Liu <yong.liu@intel.com>
> 
> diff --git a/drivers/net/virtio/virtio_rxtx_packed.h b/drivers/net/virtio/virtio_rxtx_packed.h
> index d5c259a1f6..536112983c 100644
> --- a/drivers/net/virtio/virtio_rxtx_packed.h
> +++ b/drivers/net/virtio/virtio_rxtx_packed.h
> @@ -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 */

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  
Maxime Coquelin Feb. 8, 2022, 11:11 a.m. UTC | #2
On 1/20/22 13:22, Marvin Liu wrote:
> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Marvin Liu <yong.liu@intel.com>
> 
> diff --git a/drivers/net/virtio/virtio_rxtx_packed.h b/drivers/net/virtio/virtio_rxtx_packed.h
> index d5c259a1f6..536112983c 100644
> --- a/drivers/net/virtio/virtio_rxtx_packed.h
> +++ b/drivers/net/virtio/virtio_rxtx_packed.h
> @@ -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 */

Applied to dpdk-next-virtio/main.

Thanks,
Maxime
  

Patch

diff --git a/drivers/net/virtio/virtio_rxtx_packed.h b/drivers/net/virtio/virtio_rxtx_packed.h
index d5c259a1f6..536112983c 100644
--- a/drivers/net/virtio/virtio_rxtx_packed.h
+++ b/drivers/net/virtio/virtio_rxtx_packed.h
@@ -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 */