Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp103848ybj; Thu, 19 Sep 2019 11:21:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyo2Adg8IkYRzOwARRGwWIgWxZ+ctEldy91OMe+b3LFT6TWiSLHWLArhssdQzZlkG6/ZBTg X-Received: by 2002:a17:906:d8a9:: with SMTP id qc9mr14192708ejb.199.1568917308271; Thu, 19 Sep 2019 11:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568917308; cv=none; d=google.com; s=arc-20160816; b=nuFX0MKtUCxEpScyfQSObfNrYlTguhJp7KmLqfnXj9SWuMRVUsOpxryAS9xkb00jO4 9WZ7LF4z0Ecc/maqxxQ3YPbuI8Rc+rAl0e5Zkho2ifp8XWeZfRswNElkbuQwfVnozorE 2ZpU2XJE3Bamzw5RKfceC7peq5enImzWtY5inEFppHAXRBgV2CnMvndNyQB2EcdIRxmO pYjtwng7CUBi7oLFpPJI/kgMWjGDj8JGneSXjeCmSUzLzQFALnKT7qKkBHa4LRQaigyV MhH6wKFjBA9/HQ1zsnwUoUz3gHaA+H5WGS1z7rCtyYxogNhqCoMLwGnDIsubaisS5m2U TCMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=roJBIhviAFi3q61gZXPTk5SDbsBPY23lnrOqaJNhvtI=; b=gjJxe/UkSvad7vRyVcRwEnYejrSXDptfZP2fnFmmI2Az+3syLD7+WaEOyWBwCQ6zWM +t1aJuYpDl243WzKqgUq8xyU80uNKZ+2CM2w/9tymtdZvcmByIVDP6ituRIfZNBJGkC0 Ppuvb9QbCKeJJUIJN2FLnLH7p35COdwT0lMCwsIs/nfimPI2hgCbRkGFYOF6ve3sSB3M em0bnEvgpA70LndgJJkLYLaUIVc8bmqh9rYzt81MFtOv0LleSpdMqOzFKRSq7UHWr1kn AsNRxQu+nl0maXwleA5HTnAfm381vIRImb2uZYLyrWkxgSN2Yu/JCBZB1cd/JET60EAP jqTg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g21si5976147edg.339.2019.09.19.11.21.25; Thu, 19 Sep 2019 11:21:48 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391402AbfISPsk (ORCPT + 99 others); Thu, 19 Sep 2019 11:48:40 -0400 Received: from mga17.intel.com ([192.55.52.151]:46951 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388700AbfISPsj (ORCPT ); Thu, 19 Sep 2019 11:48:39 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Sep 2019 08:48:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,524,1559545200"; d="scan'208";a="362555450" Received: from dpdk-virtio-tbie-2.sh.intel.com (HELO ___) ([10.67.104.71]) by orsmga005.jf.intel.com with ESMTP; 19 Sep 2019 08:48:36 -0700 Date: Thu, 19 Sep 2019 23:45:52 +0800 From: Tiwei Bie To: Jason Wang Cc: "Michael S. Tsirkin" , alex.williamson@redhat.com, maxime.coquelin@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, dan.daly@intel.com, cunming.liang@intel.com, zhihong.wang@intel.com, lingshan.zhu@intel.com Subject: Re: [RFC v4 0/3] vhost: introduce mdev based hardware backend Message-ID: <20190919154552.GA27657@___> References: <20190917010204.30376-1-tiwei.bie@intel.com> <993841ed-942e-c90b-8016-8e7dc76bf13a@redhat.com> <20190917105801.GA24855@___> <20190918102923-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 19, 2019 at 09:08:11PM +0800, Jason Wang wrote: > On 2019/9/18 下午10:32, Michael S. Tsirkin wrote: > > > > > So I have some questions: > > > > > > > > > > 1) Compared to method 2, what's the advantage of creating a new vhost char > > > > > device? I guess it's for keep the API compatibility? > > > > One benefit is that we can avoid doing vhost ioctls on > > > > VFIO device fd. > > > Yes, but any benefit from doing this? > > It does seem a bit more modular, but it's certainly not a big deal. > > Ok, if we go this way, it could be as simple as provide some callback to > vhost, then vhost can just forward the ioctl through parent_ops. > > > > > > > > 2) For method 2, is there any easy way for user/admin to distinguish e.g > > > > > ordinary vfio-mdev for vhost from ordinary vfio-mdev? > > > > I think device-api could be a choice. > > > Ok. > > > > > > > > > > > I saw you introduce > > > > > ops matching helper but it's not friendly to management. > > > > The ops matching helper is just to check whether a given > > > > vfio-device is based on a mdev device. > > > > > > > > > 3) A drawback of 1) and 2) is that it must follow vfio_device_ops that > > > > > assumes the parameter comes from userspace, it prevents support kernel > > > > > virtio drivers. > > > > > > > > > > 4) So comes the idea of method 3, since it register a new vhost-mdev driver, > > > > > we can use device specific ops instead of VFIO ones, then we can have a > > > > > common API between vDPA parent and vhost-mdev/virtio-mdev drivers. > > > > As the above draft shows, this requires introducing a new > > > > VFIO device driver. I think Alex's opinion matters here. > > Just to clarify, a new type of mdev driver but provides dummy > vfio_device_ops for VFIO to make container DMA ioctl work. I see. Thanks! IIUC, you mean we can provide a very tiny VFIO device driver in drivers/vhost/mdev.c, e.g.: static int vfio_vhost_mdev_open(void *device_data) { if (!try_module_get(THIS_MODULE)) return -ENODEV; return 0; } static void vfio_vhost_mdev_release(void *device_data) { module_put(THIS_MODULE); } static const struct vfio_device_ops vfio_vhost_mdev_dev_ops = { .name = "vfio-vhost-mdev", .open = vfio_vhost_mdev_open, .release = vfio_vhost_mdev_release, }; static int vhost_mdev_probe(struct device *dev) { struct mdev_device *mdev = to_mdev_device(dev); ... Check the mdev device_id proposed in ... ... https://lkml.org/lkml/2019/9/12/151 ... return vfio_add_group_dev(dev, &vfio_vhost_mdev_dev_ops, mdev); } static void vhost_mdev_remove(struct device *dev) { vfio_del_group_dev(dev); } static struct mdev_driver vhost_mdev_driver = { .name = "vhost_mdev", .probe = vhost_mdev_probe, .remove = vhost_mdev_remove, }; So we can bind above mdev driver to the virtio-mdev compatible mdev devices when we want to use vhost-mdev. After binding above driver to the mdev device, we can setup IOMMU via VFIO and get VFIO device fd of this mdev device, and pass it to vhost fd (/dev/vhost-mdev) with a SET_BACKEND ioctl. Thanks, Tiwei > > Thanks > > > > > Yes, it is. > > > > > > Thanks > > > > > >