Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17580219rwd; Tue, 27 Jun 2023 05:10:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5L8ss93m5lY8+jsFG9GRE2QzmgvYTciICmQycze5gVSMwWoasXxCqD9V2b6S1wvWnxy2cv X-Received: by 2002:a92:d1c6:0:b0:345:bcd0:92c2 with SMTP id u6-20020a92d1c6000000b00345bcd092c2mr1116924ilg.8.1687867843522; Tue, 27 Jun 2023 05:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687867843; cv=none; d=google.com; s=arc-20160816; b=cnTRAJDq577q5Z+pw/tnVlx0qIGHc/SopDjkKbiyJa8ZvrsuV8u00p/Q7CSpOxsJjL x1vo3Nwu7B7/nfN8yRCCLHy7wux6idM484coy+a7ZWwcy9CNNArdmJRpNKxKLZYaiAkG TrxqHc1FOKoeWsoJhWEWKij2/l+XBL2/gMX2wbDw92sTWVRPZg9uaWjmxXBU4Hx/irWm bmfPWONwbjRnIoDVKLSU3GBaoh099gsE+XiurfwuzxzB+PyO2xWiN3Il4HuTAaTo9An2 bRZiqEFQvemdce/nLoecKFme9ZcVx3NhJQFD1Ec15meSO+U0PX1+nsjUG/n0mTz85Mzz Z7oQ== 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=M8uI9NITXhdIkfxIh/YGGZnndpIynq2QI9XP50PGOk8=; fh=S1rZK6DPg0mAED4KjNm0cP4EEY87q6FXHFEeosELg0E=; b=NwotmVmr5o6zCg6d4tk2h3pm7v6Lrw/iPyTcSLFaHwmdVm+YvK7LKID/ZkXdQRomps EL0mA4Ym6GdXGuC7qPWvQV5OIBuU/BI20QOc+j6ftgqXv1RfsD813WtuRU/95q3W/3fH nMJEL4u29tlxkQT9sPku7wsnmz6/f8cwUvl9tRd7bqZfTpEfM1RTUb4xkeSLWpT8lgDw reMs05KvM/rth18I0aK4pfbZ6sCjhSnQVU0zDmEszPukwX90RWtrToxtZhW/6hSMpvfG Fq61bFrnpKBz6IcgzXeuTbHWsW5dINOeh9mR8zqtMftNsstTBiwgELas9F4rJAFlq8o5 NwOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JuSF3Wmx; 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 c15-20020a634e0f000000b0054fdd51a9a4si7026104pgb.396.2023.06.27.05.10.31; Tue, 27 Jun 2023 05:10:43 -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=JuSF3Wmx; 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 S231182AbjF0LiM (ORCPT + 99 others); Tue, 27 Jun 2023 07:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231410AbjF0LiH (ORCPT ); Tue, 27 Jun 2023 07:38:07 -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 E62F010FC for ; Tue, 27 Jun 2023 04:37:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687865848; 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=M8uI9NITXhdIkfxIh/YGGZnndpIynq2QI9XP50PGOk8=; b=JuSF3WmxLz7lhAimun51C0IfTJZPne1q7B5fpzfgTfwrxKKBHpiVK/tupIqLo0olX2v0Xu 96Cm9mCHcc1IuRokYbeFCqs38ylBdcVqKcgf6QpQ9b3U8idUwrhW4enXlDD0RZP6feGc51 NzbpPWG/+1TmlxOkNVXXNxQWoFdnNGM= 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-605-6Rwe48HYN8aT70oaGUc4YA-1; Tue, 27 Jun 2023 07:37:24 -0400 X-MC-Unique: 6Rwe48HYN8aT70oaGUc4YA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 472F13C0FC8D; Tue, 27 Jun 2023 11:37:24 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0A63F5CD0; Tue, 27 Jun 2023 11:37:21 +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 v1 2/2] vduse: enable Virtio-net device type Date: Tue, 27 Jun 2023 13:36:52 +0200 Message-ID: <20230627113652.65283-3-maxime.coquelin@redhat.com> In-Reply-To: <20230627113652.65283-1-maxime.coquelin@redhat.com> References: <20230627113652.65283-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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. 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 c1c2f4c711ae..89088fa27026 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) @@ -1668,6 +1669,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; } @@ -2023,6 +2028,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