mlxsw: Add a helper function for getting maximum LAG ID
authorAmit Cohen <amcohen@nvidia.com>
Fri, 26 Aug 2022 16:06:51 +0000 (18:06 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 31 Aug 2022 06:20:43 +0000 (23:20 -0700)
commitcf735d4c9bab8398259a3635fcd698726a2f1bbe
tree69368d9ba61b87f0ced753d0b137937fb27a42db
parenteb907e9779ca48e3f3fe3796ed88de017dd59414
mlxsw: Add a helper function for getting maximum LAG ID

Currently the driver queries the maximum supported LAG ID from firmware.
This will not be accurate anymore once the driver will configure 'max_lag'
via CONFIG_PROFILE command.

For resource query, firmware returns the maximum LAG ID which is supported
by hardware. Software can configure firmware to do not allocate entries for
all the supported LAGs, and to limit LAG IDs. In this case, the resource
query will not return the actual maximum LAG ID.

Add a helper function for getting this value. In case that 'max_lag' field
was set during initialization, return the value which was used, otherwise,
query firmware for the maximum supported ID.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/core.c
drivers/net/ethernet/mellanox/mlxsw/core.h
drivers/net/ethernet/mellanox/mlxsw/spectrum.c