Commit 9abd1799 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN/HiSax: Share D-Channel PH_PULL code

More duplicated code gone.

Also, remove the unused skb argument from xmit_pull_req_b().
parent 68ace479
......@@ -470,7 +470,7 @@ hdlc_l2l1(struct PStack *st, int pr, void *arg)
xmit_pull_ind_b(st->l1.bcs, skb);
break;
case (PH_PULL | REQUEST):
xmit_pull_req_b(st, skb);
xmit_pull_req_b(st);
break;
case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
......@@ -506,7 +506,7 @@ hfc_l2l1(struct PStack *st, int pr, void *arg)
xmit_pull_ind_b(st->l1.bcs, skb);
break;
case (PH_PULL | REQUEST):
xmit_pull_req_b(st, skb);
xmit_pull_req_b(st);
break;
case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......@@ -940,39 +940,11 @@ HFCD_l1hw(struct PStack *st, int pr, void *arg)
case (PH_DATA | REQUEST):
xmit_data_req_d(cs, skb);
break;
case (PH_PULL | INDICATION):
if (cs->tx_skb) {
if (cs->debug & L1_DEB_WARN)
debugl1(cs, " l2l1 tx_skb exist this shouldn't happen");
skb_queue_tail(&cs->sq, skb);
break;
}
if (cs->debug & DEB_DLOG_HEX)
LogFrame(cs, skb->data, skb->len);
if (cs->debug & DEB_DLOG_VERBOSE)
dlogframe(cs, skb, 0);
cs->tx_skb = skb;
cs->tx_cnt = 0;
#ifdef L2FRAME_DEBUG /* psa */
if (cs->debug & L1_DEB_LAPD)
Logl2Frame(cs, skb, "PH_DATA_PULLED", 0);
#endif
if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
hfc_fill_dfifo(cs);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
} else
debugl1(cs, "hfc_fill_dfifo blocked");
case (PH_PULL |INDICATION):
xmit_pull_ind_d(cs, skb);
break;
case (PH_PULL | REQUEST):
#ifdef L2FRAME_DEBUG /* psa */
if (cs->debug & L1_DEB_LAPD)
debugl1(cs, "-> PH_REQUEST_PULL");
#endif
if (!cs->tx_skb) {
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
xmit_pull_req_d(st);
break;
case (HW_RESET | REQUEST):
cs->writeisac(cs, HFCD_STATES, HFCD_LOAD_STATE | 3); /* HFC ST 3 */
......
......@@ -474,7 +474,7 @@ hfc_l2l1(struct PStack *st, int pr, void *arg)
xmit_pull_ind_b(st->l1.bcs, skb);
break;
case (PH_PULL | REQUEST):
xmit_pull_req_b(st, skb);
xmit_pull_req_b(st);
break;
case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
......@@ -1343,7 +1343,7 @@ hfcpci_l2l1(struct PStack *st, int pr, void *arg)
xmit_pull_ind_b(st->l1.bcs, skb);
break;
case (PH_PULL | REQUEST):
xmit_pull_req_b(st, skb);
xmit_pull_req_b(st);
break;
case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
......@@ -884,39 +884,11 @@ HFCSX_l1hw(struct PStack *st, int pr, void *arg)
case (PH_DATA | REQUEST):
xmit_data_req_d(cs, skb);
break;
case (PH_PULL | INDICATION):
if (cs->tx_skb) {
if (cs->debug & L1_DEB_WARN)
debugl1(cs, " l2l1 tx_skb exist this shouldn't happen");
skb_queue_tail(&cs->sq, skb);
break;
}
if (cs->debug & DEB_DLOG_HEX)
LogFrame(cs, skb->data, skb->len);
if (cs->debug & DEB_DLOG_VERBOSE)
dlogframe(cs, skb, 0);
cs->tx_skb = skb;
cs->tx_cnt = 0;
#ifdef L2FRAME_DEBUG /* psa */
if (cs->debug & L1_DEB_LAPD)
Logl2Frame(cs, skb, "PH_DATA_PULLED", 0);
#endif
if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
hfcsx_fill_dfifo(cs);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
} else
debugl1(cs, "hfcsx_fill_dfifo blocked");
case (PH_PULL |INDICATION):
xmit_pull_ind_d(cs, skb);
break;
case (PH_PULL | REQUEST):
#ifdef L2FRAME_DEBUG /* psa */
if (cs->debug & L1_DEB_LAPD)
debugl1(cs, "-> PH_REQUEST_PULL");
#endif
if (!cs->tx_skb) {
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
xmit_pull_req_d(st);
break;
case (HW_RESET | REQUEST):
Write_hfc(cs, HFCSX_STATES, HFCSX_LOAD_STATE | 3); /* HFC ST 3 */
......@@ -1132,7 +1104,7 @@ hfcsx_l2l1(struct PStack *st, int pr, void *arg)
xmit_pull_ind_b(st->l1.bcs, skb);
break;
case (PH_PULL | REQUEST):
xmit_pull_req_b(st, skb);
xmit_pull_req_b(st);
break;
case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
......@@ -104,7 +104,7 @@ hscx_l2l1(struct PStack *st, int pr, void *arg)
xmit_pull_ind_b(st->l1.bcs, skb);
break;
case (PH_PULL | REQUEST):
xmit_pull_req_b(st, skb);
xmit_pull_req_b(st);
break;
case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
......@@ -397,34 +397,10 @@ ICC_l1hw(struct PStack *st, int pr, void *arg)
xmit_data_req_d(cs, skb);
break;
case (PH_PULL |INDICATION):
if (cs->tx_skb) {
if (cs->debug & L1_DEB_WARN)
debugl1(cs, " l2l1 tx_skb exist this shouldn't happen");
skb_queue_tail(&cs->sq, skb);
break;
}
if (cs->debug & DEB_DLOG_HEX)
LogFrame(cs, skb->data, skb->len);
if (cs->debug & DEB_DLOG_VERBOSE)
dlogframe(cs, skb, 0);
cs->tx_skb = skb;
cs->tx_cnt = 0;
#ifdef L2FRAME_DEBUG /* psa */
if (cs->debug & L1_DEB_LAPD)
Logl2Frame(cs, skb, "PH_DATA_PULLED", 0);
#endif
icc_fill_fifo(cs);
xmit_pull_ind_d(cs, skb);
break;
case (PH_PULL | REQUEST):
#ifdef L2FRAME_DEBUG /* psa */
if (cs->debug & L1_DEB_LAPD)
debugl1(cs, "-> PH_REQUEST_PULL");
#endif
if (!cs->tx_skb) {
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
xmit_pull_req_d(st);
break;
case (HW_RESET | REQUEST):
if ((cs->dc.icc.ph_state == ICC_IND_EI1) ||
......
......@@ -98,33 +98,11 @@ dch_l2l1(struct PStack *st, int pr, void *arg)
xmit_data_req_d(cs, skb);
break;
case (PH_PULL |INDICATION):
if (cs->tx_skb) {
if (cs->debug & L1_DEB_WARN)
debugl1(cs, " l2l1 tx_skb exist this shouldn't happen");
skb_queue_tail(&cs->sq, skb);
break;
}
if (cs->debug & DEB_DLOG_HEX) LogFrame(cs, skb->data, skb->len);
if (cs->debug & DEB_DLOG_VERBOSE) dlogframe(cs, skb, 0);
cs->tx_skb = skb;
cs->tx_cnt = 0;
#ifdef L2FRAME_DEBUG
if (cs->debug & L1_DEB_LAPD) Logl2Frame(cs, skb, "PH_DATA_PULLED", 0);
#endif
dch_fill_fifo(cs);
xmit_pull_ind_d(cs, skb);
break;
case (PH_PULL | REQUEST):
#ifdef L2FRAME_DEBUG
if (cs->debug & L1_DEB_LAPD) debugl1(cs, "-> PH_REQUEST_PULL");
#endif
if (!cs->tx_skb) {
clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
st->l2.l1l2(st, PH_PULL | CONFIRM, NULL);
} else
set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
xmit_pull_req_d(st);
break;
case (HW_RESET | REQUEST):
case (HW_ENABLE | REQUEST):
ph_command(cs, IPACX_CMD_TIM);
......@@ -459,7 +437,7 @@ bch_l2l1(struct PStack *st, int pr, void *arg)
xmit_pull_ind_b(st->l1.bcs, skb);
break;
case (PH_PULL | REQUEST):
xmit_pull_req_b(st, skb);
xmit_pull_req_b(st);
break;
case (PH_ACTIVATE | REQUEST):
set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
......@@ -391,34 +391,10 @@ ISAC_l1hw(struct PStack *st, int pr, void *arg)
xmit_data_req_d(cs, skb);
break;
case (PH_PULL |INDICATION):
if (cs->tx_skb) {
if (cs->debug & L1_DEB_WARN)
debugl1(cs, " l2l1 tx_skb exist this shouldn't happen");
skb_queue_tail(&cs->sq, skb);
break;
}
if (cs->debug & DEB_DLOG_HEX)
LogFrame(cs, skb->data, skb->len);
if (cs->debug & DEB_DLOG_VERBOSE)
dlogframe(cs, skb, 0);
cs->tx_skb = skb;
cs->tx_cnt = 0;
#ifdef L2FRAME_DEBUG /* psa */
if (cs->debug & L1_DEB_LAPD)
Logl2Frame(cs, skb, "PH_DATA_PULLED", 0);
#endif
isac_fill_fifo(cs);
xmit_pull_ind_d(cs, skb);
break;
case (PH_PULL | REQUEST):
#ifdef L2FRAME_DEBUG /* psa */
if (cs->debug & L1_DEB_LAPD)
debugl1(cs, "-> PH_REQUEST_PULL");
#endif
if (!cs->tx_skb) {
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
xmit_pull_req_d(st);
break;
case (HW_RESET | REQUEST):
if ((cs->dc.isac.ph_state == ISAC_IND_EI) ||
......
......@@ -1550,7 +1550,7 @@ isar_l2l1(struct PStack *st, int pr, void *arg)
xmit_pull_ind_b(st->l1.bcs, skb);
break;
case (PH_PULL | REQUEST):
xmit_pull_req_b(st, skb);
xmit_pull_req_b(st);
break;
case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
......@@ -158,10 +158,34 @@ xmit_pull_ind_b(struct BCState *bcs, struct sk_buff *skb)
spin_unlock_irqrestore(&cs->lock, flags);
}
static inline void
xmit_pull_ind_d(struct IsdnCardState *cs, struct sk_buff *skb)
{
unsigned long flags;
spin_lock_irqsave(&cs->lock, flags);
if (cs->tx_skb) {
WARN_ON(1);
} else {
if (cs->debug & DEB_DLOG_HEX)
LogFrame(cs, skb->data, skb->len);
if (cs->debug & DEB_DLOG_VERBOSE)
dlogframe(cs, skb, 0);
#ifdef L2FRAME_DEBUG
if (cs->debug & L1_DEB_LAPD)
Logl2Frame(cs, skb, "PH_DATA_PULLED", 0);
#endif
cs->tx_skb = skb;
cs->tx_cnt = 0;
cs->DC_Send_Data(cs);
}
spin_unlock_irqrestore(&cs->lock, flags);
}
/* If busy, the PH_PULL | CONFIRM scheduling is handled under
* the card lock by xmit_ready_b() above, so no race */
static inline void
xmit_pull_req_b(struct PStack *st, struct sk_buff *skb)
xmit_pull_req_b(struct PStack *st)
{
struct BCState *bcs = st->l1.bcs;
struct IsdnCardState *cs = bcs->cs;
......@@ -178,6 +202,29 @@ xmit_pull_req_b(struct PStack *st, struct sk_buff *skb)
L1L2(st, PH_PULL | CONFIRM, NULL);
}
/* If busy, the PH_PULL | CONFIRM scheduling is handled under
* the card lock by xmit_ready_d() above, so no race */
static inline void
xmit_pull_req_d(struct PStack *st)
{
struct IsdnCardState *cs = st->l1.hardware;
unsigned long flags;
int busy = 0;
#ifdef L2FRAME_DEBUG
if (cs->debug & L1_DEB_LAPD)
debugl1(cs, "-> PH_REQUEST_PULL");
#endif
spin_lock_irqsave(&cs->lock, flags);
if (cs->tx_skb) {
set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
busy = 1;
}
spin_unlock_irqrestore(&cs->lock, flags);
if (!busy)
L1L2(st, PH_PULL | CONFIRM, NULL);
}
/* called with the card lock held */
static inline void
xmit_restart_b(struct BCState *bcs)
......
......@@ -147,7 +147,7 @@ jade_l2l1(struct PStack *st, int pr, void *arg)
xmit_pull_ind_b(st->l1.bcs, skb);
break;
case (PH_PULL | REQUEST):
xmit_pull_req_b(st, skb);
xmit_pull_req_b(st);
break;
case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
......@@ -841,7 +841,7 @@ tiger_l2l1(struct PStack *st, int pr, void *arg)
xmit_pull_ind_b(st->l1.bcs, skb);
break;
case (PH_PULL | REQUEST):
xmit_pull_req_b(st, skb);
xmit_pull_req_b(st);
break;
case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
......@@ -434,35 +434,11 @@ W6692_l1hw(struct PStack *st, int pr, void *arg)
case (PH_DATA | REQUEST):
xmit_data_req_d(cs, skb);
break;
case (PH_PULL | INDICATION):
if (cs->tx_skb) {
if (cs->debug & L1_DEB_WARN)
debugl1(cs, " l2l1 tx_skb exist this shouldn't happen");
skb_queue_tail(&cs->sq, skb);
break;
}
if (cs->debug & DEB_DLOG_HEX)
LogFrame(cs, skb->data, skb->len);
if (cs->debug & DEB_DLOG_VERBOSE)
dlogframe(cs, skb, 0);
cs->tx_skb = skb;
cs->tx_cnt = 0;
#ifdef L2FRAME_DEBUG /* psa */
if (cs->debug & L1_DEB_LAPD)
Logl2Frame(cs, skb, "PH_DATA_PULLED", 0);
#endif
W6692_fill_fifo(cs);
case (PH_PULL |INDICATION):
xmit_pull_ind_d(cs, skb);
break;
case (PH_PULL | REQUEST):
#ifdef L2FRAME_DEBUG /* psa */
if (cs->debug & L1_DEB_LAPD)
debugl1(cs, "-> PH_REQUEST_PULL");
#endif
if (!cs->tx_skb) {
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
xmit_pull_req_d(st);
break;
case (HW_RESET | REQUEST):
if ((cs->dc.w6692.ph_state == W_L1IND_DRD))
......@@ -597,7 +573,7 @@ W6692_l2l1(struct PStack *st, int pr, void *arg)
xmit_pull_ind_b(st->l1.bcs, skb);
break;
case (PH_PULL | REQUEST):
xmit_pull_req_b(st, skb);
xmit_pull_req_b(st);
break;
case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
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