Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/mlx5: Simplify mlx5_sriov_is_enabled() by using pci core API

It is desired to get rid of num_vfs stored inside mlx5_core_sriov to
safely support vports more than vfs.
To reduce dependency on mlx5_core_sriov num_vfs, start using
pci_num_vf() from pci core.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Bodong Wang <bodong@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>

authored by

Parav Pandit and committed by
Saeed Mahameed
eb5cc431 2aca1787

+5 -8
+5 -1
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
··· 111 111 int mlx5_sriov_attach(struct mlx5_core_dev *dev); 112 112 void mlx5_sriov_detach(struct mlx5_core_dev *dev); 113 113 int mlx5_core_sriov_configure(struct pci_dev *dev, int num_vfs); 114 - bool mlx5_sriov_is_enabled(struct mlx5_core_dev *dev); 115 114 int mlx5_core_enable_hca(struct mlx5_core_dev *dev, u16 func_id); 116 115 int mlx5_core_disable_hca(struct mlx5_core_dev *dev, u16 func_id); 117 116 int mlx5_create_scheduling_element_cmd(struct mlx5_core_dev *dev, u8 hierarchy, ··· 174 175 175 176 void mlx5e_init(void); 176 177 void mlx5e_cleanup(void); 178 + 179 + static inline bool mlx5_sriov_is_enabled(struct mlx5_core_dev *dev) 180 + { 181 + return pci_num_vf(dev->pdev) ? true : false; 182 + } 177 183 178 184 static inline int mlx5_lag_is_lacp_owner(struct mlx5_core_dev *dev) 179 185 {
-7
drivers/net/ethernet/mellanox/mlx5/core/sriov.c
··· 36 36 #include "mlx5_core.h" 37 37 #include "eswitch.h" 38 38 39 - bool mlx5_sriov_is_enabled(struct mlx5_core_dev *dev) 40 - { 41 - struct mlx5_core_sriov *sriov = &dev->priv.sriov; 42 - 43 - return !!sriov->num_vfs; 44 - } 45 - 46 39 static int sriov_restore_guids(struct mlx5_core_dev *dev, int vf) 47 40 { 48 41 struct mlx5_core_sriov *sriov = &dev->priv.sriov;