History

net/mlx5: Support querying max VFs from device

For ECPF with eswitch manager privilege, query the host max VF count by querying the device using query_functions command. With this enhancement: 1. flow steering entries are created only for valid vports based on the max VF count of the PF. 2. Driver only queries cap of valid vport. Eswitch requires the max VFs when doing initialization, so do sr-iov init before eswitch init.

Bodong Wang committed 7 years ago

Commit 86eec501 parent 10ee82c4 files · +34 −15Browse files

Unified · Split

4 files
  1. drivers/net/ethernet/mellanox/mlx5/core/main.c +9 −9
  2. drivers/net/ethernet/mellanox/mlx5/core/sriov.c +22 −0
  3. include/linux/mlx5/driver.h +2 −5
  4. include/linux/mlx5/mlx5_ifc.h +1 −1
drivers/net/ethernet/mellanox/mlx5/core/main.c+9−9
@@ -844,32 +844,32 @@ static int mlx5_init_once(struct mlx5_core_dev *dev) · 843 unmodified lines
844 goto err_rl_cleanup;844 goto err_rl_cleanup;
845 }845 }
846 846
847 err = mlx5_eswitch_init(dev);847 err = mlx5_sriov_init(dev);
848 if (err) {848 if (err) {
849 mlx5_core_err(dev, "Failed to init eswitch %d\n", err);849 mlx5_core_err(dev, "Failed to init sriov %d\n", err);
850 goto err_mpfs_cleanup;850 goto err_mpfs_cleanup;
851 }851 }
852 852
853 err = mlx5_sriov_init(dev);853 err = mlx5_eswitch_init(dev);
854 if (err) {854 if (err) {
855 mlx5_core_err(dev, "Failed to init sriov %d\n", err);855 mlx5_core_err(dev, "Failed to init eswitch %d\n", err);
856 goto err_eswitch_cleanup;856 goto err_sriov_cleanup;
857 }857 }
858 858
859 err = mlx5_fpga_init(dev);859 err = mlx5_fpga_init(dev);
860 if (err) {860 if (err) {
861 mlx5_core_err(dev, "Failed to init fpga device %d\n", err);861 mlx5_core_err(dev, "Failed to init fpga device %d\n", err);
862 goto err_sriov_cleanup;862 goto err_eswitch_cleanup;
863 }863 }
864 864
865 dev->tracer = mlx5_fw_tracer_create(dev);865 dev->tracer = mlx5_fw_tracer_create(dev);
866 866
867 return 0;867 return 0;
868 868
869err_sriov_cleanup:
870 mlx5_sriov_cleanup(dev);
871err_eswitch_cleanup:869err_eswitch_cleanup:
872 mlx5_eswitch_cleanup(dev->priv.eswitch);870 mlx5_eswitch_cleanup(dev->priv.eswitch);
871err_sriov_cleanup:
872 mlx5_sriov_cleanup(dev);
873err_mpfs_cleanup:873err_mpfs_cleanup:
874 mlx5_mpfs_cleanup(dev);874 mlx5_mpfs_cleanup(dev);
875err_rl_cleanup:875err_rl_cleanup:
@@ -893,8 +893,8 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev) · 17 unmodified lines
893{893{
894 mlx5_fw_tracer_destroy(dev->tracer);894 mlx5_fw_tracer_destroy(dev->tracer);
895 mlx5_fpga_cleanup(dev);895 mlx5_fpga_cleanup(dev);
896 mlx5_sriov_cleanup(dev);
897 mlx5_eswitch_cleanup(dev->priv.eswitch);896 mlx5_eswitch_cleanup(dev->priv.eswitch);
897 mlx5_sriov_cleanup(dev);
898 mlx5_mpfs_cleanup(dev);898 mlx5_mpfs_cleanup(dev);
899 mlx5_cleanup_rl_table(dev);899 mlx5_cleanup_rl_table(dev);
900 mlx5_vxlan_destroy(dev->vxlan);900 mlx5_vxlan_destroy(dev->vxlan);
drivers/net/ethernet/mellanox/mlx5/core/sriov.c+22−0
@@ -208,6 +208,27 @@ void mlx5_sriov_detach(struct mlx5_core_dev *dev) · 207 unmodified lines
208 mlx5_device_disable_sriov(dev);208 mlx5_device_disable_sriov(dev);
209}209}
210 210
211static u16 mlx5_get_max_vfs(struct mlx5_core_dev *dev)
212{
213 u32 out[MLX5_ST_SZ_DW(query_esw_functions_out)] = {};
214 u16 host_total_vfs;
215 int err;
216
217 if (mlx5_core_is_ecpf_esw_manager(dev)) {
218 err = mlx5_esw_query_functions(dev, out, sizeof(out));
219 host_total_vfs = MLX5_GET(query_esw_functions_out, out,
220 host_params_context.host_total_vfs);
221
222 /* Old FW doesn't support getting total_vfs from esw func
223 * but supports getting it from pci_sriov.
224 */
225 if (!err && host_total_vfs)
226 return host_total_vfs;
227 }
228
229 return pci_sriov_get_totalvfs(dev->pdev);
230}
231
211int mlx5_sriov_init(struct mlx5_core_dev *dev)232int mlx5_sriov_init(struct mlx5_core_dev *dev)
212{233{
213 struct mlx5_core_sriov *sriov = &dev->priv.sriov;234 struct mlx5_core_sriov *sriov = &dev->priv.sriov;
@@ -218,6 +239,7 @@ int mlx5_sriov_init(struct mlx5_core_dev *dev) · 4 unmodified lines
218 return 0;239 return 0;
219 240
220 total_vfs = pci_sriov_get_totalvfs(pdev);241 total_vfs = pci_sriov_get_totalvfs(pdev);
242 sriov->max_vfs = mlx5_get_max_vfs(dev);
221 sriov->num_vfs = pci_num_vf(pdev);243 sriov->num_vfs = pci_num_vf(pdev);
222 sriov->vfs_ctx = kcalloc(total_vfs, sizeof(*sriov->vfs_ctx), GFP_KERNEL);244 sriov->vfs_ctx = kcalloc(total_vfs, sizeof(*sriov->vfs_ctx), GFP_KERNEL);
223 if (!sriov->vfs_ctx)245 if (!sriov->vfs_ctx)
include/linux/mlx5/driver.h+2−5
@@ -470,6 +470,7 @@ struct mlx5_core_sriov { · 469 unmodified lines
470 struct mlx5_vf_context *vfs_ctx;470 struct mlx5_vf_context *vfs_ctx;
471 int num_vfs;471 int num_vfs;
472 int enabled_vfs;472 int enabled_vfs;
473 u16 max_vfs;
473};474};
474 475
475struct mlx5_fc_stats {476struct mlx5_fc_stats {
@@ -1103,13 +1104,9 @@ static inline bool mlx5_ecpf_vport_exists(struct mlx5_core_dev *dev) · 627 unmodified lines
1103 return mlx5_core_is_pf(dev) && MLX5_CAP_ESW(dev, ecpf_vport_exists);1104 return mlx5_core_is_pf(dev) && MLX5_CAP_ESW(dev, ecpf_vport_exists);
1104}1105}
1105 1106
1106#define MLX5_HOST_PF_MAX_VFS (127u)
1107static inline u16 mlx5_core_max_vfs(struct mlx5_core_dev *dev)1107static inline u16 mlx5_core_max_vfs(struct mlx5_core_dev *dev)
1108{1108{
1109 if (mlx5_core_is_ecpf_esw_manager(dev))1109 return dev->priv.sriov.max_vfs;
1110 return MLX5_HOST_PF_MAX_VFS;
1111 else
1112 return pci_sriov_get_totalvfs(dev->pdev);
1113}1110}
1114 1111
1115static inline int mlx5_get_gid_table_len(u16 param)1112static inline int mlx5_get_gid_table_len(u16 param)
include/linux/mlx5/mlx5_ifc.h+1−1
@@ -9711,7 +9711,7 @@ struct mlx5_ifc_host_params_context_bits { · 9710 unmodified lines
9711 u8 reserved_at_8[0x8];9711 u8 reserved_at_8[0x8];
9712 u8 host_num_of_vfs[0x10];9712 u8 host_num_of_vfs[0x10];
9713 9713
9714 u8 reserved_at_20[0x10];9714 u8 host_total_vfs[0x10];
9715 u8 host_pci_bus[0x10];9715 u8 host_pci_bus[0x10];
9716 9716
9717 u8 reserved_at_40[0x10];9717 u8 reserved_at_40[0x10];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t