mlxsw: spectrum_router: Add a helper to get subport number from a RIF
authorPetr Machata <petrm@nvidia.com>
Mon, 20 Nov 2023 18:25:30 +0000 (19:25 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 21 Nov 2023 22:53:09 +0000 (14:53 -0800)
In the CFF flood mode, responsibility for management of the PGT entries for
rFIDs is moved from FW to the driver. All rFIDs are based off either a
front panel port, or a LAG port. The flood vectors for port-based rFIDs
enable just the port itself, the ones for LAG-based rFIDs enable all member
ports of the LAG in question.

Since all rFIDs based off the same port have the same flood vector, and
similarly for LAG-based rFIDs, the flood entries are shared. The PGT
address of the flood vector is therefore determined based on the port (or
LAG) number of the RIF connected with the rFID.

Add a helper to determine subport number given a RIF, to be used in these
calculations.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://lore.kernel.org/r/d7ab43cf5b021f785f363f236e4b6780d10eea93.1700503644.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index c70333b460ea1cc787266b5cb7370820a2cc03e3..800c461deefa4b8e2c6cdca242f0a5cbc5664636 100644 (file)
@@ -753,6 +753,8 @@ union mlxsw_sp_l3addr {
 };
 
 u16 mlxsw_sp_rif_index(const struct mlxsw_sp_rif *rif);
+int mlxsw_sp_rif_subport_port(const struct mlxsw_sp_rif *rif,
+                             u16 *port, bool *is_lag);
 int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp,
                         struct netlink_ext_ack *extack);
 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
index 82a95125d9cafdfde43baf9f7234bb04a37e5717..a358ceb4e1d0deb11a020b944da83c515bbfee98 100644 (file)
@@ -8660,6 +8660,20 @@ mlxsw_sp_rif_subport_rif(const struct mlxsw_sp_rif *rif)
        return container_of(rif, struct mlxsw_sp_rif_subport, common);
 }
 
+int mlxsw_sp_rif_subport_port(const struct mlxsw_sp_rif *rif,
+                             u16 *port, bool *is_lag)
+{
+       struct mlxsw_sp_rif_subport *rif_subport;
+
+       if (WARN_ON(rif->ops->type != MLXSW_SP_RIF_TYPE_SUBPORT))
+               return -EINVAL;
+
+       rif_subport = mlxsw_sp_rif_subport_rif(rif);
+       *is_lag = rif_subport->lag;
+       *port = *is_lag ? rif_subport->lag_id : rif_subport->system_port;
+       return 0;
+}
+
 static struct mlxsw_sp_rif *
 mlxsw_sp_rif_subport_get(struct mlxsw_sp *mlxsw_sp,
                         const struct mlxsw_sp_rif_params *params,