Lines Matching refs:dev

40 static int sriov_restore_guids(struct mlx5_core_dev *dev, int vf, u16 func_id)  in sriov_restore_guids()  argument
42 struct mlx5_core_sriov *sriov = &dev->priv.sriov; in sriov_restore_guids()
62 err = mlx5_core_modify_hca_vport_context(dev, 1, 1, func_id, in); in sriov_restore_guids()
64 mlx5_core_warn(dev, "modify vport context failed, unable to restore VF %d settings\n", vf); in sriov_restore_guids()
72 static int mlx5_device_enable_sriov(struct mlx5_core_dev *dev, int num_vfs) in mlx5_device_enable_sriov() argument
74 struct mlx5_core_sriov *sriov = &dev->priv.sriov; in mlx5_device_enable_sriov()
78 err = mlx5_eswitch_enable(dev->priv.eswitch, num_vfs); in mlx5_device_enable_sriov()
80 mlx5_core_warn(dev, in mlx5_device_enable_sriov()
85 num_msix_count = mlx5_get_default_msix_vec_count(dev, num_vfs); in mlx5_device_enable_sriov()
91 MLX5_PF_NOTIFY_ENABLE_VF, dev); in mlx5_device_enable_sriov()
92 err = mlx5_core_enable_hca(dev, vf + 1); in mlx5_device_enable_sriov()
94 mlx5_core_warn(dev, "failed to enable VF %d (%d)\n", vf, err); in mlx5_device_enable_sriov()
98 err = mlx5_set_msix_vec_count(dev, vf + 1, num_msix_count); in mlx5_device_enable_sriov()
100 mlx5_core_warn(dev, in mlx5_device_enable_sriov()
107 if (MLX5_CAP_GEN(dev, port_type) == MLX5_CAP_PORT_TYPE_IB) { in mlx5_device_enable_sriov()
108 vport_num = mlx5_core_ec_sriov_enabled(dev) ? in mlx5_device_enable_sriov()
109 mlx5_core_ec_vf_vport_base(dev) + vf in mlx5_device_enable_sriov()
111 err = sriov_restore_guids(dev, vf, vport_num); in mlx5_device_enable_sriov()
113 mlx5_core_warn(dev, in mlx5_device_enable_sriov()
119 mlx5_core_dbg(dev, "successfully enabled VF* %d\n", vf); in mlx5_device_enable_sriov()
126 mlx5_device_disable_sriov(struct mlx5_core_dev *dev, int num_vfs, bool clear_vf, bool num_vf_change) in mlx5_device_disable_sriov() argument
128 struct mlx5_core_sriov *sriov = &dev->priv.sriov; in mlx5_device_disable_sriov()
141 MLX5_PF_NOTIFY_DISABLE_VF, dev); in mlx5_device_disable_sriov()
142 err = mlx5_core_disable_hca(dev, vf + 1); in mlx5_device_disable_sriov()
144 mlx5_core_warn(dev, "failed to disable VF %d\n", vf); in mlx5_device_disable_sriov()
150 mlx5_eswitch_disable_sriov(dev->priv.eswitch, clear_vf); in mlx5_device_disable_sriov()
162 if (mlx5_core_ec_sriov_enabled(dev)) in mlx5_device_disable_sriov()
168 if (wait_for_ec_vf_pages && mlx5_wait_for_pages(dev, &dev->priv.page_counters[MLX5_EC_VF])) in mlx5_device_disable_sriov()
169 mlx5_core_warn(dev, "timeout reclaiming EC VFs pages\n"); in mlx5_device_disable_sriov()
172 if (mlx5_core_is_ecpf(dev)) in mlx5_device_disable_sriov()
175 if (wait_for_vf_pages && mlx5_wait_for_pages(dev, &dev->priv.page_counters[MLX5_VF])) in mlx5_device_disable_sriov()
176 mlx5_core_warn(dev, "timeout reclaiming VFs pages\n"); in mlx5_device_disable_sriov()
181 struct mlx5_core_dev *dev = pci_get_drvdata(pdev); in mlx5_sriov_enable() local
182 struct devlink *devlink = priv_to_devlink(dev); in mlx5_sriov_enable()
186 err = mlx5_device_enable_sriov(dev, num_vfs); in mlx5_sriov_enable()
189 mlx5_core_warn(dev, "mlx5_device_enable_sriov failed : %d\n", err); in mlx5_sriov_enable()
195 mlx5_core_warn(dev, "pci_enable_sriov failed : %d\n", err); in mlx5_sriov_enable()
196 mlx5_device_disable_sriov(dev, num_vfs, true, true); in mlx5_sriov_enable()
203 struct mlx5_core_dev *dev = pci_get_drvdata(pdev); in mlx5_sriov_disable() local
204 struct devlink *devlink = priv_to_devlink(dev); in mlx5_sriov_disable()
205 int num_vfs = pci_num_vf(dev->pdev); in mlx5_sriov_disable()
209 mlx5_device_disable_sriov(dev, num_vfs, true, num_vf_change); in mlx5_sriov_disable()
215 struct mlx5_core_dev *dev = pci_get_drvdata(pdev); in mlx5_core_sriov_configure() local
216 struct mlx5_core_sriov *sriov = &dev->priv.sriov; in mlx5_core_sriov_configure()
219 mlx5_core_dbg(dev, "requested num_vfs %d\n", num_vfs); in mlx5_core_sriov_configure()
235 struct mlx5_core_dev *dev; in mlx5_core_sriov_set_msix_vec_count() local
238 dev = pci_get_drvdata(pf); in mlx5_core_sriov_set_msix_vec_count()
239 num_vf_msix = MLX5_CAP_GEN_MAX(dev, num_total_dynamic_vf_msix); in mlx5_core_sriov_set_msix_vec_count()
245 mlx5_get_default_msix_vec_count(dev, pci_num_vf(pf)); in mlx5_core_sriov_set_msix_vec_count()
247 sriov = &dev->priv.sriov; in mlx5_core_sriov_set_msix_vec_count()
252 return mlx5_set_msix_vec_count(dev, id + 1, msix_vec_count); in mlx5_core_sriov_set_msix_vec_count()
255 int mlx5_sriov_attach(struct mlx5_core_dev *dev) in mlx5_sriov_attach() argument
257 if (!mlx5_core_is_pf(dev) || !pci_num_vf(dev->pdev)) in mlx5_sriov_attach()
261 return mlx5_device_enable_sriov(dev, pci_num_vf(dev->pdev)); in mlx5_sriov_attach()
264 void mlx5_sriov_detach(struct mlx5_core_dev *dev) in mlx5_sriov_detach() argument
266 if (!mlx5_core_is_pf(dev)) in mlx5_sriov_detach()
269 mlx5_device_disable_sriov(dev, pci_num_vf(dev->pdev), false, false); in mlx5_sriov_detach()
272 static u16 mlx5_get_max_vfs(struct mlx5_core_dev *dev) in mlx5_get_max_vfs() argument
277 if (mlx5_core_is_ecpf_esw_manager(dev)) { in mlx5_get_max_vfs()
278 out = mlx5_esw_query_functions(dev); in mlx5_get_max_vfs()
292 return pci_sriov_get_totalvfs(dev->pdev); in mlx5_get_max_vfs()
295 int mlx5_sriov_init(struct mlx5_core_dev *dev) in mlx5_sriov_init() argument
297 struct mlx5_core_sriov *sriov = &dev->priv.sriov; in mlx5_sriov_init()
298 struct pci_dev *pdev = dev->pdev; in mlx5_sriov_init()
301 if (!mlx5_core_is_pf(dev)) in mlx5_sriov_init()
305 sriov->max_vfs = mlx5_get_max_vfs(dev); in mlx5_sriov_init()
307 sriov->max_ec_vfs = mlx5_core_ec_sriov_enabled(dev) ? pci_sriov_get_totalvfs(dev->pdev) : 0; in mlx5_sriov_init()
318 void mlx5_sriov_cleanup(struct mlx5_core_dev *dev) in mlx5_sriov_cleanup() argument
320 struct mlx5_core_sriov *sriov = &dev->priv.sriov; in mlx5_sriov_cleanup()
322 if (!mlx5_core_is_pf(dev)) in mlx5_sriov_cleanup()