From eae325825700cd96e8680a572168ea5270049237 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 31 Jul 2002 04:45:25 -0500 Subject: ISDN: Begin to make driver/channel mapping private to isdn_common.c --- include/linux/isdn.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 7cd0ecdd1182..cc352390f41f 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -292,8 +292,7 @@ typedef struct isdn_net_local_s { ulong magic; char name[10]; /* Name of device */ struct net_device_stats stats; /* Ethernet Statistics */ - int isdn_device; /* Index to isdn-device */ - int isdn_channel; /* Index to isdn-channel */ + int isdn_slot; /* Index to isdn device/channel */ int ppp_slot; /* PPPD device slot number */ int pre_device; /* Preselected isdn-device */ int pre_channel; /* Preselected isdn-channel */ @@ -480,8 +479,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_driver; /* Index to isdn-driver */ - int isdn_channel; /* Index to isdn-channel */ + int isdn_slot; /* Index to isdn-driver/channel */ int drv_index; /* Index to dev->usage */ int ncarrier; /* Flag: schedule NO CARRIER */ unsigned char last_cause[8]; /* Last cause message */ @@ -608,8 +606,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 */ - int chanmap[ISDN_MAX_CHANNELS];/* Map minor->device-channel */ - int drvmap[ISDN_MAX_CHANNELS]; /* Map minor->driver-index */ int usage[ISDN_MAX_CHANNELS]; /* Used by tty/ip/voice */ char num[ISDN_MAX_CHANNELS][ISDN_MSNLEN]; /* Remote number of active ch.*/ -- cgit v1.2.3 From 2ae884daef45d216b59a68c50d3674c62aa4a740 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 31 Jul 2002 04:51:22 -0500 Subject: ISDN: Remove now superfluous .drv_index from struct modem_info It's role has been taken over by .isdn_slot --- drivers/isdn/i4l/isdn_tty.c | 19 +++++-------------- drivers/isdn/i4l/isdn_ttyfax.c | 6 +----- include/linux/isdn.h | 1 - 3 files changed, 6 insertions(+), 20 deletions(-) (limited to 'include') diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 978961453c03..669ec99ea579 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -657,7 +657,6 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) isdn_tty_modem_result(RESULT_NO_DIALTONE, info); } else { info->isdn_slot = i; - info->drv_index = i; dev->m_idx[i] = info->line; dev->usage[i] |= ISDN_USAGE_OUTGOING; info->last_dir = 1; @@ -709,8 +708,6 @@ isdn_tty_modem_hup(modem_info * info, int local) if (slot < 0) return; - info->isdn_slot = -1; - #ifdef ISDN_DEBUG_MODEM_HUP printk(KERN_DEBUG "Mhup ttyI%d\n", info->line); #endif @@ -758,11 +755,8 @@ isdn_tty_modem_hup(modem_info * info, int local) isdn_slot_all_eaz(slot); info->emu.mdmreg[REG_RINGCNT] = 0; isdn_slot_free(slot, 0); - - if (info->drv_index >= 0) { - dev->m_idx[info->drv_index] = -1; - info->drv_index = -1; - } + dev->m_idx[slot] = -1; + info->isdn_slot = -1; } /* @@ -934,7 +928,6 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) isdn_tty_modem_result(RESULT_NO_DIALTONE, info); } else { info->isdn_slot = i; - info->drv_index = i; dev->m_idx[i] = info->line; dev->usage[i] |= ISDN_USAGE_OUTGOING; info->last_dir = 1; @@ -2050,7 +2043,6 @@ isdn_tty_init(void) init_waitqueue_head(&info->open_wait); init_waitqueue_head(&info->close_wait); info->isdn_slot = -1; - info->drv_index = -1; info->xmit_size = ISDN_SERIAL_XMIT_SIZE; skb_queue_head_init(&info->xmit_queue); #ifdef CONFIG_ISDN_AUDIO @@ -2221,7 +2213,6 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) wret = matchret; if (!matchret) { /* EAZ is matching */ info->isdn_slot = idx; - info->drv_index = idx; dev->m_idx[idx] = info->line; dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE; dev->usage[idx] |= isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]); @@ -2696,7 +2687,7 @@ isdn_tty_modem_result(int code, modem_info * info) /* print CID, _before_ _every_ ring */ if (!(m->mdmreg[REG_CIDONCE] & BIT_CIDONCE)) { isdn_tty_at_cout("\r\nCALLER NUMBER: ", info); - isdn_tty_at_cout(dev->num[info->drv_index], info); + isdn_tty_at_cout(dev->num[info->isdn_slot], info); if (m->mdmreg[REG_CDN] & BIT_CDN) { isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); isdn_tty_at_cout(info->emu.cpn, info); @@ -2725,7 +2716,7 @@ isdn_tty_modem_result(int code, modem_info * info) (m->mdmreg[REG_RINGCNT] == 1)) { isdn_tty_at_cout("\r\n", info); isdn_tty_at_cout("CALLER NUMBER: ", info); - isdn_tty_at_cout(dev->num[info->drv_index], info); + isdn_tty_at_cout(dev->num[info->isdn_slot], info); if (m->mdmreg[REG_CDN] & BIT_CDN) { isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); isdn_tty_at_cout(info->emu.cpn, info); @@ -3237,7 +3228,7 @@ isdn_tty_cmd_ATA(modem_info * info) if (info->msr & UART_MSR_RI) { /* Accept incoming call */ info->last_dir = 0; - strcpy(info->last_num, dev->num[info->drv_index]); + strcpy(info->last_num, dev->num[info->isdn_slot]); m->mdmreg[REG_RINGCNT] = 0; info->msr &= ~UART_MSR_RI; l2 = m->mdmreg[REG_L2PROT]; diff --git a/drivers/isdn/i4l/isdn_ttyfax.c b/drivers/isdn/i4l/isdn_ttyfax.c index 4f9e50d5b74e..1e019507d0e1 100644 --- a/drivers/isdn/i4l/isdn_ttyfax.c +++ b/drivers/isdn/i4l/isdn_ttyfax.c @@ -380,15 +380,11 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info * info) PARSE_ERROR1; } info->isdn_slot = i; - info->drv_index = i; dev->m_idx[i] = info->line; isdn_slot_command(info->isdn_slot, ISDN_CMD_FAXCMD, &c); isdn_slot_free(info->isdn_slot, ISDN_USAGE_FAX); + dev->m_idx[info->isdn_slot] = -1; info->isdn_slot = -1; - if (info->drv_index >= 0) { - dev->m_idx[info->drv_index] = -1; - info->drv_index = -1; - } restore_flags(flags); } else { isdn_slot_command(info->isdn_slot, ISDN_CMD_FAXCMD, &c); diff --git a/include/linux/isdn.h b/include/linux/isdn.h index cc352390f41f..6c7693b50e03 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -480,7 +480,6 @@ typedef struct modem_info { int dialing; /* Dial in progress or ATA */ int rcvsched; /* Receive needs schedule */ int isdn_slot; /* Index to isdn-driver/channel */ - int drv_index; /* Index to dev->usage */ int ncarrier; /* Flag: schedule NO CARRIER */ unsigned char last_cause[8]; /* Last cause message */ unsigned char last_num[ISDN_MSNLEN]; -- cgit v1.2.3 From 33c7e1fad6f6c3b4af06d5c75f4f55126266b3cb Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 31 Jul 2002 06:33:04 -0500 Subject: ISDN: Gather per-slot data Instead of having a number of arrays containg various bits of per-slot data, start aggregating this data in a struct, and then have one instance of this struct per slot. --- drivers/isdn/i4l/isdn_common.c | 207 +++++++++++++++++++++-------------------- drivers/isdn/i4l/isdn_common.h | 2 + drivers/isdn/i4l/isdn_net.c | 40 ++++---- drivers/isdn/i4l/isdn_tty.c | 21 ++--- drivers/isdn/i4l/isdn_ttyfax.c | 2 +- include/linux/isdn.h | 1 - 6 files changed, 135 insertions(+), 138 deletions(-) (limited to 'include') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index c0307992dafe..0ddf573156a0 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -44,8 +44,11 @@ MODULE_LICENSE("GPL"); isdn_dev *dev; -static int drvmap[ISDN_MAX_CHANNELS]; /* Map slot -> driver-index */ -static int chanmap[ISDN_MAX_CHANNELS]; /* Map slot -> channel-index */ +static struct { + int di; /* driver index */ + int ch; /* channel index (per driver */ + int usage; /* how is it used */ +} slot[ISDN_MAX_CHANNELS]; static char *isdn_revision = "$Revision: 1.114.6.16 $"; @@ -234,7 +237,7 @@ isdn_dc2minor(int di, int ch) { int i; for (i = 0; i < ISDN_MAX_CHANNELS; i++) - if (chanmap[i] == ch && drvmap[i] == di) + if (slot[i].ch == ch && slot[i].di == di) return i; return -1; } @@ -448,7 +451,7 @@ isdn_status_callback(isdn_ctrl * c) case ISDN_STAT_RUN: dev->drv[di]->flags |= DRV_FLAG_RUNNING; for (i = 0; i < ISDN_MAX_CHANNELS; i++) - if (drvmap[i] == di) + if (slot[i].di == di) isdn_slot_all_eaz(i); set_global_features(); break; @@ -665,20 +668,17 @@ isdn_status_callback(isdn_ctrl * c) save_flags(flags); cli(); for (i = 0; i < ISDN_MAX_CHANNELS; i++) - if ((drvmap[i] == di) && - (chanmap[i] == c->arg)) { - if (c->parm.num[0]) - dev->usage[i] &= ~ISDN_USAGE_DISABLED; - else - if (USG_NONE(dev->usage[i])) { - dev->usage[i] |= ISDN_USAGE_DISABLED; - } - else - retval = -1; - break; + if ((slot[i].di == di) && + (slot[i].ch == c->arg)) { + if (c->parm.num[0]) + isdn_slot_set_usage(i, isdn_slot_usage(i) & ~ISDN_USAGE_DISABLED); + else if (USG_NONE(isdn_slot_usage(i))) + isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_DISABLED); + else + retval = -1; + break; } restore_flags(flags); - isdn_info_update(); break; case ISDN_STAT_UNLOAD: while (dev->drv[di]->locks > 0) { @@ -693,10 +693,10 @@ isdn_status_callback(isdn_ctrl * c) cli(); isdn_tty_stat_callback(i, c); for (i = 0; i < ISDN_MAX_CHANNELS; i++) - if (drvmap[i] == di) { - drvmap[i] = -1; - chanmap[i] = -1; - dev->usage[i] &= ~ISDN_USAGE_DISABLED; + if (slot[i].di == di) { + slot[i].di = -1; + slot[i].ch = -1; + slot[i].usage &= ~ISDN_USAGE_DISABLED; isdn_unregister_devfs(i); } dev->drivers--; @@ -760,14 +760,14 @@ isdn_getnum(char **p) * It MUST be called with interrupts off. */ int -isdn_slot_readbchan(int slot, u_char * buf, u_char * fp, int len) +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(slot); - int ch = isdn_slot_channel(slot); + int di = isdn_slot_driver(sl); + int ch = isdn_slot_channel(sl); struct sk_buff *skb; u_char *cp; @@ -860,13 +860,13 @@ isdn_slot_readbchan(int slot, u_char * buf, u_char * fp, int len) static __inline int isdn_minor2drv(int minor) { - return drvmap[minor]; + return slot[minor].di; } static __inline int isdn_minor2chan(int minor) { - return chanmap[minor]; + return slot[minor].ch; } static char * @@ -879,25 +879,25 @@ isdn_statstr(void) sprintf(istatbuf, "idmap:\t"); p = istatbuf + strlen(istatbuf); for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - sprintf(p, "%s ", (drvmap[i] < 0) ? "-" : dev->drvid[drvmap[i]]); + sprintf(p, "%s ", (slot[i].di < 0) ? "-" : dev->drvid[slot[i].di]); p = istatbuf + strlen(istatbuf); } sprintf(p, "\nchmap:\t"); p = istatbuf + strlen(istatbuf); for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - sprintf(p, "%d ", chanmap[i]); + sprintf(p, "%d ", slot[i].ch); p = istatbuf + strlen(istatbuf); } sprintf(p, "\ndrmap:\t"); p = istatbuf + strlen(istatbuf); for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - sprintf(p, "%d ", drvmap[i]); + sprintf(p, "%d ", slot[i].di); p = istatbuf + strlen(istatbuf); } sprintf(p, "\nusage:\t"); p = istatbuf + strlen(istatbuf); for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - sprintf(p, "%d ", dev->usage[i]); + sprintf(p, "%d ", slot[i].usage); p = istatbuf + strlen(istatbuf); } sprintf(p, "\nflags:\t"); @@ -1736,34 +1736,28 @@ isdn_get_free_slot(int usage, int l2_proto, int l3_proto, * because we can emulate this in linklevel. */ for (i = 0; i < ISDN_MAX_CHANNELS; i++) - if (USG_NONE(dev->usage[i]) && - (drvmap[i] != -1)) { - int d = drvmap[i]; - if ((dev->usage[i] & ISDN_USAGE_EXCLUSIVE) && - ((pre_dev != d) || (pre_chan != chanmap[i]))) + if (USG_NONE(slot[i].usage) && + (slot[i].di != -1)) { + int d = slot[i].di; + if ((slot[i].usage & ISDN_USAGE_EXCLUSIVE) && + ((pre_dev != d) || (pre_chan != slot[i].ch))) continue; if (!strcmp(isdn_map_eaz2msn(msn, d), "-")) continue; - if (dev->usage[i] & ISDN_USAGE_DISABLED) + if (slot[i].usage & ISDN_USAGE_DISABLED) continue; /* usage not allowed */ if (dev->drv[d]->flags & DRV_FLAG_RUNNING) { 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 ((pre_dev < 0) || (pre_chan < 0)) { - dev->usage[i] &= ISDN_USAGE_EXCLUSIVE; - dev->usage[i] |= usage; - isdn_info_update(); + isdn_slot_set_usage(i, (isdn_slot_usage(i) & ISDN_USAGE_EXCLUSIVE) | usage); + restore_flags(flags); + return i; + } else if ((pre_dev == d) && (pre_chan == slot[i].ch)) { + isdn_slot_set_usage(i, (isdn_slot_usage(i) & ISDN_USAGE_EXCLUSIVE) | usage); restore_flags(flags); return i; - } else { - if ((pre_dev == d) && (pre_chan == chanmap[i])) { - dev->usage[i] &= ISDN_USAGE_EXCLUSIVE; - dev->usage[i] |= usage; - isdn_info_update(); - restore_flags(flags); - return i; - } } } } @@ -1778,32 +1772,31 @@ isdn_get_free_slot(int usage, int l2_proto, int l3_proto, void isdn_free_channel(int di, int ch, int usage) { - int slot; + int sl; - slot = isdn_dc2minor(di, ch); - isdn_slot_free(slot, usage); + sl = isdn_dc2minor(di, ch); + isdn_slot_free(sl, usage); } void -isdn_slot_free(int slot, int usage) +isdn_slot_free(int sl, int usage) { unsigned long flags; save_flags(flags); cli(); - if (!usage || (dev->usage[slot] & ISDN_USAGE_MASK) == usage) { - dev->usage[slot] &= (ISDN_USAGE_NONE | ISDN_USAGE_EXCLUSIVE); - strcpy(dev->num[slot], "???"); - dev->ibytes[slot] = 0; - dev->obytes[slot] = 0; + if (!usage || (slot[sl].usage & ISDN_USAGE_MASK) == usage) { + strcpy(dev->num[sl], "???"); + dev->ibytes[sl] = 0; + dev->obytes[sl] = 0; // 20.10.99 JIM, try to reinitialize v110 ! - dev->v110emu[slot] = 0; - atomic_set(&(dev->v110use[slot]), 0); - isdn_v110_close(dev->v110[slot]); - dev->v110[slot] = NULL; + dev->v110emu[sl] = 0; + atomic_set(&(dev->v110use[sl]), 0); + isdn_v110_close(dev->v110[sl]); + dev->v110[sl] = NULL; // 20.10.99 JIM, try to reinitialize v110 ! - isdn_info_update(); - skb_queue_purge(&dev->drv[isdn_slot_driver(slot)]->rpqueue[isdn_slot_channel(slot)]); + isdn_slot_set_usage(sl, isdn_slot_usage(sl) & (ISDN_USAGE_NONE | ISDN_USAGE_EXCLUSIVE)); + skb_queue_purge(&dev->drv[isdn_slot_driver(sl)]->rpqueue[isdn_slot_channel(sl)]); } restore_flags(flags); } @@ -1820,10 +1813,9 @@ isdn_unexclusive_channel(int di, int ch) save_flags(flags); cli(); for (i = 0; i < ISDN_MAX_CHANNELS; i++) - if ((drvmap[i] == di) && - (chanmap[i] == ch)) { - dev->usage[i] &= ~ISDN_USAGE_EXCLUSIVE; - isdn_info_update(); + if ((slot[i].di == di) && + (slot[i].ch == ch)) { + isdn_slot_set_usage(i, isdn_slot_usage(i) & ~ISDN_USAGE_EXCLUSIVE); restore_flags(flags); return; } @@ -1834,20 +1826,20 @@ isdn_unexclusive_channel(int di, int ch) * Return: length of data on success, -ERRcode on failure. */ int -isdn_slot_write(int slot, struct sk_buff *skb) +isdn_slot_write(int sl, struct sk_buff *skb) { int ret; struct sk_buff *nskb = NULL; int v110_ret = skb->len; - int di = isdn_slot_driver(slot); - int ch = isdn_slot_channel(slot); + int di = isdn_slot_driver(sl); + int ch = isdn_slot_channel(sl); - BUG_ON(slot < 0); + BUG_ON(sl < 0); - if (dev->v110[slot]) { - atomic_inc(&dev->v110use[slot]); - nskb = isdn_v110_encode(dev->v110[slot], skb); - atomic_dec(&dev->v110use[slot]); + if (dev->v110[sl]) { + atomic_inc(&dev->v110use[sl]); + nskb = isdn_v110_encode(dev->v110[sl], skb); + atomic_dec(&dev->v110use[sl]); if (!nskb) return 0; v110_ret = *((int *)nskb->data); @@ -1859,7 +1851,7 @@ isdn_slot_write(int slot, struct sk_buff *skb) /* V.110 must always be acknowledged */ ret = dev->drv[di]->interface->writebuf_skb(di, ch, 1, nskb); } else { - int hl = isdn_slot_hdrlen(slot); + int hl = isdn_slot_hdrlen(sl); if( skb_headroom(skb) < hl ){ /* @@ -1887,10 +1879,10 @@ isdn_slot_write(int slot, struct sk_buff *skb) } if (ret > 0) { dev->obytes[di] += ret; - if (dev->v110[slot]) { - atomic_inc(&dev->v110use[slot]); - dev->v110[slot]->skbuser++; - atomic_dec(&dev->v110use[slot]); + if (dev->v110[sl]) { + atomic_inc(&dev->v110use[sl]); + dev->v110[sl]->skbuser++; + atomic_dec(&dev->v110use[sl]); /* For V.110 return unencoded data length */ ret = v110_ret; /* if the complete frame was send we free the skb; @@ -1899,7 +1891,7 @@ isdn_slot_write(int slot, struct sk_buff *skb) dev_kfree_skb(skb); } } else - if (dev->v110[slot]) + if (dev->v110[sl]) dev_kfree_skb(nskb); return ret; } @@ -1980,9 +1972,9 @@ isdn_add_channels(driver *d, int drvidx, int n, int adding) cli(); for (j = d->channels; j < m; j++) for (k = 0; k < ISDN_MAX_CHANNELS; k++) - if (chanmap[k] < 0) { - chanmap[k] = j; - drvmap[k] = drvidx; + if (slot[k].ch < 0) { + slot[k].ch = j; + slot[k].di = drvidx; isdn_register_devfs(k); break; } @@ -2124,54 +2116,71 @@ register_isdn(isdn_if * i) } int -isdn_slot_driver(int slot) +isdn_slot_driver(int sl) { - BUG_ON(slot < 0); + BUG_ON(sl < 0); - return drvmap[slot]; + return slot[sl].di; } int -isdn_slot_channel(int slot) +isdn_slot_channel(int sl) { - BUG_ON(slot < 0); + BUG_ON(sl < 0); - return chanmap[slot]; + return slot[sl].ch; } int -isdn_slot_hdrlen(int slot) +isdn_slot_hdrlen(int sl) { - int di = isdn_slot_driver(slot); + int di = isdn_slot_driver(sl); return dev->drv[di]->interface->hl_hdrlen; } char * -isdn_slot_map_eaz2msn(int slot, char *msn) +isdn_slot_map_eaz2msn(int sl, char *msn) { - int di = isdn_slot_driver(slot); + int di = isdn_slot_driver(sl); return isdn_map_eaz2msn(msn, di); } int -isdn_slot_command(int slot, int cmd, isdn_ctrl *ctrl) +isdn_slot_command(int sl, int cmd, isdn_ctrl *ctrl) { ctrl->command = cmd; - ctrl->driver = isdn_slot_driver(slot); - ctrl->arg &= 0xff; ctrl->arg |= isdn_slot_channel(slot); + ctrl->driver = isdn_slot_driver(sl); + ctrl->arg &= 0xff; ctrl->arg |= isdn_slot_channel(sl); return isdn_command(ctrl); } void -isdn_slot_all_eaz(int slot) +isdn_slot_all_eaz(int sl) { isdn_ctrl cmd; cmd.parm.num[0] = '\0'; - isdn_slot_command(slot, ISDN_CMD_SETEAZ, &cmd); + isdn_slot_command(sl, ISDN_CMD_SETEAZ, &cmd); +} + +int +isdn_slot_usage(int sl) +{ + BUG_ON(sl < 0); + + return slot[sl].usage; +} + +void +isdn_slot_set_usage(int sl, int usage) +{ + BUG_ON(sl < 0); + + slot[sl].usage = usage; + isdn_info_update(); } /* @@ -2295,8 +2304,8 @@ static int __init isdn_init(void) init_MUTEX(&dev->sem); init_waitqueue_head(&dev->info_waitq); for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - drvmap[i] = -1; - chanmap[i] = -1; + slot[i].di = -1; + slot[i].ch = -1; dev->m_idx[i] = -1; strcpy(dev->num[i], "???"); init_waitqueue_head(&dev->mdm.info[i].open_wait); diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h index b9b5c9a7c34b..d20de983c3e5 100644 --- a/drivers/isdn/i4l/isdn_common.h +++ b/drivers/isdn/i4l/isdn_common.h @@ -52,3 +52,5 @@ extern int isdn_slot_readbchan(int slot, u_char *, u_char *, int); extern int isdn_slot_hdrlen(int slot); extern int isdn_slot_driver(int slot); extern int isdn_slot_channel(int slot); +extern int isdn_slot_usage(int slot); +extern void isdn_slot_set_usage(int slot, int usage); diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c index 83a127d18fc2..5e8809a01c88 100644 --- a/drivers/isdn/i4l/isdn_net.c +++ b/drivers/isdn/i4l/isdn_net.c @@ -488,10 +488,9 @@ isdn_net_stat_callback(int idx, isdn_ctrl *c) case 9: case 10: case 12: - if (lp->dialstate <= 6) { - dev->usage[idx] |= ISDN_USAGE_OUTGOING; - isdn_info_update(); - } else + if (lp->dialstate <= 6) + isdn_slot_set_usage(idx, isdn_slot_usage(idx) | ISDN_USAGE_OUTGOING); + else dev->rx_netdev[idx] = p; lp->dialstate = 0; isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 1); @@ -698,8 +697,7 @@ isdn_net_dial(void) isdn_slot_map_eaz2msn(lp->isdn_slot, lp->msn)); if (lp->isdn_slot >= 0) { strcpy(dev->num[lp->isdn_slot], cmd.parm.setup.phone); - dev->usage[lp->isdn_slot] |= ISDN_USAGE_OUTGOING; - isdn_info_update(); + isdn_slot_set_usage(lp->isdn_slot, isdn_slot_usage(lp->isdn_slot) | ISDN_USAGE_OUTGOING); } printk(KERN_INFO "%s: dialing %d %s... %s\n", lp->name, lp->dialretry, cmd.parm.setup.phone, @@ -2084,17 +2082,14 @@ isdn_net_swapbind(int drvidx) static void isdn_net_swap_usage(int i1, int i2) { - int u1 = dev->usage[i1] & ISDN_USAGE_EXCLUSIVE; - int u2 = dev->usage[i2] & ISDN_USAGE_EXCLUSIVE; + int u1 = isdn_slot_usage(i1); + int u2 = isdn_slot_usage(i2); #ifdef ISDN_DEBUG_NET_ICALL printk(KERN_DEBUG "n_fi: usage of %d and %d\n", i1, i2); #endif - dev->usage[i1] &= ~ISDN_USAGE_EXCLUSIVE; - dev->usage[i1] |= u2; - dev->usage[i2] &= ~ISDN_USAGE_EXCLUSIVE; - dev->usage[i2] |= u1; - isdn_info_update(); + isdn_slot_set_usage(i1, (u1 & ~ISDN_USAGE_EXCLUSIVE) | (u2 & ISDN_USAGE_EXCLUSIVE)); + isdn_slot_set_usage(i2, (u2 & ~ISDN_USAGE_EXCLUSIVE) | (u1 & ISDN_USAGE_EXCLUSIVE)); } /* @@ -2206,7 +2201,7 @@ p = dev->netdev; #endif if ((!matchret) && /* EAZ is matching */ (((!(lp->flags & ISDN_NET_CONNECTED)) && /* but not connected */ - (USG_NONE(dev->usage[idx]))) || /* and ch. unused or */ + (USG_NONE(isdn_slot_usage(idx)))) || /* and ch. unused or */ ((((lp->dialstate == 4) || (lp->dialstate == 12)) && /* if dialing */ (!(lp->flags & ISDN_NET_CALLBACK))) /* but no callback */ ))) @@ -2215,7 +2210,7 @@ p = dev->netdev; printk(KERN_DEBUG "n_fi: match1, pdev=%d pch=%d\n", lp->pre_device, lp->pre_channel); #endif - if (dev->usage[idx] & ISDN_USAGE_EXCLUSIVE) { + if (isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) { if ((lp->pre_channel != ch) || (lp->pre_device != di)) { /* Here we got a problem: @@ -2232,10 +2227,10 @@ p = dev->netdev; #ifdef ISDN_DEBUG_NET_ICALL printk(KERN_DEBUG "n_fi: ch is 0\n"); #endif - if (USG_NONE(dev->usage[sidx])) { + if (USG_NONE(isdn_slot_usage(sidx))) { /* Second Channel is free, now see if it is bound * exclusive too. */ - if (dev->usage[sidx] & ISDN_USAGE_EXCLUSIVE) { + if (isdn_slot_usage(sidx) & ISDN_USAGE_EXCLUSIVE) { #ifdef ISDN_DEBUG_NET_ICALL printk(KERN_DEBUG "n_fi: 2nd channel is down and bound\n"); #endif @@ -2263,7 +2258,7 @@ p = dev->netdev; #ifdef ISDN_DEBUG_NET_ICALL printk(KERN_DEBUG "n_fi: final check\n"); #endif - if ((dev->usage[idx] & ISDN_USAGE_EXCLUSIVE) && + if ((isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) && ((lp->pre_channel != ch) || (lp->pre_device != di))) { #ifdef ISDN_DEBUG_NET_ICALL @@ -2408,10 +2403,8 @@ p = dev->netdev; isdn_slot_free(lp->isdn_slot, ISDN_USAGE_NET); } - dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE; - dev->usage[idx] |= ISDN_USAGE_NET; strcpy(dev->num[idx], nr); - isdn_info_update(); + isdn_slot_set_usage(idx, (isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) | ISDN_USAGE_NET); dev->st_netdev[idx] = lp->netdev; lp->isdn_slot = slot; lp->ppp_slot = -1; @@ -2806,8 +2799,7 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) return -EBUSY; } /* All went ok, so update isdninfo */ - dev->usage[i] = ISDN_USAGE_EXCLUSIVE; - isdn_info_update(); + isdn_slot_set_usage(i, ISDN_USAGE_EXCLUSIVE); restore_flags(flags); lp->exclusive = i; } else { @@ -3032,7 +3024,7 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone *peer) /* for pre-bound channels, we need this extra check */ if ( strncmp(dev->num[idx],"???",3) == 0 ) return -ENOTCONN; strncpy(phone->phone,dev->num[idx],ISDN_MSNLEN); - phone->outgoing=USG_OUTGOING(dev->usage[idx]); + phone->outgoing=USG_OUTGOING(isdn_slot_usage(idx)); if ( copy_to_user(peer,phone,sizeof(*peer)) ) return -EFAULT; return 0; } diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index d2d5086cb127..95df7c7bb3d3 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -658,10 +658,9 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) } else { info->isdn_slot = i; dev->m_idx[i] = info->line; - dev->usage[i] |= ISDN_USAGE_OUTGOING; info->last_dir = 1; strcpy(info->last_num, n); - isdn_info_update(); + isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING); restore_flags(flags); isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd); strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn)); @@ -849,10 +848,9 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) } else { info->isdn_slot = i; dev->m_idx[i] = info->line; - dev->usage[i] |= ISDN_USAGE_OUTGOING; + isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING); info->last_dir = 1; // strcpy(info->last_num, n); - isdn_info_update(); restore_flags(flags); isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd); strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn)); @@ -929,9 +927,8 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) } else { info->isdn_slot = i; dev->m_idx[i] = info->line; - dev->usage[i] |= ISDN_USAGE_OUTGOING; + isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING); info->last_dir = 1; - isdn_info_update(); restore_flags(flags); isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd); strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn)); @@ -2206,7 +2203,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) (info->flags & ISDN_ASYNC_NORMAL_ACTIVE) && #endif (info->isdn_slot == -1) && - (USG_NONE(dev->usage[idx]))) { + (USG_NONE(isdn_slot_usage(idx)))) { int matchret; if ((matchret = isdn_tty_match_icall(eaz, &info->emu, di)) > wret) @@ -2214,14 +2211,12 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) if (!matchret) { /* EAZ is matching */ info->isdn_slot = idx; dev->m_idx[idx] = info->line; - dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE; - dev->usage[idx] |= isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]); strcpy(dev->num[idx], nr); strcpy(info->emu.cpn, eaz); info->emu.mdmreg[REG_SI1I] = si2bit[si1]; info->emu.mdmreg[REG_PLAN] = setup->plan; info->emu.mdmreg[REG_SCREEN] = setup->screen; - isdn_info_update(); + isdn_slot_set_usage(idx, (isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) | isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT])); restore_flags(flags); printk(KERN_INFO "isdn_tty: call from %s, -> RING on ttyI%d\n", nr, info->line); @@ -2349,14 +2344,14 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) info->last_dir = 0; info->dialing = 0; info->rcvsched = 1; - if (USG_MODEM(dev->usage[i])) { + if (USG_MODEM(isdn_slot_usage(i))) { 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(dev->usage[i])) + if (USG_VOICE(isdn_slot_usage(i))) isdn_tty_modem_result(RESULT_VCON, info); return 1; } @@ -3940,7 +3935,7 @@ isdn_tty_modem_escape(void) int midx; for (i = 0; i < ISDN_MAX_CHANNELS; i++) - if (USG_MODEM(dev->usage[i])) + if (USG_MODEM(isdn_slot_usage(i))) if ((midx = dev->m_idx[i]) >= 0) { modem_info *info = &dev->mdm.info[midx]; if (info->online) { diff --git a/drivers/isdn/i4l/isdn_ttyfax.c b/drivers/isdn/i4l/isdn_ttyfax.c index 874a748d4cf9..95c275084ac7 100644 --- a/drivers/isdn/i4l/isdn_ttyfax.c +++ b/drivers/isdn/i4l/isdn_ttyfax.c @@ -74,7 +74,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) && - (!(dev->usage[info->isdn_slot] & ISDN_USAGE_OUTGOING))) { + (!(isdn_slot_usage(info->isdn_slot) & ISDN_USAGE_OUTGOING))) { sprintf(rs, "/%s", m->cpn); isdn_tty_at_cout(rs, info); } diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 6c7693b50e03..e414029906cf 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -605,7 +605,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 */ - int usage[ISDN_MAX_CHANNELS]; /* Used by tty/ip/voice */ char num[ISDN_MAX_CHANNELS][ISDN_MSNLEN]; /* Remote number of active ch.*/ int m_idx[ISDN_MAX_CHANNELS]; /* Index for mdm.... */ -- cgit v1.2.3 From cd5869cbf146d9d1847a76c03dcae3d0f3ae6848 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 31 Jul 2002 08:05:33 -0500 Subject: ISDN: Move more slot-specific data into the per-slot struct --- drivers/isdn/i4l/isdn_common.c | 121 +++++++++++++++++++++++++++-------------- drivers/isdn/i4l/isdn_common.h | 8 +++ drivers/isdn/i4l/isdn_net.c | 24 ++++---- drivers/isdn/i4l/isdn_tty.c | 28 +++++----- drivers/isdn/i4l/isdn_ttyfax.c | 4 +- drivers/isdn/i4l/isdn_v110.c | 36 ++++++------ drivers/isdn/i4l/isdn_v110.h | 12 +++- include/linux/isdn.h | 10 ---- 8 files changed, 143 insertions(+), 100 deletions(-) (limited to 'include') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 0ddf573156a0..464abbc87775 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -44,11 +44,20 @@ MODULE_LICENSE("GPL"); isdn_dev *dev; -static struct { - int di; /* driver index */ - int ch; /* channel index (per driver */ - int usage; /* how is it used */ -} slot[ISDN_MAX_CHANNELS]; +struct isdn_slot { + int di; /* driver index */ + 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.... */ + isdn_net_dev *rx_netdev; /* rx netdev-pointers */ + isdn_net_dev *st_netdev; /* stat netdev-pointers */ +}; + +static struct isdn_slot slot[ISDN_MAX_CHANNELS]; static char *isdn_revision = "$Revision: 1.114.6.16 $"; @@ -324,7 +333,7 @@ isdn_receive_skb_callback(int di, int channel, struct sk_buff *skb) return; } /* Update statistics */ - dev->ibytes[i] += skb->len; + slot[i].ibytes += skb->len; /* First, try to deliver data to network-device */ if (isdn_net_rcv_skb(i, skb)) @@ -334,10 +343,10 @@ isdn_receive_skb_callback(int di, int channel, struct sk_buff *skb) * makes sense for async streams only, so it is * called after possible net-device delivery. */ - if (dev->v110[i]) { - atomic_inc(&dev->v110use[i]); - skb = isdn_v110_decode(dev->v110[i], skb); - atomic_dec(&dev->v110use[i]); + if (slot[i].iv110.v110) { + atomic_inc(&slot[i].iv110.v110use); + skb = isdn_v110_decode(slot[i].iv110.v110, skb); + atomic_dec(&slot[i].iv110.v110use); if (!skb) return; } @@ -381,11 +390,11 @@ isdn_command(isdn_ctrl *cmd) * Layer-2 to transparent */ if (!(features & l2_feature)) { - dev->v110emu[idx] = l2prot; + slot[idx].iv110.v110emu = l2prot; cmd->arg = (cmd->arg & 255) | (ISDN_PROTO_L2_TRANS << 8); } else - dev->v110emu[idx] = 0; + slot[idx].iv110.v110emu = 0; } } return dev->drv[cmd->driver]->interface->command(cmd); @@ -435,7 +444,7 @@ isdn_status_callback(isdn_ctrl * c) return 0; if (isdn_net_stat_callback(i, c)) return 0; - if (isdn_v110_stat_callback(i, c)) + if (isdn_v110_stat_callback(&slot[i].iv110, c)) return 0; if (isdn_tty_stat_callback(i, c)) return 0; @@ -578,7 +587,7 @@ isdn_status_callback(isdn_ctrl * c) /* Find any net-device, waiting for D-channel setup */ if (isdn_net_stat_callback(i, c)) break; - isdn_v110_stat_callback(i, c); + isdn_v110_stat_callback(&slot[i].iv110, c); /* Find any ttyI, waiting for D-channel setup */ if (isdn_tty_stat_callback(i, c)) { cmd.driver = di; @@ -601,7 +610,7 @@ isdn_status_callback(isdn_ctrl * c) /* Signal hangup to network-devices */ if (isdn_net_stat_callback(i, c)) break; - isdn_v110_stat_callback(i, c); + isdn_v110_stat_callback(&slot[i].iv110, c); if (isdn_tty_stat_callback(i, c)) break; #ifdef CONFIG_ISDN_DIVERSION @@ -623,7 +632,7 @@ isdn_status_callback(isdn_ctrl * c) isdn_info_update(); if (isdn_net_stat_callback(i, c)) break; - isdn_v110_stat_callback(i, c); + isdn_v110_stat_callback(&slot[i].iv110, c); if (isdn_tty_stat_callback(i, c)) break; break; @@ -642,7 +651,7 @@ isdn_status_callback(isdn_ctrl * c) if (isdn_net_stat_callback(i, c)) break; #endif - isdn_v110_stat_callback(i, c); + isdn_v110_stat_callback(&slot[i].iv110, c); if (isdn_tty_stat_callback(i, c)) break; break; @@ -914,7 +923,7 @@ isdn_statstr(void) sprintf(p, "\nphone:\t"); p = istatbuf + strlen(istatbuf); for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - sprintf(p, "%s ", dev->num[i]); + sprintf(p, "%s ", isdn_slot_num(i)); p = istatbuf + strlen(istatbuf); } sprintf(p, "\n"); @@ -1071,8 +1080,8 @@ isdn_status_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) sizeof(ulong) * ISDN_MAX_CHANNELS * 2))) return ret; for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - put_user(dev->ibytes[i], p++); - put_user(dev->obytes[i], p++); + put_user(slot[i].ibytes, p++); + put_user(slot[i].obytes, p++); } return 0; } else @@ -1719,7 +1728,7 @@ isdn_map_eaz2msn(char *msn, int di) int isdn_get_free_slot(int usage, int l2_proto, int l3_proto, - int pre_dev,int pre_chan, char *msn) + int pre_dev, int pre_chan, char *msn) { int i; ulong flags; @@ -1786,14 +1795,14 @@ isdn_slot_free(int sl, int usage) save_flags(flags); cli(); if (!usage || (slot[sl].usage & ISDN_USAGE_MASK) == usage) { - strcpy(dev->num[sl], "???"); - dev->ibytes[sl] = 0; - dev->obytes[sl] = 0; + strcpy(isdn_slot_num(sl), "???"); + slot[sl].ibytes = 0; + slot[sl].obytes = 0; // 20.10.99 JIM, try to reinitialize v110 ! - dev->v110emu[sl] = 0; - atomic_set(&(dev->v110use[sl]), 0); - isdn_v110_close(dev->v110[sl]); - dev->v110[sl] = NULL; + slot[sl].iv110.v110emu = 0; + atomic_set(&slot[sl].iv110.v110use, 0); + isdn_v110_close(slot[sl].iv110.v110); + slot[sl].iv110.v110 = NULL; // 20.10.99 JIM, try to reinitialize v110 ! isdn_slot_set_usage(sl, isdn_slot_usage(sl) & (ISDN_USAGE_NONE | ISDN_USAGE_EXCLUSIVE)); skb_queue_purge(&dev->drv[isdn_slot_driver(sl)]->rpqueue[isdn_slot_channel(sl)]); @@ -1836,10 +1845,10 @@ isdn_slot_write(int sl, struct sk_buff *skb) BUG_ON(sl < 0); - if (dev->v110[sl]) { - atomic_inc(&dev->v110use[sl]); - nskb = isdn_v110_encode(dev->v110[sl], skb); - atomic_dec(&dev->v110use[sl]); + if (slot[sl].iv110.v110) { + atomic_inc(&slot[sl].iv110.v110use); + nskb = isdn_v110_encode(slot[sl].iv110.v110, skb); + atomic_dec(&slot[sl].iv110.v110use); if (!nskb) return 0; v110_ret = *((int *)nskb->data); @@ -1878,11 +1887,11 @@ isdn_slot_write(int sl, struct sk_buff *skb) } } if (ret > 0) { - dev->obytes[di] += ret; - if (dev->v110[sl]) { - atomic_inc(&dev->v110use[sl]); - dev->v110[sl]->skbuser++; - atomic_dec(&dev->v110use[sl]); + slot[sl].obytes += ret; + if (slot[sl].iv110.v110) { + atomic_inc(&slot[sl].iv110.v110use); + slot[sl].iv110.v110->skbuser++; + atomic_dec(&slot[sl].iv110.v110use); /* For V.110 return unencoded data length */ ret = v110_ret; /* if the complete frame was send we free the skb; @@ -1891,7 +1900,7 @@ isdn_slot_write(int sl, struct sk_buff *skb) dev_kfree_skb(skb); } } else - if (dev->v110[sl]) + if (slot[sl].iv110.v110) dev_kfree_skb(nskb); return ret; } @@ -2183,6 +2192,38 @@ isdn_slot_set_usage(int sl, int usage) isdn_info_update(); } +void +isdn_slot_set_rx_netdev(int sl, isdn_net_dev *nd) +{ + BUG_ON(sl < 0); + + slot[sl].rx_netdev = nd; +} + +isdn_net_dev * +isdn_slot_rx_netdev(int sl) +{ + BUG_ON(sl < 0); + + return slot[sl].rx_netdev; +} + +void +isdn_slot_set_st_netdev(int sl, isdn_net_dev *nd) +{ + BUG_ON(sl < 0); + + slot[sl].rx_netdev = nd; +} + +isdn_net_dev * +isdn_slot_st_netdev(int sl) +{ + BUG_ON(sl < 0); + + return slot[sl].st_netdev; +} + /* ***************************************************************************** * And now the modules code. @@ -2306,8 +2347,8 @@ static int __init isdn_init(void) for (i = 0; i < ISDN_MAX_CHANNELS; i++) { slot[i].di = -1; slot[i].ch = -1; - dev->m_idx[i] = -1; - strcpy(dev->num[i], "???"); + slot[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); } diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h index d20de983c3e5..7b7063375ce4 100644 --- a/drivers/isdn/i4l/isdn_common.h +++ b/drivers/isdn/i4l/isdn_common.h @@ -54,3 +54,11 @@ extern int isdn_slot_driver(int slot); extern int isdn_slot_channel(int slot); extern int isdn_slot_usage(int slot); 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 int isdn_slot_set_m_idx(int slot, int midx); +extern void isdn_slot_set_rx_netdev(int sl, isdn_net_dev *nd); +extern void isdn_slot_set_st_netdev(int sl, isdn_net_dev *nd); +extern isdn_net_dev *isdn_slot_rx_netdev(int sl); +extern isdn_net_dev *isdn_slot_st_netdev(int sl); + diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c index 5e8809a01c88..ffd6031d6e5d 100644 --- a/drivers/isdn/i4l/isdn_net.c +++ b/drivers/isdn/i4l/isdn_net.c @@ -281,8 +281,8 @@ isdn_net_bind_channel(isdn_net_local * lp, int idx) cli(); lp->flags |= ISDN_NET_CONNECTED; lp->isdn_slot = idx; - dev->rx_netdev[idx] = lp->netdev; - dev->st_netdev[idx] = lp->netdev; + isdn_slot_set_rx_netdev(lp->isdn_slot, lp->netdev); + isdn_slot_set_st_netdev(lp->isdn_slot, lp->netdev); restore_flags(flags); } @@ -306,8 +306,8 @@ isdn_net_unbind_channel(isdn_net_local * lp) qdisc_reset(lp->netdev->dev.qdisc); } lp->dialstate = 0; - dev->rx_netdev[lp->isdn_slot] = NULL; - dev->st_netdev[lp->isdn_slot] = NULL; + isdn_slot_set_rx_netdev(lp->isdn_slot, NULL); + isdn_slot_set_st_netdev(lp->isdn_slot, NULL); isdn_slot_free(lp->isdn_slot, ISDN_USAGE_NET); lp->flags &= ~ISDN_NET_CONNECTED; lp->isdn_slot = -1; @@ -405,7 +405,7 @@ static void isdn_net_lp_disconnected(isdn_net_local *lp) int isdn_net_stat_callback(int idx, isdn_ctrl *c) { - isdn_net_dev *p = dev->st_netdev[idx]; + isdn_net_dev *p = isdn_slot_st_netdev(idx); int cmd = c->command; if (p) { @@ -491,7 +491,7 @@ isdn_net_stat_callback(int idx, isdn_ctrl *c) if (lp->dialstate <= 6) isdn_slot_set_usage(idx, isdn_slot_usage(idx) | ISDN_USAGE_OUTGOING); else - dev->rx_netdev[idx] = p; + isdn_slot_set_rx_netdev(idx, p); lp->dialstate = 0; isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 1); if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK) @@ -696,7 +696,7 @@ isdn_net_dial(void) sprintf(cmd.parm.setup.eazmsn, "%s", isdn_slot_map_eaz2msn(lp->isdn_slot, lp->msn)); if (lp->isdn_slot >= 0) { - strcpy(dev->num[lp->isdn_slot], cmd.parm.setup.phone); + strcpy(isdn_slot_num(lp->isdn_slot), cmd.parm.setup.phone); isdn_slot_set_usage(lp->isdn_slot, isdn_slot_usage(lp->isdn_slot) | ISDN_USAGE_OUTGOING); } printk(KERN_INFO "%s: dialing %d %s... %s\n", lp->name, @@ -1859,7 +1859,7 @@ isdn_net_receive(struct net_device *ndev, struct sk_buff *skb) int isdn_net_rcv_skb(int idx, struct sk_buff *skb) { - isdn_net_dev *p = dev->rx_netdev[idx]; + isdn_net_dev *p = isdn_slot_rx_netdev(idx); if (p) { isdn_net_local *lp = p->local; @@ -2403,9 +2403,9 @@ p = dev->netdev; isdn_slot_free(lp->isdn_slot, ISDN_USAGE_NET); } - strcpy(dev->num[idx], nr); + strcpy(isdn_slot_num(idx), nr); isdn_slot_set_usage(idx, (isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) | ISDN_USAGE_NET); - dev->st_netdev[idx] = lp->netdev; + isdn_slot_set_st_netdev(idx, lp->netdev); lp->isdn_slot = slot; lp->ppp_slot = -1; lp->flags |= ISDN_NET_CONNECTED; @@ -3022,8 +3022,8 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone *peer) idx = p->local->isdn_slot; if (idx<0) return -ENOTCONN; /* for pre-bound channels, we need this extra check */ - if ( strncmp(dev->num[idx],"???",3) == 0 ) return -ENOTCONN; - strncpy(phone->phone,dev->num[idx],ISDN_MSNLEN); + if (strncmp(isdn_slot_num(idx),"???",3) == 0 ) return -ENOTCONN; + strncpy(phone->phone,isdn_slot_num(idx),ISDN_MSNLEN); phone->outgoing=USG_OUTGOING(isdn_slot_usage(idx)); if ( copy_to_user(peer,phone,sizeof(*peer)) ) return -EFAULT; return 0; diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 95df7c7bb3d3..48e3981ae04b 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -128,7 +128,7 @@ isdn_tty_readmodem(void) modem_info *info; for (i = 0; i < ISDN_MAX_CHANNELS; i++) { - if ((midx = dev->m_idx[i]) >= 0) { + if ((midx = isdn_slot_m_idx(i)) >= 0) { info = &dev->mdm.info[midx]; if (info->online) { r = 0; @@ -182,7 +182,7 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb) #endif modem_info *info; - if ((midx = dev->m_idx[i]) < 0) { + if ((midx = isdn_slot_m_idx(i)) < 0) { /* if midx is invalid, packet is not for tty */ return 0; } @@ -657,7 +657,7 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) isdn_tty_modem_result(RESULT_NO_DIALTONE, info); } else { info->isdn_slot = i; - dev->m_idx[i] = info->line; + isdn_slot_set_m_idx(i, info->line); info->last_dir = 1; strcpy(info->last_num, n); isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING); @@ -683,7 +683,7 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) cmd.parm.setup.si2 = m->mdmreg[REG_SI2]; info->dialing = 1; info->emu.carrierwait = 0; - strcpy(dev->num[i], n); + strcpy(isdn_slot_num(i), n); isdn_info_update(); isdn_slot_command(info->isdn_slot, ISDN_CMD_DIAL, &cmd); isdn_timer_ctrl(ISDN_TIMER_CARRIER, 1); @@ -754,7 +754,7 @@ isdn_tty_modem_hup(modem_info * info, int local) isdn_slot_all_eaz(slot); info->emu.mdmreg[REG_RINGCNT] = 0; isdn_slot_free(slot, 0); - dev->m_idx[slot] = -1; + isdn_slot_set_m_idx(slot, -1); info->isdn_slot = -1; } @@ -847,7 +847,7 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) isdn_tty_modem_result(RESULT_NO_DIALTONE, info); } else { info->isdn_slot = i; - dev->m_idx[i] = info->line; + isdn_slot_set_m_idx(i, info->line); isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING); info->last_dir = 1; // strcpy(info->last_num, n); @@ -926,7 +926,7 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) isdn_tty_modem_result(RESULT_NO_DIALTONE, info); } else { info->isdn_slot = i; - dev->m_idx[i] = info->line; + isdn_slot_set_m_idx(i, info->line); isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING); info->last_dir = 1; restore_flags(flags); @@ -2210,8 +2210,8 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) wret = matchret; if (!matchret) { /* EAZ is matching */ info->isdn_slot = idx; - dev->m_idx[idx] = info->line; - strcpy(dev->num[idx], nr); + isdn_slot_set_m_idx(idx, info->line); + strcpy(isdn_slot_num(idx), nr); strcpy(info->emu.cpn, eaz); info->emu.mdmreg[REG_SI1I] = si2bit[si1]; info->emu.mdmreg[REG_PLAN] = setup->plan; @@ -2246,7 +2246,7 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) if (i < 0) return 0; - if ((mi = dev->m_idx[i]) >= 0) { + if ((mi = isdn_slot_m_idx(i)) >= 0) { info = &dev->mdm.info[mi]; switch (c->command) { case ISDN_STAT_CINF: @@ -2682,7 +2682,7 @@ isdn_tty_modem_result(int code, modem_info * info) /* print CID, _before_ _every_ ring */ if (!(m->mdmreg[REG_CIDONCE] & BIT_CIDONCE)) { isdn_tty_at_cout("\r\nCALLER NUMBER: ", info); - isdn_tty_at_cout(dev->num[info->isdn_slot], info); + isdn_tty_at_cout(isdn_slot_num(info->isdn_slot), info); if (m->mdmreg[REG_CDN] & BIT_CDN) { isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); isdn_tty_at_cout(info->emu.cpn, info); @@ -2711,7 +2711,7 @@ isdn_tty_modem_result(int code, modem_info * info) (m->mdmreg[REG_RINGCNT] == 1)) { isdn_tty_at_cout("\r\n", info); isdn_tty_at_cout("CALLER NUMBER: ", info); - isdn_tty_at_cout(dev->num[info->isdn_slot], info); + isdn_tty_at_cout(isdn_slot_num(info->isdn_slot), info); if (m->mdmreg[REG_CDN] & BIT_CDN) { isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); isdn_tty_at_cout(info->emu.cpn, info); @@ -3223,7 +3223,7 @@ isdn_tty_cmd_ATA(modem_info * info) if (info->msr & UART_MSR_RI) { /* Accept incoming call */ info->last_dir = 0; - strcpy(info->last_num, dev->num[info->isdn_slot]); + strcpy(info->last_num, isdn_slot_num(info->isdn_slot)); m->mdmreg[REG_RINGCNT] = 0; info->msr &= ~UART_MSR_RI; l2 = m->mdmreg[REG_L2PROT]; @@ -3936,7 +3936,7 @@ isdn_tty_modem_escape(void) for (i = 0; i < ISDN_MAX_CHANNELS; i++) if (USG_MODEM(isdn_slot_usage(i))) - if ((midx = dev->m_idx[i]) >= 0) { + if ((midx = isdn_slot_m_idx(i)) >= 0) { modem_info *info = &dev->mdm.info[midx]; if (info->online) { ton = 1; diff --git a/drivers/isdn/i4l/isdn_ttyfax.c b/drivers/isdn/i4l/isdn_ttyfax.c index 95c275084ac7..2a08bc0c8d71 100644 --- a/drivers/isdn/i4l/isdn_ttyfax.c +++ b/drivers/isdn/i4l/isdn_ttyfax.c @@ -380,10 +380,10 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info * info) PARSE_ERROR1; } info->isdn_slot = i; - dev->m_idx[i] = info->line; + 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_USAGE_FAX); - dev->m_idx[info->isdn_slot] = -1; + isdn_slot_set_m_idx(i, -1); info->isdn_slot = -1; restore_flags(flags); } else { diff --git a/drivers/isdn/i4l/isdn_v110.c b/drivers/isdn/i4l/isdn_v110.c index 1c34adf9c448..1676de4975cc 100644 --- a/drivers/isdn/i4l/isdn_v110.c +++ b/drivers/isdn/i4l/isdn_v110.c @@ -515,14 +515,12 @@ buffer_full: } int -isdn_v110_stat_callback(int idx, isdn_ctrl * c) +isdn_v110_stat_callback(struct isdn_v110 *iv110, isdn_ctrl *c) { isdn_v110_stream *v = NULL; int i; int ret; - if (idx < 0) - return 0; switch (c->command) { case ISDN_STAT_BSENT: /* Keep the send-queue of the driver filled @@ -531,9 +529,9 @@ isdn_v110_stat_callback(int idx, isdn_ctrl * c) * send down an Idle-Frame (or an Sync-Frame, if * v->SyncInit != 0). */ - if (!(v = dev->v110[idx])) + if (!(v = iv110->v110)) return 0; - atomic_inc(&dev->v110use[idx]); + atomic_inc(&iv110->v110use); if (v->skbidle > 0) { v->skbidle--; ret = 1; @@ -560,38 +558,38 @@ isdn_v110_stat_callback(int idx, isdn_ctrl * c) } else break; } - atomic_dec(&dev->v110use[idx]); + atomic_dec(&iv110->v110use); return ret; case ISDN_STAT_DHUP: case ISDN_STAT_BHUP: while (1) { - atomic_inc(&dev->v110use[idx]); - if (atomic_dec_and_test(&dev->v110use[idx])) { - isdn_v110_close(dev->v110[idx]); - dev->v110[idx] = NULL; + atomic_inc(&iv110->v110use); + if (atomic_dec_and_test(&iv110->v110use)) { + isdn_v110_close(iv110->v110); + iv110->v110 = NULL; break; } sti(); } break; case ISDN_STAT_BCONN: - if (dev->v110emu[idx] && (dev->v110[idx] == NULL)) { + if (iv110->v110emu && (iv110->v110 == NULL)) { int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen; int maxsize = dev->drv[c->driver]->interface->maxbufsize; - atomic_inc(&dev->v110use[idx]); - switch (dev->v110emu[idx]) { + atomic_inc(&iv110->v110use); + switch (iv110->v110emu) { case ISDN_PROTO_L2_V11096: - dev->v110[idx] = isdn_v110_open(V110_9600, hdrlen, maxsize); + iv110->v110 = isdn_v110_open(V110_9600, hdrlen, maxsize); break; case ISDN_PROTO_L2_V11019: - dev->v110[idx] = isdn_v110_open(V110_19200, hdrlen, maxsize); + iv110->v110 = isdn_v110_open(V110_19200, hdrlen, maxsize); break; case ISDN_PROTO_L2_V11038: - dev->v110[idx] = isdn_v110_open(V110_38400, hdrlen, maxsize); + iv110->v110 = isdn_v110_open(V110_38400, hdrlen, maxsize); break; default:; } - if ((v = dev->v110[idx])) { + 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) { @@ -603,8 +601,8 @@ isdn_v110_stat_callback(int idx, isdn_ctrl * c) v->skbidle++; } } else - printk(KERN_WARNING "isdn_v110: Couldn't open stream for chan %d\n", idx); - atomic_dec(&dev->v110use[idx]); + printk(KERN_WARNING "isdn_v110: Couldn't open stream\n"); + atomic_dec(&iv110->v110use); } break; default: diff --git a/drivers/isdn/i4l/isdn_v110.h b/drivers/isdn/i4l/isdn_v110.h index d557a769021d..b6563c259e44 100644 --- a/drivers/isdn/i4l/isdn_v110.h +++ b/drivers/isdn/i4l/isdn_v110.h @@ -9,8 +9,14 @@ * */ -#ifndef _isdn_v110_h_ -#define _isdn_v110_h_ +#ifndef ISDN_V110_H +#define ISDN_V110_H + +struct isdn_v110 { + int v110emu; /* V.110 emulator-mode 0=none */ + atomic_t v110use; /* Usage-Semaphore for stream */ + isdn_v110_stream *v110; /* V.110 private data */ +}; /* * isdn_v110_encode will take raw data and encode it using V.110 @@ -23,7 +29,7 @@ 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 int isdn_v110_stat_callback(int, isdn_ctrl *); +extern int isdn_v110_stat_callback(struct isdn_v110 *v110, isdn_ctrl *); extern void isdn_v110_close(isdn_v110_stream * v); #endif diff --git a/include/linux/isdn.h b/include/linux/isdn.h index e414029906cf..393daa74c73d 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -605,21 +605,11 @@ 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 num[ISDN_MAX_CHANNELS][ISDN_MSNLEN]; - /* Remote number of active ch.*/ - int m_idx[ISDN_MAX_CHANNELS]; /* Index for mdm.... */ driver *drv[ISDN_MAX_DRIVERS]; /* Array of drivers */ isdn_net_dev *netdev; /* Linked list of net-if's */ char drvid[ISDN_MAX_DRIVERS][20];/* Driver-ID */ struct task_struct *profd; /* For iprofd */ modem mdm; /* tty-driver-data */ - isdn_net_dev *rx_netdev[ISDN_MAX_CHANNELS]; /* rx netdev-pointers */ - isdn_net_dev *st_netdev[ISDN_MAX_CHANNELS]; /* stat netdev-pointers */ - ulong ibytes[ISDN_MAX_CHANNELS]; /* Statistics incoming bytes */ - ulong obytes[ISDN_MAX_CHANNELS]; /* Statistics outgoing bytes */ - int v110emu[ISDN_MAX_CHANNELS];/* V.110 emulator-mode 0=none */ - atomic_t v110use[ISDN_MAX_CHANNELS];/* Usage-Semaphore for stream */ - isdn_v110_stream *v110[ISDN_MAX_CHANNELS]; /* V.110 private data */ struct semaphore sem; /* serialize list access*/ unsigned long global_features; #ifdef CONFIG_DEVFS_FS -- cgit v1.2.3 From 93796c1f36d3d88f6ddb2cf34c19d5cb1e7e4fa7 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Fri, 2 Aug 2002 00:45:58 -0500 Subject: ISDN: More I4L linklayer cleanup Add a helper function to prepare for and start dialing, removing duplicated code from isdn_tty.c/isdn_net.c. Move some parts of the big switch statement in isdn_net.c into their own functions. --- drivers/isdn/i4l/isdn_common.c | 48 +++++ drivers/isdn/i4l/isdn_common.h | 11 ++ drivers/isdn/i4l/isdn_net.c | 428 ++++++++++++++++++++--------------------- drivers/isdn/i4l/isdn_tty.c | 36 ++-- include/linux/isdn.h | 2 +- include/linux/isdnif.h | 2 - init/main.c | 1 - 7 files changed, 279 insertions(+), 249 deletions(-) (limited to 'include') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 464abbc87775..b5eff0c62a0d 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "isdn_common.h" #include "isdn_tty.h" #include "isdn_net.h" @@ -2166,6 +2167,53 @@ isdn_slot_command(int sl, int cmd, isdn_ctrl *ctrl) return isdn_command(ctrl); } +int +isdn_slot_dial(int sl, struct dial_info *dial) +{ + isdn_ctrl cmd; + int retval; + char *msn = isdn_slot_map_eaz2msn(sl, dial->msn); + + /* check for DOV */ + if (dial->si1 == 7 && tolower(dial->phone[0]) == 'v') { /* DOV call */ + dial->si1 = 1; + dial->phone++; /* skip v/V */ + } + + strcpy(isdn_slot_num(sl), dial->phone); + isdn_slot_set_usage(sl, isdn_slot_usage(sl) | ISDN_USAGE_OUTGOING); + + retval = isdn_slot_command(sl, ISDN_CMD_CLREAZ, &cmd); + if (retval) + return retval; + + strcpy(cmd.parm.num, msn); + retval = isdn_slot_command(sl, ISDN_CMD_SETEAZ, &cmd); + + cmd.arg = dial->l2_proto << 8; + cmd.parm.fax = dial->fax; + retval = isdn_slot_command(sl, ISDN_CMD_SETL2, &cmd); + if (retval) + return retval; + + cmd.arg = dial->l3_proto << 8; + retval = isdn_slot_command(sl, ISDN_CMD_SETL3, &cmd); + if (retval) + return retval; + + cmd.parm.setup.si1 = dial->si1; + cmd.parm.setup.si2 = dial->si2; + 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, + cmd.parm.setup.si1, cmd.parm.setup.si2, + dial->l2_proto, dial->l3_proto); + + return isdn_slot_command(sl, ISDN_CMD_DIAL, &cmd); +} + void isdn_slot_all_eaz(int sl) { diff --git a/drivers/isdn/i4l/isdn_common.h b/drivers/isdn/i4l/isdn_common.h index 7b7063375ce4..ee5863cd9409 100644 --- a/drivers/isdn/i4l/isdn_common.h +++ b/drivers/isdn/i4l/isdn_common.h @@ -42,10 +42,21 @@ extern int isdn_add_channels(driver *, int, int, int); extern void isdn_dumppkt(char *, u_char *, int, int); #endif +struct dial_info { + int l2_proto; + int l3_proto; + struct T30_s *fax; + unsigned char si1; + unsigned char si2; + unsigned char *msn; + unsigned char *phone; +}; + extern int isdn_get_free_slot(int, int, int, int, int, char *); extern void isdn_slot_free(int slot, int usage); extern void isdn_slot_all_eaz(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_readbchan(int slot, u_char *, u_char *, int); diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c index ffd6031d6e5d..d32522654c46 100644 --- a/drivers/isdn/i4l/isdn_net.c +++ b/drivers/isdn/i4l/isdn_net.c @@ -556,6 +556,124 @@ isdn_net_stat_callback(int idx, isdn_ctrl *c) return 0; } +/* Initiate dialout. Set phone-number-pointer to first number + * of interface. + */ +static int +init_dialout(isdn_net_local *lp) +{ + unsigned long flags; + + save_flags(flags); + cli(); + lp->dial = lp->phone[1]; + restore_flags(flags); + + if (!lp->dial) { + printk(KERN_WARNING "%s: phone number deleted?\n", + lp->name); + isdn_net_hangup(&lp->netdev->dev); + return 0; + } + if (lp->dialtimeout > 0 && + (lp->dialstarted == 0 || + time_after(jiffies, lp->dialstarted + lp->dialtimeout + lp->dialwait))) { + lp->dialstarted = jiffies; + lp->dialwait_timer = 0; + } + lp->dialstate = 2; + return 1; +} + +/* Setup interface, dial current phone-number, switch to next number. + * If list of phone-numbers is exhausted, increment + * retry-counter. + */ +static int +do_dialout(isdn_net_local *lp) +{ + unsigned long flags; + + if(dev->global_flags & ISDN_GLOBAL_STOPPED || (ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_OFF)) { + char *s; + if (dev->global_flags & ISDN_GLOBAL_STOPPED) + s = "dial suppressed: isdn system stopped"; + else + s = "dial suppressed: dialmode `off'"; + isdn_net_unreachable(&lp->netdev->dev, 0, s); + isdn_net_hangup(&lp->netdev->dev); + return 0; + } + + save_flags(flags); + cli(); + if (!lp->dial) { + restore_flags(flags); + printk(KERN_WARNING "%s: phone number deleted?\n", + lp->name); + isdn_net_hangup(&lp->netdev->dev); + return 0; + } + if (!strncmp(lp->dial->num, "LEASED", strlen("LEASED"))) { + restore_flags(flags); + lp->dialstate = 4; + printk(KERN_INFO "%s: Open leased line ...\n", lp->name); + } else { + struct dial_info dial = { + .l2_proto = lp->l2_proto, + .l3_proto = lp->l3_proto, + .si1 = 7, + .si2 = 0, + .msn = lp->msn, + .phone = lp->dial->num, + }; + if(lp->dialtimeout > 0) { + if (time_after(jiffies, lp->dialstarted + lp->dialtimeout)) { + restore_flags(flags); + lp->dialwait_timer = jiffies + lp->dialwait; + lp->dialstarted = 0; + isdn_net_unreachable(&lp->netdev->dev, 0, "dial: timed out"); + isdn_net_hangup(&lp->netdev->dev); + return 0; + } + } + /* + * Switch to next number or back to start if at end of list. + */ + if (!(lp->dial = (isdn_net_phone *) lp->dial->next)) { + lp->dial = lp->phone[1]; + lp->dialretry++; + + if (lp->dialretry > lp->dialmax) { + restore_flags(flags); + if (lp->dialtimeout == 0) { + lp->dialwait_timer = jiffies + lp->dialwait; + lp->dialstarted = 0; + isdn_net_unreachable(&lp->netdev->dev, 0, "dial: tried all numbers dialmax times"); + } + isdn_net_hangup(&lp->netdev->dev); + return 0; + } + } + restore_flags(flags); + lp->dtimer = 0; + isdn_slot_dial(lp->isdn_slot, &dial); + } + lp->huptimer = 0; + lp->outgoing = 1; + if (lp->chargeint) { + lp->hupflags |= ISDN_HAVECHARGE; + lp->hupflags &= ~ISDN_WAITCHARGE; + } else { + lp->hupflags |= ISDN_WAITCHARGE; + lp->hupflags &= ~ISDN_HAVECHARGE; + } + lp->dialstate = + (lp->cbdelay && + (lp->flags & ISDN_NET_CBOUT)) ? 12 : 4; + return 1; +} + /* * Perform dialout for net-interfaces and timeout-handling for * D-Channel-up and B-Channel-up Messages. @@ -571,11 +689,9 @@ isdn_net_dial(void) { isdn_net_dev *p = dev->netdev; int anymore = 0; - unsigned long flags; isdn_ctrl cmd; - u_char *phone_number; - while (p) { + for (p = dev->netdev; p; p = p->next) { isdn_net_local *lp = p->local; #ifdef ISDN_DEBUG_NET_DIAL @@ -583,234 +699,106 @@ isdn_net_dial(void) printk(KERN_DEBUG "%s: dialstate=%d\n", lp->name, lp->dialstate); #endif switch (lp->dialstate) { - case 0: - /* Nothing to do for this interface */ - break; - case 1: - /* Initiate dialout. Set phone-number-pointer to first number - * of interface. - */ - save_flags(flags); - cli(); - lp->dial = lp->phone[1]; - restore_flags(flags); - if (!lp->dial) { - printk(KERN_WARNING "%s: phone number deleted?\n", - lp->name); - isdn_net_hangup(&p->dev); - break; - } - anymore = 1; - - if(lp->dialtimeout > 0) - if(lp->dialstarted == 0 || time_after(jiffies, lp->dialstarted + lp->dialtimeout + lp->dialwait)) { - lp->dialstarted = jiffies; - lp->dialwait_timer = 0; - } - - lp->dialstate++; - /* Fall through */ - case 2: - /* Prepare dialing. Clear EAZ, then set EAZ. */ - isdn_slot_command(lp->isdn_slot, ISDN_CMD_CLREAZ, &cmd); - sprintf(cmd.parm.num, "%s", isdn_slot_map_eaz2msn(lp->isdn_slot, lp->msn)); - isdn_slot_command(lp->isdn_slot, ISDN_CMD_SETEAZ, &cmd); - lp->dialretry = 0; - anymore = 1; - lp->dialstate++; - /* Fall through */ - case 3: - /* Setup interface, dial current phone-number, switch to next number. - * If list of phone-numbers is exhausted, increment - * retry-counter. - */ - if(dev->global_flags & ISDN_GLOBAL_STOPPED || (ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_OFF)) { - char *s; - if (dev->global_flags & ISDN_GLOBAL_STOPPED) - s = "dial suppressed: isdn system stopped"; - else - s = "dial suppressed: dialmode `off'"; - isdn_net_unreachable(&p->dev, 0, s); - isdn_net_hangup(&p->dev); - break; - } - cmd.arg = lp->l2_proto << 8; - isdn_slot_command(lp->isdn_slot, ISDN_CMD_SETL2, &cmd); - cmd.arg = lp->l3_proto << 8; - isdn_slot_command(lp->isdn_slot, ISDN_CMD_SETL3, &cmd); - save_flags(flags); - cli(); - if (!lp->dial) { - restore_flags(flags); - printk(KERN_WARNING "%s: phone number deleted?\n", - lp->name); - isdn_net_hangup(&p->dev); - break; - } - if (!strncmp(lp->dial->num, "LEASED", strlen("LEASED"))) { - restore_flags(flags); - lp->dialstate = 4; - printk(KERN_INFO "%s: Open leased line ...\n", lp->name); - } else { - if(lp->dialtimeout > 0) - if (time_after(jiffies, lp->dialstarted + lp->dialtimeout)) { - restore_flags(flags); - lp->dialwait_timer = jiffies + lp->dialwait; - lp->dialstarted = 0; - isdn_net_unreachable(&p->dev, 0, "dial: timed out"); - isdn_net_hangup(&p->dev); - break; - } - - cmd.parm.setup.si2 = 0; - - /* check for DOV */ - phone_number = lp->dial->num; - if ((*phone_number == 'v') || - (*phone_number == 'V')) { /* DOV call */ - cmd.parm.setup.si1 = 1; - } else { /* DATA call */ - cmd.parm.setup.si1 = 7; - } - - strcpy(cmd.parm.setup.phone, phone_number); - /* - * Switch to next number or back to start if at end of list. - */ - if (!(lp->dial = (isdn_net_phone *) lp->dial->next)) { - lp->dial = lp->phone[1]; - lp->dialretry++; - - if (lp->dialretry > lp->dialmax) { - restore_flags(flags); - if (lp->dialtimeout == 0) { - lp->dialwait_timer = jiffies + lp->dialwait; - lp->dialstarted = 0; - isdn_net_unreachable(&p->dev, 0, "dial: tried all numbers dialmax times"); - } - isdn_net_hangup(&p->dev); - break; - } - } - restore_flags(flags); - sprintf(cmd.parm.setup.eazmsn, "%s", - isdn_slot_map_eaz2msn(lp->isdn_slot, lp->msn)); - if (lp->isdn_slot >= 0) { - strcpy(isdn_slot_num(lp->isdn_slot), cmd.parm.setup.phone); - isdn_slot_set_usage(lp->isdn_slot, isdn_slot_usage(lp->isdn_slot) | ISDN_USAGE_OUTGOING); - } - printk(KERN_INFO "%s: dialing %d %s... %s\n", lp->name, - lp->dialretry, cmd.parm.setup.phone, - (cmd.parm.setup.si1 == 1) ? "DOV" : ""); - lp->dtimer = 0; -#ifdef ISDN_DEBUG_NET_DIAL - printk(KERN_DEBUG "dial: d=%d c=%d\n", lp->isdn_device, - lp->isdn_channel); -#endif - isdn_slot_command(lp->isdn_slot, ISDN_CMD_DIAL, &cmd); - } - lp->huptimer = 0; - lp->outgoing = 1; - if (lp->chargeint) { - lp->hupflags |= ISDN_HAVECHARGE; - lp->hupflags &= ~ISDN_WAITCHARGE; - } else { - lp->hupflags |= ISDN_WAITCHARGE; - lp->hupflags &= ~ISDN_HAVECHARGE; - } - anymore = 1; - lp->dialstate = - (lp->cbdelay && - (lp->flags & ISDN_NET_CBOUT)) ? 12 : 4; - break; - case 4: - /* Wait for D-Channel-connect. - * If timeout, switch back to state 3. - * Dialmax-handling moved to state 3. - */ - if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) + case 0: + /* Nothing to do for this interface */ + break; + case 1: + anymore = init_dialout(lp); + /* Fall through */ + case 2: + lp->dialretry = 0; + anymore = 1; + lp->dialstate++; + /* Fall through */ + case 3: + anymore = do_dialout(lp); + break; + case 4: + /* Wait for D-Channel-connect. + * If timeout, switch back to state 3. + * Dialmax-handling moved to state 3. + */ + if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) lp->dialstate = 3; - anymore = 1; - break; - case 5: - /* Got D-Channel-Connect, send B-Channel-request */ - anymore = 1; - lp->dtimer = 0; - lp->dialstate++; - isdn_slot_command(lp->isdn_slot, ISDN_CMD_ACCEPTB, &cmd); - break; - case 6: - /* Wait for B- or D-Channel-connect. If timeout, - * switch back to state 3. - */ + anymore = 1; + break; + case 5: + /* Got D-Channel-Connect, send B-Channel-request */ + anymore = 1; + lp->dtimer = 0; + lp->dialstate++; + isdn_slot_command(lp->isdn_slot, ISDN_CMD_ACCEPTB, &cmd); + break; + case 6: + /* Wait for B- or D-Channel-connect. If timeout, + * switch back to state 3. + */ #ifdef ISDN_DEBUG_NET_DIAL - printk(KERN_DEBUG "dialtimer2: %d\n", lp->dtimer); + printk(KERN_DEBUG "dialtimer2: %d\n", lp->dtimer); #endif - if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) - lp->dialstate = 3; - anymore = 1; - break; - case 7: - /* Got incoming Call, setup L2 and L3 protocols, - * then wait for D-Channel-connect - */ + if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) + lp->dialstate = 3; + anymore = 1; + break; + case 7: + /* Got incoming Call, setup L2 and L3 protocols, + * then wait for D-Channel-connect + */ #ifdef ISDN_DEBUG_NET_DIAL - printk(KERN_DEBUG "dialtimer4: %d\n", lp->dtimer); + printk(KERN_DEBUG "dialtimer4: %d\n", lp->dtimer); #endif - cmd.arg = lp->l2_proto << 8; - isdn_slot_command(lp->isdn_slot, ISDN_CMD_SETL2, &cmd); - cmd.arg = lp->l3_proto << 8; - isdn_slot_command(lp->isdn_slot, ISDN_CMD_SETL3, &cmd); - if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT15) - isdn_net_hangup(&p->dev); - else { - anymore = 1; - lp->dialstate++; - } - break; - case 9: - /* Got incoming D-Channel-Connect, send B-Channel-request */ - isdn_slot_command(lp->isdn_slot, ISDN_CMD_ACCEPTB, &cmd); + cmd.arg = lp->l2_proto << 8; + isdn_slot_command(lp->isdn_slot, ISDN_CMD_SETL2, &cmd); + cmd.arg = lp->l3_proto << 8; + isdn_slot_command(lp->isdn_slot, ISDN_CMD_SETL3, &cmd); + if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT15) + isdn_net_hangup(&p->dev); + else { anymore = 1; - lp->dtimer = 0; lp->dialstate++; - break; - case 8: - case 10: - /* Wait for B- or D-channel-connect */ + } + break; + case 9: + /* Got incoming D-Channel-Connect, send B-Channel-request */ + isdn_slot_command(lp->isdn_slot, ISDN_CMD_ACCEPTB, &cmd); + anymore = 1; + lp->dtimer = 0; + lp->dialstate++; + break; + case 8: + case 10: + /* Wait for B- or D-channel-connect */ #ifdef ISDN_DEBUG_NET_DIAL - printk(KERN_DEBUG "dialtimer4: %d\n", lp->dtimer); + printk(KERN_DEBUG "dialtimer4: %d\n", lp->dtimer); #endif - if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) - isdn_net_hangup(&p->dev); - else - anymore = 1; - break; - case 11: - /* Callback Delay */ - if (lp->dtimer++ > lp->cbdelay) - lp->dialstate = 1; - anymore = 1; - break; - case 12: - /* Remote does callback. Hangup after cbdelay, then wait for incoming - * call (in state 4). - */ - if (lp->dtimer++ > lp->cbdelay) - { - printk(KERN_INFO "%s: hangup waiting for callback ...\n", lp->name); - lp->dtimer = 0; - lp->dialstate = 4; - isdn_slot_command(lp->isdn_slot, ISDN_CMD_HANGUP, &cmd); - isdn_slot_all_eaz(lp->isdn_slot); - } + if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) + isdn_net_hangup(&p->dev); + else anymore = 1; - break; - default: - printk(KERN_WARNING "isdn_net: Illegal dialstate %d for device %s\n", - lp->dialstate, lp->name); + break; + case 11: + /* Callback Delay */ + if (lp->dtimer++ > lp->cbdelay) + lp->dialstate = 1; + anymore = 1; + break; + case 12: + /* Remote does callback. Hangup after cbdelay, then wait for incoming + * call (in state 4). + */ + if (lp->dtimer++ > lp->cbdelay) { + printk(KERN_INFO "%s: hangup waiting for callback ...\n", lp->name); + lp->dtimer = 0; + lp->dialstate = 4; + isdn_slot_command(lp->isdn_slot, ISDN_CMD_HANGUP, &cmd); + isdn_slot_all_eaz(lp->isdn_slot); + } + anymore = 1; + break; + default: + printk(KERN_WARNING "isdn_net: Illegal dialstate %d for device %s\n", + lp->dialstate, lp->name); } - p = (isdn_net_dev *) p->next; } isdn_timer_ctrl(ISDN_TIMER_NETDIAL, anymore); } diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 48e3981ae04b..2e06c1627bd2 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -626,7 +626,6 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) int usg = ISDN_USAGE_MODEM; int si = 7; int l2 = m->mdmreg[REG_L2PROT]; - isdn_ctrl cmd; ulong flags; int i; int j; @@ -656,36 +655,29 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) restore_flags(flags); isdn_tty_modem_result(RESULT_NO_DIALTONE, info); } else { + struct dial_info dial = { + .l2_proto = l2, + .l3_proto = m->mdmreg[REG_L3PROT], + .si1 = si, + .si2 = m->mdmreg[REG_SI2], + .msn = m->msn, + .phone = n, + }; info->isdn_slot = i; isdn_slot_set_m_idx(i, info->line); info->last_dir = 1; + info->last_l2 = l2; strcpy(info->last_num, n); - isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING); restore_flags(flags); - isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd); - strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn)); - isdn_slot_command(info->isdn_slot, ISDN_CMD_SETEAZ, &cmd); - info->last_l2 = l2; - cmd.arg = l2 << 8; - isdn_slot_command(info->isdn_slot, ISDN_CMD_SETL2, &cmd); - cmd.arg = m->mdmreg[REG_L3PROT] << 8; #ifdef CONFIG_ISDN_TTY_FAX if (l2 == ISDN_PROTO_L2_FAX) { - cmd.parm.fax = info->fax; + dial.fax = info->fax; info->fax->direction = ISDN_TTY_FAX_CONN_OUT; } #endif - isdn_slot_command(info->isdn_slot, ISDN_CMD_SETL3, &cmd); - sprintf(cmd.parm.setup.phone, "%s", n); - sprintf(cmd.parm.setup.eazmsn, "%s", - isdn_slot_map_eaz2msn(info->isdn_slot, m->msn)); - cmd.parm.setup.si1 = si; - cmd.parm.setup.si2 = m->mdmreg[REG_SI2]; info->dialing = 1; info->emu.carrierwait = 0; - strcpy(isdn_slot_num(i), n); - isdn_info_update(); - isdn_slot_command(info->isdn_slot, ISDN_CMD_DIAL, &cmd); + isdn_slot_dial(info->isdn_slot, &dial); isdn_timer_ctrl(ISDN_TIMER_CARRIER, 1); } } @@ -852,9 +844,6 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) info->last_dir = 1; // strcpy(info->last_num, n); restore_flags(flags); - isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd); - strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn)); - isdn_slot_command(info->isdn_slot, ISDN_CMD_SETEAZ, &cmd); info->last_l2 = l2; cmd.arg = l2 << 8; isdn_slot_command(info->isdn_slot, ISDN_CMD_SETL2, &cmd); @@ -930,9 +919,6 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING); info->last_dir = 1; restore_flags(flags); - isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd); - strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn)); - isdn_slot_command(info->isdn_slot, ISDN_CMD_SETEAZ, &cmd); info->last_l2 = l2; cmd.arg = l2 << 8; isdn_slot_command(info->isdn_slot, ISDN_CMD_SETL2, &cmd); diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 393daa74c73d..8255506b4b31 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -391,7 +391,7 @@ typedef struct isdn_net_dev_s { channels, which are currently online */ spinlock_t queue_lock; /* lock to protect queue */ - void *next; /* Pointer to next isdn-interface */ + struct isdn_net_dev_s *next; /* Pointer to next isdn-interface */ struct net_device dev; /* interface to upper levels */ #ifdef CONFIG_ISDN_PPP ippp_bundle * pb; /* pointer to the common bundle structure diff --git a/include/linux/isdnif.h b/include/linux/isdnif.h index 672e8b15cbf6..cb025c8e4759 100644 --- a/include/linux/isdnif.h +++ b/include/linux/isdnif.h @@ -418,9 +418,7 @@ typedef struct { char display[85];/* display message data */ isdn_cmd_stat isdn_io; /* ISDN IO-parameter/result */ aux_s aux; /* for modem commands/indications */ -#ifdef CONFIG_ISDN_TTY_FAX T30_s *fax; /* Pointer to ttys fax struct */ -#endif ulong userdata; /* User Data */ } parm; } isdn_ctrl; diff --git a/init/main.c b/init/main.c index 93efbf4fb7f6..05ab832ff1f0 100644 --- a/init/main.c +++ b/init/main.c @@ -529,7 +529,6 @@ static void do_pre_smp_initcalls(void) extern int migration_init(void); extern int spawn_ksoftirqd(void); - migration_init(); spawn_ksoftirqd(); } -- cgit v1.2.3 From 83c5d21cd14d8b148561d2d85dd1b5d6cb59efe4 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Fri, 2 Aug 2002 04:21:18 -0500 Subject: ISDN: combine isdn_net_dev and isdn_net_local They were always allocated together and had a one-to-one relationship, so let's just make them one thing. --- drivers/isdn/i4l/isdn_common.c | 6 +- drivers/isdn/i4l/isdn_net.c | 170 ++++++++++++++++++++--------------------- drivers/isdn/i4l/isdn_net.h | 2 +- drivers/isdn/i4l/isdn_ppp.c | 22 +++--- include/linux/isdn.h | 2 +- 5 files changed, 97 insertions(+), 105 deletions(-) (limited to 'include') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index b5eff0c62a0d..4bf999f057f6 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -510,9 +510,9 @@ isdn_status_callback(isdn_ctrl * c) /* Schedule connection-setup */ isdn_net_dial(); for ( p = dev->netdev; p; p = p->next ) - if (p->local->isdn_slot == isdn_dc2minor(di, cmd.arg)) { - strcpy( cmd.parm.setup.eazmsn, p->local->msn ); - isdn_slot_command(p->local->isdn_slot, ISDN_CMD_ACCEPTD, &cmd); + if (p->local.isdn_slot == isdn_dc2minor(di, cmd.arg)) { + strcpy( cmd.parm.setup.eazmsn, p->local.msn ); + isdn_slot_command(p->local.isdn_slot, ISDN_CMD_ACCEPTD, &cmd); retval = 1; break; } diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c index 1969217e3817..8a036e740fb7 100644 --- a/drivers/isdn/i4l/isdn_net.c +++ b/drivers/isdn/i4l/isdn_net.c @@ -92,7 +92,7 @@ enum { */ static __inline__ int isdn_net_device_started(isdn_net_dev *n) { - isdn_net_local *lp = n->local; + isdn_net_local *lp = &n->local; struct net_device *dev; if (lp->master) @@ -360,7 +360,7 @@ isdn_net_autohup() anymore = 0; while (p) { - isdn_net_local *l = p->local; + isdn_net_local *l = &p->local; if (jiffies == last_jiffies) l->cps = l->transcount; else @@ -475,7 +475,7 @@ isdn_net_stat_callback(int idx, isdn_ctrl *c) if (!p) return 0; - lp = p->local; + lp = &p->local; return isdn_net_handle_event(lp, cmd, c); } @@ -882,7 +882,7 @@ isdn_net_dial(void) isdn_net_dev *p = dev->netdev; for (p = dev->netdev; p; p = p->next) { - isdn_net_local *lp = p->local; + isdn_net_local *lp = &p->local; if (lp->dialstate == ST_0) continue; @@ -1181,7 +1181,7 @@ isdn_net_xmit(struct net_device *ndev, struct sk_buff *skb) lp->sqfull = 0; } /* this is a hack to allow auto-hangup for slaves on moderate loads */ - nd->queue = nd->local; + nd->queue = &nd->local; } return retv; @@ -1932,7 +1932,7 @@ isdn_net_rcv_skb(int idx, struct sk_buff *skb) isdn_net_dev *p = isdn_slot_rx_netdev(idx); if (p) { - isdn_net_local *lp = p->local; + isdn_net_local *lp = &p->local; if ((lp->flags & ISDN_NET_CONNECTED) && (lp->dialstate == ST_0)) { isdn_net_receive(&p->dev, skb); @@ -2134,13 +2134,13 @@ isdn_net_swapbind(int drvidx) dbg_net_icall("n_fi: swapping ch of %d\n", drvidx); p = dev->netdev; while (p) { - if (p->local->pre_device == drvidx) - switch (p->local->pre_channel) { + if (p->local.pre_device == drvidx) + switch (p->local.pre_channel) { case 0: - p->local->pre_channel = 1; + p->local.pre_channel = 1; break; case 1: - p->local->pre_channel = 0; + p->local.pre_channel = 0; break; } p = (isdn_net_dev *) p->next; @@ -2225,7 +2225,7 @@ p = dev->netdev; dev->usage[idx]); while (p) { int matchret; - isdn_net_local *lp = p->local; + isdn_net_local *lp = &p->local; /* If last check has triggered as binding-swap, revert it */ switch (swapped) { @@ -2490,7 +2490,7 @@ isdn_net_findif(char *name) isdn_net_dev *p = dev->netdev; while (p) { - if (!strcmp(p->local->name, name)) + if (!strcmp(p->local.name, name)) return p; p = (isdn_net_dev *) p->next; } @@ -2572,7 +2572,7 @@ isdn_net_force_dial(char *name) if (!p) return -ENODEV; - return (isdn_net_force_dial_lp(p->local)); + return (isdn_net_force_dial_lp(&p->local)); } /* @@ -2593,26 +2593,20 @@ isdn_net_new(char *name, struct net_device *master) return NULL; } memset(netdev, 0, sizeof(isdn_net_dev)); - if (!(netdev->local = (isdn_net_local *) kmalloc(sizeof(isdn_net_local), GFP_KERNEL))) { - printk(KERN_WARNING "isdn_net: Could not allocate device locals\n"); - kfree(netdev); - return NULL; - } - memset(netdev->local, 0, sizeof(isdn_net_local)); if (name == NULL) - strcpy(netdev->local->name, " "); + strcpy(netdev->local.name, " "); else - strcpy(netdev->local->name, name); - strcpy(netdev->dev.name, netdev->local->name); - netdev->dev.priv = netdev->local; + strcpy(netdev->local.name, name); + strcpy(netdev->dev.name, netdev->local.name); + netdev->dev.priv = &netdev->local; netdev->dev.init = isdn_net_init; - netdev->local->p_encap = ISDN_NET_ENCAP_RAWIP; + netdev->local.p_encap = ISDN_NET_ENCAP_RAWIP; if (master) { /* Device shall be a slave */ struct net_device *p = (((isdn_net_local *) master->priv)->slave); struct net_device *q = master; - netdev->local->master = master; + netdev->local.master = master; /* Put device at end of slave-chain */ while (p) { q = p; @@ -2628,49 +2622,48 @@ isdn_net_new(char *name, struct net_device *master) netdev->dev.watchdog_timeo = ISDN_NET_TX_TIMEOUT; if (register_netdev(&netdev->dev) != 0) { printk(KERN_WARNING "isdn_net: Could not register net-device\n"); - kfree(netdev->local); kfree(netdev); return NULL; } } - netdev->local->magic = ISDN_NET_MAGIC; + netdev->local.magic = ISDN_NET_MAGIC; - netdev->queue = netdev->local; + netdev->queue = &netdev->local; spin_lock_init(&netdev->queue_lock); - netdev->local->last = netdev->local; - netdev->local->netdev = netdev; - netdev->local->next = netdev->local; - - netdev->local->tqueue.sync = 0; - netdev->local->tqueue.routine = isdn_net_softint; - netdev->local->tqueue.data = netdev->local; - spin_lock_init(&netdev->local->xmit_lock); - - netdev->local->isdn_slot = -1; - netdev->local->pre_device = -1; - netdev->local->pre_channel = -1; - netdev->local->exclusive = -1; - netdev->local->ppp_slot = -1; - netdev->local->pppbind = -1; - skb_queue_head_init(&netdev->local->super_tx_queue); - netdev->local->l2_proto = ISDN_PROTO_L2_X75I; - netdev->local->l3_proto = ISDN_PROTO_L3_TRANS; - netdev->local->triggercps = 6000; - netdev->local->slavedelay = 10 * HZ; - netdev->local->hupflags = ISDN_INHUP; /* Do hangup even on incoming calls */ - netdev->local->onhtime = 10; /* Default hangup-time for saving costs + netdev->local.last = &netdev->local; + netdev->local.netdev = netdev; + netdev->local.next = &netdev->local; + + netdev->local.tqueue.sync = 0; + netdev->local.tqueue.routine = isdn_net_softint; + netdev->local.tqueue.data = &netdev->local; + spin_lock_init(&netdev->local.xmit_lock); + + netdev->local.isdn_slot = -1; + netdev->local.pre_device = -1; + netdev->local.pre_channel = -1; + netdev->local.exclusive = -1; + netdev->local.ppp_slot = -1; + netdev->local.pppbind = -1; + skb_queue_head_init(&netdev->local.super_tx_queue); + netdev->local.l2_proto = ISDN_PROTO_L2_X75I; + netdev->local.l3_proto = ISDN_PROTO_L3_TRANS; + netdev->local.triggercps = 6000; + netdev->local.slavedelay = 10 * HZ; + netdev->local.hupflags = ISDN_INHUP; /* Do hangup even on incoming calls */ + netdev->local.onhtime = 10; /* Default hangup-time for saving costs of those who forget configuring this */ - netdev->local->dialmax = 1; - netdev->local->flags = ISDN_NET_CBHUP | ISDN_NET_DM_MANUAL; /* Hangup before Callback, manual dial */ - netdev->local->cbdelay = 25; /* Wait 5 secs before Callback */ - netdev->local->dialtimeout = -1; /* Infinite Dial-Timeout */ - netdev->local->dialwait = 5 * HZ; /* Wait 5 sec. after failed dial */ - netdev->local->dialstarted = 0; /* Jiffies of last dial-start */ - netdev->local->dialwait_timer = 0; /* Jiffies of earliest next dial-start */ + netdev->local.dialmax = 1; + netdev->local.flags = ISDN_NET_CBHUP | ISDN_NET_DM_MANUAL; /* Hangup before Callback, manual dial */ + netdev->local.cbdelay = 25; /* Wait 5 secs before Callback */ + netdev->local.dialtimeout = -1; /* Infinite Dial-Timeout */ + netdev->local.dialwait = 5 * HZ; /* Wait 5 sec. after failed dial */ + netdev->local.dialstarted = 0; /* Jiffies of last dial-start */ + netdev->local.dialwait_timer = 0; /* Jiffies of earliest next dial-start */ /* Put into to netdev-chain */ - netdev->next = (void *) dev->netdev; + netdev->next = dev->netdev; dev->netdev = netdev; return netdev->dev.name; } @@ -2692,7 +2685,7 @@ isdn_net_newslave(char *parm) if (!(n = isdn_net_findif(parm))) return NULL; /* Master must be a real interface, not a slave */ - if (n->local->master) + if (n->local.master) return NULL; /* Master must not be started yet */ if (isdn_net_device_started(n)) @@ -2721,7 +2714,7 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) ulong flags; #endif if (p) { - isdn_net_local *lp = p->local; + isdn_net_local *lp = &p->local; /* See if any registered driver supports the features we want */ features = ((1 << cfg->l2_proto) << ISDN_FEATURE_L2_SHIFT) | @@ -2781,7 +2774,7 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) case ISDN_NET_ENCAP_X25IFACE: #ifndef CONFIG_ISDN_X25 printk(KERN_WARNING "%s: isdn-x25 support not configured\n", - p->local->name); + p->local.name); return -EINVAL; #else p->dev.type = ARPHRD_X25; /* change ARP type */ @@ -2797,7 +2790,7 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) break; printk(KERN_WARNING "%s: encapsulation protocol %d not supported\n", - p->local->name, cfg->p_encap); + p->local.name, cfg->p_encap); return -EINVAL; } if (strlen(cfg->drvid)) { @@ -2947,7 +2940,7 @@ isdn_net_getcfg(isdn_net_ioctl_cfg * cfg) isdn_net_dev *p = isdn_net_findif(cfg->name); if (p) { - isdn_net_local *lp = p->local; + isdn_net_local *lp = &p->local; strcpy(cfg->eaz, lp->msn); cfg->exclusive = lp->exclusive; @@ -3006,8 +2999,8 @@ isdn_net_addphone(isdn_net_ioctl_phone * phone) if (!(n = (isdn_net_phone *) kmalloc(sizeof(isdn_net_phone), GFP_KERNEL))) return -ENOMEM; strcpy(n->num, phone->phone); - n->next = p->local->phone[phone->outgoing & 1]; - p->local->phone[phone->outgoing & 1] = n; + n->next = p->local.phone[phone->outgoing & 1]; + p->local.phone[phone->outgoing & 1] = n; return 0; } return -ENODEV; @@ -3029,7 +3022,7 @@ isdn_net_getphones(isdn_net_ioctl_phone * phone, char *phones) if (!p) return -ENODEV; inout &= 1; - for (n = p->local->phone[inout]; n; n = n->next) { + for (n = p->local.phone[inout]; n; n = n->next) { if (more) { put_user(' ', phones++); count++; @@ -3063,7 +3056,7 @@ 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 = p->local->isdn_slot; + idx = p->local.isdn_slot; if (idx<0) return -ENOTCONN; /* for pre-bound channels, we need this extra check */ if (strncmp(isdn_slot_num(idx),"???",3) == 0 ) return -ENOTCONN; @@ -3087,16 +3080,16 @@ isdn_net_delphone(isdn_net_ioctl_phone * phone) if (p) { save_flags(flags); cli(); - n = p->local->phone[inout]; + n = p->local.phone[inout]; m = NULL; while (n) { if (!strcmp(n->num, phone->phone)) { - if (p->local->dial == n) - p->local->dial = n->next; + if (p->local.dial == n) + p->local.dial = n->next; if (m) m->next = n->next; else - p->local->phone[inout] = n->next; + p->local.phone[inout] = n->next; kfree(n); restore_flags(flags); return 0; @@ -3124,15 +3117,15 @@ isdn_net_rmallphone(isdn_net_dev * p) save_flags(flags); cli(); for (i = 0; i < 2; i++) { - n = p->local->phone[i]; + n = p->local.phone[i]; while (n) { m = n->next; kfree(n); n = m; } - p->local->phone[i] = NULL; + p->local.phone[i] = NULL; } - p->local->dial = NULL; + p->local.dial = NULL; restore_flags(flags); return 0; } @@ -3147,9 +3140,9 @@ isdn_net_force_hangup(char *name) struct net_device *q; if (p) { - if (p->local->isdn_slot < 0) + if (p->local.isdn_slot < 0) return 1; - q = p->local->slave; + q = p->local.slave; /* If this interface has slaves, do a hangup for them also. */ while (q) { isdn_net_hangup(q); @@ -3182,16 +3175,16 @@ isdn_net_realrm(isdn_net_dev * p, isdn_net_dev * q) /* Free all phone-entries */ isdn_net_rmallphone(p); /* If interface is bound exclusive, free channel-usage */ - if (p->local->exclusive != -1) - isdn_unexclusive_channel(p->local->pre_device, p->local->pre_channel); - if (p->local->master) { + if (p->local.exclusive != -1) + isdn_unexclusive_channel(p->local.pre_device, p->local.pre_channel); + if (p->local.master) { /* It's a slave-device, so update master's slave-pointer if necessary */ - if (((isdn_net_local *) (p->local->master->priv))->slave == &p->dev) - ((isdn_net_local *) (p->local->master->priv))->slave = p->local->slave; + if (((isdn_net_local *) (p->local.master->priv))->slave == &p->dev) + ((isdn_net_local *) (p->local.master->priv))->slave = p->local.slave; } else { /* Unregister only if it's a master-device */ - p->dev.hard_header_cache = p->local->org_hhc; - p->dev.header_cache_update = p->local->org_hcu; + p->dev.hard_header_cache = p->local.org_hhc; + p->dev.header_cache_update = p->local.org_hcu; unregister_netdev(&p->dev); } /* Unlink device from chain */ @@ -3199,13 +3192,13 @@ isdn_net_realrm(isdn_net_dev * p, isdn_net_dev * q) q->next = p->next; else dev->netdev = p->next; - if (p->local->slave) { + if (p->local.slave) { /* If this interface has a slave, remove it also */ - char *slavename = ((isdn_net_local *) (p->local->slave->priv))->name; + char *slavename = ((isdn_net_local *) (p->local.slave->priv))->name; isdn_net_dev *n = dev->netdev; q = NULL; while (n) { - if (!strcmp(n->local->name, slavename)) { + if (!strcmp(n->local.name, slavename)) { isdn_net_realrm(n, q); break; } @@ -3217,7 +3210,6 @@ isdn_net_realrm(isdn_net_dev * p, isdn_net_dev * q) if (dev->netdev == NULL) isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 0); restore_flags(flags); - kfree(p->local); kfree(p); return 0; @@ -3236,7 +3228,7 @@ isdn_net_rm(char *name) p = dev->netdev; q = NULL; while (p) { - if (!strcmp(p->local->name, name)) + if (!strcmp(p->local.name, name)) return (isdn_net_realrm(p, q)); q = p; p = (isdn_net_dev *) p->next; @@ -3260,7 +3252,7 @@ isdn_net_rmall(void) save_flags(flags); cli(); while (dev->netdev) { - if (!dev->netdev->local->master) { + if (!dev->netdev->local.master) { /* Remove master-devices only, slaves get removed with their master */ if ((ret = isdn_net_realrm(dev->netdev, NULL))) { restore_flags(flags); diff --git a/drivers/isdn/i4l/isdn_net.h b/drivers/isdn/i4l/isdn_net.h index 593e147157ba..70d6f3e1ce0d 100644 --- a/drivers/isdn/i4l/isdn_net.h +++ b/drivers/isdn/i4l/isdn_net.h @@ -131,7 +131,7 @@ static __inline__ void isdn_net_rm_from_bundle(isdn_net_local *lp) if (master_lp->netdev->queue == lp) { master_lp->netdev->queue = lp->next; if (lp->next == lp) { /* last in queue */ - master_lp->netdev->queue = master_lp->netdev->local; + master_lp->netdev->queue = &master_lp->netdev->local; } } lp->next = lp->last = lp; /* (re)set own pointers */ diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c index 8a0d4123a979..3f09033391f1 100644 --- a/drivers/isdn/i4l/isdn_ppp.c +++ b/drivers/isdn/i4l/isdn_ppp.c @@ -169,7 +169,7 @@ isdn_ppp_bind(isdn_net_local * lp) char exclusive[ISDN_MAX_CHANNELS]; /* exclusive flags */ memset(exclusive, 0, ISDN_MAX_CHANNELS); while (net_dev) { /* step through net devices to find exclusive minors */ - isdn_net_local *lp = net_dev->local; + isdn_net_local *lp = &net_dev->local; if (lp->pppbind >= 0) exclusive[lp->pppbind] = 1; net_dev = net_dev->next; @@ -974,7 +974,7 @@ void isdn_ppp_receive(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buf int slot; int proto; - if (net_dev->local->master) + if (net_dev->local.master) BUG(); // we're called with the master device always slot = lp->ppp_slot; @@ -1077,12 +1077,12 @@ isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff case PPP_VJC_UNCOMP: if (is->debug & 0x20) printk(KERN_DEBUG "isdn_ppp: VJC_UNCOMP\n"); - if (net_dev->local->ppp_slot < 0) { + if (net_dev->local.ppp_slot < 0) { printk(KERN_ERR __FUNCTION__": net_dev->local->ppp_slot(%d) out of range\n", - net_dev->local->ppp_slot); + net_dev->local.ppp_slot); goto drop_packet; } - if (slhc_remember(ippp_table[net_dev->local->ppp_slot]->slcomp, skb->data, skb->len) <= 0) { + if (slhc_remember(ippp_table[net_dev->local.ppp_slot]->slcomp, skb->data, skb->len) <= 0) { printk(KERN_WARNING "isdn_ppp: received illegal VJC_UNCOMP frame!\n"); goto drop_packet; } @@ -1103,12 +1103,12 @@ isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff } skb_put(skb, skb_old->len + 128); memcpy(skb->data, skb_old->data, skb_old->len); - if (net_dev->local->ppp_slot < 0) { + if (net_dev->local.ppp_slot < 0) { printk(KERN_ERR __FUNCTION__": net_dev->local->ppp_slot(%d) out of range\n", - net_dev->local->ppp_slot); + net_dev->local.ppp_slot); goto drop_packet; } - pkt_len = slhc_uncompress(ippp_table[net_dev->local->ppp_slot]->slcomp, + pkt_len = slhc_uncompress(ippp_table[net_dev->local.ppp_slot]->slcomp, skb->data, skb_old->len); kfree_skb(skb_old); if (pkt_len < 0) @@ -1144,7 +1144,7 @@ isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff return; drop_packet: - net_dev->local->stats.rx_dropped++; + net_dev->local.stats.rx_dropped++; kfree_skb(skb); } @@ -1976,7 +1976,7 @@ isdn_ppp_dial_slave(char *name) if (!(ndev = isdn_net_findif(name))) return 1; - lp = ndev->local; + lp = &ndev->local; if (!(lp->flags & ISDN_NET_CONNECTED)) return 5; @@ -2007,7 +2007,7 @@ isdn_ppp_hangup_slave(char *name) if (!(ndev = isdn_net_findif(name))) return 1; - lp = ndev->local; + lp = &ndev->local; if (!(lp->flags & ISDN_NET_CONNECTED)) return 5; diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 8255506b4b31..0be4b46d71f8 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -386,7 +386,7 @@ typedef struct isdn_net_local_s { /* the interface itself */ typedef struct isdn_net_dev_s { - isdn_net_local *local; + isdn_net_local local; isdn_net_local *queue; /* circular list of all bundled channels, which are currently online */ -- cgit v1.2.3 From a30588dccd8d5fba05f87c99e4d74c731247bcc2 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Sat, 3 Aug 2002 01:53:35 -0500 Subject: ISDN: Simplify isdn_net state machine After the preceding cleanups, it turns out that a couple of states are not necessary and can just be removed. Also, they can be given more descriptive names now. --- drivers/isdn/i4l/isdn_net.c | 140 +++++++++++++++----------------------------- include/linux/isdn.h | 3 +- 2 files changed, 48 insertions(+), 95 deletions(-) (limited to 'include') diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c index 09aa665b09d8..632c066b8212 100644 --- a/drivers/isdn/i4l/isdn_net.c +++ b/drivers/isdn/i4l/isdn_net.c @@ -39,24 +39,19 @@ #endif enum { - ST_0, - ST_1, - ST_2_UNUSED, - ST_3, - ST_4, - ST_5, - ST_6, - ST_7, - ST_8, - ST_9, - ST_10, + ST_0 = 0, + ST_OUT_0 = 1, + ST_OUT_WAIT_DCONN = 4, + ST_OUT_WAIT_BCONN = 6, + ST_IN_WAIT_DCONN = 7, + ST_IN_WAIT_BCONN = 10, ST_11, ST_12, }; /* keep clear of ISDN_CMD_* and ISDN_STAT_* */ enum { - EV_NET_DIAL = 0x200, + EV_NET_DIAL = 0x200, }; LIST_HEAD(isdn_net_devs); /* Linked list of isdn_net_dev's */ @@ -201,6 +196,7 @@ static __inline__ void isdn_net_zero_frame_cnt(isdn_net_local *lp) int isdn_net_force_dial_lp(isdn_net_local *); static int isdn_net_start_xmit(struct sk_buff *, struct net_device *); +static int do_dialout(isdn_net_local *lp); static void isdn_net_ciscohdlck_connected(isdn_net_local *lp); static void isdn_net_ciscohdlck_disconnected(isdn_net_local *lp); @@ -508,8 +504,7 @@ init_dialout(isdn_net_local *lp) lp->dialwait_timer = 0; } lp->dialretry = 0; - lp->dialstate = ST_3; - return 1; + return do_dialout(lp); } /* Setup interface, dial current phone-number, switch to next number. @@ -543,7 +538,7 @@ do_dialout(isdn_net_local *lp) } if (!strncmp(lp->dial->num, "LEASED", strlen("LEASED"))) { restore_flags(flags); - lp->dialstate = ST_4; + lp->dialstate = ST_OUT_WAIT_DCONN; printk(KERN_INFO "%s: Open leased line ...\n", lp->name); } else { struct dial_info dial = { @@ -597,7 +592,7 @@ do_dialout(isdn_net_local *lp) } lp->dialstate = (lp->cbdelay && - (lp->flags & ISDN_NET_CBOUT)) ? ST_12 : ST_4; + (lp->flags & ISDN_NET_CBOUT)) ? ST_12 : ST_OUT_WAIT_DCONN; return 1; } @@ -687,55 +682,36 @@ isdn_net_handle_event(isdn_net_local *lp, int pr, void *arg) return 1; } break; - case ST_1: + case ST_OUT_0: switch (pr) { case EV_NET_DIAL: if (init_dialout(lp) == 0) return 0; - goto st_3_net_dial; - } - break; - case ST_3: - switch (pr) { - case EV_NET_DIAL: - st_3_net_dial: - return do_dialout(lp); + return 1; } break; - case ST_4: + case ST_OUT_WAIT_DCONN: switch (pr) { + case EV_NET_TIMER_DCONN: + /* try again */ + do_dialout(lp); + return 1; case EV_NET_DIAL: /* Wait for D-Channel-connect. - * If timeout, switch back to state 3. - * Dialmax-handling moved to state 3. + * If timeout, dial again (using the next phone number) */ if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) - lp->dialstate = ST_3; - return 1; - case ISDN_STAT_NODCH: - /* No D-Channel avail. */ - lp->dialstate = ST_3; + do_dialout(lp); return 1; case ISDN_STAT_DCONN: - lp->dialstate = ST_5; - return 1; - } - break; - case ST_5: - switch (pr) { - case EV_NET_DIAL: /* Got D-Channel-Connect, send B-Channel-request */ lp->dtimer = 0; - lp->dialstate = ST_6; + lp->dialstate = ST_OUT_WAIT_BCONN; isdn_slot_command(lp->isdn_slot, ISDN_CMD_ACCEPTB, &cmd); return 1; - case ISDN_STAT_BCONN: - isdn_slot_set_usage(lp->isdn_slot, isdn_slot_usage(lp->isdn_slot) | ISDN_USAGE_OUTGOING); - isdn_net_connected(lp); - return 1; } break; - case ST_6: + case ST_OUT_WAIT_BCONN: switch (pr) { case EV_NET_DIAL: /* Wait for B- or D-Channel-connect. If timeout, @@ -743,7 +719,7 @@ isdn_net_handle_event(isdn_net_local *lp, int pr, void *arg) */ dbg_net_dial("dialtimer2: %d\n", lp->dtimer); if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) - lp->dialstate = ST_3; + do_dialout(lp); return 1; case ISDN_STAT_BCONN: isdn_slot_set_usage(lp->isdn_slot, isdn_slot_usage(lp->isdn_slot) | ISDN_USAGE_OUTGOING); @@ -751,59 +727,24 @@ isdn_net_handle_event(isdn_net_local *lp, int pr, void *arg) return 1; } break; - case ST_7: + case ST_IN_WAIT_DCONN: switch (pr) { case EV_NET_DIAL: - /* Got incoming Call, setup L2 and L3 protocols, - * then wait for D-Channel-connect - */ dbg_net_dial("dialtimer4: %d\n", lp->dtimer); - cmd.arg = lp->l2_proto << 8; - isdn_slot_command(lp->isdn_slot, ISDN_CMD_SETL2, &cmd); - cmd.arg = lp->l3_proto << 8; - isdn_slot_command(lp->isdn_slot, ISDN_CMD_SETL3, &cmd); if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT15) { isdn_net_hangup(&p->dev); } else { - lp->dialstate = ST_8; return 1; } break; case ISDN_STAT_DCONN: - lp->dialstate = ST_8; - return 1; - case ISDN_STAT_BCONN: - isdn_slot_set_rx_netdev(lp->isdn_slot, p); - isdn_net_connected(lp); - return 1; - } - break; - case ST_8: - switch (pr) { - case ISDN_STAT_DCONN: - lp->dialstate = ST_9; - return 1; - case ISDN_STAT_BCONN: - isdn_slot_set_rx_netdev(lp->isdn_slot, p); - isdn_net_connected(lp); - return 1; - } - break; - case ST_9: - switch (pr) { - case EV_NET_DIAL: - /* Got incoming D-Channel-Connect, send B-Channel-request */ isdn_slot_command(lp->isdn_slot, ISDN_CMD_ACCEPTB, &cmd); lp->dtimer = 0; - lp->dialstate = ST_10; - return 1; - case ISDN_STAT_BCONN: - isdn_slot_set_rx_netdev(lp->isdn_slot, p); - isdn_net_connected(lp); + lp->dialstate = ST_IN_WAIT_BCONN; return 1; } break; - case ST_10: + case ST_IN_WAIT_BCONN: switch (pr) { case EV_NET_DIAL: /* Wait for B- or D-channel-connect */ @@ -824,7 +765,7 @@ isdn_net_handle_event(isdn_net_local *lp, int pr, void *arg) case EV_NET_DIAL: /* Callback Delay */ if (lp->dtimer++ > lp->cbdelay) - lp->dialstate = ST_1; + lp->dialstate = ST_OUT_0; return 1; } break; @@ -837,13 +778,15 @@ isdn_net_handle_event(isdn_net_local *lp, int pr, void *arg) if (lp->dtimer++ > lp->cbdelay) { printk(KERN_INFO "%s: hangup waiting for callback ...\n", lp->name); lp->dtimer = 0; - lp->dialstate = ST_4; + lp->dialstate = ST_OUT_WAIT_DCONN; isdn_slot_command(lp->isdn_slot, ISDN_CMD_HANGUP, &cmd); isdn_slot_all_eaz(lp->isdn_slot); } return 1; case ISDN_STAT_DCONN: - lp->dialstate = ST_5; + lp->dtimer = 0; + lp->dialstate = ST_OUT_WAIT_BCONN; + isdn_slot_command(lp->isdn_slot, ISDN_CMD_ACCEPTB, &cmd); return 1; case ISDN_STAT_BCONN: isdn_slot_set_rx_netdev(lp->isdn_slot, p); @@ -1315,7 +1258,7 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev) /* Log packet, which triggered dialing */ if (dev->net_verbose) isdn_net_log_skb(skb, lp); - lp->dialstate = ST_1; + lp->dialstate = ST_OUT_0; /* Connect interface with channel */ isdn_net_bind_channel(lp, chi); #ifdef CONFIG_ISDN_PPP @@ -2184,6 +2127,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) ulong flags; char nr[32]; char *my_eaz; + isdn_ctrl cmd; int slot = isdn_dc2minor(di, ch); /* Search name in netdev-chain */ @@ -2260,7 +2204,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) if ((!matchret) && /* EAZ is matching */ (((!(lp->flags & ISDN_NET_CONNECTED)) && /* but not connected */ (USG_NONE(isdn_slot_usage(idx)))) || /* and ch. unused or */ - ((((lp->dialstate == ST_4) || (lp->dialstate == ST_12)) && /* if dialing */ + ((((lp->dialstate == ST_OUT_WAIT_DCONN) || (lp->dialstate == ST_OUT_WAIT_DCONN)) && /* if dialing */ (!(lp->flags & ISDN_NET_CALLBACK))) /* but no callback */ ))) { @@ -2431,7 +2375,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) eaz); /* if this interface is dialing, it does it probably on a different device, so free this device */ - if ((lp->dialstate == ST_4) || (lp->dialstate == ST_12)) { + if ((lp->dialstate == ST_OUT_WAIT_DCONN) || (lp->dialstate == ST_12)) { #ifdef CONFIG_ISDN_PPP if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP) isdn_ppp_free(lp); @@ -2446,12 +2390,22 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) lp->isdn_slot = slot; lp->ppp_slot = -1; lp->flags |= ISDN_NET_CONNECTED; - lp->dialstate = ST_7; + lp->dtimer = 0; lp->outgoing = 0; lp->huptimer = 0; lp->hupflags |= ISDN_WAITCHARGE; lp->hupflags &= ~ISDN_HAVECHARGE; + /* Got incoming Call, setup L2 and L3 protocols, + * then wait for D-Channel-connect + */ + cmd.arg = lp->l2_proto << 8; + isdn_slot_command(lp->isdn_slot, ISDN_CMD_SETL2, &cmd); + cmd.arg = lp->l3_proto << 8; + isdn_slot_command(lp->isdn_slot, ISDN_CMD_SETL3, &cmd); + + lp->dialstate = ST_IN_WAIT_DCONN; + #ifdef CONFIG_ISDN_PPP if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP) if (isdn_ppp_bind(lp) < 0) { @@ -2518,7 +2472,7 @@ isdn_net_force_dial_lp(isdn_net_local * lp) restore_flags(flags); return -EAGAIN; } - lp->dialstate = ST_1; + lp->dialstate = ST_OUT_0; /* Connect interface with channel */ isdn_net_bind_channel(lp, chi); #ifdef CONFIG_ISDN_PPP diff --git a/include/linux/isdn.h b/include/linux/isdn.h index 0be4b46d71f8..d7a911bed2ee 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -391,7 +391,7 @@ typedef struct isdn_net_dev_s { channels, which are currently online */ spinlock_t queue_lock; /* lock to protect queue */ - struct isdn_net_dev_s *next; /* Pointer to next isdn-interface */ + struct list_head global_list; /* global list of all isdn_net_devs */ struct net_device dev; /* interface to upper levels */ #ifdef CONFIG_ISDN_PPP ippp_bundle * pb; /* pointer to the common bundle structure @@ -606,7 +606,6 @@ typedef struct isdn_devt { 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 */ - isdn_net_dev *netdev; /* Linked list of net-if's */ char drvid[ISDN_MAX_DRIVERS][20];/* Driver-ID */ struct task_struct *profd; /* For iprofd */ modem mdm; /* tty-driver-data */ -- cgit v1.2.3 From 62720197d48df08f5c24f6a1dc231432a0458d62 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Sat, 3 Aug 2002 02:38:53 -0500 Subject: ISDN: More state machine cleanup and normal timer use Even more states can go away, and there's not really any need to have the ISDN code have manage timers by itself, just use normal kernel timers for the state machine now. --- drivers/isdn/i4l/isdn_common.c | 7 -- drivers/isdn/i4l/isdn_net.c | 183 ++++++++++++++++------------------------- include/linux/isdn.h | 11 +-- 3 files changed, 73 insertions(+), 128 deletions(-) (limited to 'include') diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index c65e556d0d39..b0aecf4dd627 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -252,7 +252,6 @@ isdn_dc2minor(int di, int ch) return -1; } -static int isdn_timer_cnt1 = 0; static int isdn_timer_cnt2 = 0; static int isdn_timer_cnt3 = 0; @@ -269,11 +268,6 @@ isdn_timer_funct(ulong dummy) isdn_tty_modem_xmit(); } if (tf & ISDN_TIMER_SLOW) { - if (++isdn_timer_cnt1 >= ISDN_TIMER_02SEC) { - isdn_timer_cnt1 = 0; - if (tf & ISDN_TIMER_NETDIAL) - isdn_net_dial(); - } if (++isdn_timer_cnt2 >= ISDN_TIMER_1SEC) { isdn_timer_cnt2 = 0; if (tf & ISDN_TIMER_NETHANGUP) @@ -308,7 +302,6 @@ isdn_timer_ctrl(int tf, int onoff) cli(); if ((tf & ISDN_TIMER_SLOW) && (!(dev->tflags & ISDN_TIMER_SLOW))) { /* If the slow-timer wasn't activated until now */ - isdn_timer_cnt1 = 0; isdn_timer_cnt2 = 0; } old_tflags = dev->tflags; diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c index 632c066b8212..68902efd62cc 100644 --- a/drivers/isdn/i4l/isdn_net.c +++ b/drivers/isdn/i4l/isdn_net.c @@ -40,18 +40,21 @@ enum { ST_0 = 0, - ST_OUT_0 = 1, ST_OUT_WAIT_DCONN = 4, ST_OUT_WAIT_BCONN = 6, ST_IN_WAIT_DCONN = 7, ST_IN_WAIT_BCONN = 10, - ST_11, - ST_12, + ST_WAIT_BEFORE_CB = 11, }; /* keep clear of ISDN_CMD_* and ISDN_STAT_* */ enum { - EV_NET_DIAL = 0x200, + EV_NET_DIAL = 0x200, + EV_NET_TIMER_IN_DCONN = 0x201, + EV_NET_TIMER_IN_BCONN = 0x202, + EV_NET_TIMER_OUT_DCONN = 0x203, + EV_NET_TIMER_OUT_BCONN = 0x204, + EV_NET_TIMER_CB = 0x205, }; LIST_HEAD(isdn_net_devs); /* Linked list of isdn_net_dev's */ @@ -478,6 +481,14 @@ isdn_net_stat_callback(int idx, isdn_ctrl *c) return isdn_net_handle_event(lp, cmd, c); } +static void +isdn_net_dial_timer(unsigned long data) +{ + isdn_net_local *lp = (isdn_net_local *) lp; + + isdn_net_handle_event(lp, lp->dial_event, NULL); +} + /* Initiate dialout. Set phone-number-pointer to first number * of interface. */ @@ -540,6 +551,7 @@ do_dialout(isdn_net_local *lp) restore_flags(flags); lp->dialstate = ST_OUT_WAIT_DCONN; printk(KERN_INFO "%s: Open leased line ...\n", lp->name); + return 1; } else { struct dial_info dial = { .l2_proto = lp->l2_proto, @@ -578,8 +590,10 @@ do_dialout(isdn_net_local *lp) } } restore_flags(flags); - lp->dtimer = 0; isdn_slot_dial(lp->isdn_slot, &dial); + lp->dial_timer.expires = jiffies + 10 * HZ; + lp->dial_event = EV_NET_TIMER_IN_DCONN; + add_timer(&lp->dial_timer); } lp->huptimer = 0; lp->outgoing = 1; @@ -590,9 +604,15 @@ do_dialout(isdn_net_local *lp) lp->hupflags |= ISDN_WAITCHARGE; lp->hupflags &= ~ISDN_HAVECHARGE; } - lp->dialstate = - (lp->cbdelay && - (lp->flags & ISDN_NET_CBOUT)) ? ST_12 : ST_OUT_WAIT_DCONN; + if (lp->cbdelay && (lp->flags & ISDN_NET_CBOUT)) { + lp->dial_timer.expires = jiffies + lp->cbdelay * HZ; + lp->dial_event = EV_NET_TIMER_CB; + } else { + lp->dial_timer.expires = jiffies + 10 * HZ; + lp->dial_event = EV_NET_TIMER_OUT_DCONN; + } + lp->dialstate = ST_OUT_WAIT_DCONN; + add_timer(&lp->dial_timer); return 1; } @@ -682,46 +702,37 @@ isdn_net_handle_event(isdn_net_local *lp, int pr, void *arg) return 1; } break; - case ST_OUT_0: - switch (pr) { - case EV_NET_DIAL: - if (init_dialout(lp) == 0) - return 0; - return 1; - } - break; case ST_OUT_WAIT_DCONN: switch (pr) { - case EV_NET_TIMER_DCONN: + case EV_NET_TIMER_OUT_DCONN: /* try again */ do_dialout(lp); return 1; - case EV_NET_DIAL: - /* Wait for D-Channel-connect. - * If timeout, dial again (using the next phone number) - */ - if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) - do_dialout(lp); + case EV_NET_TIMER_CB: + /* Remote does callback. Hangup after cbdelay, + * then wait for incoming call */ + printk(KERN_INFO "%s: hangup waiting for callback ...\n", lp->name); + isdn_net_hangup(&lp->netdev->dev); return 1; case ISDN_STAT_DCONN: /* Got D-Channel-Connect, send B-Channel-request */ - lp->dtimer = 0; + del_timer(&lp->dial_timer); lp->dialstate = ST_OUT_WAIT_BCONN; isdn_slot_command(lp->isdn_slot, ISDN_CMD_ACCEPTB, &cmd); + lp->dial_timer.expires = jiffies + 10 * HZ; + lp->dial_event = EV_NET_TIMER_OUT_BCONN; + add_timer(&lp->dial_timer); return 1; } break; case ST_OUT_WAIT_BCONN: switch (pr) { - case EV_NET_DIAL: - /* Wait for B- or D-Channel-connect. If timeout, - * switch back to state 3. - */ - dbg_net_dial("dialtimer2: %d\n", lp->dtimer); - if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) - do_dialout(lp); + case EV_NET_TIMER_OUT_BCONN: + /* try again */ + do_dialout(lp); return 1; case ISDN_STAT_BCONN: + del_timer(&lp->dial_timer); isdn_slot_set_usage(lp->isdn_slot, isdn_slot_usage(lp->isdn_slot) | ISDN_USAGE_OUTGOING); isdn_net_connected(lp); return 1; @@ -729,68 +740,36 @@ isdn_net_handle_event(isdn_net_local *lp, int pr, void *arg) break; case ST_IN_WAIT_DCONN: switch (pr) { - case EV_NET_DIAL: - dbg_net_dial("dialtimer4: %d\n", lp->dtimer); - if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT15) { - isdn_net_hangup(&p->dev); - } else { - return 1; - } + case EV_NET_TIMER_IN_DCONN: + isdn_net_hangup(&p->dev); break; case ISDN_STAT_DCONN: - isdn_slot_command(lp->isdn_slot, ISDN_CMD_ACCEPTB, &cmd); - lp->dtimer = 0; + del_timer(&lp->dial_timer); lp->dialstate = ST_IN_WAIT_BCONN; + isdn_slot_command(lp->isdn_slot, ISDN_CMD_ACCEPTB, &cmd); + lp->dial_timer.expires = jiffies + 10 * HZ; + lp->dial_event = EV_NET_TIMER_IN_BCONN; + add_timer(&lp->dial_timer); return 1; } break; case ST_IN_WAIT_BCONN: switch (pr) { - case EV_NET_DIAL: - /* Wait for B- or D-channel-connect */ - dbg_net_dial("dialtimer4: %d\n", lp->dtimer); - if (lp->dtimer++ > ISDN_TIMER_DTIMEOUT10) - isdn_net_hangup(&p->dev); - else - return 1; + case EV_NET_TIMER_IN_BCONN: + isdn_net_hangup(&p->dev); break; case ISDN_STAT_BCONN: + del_timer(&lp->dial_timer); isdn_slot_set_rx_netdev(lp->isdn_slot, p); isdn_net_connected(lp); return 1; } break; - case ST_11: + case ST_WAIT_BEFORE_CB: switch (pr) { - case EV_NET_DIAL: + case EV_NET_TIMER_CB: /* Callback Delay */ - if (lp->dtimer++ > lp->cbdelay) - lp->dialstate = ST_OUT_0; - return 1; - } - break; - case ST_12: - switch (pr) { - case EV_NET_DIAL: - /* Remote does callback. Hangup after cbdelay, then wait for incoming - * call (in state 4). - */ - if (lp->dtimer++ > lp->cbdelay) { - printk(KERN_INFO "%s: hangup waiting for callback ...\n", lp->name); - lp->dtimer = 0; - lp->dialstate = ST_OUT_WAIT_DCONN; - isdn_slot_command(lp->isdn_slot, ISDN_CMD_HANGUP, &cmd); - isdn_slot_all_eaz(lp->isdn_slot); - } - return 1; - case ISDN_STAT_DCONN: - lp->dtimer = 0; - lp->dialstate = ST_OUT_WAIT_BCONN; - isdn_slot_command(lp->isdn_slot, ISDN_CMD_ACCEPTB, &cmd); - return 1; - case ISDN_STAT_BCONN: - isdn_slot_set_rx_netdev(lp->isdn_slot, p); - isdn_net_connected(lp); + init_dialout(lp); return 1; } break; @@ -801,35 +780,6 @@ isdn_net_handle_event(isdn_net_local *lp, int pr, void *arg) return 0; } -/* - * Perform dialout for net-interfaces and timeout-handling for - * D-Channel-up and B-Channel-up Messages. - * This function is initially called from within isdn_net_start_xmit() or - * or isdn_net_find_icall() after initializing the dialstate for an - * interface. If further calls are needed, the function schedules itself - * for a timer-callback via isdn_timer_function(). - * The dialstate is also affected by incoming status-messages from - * the ISDN-Channel which are handled in isdn_net_stat_callback() above. - */ -void -isdn_net_dial(void) -{ - int anymore = 0; - struct list_head *l; - - list_for_each(l, &isdn_net_devs) { - isdn_net_dev *p = list_entry(l, isdn_net_dev, global_list); - isdn_net_local *lp = &p->local; - - if (lp->dialstate == ST_0) - continue; - - if (isdn_net_handle_event(lp, EV_NET_DIAL, NULL)) - anymore = 1; - } - isdn_timer_ctrl(ISDN_TIMER_NETDIAL, anymore); -} - /* * Perform hangup for a net-interface. */ @@ -1258,7 +1208,6 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev) /* Log packet, which triggered dialing */ if (dev->net_verbose) isdn_net_log_skb(skb, lp); - lp->dialstate = ST_OUT_0; /* Connect interface with channel */ isdn_net_bind_channel(lp, chi); #ifdef CONFIG_ISDN_PPP @@ -1278,7 +1227,7 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev) #endif /* Initiate dialing */ restore_flags(flags); - isdn_net_dial(); + init_dialout(lp); isdn_net_device_stop_queue(lp); return 1; } else { @@ -2351,8 +2300,11 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) return 0; } /* Setup dialstate. */ - lp->dtimer = 0; - lp->dialstate = ST_11; + lp->dial_timer.expires = jiffies + lp->cbdelay; + lp->dial_event = EV_NET_TIMER_CB; + add_timer(&lp->dial_timer); + + lp->dialstate = ST_WAIT_BEFORE_CB; /* Connect interface with channel */ isdn_net_bind_channel(lp, chi); #ifdef CONFIG_ISDN_PPP @@ -2375,7 +2327,7 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) eaz); /* if this interface is dialing, it does it probably on a different device, so free this device */ - if ((lp->dialstate == ST_OUT_WAIT_DCONN) || (lp->dialstate == ST_12)) { + if (lp->dialstate == ST_OUT_WAIT_DCONN) { #ifdef CONFIG_ISDN_PPP if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP) isdn_ppp_free(lp); @@ -2391,7 +2343,6 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) lp->ppp_slot = -1; lp->flags |= ISDN_NET_CONNECTED; - lp->dtimer = 0; lp->outgoing = 0; lp->huptimer = 0; lp->hupflags |= ISDN_WAITCHARGE; @@ -2404,6 +2355,9 @@ isdn_net_find_icall(int di, int ch, int idx, setup_parm *setup) cmd.arg = lp->l3_proto << 8; isdn_slot_command(lp->isdn_slot, ISDN_CMD_SETL3, &cmd); + lp->dial_timer.expires = jiffies + 15 * HZ; + lp->dial_event = EV_NET_TIMER_IN_DCONN; + add_timer(&lp->dial_timer); lp->dialstate = ST_IN_WAIT_DCONN; #ifdef CONFIG_ISDN_PPP @@ -2472,7 +2426,6 @@ isdn_net_force_dial_lp(isdn_net_local * lp) restore_flags(flags); return -EAGAIN; } - lp->dialstate = ST_OUT_0; /* Connect interface with channel */ isdn_net_bind_channel(lp, chi); #ifdef CONFIG_ISDN_PPP @@ -2485,7 +2438,7 @@ isdn_net_force_dial_lp(isdn_net_local * lp) #endif /* Initiate dialing */ restore_flags(flags); - isdn_net_dial(); + init_dialout(lp); return 0; } else return -EINVAL; @@ -2607,6 +2560,10 @@ isdn_net_new(char *name, struct net_device *master) netdev->local.dialstarted = 0; /* Jiffies of last dial-start */ netdev->local.dialwait_timer = 0; /* Jiffies of earliest next dial-start */ + init_timer(&netdev->local.dial_timer); + netdev->local.dial_timer.data = (unsigned long) &netdev->local; + netdev->local.dial_timer.function = isdn_net_dial_timer; + /* Put into to netdev-chain */ list_add(&netdev->global_list, &isdn_net_devs); return 0; diff --git a/include/linux/isdn.h b/include/linux/isdn.h index d7a911bed2ee..9544c782d17d 100644 --- a/include/linux/isdn.h +++ b/include/linux/isdn.h @@ -245,18 +245,12 @@ typedef struct { #define ISDN_TIMER_MODEMPLUS 2 #define ISDN_TIMER_MODEMRING 4 #define ISDN_TIMER_MODEMXMIT 8 -#define ISDN_TIMER_NETDIAL 16 #define ISDN_TIMER_NETHANGUP 32 #define ISDN_TIMER_CARRIER 256 /* Wait for Carrier */ #define ISDN_TIMER_FAST (ISDN_TIMER_MODEMREAD | ISDN_TIMER_MODEMPLUS | \ ISDN_TIMER_MODEMXMIT) #define ISDN_TIMER_SLOW (ISDN_TIMER_MODEMRING | ISDN_TIMER_NETHANGUP | \ - ISDN_TIMER_NETDIAL | ISDN_TIMER_CARRIER) - -/* Timeout-Values for isdn_net_dial() */ -#define ISDN_TIMER_DTIMEOUT10 (10*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1))) -#define ISDN_TIMER_DTIMEOUT15 (15*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1))) -#define ISDN_TIMER_DTIMEOUT60 (60*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1))) + ISDN_TIMER_CARRIER) /* GLOBAL_FLAGS */ #define ISDN_GLOBAL_STOPPED 1 @@ -291,6 +285,8 @@ typedef struct { typedef struct isdn_net_local_s { ulong magic; char name[10]; /* Name of device */ + struct timer_list dial_timer; /* dial timeout */ + int dial_event; /* event in case of timer expiry */ struct net_device_stats stats; /* Ethernet Statistics */ int isdn_slot; /* Index to isdn device/channel */ int ppp_slot; /* PPPD device slot number */ @@ -301,7 +297,6 @@ typedef struct isdn_net_local_s { int dialretry; /* Counter for Dialout-retries */ int dialmax; /* Max. Number of Dial-retries */ int cbdelay; /* Delay before Callback starts */ - int dtimer; /* Timeout-counter for dialing */ char msn[ISDN_MSNLEN]; /* MSNs/EAZs for this interface */ u_char cbhup; /* Flag: Reject Call before Callback*/ u_char dialstate; /* State for dialing */ -- cgit v1.2.3