Commit 10b080a3 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Have the CAPI application alloc struct capi_appl

Inside the kernel, we rather go the standard way than converting
to/from indices to the actual data structs all the time.
parent b77e092a
...@@ -121,7 +121,7 @@ struct capincci { ...@@ -121,7 +121,7 @@ struct capincci {
struct capidev { struct capidev {
struct list_head list; struct list_head list;
u16 applid; struct capi20_appl ap;
u16 errcode; u16 errcode;
unsigned userflags; unsigned userflags;
...@@ -309,7 +309,7 @@ static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci) ...@@ -309,7 +309,7 @@ static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci)
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
mp = 0; mp = 0;
if (cdev->userflags & CAPIFLAG_HIGHJACKING) if (cdev->userflags & CAPIFLAG_HIGHJACKING)
mp = np->minorp = capiminor_alloc(cdev->applid, ncci); mp = np->minorp = capiminor_alloc(cdev->ap.applid, ncci);
if (mp) { if (mp) {
mp->nccip = np; mp->nccip = np;
#ifdef _DEBUG_REFCOUNT #ifdef _DEBUG_REFCOUNT
...@@ -399,10 +399,10 @@ static void capidev_free(struct capidev *cdev) ...@@ -399,10 +399,10 @@ static void capidev_free(struct capidev *cdev)
{ {
unsigned long flags; unsigned long flags;
if (cdev->applid) if (cdev->ap.applid) {
capi20_release(cdev->applid); // XXX capi20_release(&cdev->ap);
cdev->applid = 0; cdev->ap.applid = 0;
}
skb_queue_purge(&cdev->recvqueue); skb_queue_purge(&cdev->recvqueue);
write_lock_irqsave(&capidev_list_lock, flags); write_lock_irqsave(&capidev_list_lock, flags);
...@@ -583,7 +583,7 @@ static void capi_signal(u16 applid, void *param) ...@@ -583,7 +583,7 @@ static void capi_signal(u16 applid, void *param)
return; return;
} }
BUG_ON(cdev->applid != applid); BUG_ON(cdev->ap.applid != applid);
if (CAPIMSG_COMMAND(skb->data) == CAPI_CONNECT_B3_CONF) { if (CAPIMSG_COMMAND(skb->data) == CAPI_CONNECT_B3_CONF) {
u16 info = CAPIMSG_U16(skb->data, 12); // Info field u16 info = CAPIMSG_U16(skb->data, 12); // Info field
...@@ -666,7 +666,7 @@ capi_read(struct file *file, char *buf, size_t count, loff_t *ppos) ...@@ -666,7 +666,7 @@ capi_read(struct file *file, char *buf, size_t count, loff_t *ppos)
if (ppos != &file->f_pos) if (ppos != &file->f_pos)
return -ESPIPE; return -ESPIPE;
if (!cdev->applid) if (!cdev->ap.applid)
return -ENODEV; return -ENODEV;
if ((skb = skb_dequeue(&cdev->recvqueue)) == 0) { if ((skb = skb_dequeue(&cdev->recvqueue)) == 0) {
...@@ -717,7 +717,7 @@ capi_write(struct file *file, const char *buf, size_t count, loff_t *ppos) ...@@ -717,7 +717,7 @@ capi_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
if (ppos != &file->f_pos) if (ppos != &file->f_pos)
return -ESPIPE; return -ESPIPE;
if (!cdev->applid) if (!cdev->ap.applid)
return -ENODEV; return -ENODEV;
skb = alloc_skb(count, GFP_USER); skb = alloc_skb(count, GFP_USER);
...@@ -740,14 +740,14 @@ capi_write(struct file *file, const char *buf, size_t count, loff_t *ppos) ...@@ -740,14 +740,14 @@ capi_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
return -EINVAL; return -EINVAL;
} }
} }
CAPIMSG_SETAPPID(skb->data, cdev->applid); CAPIMSG_SETAPPID(skb->data, cdev->ap.applid);
if (CAPIMSG_COMMAND(skb->data) == CAPI_DISCONNECT_B3_RESP) { if (CAPIMSG_COMMAND(skb->data) == CAPI_DISCONNECT_B3_RESP) {
capincci_free(cdev, CAPIMSG_NCCI(skb->data)); capincci_free(cdev, CAPIMSG_NCCI(skb->data));
} }
cdev->errcode = capi20_put_message(cdev->applid, skb); cdev->errcode = capi20_put_message(cdev->ap.applid, skb);
if (cdev->errcode) { if (cdev->errcode) {
kfree_skb(skb); kfree_skb(skb);
...@@ -767,7 +767,7 @@ capi_poll(struct file *file, poll_table * wait) ...@@ -767,7 +767,7 @@ capi_poll(struct file *file, poll_table * wait)
struct capidev *cdev = (struct capidev *)file->private_data; struct capidev *cdev = (struct capidev *)file->private_data;
unsigned int mask = 0; unsigned int mask = 0;
if (!cdev->applid) if (!cdev->ap.applid)
return POLLERR; return POLLERR;
poll_wait(file, &(cdev->recvwait), wait); poll_wait(file, &(cdev->recvwait), wait);
...@@ -779,7 +779,7 @@ capi_poll(struct file *file, poll_table * wait) ...@@ -779,7 +779,7 @@ capi_poll(struct file *file, poll_table * wait)
static int static int
capi_ioctl(struct inode *inode, struct file *file, capi_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct capidev *cdev = (struct capidev *)file->private_data; struct capidev *cdev = (struct capidev *)file->private_data;
capi_ioctl_struct data; capi_ioctl_struct data;
...@@ -788,21 +788,21 @@ capi_ioctl(struct inode *inode, struct file *file, ...@@ -788,21 +788,21 @@ capi_ioctl(struct inode *inode, struct file *file,
switch (cmd) { switch (cmd) {
case CAPI_REGISTER: case CAPI_REGISTER:
{ {
retval = copy_from_user((void *) &data.rparams, if (cdev->ap.applid)
(void *) arg, sizeof(struct capi_register_params));
if (retval)
return -EFAULT;
if (cdev->applid)
return -EEXIST; return -EEXIST;
cdev->errcode = capi20_register(&data.rparams,
&cdev->applid); if (copy_from_user(&cdev->ap.rparam, (void *) arg,
sizeof(struct capi_register_params)))
return -EFAULT;
cdev->errcode = capi20_register(&cdev->ap);
if (cdev->errcode) { if (cdev->errcode) {
cdev->applid = 0; cdev->ap.applid = 0;
return -EIO; return -EIO;
} }
capi20_set_signal(cdev->applid, capi_signal, cdev); capi20_set_signal(cdev->ap.applid, capi_signal, cdev);
} }
return (int)cdev->applid; return (int)cdev->ap.applid;
case CAPI_GET_VERSION: case CAPI_GET_VERSION:
{ {
...@@ -1426,7 +1426,7 @@ static int proc_capidev_read_proc(char *page, char **start, off_t off, ...@@ -1426,7 +1426,7 @@ static int proc_capidev_read_proc(char *page, char **start, off_t off,
list_for_each(l, &capidev_list) { list_for_each(l, &capidev_list) {
cdev = list_entry(l, struct capidev, list); cdev = list_entry(l, struct capidev, list);
len += sprintf(page+len, "0 %d %lu %lu %lu %lu\n", len += sprintf(page+len, "0 %d %lu %lu %lu %lu\n",
cdev->applid, cdev->ap.applid,
cdev->nrecvctlpkt, cdev->nrecvctlpkt,
cdev->nrecvdatapkt, cdev->nrecvdatapkt,
cdev->nsentctlpkt, cdev->nsentctlpkt,
...@@ -1466,7 +1466,7 @@ static int proc_capincci_read_proc(char *page, char **start, off_t off, ...@@ -1466,7 +1466,7 @@ static int proc_capincci_read_proc(char *page, char **start, off_t off,
cdev = list_entry(l, struct capidev, list); cdev = list_entry(l, struct capidev, list);
for (np=cdev->nccis; np; np = np->next) { for (np=cdev->nccis; np; np = np->next) {
len += sprintf(page+len, "%d 0x%x\n", len += sprintf(page+len, "%d 0x%x\n",
cdev->applid, cdev->ap.applid,
np->ncci); np->ncci);
if (len <= off) { if (len <= off) {
off -= len; off -= len;
......
...@@ -125,10 +125,10 @@ struct capidrv_contr { ...@@ -125,10 +125,10 @@ struct capidrv_contr {
struct capidrv_data { struct capidrv_data {
u16 appid; struct capi20_appl ap;
int ncontr; int ncontr;
struct capidrv_contr *contr_list; struct capidrv_contr *contr_list;
/* statistic */ /* statistic */
unsigned long nrecvctlpkt; unsigned long nrecvctlpkt;
unsigned long nrecvdatapkt; unsigned long nrecvdatapkt;
...@@ -518,7 +518,7 @@ static void send_message(capidrv_contr * card, _cmsg * cmsg) ...@@ -518,7 +518,7 @@ static void send_message(capidrv_contr * card, _cmsg * cmsg)
len = CAPIMSG_LEN(cmsg->buf); len = CAPIMSG_LEN(cmsg->buf);
skb = alloc_skb(len, GFP_ATOMIC); skb = alloc_skb(len, GFP_ATOMIC);
memcpy(skb_put(skb, len), cmsg->buf, len); memcpy(skb_put(skb, len), cmsg->buf, len);
capi20_put_message(global.appid, skb); capi20_put_message(global.ap.applid, skb);
global.nsentctlpkt++; global.nsentctlpkt++;
} }
...@@ -666,7 +666,7 @@ static void n0(capidrv_contr * card, capidrv_ncci * ncci) ...@@ -666,7 +666,7 @@ static void n0(capidrv_contr * card, capidrv_ncci * ncci)
isdn_ctrl cmd; isdn_ctrl cmd;
capi_fill_DISCONNECT_REQ(&cmsg, capi_fill_DISCONNECT_REQ(&cmsg,
global.appid, global.ap.applid,
card->msgid++, card->msgid++,
ncci->plcip->plci, ncci->plcip->plci,
0, /* BChannelinformation */ 0, /* BChannelinformation */
...@@ -954,7 +954,7 @@ static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg) ...@@ -954,7 +954,7 @@ static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg)
cmd.parm.setup.si2, cmd.parm.setup.si2,
cmd.parm.setup.eazmsn); cmd.parm.setup.eazmsn);
capi_fill_ALERT_REQ(cmsg, capi_fill_ALERT_REQ(cmsg,
global.appid, global.ap.applid,
card->msgid++, card->msgid++,
plcip->plci, /* adr */ plcip->plci, /* adr */
0, /* BChannelinformation */ 0, /* BChannelinformation */
...@@ -1094,7 +1094,7 @@ static void handle_plci(_cmsg * cmsg) ...@@ -1094,7 +1094,7 @@ static void handle_plci(_cmsg * cmsg)
break; /* $$$$ */ break; /* $$$$ */
} }
capi_fill_CONNECT_B3_REQ(cmsg, capi_fill_CONNECT_B3_REQ(cmsg,
global.appid, global.ap.applid,
card->msgid++, card->msgid++,
plcip->plci, /* adr */ plcip->plci, /* adr */
0 /* NCPI */ 0 /* NCPI */
...@@ -1211,7 +1211,7 @@ static void handle_ncci(_cmsg * cmsg) ...@@ -1211,7 +1211,7 @@ static void handle_ncci(_cmsg * cmsg)
if (nccip) { if (nccip) {
ncci_change_state(card, nccip, EV_NCCI_CONNECT_B3_IND); ncci_change_state(card, nccip, EV_NCCI_CONNECT_B3_IND);
capi_fill_CONNECT_B3_RESP(cmsg, capi_fill_CONNECT_B3_RESP(cmsg,
global.appid, global.ap.applid,
card->msgid++, card->msgid++,
nccip->ncci, /* adr */ nccip->ncci, /* adr */
0, /* Reject */ 0, /* Reject */
...@@ -1229,7 +1229,7 @@ static void handle_ncci(_cmsg * cmsg) ...@@ -1229,7 +1229,7 @@ static void handle_ncci(_cmsg * cmsg)
cmsg->adr.adrNCCI); cmsg->adr.adrNCCI);
} }
capi_fill_CONNECT_B3_RESP(cmsg, capi_fill_CONNECT_B3_RESP(cmsg,
global.appid, global.ap.applid,
card->msgid++, card->msgid++,
cmsg->adr.adrNCCI, cmsg->adr.adrNCCI,
2, /* Reject */ 2, /* Reject */
...@@ -1376,7 +1376,7 @@ static void capidrv_signal(u16 applid, void *dummy) ...@@ -1376,7 +1376,7 @@ static void capidrv_signal(u16 applid, void *dummy)
{ {
struct sk_buff *skb = 0; struct sk_buff *skb = 0;
while (capi20_get_message(global.appid, &skb) == CAPI_NOERROR) { while (capi20_get_message(global.ap.applid, &skb) == CAPI_NOERROR) {
capi_message2cmsg(&s_cmsg, skb->data); capi_message2cmsg(&s_cmsg, skb->data);
if (debugmode > 2) if (debugmode > 2)
printk(KERN_DEBUG "capidrv_signal: applid=%d %s\n", printk(KERN_DEBUG "capidrv_signal: applid=%d %s\n",
...@@ -1627,7 +1627,7 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) ...@@ -1627,7 +1627,7 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card)
} }
capi_fill_CONNECT_REQ(&cmdcmsg, capi_fill_CONNECT_REQ(&cmdcmsg,
global.appid, global.ap.applid,
card->msgid++, card->msgid++,
card->contrnr, /* adr */ card->contrnr, /* adr */
si2cip(bchan->si1, bchan->si2), /* cipvalue */ si2cip(bchan->si1, bchan->si2), /* cipvalue */
...@@ -1673,7 +1673,7 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) ...@@ -1673,7 +1673,7 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card)
c->arg, bchan->l2, bchan->l3); c->arg, bchan->l2, bchan->l3);
capi_fill_CONNECT_RESP(&cmdcmsg, capi_fill_CONNECT_RESP(&cmdcmsg,
global.appid, global.ap.applid,
card->msgid++, card->msgid++,
bchan->plcip->plci, /* adr */ bchan->plcip->plci, /* adr */
0, /* Reject */ 0, /* Reject */
...@@ -1720,7 +1720,7 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) ...@@ -1720,7 +1720,7 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card)
if (bchan->nccip) { if (bchan->nccip) {
bchan->disconnecting = 1; bchan->disconnecting = 1;
capi_fill_DISCONNECT_B3_REQ(&cmdcmsg, capi_fill_DISCONNECT_B3_REQ(&cmdcmsg,
global.appid, global.ap.applid,
card->msgid++, card->msgid++,
bchan->nccip->ncci, bchan->nccip->ncci,
0 /* NCPI */ 0 /* NCPI */
...@@ -1741,7 +1741,7 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) ...@@ -1741,7 +1741,7 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card)
} else if (bchan->plcip->plci) { } else if (bchan->plcip->plci) {
bchan->disconnecting = 1; bchan->disconnecting = 1;
capi_fill_DISCONNECT_REQ(&cmdcmsg, capi_fill_DISCONNECT_REQ(&cmdcmsg,
global.appid, global.ap.applid,
card->msgid++, card->msgid++,
bchan->plcip->plci, bchan->plcip->plci,
0, /* BChannelinformation */ 0, /* BChannelinformation */
...@@ -1888,7 +1888,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) ...@@ -1888,7 +1888,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb)
return 0; return 0;
} }
datahandle = nccip->datahandle; datahandle = nccip->datahandle;
capi_fill_DATA_B3_REQ(&sendcmsg, global.appid, card->msgid++, capi_fill_DATA_B3_REQ(&sendcmsg, global.ap.applid, card->msgid++,
nccip->ncci, /* adr */ nccip->ncci, /* adr */
(u32) skb->data, /* Data */ (u32) skb->data, /* Data */
skb->len, /* DataLength */ skb->len, /* DataLength */
...@@ -1912,7 +1912,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) ...@@ -1912,7 +1912,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb)
printk(KERN_DEBUG "capidrv-%d: only %d bytes headroom, need %d\n", printk(KERN_DEBUG "capidrv-%d: only %d bytes headroom, need %d\n",
card->contrnr, skb_headroom(skb), msglen); card->contrnr, skb_headroom(skb), msglen);
memcpy(skb_push(nskb, msglen), sendcmsg.buf, msglen); memcpy(skb_push(nskb, msglen), sendcmsg.buf, msglen);
errcode = capi20_put_message(global.appid, nskb); errcode = capi20_put_message(global.ap.applid, nskb);
if (errcode == CAPI_NOERROR) { if (errcode == CAPI_NOERROR) {
dev_kfree_skb(skb); dev_kfree_skb(skb);
nccip->datahandle++; nccip->datahandle++;
...@@ -1924,7 +1924,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb) ...@@ -1924,7 +1924,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb)
return errcode == CAPI_SENDQUEUEFULL ? 0 : -1; return errcode == CAPI_SENDQUEUEFULL ? 0 : -1;
} else { } else {
memcpy(skb_push(skb, msglen), sendcmsg.buf, msglen); memcpy(skb_push(skb, msglen), sendcmsg.buf, msglen);
errcode = capi20_put_message(global.appid, skb); errcode = capi20_put_message(global.ap.applid, skb);
if (errcode == CAPI_NOERROR) { if (errcode == CAPI_NOERROR) {
nccip->datahandle++; nccip->datahandle++;
global.nsentdatapkt++; global.nsentdatapkt++;
...@@ -1992,7 +1992,7 @@ static void enable_dchannel_trace(capidrv_contr *card) ...@@ -1992,7 +1992,7 @@ static void enable_dchannel_trace(capidrv_contr *card)
if (avmversion[0] > 3 || (avmversion[0] == 3 && avmversion[1] > 5)) { if (avmversion[0] > 3 || (avmversion[0] == 3 && avmversion[1] > 5)) {
printk(KERN_INFO "%s: D2 trace enabled\n", card->name); printk(KERN_INFO "%s: D2 trace enabled\n", card->name);
capi_fill_MANUFACTURER_REQ(&cmdcmsg, global.appid, capi_fill_MANUFACTURER_REQ(&cmdcmsg, global.ap.applid,
card->msgid++, card->msgid++,
contr, contr,
0x214D5641, /* ManuID */ 0x214D5641, /* ManuID */
...@@ -2001,7 +2001,7 @@ static void enable_dchannel_trace(capidrv_contr *card) ...@@ -2001,7 +2001,7 @@ static void enable_dchannel_trace(capidrv_contr *card)
(_cstruct)"\004\200\014\000\000"); (_cstruct)"\004\200\014\000\000");
} else { } else {
printk(KERN_INFO "%s: D3 trace enabled\n", card->name); printk(KERN_INFO "%s: D3 trace enabled\n", card->name);
capi_fill_MANUFACTURER_REQ(&cmdcmsg, global.appid, capi_fill_MANUFACTURER_REQ(&cmdcmsg, global.ap.applid,
card->msgid++, card->msgid++,
contr, contr,
0x214D5641, /* ManuID */ 0x214D5641, /* ManuID */
...@@ -2015,7 +2015,7 @@ static void enable_dchannel_trace(capidrv_contr *card) ...@@ -2015,7 +2015,7 @@ static void enable_dchannel_trace(capidrv_contr *card)
static void send_listen(capidrv_contr *card) static void send_listen(capidrv_contr *card)
{ {
capi_fill_LISTEN_REQ(&cmdcmsg, global.appid, capi_fill_LISTEN_REQ(&cmdcmsg, global.ap.applid,
card->msgid++, card->msgid++,
card->contrnr, /* controller */ card->contrnr, /* controller */
1 << 6, /* Infomask */ 1 << 6, /* Infomask */
...@@ -2293,7 +2293,6 @@ static void __exit proc_exit(void) ...@@ -2293,7 +2293,6 @@ static void __exit proc_exit(void)
static int __init capidrv_init(void) static int __init capidrv_init(void)
{ {
struct capi_register_params rparam;
capi_profile profile; capi_profile profile;
char rev[32]; char rev[32];
char *p; char *p;
...@@ -2310,25 +2309,26 @@ static int __init capidrv_init(void) ...@@ -2310,25 +2309,26 @@ static int __init capidrv_init(void)
} else } else
strcpy(rev, "1.0"); strcpy(rev, "1.0");
rparam.level3cnt = -2; /* number of bchannels twice */ global.ap.rparam.level3cnt = -2; /* number of bchannels twice */
rparam.datablkcnt = 16; global.ap.rparam.datablkcnt = 16;
rparam.datablklen = 2048; global.ap.rparam.datablklen = 2048;
errcode = capi20_register(&rparam, &global.appid);
errcode = capi20_register(&global.ap);
if (errcode) { if (errcode) {
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return -EIO; return -EIO;
} }
capi20_set_callback(global.appid, lower_callback); capi20_set_callback(global.ap.applid, lower_callback);
errcode = capi20_get_profile(0, &profile); errcode = capi20_get_profile(0, &profile);
if (errcode != CAPI_NOERROR) { if (errcode != CAPI_NOERROR) {
capi20_release(global.appid); capi20_release(&global.ap);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return -EIO; return -EIO;
} }
capi20_set_signal(global.appid, capidrv_signal, 0); capi20_set_signal(global.ap.applid, capidrv_signal, 0);
ncontr = profile.ncontroller; ncontr = profile.ncontroller;
for (contr = 1; contr <= ncontr; contr++) { for (contr = 1; contr <= ncontr; contr++) {
...@@ -2358,7 +2358,7 @@ static void __exit capidrv_exit(void) ...@@ -2358,7 +2358,7 @@ static void __exit capidrv_exit(void)
strcpy(rev, " ??? "); strcpy(rev, " ??? ");
} }
capi20_release(global.appid); capi20_release(&global.ap);
proc_exit(); proc_exit();
......
...@@ -55,26 +55,6 @@ MODULE_PARM(showcapimsgs, "i"); ...@@ -55,26 +55,6 @@ MODULE_PARM(showcapimsgs, "i");
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
struct capi_appl {
u16 applid;
capi_register_params rparam;
void *param;
void (*signal) (u16 applid, void *param);
struct sk_buff_head recv_queue;
int nncci;
struct capi_ncci *nccilist;
unsigned long nrecvctlpkt;
unsigned long nrecvdatapkt;
unsigned long nsentctlpkt;
unsigned long nsentdatapkt;
/* ugly hack to allow for notification of added/removed
* controllers. The Right Way (tm) is known. XXX
*/
void (*callback) (unsigned int cmd, __u32 contr, void *data);
};
struct capi_notifier { struct capi_notifier {
struct capi_notifier *next; struct capi_notifier *next;
unsigned int cmd; unsigned int cmd;
...@@ -91,7 +71,7 @@ static char capi_manufakturer[64] = "AVM Berlin"; ...@@ -91,7 +71,7 @@ static char capi_manufakturer[64] = "AVM Berlin";
#define NCCI2CTRL(ncci) (((ncci) >> 24) & 0x7f) #define NCCI2CTRL(ncci) (((ncci) >> 24) & 0x7f)
static struct capi_appl *applications[CAPI_MAXAPPL]; static struct capi20_appl *applications[CAPI_MAXAPPL];
static struct capi_ctr *cards[CAPI_MAXCONTR]; static struct capi_ctr *cards[CAPI_MAXCONTR];
static int ncards; static int ncards;
static struct sk_buff_head recv_queue; static struct sk_buff_head recv_queue;
...@@ -136,7 +116,7 @@ static inline struct capi_ctr *get_capi_ctr_by_nr(u16 contr) ...@@ -136,7 +116,7 @@ static inline struct capi_ctr *get_capi_ctr_by_nr(u16 contr)
return cards[contr - 1]; return cards[contr - 1];
} }
static inline struct capi_appl *get_capi_appl_by_nr(u16 applid) static inline struct capi20_appl *get_capi_appl_by_nr(u16 applid)
{ {
if (applid - 1 >= CAPI_MAXAPPL) if (applid - 1 >= CAPI_MAXAPPL)
return NULL; return NULL;
...@@ -199,7 +179,7 @@ static inline int capi_subcmd_valid(u8 subcmd) ...@@ -199,7 +179,7 @@ static inline int capi_subcmd_valid(u8 subcmd)
static int proc_applications_read_proc(char *page, char **start, off_t off, static int proc_applications_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data) int count, int *eof, void *data)
{ {
struct capi_appl *ap; struct capi20_appl *ap;
int i; int i;
int len = 0; int len = 0;
...@@ -313,7 +293,7 @@ static int proc_controller_read_proc(char *page, char **start, off_t off, ...@@ -313,7 +293,7 @@ static int proc_controller_read_proc(char *page, char **start, off_t off,
static int proc_applstats_read_proc(char *page, char **start, off_t off, static int proc_applstats_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data) int count, int *eof, void *data)
{ {
struct capi_appl *ap; struct capi20_appl *ap;
int i; int i;
int len = 0; int len = 0;
...@@ -517,7 +497,7 @@ static int notify_push(unsigned int cmd, u32 controller, ...@@ -517,7 +497,7 @@ static int notify_push(unsigned int cmd, u32 controller,
static void notify_up(u32 contr) static void notify_up(u32 contr)
{ {
struct capi_ctr *card = get_capi_ctr_by_nr(contr); struct capi_ctr *card = get_capi_ctr_by_nr(contr);
struct capi_appl *ap; struct capi20_appl *ap;
u16 applid; u16 applid;
printk(KERN_DEBUG "kcapi: notify up contr %d\n", contr); printk(KERN_DEBUG "kcapi: notify up contr %d\n", contr);
...@@ -533,7 +513,7 @@ static void notify_up(u32 contr) ...@@ -533,7 +513,7 @@ static void notify_up(u32 contr)
static void notify_down(u32 contr) static void notify_down(u32 contr)
{ {
struct capi_appl *ap; struct capi20_appl *ap;
u16 applid; u16 applid;
printk(KERN_DEBUG "kcapi: notify down contr %d\n", contr); printk(KERN_DEBUG "kcapi: notify down contr %d\n", contr);
...@@ -576,7 +556,7 @@ static void notify_handler(void *dummy) ...@@ -576,7 +556,7 @@ static void notify_handler(void *dummy)
static void recv_handler(void *dummy) static void recv_handler(void *dummy)
{ {
struct sk_buff *skb; struct sk_buff *skb;
struct capi_appl *ap; struct capi20_appl *ap;
while ((skb = skb_dequeue(&recv_queue)) != 0) { while ((skb = skb_dequeue(&recv_queue)) != 0) {
ap = get_capi_appl_by_nr(CAPIMSG_APPID(skb->data)); ap = get_capi_appl_by_nr(CAPIMSG_APPID(skb->data));
...@@ -650,7 +630,7 @@ static void controllercb_handle_capimsg(struct capi_ctr * card, ...@@ -650,7 +630,7 @@ static void controllercb_handle_capimsg(struct capi_ctr * card,
static void controllercb_ready(struct capi_ctr * card) static void controllercb_ready(struct capi_ctr * card)
{ {
u16 appl; u16 appl;
struct capi_appl *ap; struct capi20_appl *ap;
card->cardstate = CARD_RUNNING; card->cardstate = CARD_RUNNING;
...@@ -683,7 +663,7 @@ static void controllercb_reseted(struct capi_ctr * card) ...@@ -683,7 +663,7 @@ static void controllercb_reseted(struct capi_ctr * card)
memset(card->serial, 0, sizeof(card->serial)); memset(card->serial, 0, sizeof(card->serial));
for (appl = 1; appl <= CAPI_MAXAPPL; appl++) { for (appl = 1; appl <= CAPI_MAXAPPL; appl++) {
struct capi_appl *ap = get_capi_appl_by_nr(appl); struct capi20_appl *ap = get_capi_appl_by_nr(appl);
if (!ap) if (!ap)
continue; continue;
...@@ -870,69 +850,62 @@ u16 capi20_isinstalled(void) ...@@ -870,69 +850,62 @@ u16 capi20_isinstalled(void)
EXPORT_SYMBOL(capi20_isinstalled); EXPORT_SYMBOL(capi20_isinstalled);
u16 capi20_register(capi_register_params * rparam, u16 * applidp) u16 capi20_register(struct capi20_appl *ap)
{ {
struct capi_appl *ap;
int appl;
int i; int i;
u16 applid;
DBG(""); DBG("");
if (rparam->datablklen < 128) if (ap->rparam.datablklen < 128)
return CAPI_LOGBLKSIZETOSMALL; return CAPI_LOGBLKSIZETOSMALL;
for (appl = 1; appl <= CAPI_MAXAPPL; appl++) { for (applid = 1; applid <= CAPI_MAXAPPL; applid++) {
if (applications[appl - 1] == NULL) if (applications[applid - 1] == NULL)
break; break;
} }
if (appl > CAPI_MAXAPPL) if (applid > CAPI_MAXAPPL)
return CAPI_TOOMANYAPPLS; return CAPI_TOOMANYAPPLS;
ap = kmalloc(sizeof(*ap), GFP_KERNEL); ap->applid = applid;
if (!ap) applications[applid - 1] = ap;
return CAPI_REGOSRESOURCEERR;
memset(ap, 0, sizeof(*ap)); ap->param = NULL;
ap->applid = appl; ap->signal = NULL;
applications[appl - 1] = ap;
skb_queue_head_init(&ap->recv_queue); skb_queue_head_init(&ap->recv_queue);
ap->nncci = 0; ap->nncci = 0;
ap->nrecvctlpkt = 0;
memcpy(&ap->rparam, rparam, sizeof(capi_register_params)); ap->nrecvdatapkt = 0;
ap->nsentctlpkt = 0;
ap->nsentdatapkt = 0;
ap->callback = 0;
for (i = 0; i < CAPI_MAXCONTR; i++) { for (i = 0; i < CAPI_MAXCONTR; i++) {
if (!cards[i] || cards[i]->cardstate != CARD_RUNNING) if (!cards[i] || cards[i]->cardstate != CARD_RUNNING)
continue; continue;
register_appl(cards[i], appl, &ap->rparam); register_appl(cards[i], applid, &ap->rparam);
} }
*applidp = appl; printk(KERN_DEBUG "kcapi: appl %d up\n", applid);
printk(KERN_INFO "kcapi: appl %d up\n", appl);
return CAPI_NOERROR; return CAPI_NOERROR;
} }
EXPORT_SYMBOL(capi20_register); EXPORT_SYMBOL(capi20_register);
u16 capi20_release(u16 applid) u16 capi20_release(struct capi20_appl *ap)
{ {
struct capi_appl *ap = get_capi_appl_by_nr(applid);
int i; int i;
DBG("applid %#x", applid); DBG("applid %#x", ap->applid);
if (!ap)
return CAPI_ILLAPPNR;
skb_queue_purge(&ap->recv_queue); skb_queue_purge(&ap->recv_queue);
for (i = 0; i < CAPI_MAXCONTR; i++) { for (i = 0; i < CAPI_MAXCONTR; i++) {
if (!cards[i] || cards[i]->cardstate != CARD_RUNNING) if (!cards[i] || cards[i]->cardstate != CARD_RUNNING)
continue; continue;
release_appl(cards[i], applid); release_appl(cards[i], ap->applid);
} }
applications[applid - 1] = NULL; applications[ap->applid - 1] = NULL;
kfree(ap); printk(KERN_DEBUG "kcapi: appl %d down\n", ap->applid);
printk(KERN_INFO "kcapi: appl %d down\n", applid);
return CAPI_NOERROR; return CAPI_NOERROR;
} }
...@@ -942,7 +915,7 @@ EXPORT_SYMBOL(capi20_release); ...@@ -942,7 +915,7 @@ EXPORT_SYMBOL(capi20_release);
u16 capi20_put_message(u16 applid, struct sk_buff *skb) u16 capi20_put_message(u16 applid, struct sk_buff *skb)
{ {
struct capi_ctr *card; struct capi_ctr *card;
struct capi_appl *ap; struct capi20_appl *ap;
int showctl = 0; int showctl = 0;
u8 cmd, subcmd; u8 cmd, subcmd;
...@@ -1000,7 +973,7 @@ EXPORT_SYMBOL(capi20_put_message); ...@@ -1000,7 +973,7 @@ EXPORT_SYMBOL(capi20_put_message);
u16 capi20_get_message(u16 applid, struct sk_buff **msgp) u16 capi20_get_message(u16 applid, struct sk_buff **msgp)
{ {
struct capi_appl *ap = get_capi_appl_by_nr(applid); struct capi20_appl *ap = get_capi_appl_by_nr(applid);
struct sk_buff *skb; struct sk_buff *skb;
if (!ap) if (!ap)
...@@ -1017,7 +990,7 @@ u16 capi20_set_signal(u16 applid, ...@@ -1017,7 +990,7 @@ u16 capi20_set_signal(u16 applid,
void (*signal) (u16 applid, void *param), void (*signal) (u16 applid, void *param),
void *param) void *param)
{ {
struct capi_appl *ap = get_capi_appl_by_nr(applid); struct capi20_appl *ap = get_capi_appl_by_nr(applid);
if (!ap) if (!ap)
return CAPI_ILLAPPNR; return CAPI_ILLAPPNR;
...@@ -1287,7 +1260,7 @@ EXPORT_SYMBOL(capi20_manufacturer); ...@@ -1287,7 +1260,7 @@ EXPORT_SYMBOL(capi20_manufacturer);
/* temporary hack */ /* temporary hack */
void capi20_set_callback(u16 applid, void (*callback) (unsigned int cmd, __u32 contr, void *data)) void capi20_set_callback(u16 applid, void (*callback) (unsigned int cmd, __u32 contr, void *data))
{ {
struct capi_appl *ap = get_capi_appl_by_nr(applid); struct capi20_appl *ap = get_capi_appl_by_nr(applid);
ap->callback = callback; ap->callback = callback;
} }
......
...@@ -52,9 +52,31 @@ typedef struct kcapi_carddef { ...@@ -52,9 +52,31 @@ typedef struct kcapi_carddef {
#define KCI_CONTRUP 0 /* struct capi_profile */ #define KCI_CONTRUP 0 /* struct capi_profile */
#define KCI_CONTRDOWN 1 /* NULL */ #define KCI_CONTRDOWN 1 /* NULL */
struct capi20_appl {
u16 applid;
capi_register_params rparam;
/* internal to kernelcapi.o */
void *param;
void (*signal) (u16 applid, void *param);
struct sk_buff_head recv_queue;
int nncci;
struct capi_ncci *nccilist;
unsigned long nrecvctlpkt;
unsigned long nrecvdatapkt;
unsigned long nsentctlpkt;
unsigned long nsentdatapkt;
/* ugly hack to allow for notification of added/removed
* controllers. The Right Way (tm) is known. XXX
*/
void (*callback) (unsigned int cmd, __u32 contr, void *data);
};
u16 capi20_isinstalled(void); u16 capi20_isinstalled(void);
u16 capi20_register(capi_register_params * rparam, u16 * applidp); u16 capi20_register(struct capi20_appl *ap);
u16 capi20_release(u16 applid); u16 capi20_release(struct capi20_appl *ap);
u16 capi20_put_message(u16 applid, struct sk_buff *skb); u16 capi20_put_message(u16 applid, struct sk_buff *skb);
u16 capi20_get_message(u16 applid, struct sk_buff **msgp); u16 capi20_get_message(u16 applid, struct sk_buff **msgp);
u16 capi20_set_signal(u16 applid, u16 capi20_set_signal(u16 applid,
......
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