[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220210125201.2859463-11-vladimir.oltean@nxp.com>
Date: Thu, 10 Feb 2022 14:51:59 +0200
From: Vladimir Oltean <vladimir.oltean@....com>
To: netdev@...r.kernel.org
Cc: "David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
Ansuel Smith <ansuelsmth@...il.com>,
Tobias Waldekranz <tobias@...dekranz.com>,
DENG Qingfang <dqfext@...il.com>,
Claudiu Manoil <claudiu.manoil@....com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
UNGLinuxDriver@...rochip.com, Jiri Pirko <jiri@...nulli.us>,
Ivan Vecera <ivecera@...hat.com>
Subject: [PATCH v2 net-next 10/12] net: dsa: refactor FDB event work for user ports to separate function
The procedure for installing a FDB entry towards a LAG is different than
the one for a port. This patch refactors dsa_slave_switchdev_event_work()
into a smaller function that checks the net_device type, and if it's a
DSA slave interface (the only one supported for now), it calls the
current body of that function, now moved to dsa_slave_fdb_event_work().
As part of this change, the dsa_slave_fdb_event_work() and
dsa_fdb_offload_notify() function prototypes were also modified to take
the list of the arguments they need, instead of the full struct
dsa_switchdev_event_work that contains those arguments.
Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
---
net/dsa/slave.c | 71 ++++++++++++++++++++++++++-----------------------
1 file changed, 38 insertions(+), 33 deletions(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 273ae558ccd9..e5e22486a831 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -2423,64 +2423,69 @@ static int dsa_slave_netdevice_event(struct notifier_block *nb,
return NOTIFY_DONE;
}
-static void
-dsa_fdb_offload_notify(struct dsa_switchdev_event_work *switchdev_work)
+static void dsa_fdb_offload_notify(struct net_device *dev,
+ const unsigned char *addr, u16 vid)
{
- struct switchdev_notifier_fdb_info info = {};
+ struct switchdev_notifier_fdb_info info = {
+ .addr = addr,
+ .vid = vid,
+ .offloaded = true,
+ };
- info.addr = switchdev_work->addr;
- info.vid = switchdev_work->vid;
- info.offloaded = true;
- call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED,
- switchdev_work->dev, &info.info, NULL);
+ call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED, dev, &info.info,
+ NULL);
}
-static void dsa_slave_switchdev_event_work(struct work_struct *work)
+static void dsa_slave_fdb_event_work(struct net_device *dev,
+ unsigned long event,
+ const unsigned char *addr,
+ u16 vid, bool host_addr)
{
- struct dsa_switchdev_event_work *switchdev_work =
- container_of(work, struct dsa_switchdev_event_work, work);
- struct net_device *dev = switchdev_work->dev;
- struct dsa_switch *ds;
- struct dsa_port *dp;
+ struct dsa_port *dp = dsa_slave_to_port(dev);
+ struct dsa_switch *ds = dp->ds;
int err;
- dp = dsa_slave_to_port(dev);
- ds = dp->ds;
-
- switch (switchdev_work->event) {
+ switch (event) {
case SWITCHDEV_FDB_ADD_TO_DEVICE:
- if (switchdev_work->host_addr)
- err = dsa_port_host_fdb_add(dp, switchdev_work->addr,
- switchdev_work->vid);
+ if (host_addr)
+ err = dsa_port_host_fdb_add(dp, addr, vid);
else
- err = dsa_port_fdb_add(dp, switchdev_work->addr,
- switchdev_work->vid);
+ err = dsa_port_fdb_add(dp, addr, vid);
if (err) {
dev_err(ds->dev,
"port %d failed to add %pM vid %d to fdb: %d\n",
- dp->index, switchdev_work->addr,
- switchdev_work->vid, err);
+ dp->index, addr, vid, err);
break;
}
- dsa_fdb_offload_notify(switchdev_work);
+ dsa_fdb_offload_notify(dev, addr, vid);
break;
case SWITCHDEV_FDB_DEL_TO_DEVICE:
- if (switchdev_work->host_addr)
- err = dsa_port_host_fdb_del(dp, switchdev_work->addr,
- switchdev_work->vid);
+ if (host_addr)
+ err = dsa_port_host_fdb_del(dp, addr, vid);
else
- err = dsa_port_fdb_del(dp, switchdev_work->addr,
- switchdev_work->vid);
+ err = dsa_port_fdb_del(dp, addr, vid);
if (err) {
dev_err(ds->dev,
"port %d failed to delete %pM vid %d from fdb: %d\n",
- dp->index, switchdev_work->addr,
- switchdev_work->vid, err);
+ dp->index, addr, vid, err);
}
break;
}
+}
+
+static void dsa_slave_switchdev_event_work(struct work_struct *work)
+{
+ struct dsa_switchdev_event_work *switchdev_work =
+ container_of(work, struct dsa_switchdev_event_work, work);
+ struct net_device *dev = switchdev_work->dev;
+
+ if (dsa_slave_dev_check(dev))
+ dsa_slave_fdb_event_work(dev, switchdev_work->event,
+ switchdev_work->addr,
+ switchdev_work->vid,
+ switchdev_work->host_addr);
kfree(switchdev_work);
}
--
2.25.1
Powered by blists - more mailing lists