Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1410412rwi; Fri, 14 Oct 2022 18:45:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ltP43l0Qca2F4VfIoV4Skoqp6h7LyTmZjMVZKV4t3SxymkViEffJcLdZnj4ZAoF3/DhYP X-Received: by 2002:a05:6402:42c7:b0:45c:a6f1:c0af with SMTP id i7-20020a05640242c700b0045ca6f1c0afmr494431edc.75.1665798355293; Fri, 14 Oct 2022 18:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665798355; cv=none; d=google.com; s=arc-20160816; b=KnxvzTez6ESlPO1pDoanPNwZLMQQCFfYOi12wDlygx8ga8Qg9I7GRoXXF9CDNKwjF9 jYyKsKwOxmmqO9+YJFlyfNphxGt9E8yByRKRTmkUKuIsiqw7qp62iu8w7Vu8a5l5EDq6 /yB2+DcjN6OTnldUyj/wWcuoKVdZTuq8qlll2aZ0D9T6NpXlF4Ip7zK5c/XsHBaPW06w bmYXEnxHaMj8x6dDeLfWlhUG5wSp8grEjCBVaruG1J2vRokWA/r/xP8yZbUNTQ4d5t/B ypaC5FkGV8lttLoVgpg7jla4T149kxlBYYySZeYAShMVKYBAXVqfaxbKzzsIVnLScShe aPiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=6OKBJgFbXS3OjE73iQJfSkItm6qvzXxZpGWp2/+KhZg=; b=MAERz2YMlsfPaVPJOMN5tmaWk2/xGW6YH0V8NtVbbR5Ucw+mFw0taUAWAUR6PSqjse QPkaakCF30A1j7EbBHbo0nsF51u4J309t2ybJWedjGeXsNyOuh7z4CvivMNekNfoTejF XBLS1gP8Hvo1FHiIANj8XYyf6Rml4XvKj3n8bWGoOJoTNERot8XETXeE7MJxagUZjXWW XKupaRrHezqwqb1oUFhxh5Qrs9X9PVxtfgxoCgTcX+GjxrxnuLlTmv2EnBX78yTJaoM3 WO0iF0HP+tbFuJFd99AJe/yWCQnJ07A/0dTe33kMayDC37w65TkFjElDefaXpW7SrgOS cpsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=qJ8BIKFz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw22-20020a1709066a1600b0078d3a35e181si3362073ejc.871.2022.10.14.18.45.29; Fri, 14 Oct 2022 18:45:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=qJ8BIKFz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229560AbiJOBd6 (ORCPT + 99 others); Fri, 14 Oct 2022 21:33:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbiJOBdy (ORCPT ); Fri, 14 Oct 2022 21:33:54 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BF3F6C946 for ; Fri, 14 Oct 2022 18:33:53 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29F1XKrm028559; Sat, 15 Oct 2022 01:33:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2022-7-12; bh=6OKBJgFbXS3OjE73iQJfSkItm6qvzXxZpGWp2/+KhZg=; b=qJ8BIKFzyNbJ7xwpGBsUeLXHEm8aHYNmBLNO1Oqb6LsIpbhfQpvv3WS1bcpmyQnRINt1 j5xmkxiQgqln6yafCmXthj1YFD2wUtC9L4Dg8BBQ4YQXiCoDu1u5yduQ/Bo3a4YReQbN O65c90yLkA6QFGcCyL5eDiM3m+RgFhjl2Ur98wXeOeAnhk4nImpY1hgnHuCC2yVc65rh Dz2QNaie26p58XdWTZiAp8EMGrp5qB1zG4WwsoU7sq60KP5Ti1A5ZKbtBl64IGq2XbdQ o+CuBgajJVwWNa8exWJ5az9CgFSojL+9gsbzKGJ580MDWQ9vh3uP7eMd1zUj4E1CAdsI xw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k7k9d001e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 15 Oct 2022 01:33:49 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29F1X478008564; Sat, 15 Oct 2022 01:33:48 GMT Received: from ban25x6uut24.us.oracle.com (ban25x6uut24.us.oracle.com [10.153.73.24]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3k7ka180am-3; Sat, 15 Oct 2022 01:33:48 +0000 From: Si-Wei Liu To: mst@redhat.com, jasowang@redhat.com Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] vdpa: pass initial config to _vdpa_register_device() Date: Fri, 14 Oct 2022 17:28:08 -0700 Message-Id: <1665793690-28120-3-git-send-email-si-wei.liu@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1665793690-28120-1-git-send-email-si-wei.liu@oracle.com> References: <1665793690-28120-1-git-send-email-si-wei.liu@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-14_13,2022-10-14_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 adultscore=0 mlxscore=0 malwarescore=0 bulkscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210150007 X-Proofpoint-GUID: eEH9kAeQrAWYNgjstgH_EaHOrRAFefqk X-Proofpoint-ORIG-GUID: eEH9kAeQrAWYNgjstgH_EaHOrRAFefqk X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just as _vdpa_register_device taking @nvqs as the number of queues to feed userspace inquery via vdpa_dev_fill(), we can follow the same to stash config attributes in struct vdpa_device at the time of vdpa registration. Signed-off-by: Si-Wei Liu --- drivers/vdpa/ifcvf/ifcvf_main.c | 2 +- drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- drivers/vdpa/vdpa.c | 15 +++++++++++---- drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 2 +- drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 2 +- drivers/vdpa/vdpa_user/vduse_dev.c | 2 +- drivers/vdpa/virtio_pci/vp_vdpa.c | 3 ++- include/linux/vdpa.h | 3 ++- 8 files changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c index f9c0044..c54ab2c 100644 --- a/drivers/vdpa/ifcvf/ifcvf_main.c +++ b/drivers/vdpa/ifcvf/ifcvf_main.c @@ -771,7 +771,7 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, else ret = dev_set_name(&vdpa_dev->dev, "vdpa%u", vdpa_dev->index); - ret = _vdpa_register_device(&adapter->vdpa, vf->nr_vring); + ret = _vdpa_register_device(&adapter->vdpa, vf->nr_vring, config); if (ret) { put_device(&adapter->vdpa.dev); IFCVF_ERR(pdev, "Failed to register to vDPA bus"); diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 9091336..376082e 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -3206,7 +3206,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, mlx5_notifier_register(mdev, &ndev->nb); ndev->nb_registered = true; mvdev->vdev.mdev = &mgtdev->mgtdev; - err = _vdpa_register_device(&mvdev->vdev, max_vqs + 1); + err = _vdpa_register_device(&mvdev->vdev, max_vqs + 1, add_config); if (err) goto err_reg; diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index febdc99..566c1c6 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -215,11 +215,16 @@ static int vdpa_name_match(struct device *dev, const void *data) return (strcmp(dev_name(&vdev->dev), data) == 0); } -static int __vdpa_register_device(struct vdpa_device *vdev, u32 nvqs) +static int __vdpa_register_device(struct vdpa_device *vdev, u32 nvqs, + const struct vdpa_dev_set_config *cfg) { struct device *dev; vdev->nvqs = nvqs; + if (cfg) + vdev->vdev_cfg = *cfg; + else + vdev->vdev_cfg.mask = 0ULL; lockdep_assert_held(&vdpa_dev_lock); dev = bus_find_device(&vdpa_bus, NULL, dev_name(&vdev->dev), vdpa_name_match); @@ -237,15 +242,17 @@ static int __vdpa_register_device(struct vdpa_device *vdev, u32 nvqs) * callback after setting up valid mgmtdev for this vdpa device. * @vdev: the vdpa device to be registered to vDPA bus * @nvqs: number of virtqueues supported by this device + * @cfg: initial config on vdpa device creation * * Return: Returns an error when fail to add device to vDPA bus */ -int _vdpa_register_device(struct vdpa_device *vdev, u32 nvqs) +int _vdpa_register_device(struct vdpa_device *vdev, u32 nvqs, + const struct vdpa_dev_set_config *cfg) { if (!vdev->mdev) return -EINVAL; - return __vdpa_register_device(vdev, nvqs); + return __vdpa_register_device(vdev, nvqs, cfg); } EXPORT_SYMBOL_GPL(_vdpa_register_device); @@ -262,7 +269,7 @@ int vdpa_register_device(struct vdpa_device *vdev, u32 nvqs) int err; down_write(&vdpa_dev_lock); - err = __vdpa_register_device(vdev, nvqs); + err = __vdpa_register_device(vdev, nvqs, NULL); up_write(&vdpa_dev_lock); return err; } diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c index c6db1a1..5e1cebc 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c @@ -387,7 +387,7 @@ static int vdpasim_blk_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, if (IS_ERR(simdev)) return PTR_ERR(simdev); - ret = _vdpa_register_device(&simdev->vdpa, VDPASIM_BLK_VQ_NUM); + ret = _vdpa_register_device(&simdev->vdpa, VDPASIM_BLK_VQ_NUM, config); if (ret) goto put_dev; diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c index c3cb225..06ef5a0 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c @@ -260,7 +260,7 @@ static int vdpasim_net_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, vdpasim_net_setup_config(simdev, config); - ret = _vdpa_register_device(&simdev->vdpa, VDPASIM_NET_VQ_NUM); + ret = _vdpa_register_device(&simdev->vdpa, VDPASIM_NET_VQ_NUM, config); if (ret) goto reg_err; diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 35dceee..6530fd2 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1713,7 +1713,7 @@ static int vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name, if (ret) return ret; - ret = _vdpa_register_device(&dev->vdev->vdpa, dev->vq_num); + ret = _vdpa_register_device(&dev->vdev->vdpa, dev->vq_num, config); if (ret) { put_device(&dev->vdev->vdpa.dev); return ret; diff --git a/drivers/vdpa/virtio_pci/vp_vdpa.c b/drivers/vdpa/virtio_pci/vp_vdpa.c index d448db0..ffdc90e 100644 --- a/drivers/vdpa/virtio_pci/vp_vdpa.c +++ b/drivers/vdpa/virtio_pci/vp_vdpa.c @@ -538,7 +538,8 @@ static int vp_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, vp_vdpa->config_irq = VIRTIO_MSI_NO_VECTOR; vp_vdpa->vdpa.mdev = &vp_vdpa_mgtdev->mgtdev; - ret = _vdpa_register_device(&vp_vdpa->vdpa, vp_vdpa->queues); + ret = _vdpa_register_device(&vp_vdpa->vdpa, vp_vdpa->queues, + add_config); if (ret) { dev_err(&pdev->dev, "Failed to register to vdpa bus\n"); goto err; diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index f1838f5..b9d50e8 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -381,7 +381,8 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent, int vdpa_register_device(struct vdpa_device *vdev, u32 nvqs); void vdpa_unregister_device(struct vdpa_device *vdev); -int _vdpa_register_device(struct vdpa_device *vdev, u32 nvqs); +int _vdpa_register_device(struct vdpa_device *vdev, u32 nvqs, + const struct vdpa_dev_set_config *cfg); void _vdpa_unregister_device(struct vdpa_device *vdev); /** -- 1.8.3.1