Lines Matching refs:bcs

45 static void bch_empty_fifo(struct BCState *bcs, int count);
46 static void bch_fill_fifo(struct BCState *bcs);
48 static void bch_mode(struct BCState *bcs, int mode, int bc);
49 static void bch_close_state(struct BCState *bcs);
50 static int bch_open_state(struct IsdnCardState *cs, struct BCState *bcs);
51 static int bch_setstack(struct PStack *st, struct BCState *bcs);
448 struct BCState *bcs = st->l1.bcs; in bch_l2l1() local
454 spin_lock_irqsave(&bcs->cs->lock, flags); in bch_l2l1()
455 if (bcs->tx_skb) { in bch_l2l1()
456 skb_queue_tail(&bcs->squeue, skb); in bch_l2l1()
458 bcs->tx_skb = skb; in bch_l2l1()
459 set_bit(BC_FLG_BUSY, &bcs->Flag); in bch_l2l1()
460 bcs->hw.hscx.count = 0; in bch_l2l1()
461 bch_fill_fifo(bcs); in bch_l2l1()
463 spin_unlock_irqrestore(&bcs->cs->lock, flags); in bch_l2l1()
466 spin_lock_irqsave(&bcs->cs->lock, flags); in bch_l2l1()
467 if (bcs->tx_skb) { in bch_l2l1()
470 set_bit(BC_FLG_BUSY, &bcs->Flag); in bch_l2l1()
471 bcs->tx_skb = skb; in bch_l2l1()
472 bcs->hw.hscx.count = 0; in bch_l2l1()
473 bch_fill_fifo(bcs); in bch_l2l1()
475 spin_unlock_irqrestore(&bcs->cs->lock, flags); in bch_l2l1()
478 if (!bcs->tx_skb) { in bch_l2l1()
485 spin_lock_irqsave(&bcs->cs->lock, flags); in bch_l2l1()
486 set_bit(BC_FLG_ACTIV, &bcs->Flag); in bch_l2l1()
487 bch_mode(bcs, st->l1.mode, st->l1.bc); in bch_l2l1()
488 spin_unlock_irqrestore(&bcs->cs->lock, flags); in bch_l2l1()
495 spin_lock_irqsave(&bcs->cs->lock, flags); in bch_l2l1()
496 clear_bit(BC_FLG_ACTIV, &bcs->Flag); in bch_l2l1()
497 clear_bit(BC_FLG_BUSY, &bcs->Flag); in bch_l2l1()
498 bch_mode(bcs, 0, st->l1.bc); in bch_l2l1()
499 spin_unlock_irqrestore(&bcs->cs->lock, flags); in bch_l2l1()
509 bch_empty_fifo(struct BCState *bcs, int count) in bch_empty_fifo() argument
515 cs = bcs->cs; in bch_empty_fifo()
516 hscx = bcs->hw.hscx.hscx; in bch_empty_fifo()
521 if (bcs->hw.hscx.rcvidx + count > HSCX_BUFMAX) { in bch_empty_fifo()
525 bcs->hw.hscx.rcvidx = 0; in bch_empty_fifo()
529 ptr = bcs->hw.hscx.rcvbuf + bcs->hw.hscx.rcvidx; in bch_empty_fifo()
534 ptr = bcs->hw.hscx.rcvbuf + bcs->hw.hscx.rcvidx; in bch_empty_fifo()
535 bcs->hw.hscx.rcvidx += count; in bch_empty_fifo()
538 char *t = bcs->blog; in bch_empty_fifo()
542 debugl1(cs, "%s", bcs->blog); in bch_empty_fifo()
550 bch_fill_fifo(struct BCState *bcs) in bch_fill_fifo() argument
556 cs = bcs->cs; in bch_fill_fifo()
560 if (!bcs->tx_skb) return; in bch_fill_fifo()
561 if (bcs->tx_skb->len <= 0) return; in bch_fill_fifo()
563 hscx = bcs->hw.hscx.hscx; in bch_fill_fifo()
564 more = (bcs->mode == L1_MODE_TRANS) ? 1 : 0; in bch_fill_fifo()
565 if (bcs->tx_skb->len > B_FIFO_SIZE) { in bch_fill_fifo()
569 count = bcs->tx_skb->len; in bch_fill_fifo()
573 p = ptr = bcs->tx_skb->data; in bch_fill_fifo()
574 skb_pull(bcs->tx_skb, count); in bch_fill_fifo()
575 bcs->tx_cnt -= count; in bch_fill_fifo()
576 bcs->hw.hscx.count += count; in bch_fill_fifo()
581 char *t = bcs->blog; in bch_fill_fifo()
585 debugl1(cs, "%s", bcs->blog); in bch_fill_fifo()
596 struct BCState *bcs; in bch_int() local
601 bcs = cs->bcs + hscx; in bch_int()
606 if (!test_bit(BC_FLG_INIT, &bcs->Flag)) return; in bch_int()
614 if ((rstab & 0x40) && (bcs->mode != L1_MODE_NULL)) in bch_int()
616 debugl1(cs, "bch_int() B-%d: RDO mode=%d", hscx, bcs->mode); in bch_int()
625 bch_empty_fifo(bcs, count); in bch_int()
626 if ((count = bcs->hw.hscx.rcvidx - 1) > 0) { in bch_int()
632 memcpy(skb_put(skb, count), bcs->hw.hscx.rcvbuf, count); in bch_int()
633 skb_queue_tail(&bcs->rqueue, skb); in bch_int()
637 bcs->hw.hscx.rcvidx = 0; in bch_int()
638 schedule_event(bcs, B_RCVBUFREADY); in bch_int()
642 bch_empty_fifo(bcs, B_FIFO_SIZE); in bch_int()
644 if (bcs->mode == L1_MODE_TRANS) { // queue every chunk in bch_int()
649 memcpy(skb_put(skb, B_FIFO_SIZE), bcs->hw.hscx.rcvbuf, B_FIFO_SIZE); in bch_int()
650 skb_queue_tail(&bcs->rqueue, skb); in bch_int()
652 bcs->hw.hscx.rcvidx = 0; in bch_int()
653 schedule_event(bcs, B_RCVBUFREADY); in bch_int()
664 if (bcs->tx_skb) { in bch_int()
665 if (bcs->tx_skb->len) { in bch_int()
666 bch_fill_fifo(bcs); in bch_int()
669 if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) && in bch_int()
670 (PACKET_NOACK != bcs->tx_skb->pkt_type)) { in bch_int()
672 spin_lock_irqsave(&bcs->aclock, flags); in bch_int()
673 bcs->ackcnt += bcs->hw.hscx.count; in bch_int()
674 spin_unlock_irqrestore(&bcs->aclock, flags); in bch_int()
675 schedule_event(bcs, B_ACKPENDING); in bch_int()
678 dev_kfree_skb_irq(bcs->tx_skb); in bch_int()
679 bcs->hw.hscx.count = 0; in bch_int()
680 bcs->tx_skb = NULL; in bch_int()
682 if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) { in bch_int()
683 bcs->hw.hscx.count = 0; in bch_int()
684 set_bit(BC_FLG_BUSY, &bcs->Flag); in bch_int()
685 bch_fill_fifo(bcs); in bch_int()
687 clear_bit(BC_FLG_BUSY, &bcs->Flag); in bch_int()
688 schedule_event(bcs, B_XMTBUFREADY); in bch_int()
694 if (bcs->mode == L1_MODE_TRANS) { in bch_int()
695 bch_fill_fifo(bcs); in bch_int()
698 if (bcs->tx_skb) { // restart transmitting the whole frame in bch_int()
699 skb_push(bcs->tx_skb, bcs->hw.hscx.count); in bch_int()
700 bcs->tx_cnt += bcs->hw.hscx.count; in bch_int()
701 bcs->hw.hscx.count = 0; in bch_int()
713 bch_mode(struct BCState *bcs, int mode, int bc) in bch_mode() argument
715 struct IsdnCardState *cs = bcs->cs; in bch_mode()
716 int hscx = bcs->hw.hscx.hscx; in bch_mode()
721 bcs->mode = mode; in bch_mode()
722 bcs->channel = bc; in bch_mode()
761 bch_close_state(struct BCState *bcs) in bch_close_state() argument
763 bch_mode(bcs, 0, bcs->channel); in bch_close_state()
764 if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) { in bch_close_state()
765 kfree(bcs->hw.hscx.rcvbuf); in bch_close_state()
766 bcs->hw.hscx.rcvbuf = NULL; in bch_close_state()
767 kfree(bcs->blog); in bch_close_state()
768 bcs->blog = NULL; in bch_close_state()
769 skb_queue_purge(&bcs->rqueue); in bch_close_state()
770 skb_queue_purge(&bcs->squeue); in bch_close_state()
771 if (bcs->tx_skb) { in bch_close_state()
772 dev_kfree_skb_any(bcs->tx_skb); in bch_close_state()
773 bcs->tx_skb = NULL; in bch_close_state()
774 clear_bit(BC_FLG_BUSY, &bcs->Flag); in bch_close_state()
782 bch_open_state(struct IsdnCardState *cs, struct BCState *bcs) in bch_open_state() argument
784 if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) { in bch_open_state()
785 if (!(bcs->hw.hscx.rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) { in bch_open_state()
788 clear_bit(BC_FLG_INIT, &bcs->Flag); in bch_open_state()
791 if (!(bcs->blog = kmalloc(MAX_BLOG_SPACE, GFP_ATOMIC))) { in bch_open_state()
794 clear_bit(BC_FLG_INIT, &bcs->Flag); in bch_open_state()
795 kfree(bcs->hw.hscx.rcvbuf); in bch_open_state()
796 bcs->hw.hscx.rcvbuf = NULL; in bch_open_state()
799 skb_queue_head_init(&bcs->rqueue); in bch_open_state()
800 skb_queue_head_init(&bcs->squeue); in bch_open_state()
802 bcs->tx_skb = NULL; in bch_open_state()
803 clear_bit(BC_FLG_BUSY, &bcs->Flag); in bch_open_state()
804 bcs->event = 0; in bch_open_state()
805 bcs->hw.hscx.rcvidx = 0; in bch_open_state()
806 bcs->tx_cnt = 0; in bch_open_state()
813 bch_setstack(struct PStack *st, struct BCState *bcs) in bch_setstack() argument
815 bcs->channel = st->l1.bc; in bch_setstack()
816 if (bch_open_state(st->l1.hardware, bcs)) return (-1); in bch_setstack()
817 st->l1.bcs = bcs; in bch_setstack()
820 bcs->st = st; in bch_setstack()
830 cs->bcs[hscx].BC_SetStack = bch_setstack; in bch_init()
831 cs->bcs[hscx].BC_Close = bch_close_state; in bch_init()
832 cs->bcs[hscx].hw.hscx.hscx = hscx; in bch_init()
833 cs->bcs[hscx].cs = cs; in bch_init()
834 bch_mode(cs->bcs + hscx, 0, hscx); in bch_init()