Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4861901pxb; Wed, 19 Jan 2022 06:32:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzH15rNAejS6gv+iZ4u6mCdk0Gkh/UCASZ05XNbMbgcIZp9tFNFrrNq1Tj2e1wQYVHeA2EU X-Received: by 2002:a17:902:f689:b0:14a:3c7d:dadf with SMTP id l9-20020a170902f68900b0014a3c7ddadfmr31743540plg.48.1642602771242; Wed, 19 Jan 2022 06:32:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642602771; cv=none; d=google.com; s=arc-20160816; b=FBsxkp/B4tcbx0POhrHgU2rTP6u5eBncLIWfDByDK4tc41jDi8qL7o/6azYyjajnpu 72OOelQYDHbiRg2YD4Wbw+DvJ8UYj5/Xu33rHOyHobTKmVL0zV4vCkmsj2f6VikgJ1P2 mReuK9GeJLEr6FXnQNvejs6jLKDoKdSG/O4Au3rIIgmWlpjQgD/JvAcszyA3O/x3OZHZ XUd62DkbbX9Say+PHInTPZ6IHyFKPJGBmCxGANFzAq5+pKgOGjE5bAOsuWNVN4Ds8/M5 aklD+YOMv4qvzEB8sc+Itr9OSgwpcpfIMH+otFSUU5AHnpc8EnLqtn9cQD2TpGCVwfb9 9m6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=9CQmErdVbSRr9mtW1+GyxSplP9tubMADIUUmh9Y+ayg=; b=ZHzx2nXqFEGhf7kwBo/Xh0Pq7dcd7jaIbpSR9V3BcAOpC/invKS1h5C7B2bMNpE79G ck6u2QFsLywl8X9uQglYovEmVvV0YW55xPbPWqxR6R4brE7oziTLLXQdOA4QjkBfpHt+ 3spIf9ay4dGHThMJGrorWuEbVJ9mISoL67zbp+uASV63oskjS6MPcencd/wVpw5Wd8lH bJQfT+ylnEmd0whWpluIjnVTcYsG6cpZdqNOFN0/FCvcfOl2BbIl05TZ4TY7srlXY1Jv Vp+TSRsTMSD9TBvX/+Uahhj9G17ezvvnxbi6PTRSfyym78ExjylCj1P5EgvMICzNfJOs CRSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RRs87RMk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f15si18693195plr.122.2022.01.19.06.32.29; Wed, 19 Jan 2022 06:32:51 -0800 (PST) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RRs87RMk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357211AbiARDUh (ORCPT + 99 others); Mon, 17 Jan 2022 22:20:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20497 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344909AbiARDHt (ORCPT ); Mon, 17 Jan 2022 22:07:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642475268; 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=9CQmErdVbSRr9mtW1+GyxSplP9tubMADIUUmh9Y+ayg=; b=RRs87RMkYCJl+mUZsopuZkbmBCLWShGxMcq3HiFwVU3BbaoXLrXpVHmWY09WUOXYY+W0cw wtsopjdvkYnRnzJRWHv2k54tW6JDDFT3kQPKc1GO1eUg7zc2hOUwMgAn0lYWClXTsDw8Nf /jYQBjHw0Z0fxtq8eBUPM87CY8UEvvg= Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-jAzbXKuuO5e0qbI83MfkKQ-1; Mon, 17 Jan 2022 22:07:47 -0500 X-MC-Unique: jAzbXKuuO5e0qbI83MfkKQ-1 Received: by mail-pf1-f199.google.com with SMTP id o189-20020a625ac6000000b004be3e78847dso7289153pfb.14 for ; Mon, 17 Jan 2022 19:07:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=9CQmErdVbSRr9mtW1+GyxSplP9tubMADIUUmh9Y+ayg=; b=LRR7/TCAYPFFn5ijZgHEIBKa1TEYOO719toC/r4mDAV7ld3oBmVMr87Z54c3AM3MwA 3VIJS1uT2U8iGkWgxOOzcAgI6F3UI1ERC3//Ow8sieDrTTnVsvvA8hq5yBuXSe4EWjX/ +LZC95XNQcMiouPd4WQJ77lc8ohoiwnJbXrJYN+uCa841QptFAsx66kNNGphHsnOhdzF y2t1V4qihwd3n89Ifikl/XJSKLvWHutbYq5DU9Dfbw02DJ/iX7Tj6K9hpz9Lcas+pVYn v0YpK7ARz1gElJI94Us1npmIlrhYCq8WRD3JJznr9piPCcQMycPlSYORsE3+Se0UpMFA 4HHQ== X-Gm-Message-State: AOAM530VKi13lmXkqlEj7N+KjJr66a10dA0FgIQnWJariSnIC6/VnoQY y1QD/WUzvCBJ/EBoOp2j7cunxYS78N5fih/1HUjH6Mp995aIpL+cDsZSPhmfGJvdMJ7s6EsVsFY lEnAkWM1Nesl07jj6qwh+Ww3e X-Received: by 2002:a63:9dc8:: with SMTP id i191mr21688276pgd.601.1642475265999; Mon, 17 Jan 2022 19:07:45 -0800 (PST) X-Received: by 2002:a63:9dc8:: with SMTP id i191mr21688268pgd.601.1642475265770; Mon, 17 Jan 2022 19:07:45 -0800 (PST) Received: from [10.72.13.83] ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id a19sm4801961pfh.198.2022.01.17.19.07.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Jan 2022 19:07:45 -0800 (PST) Message-ID: <1a26d7b3-1020-50c5-f0a3-ebc645cdcddf@redhat.com> Date: Tue, 18 Jan 2022 11:07:36 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [RFC 2/3] vdpa: support exposing the count of vqs to userspace Content-Language: en-US To: "Longpeng(Mike)" , mst@redhat.com, sgarzare@redhat.com, stefanha@redhat.com Cc: virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, arei.gonglei@huawei.com, yechuan@huawei.com, huangzhichao@huawei.com References: <20220117092921.1573-1-longpeng2@huawei.com> <20220117092921.1573-3-longpeng2@huawei.com> From: Jason Wang In-Reply-To: <20220117092921.1573-3-longpeng2@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/1/17 下午5:29, Longpeng(Mike) 写道: > From: Longpeng > > - GET_VQS_COUNT: the count of virtqueues that exposed > > Signed-off-by: Longpeng > --- > drivers/vhost/vdpa.c | 13 +++++++++++++ > include/uapi/linux/vhost.h | 3 +++ > 2 files changed, 16 insertions(+) > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > index 1eea14a4ea56..c1074278fc6b 100644 > --- a/drivers/vhost/vdpa.c > +++ b/drivers/vhost/vdpa.c > @@ -369,6 +369,16 @@ static long vhost_vdpa_get_config_size(struct vhost_vdpa *v, u32 __user *argp) > return 0; > } > > +static long vhost_vdpa_get_vqs_count(struct vhost_vdpa *v, u32 __user *argp) > +{ > + struct vdpa_device *vdpa = v->vdpa; While at it, I think it's better to change vdpa->nvqs to use u32? Thanks > + > + if (copy_to_user(argp, &vdpa->nvqs, sizeof(vdpa->nvqs))) > + return -EFAULT; > + > + return 0; > +} > + > static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, > void __user *argp) > { > @@ -509,6 +519,9 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, > case VHOST_VDPA_GET_CONFIG_SIZE: > r = vhost_vdpa_get_config_size(v, argp); > break; > + case VHOST_VDPA_GET_VQS_COUNT: > + r = vhost_vdpa_get_vqs_count(v, argp); > + break; > default: > r = vhost_dev_ioctl(&v->vdev, cmd, argp); > if (r == -ENOIOCTLCMD) > diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h > index bc74e95a273a..5d99e7c242a2 100644 > --- a/include/uapi/linux/vhost.h > +++ b/include/uapi/linux/vhost.h > @@ -154,4 +154,7 @@ > /* Get the config size */ > #define VHOST_VDPA_GET_CONFIG_SIZE _IOR(VHOST_VIRTIO, 0x79, __u32) > > +/* Get the count of all virtqueues */ > +#define VHOST_VDPA_GET_VQS_COUNT _IOR(VHOST_VIRTIO, 0x80, __u32) > + > #endif