Lines Matching refs:bch
130 struct bchannel bch[2];
141 card->bch[0].debug = debug;
142 card->bch[1].debug = debug;
250 if (test_bit(FLG_ACTIVE, &fc->bch[0].Flags) &&
251 (fc->bch[0].nr & channel))
252 return &fc->bch[0];
253 else if (test_bit(FLG_ACTIVE, &fc->bch[1].Flags) &&
254 (fc->bch[1].nr & channel))
255 return &fc->bch[1];
275 write_ctrl(struct bchannel *bch, int which) {
276 struct fritzcard *fc = bch->hw;
279 hdlc = &fc->hdlc[(bch->nr - 1) & 1];
280 pr_debug("%s: hdlc %c wr%x ctrl %x\n", fc->name, '@' + bch->nr,
284 __write_ctrl_pciv2(fc, hdlc, bch->nr);
287 __write_ctrl_pci(fc, hdlc, bch->nr);
336 modehdlc(struct bchannel *bch, int protocol)
338 struct fritzcard *fc = bch->hw;
342 hdlc = &fc->hdlc[(bch->nr - 1) & 1];
344 '@' + bch->nr, bch->state, protocol, bch->nr);
350 bch->state = -1;
353 if (bch->state == ISDN_P_NONE)
357 write_ctrl(bch, 5);
358 bch->state = ISDN_P_NONE;
359 test_and_clear_bit(FLG_HDLC, &bch->Flags);
360 test_and_clear_bit(FLG_TRANSPARENT, &bch->Flags);
363 bch->state = protocol;
366 write_ctrl(bch, 5);
368 write_ctrl(bch, 1);
370 test_and_set_bit(FLG_TRANSPARENT, &bch->Flags);
373 bch->state = protocol;
376 write_ctrl(bch, 5);
378 write_ctrl(bch, 1);
380 test_and_set_bit(FLG_HDLC, &bch->Flags);
390 hdlc_empty_fifo(struct bchannel *bch, int count)
396 struct fritzcard *fc = bch->hw;
399 if (test_bit(FLG_RX_OFF, &bch->Flags)) {
401 bch->dropcnt += count;
403 cnt = bchannel_get_rxbuf(bch, count);
406 fc->name, bch->nr, count);
409 p = skb_put(bch->rx_skb, count);
413 addr = fc->addr + (bch->nr == 2 ?
417 outl(bch->nr == 2 ? AVM_HDLC_2 : AVM_HDLC_1, fc->addr);
430 bch->nr, fc->name, count);
436 hdlc_fill_fifo(struct bchannel *bch)
438 struct fritzcard *fc = bch->hw;
445 idx = (bch->nr - 1) & 1;
449 if (!bch->tx_skb) {
450 if (!test_bit(FLG_TX_EMPTY, &bch->Flags))
453 p = bch->fill;
456 count = bch->tx_skb->len - bch->tx_idx;
459 p = bch->tx_skb->data + bch->tx_idx;
465 if (test_bit(FLG_HDLC, &bch->Flags))
470 pr_debug("%s.B%d: %d/%d/%d", fc->name, bch->nr, count,
471 bch->tx_idx, bch->tx_skb->len);
472 bch->tx_idx += count;
474 pr_debug("%s.B%d: fillempty %d\n", fc->name, bch->nr, count);
478 __write_ctrl_pciv2(fc, hdlc, bch->nr);
479 addr = fc->addr + (bch->nr == 2 ?
482 __write_ctrl_pci(fc, hdlc, bch->nr);
501 bch->nr, fc->name, count);
507 HDLC_irq_xpr(struct bchannel *bch)
509 if (bch->tx_skb && bch->tx_idx < bch->tx_skb->len) {
510 hdlc_fill_fifo(bch);
512 dev_kfree_skb(bch->tx_skb);
513 if (get_next_bframe(bch)) {
514 hdlc_fill_fifo(bch);
515 test_and_clear_bit(FLG_TX_EMPTY, &bch->Flags);
516 } else if (test_bit(FLG_TX_EMPTY, &bch->Flags)) {
517 hdlc_fill_fifo(bch);
523 HDLC_irq(struct bchannel *bch, u32 stat)
525 struct fritzcard *fc = bch->hw;
530 hdlc = &fc->hdlc[(bch->nr - 1) & 1];
531 pr_debug("%s: ch%d stat %#x\n", fc->name, bch->nr, stat);
542 fc->name, bch->nr, stat);
545 write_ctrl(bch, 1);
547 write_ctrl(bch, 1);
548 if (bch->rx_skb)
549 skb_trim(bch->rx_skb, 0);
554 hdlc_empty_fifo(bch, len);
555 if (!bch->rx_skb)
557 if (test_bit(FLG_TRANSPARENT, &bch->Flags)) {
558 recv_Bchannel(bch, 0, false);
562 recv_Bchannel(bch, 0, false);
566 skb_trim(bch->rx_skb, 0);
577 pr_warn("%s: ch%d stat %x XDU %s\n", fc->name, bch->nr,
578 stat, bch->tx_skb ? "tx_skb" : "no tx_skb");
579 if (bch->tx_skb && bch->tx_skb->len) {
580 if (!test_bit(FLG_TRANSPARENT, &bch->Flags))
581 bch->tx_idx = 0;
582 } else if (test_bit(FLG_FILLEMPTY, &bch->Flags)) {
583 test_and_set_bit(FLG_TX_EMPTY, &bch->Flags);
587 write_ctrl(bch, 1);
589 HDLC_irq_xpr(bch);
592 HDLC_irq_xpr(bch);
599 struct bchannel *bch;
603 bch = Sel_BCS(fc, 1);
604 if (bch)
605 HDLC_irq(bch, stat);
611 bch = Sel_BCS(fc, 2);
612 if (bch)
613 HDLC_irq(bch, stat);
682 struct bchannel *bch = container_of(ch, struct bchannel, ch);
683 struct fritzcard *fc = bch->hw;
691 ret = bchannel_senddata(bch, skb);
693 hdlc_fill_fifo(bch);
700 if (!test_and_set_bit(FLG_ACTIVE, &bch->Flags))
701 ret = modehdlc(bch, ch->protocol);
711 mISDN_clear_bchannel(bch);
712 modehdlc(bch, ISDN_P_NONE);
727 modehdlc(&fc->bch[0], -1);
728 modehdlc(&fc->bch[1], -1);
830 channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq)
832 return mISDN_ctrl_bchannel(bch, cq);
838 struct bchannel *bch = container_of(ch, struct bchannel, ch);
839 struct fritzcard *fc = bch->hw;
846 test_and_clear_bit(FLG_OPEN, &bch->Flags);
847 cancel_work_sync(&bch->workq);
849 mISDN_clear_bchannel(bch);
850 modehdlc(bch, ISDN_P_NONE);
858 ret = channel_bctrl(bch, arg);
897 struct bchannel *bch;
903 bch = &fc->bch[rq->adr.channel - 1];
904 if (test_and_set_bit(FLG_OPEN, &bch->Flags))
906 bch->ch.protocol = rq->protocol;
907 rq->ch = &bch->ch;
1006 modehdlc(&card->bch[0], ISDN_P_NONE);
1007 modehdlc(&card->bch[1], ISDN_P_NONE);
1011 mISDN_freebchannel(&card->bch[1]);
1012 mISDN_freebchannel(&card->bch[0]);
1046 card->bch[i].nr = i + 1;
1052 mISDN_initbchannel(&card->bch[i], MAX_DATA_MEM, minsize);
1053 card->bch[i].hw = card;
1054 card->bch[i].ch.send = avm_l2l1B;
1055 card->bch[i].ch.ctrl = avm_bctrl;
1056 card->bch[i].ch.nr = i + 1;
1057 list_add(&card->bch[i].ch.list, &card->isac.dch.dev.bchannels);
1077 mISDN_freebchannel(&card->bch[1]);
1078 mISDN_freebchannel(&card->bch[0]);