Lines Matching refs:bcs

223 static void __fcpci_write_ctrl(struct fritz_bcs *bcs, int which)
225 struct fritz_adapter *adapter = bcs->adapter;
226 int idx = bcs->channel ? AVM_IDX_HDLC_2 : AVM_IDX_HDLC_1;
229 'A' + bcs->channel, which, bcs->ctrl.ctrl);
232 outl(bcs->ctrl.ctrl, adapter->io + AVM_DATA + HDLC_CTRL);
235 static void fcpci_write_ctrl(struct fritz_bcs *bcs, int which)
237 struct fritz_adapter *adapter = bcs->adapter;
241 __fcpci_write_ctrl(bcs, which);
313 static void fcpci2_write_ctrl(struct fritz_bcs *bcs, int which)
315 struct fritz_adapter *adapter = bcs->adapter;
316 int offset = bcs->channel ? AVM_HDLC_STATUS_2 : AVM_HDLC_STATUS_1;
319 'A' + bcs->channel, which, bcs->ctrl.ctrl);
321 outl(bcs->ctrl.ctrl, adapter->io + offset);
342 static void __fcpnp_write_ctrl(struct fritz_bcs *bcs, int which)
344 struct fritz_adapter *adapter = bcs->adapter;
345 unsigned char idx = bcs->channel ? AVM_IDX_HDLC_2 : AVM_IDX_HDLC_1;
348 'A' + bcs->channel, which, bcs->ctrl.ctrl);
352 outb(bcs->ctrl.sr.mode,
355 outb(bcs->ctrl.sr.xml,
358 outb(bcs->ctrl.sr.cmd,
362 static void fcpnp_write_ctrl(struct fritz_bcs *bcs, int which)
364 struct fritz_adapter *adapter = bcs->adapter;
368 __fcpnp_write_ctrl(bcs, which);
374 static inline void B_L1L2(struct fritz_bcs *bcs, int pr, void *arg)
376 struct hisax_if *ifc = (struct hisax_if *) &bcs->b_if;
382 static void hdlc_fill_fifo(struct fritz_bcs *bcs)
384 struct fritz_adapter *adapter = bcs->adapter;
385 struct sk_buff *skb = bcs->tx_skb;
394 bcs->ctrl.sr.cmd &= ~HDLC_CMD_XME;
395 if (bcs->tx_skb->len > bcs->fifo_size) {
396 count = bcs->fifo_size;
398 count = bcs->tx_skb->len;
399 if (bcs->mode != L1_MODE_TRANS)
400 bcs->ctrl.sr.cmd |= HDLC_CMD_XME;
402 DBG(0x40, "hdlc_fill_fifo %d/%d", count, bcs->tx_skb->len);
403 p = bcs->tx_skb->data;
404 skb_pull(bcs->tx_skb, count);
405 bcs->tx_cnt += count;
406 bcs->ctrl.sr.xml = ((count == bcs->fifo_size) ? 0 : count);
412 __fcpci_write_ctrl(bcs, 3);
418 fcpci2_write_ctrl(bcs, 3);
420 (bcs->channel ? AVM_HDLC_FIFO_2 : AVM_HDLC_FIFO_1),
426 __fcpnp_write_ctrl(bcs, 3);
433 static inline void hdlc_empty_fifo(struct fritz_bcs *bcs, int count)
435 struct fritz_adapter *adapter = bcs->adapter;
437 unsigned char idx = bcs->channel ? AVM_IDX_HDLC_2 : AVM_IDX_HDLC_1;
440 if (bcs->rcvidx + count > HSCX_BUFMAX) {
444 p = bcs->rcvbuf + bcs->rcvidx;
445 bcs->rcvidx += count;
456 (bcs->channel ? AVM_HDLC_FIFO_2 : AVM_HDLC_FIFO_1),
468 static inline void hdlc_rpr_irq(struct fritz_bcs *bcs, u32 stat)
470 struct fritz_adapter *adapter = bcs->adapter;
476 bcs->ctrl.sr.xml = 0;
477 bcs->ctrl.sr.cmd |= HDLC_CMD_RRS;
478 adapter->write_ctrl(bcs, 1);
479 bcs->ctrl.sr.cmd &= ~HDLC_CMD_RRS;
480 adapter->write_ctrl(bcs, 1);
481 bcs->rcvidx = 0;
487 len = bcs->fifo_size;
489 hdlc_empty_fifo(bcs, len);
491 if ((stat & HDLC_STAT_RME) || (bcs->mode == L1_MODE_TRANS)) {
493 (bcs->mode == L1_MODE_TRANS)) {
494 skb = dev_alloc_skb(bcs->rcvidx);
498 memcpy(skb_put(skb, bcs->rcvidx), bcs->rcvbuf,
499 bcs->rcvidx);
501 B_L1L2(bcs, PH_DATA | INDICATION, skb);
503 bcs->rcvidx = 0;
506 bcs->channel, stat);
507 bcs->rcvidx = 0;
512 static inline void hdlc_xdu_irq(struct fritz_bcs *bcs)
514 struct fritz_adapter *adapter = bcs->adapter;
520 bcs->ctrl.sr.xml = 0;
521 bcs->ctrl.sr.cmd |= HDLC_CMD_XRS;
522 adapter->write_ctrl(bcs, 1);
523 bcs->ctrl.sr.cmd &= ~HDLC_CMD_XRS;
525 if (!bcs->tx_skb) {
527 adapter->write_ctrl(bcs, 1);
531 if (bcs->mode == L1_MODE_HDLC) {
532 skb_push(bcs->tx_skb, bcs->tx_cnt);
533 bcs->tx_cnt = 0;
537 static inline void hdlc_xpr_irq(struct fritz_bcs *bcs)
541 skb = bcs->tx_skb;
546 hdlc_fill_fifo(bcs);
549 bcs->tx_cnt = 0;
550 bcs->tx_skb = NULL;
551 B_L1L2(bcs, PH_DATA | CONFIRM, (void *)(unsigned long)skb->truesize);
555 static void hdlc_irq_one(struct fritz_bcs *bcs, u32 stat)
557 DBG(0x10, "ch%d stat %#x", bcs->channel, stat);
560 hdlc_rpr_irq(bcs, stat);
564 hdlc_xdu_irq(bcs);
565 hdlc_xpr_irq(bcs);
570 hdlc_xpr_irq(bcs);
583 hdlc_irq_one(&adapter->bcs[nr], stat);
587 static void modehdlc(struct fritz_bcs *bcs, int mode)
589 struct fritz_adapter *adapter = bcs->adapter;
592 'A' + bcs->channel, bcs->mode, mode);
594 if (bcs->mode == mode)
597 bcs->fifo_size = 32;
598 bcs->ctrl.ctrl = 0;
599 bcs->ctrl.sr.cmd = HDLC_CMD_XRS | HDLC_CMD_RRS;
602 bcs->ctrl.sr.mode = HDLC_MODE_TRANS;
603 adapter->write_ctrl(bcs, 5);
607 bcs->rcvidx = 0;
608 bcs->tx_cnt = 0;
609 bcs->tx_skb = NULL;
611 bcs->ctrl.sr.mode = HDLC_MODE_TRANS;
613 bcs->ctrl.sr.mode = HDLC_MODE_ITF_FLG;
615 adapter->write_ctrl(bcs, 5);
616 bcs->ctrl.sr.cmd = HDLC_CMD_XRS;
617 adapter->write_ctrl(bcs, 1);
618 bcs->ctrl.sr.cmd = 0;
621 bcs->mode = mode;
626 struct fritz_bcs *bcs = ifc->priv;
634 BUG_ON(bcs->tx_skb);
635 bcs->tx_skb = skb;
637 hdlc_fill_fifo(bcs);
641 DBG(4,"B%d,PH_ACTIVATE_REQUEST %d", bcs->channel + 1, mode);
642 modehdlc(bcs, mode);
643 B_L1L2(bcs, PH_ACTIVATE | INDICATION, NULL);
646 DBG(4,"B%d,PH_DEACTIVATE_REQUEST", bcs->channel + 1);
647 modehdlc(bcs, L1_MODE_NULL);
648 B_L1L2(bcs, PH_DEACTIVATE | INDICATION, NULL);
815 adapter->bcs[0].mode = -1;
816 adapter->bcs[1].mode = -1;
817 modehdlc(&adapter->bcs[0], L1_MODE_NULL);
818 modehdlc(&adapter->bcs[1], L1_MODE_NULL);
855 adapter->bcs[i].adapter = adapter;
856 adapter->bcs[i].channel = i;
857 adapter->bcs[i].b_if.ifc.priv = &adapter->bcs[i];
858 adapter->bcs[i].b_if.ifc.l2l1 = fritz_b_l2l1;
862 b_if[i] = &adapter->bcs[i].b_if;