net/virtio: fix incorrect avail desc id

Message ID 20211021142540.43753-1-xuan.ding@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series net/virtio: fix incorrect avail desc id |

Checks

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

Commit Message

Ding, Xuan Oct. 21, 2021, 2:25 p.m. UTC
  From: Xuan Ding <xuan.ding@intel.com>

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")
Cc: stable@dpdk.org

Signed-off-by: Xuan Ding <xuan.ding@intel.com>
Signed-off-by: Yong Liu <yong.liu@intel.com>
Signed-off-by: Miao Li <miao.li@intel.com>
---
 drivers/net/virtio/virtqueue.h | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Maxime Coquelin Oct. 21, 2021, 12:15 p.m. UTC | #1
On 10/21/21 16:25, xuan.ding@intel.com wrote:
> From: Xuan Ding <xuan.ding@intel.com>
> 
> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Xuan Ding <xuan.ding@intel.com>
> Signed-off-by: Yong Liu <yong.liu@intel.com>
> Signed-off-by: Miao Li <miao.li@intel.com>
> ---
>   drivers/net/virtio/virtqueue.h | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
> index d0c48ca415..5259a6f814 100644
> --- a/drivers/net/virtio/virtqueue.h
> +++ b/drivers/net/virtio/virtqueue.h
> @@ -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;
> 

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

Thanks,
Maxime
  
Maxime Coquelin Oct. 21, 2021, 12:35 p.m. UTC | #2
On 10/21/21 16:25, xuan.ding@intel.com wrote:
> From: Xuan Ding <xuan.ding@intel.com>
> 
> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Xuan Ding <xuan.ding@intel.com>
> Signed-off-by: Yong Liu <yong.liu@intel.com>
> Signed-off-by: Miao Li <miao.li@intel.com>
> ---
>   drivers/net/virtio/virtqueue.h | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
> index d0c48ca415..5259a6f814 100644
> --- a/drivers/net/virtio/virtqueue.h
> +++ b/drivers/net/virtio/virtqueue.h
> @@ -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
  

Patch

diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
index d0c48ca415..5259a6f814 100644
--- a/drivers/net/virtio/virtqueue.h
+++ b/drivers/net/virtio/virtqueue.h
@@ -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;