summaryrefslogtreecommitdiffstats
path: root/net/switchdev/switchdev.c
diff options
context:
space:
mode:
authorArkadi Sharshevsky <arkadis@mellanox.com>2017-06-08 02:44:13 -0400
committerDavid S. Miller <davem@davemloft.net>2017-06-08 14:16:24 -0400
commitff5cf100110c6ea722d63dfa3d747ceb179e8da4 (patch)
tree6e1c080ec32aee2430227777279d88042cefe043 /net/switchdev/switchdev.c
parent0baa10fff2c8a8a0e3bca8fb43112ed93c179c38 (diff)
net: switchdev: Change notifier chain to be atomic
In order to use the switchdev notifier chain for FDB sync with the device it has to be changed to atomic. The is done because the bridge can learn new FDBs in atomic context. Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Ivan Vecera <ivecera@redhat.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Reviewed-by: Ivan Vecera <ivecera@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/switchdev/switchdev.c')
-rw-r--r--net/switchdev/switchdev.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 8d40a7d31c99..25dc67ef9d37 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -571,24 +571,17 @@ int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj,
571} 571}
572EXPORT_SYMBOL_GPL(switchdev_port_obj_dump); 572EXPORT_SYMBOL_GPL(switchdev_port_obj_dump);
573 573
574static RAW_NOTIFIER_HEAD(switchdev_notif_chain); 574static ATOMIC_NOTIFIER_HEAD(switchdev_notif_chain);
575 575
576/** 576/**
577 * register_switchdev_notifier - Register notifier 577 * register_switchdev_notifier - Register notifier
578 * @nb: notifier_block 578 * @nb: notifier_block
579 * 579 *
580 * Register switch device notifier. This should be used by code 580 * Register switch device notifier.
581 * which needs to monitor events happening in particular device.
582 * Return values are same as for atomic_notifier_chain_register().
583 */ 581 */
584int register_switchdev_notifier(struct notifier_block *nb) 582int register_switchdev_notifier(struct notifier_block *nb)
585{ 583{
586 int err; 584 return atomic_notifier_chain_register(&switchdev_notif_chain, nb);
587
588 rtnl_lock();
589 err = raw_notifier_chain_register(&switchdev_notif_chain, nb);
590 rtnl_unlock();
591 return err;
592} 585}
593EXPORT_SYMBOL_GPL(register_switchdev_notifier); 586EXPORT_SYMBOL_GPL(register_switchdev_notifier);
594 587
@@ -597,16 +590,10 @@ EXPORT_SYMBOL_GPL(register_switchdev_notifier);
597 * @nb: notifier_block 590 * @nb: notifier_block
598 * 591 *
599 * Unregister switch device notifier. 592 * Unregister switch device notifier.
600 * Return values are same as for atomic_notifier_chain_unregister().
601 */ 593 */
602int unregister_switchdev_notifier(struct notifier_block *nb) 594int unregister_switchdev_notifier(struct notifier_block *nb)
603{ 595{
604 int err; 596 return atomic_notifier_chain_unregister(&switchdev_notif_chain, nb);
605
606 rtnl_lock();
607 err = raw_notifier_chain_unregister(&switchdev_notif_chain, nb);
608 rtnl_unlock();
609 return err;
610} 597}
611EXPORT_SYMBOL_GPL(unregister_switchdev_notifier); 598EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);
612 599
@@ -616,18 +603,13 @@ EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);
616 * @dev: port device 603 * @dev: port device
617 * @info: notifier information data 604 * @info: notifier information data
618 * 605 *
619 * Call all network notifier blocks. This should be called by driver 606 * Call all network notifier blocks.
620 * when it needs to propagate hardware event.
621 * Return values are same as for atomic_notifier_call_chain().
622 * rtnl_lock must be held.
623 */ 607 */
624int call_switchdev_notifiers(unsigned long val, struct net_device *dev, 608int call_switchdev_notifiers(unsigned long val, struct net_device *dev,
625 struct switchdev_notifier_info *info) 609 struct switchdev_notifier_info *info)
626{ 610{
627 ASSERT_RTNL();
628
629 info->dev = dev; 611 info->dev = dev;
630 return raw_notifier_call_chain(&switchdev_notif_chain, val, info); 612 return atomic_notifier_call_chain(&switchdev_notif_chain, val, info);
631} 613}
632EXPORT_SYMBOL_GPL(call_switchdev_notifiers); 614EXPORT_SYMBOL_GPL(call_switchdev_notifiers);
633 615