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 9F71642DD8; Wed, 5 Jul 2023 15:22:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3F85B406B5; Wed, 5 Jul 2023 15:22:42 +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 4977A4021F for ; Wed, 5 Jul 2023 15:22:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688563359; 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=IXoOiT9agfgLT6QgT2X+gAHowf1gljqWHFsvk0PxfcU=; b=FtB8GwlkYynm6ErsU6GbnslOAx1uWb5UBDQVJa5JtzLnO+o+6AR4fBgbJHZZOQCHMqZW7V yfNxfDJOAP8Cg5mUjsRT1XFtm6AOxKoN0TWQB5wOfFqIEWgZezr0wA0IlrdTROlzqaIaWm b1rMV98PPej27cttSVZoR/3mv32j9I4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-493-Z9dDDX_1PjewB95i55JY8g-1; Wed, 05 Jul 2023 09:22:38 -0400 X-MC-Unique: Z9dDDX_1PjewB95i55JY8g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 46B85185A792; Wed, 5 Jul 2023 13:22:38 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47C0E40C2063; Wed, 5 Jul 2023 13:22:37 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, david.marchand@redhat.com Cc: Maxime Coquelin Subject: [PATCH 1/2] vhost: fix vduse features negotiation Date: Wed, 5 Jul 2023 15:22:31 +0200 Message-ID: <20230705132232.114266-2-maxime.coquelin@redhat.com> In-Reply-To: <20230705132232.114266-1-maxime.coquelin@redhat.com> References: <20230705132232.114266-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 The series introducing VDUSE support missed the application capability to disable supported features. This results in TSO being negotiated while not supported by the application. Fixes: 0adb8eccc6a6 ("vhost: add VDUSE device creation and destruction") Signed-off-by: Maxime Coquelin --- lib/vhost/socket.c | 19 +++++++++++++------ lib/vhost/vduse.c | 28 +++++++--------------------- lib/vhost/vduse.h | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c index 19a7469e45..a65d301406 100644 --- a/lib/vhost/socket.c +++ b/lib/vhost/socket.c @@ -921,6 +921,10 @@ rte_vhost_driver_register(const char *path, uint64_t flags) VHOST_LOG_CONFIG(path, ERR, "failed to init connection mutex\n"); goto out_free; } + + if (!strncmp("/dev/vduse/", path, strlen("/dev/vduse/"))) + vsocket->is_vduse = true; + vsocket->vdpa_dev = NULL; vsocket->max_queue_pairs = VHOST_MAX_QUEUE_PAIRS; vsocket->extbuf = flags & RTE_VHOST_USER_EXTBUF_SUPPORT; @@ -950,9 +954,14 @@ rte_vhost_driver_register(const char *path, uint64_t flags) * two values. */ vsocket->use_builtin_virtio_net = true; - vsocket->supported_features = VIRTIO_NET_SUPPORTED_FEATURES; - vsocket->features = VIRTIO_NET_SUPPORTED_FEATURES; - vsocket->protocol_features = VHOST_USER_PROTOCOL_FEATURES; + if (vsocket->is_vduse) { + vsocket->supported_features = VDUSE_NET_SUPPORTED_FEATURES; + vsocket->features = VDUSE_NET_SUPPORTED_FEATURES; + } else { + vsocket->supported_features = VIRTIO_NET_SUPPORTED_FEATURES; + vsocket->features = VIRTIO_NET_SUPPORTED_FEATURES; + vsocket->protocol_features = VHOST_USER_PROTOCOL_FEATURES; + } if (vsocket->async_copy) { vsocket->supported_features &= ~(1ULL << VHOST_F_LOG_ALL); @@ -993,9 +1002,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags) #endif } - if (!strncmp("/dev/vduse/", path, strlen("/dev/vduse/"))) { - vsocket->is_vduse = true; - } else { + if (!vsocket->is_vduse) { if ((flags & RTE_VHOST_USER_CLIENT) != 0) { vsocket->reconnect = !(flags & RTE_VHOST_USER_NO_RECONNECT); if (vsocket->reconnect && reconn_tid == 0) { diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c index a509daf80c..1478562be1 100644 --- a/lib/vhost/vduse.c +++ b/lib/vhost/vduse.c @@ -26,26 +26,6 @@ #define VHOST_VDUSE_API_VERSION 0 #define VDUSE_CTRL_PATH "/dev/vduse/control" -#define VDUSE_NET_SUPPORTED_FEATURES ((1ULL << VIRTIO_NET_F_MRG_RXBUF) | \ - (1ULL << VIRTIO_F_ANY_LAYOUT) | \ - (1ULL << VIRTIO_F_VERSION_1) | \ - (1ULL << VIRTIO_NET_F_GSO) | \ - (1ULL << VIRTIO_NET_F_HOST_TSO4) | \ - (1ULL << VIRTIO_NET_F_HOST_TSO6) | \ - (1ULL << VIRTIO_NET_F_HOST_UFO) | \ - (1ULL << VIRTIO_NET_F_HOST_ECN) | \ - (1ULL << VIRTIO_NET_F_CSUM) | \ - (1ULL << VIRTIO_NET_F_GUEST_CSUM) | \ - (1ULL << VIRTIO_NET_F_GUEST_TSO4) | \ - (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \ - (1ULL << VIRTIO_NET_F_GUEST_UFO) | \ - (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ - (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \ - (1ULL << VIRTIO_F_IN_ORDER) | \ - (1ULL << VIRTIO_F_IOMMU_PLATFORM) | \ - (1ULL << VIRTIO_NET_F_CTRL_VQ) | \ - (1ULL << VIRTIO_NET_F_MQ)) - struct vduse { struct fdset fdset; }; @@ -440,7 +420,7 @@ vduse_device_create(const char *path) struct virtio_net *dev; struct virtio_net_config vnet_config = { 0 }; uint64_t ver = VHOST_VDUSE_API_VERSION; - uint64_t features = VDUSE_NET_SUPPORTED_FEATURES; + uint64_t features; struct vduse_dev_config *dev_config = NULL; const char *name = path + strlen("/dev/vduse/"); @@ -488,6 +468,12 @@ vduse_device_create(const char *path) goto out_ctrl_close; } + ret = rte_vhost_driver_get_features(path, &features); + if (ret < 0) { + VHOST_LOG_CONFIG(name, ERR, "Failed to get backend features\n"); + goto out_free; + } + ret = rte_vhost_driver_get_queue_num(path, &max_queue_pairs); if (ret < 0) { VHOST_LOG_CONFIG(name, ERR, "Failed to get max queue pairs\n"); diff --git a/lib/vhost/vduse.h b/lib/vhost/vduse.h index a15e5d4c16..cd55bfd858 100644 --- a/lib/vhost/vduse.h +++ b/lib/vhost/vduse.h @@ -7,6 +7,26 @@ #include "vhost.h" +#define VDUSE_NET_SUPPORTED_FEATURES ((1ULL << VIRTIO_NET_F_MRG_RXBUF) | \ + (1ULL << VIRTIO_F_ANY_LAYOUT) | \ + (1ULL << VIRTIO_F_VERSION_1) | \ + (1ULL << VIRTIO_NET_F_GSO) | \ + (1ULL << VIRTIO_NET_F_HOST_TSO4) | \ + (1ULL << VIRTIO_NET_F_HOST_TSO6) | \ + (1ULL << VIRTIO_NET_F_HOST_UFO) | \ + (1ULL << VIRTIO_NET_F_HOST_ECN) | \ + (1ULL << VIRTIO_NET_F_CSUM) | \ + (1ULL << VIRTIO_NET_F_GUEST_CSUM) | \ + (1ULL << VIRTIO_NET_F_GUEST_TSO4) | \ + (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \ + (1ULL << VIRTIO_NET_F_GUEST_UFO) | \ + (1ULL << VIRTIO_NET_F_GUEST_ECN) | \ + (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \ + (1ULL << VIRTIO_F_IN_ORDER) | \ + (1ULL << VIRTIO_F_IOMMU_PLATFORM) | \ + (1ULL << VIRTIO_NET_F_CTRL_VQ) | \ + (1ULL << VIRTIO_NET_F_MQ)) + #ifdef VHOST_HAS_VDUSE int vduse_device_create(const char *path); -- 2.41.0