Commit 183fdaad authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN/HiSax: Separate out xmit_ready_b()

A lot of drivers do the same thing when they're ready for transmitting
the next frame, so let's share that code.
parent b688af83
......@@ -115,14 +115,7 @@ Bchan_xmt_bh(void *data)
dev_kfree_skb(bcs->hw.amd7930.tx_skb);
bcs->hw.amd7930.tx_skb = NULL;
}
if ((skb = skb_dequeue(&bcs->squeue))) {
Bchan_fill_fifo(bcs, skb);
} else {
clear_bit(BC_FLG_BUSY, &bcs->Flag);
bcs->event |= 1 << B_XMTBUFREADY;
schedule_work(&bcs->work);
}
xmit_ready_b(bcs);
}
static void
......
......@@ -341,7 +341,7 @@ hdlc_fill_fifo(struct BCState *bcs)
ptr = (u_int *) p = bcs->tx_skb->data;
skb_pull(bcs->tx_skb, count);
bcs->tx_cnt -= count;
bcs->hw.hdlc.count += count;
bcs->count += count;
bcs->hw.hdlc.ctrl.sr.xml = ((count == fifo_size) ? 0 : count);
write_ctrl(bcs, 3); /* sets the correct index too */
if (cs->subtyp == AVM_FRITZ_PCI) {
......@@ -434,9 +434,9 @@ HDLC_irq(struct BCState *bcs, u_int stat) {
* restart transmitting the whole frame.
*/
if (bcs->tx_skb) {
skb_push(bcs->tx_skb, bcs->hw.hdlc.count);
bcs->tx_cnt += bcs->hw.hdlc.count;
bcs->hw.hdlc.count = 0;
skb_push(bcs->tx_skb, bcs->count);
bcs->tx_cnt += bcs->count;
bcs->count = 0;
if (bcs->cs->debug & L1_DEB_WARN)
debugl1(bcs->cs, "ch%d XDU", bcs->channel);
} else if (bcs->cs->debug & L1_DEB_WARN)
......@@ -454,16 +454,9 @@ HDLC_irq(struct BCState *bcs, u_int stat) {
return;
}
xmit_complete_b(bcs);
bcs->hw.hdlc.count = 0;
}
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
bcs->hw.hdlc.count = 0;
test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
hdlc_fill_fifo(bcs);
} else {
test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
sched_b_event(bcs, B_XMTBUFREADY);
bcs->count = 0;
}
xmit_ready_b(bcs);
}
}
......@@ -521,7 +514,7 @@ hdlc_l2l1(struct PStack *st, int pr, void *arg)
} else {
st->l1.bcs->tx_skb = skb;
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->hw.hdlc.count = 0;
st->l1.bcs->count = 0;
spin_unlock_irqrestore(&avm_pci_lock, flags);
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
}
......@@ -533,7 +526,7 @@ hdlc_l2l1(struct PStack *st, int pr, void *arg)
}
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->hw.hdlc.count = 0;
st->l1.bcs->count = 0;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
break;
case (PH_PULL | REQUEST):
......
......@@ -482,7 +482,7 @@ Memhscx_fill_fifo(struct BCState *bcs)
p = ptr = bcs->tx_skb->data;
skb_pull(bcs->tx_skb, count);
bcs->tx_cnt -= count;
bcs->hw.hscx.count += count;
bcs->count += count;
while(cnt--)
memwritereg(cs->hw.diva.cfg_reg, bcs->hw.hscx.hscx ? 0x40 : 0,
*p++);
......@@ -565,10 +565,10 @@ Memhscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx)
return;
}
xmit_complete_b(bcs);
bcs->hw.hscx.count = 0;
bcs->count = 0;
}
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
bcs->hw.hscx.count = 0;
bcs->count = 0;
test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
Memhscx_fill_fifo(bcs);
} else {
......@@ -596,9 +596,9 @@ Memhscx_int_main(struct IsdnCardState *cs, u_char val)
* restart transmitting the whole frame.
*/
if (bcs->tx_skb) {
skb_push(bcs->tx_skb, bcs->hw.hscx.count);
bcs->tx_cnt += bcs->hw.hscx.count;
bcs->hw.hscx.count = 0;
skb_push(bcs->tx_skb, bcs->count);
bcs->tx_cnt += bcs->count;
bcs->count = 0;
}
MemWriteHSCXCMDR(cs, bcs->hw.hscx.hscx, 0x01);
if (cs->debug & L1_DEB_WARN)
......@@ -623,9 +623,9 @@ Memhscx_int_main(struct IsdnCardState *cs, u_char val)
* restart transmitting the whole frame.
*/
if (bcs->tx_skb) {
skb_push(bcs->tx_skb, bcs->hw.hscx.count);
bcs->tx_cnt += bcs->hw.hscx.count;
bcs->hw.hscx.count = 0;
skb_push(bcs->tx_skb, bcs->count);
bcs->tx_cnt += bcs->count;
bcs->count = 0;
}
MemWriteHSCXCMDR(cs, bcs->hw.hscx.hscx, 0x01);
if (cs->debug & L1_DEB_WARN)
......@@ -709,7 +709,7 @@ diva_irq_ipacx_pci(int intno, void *dev_id, struct pt_regs *regs)
cfg = (u_char *) cs->hw.diva.pci_cfg;
val = *cfg;
if (!(val &PITA_INT0_STATUS)) return; // other shared IRQ
interrupt_ipacx(cs); // handler for chip
interrupt_ipacx(cs); // handler for chip
*cfg = PITA_INT0_STATUS; // Reset PLX interrupt
}
......@@ -1158,7 +1158,7 @@ setup_diva(struct IsdnCard *card)
cs->writeisacfifo = &MemWriteISACfifo_IPACX;
cs->BC_Read_Reg = &MemReadHSCX_IPACX;
cs->BC_Write_Reg = &MemWriteHSCX_IPACX;
cs->BC_Send_Data = 0; // function located in ipacx module
cs->BC_Send_Data = &ipacx_fill_fifo;
cs->irq_func = &diva_irq_ipacx_pci;
printk(KERN_INFO "Diva: IPACX Design Id: %x\n",
MemReadISAC_IPACX(cs, IPACX_ID) &0x3F);
......
......@@ -293,8 +293,8 @@ write_modem(struct BCState *bcs) {
}
inline void
modem_fill(struct BCState *bcs) {
modem_fill(struct BCState *bcs)
{
if (bcs->tx_skb) {
if (bcs->tx_skb->len) {
write_modem(bcs);
......@@ -302,14 +302,7 @@ modem_fill(struct BCState *bcs) {
}
xmit_complete_b(bcs);
}
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
bcs->hw.hscx.count = 0;
test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
write_modem(bcs);
} else {
test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
sched_b_event(bcs, B_XMTBUFREADY);
}
xmit_ready_b(bcs);
}
static inline void receive_chars(struct IsdnCardState *cs,
......@@ -574,7 +567,7 @@ modem_l2l1(struct PStack *st, int pr, void *arg)
} else {
st->l1.bcs->tx_skb = skb;
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->hw.hscx.count = 0;
st->l1.bcs->count = 0;
spin_unlock_irqrestore(&elsa_ser_lock, flags);
write_modem(st->l1.bcs);
}
......@@ -607,6 +600,7 @@ setstack_elsa(struct PStack *st, struct BCState *bcs)
if (open_hscxstate(st->l1.hardware, bcs))
return (-1);
st->l1.l2l1 = hscx_l2l1;
// bcs->cs->BC_Send_Data = hscx_fill_fifo;
break;
case L1_MODE_MODEM:
bcs->mode = L1_MODE_MODEM;
......@@ -622,6 +616,7 @@ setstack_elsa(struct PStack *st, struct BCState *bcs)
bcs->tx_cnt = 0;
bcs->cs->hw.elsa.bcs = bcs;
st->l1.l2l1 = modem_l2l1;
bcs->cs->BC_Send_Data = modem_fill;
break;
}
st->l1.bcs = bcs;
......
......@@ -908,15 +908,7 @@ hfc2bds0_interrupt(struct IsdnCardState *cs, u_char val)
} else
debugl1(cs,"fill_data %d blocked", bcs->channel);
} else {
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
hfc_fill_fifo(bcs);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
} else
debugl1(cs,"fill_data %d blocked", bcs->channel);
} else {
sched_b_event(bcs, B_XMTBUFREADY);
}
xmit_ready_b(bcs);
}
}
}
......@@ -932,15 +924,7 @@ hfc2bds0_interrupt(struct IsdnCardState *cs, u_char val)
} else
debugl1(cs,"fill_data %d blocked", bcs->channel);
} else {
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
hfc_fill_fifo(bcs);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
} else
debugl1(cs,"fill_data %d blocked", bcs->channel);
} else {
sched_b_event(bcs, B_XMTBUFREADY);
}
xmit_ready_b(bcs);
}
}
}
......
......@@ -1036,15 +1036,7 @@ hfcpci_interrupt(int intno, void *dev_id, struct pt_regs *regs)
} else
debugl1(cs, "fill_data %d blocked", bcs->channel);
} else {
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
hfcpci_fill_fifo(bcs);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
} else
debugl1(cs, "fill_data %d blocked", bcs->channel);
} else {
sched_b_event(bcs, B_XMTBUFREADY);
}
xmit_buf_ready(bcs);
}
}
}
......@@ -1060,15 +1052,7 @@ hfcpci_interrupt(int intno, void *dev_id, struct pt_regs *regs)
} else
debugl1(cs, "fill_data %d blocked", bcs->channel);
} else {
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
hfcpci_fill_fifo(bcs);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
} else
debugl1(cs, "fill_data %d blocked", bcs->channel);
} else {
sched_b_event(bcs, B_XMTBUFREADY);
}
xmit_buf_ready(bcs);
}
}
}
......
......@@ -835,15 +835,7 @@ hfcsx_interrupt(int intno, void *dev_id, struct pt_regs *regs)
} else
debugl1(cs, "fill_data %d blocked", bcs->channel);
} else {
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
hfcsx_fill_fifo(bcs);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
} else
debugl1(cs, "fill_data %d blocked", bcs->channel);
} else {
sched_b_event(bcs, B_XMTBUFREADY);
}
xmit_ready_b(bcs);
}
}
}
......@@ -859,15 +851,7 @@ hfcsx_interrupt(int intno, void *dev_id, struct pt_regs *regs)
} else
debugl1(cs, "fill_data %d blocked", bcs->channel);
} else {
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
hfcsx_fill_fifo(bcs);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
} else
debugl1(cs, "fill_data %d blocked", bcs->channel);
} else {
sched_b_event(bcs, B_XMTBUFREADY);
}
xmit_ready_b(bcs);
}
}
}
......
......@@ -351,7 +351,6 @@ struct l3_process {
struct hscx_hw {
int hscx;
int rcvidx;
int count; /* Current skb sent count */
u_char *rcvbuf; /* B-Channel receive Buffer */
u_char tsaxr0;
u_char tsaxr1;
......@@ -360,7 +359,6 @@ struct hscx_hw {
struct w6692B_hw {
int bchan;
int rcvidx;
int count; /* Current skb sent count */
u_char *rcvbuf; /* B-Channel receive Buffer */
};
......@@ -411,7 +409,6 @@ struct hdlc_hw {
} ctrl;
u_int stat;
int rcvidx;
int count; /* Current skb sent count */
u_char *rcvbuf; /* B-Channel receive Buffer */
};
......@@ -504,6 +501,7 @@ struct BCState {
int err_rdo;
int err_inv;
#endif
int count;
union {
struct hscx_hw hscx;
struct hdlc_hw hdlc;
......@@ -1406,18 +1404,3 @@ L4L3(struct PStack *st, int pr, void *arg)
{
st->l3.l4l3(st, pr, arg);
}
static inline void
sched_b_event(struct BCState *bcs, int event)
{
set_bit(event, &bcs->event);
schedule_work(&bcs->work);
}
static inline void
xmit_complete_b(struct BCState *bcs)
{
skb_queue_tail(&bcs->cmpl_queue, bcs->tx_skb);
sched_b_event(bcs, B_CMPLREADY);
bcs->tx_skb = NULL;
}
......@@ -106,7 +106,7 @@ hscx_l2l1(struct PStack *st, int pr, void *arg)
} else {
st->l1.bcs->tx_skb = skb;
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->hw.hscx.count = 0;
st->l1.bcs->count = 0;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
}
spin_unlock_irqrestore(&cs->lock, flags);
......@@ -118,7 +118,7 @@ hscx_l2l1(struct PStack *st, int pr, void *arg)
} else {
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->hw.hscx.count = 0;
st->l1.bcs->count = 0;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
}
spin_unlock_irqrestore(&cs->lock, flags);
......
......@@ -79,7 +79,7 @@ hscx_empty_fifo(struct BCState *bcs, int count)
}
static void
__hscx_fill_fifo(struct BCState *bcs)
hscx_fill_fifo(struct BCState *bcs)
{
struct IsdnCardState *cs = bcs->cs;
int more, count;
......@@ -105,7 +105,7 @@ __hscx_fill_fifo(struct BCState *bcs)
ptr = bcs->tx_skb->data;
skb_pull(bcs->tx_skb, count);
bcs->tx_cnt -= count;
bcs->hw.hscx.count += count;
bcs->count += count;
WRITEHSCXFIFO(cs, bcs->hw.hscx.hscx, ptr, count);
WriteHSCXCMDR(cs, bcs->hw.hscx.hscx, more ? 0x8 : 0xa);
if (cs->debug & L1_DEB_HSCX_FIFO) {
......@@ -118,17 +118,6 @@ __hscx_fill_fifo(struct BCState *bcs)
}
}
static void
hscx_fill_fifo(struct BCState *bcs)
{
struct IsdnCardState *cs = bcs->cs;
unsigned long flags;
spin_lock_irqsave(&cs->lock, flags);
__hscx_fill_fifo(bcs);
spin_unlock_irqrestore(&cs->lock, flags);
}
static inline void
hscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx)
{
......@@ -204,20 +193,13 @@ hscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx)
if (val & 0x10) { /* XPR */
if (bcs->tx_skb) {
if (bcs->tx_skb->len) {
__hscx_fill_fifo(bcs);
hscx_fill_fifo(bcs);
return;
}
xmit_complete_b(bcs);
bcs->hw.hscx.count = 0;
}
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
bcs->hw.hscx.count = 0;
test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
__hscx_fill_fifo(bcs);
} else {
test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
sched_b_event(bcs, B_XMTBUFREADY);
bcs->count = 0;
}
xmit_ready_b(bcs);
}
}
......@@ -234,7 +216,7 @@ hscx_int_main(struct IsdnCardState *cs, u_char val)
exval = READHSCX(cs, 1, HSCX_EXIR);
if (exval & 0x40) {
if (bcs->mode == 1)
__hscx_fill_fifo(bcs);
hscx_fill_fifo(bcs);
else {
#ifdef ERROR_STATISTIC
bcs->err_tx++;
......@@ -243,9 +225,9 @@ hscx_int_main(struct IsdnCardState *cs, u_char val)
* restart transmitting the whole frame.
*/
if (bcs->tx_skb) {
skb_push(bcs->tx_skb, bcs->hw.hscx.count);
bcs->tx_cnt += bcs->hw.hscx.count;
bcs->hw.hscx.count = 0;
skb_push(bcs->tx_skb, bcs->count);
bcs->tx_cnt += bcs->count;
bcs->count = 0;
}
WriteHSCXCMDR(cs, bcs->hw.hscx.hscx, 0x01);
if (cs->debug & L1_DEB_WARN)
......@@ -264,7 +246,7 @@ hscx_int_main(struct IsdnCardState *cs, u_char val)
exval = READHSCX(cs, 0, HSCX_EXIR);
if (exval & 0x40) {
if (bcs->mode == L1_MODE_TRANS)
__hscx_fill_fifo(bcs);
hscx_fill_fifo(bcs);
else {
/* Here we lost an TX interrupt, so
* restart transmitting the whole frame.
......@@ -273,9 +255,9 @@ hscx_int_main(struct IsdnCardState *cs, u_char val)
bcs->err_tx++;
#endif
if (bcs->tx_skb) {
skb_push(bcs->tx_skb, bcs->hw.hscx.count);
bcs->tx_cnt += bcs->hw.hscx.count;
bcs->hw.hscx.count = 0;
skb_push(bcs->tx_skb, bcs->count);
bcs->tx_cnt += bcs->count;
bcs->count = 0;
}
WriteHSCXCMDR(cs, bcs->hw.hscx.hscx, 0x01);
if (cs->debug & L1_DEB_WARN)
......
......@@ -47,7 +47,6 @@ static void __devinit dch_setstack(struct PStack *st, struct IsdnCardState *cs);
static void __devinit dch_init(struct IsdnCardState *cs);
static void bch_l2l1(struct PStack *st, int pr, void *arg);
static void bch_empty_fifo(struct BCState *bcs, int count);
static void bch_fill_fifo(struct BCState *bcs);
static void bch_int(struct IsdnCardState *cs, u_char hscx);
static void bch_mode(struct BCState *bcs, int mode, int bc);
static void bch_close_state(struct BCState *bcs);
......@@ -543,9 +542,9 @@ bch_l2l1(struct PStack *st, int pr, void *arg)
} else {
st->l1.bcs->tx_skb = skb;
set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->hw.hscx.count = 0;
st->l1.bcs->count = 0;
spin_unlock_irqrestore(&ipacx_lock, flags);
bch_fill_fifo(st->l1.bcs);
ipacx_fill_fifo(st->l1.bcs);
}
break;
case (PH_PULL | INDICATION):
......@@ -555,8 +554,8 @@ bch_l2l1(struct PStack *st, int pr, void *arg)
}
set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->hw.hscx.count = 0;
bch_fill_fifo(st->l1.bcs);
st->l1.bcs->count = 0;
ipacx_fill_fifo(st->l1.bcs);
break;
case (PH_PULL | REQUEST):
if (!st->l1.bcs->tx_skb) {
......@@ -630,8 +629,8 @@ bch_empty_fifo(struct BCState *bcs, int count)
//----------------------------------------------------------
// Fill buffer to transmit FIFO
//----------------------------------------------------------
static void
bch_fill_fifo(struct BCState *bcs)
void
ipacx_fill_fifo(struct BCState *bcs)
{
struct IsdnCardState *cs;
int more, count, cnt;
......@@ -640,7 +639,7 @@ bch_fill_fifo(struct BCState *bcs)
cs = bcs->cs;
if ((cs->debug &L1_DEB_HSCX) && !(cs->debug &L1_DEB_HSCX_FIFO))
debugl1(cs, "bch_fill_fifo()");
debugl1(cs, "ipacx_fill_fifo()");
if (!bcs->tx_skb) return;
if (bcs->tx_skb->len <= 0) return;
......@@ -659,7 +658,7 @@ bch_fill_fifo(struct BCState *bcs)
p = ptr = bcs->tx_skb->data;
skb_pull(bcs->tx_skb, count);
bcs->tx_cnt -= count;
bcs->hw.hscx.count += count;
bcs->count += count;
while (cnt--) cs->BC_Write_Reg(cs, hscx, IPACX_XFIFOB, *p++);
cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, (more ? 0x08 : 0x0a));
spin_unlock_irqrestore(&ipacx_lock, flags);
......@@ -747,32 +746,25 @@ bch_int(struct IsdnCardState *cs, u_char hscx)
if (istab &0x10) { // XPR
if (bcs->tx_skb) {
if (bcs->tx_skb->len) {
bch_fill_fifo(bcs);
ipacx_fill_fifo(bcs);
goto afterXPR;
}
xmit_complete_b(bcs);
bcs->hw.hscx.count = 0;
}
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
bcs->hw.hscx.count = 0;
set_bit(BC_FLG_BUSY, &bcs->Flag);
bch_fill_fifo(bcs);
} else {
clear_bit(BC_FLG_BUSY, &bcs->Flag);
sched_b_event(bcs, B_XMTBUFREADY);
bcs->count = 0;
}
xmit_ready_b(bcs);
}
afterXPR:
if (istab &0x04) { // XDU
if (bcs->mode == L1_MODE_TRANS) {
bch_fill_fifo(bcs);
ipacx_fill_fifo(bcs);
}
else {
if (bcs->tx_skb) { // restart transmitting the whole frame
skb_push(bcs->tx_skb, bcs->hw.hscx.count);
bcs->tx_cnt += bcs->hw.hscx.count;
bcs->hw.hscx.count = 0;
skb_push(bcs->tx_skb, bcs->count);
bcs->tx_cnt += bcs->count;
bcs->count = 0;
}
cs->BC_Write_Reg(cs, hscx, IPACX_CMDRB, 0x01); // XRES
if (cs->debug &L1_DEB_WARN)
......
......@@ -157,5 +157,6 @@
extern void init_ipacx(struct IsdnCardState *cs, int part);
extern void interrupt_ipacx(struct IsdnCardState *cs);
extern void ipacx_fill_fifo(struct BCState *bcs);
#endif
......@@ -34,3 +34,33 @@ extern void l1_msg_b(struct PStack *st, int pr, void *arg);
#ifdef L2FRAME_DEBUG
extern void Logl2Frame(struct IsdnCardState *cs, struct sk_buff *skb, char *buf, int dir);
#endif
static inline void
sched_b_event(struct BCState *bcs, int event)
{
set_bit(event, &bcs->event);
schedule_work(&bcs->work);
}
static inline void
xmit_complete_b(struct BCState *bcs)
{
skb_queue_tail(&bcs->cmpl_queue, bcs->tx_skb);
sched_b_event(bcs, B_CMPLREADY);
bcs->tx_skb = NULL;
}
static inline void
xmit_ready_b(struct BCState *bcs)
{
bcs->tx_skb = skb_dequeue(&bcs->squeue);
if (bcs->tx_skb) {
bcs->count = 0;
set_bit(BC_FLG_BUSY, &bcs->Flag);
bcs->cs->BC_Send_Data(bcs);
} else {
clear_bit(BC_FLG_BUSY, &bcs->Flag);
sched_b_event(bcs, B_XMTBUFREADY);
}
}
......@@ -156,7 +156,7 @@ jade_l2l1(struct PStack *st, int pr, void *arg)
} else {
st->l1.bcs->tx_skb = skb;
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->hw.hscx.count = 0;
st->l1.bcs->count = 0;
spin_unlock_irqrestore(&jade_lock, flags);
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
}
......@@ -168,7 +168,7 @@ jade_l2l1(struct PStack *st, int pr, void *arg)
}
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->hw.hscx.count = 0;
st->l1.bcs->count = 0;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
break;
case (PH_PULL | REQUEST):
......
......@@ -106,7 +106,7 @@ jade_fill_fifo(struct BCState *bcs)
ptr = bcs->tx_skb->data;
skb_pull(bcs->tx_skb, count);
bcs->tx_cnt -= count;
bcs->hw.hscx.count += count;
bcs->count += count;
WRITEJADEFIFO(cs, bcs->hw.hscx.hscx, ptr, count);
WriteJADECMDR(cs, bcs->hw.hscx.hscx, jade_HDLC_XCMD, more ? jadeXCMD_XF : (jadeXCMD_XF|jadeXCMD_XME));
spin_unlock_irqrestore(&jade_irq_lock, flags);
......@@ -187,16 +187,9 @@ jade_interrupt(struct IsdnCardState *cs, u_char val, u_char jade)
return;
}
xmit_complete_b(bcs);
bcs->hw.hscx.count = 0;
}
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
bcs->hw.hscx.count = 0;
test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
jade_fill_fifo(bcs);
} else {
test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
sched_b_event(bcs, B_XMTBUFREADY);
bcs->count = 0;
}
xmit_ready_b(bcs);
}
}
......@@ -220,9 +213,9 @@ jade_int_main(struct IsdnCardState *cs, u_char val, int jade)
* restart transmitting the whole frame.
*/
if (bcs->tx_skb) {
skb_push(bcs->tx_skb, bcs->hw.hscx.count);
bcs->tx_cnt += bcs->hw.hscx.count;
bcs->hw.hscx.count = 0;
skb_push(bcs->tx_skb, bcs->count);
bcs->tx_cnt += bcs->count;
bcs->count = 0;
}
WriteJADECMDR(cs, bcs->hw.hscx.hscx, jade_HDLC_XCMD, jadeXCMD_XRES);
if (cs->debug & L1_DEB_WARN)
......
......@@ -279,7 +279,7 @@ W6692B_fill_fifo(struct BCState *bcs)
ptr = bcs->tx_skb->data;
skb_pull(bcs->tx_skb, count);
bcs->tx_cnt -= count;
bcs->hw.w6692.count += count;
bcs->count += count;
WRITEW6692BFIFO(cs, bcs->channel, ptr, count);
cs->BC_Write_Reg(cs, bcs->channel, W_B_CMDR, W_B_CMDR_RACT | W_B_CMDR_XMS | (more ? 0 : W_B_CMDR_XME));
spin_unlock_irqrestore(&w6692_lock , flags);
......@@ -361,16 +361,9 @@ W6692B_interrupt(struct IsdnCardState *cs, u_char bchan)
return;
}
xmit_complete_b(bcs);
bcs->hw.w6692.count = 0;
}
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
bcs->hw.w6692.count = 0;
test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
W6692B_fill_fifo(bcs);
} else {
test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
sched_b_event(bcs, B_XMTBUFREADY);
bcs->count = 0;
}
xmit_ready_b(bcs);
}
if (val & W_B_EXI_XDUN) { /* XDUN */
if (bcs->mode == 1)
......@@ -380,9 +373,9 @@ W6692B_interrupt(struct IsdnCardState *cs, u_char bchan)
* restart transmitting the whole frame.
*/
if (bcs->tx_skb) {
skb_push(bcs->tx_skb, bcs->hw.w6692.count);
bcs->tx_cnt += bcs->hw.w6692.count;
bcs->hw.w6692.count = 0;
skb_push(bcs->tx_skb, bcs->count);
bcs->tx_cnt += bcs->count;
bcs->count = 0;
}
cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_XRST | W_B_CMDR_RACT);
if (cs->debug & L1_DEB_WARN)
......@@ -742,7 +735,7 @@ W6692_l2l1(struct PStack *st, int pr, void *arg)
} else {
st->l1.bcs->tx_skb = skb;
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->hw.w6692.count = 0;
st->l1.bcs->count = 0;
spin_unlock_irqrestore(&w6692_lock , flags);
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
}
......@@ -754,7 +747,7 @@ W6692_l2l1(struct PStack *st, int pr, void *arg)
}
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->hw.w6692.count = 0;
st->l1.bcs->count = 0;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
break;
case (PH_PULL | REQUEST):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment