net/mlx5: Implement sriov_get_vf_total_msix/count() callbacks
The mlx5 implementation executes a firmware command on the PF to change the configuration of the selected VF. Link: https://lore.kernel.org/linux-pci/20210314124256.70253-5-leon@kernel.org Acked-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
This commit is contained in:
parent
604774add5
commit
e71b75f737
@ -1700,6 +1700,8 @@ static struct pci_driver mlx5_core_driver = {
|
|||||||
.shutdown = shutdown,
|
.shutdown = shutdown,
|
||||||
.err_handler = &mlx5_err_handler,
|
.err_handler = &mlx5_err_handler,
|
||||||
.sriov_configure = mlx5_core_sriov_configure,
|
.sriov_configure = mlx5_core_sriov_configure,
|
||||||
|
.sriov_get_vf_total_msix = mlx5_sriov_get_vf_total_msix,
|
||||||
|
.sriov_set_msix_vec_count = mlx5_core_sriov_set_msix_vec_count,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void mlx5_core_verify_params(void)
|
static void mlx5_core_verify_params(void)
|
||||||
|
@ -140,6 +140,7 @@ void mlx5_sriov_cleanup(struct mlx5_core_dev *dev);
|
|||||||
int mlx5_sriov_attach(struct mlx5_core_dev *dev);
|
int mlx5_sriov_attach(struct mlx5_core_dev *dev);
|
||||||
void mlx5_sriov_detach(struct mlx5_core_dev *dev);
|
void mlx5_sriov_detach(struct mlx5_core_dev *dev);
|
||||||
int mlx5_core_sriov_configure(struct pci_dev *dev, int num_vfs);
|
int mlx5_core_sriov_configure(struct pci_dev *dev, int num_vfs);
|
||||||
|
int mlx5_core_sriov_set_msix_vec_count(struct pci_dev *vf, int msix_vec_count);
|
||||||
int mlx5_core_enable_hca(struct mlx5_core_dev *dev, u16 func_id);
|
int mlx5_core_enable_hca(struct mlx5_core_dev *dev, u16 func_id);
|
||||||
int mlx5_core_disable_hca(struct mlx5_core_dev *dev, u16 func_id);
|
int mlx5_core_disable_hca(struct mlx5_core_dev *dev, u16 func_id);
|
||||||
int mlx5_create_scheduling_element_cmd(struct mlx5_core_dev *dev, u8 hierarchy,
|
int mlx5_create_scheduling_element_cmd(struct mlx5_core_dev *dev, u8 hierarchy,
|
||||||
@ -278,4 +279,10 @@ int mlx5_load_one(struct mlx5_core_dev *dev, bool boot);
|
|||||||
int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out);
|
int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out);
|
||||||
|
|
||||||
void mlx5_events_work_enqueue(struct mlx5_core_dev *dev, struct work_struct *work);
|
void mlx5_events_work_enqueue(struct mlx5_core_dev *dev, struct work_struct *work);
|
||||||
|
static inline u32 mlx5_sriov_get_vf_total_msix(struct pci_dev *pdev)
|
||||||
|
{
|
||||||
|
struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
|
||||||
|
|
||||||
|
return MLX5_CAP_GEN_MAX(dev, num_total_dynamic_vf_msix);
|
||||||
|
}
|
||||||
#endif /* __MLX5_CORE_H__ */
|
#endif /* __MLX5_CORE_H__ */
|
||||||
|
@ -187,6 +187,41 @@ int mlx5_core_sriov_configure(struct pci_dev *pdev, int num_vfs)
|
|||||||
return err ? err : num_vfs;
|
return err ? err : num_vfs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mlx5_core_sriov_set_msix_vec_count(struct pci_dev *vf, int msix_vec_count)
|
||||||
|
{
|
||||||
|
struct pci_dev *pf = pci_physfn(vf);
|
||||||
|
struct mlx5_core_sriov *sriov;
|
||||||
|
struct mlx5_core_dev *dev;
|
||||||
|
int num_vf_msix, id;
|
||||||
|
|
||||||
|
dev = pci_get_drvdata(pf);
|
||||||
|
num_vf_msix = MLX5_CAP_GEN_MAX(dev, num_total_dynamic_vf_msix);
|
||||||
|
if (!num_vf_msix)
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
if (!msix_vec_count)
|
||||||
|
msix_vec_count =
|
||||||
|
mlx5_get_default_msix_vec_count(dev, pci_num_vf(pf));
|
||||||
|
|
||||||
|
sriov = &dev->priv.sriov;
|
||||||
|
|
||||||
|
/* Reversed translation of PCI VF function number to the internal
|
||||||
|
* function_id, which exists in the name of virtfn symlink.
|
||||||
|
*/
|
||||||
|
for (id = 0; id < pci_num_vf(pf); id++) {
|
||||||
|
if (!sriov->vfs_ctx[id].enabled)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (vf->devfn == pci_iov_virtfn_devfn(pf, id))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id == pci_num_vf(pf) || !sriov->vfs_ctx[id].enabled)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
return mlx5_set_msix_vec_count(dev, id + 1, msix_vec_count);
|
||||||
|
}
|
||||||
|
|
||||||
int mlx5_sriov_attach(struct mlx5_core_dev *dev)
|
int mlx5_sriov_attach(struct mlx5_core_dev *dev)
|
||||||
{
|
{
|
||||||
if (!mlx5_core_is_pf(dev) || !pci_num_vf(dev->pdev))
|
if (!mlx5_core_is_pf(dev) || !pci_num_vf(dev->pdev))
|
||||||
|
Loading…
Reference in New Issue
Block a user