@@ -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");
@@ -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;
@@ -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->init_cfg = *cfg;
+ else
+ vdev->init_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;
}
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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);
/**