Lines Matching refs:bc
90 struct tiger_ch bc[2];
108 card->bc[0].bch.debug = debug;
109 card->bc[1].bch.debug = debug;
187 fill_mem(struct tiger_ch *bc, u32 idx, u32 cnt, u32 fill)
189 struct tiger_hw *card = bc->bch.hw;
193 bc->bch.nr, fill, cnt, idx, card->send.idx);
194 if (bc->bch.nr & 2) {
210 mode_tiger(struct tiger_ch *bc, u32 protocol)
212 struct tiger_hw *card = bc->bch.hw;
215 bc->bch.nr, bc->bch.state, protocol);
218 if (bc->bch.state == ISDN_P_NONE)
220 fill_mem(bc, 0, card->send.size, 0xff);
221 bc->bch.state = protocol;
223 if ((card->bc[0].bch.state == ISDN_P_NONE) &&
224 (card->bc[1].bch.state == ISDN_P_NONE)) {
229 test_and_clear_bit(FLG_HDLC, &bc->bch.Flags);
230 test_and_clear_bit(FLG_TRANSPARENT, &bc->bch.Flags);
231 bc->txstate = 0;
232 bc->rxstate = 0;
233 bc->lastrx = -1;
236 test_and_set_bit(FLG_TRANSPARENT, &bc->bch.Flags);
237 bc->bch.state = protocol;
238 bc->idx = 0;
239 bc->free = card->send.size/2;
240 bc->rxstate = 0;
241 bc->txstate = TX_INIT | TX_IDLE;
242 bc->lastrx = -1;
250 test_and_set_bit(FLG_HDLC, &bc->bch.Flags);
251 bc->bch.state = protocol;
252 bc->idx = 0;
253 bc->free = card->send.size/2;
254 bc->rxstate = 0;
255 bc->txstate = TX_INIT | TX_IDLE;
256 isdnhdlc_rcv_init(&bc->hrecv, 0);
257 isdnhdlc_out_init(&bc->hsend, 0);
258 bc->lastrx = -1;
323 card->bc[i].hsbuf = kmalloc(NJ_DMA_TXSIZE, GFP_ATOMIC);
324 if (!card->bc[i].hsbuf) {
328 card->bc[i].hrbuf = kmalloc(NJ_DMA_RXSIZE, GFP_ATOMIC);
329 if (!card->bc[i].hrbuf) {
375 read_dma(struct tiger_ch *bc, u32 idx, int cnt)
377 struct tiger_hw *card = bc->bch.hw;
382 if (bc->lastrx == idx) {
383 bc->rxstate |= RX_OVERRUN;
385 bc->bch.nr, idx);
387 bc->lastrx = idx;
388 if (!bc->bch.rx_skb) {
389 bc->bch.rx_skb = mI_alloc_skb(bc->bch.maxlen, GFP_ATOMIC);
390 if (!bc->bch.rx_skb) {
392 card->name, bc->bch.nr);
397 if (test_bit(FLG_TRANSPARENT, &bc->bch.Flags)) {
398 if ((bc->bch.rx_skb->len + cnt) > bc->bch.maxlen) {
400 bc->bch.nr, bc->bch.rx_skb->len + cnt);
401 skb_trim(bc->bch.rx_skb, 0);
404 p = skb_put(bc->bch.rx_skb, cnt);
406 p = bc->hrbuf;
410 if (bc->bch.nr & 2)
416 pn = bc->hrbuf;
418 if (test_bit(FLG_HDLC, &bc->bch.Flags)) {
419 stat = isdnhdlc_decode(&bc->hrecv, pn, cnt, &i,
420 bc->bch.rx_skb->data, bc->bch.maxlen);
422 p = skb_put(bc->bch.rx_skb, stat);
425 card->name, bc->bch.nr);
428 card->name, bc->bch.nr);
431 card->name, bc->bch.nr, bc->bch.maxlen);
438 bc->bch.nr, card->name, stat);
442 recv_Bchannel(&bc->bch, 0);
444 if (test_bit(FLG_HDLC, &bc->bch.Flags)) {
447 if (!bc->bch.rx_skb) {
448 bc->bch.rx_skb = mI_alloc_skb(bc->bch.maxlen,
450 if (!bc->bch.rx_skb) {
452 card->name, bc->bch.nr);
476 if (test_bit(FLG_ACTIVE, &card->bc[0].bch.Flags))
477 read_dma(&card->bc[0], idx, cnt);
478 if (test_bit(FLG_ACTIVE, &card->bc[1].bch.Flags))
479 read_dma(&card->bc[1], idx, cnt);
484 resync(struct tiger_ch *bc, struct tiger_hw *card)
488 if (bc->free > card->send.size / 2)
489 bc->free = card->send.size / 2;
495 bc->idx = (card->recv.size / 2) - 1;
497 bc->idx = card->recv.size - 1;
498 bc->txstate = TX_RUN;
500 __func__, bc->bch.nr, bc->free, bc->idx, card->send.idx);
506 fill_hdlc_flag(struct tiger_ch *bc)
508 struct tiger_hw *card = bc->bch.hw;
513 if (bc->free == 0)
516 __func__, bc->bch.nr, bc->free, bc->txstate,
517 bc->idx, card->send.idx);
518 if (bc->txstate & (TX_IDLE | TX_INIT | TX_UNDERRUN))
519 resync(bc, card);
520 count = isdnhdlc_encode(&bc->hsend, NULL, 0, &i,
521 bc->hsbuf, bc->free);
523 bc->bch.nr, count);
524 bc->free -= count;
525 p = bc->hsbuf;
526 m = (bc->bch.nr & 1) ? 0xffffff00 : 0xffff00ff;
528 if (bc->idx >= card->send.size)
529 bc->idx = 0;
530 v = card->send.start[bc->idx];
532 v |= (bc->bch.nr & 1) ? (u32)(p[i]) : ((u32)(p[i])) << 8;
533 card->send.start[bc->idx++] = v;
537 bc->bch.nr, card->name, count);
543 fill_dma(struct tiger_ch *bc)
545 struct tiger_hw *card = bc->bch.hw;
550 if (bc->free == 0)
552 count = bc->bch.tx_skb->len - bc->bch.tx_idx;
556 __func__, bc->bch.nr, count, bc->free, bc->bch.tx_idx,
557 bc->bch.tx_skb->len, bc->txstate, bc->idx, card->send.idx);
558 if (bc->txstate & (TX_IDLE | TX_INIT | TX_UNDERRUN))
559 resync(bc, card);
560 p = bc->bch.tx_skb->data + bc->bch.tx_idx;
561 if (test_bit(FLG_HDLC, &bc->bch.Flags)) {
562 count = isdnhdlc_encode(&bc->hsend, p, count, &i,
563 bc->hsbuf, bc->free);
565 bc->bch.nr, i, count);
566 bc->bch.tx_idx += i;
567 bc->free -= count;
568 p = bc->hsbuf;
570 if (count > bc->free)
571 count = bc->free;
572 bc->bch.tx_idx += count;
573 bc->free -= count;
575 m = (bc->bch.nr & 1) ? 0xffffff00 : 0xffff00ff;
577 if (bc->idx >= card->send.size)
578 bc->idx = 0;
579 v = card->send.start[bc->idx];
581 v |= (bc->bch.nr & 1) ? (u32)(p[i]) : ((u32)(p[i])) << 8;
582 card->send.start[bc->idx++] = v;
586 bc->bch.nr, card->name, count);
589 if (bc->free)
590 bc_next_frame(bc);
595 bc_next_frame(struct tiger_ch *bc)
597 if (bc->bch.tx_skb && bc->bch.tx_idx < bc->bch.tx_skb->len)
598 fill_dma(bc);
600 if (bc->bch.tx_skb) {
602 if (test_bit(FLG_TRANSPARENT, &bc->bch.Flags))
603 confirm_Bsend(&bc->bch);
604 dev_kfree_skb(bc->bch.tx_skb);
606 if (get_next_bframe(&bc->bch))
607 fill_dma(bc);
615 send_tiger_bc(struct tiger_hw *card, struct tiger_ch *bc)
619 bc->free += card->send.size / 2;
620 if (bc->free >= card->send.size) {
621 if (!(bc->txstate & (TX_UNDERRUN | TX_INIT))) {
623 bc->bch.nr, bc->txstate);
624 bc->txstate |= TX_UNDERRUN;
626 bc->free = card->send.size;
628 ret = bc_next_frame(bc);
630 if (test_bit(FLG_HDLC, &bc->bch.Flags)) {
631 fill_hdlc_flag(bc);
635 bc->bch.nr, bc->free, bc->idx, card->send.idx);
636 if (!(bc->txstate & (TX_IDLE | TX_INIT))) {
637 fill_mem(bc, bc->idx, bc->free, 0xff);
638 if (bc->free == card->send.size)
639 bc->txstate |= TX_IDLE;
659 if (test_bit(FLG_ACTIVE, &card->bc[i].bch.Flags))
660 send_tiger_bc(card, &card->bc[i]);
731 struct tiger_ch *bc = container_of(bch, struct tiger_ch, bch);
743 fill_dma(bc);
754 ret = mode_tiger(bc, ch->protocol);
765 mode_tiger(bc, ISDN_P_NONE);
778 channel_bctrl(struct tiger_ch *bc, struct mISDN_ctrl_req *cq)
781 struct tiger_hw *card = bc->bch.hw;
801 struct tiger_ch *bc = container_of(bch, struct tiger_ch, bch);
815 mode_tiger(bc, ISDN_P_NONE);
824 ret = channel_bctrl(bc, arg);
866 bch = &card->bc[rq->adr.channel - 1].bch;
942 mode_tiger(&card->bc[0], ISDN_P_NONE);
943 mode_tiger(&card->bc[1], ISDN_P_NONE);
959 mode_tiger(&card->bc[0], ISDN_P_NONE);
960 mode_tiger(&card->bc[1], ISDN_P_NONE);
972 mISDN_freebchannel(&card->bc[i].bch);
973 kfree(card->bc[i].hsbuf);
974 kfree(card->bc[i].hrbuf);
1027 card->bc[i].bch.nr = i + 1;
1029 mISDN_initbchannel(&card->bc[i].bch, MAX_DATA_MEM);
1030 card->bc[i].bch.hw = card;
1031 card->bc[i].bch.ch.send = nj_l2l1B;
1032 card->bc[i].bch.ch.ctrl = nj_bctrl;
1033 card->bc[i].bch.ch.nr = i + 1;
1034 list_add(&card->bc[i].bch.ch.list,
1036 card->bc[i].bch.hw = card;