From bb457b472ce9a088f36d2130a6e8ef19088f10d1 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Sat, 19 Oct 2002 03:07:53 -0500 Subject: ISDN/PPP: Separate out and rewrite MPPP code The MPPP code was badly broken by the previous interface changes for ISDN network interfaces and sync-PPP, and in need of a serious cleanup. Now it's basically mostly rewritten, in a separate file but only lightly tested. --- include/linux/isdn.h | 17 ++++++++++++++--- include/linux/isdn_ppp.h | 16 ---------------- 2 files changed, 14 insertions(+), 19 deletions(-) (limited to 'include/linux') diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 0d0ce25b333e..362161a2ef76 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -312,6 +312,13 @@ struct isdn_netif_ops { void (*close)(struct isdn_net_local_s *); }; +typedef struct { + unsigned long seqerrs; + unsigned long frame_drops; + unsigned long overflows; + unsigned long max_queue_len; +} isdn_mppp_stats; + /* Local interface-data */ typedef struct isdn_net_local_s { ulong magic; @@ -357,8 +364,12 @@ typedef struct isdn_net_local_s { struct concap_device_ops *dops; /* callbacks used by encapsulator */ #endif #ifdef CONFIG_ISDN_PPP - unsigned int mpppcfg; - long mp_seqno; + unsigned int mp_cfg; + u32 mp_txseq; + struct sk_buff_head mp_frags; /* fragments sl list */ + u32 mp_rxseq; /* last processed packet seq #: any + packets with smaller seq # will + be dropped unconditionally */ struct ippp_ccp *ccp; unsigned long debug; #ifdef CONFIG_ISDN_PPP_VJ @@ -427,7 +438,7 @@ typedef struct isdn_net_dev_s { struct list_head global_list; /* global list of all isdn_net_devs */ #ifdef CONFIG_ISDN_PPP unsigned int pppcfg; - unsigned int pppseq; /* last seq no seen */ + u32 mp_rxseq; /* last seq no seen on this channel */ struct ippp_ccp *ccp; unsigned long debug; diff --git a/include/linux/isdn_ppp.h b/include/linux/isdn_ppp.h index ec6016c37421..b53107c1b1b4 100644 --- a/include/linux/isdn_ppp.h +++ b/include/linux/isdn_ppp.h @@ -130,24 +130,8 @@ struct isdn_ppp_compressor { extern int isdn_ppp_register_compressor(struct isdn_ppp_compressor *); extern int isdn_ppp_unregister_compressor(struct isdn_ppp_compressor *); -typedef struct { - unsigned long seqerrs; - unsigned long frame_drops; - unsigned long overflows; - unsigned long max_queue_len; -} isdn_mppp_stats; - typedef struct { int mp_mrru; /* unused */ - struct sk_buff * frags; /* fragments sl list -- use skb->next */ - long frames; /* number of frames in the frame list */ - unsigned int seq; /* last processed packet seq #: any packets - * with smaller seq # will be dropped - * unconditionally */ - spinlock_t lock; - int ref_ct; - /* statistics */ - isdn_mppp_stats stats; } ippp_bundle; #define IPPP_MAX_RQ_LEN 8 -- cgit v1.2.3 From a274edfa7cb2c82b8cda34b2525792ade7a8fa00 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:17:03 -0600 Subject: ISDN: header cosmetics Updating copyright lines, deleting the CVS $Id lines, move PPP CCP reset related declarations into drivers/isdn/i4l/isdn_ppp_ccp.c. --- drivers/isdn/i4l/isdn_audio.c | 10 +-- drivers/isdn/i4l/isdn_audio.h | 4 +- drivers/isdn/i4l/isdn_ciscohdlck.c | 3 +- drivers/isdn/i4l/isdn_ciscohdlck.h | 3 +- drivers/isdn/i4l/isdn_common.c | 5 +- drivers/isdn/i4l/isdn_common.h | 5 +- drivers/isdn/i4l/isdn_concap.c | 6 +- drivers/isdn/i4l/isdn_concap.h | 5 +- drivers/isdn/i4l/isdn_fsm.c | 9 +-- drivers/isdn/i4l/isdn_fsm.h | 9 +-- drivers/isdn/i4l/isdn_net.c | 8 +-- drivers/isdn/i4l/isdn_net.h | 12 ++-- drivers/isdn/i4l/isdn_net_lib.c | 3 +- drivers/isdn/i4l/isdn_ppp.c | 12 ++-- drivers/isdn/i4l/isdn_ppp.h | 6 +- drivers/isdn/i4l/isdn_ppp_ccp.c | 40 +++++++++++ drivers/isdn/i4l/isdn_ppp_ccp.h | 10 +++ drivers/isdn/i4l/isdn_ppp_mp.c | 19 +++++ drivers/isdn/i4l/isdn_ppp_mp.h | 11 ++- drivers/isdn/i4l/isdn_ppp_vj.c | 12 ++-- drivers/isdn/i4l/isdn_ppp_vj.h | 8 +++ drivers/isdn/i4l/isdn_tty.c | 6 +- drivers/isdn/i4l/isdn_tty.h | 5 +- drivers/isdn/i4l/isdn_ttyfax.c | 5 +- drivers/isdn/i4l/isdn_ttyfax.h | 5 +- drivers/isdn/i4l/isdn_v110.c | 5 +- drivers/isdn/i4l/isdn_v110.h | 5 +- drivers/isdn/i4l/isdn_x25iface.c | 9 ++- drivers/isdn/i4l/isdn_x25iface.h | 11 ++- include/linux/isdn.h | 8 +-- include/linux/isdn_ppp.h | 141 ++++++++++++++----------------------- 31 files changed, 201 insertions(+), 199 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_audio.c b/drivers/isdn/i4l/isdn_audio.c index bdd92d81d13d..3b2e0fc4d112 100644 --- a/drivers/isdn/i4l/isdn_audio.c +++ b/drivers/isdn/i4l/isdn_audio.c @@ -1,14 +1,14 @@ -/* $Id: isdn_audio.c,v 1.21.6.3 2002/08/13 09:45:33 keil Exp $ - * - * Linux ISDN subsystem, audio conversion and compression (linklevel). +/* Linux ISDN subsystem, audio conversion and compression * * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de) - * DTMF code (c) 1996 by Christian Mock (cm@tahina.priv.at) - * Silence detection (c) 1998 by Armin Schindler (mac@gismo.telekom.de) + * 1996 by Christian Mock (cm@tahina.priv.at) + * 1998 by Armin Schindler (mac@gismo.telekom.de) * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * + * DTMF code by Christian Mock + * Silence detection by Armin Schindler */ #include diff --git a/drivers/isdn/i4l/isdn_audio.h b/drivers/isdn/i4l/isdn_audio.h index e60c980c953a..e08d7d2a0700 100644 --- a/drivers/isdn/i4l/isdn_audio.h +++ b/drivers/isdn/i4l/isdn_audio.h @@ -1,6 +1,4 @@ -/* $Id: isdn_audio.h,v 1.9.6.1 2001/09/23 22:24:31 kai Exp $ - * - * Linux ISDN subsystem, audio conversion and compression (linklevel). +/* Linux ISDN subsystem, audio conversion and compression * * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de) * diff --git a/drivers/isdn/i4l/isdn_ciscohdlck.c b/drivers/isdn/i4l/isdn_ciscohdlck.c index cab5b1a2100f..c6c321fbe72b 100644 --- a/drivers/isdn/i4l/isdn_ciscohdlck.c +++ b/drivers/isdn/i4l/isdn_ciscohdlck.c @@ -1,5 +1,4 @@ -/* - * Linux ISDN subsystem, CISCO HDLC network interfaces +/* Linux ISDN subsystem, CISCO HDLC network interfaces * * Copyright 1994-1998 by Fritz Elfert (fritz@isdn4linux.de) * 1995,96 by Thinking Objects Software GmbH Wuerzburg diff --git a/drivers/isdn/i4l/isdn_ciscohdlck.h b/drivers/isdn/i4l/isdn_ciscohdlck.h index 24cd87d2f674..8eecdcb697b4 100644 --- a/drivers/isdn/i4l/isdn_ciscohdlck.h +++ b/drivers/isdn/i4l/isdn_ciscohdlck.h @@ -1,5 +1,4 @@ -/* - * Linux ISDN subsystem, CISCO HDLC network interfaces +/* Linux ISDN subsystem, CISCO HDLC network interfaces * * Copyright 1999-2002 by Kai Germaschewski * 2001 by Bjoern A. Zeeb diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 37a7968aabb7..0d02b6226317 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -1,6 +1,4 @@ -/* $Id: isdn_common.c,v 1.114.6.16 2001/11/06 20:58:28 kai Exp $ - * - * Linux ISDN subsystem, common used functions (linklevel). +/* Linux ISDN subsystem, common used functions * * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de) * Copyright 1995,96 Thinking Objects Software GmbH Wuerzburg @@ -8,7 +6,6 @@ * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * */ #include diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h index 64e1c1e9c819..e059ead2cc0c 100644 --- a/drivers/isdn/i4l/isdn_common.h +++ b/drivers/isdn/i4l/isdn_common.h @@ -1,7 +1,4 @@ -/* $Id: isdn_common.h,v 1.21.6.1 2001/09/23 22:24:31 kai Exp $ - * - * header for Linux ISDN subsystem - * common used functions and debugging-switches (linklevel). +/* Linux ISDN subsystem, common used functions and debugging-switches * * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de) * Copyright 1995,96 by Thinking Objects Software GmbH Wuerzburg diff --git a/drivers/isdn/i4l/isdn_concap.c b/drivers/isdn/i4l/isdn_concap.c index 935358fe2bb2..31e761e6c11c 100644 --- a/drivers/isdn/i4l/isdn_concap.c +++ b/drivers/isdn/i4l/isdn_concap.c @@ -1,16 +1,12 @@ -/* $Id: isdn_concap.c,v 1.8.6.1 2001/09/23 22:24:31 kai Exp $ - * - * Linux ISDN subsystem, protocol encapsulation +/* Linux ISDN subsystem, protocol encapsulation * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * */ /* Stuff to support the concap_proto by isdn4linux. isdn4linux - specific * stuff goes here. Stuff that depends only on the concap protocol goes to * another -- protocol specific -- source file. - * */ diff --git a/drivers/isdn/i4l/isdn_concap.h b/drivers/isdn/i4l/isdn_concap.h index 8150d6f595e0..49ee3cb27101 100644 --- a/drivers/isdn/i4l/isdn_concap.h +++ b/drivers/isdn/i4l/isdn_concap.h @@ -1,10 +1,7 @@ -/* $Id: isdn_concap.h,v 1.3.6.1 2001/09/23 22:24:31 kai Exp $ - * - * Linux ISDN subsystem, protocol encapsulation +/* Linux ISDN subsystem, protocol encapsulation * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * */ extern struct concap_device_ops isdn_concap_reliable_dl_dops; diff --git a/drivers/isdn/i4l/isdn_fsm.c b/drivers/isdn/i4l/isdn_fsm.c index 52de59763fe8..5e453f1edd62 100644 --- a/drivers/isdn/i4l/isdn_fsm.c +++ b/drivers/isdn/i4l/isdn_fsm.c @@ -1,17 +1,14 @@ -/* $Id: fsm.c,v 1.14.6.4 2001/09/23 22:24:47 kai Exp $ - * - * Finite state machine +/* Linux ISDN subsystem, finite state machine * * Author Karsten Keil - * Copyright by Karsten Keil - * by Kai Germaschewski + * Copyright by Karsten Keil + * 2001-2002 by Kai Germaschewski * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * * Thanks to Jan den Ouden * Fritz Elfert - * */ #include diff --git a/drivers/isdn/i4l/isdn_fsm.h b/drivers/isdn/i4l/isdn_fsm.h index 4a48a401da45..95beb142b392 100644 --- a/drivers/isdn/i4l/isdn_fsm.h +++ b/drivers/isdn/i4l/isdn_fsm.h @@ -1,14 +1,11 @@ -/* $Id: fsm.h,v 1.3.2.2 2001/09/23 22:24:47 kai Exp $ - * - * Finite state machine +/* Linux ISDN subsystem, finite state machine * * Author Karsten Keil - * Copyright by Karsten Keil - * by Kai Germaschewski + * Copyright by Karsten Keil + * 2001-2002 by Kai Germaschewski * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * */ #ifndef __ISDN_FSM_H__ diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c index 26668600867c..c41f6e0ef850 100644 --- a/drivers/isdn/i4l/isdn_net.c +++ b/drivers/isdn/i4l/isdn_net.c @@ -1,6 +1,4 @@ -/* $Id: isdn_net.c,v 1.140.6.11 2001/11/06 20:58:28 kai Exp $ - * - * Linux ISDN subsystem, network interfaces and related functions (linklevel). +/* Linux ISDN subsystem, network interfaces and related functions (linklevel). * * Copyright 1994-1998 by Fritz Elfert (fritz@isdn4linux.de) * 1995,96 by Thinking Objects Software GmbH Wuerzburg @@ -9,7 +7,9 @@ * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * + */ + +/* * Data Over Voice (DOV) support added - Guy Ellis 23-Mar-02 * guy@traverse.com.au * Outgoing calls - looks for a 'V' in first char of dialed number diff --git a/drivers/isdn/i4l/isdn_net.h b/drivers/isdn/i4l/isdn_net.h index 01ad56c3e926..1f4933dd0f7a 100644 --- a/drivers/isdn/i4l/isdn_net.h +++ b/drivers/isdn/i4l/isdn_net.h @@ -1,14 +1,12 @@ -/* $Id: isdn_net.h,v 1.19.6.4 2001/09/28 08:05:29 kai Exp $ - * - * header for Linux ISDN subsystem, network related functions (linklevel). +/* Linux ISDN subsystem, network related functions * * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de) - * Copyright 1995,96 by Thinking Objects Software GmbH Wuerzburg - * Copyright 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de) + * 1995,96 by Thinking Objects Software GmbH Wuerzburg + * 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de) + * 1999-2002 by Kai Germaschewski * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * */ #include @@ -39,6 +37,8 @@ int isdn_net_autodial(struct sk_buff *skb, struct net_device *ndev); isdn_net_dev *isdn_net_get_xmit_dev(isdn_net_local *mlp); void isdn_netif_rx(isdn_net_dev *idev, struct sk_buff *skb, u16 protocol); +/* ====================================================================== */ + static inline int put_u8(unsigned char *p, u8 x) { diff --git a/drivers/isdn/i4l/isdn_net_lib.c b/drivers/isdn/i4l/isdn_net_lib.c index dd311872747c..2684ba648e72 100644 --- a/drivers/isdn/i4l/isdn_net_lib.c +++ b/drivers/isdn/i4l/isdn_net_lib.c @@ -1,5 +1,4 @@ -/* - * Linux ISDN subsystem, Network interface configuration +/* Linux ISDN subsystem, Network interface configuration * * Copyright 1994-1998 by Fritz Elfert (fritz@isdn4linux.de) * 1995,96 by Thinking Objects Software GmbH Wuerzburg diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c index b50fd57a1707..4d2b0a137dc9 100644 --- a/drivers/isdn/i4l/isdn_ppp.c +++ b/drivers/isdn/i4l/isdn_ppp.c @@ -1,12 +1,10 @@ -/* $Id: isdn_ppp.c,v 1.85.6.9 2001/11/06 20:58:28 kai Exp $ +/* Linux ISDN subsystem, functions for synchronous PPP (linklevel). * - * Linux ISDN subsystem, functions for synchronous PPP (linklevel). - * - * Copyright 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de) + * Copyright 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de) + * 1999-2002 by Kai Germaschewski * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * */ #include @@ -23,6 +21,10 @@ #include "isdn_ppp_mp.h" #include "isdn_net.h" +/* ====================================================================== */ + +#define IPPP_MAX_RQ_LEN 8 /* max #frames queued for ipppd to read */ + static int isdn_ppp_set_compressor(isdn_net_dev *idev, struct isdn_ppp_comp_data *); diff --git a/drivers/isdn/i4l/isdn_ppp.h b/drivers/isdn/i4l/isdn_ppp.h index 136077ec8bba..fc74cada051a 100644 --- a/drivers/isdn/i4l/isdn_ppp.h +++ b/drivers/isdn/i4l/isdn_ppp.h @@ -1,12 +1,10 @@ -/* $Id: isdn_ppp.h,v 1.17.6.1 2001/09/23 22:24:32 kai Exp $ - * - * header for Linux ISDN subsystem, functions for synchronous PPP (linklevel). +/* Linux ISDN subsystem, functions for synchronous PPP (linklevel). * * Copyright 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de) + * 1999-2002 by Kai Germaschewski * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * */ #include /* for PPP_PROTOCOL */ diff --git a/drivers/isdn/i4l/isdn_ppp_ccp.c b/drivers/isdn/i4l/isdn_ppp_ccp.c index f62cf38f831f..3e4e24379aba 100644 --- a/drivers/isdn/i4l/isdn_ppp_ccp.c +++ b/drivers/isdn/i4l/isdn_ppp_ccp.c @@ -1,3 +1,13 @@ +/* Linux ISDN subsystem, PPP CCP support + * + * Copyright 1994-1998 by Fritz Elfert (fritz@isdn4linux.de) + * 1995,96 by Thinking Objects Software GmbH Wuerzburg + * 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de) + * 1999-2002 by Kai Germaschewski + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + */ #include "isdn_ppp_ccp.h" #include "isdn_common.h" @@ -5,6 +15,36 @@ #include "isdn_ppp.h" #include +/* ====================================================================== */ +enum ippp_ccp_reset_states { + CCPResetIdle, + CCPResetSentReq, + CCPResetRcvdReq, + CCPResetSentAck, + CCPResetRcvdAck +}; + +struct ippp_ccp_reset_state { + enum ippp_ccp_reset_states state;/* State of this transaction */ + struct ippp_ccp *ccp; /* Backlink */ + unsigned char id; /* id index */ + unsigned char ta:1; /* The timer is active (flag) */ + unsigned char expra:1; /* We expect a ResetAck at all */ + int dlen; /* Databytes stored in data */ + struct timer_list timer; /* For timeouts/retries */ + /* This is a hack but seems sufficient for the moment. We do not want + to have this be yet another allocation for some bytes, it is more + memory management overhead than the whole mess is worth. */ + unsigned char data[IPPP_RESET_MAXDATABYTES]; +}; + +/* The data structure keeping track of the currently outstanding CCP Reset + transactions. */ +struct ippp_ccp_reset { + struct ippp_ccp_reset_state *rs[256]; /* One per possible id */ + unsigned char lastid; /* Last id allocated */ +}; + /* In-kernel handling of CCP Reset-Request and Reset-Ack is necessary, but absolutely nontrivial. The most abstruse problem we are facing is that the generation, reception and all the handling of timeouts and diff --git a/drivers/isdn/i4l/isdn_ppp_ccp.h b/drivers/isdn/i4l/isdn_ppp_ccp.h index 35d7e75dc343..6d3ec7c9f8de 100644 --- a/drivers/isdn/i4l/isdn_ppp_ccp.h +++ b/drivers/isdn/i4l/isdn_ppp_ccp.h @@ -1,3 +1,13 @@ +/* Linux ISDN subsystem, PPP CCP support + * + * Copyright 1994-1998 by Fritz Elfert (fritz@isdn4linux.de) + * 1995,96 by Thinking Objects Software GmbH Wuerzburg + * 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de) + * 1999-2002 by Kai Germaschewski + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + */ #include #include diff --git a/drivers/isdn/i4l/isdn_ppp_mp.c b/drivers/isdn/i4l/isdn_ppp_mp.c index 06545577de7b..3f2345f9197d 100644 --- a/drivers/isdn/i4l/isdn_ppp_mp.c +++ b/drivers/isdn/i4l/isdn_ppp_mp.c @@ -1,3 +1,13 @@ +/* Linux ISDN subsystem, PPP CCP support + * + * Copyright 1994-1998 by Fritz Elfert (fritz@isdn4linux.de) + * 1995,96 by Thinking Objects Software GmbH Wuerzburg + * 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de) + * 1999-2002 by Kai Germaschewski + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + */ #include "isdn_ppp_mp.h" #include "isdn_ppp_ccp.h" @@ -5,6 +15,15 @@ #include "isdn_net.h" #include "isdn_ppp.h" +/* ====================================================================== */ + +#define MP_END_FRAG 0x40 +#define MP_BEGIN_FRAG 0x80 + +#define MP_MAX_QUEUE_LEN 16 + +/* ====================================================================== */ + int ippp_mp_bind(isdn_net_dev *idev) { diff --git a/drivers/isdn/i4l/isdn_ppp_mp.h b/drivers/isdn/i4l/isdn_ppp_mp.h index 3ae3c9c59354..4eacffc728ef 100644 --- a/drivers/isdn/i4l/isdn_ppp_mp.h +++ b/drivers/isdn/i4l/isdn_ppp_mp.h @@ -1,3 +1,13 @@ +/* Linux ISDN subsystem, PPP CCP support + * + * Copyright 1994-1998 by Fritz Elfert (fritz@isdn4linux.de) + * 1995,96 by Thinking Objects Software GmbH Wuerzburg + * 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de) + * 1999-2002 by Kai Germaschewski + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + */ #ifndef __ISDN_PPP_MP_H__ #define __ISDN_PPP_MP_H__ @@ -5,7 +15,6 @@ #include #include - #ifdef CONFIG_ISDN_MPP int ippp_mp_bind(isdn_net_dev *idev); diff --git a/drivers/isdn/i4l/isdn_ppp_vj.c b/drivers/isdn/i4l/isdn_ppp_vj.c index 4e2bb3af7c51..ef97182b5800 100644 --- a/drivers/isdn/i4l/isdn_ppp_vj.c +++ b/drivers/isdn/i4l/isdn_ppp_vj.c @@ -1,13 +1,17 @@ +/* Linux ISDN subsystem, PPP VJ header compression + * + * Copyright 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de) + * 1999-2002 by Kai Germaschewski + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + */ #include "isdn_ppp_vj.h" #include "isdn_common.h" #include "isdn_net.h" #include "isdn_ppp.h" -/* ====================================================================== */ -/* VJ header compression */ -/* ====================================================================== */ - struct slcompress * ippp_vj_alloc(void) { diff --git a/drivers/isdn/i4l/isdn_ppp_vj.h b/drivers/isdn/i4l/isdn_ppp_vj.h index 7197a1f363fe..1af3ca9049e2 100644 --- a/drivers/isdn/i4l/isdn_ppp_vj.h +++ b/drivers/isdn/i4l/isdn_ppp_vj.h @@ -1,3 +1,11 @@ +/* Linux ISDN subsystem, PPP VJ header compression + * + * Copyright 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de) + * 1999-2002 by Kai Germaschewski + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + */ #ifndef __ISDN_PPP_VJ_H__ #define __ISDN_PPP_VJ_H__ diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index c7b3f8ce4c71..eb79e21a5aeb 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -1,14 +1,12 @@ -/* $Id: isdn_tty.c,v 1.94.6.9 2001/11/06 20:58:29 kai Exp $ - * - * Linux ISDN subsystem, tty functions and AT-command emulator (linklevel). +/* Linux ISDN subsystem, tty functions and AT-command emulator * * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de) * Copyright 1995,96 by Thinking Objects Software GmbH Wuerzburg * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * */ + #undef ISDN_TTY_STAT_DEBUG #include diff --git a/drivers/isdn/i4l/isdn_tty.h b/drivers/isdn/i4l/isdn_tty.h index 8cad26a3714a..9863a7577f16 100644 --- a/drivers/isdn/i4l/isdn_tty.h +++ b/drivers/isdn/i4l/isdn_tty.h @@ -1,13 +1,10 @@ -/* $Id: isdn_tty.h,v 1.22.6.2 2001/09/23 22:24:32 kai Exp $ - * - * header for Linux ISDN subsystem, tty related functions (linklevel). +/* Linux ISDN subsystem, tty related functions * * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de) * Copyright 1995,96 by Thinking Objects Software GmbH Wuerzburg * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * */ #include diff --git a/drivers/isdn/i4l/isdn_ttyfax.c b/drivers/isdn/i4l/isdn_ttyfax.c index 2f7a5a0f2b48..14f7122d098a 100644 --- a/drivers/isdn/i4l/isdn_ttyfax.c +++ b/drivers/isdn/i4l/isdn_ttyfax.c @@ -1,6 +1,4 @@ -/* $Id: isdn_ttyfax.c,v 1.7.6.2 2001/09/23 22:24:32 kai Exp $ - * - * Linux ISDN subsystem, tty_fax AT-command emulator (linklevel). +/* Linux ISDN subsystem, tty_fax AT-command emulator * * Copyright 1999 by Armin Schindler (mac@melware.de) * Copyright 1999 by Ralf Spachmann (mel@melware.de) @@ -8,7 +6,6 @@ * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * */ #undef ISDN_TTY_FAX_STAT_DEBUG diff --git a/drivers/isdn/i4l/isdn_ttyfax.h b/drivers/isdn/i4l/isdn_ttyfax.h index 244ada3ca127..3567899e4e88 100644 --- a/drivers/isdn/i4l/isdn_ttyfax.h +++ b/drivers/isdn/i4l/isdn_ttyfax.h @@ -1,6 +1,4 @@ -/* $Id: isdn_ttyfax.h,v 1.2.6.1 2001/09/23 22:24:32 kai Exp $ - * - * header for Linux ISDN subsystem, tty_fax related functions (linklevel). +/* Linux ISDN subsystem, tty_fax related functions * * Copyright 1999 by Armin Schindler (mac@melware.de) * Copyright 1999 by Ralf Spachmann (mel@melware.de) @@ -8,7 +6,6 @@ * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * */ diff --git a/drivers/isdn/i4l/isdn_v110.c b/drivers/isdn/i4l/isdn_v110.c index 1676de4975cc..421764a27289 100644 --- a/drivers/isdn/i4l/isdn_v110.c +++ b/drivers/isdn/i4l/isdn_v110.c @@ -1,12 +1,9 @@ -/* $Id: isdn_v110.c,v 1.5.6.4 2001/09/23 22:24:32 kai Exp $ - * - * Linux ISDN subsystem, V.110 related functions (linklevel). +/* Linux ISDN subsystem, V.110 * * Copyright by Thomas Pfeiffer (pfeiffer@pds.de) * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * */ #include diff --git a/drivers/isdn/i4l/isdn_v110.h b/drivers/isdn/i4l/isdn_v110.h index b6563c259e44..ba0bf9d38286 100644 --- a/drivers/isdn/i4l/isdn_v110.h +++ b/drivers/isdn/i4l/isdn_v110.h @@ -1,12 +1,9 @@ -/* $Id: isdn_v110.h,v 1.4.6.1 2001/09/23 22:24:32 kai Exp $ - * - * Linux ISDN subsystem, V.110 related functions (linklevel). +/* Linux ISDN subsystem, V.110 related functions * * Copyright by Thomas Pfeiffer (pfeiffer@pds.de) * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * */ #ifndef ISDN_V110_H diff --git a/drivers/isdn/i4l/isdn_x25iface.c b/drivers/isdn/i4l/isdn_x25iface.c index edbf4eed016d..d394b4a39bd4 100644 --- a/drivers/isdn/i4l/isdn_x25iface.c +++ b/drivers/isdn/i4l/isdn_x25iface.c @@ -1,10 +1,10 @@ -/* $Id: isdn_x25iface.c,v 1.9.6.1 2001/09/23 22:24:32 kai Exp $ - * - * Linux ISDN subsystem, X.25 related functions +/* * Linux ISDN subsystem, X.25 related functions * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * + */ + +/* * stuff needed to support the Linux X.25 PLP code on top of devices that * can provide a lab_b service using the concap_proto mechanism. * This module supports a network interface wich provides lapb_sematics @@ -17,7 +17,6 @@ * */ -/* #include */ #include #include #include diff --git a/drivers/isdn/i4l/isdn_x25iface.h b/drivers/isdn/i4l/isdn_x25iface.h index ef69d3af9628..12fc46c471af 100644 --- a/drivers/isdn/i4l/isdn_x25iface.h +++ b/drivers/isdn/i4l/isdn_x25iface.h @@ -1,17 +1,16 @@ -/* $Id: isdn_x25iface.h,v 1.3.6.1 2001/09/23 22:24:32 kai Exp $ - * - * header for Linux ISDN subsystem, x.25 related functions +/* Linux ISDN subsystem, x.25 related functions * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. - * */ #ifndef _LINUX_ISDN_X25IFACE_H #define _LINUX_ISDN_X25IFACE_H #define ISDN_X25IFACE_MAGIC 0x1e75a2b9 -/* #define DEBUG_ISDN_X25 if you want isdn_x25 debugging messages */ + +#undef DEBUG_ISDN_X25 + #ifdef DEBUG_ISDN_X25 # define IX25DEBUG(fmt,args...) printk(KERN_DEBUG fmt , ## args) #else @@ -26,8 +25,6 @@ extern struct concap_proto_ops * isdn_x25iface_concap_proto_ops_pt; extern struct concap_proto * isdn_x25iface_proto_new(void); - - #endif diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 362161a2ef76..42baf99a835a 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -1,10 +1,9 @@ -/* $Id: isdn.h,v 1.111.6.9 2001/09/23 22:25:05 kai Exp $ - * - * Main header for the Linux ISDN subsystem (linklevel). +/* Linux ISDN subsystem, main header * * Copyright 1994,95,96 by Fritz Elfert (fritz@isdn4linux.de) * Copyright 1995,96 by Thinking Objects Software GmbH Wuerzburg * Copyright 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de) + * Copyright 2000-2002 by Kai Germaschewski (kai@germaschewski.name) * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. @@ -441,9 +440,6 @@ typedef struct isdn_net_dev_s { u32 mp_rxseq; /* last seq no seen on this channel */ struct ippp_ccp *ccp; unsigned long debug; - - ippp_bundle * pb; /* pointer to the common bundle structure - * with the per-bundle data */ #endif #ifdef CONFIG_ISDN_X25 struct concap_proto *cprot; /* connection oriented encapsulation protocol */ diff --git a/include/linux/isdn_ppp.h b/include/linux/isdn_ppp.h index b53107c1b1b4..669822e2868a 100644 --- a/include/linux/isdn_ppp.h +++ b/include/linux/isdn_ppp.h @@ -1,10 +1,15 @@ -/* +/* Linux ISDN subsystem, sync PPP, interface to ipppd + * + * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de) + * Copyright 1995,96 Thinking Objects Software GmbH Wuerzburg + * Copyright 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de) + * Copyright 2000-2002 by Kai Germaschewski (kai@germaschewski.name) + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */ - #ifndef _LINUX_ISDN_PPP_H #define _LINUX_ISDN_PPP_H @@ -16,22 +21,21 @@ struct pppcallinfo { - int calltype; - unsigned char local_num[64]; - unsigned char remote_num[64]; - int charge_units; + int calltype; + unsigned char local_num[64]; + unsigned char remote_num[64]; + int charge_units; }; -#define PPPIOCGCALLINFO _IOWR('t',128,struct pppcallinfo) -#define PPPIOCBUNDLE _IOW('t',129,int) -#define PPPIOCGMPFLAGS _IOR('t',130,int) -#define PPPIOCSMPFLAGS _IOW('t',131,int) -#define PPPIOCSMPMTU _IOW('t',132,int) -#define PPPIOCSMPMRU _IOW('t',133,int) -#define PPPIOCGCOMPRESSORS _IOR('t',134,unsigned long [8]) -#define PPPIOCSCOMPRESSOR _IOW('t',135,int) -#define PPPIOCGIFNAME _IOR('t',136, char [IFNAMSIZ] ) - +#define PPPIOCGCALLINFO _IOWR('t',128,struct pppcallinfo) +#define PPPIOCBUNDLE _IOW('t',129,int) +#define PPPIOCGMPFLAGS _IOR('t',130,int) +#define PPPIOCSMPFLAGS _IOW('t',131,int) +#define PPPIOCSMPMTU _IOW('t',132,int) +#define PPPIOCSMPMRU _IOW('t',133,int) +#define PPPIOCGCOMPRESSORS _IOR('t',134,unsigned long[8]) +#define PPPIOCSCOMPRESSOR _IOW('t',135,int) +#define PPPIOCGIFNAME _IOR('t',136,char[IFNAMSIZ]) #define SC_MP_PROT 0x00000200 #define SC_REJ_MP_PROT 0x00000400 @@ -44,26 +48,19 @@ struct pppcallinfo #define IPPP_COMP_FLAG_LINK 0x2 struct isdn_ppp_comp_data { - int num; - unsigned char options[ISDN_PPP_COMP_MAX_OPTIONS]; - int optlen; - int flags; + int num; + unsigned char options[ISDN_PPP_COMP_MAX_OPTIONS]; + int optlen; + int flags; }; #ifdef __KERNEL__ - -#include #include #include #define DECOMP_ERR_NOMEM (-10) -#define MP_END_FRAG 0x40 -#define MP_BEGIN_FRAG 0x80 - -#define MP_MAX_QUEUE_LEN 16 - /* * We need a way for the decompressor to influence the generation of CCP * Reset-Requests in a variety of ways. The decompressor is already returning @@ -82,15 +79,15 @@ struct isdn_ppp_comp_data { #define IPPP_RESET_MAXDATABYTES 32 struct isdn_ppp_resetparams { - unsigned char valid:1; /* rw Is this structure filled at all ? */ - unsigned char rsend:1; /* rw Should we send one at all ? */ - unsigned char idval:1; /* rw Is the id field valid ? */ - unsigned char dtval:1; /* rw Is the data field valid ? */ - unsigned char expra:1; /* rw Is an Ack expected for this Req ? */ - unsigned char id; /* wo Send CCP ResetReq with this id */ - unsigned short maxdlen; /* ro Max bytes to be stored in data field */ - unsigned short dlen; /* rw Bytes stored in data field */ - unsigned char *data; /* wo Data for ResetReq info field */ + unsigned char valid:1; /* rw Is this structure filled at all ? */ + unsigned char rsend:1; /* rw Should we send one at all ? */ + unsigned char idval:1; /* rw Is the id field valid ? */ + unsigned char dtval:1; /* rw Is the data field valid ? */ + unsigned char expra:1; /* rw Is an Ack expected for this Req ? */ + unsigned char id; /* wo Send CCP ResetReq with this id */ + unsigned short maxdlen; /* ro Max bytes to be stored in data field */ + unsigned short dlen; /* rw Bytes stored in data field */ + unsigned char *data; /* wo Data for ResetReq info field */ }; /* @@ -98,73 +95,37 @@ struct isdn_ppp_resetparams { * check the original include for more information */ struct isdn_ppp_compressor { - struct isdn_ppp_compressor *next, *prev; - int num; /* CCP compression protocol number */ + struct isdn_ppp_compressor *next, *prev; + int num; /* CCP compression protocol number */ - void *(*alloc) (struct isdn_ppp_comp_data *); - void (*free) (void *state); - int (*init) (void *state, struct isdn_ppp_comp_data *, - int unit,int debug); + void *(*alloc) (struct isdn_ppp_comp_data *); + void (*free) (void *state); + int (*init) (void *state, struct isdn_ppp_comp_data *, + int unit,int debug); - /* The reset entry needs to get more exact information about the - ResetReq or ResetAck it was called with. The parameters are - obvious. If reset is called without a Req or Ack frame which - could be handed into it, code MUST be set to 0. Using rsparm, - the reset entry can control if and how a ResetAck is returned. */ + /* The reset entry needs to get more exact information about the + ResetReq or ResetAck it was called with. The parameters are + obvious. If reset is called without a Req or Ack frame which + could be handed into it, code MUST be set to 0. Using rsparm, + the reset entry can control if and how a ResetAck is returned. */ - void (*reset) (void *state, unsigned char code, unsigned char id, - unsigned char *data, unsigned len, - struct isdn_ppp_resetparams *rsparm); + void (*reset) (void *state, unsigned char code, unsigned char id, + unsigned char *data, unsigned len, + struct isdn_ppp_resetparams *rsparm); - int (*compress) (void *state, struct sk_buff *in, - struct sk_buff *skb_out, int proto); + int (*compress) (void *state, struct sk_buff *in, + struct sk_buff *skb_out, int proto); int (*decompress) (void *state,struct sk_buff *in, struct sk_buff *skb_out, struct isdn_ppp_resetparams *rsparm); - void (*incomp) (void *state, struct sk_buff *in,int proto); - void (*stat) (void *state, struct compstat *stats); + void (*incomp) (void *state, struct sk_buff *in,int proto); + void (*stat) (void *state, struct compstat *stats); }; extern int isdn_ppp_register_compressor(struct isdn_ppp_compressor *); extern int isdn_ppp_unregister_compressor(struct isdn_ppp_compressor *); -typedef struct { - int mp_mrru; /* unused */ -} ippp_bundle; - -#define IPPP_MAX_RQ_LEN 8 - -/* The data structure for one CCP reset transaction */ -enum ippp_ccp_reset_states { - CCPResetIdle, - CCPResetSentReq, - CCPResetRcvdReq, - CCPResetSentAck, - CCPResetRcvdAck -}; - -struct ippp_ccp_reset_state { - enum ippp_ccp_reset_states state; /* State of this transaction */ - struct ippp_ccp *ccp; /* Backlink */ - unsigned char id; /* id index */ - unsigned char ta:1; /* The timer is active (flag) */ - unsigned char expra:1; /* We expect a ResetAck at all */ - int dlen; /* Databytes stored in data */ - struct timer_list timer; /* For timeouts/retries */ - /* This is a hack but seems sufficient for the moment. We do not want - to have this be yet another allocation for some bytes, it is more - memory management overhead than the whole mess is worth. */ - unsigned char data[IPPP_RESET_MAXDATABYTES]; -}; - -/* The data structure keeping track of the currently outstanding CCP Reset - transactions. */ -struct ippp_ccp_reset { - struct ippp_ccp_reset_state *rs[256]; /* One per possible id */ - unsigned char lastid; /* Last id allocated by the engine */ -}; - #endif /* __KERNEL__ */ #endif /* _LINUX_ISDN_PPP_H */ -- cgit v1.2.3 From fa581f7120af893d256f62ffef394cdd59caa356 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:25:55 -0600 Subject: ISDN: Move drivers/isdn/i4l/isdn_fsm.h include/linux/isdn/fsm.h Though I've been mostly moving stuff out of include/linux and into drivers/isdn/i4l, the finite state machine definitions actually need to be more wildly accessible, so they go the opposite way. --- drivers/isdn/i4l/isdn_fsm.c | 2 +- drivers/isdn/i4l/isdn_fsm.h | 58 ----------------------------------------- drivers/isdn/i4l/isdn_net_lib.c | 1 - include/linux/isdn.h | 4 +-- include/linux/isdn/fsm.h | 58 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 63 deletions(-) delete mode 100644 drivers/isdn/i4l/isdn_fsm.h create mode 100644 include/linux/isdn/fsm.h (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_fsm.c b/drivers/isdn/i4l/isdn_fsm.c index 5e453f1edd62..673b3ad9d632 100644 --- a/drivers/isdn/i4l/isdn_fsm.c +++ b/drivers/isdn/i4l/isdn_fsm.c @@ -16,7 +16,7 @@ #include #include #include -#include "isdn_fsm.h" +#include int fsm_new(struct fsm *fsm) diff --git a/drivers/isdn/i4l/isdn_fsm.h b/drivers/isdn/i4l/isdn_fsm.h deleted file mode 100644 index 95beb142b392..000000000000 --- a/drivers/isdn/i4l/isdn_fsm.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Linux ISDN subsystem, finite state machine - * - * Author Karsten Keil - * Copyright by Karsten Keil - * 2001-2002 by Kai Germaschewski - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - */ - -#ifndef __ISDN_FSM_H__ -#define __ISDN_FSM_H__ - -#include -#include - -struct fsm_inst; - -typedef int (*fsm_fn)(struct fsm_inst *, int, void *); - -struct fsm { - fsm_fn *jumpmatrix; - int st_cnt, ev_cnt, fn_cnt; - char **st_str, **ev_str; - struct fsm_node *fn_tbl; -}; - -struct fsm_inst { - struct fsm *fsm; - int state; - int debug; - void *userdata; - int userint; - void (*printdebug) (struct fsm_inst *, char *, ...); -}; - -struct fsm_node { - int st, ev; - fsm_fn fn; -}; - -struct fsm_timer { - struct fsm_inst *fi; - struct timer_list tl; - int ev; - void *arg; -}; - -int fsm_new(struct fsm *fsm); -void fsm_free(struct fsm *fsm); -int fsm_event(struct fsm_inst *fi, int event, void *arg); -void fsm_change_state(struct fsm_inst *fi, int newstate); -void fsm_init_timer(struct fsm_inst *fi, struct fsm_timer *ft); -int fsm_add_timer(struct fsm_timer *ft, int timeout, int event); -void fsm_mod_timer(struct fsm_timer *ft, int timeout, int event); -void fsm_del_timer(struct fsm_timer *ft); - -#endif diff --git a/drivers/isdn/i4l/isdn_net_lib.c b/drivers/isdn/i4l/isdn_net_lib.c index 2fcafe906181..8bc24804a21d 100644 --- a/drivers/isdn/i4l/isdn_net_lib.c +++ b/drivers/isdn/i4l/isdn_net_lib.c @@ -56,7 +56,6 @@ #include "isdn_common.h" #include "isdn_net.h" #include "isdn_ppp.h" -#include "isdn_fsm.h" #define ISDN_NET_TX_TIMEOUT (20*HZ) diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 42baf99a835a..5055fbe6b687 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -14,9 +14,7 @@ #define __ISDN_H__ #include - -// FIXME!!! -#include <../drivers/isdn/i4l/isdn_fsm.h> +#include #ifdef CONFIG_COBALT_MICRO_SERVER /* Save memory */ diff --git a/include/linux/isdn/fsm.h b/include/linux/isdn/fsm.h new file mode 100644 index 000000000000..95beb142b392 --- /dev/null +++ b/include/linux/isdn/fsm.h @@ -0,0 +1,58 @@ +/* Linux ISDN subsystem, finite state machine + * + * Author Karsten Keil + * Copyright by Karsten Keil + * 2001-2002 by Kai Germaschewski + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + */ + +#ifndef __ISDN_FSM_H__ +#define __ISDN_FSM_H__ + +#include +#include + +struct fsm_inst; + +typedef int (*fsm_fn)(struct fsm_inst *, int, void *); + +struct fsm { + fsm_fn *jumpmatrix; + int st_cnt, ev_cnt, fn_cnt; + char **st_str, **ev_str; + struct fsm_node *fn_tbl; +}; + +struct fsm_inst { + struct fsm *fsm; + int state; + int debug; + void *userdata; + int userint; + void (*printdebug) (struct fsm_inst *, char *, ...); +}; + +struct fsm_node { + int st, ev; + fsm_fn fn; +}; + +struct fsm_timer { + struct fsm_inst *fi; + struct timer_list tl; + int ev; + void *arg; +}; + +int fsm_new(struct fsm *fsm); +void fsm_free(struct fsm *fsm); +int fsm_event(struct fsm_inst *fi, int event, void *arg); +void fsm_change_state(struct fsm_inst *fi, int newstate); +void fsm_init_timer(struct fsm_inst *fi, struct fsm_timer *ft); +int fsm_add_timer(struct fsm_timer *ft, int timeout, int event); +void fsm_mod_timer(struct fsm_timer *ft, int timeout, int event); +void fsm_del_timer(struct fsm_timer *ft); + +#endif -- cgit v1.2.3 From dbf409677625ce034e4d9b83b589c224c750fdc9 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:26:44 -0600 Subject: ISDN: Move ISDN net lib interface related definitions into isdn_net_lib.h --- drivers/isdn/i4l/isdn_ciscohdlck.c | 4 +- drivers/isdn/i4l/isdn_ciscohdlck.h | 2 +- drivers/isdn/i4l/isdn_common.c | 7 ++-- drivers/isdn/i4l/isdn_net.c | 46 +++-------------------- drivers/isdn/i4l/isdn_net.h | 77 ++------------------------------------ drivers/isdn/i4l/isdn_net_lib.c | 19 +++++++++- drivers/isdn/i4l/isdn_ppp.c | 2 +- drivers/isdn/i4l/isdn_ppp_ccp.c | 2 +- drivers/isdn/i4l/isdn_ppp_mp.c | 2 +- drivers/isdn/i4l/isdn_ppp_vj.c | 2 +- include/linux/isdn.h | 31 --------------- 11 files changed, 38 insertions(+), 156 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_ciscohdlck.c b/drivers/isdn/i4l/isdn_ciscohdlck.c index c6c321fbe72b..669dc1c7bb93 100644 --- a/drivers/isdn/i4l/isdn_ciscohdlck.c +++ b/drivers/isdn/i4l/isdn_ciscohdlck.c @@ -13,7 +13,7 @@ */ #include "isdn_common.h" -#include "isdn_net.h" +#include "isdn_net_lib.h" #include "isdn_ciscohdlck.h" #include @@ -417,7 +417,7 @@ isdn_ciscohdlck_header(struct sk_buff *skb, struct net_device *dev, return 4; } -struct isdn_netif_ops ciscohdlck_ops = { +struct isdn_netif_ops isdn_ciscohdlck_ops = { .hard_start_xmit = isdn_net_start_xmit, .hard_header = isdn_ciscohdlck_header, .do_ioctl = isdn_ciscohdlck_dev_ioctl, diff --git a/drivers/isdn/i4l/isdn_ciscohdlck.h b/drivers/isdn/i4l/isdn_ciscohdlck.h index 8eecdcb697b4..c9cebdaf5395 100644 --- a/drivers/isdn/i4l/isdn_ciscohdlck.h +++ b/drivers/isdn/i4l/isdn_ciscohdlck.h @@ -10,6 +10,6 @@ #ifndef ISDN_CISCOHDLCK_H #define ISDN_CISCOHDLCK_H -extern struct isdn_netif_ops ciscohdlck_ops; +extern struct isdn_netif_ops isdn_ciscohdlck_ops; #endif diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 0ddb680cc3af..ac4ab500a97d 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -18,8 +18,9 @@ #include #include #include "isdn_common.h" -#include "isdn_tty.h" +#include "isdn_net_lib.h" #include "isdn_net.h" +#include "isdn_tty.h" #include "isdn_ppp.h" #ifdef CONFIG_ISDN_AUDIO #include "isdn_audio.h" @@ -2183,7 +2184,7 @@ static int __init isdn_init(void) } #endif /* CONFIG_ISDN_PPP */ - isdn_net_init(); + isdn_net_lib_init(); printk(KERN_NOTICE "ISDN subsystem initialized\n"); isdn_info_update(); return 0; @@ -2211,7 +2212,7 @@ static void __exit isdn_exit(void) #endif save_flags(flags); cli(); - isdn_net_exit(); + isdn_net_lib_exit(); isdn_tty_exit(); if (unregister_chrdev(ISDN_MAJOR, "isdn")) diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c index 53b9748937bd..370e3e5f8011 100644 --- a/drivers/isdn/i4l/isdn_net.c +++ b/drivers/isdn/i4l/isdn_net.c @@ -9,18 +9,12 @@ * of the GNU General Public License, incorporated herein by reference. */ -#include #include -#include -#include -#include #include +#include #include "isdn_common.h" +#include "isdn_net_lib.h" #include "isdn_net.h" -#include "isdn_ppp.h" -#include -#include "isdn_concap.h" -#include "isdn_ciscohdlck.h" // ISDN_NET_ENCAP_IPTYP // ethernet type field @@ -46,7 +40,7 @@ isdn_iptyp_receive(isdn_net_local *lp, isdn_net_dev *idev, isdn_netif_rx(idev, skb, protocol); } -static struct isdn_netif_ops iptyp_ops = { +struct isdn_netif_ops isdn_iptyp_ops = { .hard_start_xmit = isdn_net_start_xmit, .hard_header = isdn_iptyp_header, .flags = IFF_NOARP | IFF_POINTOPOINT, @@ -76,7 +70,7 @@ isdn_uihdlc_receive(isdn_net_local *lp, isdn_net_dev *idev, isdn_netif_rx(idev, skb, htons(ETH_P_IP)); } -static struct isdn_netif_ops uihdlc_ops = { +struct isdn_netif_ops isdn_uihdlc_ops = { .hard_start_xmit = isdn_net_start_xmit, .hard_header = isdn_uihdlc_header, .flags = IFF_NOARP | IFF_POINTOPOINT, @@ -98,7 +92,7 @@ isdn_rawip_receive(isdn_net_local *lp, isdn_net_dev *idev, netif_rx(skb); } -static struct isdn_netif_ops rawip_ops = { +struct isdn_netif_ops isdn_rawip_ops = { .hard_start_xmit = isdn_net_start_xmit, .flags = IFF_NOARP | IFF_POINTOPOINT, .type = ARPHRD_PPP, @@ -148,37 +142,9 @@ isdn_ether_init(isdn_net_local *lp) return 0; } -static struct isdn_netif_ops ether_ops = { +struct isdn_netif_ops isdn_ether_ops = { .hard_start_xmit = isdn_net_start_xmit, .receive = isdn_ether_receive, .init = isdn_ether_init, .open = isdn_ether_open, }; - -// ====================================================================== - -void -isdn_net_init(void) -{ - isdn_net_lib_init(); - - register_isdn_netif(ISDN_NET_ENCAP_ETHER, ðer_ops); - register_isdn_netif(ISDN_NET_ENCAP_RAWIP, &rawip_ops); - register_isdn_netif(ISDN_NET_ENCAP_IPTYP, &iptyp_ops); - register_isdn_netif(ISDN_NET_ENCAP_UIHDLC, &uihdlc_ops); - register_isdn_netif(ISDN_NET_ENCAP_CISCOHDLC, &ciscohdlck_ops); - register_isdn_netif(ISDN_NET_ENCAP_CISCOHDLCK, &ciscohdlck_ops); -#ifdef CONFIG_ISDN_X25 - register_isdn_netif(ISDN_NET_ENCAP_X25IFACE, &isdn_x25_ops); -#endif -#ifdef CONFIG_ISDN_PPP - register_isdn_netif(ISDN_NET_ENCAP_SYNCPPP, &isdn_ppp_ops); -#endif -} - -void -isdn_net_exit(void) -{ - isdn_net_lib_exit(); -} - diff --git a/drivers/isdn/i4l/isdn_net.h b/drivers/isdn/i4l/isdn_net.h index 1f4933dd0f7a..049f2aa3059c 100644 --- a/drivers/isdn/i4l/isdn_net.h +++ b/drivers/isdn/i4l/isdn_net.h @@ -9,76 +9,7 @@ * of the GNU General Public License, incorporated herein by reference. */ -#include -#include -#include - -void isdn_net_init(void); -void isdn_net_exit(void); -void isdn_net_lib_init(void); -void isdn_net_lib_exit(void); -void isdn_net_hangup_all(void); -int isdn_net_ioctl(struct inode *, struct file *, uint, ulong); - -int register_isdn_netif(int encap, struct isdn_netif_ops *ops); -int isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev); -void isdn_net_online(isdn_net_dev *idev); -void isdn_net_offline(isdn_net_dev *idev); - -int isdn_net_stat_callback(int, isdn_ctrl *); -int isdn_net_find_icall(int, int, int, setup_parm *); -int isdn_net_rcv_skb(int, struct sk_buff *); - -int isdn_net_hangup(isdn_net_dev *); -int isdn_net_dial_req(isdn_net_dev *); -void isdn_net_writebuf_skb(isdn_net_dev *, struct sk_buff *skb); -void isdn_net_write_super(isdn_net_dev *, struct sk_buff *skb); -int isdn_net_autodial(struct sk_buff *skb, struct net_device *ndev); -isdn_net_dev *isdn_net_get_xmit_dev(isdn_net_local *mlp); -void isdn_netif_rx(isdn_net_dev *idev, struct sk_buff *skb, u16 protocol); - -/* ====================================================================== */ - -static inline int -put_u8(unsigned char *p, u8 x) -{ - *p = x; - return 1; -} - -static inline int -put_u16(unsigned char *p, u16 x) -{ - *((u16 *)p) = htons(x); - return 2; -} - -static inline int -put_u32(unsigned char *p, u32 x) -{ - *((u32 *)p) = htonl(x); - return 4; -} - -static inline int -get_u8(unsigned char *p, u8 *x) -{ - *x = *p; - return 1; -} - -static inline int -get_u16(unsigned char *p, u16 *x) -{ - *x = ntohs(*((u16 *)p)); - return 2; -} - -static inline int -get_u32(unsigned char *p, u32 *x) -{ - *x = ntohl(*((u32 *)p)); - return 4; -} - - +extern struct isdn_netif_ops isdn_iptyp_ops; +extern struct isdn_netif_ops isdn_uihdlc_ops; +extern struct isdn_netif_ops isdn_rawip_ops; +extern struct isdn_netif_ops isdn_ether_ops; diff --git a/drivers/isdn/i4l/isdn_net_lib.c b/drivers/isdn/i4l/isdn_net_lib.c index 8bc24804a21d..cf8d99d18f93 100644 --- a/drivers/isdn/i4l/isdn_net_lib.c +++ b/drivers/isdn/i4l/isdn_net_lib.c @@ -1,4 +1,4 @@ -/* Linux ISDN subsystem, Network interface configuration +/* Linux ISDN subsystem, network interface support code * * Copyright 1994-1998 by Fritz Elfert (fritz@isdn4linux.de) * 1995,96 by Thinking Objects Software GmbH Wuerzburg @@ -54,8 +54,10 @@ #include #include #include "isdn_common.h" +#include "isdn_net_lib.h" #include "isdn_net.h" #include "isdn_ppp.h" +#include "isdn_ciscohdlck.h" #define ISDN_NET_TX_TIMEOUT (20*HZ) @@ -2335,12 +2337,25 @@ void isdn_net_lib_init(void) { fsm_new(&isdn_net_fsm); + + register_isdn_netif(ISDN_NET_ENCAP_ETHER, &isdn_ether_ops); + register_isdn_netif(ISDN_NET_ENCAP_RAWIP, &isdn_rawip_ops); + register_isdn_netif(ISDN_NET_ENCAP_IPTYP, &isdn_iptyp_ops); + register_isdn_netif(ISDN_NET_ENCAP_UIHDLC, &isdn_uihdlc_ops); + register_isdn_netif(ISDN_NET_ENCAP_CISCOHDLC, &isdn_ciscohdlck_ops); + register_isdn_netif(ISDN_NET_ENCAP_CISCOHDLCK, &isdn_ciscohdlck_ops); +#ifdef CONFIG_ISDN_X25 + register_isdn_netif(ISDN_NET_ENCAP_X25IFACE, &isdn_x25_ops); +#endif +#ifdef CONFIG_ISDN_PPP + register_isdn_netif(ISDN_NET_ENCAP_SYNCPPP, &isdn_ppp_ops); +#endif } void isdn_net_lib_exit(void) { - isdn_net_cleanup(); + fsm_free(&isdn_net_fsm); } diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c index 0e41f64b2608..27094f60851b 100644 --- a/drivers/isdn/i4l/isdn_ppp.c +++ b/drivers/isdn/i4l/isdn_ppp.c @@ -15,11 +15,11 @@ #include #include "isdn_common.h" +#include "isdn_net_lib.h" #include "isdn_ppp.h" #include "isdn_ppp_ccp.h" #include "isdn_ppp_vj.h" #include "isdn_ppp_mp.h" -#include "isdn_net.h" /* ====================================================================== */ diff --git a/drivers/isdn/i4l/isdn_ppp_ccp.c b/drivers/isdn/i4l/isdn_ppp_ccp.c index 2e51d4a54b4e..5a8f2dc7e01b 100644 --- a/drivers/isdn/i4l/isdn_ppp_ccp.c +++ b/drivers/isdn/i4l/isdn_ppp_ccp.c @@ -11,7 +11,7 @@ #include "isdn_ppp_ccp.h" #include "isdn_common.h" -#include "isdn_net.h" +#include "isdn_net_lib.h" #include "isdn_ppp.h" #include diff --git a/drivers/isdn/i4l/isdn_ppp_mp.c b/drivers/isdn/i4l/isdn_ppp_mp.c index 3f18fe370dc9..995e209eafb2 100644 --- a/drivers/isdn/i4l/isdn_ppp_mp.c +++ b/drivers/isdn/i4l/isdn_ppp_mp.c @@ -12,7 +12,7 @@ #include "isdn_ppp_mp.h" #include "isdn_ppp_ccp.h" #include "isdn_common.h" -#include "isdn_net.h" +#include "isdn_net_lib.h" #include "isdn_ppp.h" /* ====================================================================== */ diff --git a/drivers/isdn/i4l/isdn_ppp_vj.c b/drivers/isdn/i4l/isdn_ppp_vj.c index ef97182b5800..648d4480fe9c 100644 --- a/drivers/isdn/i4l/isdn_ppp_vj.c +++ b/drivers/isdn/i4l/isdn_ppp_vj.c @@ -9,7 +9,7 @@ #include "isdn_ppp_vj.h" #include "isdn_common.h" -#include "isdn_net.h" +#include "isdn_net_lib.h" #include "isdn_ppp.h" struct slcompress * diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 5055fbe6b687..f58b3f83966d 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -278,37 +278,6 @@ struct isdn_net_phone { which holds the linux device structure (here: isdn_net_device) */ -struct isdn_net_dev_s; -struct isdn_net_local_s; - -struct isdn_netif_ops { - int (*hard_start_xmit) (struct sk_buff *skb, - struct net_device *dev); - int (*hard_header) (struct sk_buff *skb, - struct net_device *dev, - unsigned short type, - void *daddr, - void *saddr, - unsigned len); - int (*do_ioctl)(struct net_device *dev, - struct ifreq *ifr, int cmd); - - unsigned short flags; /* interface flags (a la BSD) */ - unsigned short type; /* interface hardware type */ - unsigned char addr_len;/* hardware address length */ - void (*receive)(struct isdn_net_local_s *, - struct isdn_net_dev_s *, - struct sk_buff *); - void (*connected)(struct isdn_net_dev_s *); - void (*disconnected)(struct isdn_net_dev_s *); - int (*bind)(struct isdn_net_dev_s *); - void (*unbind)(struct isdn_net_dev_s *); - int (*init)(struct isdn_net_local_s *); - void (*cleanup)(struct isdn_net_local_s *); - int (*open)(struct isdn_net_local_s *); - void (*close)(struct isdn_net_local_s *); -}; - typedef struct { unsigned long seqerrs; unsigned long frame_drops; -- cgit v1.2.3 From aa799cfeddf35db910eb2165f1d672dcba2258c9 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:28:28 -0600 Subject: ISDN: Move isdn_net_lib specific definitions out of linux/isdn.h isdn_net_dev and isdn_net_local logically are used by isdn_net_lib, so let's move them there. --- drivers/isdn/i4l/isdn_common.c | 12 ++-- drivers/isdn/i4l/isdn_common.h | 4 +- drivers/isdn/i4l/isdn_ppp.h | 3 +- drivers/isdn/i4l/isdn_ppp_mp.h | 3 +- drivers/isdn/i4l/isdn_ppp_vj.h | 4 +- include/linux/isdn.h | 136 ----------------------------------------- 6 files changed, 11 insertions(+), 151 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index ac4ab500a97d..7a42eadb6fff 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -44,7 +44,7 @@ struct isdn_slot { unsigned long obytes; /* Statistics outgoing bytes */ struct isdn_v110 iv110; /* For V.110 */ int m_idx; /* Index for mdm.... */ - isdn_net_dev *idev; /* pointer to isdn_net_dev */ + isdn_net_dev *priv; /* pointer to isdn_net_dev */ }; static struct isdn_slot slot[ISDN_MAX_CHANNELS]; @@ -2023,19 +2023,19 @@ isdn_slot_num(int sl) } void -isdn_slot_set_idev(int sl, isdn_net_dev *idev) +isdn_slot_set_priv(int sl, void *priv) { BUG_ON(sl < 0); - slot[sl].idev = idev; + slot[sl].priv = priv; } -isdn_net_dev * -isdn_slot_idev(int sl) +void * +isdn_slot_priv(int sl) { BUG_ON(sl < 0); - return slot[sl].idev; + return slot[sl].priv; } int diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h index e059ead2cc0c..5aa1e5f71728 100644 --- a/drivers/isdn/i4l/isdn_common.h +++ b/drivers/isdn/i4l/isdn_common.h @@ -96,6 +96,6 @@ extern void isdn_slot_set_usage(int slot, int usage); extern char *isdn_slot_num(int slot); extern int isdn_slot_m_idx(int slot); extern void isdn_slot_set_m_idx(int slot, int midx); -extern void isdn_slot_set_idev(int sl, isdn_net_dev *); -extern isdn_net_dev *isdn_slot_idev(int sl); +extern void isdn_slot_set_priv(int sl, void *); +extern void *isdn_slot_priv(int sl); extern int isdn_hard_header_len(void); diff --git a/drivers/isdn/i4l/isdn_ppp.h b/drivers/isdn/i4l/isdn_ppp.h index df63397a8acb..00996432ad15 100644 --- a/drivers/isdn/i4l/isdn_ppp.h +++ b/drivers/isdn/i4l/isdn_ppp.h @@ -7,8 +7,7 @@ * of the GNU General Public License, incorporated herein by reference. */ -#include /* for PPP_PROTOCOL */ -#include /* for isdn_ppp info */ +#include "isdn_net_lib.h" extern struct file_operations isdn_ppp_fops; extern struct isdn_netif_ops isdn_ppp_ops; diff --git a/drivers/isdn/i4l/isdn_ppp_mp.h b/drivers/isdn/i4l/isdn_ppp_mp.h index 4eacffc728ef..e684edebcd07 100644 --- a/drivers/isdn/i4l/isdn_ppp_mp.h +++ b/drivers/isdn/i4l/isdn_ppp_mp.h @@ -12,8 +12,7 @@ #ifndef __ISDN_PPP_MP_H__ #define __ISDN_PPP_MP_H__ -#include -#include +#include "isdn_net_lib.h" #ifdef CONFIG_ISDN_MPP diff --git a/drivers/isdn/i4l/isdn_ppp_vj.h b/drivers/isdn/i4l/isdn_ppp_vj.h index 1af3ca9049e2..e1fdeac199b7 100644 --- a/drivers/isdn/i4l/isdn_ppp_vj.h +++ b/drivers/isdn/i4l/isdn_ppp_vj.h @@ -10,9 +10,7 @@ #ifndef __ISDN_PPP_VJ_H__ #define __ISDN_PPP_VJ_H__ -#include -#include - +#include "isdn_net_lib.h" #ifdef CONFIG_ISDN_PPP_VJ diff --git a/include/linux/isdn.h b/include/linux/isdn.h index f58b3f83966d..61ce8db1d46d 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -278,142 +278,6 @@ struct isdn_net_phone { which holds the linux device structure (here: isdn_net_device) */ -typedef struct { - unsigned long seqerrs; - unsigned long frame_drops; - unsigned long overflows; - unsigned long max_queue_len; -} isdn_mppp_stats; - -/* Local interface-data */ -typedef struct isdn_net_local_s { - ulong magic; - struct net_device_stats stats; /* Ethernet Statistics */ - int flags; /* Connection-flags */ - int dialmax; /* Max. Number of Dial-retries */ - int dialtimeout; /* How long shall we try on dialing */ - int dialwait; /* wait after failed attempt */ - - int cbdelay; /* Delay before Callback starts */ - char msn[ISDN_MSNLEN]; /* MSNs/EAZs for this interface */ - - u_char cbhup; /* Flag: Reject Call before Callback*/ - int hupflags; /* Flags for charge-unit-hangup: */ - int onhtime; /* Time to keep link up */ - - u_char p_encap; /* Packet encapsulation */ - u_char l2_proto; /* Layer-2-protocol */ - u_char l3_proto; /* Layer-3-protocol */ - - ulong slavedelay; /* Dynamic bundling delaytime */ - int triggercps; /* BogoCPS needed for trigger slave */ - struct list_head phone[2]; /* List of remote-phonenumbers */ - /* phone[0] = Incoming Numbers */ - /* phone[1] = Outgoing Numbers */ - - struct list_head slaves; /* list of all bundled channels - protected by serializing config - ioctls / no change allowed when - interface is running */ - struct list_head online; /* list of all bundled channels - which can be used for actual - data (IP) transfer - protected by xmit_lock */ - - spinlock_t xmit_lock; /* used to protect the xmit path of - a net_device, including all - associated channels's frame_cnt */ - struct list_head running_devs; /* member of global running_devs */ - atomic_t refcnt; /* references held by ISDN code */ - -#ifdef CONFIG_ISDN_X25 - struct concap_device_ops *dops; /* callbacks used by encapsulator */ -#endif -#ifdef CONFIG_ISDN_PPP - unsigned int mp_cfg; - u32 mp_txseq; - struct sk_buff_head mp_frags; /* fragments sl list */ - u32 mp_rxseq; /* last processed packet seq #: any - packets with smaller seq # will - be dropped unconditionally */ - struct ippp_ccp *ccp; - unsigned long debug; -#ifdef CONFIG_ISDN_PPP_VJ - unsigned char *cbuf; - struct slcompress *slcomp; -#endif -#endif - - /* use an own struct for that in later versions */ - ulong cisco_myseq; /* Local keepalive seq. for Cisco */ - ulong cisco_mineseen; /* returned keepalive seq. from remote */ - ulong cisco_yourseq; /* Remote keepalive seq. for Cisco */ - int cisco_keepalive_period; /* keepalive period */ - ulong cisco_last_slarp_in; /* jiffie of last keepalive packet we received */ - char cisco_line_state; /* state of line according to keepalive packets */ - char cisco_debserint; /* debugging flag of cisco hdlc with slarp */ - - struct timer_list cisco_timer; - - struct isdn_netif_ops *ops; - - struct net_device dev; /* interface to upper levels */ -} isdn_net_local; - -/* the interface itself */ -typedef struct isdn_net_dev_s { - int isdn_slot; /* Index to isdn device/channel */ - int pre_device; /* Preselected isdn-device */ - int pre_channel; /* Preselected isdn-channel */ - int exclusive; /* -1 if non excl./idx to excl chan */ - - struct timer_list dial_timer; /* dial events timer */ - struct fsm_inst fi; /* call control state machine */ - int dial_event; /* event in case of timer expiry */ - int dial; /* # of phone number just dialed */ - int outgoing; /* Flag: outgoing call */ - int dialretry; /* Counter for Dialout-retries */ - - int cps; /* current speed of this interface */ - int transcount; /* byte-counter for cps-calculation */ - int last_jiffies; /* when transcount was reset */ - int sqfull; /* Flag: netdev-queue overloaded */ - ulong sqfull_stamp; /* Start-Time of overload */ - - int huptimer; /* Timeout-counter for auto-hangup */ - int charge; /* Counter for charging units */ - int charge_state; /* ChargeInfo state machine */ - unsigned long chargetime; /* Timer for Charging info */ - int chargeint; /* Interval between charge-infos */ - - int pppbind; /* ippp device for bindings */ - struct ipppd *ipppd; /* /dev/ipppX which controls us */ - - struct sk_buff_head super_tx_queue; /* List of supervisory frames to */ - /* be transmitted asap */ - int frame_cnt; /* number of frames currently */ - /* queued in HL driver */ - struct tasklet_struct tlet; - - isdn_net_local *mlp; /* Ptr to master device for all devs*/ - - struct list_head slaves; /* member of local->slaves */ - struct list_head online; /* member of local->online */ - - char name[10]; /* Name of device */ - struct list_head global_list; /* global list of all isdn_net_devs */ -#ifdef CONFIG_ISDN_PPP - unsigned int pppcfg; - u32 mp_rxseq; /* last seq no seen on this channel */ - struct ippp_ccp *ccp; - unsigned long debug; -#endif -#ifdef CONFIG_ISDN_X25 - struct concap_proto *cprot; /* connection oriented encapsulation protocol */ -#endif - -} isdn_net_dev; - /*===================== End of ip-over-ISDN stuff ===========================*/ /*======================= Start of ISDN-tty stuff ===========================*/ -- cgit v1.2.3 From e7288954a5b40b1260a09c21c183679ebab40a5c Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:30:13 -0600 Subject: ISDN: alloc CISCO HDLC info dynamically There's really no need to allocate private storage for all possible interface types, just leave it to the interface type to alloc the memory it needs. CISCO HDLC does that, now. --- drivers/isdn/i4l/isdn_ciscohdlck.c | 123 ++++++++++++++++++++++--------------- drivers/isdn/i4l/isdn_ciscohdlck.h | 11 ++++ drivers/isdn/i4l/isdn_net_lib.h | 37 +++++++---- include/linux/isdn.h | 27 -------- 4 files changed, 109 insertions(+), 89 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_ciscohdlck.c b/drivers/isdn/i4l/isdn_ciscohdlck.c index 669dc1c7bb93..e2a0c7541197 100644 --- a/drivers/isdn/i4l/isdn_ciscohdlck.c +++ b/drivers/isdn/i4l/isdn_ciscohdlck.c @@ -55,6 +55,7 @@ static int isdn_ciscohdlck_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { isdn_net_local *mlp = dev->priv; + struct inl_cisco *cisco = mlp->inl_priv; unsigned long len = 0; int period; char debserint; @@ -66,13 +67,13 @@ isdn_ciscohdlck_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) switch (cmd) { /* get/set keepalive period */ case SIOCGKEEPPERIOD: - len = sizeof(mlp->cisco_keepalive_period); + len = sizeof(cisco->keepalive_period); if (copy_to_user((char *)ifr->ifr_ifru.ifru_data, - (char *)&mlp->cisco_keepalive_period, len)) + (char *)&cisco->keepalive_period, len)) rc = -EFAULT; break; case SIOCSKEEPPERIOD: - len = sizeof(mlp->cisco_keepalive_period); + len = sizeof(cisco->keepalive_period); if (copy_from_user((char *)&period, (char *)ifr->ifr_ifru.ifru_data, len)) { rc = -EFAULT; @@ -82,21 +83,21 @@ isdn_ciscohdlck_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) rc = -EINVAL; break; } - mod_timer(&mlp->cisco_timer, jiffies + period * HZ); + mod_timer(&cisco->timer, jiffies + period * HZ); printk(KERN_INFO "%s: Keepalive period set " "to %d seconds.\n", dev->name, period); - mlp->cisco_keepalive_period = period; + cisco->keepalive_period = period; break; /* get/set debugging */ case SIOCGDEBSERINT: - len = sizeof(mlp->cisco_debserint); + len = sizeof(cisco->debserint); if (copy_to_user((char *)ifr->ifr_ifru.ifru_data, - (char *)&mlp->cisco_debserint, len)) + (char *)&cisco->debserint, len)) rc = -EFAULT; break; case SIOCSDEBSERINT: - len = sizeof(mlp->cisco_debserint); + len = sizeof(cisco->debserint); if (copy_from_user((char *)&debserint, (char *)ifr->ifr_ifru.ifru_data, len)) { rc = -EFAULT; @@ -106,7 +107,7 @@ isdn_ciscohdlck_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) rc = -EINVAL; break; } - mlp->cisco_debserint = debserint; + cisco->debserint = debserint; break; default: @@ -121,10 +122,11 @@ static void isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data) { isdn_net_local *mlp = (isdn_net_local *) data; - isdn_net_dev *idev; + isdn_net_dev *idev; + struct inl_cisco *cisco = mlp->inl_priv; struct sk_buff *skb; unsigned char *p; - unsigned long last_cisco_myseq = mlp->cisco_myseq; + unsigned long last_cisco_myseq = cisco->myseq; int myseq_diff = 0; if (list_empty(&mlp->online)) { @@ -132,33 +134,33 @@ isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data) return; } idev = list_entry(mlp->online.next, isdn_net_dev, online); - mlp->cisco_myseq++; + cisco->myseq++; - myseq_diff = (mlp->cisco_myseq - mlp->cisco_mineseen); - if (mlp->cisco_line_state && (myseq_diff >= 3 || myseq_diff <= -3)) { + myseq_diff = cisco->myseq - cisco->mineseen; + if (cisco->line_state && (myseq_diff >= 3 || myseq_diff <= -3)) { /* line up -> down */ - mlp->cisco_line_state = 0; + cisco->line_state = 0; printk (KERN_WARNING "UPDOWN: Line protocol on Interface %s," " changed state to down\n", idev->name); /* should stop routing higher-level data accross */ - } else if (!mlp->cisco_line_state && + } else if (!cisco->line_state && myseq_diff >= 0 && myseq_diff <= 2) { /* line down -> up */ - mlp->cisco_line_state = 1; + cisco->line_state = 1; printk (KERN_WARNING "UPDOWN: Line protocol on Interface %s," " changed state to up\n", idev->name); /* restart routing higher-level data accross */ } - if (mlp->cisco_debserint) + if (cisco->debserint) printk (KERN_DEBUG "%s: HDLC " - "myseq %lu, mineseen %lu%c, yourseen %lu, %s\n", - idev->name, last_cisco_myseq, mlp->cisco_mineseen, - (last_cisco_myseq == mlp->cisco_mineseen) ? '*' : 040, - mlp->cisco_yourseq, - (mlp->cisco_line_state) ? "line up" : "line down"); + "myseq %u, mineseen %u%c, yourseen %u, %s\n", + idev->name, cisco->myseq, cisco->mineseen, + (last_cisco_myseq == cisco->mineseen) ? '*' : 040, + cisco->yourseq, + (cisco->line_state) ? "line up" : "line down"); skb = isdn_net_ciscohdlck_alloc_skb(idev, 4 + 14); if (!skb) @@ -173,13 +175,13 @@ isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data) /* slarp keepalive */ p += put_u32(p, CISCO_SLARP_KEEPALIVE); - p += put_u32(p, mlp->cisco_myseq); - p += put_u32(p, mlp->cisco_yourseq); + p += put_u32(p, cisco->myseq); + p += put_u32(p, cisco->yourseq); p += put_u16(p, 0xffff); // reliablity, always 0xffff isdn_net_write_super(idev, skb); - mod_timer(&mlp->cisco_timer, jiffies + mlp->cisco_keepalive_period * HZ); + mod_timer(&cisco->timer, jiffies + cisco->keepalive_period * HZ); } static void @@ -219,24 +221,25 @@ static void isdn_ciscohdlck_connected(isdn_net_dev *idev) { isdn_net_local *lp = idev->mlp; + struct inl_cisco *cisco = lp->inl_priv; - lp->cisco_myseq = 0; - lp->cisco_mineseen = 0; - lp->cisco_yourseq = 0; - lp->cisco_keepalive_period = ISDN_TIMER_KEEPINT; - lp->cisco_last_slarp_in = 0; - lp->cisco_line_state = 0; - lp->cisco_debserint = 0; + cisco->myseq = 0; + cisco->mineseen = 0; + cisco->yourseq = 0; + cisco->keepalive_period = ISDN_TIMER_KEEPINT; + cisco->last_slarp_in = 0; + cisco->line_state = 0; + cisco->debserint = 0; if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK) { /* send slarp request because interface/seq.no.s reset */ isdn_net_ciscohdlck_slarp_send_request(lp); - init_timer(&lp->cisco_timer); - lp->cisco_timer.data = (unsigned long) lp; - lp->cisco_timer.function = isdn_net_ciscohdlck_slarp_send_keepalive; - lp->cisco_timer.expires = jiffies + lp->cisco_keepalive_period * HZ; - add_timer(&lp->cisco_timer); + init_timer(&cisco->timer); + cisco->timer.data = (unsigned long) lp; + cisco->timer.function = isdn_net_ciscohdlck_slarp_send_keepalive; + cisco->timer.expires = jiffies + cisco->keepalive_period * HZ; + add_timer(&cisco->timer); } netif_wake_queue(&lp->dev); } @@ -245,9 +248,10 @@ static void isdn_ciscohdlck_disconnected(isdn_net_dev *idev) { isdn_net_local *lp = idev->mlp; + struct inl_cisco *cisco = lp->inl_priv; if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK) { - del_timer(&lp->cisco_timer); + del_timer(&cisco->timer); } } @@ -295,6 +299,7 @@ static void isdn_net_ciscohdlck_slarp_in(isdn_net_dev *idev, struct sk_buff *skb) { isdn_net_local *mlp = idev->mlp; + struct inl_cisco *cisco = mlp->inl_priv; unsigned char *p; int period; u32 code; @@ -311,7 +316,7 @@ isdn_net_ciscohdlck_slarp_in(isdn_net_dev *idev, struct sk_buff *skb) switch (code) { case CISCO_SLARP_REQUEST: - mlp->cisco_yourseq = 0; + cisco->yourseq = 0; isdn_net_ciscohdlck_slarp_send_reply(idev); break; case CISCO_SLARP_REPLY: @@ -338,21 +343,20 @@ isdn_net_ciscohdlck_slarp_in(isdn_net_dev *idev, struct sk_buff *skb) HIPQUAD(addr), HIPQUAD(mask)); break; case CISCO_SLARP_KEEPALIVE: - period = (int)((jiffies - mlp->cisco_last_slarp_in - + HZ/2 - 1) / HZ); - if (mlp->cisco_debserint && - (period != mlp->cisco_keepalive_period) && - mlp->cisco_last_slarp_in) { + period = (jiffies - cisco->last_slarp_in + HZ/2 - 1) / HZ; + if (cisco->debserint && + (period != cisco->keepalive_period) && + cisco->last_slarp_in) { printk(KERN_DEBUG "%s: Keepalive period mismatch - " "is %d but should be %d.\n", - idev->name, period, mlp->cisco_keepalive_period); + idev->name, period, cisco->keepalive_period); } - mlp->cisco_last_slarp_in = jiffies; + cisco->last_slarp_in = jiffies; p += get_u32(p, &my_seq); p += get_u32(p, &your_seq); p += get_u16(p, &unused); - mlp->cisco_yourseq = my_seq; - mlp->cisco_mineseen = your_seq; + cisco->yourseq = my_seq; + cisco->mineseen = your_seq; break; } } @@ -361,6 +365,7 @@ static void isdn_ciscohdlck_receive(isdn_net_local *lp, isdn_net_dev *idev, struct sk_buff *skb) { + struct inl_cisco *cisco = lp->inl_priv; unsigned char *p; u8 addr; u8 ctrl; @@ -387,7 +392,7 @@ isdn_ciscohdlck_receive(isdn_net_local *lp, isdn_net_dev *idev, isdn_net_ciscohdlck_slarp_in(idev, skb); goto out_free; case CISCO_TYPE_CDP: - if (lp->cisco_debserint) + if (cisco->debserint) printk(KERN_DEBUG "%s: Received CDP packet. use " "\"no cdp enable\" on cisco.\n", idev->name); goto out_free; @@ -417,6 +422,22 @@ isdn_ciscohdlck_header(struct sk_buff *skb, struct net_device *dev, return 4; } +static int +isdn_ciscohdlck_open(isdn_net_local *lp) +{ + lp->inl_priv = kmalloc(sizeof(struct inl_cisco), GFP_KERNEL); + if (!lp->inl_priv) + return -ENOMEM; + + return 0; +} + +static void +isdn_ciscohdlck_close(isdn_net_local *lp) +{ + kfree(lp->inl_priv); +} + struct isdn_netif_ops isdn_ciscohdlck_ops = { .hard_start_xmit = isdn_net_start_xmit, .hard_header = isdn_ciscohdlck_header, @@ -426,4 +447,6 @@ struct isdn_netif_ops isdn_ciscohdlck_ops = { .receive = isdn_ciscohdlck_receive, .connected = isdn_ciscohdlck_connected, .disconnected = isdn_ciscohdlck_disconnected, + .open = isdn_ciscohdlck_open, + .close = isdn_ciscohdlck_close, }; diff --git a/drivers/isdn/i4l/isdn_ciscohdlck.h b/drivers/isdn/i4l/isdn_ciscohdlck.h index c9cebdaf5395..dda0d7a07744 100644 --- a/drivers/isdn/i4l/isdn_ciscohdlck.h +++ b/drivers/isdn/i4l/isdn_ciscohdlck.h @@ -12,4 +12,15 @@ extern struct isdn_netif_ops isdn_ciscohdlck_ops; +struct inl_cisco { + u32 myseq; /* local keepalive seq. for Cisco */ + u32 mineseen; /* returned keepalive seq. from remote */ + u32 yourseq; /* remote keepalive seq. for Cisco */ + int keepalive_period; /* keepalive period */ + int last_slarp_in; /* jiffie of last recvd keepalive pkt */ + char line_state; /* state of line */ + char debserint; /* debugging flags */ + struct timer_list timer; +}; + #endif diff --git a/drivers/isdn/i4l/isdn_net_lib.h b/drivers/isdn/i4l/isdn_net_lib.h index e45da8224fe2..92ef9e8395a1 100644 --- a/drivers/isdn/i4l/isdn_net_lib.h +++ b/drivers/isdn/i4l/isdn_net_lib.h @@ -69,6 +69,29 @@ int register_isdn_netif(int encap, struct isdn_netif_ops *ops); /* ====================================================================== */ +/* Feature- and status-flags for a net-interface */ +#define ISDN_NET_SECURE 0x02 /* Accept calls from phonelist only */ +#define ISDN_NET_CALLBACK 0x04 /* activate callback */ +#define ISDN_NET_CBHUP 0x08 /* hangup before callback */ +#define ISDN_NET_CBOUT 0x10 /* remote machine does callback */ + +#define ISDN_NET_MAGIC 0x49344C02 /* for paranoia-checking */ + +/* Phone-list-element */ +struct isdn_net_phone { + struct list_head list; + char num[ISDN_MSNLEN]; +}; + +/* + Principles when extending structures for generic encapsulation protocol + ("concap") support: + - Stuff which is hardware specific (here i4l-specific) goes in + the netdev -> local structure (here: isdn_net_local) + - Stuff which is encapsulation protocol specific goes in the structure + which holds the linux device structure (here: isdn_net_device) +*/ + /* per network interface data (dev->priv) */ struct isdn_net_local_s { @@ -128,18 +151,8 @@ struct isdn_net_local_s { struct slcompress *slcomp; #endif #endif - - /* use an own struct for that in later versions */ - ulong cisco_myseq; /* Local keepalive seq. for Cisco */ - ulong cisco_mineseen; /* returned keepalive seq. from remote */ - ulong cisco_yourseq; /* Remote keepalive seq. for Cisco */ - int cisco_keepalive_period; /* keepalive period */ - ulong cisco_last_slarp_in; /* jiffie of last keepalive packet we received */ - char cisco_line_state; /* state of line according to keepalive packets */ - char cisco_debserint; /* debugging flag of cisco hdlc with slarp */ - - struct timer_list cisco_timer; - + void *inl_priv; /* interface types can put their + private data here */ struct isdn_netif_ops *ops; struct net_device dev; /* interface to upper levels */ diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 61ce8db1d46d..8a1afe26f172 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -253,33 +253,6 @@ typedef struct { /* GLOBAL_FLAGS */ #define ISDN_GLOBAL_STOPPED 1 -/*=================== Start of ip-over-ISDN stuff =========================*/ - -/* Feature- and status-flags for a net-interface */ -#define ISDN_NET_SECURE 0x02 /* Accept calls from phonelist only */ -#define ISDN_NET_CALLBACK 0x04 /* activate callback */ -#define ISDN_NET_CBHUP 0x08 /* hangup before callback */ -#define ISDN_NET_CBOUT 0x10 /* remote machine does callback */ - -#define ISDN_NET_MAGIC 0x49344C02 /* for paranoia-checking */ - -/* Phone-list-element */ -struct isdn_net_phone { - struct list_head list; - char num[ISDN_MSNLEN]; -}; - -/* - Principles when extending structures for generic encapsulation protocol - ("concap") support: - - Stuff which is hardware specific (here i4l-specific) goes in - the netdev -> local structure (here: isdn_net_local) - - Stuff which is encapsulation protocol specific goes in the structure - which holds the linux device structure (here: isdn_net_device) -*/ - -/*===================== End of ip-over-ISDN stuff ===========================*/ - /*======================= Start of ISDN-tty stuff ===========================*/ #define ISDN_ASYNC_MAGIC 0x49344C01 /* for paranoia-checking */ -- cgit v1.2.3 From 6afb7be2ae6ea38a72d13ad3b76742800f55ec18 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:34:03 -0600 Subject: ISDN: Remove rcv_waitq/snd_waitq The arrays were only allocated and initialized, never used. --- drivers/isdn/i4l/isdn_audio.c | 2 -- drivers/isdn/i4l/isdn_common.c | 29 +++-------------------------- include/linux/isdn.h | 2 -- 3 files changed, 3 insertions(+), 30 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_audio.c b/drivers/isdn/i4l/isdn_audio.c index 2602dfc059a4..a2c4c7883eaf 100644 --- a/drivers/isdn/i4l/isdn_audio.c +++ b/drivers/isdn/i4l/isdn_audio.c @@ -570,7 +570,6 @@ isdn_audio_eval_dtmf(modem_info * info) /* Schedule dequeuing */ if ((dev->modempoll) && (info->rcvsched)) isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 1); - wake_up_interruptible(&dev->drv[di]->rcv_waitq[ch]); } else kfree_skb(skb); s->last = what; @@ -691,7 +690,6 @@ isdn_audio_put_dle_code(modem_info * info, u_char code) /* Schedule dequeuing */ if ((dev->modempoll) && (info->rcvsched)) isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 1); - wake_up_interruptible(&dev->drv[di]->rcv_waitq[ch]); } void diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 7a42eadb6fff..f49de99aa06a 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -319,12 +319,9 @@ isdn_receive_skb_callback(int di, int channel, struct sk_buff *skb) } /* No network-device found, deliver to tty or raw-channel */ - if (skb->len) { - if (isdn_tty_rcv_skb(i, di, channel, skb)) - return; - wake_up_interruptible(&dev->drv[di]->rcv_waitq[channel]); - } else - dev_kfree_skb(skb); + if (isdn_tty_rcv_skb(i, di, channel, skb)) + return; + dev_kfree_skb(skb); } /* @@ -436,7 +433,6 @@ isdn_status_callback(isdn_ctrl * c) return 0; if (isdn_tty_stat_callback(i, c)) return 0; - wake_up_interruptible(&dev->drv[di]->snd_waitq[c->arg]); break; case ISDN_STAT_STAVAIL: save_flags(flags); @@ -658,7 +654,6 @@ isdn_status_callback(isdn_ctrl * c) for (i = 0; i < dev->drv[di]->channels; i++) skb_queue_purge(&dev->drv[di]->rpqueue[i]); kfree(dev->drv[di]->rpqueue); - kfree(dev->drv[di]->rcv_waitq); kfree(dev->drv[di]); dev->drv[di] = NULL; dev->drvid[di][0] = '\0'; @@ -1701,24 +1696,6 @@ isdn_add_channels(driver *d, int drvidx, int n, int adding) skb_queue_head_init(&d->rpqueue[j]); } - if ((adding) && (d->rcv_waitq)) - kfree(d->rcv_waitq); - d->rcv_waitq = kmalloc(sizeof(wait_queue_head_t) * 2 * m, GFP_KERNEL); - if (!d->rcv_waitq) { - printk(KERN_WARNING "register_isdn: Could not alloc rcv_waitq\n"); - if (!adding) { - kfree(d->rpqueue); - kfree(d->rcvcount); - kfree(d->rcverr); - } - return -1; - } - d->snd_waitq = d->rcv_waitq + m; - for (j = 0; j < m; j++) { - init_waitqueue_head(&d->rcv_waitq[j]); - init_waitqueue_head(&d->snd_waitq[j]); - } - dev->channels += n; save_flags(flags); cli(); diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 8a1afe26f172..8ce00dae9a84 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -434,8 +434,6 @@ typedef struct { unsigned long DLEflag; /* Flags: Insert DLE at next read */ #endif struct sk_buff_head *rpqueue; /* Pointers to start of Rcv-Queue */ - wait_queue_head_t *rcv_waitq; /* Wait-Queues for B-Channel-Reads */ - wait_queue_head_t *snd_waitq; /* Wait-Queue for B-Channel-Send's */ char msn2eaz[10][ISDN_MSNLEN]; /* Mapping-Table MSN->EAZ */ } driver; -- cgit v1.2.3 From 96d1d0390e22e154f54336f8a9ac17c135cec619 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:36:36 -0600 Subject: ISDN: Make array of drivers private to isdn_common.c Currently, we need to provide a couple of helper functions to avoid breaking isdn_tty with this change, as that gets cleaned up, the need for those helpers should vanish as well. --- drivers/isdn/i4l/isdn_audio.c | 6 +- drivers/isdn/i4l/isdn_common.c | 214 ++++++++++++++++++++++++++--------------- drivers/isdn/i4l/isdn_common.h | 7 +- drivers/isdn/i4l/isdn_tty.c | 19 ++-- drivers/isdn/i4l/isdn_v110.c | 9 +- include/linux/isdn.h | 25 ----- 6 files changed, 159 insertions(+), 121 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_audio.c b/drivers/isdn/i4l/isdn_audio.c index a2c4c7883eaf..8e618de64e79 100644 --- a/drivers/isdn/i4l/isdn_audio.c +++ b/drivers/isdn/i4l/isdn_audio.c @@ -564,8 +564,7 @@ isdn_audio_eval_dtmf(modem_info * info) cli(); di = isdn_slot_driver(info->isdn_slot); ch = isdn_slot_channel(info->isdn_slot); - __skb_queue_tail(&dev->drv[di]->rpqueue[ch], skb); - dev->drv[di]->rcvcount[ch] += 2; + isdn_drv_queue_tail(di, ch, skb, 2); restore_flags(flags); /* Schedule dequeuing */ if ((dev->modempoll) && (info->rcvsched)) @@ -684,8 +683,7 @@ isdn_audio_put_dle_code(modem_info * info, u_char code) cli(); di = isdn_slot_driver(info->isdn_slot); ch = isdn_slot_channel(info->isdn_slot); - __skb_queue_tail(&dev->drv[di]->rpqueue[ch], skb); - dev->drv[di]->rcvcount[ch] += 2; + isdn_drv_queue_tail(di, ch, skb, 2); restore_flags(flags); /* Schedule dequeuing */ if ((dev->modempoll) && (info->rcvsched)) diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 147b52d05ffb..f42497d38fbc 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -49,6 +49,69 @@ struct isdn_slot { static struct isdn_slot slot[ISDN_MAX_CHANNELS]; +/* ====================================================================== */ + +#define DRV_FLAG_RUNNING 1 +#define DRV_FLAG_REJBUS 2 +#define DRV_FLAG_LOADED 4 + +/* Description of hardware-level-driver */ +struct isdn_driver { + unsigned long online; /* Channel Online flags */ + unsigned long flags; /* Misc driver Flags */ + int locks; /* Number of locks */ + int channels; /* Number of channels */ + wait_queue_head_t st_waitq; /* Wait-Queue for status-reads */ + int maxbufsize; /* Maximum Buffersize supported*/ + int stavail; /* Chars avail on Status-device*/ + isdn_if *interface; /* Interface to driver */ + int *rcverr; /* Error-counters for B rx */ + int *rcvcount; /* Byte-counters for B rx */ +#ifdef CONFIG_ISDN_AUDIO + unsigned long DLEflag; /* Insert DLE at next read */ +#endif + struct sk_buff_head *rpqueue; /* Pointers to rx queue */ + char msn2eaz[10][ISDN_MSNLEN]; /* MSN->EAZ */ + struct fsm_inst fi; +} driver; + +struct isdn_driver *drivers[ISDN_MAX_DRIVERS]; + +int +isdn_drv_queue_empty(int di, int ch) +{ + return skb_queue_empty(&drivers[di]->rpqueue[ch]); +} + +void +isdn_drv_queue_tail(int di, int ch, struct sk_buff *skb, int len) +{ + __skb_queue_tail(&drivers[di]->rpqueue[ch], skb); + drivers[di]->rcvcount[ch] += len; +} + +int +isdn_drv_maxbufsize(int di) +{ + return drivers[di]->maxbufsize; +} + +int +isdn_drv_writebuf_skb(int di, int ch, int x, struct sk_buff *skb) +{ + return drivers[di]->interface->writebuf_skb(di, ch, 1, skb); +} + +int +isdn_drv_hdrlen(int di) +{ + return drivers[di]->interface->hl_hdrlen; +} + +static int isdn_add_channels(struct isdn_driver *, int, int, int); + +/* ====================================================================== */ + #if defined(CONFIG_ISDN_DIVERSION) || defined(CONFIG_ISDN_DIVERSION_MODULE) static isdn_divert_if *divert_if; /* = NULL */ #else @@ -75,7 +138,7 @@ isdn_lock_drivers(void) cmd.arg = 0; cmd.command = ISDN_CMD_LOCK; isdn_command(&cmd); - dev->drv[i]->locks++; + drivers[i]->locks++; } } @@ -92,14 +155,14 @@ isdn_unlock_drivers(void) int i; for (i = 0; i < dev->drivers; i++) - if (dev->drv[i]->locks > 0) { + if (drivers[i]->locks > 0) { isdn_ctrl cmd; cmd.driver = i; cmd.arg = 0; cmd.command = ISDN_CMD_UNLOCK; isdn_command(&cmd); - dev->drv[i]->locks--; + drivers[i]->locks--; } } @@ -342,7 +405,7 @@ isdn_command(isdn_ctrl *cmd) } if (cmd->command == ISDN_CMD_SETL2) { unsigned long l2prot = (cmd->arg >> 8) & 255; - unsigned long features = (dev->drv[cmd->driver]->interface->features + unsigned long features = (drivers[cmd->driver]->interface->features >> ISDN_FEATURE_L2_SHIFT) & ISDN_FEATURE_L2_MASK; unsigned long l2_feature = (1 << l2prot); @@ -389,7 +452,7 @@ isdn_command(isdn_ctrl *cmd) printk(KERN_DEBUG "%s: cmd = %d\n", __FUNCTION__, cmd->command); } #endif - return dev->drv[cmd->driver]->interface->command(cmd); + return drivers[cmd->driver]->interface->command(cmd); } /* @@ -441,19 +504,19 @@ isdn_status_callback(isdn_ctrl * c) break; case ISDN_STAT_STAVAIL: spin_lock_irqsave(&stat_lock, flags); - dev->drv[di]->stavail += c->arg; + drivers[di]->stavail += c->arg; spin_unlock_irqrestore(&stat_lock, flags); - wake_up_interruptible(&dev->drv[di]->st_waitq); + wake_up_interruptible(&drivers[di]->st_waitq); break; case ISDN_STAT_RUN: - dev->drv[di]->flags |= DRV_FLAG_RUNNING; + drivers[di]->flags |= DRV_FLAG_RUNNING; for (i = 0; i < ISDN_MAX_CHANNELS; i++) if (slot[i].di == di) isdn_slot_all_eaz(i); set_global_features(); break; case ISDN_STAT_STOP: - dev->drv[di]->flags &= ~DRV_FLAG_RUNNING; + drivers[di]->flags &= ~DRV_FLAG_RUNNING; break; case ISDN_STAT_ICALL: if (i < 0) @@ -476,7 +539,7 @@ isdn_status_callback(isdn_ctrl * c) if (divert_if) if ((retval = divert_if->stat_callback(c))) return(retval); /* processed */ - if ((!retval) && (dev->drv[di]->flags & DRV_FLAG_REJBUS)) { + if ((!retval) && (drivers[di]->flags & DRV_FLAG_REJBUS)) { /* No tty responding */ cmd.driver = di; cmd.arg = c->arg; @@ -565,7 +628,7 @@ isdn_status_callback(isdn_ctrl * c) if (i < 0) return -1; dbg_statcallb("DHUP: %d\n", i); - dev->drv[di]->online &= ~(1 << (c->arg)); + drivers[di]->online &= ~(1 << (c->arg)); isdn_info_update(); /* Signal hangup to network-devices */ if (isdn_net_stat_callback(i, c)) @@ -581,7 +644,7 @@ isdn_status_callback(isdn_ctrl * c) return -1; dbg_statcallb("BCONN: %ld\n", c->arg); /* Signal B-channel-connect to network-devices */ - dev->drv[di]->online |= (1 << (c->arg)); + drivers[di]->online |= (1 << (c->arg)); isdn_info_update(); if (isdn_net_stat_callback(i, c)) break; @@ -593,7 +656,7 @@ isdn_status_callback(isdn_ctrl * c) if (i < 0) return -1; dbg_statcallb("BHUP: %d\n", i); - dev->drv[di]->online &= ~(1 << (c->arg)); + drivers[di]->online &= ~(1 << (c->arg)); isdn_info_update(); /* Signal hangup to network-devices */ if (isdn_net_stat_callback(i, c)) @@ -612,7 +675,7 @@ isdn_status_callback(isdn_ctrl * c) break; break; case ISDN_STAT_ADDCH: - if (isdn_add_channels(dev->drv[di], di, c->arg, 1)) + if (isdn_add_channels(drivers[di], di, c->arg, 1)) return -1; isdn_info_update(); break; @@ -633,13 +696,13 @@ isdn_status_callback(isdn_ctrl * c) restore_flags(flags); break; case ISDN_STAT_UNLOAD: - while (dev->drv[di]->locks > 0) { + while (drivers[di]->locks > 0) { isdn_ctrl cmd; cmd.driver = di; cmd.arg = 0; cmd.command = ISDN_CMD_UNLOCK; isdn_command(&cmd); - dev->drv[di]->locks--; + drivers[di]->locks--; } save_flags(flags); cli(); @@ -652,14 +715,14 @@ isdn_status_callback(isdn_ctrl * c) isdn_unregister_devfs(i); } dev->drivers--; - dev->channels -= dev->drv[di]->channels; - kfree(dev->drv[di]->rcverr); - kfree(dev->drv[di]->rcvcount); - for (i = 0; i < dev->drv[di]->channels; i++) - skb_queue_purge(&dev->drv[di]->rpqueue[i]); - kfree(dev->drv[di]->rpqueue); - kfree(dev->drv[di]); - dev->drv[di] = NULL; + dev->channels -= drivers[di]->channels; + kfree(drivers[di]->rcverr); + kfree(drivers[di]->rcvcount); + for (i = 0; i < drivers[di]->channels; i++) + skb_queue_purge(&drivers[di]->rpqueue[i]); + kfree(drivers[di]->rpqueue); + kfree(drivers[di]); + drivers[di] = NULL; dev->drvid[di][0] = '\0'; isdn_info_update(); set_global_features(); @@ -720,23 +783,23 @@ isdn_slot_readbchan(int sl, u_char * buf, u_char * fp, int len) struct sk_buff *skb; u_char *cp; - if (!dev->drv[di]) + if (!drivers[di]) return 0; - if (skb_queue_empty(&dev->drv[di]->rpqueue[ch])) + if (skb_queue_empty(&drivers[di]->rpqueue[ch])) return 0; - if (len > dev->drv[di]->rcvcount[ch]) - len = dev->drv[di]->rcvcount[ch]; + if (len > drivers[di]->rcvcount[ch]) + len = drivers[di]->rcvcount[ch]; cp = buf; count = 0; while (len) { - if (!(skb = skb_peek(&dev->drv[di]->rpqueue[ch]))) + if (!(skb = skb_peek(&drivers[di]->rpqueue[ch]))) break; #ifdef CONFIG_ISDN_AUDIO if (ISDN_AUDIO_SKB_LOCK(skb)) break; ISDN_AUDIO_SKB_LOCK(skb) = 1; - if ((ISDN_AUDIO_SKB_DLECOUNT(skb)) || (dev->drv[di]->DLEflag & (1 << ch))) { + if ((ISDN_AUDIO_SKB_DLECOUNT(skb)) || (drivers[di]->DLEflag & (1 << ch))) { char *p = skb->data; unsigned long DLEmask = (1 << ch); @@ -744,13 +807,13 @@ isdn_slot_readbchan(int sl, u_char * buf, u_char * fp, int len) count_pull = count_put = 0; while ((count_pull < skb->len) && (len > 0)) { len--; - if (dev->drv[di]->DLEflag & DLEmask) { + if (drivers[di]->DLEflag & DLEmask) { *cp++ = DLE; - dev->drv[di]->DLEflag &= ~DLEmask; + drivers[di]->DLEflag &= ~DLEmask; } else { *cp++ = *p; if (*p == DLE) { - dev->drv[di]->DLEflag |= DLEmask; + drivers[di]->DLEflag |= DLEmask; (ISDN_AUDIO_SKB_DLECOUNT(skb))--; } p++; @@ -789,7 +852,7 @@ isdn_slot_readbchan(int sl, u_char * buf, u_char * fp, int len) #ifdef CONFIG_ISDN_AUDIO ISDN_AUDIO_SKB_LOCK(skb) = 0; #endif - skb = skb_dequeue(&dev->drv[di]->rpqueue[ch]); + skb = skb_dequeue(&drivers[di]->rpqueue[ch]); dev_kfree_skb(skb); } else { /* Not yet emptied this buff, so it @@ -801,7 +864,7 @@ isdn_slot_readbchan(int sl, u_char * buf, u_char * fp, int len) ISDN_AUDIO_SKB_LOCK(skb) = 0; #endif } - dev->drv[di]->rcvcount[ch] -= count_put; + drivers[di]->rcvcount[ch] -= count_put; } return count; } @@ -852,8 +915,8 @@ isdn_statstr(void) sprintf(p, "\nflags:\t"); p = istatbuf + strlen(istatbuf); for (i = 0; i < ISDN_MAX_DRIVERS; i++) { - if (dev->drv[i]) { - sprintf(p, "%ld ", dev->drv[i]->online); + if (drivers[i]) { + sprintf(p, "%ld ", drivers[i]->online); p = istatbuf + strlen(istatbuf); } else { sprintf(p, "? "); @@ -1090,14 +1153,14 @@ isdn_ctrl_read(struct file *file, char *buf, size_t count, loff_t * off) isdn_BUG(); return -ENODEV; } - if (!dev->drv[drvidx]->interface->readstat) { + if (!drivers[drvidx]->interface->readstat) { isdn_BUG(); return 0; } - add_wait_queue(&dev->drv[drvidx]->st_waitq, &wait); + add_wait_queue(&drivers[drvidx]->st_waitq, &wait); for (;;) { spin_lock_irqsave(&stat_lock, flags); - len = dev->drv[drvidx]->stavail; + len = drivers[drvidx]->stavail; spin_unlock_irqrestore(&stat_lock, flags); if (len > 0) break; @@ -1112,7 +1175,7 @@ isdn_ctrl_read(struct file *file, char *buf, size_t count, loff_t * off) schedule(); } __set_current_state(TASK_RUNNING); - remove_wait_queue(&dev->drv[drvidx]->st_waitq, &wait); + remove_wait_queue(&drivers[drvidx]->st_waitq, &wait); if (len < 0) return len; @@ -1120,15 +1183,15 @@ isdn_ctrl_read(struct file *file, char *buf, size_t count, loff_t * off) if (count > len) count = len; - len = dev->drv[drvidx]->interface->readstat(buf, count, 1, drvidx, - isdn_minor2chan(minor)); + len = drivers[drvidx]->interface->readstat(buf, count, 1, drvidx, + isdn_minor2chan(minor)); spin_lock_irqsave(&stat_lock, flags); if (len) { - dev->drv[drvidx]->stavail -= len; + drivers[drvidx]->stavail -= len; } else { isdn_BUG(); - dev->drv[drvidx]->stavail = 0; + drivers[drvidx]->stavail = 0; } spin_unlock_irqrestore(&stat_lock, flags); @@ -1151,11 +1214,11 @@ isdn_ctrl_write(struct file *file, const char *buf, size_t count, loff_t *off) retval = -ENODEV; goto out; } - if (!dev->drv[drvidx]->interface->writecmd) { + if (!drivers[drvidx]->interface->writecmd) { retval = -EINVAL; goto out; } - retval = dev->drv[drvidx]->interface-> + retval = drivers[drvidx]->interface-> writecmd(buf, count, 1, drvidx, isdn_minor2chan(minor - ISDN_MINOR_CTRL)); out: @@ -1174,9 +1237,9 @@ isdn_ctrl_poll(struct file *file, poll_table *wait) /* driver deregistered while file open */ return POLLHUP; - poll_wait(file, &(dev->drv[drvidx]->st_waitq), wait); + poll_wait(file, &drivers[drvidx]->st_waitq, wait); mask = POLLOUT | POLLWRNORM; - if (dev->drv[drvidx]->stavail) + if (drivers[drvidx]->stavail) mask |= POLLIN | POLLRDNORM; return mask; @@ -1255,9 +1318,9 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) if (drvidx == -1) return -ENODEV; if (iocts.arg) - dev->drv[drvidx]->flags |= DRV_FLAG_REJBUS; + drivers[drvidx]->flags |= DRV_FLAG_REJBUS; else - dev->drv[drvidx]->flags &= ~DRV_FLAG_REJBUS; + drivers[drvidx]->flags &= ~DRV_FLAG_REJBUS; return 0; case IIOCSIGPRF: dev->profd = current; @@ -1355,7 +1418,7 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) /* Fall through */ case ',': bname[j] = '\0'; - strcpy(dev->drv[drvidx]->msn2eaz[i], bname); + strcpy(drivers[drvidx]->msn2eaz[i], bname); j = ISDN_MSNLEN; break; default: @@ -1371,8 +1434,8 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) p = (char *) iocts.arg; for (i = 0; i < 10; i++) { sprintf(bname, "%s%s", - strlen(dev->drv[drvidx]->msn2eaz[i]) ? - dev->drv[drvidx]->msn2eaz[i] : "_", + strlen(drivers[drvidx]->msn2eaz[i]) ? + drivers[drvidx]->msn2eaz[i] : "_", (i < 9) ? "," : "\0"); if (copy_to_user(p, bname, strlen(bname) + 1)) return -EFAULT; @@ -1494,7 +1557,7 @@ static struct file_operations isdn_fops = char * isdn_map_eaz2msn(char *msn, int di) { - driver *this = dev->drv[di]; + struct isdn_driver *this = drivers[di]; int i; if (strlen(msn) == 1) { @@ -1538,11 +1601,11 @@ isdn_get_free_slot(int usage, int l2_proto, int l3_proto, continue; if (slot[i].usage & ISDN_USAGE_DISABLED) continue; /* usage not allowed */ - if (!dev->drv[d]->flags & DRV_FLAG_RUNNING) + if (!drivers[d]->flags & DRV_FLAG_RUNNING) continue; - if (((dev->drv[d]->interface->features & features) == features) || - (((dev->drv[d]->interface->features & vfeatures) == vfeatures) && - (dev->drv[d]->interface->features & ISDN_FEATURE_L2_TRANS))) { + if (((drivers[d]->interface->features & features) == features) || + (((drivers[d]->interface->features & vfeatures) == vfeatures) && + (drivers[d]->interface->features & ISDN_FEATURE_L2_TRANS))) { if (pre_dev < 0 || pre_chan < 0 || (pre_dev == d && pre_chan == slot[i].ch)) { isdn_slot_set_usage(i, usage); @@ -1584,7 +1647,7 @@ isdn_slot_free(int sl) slot[sl].iv110.v110 = NULL; // 20.10.99 JIM, try to reinitialize v110 ! isdn_slot_set_usage(sl, ISDN_USAGE_NONE); - skb_queue_purge(&dev->drv[isdn_slot_driver(sl)]->rpqueue[isdn_slot_channel(sl)]); + skb_queue_purge(&drivers[isdn_slot_driver(sl)]->rpqueue[isdn_slot_channel(sl)]); restore_flags(flags); } @@ -1615,7 +1678,7 @@ isdn_slot_write(int sl, struct sk_buff *skb) return v110_ret; } /* V.110 must always be acknowledged */ - ret = dev->drv[di]->interface->writebuf_skb(di, ch, 1, nskb); + ret = drivers[di]->interface->writebuf_skb(di, ch, 1, nskb); } else { int hl = isdn_slot_hdrlen(sl); @@ -1633,14 +1696,14 @@ isdn_slot_write(int sl, struct sk_buff *skb) skb_tmp = skb_realloc_headroom(skb, hl); printk(KERN_DEBUG "isdn_writebuf_skb_stub: reallocating headroom%s\n", skb_tmp ? "" : " failed"); if (!skb_tmp) return -ENOMEM; /* 0 better? */ - ret = dev->drv[di]->interface->writebuf_skb(di, ch, 1, skb_tmp); + ret = drivers[di]->interface->writebuf_skb(di, ch, 1, skb_tmp); if( ret > 0 ){ dev_kfree_skb(skb); } else { dev_kfree_skb(skb_tmp); } } else { - ret = dev->drv[di]->interface->writebuf_skb(di, ch, 1, skb); + ret = drivers[di]->interface->writebuf_skb(di, ch, 1, skb); } } if (ret > 0) { @@ -1662,8 +1725,8 @@ isdn_slot_write(int sl, struct sk_buff *skb) return ret; } -int -isdn_add_channels(driver *d, int drvidx, int n, int adding) +static int +isdn_add_channels(struct isdn_driver *d, int drvidx, int n, int adding) { int j, k, m; ulong flags; @@ -1742,10 +1805,10 @@ set_global_features(void) dev->global_features = 0; for (drvidx = 0; drvidx < ISDN_MAX_DRIVERS; drvidx++) { - if (!dev->drv[drvidx]) + if (!drivers[drvidx]) continue; - if (dev->drv[drvidx]->interface) - dev->global_features |= dev->drv[drvidx]->interface->features; + if (drivers[drvidx]->interface) + dev->global_features |= drivers[drvidx]->interface->features; } } @@ -1810,7 +1873,7 @@ EXPORT_SYMBOL(isdn_ppp_unregister_compressor); int register_isdn(isdn_if * i) { - driver *d; + struct isdn_driver *d; int j; ulong flags; int drvidx; @@ -1831,14 +1894,13 @@ register_isdn(isdn_if * i) memset((char *) d, 0, sizeof(driver)); d->maxbufsize = i->maxbufsize; - d->pktcount = 0; d->stavail = 0; d->flags = DRV_FLAG_LOADED; d->online = 0; d->interface = i; d->channels = 0; for (drvidx = 0; drvidx < ISDN_MAX_DRIVERS; drvidx++) - if (!dev->drv[drvidx]) + if (!drivers[drvidx]) break; if (isdn_add_channels(d, drvidx, i->channels, 0)) { kfree(d); @@ -1854,7 +1916,7 @@ register_isdn(isdn_if * i) for (j = 0; j < drvidx; j++) if (!strcmp(i->id, dev->drvid[j])) sprintf(i->id, "line%d", drvidx); - dev->drv[drvidx] = d; + drivers[drvidx] = d; strcpy(dev->drvid[drvidx], i->id); isdn_info_update(); dev->drivers++; @@ -1884,7 +1946,7 @@ isdn_slot_hdrlen(int sl) { int di = isdn_slot_driver(sl); - return dev->drv[di]->interface->hl_hdrlen; + return drivers[di]->interface->hl_hdrlen; } char * @@ -2041,9 +2103,9 @@ isdn_hard_header_len(void) int max = 0; for (drvidx = 0; drvidx < ISDN_MAX_DRIVERS; drvidx++) { - if (dev->drv[drvidx] && - max < dev->drv[drvidx]->interface->hl_hdrlen) { - max = dev->drv[drvidx]->interface->hl_hdrlen; + if (drivers[drvidx] && + max < drivers[drvidx]->interface->hl_hdrlen) { + max = drivers[drvidx]->interface->hl_hdrlen; } } return max; diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h index 5aa1e5f71728..ee9d125e592c 100644 --- a/drivers/isdn/i4l/isdn_common.h +++ b/drivers/isdn/i4l/isdn_common.h @@ -63,7 +63,6 @@ extern char *isdn_map_eaz2msn(char *msn, int di); extern void isdn_timer_ctrl(int tf, int onoff); extern int isdn_getnum(char **); extern int isdn_msncmp( const char *, const char *); -extern int isdn_add_channels(driver *, int, int, int); #if defined(ISDN_DEBUG_NET_DUMP) || defined(ISDN_DEBUG_MODEM_DUMP) extern void isdn_dumppkt(char *, u_char *, int, int); #else @@ -99,3 +98,9 @@ extern void isdn_slot_set_m_idx(int slot, int midx); extern void isdn_slot_set_priv(int sl, void *); extern void *isdn_slot_priv(int sl); extern int isdn_hard_header_len(void); + +int isdn_drv_queue_empty(int di, int ch); +void isdn_drv_queue_tail(int di, int ch, struct sk_buff *skb, int len); +int isdn_drv_maxbufsize(int di); +int isdn_drv_writebuf_skb(int di, int ch, int x, struct sk_buff *skb); +int isdn_drv_hdrlen(int di); diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index a565d3787e2e..8789f5e83137 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -264,7 +264,7 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb) /* Try to deliver directly via tty-flip-buf if queue is empty */ save_flags(flags); cli(); - if (skb_queue_empty(&dev->drv[di]->rpqueue[channel])) + if (isdn_drv_queue_empty(di, channel)) if (isdn_tty_try_read(info, skb)) { restore_flags(flags); return 1; @@ -272,13 +272,11 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb) /* Direct deliver failed or queue wasn't empty. * Queue up for later dequeueing via timer-irq. */ - __skb_queue_tail(&dev->drv[di]->rpqueue[channel], skb); - dev->drv[di]->rcvcount[channel] += - (skb->len + isdn_drv_queue_tail(di, channel, skb, skb->len #ifdef CONFIG_ISDN_AUDIO + ISDN_AUDIO_SKB_DLECOUNT(skb) #endif - ); + ); restore_flags(flags); /* Schedule dequeuing */ if ((dev->modempoll) && (info->rcvsched)) @@ -1109,8 +1107,8 @@ isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int co if (c > info->xmit_size - info->xmit_count) c = info->xmit_size - info->xmit_count; di = isdn_slot_driver(info->isdn_slot); - if (di >= 0 && c > dev->drv[di]->maxbufsize) - c = dev->drv[di]->maxbufsize; + if (di >= 0 && c > isdn_drv_maxbufsize(di)) + c = isdn_drv_maxbufsize(di); if (c <= 0) break; if ((info->online > 1) @@ -2211,7 +2209,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) } restore_flags(flags); printk(KERN_INFO "isdn_tty: call from %s -> %s %s\n", nr, eaz, - ((dev->drv[di]->flags & DRV_FLAG_REJBUS) && (wret != 2))? "rejected" : "ignored"); + (wret != 2)? "rejected" : "ignored"); return (wret == 2)?3:0; } @@ -2441,7 +2439,7 @@ isdn_tty_at_cout(char *msg, modem_info * info) /* data is in queue or flip buffer is full */ di = isdn_slot_driver(info->isdn_slot); ch = isdn_slot_channel(info->isdn_slot); if ((info->online) && (((tty->flip.count + strlen(msg)) >= TTY_FLIPBUF_SIZE) || - (!skb_queue_empty(&dev->drv[di]->rpqueue[ch])))) { + (!isdn_drv_queue_empty(di, ch)))) { skb = alloc_skb(strlen(msg) #ifdef CONFIG_ISDN_AUDIO + sizeof(isdn_audio_skb) @@ -2484,8 +2482,7 @@ isdn_tty_at_cout(char *msg, modem_info * info) } } if (skb) { - __skb_queue_tail(&dev->drv[di]->rpqueue[ch], skb); - dev->drv[di]->rcvcount[ch] += skb->len; + isdn_drv_queue_tail(di, ch, skb, skb->len); restore_flags(flags); /* Schedule dequeuing */ if ((dev->modempoll) && (info->rcvsched)) diff --git a/drivers/isdn/i4l/isdn_v110.c b/drivers/isdn/i4l/isdn_v110.c index ae4b28229904..81470cd6cfdd 100644 --- a/drivers/isdn/i4l/isdn_v110.c +++ b/drivers/isdn/i4l/isdn_v110.c @@ -13,6 +13,7 @@ #include #include "isdn_v110.h" +#include "isdn_common.h" #undef ISDN_V110_DEBUG @@ -542,7 +543,7 @@ isdn_v110_stat_callback(struct isdn_v110 *iv110, isdn_ctrl *c) else skb = isdn_v110_idle(v); if (skb) { - if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) { + if (isdn_drv_writebuf_skb(c->driver, c->arg, 1, skb) <= 0) { dev_kfree_skb(skb); break; } else { @@ -569,8 +570,8 @@ isdn_v110_stat_callback(struct isdn_v110 *iv110, isdn_ctrl *c) break; case ISDN_STAT_BCONN: if (iv110->v110emu && (iv110->v110 == NULL)) { - int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen; - int maxsize = dev->drv[c->driver]->interface->maxbufsize; + int hdrlen = isdn_drv_hdrlen(c->driver); + int maxsize = isdn_drv_maxbufsize(c->driver); atomic_inc(&iv110->v110use); switch (iv110->v110emu) { case ISDN_PROTO_L2_V11096: @@ -587,7 +588,7 @@ isdn_v110_stat_callback(struct isdn_v110 *iv110, isdn_ctrl *c) if ((v = iv110->v110)) { while (v->SyncInit) { struct sk_buff *skb = isdn_v110_sync(v); - if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) { + if (isdn_drv_writebuf_skb(c->driver, c->arg, 1, skb) <= 0) { dev_kfree_skb(skb); /* Unable to send, try later */ break; diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 8ce00dae9a84..6b0af2383fdb 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -413,30 +413,6 @@ typedef struct { char *private; } infostruct; -#define DRV_FLAG_RUNNING 1 -#define DRV_FLAG_REJBUS 2 -#define DRV_FLAG_LOADED 4 - -/* Description of hardware-level-driver */ -typedef struct { - ulong online; /* Channel-Online flags */ - ulong flags; /* Misc driver Flags */ - int locks; /* Number of locks for this driver */ - int channels; /* Number of channels */ - wait_queue_head_t st_waitq; /* Wait-Queue for status-read's */ - int maxbufsize; /* Maximum Buffersize supported */ - unsigned long pktcount; /* Until now: unused */ - int stavail; /* Chars avail on Status-device */ - isdn_if *interface; /* Interface to driver */ - int *rcverr; /* Error-counters for B-Ch.-receive */ - int *rcvcount; /* Byte-counters for B-Ch.-receive */ -#ifdef CONFIG_ISDN_AUDIO - unsigned long DLEflag; /* Flags: Insert DLE at next read */ -#endif - struct sk_buff_head *rpqueue; /* Pointers to start of Rcv-Queue */ - char msn2eaz[10][ISDN_MSNLEN]; /* Mapping-Table MSN->EAZ */ -} driver; - /* Main driver-data */ typedef struct isdn_devt { unsigned short flags; /* Bitmapped Flags: */ @@ -451,7 +427,6 @@ typedef struct isdn_devt { infostruct *infochain; /* List of open info-devs. */ wait_queue_head_t info_waitq; /* Wait-Queue for isdninfo */ struct timer_list timer; /* Misc.-function Timer */ - driver *drv[ISDN_MAX_DRIVERS]; /* Array of drivers */ char drvid[ISDN_MAX_DRIVERS][20];/* Driver-ID */ struct task_struct *profd; /* For iprofd */ modem mdm; /* tty-driver-data */ -- cgit v1.2.3 From dbc67c41077ed29cdb182ef0c12c0199434b245e Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:38:28 -0600 Subject: ISDN: Get rid of global drivers count It's useless information, we need to iterate over all potential drivers anyway, since possibly the first one has unregistered before the second, leaving a hole. --- drivers/isdn/i4l/isdn_common.c | 67 ++++++++++++++++++++++++------------------ include/linux/isdn.h | 1 - 2 files changed, 39 insertions(+), 29 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 72f54e837ef3..9ce6b2af541b 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -114,10 +114,29 @@ static void isdn_receive_skb_callback(int di, int ch, struct sk_buff *skb); static int isdn_status_callback(isdn_ctrl * c); static void set_global_features(void); +/* + * Helper keeping track of the features the drivers support + */ +static void +set_global_features(void) +{ + unsigned long flags; + int drvidx; + + dev->global_features = 0; + spin_lock_irqsave(&drivers_lock, flags); + for (drvidx = 0; drvidx < ISDN_MAX_DRIVERS; drvidx++) { + if (!drivers[drvidx]) + continue; + if (drivers[drvidx]->interface) + dev->global_features |= drivers[drvidx]->interface->features; + } + spin_unlock_irqrestore(&drivers_lock, flags); +} + /* * Register a new ISDN interface */ - int register_isdn(isdn_if *iif) { @@ -125,12 +144,6 @@ register_isdn(isdn_if *iif) unsigned long flags; int drvidx; - if (dev->drivers >= ISDN_MAX_DRIVERS) { - printk(KERN_WARNING "register_isdn: Max. %d drivers supported\n", - ISDN_MAX_DRIVERS); - goto fail; - } - drv = kmalloc(sizeof(*drv), GFP_KERNEL); if (!drv) { printk(KERN_WARNING "register_isdn: out of mem\n"); @@ -150,6 +163,9 @@ register_isdn(isdn_if *iif) if (!drivers[drvidx]) break; + if (drvidx == ISDN_MAX_DRIVERS) + goto fail_unlock; + if (!strlen(iif->id)) sprintf(iif->id, "line%d", drvidx); @@ -170,7 +186,6 @@ register_isdn(isdn_if *iif) iif->statcallb = isdn_status_callback; isdn_info_update(); - dev->drivers++; set_global_features(); return 1; @@ -200,10 +215,14 @@ static int isdn_command(isdn_ctrl *cmd); void isdn_lock_drivers(void) { + isdn_ctrl cmd; + unsigned long flags; int i; - for (i = 0; i < dev->drivers; i++) { - isdn_ctrl cmd; + spin_lock_irqsave(&drivers_lock, flags); + for (i = 0; i < ISDN_MAX_DRIVERS; i++) { + if (!drivers[i]) + continue; cmd.driver = i; cmd.arg = 0; @@ -211,6 +230,7 @@ isdn_lock_drivers(void) isdn_command(&cmd); drivers[i]->locks++; } + spin_unlock_irqrestore(&drivers_lock, flags); } void @@ -223,18 +243,24 @@ isdn_MOD_INC_USE_COUNT(void) void isdn_unlock_drivers(void) { + isdn_ctrl cmd; + unsigned long flags; int i; - for (i = 0; i < dev->drivers; i++) - if (drivers[i]->locks > 0) { - isdn_ctrl cmd; + spin_lock_irqsave(&drivers_lock, flags); + for (i = 0; i < ISDN_MAX_DRIVERS; i++) { + if (!drivers[i]) + continue; + if (drivers[i]->locks > 0) { cmd.driver = i; cmd.arg = 0; cmd.command = ISDN_CMD_UNLOCK; isdn_command(&cmd); drivers[i]->locks--; } + } + spin_unlock_irqrestore(&drivers_lock, flags); } void @@ -785,7 +811,6 @@ isdn_status_callback(isdn_ctrl * c) slot[i].usage &= ~ISDN_USAGE_DISABLED; isdn_unregister_devfs(i); } - dev->drivers--; dev->channels -= drivers[di]->channels; kfree(drivers[di]->rcverr); kfree(drivers[di]->rcvcount); @@ -1869,20 +1894,6 @@ isdn_add_channels(struct isdn_driver *d, int drvidx, int n, int adding) * Low-level-driver registration */ -static void -set_global_features(void) -{ - int drvidx; - - dev->global_features = 0; - for (drvidx = 0; drvidx < ISDN_MAX_DRIVERS; drvidx++) { - if (!drivers[drvidx]) - continue; - if (drivers[drvidx]->interface) - dev->global_features |= drivers[drvidx]->interface->features; - } -} - #if defined(CONFIG_ISDN_DIVERSION) || defined(CONFIG_ISDN_DIVERSION_MODULE) static char *map_drvname(int di) diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 6b0af2383fdb..1f71bd37a4db 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -417,7 +417,6 @@ typedef struct { typedef struct isdn_devt { unsigned short flags; /* Bitmapped Flags: */ /* */ - int drivers; /* Current number of drivers */ int channels; /* Current number of channels */ int net_verbose; /* Verbose-Flag */ int modempoll; /* Flag: tty-read active */ -- cgit v1.2.3 From 83a64b2637e4fcda267663df85986f4d47dae4fb Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:39:24 -0600 Subject: ISDN: Kill drvid[] array We know the driver ids via drivers[]->interface->id already, no need to keep them around a second time. --- drivers/isdn/i4l/isdn_common.c | 80 +++++++++++++++++++++++------------------- drivers/isdn/i4l/isdn_common.h | 12 ++++--- include/linux/isdn.h | 1 - 3 files changed, 50 insertions(+), 43 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 9ce6b2af541b..6f7b9c11ad7d 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -109,6 +109,42 @@ isdn_drv_hdrlen(int di) return drivers[di]->interface->hl_hdrlen; } +int +__isdn_drv_lookup(char *drvid) +{ + int drvidx; + + for (drvidx = 0; drvidx < ISDN_MAX_DRIVERS; drvidx++) { + if (!drivers[drvidx]) + continue; + + if (strcmp(drivers[drvidx]->interface->id, drvid) == 0) + return drvidx; + } + return -1; +} + +int +isdn_drv_lookup(char *drvid) +{ + unsigned long flags; + int drvidx; + + spin_lock_irqsave(&drivers_lock, flags); + drvidx = __isdn_drv_lookup(drvid); + spin_unlock_irqrestore(&drivers_lock, flags); + return drvidx; +} + +char *isdn_drv_drvid(int di) +{ + if (!drivers[di]) { + isdn_BUG(); + return ""; + } + return drivers[di]->interface->id; +} + static int isdn_add_channels(struct isdn_driver *, int, int, int); static void isdn_receive_skb_callback(int di, int ch, struct sk_buff *skb); static int isdn_status_callback(isdn_ctrl * c); @@ -169,11 +205,8 @@ register_isdn(isdn_if *iif) if (!strlen(iif->id)) sprintf(iif->id, "line%d", drvidx); - strcpy(dev->drvid[drvidx], iif->id); - - for (drvidx = 0; drvidx < ISDN_MAX_DRIVERS; drvidx++) - if (strcmp(iif->id, dev->drvid[drvidx]) == 0) - goto fail_unlock; + if (__isdn_drv_lookup(iif->id) >= 0) + goto fail_unlock; if (isdn_add_channels(drv, drvidx, iif->channels, 0)) goto fail_unlock; @@ -693,7 +726,7 @@ isdn_status_callback(isdn_ctrl * c) case ISDN_STAT_CAUSE: dbg_statcallb("CAUSE: %d %s\n", i, c->parm.num); printk(KERN_INFO "isdn: %s,ch%ld cause: %s\n", - dev->drvid[di], c->arg, c->parm.num); + isdn_drv_drvid(di), c->arg, c->parm.num); isdn_tty_stat_callback(i, c); if (divert_if) divert_if->stat_callback(c); @@ -819,7 +852,6 @@ isdn_status_callback(isdn_ctrl * c) kfree(drivers[di]->rpqueue); kfree(drivers[di]); drivers[di] = NULL; - dev->drvid[di][0] = '\0'; isdn_info_update(); set_global_features(); restore_flags(flags); @@ -987,7 +1019,7 @@ isdn_statstr(void) sprintf(istatbuf, "idmap:\t"); p = istatbuf + strlen(istatbuf); for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - sprintf(p, "%s ", (slot[i].di < 0) ? "-" : dev->drvid[slot[i].di]); + sprintf(p, "%s ", (slot[i].di < 0) ? "-" : isdn_drv_drvid(slot[i].di)); p = istatbuf + strlen(istatbuf); } sprintf(p, "\nchmap:\t"); @@ -1395,7 +1427,6 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) case IIOCSETBRJ: drvidx = -1; if (arg) { - int i; char *p; if (copy_from_user((char *) &iocts, (char *) arg, sizeof(isdn_ioctl_struct))) @@ -1403,12 +1434,7 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) if (strlen(iocts.drvid)) { if ((p = strchr(iocts.drvid, ','))) *p = 0; - drvidx = -1; - for (i = 0; i < ISDN_MAX_DRIVERS; i++) - if (!(strcmp(dev->drvid[i], iocts.drvid))) { - drvidx = i; - break; - } + drvidx = isdn_drv_lookup(iocts.drvid); } } if (drvidx == -1) @@ -1485,15 +1511,7 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) (char *) arg, sizeof(isdn_ioctl_struct))) return -EFAULT; - if (strlen(iocts.drvid)) { - drvidx = -1; - for (i = 0; i < ISDN_MAX_DRIVERS; i++) - if (!(strcmp(dev->drvid[i], iocts.drvid))) { - drvidx = i; - break; - } - } else - drvidx = 0; + drvidx = isdn_drv_lookup(iocts.drvid); if (drvidx == -1) return -ENODEV; if (cmd == IIOCSETMAP) { @@ -1555,21 +1573,9 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) else return -EINVAL; if (arg) { - int i; - char *p; if (copy_from_user((char *) &iocts, (char *) arg, sizeof(isdn_ioctl_struct))) return -EFAULT; - if (strlen(iocts.drvid)) { - if ((p = strchr(iocts.drvid, ','))) - *p = 0; - drvidx = -1; - for (i = 0; i < ISDN_MAX_DRIVERS; i++) - if (!(strcmp(dev->drvid[i], iocts.drvid))) { - drvidx = i; - break; - } - } else - drvidx = 0; + drvidx = isdn_drv_lookup(iocts.drvid); if (drvidx == -1) return -ENODEV; if ((ret = verify_area(VERIFY_WRITE, (void *) arg, diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h index ee9d125e592c..96aab20198f9 100644 --- a/drivers/isdn/i4l/isdn_common.h +++ b/drivers/isdn/i4l/isdn_common.h @@ -99,8 +99,10 @@ extern void isdn_slot_set_priv(int sl, void *); extern void *isdn_slot_priv(int sl); extern int isdn_hard_header_len(void); -int isdn_drv_queue_empty(int di, int ch); -void isdn_drv_queue_tail(int di, int ch, struct sk_buff *skb, int len); -int isdn_drv_maxbufsize(int di); -int isdn_drv_writebuf_skb(int di, int ch, int x, struct sk_buff *skb); -int isdn_drv_hdrlen(int di); +int isdn_drv_queue_empty(int di, int ch); +void isdn_drv_queue_tail(int di, int ch, struct sk_buff *skb, int len); +int isdn_drv_maxbufsize(int di); +int isdn_drv_writebuf_skb(int di, int ch, int x, struct sk_buff *skb); +int isdn_drv_hdrlen(int di); +int isdn_drv_lookup(char *drvid); +char *isdn_drv_drvid(int di); diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 1f71bd37a4db..ded1aad43e4c 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -426,7 +426,6 @@ typedef struct isdn_devt { infostruct *infochain; /* List of open info-devs. */ wait_queue_head_t info_waitq; /* Wait-Queue for isdninfo */ struct timer_list timer; /* Misc.-function Timer */ - char drvid[ISDN_MAX_DRIVERS][20];/* Driver-ID */ struct task_struct *profd; /* For iprofd */ modem mdm; /* tty-driver-data */ struct semaphore sem; /* serialize list access*/ -- cgit v1.2.3 From b13ad6640872702e3a244bc9a883d679663cc11d Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:42:48 -0600 Subject: ISDN: Remove ISDN_STAT_NODCH It was never used anywhere (except for debugging output). Also, fix some compiler warnings. --- drivers/isdn/i4l/isdn_common.c | 15 +-------------- drivers/isdn/i4l/isdn_common.h | 2 +- drivers/isdn/i4l/isdn_tty.c | 16 ---------------- drivers/isdn/icn/icn.c | 1 - drivers/isdn/isdnloop/isdnloop.c | 1 - include/linux/isdnif.h | 1 - 6 files changed, 2 insertions(+), 34 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 0318ecaabbbb..2b29175e03e8 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -226,7 +226,6 @@ static int slot_bconn(struct fsm_inst *fi, int pr, void *arg) { struct isdn_slot *slot = fi->userdata; - int sl = slot - slots; isdn_ctrl *ctrl = arg; fsm_change_state(fi, ST_SLOT_ACTIVE); @@ -242,7 +241,6 @@ static int slot_bhup(struct fsm_inst *fi, int pr, void *arg) { struct isdn_slot *slot = fi->userdata; - int sl = slot - slots; isdn_ctrl *ctrl = arg; fsm_change_state(fi, ST_SLOT_WAIT_DHUP); @@ -255,7 +253,6 @@ static int slot_dhup(struct fsm_inst *fi, int pr, void *arg) { struct isdn_slot *slot = fi->userdata; - int sl = slot - slots; isdn_ctrl *ctrl = arg; fsm_change_state(fi, ST_SLOT_BOUND); @@ -314,7 +311,6 @@ static int slot_bsent(struct fsm_inst *fi, int pr, void *arg) { struct isdn_slot *slot = fi->userdata; - int sl = slot - slots; isdn_ctrl *ctrl = arg; do_stat_cb(slot, ctrl); @@ -489,10 +485,10 @@ struct isdn_driver { isdn_if *interface; /* Interface to driver */ int *rcverr; /* Error-counters for B rx */ int *rcvcount; /* Byte-counters for B rx */ + struct sk_buff_head *rpqueue; #ifdef CONFIG_ISDN_AUDIO unsigned long DLEflag; /* Insert DLE at next read */ #endif - struct sk_buff_head *rpqueue; /* Pointers to rx queue */ char msn2eaz[10][ISDN_MSNLEN]; /* MSN->EAZ */ struct fsm_inst fi; } driver; @@ -1255,15 +1251,6 @@ isdn_status_callback(isdn_ctrl * c) break; #endif #if 0 // FIXME - case ISDN_STAT_NODCH: - if (i < 0) - return -1; - dbg_statcallb("NODCH: %ld\n", c->arg); - if (isdn_net_stat_callback(i, c)) - break; - if (isdn_tty_stat_callback(i, c)) - break; - break; case ISDN_STAT_DISCH: save_flags(flags); cli(); diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h index aec350c5f625..ebe6fa9492e8 100644 --- a/drivers/isdn/i4l/isdn_common.h +++ b/drivers/isdn/i4l/isdn_common.h @@ -66,7 +66,7 @@ extern int isdn_msncmp( const char *, const char *); #if defined(ISDN_DEBUG_NET_DUMP) || defined(ISDN_DEBUG_MODEM_DUMP) extern void isdn_dumppkt(char *, u_char *, int, int); #else -static inline void isdn_dumppkt(char *s, char *ss, u_char *d, int l, int m) { } +static inline void isdn_dumppkt(char *s, u_char *d, int l, int m) { } #endif struct dial_info { diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 67dfd9317b55..fa14bb2b0112 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -2349,22 +2349,6 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) return 1; } break; - case ISDN_STAT_NODCH: -#ifdef ISDN_TTY_STAT_DEBUG - printk(KERN_DEBUG "tty_STAT_NODCH ttyI%d\n", info->line); -#endif - if (TTY_IS_ACTIVE(info)) { - if (info->dialing) { - info->dialing = 0; - info->last_l2 = -1; - info->last_si = 0; - sprintf(info->last_cause, "0000"); - isdn_tty_modem_result(RESULT_NO_DIALTONE, info); - } - isdn_tty_modem_hup(info, 0); - return 1; - } - break; case ISDN_STAT_UNLOAD: #ifdef ISDN_TTY_STAT_DEBUG printk(KERN_DEBUG "tty_STAT_UNLOAD ttyI%d\n", info->line); diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c index fb1f030d9c92..ef49d7201cc2 100644 --- a/drivers/isdn/icn/icn.c +++ b/drivers/isdn/icn/icn.c @@ -424,7 +424,6 @@ static icn_stat icn_stat_table[] = {"AOC", ISDN_STAT_CINF, 6}, /* Charge-info, DSS1-type */ {"CAU", ISDN_STAT_CAUSE, 7}, /* Cause code */ {"TEI OK", ISDN_STAT_RUN, 0}, /* Card connected to wallplug */ - {"NO D-CHAN", ISDN_STAT_NODCH, 0}, /* No D-channel available */ {"E_L1: ACT FAIL", ISDN_STAT_BHUP, 8}, /* Layer-1 activation failed */ {"E_L2: DATA LIN", ISDN_STAT_BHUP, 8}, /* Layer-2 data link lost */ {"E_L1: ACTIVATION FAILED", diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c index 612c7b19c85a..48752d299e8c 100644 --- a/drivers/isdn/isdnloop/isdnloop.c +++ b/drivers/isdn/isdnloop/isdnloop.c @@ -166,7 +166,6 @@ static isdnloop_stat isdnloop_stat_table[] = {"AOC", ISDN_STAT_CINF, 6}, /* Charge-info, DSS1-type */ {"CAU", ISDN_STAT_CAUSE, 7}, /* Cause code */ {"TEI OK", ISDN_STAT_RUN, 0}, /* Card connected to wallplug */ - {"NO D-CHAN", ISDN_STAT_NODCH, 0}, /* No D-channel available */ {"E_L1: ACT FAIL", ISDN_STAT_BHUP, 8}, /* Layer-1 activation failed */ {"E_L2: DATA LIN", ISDN_STAT_BHUP, 8}, /* Layer-2 data link lost */ {"E_L1: ACTIVATION FAILED", diff --git a/include/linux/isdnif.h b/include/linux/isdnif.h index c9718d4de584..b3298c9a66d4 100644 --- a/include/linux/isdnif.h +++ b/include/linux/isdnif.h @@ -202,7 +202,6 @@ typedef struct #define ISDN_STAT_LOAD 265 /* Signal new lowlevel-driver is loaded */ #define ISDN_STAT_UNLOAD 266 /* Signal unload of lowlevel-driver */ #define ISDN_STAT_BSENT 267 /* Signal packet sent */ -#define ISDN_STAT_NODCH 268 /* Signal no D-Channel */ #define ISDN_STAT_ADDCH 269 /* Add more Channels */ #define ISDN_STAT_CAUSE 270 /* Cause-Message */ #define ISDN_STAT_ICALLW 271 /* Incoming call without B-chan waiting */ -- cgit v1.2.3 From 05abe02258c620ec16f7c7b4e18a51550fb70537 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:44:07 -0600 Subject: ISDN: Remove ISDN_STAT_L1ERR It wasn't used in any actual hardware driver, nor did it cause any action at all. --- drivers/isdn/i4l/isdn_common.c | 2 -- drivers/isdn/isdnloop/isdnloop.c | 3 --- include/linux/isdnif.h | 7 ------- 3 files changed, 12 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 2dfd2cfd11ef..157d5f70448d 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -1307,8 +1307,6 @@ isdn_status_callback(isdn_ctrl * c) restore_flags(flags); break; #endif - case ISDN_STAT_L1ERR: - break; case CAPI_PUT_MESSAGE: return(isdn_capi_rec_hl_msg(&c->parm.cmsg)); #ifdef CONFIG_ISDN_TTY_FAX diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c index 48752d299e8c..267e0e4a527b 100644 --- a/drivers/isdn/isdnloop/isdnloop.c +++ b/drivers/isdn/isdnloop/isdnloop.c @@ -71,9 +71,6 @@ isdnloop_bchan_send(isdnloop_card * card, int ch) printk(KERN_WARNING "isdnloop: no rcard, skb dropped\n"); dev_kfree_skb(skb); - cmd.command = ISDN_STAT_L1ERR; - cmd.parm.errcode = ISDN_STAT_L1ERR_SEND; - card->interface.statcallb(&cmd); }; cmd.command = ISDN_STAT_BSENT; cmd.parm.length = len; diff --git a/include/linux/isdnif.h b/include/linux/isdnif.h index b3298c9a66d4..342dd971b1b6 100644 --- a/include/linux/isdnif.h +++ b/include/linux/isdnif.h @@ -208,7 +208,6 @@ typedef struct #define ISDN_STAT_REDIR 272 /* Redir result */ #define ISDN_STAT_PROT 273 /* protocol IO specific callback */ #define ISDN_STAT_DISPLAY 274 /* deliver a received display message */ -#define ISDN_STAT_L1ERR 275 /* Signal Layer-1 Error */ #define ISDN_STAT_FAXIND 276 /* FAX indications from HL-driver */ #define ISDN_STAT_AUDIO 277 /* DTMF, DSP indications */ #define ISDN_STAT_DISCH 278 /* Disable/Enable channel usage */ @@ -219,12 +218,6 @@ typedef struct #define ISDN_AUDIO_SETDD 0 /* Set DTMF detection */ #define ISDN_AUDIO_DTMF 1 /* Rx/Tx DTMF */ -/* - * Values for errcode field - */ -#define ISDN_STAT_L1ERR_SEND 1 -#define ISDN_STAT_L1ERR_RECV 2 - /* * Values for feature-field of interface-struct. */ -- cgit v1.2.3 From 4a4833072f8cdb23905dc1225cb7aaf329715f97 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:47:51 -0600 Subject: ISDN: Remove ttyI specific from global "dev" variable ISDN still has a huge global struct called "dev", which is a mess of parts which should be private to their respective subsystem. It's supposed to die, this is another step in making that happen. --- drivers/isdn/i4l/isdn_common.c | 22 +++++++++++++--------- drivers/isdn/i4l/isdn_net_lib.c | 2 +- drivers/isdn/i4l/isdn_tty.c | 33 +++++++++++++++++---------------- drivers/isdn/i4l/isdn_tty.h | 12 ++++++++++++ include/linux/isdn.h | 12 ------------ 5 files changed, 43 insertions(+), 38 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 18d6061d5a24..a64e8a2921aa 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -356,10 +356,15 @@ slot_icall(struct fsm_inst *fi, int pr, void *arg) return 0; } +/* should become broadcast later */ static int slot_in_dhup(struct fsm_inst *fi, int pr, void *arg) { + struct isdn_slot *slot = fi->userdata; + isdn_ctrl *ctrl = arg; + fsm_change_state(fi, ST_SLOT_NULL); + do_stat_cb(slot, ctrl); return 0; } @@ -1847,14 +1852,14 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) return ret; for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - if (copy_to_user(p, dev->mdm.info[i].emu.profile, + if (copy_to_user(p, isdn_mdm.info[i].emu.profile, ISDN_MODEM_NUMREG)) return -EFAULT; p += ISDN_MODEM_NUMREG; - if (copy_to_user(p, dev->mdm.info[i].emu.pmsn, ISDN_MSNLEN)) + if (copy_to_user(p, isdn_mdm.info[i].emu.pmsn, ISDN_MSNLEN)) return -EFAULT; p += ISDN_MSNLEN; - if (copy_to_user(p, dev->mdm.info[i].emu.plmsn, ISDN_LMSNLEN)) + if (copy_to_user(p, isdn_mdm.info[i].emu.plmsn, ISDN_LMSNLEN)) return -EFAULT; p += ISDN_LMSNLEN; } @@ -1874,14 +1879,14 @@ isdn_ctrl_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) return ret; for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - if (copy_from_user(dev->mdm.info[i].emu.profile, p, + if (copy_from_user(isdn_mdm.info[i].emu.profile, p, ISDN_MODEM_NUMREG)) return -EFAULT; p += ISDN_MODEM_NUMREG; - if (copy_from_user(dev->mdm.info[i].emu.plmsn, p, ISDN_LMSNLEN)) + if (copy_from_user(isdn_mdm.info[i].emu.plmsn, p, ISDN_LMSNLEN)) return -EFAULT; p += ISDN_LMSNLEN; - if (copy_from_user(dev->mdm.info[i].emu.pmsn, p, ISDN_MSNLEN)) + if (copy_from_user(isdn_mdm.info[i].emu.pmsn, p, ISDN_MSNLEN)) return -EFAULT; p += ISDN_MSNLEN; } @@ -2403,7 +2408,6 @@ isdn_slot_command(int sl, int cmd, isdn_ctrl *ctrl) return fsm_event(&slots[sl].fi, EV_SLOT_CMD_HANGUP, ctrl); } HERE; -// return isdn_command(ctrl); return -1; } @@ -2683,8 +2687,8 @@ static int __init isdn_init(void) slots[i].ch = -1; slots[i].m_idx = -1; strcpy(isdn_slot_num(i), "???"); - init_waitqueue_head(&dev->mdm.info[i].open_wait); - init_waitqueue_head(&dev->mdm.info[i].close_wait); + init_waitqueue_head(&isdn_mdm.info[i].open_wait); + init_waitqueue_head(&isdn_mdm.info[i].close_wait); slots[i].fi.fsm = &slot_fsm; slots[i].fi.state = ST_SLOT_NULL; slots[i].fi.debug = 1; diff --git a/drivers/isdn/i4l/isdn_net_lib.c b/drivers/isdn/i4l/isdn_net_lib.c index 6b4c452c0bdc..36685d31235b 100644 --- a/drivers/isdn/i4l/isdn_net_lib.c +++ b/drivers/isdn/i4l/isdn_net_lib.c @@ -408,7 +408,7 @@ isdn_net_addif(char *name, isdn_net_local *mlp) mlp->hupflags = ISDN_INHUP; mlp->onhtime = 10; mlp->dialmax = 1; - mlp->flags = ISDN_NET_CBHUP | ISDN_NET_DM_MANUAL; + mlp->flags = ISDN_NET_CBHUP | ISDN_NET_DM_MANUAL | ISDN_NET_SECURE; mlp->cbdelay = 5 * HZ; /* Wait 5 secs before call-back */ mlp->dialtimeout = 60 * HZ;/* Wait 1 min for connection */ mlp->dialwait = 5 * HZ; /* Wait 5 sec. after failed dial */ diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 4b44a7d38871..a4c7d393e58a 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -48,6 +48,8 @@ static char *isdn_ttyname_ttyI = "ttyI"; static char *isdn_ttyname_cui = "cui"; #endif +struct isdn_modem isdn_mdm; + static int bit2si[8] = {1, 5, 7, 7, 7, 7, 7, 7}; static int si2bit[8] = @@ -126,7 +128,7 @@ isdn_tty_readmodem(void) for (i = 0; i < ISDN_MAX_CHANNELS; i++) { if ((midx = isdn_slot_m_idx(i)) >= 0) { - info = &dev->mdm.info[midx]; + info = &isdn_mdm.info[midx]; if (info->online) { r = 0; #ifdef CONFIG_ISDN_AUDIO @@ -1669,7 +1671,7 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp) line = minor(tty->device) - tty->driver.minor_start; if (line < 0 || line > ISDN_MAX_CHANNELS) return -ENODEV; - info = &dev->mdm.info[line]; + info = &isdn_mdm.info[line]; if (isdn_tty_paranoia_check(info, tty->device, "isdn_tty_open")) return -ENODEV; #ifdef ISDN_DEBUG_MODEM_OPEN @@ -1939,11 +1941,11 @@ modem_write_profile(atemu * m) int isdn_tty_init(void) { - modem *m; + struct isdn_modem *m; int i, retval; modem_info *info; - m = &dev->mdm; + m = &isdn_mdm; memset(&m->tty_modem, 0, sizeof(struct tty_driver)); m->tty_modem.magic = TTY_DRIVER_MAGIC; m->tty_modem.name = isdn_ttyname_ttyI; @@ -2049,9 +2051,9 @@ isdn_tty_init(void) #endif kfree(info->xmit_buf - 4); } - tty_unregister_driver(&dev->mdm.cua_modem); + tty_unregister_driver(&isdn_mdm.cua_modem); err_unregister_tty: - tty_unregister_driver(&dev->mdm.tty_modem); + tty_unregister_driver(&isdn_mdm.tty_modem); err: return retval; } @@ -2059,20 +2061,19 @@ isdn_tty_init(void) void isdn_tty_exit(void) { - modem *m = &dev->mdm; modem_info *info; int i; for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - info = &m->info[i]; + info = &isdn_mdm.info[i]; isdn_tty_cleanup_xmit(info); #ifdef CONFIG_ISDN_TTY_FAX kfree(info->fax); #endif kfree(info->xmit_buf - 4); } - tty_unregister_driver(&dev->mdm.cua_modem); - tty_unregister_driver(&dev->mdm.tty_modem); + tty_unregister_driver(&isdn_mdm.cua_modem); + tty_unregister_driver(&isdn_mdm.tty_modem); } /* @@ -2168,7 +2169,7 @@ isdn_tty_find_icall(int di, int ch, int sl, setup_parm *setup) save_flags(flags); cli(); for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - modem_info *info = &dev->mdm.info[i]; + modem_info *info = &isdn_mdm.info[i]; if (info->count == 0) continue; @@ -2354,7 +2355,7 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) printk(KERN_DEBUG "tty_STAT_UNLOAD ttyI%d\n", info->line); #endif for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - info = &dev->mdm.info[i]; + info = &isdn_mdm.info[i]; if (isdn_slot_driver(info->isdn_slot) == c->driver) { if (info->online) isdn_tty_modem_hup(info, 1); @@ -3905,7 +3906,7 @@ isdn_tty_modem_escape(void) for (i = 0; i < ISDN_MAX_CHANNELS; i++) if (USG_MODEM(isdn_slot_usage(i))) if ((midx = isdn_slot_m_idx(i)) >= 0) { - modem_info *info = &dev->mdm.info[midx]; + modem_info *info = &isdn_mdm.info[midx]; if (info->online) { ton = 1; if ((info->emu.pluscount == 3) && @@ -3931,7 +3932,7 @@ isdn_tty_modem_ring(void) int i; for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - modem_info *info = &dev->mdm.info[i]; + modem_info *info = &isdn_mdm.info[i]; if (info->msr & UART_MSR_RI) { ton = 1; isdn_tty_modem_result(RESULT_RING, info); @@ -3951,7 +3952,7 @@ isdn_tty_modem_xmit(void) int i; for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - modem_info *info = &dev->mdm.info[i]; + modem_info *info = &isdn_mdm.info[i]; if (info->online) { ton = 1; isdn_tty_senddown(info); @@ -3972,7 +3973,7 @@ isdn_tty_carrier_timeout(void) int i; for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - modem_info *info = &dev->mdm.info[i]; + modem_info *info = &isdn_mdm.info[i]; if (info->dialing) { if (info->emu.carrierwait++ > info->emu.mdmreg[REG_WAITC]) { info->dialing = 0; diff --git a/drivers/isdn/i4l/isdn_tty.h b/drivers/isdn/i4l/isdn_tty.h index 5b82b66fc134..48194fd4c619 100644 --- a/drivers/isdn/i4l/isdn_tty.h +++ b/drivers/isdn/i4l/isdn_tty.h @@ -117,3 +117,15 @@ extern void isdn_tty_fax_bitorder(modem_info *, struct sk_buff *); extern int isdn_tty_init(void); extern void isdn_tty_exit(void); + +struct isdn_modem { + int refcount; /* Number of opens */ + struct tty_driver tty_modem; /* tty-device */ + struct tty_driver cua_modem; /* cua-device */ + struct tty_struct *modem_table[ISDN_MAX_CHANNELS]; /* ?? copied from Orig */ + struct termios *modem_termios[ISDN_MAX_CHANNELS]; + struct termios *modem_termios_locked[ISDN_MAX_CHANNELS]; + modem_info info[ISDN_MAX_CHANNELS]; /* Private data */ +}; + +extern struct isdn_modem isdn_mdm; diff --git a/include/linux/isdn.h b/include/linux/isdn.h index ded1aad43e4c..74376a0a5e38 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -368,17 +368,6 @@ typedef struct modem_info { #define ISDN_MODEM_WINSIZE 8 -/* Description of one ISDN-tty */ -typedef struct { - int refcount; /* Number of opens */ - struct tty_driver tty_modem; /* tty-device */ - struct tty_driver cua_modem; /* cua-device */ - struct tty_struct *modem_table[ISDN_MAX_CHANNELS]; /* ?? copied from Orig */ - struct termios *modem_termios[ISDN_MAX_CHANNELS]; - struct termios *modem_termios_locked[ISDN_MAX_CHANNELS]; - modem_info info[ISDN_MAX_CHANNELS]; /* Private data */ -} modem; - /*======================= End of ISDN-tty stuff ============================*/ /*======================== Start of V.110 stuff ============================*/ @@ -427,7 +416,6 @@ typedef struct isdn_devt { wait_queue_head_t info_waitq; /* Wait-Queue for isdninfo */ struct timer_list timer; /* Misc.-function Timer */ struct task_struct *profd; /* For iprofd */ - modem mdm; /* tty-driver-data */ struct semaphore sem; /* serialize list access*/ unsigned long global_features; #ifdef CONFIG_DEVFS_FS -- cgit v1.2.3 From 620a00187ea32b497e5cf46aa73949b5ad7a4fbf Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:49:56 -0600 Subject: ISDN: Move the tty receive queue out of generic code Moving the tty receive queue into the tty-specific data in fact simplifies the common code (which doesn't need to know it at all, now), and the tty code, which can access the queue more directly. --- drivers/isdn/i4l/isdn_audio.c | 5 +- drivers/isdn/i4l/isdn_common.c | 182 +---------------------------------------- drivers/isdn/i4l/isdn_common.h | 3 - drivers/isdn/i4l/isdn_tty.c | 110 +++++++++++++++++++++++-- drivers/isdn/i4l/isdn_tty.h | 7 ++ include/linux/isdn.h | 3 + 6 files changed, 119 insertions(+), 191 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_audio.c b/drivers/isdn/i4l/isdn_audio.c index 4a4bfcd68f6b..fddfa960b0bb 100644 --- a/drivers/isdn/i4l/isdn_audio.c +++ b/drivers/isdn/i4l/isdn_audio.c @@ -14,6 +14,7 @@ #include #include "isdn_audio.h" #include "isdn_common.h" +#include "isdn_tty.h" /* * Misc. lookup-tables. @@ -564,7 +565,7 @@ isdn_audio_eval_dtmf(modem_info * info) cli(); di = isdn_slot_driver(info->isdn_slot); ch = isdn_slot_channel(info->isdn_slot); - isdn_slot_queue_tail(info->isdn_slot, skb, 2); + isdn_tty_queue_tail(info, skb, 2); restore_flags(flags); /* Schedule dequeuing */ if ((dev->modempoll) && (info->rcvsched)) @@ -683,7 +684,7 @@ isdn_audio_put_dle_code(modem_info * info, u_char code) cli(); di = isdn_slot_driver(info->isdn_slot); ch = isdn_slot_channel(info->isdn_slot); - isdn_slot_queue_tail(info->isdn_slot, skb, 2); + isdn_tty_queue_tail(info, skb, 2); restore_flags(flags); /* Schedule dequeuing */ if ((dev->modempoll) && (info->rcvsched)) diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 3383f1f341b2..8c58b98c3438 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -299,13 +299,8 @@ slot_data_req(struct fsm_inst *fi, int pr, void *arg) { struct isdn_slot *slot = fi->userdata; struct sk_buff *skb = arg; - int retval; - /* Update statistics */ -// slots[sl].ibytes += skb->len; - - retval = isdn_drv_writebuf_skb(slot->di, slot->ch, 1, skb); - return retval; + return isdn_drv_writebuf_skb(slot->di, slot->ch, 1, skb); } static int @@ -401,7 +396,6 @@ slot_unbind(struct fsm_inst *fi, int pr, void *arg) slot->iv110.v110 = NULL; // 20.10.99 JIM, try to reinitialize v110 ! isdn_slot_set_usage(sl, ISDN_USAGE_NONE); - isdn_slot_queue_purge(sl); return 0; } @@ -497,12 +491,6 @@ struct isdn_driver { int maxbufsize; /* Maximum Buffersize supported*/ int stavail; /* Chars avail on Status-device*/ isdn_if *interface; /* Interface to driver */ - int *rcverr; /* Error-counters for B rx */ - int *rcvcount; /* Byte-counters for B rx */ - struct sk_buff_head *rpqueue; -#ifdef CONFIG_ISDN_AUDIO - unsigned long DLEflag; /* Insert DLE at next read */ -#endif char msn2eaz[10][ISDN_MSNLEN]; /* MSN->EAZ */ struct fsm_inst fi; } driver; @@ -578,13 +566,6 @@ isdn_drv_lookup(char *drvid) static void drv_destroy(struct isdn_driver *drv) { - int i; - - kfree(drv->rcverr); - kfree(drv->rcvcount); - for (i = 0; i < drv->channels; i++) - skb_queue_purge(&drv->rpqueue[i]); - kfree(drv->rpqueue); kfree(drv); } @@ -1446,108 +1427,6 @@ isdn_getnum(char **p) #define DLE 0x10 -/* - * isdn_slot_readbchan() tries to get data from the read-queue. - * It MUST be called with interrupts off. - */ -int -isdn_slot_readbchan(int sl, u_char * buf, u_char * fp, int len) -{ - int count; - int count_pull; - int count_put; - int dflag; - int di = isdn_slot_driver(sl); - int ch = isdn_slot_channel(sl); - struct sk_buff *skb; - u_char *cp; - - if (!drivers[di]) - return 0; - if (skb_queue_empty(&drivers[di]->rpqueue[ch])) - return 0; - - if (len > drivers[di]->rcvcount[ch]) - len = drivers[di]->rcvcount[ch]; - cp = buf; - count = 0; - while (len) { - if (!(skb = skb_peek(&drivers[di]->rpqueue[ch]))) - break; -#ifdef CONFIG_ISDN_AUDIO - if (ISDN_AUDIO_SKB_LOCK(skb)) - break; - ISDN_AUDIO_SKB_LOCK(skb) = 1; - if ((ISDN_AUDIO_SKB_DLECOUNT(skb)) || (drivers[di]->DLEflag & (1 << ch))) { - char *p = skb->data; - unsigned long DLEmask = (1 << ch); - - dflag = 0; - count_pull = count_put = 0; - while ((count_pull < skb->len) && (len > 0)) { - len--; - if (drivers[di]->DLEflag & DLEmask) { - *cp++ = DLE; - drivers[di]->DLEflag &= ~DLEmask; - } else { - *cp++ = *p; - if (*p == DLE) { - drivers[di]->DLEflag |= DLEmask; - (ISDN_AUDIO_SKB_DLECOUNT(skb))--; - } - p++; - count_pull++; - } - count_put++; - } - if (count_pull >= skb->len) - dflag = 1; - } else { -#endif - /* No DLE's in buff, so simply copy it */ - dflag = 1; - if ((count_pull = skb->len) > len) { - count_pull = len; - dflag = 0; - } - count_put = count_pull; - memcpy(cp, skb->data, count_put); - cp += count_put; - len -= count_put; -#ifdef CONFIG_ISDN_AUDIO - } -#endif - count += count_put; - if (fp) { - memset(fp, 0, count_put); - fp += count_put; - } - if (dflag) { - /* We got all the data in this buff. - * Now we can dequeue it. - */ - if (fp) - *(fp - 1) = 0xff; -#ifdef CONFIG_ISDN_AUDIO - ISDN_AUDIO_SKB_LOCK(skb) = 0; -#endif - skb = skb_dequeue(&drivers[di]->rpqueue[ch]); - dev_kfree_skb(skb); - } else { - /* Not yet emptied this buff, so it - * must stay in the queue, for further calls - * but we pull off the data we got until now. - */ - skb_pull(skb, count_pull); -#ifdef CONFIG_ISDN_AUDIO - ISDN_AUDIO_SKB_LOCK(skb) = 0; -#endif - } - drivers[di]->rcvcount[ch] -= count_put; - } - return count; -} - static __inline int isdn_minor2drv(int minor) { @@ -2380,40 +2259,6 @@ isdn_add_channels(struct isdn_driver *d, int drvidx, int n, int adding) ISDN_MAX_CHANNELS); return -1; } - if ((adding) && (d->rcverr)) - kfree(d->rcverr); - if (!(d->rcverr = kmalloc(sizeof(int) * m, GFP_KERNEL))) { - printk(KERN_WARNING "register_isdn: Could not alloc rcverr\n"); - return -1; - } - memset((char *) d->rcverr, 0, sizeof(int) * m); - - if ((adding) && (d->rcvcount)) - kfree(d->rcvcount); - if (!(d->rcvcount = kmalloc(sizeof(int) * m, GFP_KERNEL))) { - printk(KERN_WARNING "register_isdn: Could not alloc rcvcount\n"); - if (!adding) kfree(d->rcverr); - return -1; - } - memset((char *) d->rcvcount, 0, sizeof(int) * m); - - if ((adding) && (d->rpqueue)) { - for (j = 0; j < d->channels; j++) - skb_queue_purge(&d->rpqueue[j]); - kfree(d->rpqueue); - } - if (!(d->rpqueue = kmalloc(sizeof(struct sk_buff_head) * m, GFP_KERNEL))) { - printk(KERN_WARNING "register_isdn: Could not alloc rpqueue\n"); - if (!adding) { - kfree(d->rcvcount); - kfree(d->rcverr); - } - return -1; - } - for (j = 0; j < m; j++) { - skb_queue_head_init(&d->rpqueue[j]); - } - dev->channels += n; save_flags(flags); cli(); @@ -2689,31 +2534,6 @@ isdn_slot_priv(int sl) return slots[sl].priv; } -int -isdn_slot_queue_empty(int sl) -{ - BUG_ON(sl < 0); - - return skb_queue_empty(&drivers[slots[sl].di]->rpqueue[slots[sl].ch]); -} - -void -isdn_slot_queue_tail(int sl, struct sk_buff *skb, int len) -{ - BUG_ON(sl < 0); - - __skb_queue_tail(&drivers[slots[sl].di]->rpqueue[slots[sl].ch], skb); - drivers[slots[sl].di]->rcvcount[slots[sl].ch] += len; -} - -void -isdn_slot_queue_purge(int sl) -{ - BUG_ON(sl < 0); - - skb_queue_purge(&drivers[slots[sl].di]->rpqueue[slots[sl].ch]); -} - int isdn_hard_header_len(void) { diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h index f06ccab719f2..edcf4f00d8e2 100644 --- a/drivers/isdn/i4l/isdn_common.h +++ b/drivers/isdn/i4l/isdn_common.h @@ -99,9 +99,6 @@ extern void isdn_slot_set_priv(int sl, int usage, void *priv, int (*stat_cb)(in extern void *isdn_slot_priv(int sl); extern int isdn_hard_header_len(void); -int isdn_slot_queue_empty(int sl); -void isdn_slot_queue_tail(int sl, struct sk_buff *skb, int len); -void isdn_slot_queue_purge(int sl); int isdn_drv_maxbufsize(int di); int isdn_drv_writebuf_skb(int di, int ch, int x, struct sk_buff *skb); int isdn_drv_hdrlen(int di); diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index a4c7d393e58a..3a688ba73c07 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -110,6 +110,103 @@ isdn_tty_try_read(modem_info * info, struct sk_buff *skb) return 0; } +/* + * isdn_slot_readbchan() tries to get data from the read-queue. + * It MUST be called with interrupts off. + */ +static int +isdn_tty_readbchan(struct modem_info *info, u_char * buf, u_char * fp, int len) +{ + int count; + int count_pull; + int count_put; + int dflag; + struct sk_buff *skb; + u_char *cp; + + if (skb_queue_empty(&info->rpqueue)) + return 0; + + if (len > info->rcvcount) + len = info->rcvcount; + cp = buf; + count = 0; + while (len) { + if (!(skb = skb_peek(&info->rpqueue))) + break; +#ifdef CONFIG_ISDN_AUDIO + if (ISDN_AUDIO_SKB_LOCK(skb)) + break; + ISDN_AUDIO_SKB_LOCK(skb) = 1; + if (ISDN_AUDIO_SKB_DLECOUNT(skb) || info->DLEflag) { + char *p = skb->data; + + dflag = 0; + count_pull = count_put = 0; + while ((count_pull < skb->len) && (len > 0)) { + len--; + if (info->DLEflag) { + *cp++ = DLE; + info->DLEflag = 0; + } else { + *cp++ = *p; + if (*p == DLE) { + info->DLEflag = 1; + (ISDN_AUDIO_SKB_DLECOUNT(skb))--; + } + p++; + count_pull++; + } + count_put++; + } + if (count_pull >= skb->len) + dflag = 1; + } else { +#endif + /* No DLE's in buff, so simply copy it */ + dflag = 1; + if ((count_pull = skb->len) > len) { + count_pull = len; + dflag = 0; + } + count_put = count_pull; + memcpy(cp, skb->data, count_put); + cp += count_put; + len -= count_put; +#ifdef CONFIG_ISDN_AUDIO + } +#endif + count += count_put; + if (fp) { + memset(fp, 0, count_put); + fp += count_put; + } + if (dflag) { + /* We got all the data in this buff. + * Now we can dequeue it. + */ + if (fp) + *(fp - 1) = 0xff; +#ifdef CONFIG_ISDN_AUDIO + ISDN_AUDIO_SKB_LOCK(skb) = 0; +#endif + skb = skb_dequeue(&info->rpqueue); + dev_kfree_skb(skb); + } else { + /* Not yet emptied this buff, so it + * must stay in the queue, for further calls + * but we pull off the data we got until now. + */ + skb_pull(skb, count_pull); +#ifdef CONFIG_ISDN_AUDIO + ISDN_AUDIO_SKB_LOCK(skb) = 0; +#endif + } + info->rcvcount -= count_put; + } + return count; +} + /* isdn_tty_readmodem() is called periodically from within timer-interrupt. * It tries getting received data from the receive queue an stuff it into * the tty's flip-buffer. @@ -142,7 +239,7 @@ isdn_tty_readmodem(void) if (c > 0) { save_flags(flags); cli(); - r = isdn_slot_readbchan(info->isdn_slot, + r = isdn_tty_readbchan(info, tty->flip.char_buf_ptr, tty->flip.flag_buf_ptr, c); /* CISCO AsyncPPP Hack */ @@ -263,7 +360,7 @@ isdn_tty_rcv_skb(int i, struct sk_buff *skb) /* Try to deliver directly via tty-flip-buf if queue is empty */ save_flags(flags); cli(); - if (isdn_slot_queue_empty(i)) + if (skb_queue_empty(&info->rpqueue)) if (isdn_tty_try_read(info, skb)) { restore_flags(flags); return 1; @@ -271,7 +368,7 @@ isdn_tty_rcv_skb(int i, struct sk_buff *skb) /* Direct deliver failed or queue wasn't empty. * Queue up for later dequeueing via timer-irq. */ - isdn_slot_queue_tail(i, skb, skb->len + isdn_tty_queue_tail(info, skb, skb->len #ifdef CONFIG_ISDN_AUDIO + ISDN_AUDIO_SKB_DLECOUNT(skb) #endif @@ -739,6 +836,7 @@ isdn_tty_modem_hup(modem_info * info, int local) isdn_slot_all_eaz(slot); info->emu.mdmreg[REG_RINGCNT] = 0; + skb_queue_purge(&info->rpqueue); isdn_slot_free(slot); isdn_slot_set_priv(slot, 0, NULL, NULL, NULL); info->isdn_slot = -1; @@ -2025,6 +2123,7 @@ isdn_tty_init(void) init_waitqueue_head(&info->open_wait); init_waitqueue_head(&info->close_wait); info->isdn_slot = -1; + skb_queue_head_init(&info->rpqueue); info->xmit_size = ISDN_SERIAL_XMIT_SIZE; skb_queue_head_init(&info->xmit_queue); #ifdef CONFIG_ISDN_AUDIO @@ -2067,6 +2166,7 @@ isdn_tty_exit(void) for (i = 0; i < ISDN_MAX_CHANNELS; i++) { info = &isdn_mdm.info[i]; isdn_tty_cleanup_xmit(info); + skb_queue_purge(&info->rpqueue); #ifdef CONFIG_ISDN_TTY_FAX kfree(info->fax); #endif @@ -2430,7 +2530,7 @@ isdn_tty_at_cout(char *msg, modem_info * info) di = -1; ch = -1; } if ((info->online) && (((tty->flip.count + strlen(msg)) >= TTY_FLIPBUF_SIZE) || - (!isdn_slot_queue_empty(info->isdn_slot)))) { + (!skb_queue_empty(&info->rpqueue)))) { skb = alloc_skb(strlen(msg) #ifdef CONFIG_ISDN_AUDIO + sizeof(isdn_audio_skb) @@ -2473,7 +2573,7 @@ isdn_tty_at_cout(char *msg, modem_info * info) } } if (skb) { - isdn_slot_queue_tail(info->isdn_slot, skb, skb->len); + isdn_tty_queue_tail(info, skb, skb->len); restore_flags(flags); /* Schedule dequeuing */ if ((dev->modempoll) && (info->rcvsched)) diff --git a/drivers/isdn/i4l/isdn_tty.h b/drivers/isdn/i4l/isdn_tty.h index 48194fd4c619..96c14d1765e0 100644 --- a/drivers/isdn/i4l/isdn_tty.h +++ b/drivers/isdn/i4l/isdn_tty.h @@ -129,3 +129,10 @@ struct isdn_modem { }; extern struct isdn_modem isdn_mdm; + +static inline void +isdn_tty_queue_tail(modem_info *info, struct sk_buff *skb, int len) +{ + __skb_queue_tail(&info->rpqueue, skb); + info->rcvcount += len; +} diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 74376a0a5e38..4ab5ac856cc9 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -328,6 +328,8 @@ typedef struct modem_info { int dialing; /* Dial in progress or ATA */ int rcvsched; /* Receive needs schedule */ int isdn_slot; /* Index to isdn-driver/channel */ + struct sk_buff_head rpqueue; /* Queue of recv'd packets */ + int rcvcount; /* Byte-counters for B rx */ int ncarrier; /* Flag: schedule NO CARRIER */ unsigned char last_cause[8]; /* Last cause message */ unsigned char last_num[ISDN_MSNLEN]; @@ -344,6 +346,7 @@ typedef struct modem_info { struct sk_buff_head xmit_queue; /* transmit queue */ atomic_t xmit_lock; /* Semaphore for isdn_tty_write */ #ifdef CONFIG_ISDN_AUDIO + unsigned long DLEflag; /* Insert DLE at next read */ int vonline; /* Voice-channel status */ /* Bit 0 = recording */ /* Bit 1 = playback */ -- cgit v1.2.3 From b6b5803ff9b3dbad981deb6092cbea890bc64cb7 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:56:02 -0600 Subject: ISDN: Pass around struct isdn_slot directly The common way in the kernel is to pass around the struct (e.g. struct net_device), and leave the user the possibility to add its private data using ::priv, so do it the same way when accessing an ISDN channel. --- drivers/isdn/i4l/isdn_common.c | 138 ++++++++++------------------------------ drivers/isdn/i4l/isdn_common.h | 45 ++++++++----- drivers/isdn/i4l/isdn_net_lib.c | 96 ++++++++++++++-------------- drivers/isdn/i4l/isdn_net_lib.h | 6 +- drivers/isdn/i4l/isdn_tty.c | 96 +++++++++++++++------------- drivers/isdn/i4l/isdn_tty.h | 2 +- drivers/isdn/i4l/isdn_ttyfax.c | 23 +++---- drivers/isdn/i4l/isdn_v110.c | 14 ++-- drivers/isdn/i4l/isdn_v110.h | 6 +- include/linux/isdn.h | 2 +- 10 files changed, 190 insertions(+), 238 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 941d75df098a..3a2f833798f0 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -26,7 +26,6 @@ #include "isdn_audio.h" #endif #include -#include "isdn_v110.h" #include MODULE_DESCRIPTION("ISDN4Linux: link layer"); @@ -57,22 +56,6 @@ static char *slot_st_str[] = { "ST_SLOT_WAIT_DHUP", }; -struct isdn_slot { - int di; /* driver index */ - struct isdn_driver *drv; /* driver */ - int ch; /* channel index (per driver) */ - int usage; /* how is it used */ - char num[ISDN_MSNLEN]; /* the current phone number */ - unsigned long ibytes; /* Statistics incoming bytes */ - unsigned long obytes; /* Statistics outgoing bytes */ - struct isdn_v110 iv110; /* For V.110 */ - int m_idx; /* Index for mdm.... */ - void *priv; /* pointer to isdn_net_dev */ - int (*event_cb)(int sl, int pr, void *arg); - struct fsm_inst fi; -}; - - static char *ev_str[] = { "EV_DRV_REGISTER", "EV_STAT_RUN", @@ -117,10 +100,8 @@ static int isdn_v110_data_req(struct isdn_slot *slot, struct sk_buff *skb); static inline int do_event_cb(struct isdn_slot *slot, int pr, void *arg) { - int sl = slot - slots; - if (slot->event_cb) - return slot->event_cb(sl, pr, arg); + return slot->event_cb(slot, pr, arg); return -ENXIO; } @@ -304,7 +285,6 @@ slot_icall(struct fsm_inst *fi, int pr, void *arg) { struct isdn_slot *slot = fi->userdata; isdn_ctrl *ctrl = arg; - int sl = slot - slots; int retval; fsm_change_state(fi, ST_SLOT_IN); @@ -314,15 +294,13 @@ slot_icall(struct fsm_inst *fi, int pr, void *arg) strcpy(slot->num, ctrl->parm.setup.phone); /* Try to find a network-interface which will accept incoming call */ - retval = isdn_net_find_icall(ctrl->driver, ctrl->arg, sl, - &ctrl->parm.setup); + retval = isdn_net_find_icall(slot, &ctrl->parm.setup); /* already taken by net now? */ if (fi->state != ST_SLOT_IN) goto out; - retval = isdn_tty_find_icall(ctrl->driver, ctrl->arg, sl, - &ctrl->parm.setup); + retval = isdn_tty_find_icall(slot, &ctrl->parm.setup); out: return 0; } @@ -342,12 +320,11 @@ static int slot_unbind(struct fsm_inst *fi, int pr, void *arg) { struct isdn_slot *slot = fi->userdata; - int sl = slot - slots; isdn_ctrl cmd; strcpy(slot->num, "???"); cmd.parm.num[0] = '\0'; - isdn_slot_command(sl, ISDN_CMD_SETEAZ, &cmd); + isdn_slot_command(slot, ISDN_CMD_SETEAZ, &cmd); slot->ibytes = 0; slot->obytes = 0; slot->usage = ISDN_USAGE_NONE; @@ -1990,7 +1967,7 @@ isdn_map_eaz2msn(char *msn, int di) * Find an unused ISDN-channel, whose feature-flags match the * given L2- and L3-protocols. */ -int +struct isdn_slot * isdn_get_free_slot(int usage, int l2_proto, int l3_proto, int pre_dev, int pre_chan, char *msn) { @@ -2029,32 +2006,28 @@ isdn_get_free_slot(int usage, int l2_proto, int l3_proto, slot->usage = usage; isdn_info_update(); fsm_event(&slot->fi, EV_SLOT_BIND, NULL); - return i; + return slot; } } restore_flags(flags); - return -1; + return NULL; } /* * Set state of ISDN-channel to 'unused' */ void -isdn_slot_free(int sl) +isdn_slot_free(struct isdn_slot *slot) { - fsm_event(&slots[sl].fi, EV_SLOT_UNBIND, NULL); + fsm_event(&slot->fi, EV_SLOT_UNBIND, NULL); } /* * Return: length of data on success, -ERRcode on failure. */ int -isdn_slot_write(int sl, struct sk_buff *skb) +isdn_slot_write(struct isdn_slot *slot, struct sk_buff *skb) { - struct isdn_slot *slot = &slots[sl]; - - BUG_ON(sl < 0); - return fsm_event(&slot->fi, EV_DATA_REQ, skb); } @@ -2157,38 +2130,26 @@ EXPORT_SYMBOL(isdn_ppp_unregister_compressor); #endif int -isdn_slot_maxbufsize(int sl) +isdn_slot_maxbufsize(struct isdn_slot *slot) { - BUG_ON(sl < 0); - - return slots[sl].drv->maxbufsize; + return slot->drv->maxbufsize; } int -isdn_slot_hdrlen(int sl) +isdn_slot_hdrlen(struct isdn_slot *slot) { - struct isdn_slot *slot = &slots[sl]; - - BUG_ON(sl < 0); - return slot->drv->interface->hl_hdrlen; } char * -isdn_slot_map_eaz2msn(int sl, char *msn) +isdn_slot_map_eaz2msn(struct isdn_slot *slot, char *msn) { - struct isdn_slot *slot = &slots[sl]; - - BUG_ON(sl < 0); - return isdn_map_eaz2msn(msn, slot->di); } int -isdn_slot_command(int sl, int cmd, isdn_ctrl *ctrl) +isdn_slot_command(struct isdn_slot *slot, int cmd, isdn_ctrl *ctrl) { - struct isdn_slot *slot = &slots[sl]; - ctrl->command = cmd; ctrl->driver = slot->di; @@ -2230,14 +2191,11 @@ isdn_slot_command(int sl, int cmd, isdn_ctrl *ctrl) } int -isdn_slot_dial(int sl, struct dial_info *dial) +isdn_slot_dial(struct isdn_slot *slot, struct dial_info *dial) { - struct isdn_slot *slot = &slots[sl]; isdn_ctrl cmd; int retval; - char *msn = isdn_slot_map_eaz2msn(sl, dial->msn); - - BUG_ON(sl < 0); + char *msn = isdn_slot_map_eaz2msn(slot, dial->msn); /* check for DOV */ if (dial->si1 == 7 && tolower(dial->phone[0]) == 'v') { /* DOV call */ @@ -2249,21 +2207,21 @@ isdn_slot_dial(int sl, struct dial_info *dial) slot->usage |= ISDN_USAGE_OUTGOING; isdn_info_update(); - retval = isdn_slot_command(sl, ISDN_CMD_CLREAZ, &cmd); + retval = isdn_slot_command(slot, ISDN_CMD_CLREAZ, &cmd); if (retval) return retval; strcpy(cmd.parm.num, msn); - retval = isdn_slot_command(sl, ISDN_CMD_SETEAZ, &cmd); + retval = isdn_slot_command(slot, ISDN_CMD_SETEAZ, &cmd); cmd.arg = dial->l2_proto << 8; cmd.parm.fax = dial->fax; - retval = isdn_slot_command(sl, ISDN_CMD_SETL2, &cmd); + retval = isdn_slot_command(slot, ISDN_CMD_SETL2, &cmd); if (retval) return retval; cmd.arg = dial->l3_proto << 8; - retval = isdn_slot_command(sl, ISDN_CMD_SETL3, &cmd); + retval = isdn_slot_command(slot, ISDN_CMD_SETL3, &cmd); if (retval) return retval; @@ -2272,12 +2230,12 @@ isdn_slot_dial(int sl, struct dial_info *dial) strcpy(cmd.parm.setup.eazmsn, msn); strcpy(cmd.parm.setup.phone, dial->phone); - printk(KERN_INFO "ISDN: slot %d: Dialing %s -> %s (SI %d/%d) (B %d/%d)\n", - sl, cmd.parm.setup.eazmsn, cmd.parm.setup.phone, + printk(KERN_INFO "ISDN: Dialing %s -> %s (SI %d/%d) (B %d/%d)\n", + cmd.parm.setup.eazmsn, cmd.parm.setup.phone, cmd.parm.setup.si1, cmd.parm.setup.si2, dial->l2_proto, dial->l3_proto); - return isdn_slot_command(sl, ISDN_CMD_DIAL, &cmd); + return isdn_slot_command(slot, ISDN_CMD_DIAL, &cmd); } int @@ -2297,39 +2255,15 @@ isdn_slot_m_idx(int sl) } void -isdn_slot_set_m_idx(int sl, int midx) +isdn_slot_set_m_idx(struct isdn_slot *slot, int midx) { - BUG_ON(sl < 0); - - slots[sl].m_idx = midx; + slot->m_idx = midx; } char * -isdn_slot_num(int sl) -{ - BUG_ON(sl < 0); - - return slots[sl].num; -} - -void -isdn_slot_set_priv(int sl, int usage, void *priv, - int (*event_cb)(int sl, int pr, void *arg)) -{ - BUG_ON(sl < 0); - - slots[sl].usage &= ISDN_USAGE_EXCLUSIVE; - slots[sl].usage |= usage; - slots[sl].priv = priv; - slots[sl].event_cb = event_cb; -} - -void * -isdn_slot_priv(int sl) +isdn_slot_num(struct isdn_slot *slot) { - BUG_ON(sl < 0); - - return slots[sl].priv; + return slot->num; } int @@ -2548,35 +2482,29 @@ isdn_v110_add_features(struct isdn_driver *drv) static void __isdn_v110_open(struct isdn_slot *slot) { - int sl = slot - slots; - if (!slot->iv110.v110emu) return; - isdn_v110_open(sl, &slot->iv110); + isdn_v110_open(slot, &slot->iv110); } static void __isdn_v110_close(struct isdn_slot *slot) { - int sl = slot - slots; - if (!slot->iv110.v110emu) return; - isdn_v110_close(sl, &slot->iv110); + isdn_v110_close(slot, &slot->iv110); } static void __isdn_v110_bsent(struct isdn_slot *slot, int pr, isdn_ctrl *c) { - int sl = slot - slots; - if (!slot->iv110.v110emu) { do_event_cb(slot, pr, c); return; } - isdn_v110_bsent(sl, &slot->iv110); + isdn_v110_bsent(slot, &slot->iv110); } /* @@ -2615,8 +2543,6 @@ isdn_v110_setl2(struct isdn_slot *slot, isdn_ctrl *cmd) static int isdn_v110_data_ind(struct isdn_slot *slot, struct sk_buff *skb) { - int sl = slot - slots; - if (!slot->iv110.v110emu) goto recv; @@ -2626,7 +2552,7 @@ isdn_v110_data_ind(struct isdn_slot *slot, struct sk_buff *skb) recv: if (slot->event_cb) - slot->event_cb(sl, EV_DATA_IND, skb); + slot->event_cb(slot, EV_DATA_IND, skb); return 0; } diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h index df087a2316b8..294c17956f39 100644 --- a/drivers/isdn/i4l/isdn_common.h +++ b/drivers/isdn/i4l/isdn_common.h @@ -10,6 +10,7 @@ */ #include +#include "isdn_v110.h" #undef ISDN_DEBUG_MODEM_OPEN #undef ISDN_DEBUG_MODEM_IOCTL @@ -68,6 +69,21 @@ extern void isdn_dumppkt(char *, u_char *, int, int); static inline void isdn_dumppkt(char *s, u_char *d, int l, int m) { } #endif +struct isdn_slot { + int di; /* driver index */ + struct isdn_driver *drv; /* driver */ + int ch; /* channel index (per driver) */ + int usage; /* how is it used */ + char num[ISDN_MSNLEN]; /* the current phone number */ + unsigned long ibytes; /* Statistics incoming bytes */ + unsigned long obytes; /* Statistics outgoing bytes */ + struct isdn_v110 iv110; /* For V.110 */ + int m_idx; /* Index for mdm.... */ + void *priv; /* pointer to isdn_net_dev */ + int (*event_cb)(struct isdn_slot *, int pr, void *arg); + struct fsm_inst fi; +}; + struct dial_info { int l2_proto; int l3_proto; @@ -78,22 +94,19 @@ struct dial_info { unsigned char *phone; }; -extern int isdn_get_free_slot(int, int, int, int, int, char *); -extern void isdn_slot_free(int slot); -extern int isdn_slot_command(int slot, int cmd, isdn_ctrl *); -extern int isdn_slot_dial(int slot, struct dial_info *dial); -extern char *isdn_slot_map_eaz2msn(int slot, char *msn); -extern int isdn_slot_write(int slot, struct sk_buff *); -extern int isdn_slot_hdrlen(int slot); -extern int isdn_slot_maxbufsize(int slot); -extern int isdn_slot_usage(int slot); -extern char *isdn_slot_num(int slot); -extern int isdn_slot_m_idx(int slot); -extern void isdn_slot_set_m_idx(int slot, int midx); -extern void isdn_slot_set_priv(int sl, int usage, void *priv, - int (*event_cb)(int sl, int pr, void *arg)); -extern void *isdn_slot_priv(int sl); -extern int isdn_hard_header_len(void); +struct isdn_slot *isdn_get_free_slot(int, int, int, int, int, char *); +void isdn_slot_free(struct isdn_slot *); +int isdn_slot_command(struct isdn_slot *, int cmd, isdn_ctrl *); +int isdn_slot_dial(struct isdn_slot *, struct dial_info *dial); +char *isdn_slot_map_eaz2msn(struct isdn_slot *, char *msn); +int isdn_slot_write(struct isdn_slot *, struct sk_buff *); +int isdn_slot_hdrlen(struct isdn_slot *); +int isdn_slot_maxbufsize(struct isdn_slot *); +char *isdn_slot_num(struct isdn_slot *); +void isdn_slot_set_m_idx(struct isdn_slot *, int midx); +int isdn_hard_header_len(void); +int isdn_slot_m_idx(int sl); +int isdn_slot_usage(int sl); int isdn_drv_lookup(char *drvid); char *isdn_drv_drvid(int di); diff --git a/drivers/isdn/i4l/isdn_net_lib.c b/drivers/isdn/i4l/isdn_net_lib.c index 22621984d4eb..78e3874c46a2 100644 --- a/drivers/isdn/i4l/isdn_net_lib.c +++ b/drivers/isdn/i4l/isdn_net_lib.c @@ -294,21 +294,21 @@ isdn_net_bind(isdn_net_dev *idev, isdn_net_ioctl_cfg *cfg) goto out; } } - if (cfg->exclusive == (idev->exclusive >= 0) && + if (cfg->exclusive == !!idev->exclusive && drvidx == idev->pre_device && chidx == idev->pre_channel) { /* no change */ retval = 0; goto out; } - if (idev->exclusive >= 0) { + if (idev->exclusive) { isdn_slot_free(idev->exclusive); - idev->exclusive = -1; + idev->exclusive = NULL; } if (cfg->exclusive) { /* If binding is exclusive, try to grab the channel */ idev->exclusive = isdn_get_free_slot(ISDN_USAGE_NET | ISDN_USAGE_EXCLUSIVE, mlp->l2_proto, mlp->l3_proto, drvidx, chidx, cfg->eaz); - if (idev->exclusive < 0) { + if (!idev->exclusive) { /* Grab failed, because desired channel is in use */ retval = -EBUSY; goto out; @@ -368,10 +368,10 @@ isdn_net_addif(char *name, isdn_net_local *mlp) tasklet_init(&idev->tlet, isdn_net_tasklet, (unsigned long) idev); skb_queue_head_init(&idev->super_tx_queue); - idev->isdn_slot = -1; + idev->isdn_slot = NULL; idev->pre_device = -1; idev->pre_channel = -1; - idev->exclusive = -1; + idev->exclusive = NULL; idev->pppbind = -1; @@ -643,7 +643,7 @@ isdn_net_getcfg(isdn_net_ioctl_cfg *cfg) mlp = idev->mlp; strcpy(cfg->eaz, mlp->msn); - cfg->exclusive = idev->exclusive >= 0; + cfg->exclusive = !!idev->exclusive; if (idev->pre_device >= 0) { sprintf(cfg->drvid, "%s,%d", isdn_drv_drvid(idev->pre_device), idev->pre_channel); @@ -853,7 +853,7 @@ static int isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone *peer) { isdn_net_dev *idev = isdn_net_findif(phone->name); - int idx; + struct isdn_slot *slot; if (!idev) return -ENODEV; @@ -863,15 +863,15 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone *peer) * in (partially) wrong number copied to user. This race * currently ignored. */ - idx = idev->isdn_slot; - if (idx < 0) + slot = idev->isdn_slot; + if (slot < 0) return -ENOTCONN; /* for pre-bound channels, we need this extra check */ - if (strncmp(isdn_slot_num(idx), "???", 3) == 0 ) + if (strncmp(isdn_slot_num(slot), "???", 3) == 0 ) return -ENOTCONN; - strncpy(phone->phone, isdn_slot_num(idx), ISDN_MSNLEN); - phone->outgoing = USG_OUTGOING(isdn_slot_usage(idx)); + strncpy(phone->phone, isdn_slot_num(slot), ISDN_MSNLEN); + phone->outgoing = USG_OUTGOING(slot->usage); if (copy_to_user(peer, phone, sizeof(*peer))) return -EFAULT; @@ -1202,14 +1202,15 @@ isdn_net_unbind_channel(isdn_net_dev *idev) if (mlp->ops->unbind) mlp->ops->unbind(idev); - isdn_slot_set_priv(idev->isdn_slot, 0, NULL, NULL); + idev->isdn_slot->priv = NULL; + idev->isdn_slot->event_cb = NULL; skb_queue_purge(&idev->super_tx_queue); if (idev->isdn_slot != idev->exclusive) isdn_slot_free(idev->isdn_slot); - idev->isdn_slot = -1; + idev->isdn_slot = NULL; if (idev->fi.state != ST_NULL) { lp_put(mlp); @@ -1217,27 +1218,29 @@ isdn_net_unbind_channel(isdn_net_dev *idev) } } -static int isdn_net_event_callback(int sl, int pr, void *arg); +static int isdn_net_event_callback(struct isdn_slot *slot, int pr, void *arg); /* * Assign an ISDN-channel to a net-interface */ static int -isdn_net_bind_channel(isdn_net_dev *idev, int slot) +isdn_net_bind_channel(isdn_net_dev *idev, struct isdn_slot *slot) { isdn_net_local *mlp = idev->mlp; int retval = 0; - idev->isdn_slot = slot; - isdn_slot_set_priv(idev->isdn_slot, ISDN_USAGE_NET, idev, - isdn_net_event_callback); - if (mlp->ops->bind) retval = mlp->ops->bind(idev); if (retval < 0) - isdn_net_unbind_channel(idev); + goto out; + idev->isdn_slot = slot; + slot->priv = idev; + slot->event_cb = isdn_net_event_callback; + slot->usage |= ISDN_USAGE_NET; + + out: return retval; } @@ -1368,7 +1371,7 @@ accept_icall(struct fsm_inst *fi, int pr, void *arg) isdn_net_dev *idev = fi->userdata; isdn_net_local *mlp = idev->mlp; isdn_ctrl cmd; - int slot = (int) arg; + struct isdn_slot *slot = arg; isdn_net_bind_channel(idev, slot); @@ -1407,8 +1410,8 @@ do_callback(struct fsm_inst *fi, int pr, void *arg) } static int -isdn_net_dev_icall(isdn_net_dev *idev, int slot, int di, int ch, int si1, - char *eaz, char *nr) +isdn_net_dev_icall(isdn_net_dev *idev, struct isdn_slot *slot, + int si1, char *eaz, char *nr) { isdn_net_local *mlp = idev->mlp; struct isdn_net_phone *ph; @@ -1438,11 +1441,11 @@ isdn_net_dev_icall(isdn_net_dev *idev, int slot, int di, int ch, int si1, } dbg_net_icall("%s: pdev=%d di=%d pch=%d ch = %d\n", idev->name, - idev->pre_device, di, idev->pre_channel, ch); + idev->pre_device, slot->di, idev->pre_channel, slot->ch); /* check if exclusive */ - if ((isdn_slot_usage(slot) & ISDN_USAGE_EXCLUSIVE) && - (idev->pre_channel != ch || idev->pre_device != di)) { + if ((slot->usage & ISDN_USAGE_EXCLUSIVE) && + (idev->pre_channel != slot->ch || idev->pre_device != slot->di)) { dbg_net_icall("%s: excl check failed\n", idev->name); return 0; } @@ -1476,7 +1479,7 @@ isdn_net_dev_icall(isdn_net_dev *idev, int slot, int di, int ch, int si1, printk(KERN_INFO "%s: call from %s -> %s accepted\n", idev->name, nr, eaz); - if (fsm_event(&idev->fi, EV_NET_DO_ACCEPT, (void *) slot)) { + if (fsm_event(&idev->fi, EV_NET_DO_ACCEPT, slot)) { lp_put(mlp); return 0; } @@ -1500,7 +1503,7 @@ isdn_net_dev_icall(isdn_net_dev *idev, int slot, int di, int ch, int si1, * would eventually match if CID was longer. */ int -isdn_net_find_icall(int di, int ch, int sl, setup_parm *setup) +isdn_net_find_icall(struct isdn_slot *slot, setup_parm *setup) { isdn_net_local *lp; isdn_net_dev *idev; @@ -1540,8 +1543,8 @@ isdn_net_find_icall(int di, int ch, int sl, setup_parm *setup) return 0; } - dbg_net_icall("n_fi: di=%d ch=%d sl=%d usg=%d\n", di, ch, sl, - isdn_slot_usage(sl)); + dbg_net_icall("n_fi: di=%d ch=%d usg=%#x\n", slot->di, slot->ch, + slot->usage); retval = 0; spin_lock_irqsave(&running_devs_lock, flags); @@ -1550,7 +1553,7 @@ isdn_net_find_icall(int di, int ch, int sl, setup_parm *setup) spin_unlock_irqrestore(&running_devs_lock, flags); list_for_each_entry(idev, &lp->slaves, slaves) { - retval = isdn_net_dev_icall(idev, sl, di, ch, si1, eaz, nr); + retval = isdn_net_dev_icall(idev, slot, si1, eaz, nr); if (retval > 0) break; } @@ -1599,7 +1602,7 @@ do_dial(struct fsm_inst *fi, int pr, void *arg) { isdn_net_dev *idev = fi->userdata; isdn_net_local *mlp = idev->mlp; - int slot; + struct isdn_slot *slot; if (ISDN_NET_DIALMODE(*mlp) == ISDN_NET_DM_OFF) return -EPERM; @@ -1607,13 +1610,13 @@ do_dial(struct fsm_inst *fi, int pr, void *arg) if (list_empty(&mlp->phone[1])) /* no number to dial ? */ return -EINVAL; - if (idev->exclusive >= 0) + if (idev->exclusive) slot = idev->exclusive; else slot = isdn_get_free_slot(ISDN_USAGE_NET, mlp->l2_proto, mlp->l3_proto, idev->pre_device, idev->pre_channel, mlp->msn); - if (slot < 0) + if (!slot) return -EAGAIN; if (isdn_net_bind_channel(idev, slot) < 0) { @@ -1856,12 +1859,12 @@ isdn_net_hangup(isdn_net_dev *idev) printk(KERN_INFO "%s: local hangup\n", idev->name); // FIXME via state machine - if (idev->isdn_slot >= 0) - isdn_slot_command(idev->isdn_slot, ISDN_CMD_HANGUP, &cmd); + if (idev->isdn_slot) + isdn_slot_command(idev->isdn_slot, ISDN_CMD_HANGUP, &cmd); return 1; } -static int isdn_net_rcv_skb(int idx, struct sk_buff *skb); +static int isdn_net_rcv_skb(struct isdn_slot *slot, struct sk_buff *skb); /* * Handle status-messages from ISDN-interfacecard. @@ -1869,16 +1872,17 @@ static int isdn_net_rcv_skb(int idx, struct sk_buff *skb); * isdn_status_callback, which itself is called from the low-level driver. */ static int -isdn_net_event_callback(int sl, int pr, void *arg) +isdn_net_event_callback(struct isdn_slot *slot, int pr, void *arg) { - isdn_net_dev *idev = isdn_slot_priv(sl); + isdn_net_dev *idev = slot->priv; - if (!idev) + if (!idev) { + isdn_BUG(); return 0; - + } switch (pr) { case EV_DATA_IND: - return isdn_net_rcv_skb(sl, arg); + return isdn_net_rcv_skb(slot, arg); case EV_STAT_DCONN: return fsm_event(&idev->fi, EV_NET_STAT_DCONN, arg); case EV_STAT_BCONN: @@ -2267,9 +2271,9 @@ isdn_net_write_super(isdn_net_dev *idev, struct sk_buff *skb) * else return 0. */ static int -isdn_net_rcv_skb(int idx, struct sk_buff *skb) +isdn_net_rcv_skb(struct isdn_slot *slot, struct sk_buff *skb) { - isdn_net_dev *idev = isdn_slot_priv(idx); + isdn_net_dev *idev = slot->priv; isdn_net_local *mlp; if (!idev) { diff --git a/drivers/isdn/i4l/isdn_net_lib.h b/drivers/isdn/i4l/isdn_net_lib.h index cd822e827d2f..0258036dc0fb 100644 --- a/drivers/isdn/i4l/isdn_net_lib.h +++ b/drivers/isdn/i4l/isdn_net_lib.h @@ -50,7 +50,7 @@ void isdn_net_lib_init(void); void isdn_net_lib_exit(void); void isdn_net_hangup_all(void); int isdn_net_ioctl(struct inode *, struct file *, uint, ulong); -int isdn_net_find_icall(int, int, int, setup_parm *); +int isdn_net_find_icall(struct isdn_slot *slot, setup_parm *setup); /* provided for interface types to use */ void isdn_net_writebuf_skb(isdn_net_dev *, struct sk_buff *skb); @@ -133,10 +133,10 @@ struct isdn_net_local_s { /* per ISDN channel (ISDN interface) data */ struct isdn_net_dev_s { - int isdn_slot; /* Index to isdn device/channel */ + struct isdn_slot *isdn_slot; /* Index to isdn device/channel */ + struct isdn_slot *exclusive; /* NULL if non excl */ int pre_device; /* Preselected isdn-device */ int pre_channel; /* Preselected isdn-channel */ - int exclusive; /* -1 if non excl./idx to excl chan */ struct timer_list dial_timer; /* dial events timer */ struct fsm_inst fi; /* call control state machine */ diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 90b7c6bf603b..3a57ba4fa2c0 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -31,20 +31,20 @@ static void isdn_tty_modem_reset_regs(modem_info *, int); static void isdn_tty_cmd_ATA(modem_info *); static void isdn_tty_flush_buffer(struct tty_struct *); static void isdn_tty_modem_result(int, modem_info *); -static int isdn_tty_stat_callback(int i, isdn_ctrl *c); -static int isdn_tty_rcv_skb(int i, struct sk_buff *skb); +static int isdn_tty_stat_callback(struct isdn_slot *slot, isdn_ctrl *c); +static int isdn_tty_rcv_skb(struct isdn_slot *slot, struct sk_buff *skb); #ifdef CONFIG_ISDN_AUDIO static int isdn_tty_countDLE(unsigned char *, int); #endif static int -isdn_tty_event_callback(int sl, int pr, void *arg) +isdn_tty_event_callback(struct isdn_slot *slot, int pr, void *arg) { switch (pr) { case EV_DATA_IND: - return isdn_tty_rcv_skb(sl, arg); + return isdn_tty_rcv_skb(slot, arg); default: - return isdn_tty_stat_callback(sl, arg); + return isdn_tty_stat_callback(slot, arg); } } @@ -281,7 +281,7 @@ isdn_tty_readmodem(void) } static int -isdn_tty_rcv_skb(int i, struct sk_buff *skb) +isdn_tty_rcv_skb(struct isdn_slot *slot, struct sk_buff *skb) { ulong flags; #ifdef CONFIG_ISDN_AUDIO @@ -289,7 +289,7 @@ isdn_tty_rcv_skb(int i, struct sk_buff *skb) #endif modem_info *info; - info = isdn_slot_priv(i); + info = slot->priv; #ifdef CONFIG_ISDN_AUDIO ifmt = 1; @@ -728,7 +728,7 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) int si = 7; int l2 = m->mdmreg[REG_L2PROT]; ulong flags; - int i; + struct isdn_slot *slot; int j; for (j = 7; j >= 0; j--) @@ -751,8 +751,8 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) m->mdmreg[REG_SI1I] = si2bit[si]; save_flags(flags); cli(); - i = isdn_get_free_slot(usg, l2, m->mdmreg[REG_L3PROT], -1, -1, m->msn); - if (i < 0) { + slot = isdn_get_free_slot(usg, l2, m->mdmreg[REG_L3PROT], -1, -1, m->msn); + if (!slot) { restore_flags(flags); isdn_tty_modem_result(RESULT_NO_DIALTONE, info); } else { @@ -765,9 +765,11 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) .phone = n, }; - info->isdn_slot = i; - isdn_slot_set_m_idx(i, info->line); - isdn_slot_set_priv(i, ISDN_USAGE_MODEM, info, isdn_tty_event_callback); + info->isdn_slot = slot; + isdn_slot_set_m_idx(slot, info->line); + slot->usage |= ISDN_USAGE_MODEM; + slot->priv = info; + slot->event_cb = isdn_tty_event_callback; info->last_dir = 1; info->last_l2 = l2; strcpy(info->last_num, n); @@ -793,13 +795,13 @@ void isdn_tty_modem_hup(modem_info * info, int local) { isdn_ctrl cmd; - int slot; + struct isdn_slot *slot; if (!info) return; slot = info->isdn_slot; - if (slot < 0) + if (!slot) return; #ifdef ISDN_DEBUG_MODEM_HUP @@ -848,9 +850,10 @@ isdn_tty_modem_hup(modem_info * info, int local) info->emu.mdmreg[REG_RINGCNT] = 0; skb_queue_purge(&info->rpqueue); + slot->priv = NULL; + slot->event_cb = NULL; isdn_slot_free(slot); - isdn_slot_set_priv(slot, 0, NULL, NULL); - info->isdn_slot = -1; + info->isdn_slot = NULL; } /* @@ -910,7 +913,7 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) int l2 = m->mdmreg[REG_L2PROT]; isdn_ctrl cmd; ulong flags; - int i; + struct isdn_slot *slot; int j; int l; @@ -935,14 +938,16 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) m->mdmreg[REG_SI1I] = si2bit[si]; save_flags(flags); cli(); - i = isdn_get_free_slot(usg, l2, m->mdmreg[REG_L3PROT], -1, -1, m->msn); - if (i < 0) { + slot = isdn_get_free_slot(usg, l2, m->mdmreg[REG_L3PROT], -1, -1, m->msn); + if (!slot) { restore_flags(flags); isdn_tty_modem_result(RESULT_NO_DIALTONE, info); } else { - info->isdn_slot = i; - isdn_slot_set_m_idx(i, info->line); - isdn_slot_set_priv(i, ISDN_USAGE_MODEM, info, isdn_tty_event_callback); + info->isdn_slot = slot; + isdn_slot_set_m_idx(slot, info->line); + slot->usage |= ISDN_USAGE_MODEM; + slot->priv = info; + slot->event_cb = isdn_tty_event_callback; info->last_dir = 1; // strcpy(info->last_num, n); restore_flags(flags); @@ -981,7 +986,7 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) int l2 = m->mdmreg[REG_L2PROT]; isdn_ctrl cmd; ulong flags; - int i; + struct isdn_slot *slot; int j; int l; @@ -1010,14 +1015,16 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) m->mdmreg[REG_SI1I] = si2bit[si]; save_flags(flags); cli(); - i = isdn_get_free_slot(usg, l2, m->mdmreg[REG_L3PROT], -1, -1, m->msn); - if (i < 0) { + slot = isdn_get_free_slot(usg, l2, m->mdmreg[REG_L3PROT], -1, -1, m->msn); + if (!slot) { restore_flags(flags); isdn_tty_modem_result(RESULT_NO_DIALTONE, info); } else { - info->isdn_slot = i; - isdn_slot_set_m_idx(i, info->line); - isdn_slot_set_priv(i, ISDN_USAGE_MODEM, info, isdn_tty_event_callback); + info->isdn_slot = slot; + isdn_slot_set_m_idx(slot, info->line); + slot->usage |= ISDN_USAGE_MODEM; + slot->priv = info; + slot->event_cb = isdn_tty_event_callback; info->last_dir = 1; restore_flags(flags); info->last_l2 = l2; @@ -1212,7 +1219,7 @@ isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int co c = count; if (c > info->xmit_size - info->xmit_count) c = info->xmit_size - info->xmit_count; - if (info->isdn_slot >= 0 && c > isdn_slot_maxbufsize(info->isdn_slot)) + if (info->isdn_slot && c > isdn_slot_maxbufsize(info->isdn_slot)) c = isdn_slot_maxbufsize(info->isdn_slot); if (c <= 0) break; @@ -2123,7 +2130,7 @@ isdn_tty_init(void) info->normal_termios = m->tty_modem.init_termios; init_waitqueue_head(&info->open_wait); init_waitqueue_head(&info->close_wait); - info->isdn_slot = -1; + info->isdn_slot = NULL; skb_queue_head_init(&info->rpqueue); info->xmit_size = ISDN_SERIAL_XMIT_SIZE; skb_queue_head_init(&info->xmit_queue); @@ -2240,7 +2247,7 @@ isdn_tty_match_icall(char *cid, atemu *emu, int di) * CID is longer. */ int -isdn_tty_find_icall(int di, int ch, int sl, setup_parm *setup) +isdn_tty_find_icall(struct isdn_slot *slot, setup_parm *setup) { char *eaz; int i; @@ -2285,17 +2292,18 @@ isdn_tty_find_icall(int di, int ch, int sl, setup_parm *setup) #ifndef FIX_FILE_TRANSFER (info->flags & ISDN_ASYNC_NORMAL_ACTIVE) && #endif - (info->isdn_slot == -1) && - (USG_NONE(isdn_slot_usage(sl)))) { + (!info->isdn_slot)) { int matchret; - if ((matchret = isdn_tty_match_icall(eaz, &info->emu, di)) > wret) + if ((matchret = isdn_tty_match_icall(eaz, &info->emu, slot->di)) > wret) wret = matchret; if (!matchret) { /* EAZ is matching */ - info->isdn_slot = sl; - isdn_slot_set_m_idx(sl, info->line); - isdn_slot_set_priv(sl, isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]), info, isdn_tty_event_callback); - strcpy(isdn_slot_num(sl), nr); + info->isdn_slot = slot; + isdn_slot_set_m_idx(slot, info->line); + slot->usage |= isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]); + slot->priv = info; + slot->event_cb = isdn_tty_event_callback; + strcpy(slot->num, nr); strcpy(info->emu.cpn, eaz); info->emu.mdmreg[REG_SI1I] = si2bit[si1]; info->emu.mdmreg[REG_PLAN] = setup->plan; @@ -2321,13 +2329,13 @@ isdn_tty_find_icall(int di, int ch, int sl, setup_parm *setup) (info->flags & (ISDN_ASYNC_NORMAL_ACTIVE | ISDN_ASYNC_CALLOUT_ACTIVE)) static int -isdn_tty_stat_callback(int i, isdn_ctrl *c) +isdn_tty_stat_callback(struct isdn_slot *slot, isdn_ctrl *c) { isdn_ctrl cmd; modem_info *info; char *e; - info = isdn_slot_priv(i); + info = slot->priv; if (1) { switch (c->command) { case ISDN_STAT_CINF: @@ -2423,14 +2431,14 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) info->last_dir = 0; info->dialing = 0; info->rcvsched = 1; - if (USG_MODEM(isdn_slot_usage(i))) { + if (USG_MODEM(slot->usage)) { if (info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) { strcpy(info->emu.connmsg, c->parm.num); isdn_tty_modem_result(RESULT_CONNECT, info); } else isdn_tty_modem_result(RESULT_CONNECT64000, info); } - if (USG_VOICE(isdn_slot_usage(i))) + if (USG_VOICE(slot->usage)) isdn_tty_modem_result(RESULT_VCON, info); return 1; } @@ -2570,7 +2578,7 @@ isdn_tty_at_cout(char *msg, modem_info * info) static void isdn_tty_on_hook(modem_info * info) { - if (info->isdn_slot >= 0) { + if (info->isdn_slot) { #ifdef ISDN_DEBUG_MODEM_HUP printk(KERN_DEBUG "Mhup in isdn_tty_on_hook\n"); #endif diff --git a/drivers/isdn/i4l/isdn_tty.h b/drivers/isdn/i4l/isdn_tty.h index 96c14d1765e0..060302c6a589 100644 --- a/drivers/isdn/i4l/isdn_tty.h +++ b/drivers/isdn/i4l/isdn_tty.h @@ -104,7 +104,7 @@ extern void isdn_tty_carrier_timeout(void); extern void isdn_tty_modem_xmit(void); extern int isdn_tty_init(void); extern void isdn_tty_readmodem(void); -extern int isdn_tty_find_icall(int, int, int, setup_parm *); +extern int isdn_tty_find_icall(struct isdn_slot *slot, setup_parm *setup); extern void isdn_tty_cleanup_xmit(modem_info *); extern int isdn_tty_capi_facility(capi_msg *cm); extern void isdn_tty_at_cout(char *, modem_info *); diff --git a/drivers/isdn/i4l/isdn_ttyfax.c b/drivers/isdn/i4l/isdn_ttyfax.c index bfe49a1400a2..35142304fdbe 100644 --- a/drivers/isdn/i4l/isdn_ttyfax.c +++ b/drivers/isdn/i4l/isdn_ttyfax.c @@ -53,7 +53,7 @@ isdn_tty_fax_modem_result(int code, modem_info * info) case 2: /* +FCON */ /* Append CPN, if enabled */ if ((m->mdmreg[REG_CPNFCON] & BIT_CPNFCON) && - (!(isdn_slot_usage(info->isdn_slot) & ISDN_USAGE_OUTGOING))) { + (!(info->isdn_slot->usage & ISDN_USAGE_OUTGOING))) { sprintf(rs, "/%s", m->cpn); isdn_tty_at_cout(rs, info); } @@ -301,7 +301,8 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info * info) static char *cmd[] = {"AE", "TS", "RS", "TM", "RM", "TH", "RH"}; isdn_ctrl c; - int par, i; + int par; + struct isdn_slot *slot; long flags; for (c.parm.aux.cmd = 0; c.parm.aux.cmd < 7; c.parm.aux.cmd++) @@ -343,7 +344,7 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info * info) printk(KERN_DEBUG "isdn_tty_cmd_FCLASS1 %d/%d/%d)\n", c.parm.aux.cmd, c.parm.aux.subcmd, c.parm.aux.para[0]); #endif - if (info->isdn_slot < 0) { + if (!info->isdn_slot) { save_flags(flags); cli(); if ((c.parm.aux.subcmd == AT_EQ_VALUE) || @@ -352,18 +353,18 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info * info) PARSE_ERROR1; } /* get a temporary connection to the first free fax driver */ - i = isdn_get_free_slot(ISDN_USAGE_FAX, ISDN_PROTO_L2_FAX, + slot = isdn_get_free_slot(ISDN_USAGE_FAX, ISDN_PROTO_L2_FAX, ISDN_PROTO_L3_FCLASS1, -1, -1, "00"); - if (i < 0) { + if (!slot) { restore_flags(flags); PARSE_ERROR1; } - info->isdn_slot = i; - isdn_slot_set_m_idx(i, info->line); - isdn_slot_command(info->isdn_slot, ISDN_CMD_FAXCMD, &c); - isdn_slot_free(info->isdn_slot); - isdn_slot_set_m_idx(i, -1); - info->isdn_slot = -1; + info->isdn_slot = slot; + isdn_slot_set_m_idx(slot, info->line); + isdn_slot_command(slot, ISDN_CMD_FAXCMD, &c); + isdn_slot_free(slot); + isdn_slot_set_m_idx(slot, -1); + info->isdn_slot = NULL; restore_flags(flags); } else { isdn_slot_command(info->isdn_slot, ISDN_CMD_FAXCMD, &c); diff --git a/drivers/isdn/i4l/isdn_v110.c b/drivers/isdn/i4l/isdn_v110.c index ed2d8f12abf8..be702981df0e 100644 --- a/drivers/isdn/i4l/isdn_v110.c +++ b/drivers/isdn/i4l/isdn_v110.c @@ -512,11 +512,11 @@ buffer_full: void -isdn_v110_open(int sl, struct isdn_v110 *iv110) +isdn_v110_open(struct isdn_slot *slot, struct isdn_v110 *iv110) { isdn_v110_stream *v; - int hdrlen = isdn_slot_hdrlen(sl); - int maxsize = isdn_slot_maxbufsize(sl); + int hdrlen = isdn_slot_hdrlen(slot); + int maxsize = isdn_slot_maxbufsize(slot); atomic_inc(&iv110->v110use); switch (iv110->v110emu) { @@ -533,7 +533,7 @@ isdn_v110_open(int sl, struct isdn_v110 *iv110) if ((v = iv110->v110)) { while (v->SyncInit) { struct sk_buff *skb = isdn_v110_sync(v); - if (isdn_slot_write(sl, skb) <= 0) { + if (isdn_slot_write(slot, skb) <= 0) { dev_kfree_skb(skb); /* Unable to send, try later */ break; @@ -547,7 +547,7 @@ isdn_v110_open(int sl, struct isdn_v110 *iv110) } void -isdn_v110_close(int sl, struct isdn_v110 *iv110) +isdn_v110_close(struct isdn_slot *slot, struct isdn_v110 *iv110) { while (1) { atomic_inc(&iv110->v110use); @@ -560,7 +560,7 @@ isdn_v110_close(int sl, struct isdn_v110 *iv110) } int -isdn_v110_bsent(int sl, struct isdn_v110 *iv110) +isdn_v110_bsent(struct isdn_slot *slot, struct isdn_v110 *iv110) { isdn_v110_stream *v = iv110->v110; int i, ret; @@ -587,7 +587,7 @@ isdn_v110_bsent(int sl, struct isdn_v110 *iv110) else skb = isdn_v110_idle(v); if (skb) { - if (isdn_slot_write(sl, skb) <= 0) { + if (isdn_slot_write(slot, skb) <= 0) { dev_kfree_skb(skb); break; } else { diff --git a/drivers/isdn/i4l/isdn_v110.h b/drivers/isdn/i4l/isdn_v110.h index 77a947481166..36b404f56f48 100644 --- a/drivers/isdn/i4l/isdn_v110.h +++ b/drivers/isdn/i4l/isdn_v110.h @@ -26,10 +26,10 @@ extern struct sk_buff *isdn_v110_encode(isdn_v110_stream *, struct sk_buff *); */ extern struct sk_buff *isdn_v110_decode(isdn_v110_stream *, struct sk_buff *); -extern void isdn_v110_open(int sl, struct isdn_v110 *iv110); +extern void isdn_v110_open(struct isdn_slot *slot, struct isdn_v110 *iv110); -extern void isdn_v110_close(int sl, struct isdn_v110 *iv110); +extern void isdn_v110_close(struct isdn_slot *slot, struct isdn_v110 *iv110); -extern int isdn_v110_bsent(int sl, struct isdn_v110 *iv110); +extern int isdn_v110_bsent(struct isdn_slot *slot, struct isdn_v110 *iv110); #endif diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 4ab5ac856cc9..c5352e5d1194 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -327,7 +327,7 @@ typedef struct modem_info { /* 2 = B-Channel is up, deliver d.*/ int dialing; /* Dial in progress or ATA */ int rcvsched; /* Receive needs schedule */ - int isdn_slot; /* Index to isdn-driver/channel */ + struct isdn_slot *isdn_slot; /* Ptr to isdn-driver/channel */ struct sk_buff_head rpqueue; /* Queue of recv'd packets */ int rcvcount; /* Byte-counters for B rx */ int ncarrier; /* Flag: schedule NO CARRIER */ -- cgit v1.2.3 From 91267c945b0f04f4089ce8749ff6d1a2c2114275 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:57:04 -0600 Subject: ISDN: New timer handling for "+++" escape sequence Instead of having one common timer and walking the list of all ISDN channels, which might be possibly associated with a ttyI and even more possibly so waiting for the silence period after "+++", just use a per ttyI timer, which only gets activated when necessary. --- drivers/isdn/i4l/isdn_common.c | 4 +- drivers/isdn/i4l/isdn_tty.c | 121 ++++++++++++++++------------------------- drivers/isdn/i4l/isdn_tty.h | 1 - include/linux/isdn.h | 5 +- 4 files changed, 50 insertions(+), 81 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 3a2f833798f0..238bd997dbde 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -1163,8 +1163,6 @@ isdn_timer_funct(ulong dummy) if (tf & ISDN_TIMER_FAST) { if (tf & ISDN_TIMER_MODEMREAD) isdn_tty_readmodem(); - if (tf & ISDN_TIMER_MODEMPLUS) - isdn_tty_modem_escape(); if (tf & ISDN_TIMER_MODEMXMIT) isdn_tty_modem_xmit(); } @@ -1983,7 +1981,7 @@ isdn_get_free_slot(int usage, int l2_proto, int l3_proto, for (i = 0; i < ISDN_MAX_CHANNELS; i++) { slot = &slots[i]; - if (drivers[slot->di]->fi.state != ST_DRV_RUNNING) + if (!slot->drv || slot->drv->fi.state != ST_DRV_RUNNING) continue; if (!USG_NONE(slots[i].usage)) diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 3a57ba4fa2c0..5635c9ff3658 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -26,7 +26,9 @@ /* Prototypes */ static int isdn_tty_edit_at(const char *, int, modem_info *, int); -static void isdn_tty_check_esc(const u_char *, u_char, int, int *, int *, int); +static void isdn_tty_escape_timer(unsigned long data); +static void isdn_tty_check_esc(struct modem_info *info, + const unsigned char *p, int count); static void isdn_tty_modem_reset_regs(modem_info *, int); static void isdn_tty_cmd_ATA(modem_info *); static void isdn_tty_flush_buffer(struct tty_struct *); @@ -1228,13 +1230,6 @@ isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int co || (info->vonline & 3) #endif ) { -#ifdef CONFIG_ISDN_AUDIO - if (!info->vonline) -#endif - isdn_tty_check_esc(buf, m->mdmreg[REG_ESC], c, - &(m->pluscount), - &(m->lastplus), - from_user); if (from_user) { if (copy_from_user(&(info->xmit_buf[info->xmit_count]), buf, c)) { total = -EFAULT; @@ -1242,6 +1237,10 @@ isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int co } } else memcpy(&(info->xmit_buf[info->xmit_count]), buf, c); +#ifdef CONFIG_ISDN_AUDIO + if (!info->vonline) +#endif + isdn_tty_check_esc(info, &info->xmit_buf[info->xmit_count], c); #ifdef CONFIG_ISDN_AUDIO if (info->vonline) { int cc = isdn_tty_handleDLEdown(info, m, c); @@ -2131,6 +2130,9 @@ isdn_tty_init(void) init_waitqueue_head(&info->open_wait); init_waitqueue_head(&info->close_wait); info->isdn_slot = NULL; + init_timer(&info->escape_timer); + info->escape_timer.data = (unsigned long) info; + info->escape_timer.function = isdn_tty_escape_timer; skb_queue_head_init(&info->rpqueue); info->xmit_size = ISDN_SERIAL_XMIT_SIZE; skb_queue_head_init(&info->xmit_queue); @@ -2595,55 +2597,56 @@ isdn_tty_off_hook(void) #define PLUSWAIT1 (HZ/2) /* 0.5 sec. */ #define PLUSWAIT2 (HZ*3/2) /* 1.5 sec */ +static void +isdn_tty_escape_timer(unsigned long data) +{ + struct modem_info *info = (struct modem_info *) data; + + if (!info->online) + return; + + info->emu.pluscount = 0; + info->online = 0; + isdn_tty_modem_result(RESULT_OK, info); +} + /* * Check Buffer for Modem-escape-sequence, activate timer-callback to * isdn_tty_modem_escape() if sequence found. - * - * Parameters: - * p pointer to databuffer - * plus escape-character - * count length of buffer - * pluscount count of valid escape-characters so far - * lastplus timestamp of last character */ -static void -isdn_tty_check_esc(const u_char * p, u_char plus, int count, int *pluscount, - int *lastplus, int from_user) +static void isdn_tty_check_esc(struct modem_info *info, + const unsigned char *p, int count) { - char cbuf[3]; + unsigned char plus = info->emu.mdmreg[REG_ESC]; if (plus > 127) return; + if (count > 3) { p += count - 3; count = 3; - *pluscount = 0; + info->emu.pluscount = 0; + info->emu.lastplus = jiffies; } - if (from_user) { - if (copy_from_user(cbuf, p, count)) - return; - p = cbuf; - } - while (count > 0) { - if (*(p++) == plus) { - if ((*pluscount)++) { - /* Time since last '+' > 0.5 sec. ? */ - if (time_after(jiffies, *lastplus + PLUSWAIT1)) - *pluscount = 1; - } else { - /* Time since last non-'+' < 1.5 sec. ? */ - if (time_before(jiffies, *lastplus + PLUSWAIT2)) - *pluscount = 0; - } - if ((*pluscount == 3) && (count == 1)) - isdn_timer_ctrl(ISDN_TIMER_MODEMPLUS, 1); - if (*pluscount > 3) - *pluscount = 1; - } else - *pluscount = 0; - *lastplus = jiffies; - count--; + for (; count > 0; info->emu.lastplus = jiffies, count--) { + if (*(p++) != plus) { + info->emu.pluscount = 0; + continue; + } + if (info->emu.pluscount == 0) { + if (time_after(jiffies, info->emu.lastplus + PLUSWAIT2)) + info->emu.pluscount = 1; + } else { + if (time_after(jiffies, info->emu.lastplus + PLUSWAIT1)) + info->emu.pluscount = 1; + else + info->emu.pluscount++; + } } + if (info->emu.pluscount == 3) + mod_timer(&info->escape_timer, jiffies + PLUSWAIT2); + else + del_timer(&info->escape_timer); } /* @@ -3977,36 +3980,6 @@ isdn_tty_edit_at(const char *p, int count, modem_info * info, int user) return total; } -/* - * Switch all modem-channels who are online and got a valid - * escape-sequence 1.5 seconds ago, to command-mode. - * This function is called every second via timer-interrupt from within - * timer-dispatcher isdn_timer_function() - */ -void -isdn_tty_modem_escape(void) -{ - int ton = 0; - int i; - int midx; - - for (i = 0; i < ISDN_MAX_CHANNELS; i++) - if (USG_MODEM(isdn_slot_usage(i))) - if ((midx = isdn_slot_m_idx(i)) >= 0) { - modem_info *info = &isdn_mdm.info[midx]; - if (info->online) { - ton = 1; - if ((info->emu.pluscount == 3) && - time_after(jiffies , info->emu.lastplus + PLUSWAIT2)) { - info->emu.pluscount = 0; - info->online = 0; - isdn_tty_modem_result(RESULT_OK, info); - } - } - } - isdn_timer_ctrl(ISDN_TIMER_MODEMPLUS, ton); -} - /* * Put a RING-message to all modem-channels who have the RI-bit set. * This function is called every second via timer-interrupt from within diff --git a/drivers/isdn/i4l/isdn_tty.h b/drivers/isdn/i4l/isdn_tty.h index 060302c6a589..d0f53375bb54 100644 --- a/drivers/isdn/i4l/isdn_tty.h +++ b/drivers/isdn/i4l/isdn_tty.h @@ -98,7 +98,6 @@ ((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \ (info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS2)) -extern void isdn_tty_modem_escape(void); extern void isdn_tty_modem_ring(void); extern void isdn_tty_carrier_timeout(void); extern void isdn_tty_modem_xmit(void); diff --git a/include/linux/isdn.h b/include/linux/isdn.h index c5352e5d1194..a9067e07e325 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -242,12 +242,10 @@ typedef struct { #define ISDN_TIMER_RINGING 5 /* tty RINGs = ISDN_TIMER_1SEC * this factor */ #define ISDN_TIMER_KEEPINT 10 /* Cisco-Keepalive = ISDN_TIMER_1SEC * this factor */ #define ISDN_TIMER_MODEMREAD 1 -#define ISDN_TIMER_MODEMPLUS 2 #define ISDN_TIMER_MODEMRING 4 #define ISDN_TIMER_MODEMXMIT 8 #define ISDN_TIMER_CARRIER 256 /* Wait for Carrier */ -#define ISDN_TIMER_FAST (ISDN_TIMER_MODEMREAD | ISDN_TIMER_MODEMPLUS | \ - ISDN_TIMER_MODEMXMIT) +#define ISDN_TIMER_FAST (ISDN_TIMER_MODEMREAD | ISDN_TIMER_MODEMXMIT) #define ISDN_TIMER_SLOW (ISDN_TIMER_MODEMRING | ISDN_TIMER_CARRIER) /* GLOBAL_FLAGS */ @@ -363,6 +361,7 @@ typedef struct modem_info { #endif struct tty_struct *tty; /* Pointer to corresponding tty */ atemu emu; /* AT-emulator data */ + struct timer_list escape_timer; /* to recognize +++ escape */ struct termios normal_termios; /* For saving termios structs */ struct termios callout_termios; wait_queue_head_t open_wait, close_wait; -- cgit v1.2.3 From 5673f7e9efafbfc8506b9b4cba5d24ee45655645 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:58:11 -0600 Subject: ISDN: New timer handling for ttyI RING response Again, use a per ttyI timer handler for RING messages, only activated when used. --- drivers/isdn/i4l/isdn_ciscohdlck.c | 2 +- drivers/isdn/i4l/isdn_common.c | 6 ------ drivers/isdn/i4l/isdn_tty.c | 34 +++++++++++++++------------------- drivers/isdn/i4l/isdn_tty.h | 1 - include/linux/isdn.h | 6 ++---- 5 files changed, 18 insertions(+), 31 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_ciscohdlck.c b/drivers/isdn/i4l/isdn_ciscohdlck.c index e2a0c7541197..f8e903aa1b3c 100644 --- a/drivers/isdn/i4l/isdn_ciscohdlck.c +++ b/drivers/isdn/i4l/isdn_ciscohdlck.c @@ -226,7 +226,7 @@ isdn_ciscohdlck_connected(isdn_net_dev *idev) cisco->myseq = 0; cisco->mineseen = 0; cisco->yourseq = 0; - cisco->keepalive_period = ISDN_TIMER_KEEPINT; + cisco->keepalive_period = 10; cisco->last_slarp_in = 0; cisco->line_state = 0; cisco->debserint = 0; diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 238bd997dbde..9c7286a012b2 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -1154,7 +1154,6 @@ isdn_dc2minor(int di, int ch) } static int isdn_timer_cnt2 = 0; -static int isdn_timer_cnt3 = 0; static void isdn_timer_funct(ulong dummy) @@ -1169,11 +1168,6 @@ isdn_timer_funct(ulong dummy) if (tf & ISDN_TIMER_SLOW) { if (++isdn_timer_cnt2 >= ISDN_TIMER_1SEC) { isdn_timer_cnt2 = 0; - if (++isdn_timer_cnt3 >= ISDN_TIMER_RINGING) { - isdn_timer_cnt3 = 0; - if (tf & ISDN_TIMER_MODEMRING) - isdn_tty_modem_ring(); - } if (tf & ISDN_TIMER_CARRIER) isdn_tty_carrier_timeout(); } diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 5635c9ff3658..9036643f351e 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -20,6 +20,7 @@ #define VBUFX (VBUF/16) #endif +#define RING_TIMEOUT (5*HZ) /* repeat RING every 5 secs */ #define FIX_FILE_TRANSFER #define DUMMY_HAYES_AT @@ -27,6 +28,7 @@ static int isdn_tty_edit_at(const char *, int, modem_info *, int); static void isdn_tty_escape_timer(unsigned long data); +static void isdn_tty_ring_timer(unsigned long data); static void isdn_tty_check_esc(struct modem_info *info, const unsigned char *p, int count); static void isdn_tty_modem_reset_regs(modem_info *, int); @@ -2133,6 +2135,9 @@ isdn_tty_init(void) init_timer(&info->escape_timer); info->escape_timer.data = (unsigned long) info; info->escape_timer.function = isdn_tty_escape_timer; + init_timer(&info->ring_timer); + info->ring_timer.data = (unsigned long) info; + info->ring_timer.function = isdn_tty_ring_timer; skb_queue_head_init(&info->rpqueue); info->xmit_size = ISDN_SERIAL_XMIT_SIZE; skb_queue_head_init(&info->xmit_queue); @@ -2315,7 +2320,7 @@ isdn_tty_find_icall(struct isdn_slot *slot, setup_parm *setup) info->line); info->msr |= UART_MSR_RI; isdn_tty_modem_result(RESULT_RING, info); - isdn_timer_ctrl(ISDN_TIMER_MODEMRING, 1); + mod_timer(&info->ring_timer, jiffies + RING_TIMEOUT); return 1; } } @@ -3980,27 +3985,18 @@ isdn_tty_edit_at(const char *p, int count, modem_info * info, int user) return total; } -/* - * Put a RING-message to all modem-channels who have the RI-bit set. - * This function is called every second via timer-interrupt from within - * timer-dispatcher isdn_timer_function() - */ -void -isdn_tty_modem_ring(void) +static void +isdn_tty_ring_timer(unsigned long data) { - int ton = 0; - int i; + struct modem_info *info = (struct modem_info *) data; - for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - modem_info *info = &isdn_mdm.info[i]; - if (info->msr & UART_MSR_RI) { - ton = 1; - isdn_tty_modem_result(RESULT_RING, info); - } - } - isdn_timer_ctrl(ISDN_TIMER_MODEMRING, ton); -} + if (!(info->msr & UART_MSR_RI)) + return; + isdn_tty_modem_result(RESULT_RING, info); + mod_timer(&info->ring_timer, jiffies + RING_TIMEOUT); +} + /* * For all online tty's, try sending data to * the lower levels. diff --git a/drivers/isdn/i4l/isdn_tty.h b/drivers/isdn/i4l/isdn_tty.h index d0f53375bb54..59638874f8ba 100644 --- a/drivers/isdn/i4l/isdn_tty.h +++ b/drivers/isdn/i4l/isdn_tty.h @@ -98,7 +98,6 @@ ((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \ (info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS2)) -extern void isdn_tty_modem_ring(void); extern void isdn_tty_carrier_timeout(void); extern void isdn_tty_modem_xmit(void); extern int isdn_tty_init(void); diff --git a/include/linux/isdn.h b/include/linux/isdn.h index a9067e07e325..25a9631d0bd5 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -239,14 +239,11 @@ typedef struct { #define ISDN_TIMER_RES 4 /* Main Timer-Resolution */ #define ISDN_TIMER_02SEC (HZ/ISDN_TIMER_RES/5) /* Slow-Timer1 .2 sec */ #define ISDN_TIMER_1SEC (HZ/ISDN_TIMER_RES) /* Slow-Timer2 1 sec */ -#define ISDN_TIMER_RINGING 5 /* tty RINGs = ISDN_TIMER_1SEC * this factor */ -#define ISDN_TIMER_KEEPINT 10 /* Cisco-Keepalive = ISDN_TIMER_1SEC * this factor */ #define ISDN_TIMER_MODEMREAD 1 -#define ISDN_TIMER_MODEMRING 4 #define ISDN_TIMER_MODEMXMIT 8 #define ISDN_TIMER_CARRIER 256 /* Wait for Carrier */ #define ISDN_TIMER_FAST (ISDN_TIMER_MODEMREAD | ISDN_TIMER_MODEMXMIT) -#define ISDN_TIMER_SLOW (ISDN_TIMER_MODEMRING | ISDN_TIMER_CARRIER) +#define ISDN_TIMER_SLOW (ISDN_TIMER_CARRIER) /* GLOBAL_FLAGS */ #define ISDN_GLOBAL_STOPPED 1 @@ -362,6 +359,7 @@ typedef struct modem_info { struct tty_struct *tty; /* Pointer to corresponding tty */ atemu emu; /* AT-emulator data */ struct timer_list escape_timer; /* to recognize +++ escape */ + struct timer_list ring_timer; /* for writing 'RING' responses */ struct termios normal_termios; /* For saving termios structs */ struct termios callout_termios; wait_queue_head_t open_wait, close_wait; -- cgit v1.2.3 From a4426b1ff253a43c99bc5eaac7325251db873237 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 08:59:40 -0600 Subject: ISDN: New timer handling for ttyI NO CARRIER response Again, use a per ttyI timer handler for NO CARRIER messages, only activated when used. --- drivers/isdn/i4l/isdn_common.c | 13 ------------- drivers/isdn/i4l/isdn_tty.c | 39 ++++++++++++++------------------------- drivers/isdn/i4l/isdn_tty.h | 1 - include/linux/isdn.h | 6 +----- 4 files changed, 15 insertions(+), 44 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 9c7286a012b2..e57624e24d56 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -1153,8 +1153,6 @@ isdn_dc2minor(int di, int ch) return -1; } -static int isdn_timer_cnt2 = 0; - static void isdn_timer_funct(ulong dummy) { @@ -1165,13 +1163,6 @@ isdn_timer_funct(ulong dummy) if (tf & ISDN_TIMER_MODEMXMIT) isdn_tty_modem_xmit(); } - if (tf & ISDN_TIMER_SLOW) { - if (++isdn_timer_cnt2 >= ISDN_TIMER_1SEC) { - isdn_timer_cnt2 = 0; - if (tf & ISDN_TIMER_CARRIER) - isdn_tty_carrier_timeout(); - } - } if (tf) { unsigned long flags; @@ -1191,10 +1182,6 @@ isdn_timer_ctrl(int tf, int onoff) save_flags(flags); cli(); - if ((tf & ISDN_TIMER_SLOW) && (!(dev->tflags & ISDN_TIMER_SLOW))) { - /* If the slow-timer wasn't activated until now */ - isdn_timer_cnt2 = 0; - } old_tflags = dev->tflags; if (onoff) dev->tflags |= tf; diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 9036643f351e..abef4ba29e18 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -29,6 +29,7 @@ static int isdn_tty_edit_at(const char *, int, modem_info *, int); static void isdn_tty_escape_timer(unsigned long data); static void isdn_tty_ring_timer(unsigned long data); +static void isdn_tty_connect_timer(unsigned long data); static void isdn_tty_check_esc(struct modem_info *info, const unsigned char *p, int count); static void isdn_tty_modem_reset_regs(modem_info *, int); @@ -785,9 +786,8 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) } #endif info->dialing = 1; - info->emu.carrierwait = 0; isdn_slot_dial(info->isdn_slot, &dial); - isdn_timer_ctrl(ISDN_TIMER_CARRIER, 1); + mod_timer(&info->connect_timer, jiffies + info->emu.mdmreg[REG_WAITC] * HZ); } } @@ -974,7 +974,7 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) // strcpy(dev->num[i], n); isdn_info_update(); isdn_slot_command(info->isdn_slot, CAPI_PUT_MESSAGE, &cmd); - isdn_timer_ctrl(ISDN_TIMER_CARRIER, 1); + mod_timer(&info->connect_timer, jiffies + info->emu.mdmreg[REG_WAITC] * HZ); } } @@ -2138,6 +2138,9 @@ isdn_tty_init(void) init_timer(&info->ring_timer); info->ring_timer.data = (unsigned long) info; info->ring_timer.function = isdn_tty_ring_timer; + init_timer(&info->connect_timer); + info->connect_timer.data = (unsigned long) info; + info->connect_timer.function = isdn_tty_connect_timer; skb_queue_head_init(&info->rpqueue); info->xmit_size = ISDN_SERIAL_XMIT_SIZE; skb_queue_head_init(&info->xmit_queue); @@ -3313,9 +3316,8 @@ isdn_tty_cmd_ATA(modem_info * info) #endif isdn_slot_command(info->isdn_slot, ISDN_CMD_SETL3, &cmd); info->dialing = 16; - info->emu.carrierwait = 0; isdn_slot_command(info->isdn_slot, ISDN_CMD_ACCEPTD, &cmd); - isdn_timer_ctrl(ISDN_TIMER_CARRIER, 1); + mod_timer(&info->connect_timer, jiffies + info->emu.mdmreg[REG_WAITC] * HZ); } else isdn_tty_modem_result(RESULT_NO_ANSWER, info); } @@ -4018,27 +4020,14 @@ isdn_tty_modem_xmit(void) isdn_timer_ctrl(ISDN_TIMER_MODEMXMIT, ton); } -/* - * Check all channels if we have a 'no carrier' timeout. - * Timeout value is set by Register S7. - */ -void -isdn_tty_carrier_timeout(void) +static void +isdn_tty_connect_timer(unsigned long data) { - int ton = 0; - int i; + struct modem_info *info = (struct modem_info *) data; - for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - modem_info *info = &isdn_mdm.info[i]; - if (info->dialing) { - if (info->emu.carrierwait++ > info->emu.mdmreg[REG_WAITC]) { - info->dialing = 0; - isdn_tty_modem_result(RESULT_NO_CARRIER, info); - isdn_tty_modem_hup(info, 1); - } - else - ton = 1; - } + if (info->dialing) { + info->dialing = 0; + isdn_tty_modem_result(RESULT_NO_CARRIER, info); + isdn_tty_modem_hup(info, 1); } - isdn_timer_ctrl(ISDN_TIMER_CARRIER, ton); } diff --git a/drivers/isdn/i4l/isdn_tty.h b/drivers/isdn/i4l/isdn_tty.h index 59638874f8ba..cd2be9c4cc5f 100644 --- a/drivers/isdn/i4l/isdn_tty.h +++ b/drivers/isdn/i4l/isdn_tty.h @@ -98,7 +98,6 @@ ((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \ (info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS2)) -extern void isdn_tty_carrier_timeout(void); extern void isdn_tty_modem_xmit(void); extern int isdn_tty_init(void); extern void isdn_tty_readmodem(void); diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 25a9631d0bd5..5f8606e00601 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -237,13 +237,9 @@ typedef struct { /* Timer-delays and scheduling-flags */ #define ISDN_TIMER_RES 4 /* Main Timer-Resolution */ -#define ISDN_TIMER_02SEC (HZ/ISDN_TIMER_RES/5) /* Slow-Timer1 .2 sec */ -#define ISDN_TIMER_1SEC (HZ/ISDN_TIMER_RES) /* Slow-Timer2 1 sec */ #define ISDN_TIMER_MODEMREAD 1 #define ISDN_TIMER_MODEMXMIT 8 -#define ISDN_TIMER_CARRIER 256 /* Wait for Carrier */ #define ISDN_TIMER_FAST (ISDN_TIMER_MODEMREAD | ISDN_TIMER_MODEMXMIT) -#define ISDN_TIMER_SLOW (ISDN_TIMER_CARRIER) /* GLOBAL_FLAGS */ #define ISDN_GLOBAL_STOPPED 1 @@ -300,7 +296,6 @@ typedef struct atemu { int mdmcmdl; /* Length of Modem-Commandbuffer */ int pluscount; /* Counter for +++ sequence */ int lastplus; /* Timestamp of last + */ - int carrierwait; /* Seconds of carrier waiting */ char mdmcmd[255]; /* Modem-Commandbuffer */ unsigned int charge; /* Charge units of current connection */ } atemu; @@ -360,6 +355,7 @@ typedef struct modem_info { atemu emu; /* AT-emulator data */ struct timer_list escape_timer; /* to recognize +++ escape */ struct timer_list ring_timer; /* for writing 'RING' responses */ + struct timer_list connect_timer; /* waiting for CONNECT */ struct termios normal_termios; /* For saving termios structs */ struct termios callout_termios; wait_queue_head_t open_wait, close_wait; -- cgit v1.2.3 From 942e661203a2cb6f6bad3df5be2ad11b6121f350 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 09:00:20 -0600 Subject: ISDN: Remove delayed ttyI xmit There's really no good reason to delay sending out data on a ttyI, ISDN is slow enough anyway ;) (There is one reason, i.e. allowing to coalesce multiple chars, but that is better fixed by having the upper levels (tty) send larger buffers) --- drivers/isdn/i4l/isdn_common.c | 2 -- drivers/isdn/i4l/isdn_tty.c | 32 ++++++++------------------------ drivers/isdn/i4l/isdn_tty.h | 1 - include/linux/isdn.h | 3 +-- 4 files changed, 9 insertions(+), 29 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index e57624e24d56..168f5ff260e1 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -1160,8 +1160,6 @@ isdn_timer_funct(ulong dummy) if (tf & ISDN_TIMER_FAST) { if (tf & ISDN_TIMER_MODEMREAD) isdn_tty_readmodem(); - if (tf & ISDN_TIMER_MODEMXMIT) - isdn_tty_modem_xmit(); } if (tf) { diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index abef4ba29e18..70f975b1349a 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -26,6 +26,7 @@ /* Prototypes */ +static void isdn_tty_modem_xmit(struct modem_info *info); static int isdn_tty_edit_at(const char *, int, modem_info *, int); static void isdn_tty_escape_timer(unsigned long data); static void isdn_tty_ring_timer(unsigned long data); @@ -1312,11 +1313,7 @@ isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int co } atomic_dec(&info->xmit_lock); if ((info->xmit_count) || (skb_queue_len(&info->xmit_queue))) { - if (m->mdmreg[REG_DXMT] & BIT_DXMT) { - isdn_tty_senddown(info); - isdn_tty_tint(info); - } - isdn_timer_ctrl(ISDN_TIMER_MODEMXMIT, 1); + isdn_tty_modem_xmit(info); } out: if (from_user) @@ -1384,7 +1381,7 @@ isdn_tty_flush_chars(struct tty_struct *tty) if (isdn_tty_paranoia_check(info, tty->device, "isdn_tty_flush_chars")) return; if ((info->xmit_count) || (skb_queue_len(&info->xmit_queue))) - isdn_timer_ctrl(ISDN_TIMER_MODEMXMIT, 1); + isdn_tty_modem_xmit(info); } /* @@ -3999,25 +3996,11 @@ isdn_tty_ring_timer(unsigned long data) mod_timer(&info->ring_timer, jiffies + RING_TIMEOUT); } -/* - * For all online tty's, try sending data to - * the lower levels. - */ -void -isdn_tty_modem_xmit(void) +static void +isdn_tty_modem_xmit(struct modem_info *info) { - int ton = 1; - int i; - - for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - modem_info *info = &isdn_mdm.info[i]; - if (info->online) { - ton = 1; - isdn_tty_senddown(info); - isdn_tty_tint(info); - } - } - isdn_timer_ctrl(ISDN_TIMER_MODEMXMIT, ton); + isdn_tty_senddown(info); + isdn_tty_tint(info); } static void @@ -4031,3 +4014,4 @@ isdn_tty_connect_timer(unsigned long data) isdn_tty_modem_hup(info, 1); } } + diff --git a/drivers/isdn/i4l/isdn_tty.h b/drivers/isdn/i4l/isdn_tty.h index cd2be9c4cc5f..3265fb9fd323 100644 --- a/drivers/isdn/i4l/isdn_tty.h +++ b/drivers/isdn/i4l/isdn_tty.h @@ -98,7 +98,6 @@ ((info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_FAX) && \ (info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS2)) -extern void isdn_tty_modem_xmit(void); extern int isdn_tty_init(void); extern void isdn_tty_readmodem(void); extern int isdn_tty_find_icall(struct isdn_slot *slot, setup_parm *setup); diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 5f8606e00601..f880d2581520 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -238,8 +238,7 @@ typedef struct { /* Timer-delays and scheduling-flags */ #define ISDN_TIMER_RES 4 /* Main Timer-Resolution */ #define ISDN_TIMER_MODEMREAD 1 -#define ISDN_TIMER_MODEMXMIT 8 -#define ISDN_TIMER_FAST (ISDN_TIMER_MODEMREAD | ISDN_TIMER_MODEMXMIT) +#define ISDN_TIMER_FAST (ISDN_TIMER_MODEMREAD) /* GLOBAL_FLAGS */ #define ISDN_GLOBAL_STOPPED 1 -- cgit v1.2.3 From e6926b1210b14eb42095de4c87c28500556a4fc9 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Tue, 29 Oct 2002 09:01:08 -0600 Subject: ISDN: New timer handling for read timer Again, use a per ttyI timer handler to feed arrived data into the ttyI. Really, there shouldn't be the need for any timer at all, rather working flow control, but that'll take a bit to fix. --- drivers/isdn/i4l/isdn_audio.c | 6 +-- drivers/isdn/i4l/isdn_common.c | 40 ----------------- drivers/isdn/i4l/isdn_common.h | 1 - drivers/isdn/i4l/isdn_tty.c | 98 ++++++++++++++++++++---------------------- drivers/isdn/i4l/isdn_tty.h | 1 - include/linux/isdn.h | 7 +-- 6 files changed, 50 insertions(+), 103 deletions(-) (limited to 'include/linux') diff --git a/drivers/isdn/i4l/isdn_audio.c b/drivers/isdn/i4l/isdn_audio.c index c4b828d13e9a..47b90e49b8d8 100644 --- a/drivers/isdn/i4l/isdn_audio.c +++ b/drivers/isdn/i4l/isdn_audio.c @@ -506,7 +506,7 @@ isdn_audio_goertzel(int *sample, modem_info * info) ((sk2 * sk2) >> AMP_BITS); } skb_queue_tail(&info->dtmf_queue, skb); - isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 1); + mod_timer(&info->read_timer, jiffies + 4); } void @@ -565,7 +565,7 @@ isdn_audio_eval_dtmf(modem_info * info) restore_flags(flags); /* Schedule dequeuing */ if ((dev->modempoll) && (info->rcvsched)) - isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 1); + mod_timer(&info->read_timer, jiffies + 4); } else kfree_skb(skb); s->last = what; @@ -680,7 +680,7 @@ isdn_audio_put_dle_code(modem_info * info, u_char code) restore_flags(flags); /* Schedule dequeuing */ if ((dev->modempoll) && (info->rcvsched)) - isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 1); + mod_timer(&info->read_timer, jiffies + 4); } void diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 168f5ff260e1..ff0f63576bb0 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -1153,43 +1153,6 @@ isdn_dc2minor(int di, int ch) return -1; } -static void -isdn_timer_funct(ulong dummy) -{ - int tf = dev->tflags; - if (tf & ISDN_TIMER_FAST) { - if (tf & ISDN_TIMER_MODEMREAD) - isdn_tty_readmodem(); - } - if (tf) - { - unsigned long flags; - - save_flags(flags); - cli(); - mod_timer(&dev->timer, jiffies+ISDN_TIMER_RES); - restore_flags(flags); - } -} - -void -isdn_timer_ctrl(int tf, int onoff) -{ - unsigned long flags; - int old_tflags; - - save_flags(flags); - cli(); - old_tflags = dev->tflags; - if (onoff) - dev->tflags |= tf; - else - dev->tflags &= ~tf; - if (dev->tflags && !old_tflags) - mod_timer(&dev->timer, jiffies+ISDN_TIMER_RES); - restore_flags(flags); -} - static int __drv_command(struct isdn_driver *drv, isdn_ctrl *c) { @@ -2366,8 +2329,6 @@ static int __init isdn_init(void) goto err_drv_fsm; } memset(dev, 0, sizeof(*dev)); - init_timer(&dev->timer); - dev->timer.function = isdn_timer_funct; init_MUTEX(&dev->sem); init_waitqueue_head(&dev->info_waitq); for (i = 0; i < ISDN_MAX_CHANNELS; i++) { @@ -2435,7 +2396,6 @@ static void __exit isdn_exit(void) isdn_tty_exit(); unregister_chrdev(ISDN_MAJOR, "isdn"); isdn_cleanup_devfs(); - del_timer_sync(&dev->timer); vfree(dev); fsm_free(&drv_fsm); fsm_free(&slot_fsm); diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h index 294c17956f39..ebed1119eb25 100644 --- a/drivers/isdn/i4l/isdn_common.h +++ b/drivers/isdn/i4l/isdn_common.h @@ -60,7 +60,6 @@ extern void isdn_unlock_drivers(void); extern void isdn_free_channel(int di, int ch, int usage); extern void isdn_info_update(void); extern char *isdn_map_eaz2msn(char *msn, int di); -extern void isdn_timer_ctrl(int tf, int onoff); extern int isdn_getnum(char **); extern int isdn_msncmp( const char *, const char *); #if defined(ISDN_DEBUG_NET_DUMP) || defined(ISDN_DEBUG_MODEM_DUMP) diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 70f975b1349a..93c9f986025d 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -229,61 +229,53 @@ isdn_tty_readbchan(struct modem_info *info, u_char * buf, u_char * fp, int len) * It tries getting received data from the receive queue an stuff it into * the tty's flip-buffer. */ -void -isdn_tty_readmodem(void) +static void +isdn_tty_readmodem(unsigned long data) { - int resched = 0; - int midx; - int i; + struct modem_info *info = (struct modem_info *) data; int c; int r; ulong flags; struct tty_struct *tty; - modem_info *info; - for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - if ((midx = isdn_slot_m_idx(i)) >= 0) { - info = &isdn_mdm.info[midx]; - if (info->online) { - r = 0; + if (!info->online) + return; + + r = 0; #ifdef CONFIG_ISDN_AUDIO - isdn_audio_eval_dtmf(info); - if ((info->vonline & 1) && (info->emu.vpar[1])) - isdn_audio_eval_silence(info); -#endif - if ((tty = info->tty)) { - if (info->mcr & UART_MCR_RTS) { - c = TTY_FLIPBUF_SIZE - tty->flip.count; - if (c > 0) { - save_flags(flags); - cli(); - r = isdn_tty_readbchan(info, - tty->flip.char_buf_ptr, - tty->flip.flag_buf_ptr, c); - /* CISCO AsyncPPP Hack */ - if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) - memset(tty->flip.flag_buf_ptr, 0, r); - tty->flip.count += r; - tty->flip.flag_buf_ptr += r; - tty->flip.char_buf_ptr += r; - if (r) - schedule_delayed_work(&tty->flip.work, 1); - restore_flags(flags); - } - } else - r = 1; - } else - r = 1; - if (r) { - info->rcvsched = 0; - resched = 1; - } else - info->rcvsched = 1; + isdn_audio_eval_dtmf(info); + if ((info->vonline & 1) && (info->emu.vpar[1])) + isdn_audio_eval_silence(info); +#endif + if ((tty = info->tty)) { + if (info->mcr & UART_MCR_RTS) { + c = TTY_FLIPBUF_SIZE - tty->flip.count; + if (c > 0) { + save_flags(flags); + cli(); + r = isdn_tty_readbchan(info, + tty->flip.char_buf_ptr, + tty->flip.flag_buf_ptr, c); + /* CISCO AsyncPPP Hack */ + if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP)) + memset(tty->flip.flag_buf_ptr, 0, r); + tty->flip.count += r; + tty->flip.flag_buf_ptr += r; + tty->flip.char_buf_ptr += r; + if (r) + schedule_delayed_work(&tty->flip.work, 1); + restore_flags(flags); } - } - } - if (!resched) - isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 0); + } else + r = 1; + } else + r = 1; + + if (r) { + info->rcvsched = 0; + mod_timer(&info->read_timer, jiffies + 4); + } else + info->rcvsched = 1; } static int @@ -393,8 +385,8 @@ isdn_tty_rcv_skb(struct isdn_slot *slot, struct sk_buff *skb) ); restore_flags(flags); /* Schedule dequeuing */ - if ((dev->modempoll) && (info->rcvsched)) - isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 1); + if (dev->modempoll && info->rcvsched) + mod_timer(&info->read_timer, jiffies + 4); return 1; } @@ -2138,6 +2130,9 @@ isdn_tty_init(void) init_timer(&info->connect_timer); info->connect_timer.data = (unsigned long) info; info->connect_timer.function = isdn_tty_connect_timer; + init_timer(&info->read_timer); + info->read_timer.data = (unsigned long) info; + info->read_timer.function = isdn_tty_readmodem; skb_queue_head_init(&info->rpqueue); info->xmit_size = ISDN_SERIAL_XMIT_SIZE; skb_queue_head_init(&info->xmit_queue); @@ -2570,9 +2565,8 @@ isdn_tty_at_cout(char *msg, modem_info * info) isdn_tty_queue_tail(info, skb, skb->len); restore_flags(flags); /* Schedule dequeuing */ - if ((dev->modempoll) && (info->rcvsched)) - isdn_timer_ctrl(ISDN_TIMER_MODEMREAD, 1); - + if (dev->modempoll && info->rcvsched) + mod_timer(&info->read_timer, jiffies + 4); } else { restore_flags(flags); schedule_delayed_work(&tty->flip.work, 1); diff --git a/drivers/isdn/i4l/isdn_tty.h b/drivers/isdn/i4l/isdn_tty.h index 3265fb9fd323..2a902f74b586 100644 --- a/drivers/isdn/i4l/isdn_tty.h +++ b/drivers/isdn/i4l/isdn_tty.h @@ -99,7 +99,6 @@ (info->emu.mdmreg[REG_L3PROT] == ISDN_PROTO_L3_FCLASS2)) extern int isdn_tty_init(void); -extern void isdn_tty_readmodem(void); extern int isdn_tty_find_icall(struct isdn_slot *slot, setup_parm *setup); extern void isdn_tty_cleanup_xmit(modem_info *); extern int isdn_tty_capi_facility(capi_msg *cm); diff --git a/include/linux/isdn.h b/include/linux/isdn.h index f880d2581520..2f429e27a007 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -235,11 +235,6 @@ typedef struct { #define USG_MODEMORVOICE(x) (((x & ISDN_USAGE_MASK)==ISDN_USAGE_MODEM) || \ ((x & ISDN_USAGE_MASK)==ISDN_USAGE_VOICE) ) -/* Timer-delays and scheduling-flags */ -#define ISDN_TIMER_RES 4 /* Main Timer-Resolution */ -#define ISDN_TIMER_MODEMREAD 1 -#define ISDN_TIMER_FAST (ISDN_TIMER_MODEMREAD) - /* GLOBAL_FLAGS */ #define ISDN_GLOBAL_STOPPED 1 @@ -355,6 +350,7 @@ typedef struct modem_info { struct timer_list escape_timer; /* to recognize +++ escape */ struct timer_list ring_timer; /* for writing 'RING' responses */ struct timer_list connect_timer; /* waiting for CONNECT */ + struct timer_list read_timer; /* read incoming data */ struct termios normal_termios; /* For saving termios structs */ struct termios callout_termios; wait_queue_head_t open_wait, close_wait; @@ -409,7 +405,6 @@ typedef struct isdn_devt { int global_flags; infostruct *infochain; /* List of open info-devs. */ wait_queue_head_t info_waitq; /* Wait-Queue for isdninfo */ - struct timer_list timer; /* Misc.-function Timer */ struct task_struct *profd; /* For iprofd */ struct semaphore sem; /* serialize list access*/ unsigned long global_features; -- cgit v1.2.3