Skip to content

Commit 214cdb9

Browse files
viviendavem330
authored andcommitted
net: dsa: mv88e6xxx: support VLAN filtering
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 46fbe5e commit 214cdb9

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

drivers/net/dsa/mv88e6171.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
106106
.port_join_bridge = mv88e6xxx_port_bridge_join,
107107
.port_leave_bridge = mv88e6xxx_port_bridge_leave,
108108
.port_stp_update = mv88e6xxx_port_stp_update,
109+
.port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
109110
.port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
110111
.port_vlan_add = mv88e6xxx_port_vlan_add,
111112
.port_vlan_del = mv88e6xxx_port_vlan_del,

drivers/net/dsa/mv88e6352.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
327327
.port_join_bridge = mv88e6xxx_port_bridge_join,
328328
.port_leave_bridge = mv88e6xxx_port_bridge_leave,
329329
.port_stp_update = mv88e6xxx_port_stp_update,
330+
.port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
330331
.port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
331332
.port_vlan_add = mv88e6xxx_port_vlan_add,
332333
.port_vlan_del = mv88e6xxx_port_vlan_del,

drivers/net/dsa/mv88e6xxx.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,45 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
17121712
return err;
17131713
}
17141714

1715+
static const char * const mv88e6xxx_port_8021q_mode_names[] = {
1716+
[PORT_CONTROL_2_8021Q_DISABLED] = "Disabled",
1717+
[PORT_CONTROL_2_8021Q_FALLBACK] = "Fallback",
1718+
[PORT_CONTROL_2_8021Q_CHECK] = "Check",
1719+
[PORT_CONTROL_2_8021Q_SECURE] = "Secure",
1720+
};
1721+
1722+
int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1723+
bool vlan_filtering)
1724+
{
1725+
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
1726+
u16 old, new = vlan_filtering ? PORT_CONTROL_2_8021Q_SECURE :
1727+
PORT_CONTROL_2_8021Q_DISABLED;
1728+
int ret;
1729+
1730+
mutex_lock(&ps->smi_mutex);
1731+
1732+
ret = _mv88e6xxx_reg_read(ds, REG_PORT(port), PORT_CONTROL_2);
1733+
if (ret < 0)
1734+
goto unlock;
1735+
1736+
old = ret & PORT_CONTROL_2_8021Q_MASK;
1737+
1738+
ret &= ~PORT_CONTROL_2_8021Q_MASK;
1739+
ret |= new & PORT_CONTROL_2_8021Q_MASK;
1740+
1741+
ret = _mv88e6xxx_reg_write(ds, REG_PORT(port), PORT_CONTROL_2, ret);
1742+
if (ret < 0)
1743+
goto unlock;
1744+
1745+
netdev_dbg(ds->ports[port], "802.1Q Mode: %s (was %s)\n",
1746+
mv88e6xxx_port_8021q_mode_names[new],
1747+
mv88e6xxx_port_8021q_mode_names[old]);
1748+
unlock:
1749+
mutex_unlock(&ps->smi_mutex);
1750+
1751+
return ret;
1752+
}
1753+
17151754
int mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
17161755
const struct switchdev_obj_port_vlan *vlan,
17171756
struct switchdev_trans *trans)

drivers/net/dsa/mv88e6xxx.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
490490
struct net_device *bridge);
491491
int mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port);
492492
int mv88e6xxx_port_stp_update(struct dsa_switch *ds, int port, u8 state);
493+
int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
494+
bool vlan_filtering);
493495
int mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
494496
const struct switchdev_obj_port_vlan *vlan,
495497
struct switchdev_trans *trans);

0 commit comments

Comments
 (0)