Lines Matching refs:bcs

61 GetFreeFifoBytes(struct BCState *bcs)  in GetFreeFifoBytes()  argument
65 if (bcs->hw.hfc.f1 == bcs->hw.hfc.f2) in GetFreeFifoBytes()
66 return (bcs->cs->hw.hfc.fifosize); in GetFreeFifoBytes()
67 s = bcs->hw.hfc.send[bcs->hw.hfc.f1] - bcs->hw.hfc.send[bcs->hw.hfc.f2]; in GetFreeFifoBytes()
69 s += bcs->cs->hw.hfc.fifosize; in GetFreeFifoBytes()
70 s = bcs->cs->hw.hfc.fifosize - s; in GetFreeFifoBytes()
75 ReadZReg(struct BCState *bcs, u_char reg) in ReadZReg() argument
79 WaitNoBusy(bcs->cs); in ReadZReg()
80 val = 256 * bcs->cs->BC_Read_Reg(bcs->cs, HFC_DATA, reg | HFC_CIP | HFC_Z_HIGH); in ReadZReg()
81 WaitNoBusy(bcs->cs); in ReadZReg()
82 val += bcs->cs->BC_Read_Reg(bcs->cs, HFC_DATA, reg | HFC_CIP | HFC_Z_LOW); in ReadZReg()
87 hfc_sched_event(struct BCState *bcs, int event) in hfc_sched_event() argument
89 bcs->event |= 1 << event; in hfc_sched_event()
90 queue_task(&bcs->tqueue, &tq_immediate); in hfc_sched_event()
95 hfc_clear_fifo(struct BCState *bcs) in hfc_clear_fifo() argument
97 struct IsdnCardState *cs = bcs->cs; in hfc_clear_fifo()
107 cip = HFC_CIP | HFC_F1 | HFC_REC | HFC_CHANNEL(bcs->channel); in hfc_clear_fifo()
114 cip = HFC_CIP | HFC_F2 | HFC_REC | HFC_CHANNEL(bcs->channel); in hfc_clear_fifo()
117 z1 = ReadZReg(bcs, HFC_Z1 | HFC_REC | HFC_CHANNEL(bcs->channel)); in hfc_clear_fifo()
118 z2 = ReadZReg(bcs, HFC_Z2 | HFC_REC | HFC_CHANNEL(bcs->channel)); in hfc_clear_fifo()
123 bcs->channel, f1, f2); in hfc_clear_fifo()
131 bcs->channel, z1, z2, rcnt); in hfc_clear_fifo()
132 cip = HFC_CIP | HFC_FIFO_OUT | HFC_REC | HFC_CHANNEL(bcs->channel); in hfc_clear_fifo()
141 HFC_CHANNEL(bcs->channel)); in hfc_clear_fifo()
144 cip = HFC_CIP | HFC_F1 | HFC_REC | HFC_CHANNEL(bcs->channel); in hfc_clear_fifo()
147 cip = HFC_CIP | HFC_F2 | HFC_REC | HFC_CHANNEL(bcs->channel); in hfc_clear_fifo()
150 z1 = ReadZReg(bcs, HFC_Z1 | HFC_REC | HFC_CHANNEL(bcs->channel)); in hfc_clear_fifo()
151 z2 = ReadZReg(bcs, HFC_Z2 | HFC_REC | HFC_CHANNEL(bcs->channel)); in hfc_clear_fifo()
160 hfc_empty_fifo(struct BCState *bcs, int count) in hfc_empty_fifo() argument
164 struct IsdnCardState *cs = bcs->cs; in hfc_empty_fifo()
175 cip = HFC_CIP | HFC_FIFO_OUT | HFC_REC | HFC_CHANNEL(bcs->channel); in hfc_empty_fifo()
180 HFC_CHANNEL(bcs->channel)); in hfc_empty_fifo()
184 if ((count < 4) && (bcs->mode != L1_MODE_TRANS)) { in hfc_empty_fifo()
187 cip = HFC_CIP | HFC_FIFO_OUT | HFC_REC | HFC_CHANNEL(bcs->channel); in hfc_empty_fifo()
192 HFC_CHANNEL(bcs->channel)); in hfc_empty_fifo()
195 bcs->err_inv++; in hfc_empty_fifo()
199 if (bcs->mode == L1_MODE_TRANS) in hfc_empty_fifo()
208 cip = HFC_CIP | HFC_FIFO_OUT | HFC_REC | HFC_CHANNEL(bcs->channel); in hfc_empty_fifo()
215 printk(KERN_WARNING "HFC FIFO channel %d BUSY Error\n", bcs->channel); in hfc_empty_fifo()
217 if (bcs->mode != L1_MODE_TRANS) { in hfc_empty_fifo()
220 HFC_CHANNEL(bcs->channel)); in hfc_empty_fifo()
225 if (bcs->mode != L1_MODE_TRANS) { in hfc_empty_fifo()
234 bcs->channel, chksum, stat); in hfc_empty_fifo()
240 bcs->err_crc++; in hfc_empty_fifo()
245 HFC_CHANNEL(bcs->channel)); in hfc_empty_fifo()
253 hfc_fill_fifo(struct BCState *bcs) in hfc_fill_fifo() argument
255 struct IsdnCardState *cs = bcs->cs; in hfc_fill_fifo()
262 if (!bcs->tx_skb) in hfc_fill_fifo()
264 if (bcs->tx_skb->len <= 0) in hfc_fill_fifo()
269 cip = HFC_CIP | HFC_F1 | HFC_SEND | HFC_CHANNEL(bcs->channel); in hfc_fill_fifo()
275 if (bcs->mode != L1_MODE_TRANS) { in hfc_fill_fifo()
276 bcs->hw.hfc.f1 = cs->BC_Read_Reg(cs, HFC_DATA, cip); in hfc_fill_fifo()
277 cip = HFC_CIP | HFC_F2 | HFC_SEND | HFC_CHANNEL(bcs->channel); in hfc_fill_fifo()
279 bcs->hw.hfc.f2 = cs->BC_Read_Reg(cs, HFC_DATA, cip); in hfc_fill_fifo()
280 bcs->hw.hfc.send[bcs->hw.hfc.f1] = ReadZReg(bcs, HFC_Z1 | HFC_SEND | HFC_CHANNEL(bcs->channel)); in hfc_fill_fifo()
283 bcs->channel, bcs->hw.hfc.f1, bcs->hw.hfc.f2, in hfc_fill_fifo()
284 bcs->hw.hfc.send[bcs->hw.hfc.f1]); in hfc_fill_fifo()
285 fcnt = bcs->hw.hfc.f1 - bcs->hw.hfc.f2; in hfc_fill_fifo()
294 count = GetFreeFifoBytes(bcs); in hfc_fill_fifo()
298 z1 = ReadZReg(bcs, HFC_Z1 | HFC_REC | HFC_CHANNEL(bcs->channel)); in hfc_fill_fifo()
299 z2 = ReadZReg(bcs, HFC_Z2 | HFC_REC | HFC_CHANNEL(bcs->channel)); in hfc_fill_fifo()
306 bcs->channel, bcs->tx_skb->len, in hfc_fill_fifo()
308 if (count < bcs->tx_skb->len) { in hfc_fill_fifo()
314 cip = HFC_CIP | HFC_FIFO_IN | HFC_SEND | HFC_CHANNEL(bcs->channel); in hfc_fill_fifo()
316 while ((idx < bcs->tx_skb->len) && WaitNoBusy(cs)) in hfc_fill_fifo()
317 cs->BC_Write_Reg(cs, HFC_DATA_NODEB, cip, bcs->tx_skb->data[idx++]); in hfc_fill_fifo()
318 if (idx != bcs->tx_skb->len) { in hfc_fill_fifo()
320 printk(KERN_WARNING "HFC S FIFO channel %d BUSY Error\n", bcs->channel); in hfc_fill_fifo()
322 count = bcs->tx_skb->len; in hfc_fill_fifo()
323 bcs->tx_cnt -= count; in hfc_fill_fifo()
324 if (PACKET_NOACK == bcs->tx_skb->pkt_type) in hfc_fill_fifo()
326 dev_kfree_skb_any(bcs->tx_skb); in hfc_fill_fifo()
327 bcs->tx_skb = NULL; in hfc_fill_fifo()
328 if (bcs->mode != L1_MODE_TRANS) { in hfc_fill_fifo()
331 cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F1_INC | HFC_SEND | HFC_CHANNEL(bcs->channel)); in hfc_fill_fifo()
333 if (bcs->st->lli.l1writewakeup && (count >= 0)) in hfc_fill_fifo()
334 bcs->st->lli.l1writewakeup(bcs->st, count); in hfc_fill_fifo()
335 test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); in hfc_fill_fifo()
342 main_irq_hfc(struct BCState *bcs) in main_irq_hfc() argument
345 struct IsdnCardState *cs = bcs->cs; in main_irq_hfc()
355 cip = HFC_CIP | HFC_F1 | HFC_REC | HFC_CHANNEL(bcs->channel); in main_irq_hfc()
362 if (bcs->mode == L1_MODE_HDLC) { in main_irq_hfc()
364 cip = HFC_CIP | HFC_F2 | HFC_REC | HFC_CHANNEL(bcs->channel); in main_irq_hfc()
370 bcs->channel, f1, f2); in main_irq_hfc()
374 if (receive || (bcs->mode == L1_MODE_TRANS)) { in main_irq_hfc()
376 z1 = ReadZReg(bcs, HFC_Z1 | HFC_REC | HFC_CHANNEL(bcs->channel)); in main_irq_hfc()
377 z2 = ReadZReg(bcs, HFC_Z2 | HFC_REC | HFC_CHANNEL(bcs->channel)); in main_irq_hfc()
381 if ((bcs->mode == L1_MODE_HDLC) || (rcnt)) { in main_irq_hfc()
385 bcs->channel, z1, z2, rcnt); in main_irq_hfc()
387 if ((skb = hfc_empty_fifo(bcs, rcnt))) { in main_irq_hfc()
388 skb_queue_tail(&bcs->rqueue, skb); in main_irq_hfc()
389 hfc_sched_event(bcs, B_RCVBUFREADY); in main_irq_hfc()
397 if (bcs->tx_skb) { in main_irq_hfc()
399 test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); in main_irq_hfc()
400 hfc_fill_fifo(bcs); in main_irq_hfc()
401 if (test_bit(BC_FLG_BUSY, &bcs->Flag)) in main_irq_hfc()
404 if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) { in main_irq_hfc()
406 test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); in main_irq_hfc()
407 hfc_fill_fifo(bcs); in main_irq_hfc()
408 if (test_bit(BC_FLG_BUSY, &bcs->Flag)) in main_irq_hfc()
412 hfc_sched_event(bcs, B_XMTBUFREADY); in main_irq_hfc()
422 mode_hfc(struct BCState *bcs, int mode, int bc) in mode_hfc() argument
424 struct IsdnCardState *cs = bcs->cs; in mode_hfc()
428 mode, bc, bcs->channel); in mode_hfc()
429 bcs->mode = mode; in mode_hfc()
430 bcs->channel = bc; in mode_hfc()
446 hfc_clear_fifo(bcs); /* complete fifo clear */ in mode_hfc()
472 hfc_clear_fifo(bcs); in mode_hfc()
485 if (st->l1.bcs->tx_skb) { in hfc_l2l1()
486 skb_queue_tail(&st->l1.bcs->squeue, skb); in hfc_l2l1()
489 st->l1.bcs->tx_skb = skb; in hfc_l2l1()
490 test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag); in hfc_l2l1()
491 st->l1.bcs->cs->BC_Send_Data(st->l1.bcs); in hfc_l2l1()
496 if (st->l1.bcs->tx_skb) { in hfc_l2l1()
502 test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag); in hfc_l2l1()
503 st->l1.bcs->tx_skb = skb; in hfc_l2l1()
504 st->l1.bcs->cs->BC_Send_Data(st->l1.bcs); in hfc_l2l1()
508 if (!st->l1.bcs->tx_skb) { in hfc_l2l1()
515 test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); in hfc_l2l1()
516 mode_hfc(st->l1.bcs, st->l1.mode, st->l1.bc); in hfc_l2l1()
523 test_and_clear_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); in hfc_l2l1()
524 test_and_clear_bit(BC_FLG_BUSY, &st->l1.bcs->Flag); in hfc_l2l1()
525 mode_hfc(st->l1.bcs, 0, st->l1.bc); in hfc_l2l1()
533 close_hfcstate(struct BCState *bcs) in close_hfcstate() argument
535 mode_hfc(bcs, 0, bcs->channel); in close_hfcstate()
536 if (test_bit(BC_FLG_INIT, &bcs->Flag)) { in close_hfcstate()
537 skb_queue_purge(&bcs->rqueue); in close_hfcstate()
538 skb_queue_purge(&bcs->squeue); in close_hfcstate()
539 if (bcs->tx_skb) { in close_hfcstate()
540 dev_kfree_skb_any(bcs->tx_skb); in close_hfcstate()
541 bcs->tx_skb = NULL; in close_hfcstate()
542 test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); in close_hfcstate()
545 test_and_clear_bit(BC_FLG_INIT, &bcs->Flag); in close_hfcstate()
549 open_hfcstate(struct IsdnCardState *cs, struct BCState *bcs) in open_hfcstate() argument
551 if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) { in open_hfcstate()
552 skb_queue_head_init(&bcs->rqueue); in open_hfcstate()
553 skb_queue_head_init(&bcs->squeue); in open_hfcstate()
555 bcs->tx_skb = NULL; in open_hfcstate()
556 test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); in open_hfcstate()
557 bcs->event = 0; in open_hfcstate()
558 bcs->tx_cnt = 0; in open_hfcstate()
563 setstack_hfc(struct PStack *st, struct BCState *bcs) in setstack_hfc() argument
565 bcs->channel = st->l1.bc; in setstack_hfc()
566 if (open_hfcstate(st->l1.hardware, bcs)) in setstack_hfc()
568 st->l1.bcs = bcs; in setstack_hfc()
571 bcs->st = st; in setstack_hfc()
577 init_send(struct BCState *bcs) in init_send() argument
581 if (!(bcs->hw.hfc.send = kmalloc(32 * sizeof(unsigned int), GFP_ATOMIC))) { in init_send()
587 bcs->hw.hfc.send[i] = 0x1fff; in init_send()
593 init_send(&cs->bcs[0]); in inithfc()
594 init_send(&cs->bcs[1]); in inithfc()
596 cs->bcs[0].BC_SetStack = setstack_hfc; in inithfc()
597 cs->bcs[1].BC_SetStack = setstack_hfc; in inithfc()
598 cs->bcs[0].BC_Close = close_hfcstate; in inithfc()
599 cs->bcs[1].BC_Close = close_hfcstate; in inithfc()
600 mode_hfc(cs->bcs, 0, 0); in inithfc()
601 mode_hfc(cs->bcs + 1, 0, 0); in inithfc()
607 if (cs->bcs[0].hw.hfc.send) { in releasehfc()
608 kfree(cs->bcs[0].hw.hfc.send); in releasehfc()
609 cs->bcs[0].hw.hfc.send = NULL; in releasehfc()
611 if (cs->bcs[1].hw.hfc.send) { in releasehfc()
612 kfree(cs->bcs[1].hw.hfc.send); in releasehfc()
613 cs->bcs[1].hw.hfc.send = NULL; in releasehfc()