aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Hiramoto <karl@hiramoto.org>2010-07-08 16:55:30 -0400
committerDavid S. Miller <davem@davemloft.net>2010-07-09 03:09:20 -0400
commit7313bb8f3dd6e28bcf9c42adfd54a5cf9a4949e0 (patch)
tree65d8486a2ff4aabc23e0b021f068dd3788081923
parent68dc9d36c19aa1fd1633427b419d5e1f44753e8a (diff)
atm: propagate signal changes via notifier
Add notifier chain for changes in atm_dev. Clients like br2684 will call register_atmdevice_notifier() to be notified of changes. Drivers will call atm_dev_signal_change() to notify clients like br2684 of the change. On DSL and ATM devices it's usefull to have a know if you have a carrier signal. netdevice LOWER_UP changes can be propagated to userspace via netlink monitor. Signed-off-by: Karl Hiramoto <karl@hiramoto.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/atmdev.h17
-rw-r--r--net/atm/common.c30
2 files changed, 47 insertions, 0 deletions
diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
index 817b23705c91..f6481daf6e52 100644
--- a/include/linux/atmdev.h
+++ b/include/linux/atmdev.h
@@ -431,6 +431,14 @@ struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops,
431 int number,unsigned long *flags); /* number == -1: pick first available */ 431 int number,unsigned long *flags); /* number == -1: pick first available */
432struct atm_dev *atm_dev_lookup(int number); 432struct atm_dev *atm_dev_lookup(int number);
433void atm_dev_deregister(struct atm_dev *dev); 433void atm_dev_deregister(struct atm_dev *dev);
434
435/* atm_dev_signal_change
436 *
437 * Propagate lower layer signal change in atm_dev->signal to netdevice.
438 * The event will be sent via a notifier call chain.
439 */
440void atm_dev_signal_change(struct atm_dev *dev, char signal);
441
434void vcc_insert_socket(struct sock *sk); 442void vcc_insert_socket(struct sock *sk);
435 443
436 444
@@ -510,6 +518,15 @@ void register_atm_ioctl(struct atm_ioctl *);
510 */ 518 */
511void deregister_atm_ioctl(struct atm_ioctl *); 519void deregister_atm_ioctl(struct atm_ioctl *);
512 520
521
522/* register_atmdevice_notifier - register atm_dev notify events
523 *
524 * Clients like br2684 will register notify events
525 * Currently we notify of signal found/lost
526 */
527int register_atmdevice_notifier(struct notifier_block *nb);
528void unregister_atmdevice_notifier(struct notifier_block *nb);
529
513#endif /* __KERNEL__ */ 530#endif /* __KERNEL__ */
514 531
515#endif 532#endif
diff --git a/net/atm/common.c b/net/atm/common.c
index b43feb1a3995..940404a73b3d 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -37,6 +37,8 @@ EXPORT_SYMBOL(vcc_hash);
37DEFINE_RWLOCK(vcc_sklist_lock); 37DEFINE_RWLOCK(vcc_sklist_lock);
38EXPORT_SYMBOL(vcc_sklist_lock); 38EXPORT_SYMBOL(vcc_sklist_lock);
39 39
40static ATOMIC_NOTIFIER_HEAD(atm_dev_notify_chain);
41
40static void __vcc_insert_socket(struct sock *sk) 42static void __vcc_insert_socket(struct sock *sk)
41{ 43{
42 struct atm_vcc *vcc = atm_sk(sk); 44 struct atm_vcc *vcc = atm_sk(sk);
@@ -212,6 +214,22 @@ void vcc_release_async(struct atm_vcc *vcc, int reply)
212} 214}
213EXPORT_SYMBOL(vcc_release_async); 215EXPORT_SYMBOL(vcc_release_async);
214 216
217void atm_dev_signal_change(struct atm_dev *dev, char signal)
218{
219 pr_debug("%s signal=%d dev=%p number=%d dev->signal=%d\n",
220 __func__, signal, dev, dev->number, dev->signal);
221
222 /* atm driver sending invalid signal */
223 WARN_ON(signal < ATM_PHY_SIG_LOST || signal > ATM_PHY_SIG_FOUND);
224
225 if (dev->signal == signal)
226 return; /* no change */
227
228 dev->signal = signal;
229
230 atomic_notifier_call_chain(&atm_dev_notify_chain, signal, dev);
231}
232EXPORT_SYMBOL(atm_dev_signal_change);
215 233
216void atm_dev_release_vccs(struct atm_dev *dev) 234void atm_dev_release_vccs(struct atm_dev *dev)
217{ 235{
@@ -781,6 +799,18 @@ int vcc_getsockopt(struct socket *sock, int level, int optname,
781 return vcc->dev->ops->getsockopt(vcc, level, optname, optval, len); 799 return vcc->dev->ops->getsockopt(vcc, level, optname, optval, len);
782} 800}
783 801
802int register_atmdevice_notifier(struct notifier_block *nb)
803{
804 return atomic_notifier_chain_register(&atm_dev_notify_chain, nb);
805}
806EXPORT_SYMBOL_GPL(register_atmdevice_notifier);
807
808void unregister_atmdevice_notifier(struct notifier_block *nb)
809{
810 atomic_notifier_chain_unregister(&atm_dev_notify_chain, nb);
811}
812EXPORT_SYMBOL_GPL(unregister_atmdevice_notifier);
813
784static int __init atm_init(void) 814static int __init atm_init(void)
785{ 815{
786 int error; 816 int error;