Lines Matching defs:bch

143 	struct bchannel		bch[2];
154 card->bch[0].debug = debug;
155 card->bch[1].debug = debug;
263 if (test_bit(FLG_ACTIVE, &fc->bch[0].Flags) &&
264 (fc->bch[0].nr & channel))
265 return &fc->bch[0];
266 else if (test_bit(FLG_ACTIVE, &fc->bch[1].Flags) &&
267 (fc->bch[1].nr & channel))
268 return &fc->bch[1];
288 write_ctrl(struct bchannel *bch, int which) {
289 struct fritzcard *fc = bch->hw;
292 hdlc = &fc->hdlc[(bch->nr - 1) & 1];
293 pr_debug("%s: hdlc %c wr%x ctrl %x\n", fc->name, '@' + bch->nr,
297 __write_ctrl_pciv2(fc, hdlc, bch->nr);
300 __write_ctrl_pci(fc, hdlc, bch->nr);
349 modehdlc(struct bchannel *bch, int protocol)
351 struct fritzcard *fc = bch->hw;
355 hdlc = &fc->hdlc[(bch->nr - 1) & 1];
357 '@' + bch->nr, bch->state, protocol, bch->nr);
363 bch->state = -1;
365 if (bch->state == ISDN_P_NONE)
369 write_ctrl(bch, 5);
370 bch->state = ISDN_P_NONE;
371 test_and_clear_bit(FLG_HDLC, &bch->Flags);
372 test_and_clear_bit(FLG_TRANSPARENT, &bch->Flags);
375 bch->state = protocol;
378 write_ctrl(bch, 5);
380 write_ctrl(bch, 1);
382 test_and_set_bit(FLG_TRANSPARENT, &bch->Flags);
385 bch->state = protocol;
388 write_ctrl(bch, 5);
390 write_ctrl(bch, 1);
392 test_and_set_bit(FLG_HDLC, &bch->Flags);
402 hdlc_empty_fifo(struct bchannel *bch, int count)
408 struct fritzcard *fc = bch->hw;
411 if (test_bit(FLG_RX_OFF, &bch->Flags)) {
413 bch->dropcnt += count;
415 cnt = bchannel_get_rxbuf(bch, count);
418 fc->name, bch->nr, count);
421 p = skb_put(bch->rx_skb, count);
425 addr = fc->addr + (bch->nr == 2 ?
429 outl(bch->nr == 2 ? AVM_HDLC_2 : AVM_HDLC_1, fc->addr);
442 bch->nr, fc->name, count);
448 hdlc_fill_fifo(struct bchannel *bch)
450 struct fritzcard *fc = bch->hw;
457 idx = (bch->nr - 1) & 1;
461 if (!bch->tx_skb) {
462 if (!test_bit(FLG_TX_EMPTY, &bch->Flags))
465 p = bch->fill;
468 count = bch->tx_skb->len - bch->tx_idx;
471 p = bch->tx_skb->data + bch->tx_idx;
477 if (test_bit(FLG_HDLC, &bch->Flags))
482 pr_debug("%s.B%d: %d/%d/%d", fc->name, bch->nr, count,
483 bch->tx_idx, bch->tx_skb->len);
484 bch->tx_idx += count;
486 pr_debug("%s.B%d: fillempty %d\n", fc->name, bch->nr, count);
490 __write_ctrl_pciv2(fc, hdlc, bch->nr);
491 addr = fc->addr + (bch->nr == 2 ?
494 __write_ctrl_pci(fc, hdlc, bch->nr);
513 bch->nr, fc->name, count);
519 HDLC_irq_xpr(struct bchannel *bch)
521 if (bch->tx_skb && bch->tx_idx < bch->tx_skb->len) {
522 hdlc_fill_fifo(bch);
524 if (bch->tx_skb)
525 dev_kfree_skb(bch->tx_skb);
526 if (get_next_bframe(bch)) {
527 hdlc_fill_fifo(bch);
528 test_and_clear_bit(FLG_TX_EMPTY, &bch->Flags);
529 } else if (test_bit(FLG_TX_EMPTY, &bch->Flags)) {
530 hdlc_fill_fifo(bch);
536 HDLC_irq(struct bchannel *bch, u32 stat)
538 struct fritzcard *fc = bch->hw;
543 hdlc = &fc->hdlc[(bch->nr - 1) & 1];
544 pr_debug("%s: ch%d stat %#x\n", fc->name, bch->nr, stat);
555 fc->name, bch->nr, stat);
558 write_ctrl(bch, 1);
560 write_ctrl(bch, 1);
561 if (bch->rx_skb)
562 skb_trim(bch->rx_skb, 0);
567 hdlc_empty_fifo(bch, len);
568 if (!bch->rx_skb)
570 if (test_bit(FLG_TRANSPARENT, &bch->Flags)) {
571 recv_Bchannel(bch, 0, false);
575 recv_Bchannel(bch, 0, false);
579 skb_trim(bch->rx_skb, 0);
590 pr_warning("%s: ch%d stat %x XDU %s\n", fc->name, bch->nr,
591 stat, bch->tx_skb ? "tx_skb" : "no tx_skb");
592 if (bch->tx_skb && bch->tx_skb->len) {
593 if (!test_bit(FLG_TRANSPARENT, &bch->Flags))
594 bch->tx_idx = 0;
595 } else if (test_bit(FLG_FILLEMPTY, &bch->Flags)) {
596 test_and_set_bit(FLG_TX_EMPTY, &bch->Flags);
600 write_ctrl(bch, 1);
602 HDLC_irq_xpr(bch);
605 HDLC_irq_xpr(bch);
612 struct bchannel *bch;
616 bch = Sel_BCS(fc, 1);
617 if (bch)
618 HDLC_irq(bch, stat);
624 bch = Sel_BCS(fc, 2);
625 if (bch)
626 HDLC_irq(bch, stat);
695 struct bchannel *bch = container_of(ch, struct bchannel, ch);
696 struct fritzcard *fc = bch->hw;
704 ret = bchannel_senddata(bch, skb);
706 hdlc_fill_fifo(bch);
713 if (!test_and_set_bit(FLG_ACTIVE, &bch->Flags))
714 ret = modehdlc(bch, ch->protocol);
724 mISDN_clear_bchannel(bch);
725 modehdlc(bch, ISDN_P_NONE);
740 modehdlc(&fc->bch[0], -1);
741 modehdlc(&fc->bch[1], -1);
843 channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq)
845 return mISDN_ctrl_bchannel(bch, cq);
851 struct bchannel *bch = container_of(ch, struct bchannel, ch);
852 struct fritzcard *fc = bch->hw;
859 test_and_clear_bit(FLG_OPEN, &bch->Flags);
860 cancel_work_sync(&bch->workq);
862 mISDN_clear_bchannel(bch);
863 modehdlc(bch, ISDN_P_NONE);
871 ret = channel_bctrl(bch, arg);
910 struct bchannel *bch;
916 bch = &fc->bch[rq->adr.channel - 1];
917 if (test_and_set_bit(FLG_OPEN, &bch->Flags))
919 bch->ch.protocol = rq->protocol;
920 rq->ch = &bch->ch;
1019 modehdlc(&card->bch[0], ISDN_P_NONE);
1020 modehdlc(&card->bch[1], ISDN_P_NONE);
1024 mISDN_freebchannel(&card->bch[1]);
1025 mISDN_freebchannel(&card->bch[0]);
1059 card->bch[i].nr = i + 1;
1065 mISDN_initbchannel(&card->bch[i], MAX_DATA_MEM, minsize);
1066 card->bch[i].hw = card;
1067 card->bch[i].ch.send = avm_l2l1B;
1068 card->bch[i].ch.ctrl = avm_bctrl;
1069 card->bch[i].ch.nr = i + 1;
1070 list_add(&card->bch[i].ch.list, &card->isac.dch.dev.bchannels);
1090 mISDN_freebchannel(&card->bch[1]);
1091 mISDN_freebchannel(&card->bch[0]);