]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mlxsw: spectrum: Switch to VID 4095 as default VID
authorIdo Schimmel <idosch@mellanox.com>
Thu, 20 Dec 2018 19:42:33 +0000 (19:42 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Dec 2018 23:48:54 +0000 (15:48 -0800)
There is no need to abuse VID 1 anymore and we can instead use VID 4095
as the default VLAN, which will be configured on the port throughout its
lifetime.

The OVS join / leave functions are changed to enable VIDs 1-4094
(inclusive) instead of 2-4095. This because VID 4095 is now the default
VLAN instead of 1.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c

index 61848db516c7b1160b6df8478f5ca1d952ac8115..0aa8ec402fdcc2449dfa07d2c2406d5a932d4e39 100644 (file)
@@ -4670,8 +4670,6 @@ static int mlxsw_sp_port_lag_join(struct mlxsw_sp_port *mlxsw_sp_port,
                                  struct net_device *lag_dev)
 {
        struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
-       struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
-       u16 vid = MLXSW_SP_DEFAULT_VID;
        struct mlxsw_sp_upper *lag;
        u16 lag_id;
        u8 port_index;
@@ -4705,9 +4703,8 @@ static int mlxsw_sp_port_lag_join(struct mlxsw_sp_port *mlxsw_sp_port,
        lag->ref_count++;
 
        /* Port is no longer usable as a router interface */
-       mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_vid(mlxsw_sp_port, vid);
-       if (mlxsw_sp_port_vlan->fid)
-               mlxsw_sp_port_vlan_router_leave(mlxsw_sp_port_vlan);
+       if (mlxsw_sp_port->default_vlan->fid)
+               mlxsw_sp_port_vlan_router_leave(mlxsw_sp_port->default_vlan);
 
        return 0;
 
@@ -4735,7 +4732,8 @@ static void mlxsw_sp_port_lag_leave(struct mlxsw_sp_port *mlxsw_sp_port,
        mlxsw_sp_lag_col_port_remove(mlxsw_sp_port, lag_id);
 
        /* Any VLANs configured on the port are no longer valid */
-       mlxsw_sp_port_vlan_flush(mlxsw_sp_port, true);
+       mlxsw_sp_port_vlan_flush(mlxsw_sp_port, false);
+       mlxsw_sp_port_vlan_cleanup(mlxsw_sp_port->default_vlan);
        /* Make the LAG and its directly linked uppers leave bridges they
         * are memeber in
         */
@@ -4749,7 +4747,6 @@ static void mlxsw_sp_port_lag_leave(struct mlxsw_sp_port *mlxsw_sp_port,
        mlxsw_sp_port->lagged = 0;
        lag->ref_count--;
 
-       mlxsw_sp_port_vlan_create(mlxsw_sp_port, MLXSW_SP_DEFAULT_VID);
        /* Make sure untagged frames are allowed to ingress */
        mlxsw_sp_port_pvid_set(mlxsw_sp_port, MLXSW_SP_DEFAULT_VID);
 }
@@ -4829,7 +4826,7 @@ static int mlxsw_sp_port_ovs_join(struct mlxsw_sp_port *mlxsw_sp_port)
        err = mlxsw_sp_port_stp_set(mlxsw_sp_port, true);
        if (err)
                goto err_port_stp_set;
-       err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, 2, VLAN_N_VID - 1,
+       err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, 1, VLAN_N_VID - 2,
                                     true, false);
        if (err)
                goto err_port_vlan_set;
@@ -4861,7 +4858,7 @@ static void mlxsw_sp_port_ovs_leave(struct mlxsw_sp_port *mlxsw_sp_port)
                mlxsw_sp_port_vid_learning_set(mlxsw_sp_port,
                                               vid, true);
 
-       mlxsw_sp_port_vlan_set(mlxsw_sp_port, 2, VLAN_N_VID - 1,
+       mlxsw_sp_port_vlan_set(mlxsw_sp_port, 1, VLAN_N_VID - 2,
                               false, false);
        mlxsw_sp_port_stp_set(mlxsw_sp_port, false);
        mlxsw_sp_port_vp_mode_set(mlxsw_sp_port, false);
index 4e11915d676add9e9d09491b314a71f481d06147..a1c32a81b0110dd2dc025ab308f4302ed08be2bf 100644 (file)
@@ -25,7 +25,7 @@
 #include "core_acl_flex_actions.h"
 #include "reg.h"
 
-#define MLXSW_SP_DEFAULT_VID 1
+#define MLXSW_SP_DEFAULT_VID (VLAN_N_VID - 1)
 
 #define MLXSW_SP_FID_8021D_MAX 1024
 
index b3a7cf2cf7d9d7e9235a70514b52073119be4528..1bd2c6e15f8d0b68ca46c826939ec325a87bd044 100644 (file)
@@ -1974,20 +1974,14 @@ mlxsw_sp_bridge_8021q_port_join(struct mlxsw_sp_bridge_device *bridge_device,
                                struct mlxsw_sp_port *mlxsw_sp_port,
                                struct netlink_ext_ack *extack)
 {
-       struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
-       u16 vid = MLXSW_SP_DEFAULT_VID;
-
        if (is_vlan_dev(bridge_port->dev)) {
                NL_SET_ERR_MSG_MOD(extack, "Can not enslave a VLAN device to a VLAN-aware bridge");
                return -EINVAL;
        }
 
-       mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_vid(mlxsw_sp_port, vid);
-       if (WARN_ON(!mlxsw_sp_port_vlan))
-               return -EINVAL;
-
-       /* Let VLAN-aware bridge take care of its own VLANs */
-       mlxsw_sp_port_vlan_destroy(mlxsw_sp_port_vlan);
+       /* Port is no longer usable as a router interface */
+       if (mlxsw_sp_port->default_vlan->fid)
+               mlxsw_sp_port_vlan_router_leave(mlxsw_sp_port->default_vlan);
 
        return 0;
 }
@@ -1997,7 +1991,6 @@ mlxsw_sp_bridge_8021q_port_leave(struct mlxsw_sp_bridge_device *bridge_device,
                                 struct mlxsw_sp_bridge_port *bridge_port,
                                 struct mlxsw_sp_port *mlxsw_sp_port)
 {
-       mlxsw_sp_port_vlan_create(mlxsw_sp_port, MLXSW_SP_DEFAULT_VID);
        /* Make sure untagged frames are allowed to ingress */
        mlxsw_sp_port_pvid_set(mlxsw_sp_port, MLXSW_SP_DEFAULT_VID);
 }
@@ -2199,7 +2192,7 @@ mlxsw_sp_bridge_8021d_port_leave(struct mlxsw_sp_bridge_device *bridge_device,
 
        vid = is_vlan_dev(dev) ? vlan_dev_vlan_id(dev) : MLXSW_SP_DEFAULT_VID;
        mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_vid(mlxsw_sp_port, vid);
-       if (!mlxsw_sp_port_vlan)
+       if (!mlxsw_sp_port_vlan || !mlxsw_sp_port_vlan->bridge_port)
                return;
 
        mlxsw_sp_port_vlan_bridge_leave(mlxsw_sp_port_vlan);