Commit f7936d0b authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

mlxsw: spectrum_buffers: Add ability to veto TC's configuration

Subsequent patches are going to need to veto changes in certain TCs'
binding and threshold configurations.

Add fields to the TC's struct that indicate if the TC can be bound to a
different pool and whether its threshold can change and enforce that.
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Reviewed-by: default avatarPetr Machata <petrm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0636f4de
......@@ -30,6 +30,8 @@ struct mlxsw_sp_sb_cm {
u32 max_buff;
u16 pool_index;
struct mlxsw_cp_sb_occ occ;
u8 freeze_pool:1,
freeze_thresh:1;
};
#define MLXSW_SP_SB_INFI -1U
......@@ -1059,6 +1061,7 @@ int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port,
mlxsw_core_port_driver_priv(mlxsw_core_port);
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
u8 local_port = mlxsw_sp_port->local_port;
const struct mlxsw_sp_sb_cm *cm;
u8 pg_buff = tc_index;
enum mlxsw_reg_sbxx_dir dir = (enum mlxsw_reg_sbxx_dir) pool_type;
u32 max_buff;
......@@ -1069,6 +1072,21 @@ int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port,
return -EINVAL;
}
if (dir == MLXSW_REG_SBXX_DIR_INGRESS)
cm = &mlxsw_sp->sb_vals->cms_ingress[tc_index];
else
cm = &mlxsw_sp->sb_vals->cms_egress[tc_index];
if (cm->freeze_pool && cm->pool_index != pool_index) {
NL_SET_ERR_MSG_MOD(extack, "Binding this TC to a different pool is forbidden");
return -EINVAL;
}
if (cm->freeze_thresh && cm->max_buff != threshold) {
NL_SET_ERR_MSG_MOD(extack, "Changing this TC's threshold is forbidden");
return -EINVAL;
}
err = mlxsw_sp_sb_threshold_in(mlxsw_sp, pool_index,
threshold, &max_buff, extack);
if (err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment