mlxsw: spectrum_dcb: Configure DSCP map as the last rule is removed
authorPetr Machata <petrm@mellanox.com>
Wed, 17 Jul 2019 20:29:07 +0000 (23:29 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 17 Jul 2019 22:19:46 +0000 (15:19 -0700)
Spectrum systems use DSCP rewrite map to update DSCP field in egressing
packets to correspond to priority that the packet has. Whether rewriting
will take place is determined at the point when the packet ingresses the
switch: if the port is in Trust L3 mode, packet priority is determined from
the DSCP map at the port, and DSCP rewrite will happen. If the port is in
Trust L2 mode, 802.1p is used for packet prioritization, and no DSCP
rewrite will happen.

The driver determines the port trust mode based on whether any DSCP
prioritization rules are in effect at given port. If there are any, trust
level is L3, otherwise it's L2. When the last DSCP rule is removed, the
port is switched to trust L2. Under that scenario, if DSCP of a packet
should be rewritten, it should be rewritten to 0.

However, when switching to Trust L2, the driver neglects to also update the
DSCP rewrite map. The last DSCP rule thus remains in effect, and packets
egressing through this port, if they have the right priority, will have
their DSCP set according to this rule.

Fix by first configuring the rewrite map, and only then switching to trust
L2 and bailing out.

Fixes: b2b1dab6884e ("mlxsw: spectrum: Support ieee_setapp, ieee_delapp")
Signed-off-by: Petr Machata <petrm@mellanox.com>
Reported-by: Alex Veber <alexve@mellanox.com>
Tested-by: Alex Veber <alexve@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c

index b25048c6c7618e4b2e9fa210bcdfe7516bcb41d2..21296fa7f7fbf52060d51740e9c2247085c4e8d0 100644 (file)
@@ -408,14 +408,6 @@ static int mlxsw_sp_port_dcb_app_update(struct mlxsw_sp_port *mlxsw_sp_port)
        have_dscp = mlxsw_sp_port_dcb_app_prio_dscp_map(mlxsw_sp_port,
                                                        &prio_map);
 
-       if (!have_dscp) {
-               err = mlxsw_sp_port_dcb_toggle_trust(mlxsw_sp_port,
-                                       MLXSW_REG_QPTS_TRUST_STATE_PCP);
-               if (err)
-                       netdev_err(mlxsw_sp_port->dev, "Couldn't switch to trust L2\n");
-               return err;
-       }
-
        mlxsw_sp_port_dcb_app_dscp_prio_map(mlxsw_sp_port, default_prio,
                                            &dscp_map);
        err = mlxsw_sp_port_dcb_app_update_qpdpm(mlxsw_sp_port,
@@ -432,6 +424,14 @@ static int mlxsw_sp_port_dcb_app_update(struct mlxsw_sp_port *mlxsw_sp_port)
                return err;
        }
 
+       if (!have_dscp) {
+               err = mlxsw_sp_port_dcb_toggle_trust(mlxsw_sp_port,
+                                       MLXSW_REG_QPTS_TRUST_STATE_PCP);
+               if (err)
+                       netdev_err(mlxsw_sp_port->dev, "Couldn't switch to trust L2\n");
+               return err;
+       }
+
        err = mlxsw_sp_port_dcb_toggle_trust(mlxsw_sp_port,
                                             MLXSW_REG_QPTS_TRUST_STATE_DSCP);
        if (err) {