Commit d5ccda92 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'mlxsw-configure-max-lag-id-for-spectrum-4'

Petr Machata says:

====================
mlxsw: Configure max LAG ID for Spectrum-4

Amit Cohen writes:

In the device, LAG identifiers are stored in the port group table (PGT).
During initialization, firmware reserves a certain amount of entries at
the beginning of this table for LAG identifiers.

In Spectrum-4, the size of the PGT table did not increase, but the
maximum number of LAG identifiers was doubled, leaving less room for
others entries (e.g., flood entries) that also reside in the PGT.

Therefore, in order to avoid a regression and as long as there is no
explicit requirement to support 256 LAGs, configure the firmware to
allocate the same amount of LAG entries (128) as in Spectrum-{2,3}.

This can be done via the 'max_lag' field in CONFIG_PROFILE command.

Patch set overview:
Patch #1 edits the comment of the existing 'max_lag' field.
Patch #2 adds support for configuring 'max_lag' field via CONFIG_PROFILE
command.
Patch #3 adds an helper function to get the actual 'max_lag' in the
device.
Patch #4 adjusts Spectrum-4 to configure 'max_lag' field.
====================

Link: https://lore.kernel.org/r/cover.1661527928.git.petrm@nvidia.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents fa872447 c503d8ae
...@@ -703,6 +703,9 @@ MLXSW_ITEM32(cmd_mbox, config_profile, max_vepa_channels, 0x10, 0, 8); ...@@ -703,6 +703,9 @@ MLXSW_ITEM32(cmd_mbox, config_profile, max_vepa_channels, 0x10, 0, 8);
/* cmd_mbox_config_profile_max_lag /* cmd_mbox_config_profile_max_lag
* Maximum number of LAG IDs requested. * Maximum number of LAG IDs requested.
* Reserved when Spectrum-1/2/3, supported from Spectrum-4 and above.
* For Spectrum-4, firmware sets 128 for values between 1-128 and 256 for values
* between 129-256.
*/ */
MLXSW_ITEM32(cmd_mbox, config_profile, max_lag, 0x14, 0, 16); MLXSW_ITEM32(cmd_mbox, config_profile, max_lag, 0x14, 0, 16);
......
...@@ -186,6 +186,23 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core) ...@@ -186,6 +186,23 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core)
} }
EXPORT_SYMBOL(mlxsw_core_max_ports); EXPORT_SYMBOL(mlxsw_core_max_ports);
int mlxsw_core_max_lag(struct mlxsw_core *mlxsw_core, u16 *p_max_lag)
{
struct mlxsw_driver *driver = mlxsw_core->driver;
if (driver->profile->used_max_lag) {
*p_max_lag = driver->profile->max_lag;
return 0;
}
if (!MLXSW_CORE_RES_VALID(mlxsw_core, MAX_LAG))
return -EIO;
*p_max_lag = MLXSW_CORE_RES_GET(mlxsw_core, MAX_LAG);
return 0;
}
EXPORT_SYMBOL(mlxsw_core_max_lag);
void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core) void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core)
{ {
return mlxsw_core->driver_priv; return mlxsw_core->driver_priv;
...@@ -2099,6 +2116,7 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, ...@@ -2099,6 +2116,7 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
struct mlxsw_core *mlxsw_core; struct mlxsw_core *mlxsw_core;
struct mlxsw_driver *mlxsw_driver; struct mlxsw_driver *mlxsw_driver;
size_t alloc_size; size_t alloc_size;
u16 max_lag;
int err; int err;
mlxsw_driver = mlxsw_core_driver_get(device_kind); mlxsw_driver = mlxsw_core_driver_get(device_kind);
...@@ -2140,10 +2158,9 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, ...@@ -2140,10 +2158,9 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
if (err) if (err)
goto err_ports_init; goto err_ports_init;
if (MLXSW_CORE_RES_VALID(mlxsw_core, MAX_LAG) && err = mlxsw_core_max_lag(mlxsw_core, &max_lag);
MLXSW_CORE_RES_VALID(mlxsw_core, MAX_LAG_MEMBERS)) { if (!err && MLXSW_CORE_RES_VALID(mlxsw_core, MAX_LAG_MEMBERS)) {
alloc_size = sizeof(*mlxsw_core->lag.mapping) * alloc_size = sizeof(*mlxsw_core->lag.mapping) * max_lag *
MLXSW_CORE_RES_GET(mlxsw_core, MAX_LAG) *
MLXSW_CORE_RES_GET(mlxsw_core, MAX_LAG_MEMBERS); MLXSW_CORE_RES_GET(mlxsw_core, MAX_LAG_MEMBERS);
mlxsw_core->lag.mapping = kzalloc(alloc_size, GFP_KERNEL); mlxsw_core->lag.mapping = kzalloc(alloc_size, GFP_KERNEL);
if (!mlxsw_core->lag.mapping) { if (!mlxsw_core->lag.mapping) {
......
...@@ -35,6 +35,8 @@ struct mlxsw_fw_rev; ...@@ -35,6 +35,8 @@ struct mlxsw_fw_rev;
unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core); unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);
int mlxsw_core_max_lag(struct mlxsw_core *mlxsw_core, u16 *p_max_lag);
void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core); void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core);
struct mlxsw_linecards *mlxsw_core_linecards(struct mlxsw_core *mlxsw_core); struct mlxsw_linecards *mlxsw_core_linecards(struct mlxsw_core *mlxsw_core);
...@@ -295,6 +297,7 @@ struct mlxsw_swid_config { ...@@ -295,6 +297,7 @@ struct mlxsw_swid_config {
struct mlxsw_config_profile { struct mlxsw_config_profile {
u16 used_max_vepa_channels:1, u16 used_max_vepa_channels:1,
used_max_lag:1,
used_max_mid:1, used_max_mid:1,
used_max_pgt:1, used_max_pgt:1,
used_max_system_port:1, used_max_system_port:1,
...@@ -310,6 +313,7 @@ struct mlxsw_config_profile { ...@@ -310,6 +313,7 @@ struct mlxsw_config_profile {
used_kvd_sizes:1, used_kvd_sizes:1,
used_cqe_time_stamp_type:1; used_cqe_time_stamp_type:1;
u8 max_vepa_channels; u8 max_vepa_channels;
u16 max_lag;
u16 max_mid; u16 max_mid;
u16 max_pgt; u16 max_pgt;
u16 max_system_port; u16 max_system_port;
......
...@@ -1187,6 +1187,11 @@ static int mlxsw_pci_config_profile(struct mlxsw_pci *mlxsw_pci, char *mbox, ...@@ -1187,6 +1187,11 @@ static int mlxsw_pci_config_profile(struct mlxsw_pci *mlxsw_pci, char *mbox,
mlxsw_cmd_mbox_config_profile_max_vepa_channels_set( mlxsw_cmd_mbox_config_profile_max_vepa_channels_set(
mbox, profile->max_vepa_channels); mbox, profile->max_vepa_channels);
} }
if (profile->used_max_lag) {
mlxsw_cmd_mbox_config_profile_set_max_lag_set(mbox, 1);
mlxsw_cmd_mbox_config_profile_max_lag_set(mbox,
profile->max_lag);
}
if (profile->used_max_mid) { if (profile->used_max_mid) {
mlxsw_cmd_mbox_config_profile_set_max_mid_set( mlxsw_cmd_mbox_config_profile_set_max_mid_set(
mbox, 1); mbox, 1);
......
...@@ -2691,6 +2691,7 @@ static void mlxsw_sp_traps_fini(struct mlxsw_sp *mlxsw_sp) ...@@ -2691,6 +2691,7 @@ static void mlxsw_sp_traps_fini(struct mlxsw_sp *mlxsw_sp)
static int mlxsw_sp_lag_init(struct mlxsw_sp *mlxsw_sp) static int mlxsw_sp_lag_init(struct mlxsw_sp *mlxsw_sp)
{ {
char slcr_pl[MLXSW_REG_SLCR_LEN]; char slcr_pl[MLXSW_REG_SLCR_LEN];
u16 max_lag;
u32 seed; u32 seed;
int err; int err;
...@@ -2709,12 +2710,14 @@ static int mlxsw_sp_lag_init(struct mlxsw_sp *mlxsw_sp) ...@@ -2709,12 +2710,14 @@ static int mlxsw_sp_lag_init(struct mlxsw_sp *mlxsw_sp)
if (err) if (err)
return err; return err;
if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_LAG) || err = mlxsw_core_max_lag(mlxsw_sp->core, &max_lag);
!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_LAG_MEMBERS)) if (err)
return err;
if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_LAG_MEMBERS))
return -EIO; return -EIO;
mlxsw_sp->lags = kcalloc(MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_LAG), mlxsw_sp->lags = kcalloc(max_lag, sizeof(struct mlxsw_sp_upper),
sizeof(struct mlxsw_sp_upper),
GFP_KERNEL); GFP_KERNEL);
if (!mlxsw_sp->lags) if (!mlxsw_sp->lags)
return -ENOMEM; return -ENOMEM;
...@@ -3509,6 +3512,33 @@ static const struct mlxsw_config_profile mlxsw_sp2_config_profile = { ...@@ -3509,6 +3512,33 @@ static const struct mlxsw_config_profile mlxsw_sp2_config_profile = {
.cqe_time_stamp_type = MLXSW_CMD_MBOX_CONFIG_PROFILE_CQE_TIME_STAMP_TYPE_UTC, .cqe_time_stamp_type = MLXSW_CMD_MBOX_CONFIG_PROFILE_CQE_TIME_STAMP_TYPE_UTC,
}; };
/* Reduce number of LAGs from full capacity (256) to the maximum supported LAGs
* in Spectrum-2/3, to avoid regression in number of free entries in the PGT
* table.
*/
#define MLXSW_SP4_CONFIG_PROFILE_MAX_LAG 128
static const struct mlxsw_config_profile mlxsw_sp4_config_profile = {
.used_max_lag = 1,
.max_lag = MLXSW_SP4_CONFIG_PROFILE_MAX_LAG,
.used_flood_mode = 1,
.flood_mode = MLXSW_CMD_MBOX_CONFIG_PROFILE_FLOOD_MODE_CONTROLLED,
.used_max_ib_mc = 1,
.max_ib_mc = 0,
.used_max_pkey = 1,
.max_pkey = 0,
.used_ubridge = 1,
.ubridge = 1,
.swid_config = {
{
.used_type = 1,
.type = MLXSW_PORT_SWID_TYPE_ETH,
}
},
.used_cqe_time_stamp_type = 1,
.cqe_time_stamp_type = MLXSW_CMD_MBOX_CONFIG_PROFILE_CQE_TIME_STAMP_TYPE_UTC,
};
static void static void
mlxsw_sp_resource_size_params_prepare(struct mlxsw_core *mlxsw_core, mlxsw_sp_resource_size_params_prepare(struct mlxsw_core *mlxsw_core,
struct devlink_resource_size_params *kvd_size_params, struct devlink_resource_size_params *kvd_size_params,
...@@ -4039,7 +4069,7 @@ static struct mlxsw_driver mlxsw_sp4_driver = { ...@@ -4039,7 +4069,7 @@ static struct mlxsw_driver mlxsw_sp4_driver = {
.params_unregister = mlxsw_sp2_params_unregister, .params_unregister = mlxsw_sp2_params_unregister,
.ptp_transmitted = mlxsw_sp_ptp_transmitted, .ptp_transmitted = mlxsw_sp_ptp_transmitted,
.txhdr_len = MLXSW_TXHDR_LEN, .txhdr_len = MLXSW_TXHDR_LEN,
.profile = &mlxsw_sp2_config_profile, .profile = &mlxsw_sp4_config_profile,
.sdq_supports_cqe_v2 = true, .sdq_supports_cqe_v2 = true,
}; };
...@@ -4263,10 +4293,13 @@ static int mlxsw_sp_lag_index_get(struct mlxsw_sp *mlxsw_sp, ...@@ -4263,10 +4293,13 @@ static int mlxsw_sp_lag_index_get(struct mlxsw_sp *mlxsw_sp,
{ {
struct mlxsw_sp_upper *lag; struct mlxsw_sp_upper *lag;
int free_lag_id = -1; int free_lag_id = -1;
u64 max_lag; u16 max_lag;
int i; int err, i;
err = mlxsw_core_max_lag(mlxsw_sp->core, &max_lag);
if (err)
return err;
max_lag = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_LAG);
for (i = 0; i < max_lag; i++) { for (i = 0; i < max_lag; i++) {
lag = mlxsw_sp_lag_get(mlxsw_sp, i); lag = mlxsw_sp_lag_get(mlxsw_sp, i);
if (lag->ref_count) { if (lag->ref_count) {
......
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