]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
net: dsa: mv88e6xxx: support VLAN filtering
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Fri, 26 Feb 2016 18:16:08 +0000 (13:16 -0500)
committerDavid S. Miller <davem@davemloft.net>
Tue, 1 Mar 2016 21:24:53 +0000 (16:24 -0500)
Implement port_vlan_filtering in the driver to toggle the related port
802.1Q mode between DISABLED and SECURE, on user request.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/mv88e6171.c
drivers/net/dsa/mv88e6352.c
drivers/net/dsa/mv88e6xxx.c
drivers/net/dsa/mv88e6xxx.h

index dd1ebaf4807710f19e5d68a174135f6687df6f98..d72ccbdf53ec832cdc123960821e09e46c5b6d8c 100644 (file)
@@ -106,6 +106,7 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
        .port_join_bridge       = mv88e6xxx_port_bridge_join,
        .port_leave_bridge      = mv88e6xxx_port_bridge_leave,
        .port_stp_update        = mv88e6xxx_port_stp_update,
+       .port_vlan_filtering    = mv88e6xxx_port_vlan_filtering,
        .port_vlan_prepare      = mv88e6xxx_port_vlan_prepare,
        .port_vlan_add          = mv88e6xxx_port_vlan_add,
        .port_vlan_del          = mv88e6xxx_port_vlan_del,
index bbca36ac4f7769df483b34375365a0028918980e..a41fa5043d77a883a45351044db6ee605ea5d25e 100644 (file)
@@ -327,6 +327,7 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
        .port_join_bridge       = mv88e6xxx_port_bridge_join,
        .port_leave_bridge      = mv88e6xxx_port_bridge_leave,
        .port_stp_update        = mv88e6xxx_port_stp_update,
+       .port_vlan_filtering    = mv88e6xxx_port_vlan_filtering,
        .port_vlan_prepare      = mv88e6xxx_port_vlan_prepare,
        .port_vlan_add          = mv88e6xxx_port_vlan_add,
        .port_vlan_del          = mv88e6xxx_port_vlan_del,
index 27a19dccfd6551fb58e9db1a97cebb82de3e87ac..d11c9d58cf101f81c2b468fffbc0429c713b1c40 100644 (file)
@@ -1712,6 +1712,45 @@ unlock:
        return err;
 }
 
+static const char * const mv88e6xxx_port_8021q_mode_names[] = {
+       [PORT_CONTROL_2_8021Q_DISABLED] = "Disabled",
+       [PORT_CONTROL_2_8021Q_FALLBACK] = "Fallback",
+       [PORT_CONTROL_2_8021Q_CHECK] = "Check",
+       [PORT_CONTROL_2_8021Q_SECURE] = "Secure",
+};
+
+int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
+                                 bool vlan_filtering)
+{
+       struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
+       u16 old, new = vlan_filtering ? PORT_CONTROL_2_8021Q_SECURE :
+               PORT_CONTROL_2_8021Q_DISABLED;
+       int ret;
+
+       mutex_lock(&ps->smi_mutex);
+
+       ret = _mv88e6xxx_reg_read(ds, REG_PORT(port), PORT_CONTROL_2);
+       if (ret < 0)
+               goto unlock;
+
+       old = ret & PORT_CONTROL_2_8021Q_MASK;
+
+       ret &= ~PORT_CONTROL_2_8021Q_MASK;
+       ret |= new & PORT_CONTROL_2_8021Q_MASK;
+
+       ret = _mv88e6xxx_reg_write(ds, REG_PORT(port), PORT_CONTROL_2, ret);
+       if (ret < 0)
+               goto unlock;
+
+       netdev_dbg(ds->ports[port], "802.1Q Mode: %s (was %s)\n",
+                  mv88e6xxx_port_8021q_mode_names[new],
+                  mv88e6xxx_port_8021q_mode_names[old]);
+unlock:
+       mutex_unlock(&ps->smi_mutex);
+
+       return ret;
+}
+
 int mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
                                const struct switchdev_obj_port_vlan *vlan,
                                struct switchdev_trans *trans)
index 85a416620f7c121f1f04b2751a95c41c0dd1c694..d7b088dd8e163f1ba4d794b08aa578928e9c7788 100644 (file)
@@ -490,6 +490,8 @@ int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
                               struct net_device *bridge);
 int mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port);
 int mv88e6xxx_port_stp_update(struct dsa_switch *ds, int port, u8 state);
+int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
+                                 bool vlan_filtering);
 int mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
                                const struct switchdev_obj_port_vlan *vlan,
                                struct switchdev_trans *trans);