diff options
author | Jiri Pirko <jiri@mellanox.com> | 2016-08-19 08:43:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-08-19 21:01:56 -0400 |
commit | 8912862f067276b480c4fed9da74c9c5601130a6 (patch) | |
tree | ef9ebe420e2c838945aa5d282650ce403ba8c22e | |
parent | 56cff471d0c62b721a298f806e7637501debb513 (diff) |
mlxsw: spectrum_buffers: Fix pool value handling in mlxsw_sp_sb_tc_pool_bind_set
Pool index has to be converted by get_pool helper to work correctly for
egress pool. In mlxsw the egress pool index starts from 0.
Fixes: 0f433fa0ecc ("mlxsw: spectrum_buffers: Implement shared buffer configuration")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c index 237418a0e6e0..953b214f38d0 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c | |||
@@ -717,22 +717,18 @@ int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port, | |||
717 | u8 local_port = mlxsw_sp_port->local_port; | 717 | u8 local_port = mlxsw_sp_port->local_port; |
718 | u8 pg_buff = tc_index; | 718 | u8 pg_buff = tc_index; |
719 | enum mlxsw_reg_sbxx_dir dir = pool_type; | 719 | enum mlxsw_reg_sbxx_dir dir = pool_type; |
720 | u8 pool = pool_index; | 720 | u8 pool = pool_get(pool_index); |
721 | u32 max_buff; | 721 | u32 max_buff; |
722 | int err; | 722 | int err; |
723 | 723 | ||
724 | if (dir != dir_get(pool_index)) | ||
725 | return -EINVAL; | ||
726 | |||
724 | err = mlxsw_sp_sb_threshold_in(mlxsw_sp, pool, dir, | 727 | err = mlxsw_sp_sb_threshold_in(mlxsw_sp, pool, dir, |
725 | threshold, &max_buff); | 728 | threshold, &max_buff); |
726 | if (err) | 729 | if (err) |
727 | return err; | 730 | return err; |
728 | 731 | ||
729 | if (pool_type == DEVLINK_SB_POOL_TYPE_EGRESS) { | ||
730 | if (pool < MLXSW_SP_SB_POOL_COUNT) | ||
731 | return -EINVAL; | ||
732 | pool -= MLXSW_SP_SB_POOL_COUNT; | ||
733 | } else if (pool >= MLXSW_SP_SB_POOL_COUNT) { | ||
734 | return -EINVAL; | ||
735 | } | ||
736 | return mlxsw_sp_sb_cm_write(mlxsw_sp, local_port, pg_buff, dir, | 732 | return mlxsw_sp_sb_cm_write(mlxsw_sp, local_port, pg_buff, dir, |
737 | 0, max_buff, pool); | 733 | 0, max_buff, pool); |
738 | } | 734 | } |