mlxsw: spectrum_buffers: Query shared buffer size from firmware
authorIdo Schimmel <idosch@mellanox.com>
Fri, 24 Mar 2017 07:02:49 +0000 (08:02 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 24 Mar 2017 20:53:28 +0000 (13:53 -0700)
Instead of hard coding the size of the shared buffer in the driver,
query it from the firmware, as it may change in future devices.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c

index 3ab853db59eeba06abff2ed3487b236c62f2f4bb..7e67d0e5b7f3649133ed6f568bb78a083ed0d4a6 100644 (file)
@@ -536,12 +536,15 @@ static int mlxsw_sp_sb_mms_init(struct mlxsw_sp *mlxsw_sp)
        return 0;
 }
 
-#define MLXSW_SP_SB_SIZE (16 * 1024 * 1024)
-
 int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp)
 {
+       u64 sb_size;
        int err;
 
+       if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_BUFFER_SIZE))
+               return -EIO;
+       sb_size = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_BUFFER_SIZE);
+
        err = mlxsw_sp_sb_ports_init(mlxsw_sp);
        if (err)
                return err;
@@ -554,8 +557,7 @@ int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp)
        err = mlxsw_sp_sb_mms_init(mlxsw_sp);
        if (err)
                goto err_sb_mms_init;
-       err = devlink_sb_register(priv_to_devlink(mlxsw_sp->core), 0,
-                                 MLXSW_SP_SB_SIZE,
+       err = devlink_sb_register(priv_to_devlink(mlxsw_sp->core), 0, sb_size,
                                  MLXSW_SP_SB_POOL_COUNT,
                                  MLXSW_SP_SB_POOL_COUNT,
                                  MLXSW_SP_SB_TC_COUNT,