Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp114325pxb; Tue, 14 Sep 2021 20:28:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuo2EAFiA20u80fdFyO4YFnJyg5vUq+hgCEOgbM9XCT7CDhIgUsLM9W9nO6iYv3oBouvik X-Received: by 2002:a02:ca0b:: with SMTP id i11mr17572487jak.84.1631676481596; Tue, 14 Sep 2021 20:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631676481; cv=none; d=google.com; s=arc-20160816; b=J0nUgWtpVRMuUx+S6570t1SHBUUpBQeud8+Wn6YWcLGAJo1nmDHY9CA2NcGASQRrJp rZDQordIR+E35mdRGHM3fS9oRqEGLL8YcQpLIuM9GkSfaprCufjQf3kxnbJsNKKNhav5 HJhWAI/WM7WlX/P43UyVuZKcf42UThhWh67DAKtt3vbtdjq2BVhytuQaClB6iAQK++1R 4pj9BIBRtKvkvBfoiUzhOIfL8wW2ET+D57aTy5abe9eTFifDl7Gs81bvLWJt8tEVk9VZ JEv3AJI0Vv1ekoyadxJeCV+Hn4Gz9bLftX0ebkEDaKKeCBoMCx+ahLnsTZgaDg941scR TKgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date; bh=oEaQdf0P6k/3SUtZwdqLU2C8rlhupQ/kwE48OhSbWV8=; b=Umun52bF9loAUqQ4DaugWj+dbYQvb3NpGhPOp0cY/YCwQptO8ye7fRKiNBDS8KAr87 vcKWNVyOXbqYO8/MjvtBy7HvMs25+vOBVrMuASSQH6QLR79Cx8LNrSMuQ23xBjQztHWG +WosufHy7+kVxqEu/owOwkspcDn5OlV8A6wwoBlmBc/APN4X+CvlaGMS9DfyitKQ1y0t M9me0CKdb1q6eYFqwA2s3a+ijiTGcNzRpPg67yMfxDF99ON9V7y/OekiSO7IU7xG/EU3 zbXrHy9zWQDgzQ2IGCAX+CEhfJ8m77jQuStRYZXrFhJwvgeEAAs3CN9fYZxo/s7L/Bst dzBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v9si11136775ile.167.2021.09.14.20.27.49; Tue, 14 Sep 2021 20:28:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236007AbhIOD0O (ORCPT + 99 others); Tue, 14 Sep 2021 23:26:14 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:38704 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229986AbhIOD0N (ORCPT ); Tue, 14 Sep 2021 23:26:13 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R861e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=wuzongyong@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0UoQrnCA_1631676293; Received: from localhost(mailfrom:wuzongyong@linux.alibaba.com fp:SMTPD_---0UoQrnCA_1631676293) by smtp.aliyun-inc.com(127.0.0.1); Wed, 15 Sep 2021 11:24:53 +0800 Date: Wed, 15 Sep 2021 11:24:53 +0800 From: Wu Zongyong To: "Michael S. Tsirkin" Cc: jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, wei.yang1@linux.alibaba.com Subject: Re: [PATCH v2 4/5] vdpa: add new vdpa attribute VDPA_ATTR_DEV_F_VERSION_1 Message-ID: <20210915032453.GA18793@L-PF27918B-1352.localdomain> Reply-To: Wu Zongyong References: <834528d24c839080215b2e077f100e9ed5073edc.1631621507.git.wuzongyong@linux.alibaba.com> <20210914085711-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210914085711-mutt-send-email-mst@kernel.org> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 14, 2021 at 08:58:28AM -0400, Michael S. Tsirkin wrote: > On Tue, Sep 14, 2021 at 08:24:51PM +0800, Wu Zongyong wrote: > > This new attribute advertises whether the vdpa device is legacy or not. > > Users can pick right virtqueue size if the vdpa device is legacy which > > doesn't support to change virtqueue size. > > > > Signed-off-by: Wu Zongyong > > So if we are bothering with legacy, I think there are > several things to do when building the interface > - support transitional devices, that is allow userspace > to tell device it's in legacy mode > - support reporting/setting supporting endian-ness It's true if we try to implement a general drvier for legacy. But this series is dedicated to implement a driver only for ENI. Is it necessary to implement what you said here in this series? > > > --- > > drivers/vdpa/vdpa.c | 6 ++++++ > > drivers/virtio/virtio_vdpa.c | 7 ++++++- > > include/uapi/linux/vdpa.h | 1 + > > 3 files changed, 13 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c > > index 1dc121a07a93..533d7f589eee 100644 > > --- a/drivers/vdpa/vdpa.c > > +++ b/drivers/vdpa/vdpa.c > > @@ -12,6 +12,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -494,6 +495,7 @@ vdpa_dev_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq > > u16 max_vq_size; > > u32 device_id; > > u32 vendor_id; > > + u64 features; > > void *hdr; > > int err; > > > > @@ -508,6 +510,7 @@ vdpa_dev_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq > > device_id = vdev->config->get_device_id(vdev); > > vendor_id = vdev->config->get_vendor_id(vdev); > > max_vq_size = vdev->config->get_vq_num_max(vdev); > > + features = vdev->config->get_features(vdev); > > > > err = -EMSGSIZE; > > if (nla_put_string(msg, VDPA_ATTR_DEV_NAME, dev_name(&vdev->dev))) > > @@ -520,6 +523,9 @@ vdpa_dev_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u32 seq > > goto msg_err; > > if (nla_put_u16(msg, VDPA_ATTR_DEV_MAX_VQ_SIZE, max_vq_size)) > > goto msg_err; > > + if (features & BIT_ULL(VIRTIO_F_VERSION_1) && > > + nla_put_flag(msg, VDPA_ATTR_DEV_VERSION_1)) > > + goto msg_err; > > > > genlmsg_end(msg, hdr); > > return 0; > > diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c > > index 72eaef2caeb1..1cba957c4cdc 100644 > > --- a/drivers/virtio/virtio_vdpa.c > > +++ b/drivers/virtio/virtio_vdpa.c > > @@ -7,6 +7,7 @@ > > * > > */ > > > > +#include "linux/virtio_config.h" > > #include > > #include > > #include > > @@ -145,6 +146,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index, > > /* Assume split virtqueue, switch to packed if necessary */ > > struct vdpa_vq_state state = {0}; > > unsigned long flags; > > + bool may_reduce_num = false; > > u32 align, num; > > int err; > > > > @@ -169,10 +171,13 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index, > > goto error_new_virtqueue; > > } > > > > + if (ops->get_features(vdpa) & BIT_ULL(VIRTIO_F_VERSION_1)) > > + may_reduce_num = true; > > + > > /* Create the vring */ > > align = ops->get_vq_align(vdpa); > > vq = vring_create_virtqueue(index, num, align, vdev, > > - true, true, ctx, > > + true, may_reduce_num, ctx, > > virtio_vdpa_notify, callback, name); > > if (!vq) { > > err = -ENOMEM; > > diff --git a/include/uapi/linux/vdpa.h b/include/uapi/linux/vdpa.h > > index 66a41e4ec163..ce0b74276a5b 100644 > > --- a/include/uapi/linux/vdpa.h > > +++ b/include/uapi/linux/vdpa.h > > @@ -32,6 +32,7 @@ enum vdpa_attr { > > VDPA_ATTR_DEV_VENDOR_ID, /* u32 */ > > VDPA_ATTR_DEV_MAX_VQS, /* u32 */ > > VDPA_ATTR_DEV_MAX_VQ_SIZE, /* u16 */ > > + VDPA_ATTR_DEV_VERSION_1, /* flag */ > > > > /* new attributes must be added above here */ > > VDPA_ATTR_MAX, > > -- > > 2.31.1