Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28823518rwd; Wed, 5 Jul 2023 03:19:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlEisFUtkqpKGDzoghcXYHwMXsV/PQ8WbqCECY8Tnzk9DHYJ92UJqXhln1KGL093GjFXkiVZ X-Received: by 2002:a05:6359:617:b0:133:ec3:1079 with SMTP id eh23-20020a056359061700b001330ec31079mr11437917rwb.10.1688552350446; Wed, 05 Jul 2023 03:19:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688552350; cv=none; d=google.com; s=arc-20160816; b=EYFRz7KnGJbSFQNGdiy9rlec7FIBhSjwI5dFUJG/8HpvRyS7DLves1OgWdmcMISIh8 AqZmUfGqrWK+G/ck67+OZLsg9SifCMufESun9RSIYHtz7UoKroaIcz4wCW2qOVPMHfpv jeNai1aXR1U6q+RDUN/1YO7y3r/KKLqPYRRLHzopgmj0g+haUTxHBKAGVRwgmi0jO7lr Sn1iOFXm76dsOEJrAk3iwl14AaI3ruPdAmDnJrk26sSp7fWL1SJuS9evguoX3W4XcyJr 64W7qeBMzW4to4XsPI0DK1B+hwVhBbF+Q/ls4fLCT+9gVR0UP2/O5wabi3e8+86eF1dn nRBg== 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=NIsO39jKX7ffxFH62zh66XsC1ev6Ag4yFY+Ngvoj31TD9c9ibBrUrmrFZtsooV3fZF NIXzRZs8Tcc+Jbrqz/J/J1YnEpLK3xw2rird0QsXfazYrIBe5jnsPDAjLLE3oTlNATYY 6YA4BBQHXxjQ8M+VP25+3j+DBLTYjKgNUM16lmZKuHC0PTxELD1zjP8Pc+wsdEAO+8lv LybxmmjfwBhF+jBNXCHY1NhomZ+GmJwm01QKcNcnIvI+s1wZkV8WbuQLGP4a/gj+DKtu 2BaWvmY8YxSixdbS9Ttz0cMxZ/wCG3YUVQMk1waymHWjJvEQL3P4AJNoVhiv56OxycIY Hk7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B8AXedT2; 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 w22-20020aa78596000000b0066ce96ce70csi20378680pfn.122.2023.07.05.03.18.56; Wed, 05 Jul 2023 03:19:10 -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=B8AXedT2; 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 S232035AbjGEKFg (ORCPT + 99 others); Wed, 5 Jul 2023 06:05:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231661AbjGEKFc (ORCPT ); Wed, 5 Jul 2023 06:05:32 -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 44B8F171C for ; Wed, 5 Jul 2023 03:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688551483; 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=B8AXedT2FhAn9fTu4danjXDYDK8/nU+Ww7maoB+f4r+KBiderbs/1EqqP0VeNeiRclCnrk KQYd4ZOglhWedmt1cd2y2ZTORdWQFRoRt19pYoKknWIUhDJWOrQvuwDZ2GKSHelVkFGkA2 dJj4lfSMpti1uRudEA3mwuec+BW7O7A= 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-587-gWa3ah60PhGhuzMFrxk5RQ-1; Wed, 05 Jul 2023 06:04:40 -0400 X-MC-Unique: gWa3ah60PhGhuzMFrxk5RQ-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 3A45F2A5957D; Wed, 5 Jul 2023 10:04:40 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BE904021523; Wed, 5 Jul 2023 10:04:37 +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 v3 2/3] vduse: enable Virtio-net device type Date: Wed, 5 Jul 2023 12:04:29 +0200 Message-ID: <20230705100430.61927-3-maxime.coquelin@redhat.com> In-Reply-To: <20230705100430.61927-1-maxime.coquelin@redhat.com> References: <20230705100430.61927-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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