Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp27930692rwd; Tue, 4 Jul 2023 09:52:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlFGfl2rCoXk0RsNSIYKASOn36aTW2nB2nMFHNWBg0zkzIuvSVgKT+LU4+I2iEXseKBYGQ1w X-Received: by 2002:a05:6a00:1402:b0:67a:b045:e295 with SMTP id l2-20020a056a00140200b0067ab045e295mr13152025pfu.0.1688489552291; Tue, 04 Jul 2023 09:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688489552; cv=none; d=google.com; s=arc-20160816; b=Mp+dTTJMycS9sJ5CBMQGDc8+23VkhxTA36LNFEn2YaDAErUFYqXv7maw6gAa/dFvEW vsuUT/YMrVkBkZ9rXjuvUy2u729k7vm/UgjWTnIxwxxEU5Z1XRXMC7ifbJInGxJDzHet DR8KqU/rl1wtE4QOTi26k3Gi3Ag3haYETiYjoXQb5UNAG3xed63IjHBvfoeFxpxs8Wu0 26AlQvnjIllXZXyW+bHzWOu0HH4msTAcpNJrH5A4SnC7S6oSnmk0oK3Q/uBd/IMJaczN SHj6/w9vevb9VORIDiejE+wRvUmHS9tQY0h5hPM82Dij7oFbR2iU3B+iZ+M9/r3Z4Zcm CkbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Iud4Ecey6anqNBpQug6H+pW6me9r94dCbe9UYyq8Yto=; fh=S1rZK6DPg0mAED4KjNm0cP4EEY87q6FXHFEeosELg0E=; b=o2P97DHTxMLwpMRscuw8ZA0BDFu/YJ0EjcqM3aVrCqZfu+2h4qAFJbsamuds25UBBd K0UsHUEPZs6ElwXXM7s9Kof7y3+e4Bvsoh8ZaVVu2DXBoJqhZa45Eo7MPc+/KL0ntCCz tHEjG+gacO9i+8b62AZYAipn7xbABq+fYDJX5rIqqcgr0jW8eRmgChtBjKHm//FT8BrJ 4JP90yQC3q8HqRgIGW0NI7Tvbo1c04R9UOW4qAdUhotjiDNOJF6M3aGARNzxesg0uOaj cVR1e8oqu8wZGWpyF7vFZ3FlAn6FBsntDjae+BvEvuGalgUSCtTuQHbJHztnefadwDRJ smFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MXp3KB8l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cg16-20020a056a00291000b0066879af7571si9984664pfb.130.2023.07.04.09.52.18; Tue, 04 Jul 2023 09:52:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MXp3KB8l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231776AbjGDQlu (ORCPT + 99 others); Tue, 4 Jul 2023 12:41:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231542AbjGDQlq (ORCPT ); Tue, 4 Jul 2023 12:41:46 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 826A110D9 for ; Tue, 4 Jul 2023 09:41:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688488860; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Iud4Ecey6anqNBpQug6H+pW6me9r94dCbe9UYyq8Yto=; b=MXp3KB8l18E8BbXQFopfgTr+LIe4pcjQ0+jo8Y5gNUf5TRXjKA4Ep5KFKjdUnncAEvmU8M wk95s0fNMXbmfGj03IC5ObYcNmUs17qxQHUP4rUlcsVqDh3OMGs8HarAea2csZE/jvsThL Cz+RpGe4DQ9lw8AP++tRNLFN3+MQRxY= 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-587-yND8ajmSMUih4BgGEC2E9w-1; Tue, 04 Jul 2023 12:40:57 -0400 X-MC-Unique: yND8ajmSMUih4BgGEC2E9w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A5F9E86F122; Tue, 4 Jul 2023 16:40:56 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E9E4492B02; Tue, 4 Jul 2023 16:40:54 +0000 (UTC) From: Maxime Coquelin To: xieyongji@bytedance.com, jasowang@redhat.com, mst@redhat.com, david.marchand@redhat.com, lulu@redhat.com Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, Maxime Coquelin Subject: [PATCH v2 2/3] vduse: enable Virtio-net device type Date: Tue, 4 Jul 2023 18:40:44 +0200 Message-ID: <20230704164045.39119-3-maxime.coquelin@redhat.com> In-Reply-To: <20230704164045.39119-1-maxime.coquelin@redhat.com> References: <20230704164045.39119-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds Virtio-net device type to the supported devices types. Initialization fails if the device does not support VIRTIO_F_VERSION_1 feature, in order to guarantee the configuration space is read-only. Acked-by: Jason Wang Reviewed-by: Xie Yongji Signed-off-by: Maxime Coquelin --- drivers/vdpa/vdpa_user/vduse_dev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index ff9fdd6783fe..1271c9796517 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -142,6 +142,7 @@ static struct workqueue_struct *vduse_irq_bound_wq; static u32 allowed_device_id[] = { VIRTIO_ID_BLOCK, + VIRTIO_ID_NET, }; static inline struct vduse_dev *vdpa_to_vduse(struct vdpa_device *vdpa) @@ -1672,6 +1673,10 @@ static bool features_is_valid(struct vduse_dev_config *config) (config->features & (1ULL << VIRTIO_BLK_F_CONFIG_WCE))) return false; + if ((config->device_id == VIRTIO_ID_NET) && + !(config->features & (1ULL << VIRTIO_F_VERSION_1))) + return false; + return true; } @@ -2027,6 +2032,7 @@ static const struct vdpa_mgmtdev_ops vdpa_dev_mgmtdev_ops = { static struct virtio_device_id id_table[] = { { VIRTIO_ID_BLOCK, VIRTIO_DEV_ANY_ID }, + { VIRTIO_ID_NET, VIRTIO_DEV_ANY_ID }, { 0 }, }; -- 2.41.0