diff options
Diffstat (limited to 'drivers/isdn')
55 files changed, 1727 insertions, 1723 deletions
diff --git a/drivers/isdn/Kconfig b/drivers/isdn/Kconfig index 022a1945295..4fb601670de 100644 --- a/drivers/isdn/Kconfig +++ b/drivers/isdn/Kconfig @@ -7,15 +7,14 @@ menuconfig ISDN depends on NET depends on !S390 ---help--- - ISDN ("Integrated Services Digital Networks", called RNIS in France) - is a special type of fully digital telephone service; it's mostly - used to connect to your Internet service provider (with SLIP or - PPP). The main advantage is that the speed is higher than ordinary - modem/telephone connections, and that you can have voice - conversations while downloading stuff. It only works if your - computer is equipped with an ISDN card and both you and your service - provider purchased an ISDN line from the phone company. For - details, read <http://www.alumni.caltech.edu/~dank/isdn/> on the WWW. + ISDN ("Integrated Services Digital Network", called RNIS in France) + is a fully digital telephone service that can be used for voice and + data connections. If your computer is equipped with an ISDN + adapter you can use it to connect to your Internet service provider + (with SLIP or PPP) faster than via a conventional telephone modem + (though still much slower than with DSL) or to make and accept + voice calls (eg. turning your PC into a software answering machine + or PABX). Select this option if you want your kernel to support ISDN. @@ -39,17 +38,22 @@ menuconfig ISDN_I4L It is still available, though, for use with adapters that are not supported by the new CAPI subsystem yet. -source "drivers/isdn/mISDN/Kconfig" - source "drivers/isdn/i4l/Kconfig" menuconfig ISDN_CAPI tristate "CAPI 2.0 subsystem" help - This provides the CAPI (Common ISDN Application Programming - Interface, a standard making it easy for programs to access ISDN - hardware, see <http://www.capi.org/>. This is needed for AVM's set - of active ISDN controllers like B1, T1, M1. + This provides CAPI (the Common ISDN Application Programming + Interface) Version 2.0, a standard making it easy for programs to + access ISDN hardware in a device independent way. (For details see + <http://www.capi.org/>.) CAPI supports making and accepting voice + and data connections, controlling call options and protocols, + as well as ISDN supplementary services like call forwarding or + three-party conferences (if supported by the specific hardware + driver). + + Select this option and the appropriate hardware driver below if + you have an ISDN adapter supported by the CAPI subsystem. if ISDN_CAPI @@ -61,4 +65,13 @@ endif # ISDN_CAPI source "drivers/isdn/gigaset/Kconfig" +source "drivers/isdn/hysdn/Kconfig" + +source "drivers/isdn/mISDN/Kconfig" + +config ISDN_HDLC + tristate + select CRC_CCITT + select BITREVERSE + endif # ISDN diff --git a/drivers/isdn/capi/Kconfig b/drivers/isdn/capi/Kconfig index b2a04755c96..a168e8a891b 100644 --- a/drivers/isdn/capi/Kconfig +++ b/drivers/isdn/capi/Kconfig @@ -17,8 +17,7 @@ config CAPI_TRACE If unsure, say Y. config ISDN_CAPI_MIDDLEWARE - bool "CAPI2.0 Middleware support (EXPERIMENTAL)" - depends on EXPERIMENTAL + bool "CAPI2.0 Middleware support" help This option will enhance the capabilities of the /dev/capi20 interface. It will provide a means of moving a data connection, @@ -35,18 +34,19 @@ config ISDN_CAPI_CAPI20 Y/M here. config ISDN_CAPI_CAPIFS_BOOL - bool "CAPI2.0 filesystem support" + bool "CAPI2.0 filesystem support (DEPRECATED)" depends on ISDN_CAPI_MIDDLEWARE && ISDN_CAPI_CAPI20 + help + This option provides a special file system, similar to /dev/pts with + device nodes for the special ttys established by using the + middleware extension above. + You no longer need this, udev fully replaces it. This feature is + scheduled for removal. config ISDN_CAPI_CAPIFS tristate depends on ISDN_CAPI_CAPIFS_BOOL default ISDN_CAPI_CAPI20 - help - This option provides a special file system, similar to /dev/pts with - device nodes for the special ttys established by using the - middleware extension above. If you want to use pppd with - pppdcapiplugin to dial up to your ISP, say Y here. config ISDN_CAPI_CAPIDRV tristate "CAPI2.0 capidrv interface support" diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index 65bf91e16a4..ee5837522f5 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c @@ -23,16 +23,13 @@ #include <linux/smp_lock.h> #include <linux/timer.h> #include <linux/wait.h> -#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE #include <linux/tty.h> -#ifdef CONFIG_PPP #include <linux/netdevice.h> #include <linux/ppp_defs.h> #include <linux/if_ppp.h> -#endif /* CONFIG_PPP */ -#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ #include <linux/skbuff.h> #include <linux/proc_fs.h> +#include <linux/seq_file.h> #include <linux/poll.h> #include <linux/capi.h> #include <linux/kernelcapi.h> @@ -41,35 +38,29 @@ #include <linux/moduleparam.h> #include <linux/isdn/capiutil.h> #include <linux/isdn/capicmd.h> -#if defined(CONFIG_ISDN_CAPI_CAPIFS) || defined(CONFIG_ISDN_CAPI_CAPIFS_MODULE) -#include "capifs.h" -#endif -static char *revision = "$Revision: 1.1.2.7 $"; +#include "capifs.h" MODULE_DESCRIPTION("CAPI4Linux: Userspace /dev/capi20 interface"); MODULE_AUTHOR("Carsten Paeth"); MODULE_LICENSE("GPL"); -#undef _DEBUG_REFCOUNT /* alloc/free and open/close debug */ #undef _DEBUG_TTYFUNCS /* call to tty_driver */ #undef _DEBUG_DATAFLOW /* data flow */ /* -------- driver information -------------------------------------- */ static struct class *capi_class; - static int capi_major = 68; /* allocated */ + +module_param_named(major, capi_major, uint, 0); + #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE -#define CAPINC_NR_PORTS 32 +#define CAPINC_NR_PORTS 32 #define CAPINC_MAX_PORTS 256 -static int capi_ttymajor = 191; + static int capi_ttyminors = CAPINC_NR_PORTS; -#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ -module_param_named(major, capi_major, uint, 0); -#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE -module_param_named(ttymajor, capi_ttymajor, uint, 0); module_param_named(ttyminors, capi_ttyminors, uint, 0); #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ @@ -83,53 +74,43 @@ module_param_named(ttyminors, capi_ttyminors, uint, 0); struct capidev; struct capincci; -#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE struct capiminor; -struct datahandle_queue { +struct ackqueue_entry { struct list_head list; u16 datahandle; }; struct capiminor { - struct list_head list; - struct capincci *nccip; + struct kref kref; + unsigned int minor; + struct dentry *capifs_dentry; - struct capi20_appl *ap; - u32 ncci; - u16 datahandle; - u16 msgid; + struct capi20_appl *ap; + u32 ncci; + atomic_t datahandle; + atomic_t msgid; - struct tty_struct *tty; + struct tty_port port; int ttyinstop; int ttyoutstop; - struct sk_buff *ttyskb; - atomic_t ttyopencount; - struct sk_buff_head inqueue; - int inbytes; - struct sk_buff_head outqueue; - int outbytes; + struct sk_buff_head inqueue; + + struct sk_buff_head outqueue; + int outbytes; + struct sk_buff *outskb; + spinlock_t outlock; /* transmit path */ struct list_head ackqueue; int nack; spinlock_t ackqlock; }; -#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ - -/* FIXME: The following lock is a sledgehammer-workaround to a - * locking issue with the capiminor (and maybe other) data structure(s). - * Access to this data is done in a racy way and crashes the machine with - * a FritzCard DSL driver; sooner or later. This is a workaround - * which trades scalability vs stability, so it doesn't crash the kernel anymore. - * The correct (and scalable) fix for the issue seems to require - * an API change to the drivers... . */ -static DEFINE_SPINLOCK(workaround_lock); struct capincci { - struct capincci *next; + struct list_head list; u32 ncci; struct capidev *cdev; #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE @@ -146,28 +127,28 @@ struct capidev { struct sk_buff_head recvqueue; wait_queue_head_t recvwait; - struct capincci *nccis; + struct list_head nccis; - struct mutex ncci_list_mtx; + struct mutex lock; }; /* -------- global variables ---------------------------------------- */ -static DEFINE_RWLOCK(capidev_list_lock); +static DEFINE_MUTEX(capidev_list_lock); static LIST_HEAD(capidev_list); #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE -static DEFINE_RWLOCK(capiminor_list_lock); -static LIST_HEAD(capiminor_list); -#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ -#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE +static DEFINE_SPINLOCK(capiminors_lock); +static struct capiminor **capiminors; + +static struct tty_driver *capinc_tty_driver; + /* -------- datahandles --------------------------------------------- */ -static int capincci_add_ack(struct capiminor *mp, u16 datahandle) +static int capiminor_add_ack(struct capiminor *mp, u16 datahandle) { - struct datahandle_queue *n; - unsigned long flags; + struct ackqueue_entry *n; n = kmalloc(sizeof(*n), GFP_ATOMIC); if (unlikely(!n)) { @@ -176,253 +157,246 @@ static int capincci_add_ack(struct capiminor *mp, u16 datahandle) } n->datahandle = datahandle; INIT_LIST_HEAD(&n->list); - spin_lock_irqsave(&mp->ackqlock, flags); + spin_lock_bh(&mp->ackqlock); list_add_tail(&n->list, &mp->ackqueue); mp->nack++; - spin_unlock_irqrestore(&mp->ackqlock, flags); + spin_unlock_bh(&mp->ackqlock); return 0; } static int capiminor_del_ack(struct capiminor *mp, u16 datahandle) { - struct datahandle_queue *p, *tmp; - unsigned long flags; + struct ackqueue_entry *p, *tmp; - spin_lock_irqsave(&mp->ackqlock, flags); + spin_lock_bh(&mp->ackqlock); list_for_each_entry_safe(p, tmp, &mp->ackqueue, list) { if (p->datahandle == datahandle) { list_del(&p->list); - kfree(p); mp->nack--; - spin_unlock_irqrestore(&mp->ackqlock, flags); + spin_unlock_bh(&mp->ackqlock); + kfree(p); return 0; } } - spin_unlock_irqrestore(&mp->ackqlock, flags); + spin_unlock_bh(&mp->ackqlock); return -1; } static void capiminor_del_all_ack(struct capiminor *mp) { - struct datahandle_queue *p, *tmp; - unsigned long flags; + struct ackqueue_entry *p, *tmp; - spin_lock_irqsave(&mp->ackqlock, flags); list_for_each_entry_safe(p, tmp, &mp->ackqueue, list) { list_del(&p->list); kfree(p); mp->nack--; } - spin_unlock_irqrestore(&mp->ackqlock, flags); } /* -------- struct capiminor ---------------------------------------- */ +static const struct tty_port_operations capiminor_port_ops; /* we have none */ + static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci) { - struct capiminor *mp, *p; - unsigned int minor = 0; - unsigned long flags; + struct capiminor *mp; + struct device *dev; + unsigned int minor; - mp = kzalloc(sizeof(*mp), GFP_ATOMIC); + mp = kzalloc(sizeof(*mp), GFP_KERNEL); if (!mp) { printk(KERN_ERR "capi: can't alloc capiminor\n"); return NULL; } + kref_init(&mp->kref); + mp->ap = ap; mp->ncci = ncci; - mp->msgid = 0; - atomic_set(&mp->ttyopencount,0); INIT_LIST_HEAD(&mp->ackqueue); spin_lock_init(&mp->ackqlock); skb_queue_head_init(&mp->inqueue); skb_queue_head_init(&mp->outqueue); + spin_lock_init(&mp->outlock); - /* Allocate the least unused minor number. - */ - write_lock_irqsave(&capiminor_list_lock, flags); - if (list_empty(&capiminor_list)) - list_add(&mp->list, &capiminor_list); - else { - list_for_each_entry(p, &capiminor_list, list) { - if (p->minor > minor) - break; - minor++; - } - - if (minor < capi_ttyminors) { - mp->minor = minor; - list_add(&mp->list, p->list.prev); + tty_port_init(&mp->port); + mp->port.ops = &capiminor_port_ops; + + /* Allocate the least unused minor number. */ + spin_lock(&capiminors_lock); + for (minor = 0; minor < capi_ttyminors; minor++) + if (!capiminors[minor]) { + capiminors[minor] = mp; + break; } - } - write_unlock_irqrestore(&capiminor_list_lock, flags); + spin_unlock(&capiminors_lock); - if (!(minor < capi_ttyminors)) { + if (minor == capi_ttyminors) { printk(KERN_NOTICE "capi: out of minors\n"); - kfree(mp); - return NULL; + goto err_out1; } + mp->minor = minor; + + dev = tty_register_device(capinc_tty_driver, minor, NULL); + if (IS_ERR(dev)) + goto err_out2; + return mp; + +err_out2: + spin_lock(&capiminors_lock); + capiminors[minor] = NULL; + spin_unlock(&capiminors_lock); + +err_out1: + kfree(mp); + return NULL; } -static void capiminor_free(struct capiminor *mp) +static void capiminor_destroy(struct kref *kref) { - unsigned long flags; - - write_lock_irqsave(&capiminor_list_lock, flags); - list_del(&mp->list); - write_unlock_irqrestore(&capiminor_list_lock, flags); + struct capiminor *mp = container_of(kref, struct capiminor, kref); - kfree_skb(mp->ttyskb); - mp->ttyskb = NULL; + kfree_skb(mp->outskb); skb_queue_purge(&mp->inqueue); skb_queue_purge(&mp->outqueue); capiminor_del_all_ack(mp); kfree(mp); } -static struct capiminor *capiminor_find(unsigned int minor) +static struct capiminor *capiminor_get(unsigned int minor) { - struct list_head *l; - struct capiminor *p = NULL; + struct capiminor *mp; - read_lock(&capiminor_list_lock); - list_for_each(l, &capiminor_list) { - p = list_entry(l, struct capiminor, list); - if (p->minor == minor) - break; - } - read_unlock(&capiminor_list_lock); - if (l == &capiminor_list) - return NULL; + spin_lock(&capiminors_lock); + mp = capiminors[minor]; + if (mp) + kref_get(&mp->kref); + spin_unlock(&capiminors_lock); - return p; + return mp; +} + +static inline void capiminor_put(struct capiminor *mp) +{ + kref_put(&mp->kref, capiminor_destroy); +} + +static void capiminor_free(struct capiminor *mp) +{ + tty_unregister_device(capinc_tty_driver, mp->minor); + + spin_lock(&capiminors_lock); + capiminors[mp->minor] = NULL; + spin_unlock(&capiminors_lock); + + capiminor_put(mp); } -#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ /* -------- struct capincci ----------------------------------------- */ -static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci) +static void capincci_alloc_minor(struct capidev *cdev, struct capincci *np) { - struct capincci *np, **pp; -#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE - struct capiminor *mp = NULL; -#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ + struct capiminor *mp; + dev_t device; - np = kzalloc(sizeof(*np), GFP_ATOMIC); - if (!np) - return NULL; - np->ncci = ncci; - np->cdev = cdev; -#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE - mp = NULL; - if (cdev->userflags & CAPIFLAG_HIGHJACKING) - mp = np->minorp = capiminor_alloc(&cdev->ap, ncci); + if (!(cdev->userflags & CAPIFLAG_HIGHJACKING)) + return; + + mp = np->minorp = capiminor_alloc(&cdev->ap, np->ncci); if (mp) { - mp->nccip = np; -#ifdef _DEBUG_REFCOUNT - printk(KERN_DEBUG "set mp->nccip\n"); -#endif -#if defined(CONFIG_ISDN_CAPI_CAPIFS) || defined(CONFIG_ISDN_CAPI_CAPIFS_MODULE) - capifs_new_ncci(mp->minor, MKDEV(capi_ttymajor, mp->minor)); -#endif + device = MKDEV(capinc_tty_driver->major, mp->minor); + mp->capifs_dentry = capifs_new_ncci(mp->minor, device); } -#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ - for (pp=&cdev->nccis; *pp; pp = &(*pp)->next) - ; - *pp = np; - return np; } -static void capincci_free(struct capidev *cdev, u32 ncci) +static void capincci_free_minor(struct capincci *np) { - struct capincci *np, **pp; -#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE - struct capiminor *mp; -#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ + struct capiminor *mp = np->minorp; + struct tty_struct *tty; - pp=&cdev->nccis; - while (*pp) { - np = *pp; - if (ncci == 0xffffffff || np->ncci == ncci) { - *pp = (*pp)->next; -#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE - if ((mp = np->minorp) != NULL) { -#if defined(CONFIG_ISDN_CAPI_CAPIFS) || defined(CONFIG_ISDN_CAPI_CAPIFS_MODULE) - capifs_free_ncci(mp->minor); -#endif - if (mp->tty) { - mp->nccip = NULL; -#ifdef _DEBUG_REFCOUNT - printk(KERN_DEBUG "reset mp->nccip\n"); -#endif - tty_hangup(mp->tty); - } else { - capiminor_free(mp); - } - } -#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ - kfree(np); - if (*pp == NULL) return; - } else { - pp = &(*pp)->next; + if (mp) { + capifs_free_ncci(mp->capifs_dentry); + + tty = tty_port_tty_get(&mp->port); + if (tty) { + tty_vhangup(tty); + tty_kref_put(tty); } + + capiminor_free(mp); } } -static struct capincci *capincci_find(struct capidev *cdev, u32 ncci) +static inline unsigned int capincci_minor_opencount(struct capincci *np) { - struct capincci *p; + struct capiminor *mp = np->minorp; + unsigned int count = 0; + struct tty_struct *tty; - for (p=cdev->nccis; p ; p = p->next) { - if (p->ncci == ncci) - break; + if (mp) { + tty = tty_port_tty_get(&mp->port); + if (tty) { + count = tty->count; + tty_kref_put(tty); + } } - return p; + return count; } -/* -------- struct capidev ------------------------------------------ */ +#else /* !CONFIG_ISDN_CAPI_MIDDLEWARE */ + +static inline void +capincci_alloc_minor(struct capidev *cdev, struct capincci *np) { } +static inline void capincci_free_minor(struct capincci *np) { } -static struct capidev *capidev_alloc(void) +static inline unsigned int capincci_minor_opencount(struct capincci *np) { - struct capidev *cdev; - unsigned long flags; + return 0; +} - cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); - if (!cdev) +#endif /* !CONFIG_ISDN_CAPI_MIDDLEWARE */ + +static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci) +{ + struct capincci *np; + + np = kzalloc(sizeof(*np), GFP_KERNEL); + if (!np) return NULL; + np->ncci = ncci; + np->cdev = cdev; - mutex_init(&cdev->ncci_list_mtx); - skb_queue_head_init(&cdev->recvqueue); - init_waitqueue_head(&cdev->recvwait); - write_lock_irqsave(&capidev_list_lock, flags); - list_add_tail(&cdev->list, &capidev_list); - write_unlock_irqrestore(&capidev_list_lock, flags); - return cdev; + capincci_alloc_minor(cdev, np); + + list_add_tail(&np->list, &cdev->nccis); + + return np; } -static void capidev_free(struct capidev *cdev) +static void capincci_free(struct capidev *cdev, u32 ncci) { - unsigned long flags; + struct capincci *np, *tmp; |