Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1313660ybv; Thu, 13 Feb 2020 20:40:33 -0800 (PST) X-Google-Smtp-Source: APXvYqwT8i4UuLIlsDQtBUt3TMBeIPOWcXVr603g21ihI44CLNFxAX5CzcaM61LnBBq0EHclsQxr X-Received: by 2002:aca:3f43:: with SMTP id m64mr622256oia.165.1581655233655; Thu, 13 Feb 2020 20:40:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581655233; cv=none; d=google.com; s=arc-20160816; b=KouLVv5AKMD6aJlA1qIZAt+zwzrq6xsbxfdfBqHWSffzSJlwpNJjN/+OVzrh4Ne2zV MeGyqBF4njUCC12i31NvCriFL0wYVAIWr+2UzWz0DYt5MI0ssGdR8uSYi+BEgevLemjr ypoCAshwb0AeHDLoh08UaTxFpFSc8Uwi2toyRKGqNlLIO8+3f7DprSKZzFeWviFI+68u RLNDi91AHmXx5AXhrIvxZrvC75U0PW5tIv8RBNZxj7fE3jLtGHaE8cXupxRo9tfP7ER+ QA/n4DpaeP7eK4ei69uP4AsNdRERWNuDbho0AmrcXVFGlWYtqS4sTXzdeDHPxU4bSJ43 6YRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=x3yOWLF6bcHCCuN6HWm7zeGRKO0RfJCz2+K5iNwYZJc=; b=DrsJLnuIdj+EUHBTFMxf8/TqqWcG+dEx0l9tTbvTY6YWRJwxY347jvNEdGZFLFxaPp 9fTynlE+kDeIjTg4mdNJ7HT/E+EPjwtgOEIFoakXfmvwH5B4JF4yQ7BpPMh/thwze4v7 0wr+o/LZxhhjg+xaWrNUaS72x6vIs4IwvrqMZorY3dXRHgFz4oWaoOchLxI6Sv7OaWC/ eaYyp5laFSn7Oaxs2ENyTQY/2iEGDy6T7AN/9vwndKjpkGWL19wEBiddyHKXz7XhT/ER uL4L6HJr3HfHM995WadTqtCbbxHCtwxdtzSSj2TzoWX2xynavL2XSGhuTpSJufN/0u2N S1IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z+oxFQ6F; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c5si2147947otp.108.2020.02.13.20.40.20; Thu, 13 Feb 2020 20:40:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z+oxFQ6F; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728718AbgBNEkQ (ORCPT + 99 others); Thu, 13 Feb 2020 23:40:16 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:30220 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728610AbgBNEkP (ORCPT ); Thu, 13 Feb 2020 23:40:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581655214; 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=x3yOWLF6bcHCCuN6HWm7zeGRKO0RfJCz2+K5iNwYZJc=; b=Z+oxFQ6FiIGWjS4ZsRD9RNgGuHUCuR9dwgc4qnVmBVXWlSxGqgEBwA3jqW14VZ5hRxR6Y1 IBYG2uFWjH0mi7rQCBTojboH/CiamevXpScdlFKkbXSpsPialqo/CU4VOA8A2EojR7C54E 4sD9aY9L0zT58Hqs2FyEM/SRxLp3MOU= 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-254-o4poq0lXOLKmZXu4jaC7VQ-1; Thu, 13 Feb 2020 23:40:13 -0500 X-MC-Unique: o4poq0lXOLKmZXu4jaC7VQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AFBC81851FC6; Fri, 14 Feb 2020 04:40:10 +0000 (UTC) Received: from [10.72.13.213] (ovpn-13-213.pek2.redhat.com [10.72.13.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB4B68AC40; Fri, 14 Feb 2020 04:39:49 +0000 (UTC) Subject: Re: [PATCH V2 3/5] vDPA: introduce vDPA bus To: Jason Gunthorpe , "Michael S. Tsirkin" Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, tiwei.bie@intel.com, maxime.coquelin@redhat.com, cunming.liang@intel.com, zhihong.wang@intel.com, rob.miller@broadcom.com, xiao.w.wang@intel.com, haotian.wang@sifive.com, lingshan.zhu@intel.com, eperezma@redhat.com, lulu@redhat.com, parav@mellanox.com, kevin.tian@intel.com, stefanha@redhat.com, rdunlap@infradead.org, hch@infradead.org, aadam@redhat.com, jiri@mellanox.com, shahafs@mellanox.com, hanand@xilinx.com, mhabets@solarflare.com References: <20200211134746.GI4271@mellanox.com> <20200212125108.GS4271@mellanox.com> <12775659-1589-39e4-e344-b7a2c792b0f3@redhat.com> <20200213134128.GV4271@mellanox.com> <20200213150542.GW4271@mellanox.com> <20200213103714-mutt-send-email-mst@kernel.org> <20200213155154.GX4271@mellanox.com> <20200213105743-mutt-send-email-mst@kernel.org> <20200213161320.GY4271@mellanox.com> From: Jason Wang Message-ID: Date: Fri, 14 Feb 2020 12:39:48 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20200213161320.GY4271@mellanox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/2/14 =E4=B8=8A=E5=8D=8812:13, Jason Gunthorpe wrote: > On Thu, Feb 13, 2020 at 10:59:34AM -0500, Michael S. Tsirkin wrote: >> On Thu, Feb 13, 2020 at 11:51:54AM -0400, Jason Gunthorpe wrote: >>> The 'class' is supposed to provide all the library functions to remov= e >>> this duplication. Instead of plugging the HW driver in via some bus >>> scheme every subsystem has its own 'ops' that the HW driver provides >>> to the subsystem's class via subsystem_register() >> Hmm I'm not familiar with subsystem_register. A grep didn't find it >> in the kernel either ... > I mean it is the registration function provided by the subsystem that > owns the class, for instance tpm_chip_register(), > ib_register_device(), register_netdev(), rtc_register_device() etc > > So if you have some vhost (vhost net?) class then you'd have some > vhost_vdpa_init/alloc(); vhost_vdpa_register(), sequence > presumably. (vs trying to do it with a bus matcher) > > I recommend to look at rtc and tpm for fairly simple easy to follow > patterns for creating a subsystem in the kernel. A subsystem owns a cla= ss, > allows HW drivers to plug in to it, and provides a consistent user > API via a cdev/sysfs/etc. > > The driver model class should revolve around the char dev and sysfs > uABI - if you enumerate the devices on the class then they should all > follow the char dev and sysfs interfaces contract of that class. > > Those examples show how to do all the refcounting semi-sanely, > introduce sysfs, cdevs, etc. > > I thought the latest proposal was to use the existing vhost class and > largely the existing vhost API, so it probably just needs to make sure > the common class-wide stuff is split from the 'driver' stuff of the > existing vhost to netdev. Still, netdev is only one of the type we want to support. And we can not=20 guarantee or forecast that vhost is the only API that is used. Let's take virtio as an example, it is implemented through a bus which=20 allows different subsystems on top. And it can provide a variety of=20 different uAPIs. For best performance, VFIO could be used for userspace=20 drivers, but it requires the bus has support from VFIO. For vDPA devices, it's just the same logic. A bus allows different=20 drivers and subsystems on top. One of the subsystem could be vhost that=20 provides a unified API for userspace driver. Thanks > > Jason >