13 #include <linux/module.h>
16 #include <linux/signal.h>
17 #include <linux/kernel.h>
19 #include <linux/netdevice.h>
20 #include <linux/slab.h>
23 #define VER_CARDTYPE 1
32 #include <linux/kernelcapi.h>
34 static char hycapi_revision[] =
"$Revision: 1.8.6.4 $";
49 static inline int _hycapi_appCheck(
int app_id,
int ctrl_no)
51 if ((ctrl_no <= 0) || (ctrl_no >
CAPI_MAXCONTR) || (app_id <= 0) ||
54 printk(
KERN_ERR "HYCAPI: Invalid request app_id %d for controller %d", app_id, ctrl_no);
57 return ((hycapi_applications[app_id - 1].ctrl_mask & (1 << (ctrl_no-1))) != 0);
69 #ifdef HYCAPI_PRINTFNAMES
84 hycapictrl_info *cinfo =
NULL;
86 #ifdef HYCAPI_PRINTFNAMES
97 if (hycapi_applications[i].listen_req[ctrl->
cnr - 1]) {
98 kfree_skb(hycapi_applications[i].listen_req[ctrl->
cnr - 1]);
104 kfree(card->hyctrlinfo);
107 card->hyctrlinfo =
NULL;
119 hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->
driverdata);
122 spin_lock_irq(&cinfo->lock);
123 #ifdef HYCAPI_PRINTFNAMES
126 cinfo->skbs[cinfo->in_idx++] =
skb;
127 if (cinfo->in_idx >= HYSDN_MAX_CAPI_SKB)
130 if (cinfo->sk_count >= HYSDN_MAX_CAPI_SKB) {
137 spin_unlock_irq(&cinfo->lock);
154 char ExtFeatureDefaults[] =
"49 /0/0/0/0,*/1,*/2,*/3,*/4,*/5,*/6,*/7,*/8,*/9,*";
155 hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->
driverdata);
159 __u8 _command = 0xa0, _subcommand = 0x80;
160 __u16 MessageNumber = 0x0000;
161 __u16 MessageBufferSize = 0;
162 int slen =
strlen(ExtFeatureDefaults);
163 #ifdef HYCAPI_PRINTFNAMES
170 printk(
KERN_ERR "HYSDN card%d: memory squeeze in hycapi_register_appl\n",
184 hycapi_applications[appl - 1].
ctrl_mask |= (1 << (ctrl->
cnr - 1));
185 hycapi_send_message(ctrl, skb);
196 static void hycapi_restart_internal(
struct capi_ctr *ctrl)
200 #ifdef HYCAPI_PRINTFNAMES
204 if (_hycapi_appCheck(i + 1, ctrl->
cnr) == 1) {
205 hycapi_register_internal(ctrl, i + 1,
206 &hycapi_applications[i].rp);
207 if (hycapi_applications[i].listen_req[ctrl->
cnr - 1]) {
209 hycapi_sendmsg_internal(ctrl, skb);
226 int MaxLogicalConnections = 0, MaxBDataBlocks = 0, MaxBDataLen = 0;
227 hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->
driverdata);
229 int chk = _hycapi_appCheck(appl, ctrl->
cnr);
243 if (MaxLogicalConnections < 0) {
244 MaxLogicalConnections = card->
bchans * -MaxLogicalConnections;
246 if (MaxLogicalConnections == 0) {
247 MaxLogicalConnections = card->
bchans;
251 memcpy(&hycapi_applications[appl - 1].rp,
262 static void hycapi_release_internal(
struct capi_ctr *ctrl,
__u16 appl)
264 hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->
driverdata);
268 __u8 _command = 0xa1, _subcommand = 0x80;
269 __u16 MessageNumber = 0x0000;
273 #ifdef HYCAPI_PRINTFNAMES
278 printk(
KERN_ERR "HYSDN card%d: memory squeeze in hycapi_register_appl\n",
287 hycapi_send_message(ctrl, skb);
288 hycapi_applications[appl - 1].
ctrl_mask &= ~(1 << (ctrl->
cnr - 1));
303 chk = _hycapi_appCheck(appl, ctrl->
cnr);
305 printk(
KERN_ERR "HYCAPI: Releasing invalid appl %d on controller %d\n", appl, ctrl->
cnr);
308 if (hycapi_applications[appl - 1].listen_req[ctrl->
cnr - 1]) {
309 kfree_skb(hycapi_applications[appl - 1].listen_req[ctrl->
cnr - 1]);
314 hycapi_release_internal(ctrl, appl);
325 hycapictrl_info *cinfo = card->hyctrlinfo;
327 #ifdef HYCAPI_PRINTFNAMES
331 ctrl = &cinfo->capi_ctrl;
332 hycapi_remove_ctr(ctrl);
345 hycapictrl_info *cinfo = card->hyctrlinfo;
347 #ifdef HYCAPI_PRINTFNAMES
351 ctrl = &cinfo->capi_ctrl;
380 switch (_hycapi_appCheck(appl_id, ctrl->
cnr))
384 hycapi_register_internal(ctrl,
386 &(hycapi_applications[appl_id - 1].rp));
404 skb_copy_from_linear_data(skb, msghead, 22);
405 skb_copy_to_linear_data_offset(skb, _len2,
416 if (hycapi_applications[appl_id - 1].listen_req[ctrl->
cnr - 1])
418 kfree_skb(hycapi_applications[appl_id - 1].listen_req[ctrl->
cnr - 1]);
431 hycapi_sendmsg_internal(ctrl, skb);
438 static int hycapi_proc_show(
struct seq_file *
m,
void *
v)
441 hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->
driverdata);
445 seq_printf(m,
"%-16s %s\n",
"name", cinfo->cardname);
450 case BD_PCCARD: s =
"HYSDN Hycard";
break;
451 case BD_ERGO: s =
"HYSDN Ergo2";
break;
452 case BD_METRO: s =
"HYSDN Metro4";
break;
453 case BD_CHAMP2: s =
"HYSDN Champ2";
break;
454 case BD_PLEXUS: s =
"HYSDN Plexus30";
break;
455 default: s =
"???";
break;
461 seq_printf(m,
"%-16s %s\n",
"ver_cardtype", s);
465 seq_printf(m,
"%-16s %s\n",
"cardname", cinfo->cardname);
477 .open = hycapi_proc_open,
493 #ifdef HYCAPI_PRINTFNAMES
500 static char *hycapi_procinfo(
struct capi_ctr *ctrl)
502 hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->
driverdata);
503 #ifdef HYCAPI_PRINTFNAMES
508 sprintf(cinfo->infobuf,
"%s %s 0x%x %d %s",
509 cinfo->cardname[0] ? cinfo->cardname :
"-",
511 cinfo->card ? cinfo->card->iobase : 0x0,
512 cinfo->card ? cinfo->card->irq : 0,
515 return cinfo->infobuf;
531 hycapictrl_info *cinfo = card->hyctrlinfo;
536 __u32 CP64[2] = {0, 0};
537 #ifdef HYCAPI_PRINTFNAMES
543 ctrl = &cinfo->capi_ctrl;
545 printk(
KERN_ERR "HYSDN Card%d: invalid CAPI-message, length %d!\n",
554 len2 = len + (30 - MsgLen);
587 "protocol. NCPI ignored.\n", card->
myid);
591 " current state\n", card->
myid);
635 hycapictrl_info *cinfo = card->hyctrlinfo;
636 #ifdef HYCAPI_PRINTFNAMES
642 spin_lock_irq(&cinfo->lock);
644 cinfo->skbs[cinfo->out_idx++] =
NULL;
645 if (cinfo->out_idx >= HYSDN_MAX_CAPI_SKB)
648 if (cinfo->sk_count-- == HYSDN_MAX_CAPI_SKB)
650 spin_unlock_irq(&cinfo->lock);
663 hycapictrl_info *cinfo = card->hyctrlinfo;
667 if (!cinfo->sk_count)
670 return (cinfo->skbs[cinfo->out_idx]);
708 static void hycapi_fill_profile(
hysdn_card *card)
710 hycapictrl_info *cinfo =
NULL;
712 cinfo = card->hyctrlinfo;
714 ctrl = &cinfo->capi_ctrl;
723 GLOBAL_OPTION_B_CHANNEL_OPERATION;
725 (card->
faxchans ? B1_PROT_T30 : 0) |
726 B1_PROT_64KBIT_TRANSPARENT;
728 (card->
faxchans ? B2_PROT_T30 : 0) |
732 (card->
faxchans ? B3_PROT_T30 : 0) |
733 (card->
faxchans ? B3_PROT_T30EXT : 0) |
740 hycapictrl_info *cinfo =
NULL;
743 #ifdef HYCAPI_PRINTFNAMES
749 if (!card->hyctrlinfo) {
750 cinfo = kzalloc(
sizeof(hycapictrl_info),
GFP_ATOMIC);
755 card->hyctrlinfo = cinfo;
758 INIT_LIST_HEAD(&cinfo->ncci_head);
766 default:
strcpy(cinfo->cardname,
"HYSDN ???");
break;
769 ctrl = &cinfo->capi_ctrl;
788 hycapi_fill_profile(card);
792 ctrl = &card->hyctrlinfo->capi_ctrl;
793 hycapi_fill_profile(card);
795 hycapi_restart_internal(ctrl);