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
844844 goto err_rl_cleanup;
845845 }
846846
847− err = mlx5_eswitch_init(dev);
847+ err = mlx5_sriov_init(dev);
848848 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);
850850 goto err_mpfs_cleanup;
851851 }
852852
853− err = mlx5_sriov_init(dev);
853+ err = mlx5_eswitch_init(dev);
854854 if (err) {
855− mlx5_core_err(dev, "Failed to init sriov %d\n", err);
856− goto err_eswitch_cleanup;
855+ mlx5_core_err(dev, "Failed to init eswitch %d\n", err);
856+ goto err_sriov_cleanup;
857857 }
858858
859859 err = mlx5_fpga_init(dev);
860860 if (err) {
861861 mlx5_core_err(dev, "Failed to init fpga device %d\n", err);
862− goto err_sriov_cleanup;
862+ goto err_eswitch_cleanup;
863863 }
864864
865865 dev->tracer = mlx5_fw_tracer_create(dev);
866866
867867 return 0;
868868
869−err_sriov_cleanup:
870− mlx5_sriov_cleanup(dev);
871869 err_eswitch_cleanup:
872870 mlx5_eswitch_cleanup(dev->priv.eswitch);
871+err_sriov_cleanup:
872+ mlx5_sriov_cleanup(dev);
873873 err_mpfs_cleanup:
874874 mlx5_mpfs_cleanup(dev);
875875 err_rl_cleanup:
@@ -893,8 +893,8 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev) · 17 unmodified lines
893893 {
894894 mlx5_fw_tracer_destroy(dev->tracer);
895895 mlx5_fpga_cleanup(dev);
896− mlx5_sriov_cleanup(dev);
897896 mlx5_eswitch_cleanup(dev->priv.eswitch);
897+ mlx5_sriov_cleanup(dev);
898898 mlx5_mpfs_cleanup(dev);
899899 mlx5_cleanup_rl_table(dev);
900900 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
208208 mlx5_device_disable_sriov(dev);
209209 }
210210
211+static 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+
211232 int mlx5_sriov_init(struct mlx5_core_dev *dev)
212233 {
213234 struct mlx5_core_sriov *sriov = &dev->priv.sriov;
@@ -218,6 +239,7 @@ int mlx5_sriov_init(struct mlx5_core_dev *dev) · 4 unmodified lines
218239 return 0;
219240
220241 total_vfs = pci_sriov_get_totalvfs(pdev);
242+ sriov->max_vfs = mlx5_get_max_vfs(dev);
221243 sriov->num_vfs = pci_num_vf(pdev);
222244 sriov->vfs_ctx = kcalloc(total_vfs, sizeof(*sriov->vfs_ctx), GFP_KERNEL);
223245 if (!sriov->vfs_ctx)
include/linux/mlx5/driver.h+2−5
@@ -470,6 +470,7 @@ struct mlx5_core_sriov { · 469 unmodified lines
470470 struct mlx5_vf_context *vfs_ctx;
471471 int num_vfs;
472472 int enabled_vfs;
473+ u16 max_vfs;
473474 };
474475
475476 struct mlx5_fc_stats {
@@ -1103,13 +1104,9 @@ static inline bool mlx5_ecpf_vport_exists(struct mlx5_core_dev *dev) · 627 unmodified lines
11031104 return mlx5_core_is_pf(dev) && MLX5_CAP_ESW(dev, ecpf_vport_exists);
11041105 }
11051106
1106−#define MLX5_HOST_PF_MAX_VFS (127u)
11071107 static inline u16 mlx5_core_max_vfs(struct mlx5_core_dev *dev)
11081108 {
1109− if (mlx5_core_is_ecpf_esw_manager(dev))
1110− return MLX5_HOST_PF_MAX_VFS;
1111− else
1112− return pci_sriov_get_totalvfs(dev->pdev);
1109+ return dev->priv.sriov.max_vfs;
11131110 }
11141111
11151112 static 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
97119711 u8 reserved_at_8[0x8];
97129712 u8 host_num_of_vfs[0x10];
97139713
9714− u8 reserved_at_20[0x10];
9714+ u8 host_total_vfs[0x10];
97159715 u8 host_pci_bus[0x10];
97169716
97179717 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