Subject: [PATCH net-next 00/11] mlxsw: Move allocation of LAG table to the driver

From: Petr Machata <[email-masked]>
Date: Thu, 19 Oct 2023 12:27:09 +0200

PGT is an in-HW table that maps addresses to sets of ports. Then when some
HW process needs a set of ports as an argument, instead of embedding the
actual set in the dynamic configuration, what gets configured is the
address referencing the set. The HW then works with the appropriate PGT
entry.

Within the PGT is placed a LAG table. That is a contiguous block of PGT
memory where each entry describes which ports are members of the
corresponding LAG port.

The PGT is split to two parts: one managed by the FW, and one managed by
the driver. Historically, the FW part included also the LAG table, referred
to as FW LAG mode. Giving the responsibility for placement of the LAG table
to the driver, referred to as SW LAG mode, makes the whole system more
flexible. The FW currently supports both FW and SW LAG modes. To shed
complexity, the FW should in the future only support SW LAG mode.

Hence this patchset, where support for placement of LAG is added to mlxsw.

There are FW versions out there that do not support SW LAG mode, and on
Spectrum-1 in particular, there is no plan to support it at all. mlxsw will
therefore have to support both modes of operation.

Another aspect is that at least on Spectrum-1, there are FW versions out
there that claim to support driver-placed LAG table, but then reject or
ignore configurations enabling the same. The driver thus has to have a say
in whether an attempt to configure SW LAG mode should even be done.

The feature is therefore expressed in terms of "does the driver prefer SW
LAG mode?", and "what LAG mode the PCI module managed to configure the FW
with". This is unlike current flood mode configuration, where the driver
can give a strict value, and that's what gets configured. But it gives a
chance to the driver to determine whether LAG mode should be enabled at
all.

The "does the driver prefer SW LAG mode?" bit is expressed as a boolean
lag_mode_prefer_sw. The reason for this is largely another feature that
will be introduced in a follow-up patchset: support for CFF flood mode. The
driver currently requires that the FW be configured with what is called
controlled flood mode. But on capable systems, CFF would be preferred. So
there are two values in flight: the preferred flood mode, and the fallback.
This could be expressed with an array of flood modes ordered by preference,
but that looks like an overkill in comparison. This flag/value model is
then reused for LAG mode as well, except the fallback value is absent and
implied to be FW, because there are no other values to choose from.

The patchset progresses as follows:

- Patches #1 to #5 adjust reg.h and cmd.h with new register fields,
  constants and remarks.

- Patches #6 and #7 add the ability to request SW LAG mode and to query the
  LAG mode that was actually negotiated. This is where the abovementioned
  lag_mode_prefer_sw flag is added.

- Patches #7 to #9 generalize PGT allocations to make it possible to
  allocate the LAG table, which is done in patch #10.

- In patch #11, toggle lag_mode_prefer_sw on Spectrum-2 and above, which
  makes the newly-added code live.

Petr Machata (11):
  mlxsw: reg: Drop SGCR.llb
  mlxsw: reg: Add SGCR.lag_lookup_pgt_base
  mlxsw: cmd: Fix omissions in CONFIG_PROFILE field names in comments
  mlxsw: cmd: Add CONFIG_PROFILE.{set_, }lag_mode
  mlxsw: cmd: Add QUERY_FW.lag_mode_support
  mlxsw: core, pci: Add plumbing related to LAG mode
  mlxsw: pci: Permit toggling LAG mode
  mlxsw: spectrum_fid: Allocate PGT for the whole FID family in one go
  mlxsw: spectrum_pgt: Generalize PGT allocation
  mlxsw: spectrum: Allocate LAG table when in SW LAG mode
  mlxsw: spectrum: Set SW LAG mode on Spectrum>1

 drivers/net/ethernet/mellanox/mlxsw/cmd.h     | 43 +++++++--
 drivers/net/ethernet/mellanox/mlxsw/core.c    |  7 ++
 drivers/net/ethernet/mellanox/mlxsw/core.h    |  4 +
 drivers/net/ethernet/mellanox/mlxsw/pci.c     | 28 +++++-
 drivers/net/ethernet/mellanox/mlxsw/reg.h     | 14 +--
 .../net/ethernet/mellanox/mlxsw/spectrum.c    | 95 ++++++++++++++++---
 .../net/ethernet/mellanox/mlxsw/spectrum.h    |  3 +-
 .../ethernet/mellanox/mlxsw/spectrum_fid.c    | 69 +++++++-------
 .../ethernet/mellanox/mlxsw/spectrum_pgt.c    | 20 +---
 9 files changed, 202 insertions(+), 81 deletions(-)

-- 
2.41.0