return mlx5_core_is_ecpf_esw_manager(dev);
}
-int mlx5_cmd_host_pf_enable_hca(struct mlx5_core_dev *dev)
+int mlx5_cmd_pf_enable_hca(struct mlx5_core_dev *dev, u16 vport_num)
{
u32 out[MLX5_ST_SZ_DW(enable_hca_out)] = {};
u32 in[MLX5_ST_SZ_DW(enable_hca_in)] = {};
+ u16 vhca_id;
MLX5_SET(enable_hca_in, in, opcode, MLX5_CMD_OP_ENABLE_HCA);
- MLX5_SET(enable_hca_in, in, function_id, 0);
- MLX5_SET(enable_hca_in, in, embedded_cpu_function, 0);
- return mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
+ if (mlx5_vport_use_vhca_id_as_func_id(dev, vport_num, &vhca_id)) {
+ MLX5_SET(enable_hca_in, in, function_id, vhca_id);
+ MLX5_SET(enable_hca_in, in, function_id_type, 1);
+ } else {
+ MLX5_SET(enable_hca_in, in, function_id, vport_num);
+ }
+ return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
}
-int mlx5_cmd_host_pf_disable_hca(struct mlx5_core_dev *dev)
+int mlx5_cmd_pf_disable_hca(struct mlx5_core_dev *dev, u16 vport_num)
{
u32 out[MLX5_ST_SZ_DW(disable_hca_out)] = {};
u32 in[MLX5_ST_SZ_DW(disable_hca_in)] = {};
+ u16 vhca_id;
MLX5_SET(disable_hca_in, in, opcode, MLX5_CMD_OP_DISABLE_HCA);
- MLX5_SET(disable_hca_in, in, function_id, 0);
- MLX5_SET(disable_hca_in, in, embedded_cpu_function, 0);
+ if (mlx5_vport_use_vhca_id_as_func_id(dev, vport_num, &vhca_id)) {
+ MLX5_SET(disable_hca_in, in, function_id, vhca_id);
+ MLX5_SET(disable_hca_in, in, function_id_type, 1);
+ } else {
+ MLX5_SET(disable_hca_in, in, function_id, vport_num);
+ }
return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
}
int mlx5_ec_init(struct mlx5_core_dev *dev);
void mlx5_ec_cleanup(struct mlx5_core_dev *dev);
-int mlx5_cmd_host_pf_enable_hca(struct mlx5_core_dev *dev);
-int mlx5_cmd_host_pf_disable_hca(struct mlx5_core_dev *dev);
+int mlx5_cmd_pf_enable_hca(struct mlx5_core_dev *dev, u16 vport_num);
+int mlx5_cmd_pf_disable_hca(struct mlx5_core_dev *dev, u16 vport_num);
#else /* CONFIG_MLX5_ESWITCH */
return err;
}
-int mlx5_esw_host_pf_enable_hca(struct mlx5_core_dev *dev)
+static int mlx5_esw_pf_enable_hca(struct mlx5_core_dev *dev, u16 vport_num)
{
struct mlx5_eswitch *esw = dev->priv.eswitch;
struct mlx5_vport *vport;
if (!mlx5_core_is_ecpf(dev) || !mlx5_esw_allowed(esw))
return 0;
- vport = mlx5_eswitch_get_vport(esw, MLX5_VPORT_HOST_PF);
+ vport = mlx5_eswitch_get_vport(esw, vport_num);
if (IS_ERR(vport))
return PTR_ERR(vport);
- /* Once vport and representor are ready, take out the external host PF
- * out of initializing state. Enabling HCA clears the iser->initializing
- * bit and host PF driver loading can progress.
+ /* Once vport and representor are ready, take the PF out of
+ * initializing state. Enabling HCA clears the iser->initializing
+ * bit and PF driver loading can progress.
*/
- err = mlx5_cmd_host_pf_enable_hca(dev);
+ err = mlx5_cmd_pf_enable_hca(dev, vport_num);
if (err)
return err;
return 0;
}
-int mlx5_esw_host_pf_disable_hca(struct mlx5_core_dev *dev)
+static int mlx5_esw_pf_disable_hca(struct mlx5_core_dev *dev, u16 vport_num)
{
struct mlx5_eswitch *esw = dev->priv.eswitch;
struct mlx5_vport *vport;
if (!mlx5_core_is_ecpf(dev) || !mlx5_esw_allowed(esw))
return 0;
- vport = mlx5_eswitch_get_vport(esw, MLX5_VPORT_HOST_PF);
+ vport = mlx5_eswitch_get_vport(esw, vport_num);
if (IS_ERR(vport))
return PTR_ERR(vport);
- err = mlx5_cmd_host_pf_disable_hca(dev);
+ err = mlx5_cmd_pf_disable_hca(dev, vport_num);
if (err)
return err;
return 0;
}
+int mlx5_esw_host_pf_enable_hca(struct mlx5_core_dev *dev)
+{
+ return mlx5_esw_pf_enable_hca(dev, MLX5_VPORT_HOST_PF);
+}
+
+int mlx5_esw_host_pf_disable_hca(struct mlx5_core_dev *dev)
+{
+ return mlx5_esw_pf_disable_hca(dev, MLX5_VPORT_HOST_PF);
+}
+
/* mlx5_eswitch_enable_pf_vf_vports() enables vports of PF, ECPF and VFs
* whichever are present on the eswitch.
*/
void mlx5_query_nic_sw_system_image_guid(struct mlx5_core_dev *mdev, u8 *buf,
u8 *len);
+bool mlx5_vport_use_vhca_id_as_func_id(struct mlx5_core_dev *dev,
+ u16 vport_num, u16 *vhca_id);
int mlx5_vport_set_other_func_cap(struct mlx5_core_dev *dev, const void *hca_cap, u16 vport,
u16 opmod);
#define mlx5_vport_get_other_func_general_cap(dev, vport, out) \
buf[(*len)++] = MLX5_CAP_GEN_2(mdev, load_balance_id);
}
-static bool mlx5_vport_use_vhca_id_as_func_id(struct mlx5_core_dev *dev,
- u16 vport_num, u16 *vhca_id)
+bool mlx5_vport_use_vhca_id_as_func_id(struct mlx5_core_dev *dev,
+ u16 vport_num, u16 *vhca_id)
{
if (!MLX5_CAP_GEN_2(dev, function_id_type_vhca_id))
return false;