From nobody Fri Apr 10 12:39:05 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E64F6C433FE for ; Sat, 15 Oct 2022 01:35:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbiJOBfm (ORCPT ); Fri, 14 Oct 2022 21:35:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbiJOBfk (ORCPT ); Fri, 14 Oct 2022 21:35:40 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 700476CD0D for ; Fri, 14 Oct 2022 18:35:39 -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 29F1WggE026634; 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=Vceponq7eAFUqTu6CGWdqDZyJ21Mh5Eod4o60p5T6SU=; b=2BQNpXYndeJ0JkprQuWZHzEEJbyZYTL/jKtU9cLLag6ZQhP6TZqSJuVVGQ0DXFYTQNAj +doENKXWAqOVgrdiiN4Btinl3jnfcifivqOnwh4/Hr03AjuORxh69kl0XSiIpQ8/4gL4 gqjVWulhCwSOCdGygepFDvYPl7FKiQzPyEjkSJCt3klcfUYZuBWMmkiUcysRgHvJ9WQb +GAKzLrQZY/3+3X6THDgcvYAykfIwBFDSleKLidZsF5hNqbQePJqZypB1s+hQBOAg6DI IIgRodN/99faYNircg39lN0Qzd3LlbgJZB4Mw0WP4BsXPmRxXHGEdOU0teLnhAO9WaOG 2Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k7k9d001c-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 29F1X477008564; 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-2; 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 1/4] vdpa: save vdpa_dev_set_config in struct vdpa_device Date: Fri, 14 Oct 2022 17:28:07 -0700 Message-Id: <1665793690-28120-2-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: poIVo5XTPAmVzwdroxI1W7Zi2p-wHL1F X-Proofpoint-ORIG-GUID: poIVo5XTPAmVzwdroxI1W7Zi2p-wHL1F Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In order to allow live migration orchestration software to export the initial set of vdpa attributes with which the device was created, it will be useful if the vdpa tool can report the config on demand with simple query. This will ease the orchestration software implementation so that it doesn't have to keep track of vdpa config change, or have to persist vdpa attributes across failure and recovery, in fear of being killed due to accidental software error. This commit attempts to make struct vdpa_device contain the struct vdpa_dev_set_config, where all config attributes upon vdpa creation are carried over. Which will be used in subsequent commits. Signed-off-by: Si-Wei Liu --- include/linux/vdpa.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 6d0f5e4..f1838f5 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -58,6 +58,16 @@ struct vdpa_vq_state { }; }; =20 +struct vdpa_dev_set_config { + u64 device_features; + struct { + u8 mac[ETH_ALEN]; + u16 mtu; + u16 max_vq_pairs; + } net; + u64 mask; +}; + struct vdpa_mgmt_dev; =20 /** @@ -77,6 +87,8 @@ struct vdpa_vq_state { * @nvqs: maximum number of supported virtqueues * @mdev: management device pointer; caller must setup when registering de= vice as part * of dev_add() mgmtdev ops callback before invoking _vdpa_register_devi= ce(). + * @vdev_cfg: initial device config on vdpa creation; useful when instanti= ate with + * the exact same config is needed. */ struct vdpa_device { struct device dev; @@ -91,6 +103,7 @@ struct vdpa_device { struct vdpa_mgmt_dev *mdev; unsigned int ngroups; unsigned int nas; + struct vdpa_dev_set_config vdev_cfg; }; =20 /** @@ -103,16 +116,6 @@ struct vdpa_iova_range { u64 last; }; =20 -struct vdpa_dev_set_config { - u64 device_features; - struct { - u8 mac[ETH_ALEN]; - u16 mtu; - u16 max_vq_pairs; - } net; - u64 mask; -}; - /** * Corresponding file area for device memory mapping * @file: vma->vm_file for the mapping --=20 1.8.3.1 From nobody Fri Apr 10 12:39:05 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7912C4167B for ; Sat, 15 Oct 2022 01:34:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbiJOBd6 (ORCPT ); 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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_mai= n.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 *mde= v, const char *name, else ret =3D dev_set_name(&vdpa_dev->dev, "vdpa%u", vdpa_dev->index); =20 - ret =3D _vdpa_register_device(&adapter->vdpa, vf->nr_vring); + ret =3D _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 =3D true; mvdev->vdev.mdev =3D &mgtdev->mgtdev; - err =3D _vdpa_register_device(&mvdev->vdev, max_vqs + 1); + err =3D _vdpa_register_device(&mvdev->vdev, max_vqs + 1, add_config); if (err) goto err_reg; =20 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) =3D=3D 0); } =20 -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; =20 vdev->nvqs =3D nvqs; + if (cfg) + vdev->vdev_cfg =3D *cfg; + else + vdev->vdev_cfg.mask =3D 0ULL; =20 lockdep_assert_held(&vdpa_dev_lock); dev =3D 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; =20 - return __vdpa_register_device(vdev, nvqs); + return __vdpa_register_device(vdev, nvqs, cfg); } EXPORT_SYMBOL_GPL(_vdpa_register_device); =20 @@ -262,7 +269,7 @@ int vdpa_register_device(struct vdpa_device *vdev, u32 = nvqs) int err; =20 down_write(&vdpa_dev_lock); - err =3D __vdpa_register_device(vdev, nvqs); + err =3D __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/v= dpa_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 *md= ev, const char *name, if (IS_ERR(simdev)) return PTR_ERR(simdev); =20 - ret =3D _vdpa_register_device(&simdev->vdpa, VDPASIM_BLK_VQ_NUM); + ret =3D _vdpa_register_device(&simdev->vdpa, VDPASIM_BLK_VQ_NUM, config); if (ret) goto put_dev; =20 diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c b/drivers/vdpa/vdpa_sim/v= dpa_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 *md= ev, const char *name, =20 vdpasim_net_setup_config(simdev, config); =20 - ret =3D _vdpa_register_device(&simdev->vdpa, VDPASIM_NET_VQ_NUM); + ret =3D _vdpa_register_device(&simdev->vdpa, VDPASIM_NET_VQ_NUM, config); if (ret) goto reg_err; =20 diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vd= use_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, c= onst char *name, if (ret) return ret; =20 - ret =3D _vdpa_register_device(&dev->vdev->vdpa, dev->vq_num); + ret =3D _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 =3D VIRTIO_MSI_NO_VECTOR; =20 vp_vdpa->vdpa.mdev =3D &vp_vdpa_mgtdev->mgtdev; - ret =3D _vdpa_register_device(&vp_vdpa->vdpa, vp_vdpa->queues); + ret =3D _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); =20 -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); =20 /** --=20 1.8.3.1 From nobody Fri Apr 10 12:39:05 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3E9DC4332F for ; Sat, 15 Oct 2022 01:34:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229588AbiJOBeG (ORCPT ); Fri, 14 Oct 2022 21:34:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbiJOBdy (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 8966E53D2C for ; Fri, 14 Oct 2022 18:33:53 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29F0u44H027651; Sat, 15 Oct 2022 01:33:50 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=cSVJI1bSDiyO0vZzhdwXj6L1TMUgHBA1v+QaHDOHvCc=; b=IfuHSZymM5RMkxtJ+U+/2s+yzdRXI2qrxmh1qt7g/xINHzSpuwvWGYLpD+ZLqPaWn4XZ +t83Tbd5S8DX/B+CMloJlPJp8iq6VrUjGhEuClCjd6I+9sa9AoWRXf9JuyxC2OvMfBOI ekM7Mg9nn2+gR+/1VhObn/yAayDtUTG7uAju25nLz8hsQkWLdtICxauI9H8QPiZdrcR3 nbHPvKgimozGqOMk9mYFSTpPDoBB+t3zcOkpMUYVyO9s2cTqy22sjc0XxubYLF+J1xR6 D0EL22W9NDhTP93zHHIaWow21ZWblL6EefakdXsXon1DhuMqO9LV5CYwDugfHLdXccG7 0g== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k7acvh0yj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 15 Oct 2022 01:33:50 +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 29F1X479008564; Sat, 15 Oct 2022 01:33:49 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-4; Sat, 15 Oct 2022 01:33:49 +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 3/4] vdpa: show dev config as-is in "vdpa dev show" output Date: Fri, 14 Oct 2022 17:28:09 -0700 Message-Id: <1665793690-28120-4-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: F5060o5C_sKBkBOOjs3KTnP9fY_LiCyX X-Proofpoint-ORIG-GUID: F5060o5C_sKBkBOOjs3KTnP9fY_LiCyX Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Live migration of vdpa would typically require re-instate vdpa device with an idential set of configs on the destination node, same way as how source node created the device in the first place. In order to save orchestration software from memorizing and keeping track of vdpa config, it will be helpful if the vdpa tool provides the aids for exporting the initial configs from which vdpa device was created as-is. The "vdpa dev show" command seems to be the right vehicle for that. It is unlike the "vdpa dev config show" command output that usually goes with the live value in the device config space, which is not quite reliable subject to the dynamics of feature negotiation and possible change in device config space. Examples: 1) Create vDPA by default without any config attribute $ vdpa dev add mgmtdev pci/0000:41:04.2 name vdpa0 $ vdpa dev show vdpa0 vdpa0: type network mgmtdev pci/0000:41:04.2 vendor_id 5555 max_vqs 9 max_v= q_size 256 $ vdpa dev -jp show vdpa0 { "dev": { "vdpa0": { "type": "network", "mgmtdev": "pci/0000:41:04.2", "vendor_id": 5555, "max_vqs": 9, "max_vq_size": 256, } } } 2) Create vDPA with config attribute(s) specified $ vdpa dev add mgmtdev pci/0000:41:04.2 name vdpa0 \ mac e4:11:c6:d3:45:f0 max_vq_pairs 4 $ vdpa dev show vdpa0: type network mgmtdev pci/0000:41:04.2 vendor_id 5555 max_vqs 9 max_v= q_size 256 mac e4:11:c6:d3:45:f0 max_vq_pairs 4 $ vdpa dev -jp show { "dev": { "vdpa0": { "type": "network", "mgmtdev": "pci/0000:41:04.2", "vendor_id": 5555, "max_vqs": 9, "max_vq_size": 256, "mac": "e4:11:c6:d3:45:f0", "max_vq_pairs": 4 } } } Signed-off-by: Si-Wei Liu --- drivers/vdpa/vdpa.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index 566c1c6..91eca6d 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -677,6 +677,41 @@ static int vdpa_nl_cmd_dev_del_set_doit(struct sk_buff= *skb, struct genl_info *i } =20 static int +vdpa_dev_cfgattrs_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 = device_id) +{ + struct vdpa_dev_set_config *cfg =3D &vdev->vdev_cfg; + int err =3D -EMSGSIZE; + + if (!cfg->mask) + return 0; + + switch (device_id) { + case VIRTIO_ID_NET: + if ((cfg->mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MACADDR)) !=3D 0 && + nla_put(msg, VDPA_ATTR_DEV_NET_CFG_MACADDR, + sizeof(cfg->net.mac), cfg->net.mac)) + return err; + if ((cfg->mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)) !=3D 0 && + nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MTU, cfg->net.mtu)) + return err; + if ((cfg->mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP)) !=3D 0 && + nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, + cfg->net.max_vq_pairs)) + return err; + break; + default: + break; + } + + if ((cfg->mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES)) !=3D 0 && + nla_put_u64_64bit(msg, VDPA_ATTR_DEV_FEATURES, + cfg->device_features, VDPA_ATTR_PAD)) + return err; + + return 0; +} + +static int vdpa_dev_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid, u= 32 seq, int flags, struct netlink_ext_ack *extack) { @@ -715,6 +750,10 @@ static int vdpa_nl_cmd_dev_del_set_doit(struct sk_buff= *skb, struct genl_info *i if (nla_put_u16(msg, VDPA_ATTR_DEV_MIN_VQ_SIZE, min_vq_size)) goto msg_err; =20 + err =3D vdpa_dev_cfgattrs_fill(vdev, msg, device_id); + if (err) + goto msg_err; + genlmsg_end(msg, hdr); return 0; =20 --=20 1.8.3.1 From nobody Fri Apr 10 12:39:05 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A753C4332F for ; Sat, 15 Oct 2022 01:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229579AbiJOBeM (ORCPT ); Fri, 14 Oct 2022 21:34:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbiJOBd5 (ORCPT ); Fri, 14 Oct 2022 21:33:57 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E79F6C946 for ; Fri, 14 Oct 2022 18:33:55 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29F0pCq1025287; Sat, 15 Oct 2022 01:33:51 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=9ktHFLbxiHPNJk8/uwRXopWzYH45YEFFBA2qhx+h77s=; b=1m9moB4422aQ164SIfPyuWnegpRz2XJHvejcaSNzAu+8os4lbQYlKIwZXLwQ5iMLBwMM g+qqzvZBlED0wAb4d1jmtfmRoJ1vlGTUzfYPNUmPVabsVvYUggjQNOjSA9K8mVlxqrNI KcyWgVbP/UeH2PcP3t/ulD2QNPZ3ft63mWmgS8my/wHV6qtiTSjjT0/yWKSKxkF3J+px 91iLgoKhFFXeUoscOvdCFOeKySCYFUdb7hjJhJAmjL3vQOSBbQVLU47MAKYuipOhYOtQ 1PM4NauP5Gg9wpBk5R9qhXKQWDdbsc+UmMVxb5nXv7W3HSlYqM4BA6Wf85ESlt9HceCi cQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k79sg17d0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 15 Oct 2022 01:33:51 +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 29F1X47A008564; Sat, 15 Oct 2022 01:33:50 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-5; Sat, 15 Oct 2022 01:33:50 +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 4/4] vdpa: fix improper error message when adding vdpa dev Date: Fri, 14 Oct 2022 17:28:10 -0700 Message-Id: <1665793690-28120-5-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: EdPlJR4y-Udb6aZ_Vf42AaiPUyLPzCvj X-Proofpoint-ORIG-GUID: EdPlJR4y-Udb6aZ_Vf42AaiPUyLPzCvj Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In below example, before the fix, mtu attribute is supported by the parent mgmtdev, but the error message showing "All provided are not supported" is just misleading. $ vdpa mgmtdev show vdpasim_net: supported_classes net max_supported_vqs 3 dev_features MTU MAC CTRL_VQ CTRL_MAC_ADDR ANY_LAYOUT VERSION_1 ACCESS_PL= ATFORM $ vdpa dev add mgmtdev vdpasim_net name vdpasim0 mtu 5000 max_vqp 2 Error: vdpa: All provided attributes are not supported. kernel answers: Operation not supported After fix, the relevant error message will be like: $ vdpa dev add mgmtdev vdpasim_net name vdpasim0 mtu 5000 max_vqp 2 Error: vdpa: Some provided attributes are not supported. kernel answers: Operation not supported $ vdpa dev add mgmtdev vdpasim_net name vdpasim0 max_vqp 2 Error: vdpa: All provided attributes are not supported. kernel answers: Operation not supported Signed-off-by: Si-Wei Liu --- drivers/vdpa/vdpa.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c index 91eca6d..ff15e0a 100644 --- a/drivers/vdpa/vdpa.c +++ b/drivers/vdpa/vdpa.c @@ -629,13 +629,20 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buf= f *skb, struct genl_info *i err =3D PTR_ERR(mdev); goto err; } - if ((config.mask & mdev->config_attr_mask) !=3D config.mask) { + if (config.mask && (config.mask & mdev->config_attr_mask) =3D=3D 0) { NL_SET_ERR_MSG_MOD(info->extack, "All provided attributes are not supported"); err =3D -EOPNOTSUPP; goto err; } =20 + if ((config.mask & mdev->config_attr_mask) !=3D config.mask) { + NL_SET_ERR_MSG_MOD(info->extack, + "Some provided attributes are not supported"); + err =3D -EOPNOTSUPP; + goto err; + } + err =3D mdev->ops->dev_add(mdev, name, &config); err: up_write(&vdpa_dev_lock); --=20 1.8.3.1