return mlx5_esw_host_pf_from_host_params(entry);
}
+bool mlx5_esw_get_spf_disabled(struct mlx5_core_dev *dev, const u32 *out,
+ u16 vhca_id)
+{
+ int num_entries;
+ const u8 *entry;
+ int i;
+
+ num_entries = MLX5_GET(query_esw_functions_out, out, net_function_num);
+ entry = MLX5_ADDR_OF(query_esw_functions_out, out, net_function_params);
+
+ for (i = 0; i < num_entries; i++) {
+ u16 entry_vhca_id = MLX5_GET(network_function_params,
+ entry, vhca_id);
+
+ if (entry_vhca_id == vhca_id) {
+ int state;
+
+ state = MLX5_GET(network_function_params, entry,
+ vhca_state);
+ return state != MLX5_VHCA_STATE_IN_USE;
+ }
+ entry += MLX5_UN_SZ_BYTES(net_function_params);
+ }
+
+ return true;
+}
+
static int mlx5_esw_host_functions_enabled_query(struct mlx5_eswitch *esw)
{
struct mlx5_esw_pf_info host_pf_info;
return err;
}
-static int mlx5_esw_pf_enable_hca(struct mlx5_core_dev *dev, u16 vport_num)
+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;
return 0;
}
-static int mlx5_esw_pf_disable_hca(struct mlx5_core_dev *dev, u16 vport_num)
+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;
const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev);
struct mlx5_esw_pf_info mlx5_esw_get_host_pf_info(struct mlx5_core_dev *dev,
const u32 *out);
+bool mlx5_esw_get_spf_disabled(struct mlx5_core_dev *dev, const u32 *out,
+ u16 vhca_id);
+int mlx5_esw_pf_enable_hca(struct mlx5_core_dev *dev, u16 vport_num);
+int mlx5_esw_pf_disable_hca(struct mlx5_core_dev *dev, u16 vport_num);
int mlx5_esw_host_pf_enable_hca(struct mlx5_core_dev *dev);
int mlx5_esw_host_pf_disable_hca(struct mlx5_core_dev *dev);
struct netlink_ext_ack *extack)
{
struct mlx5_vport *vport = mlx5_devlink_port_vport_get(port);
- struct mlx5_esw_pf_info host_pf_info;
+ struct mlx5_eswitch *esw = vport->dev->priv.eswitch;
const u32 *query_out;
+ bool pf_disabled;
- if (vport->vport != MLX5_VPORT_HOST_PF) {
+ if (mlx5_eswitch_is_vf_vport(esw, vport->vport)) {
NL_SET_ERR_MSG_MOD(extack, "State get is not supported for VF");
return -EOPNOTSUPP;
}
if (IS_ERR(query_out))
return PTR_ERR(query_out);
- host_pf_info = mlx5_esw_get_host_pf_info(vport->dev, query_out);
+ if (vport->vport == MLX5_VPORT_HOST_PF) {
+ struct mlx5_esw_pf_info host_pf_info;
+
+ host_pf_info = mlx5_esw_get_host_pf_info(vport->dev,
+ query_out);
+ pf_disabled = host_pf_info.pf_disabled;
+ } else {
+ pf_disabled = mlx5_esw_get_spf_disabled(vport->dev, query_out,
+ vport->vhca_id);
+ }
- *opstate = host_pf_info.pf_disabled ?
- DEVLINK_PORT_FN_OPSTATE_DETACHED :
- DEVLINK_PORT_FN_OPSTATE_ATTACHED;
+ *opstate = pf_disabled ? DEVLINK_PORT_FN_OPSTATE_DETACHED :
+ DEVLINK_PORT_FN_OPSTATE_ATTACHED;
kvfree(query_out);
return 0;
struct netlink_ext_ack *extack)
{
struct mlx5_vport *vport = mlx5_devlink_port_vport_get(port);
+ struct mlx5_eswitch *esw = vport->dev->priv.eswitch;
struct mlx5_core_dev *dev;
- if (vport->vport != MLX5_VPORT_HOST_PF) {
+ if (mlx5_eswitch_is_vf_vport(esw, vport->vport)) {
NL_SET_ERR_MSG_MOD(extack, "State set is not supported for VF");
return -EOPNOTSUPP;
}
switch (state) {
case DEVLINK_PORT_FN_STATE_ACTIVE:
- return mlx5_esw_host_pf_enable_hca(dev);
+ return mlx5_esw_pf_enable_hca(dev, vport->vport);
case DEVLINK_PORT_FN_STATE_INACTIVE:
- return mlx5_esw_host_pf_disable_hca(dev);
+ return mlx5_esw_pf_disable_hca(dev, vport->vport);
default:
return -EOPNOTSUPP;
}