diff options
Diffstat (limited to 'drivers/staging/fsl-dpaa2/ethsw/ethsw.c')
-rw-r--r-- | drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 14a9eebf687e..39c0fe347188 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -18,8 +18,6 @@ #include "ethsw.h" -static struct workqueue_struct *ethsw_owq; - /* Minimal supported DPSW version */ #define DPSW_MIN_VER_MAJOR 8 #define DPSW_MIN_VER_MINOR 1 @@ -1174,10 +1172,6 @@ static int port_netdevice_event(struct notifier_block *unused, return notifier_from_errno(err); } -static struct notifier_block port_nb __read_mostly = { - .notifier_call = port_netdevice_event, -}; - struct ethsw_switchdev_event_work { struct work_struct work; struct switchdev_notifier_fdb_info fdb_info; @@ -1233,8 +1227,10 @@ static int port_switchdev_event(struct notifier_block *unused, unsigned long event, void *ptr) { struct net_device *dev = switchdev_notifier_info_to_dev(ptr); + struct ethsw_port_priv *port_priv = netdev_priv(dev); struct ethsw_switchdev_event_work *switchdev_work; struct switchdev_notifier_fdb_info *fdb_info = ptr; + struct ethsw_core *ethsw = port_priv->ethsw_data; if (!ethsw_port_dev_check(dev)) return NOTIFY_DONE; @@ -1270,7 +1266,7 @@ static int port_switchdev_event(struct notifier_block *unused, return NOTIFY_DONE; } - queue_work(ethsw_owq, &switchdev_work->work); + queue_work(ethsw->workqueue, &switchdev_work->work); return NOTIFY_DONE; @@ -1318,31 +1314,27 @@ static int port_switchdev_blocking_event(struct notifier_block *unused, return NOTIFY_DONE; } -static struct notifier_block port_switchdev_nb = { - .notifier_call = port_switchdev_event, -}; - -static struct notifier_block port_switchdev_blocking_nb = { - .notifier_call = port_switchdev_blocking_event, -}; - static int ethsw_register_notifier(struct device *dev) { + struct ethsw_core *ethsw = dev_get_drvdata(dev); int err; - err = register_netdevice_notifier(&port_nb); + ethsw->port_nb.notifier_call = port_netdevice_event; + err = register_netdevice_notifier(ðsw->port_nb); if (err) { dev_err(dev, "Failed to register netdev notifier\n"); return err; } - err = register_switchdev_notifier(&port_switchdev_nb); + ethsw->port_switchdev_nb.notifier_call = port_switchdev_event; + err = register_switchdev_notifier(ðsw->port_switchdev_nb); if (err) { dev_err(dev, "Failed to register switchdev notifier\n"); goto err_switchdev_nb; } - err = register_switchdev_blocking_notifier(&port_switchdev_blocking_nb); + ethsw->port_switchdevb_nb.notifier_call = port_switchdev_blocking_event; + err = register_switchdev_blocking_notifier(ðsw->port_switchdevb_nb); if (err) { dev_err(dev, "Failed to register switchdev blocking notifier\n"); goto err_switchdev_blocking_nb; @@ -1351,9 +1343,9 @@ static int ethsw_register_notifier(struct device *dev) return 0; err_switchdev_blocking_nb: - unregister_switchdev_notifier(&port_switchdev_nb); + unregister_switchdev_notifier(ðsw->port_switchdev_nb); err_switchdev_nb: - unregister_netdevice_notifier(&port_nb); + unregister_netdevice_notifier(ðsw->port_nb); return err; } @@ -1435,9 +1427,10 @@ static int ethsw_init(struct fsl_mc_device *sw_dev) } } - ethsw_owq = alloc_ordered_workqueue("%s_ordered", WQ_MEM_RECLAIM, - "ethsw"); - if (!ethsw_owq) { + ethsw->workqueue = alloc_ordered_workqueue("%s_%d_ordered", + WQ_MEM_RECLAIM, "ethsw", + ethsw->sw_attr.id); + if (!ethsw->workqueue) { err = -ENOMEM; goto err_close; } @@ -1449,7 +1442,7 @@ static int ethsw_init(struct fsl_mc_device *sw_dev) return 0; err_destroy_ordered_workqueue: - destroy_workqueue(ethsw_owq); + destroy_workqueue(ethsw->workqueue); err_close: dpsw_close(ethsw->mc_io, 0, ethsw->dpsw_handle); @@ -1491,21 +1484,22 @@ static int ethsw_port_init(struct ethsw_port_priv *port_priv, u16 port) static void ethsw_unregister_notifier(struct device *dev) { + struct ethsw_core *ethsw = dev_get_drvdata(dev); struct notifier_block *nb; int err; - nb = &port_switchdev_blocking_nb; + nb = ðsw->port_switchdevb_nb; err = unregister_switchdev_blocking_notifier(nb); if (err) dev_err(dev, "Failed to unregister switchdev blocking notifier (%d)\n", err); - err = unregister_switchdev_notifier(&port_switchdev_nb); + err = unregister_switchdev_notifier(ðsw->port_switchdev_nb); if (err) dev_err(dev, "Failed to unregister switchdev notifier (%d)\n", err); - err = unregister_netdevice_notifier(&port_nb); + err = unregister_netdevice_notifier(ðsw->port_nb); if (err) dev_err(dev, "Failed to unregister netdev notifier (%d)\n", err); @@ -1536,7 +1530,7 @@ static int ethsw_remove(struct fsl_mc_device *sw_dev) ethsw_teardown_irqs(sw_dev); - destroy_workqueue(ethsw_owq); + destroy_workqueue(ethsw->workqueue); dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle); |