mlxsw: spectrum: Add an API to configure security checks
authorIdo Schimmel <idosch@nvidia.com>
Tue, 8 Nov 2022 10:47:13 +0000 (11:47 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 10 Nov 2022 03:06:14 +0000 (19:06 -0800)
Add an API to enable or disable security checks on a local port. It will
be used by subsequent patches when the 'BR_PORT_LOCKED' flag is toggled.

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

index 04dc79da6024fa95fcf226f4dead83a39e1af197..b3436652191462b34a70f52ccc2c98feea4d6407 100644 (file)
@@ -466,6 +466,24 @@ int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
        return err;
 }
 
+int mlxsw_sp_port_security_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable)
+{
+       struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
+       char spfsr_pl[MLXSW_REG_SPFSR_LEN];
+       int err;
+
+       if (mlxsw_sp_port->security == enable)
+               return 0;
+
+       mlxsw_reg_spfsr_pack(spfsr_pl, mlxsw_sp_port->local_port, enable);
+       err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spfsr), spfsr_pl);
+       if (err)
+               return err;
+
+       mlxsw_sp_port->security = enable;
+       return 0;
+}
+
 int mlxsw_sp_ethtype_to_sver_type(u16 ethtype, u8 *p_sver_type)
 {
        switch (ethtype) {
index c8ff2a6d7e90dd308d248c99d149f49294dc7857..bbc73324451db8b7ca981a617e7f7aa38291e50e 100644 (file)
@@ -321,7 +321,8 @@ struct mlxsw_sp_port {
        struct mlxsw_sp *mlxsw_sp;
        u16 local_port;
        u8 lagged:1,
-          split:1;
+          split:1,
+          security:1;
        u16 pvid;
        u16 lag_id;
        struct {
@@ -687,6 +688,8 @@ int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
 int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable);
 int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
                                   bool learn_enable);
+int mlxsw_sp_port_security_set(struct mlxsw_sp_port *mlxsw_sp_port,
+                              bool enable);
 int mlxsw_sp_ethtype_to_sver_type(u16 ethtype, u8 *p_sver_type);
 int mlxsw_sp_port_egress_ethtype_set(struct mlxsw_sp_port *mlxsw_sp_port,
                                     u16 ethtype);