[PATCH v1 13/21] net/virtio-user: simplify queues setup

Xia, Chenbo chenbo.xia at intel.com
Tue Jan 31 06:21:10 CET 2023


> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin at redhat.com>
> Sent: Wednesday, November 30, 2022 11:57 PM
> To: dev at dpdk.org; Xia, Chenbo <chenbo.xia at intel.com>;
> david.marchand at redhat.com; eperezma at redhat.com
> Cc: Maxime Coquelin <maxime.coquelin at redhat.com>
> Subject: [PATCH v1 13/21] net/virtio-user: simplify queues setup
> 
> The only reason two loops were needed to iterate over
> queues at setup time was to be able to print whether it
> was a Tx or Rx queue.
> 
> This patch changes queues iteration to a single loop.
> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
> ---
>  drivers/net/virtio/virtio_user/virtio_user_dev.c | 16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index 19599aa3f6..873c6aa036 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -118,19 +118,11 @@ static int
>  virtio_user_queue_setup(struct virtio_user_dev *dev,
>  			int (*fn)(struct virtio_user_dev *, uint32_t))
>  {
> -	uint32_t i, queue_sel;
> +	uint32_t i;
> 
> -	for (i = 0; i < dev->max_queue_pairs; ++i) {
> -		queue_sel = 2 * i + VTNET_SQ_RQ_QUEUE_IDX;
> -		if (fn(dev, queue_sel) < 0) {
> -			PMD_DRV_LOG(ERR, "(%s) setup rx vq %u failed", dev->path,
> i);
> -			return -1;
> -		}
> -	}
> -	for (i = 0; i < dev->max_queue_pairs; ++i) {
> -		queue_sel = 2 * i + VTNET_SQ_TQ_QUEUE_IDX;
> -		if (fn(dev, queue_sel) < 0) {
> -			PMD_DRV_LOG(INFO, "(%s) setup tx vq %u failed", dev-
> >path, i);
> +	for (i = 0; i < dev->max_queue_pairs * 2; ++i) {
> +		if (fn(dev, i) < 0) {
> +			PMD_DRV_LOG(ERR, "(%s) setup VQ %u failed", dev->path,
> i);
>  			return -1;
>  		}
>  	}
> --
> 2.38.1

Reviewed-by: Chenbo Xia <chenbo.xia at intel.com> 


More information about the dev mailing list