Commit f496c9bb authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN/HiSax: Share fill_fifo() for B-Channels

Something else which can be nicely shared amongst various drivers...
parent c0dcd234
......@@ -316,35 +316,24 @@ static inline void
hdlc_fill_fifo(struct BCState *bcs)
{
struct IsdnCardState *cs = bcs->cs;
int count, cnt =0;
int count, more, cnt =0;
int fifo_size = 32;
u_char *p;
u_int *ptr;
unsigned char *p;
unsigned int *ptr;
if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
debugl1(cs, "hdlc_fill_fifo");
if (!bcs->tx_skb)
return;
if (bcs->tx_skb->len <= 0)
p = xmit_fill_fifo_b(bcs, fifo_size, &count, &more);
if (!p)
return;
bcs->hw.hdlc.ctrl.sr.cmd &= ~HDLC_CMD_XME;
if (bcs->tx_skb->len > fifo_size) {
count = fifo_size;
} else {
count = bcs->tx_skb->len;
if (bcs->mode != L1_MODE_TRANS)
bcs->hw.hdlc.ctrl.sr.cmd |= HDLC_CMD_XME;
}
if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
debugl1(cs, "hdlc_fill_fifo %d/%ld", count, bcs->tx_skb->len);
ptr = (u_int *) p = bcs->tx_skb->data;
skb_pull(bcs->tx_skb, count);
bcs->tx_cnt -= count;
bcs->count += count;
if (more)
bcs->hw.hdlc.ctrl.sr.cmd &= ~HDLC_CMD_XME;
else
bcs->hw.hdlc.ctrl.sr.cmd |= HDLC_CMD_XME;
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) {
ptr = (unsigned int *) p;
while (cnt<count) {
#ifdef __powerpc__
#ifdef CONFIG_APUS
......@@ -363,16 +352,6 @@ hdlc_fill_fifo(struct BCState *bcs)
cnt++;
}
}
if (cs->debug & L1_DEB_HSCX_FIFO) {
char *t = bcs->blog;
if (cs->subtyp == AVM_FRITZ_PNP)
p = (u_char *) ptr;
t += sprintf(t, "hdlc_fill_fifo %c cnt %d",
bcs->channel ? 'B' : 'A', count);
QuickHex(t, p, count);
debugl1(cs, bcs->blog);
}
}
static void
......
......@@ -456,46 +456,19 @@ static void
Memhscx_fill_fifo(struct BCState *bcs)
{
struct IsdnCardState *cs = bcs->cs;
int more, count, cnt;
int more, count;
int fifo_size = test_bit(HW_IPAC, &cs->HW_Flags)? 64: 32;
u_char *ptr,*p;
unsigned long flags;
if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
debugl1(cs, "hscx_fill_fifo");
unsigned char *p;
if (!bcs->tx_skb)
return;
if (bcs->tx_skb->len <= 0)
p = xmit_fill_fifo_b(bcs, fifo_size, &count, &more);
if (!p)
return;
more = (bcs->mode == L1_MODE_TRANS) ? 1 : 0;
if (bcs->tx_skb->len > fifo_size) {
more = !0;
count = fifo_size;
} else
count = bcs->tx_skb->len;
cnt = count;
MemwaitforXFW(cs, bcs->hw.hscx.hscx);
spin_lock_irqsave(&diva_lock, flags);
p = ptr = bcs->tx_skb->data;
skb_pull(bcs->tx_skb, count);
bcs->tx_cnt -= count;
bcs->count += count;
while(cnt--)
while (count--)
memwritereg(cs->hw.diva.cfg_reg, bcs->hw.hscx.hscx ? 0x40 : 0,
*p++);
MemWriteHSCXCMDR(cs, bcs->hw.hscx.hscx, more ? 0x8 : 0xa);
spin_unlock_irqrestore(&diva_lock, flags);
if (cs->debug & L1_DEB_HSCX_FIFO) {
char *t = bcs->blog;
t += sprintf(t, "hscx_fill_fifo %c cnt %d",
bcs->hw.hscx.hscx ? 'B' : 'A', count);
QuickHex(t, ptr, count);
debugl1(cs, bcs->blog);
}
}
static inline void
......
......@@ -597,41 +597,19 @@ bch_empty_fifo(struct BCState *bcs, int count)
void
ipacx_fill_fifo(struct BCState *bcs)
{
struct IsdnCardState *cs;
int more, count, cnt;
u_char *ptr, *p, hscx;
struct IsdnCardState *cs = bcs->cs;
int more, count;
unsigned char hscx = bcs->hw.hscx.hscx;
unsigned char *p;
cs = bcs->cs;
if ((cs->debug &L1_DEB_HSCX) && !(cs->debug &L1_DEB_HSCX_FIFO))
debugl1(cs, "ipacx_fill_fifo()");
p = xmit_fill_fifo_b(bcs, B_FIFO_SIZE, &count, &more);
if (!p)
return;
if (!bcs->tx_skb) return;
if (bcs->tx_skb->len <= 0) return;
while (count--)
cs->BC_Write_Reg(cs, hscx, IPACX_XFIFOB, *p++);
hscx = bcs->hw.hscx.hscx;
more = (bcs->mode == L1_MODE_TRANS) ? 1 : 0;
if (bcs->tx_skb->len > B_FIFO_SIZE) {
more = 1;
count = B_FIFO_SIZE;
} else {
count = bcs->tx_skb->len;
}
cnt = count;
p = ptr = bcs->tx_skb->data;
skb_pull(bcs->tx_skb, count);
bcs->tx_cnt -= 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));
if (cs->debug &L1_DEB_HSCX_FIFO) {
char *t = bcs->blog;
t += sprintf(t, "chb_fill_fifo() B-%d cnt %d", hscx, count);
QuickHex(t, ptr, count);
debugl1(cs, bcs->blog);
}
}
//----------------------------------------------------------
......
......@@ -176,3 +176,38 @@ xmit_xdu_b(struct BCState *bcs, void (*reset_xmit)(struct BCState *bcs))
reset_xmit(bcs);
}
}
static inline unsigned char *
xmit_fill_fifo_b(struct BCState *bcs, int fifo_size, int *count, int *more)
{
struct IsdnCardState *cs = bcs->cs;
if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
debugl1(cs, __FUNCTION__);
if (!bcs->tx_skb || bcs->tx_skb->len <= 0) {
WARN_ON(1);
return NULL;
}
*more = (bcs->mode == L1_MODE_TRANS);
if (bcs->tx_skb->len > fifo_size) {
*more = 1;
*count = fifo_size;
} else {
*count = bcs->tx_skb->len;
}
skb_pull(bcs->tx_skb, *count);
bcs->tx_cnt -= *count;
bcs->count += *count;
if (cs->debug & L1_DEB_HSCX_FIFO) {
char *t = bcs->blog;
t += sprintf(t, "%s %c cnt %d", __FUNCTION__,
bcs->hw.hscx.hscx ? 'B' : 'A', *count);
QuickHex(t, bcs->tx_skb->data, *count);
debugl1(cs, bcs->blog);
}
return bcs->tx_skb->data;
}
......@@ -49,7 +49,6 @@ jade_empty_fifo(struct BCState *bcs, int count)
{
u_char *ptr;
struct IsdnCardState *cs = bcs->cs;
unsigned long flags;
if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
debugl1(cs, "jade_empty_fifo");
......@@ -63,10 +62,8 @@ jade_empty_fifo(struct BCState *bcs, int count)
}
ptr = bcs->hw.hscx.rcvbuf + bcs->hw.hscx.rcvidx;
bcs->hw.hscx.rcvidx += count;
spin_lock_irqsave(&jade_irq_lock, flags);
READJADEFIFO(cs, bcs->hw.hscx.hscx, ptr, count);
WriteJADECMDR(cs, bcs->hw.hscx.hscx, jade_HDLC_RCMD, jadeRCMD_RMC);
spin_unlock_irqrestore(&jade_irq_lock, flags);
if (cs->debug & L1_DEB_HSCX_FIFO) {
char *t = bcs->blog;
......@@ -83,41 +80,17 @@ jade_fill_fifo(struct BCState *bcs)
struct IsdnCardState *cs = bcs->cs;
int more, count;
int fifo_size = 32;
u_char *ptr;
unsigned long flags;
int hscx = bcs->hw.hscx.hscx;
unsigned char *p;
if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
debugl1(cs, "jade_fill_fifo");
if (!bcs->tx_skb)
p = xmit_fill_fifo_b(bcs, fifo_size, &count, &more);
if (!p)
return;
if (bcs->tx_skb->len <= 0)
return;
more = (bcs->mode == L1_MODE_TRANS) ? 1 : 0;
if (bcs->tx_skb->len > fifo_size) {
more = !0;
count = fifo_size;
} else
count = bcs->tx_skb->len;
waitforXFW(cs, bcs->hw.hscx.hscx);
spin_lock_irqsave(&jade_irq_lock, flags);
ptr = bcs->tx_skb->data;
skb_pull(bcs->tx_skb, count);
bcs->tx_cnt -= 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);
if (cs->debug & L1_DEB_HSCX_FIFO) {
char *t = bcs->blog;
t += sprintf(t, "jade_fill_fifo %c cnt %d",
bcs->hw.hscx.hscx ? 'B' : 'A', count);
QuickHex(t, ptr, count);
debugl1(cs, bcs->blog);
}
waitforXFW(cs, hscx);
WRITEJADEFIFO(cs, hscx, p, count);
WriteJADECMDR(cs, hscx, jade_HDLC_XCMD,
more ? jadeXCMD_XF : (jadeXCMD_XF|jadeXCMD_XME));
}
......
......@@ -245,37 +245,14 @@ W6692B_fill_fifo(struct BCState *bcs)
{
struct IsdnCardState *cs = bcs->cs;
int more, count;
u_char *ptr;
if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
debugl1(cs, "W6692B_fill_fifo");
unsigned char *p;
if (!bcs->tx_skb)
return;
if (bcs->tx_skb->len <= 0)
p = xmit_fill_fifo_b(bcs, W_B_FIFO_THRESH, &count, &more);
if (!p)
return;
more = (bcs->mode == L1_MODE_TRANS) ? 1 : 0;
if (bcs->tx_skb->len > W_B_FIFO_THRESH) {
more = !0;
count = W_B_FIFO_THRESH;
} else
count = bcs->tx_skb->len;
ptr = bcs->tx_skb->data;
skb_pull(bcs->tx_skb, count);
bcs->tx_cnt -= count;
bcs->count += count;
WRITEW6692BFIFO(cs, bcs->channel, ptr, count);
WRITEW6692BFIFO(cs, bcs->channel, p, 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));
if (cs->debug & L1_DEB_HSCX_FIFO) {
char *t = bcs->blog;
t += sprintf(t, "W6692B_fill_fifo %c cnt %d",
bcs->channel + '1', count);
QuickHex(t, ptr, count);
debugl1(cs, bcs->blog);
}
}
static void
......
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