Lines Matching +full:controller +full:- +full:data

40 /* ------------------------------------------------------------- */
45 u32 controller; member
48 /* ------------------------------------------------------------- */
63 /* -------- controller ref counting -------------------------------------- */
68 if (!try_module_get(ctr->owner)) in capi_ctr_get()
76 module_put(ctr->owner); in capi_ctr_put()
79 /* ------------------------------------------------------------- */
83 if (contr < 1 || contr - 1 >= CAPI_MAXCONTR) in get_capi_ctr_by_nr()
86 return capi_controller[contr - 1]; in get_capi_ctr_by_nr()
93 if (applid < 1 || applid - 1 >= CAPI_MAXAPPL) in __get_capi_appl_by_nr()
96 return capi_applications[applid - 1]; in __get_capi_appl_by_nr()
101 if (applid < 1 || applid - 1 >= CAPI_MAXAPPL) in get_capi_appl_by_nr()
104 return rcu_dereference(capi_applications[applid - 1]); in get_capi_appl_by_nr()
107 /* -------- util functions ------------------------------------ */
144 /* ------------------------------------------------------------ */
152 ctr->register_appl(ctr, applid, rparam); in register_appl()
154 printk(KERN_WARNING "%s: cannot get controller resources\n", in register_appl()
163 ctr->release_appl(ctr, applid); in release_appl()
180 if (ctr->state == CAPI_CTR_RUNNING) in notify_up()
183 ctr->state = CAPI_CTR_RUNNING; in notify_up()
188 register_appl(ctr, applid, &ap->rparam); in notify_up()
202 if (ctr->state == CAPI_CTR_DETECTED || ctr->state == CAPI_CTR_DETACHED) in ctr_down()
205 ctr->state = new_state; in ctr_down()
207 memset(ctr->manu, 0, sizeof(ctr->manu)); in ctr_down()
208 memset(&ctr->version, 0, sizeof(ctr->version)); in ctr_down()
209 memset(&ctr->profile, 0, sizeof(ctr->profile)); in ctr_down()
210 memset(ctr->serial, 0, sizeof(ctr->serial)); in ctr_down()
242 switch (event->type) { in do_notify_work()
244 notify_up(event->controller); in do_notify_work()
247 notify_down(event->controller); in do_notify_work()
254 static int notify_push(unsigned int event_type, u32 controller) in notify_push() argument
259 return -ENOMEM; in notify_push()
261 INIT_WORK(&event->work, do_notify_work); in notify_push()
262 event->type = event_type; in notify_push()
263 event->controller = controller; in notify_push()
265 queue_work(kcapi_wq, &event->work); in notify_push()
269 /* -------- Receiver ------------------------------------------ */
277 if ((!ap) || (ap->release_in_progress)) in recv_handler()
280 mutex_lock(&ap->recv_mtx); in recv_handler()
281 while ((skb = skb_dequeue(&ap->recv_queue))) { in recv_handler()
282 if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_IND) in recv_handler()
283 ap->nrecvdatapkt++; in recv_handler()
285 ap->nrecvctlpkt++; in recv_handler()
287 ap->recv_message(ap, skb); in recv_handler()
289 mutex_unlock(&ap->recv_mtx); in recv_handler()
293 * capi_ctr_handle_message() - handle incoming CAPI message
294 * @ctr: controller descriptor structure.
309 if (ctr->state != CAPI_CTR_RUNNING) { in capi_ctr_handle_message()
310 cdb = capi_message2str(skb->data); in capi_ctr_handle_message()
312 printk(KERN_INFO "kcapi: controller [%03d] not active, got: %s", in capi_ctr_handle_message()
313 ctr->cnr, cdb->buf); in capi_ctr_handle_message()
316 printk(KERN_INFO "kcapi: controller [%03d] not active, cannot trace\n", in capi_ctr_handle_message()
317 ctr->cnr); in capi_ctr_handle_message()
321 cmd = CAPIMSG_COMMAND(skb->data); in capi_ctr_handle_message()
322 subcmd = CAPIMSG_SUBCOMMAND(skb->data); in capi_ctr_handle_message()
324 ctr->nrecvdatapkt++; in capi_ctr_handle_message()
325 if (ctr->traceflag > 2) in capi_ctr_handle_message()
328 ctr->nrecvctlpkt++; in capi_ctr_handle_message()
329 if (ctr->traceflag) in capi_ctr_handle_message()
332 showctl |= (ctr->traceflag & 1); in capi_ctr_handle_message()
336 ctr->cnr, CAPIMSG_APPID(skb->data), in capi_ctr_handle_message()
338 CAPIMSG_LEN(skb->data)); in capi_ctr_handle_message()
340 cdb = capi_message2str(skb->data); in capi_ctr_handle_message()
343 ctr->cnr, cdb->buf); in capi_ctr_handle_message()
347 ctr->cnr, CAPIMSG_APPID(skb->data), in capi_ctr_handle_message()
349 CAPIMSG_LEN(skb->data)); in capi_ctr_handle_message()
355 ap = get_capi_appl_by_nr(CAPIMSG_APPID(skb->data)); in capi_ctr_handle_message()
358 cdb = capi_message2str(skb->data); in capi_ctr_handle_message()
361 CAPIMSG_APPID(skb->data), cdb->buf); in capi_ctr_handle_message()
365 CAPIMSG_APPID(skb->data), in capi_ctr_handle_message()
369 skb_queue_tail(&ap->recv_queue, skb); in capi_ctr_handle_message()
370 queue_work(kcapi_wq, &ap->recv_work); in capi_ctr_handle_message()
382 * capi_ctr_ready() - signal CAPI controller ready
383 * @ctr: controller descriptor structure.
385 * Called by hardware driver to signal that the controller is up and running.
390 printk(KERN_NOTICE "kcapi: controller [%03d] \"%s\" ready.\n", in capi_ctr_ready()
391 ctr->cnr, ctr->name); in capi_ctr_ready()
393 notify_push(CAPICTR_UP, ctr->cnr); in capi_ctr_ready()
399 * capi_ctr_down() - signal CAPI controller not ready
400 * @ctr: controller descriptor structure.
402 * Called by hardware driver to signal that the controller is down and
408 printk(KERN_NOTICE "kcapi: controller [%03d] down.\n", ctr->cnr); in capi_ctr_down()
410 notify_push(CAPICTR_DOWN, ctr->cnr); in capi_ctr_down()
415 /* ------------------------------------------------------------- */
418 * attach_capi_ctr() - register CAPI controller
419 * @ctr: controller descriptor structure.
421 * Called by hardware driver to register a controller with the CAPI subsystem.
437 printk(KERN_ERR "kcapi: out of controller slots\n"); in attach_capi_ctr()
438 return -EBUSY; in attach_capi_ctr()
442 ctr->nrecvctlpkt = 0; in attach_capi_ctr()
443 ctr->nrecvdatapkt = 0; in attach_capi_ctr()
444 ctr->nsentctlpkt = 0; in attach_capi_ctr()
445 ctr->nsentdatapkt = 0; in attach_capi_ctr()
446 ctr->cnr = i + 1; in attach_capi_ctr()
447 ctr->state = CAPI_CTR_DETECTED; in attach_capi_ctr()
448 ctr->blocked = 0; in attach_capi_ctr()
449 ctr->traceflag = showcapimsgs; in attach_capi_ctr()
451 sprintf(ctr->procfn, "capi/controllers/%d", ctr->cnr); in attach_capi_ctr()
452 ctr->procent = proc_create_single_data(ctr->procfn, 0, NULL, in attach_capi_ctr()
453 ctr->proc_show, ctr); in attach_capi_ctr()
459 printk(KERN_NOTICE "kcapi: controller [%03d]: %s attached\n", in attach_capi_ctr()
460 ctr->cnr, ctr->name); in attach_capi_ctr()
467 * detach_capi_ctr() - unregister CAPI controller
468 * @ctr: controller descriptor structure.
470 * Called by hardware driver to remove the registration of a controller
483 if (ctr->cnr < 1 || ctr->cnr - 1 >= CAPI_MAXCONTR) { in detach_capi_ctr()
484 err = -EINVAL; in detach_capi_ctr()
488 if (capi_controller[ctr->cnr - 1] != ctr) { in detach_capi_ctr()
489 err = -EINVAL; in detach_capi_ctr()
492 capi_controller[ctr->cnr - 1] = NULL; in detach_capi_ctr()
493 ncontrollers--; in detach_capi_ctr()
495 if (ctr->procent) in detach_capi_ctr()
496 remove_proc_entry(ctr->procfn, NULL); in detach_capi_ctr()
498 printk(KERN_NOTICE "kcapi: controller [%03d]: %s unregistered\n", in detach_capi_ctr()
499 ctr->cnr, ctr->name); in detach_capi_ctr()
509 /* ------------------------------------------------------------- */
510 /* -------- CAPI2.0 Interface ---------------------------------- */
511 /* ------------------------------------------------------------- */
514 * capi20_isinstalled() - CAPI 2.0 operation CAPI_INSTALLED
516 * Return value: CAPI result code (CAPI_NOERROR if at least one ISDN controller
529 capi_controller[i]->state == CAPI_CTR_RUNNING) { in capi20_isinstalled()
540 * capi20_register() - CAPI 2.0 operation CAPI_REGISTER
544 * A unique application ID is assigned and stored in @ap->applid.
546 * callback function @ap->recv_message() may be called at any time
558 if (ap->rparam.datablklen < 128) in capi20_register()
561 ap->nrecvctlpkt = 0; in capi20_register()
562 ap->nrecvdatapkt = 0; in capi20_register()
563 ap->nsentctlpkt = 0; in capi20_register()
564 ap->nsentdatapkt = 0; in capi20_register()
565 mutex_init(&ap->recv_mtx); in capi20_register()
566 skb_queue_head_init(&ap->recv_queue); in capi20_register()
567 INIT_WORK(&ap->recv_work, recv_handler); in capi20_register()
568 ap->release_in_progress = 0; in capi20_register()
573 if (capi_applications[applid - 1] == NULL) in capi20_register()
581 ap->applid = applid; in capi20_register()
582 capi_applications[applid - 1] = ap; in capi20_register()
586 capi_controller[i]->state != CAPI_CTR_RUNNING) in capi20_register()
588 register_appl(capi_controller[i], applid, &ap->rparam); in capi20_register()
601 * capi20_release() - CAPI 2.0 operation CAPI_RELEASE
606 * callback function @ap->recv_message() will no longer be called.
614 DBG("applid %#x", ap->applid); in capi20_release()
618 ap->release_in_progress = 1; in capi20_release()
619 capi_applications[ap->applid - 1] = NULL; in capi20_release()
625 capi_controller[i]->state != CAPI_CTR_RUNNING) in capi20_release()
627 release_appl(capi_controller[i], ap->applid); in capi20_release()
633 skb_queue_purge(&ap->recv_queue); in capi20_release()
636 printk(KERN_DEBUG "kcapi: appl %d down\n", ap->applid); in capi20_release()
643 * capi20_put_message() - CAPI 2.0 operation CAPI_PUT_MESSAGE
657 DBG("applid %#x", ap->applid); in capi20_put_message()
661 if ((ap->applid == 0) || ap->release_in_progress) in capi20_put_message()
663 if (skb->len < 12 in capi20_put_message()
664 || !capi_cmd_valid(CAPIMSG_COMMAND(skb->data)) in capi20_put_message()
665 || !capi_subcmd_valid(CAPIMSG_SUBCOMMAND(skb->data))) in capi20_put_message()
669 * The controller reference is protected by the existence of the in capi20_put_message()
673 ctr = get_capi_ctr_by_nr(CAPIMSG_CONTROLLER(skb->data)); in capi20_put_message()
674 if (!ctr || ctr->state != CAPI_CTR_RUNNING) in capi20_put_message()
676 if (ctr->blocked) in capi20_put_message()
679 cmd = CAPIMSG_COMMAND(skb->data); in capi20_put_message()
680 subcmd = CAPIMSG_SUBCOMMAND(skb->data); in capi20_put_message()
683 ctr->nsentdatapkt++; in capi20_put_message()
684 ap->nsentdatapkt++; in capi20_put_message()
685 if (ctr->traceflag > 2) in capi20_put_message()
688 ctr->nsentctlpkt++; in capi20_put_message()
689 ap->nsentctlpkt++; in capi20_put_message()
690 if (ctr->traceflag) in capi20_put_message()
693 showctl |= (ctr->traceflag & 1); in capi20_put_message()
697 CAPIMSG_CONTROLLER(skb->data), in capi20_put_message()
698 CAPIMSG_APPID(skb->data), in capi20_put_message()
700 CAPIMSG_LEN(skb->data)); in capi20_put_message()
702 _cdebbuf *cdb = capi_message2str(skb->data); in capi20_put_message()
705 CAPIMSG_CONTROLLER(skb->data), in capi20_put_message()
706 cdb->buf); in capi20_put_message()
710 CAPIMSG_CONTROLLER(skb->data), in capi20_put_message()
711 CAPIMSG_APPID(skb->data), in capi20_put_message()
713 CAPIMSG_LEN(skb->data)); in capi20_put_message()
716 return ctr->send_message(ctr, skb); in capi20_put_message()
720 * capi20_get_manufacturer() - CAPI 2.0 operation CAPI_GET_MANUFACTURER
721 * @contr: controller number.
724 * Retrieve information about the manufacturer of the specified ISDN controller
742 if (ctr && ctr->state == CAPI_CTR_RUNNING) { in capi20_get_manufacturer()
743 strscpy_pad(buf, ctr->manu, CAPI_MANUFACTURER_LEN); in capi20_get_manufacturer()
753 * capi20_get_version() - CAPI 2.0 operation CAPI_GET_VERSION
754 * @contr: controller number.
757 * Retrieve version information for the specified ISDN controller
775 if (ctr && ctr->state == CAPI_CTR_RUNNING) { in capi20_get_version()
776 memcpy(verp, &ctr->version, sizeof(capi_version)); in capi20_get_version()
786 * capi20_get_serial() - CAPI 2.0 operation CAPI_GET_SERIAL_NUMBER
787 * @contr: controller number.
790 * Retrieve the serial number of the specified ISDN controller
808 if (ctr && ctr->state == CAPI_CTR_RUNNING) { in capi20_get_serial()
809 strscpy(serial, ctr->serial, CAPI_SERIAL_LEN); in capi20_get_serial()
819 * capi20_get_profile() - CAPI 2.0 operation CAPI_GET_PROFILE
820 * @contr: controller number.
823 * Retrieve capability information for the specified ISDN controller
834 profp->ncontroller = ncontrollers; in capi20_get_profile()
841 if (ctr && ctr->state == CAPI_CTR_RUNNING) { in capi20_get_profile()
842 memcpy(profp, &ctr->profile, sizeof(struct capi_profile)); in capi20_get_profile()
852 * capi20_manufacturer() - CAPI 2.0 operation CAPI_MANUFACTURER
854 * @data: parameter.
860 int capi20_manufacturer(unsigned long cmd, void __user *data) in capi20_manufacturer() argument
870 if (copy_from_user(&fdef, data, sizeof(kcapi_flagdef))) in capi20_manufacturer()
871 return -EFAULT; in capi20_manufacturer()
877 ctr->traceflag = fdef.flag; in capi20_manufacturer()
879 ctr->cnr, ctr->traceflag); in capi20_manufacturer()
882 retval = -ESRCH; in capi20_manufacturer()
895 return -EINVAL; in capi20_manufacturer()
898 /* ------------------------------------------------------------- */
899 /* -------- Init & Cleanup ------------------------------------- */
900 /* ------------------------------------------------------------- */
912 return -ENOMEM; in kcapi_init()