Commit 3bcbfef3 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: maintain outstanding CAPI messages in the drivers

It's up to the drivers to maintain their list of buffered messages
themselves. As most drivers can share common code, provide it
in capilib.o, inside of the module kernelcapi.o
parent 86315789
...@@ -6,11 +6,11 @@ O_TARGET := vmlinux-obj.o ...@@ -6,11 +6,11 @@ O_TARGET := vmlinux-obj.o
# Objects that export symbols. # Objects that export symbols.
export-objs := kcapi.o capiutil.o capifs.o export-objs := kcapi.o capiutil.o capilib.o capifs.o
# Multipart objects. # Multipart objects.
kernelcapi-objs := kcapi.o capiutil.o kernelcapi-objs := kcapi.o capiutil.o capilib.o
# Ordering constraints: kernelcapi.o first # Ordering constraints: kernelcapi.o first
......
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/isdn/capilli.h>
#define DBG(format, arg...) do { \
printk(KERN_DEBUG __FUNCTION__ ": " format "\n" , ## arg); \
} while (0)
struct capilib_msgidqueue {
struct capilib_msgidqueue *next;
u16 msgid;
};
struct capilib_ncci {
struct list_head list;
u16 applid;
u32 ncci;
u32 winsize;
int nmsg;
struct capilib_msgidqueue *msgidqueue;
struct capilib_msgidqueue *msgidlast;
struct capilib_msgidqueue *msgidfree;
struct capilib_msgidqueue msgidpool[CAPI_MAXDATAWINDOW];
};
// ---------------------------------------------------------------------------
// NCCI Handling
static inline void mq_init(struct capilib_ncci * np)
{
int i;
np->msgidqueue = 0;
np->msgidlast = 0;
np->nmsg = 0;
memset(np->msgidpool, 0, sizeof(np->msgidpool));
np->msgidfree = &np->msgidpool[0];
for (i = 1; i < np->winsize; i++) {
np->msgidpool[i].next = np->msgidfree;
np->msgidfree = &np->msgidpool[i];
}
}
static inline int mq_enqueue(struct capilib_ncci * np, u16 msgid)
{
struct capilib_msgidqueue *mq;
if ((mq = np->msgidfree) == 0)
return 0;
np->msgidfree = mq->next;
mq->msgid = msgid;
mq->next = 0;
if (np->msgidlast)
np->msgidlast->next = mq;
np->msgidlast = mq;
if (!np->msgidqueue)
np->msgidqueue = mq;
np->nmsg++;
return 1;
}
static inline int mq_dequeue(struct capilib_ncci * np, u16 msgid)
{
struct capilib_msgidqueue **pp;
for (pp = &np->msgidqueue; *pp; pp = &(*pp)->next) {
if ((*pp)->msgid == msgid) {
struct capilib_msgidqueue *mq = *pp;
*pp = mq->next;
if (mq == np->msgidlast)
np->msgidlast = 0;
mq->next = np->msgidfree;
np->msgidfree = mq;
np->nmsg--;
return 1;
}
}
return 0;
}
void capilib_new_ncci(struct list_head *head, u16 applid, u32 ncci, u32 winsize)
{
struct capilib_ncci *np;
np = kmalloc(sizeof(*np), GFP_ATOMIC);
if (!np) {
printk(KERN_WARNING "capilib_new_ncci: no memory.\n");
return;
}
if (winsize > CAPI_MAXDATAWINDOW) {
printk(KERN_ERR "capi_new_ncci: winsize %d too big\n",
winsize);
winsize = CAPI_MAXDATAWINDOW;
}
np->applid = applid;
np->ncci = ncci;
np->winsize = winsize;
mq_init(np);
list_add_tail(&np->list, head);
DBG("kcapi: appl %d ncci 0x%x up", applid, ncci);
}
EXPORT_SYMBOL(capilib_new_ncci);
void capilib_free_ncci(struct list_head *head, u16 applid, u32 ncci)
{
struct list_head *l;
struct capilib_ncci *np;
list_for_each(l, head) {
np = list_entry(l, struct capilib_ncci, list);
if (np->applid != applid)
continue;
if (np->ncci != ncci)
continue;
printk(KERN_INFO "kcapi: appl %d ncci 0x%x down\n", applid, ncci);
list_del(&np->list);
kfree(np);
return;
}
printk(KERN_ERR "capilib_free_ncci: ncci 0x%x not found\n", ncci);
}
EXPORT_SYMBOL(capilib_free_ncci);
void capilib_release_appl(struct list_head *head, u16 applid)
{
struct list_head *l, *n;
struct capilib_ncci *np;
list_for_each_safe(l, n, head) {
np = list_entry(l, struct capilib_ncci, list);
if (np->applid != applid)
continue;
printk(KERN_INFO "kcapi: appl %d ncci 0x%x forced down\n", applid, np->ncci);
list_del(&np->list);
kfree(np);
}
}
EXPORT_SYMBOL(capilib_release_appl);
void capilib_release(struct list_head *head)
{
struct list_head *l, *n;
struct capilib_ncci *np;
list_for_each_safe(l, n, head) {
np = list_entry(l, struct capilib_ncci, list);
printk(KERN_INFO "kcapi: appl %d ncci 0x%x forced down\n", np->applid, np->ncci);
list_del(&np->list);
kfree(np);
}
}
EXPORT_SYMBOL(capilib_release);
u16 capilib_data_b3_req(struct list_head *head, u16 applid, u32 ncci, u16 msgid)
{
struct list_head *l;
struct capilib_ncci *np;
list_for_each(l, head) {
np = list_entry(l, struct capilib_ncci, list);
if (np->applid != applid)
continue;
if (np->ncci != ncci)
continue;
if (mq_enqueue(np, msgid) == 0)
return CAPI_SENDQUEUEFULL;
return CAPI_NOERROR;
}
printk(KERN_ERR "capilib_data_b3_req: ncci 0x%x not found\n", ncci);
return CAPI_NOERROR;
}
EXPORT_SYMBOL(capilib_data_b3_req);
void capilib_data_b3_conf(struct list_head *head, u16 applid, u32 ncci, u16 msgid)
{
struct list_head *l;
struct capilib_ncci *np;
list_for_each(l, head) {
np = list_entry(l, struct capilib_ncci, list);
if (np->applid != applid)
continue;
if (np->ncci != ncci)
continue;
if (mq_dequeue(np, msgid) == 0) {
printk(KERN_ERR "kcapi: msgid %hu ncci 0x%x not on queue\n",
msgid, ncci);
}
return;
}
printk(KERN_ERR "capilib_data_b3_conf: ncci 0x%x not found\n", ncci);
}
EXPORT_SYMBOL(capilib_data_b3_conf);
...@@ -55,23 +55,6 @@ MODULE_PARM(showcapimsgs, "i"); ...@@ -55,23 +55,6 @@ MODULE_PARM(showcapimsgs, "i");
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
struct msgidqueue {
struct msgidqueue *next;
u16 msgid;
};
struct capi_ncci {
struct capi_ncci *next;
u16 applid;
u32 ncci;
u32 winsize;
int nmsg;
struct msgidqueue *msgidqueue;
struct msgidqueue *msgidlast;
struct msgidqueue *msgidfree;
struct msgidqueue msgidpool[CAPI_MAXDATAWINDOW];
};
struct capi_appl { struct capi_appl {
u16 applid; u16 applid;
capi_register_params rparam; capi_register_params rparam;
...@@ -245,45 +228,6 @@ static int proc_applications_read_proc(char *page, char **start, off_t off, ...@@ -245,45 +228,6 @@ static int proc_applications_read_proc(char *page, char **start, off_t off,
return len; return len;
} }
/*
* /proc/capi/ncci:
* applid ncci winsize nblk
*/
static int proc_ncci_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct capi_appl *ap;
struct capi_ncci *np;
int i;
int len = 0;
for (i=1; i <= CAPI_MAXAPPL; i++) {
ap = get_capi_appl_by_nr(i);
if (!ap) continue;
for (np = ap->nccilist; np; np = np->next) {
len += sprintf(page+len, "%d 0x%x %d %d\n",
np->applid,
np->ncci,
np->winsize,
np->nmsg);
if (len <= off) {
off -= len;
len = 0;
} else {
if (len-off > count)
goto endloop;
}
}
}
endloop:
*start = page+off;
if (len < count)
*eof = 1;
if (len>count) len = count;
if (len<0) len = 0;
return len;
}
/* /*
* /proc/capi/driver: * /proc/capi/driver:
* driver ncontroller * driver ncontroller
...@@ -477,7 +421,6 @@ static struct procfsentries { ...@@ -477,7 +421,6 @@ static struct procfsentries {
} procfsentries[] = { } procfsentries[] = {
{ "capi", S_IFDIR, 0 }, { "capi", S_IFDIR, 0 },
{ "capi/applications", 0 , proc_applications_read_proc }, { "capi/applications", 0 , proc_applications_read_proc },
{ "capi/ncci", 0 , proc_ncci_read_proc },
{ "capi/driver", 0 , proc_driver_read_proc }, { "capi/driver", 0 , proc_driver_read_proc },
{ "capi/users", 0 , proc_users_read_proc }, { "capi/users", 0 , proc_users_read_proc },
{ "capi/controller", 0 , proc_controller_read_proc }, { "capi/controller", 0 , proc_controller_read_proc },
...@@ -525,26 +468,9 @@ static void register_appl(struct capi_ctr *card, u16 applid, capi_register_param ...@@ -525,26 +468,9 @@ static void register_appl(struct capi_ctr *card, u16 applid, capi_register_param
static void release_appl(struct capi_ctr *card, u16 applid) static void release_appl(struct capi_ctr *card, u16 applid)
{ {
struct capi_appl *ap = get_capi_appl_by_nr(applid); DBG("applid %#x", applid);
struct capi_ncci **pp, **nextpp;
DBG("");
for (pp = &ap->nccilist; *pp; pp = nextpp) {
if (NCCI2CTRL((*pp)->ncci) == card->cnr) {
struct capi_ncci *np = *pp;
*pp = np->next;
printk(KERN_INFO "kcapi: appl %d ncci 0x%x down!\n", applid, np->ncci);
kfree(np);
ap->nncci--;
nextpp = pp;
} else {
nextpp = &(*pp)->next;
}
}
card->driver->release_appl(card, applid); card->driver->release_appl(card, applid);
capi_ctr_put(card); capi_ctr_put(card);
} }
...@@ -679,130 +605,12 @@ static void notify_handler(void *dummy) ...@@ -679,130 +605,12 @@ static void notify_handler(void *dummy)
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
} }
/* -------- NCCI Handling ------------------------------------- */
static inline void mq_init(struct capi_ncci * np)
{
int i;
np->msgidqueue = 0;
np->msgidlast = 0;
np->nmsg = 0;
memset(np->msgidpool, 0, sizeof(np->msgidpool));
np->msgidfree = &np->msgidpool[0];
for (i = 1; i < np->winsize; i++) {
np->msgidpool[i].next = np->msgidfree;
np->msgidfree = &np->msgidpool[i];
}
}
static inline int mq_enqueue(struct capi_ncci * np, u16 msgid)
{
struct msgidqueue *mq;
if ((mq = np->msgidfree) == 0)
return 0;
np->msgidfree = mq->next;
mq->msgid = msgid;
mq->next = 0;
if (np->msgidlast)
np->msgidlast->next = mq;
np->msgidlast = mq;
if (!np->msgidqueue)
np->msgidqueue = mq;
np->nmsg++;
return 1;
}
static inline int mq_dequeue(struct capi_ncci * np, u16 msgid)
{
struct msgidqueue **pp;
for (pp = &np->msgidqueue; *pp; pp = &(*pp)->next) {
if ((*pp)->msgid == msgid) {
struct msgidqueue *mq = *pp;
*pp = mq->next;
if (mq == np->msgidlast)
np->msgidlast = 0;
mq->next = np->msgidfree;
np->msgidfree = mq;
np->nmsg--;
return 1;
}
}
return 0;
}
/*
* ncci management
*/
static void controllercb_new_ncci(struct capi_ctr * card,
u16 appl, u32 ncci, u32 winsize)
{
struct capi_ncci *np;
struct capi_appl *ap = get_capi_appl_by_nr(appl);
if (!ap) {
printk(KERN_ERR "avmb1_handle_new_ncci: illegal appl %d\n", appl);
return;
}
if ((np = (struct capi_ncci *) kmalloc(sizeof(struct capi_ncci), GFP_ATOMIC)) == 0) {
printk(KERN_ERR "capi_new_ncci: alloc failed ncci 0x%x\n", ncci);
return;
}
if (winsize > CAPI_MAXDATAWINDOW) {
printk(KERN_ERR "capi_new_ncci: winsize %d too big, set to %d\n",
winsize, CAPI_MAXDATAWINDOW);
winsize = CAPI_MAXDATAWINDOW;
}
np->applid = appl;
np->ncci = ncci;
np->winsize = winsize;
mq_init(np);
np->next = ap->nccilist;
ap->nccilist = np;
ap->nncci++;
printk(KERN_INFO "kcapi: appl %d ncci 0x%x up\n", appl, ncci);
}
static void controllercb_free_ncci(struct capi_ctr * card,
u16 appl, u32 ncci)
{
struct capi_ncci **pp;
struct capi_appl *ap = get_capi_appl_by_nr(appl);
if (!ap) {
printk(KERN_ERR "free_ncci: illegal appl %d\n", appl);
return;
}
for (pp = &ap->nccilist; *pp; pp = &(*pp)->next) {
if ((*pp)->ncci == ncci) {
struct capi_ncci *np = *pp;
*pp = np->next;
kfree(np);
ap->nncci--;
printk(KERN_INFO "kcapi: appl %d ncci 0x%x down\n", appl, ncci);
return;
}
}
printk(KERN_ERR "free_ncci: ncci 0x%x not found\n", ncci);
}
static struct capi_ncci *find_ncci(struct capi_appl * app, u32 ncci)
{
struct capi_ncci *np;
for (np = app->nccilist; np; np = np->next) {
if (np->ncci == ncci)
return np;
}
return 0;
}
/* -------- Receiver ------------------------------------------ */ /* -------- Receiver ------------------------------------------ */
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 capi_appl *ap;
struct capi_ncci *np;
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));
...@@ -818,13 +626,6 @@ static void recv_handler(void *dummy) ...@@ -818,13 +626,6 @@ static void recv_handler(void *dummy)
kfree_skb(skb); kfree_skb(skb);
continue; continue;
} }
if ( CAPIMSG_COMMAND(skb->data) == CAPI_DATA_B3
&& CAPIMSG_SUBCOMMAND(skb->data) == CAPI_CONF
&& (np = find_ncci(ap, CAPIMSG_NCCI(skb->data))) != 0
&& mq_dequeue(np, CAPIMSG_MSGID(skb->data)) == 0) {
printk(KERN_ERR "kcapi: msgid %hu ncci 0x%x not on queue\n",
CAPIMSG_MSGID(skb->data), np->ncci);
}
if ( CAPIMSG_COMMAND(skb->data) == CAPI_DATA_B3 if ( CAPIMSG_COMMAND(skb->data) == CAPI_DATA_B3
&& CAPIMSG_SUBCOMMAND(skb->data) == CAPI_IND) { && CAPIMSG_SUBCOMMAND(skb->data) == CAPI_IND) {
ap->nrecvdatapkt++; ap->nrecvdatapkt++;
...@@ -917,22 +718,9 @@ static void controllercb_reseted(struct capi_ctr * card) ...@@ -917,22 +718,9 @@ static void controllercb_reseted(struct capi_ctr * card)
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 capi_appl *ap = get_capi_appl_by_nr(appl);
struct capi_ncci **pp, **nextpp;
if (!ap) if (!ap)
continue; continue;
for (pp = &ap->nccilist; *pp; pp = nextpp) {
if (NCCI2CTRL((*pp)->ncci) == card->cnr) {
struct capi_ncci *np = *pp;
*pp = np->next;
printk(KERN_INFO "kcapi: appl %d ncci 0x%x forced down!\n", appl, np->ncci);
kfree(np);
nextpp = pp;
} else {
nextpp = &(*pp)->next;
}
}
capi_ctr_put(card); capi_ctr_put(card);
} }
...@@ -993,8 +781,6 @@ attach_capi_ctr(struct capi_driver *driver, char *name, void *driverdata) ...@@ -993,8 +781,6 @@ attach_capi_ctr(struct capi_driver *driver, char *name, void *driverdata)
card->suspend_output = controllercb_suspend_output; card->suspend_output = controllercb_suspend_output;
card->resume_output = controllercb_resume_output; card->resume_output = controllercb_resume_output;
card->handle_capimsg = controllercb_handle_capimsg; card->handle_capimsg = controllercb_handle_capimsg;
card->new_ncci = controllercb_new_ncci;
card->free_ncci = controllercb_free_ncci;
list_add_tail(&card->driver_list, &driver->contr_head); list_add_tail(&card->driver_list, &driver->contr_head);
driver->ncontroller++; driver->ncontroller++;
...@@ -1185,7 +971,6 @@ static u16 capi_put_message(u16 applid, struct sk_buff *skb) ...@@ -1185,7 +971,6 @@ static u16 capi_put_message(u16 applid, struct sk_buff *skb)
{ {
struct capi_ctr *card; struct capi_ctr *card;
struct capi_appl *ap; struct capi_appl *ap;
struct capi_ncci *np;
int showctl = 0; int showctl = 0;
u8 cmd, subcmd; u8 cmd, subcmd;
...@@ -1213,9 +998,6 @@ static u16 capi_put_message(u16 applid, struct sk_buff *skb) ...@@ -1213,9 +998,6 @@ static u16 capi_put_message(u16 applid, struct sk_buff *skb)
subcmd = CAPIMSG_SUBCOMMAND(skb->data); subcmd = CAPIMSG_SUBCOMMAND(skb->data);
if (cmd == CAPI_DATA_B3 && subcmd== CAPI_REQ) { if (cmd == CAPI_DATA_B3 && subcmd== CAPI_REQ) {
if ((np = find_ncci(ap, CAPIMSG_NCCI(skb->data))) != 0
&& mq_enqueue(np, CAPIMSG_MSGID(skb->data)) == 0)
return CAPI_SENDQUEUEFULL;
card->nsentdatapkt++; card->nsentdatapkt++;
ap->nsentdatapkt++; ap->nsentdatapkt++;
if (card->traceflag > 2) showctl |= 2; if (card->traceflag > 2) showctl |= 2;
...@@ -1239,8 +1021,7 @@ static u16 capi_put_message(u16 applid, struct sk_buff *skb) ...@@ -1239,8 +1021,7 @@ static u16 capi_put_message(u16 applid, struct sk_buff *skb)
} }
} }
card->driver->send_message(card, skb); return card->driver->send_message(card, skb);
return CAPI_NOERROR;
} }
static u16 capi_get_message(u16 applid, struct sk_buff **msgp) static u16 capi_get_message(u16 applid, struct sk_buff **msgp)
......
...@@ -69,6 +69,7 @@ typedef struct avmctrl_info { ...@@ -69,6 +69,7 @@ typedef struct avmctrl_info {
struct avmcard *card; struct avmcard *card;
struct capi_ctr *capi_ctrl; struct capi_ctr *capi_ctrl;
struct list_head ncci_head;
} avmctrl_info; } avmctrl_info;
typedef struct avmcard { typedef struct avmcard {
...@@ -549,7 +550,7 @@ void b1_reset_ctr(struct capi_ctr *ctrl); ...@@ -549,7 +550,7 @@ void b1_reset_ctr(struct capi_ctr *ctrl);
void b1_register_appl(struct capi_ctr *ctrl, u16 appl, void b1_register_appl(struct capi_ctr *ctrl, u16 appl,
capi_register_params *rp); capi_register_params *rp);
void b1_release_appl(struct capi_ctr *ctrl, u16 appl); void b1_release_appl(struct capi_ctr *ctrl, u16 appl);
void b1_send_message(struct capi_ctr *ctrl, struct sk_buff *skb); u16 b1_send_message(struct capi_ctr *ctrl, struct sk_buff *skb);
void b1_parse_version(avmctrl_info *card); void b1_parse_version(avmctrl_info *card);
void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs); void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs);
...@@ -574,7 +575,7 @@ void b1dma_register_appl(struct capi_ctr *ctrl, ...@@ -574,7 +575,7 @@ void b1dma_register_appl(struct capi_ctr *ctrl,
u16 appl, u16 appl,
capi_register_params *rp); capi_register_params *rp);
void b1dma_release_appl(struct capi_ctr *ctrl, u16 appl); void b1dma_release_appl(struct capi_ctr *ctrl, u16 appl);
void b1dma_send_message(struct capi_ctr *ctrl, struct sk_buff *skb); u16 b1dma_send_message(struct capi_ctr *ctrl, struct sk_buff *skb);
int b1dmactl_read_proc(char *page, char **start, off_t off, int b1dmactl_read_proc(char *page, char **start, off_t off,
int count, int *eof, struct capi_ctr *ctrl); int count, int *eof, struct capi_ctr *ctrl);
......
...@@ -80,6 +80,7 @@ avmcard *b1_alloc_card(int nr_controllers) ...@@ -80,6 +80,7 @@ avmcard *b1_alloc_card(int nr_controllers)
card->ctrlinfo = cinfo; card->ctrlinfo = cinfo;
for (i = 0; i < nr_controllers; i++) { for (i = 0; i < nr_controllers; i++) {
INIT_LIST_HEAD(&cinfo[i].ncci_head);
cinfo[i].card = card; cinfo[i].card = card;
} }
spin_lock_init(&card->lock); spin_lock_init(&card->lock);
...@@ -331,6 +332,7 @@ void b1_reset_ctr(struct capi_ctr *ctrl) ...@@ -331,6 +332,7 @@ void b1_reset_ctr(struct capi_ctr *ctrl)
b1_reset(port); b1_reset(port);
memset(cinfo->version, 0, sizeof(cinfo->version)); memset(cinfo->version, 0, sizeof(cinfo->version));
capilib_release(&cinfo->ncci_head);
ctrl->reseted(ctrl); ctrl->reseted(ctrl);
} }
...@@ -366,6 +368,8 @@ void b1_release_appl(struct capi_ctr *ctrl, u16 appl) ...@@ -366,6 +368,8 @@ void b1_release_appl(struct capi_ctr *ctrl, u16 appl)
unsigned int port = card->port; unsigned int port = card->port;
unsigned long flags; unsigned long flags;
capilib_release_appl(&cinfo->ncci_head, appl);
save_flags(flags); save_flags(flags);
cli(); cli();
b1_put_byte(port, SEND_RELEASE); b1_put_byte(port, SEND_RELEASE);
...@@ -373,7 +377,7 @@ void b1_release_appl(struct capi_ctr *ctrl, u16 appl) ...@@ -373,7 +377,7 @@ void b1_release_appl(struct capi_ctr *ctrl, u16 appl)
restore_flags(flags); restore_flags(flags);
} }
void b1_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) u16 b1_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
{ {
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
avmcard *card = cinfo->card; avmcard *card = cinfo->card;
...@@ -382,20 +386,36 @@ void b1_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) ...@@ -382,20 +386,36 @@ void b1_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
u16 len = CAPIMSG_LEN(skb->data); u16 len = CAPIMSG_LEN(skb->data);
u8 cmd = CAPIMSG_COMMAND(skb->data); u8 cmd = CAPIMSG_COMMAND(skb->data);
u8 subcmd = CAPIMSG_SUBCOMMAND(skb->data); u8 subcmd = CAPIMSG_SUBCOMMAND(skb->data);
u16 dlen, retval;
save_flags(flags);
cli();
if (CAPICMD(cmd, subcmd) == CAPI_DATA_B3_REQ) { if (CAPICMD(cmd, subcmd) == CAPI_DATA_B3_REQ) {
u16 dlen = CAPIMSG_DATALEN(skb->data); retval = capilib_data_b3_req(&cinfo->ncci_head,
CAPIMSG_APPID(skb->data),
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
if (retval != CAPI_NOERROR)
goto out;
dlen = CAPIMSG_DATALEN(skb->data);
save_flags(flags);
cli();
b1_put_byte(port, SEND_DATA_B3_REQ); b1_put_byte(port, SEND_DATA_B3_REQ);
b1_put_slice(port, skb->data, len); b1_put_slice(port, skb->data, len);
b1_put_slice(port, skb->data + len, dlen); b1_put_slice(port, skb->data + len, dlen);
restore_flags(flags);
} else { } else {
retval = CAPI_NOERROR;
save_flags(flags);
cli();
b1_put_byte(port, SEND_MESSAGE); b1_put_byte(port, SEND_MESSAGE);
b1_put_slice(port, skb->data, len); b1_put_slice(port, skb->data, len);
restore_flags(flags);
} }
restore_flags(flags); out:
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
return retval;
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
...@@ -525,6 +545,11 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs) ...@@ -525,6 +545,11 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
card->name); card->name);
} else { } else {
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_CONF)
capilib_data_b3_conf(&cinfo->ncci_head, ApplId,
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
ctrl->handle_capimsg(ctrl, ApplId, skb); ctrl->handle_capimsg(ctrl, ApplId, skb);
} }
break; break;
...@@ -535,7 +560,7 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs) ...@@ -535,7 +560,7 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
NCCI = b1_get_word(card->port); NCCI = b1_get_word(card->port);
WindowSize = b1_get_word(card->port); WindowSize = b1_get_word(card->port);
ctrl->new_ncci(ctrl, ApplId, NCCI, WindowSize); capilib_new_ncci(&cinfo->ncci_head, ApplId, NCCI, WindowSize);
break; break;
...@@ -545,8 +570,8 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs) ...@@ -545,8 +570,8 @@ void b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
NCCI = b1_get_word(card->port); NCCI = b1_get_word(card->port);
if (NCCI != 0xffffffff) if (NCCI != 0xffffffff)
ctrl->free_ncci(ctrl, ApplId, NCCI); capilib_free_ncci(&cinfo->ncci_head, ApplId, NCCI);
break; break;
case RECEIVE_START: case RECEIVE_START:
......
...@@ -488,6 +488,11 @@ static void b1dma_handle_rx(avmcard *card) ...@@ -488,6 +488,11 @@ static void b1dma_handle_rx(avmcard *card)
card->name); card->name);
} else { } else {
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_CONF)
capilib_data_b3_conf(&cinfo->ncci_head, ApplId,
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
ctrl->handle_capimsg(ctrl, ApplId, skb); ctrl->handle_capimsg(ctrl, ApplId, skb);
} }
break; break;
...@@ -498,7 +503,7 @@ static void b1dma_handle_rx(avmcard *card) ...@@ -498,7 +503,7 @@ static void b1dma_handle_rx(avmcard *card)
NCCI = _get_word(&p); NCCI = _get_word(&p);
WindowSize = _get_word(&p); WindowSize = _get_word(&p);
ctrl->new_ncci(ctrl, ApplId, NCCI, WindowSize); capilib_new_ncci(&cinfo->ncci_head, ApplId, NCCI, WindowSize);
break; break;
...@@ -508,7 +513,7 @@ static void b1dma_handle_rx(avmcard *card) ...@@ -508,7 +513,7 @@ static void b1dma_handle_rx(avmcard *card)
NCCI = _get_word(&p); NCCI = _get_word(&p);
if (NCCI != 0xffffffff) if (NCCI != 0xffffffff)
ctrl->free_ncci(ctrl, ApplId, NCCI); capilib_free_ncci(&cinfo->ncci_head, ApplId, NCCI);
break; break;
...@@ -734,6 +739,7 @@ void b1dma_reset_ctr(struct capi_ctr *ctrl) ...@@ -734,6 +739,7 @@ void b1dma_reset_ctr(struct capi_ctr *ctrl)
b1dma_reset(card); b1dma_reset(card);
memset(cinfo->version, 0, sizeof(cinfo->version)); memset(cinfo->version, 0, sizeof(cinfo->version));
capilib_release(&cinfo->ncci_head);
ctrl->reseted(ctrl); ctrl->reseted(ctrl);
} }
...@@ -785,6 +791,8 @@ void b1dma_release_appl(struct capi_ctr *ctrl, u16 appl) ...@@ -785,6 +791,8 @@ void b1dma_release_appl(struct capi_ctr *ctrl, u16 appl)
struct sk_buff *skb; struct sk_buff *skb;
void *p; void *p;
capilib_release_appl(&cinfo->ncci_head, appl);
skb = alloc_skb(7, GFP_ATOMIC); skb = alloc_skb(7, GFP_ATOMIC);
if (!skb) { if (!skb) {
printk(KERN_CRIT "%s: no memory, lost release appl.\n", printk(KERN_CRIT "%s: no memory, lost release appl.\n",
...@@ -804,12 +812,24 @@ void b1dma_release_appl(struct capi_ctr *ctrl, u16 appl) ...@@ -804,12 +812,24 @@ void b1dma_release_appl(struct capi_ctr *ctrl, u16 appl)
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
void b1dma_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) u16 b1dma_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
{ {
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
avmcard *card = cinfo->card; avmcard *card = cinfo->card;
u16 retval = CAPI_NOERROR;
b1dma_queue_tx(card, skb); if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_REQ) {
retval = capilib_data_b3_req(&cinfo->ncci_head,
CAPIMSG_APPID(skb->data),
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
}
if (retval == CAPI_NOERROR)
b1dma_queue_tx(card, skb);
else
dev_kfree_skb_any(skb);
return retval;
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
......
...@@ -548,6 +548,7 @@ static void c4_handle_rx(avmcard *card) ...@@ -548,6 +548,7 @@ static void c4_handle_rx(avmcard *card)
MsgLen = _get_slice(&p, card->msgbuf); MsgLen = _get_slice(&p, card->msgbuf);
cidx = CAPIMSG_CONTROLLER(card->msgbuf)-card->cardnr; cidx = CAPIMSG_CONTROLLER(card->msgbuf)-card->cardnr;
if (cidx >= card->nlogcontr) cidx = 0; if (cidx >= card->nlogcontr) cidx = 0;
cinfo = &card->ctrlinfo[cidx];
ctrl = card->ctrlinfo[cidx].capi_ctrl; ctrl = card->ctrlinfo[cidx].capi_ctrl;
if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) { if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) {
...@@ -555,6 +556,11 @@ static void c4_handle_rx(avmcard *card) ...@@ -555,6 +556,11 @@ static void c4_handle_rx(avmcard *card)
card->name); card->name);
} else { } else {
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_CONF)
capilib_data_b3_conf(&cinfo->ncci_head, ApplId,
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
ctrl->handle_capimsg(ctrl, ApplId, skb); ctrl->handle_capimsg(ctrl, ApplId, skb);
} }
break; break;
...@@ -566,9 +572,8 @@ static void c4_handle_rx(avmcard *card) ...@@ -566,9 +572,8 @@ static void c4_handle_rx(avmcard *card)
WindowSize = _get_word(&p); WindowSize = _get_word(&p);
cidx = (NCCI&0x7f) - card->cardnr; cidx = (NCCI&0x7f) - card->cardnr;
if (cidx >= card->nlogcontr) cidx = 0; if (cidx >= card->nlogcontr) cidx = 0;
ctrl = card->ctrlinfo[cidx].capi_ctrl;
ctrl->new_ncci(ctrl, ApplId, NCCI, WindowSize); capilib_new_ncci(&card->ctrlinfo[cidx].ncci_head, ApplId, NCCI, WindowSize);
break; break;
...@@ -580,9 +585,7 @@ static void c4_handle_rx(avmcard *card) ...@@ -580,9 +585,7 @@ static void c4_handle_rx(avmcard *card)
if (NCCI != 0xffffffff) { if (NCCI != 0xffffffff) {
cidx = (NCCI&0x7f) - card->cardnr; cidx = (NCCI&0x7f) - card->cardnr;
if (cidx >= card->nlogcontr) cidx = 0; if (cidx >= card->nlogcontr) cidx = 0;
ctrl = card->ctrlinfo[cidx].capi_ctrl; capilib_free_ncci(&card->ctrlinfo[cidx].ncci_head, ApplId, NCCI);
if (ctrl)
ctrl->free_ncci(ctrl, ApplId, NCCI);
} }
break; break;
...@@ -675,6 +678,7 @@ static void c4_handle_interrupt(avmcard *card) ...@@ -675,6 +678,7 @@ static void c4_handle_interrupt(avmcard *card)
for (i=0; i < 4; i++) { for (i=0; i < 4; i++) {
avmctrl_info *cinfo = &card->ctrlinfo[i]; avmctrl_info *cinfo = &card->ctrlinfo[i];
memset(cinfo->version, 0, sizeof(cinfo->version)); memset(cinfo->version, 0, sizeof(cinfo->version));
capilib_release(&cinfo->ncci_head);
if (cinfo->capi_ctrl) if (cinfo->capi_ctrl)
cinfo->capi_ctrl->reseted(cinfo->capi_ctrl); cinfo->capi_ctrl->reseted(cinfo->capi_ctrl);
} }
...@@ -974,6 +978,8 @@ void c4_release_appl(struct capi_ctr *ctrl, u16 appl) ...@@ -974,6 +978,8 @@ void c4_release_appl(struct capi_ctr *ctrl, u16 appl)
struct sk_buff *skb; struct sk_buff *skb;
void *p; void *p;
capilib_release_appl(&cinfo->ncci_head, appl);
if (ctrl->cnr == card->cardnr) { if (ctrl->cnr == card->cardnr) {
skb = alloc_skb(7, GFP_ATOMIC); skb = alloc_skb(7, GFP_ATOMIC);
if (!skb) { if (!skb) {
...@@ -996,12 +1002,25 @@ void c4_release_appl(struct capi_ctr *ctrl, u16 appl) ...@@ -996,12 +1002,25 @@ void c4_release_appl(struct capi_ctr *ctrl, u16 appl)
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
static void c4_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) static u16 c4_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
{ {
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
avmcard *card = cinfo->card; avmcard *card = cinfo->card;
skb_queue_tail(&card->dma->send_queue, skb); u16 retval = CAPI_NOERROR;
c4_dispatch_tx(card);
if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_REQ) {
retval = capilib_data_b3_req(&cinfo->ncci_head,
CAPIMSG_APPID(skb->data),
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
}
if (retval == CAPI_NOERROR) {
skb_queue_tail(&card->dma->send_queue, skb);
c4_dispatch_tx(card);
} else {
dev_kfree_skb_any(skb);
}
return retval;
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/capi.h> #include <linux/capi.h>
#include <linux/netdevice.h>
#include <linux/kernelcapi.h> #include <linux/kernelcapi.h>
#include <linux/init.h> #include <linux/init.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -174,6 +175,11 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs) ...@@ -174,6 +175,11 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
card->name); card->name);
} else { } else {
memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3)
capilib_data_b3_conf(&cinfo->ncci_head, ApplId,
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
ctrl->handle_capimsg(ctrl, ApplId, skb); ctrl->handle_capimsg(ctrl, ApplId, skb);
} }
break; break;
...@@ -184,7 +190,7 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs) ...@@ -184,7 +190,7 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
NCCI = b1_get_word(card->port); NCCI = b1_get_word(card->port);
WindowSize = b1_get_word(card->port); WindowSize = b1_get_word(card->port);
ctrl->new_ncci(ctrl, ApplId, NCCI, WindowSize); capilib_new_ncci(&cinfo->ncci_head, ApplId, NCCI, WindowSize);
break; break;
...@@ -194,7 +200,7 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs) ...@@ -194,7 +200,7 @@ static void t1isa_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
NCCI = b1_get_word(card->port); NCCI = b1_get_word(card->port);
if (NCCI != 0xffffffff) if (NCCI != 0xffffffff)
ctrl->free_ncci(ctrl, ApplId, NCCI); capilib_free_ncci(&cinfo->ncci_head, ApplId, NCCI);
break; break;
...@@ -313,6 +319,7 @@ void t1isa_reset_ctr(struct capi_ctr *ctrl) ...@@ -313,6 +319,7 @@ void t1isa_reset_ctr(struct capi_ctr *ctrl)
b1_reset(port); b1_reset(port);
memset(cinfo->version, 0, sizeof(cinfo->version)); memset(cinfo->version, 0, sizeof(cinfo->version));
capilib_release(&cinfo->ncci_head);
ctrl->reseted(ctrl); ctrl->reseted(ctrl);
} }
...@@ -433,7 +440,7 @@ static int t1isa_add_card(struct capi_driver *driver, struct capicardparams *p) ...@@ -433,7 +440,7 @@ static int t1isa_add_card(struct capi_driver *driver, struct capicardparams *p)
return retval; return retval;
} }
static void t1isa_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) static u16 t1isa_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
{ {
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
avmcard *card = cinfo->card; avmcard *card = cinfo->card;
...@@ -442,20 +449,36 @@ static void t1isa_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) ...@@ -442,20 +449,36 @@ static void t1isa_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
u16 len = CAPIMSG_LEN(skb->data); u16 len = CAPIMSG_LEN(skb->data);
u8 cmd = CAPIMSG_COMMAND(skb->data); u8 cmd = CAPIMSG_COMMAND(skb->data);
u8 subcmd = CAPIMSG_SUBCOMMAND(skb->data); u8 subcmd = CAPIMSG_SUBCOMMAND(skb->data);
u16 dlen, retval;
save_flags(flags);
cli();
if (CAPICMD(cmd, subcmd) == CAPI_DATA_B3_REQ) { if (CAPICMD(cmd, subcmd) == CAPI_DATA_B3_REQ) {
u16 dlen = CAPIMSG_DATALEN(skb->data); retval = capilib_data_b3_req(&cinfo->ncci_head,
CAPIMSG_APPID(skb->data),
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
if (retval != CAPI_NOERROR)
goto out;
dlen = CAPIMSG_DATALEN(skb->data);
save_flags(flags);
cli();
b1_put_byte(port, SEND_DATA_B3_REQ); b1_put_byte(port, SEND_DATA_B3_REQ);
t1_put_slice(port, skb->data, len); t1_put_slice(port, skb->data, len);
t1_put_slice(port, skb->data + len, dlen); t1_put_slice(port, skb->data + len, dlen);
restore_flags(flags);
} else { } else {
retval = CAPI_NOERROR;
save_flags(flags);
cli();
b1_put_byte(port, SEND_MESSAGE); b1_put_byte(port, SEND_MESSAGE);
t1_put_slice(port, skb->data, len); t1_put_slice(port, skb->data, len);
restore_flags(flags);
} }
restore_flags(flags); out:
dev_kfree_skb(skb); dev_kfree_skb_any(skb);
return retval;
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/netdevice.h>
#define VER_DRIVER 0 #define VER_DRIVER 0
#define VER_CARDTYPE 1 #define VER_CARDTYPE 1
...@@ -62,9 +62,12 @@ Kernel-Capi callback reset_ctr ...@@ -62,9 +62,12 @@ Kernel-Capi callback reset_ctr
void void
hycapi_reset_ctr(struct capi_ctr *ctrl) hycapi_reset_ctr(struct capi_ctr *ctrl)
{ {
hycapictrl_info *cinfo = ctrl->driverdata;
#ifdef HYCAPI_PRINTFNAMES #ifdef HYCAPI_PRINTFNAMES
printk(KERN_NOTICE "HYCAPI hycapi_reset_ctr\n"); printk(KERN_NOTICE "HYCAPI hycapi_reset_ctr\n");
#endif #endif
capilib_release(&cinfo->ncci_head);
ctrl->reseted(ctrl); ctrl->reseted(ctrl);
} }
...@@ -269,6 +272,9 @@ static void hycapi_release_internal(struct capi_ctr *ctrl, __u16 appl) ...@@ -269,6 +272,9 @@ static void hycapi_release_internal(struct capi_ctr *ctrl, __u16 appl)
__u16 len; __u16 len;
__u8 _command = 0xa1, _subcommand = 0x80; __u8 _command = 0xa1, _subcommand = 0x80;
__u16 MessageNumber = 0x0000; __u16 MessageNumber = 0x0000;
capilib_release_appl(&cinfo->ncci_head, appl);
#ifdef HYCAPI_PRINTFNAMES #ifdef HYCAPI_PRINTFNAMES
printk(KERN_NOTICE "hycapi_release_appl\n"); printk(KERN_NOTICE "hycapi_release_appl\n");
#endif #endif
...@@ -373,12 +379,14 @@ firmware-releases that do not check the MsgLen-Indication! ...@@ -373,12 +379,14 @@ firmware-releases that do not check the MsgLen-Indication!
***************************************************************/ ***************************************************************/
void hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) u16 hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
{ {
__u16 appl_id; __u16 appl_id;
int _len, _len2; int _len, _len2;
__u8 msghead[64]; __u8 msghead[64];
hycapictrl_info *cinfo = ctrl->driverdata;
u16 retval = CAPI_NOERROR;
appl_id = CAPIMSG_APPID(skb->data); appl_id = CAPIMSG_APPID(skb->data);
switch(_hycapi_appCheck(appl_id, ctrl->cnr)) switch(_hycapi_appCheck(appl_id, ctrl->cnr))
{ {
...@@ -392,12 +400,13 @@ void hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) ...@@ -392,12 +400,13 @@ void hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
break; break;
default: default:
printk(KERN_ERR "HYCAPI: Controller mixup!\n"); printk(KERN_ERR "HYCAPI: Controller mixup!\n");
return; retval = CAPI_ILLAPPNR;
goto out;
} }
switch(CAPIMSG_CMD(skb->data)) { switch(CAPIMSG_CMD(skb->data)) {
case CAPI_DISCONNECT_B3_RESP: case CAPI_DISCONNECT_B3_RESP:
ctrl->free_ncci(ctrl, appl_id, capilib_free_ncci(&cinfo->ncci_head, appl_id,
CAPIMSG_NCCI(skb->data)); CAPIMSG_NCCI(skb->data));
break; break;
case CAPI_DATA_B3_REQ: case CAPI_DATA_B3_REQ:
_len = CAPIMSG_LEN(skb->data); _len = CAPIMSG_LEN(skb->data);
...@@ -407,6 +416,10 @@ void hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) ...@@ -407,6 +416,10 @@ void hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
memcpy(skb->data + _len2, msghead, 22); memcpy(skb->data + _len2, msghead, 22);
skb_pull(skb, _len2); skb_pull(skb, _len2);
CAPIMSG_SETLEN(skb->data, 22); CAPIMSG_SETLEN(skb->data, 22);
retval = capilib_data_b3_req(&cinfo->ncci_head,
CAPIMSG_APPID(skb->data),
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
} }
break; break;
case CAPI_LISTEN_REQ: case CAPI_LISTEN_REQ:
...@@ -423,7 +436,13 @@ void hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) ...@@ -423,7 +436,13 @@ void hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
default: default:
break; break;
} }
hycapi_sendmsg_internal(ctrl, skb); out:
if (retval == CAPI_NOERROR)
hycapi_sendmsg_internal(ctrl, skb);
else
dev_kfree_skb_any(skb);
return retval;
} }
/********************************************************************* /*********************************************************************
...@@ -575,8 +594,8 @@ hycapi_rx_capipkt(hysdn_card * card, uchar * buf, word len) ...@@ -575,8 +594,8 @@ hycapi_rx_capipkt(hysdn_card * card, uchar * buf, word len)
switch(info) switch(info)
{ {
case 0: case 0:
ctrl->new_ncci(ctrl, ApplId, CAPIMSG_NCCI(skb->data), capilib_new_ncci(&cinfo->ncci_head, ApplId, CAPIMSG_NCCI(skb->data),
hycapi_applications[ApplId-1].rp.datablkcnt); hycapi_applications[ApplId-1].rp.datablkcnt);
break; break;
case 0x0001: case 0x0001:
...@@ -604,9 +623,14 @@ hycapi_rx_capipkt(hysdn_card * card, uchar * buf, word len) ...@@ -604,9 +623,14 @@ hycapi_rx_capipkt(hysdn_card * card, uchar * buf, word len)
} }
break; break;
case CAPI_CONNECT_B3_IND: case CAPI_CONNECT_B3_IND:
ctrl->new_ncci(ctrl, ApplId, capilib_new_ncci(&cinfo->ncci_head, ApplId,
CAPIMSG_NCCI(skb->data), CAPIMSG_NCCI(skb->data),
hycapi_applications[ApplId-1].rp.datablkcnt); hycapi_applications[ApplId-1].rp.datablkcnt);
break;
case CAPI_DATA_B3_CONF:
capilib_data_b3_conf(&cinfo->ncci_head, ApplId,
CAPIMSG_NCCI(skb->data),
CAPIMSG_MSGID(skb->data));
break; break;
default: default:
break; break;
...@@ -786,6 +810,7 @@ hycapi_capi_create(hysdn_card *card) ...@@ -786,6 +810,7 @@ hycapi_capi_create(hysdn_card *card)
card->hyctrlinfo = cinfo; card->hyctrlinfo = cinfo;
cinfo->card = card; cinfo->card = card;
spin_lock_init(&cinfo->lock); spin_lock_init(&cinfo->lock);
INIT_LIST_HEAD(&cinfo->ncci_head);
switch (card->brdtype) { switch (card->brdtype) {
case BD_PCCARD: strcpy(cinfo->cardname,"HYSDN Hycard"); break; case BD_PCCARD: strcpy(cinfo->cardname,"HYSDN Hycard"); break;
......
...@@ -213,6 +213,8 @@ typedef struct HYSDN_CARD { ...@@ -213,6 +213,8 @@ typedef struct HYSDN_CARD {
int in_idx, out_idx; /* indexes to buffer ring */ int in_idx, out_idx; /* indexes to buffer ring */
int sk_count; /* number of buffers currently in ring */ int sk_count; /* number of buffers currently in ring */
struct sk_buff *tx_skb; /* buffer for tx operation */ struct sk_buff *tx_skb; /* buffer for tx operation */
struct list_head ncci_head;
} *hyctrlinfo; } *hyctrlinfo;
#endif /* CONFIG_HYSDN_CAPI */ #endif /* CONFIG_HYSDN_CAPI */
} hysdn_card; } hysdn_card;
...@@ -284,7 +286,7 @@ extern void hycapi_remove_ctr(struct capi_ctr *); ...@@ -284,7 +286,7 @@ extern void hycapi_remove_ctr(struct capi_ctr *);
extern void hycapi_register_appl(struct capi_ctr *, __u16 appl, extern void hycapi_register_appl(struct capi_ctr *, __u16 appl,
capi_register_params *); capi_register_params *);
extern void hycapi_release_appl(struct capi_ctr *, __u16 appl); extern void hycapi_release_appl(struct capi_ctr *, __u16 appl);
extern void hycapi_send_message(struct capi_ctr *, struct sk_buff *skb); extern u16 hycapi_send_message(struct capi_ctr *, struct sk_buff *skb);
extern char *hycapi_procinfo(struct capi_ctr *); extern char *hycapi_procinfo(struct capi_ctr *);
extern int hycapi_read_proc(char *page, char **start, off_t off, extern int hycapi_read_proc(char *page, char **start, off_t off,
int count, int *eof, struct capi_ctr *card); int count, int *eof, struct capi_ctr *card);
......
...@@ -12,7 +12,10 @@ ...@@ -12,7 +12,10 @@
#ifndef __CAPILLI_H__ #ifndef __CAPILLI_H__
#define __CAPILLI_H__ #define __CAPILLI_H__
#include <linux/kernel.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/capi.h>
#include <linux/kernelcapi.h>
typedef struct capiloaddatapart { typedef struct capiloaddatapart {
int user; /* data in userspace ? */ int user; /* data in userspace ? */
...@@ -60,10 +63,6 @@ struct capi_ctr { ...@@ -60,10 +63,6 @@ struct capi_ctr {
void (*handle_capimsg)(struct capi_ctr * card, void (*handle_capimsg)(struct capi_ctr * card,
__u16 appl, struct sk_buff *skb); __u16 appl, struct sk_buff *skb);
void (*new_ncci)(struct capi_ctr * card,
__u16 appl, __u32 ncci, __u32 winsize);
void (*free_ncci)(struct capi_ctr * card, __u16 appl, __u32 ncci);
/* management information for kcapi */ /* management information for kcapi */
unsigned long nrecvctlpkt; unsigned long nrecvctlpkt;
...@@ -85,7 +84,7 @@ struct capi_driver { ...@@ -85,7 +84,7 @@ struct capi_driver {
void (*register_appl)(struct capi_ctr *, __u16 appl, void (*register_appl)(struct capi_ctr *, __u16 appl,
capi_register_params *); capi_register_params *);
void (*release_appl)(struct capi_ctr *, __u16 appl); void (*release_appl)(struct capi_ctr *, __u16 appl);
void (*send_message)(struct capi_ctr *, struct sk_buff *skb); u16 (*send_message)(struct capi_ctr *, struct sk_buff *skb);
char *(*procinfo)(struct capi_ctr *); char *(*procinfo)(struct capi_ctr *);
int (*ctr_read_proc)(char *page, char **start, off_t off, int (*ctr_read_proc)(char *page, char **start, off_t off,
...@@ -109,4 +108,16 @@ void detach_capi_driver(struct capi_driver *driver); ...@@ -109,4 +108,16 @@ void detach_capi_driver(struct capi_driver *driver);
struct capi_ctr *attach_capi_ctr(struct capi_driver *driver, char *name, void *data); struct capi_ctr *attach_capi_ctr(struct capi_driver *driver, char *name, void *data);
int detach_capi_ctr(struct capi_ctr *); int detach_capi_ctr(struct capi_ctr *);
// ---------------------------------------------------------------------------
// library functions for use by hardware controller drivers
void capilib_new_ncci(struct list_head *head, u16 applid, u32 ncci, u32 winsize);
void capilib_free_ncci(struct list_head *head, u16 applid, u32 ncci);
void capilib_release_appl(struct list_head *head, u16 applid);
void capilib_release(struct list_head *head);
void capilib_data_b3_conf(struct list_head *head, u16 applid, u32 ncci, u16 msgid);
u16 capilib_data_b3_req(struct list_head *head, u16 applid, u32 ncci, u16 msgid);
#endif /* __CAPILLI_H__ */ #endif /* __CAPILLI_H__ */
...@@ -47,6 +47,8 @@ typedef struct kcapi_carddef { ...@@ -47,6 +47,8 @@ typedef struct kcapi_carddef {
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/skbuff.h>
struct capi_interface { struct capi_interface {
__u16 (*capi_isinstalled) (void); __u16 (*capi_isinstalled) (void);
......
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