From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>
Cc: Roopa Prabhu <roopa@nvidia.com>,
Nikolay Aleksandrov <nikolay@nvidia.com>,
Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Vivien Didelot <vivien.didelot@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
Vadym Kochan <vkochan@marvell.com>,
Taras Chornyi <tchornyi@marvell.com>,
Jiri Pirko <jiri@nvidia.com>, Ido Schimmel <idosch@nvidia.com>,
UNGLinuxDriver@microchip.com,
Grygorii Strashko <grygorii.strashko@ti.com>,
Marek Behun <kabel@blackhole.sk>,
DENG Qingfang <dqfext@gmail.com>,
Kurt Kanzenbach <kurt@linutronix.de>,
Hauke Mehrtens <hauke@hauke-m.de>,
Woojung Huh <woojung.huh@microchip.com>,
Sean Wang <sean.wang@mediatek.com>,
Landen Chao <Landen.Chao@mediatek.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
George McCollister <george.mccollister@gmail.com>,
Ioana Ciornei <ioana.ciornei@nxp.com>,
Saeed Mahameed <saeedm@nvidia.com>,
Leon Romanovsky <leon@kernel.org>,
Lars Povlsen <lars.povlsen@microchip.com>,
Steen Hegelund <Steen.Hegelund@microchip.com>,
Julian Wiedmann <jwi@linux.ibm.com>,
Alexandra Winter <wintera@linux.ibm.com>,
Karsten Graul <kgraul@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Ivan Vecera <ivecera@redhat.com>, Vlad Buslov <vladbu@nvidia.com>,
Jianbo Liu <jianbol@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
Roi Dayan <roid@nvidia.com>,
Tobias Waldekranz <tobias@waldekranz.com>,
Vignesh Raghavendra <vigneshr@ti.com>,
Jesse Brandeburg <jesse.brandeburg@intel.com>,
linux-s390@vger.kernel.org
Subject: [PATCH v3 net-next 7/7] net: dsa: handle SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE synchronously
Date: Fri, 20 Aug 2021 14:57:46 +0300 [thread overview]
Message-ID: <20210820115746.3701811-8-vladimir.oltean@nxp.com> (raw)
In-Reply-To: <20210820115746.3701811-1-vladimir.oltean@nxp.com>
Since the switchdev FDB entry notifications are now blocking and
deferred by switchdev and not by us, switchdev will also wait for us to
finish, which means we can proceed with our FDB isolation mechanism
based on dp->bridge_num.
It also means that the ordered workqueue is no longer needed, drop it
and simply call the driver.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
v2->v3: none
net/dsa/dsa.c | 15 -------
net/dsa/dsa_priv.h | 15 -------
net/dsa/slave.c | 110 ++++++++++++---------------------------------
3 files changed, 28 insertions(+), 112 deletions(-)
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 1dc45e40f961..b2126334387f 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -338,13 +338,6 @@ static struct packet_type dsa_pack_type __read_mostly = {
.func = dsa_switch_rcv,
};
-static struct workqueue_struct *dsa_owq;
-
-bool dsa_schedule_work(struct work_struct *work)
-{
- return queue_work(dsa_owq, work);
-}
-
int dsa_devlink_param_get(struct devlink *dl, u32 id,
struct devlink_param_gset_ctx *ctx)
{
@@ -465,11 +458,6 @@ static int __init dsa_init_module(void)
{
int rc;
- dsa_owq = alloc_ordered_workqueue("dsa_ordered",
- WQ_MEM_RECLAIM);
- if (!dsa_owq)
- return -ENOMEM;
-
rc = dsa_slave_register_notifier();
if (rc)
goto register_notifier_fail;
@@ -482,8 +470,6 @@ static int __init dsa_init_module(void)
return 0;
register_notifier_fail:
- destroy_workqueue(dsa_owq);
-
return rc;
}
module_init(dsa_init_module);
@@ -494,7 +480,6 @@ static void __exit dsa_cleanup_module(void)
dsa_slave_unregister_notifier();
dev_remove_pack(&dsa_pack_type);
- destroy_workqueue(dsa_owq);
}
module_exit(dsa_cleanup_module);
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index b7a269e0513f..f759abceeb18 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -125,20 +125,6 @@ struct dsa_notifier_tag_8021q_vlan_info {
u16 vid;
};
-struct dsa_switchdev_event_work {
- struct dsa_switch *ds;
- int port;
- 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;
- bool host_addr;
-};
-
/* DSA_NOTIFIER_HSR_* */
struct dsa_notifier_hsr_info {
struct net_device *hsr;
@@ -169,7 +155,6 @@ const struct dsa_device_ops *dsa_tag_driver_get(int tag_protocol);
void dsa_tag_driver_put(const struct dsa_device_ops *ops);
const struct dsa_device_ops *dsa_find_tagger_by_name(const char *buf);
-bool dsa_schedule_work(struct work_struct *work);
const char *dsa_tag_protocol_to_str(const struct dsa_device_ops *ops);
static inline int dsa_tag_protocol_overhead(const struct dsa_device_ops *ops)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 196a0e1f4294..8507e0cd2b9e 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -2278,73 +2278,18 @@ 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 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;
+ ether_addr_copy(info.addr, addr);
+ info.vid = vid;
info.offloaded = true;
- dp = dsa_to_port(ds, switchdev_work->port);
- call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED,
- dp->slave, &info.info, NULL);
-}
-
-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 dsa_switch *ds = switchdev_work->ds;
- struct dsa_port *dp;
- int err;
-
- dp = dsa_to_port(ds, switchdev_work->port);
-
- rtnl_lock();
- 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);
- 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;
- }
- 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);
- 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);
- }
-
- break;
- }
- rtnl_unlock();
- dev_put(switchdev_work->dev);
- kfree(switchdev_work);
+ call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED, dev, &info.info,
+ NULL);
}
static bool dsa_foreign_dev_check(const struct net_device *dev,
@@ -2369,10 +2314,12 @@ static int dsa_slave_fdb_event(struct net_device *dev,
const struct switchdev_notifier_fdb_info *fdb_info,
unsigned long event)
{
- struct dsa_switchdev_event_work *switchdev_work;
struct dsa_port *dp = dsa_slave_to_port(dev);
+ const unsigned char *addr = fdb_info->addr;
bool host_addr = fdb_info->is_local;
struct dsa_switch *ds = dp->ds;
+ u16 vid = fdb_info->vid;
+ int err;
if (ctx && ctx != dp)
return 0;
@@ -2397,30 +2344,29 @@ static int dsa_slave_fdb_event(struct net_device *dev,
if (dsa_foreign_dev_check(dev, orig_dev))
host_addr = true;
- switchdev_work = kzalloc(sizeof(*switchdev_work), GFP_ATOMIC);
- if (!switchdev_work)
- return -ENOMEM;
-
netdev_dbg(dev, "%s FDB entry towards %s, addr %pM vid %d%s\n",
event == SWITCHDEV_FDB_ADD_TO_DEVICE ? "Adding" : "Deleting",
- orig_dev->name, fdb_info->addr, fdb_info->vid,
- host_addr ? " as host address" : "");
-
- INIT_WORK(&switchdev_work->work, dsa_slave_switchdev_event_work);
- switchdev_work->ds = ds;
- switchdev_work->port = dp->index;
- switchdev_work->event = event;
- switchdev_work->dev = dev;
+ orig_dev->name, addr, vid, host_addr ? " as host address" : "");
- ether_addr_copy(switchdev_work->addr, fdb_info->addr);
- switchdev_work->vid = fdb_info->vid;
- switchdev_work->host_addr = host_addr;
+ switch (event) {
+ case SWITCHDEV_FDB_ADD_TO_DEVICE:
+ if (host_addr)
+ err = dsa_port_host_fdb_add(dp, addr, vid);
+ else
+ err = dsa_port_fdb_add(dp, addr, vid);
+ if (!err)
+ dsa_fdb_offload_notify(dev, addr, vid);
+ break;
- /* Hold a reference for dsa_fdb_offload_notify */
- dev_hold(dev);
- dsa_schedule_work(&switchdev_work->work);
+ case SWITCHDEV_FDB_DEL_TO_DEVICE:
+ if (host_addr)
+ err = dsa_port_host_fdb_del(dp, addr, vid);
+ else
+ err = dsa_port_fdb_del(dp, addr, vid);
+ break;
+ }
- return 0;
+ return err;
}
static int
--
2.25.1
next prev parent reply other threads:[~2021-08-20 11:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-20 11:57 [PATCH v3 net-next 0/7] Make SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE blocking Vladimir Oltean
2021-08-20 11:57 ` [PATCH v3 net-next 1/7] net: bridge: move br_fdb_replay inside br_switchdev.c Vladimir Oltean
2021-08-20 11:57 ` [PATCH v3 net-next 2/7] net: switchdev: keep the MAC address by value in struct switchdev_notifier_fdb_info Vladimir Oltean
2021-08-20 11:57 ` [PATCH v3 net-next 3/7] net: switchdev: move SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE to the blocking notifier chain Vladimir Oltean
2021-08-20 15:54 ` Jakub Kicinski
2021-08-20 15:57 ` Vladimir Oltean
2021-08-20 16:55 ` Jakub Kicinski
2021-08-20 11:57 ` [PATCH v3 net-next 4/7] net: bridge: switchdev: make br_fdb_replay offer sleepable context to consumers Vladimir Oltean
2021-08-20 11:57 ` [PATCH v3 net-next 5/7] net: switchdev: drop the atomic notifier block from switchdev_bridge_port_{,un}offload Vladimir Oltean
2021-08-20 11:57 ` [PATCH v3 net-next 6/7] net: switchdev: don't assume RCU context in switchdev_handle_fdb_{add,del}_to_device Vladimir Oltean
2021-08-20 11:57 ` Vladimir Oltean [this message]
2021-08-20 15:46 ` [PATCH v3 net-next 0/7] Make SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE blocking Vlad Buslov
2021-08-26 14:35 ` Alexandra Winter
2021-08-26 14:41 ` Vladimir Oltean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210820115746.3701811-8-vladimir.oltean@nxp.com \
--to=vladimir.oltean@nxp.com \
--cc=Landen.Chao@mediatek.com \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@lunn.ch \
--cc=borntraeger@de.ibm.com \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=dqfext@gmail.com \
--cc=f.fainelli@gmail.com \
--cc=george.mccollister@gmail.com \
--cc=gor@linux.ibm.com \
--cc=grygorii.strashko@ti.com \
--cc=hauke@hauke-m.de \
--cc=hca@linux.ibm.com \
--cc=idosch@nvidia.com \
--cc=ioana.ciornei@nxp.com \
--cc=ivecera@redhat.com \
--cc=jesse.brandeburg@intel.com \
--cc=jianbol@nvidia.com \
--cc=jiri@nvidia.com \
--cc=jwi@linux.ibm.com \
--cc=kabel@blackhole.sk \
--cc=kgraul@linux.ibm.com \
--cc=kuba@kernel.org \
--cc=kurt@linutronix.de \
--cc=lars.povlsen@microchip.com \
--cc=leon@kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=nikolay@nvidia.com \
--cc=olteanv@gmail.com \
--cc=roid@nvidia.com \
--cc=roopa@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=sean.wang@mediatek.com \
--cc=tchornyi@marvell.com \
--cc=tobias@waldekranz.com \
--cc=vigneshr@ti.com \
--cc=vivien.didelot@gmail.com \
--cc=vkochan@marvell.com \
--cc=vladbu@nvidia.com \
--cc=wintera@linux.ibm.com \
--cc=woojung.huh@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox