Commit eae32582 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Begin to make driver/channel mapping private to isdn_common.c

parent 0342d35c
......@@ -564,8 +564,8 @@ isdn_audio_eval_dtmf(modem_info * info)
ISDN_AUDIO_SKB_LOCK(skb) = 0;
save_flags(flags);
cli();
di = info->isdn_driver;
ch = info->isdn_channel;
di = isdn_slot_driver(info->isdn_slot);
ch = isdn_slot_channel(info->isdn_slot);
__skb_queue_tail(&dev->drv[di]->rpqueue[ch], skb);
dev->drv[di]->rcvcount[ch] += 2;
restore_flags(flags);
......@@ -685,8 +685,8 @@ isdn_audio_put_dle_code(modem_info * info, u_char code)
ISDN_AUDIO_SKB_LOCK(skb) = 0;
save_flags(flags);
cli();
di = info->isdn_driver;
ch = info->isdn_channel;
di = isdn_slot_driver(info->isdn_slot);
ch = isdn_slot_channel(info->isdn_slot);
__skb_queue_tail(&dev->drv[di]->rpqueue[ch], skb);
dev->drv[di]->rcvcount[ch] += 2;
restore_flags(flags);
......
......@@ -44,6 +44,9 @@ 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 char *isdn_revision = "$Revision: 1.114.6.16 $";
extern char *isdn_net_revision;
......@@ -230,7 +233,7 @@ isdn_dc2minor(int di, int ch)
{
int i;
for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if (dev->chanmap[i] == ch && dev->drvmap[i] == di)
if (chanmap[i] == ch && drvmap[i] == di)
return i;
return -1;
}
......@@ -458,8 +461,8 @@ 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 (dev->drvmap[i] == di)
isdn_all_eaz(di, dev->chanmap[i]);
if (drvmap[i] == di)
isdn_all_eaz(di, chanmap[i]);
set_global_features();
break;
case ISDN_STAT_STOP:
......@@ -506,14 +509,10 @@ isdn_status_callback(isdn_ctrl * c)
case 1:
/* Schedule connection-setup */
isdn_net_dial();
cmd.driver = di;
cmd.arg = c->arg;
cmd.command = ISDN_CMD_ACCEPTD;
for ( p = dev->netdev; p; p = p->next )
if ( p->local->isdn_channel == cmd.arg )
{
if (p->local->isdn_slot == isdn_dc2minor(di, cmd.arg)) {
strcpy( cmd.parm.setup.eazmsn, p->local->msn );
isdn_command(&cmd);
isdn_slot_command(p->local->isdn_slot, ISDN_CMD_ACCEPTD, &cmd);
retval = 1;
break;
}
......@@ -679,8 +678,8 @@ isdn_status_callback(isdn_ctrl * c)
save_flags(flags);
cli();
for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if ((dev->drvmap[i] == di) &&
(dev->chanmap[i] == c->arg)) {
if ((drvmap[i] == di) &&
(chanmap[i] == c->arg)) {
if (c->parm.num[0])
dev->usage[i] &= ~ISDN_USAGE_DISABLED;
else
......@@ -707,9 +706,9 @@ isdn_status_callback(isdn_ctrl * c)
cli();
isdn_tty_stat_callback(i, c);
for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if (dev->drvmap[i] == di) {
dev->drvmap[i] = -1;
dev->chanmap[i] = -1;
if (drvmap[i] == di) {
drvmap[i] = -1;
chanmap[i] = -1;
dev->usage[i] &= ~ISDN_USAGE_DISABLED;
isdn_unregister_devfs(i);
}
......@@ -884,13 +883,13 @@ isdn_readbchan(int di, int channel, u_char * buf, u_char * fp, int len, wait_que
static __inline int
isdn_minor2drv(int minor)
{
return (dev->drvmap[minor]);
return drvmap[minor];
}
static __inline int
isdn_minor2chan(int minor)
{
return (dev->chanmap[minor]);
return chanmap[minor];
}
static char *
......@@ -903,19 +902,19 @@ isdn_statstr(void)
sprintf(istatbuf, "idmap:\t");
p = istatbuf + strlen(istatbuf);
for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
sprintf(p, "%s ", (dev->drvmap[i] < 0) ? "-" : dev->drvid[dev->drvmap[i]]);
sprintf(p, "%s ", (drvmap[i] < 0) ? "-" : dev->drvid[drvmap[i]]);
p = istatbuf + strlen(istatbuf);
}
sprintf(p, "\nchmap:\t");
p = istatbuf + strlen(istatbuf);
for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
sprintf(p, "%d ", dev->chanmap[i]);
sprintf(p, "%d ", chanmap[i]);
p = istatbuf + strlen(istatbuf);
}
sprintf(p, "\ndrmap:\t");
p = istatbuf + strlen(istatbuf);
for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
sprintf(p, "%d ", dev->drvmap[i]);
sprintf(p, "%d ", drvmap[i]);
p = istatbuf + strlen(istatbuf);
}
sprintf(p, "\nusage:\t");
......@@ -1761,10 +1760,10 @@ isdn_get_free_channel(int usage, int l2_proto, int l3_proto, int pre_dev
*/
for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if (USG_NONE(dev->usage[i]) &&
(dev->drvmap[i] != -1)) {
int d = dev->drvmap[i];
(drvmap[i] != -1)) {
int d = drvmap[i];
if ((dev->usage[i] & ISDN_USAGE_EXCLUSIVE) &&
((pre_dev != d) || (pre_chan != dev->chanmap[i])))
((pre_dev != d) || (pre_chan != chanmap[i])))
continue;
if (!strcmp(isdn_map_eaz2msn(msn, d), "-"))
continue;
......@@ -1781,7 +1780,7 @@ isdn_get_free_channel(int usage, int l2_proto, int l3_proto, int pre_dev
restore_flags(flags);
return i;
} else {
if ((pre_dev == d) && (pre_chan == dev->chanmap[i])) {
if ((pre_dev == d) && (pre_chan == chanmap[i])) {
dev->usage[i] &= ISDN_USAGE_EXCLUSIVE;
dev->usage[i] |= usage;
isdn_info_update();
......@@ -1802,27 +1801,32 @@ isdn_get_free_channel(int usage, int l2_proto, int l3_proto, int pre_dev
void
isdn_free_channel(int di, int ch, int usage)
{
int i;
ulong flags;
int slot;
slot = isdn_dc2minor(di, ch);
isdn_slot_free(slot, usage);
}
void
isdn_slot_free(int slot, int usage)
{
unsigned long flags;
save_flags(flags);
cli();
for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if (((!usage) || ((dev->usage[i] & ISDN_USAGE_MASK) == usage)) &&
(dev->drvmap[i] == di) &&
(dev->chanmap[i] == ch)) {
dev->usage[i] &= (ISDN_USAGE_NONE | ISDN_USAGE_EXCLUSIVE);
strcpy(dev->num[i], "???");
dev->ibytes[i] = 0;
dev->obytes[i] = 0;
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;
// 20.10.99 JIM, try to reinitialize v110 !
dev->v110emu[i] = 0;
atomic_set(&(dev->v110use[i]), 0);
isdn_v110_close(dev->v110[i]);
dev->v110[i] = NULL;
dev->v110emu[slot] = 0;
atomic_set(&(dev->v110use[slot]), 0);
isdn_v110_close(dev->v110[slot]);
dev->v110[slot] = NULL;
// 20.10.99 JIM, try to reinitialize v110 !
isdn_info_update();
skb_queue_purge(&dev->drv[di]->rpqueue[ch]);
skb_queue_purge(&dev->drv[isdn_slot_driver(slot)]->rpqueue[isdn_slot_channel(slot)]);
}
restore_flags(flags);
}
......@@ -1839,8 +1843,8 @@ isdn_unexclusive_channel(int di, int ch)
save_flags(flags);
cli();
for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if ((dev->drvmap[i] == di) &&
(dev->chanmap[i] == ch)) {
if ((drvmap[i] == di) &&
(chanmap[i] == ch)) {
dev->usage[i] &= ~ISDN_USAGE_EXCLUSIVE;
isdn_info_update();
restore_flags(flags);
......@@ -1997,9 +2001,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 (dev->chanmap[k] < 0) {
dev->chanmap[k] = j;
dev->drvmap[k] = drvidx;
if (chanmap[k] < 0) {
chanmap[k] = j;
drvmap[k] = drvidx;
isdn_register_devfs(k);
break;
}
......@@ -2140,6 +2144,75 @@ register_isdn(isdn_if * i)
return 1;
}
int
isdn_slot_driver(int slot)
{
BUG_ON(slot < 0);
return drvmap[slot];
}
int
isdn_slot_channel(int slot)
{
BUG_ON(slot < 0);
return chanmap[slot];
}
int
isdn_slot_hdrlen(int slot)
{
int di = isdn_slot_driver(slot);
return dev->drv[di]->interface->hl_hdrlen;
}
char *
isdn_slot_map_eaz2msn(int slot, char *msn)
{
int di = isdn_slot_driver(slot);
return isdn_map_eaz2msn(msn, di);
}
int
isdn_slot_command(int slot, int cmd, isdn_ctrl *ctrl)
{
ctrl->command = cmd;
ctrl->driver = isdn_slot_driver(slot);
ctrl->arg &= 0xff; ctrl->arg |= isdn_slot_channel(slot);
return isdn_command(ctrl);
}
void
isdn_slot_all_eaz(int slot)
{
isdn_ctrl cmd;
cmd.parm.num[0] = '\0';
isdn_slot_command(slot, ISDN_CMD_SETEAZ, &cmd);
}
int
isdn_slot_readbchan(int slot, u_char *buf, u_char *fp, int len, wait_queue_head_t *sleep)
{
int di = isdn_slot_driver(slot);
int ch = isdn_slot_channel(slot);
return isdn_readbchan(di, ch, buf, fp, len, sleep);
}
int
isdn_slot_writebuf_skb_stub(int slot, int ack, struct sk_buff *skb)
{
int di = isdn_slot_driver(slot);
int ch = isdn_slot_channel(slot);
return isdn_writebuf_skb_stub(di, ch, ack, skb);
}
/*
*****************************************************************************
* And now the modules code.
......@@ -2261,8 +2334,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++) {
dev->drvmap[i] = -1;
dev->chanmap[i] = -1;
drvmap[i] = -1;
chanmap[i] = -1;
dev->m_idx[i] = -1;
strcpy(dev->num[i], "???");
init_waitqueue_head(&dev->mdm.info[i].open_wait);
......
......@@ -47,3 +47,13 @@ extern int isdn_add_channels(driver *, int, int, int);
#if defined(ISDN_DEBUG_NET_DUMP) || defined(ISDN_DEBUG_MODEM_DUMP)
extern void isdn_dumppkt(char *, u_char *, int, int);
#endif
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 char *isdn_slot_map_eaz2msn(int slot, char *msn);
extern int isdn_slot_writebuf_skb_stub(int slot, int, struct sk_buff *);
extern int isdn_slot_readbchan(int slot, u_char *, u_char *, int, wait_queue_head_t *);
extern int isdn_slot_hdrlen(int slot);
extern int isdn_slot_driver(int slot);
extern int isdn_slot_channel(int slot);
This diff is collapsed.
......@@ -804,11 +804,11 @@ isdn_ppp_write(struct file *file, const char *buf, size_t count, loff_t *off)
if (proto != PPP_LCP)
lp->huptimer = 0;
if (lp->isdn_device < 0 || lp->isdn_channel < 0) {
if (lp->isdn_slot < 0) {
retval = 0;
goto out;
}
if ((dev->drv[lp->isdn_device]->flags & DRV_FLAG_RUNNING) &&
if ((dev->drv[isdn_slot_driver(lp->isdn_slot)]->flags & DRV_FLAG_RUNNING) &&
lp->dialstate == 0 &&
(lp->flags & ISDN_NET_CONNECTED)) {
unsigned short hl;
......@@ -818,7 +818,7 @@ isdn_ppp_write(struct file *file, const char *buf, size_t count, loff_t *off)
* sk_buff. old call to dev_alloc_skb only reserved
* 16 bytes, now we are looking what the driver want
*/
hl = dev->drv[lp->isdn_device]->interface->hl_hdrlen;
hl = isdn_slot_hdrlen(lp->isdn_slot);
skb = alloc_skb(hl+count, GFP_ATOMIC);
if (!skb) {
printk(KERN_WARNING "isdn_ppp_write: out of memory!\n");
......@@ -1263,7 +1263,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
* sk_buff. old call to dev_alloc_skb only reserved
* 16 bytes, now we are looking what the driver want.
*/
hl = dev->drv[lp->isdn_device]->interface->hl_hdrlen + IPPP_MAX_HEADER;
hl = isdn_slot_hdrlen(lp->isdn_slot) + IPPP_MAX_HEADER;;
/*
* Note: hl might still be insufficient because the method
* above does not account for a possibible MPPP slave channel
......@@ -2094,7 +2094,7 @@ static void isdn_ppp_ccp_xmit_reset(struct ippp_struct *is, int proto,
isdn_net_local *lp = is->lp;
/* Alloc large enough skb */
hl = dev->drv[lp->isdn_device]->interface->hl_hdrlen;
hl = isdn_slot_hdrlen(lp->isdn_slot);
skb = alloc_skb(len + hl + 16,GFP_ATOMIC);
if(!skb) {
printk(KERN_WARNING
......
This diff is collapsed.
......@@ -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_channel] & ISDN_USAGE_OUTGOING))) {
(!(dev->usage[info->isdn_slot] & ISDN_USAGE_OUTGOING))) {
sprintf(rs, "/%s", m->cpn);
isdn_tty_at_cout(rs, info);
}
......@@ -360,12 +360,11 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info * info)
default:
PARSE_ERROR1;
}
c.command = ISDN_CMD_FAXCMD;
#ifdef ISDN_TTY_FAX_CMD_DEBUG
printk(KERN_DEBUG "isdn_tty_cmd_FCLASS1 %d/%d/%d)\n",
c.parm.aux.cmd, c.parm.aux.subcmd, c.parm.aux.para[0]);
#endif
if (info->isdn_driver < 0) {
if (info->isdn_slot < 0) {
save_flags(flags);
cli();
if ((c.parm.aux.subcmd == AT_EQ_VALUE) ||
......@@ -380,26 +379,19 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info * info)
restore_flags(flags);
PARSE_ERROR1;
}
info->isdn_driver = dev->drvmap[i];
info->isdn_channel = dev->chanmap[i];
info->isdn_slot = i;
info->drv_index = i;
dev->m_idx[i] = info->line;
c.driver = info->isdn_driver;
c.arg = info->isdn_channel;
isdn_command(&c);
isdn_free_channel(info->isdn_driver, info->isdn_channel,
ISDN_USAGE_FAX);
info->isdn_driver = -1;
info->isdn_channel = -1;
isdn_slot_command(info->isdn_slot, ISDN_CMD_FAXCMD, &c);
isdn_slot_free(info->isdn_slot, ISDN_USAGE_FAX);
info->isdn_slot = -1;
if (info->drv_index >= 0) {
dev->m_idx[info->drv_index] = -1;
info->drv_index = -1;
}
restore_flags(flags);
} else {
c.driver = info->isdn_driver;
c.arg = info->isdn_channel;
isdn_command(&c);
isdn_slot_command(info->isdn_slot, ISDN_CMD_FAXCMD, &c);
}
return 1;
}
......@@ -800,10 +792,7 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info)
printk(KERN_DEBUG "isdn_tty: Fax FDR\n");
#endif
f->code = ISDN_TTY_FAX_DR;
cmd.driver = info->isdn_driver;
cmd.arg = info->isdn_channel;
cmd.command = ISDN_CMD_FAXCMD;
isdn_command(&cmd);
isdn_slot_command(info->isdn_slot, ISDN_CMD_FAXCMD, &cmd);
if (f->phase == ISDN_FAX_PHASE_B) {
f->phase = ISDN_FAX_PHASE_C;
} else if (f->phase == ISDN_FAX_PHASE_D) {
......@@ -855,10 +844,7 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info)
#endif
if ((f->phase == ISDN_FAX_PHASE_B) || (f->phase == ISDN_FAX_PHASE_D)) {
f->code = ISDN_TTY_FAX_DT;
cmd.driver = info->isdn_driver;
cmd.arg = info->isdn_channel;
cmd.command = ISDN_CMD_FAXCMD;
isdn_command(&cmd);
isdn_slot_command(info->isdn_slot, ISDN_CMD_FAXCMD, &cmd);
if (f->phase == ISDN_FAX_PHASE_D) {
f->phase = ISDN_FAX_PHASE_C;
isdn_tty_fax_modem_result(7, info); /* CONNECT */
......@@ -913,10 +899,7 @@ isdn_tty_cmd_FCLASS2(char **p, modem_info * info)
PARSE_ERROR1;
f->fet = par;
f->code = ISDN_TTY_FAX_ET;
cmd.driver = info->isdn_driver;
cmd.arg = info->isdn_channel;
cmd.command = ISDN_CMD_FAXCMD;
isdn_command(&cmd);
isdn_slot_command(info->isdn_slot, ISDN_CMD_FAXCMD, &cmd);
#ifdef ISDN_TTY_FAX_STAT_DEBUG
printk(KERN_DEBUG "isdn_tty: Fax FET=%d\n", par);
#endif
......
......@@ -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.*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment