From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id ECDACA00C4;
	Tue, 26 Jul 2022 10:52:52 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 8C84340DDD;
	Tue, 26 Jul 2022 10:52:52 +0200 (CEST)
Received: from us-smtp-delivery-124.mimecast.com
 (us-smtp-delivery-124.mimecast.com [170.10.129.124])
 by mails.dpdk.org (Postfix) with ESMTP id 9308540695
 for <dev@dpdk.org>; Tue, 26 Jul 2022 10:52:50 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1658825570;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=KOUb6tP/XwmmnGKdnc2dykUxwphcpUdeZcNVpFcYWpY=;
 b=dSejiosPU9vJ1StS9PjmRrNngOeMcYV8UJPgGeIq1ybHz35UJYe8SHF0qT1n5jHDoZl6LV
 SXkXiYzBSxe9UjeXXm2mkea4tpk8OrM53WVzZc8cUBKjR0pavGR+XZPqqXNVNSgdFsrpvh
 4wo8NPRRVuNHnIztGlW6z8pApUSCh98=
Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com
 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS
 (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 us-mta-551-oBihrEteN86Tx1lYe1qEpg-1; Tue, 26 Jul 2022 04:52:46 -0400
X-MC-Unique: oBihrEteN86Tx1lYe1qEpg-1
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com
 [10.11.54.2])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 848472803027;
 Tue, 26 Jul 2022 08:52:46 +0000 (UTC)
Received: from [10.39.208.26] (unknown [10.39.208.26])
 by smtp.corp.redhat.com (Postfix) with ESMTPS id C69AB403D0CA;
 Tue, 26 Jul 2022 08:52:45 +0000 (UTC)
Message-ID: <4cd4f7bf-da0d-5ddd-9783-afd7c1b1a3fc@redhat.com>
Date: Tue, 26 Jul 2022 10:52:44 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.11.0
Subject: Re: [PATCH v3 3/4] vhost: keep a reference to virtqueue index
To: David Marchand <david.marchand@redhat.com>, dev@dpdk.org
Cc: Chenbo Xia <chenbo.xia@intel.com>
References: <20220722135320.109269-1-david.marchand@redhat.com>
 <20220725203206.427083-1-david.marchand@redhat.com>
 <20220725203206.427083-4-david.marchand@redhat.com>
From: Maxime Coquelin <maxime.coquelin@redhat.com>
In-Reply-To: <20220725203206.427083-4-david.marchand@redhat.com>
X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2
Authentication-Results: relay.mimecast.com;
 auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Language: en-US
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org



On 7/25/22 22:32, David Marchand wrote:
> Having a back reference to the index of the vq in the dev->virtqueue[]
> array makes it possible to unify the internal API, with only passing dev
> and vq.
> It also allows displaying the vq index in log messages.
> 
> Remove virtqueue index checks where unneeded (like in static helpers
> called from a loop on all available virtqueue).
> Move virtqueue index validity checks the sooner possible.
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> Changes since v2:
> - rebased on top of cleanup that avoids some use-after-free issues in
>    case of allocation failures or numa realloactions,
> 
> Changes since v1:
> - fix vq init (that's what happens when only recompiling the vhost
>    library and not relinking testpmd...),
> 
> ---
>   lib/vhost/iotlb.c      |  5 +--
>   lib/vhost/iotlb.h      |  2 +-
>   lib/vhost/vhost.c      | 72 +++++++++++++----------------------
>   lib/vhost/vhost.h      |  3 ++
>   lib/vhost/vhost_user.c | 46 +++++++++++-----------
>   lib/vhost/virtio_net.c | 86 +++++++++++++++++++-----------------------
>   6 files changed, 91 insertions(+), 123 deletions(-)
> 

...

> diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
> index 35fa4670fd..467dfb203f 100644
> --- a/lib/vhost/virtio_net.c
> +++ b/lib/vhost/virtio_net.c

...

> @@ -2275,12 +2267,11 @@ rte_vhost_clear_queue(int vid, uint16_t queue_id, struct rte_mbuf **pkts,
>   	}
>   
>   	if ((queue_id & 1) == 0)
> -		n_pkts_cpl = vhost_poll_enqueue_completed(dev, queue_id,
> -				pkts, count, dma_id, vchan_id);
> -	else {
> +		n_pkts_cpl = vhost_poll_enqueue_completed(dev, vq, pkts, count,
> +			dma_id, vchan_id);
> +	else
>   		n_pkts_cpl = async_poll_dequeue_completed(dev, vq, pkts, count,
> -					dma_id, vchan_id, dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS);
> -	}
> +			dma_id, vchan_id, dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS);

One of the two functions should be renamed for consistency, but that's
not the point of this series.

For this patch:

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

Thanks,
Maxime