mlxsw: spectrum: Add mlxsw_sp_port_egress_ethtype_set()
authorAmit Cohen <amcohen@nvidia.com>
Wed, 17 Mar 2021 10:35:25 +0000 (12:35 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 17 Mar 2021 19:26:28 +0000 (12:26 -0700)
A subsequent patch will cause decapsulated packets to have their EtherType
determined by the egress port. Add mlxsw_sp_port_egress_ethtype_set() which
will be called when a port joins an 802.1ad bridge, so that it will set an
802.1ad EtherType on decapsulated packets transmitted through it, instead
of the default 802.1q EtherType.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.h

index 7e40d45..9aba4fe 100644 (file)
@@ -402,6 +402,22 @@ int mlxsw_sp_ethtype_to_sver_type(u16 ethtype, u8 *p_sver_type)
        return 0;
 }
 
+int mlxsw_sp_port_egress_ethtype_set(struct mlxsw_sp_port *mlxsw_sp_port,
+                                    u16 ethtype)
+{
+       struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
+       char spevet_pl[MLXSW_REG_SPEVET_LEN];
+       u8 sver_type;
+       int err;
+
+       err = mlxsw_sp_ethtype_to_sver_type(ethtype, &sver_type);
+       if (err)
+               return err;
+
+       mlxsw_reg_spevet_pack(spevet_pl, mlxsw_sp_port->local_port, sver_type);
+       return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spevet), spevet_pl);
+}
+
 static int __mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port,
                                    u16 vid, u16 ethtype)
 {
index 63cc8fa..180ffa4 100644 (file)
@@ -609,6 +609,8 @@ 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_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);
 int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid,
                           u16 ethtype);
 struct mlxsw_sp_port_vlan *