[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211025222415.983883-15-vladimir.oltean@nxp.com>
Date: Tue, 26 Oct 2021 01:24:14 +0300
From: Vladimir Oltean <vladimir.oltean@....com>
To: netdev@...r.kernel.org, Roopa Prabhu <roopa@...dia.com>,
Nikolay Aleksandrov <nikolay@...dia.com>,
Ido Schimmel <idosch@...dia.com>
Cc: Jakub Kicinski <kuba@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
Vivien Didelot <vivien.didelot@...il.com>,
Vladimir Oltean <olteanv@...il.com>,
Jiri Pirko <jiri@...dia.com>
Subject: [RFC PATCH net-next 14/15] net: dsa: propagate feedback to SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE
The strategy is to copy the entire struct switchdev_notifier_fdb_info to
our deferred work, since that contains pointers to the bridge cookies
waiting for us to tell it how things went with offloading the FDB entry.
Now that we have a full struct switchdev_notifier_fdb_info in the
deferred work, we can use that just fine to call dsa_fdb_offload_notify,
although that is not the primary purpose of this patch.
The shelf life of the cookies is basically right until the point where
we call switchdev_fdb_mark_done(). Since that wakes up the completion
and therefore the process that called into the bridge, it can just as
well free its on-stack data structures, so drivers can do nothing
(safely) with their struct switchdev_notifier_fdb_info copy after that
point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
---
net/dsa/dsa_priv.h | 6 +-----
net/dsa/slave.c | 42 +++++++++++++-----------------------------
2 files changed, 14 insertions(+), 34 deletions(-)
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index a5c9bc7b66c6..5d3f8291ec7f 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -131,11 +131,7 @@ struct dsa_switchdev_event_work {
struct net_device *dev;
struct work_struct work;
unsigned long event;
- /* Specific for SWITCHDEV_FDB_ADD_TO_DEVICE and
- * SWITCHDEV_FDB_DEL_TO_DEVICE
- */
- unsigned char addr[ETH_ALEN];
- u16 vid;
+ struct switchdev_notifier_fdb_info fdb_info;
bool host_addr;
};
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index af573d16dff5..1329e56e22ca 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -2388,66 +2388,50 @@ static int dsa_slave_netdevice_event(struct notifier_block *nb,
static void
dsa_fdb_offload_notify(struct dsa_switchdev_event_work *switchdev_work)
{
- struct switchdev_notifier_fdb_info info = {};
+ struct switchdev_notifier_fdb_info *fdb_info = &switchdev_work->fdb_info;
struct dsa_switch *ds = switchdev_work->ds;
struct dsa_port *dp;
if (!dsa_is_user_port(ds, switchdev_work->port))
return;
- ether_addr_copy(info.addr, switchdev_work->addr);
- info.vid = switchdev_work->vid;
- info.offloaded = true;
+ fdb_info->offloaded = true;
dp = dsa_to_port(ds, switchdev_work->port);
call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED,
- dp->slave, &info.info, NULL);
+ dp->slave, &fdb_info->info, NULL);
}
static void dsa_slave_switchdev_event_work(struct work_struct *work)
{
+ struct netlink_ext_ack *extack;
struct dsa_switchdev_event_work *switchdev_work =
container_of(work, struct dsa_switchdev_event_work, work);
+ struct switchdev_notifier_fdb_info *fdb_info = &switchdev_work->fdb_info;
struct dsa_switch *ds = switchdev_work->ds;
struct dsa_port *dp;
int err;
dp = dsa_to_port(ds, switchdev_work->port);
+ extack = switchdev_notifier_info_to_extack(&fdb_info->info);
switch (switchdev_work->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);
+ err = dsa_port_host_fdb_add(dp, fdb_info->addr, fdb_info->vid);
else
- err = dsa_port_fdb_add(dp, switchdev_work->addr,
- switchdev_work->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);
- break;
- }
+ err = dsa_port_fdb_add(dp, fdb_info->addr, fdb_info->vid);
dsa_fdb_offload_notify(switchdev_work);
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);
+ err = dsa_port_host_fdb_del(dp, fdb_info->addr, fdb_info->vid);
else
- err = dsa_port_fdb_del(dp, switchdev_work->addr,
- switchdev_work->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);
- }
-
+ err = dsa_port_fdb_del(dp, fdb_info->addr, fdb_info->vid);
break;
}
+ switchdev_fdb_mark_done(fdb_info, err);
dev_put(switchdev_work->dev);
kfree(switchdev_work);
}
@@ -2516,12 +2500,12 @@ static int dsa_slave_fdb_event(struct net_device *dev,
switchdev_work->event = event;
switchdev_work->dev = dev;
- ether_addr_copy(switchdev_work->addr, fdb_info->addr);
- switchdev_work->vid = fdb_info->vid;
+ memcpy(&switchdev_work->fdb_info, fdb_info, sizeof(*fdb_info));
switchdev_work->host_addr = host_addr;
/* Hold a reference for dsa_fdb_offload_notify */
dev_hold(dev);
+ switchdev_fdb_mark_pending(fdb_info);
dsa_schedule_work(&switchdev_work->work);
return 0;
--
2.25.1
Powered by blists - more mailing lists