Commit c2d10f68 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN/HiSax: Shared xmit_fill_fifo() for D-Channel.

Now repeat the steps of unifying the xmit path for B-Channels for
D-Channel handling. Parts of xmit_fill_fifo() can easily be shared.
parent f496c9bb
......@@ -146,29 +146,15 @@ static void
icc_fill_fifo(struct IsdnCardState *cs)
{
int count, more;
u_char *ptr;
unsigned char *p;
unsigned long flags;
if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO))
debugl1(cs, "icc_fill_fifo");
if (!cs->tx_skb)
p = xmit_fill_fifo_d(cs, 32, &count, &more);
if (!p)
return;
count = cs->tx_skb->len;
if (count <= 0)
return;
more = 0;
if (count > 32) {
more = !0;
count = 32;
}
spin_lock_irqsave(&icc_lock, flags);
ptr = cs->tx_skb->data;
skb_pull(cs->tx_skb, count);
cs->tx_cnt += count;
cs->writeisacfifo(cs, ptr, count);
cs->writeisacfifo(cs, p, count);
cs->writeisac(cs, ICC_CMDR, more ? 0x8 : 0xa);
if (test_and_set_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) {
debugl1(cs, "icc_fill_fifo dbusytimer running");
......@@ -178,13 +164,6 @@ icc_fill_fifo(struct IsdnCardState *cs)
cs->dbusytimer.expires = jiffies + ((DBUSY_TIMER_VALUE * HZ)/1000);
add_timer(&cs->dbusytimer);
spin_unlock_irqrestore(&icc_lock, flags);
if (cs->debug & L1_DEB_ISAC_FIFO) {
char *t = cs->dlog;
t += sprintf(t, "icc_fill_fifo cnt %d", count);
QuickHex(t, ptr, count);
debugl1(cs, cs->dlog);
}
}
void
......
......@@ -347,27 +347,20 @@ dch_empty_fifo(struct IsdnCardState *cs, int count)
static void
dch_fill_fifo(struct IsdnCardState *cs)
{
int count;
u_char cmd, *ptr;
int count, more;
unsigned char cmd, *p;
if ((cs->debug &L1_DEB_ISAC) && !(cs->debug &L1_DEB_ISAC_FIFO))
debugl1(cs, "dch_fill_fifo()");
if (!cs->tx_skb) return;
count = cs->tx_skb->len;
if (count <= 0) return;
if (count > D_FIFO_SIZE) {
count = D_FIFO_SIZE;
p = xmit_fill_fifo_d(cs, 32, &count, &more);
if (!p)
return;
if (more) {
cmd = 0x08; // XTF
} else {
cmd = 0x0A; // XTF | XME
}
ptr = cs->tx_skb->data;
skb_pull(cs->tx_skb, count);
cs->tx_cnt += count;
cs->writeisacfifo(cs, ptr, count);
cs->writeisacfifo(cs, p, count);
cs->writeisac(cs, IPACX_CMDRD, cmd);
// set timeout for transmission contol
......@@ -378,14 +371,6 @@ dch_fill_fifo(struct IsdnCardState *cs)
init_timer(&cs->dbusytimer);
cs->dbusytimer.expires = jiffies + ((DBUSY_TIMER_VALUE * HZ)/1000);
add_timer(&cs->dbusytimer);
if (cs->debug &L1_DEB_ISAC_FIFO) {
char *t = cs->dlog;
t += sprintf(t, "dch_fill_fifo() cnt %d", count);
QuickHex(t, ptr, count);
debugl1(cs, cs->dlog);
}
}
//----------------------------------------------------------
......
......@@ -150,29 +150,15 @@ static void
isac_fill_fifo(struct IsdnCardState *cs)
{
int count, more;
u_char *ptr;
unsigned char *p;
unsigned long flags;
if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO))
debugl1(cs, "isac_fill_fifo");
if (!cs->tx_skb)
p = xmit_fill_fifo_d(cs, 32, &count, &more);
if (!p)
return;
count = cs->tx_skb->len;
if (count <= 0)
return;
more = 0;
if (count > 32) {
more = !0;
count = 32;
}
spin_lock_irqsave(&isac_lock, flags);
ptr = cs->tx_skb->data;
skb_pull(cs->tx_skb, count);
cs->tx_cnt += count;
cs->writeisacfifo(cs, ptr, count);
cs->writeisacfifo(cs, p, count);
cs->writeisac(cs, ISAC_CMDR, more ? 0x8 : 0xa);
if (test_and_set_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) {
debugl1(cs, "isac_fill_fifo dbusytimer running");
......@@ -182,13 +168,6 @@ isac_fill_fifo(struct IsdnCardState *cs)
cs->dbusytimer.expires = jiffies + ((DBUSY_TIMER_VALUE * HZ)/1000);
add_timer(&cs->dbusytimer);
spin_unlock_irqrestore(&isac_lock, flags);
if (cs->debug & L1_DEB_ISAC_FIFO) {
char *t = cs->dlog;
t += sprintf(t, "isac_fill_fifo cnt %d", count);
QuickHex(t, ptr, count);
debugl1(cs, cs->dlog);
}
}
void
......
......@@ -181,6 +181,7 @@ static inline unsigned char *
xmit_fill_fifo_b(struct BCState *bcs, int fifo_size, int *count, int *more)
{
struct IsdnCardState *cs = bcs->cs;
unsigned char *p;
if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
debugl1(cs, __FUNCTION__);
......@@ -197,6 +198,7 @@ xmit_fill_fifo_b(struct BCState *bcs, int fifo_size, int *count, int *more)
} else {
*count = bcs->tx_skb->len;
}
p = bcs->tx_skb->data;
skb_pull(bcs->tx_skb, *count);
bcs->tx_cnt -= *count;
bcs->count += *count;
......@@ -206,8 +208,43 @@ xmit_fill_fifo_b(struct BCState *bcs, int fifo_size, int *count, int *more)
t += sprintf(t, "%s %c cnt %d", __FUNCTION__,
bcs->hw.hscx.hscx ? 'B' : 'A', *count);
QuickHex(t, bcs->tx_skb->data, *count);
QuickHex(t, p, *count);
debugl1(cs, bcs->blog);
}
return bcs->tx_skb->data;
return p;
}
static inline unsigned char *
xmit_fill_fifo_d(struct IsdnCardState *cs, int fifo_size, int *count, int *more)
{
unsigned char *p;
if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO))
debugl1(cs, __FUNCTION__);
if (!cs->tx_skb || cs->tx_skb->len <= 0) {
WARN_ON(1);
return NULL;
}
*more = 0;
if (cs->tx_skb->len > fifo_size) {
*more = 1;
*count = fifo_size;
} else {
*count = cs->tx_skb->len;
}
p = cs->tx_skb->data;
skb_pull(cs->tx_skb, *count);
cs->tx_cnt += *count;
if (cs->debug & L1_DEB_ISAC_FIFO) {
char *t = cs->dlog;
t += sprintf(t, "%s cnt %d", __FUNCTION__, *count);
QuickHex(t, p, *count);
debugl1(cs, cs->dlog);
}
return p;
}
......@@ -172,27 +172,13 @@ static void
W6692_fill_fifo(struct IsdnCardState *cs)
{
int count, more;
u_char *ptr;
if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO))
debugl1(cs, "W6692_fill_fifo");
if (!cs->tx_skb)
return;
unsigned char *p;
count = cs->tx_skb->len;
if (count <= 0)
p = xmit_fill_fifo_d(cs, W_D_FIFO_THRESH, &count, &more);
if (!p)
return;
more = 0;
if (count > W_D_FIFO_THRESH) {
more = !0;
count = W_D_FIFO_THRESH;
}
ptr = cs->tx_skb->data;
skb_pull(cs->tx_skb, count);
cs->tx_cnt += count;
cs->writeW6692fifo(cs, ptr, count);
cs->writeW6692fifo(cs, p, count);
cs->writeW6692(cs, W_D_CMDR, more ? W_D_CMDR_XMS : (W_D_CMDR_XMS | W_D_CMDR_XME));
if (test_and_set_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) {
debugl1(cs, "W6692_fill_fifo dbusytimer running");
......@@ -201,13 +187,6 @@ W6692_fill_fifo(struct IsdnCardState *cs)
init_timer(&cs->dbusytimer);
cs->dbusytimer.expires = jiffies + ((DBUSY_TIMER_VALUE * HZ) / 1000);
add_timer(&cs->dbusytimer);
if (cs->debug & L1_DEB_ISAC_FIFO) {
char *t = cs->dlog;
t += sprintf(t, "W6692_fill_fifo cnt %d", count);
QuickHex(t, ptr, count);
debugl1(cs, cs->dlog);
}
}
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