Message ID | 1499268990-19251-5-git-send-email-arkadis@mellanox.com |
---|---|
State | RFC, archived |
Delegated to: | David Miller |
Headers | show |
On 07/05/2017 08:36 AM, Arkadi Sharshevsky wrote: > This workqueue will be used for FDB add/del processing. It should > be destroyed after all devices unregistered successfully. > > Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com> > --- > include/net/dsa.h | 1 + > net/dsa/dsa.c | 13 +++++++++++++ > 2 files changed, 14 insertions(+) > > diff --git a/include/net/dsa.h b/include/net/dsa.h > index f054d41..4835b0e 100644 > --- a/include/net/dsa.h > +++ b/include/net/dsa.h > @@ -451,6 +451,7 @@ void unregister_switch_driver(struct dsa_switch_driver *type); > struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev); > > struct net_device *dsa_dev_to_net_device(struct device *dev); > +bool dsa_schedule_work(struct work_struct *work); I'd move this to dsa_priv.h in net/dsa/ because it is not supposed to be used by DSA drivers. You may also consider squashing this into the next patch since in itself it's not used just yet. > > /* Keep inline for faster access in hot path */ > static inline bool netdev_uses_dsa(struct net_device *dev) > diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c > index 416ac4e..9abe6dc 100644 > --- a/net/dsa/dsa.c > +++ b/net/dsa/dsa.c > @@ -271,10 +271,22 @@ 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); > +} > + > 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) > return rc; > @@ -294,6 +306,7 @@ static void __exit dsa_cleanup_module(void) > dsa_slave_unregister_notifier(); > dev_remove_pack(&dsa_pack_type); > dsa_legacy_unregister(); > + destroy_workqueue(dsa_owq); > } > module_exit(dsa_cleanup_module); > >
Hi Arkadi, Florian Fainelli <f.fainelli@gmail.com> writes: > On 07/05/2017 08:36 AM, Arkadi Sharshevsky wrote: >> This workqueue will be used for FDB add/del processing. It should >> be destroyed after all devices unregistered successfully. >> >> Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com> >> --- >> include/net/dsa.h | 1 + >> net/dsa/dsa.c | 13 +++++++++++++ >> 2 files changed, 14 insertions(+) >> >> diff --git a/include/net/dsa.h b/include/net/dsa.h >> index f054d41..4835b0e 100644 >> --- a/include/net/dsa.h >> +++ b/include/net/dsa.h >> @@ -451,6 +451,7 @@ void unregister_switch_driver(struct dsa_switch_driver *type); >> struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev); >> >> struct net_device *dsa_dev_to_net_device(struct device *dev); >> +bool dsa_schedule_work(struct work_struct *work); > > I'd move this to dsa_priv.h in net/dsa/ because it is not supposed to be > used by DSA drivers. > > You may also consider squashing this into the next patch since in itself > it's not used just yet. I agree with Florian on this. Even though it'll make the next patch a bit bigger, it'll make it easier to understand the whole workqueue processing logic. Thanks, Vivien
On 07/06/2017 09:45 PM, Vivien Didelot wrote: > Hi Arkadi, > > Florian Fainelli <f.fainelli@gmail.com> writes: > >> On 07/05/2017 08:36 AM, Arkadi Sharshevsky wrote: >>> This workqueue will be used for FDB add/del processing. It should >>> be destroyed after all devices unregistered successfully. >>> >>> Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com> >>> --- >>> include/net/dsa.h | 1 + >>> net/dsa/dsa.c | 13 +++++++++++++ >>> 2 files changed, 14 insertions(+) >>> >>> diff --git a/include/net/dsa.h b/include/net/dsa.h >>> index f054d41..4835b0e 100644 >>> --- a/include/net/dsa.h >>> +++ b/include/net/dsa.h >>> @@ -451,6 +451,7 @@ void unregister_switch_driver(struct dsa_switch_driver *type); >>> struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev); >>> >>> struct net_device *dsa_dev_to_net_device(struct device *dev); >>> +bool dsa_schedule_work(struct work_struct *work); >> >> I'd move this to dsa_priv.h in net/dsa/ because it is not supposed to be >> used by DSA drivers. >> >> You may also consider squashing this into the next patch since in itself >> it's not used just yet. > > I agree with Florian on this. Even though it'll make the next patch a > bit bigger, it'll make it easier to understand the whole workqueue > processing logic. > > Thanks, > > Vivien > Ok no problem, will squash. Thanks
diff --git a/include/net/dsa.h b/include/net/dsa.h index f054d41..4835b0e 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -451,6 +451,7 @@ void unregister_switch_driver(struct dsa_switch_driver *type); struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev); struct net_device *dsa_dev_to_net_device(struct device *dev); +bool dsa_schedule_work(struct work_struct *work); /* Keep inline for faster access in hot path */ static inline bool netdev_uses_dsa(struct net_device *dev) diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 416ac4e..9abe6dc 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -271,10 +271,22 @@ 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); +} + 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) return rc; @@ -294,6 +306,7 @@ static void __exit dsa_cleanup_module(void) dsa_slave_unregister_notifier(); dev_remove_pack(&dsa_pack_type); dsa_legacy_unregister(); + destroy_workqueue(dsa_owq); } module_exit(dsa_cleanup_module);
This workqueue will be used for FDB add/del processing. It should be destroyed after all devices unregistered successfully. Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com> --- include/net/dsa.h | 1 + net/dsa/dsa.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)