From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A8AEBA0C43; Tue, 28 Sep 2021 17:38:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F9E4410DB; Tue, 28 Sep 2021 17:38:37 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id B922A410D7 for ; Tue, 28 Sep 2021 17:38:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632843516; 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=sGUfowcC9D4h0jaqT/sQlecCjShSkGSD0w8o6JtbwTU=; b=FQcuvTOQZUvfb/F91wFsB7dYvirzb4Q2dS0Fr5FL7imZZ78jLU34PQavBNJhWIhvY+KiYw tA1mKtb9FLsEVqoJssBCcUVaeJ/y5O7XAn1s5UPahCpG3SnBMwOEjeJj39Q+UzozkaT4Bs w4Jwu/wmZOMVnANts2pfVssjyfvXE+c= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-204-CbaOhk4DM7KhFpAPwW6Prg-1; Tue, 28 Sep 2021 11:38:34 -0400 X-MC-Unique: CbaOhk4DM7KhFpAPwW6Prg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A33F28E4AA1; Tue, 28 Sep 2021 15:38:33 +0000 (UTC) Received: from [10.39.208.26] (unknown [10.39.208.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DB7BD60854; Tue, 28 Sep 2021 15:38:32 +0000 (UTC) Message-ID: <96996199-52c1-458c-0f9b-45f16ccaa249@redhat.com> Date: Tue, 28 Sep 2021 17:38:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 To: David Marchand , dev@dpdk.org Cc: Chenbo Xia References: <20210917093344.31719-1-david.marchand@redhat.com> From: Maxime Coquelin In-Reply-To: <20210917093344.31719-1-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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 Subject: Re: [dpdk-dev] [PATCH] net/virtio: fix virtio-user init when using existing tap X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 9/17/21 11:33, David Marchand wrote: > When attaching to an existing mono queue tap, the virtio-user was not > reporting that the virtio device was not properly initialised which > prevented from starting the port later. > > $ ip tuntap add test mode tap > $ dpdk-testpmd --vdev \ > net_virtio_user0,iface=test,path=/dev/vhost-net,queues=2 -- -i > > ... > virtio_user_dev_init_mac(): (/dev/vhost-net) No valid MAC in devargs or > device, use random > vhost_kernel_open_tap(): TUNSETIFF failed: Invalid argument > vhost_kernel_enable_queue_pair(): fail to open tap for vhost kernel > virtio_user_start_device(): (/dev/vhost-net) Failed to start device > ... > Configuring Port 0 (socket 0) > vhost_kernel_open_tap(): TUNSETIFF failed: Invalid argument > vhost_kernel_enable_queue_pair(): fail to open tap for vhost kernel > virtio_set_multiple_queues(): Multiqueue configured but send command > failed, this is too late now... > Fail to start port 0: Invalid argument > Please stop the ports first > Done > > The virtio-user with vhost-kernel backend was going through a lot > of complications to initialise tap fds only when using them. > > For each qp enabled for the first time, a tapfd was created via > TUNSETIFF with unneeded additional steps (see below) and then mapped to > the right qp in the vhost-net backend. > Unneeded steps (as long as it has been done once for the port): > - tap features were queried while this is a constant on a running > system, > - the device name in DPDK was updated, > - the mac address of the tap was set, > > On subsequent qps state change, the vhost-net backend fd mapping was > updated and the associated queue/tapfd were disabled/enabled via > TUNSETQUEUE. > > Now, this patch simplifies the whole logic by keeping all tapfds opened > and in enabled state (from the tap point of view) at all time. > > Unused ioctl defines are removed. > > Tap features are validated earlier to fail initialisation asap. > Tap name discovery and mac address configuration are moved when > configuring qp 0. > > To support attaching to mono queue tap, the virtio-user driver now tries > to attach in multi queue first, then fallbacks to mono queue. > > Finally (but this is more for consistency), VIRTIO_NET_F_MQ feature is > exposed only if the underlying tap supports multi queue. > > Signed-off-by: David Marchand > --- > drivers/net/virtio/virtio_user/vhost_kernel.c | 89 +++++---- > .../net/virtio/virtio_user/vhost_kernel_tap.c | 173 +++++++++--------- > .../net/virtio/virtio_user/vhost_kernel_tap.h | 16 +- > 3 files changed, 143 insertions(+), 135 deletions(-) > Applied to dpdk-next-virtio/main. Thanks, Maxime