1 From 829d9def89b452c4d13d15fd578dea524d9f8521 Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Sat, 9 Nov 2019 15:02:48 +0200
4 Subject: [PATCH] net: mscc: ocelot: break apart vlan operations into
7 We need an implementation of these functions that is agnostic to the
8 higher layer (switchdev or dsa).
10 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
13 drivers/net/ethernet/mscc/ocelot.c | 60 ++++++++++++++++++++++++++------------
14 1 file changed, 42 insertions(+), 18 deletions(-)
16 --- a/drivers/net/ethernet/mscc/ocelot.c
17 +++ b/drivers/net/ethernet/mscc/ocelot.c
18 @@ -270,18 +270,11 @@ static void ocelot_port_set_pvid(struct
19 ocelot_port->pvid = pvid;
22 -static int ocelot_vlan_vid_add(struct net_device *dev, u16 vid, bool pvid,
24 +static int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid,
27 - struct ocelot_port *ocelot_port = netdev_priv(dev);
28 - struct ocelot *ocelot = ocelot_port->ocelot;
29 - int port = ocelot_port->chip_port;
32 - /* Add the port MAC address to with the right VLAN information */
33 - ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr, vid,
36 /* Make the port a member of the VLAN */
37 ocelot->vlan_mask[vid] |= BIT(port);
38 ret = ocelot_vlant_set_mask(ocelot, vid, ocelot->vlan_mask[vid]);
39 @@ -302,22 +295,29 @@ static int ocelot_vlan_vid_add(struct ne
43 -static int ocelot_vlan_vid_del(struct net_device *dev, u16 vid)
44 +static int ocelot_vlan_vid_add(struct net_device *dev, u16 vid, bool pvid,
47 struct ocelot_port *ocelot_port = netdev_priv(dev);
48 struct ocelot *ocelot = ocelot_port->ocelot;
49 int port = ocelot_port->chip_port;
52 - /* 8021q removes VID 0 on module unload for all interfaces
53 - * with VLAN filtering feature. We need to keep it to receive
58 + ret = ocelot_vlan_add(ocelot, port, vid, pvid, untagged);
62 - /* Del the port MAC address to with the right VLAN information */
63 - ocelot_mact_forget(ocelot, dev->dev_addr, vid);
64 + /* Add the port MAC address to with the right VLAN information */
65 + ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr, vid,
71 +static int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid)
73 + struct ocelot_port *ocelot_port = ocelot->ports[port];
76 /* Stop the port from being a member of the vlan */
77 ocelot->vlan_mask[vid] &= ~BIT(port);
78 @@ -335,6 +335,30 @@ static int ocelot_vlan_vid_del(struct ne
83 +static int ocelot_vlan_vid_del(struct net_device *dev, u16 vid)
85 + struct ocelot_port *ocelot_port = netdev_priv(dev);
86 + struct ocelot *ocelot = ocelot_port->ocelot;
87 + int port = ocelot_port->chip_port;
90 + /* 8021q removes VID 0 on module unload for all interfaces
91 + * with VLAN filtering feature. We need to keep it to receive
97 + ret = ocelot_vlan_del(ocelot, port, vid);
101 + /* Del the port MAC address to with the right VLAN information */
102 + ocelot_mact_forget(ocelot, dev->dev_addr, vid);
107 static void ocelot_vlan_init(struct ocelot *ocelot)