Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3436853ybn; Fri, 27 Sep 2019 06:24:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrDhQB3KQLAILRzoj5MGwGxmXOVq2RL/Yvn61xhqIrZNcnT2BHFah6ke2SuVd9FLNkjKDh X-Received: by 2002:a17:906:eda1:: with SMTP id sa1mr7640779ejb.293.1569590677797; Fri, 27 Sep 2019 06:24:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569590677; cv=none; d=google.com; s=arc-20160816; b=pgZG3mYanFyMwlHOoioZMk3B0/MGvnqrMebA6XadCg6ZEHuAn0of5hKm/coUgifH6k H+3zDBJ8Rse5YB+eTki53pZCvXk0tkcAMRiVPP+vZGFqd/25QijDQ0lCFVleiQd/b32Q cD0fq5s6XloGYIQj4kM/m5r0QPqVMx7Kb42MQHU031ikGfslU6NDoJ/It3uYCCLc2C9t FIC/7fJBSlaM1uMy562qAJINS7Lx8/8Z2yrb1r95BAKA276CLMonlzvHT/zsSIHJ+TOD emTWDm+0YH1oId5Xv1NgcbQ3Zjzuxrjm+2eUUXue0SfZ15XQkY6ETGWEPBFHCdehesnF 1Mrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=AyTMKGoGs/Lkq3kyZ5E07Ek1WWcR6PtX7h75NGzXR98=; b=H6/674K2KmszX6f4ZuvwOeBmXe457reZ0Nnym6uRdp7PbA9jUFZN7eU5mH0DPacu/L bIZU67NBxDe16W0yhSVZAtVC33L+x8UYqxctT2vZdHThdeGIArhrclxbuJXSKDKzK6lk tDc+mIZo9STc0DORh8fL7/GXnUjK+3x6BcJJMUG91K+gfT++OgSVuIoYxuv56Wi/oLb8 T9fimGaeNhDy1CMRYH03u6yLIyiAWc0XJKFj5IpAohZPgaEj6KTaLs3KGCqU1Y9E9G6/ IACM+ihIXAW6LUd417rY4RT+EydVd1GyUmXZ5q4q6FSWJweBn9PFXuZL0GyDW3Hhoed0 WFDA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e22si2730082ejx.107.2019.09.27.06.24.12; Fri, 27 Sep 2019 06:24:37 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727366AbfI0NX4 (ORCPT + 99 others); Fri, 27 Sep 2019 09:23:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51230 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727128AbfI0NXz (ORCPT ); Fri, 27 Sep 2019 09:23:55 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 254C5796E9 for ; Fri, 27 Sep 2019 13:23:55 +0000 (UTC) Received: by mail-qt1-f198.google.com with SMTP id n4so5682323qtp.19 for ; Fri, 27 Sep 2019 06:23:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=AyTMKGoGs/Lkq3kyZ5E07Ek1WWcR6PtX7h75NGzXR98=; b=iLDmfmeYpNb0n8fYzdiDPATcVrHb/fsRflGi3KXbTHAI4C8a2rM0GVQ84R4+VdrzK6 Elqs49xadPfiPDqHIXV/NH2zf1J4E9nw9JAhj1LYWiHSIm20+88JybWFgukHgrPnUb0g cAsvWdx5smRA936rWZbEuKEJB1Jc/+KApIr5A3vgdNstOa2jMH1kvnuDDJ2iZL4kzkBc mdKhsjVOmE5qVF1Enzcb3XSF2O5WLIbYrzYRLMId+d9sD4zdUUZ/mcaZovcoGrFY1T/t 3X7G4ARrUnN3z6RsET9t8sup/nrwQGuGxI2tFoxRp/WLG96c9/E5Ak/eqIufICC5N77K d2Mw== X-Gm-Message-State: APjAAAVfRoqy5viLdqtD2UzVGjlAZp/kCec7SSPbVmB2sNO32Lw/ZVTQ NbXozaJYZI+dPKPLAhvHH5SDMNzKvdPa/pFhQFx0B8xfUByBtguYyN4oUAVz33fX59MG7C/p2y1 +BlWQ+nuHCSjimg8RsyvWQzKO X-Received: by 2002:ae9:ebcc:: with SMTP id b195mr4157306qkg.387.1569590634431; Fri, 27 Sep 2019 06:23:54 -0700 (PDT) X-Received: by 2002:ae9:ebcc:: with SMTP id b195mr4157280qkg.387.1569590634189; Fri, 27 Sep 2019 06:23:54 -0700 (PDT) Received: from redhat.com (bzq-79-176-40-226.red.bezeqint.net. [79.176.40.226]) by smtp.gmail.com with ESMTPSA id m14sm1073230qki.27.2019.09.27.06.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2019 06:23:52 -0700 (PDT) Date: Fri, 27 Sep 2019 09:23:46 -0400 From: "Michael S. Tsirkin" To: Jason Wang Cc: Tiwei Bie , 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: [PATCH] vhost: introduce mdev based hardware backend Message-ID: <20190927092219-mutt-send-email-mst@kernel.org> References: <20190926045427.4973-1-tiwei.bie@intel.com> <20190926042156-mutt-send-email-mst@kernel.org> <20190926131439.GA11652@___> <8ab5a8d9-284d-bba5-803d-08523c0814e1@redhat.com> <20190927053935-mutt-send-email-mst@kernel.org> <20190927084408-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: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 27, 2019 at 09:17:56PM +0800, Jason Wang wrote: > > On 2019/9/27 下午8:46, Michael S. Tsirkin wrote: > > On Fri, Sep 27, 2019 at 08:17:47PM +0800, Jason Wang wrote: > > > On 2019/9/27 下午5:41, Michael S. Tsirkin wrote: > > > > On Fri, Sep 27, 2019 at 11:27:12AM +0800, Jason Wang wrote: > > > > > On 2019/9/26 下午9:14, Tiwei Bie wrote: > > > > > > On Thu, Sep 26, 2019 at 04:35:18AM -0400, Michael S. Tsirkin wrote: > > > > > > > On Thu, Sep 26, 2019 at 12:54:27PM +0800, Tiwei Bie wrote: > > > > > > [...] > > > > > > > > diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h > > > > > > > > index 40d028eed645..5afbc2f08fa3 100644 > > > > > > > > --- a/include/uapi/linux/vhost.h > > > > > > > > +++ b/include/uapi/linux/vhost.h > > > > > > > > @@ -116,4 +116,12 @@ > > > > > > > > #define VHOST_VSOCK_SET_GUEST_CID _IOW(VHOST_VIRTIO, 0x60, __u64) > > > > > > > > #define VHOST_VSOCK_SET_RUNNING _IOW(VHOST_VIRTIO, 0x61, int) > > > > > > > > +/* VHOST_MDEV specific defines */ > > > > > > > > + > > > > > > > > +#define VHOST_MDEV_SET_STATE _IOW(VHOST_VIRTIO, 0x70, __u64) > > > > > > > > + > > > > > > > > +#define VHOST_MDEV_S_STOPPED 0 > > > > > > > > +#define VHOST_MDEV_S_RUNNING 1 > > > > > > > > +#define VHOST_MDEV_S_MAX 2 > > > > > > > > + > > > > > > > > #endif > > > > > > > So assuming we have an underlying device that behaves like virtio: > > > > > > I think they are really good questions/suggestions. Thanks! > > > > > > > > > > > > > 1. Should we use SET_STATUS maybe? > > > > > > I like this idea. I will give it a try. > > > > > > > > > > > > > 2. Do we want a reset ioctl? > > > > > > I think it is helpful. If we use SET_STATUS, maybe we > > > > > > can use it to support the reset. > > > > > > > > > > > > > 3. Do we want ability to enable rings individually? > > > > > > I will make it possible at least in the vhost layer. > > > > > Note the API support e.g set_vq_ready(). > > > > virtio spec calls this "enabled" so let's stick to that. > > > > > > Ok. > > > > > > > > > > > > > 4. Does device need to limit max ring size? > > > > > > > 5. Does device need to limit max number of queues? > > > > > > I think so. It's helpful to have ioctls to report the max > > > > > > ring size and max number of queues. > > > > > An issue is the max number of queues is done through a device specific way, > > > > > usually device configuration space. This is supported by the transport API, > > > > > but how to expose it to userspace may need more thought. > > > > > > > > > > Thanks > > > > an ioctl for device config? But for v1 I'd be quite happy to just have > > > > a minimal working device with 2 queues. > > > > > > I'm fully agree, and it will work as long as VIRTIO_NET_F_MQ and > > > VIRTIO_NET_F_CTRL_VQ is not advertised by the mdev device. > > > > > > Thanks > > Hmm this means we need to validate the features bits, > > not just pass them through to the hardware. > > Problem is, how do we add more feature bits later, > > without testing all hardware? > > I guess this means the device specific driver must do it. > > > > That looks not good, maybe a virtio device id based features blacklist in > vhost-mdev. Then MQ and CTRL_VQ could be filtered out by vhost-mdev. > > Thanks Two implementations of e.g. virtio net can have different features whitelisted. So I think there's no way but let the driver do it. We should probably provide a standard place in the ops for driver to supply the whitelist, to make sure drivers don't forget. > > > > > > > Thanks!