28 #define TIMER3_VALUE 7000
30 static struct Fsm l1fsm_b;
31 static struct Fsm l1fsm_s;
43 #define L1S_STATE_COUNT (ST_L1_F8 + 1)
45 static char *strL1SState[] =
56 #ifdef HISAX_UINTERFACE
68 #define L1U_STATE_COUNT (ST_L1_TRANS + 1)
70 static char *strL1UState[] =
86 #define L1B_STATE_COUNT (ST_L1_ACTIV + 1)
88 static char *strL1BState[] =
111 #define L1_EVENT_COUNT (EV_TIMER3 + 1)
113 static char *strL1Event[] =
136 sprintf(tmp,
"Card%d ", cs->cardnr + 1);
146 struct IsdnCardState *
cs = st->l1.hardware;
150 sprintf(tmp,
"Card%d ", cs->cardnr + 1);
156 L1activated(
struct IsdnCardState *
cs)
171 L1deactivated(
struct IsdnCardState *cs)
177 if (
test_bit(FLG_L1_DBUSY, &cs->HW_Flags))
188 struct PStack *stptr;
194 while (stptr !=
NULL) {
207 struct PStack *stptr = cs->stlist;
208 int found, tei, sapi;
215 if (cs->debug & L1_DEB_LAPD)
220 debugl1(cs,
"D-channel frame too short(%d)", skb->
len);
224 if ((skb->
data[0] & 1) || !(skb->
data[1] & 1)) {
225 debugl1(cs,
"D-channel frame wrong EA0/EA1");
229 sapi = skb->
data[0] >> 2;
230 tei = skb->
data[1] >> 1;
231 if (cs->debug & DEB_DLOG_HEX)
233 if (cs->debug & DEB_DLOG_VERBOSE)
237 while (stptr !=
NULL) {
245 while (stptr !=
NULL) {
256 while (stptr !=
NULL)
257 if (tei == stptr->l2.tei) {
271 BChannel_proc_xmt(
struct BCState *bcs)
273 struct PStack *st = bcs->st;
275 if (
test_bit(BC_FLG_BUSY, &bcs->Flag)) {
276 debugl1(bcs->cs,
"BC_BUSY Error");
282 if (!
test_bit(BC_FLG_ACTIV, &bcs->Flag)) {
283 if (!
test_bit(BC_FLG_BUSY, &bcs->Flag) &&
284 skb_queue_empty(&bcs->squeue)) {
291 BChannel_proc_rcv(
struct BCState *bcs)
305 BChannel_proc_ack(
struct BCState *bcs)
313 spin_unlock_irqrestore(&bcs->aclock, flags);
321 struct BCState *bcs =
container_of(work,
struct BCState, tqueue);
326 BChannel_proc_rcv(bcs);
328 BChannel_proc_xmt(bcs);
330 BChannel_proc_ack(bcs);
337 st->next = cs->stlist;
348 if (cs->stlist == st)
349 cs->stlist = st->next;
364 struct BCState *bcs = cs->bcs +
bc;
370 bcs->BC_SetStack =
NULL;
371 bcs->BC_Close =
NULL;
380 switch (cmd & ~0x10) {
405 return "invalid command";
409 static char tmpdeb[32];
414 switch (ptr[2] & ~0x10) {
418 sprintf(tmpdeb,
"%s[%d](nr %d)", l2cmd(ptr[2]), ptr[3] & 1, ptr[3] >> 1);
427 sprintf(tmpdeb,
"%s[%d]", l2cmd(ptr[2]), (ptr[2] & 0x10) >> 4);
431 sprintf(tmpdeb,
"I[%d](ns %d, nr %d)", ptr[3] & 1, ptr[2] >> 1, ptr[3] >> 1);
434 return "invalid command";
448 if (ptr[0] & 1 || !(ptr[1] & 1))
449 debugl1(cs,
"Address not LAPD");
451 debugl1(cs,
"%s %s: %s%c (sapi %d, tei %d)",
452 (dir ?
"<-" :
"->"), buf, l2frames(ptr),
453 ((ptr[0] & 2) >> 1) == dir ?
'C' :
'R', ptr[0] >> 2, ptr[1] >> 1);
474 l1_deact_req_s(
struct FsmInst *fi,
int event,
void *arg)
484 l1_power_up_s(
struct FsmInst *fi,
int event,
void *arg)
498 l1_go_F5(
struct FsmInst *fi,
int event,
void *arg)
504 l1_go_F8(
struct FsmInst *fi,
int event,
void *arg)
510 l1_info2_ind(
struct FsmInst *fi,
int event,
void *arg)
514 #ifdef HISAX_UINTERFACE
524 l1_info4_ind(
struct FsmInst *fi,
int event,
void *arg)
528 #ifdef HISAX_UINTERFACE
546 l1_timer3(
struct FsmInst *fi,
int event,
void *arg)
552 L1deactivated(st->l1.hardware);
554 #ifdef HISAX_UINTERFACE
564 l1_timer_act(
struct FsmInst *fi,
int event,
void *arg)
570 L1activated(st->l1.hardware);
574 l1_timer_deact(
struct FsmInst *fi,
int event,
void *arg)
580 L1deactivated(st->l1.hardware);
585 l1_activate_s(
struct FsmInst *fi,
int event,
void *arg)
593 l1_activate_no(
struct FsmInst *fi,
int event,
void *arg)
599 L1deactivated(st->l1.hardware);
651 #ifdef HISAX_UINTERFACE
653 l1_deact_req_u(
struct FsmInst *fi,
int event,
void *arg)
664 l1_power_up_u(
struct FsmInst *fi,
int event,
void *arg)
673 l1_info0_ind(
struct FsmInst *fi,
int event,
void *arg)
679 l1_activate_u(
struct FsmInst *fi,
int event,
void *arg)
686 static struct FsmNode L1UFnList[] __initdata =
711 l1b_activate(
struct FsmInst *fi,
int event,
void *arg)
720 l1b_deactivate(
struct FsmInst *fi,
int event,
void *arg)
729 l1b_timer_act(
struct FsmInst *fi,
int event,
void *arg)
738 l1b_timer_deact(
struct FsmInst *fi,
int event,
void *arg)
746 static struct FsmNode L1BFnList[] __initdata =
761 l1fsm_s.strEvent = strL1Event;
762 l1fsm_s.strState = strL1SState;
769 l1fsm_b.strEvent = strL1Event;
770 l1fsm_b.strState = strL1BState;
776 #ifdef HISAX_UINTERFACE
793 #ifdef HISAX_UINTERFACE
801 dch_l2l1(
struct PStack *st,
int pr,
void *arg)
803 struct IsdnCardState *cs = (
struct IsdnCardState *) st->l1.hardware;
809 st->l1.l1hw(st, pr, arg);
813 debugl1(cs,
"PH_ACTIVATE_REQ %s",
814 st->l1.l1m.fsm->strState[st->l1.l1m.state]);
824 debugl1(cs,
"PH_TEST_LOOP B1");
826 debugl1(cs,
"PH_TEST_LOOP B2");
827 if (!(3 & (
long) arg))
828 debugl1(cs,
"PH_TEST_LOOP DISABLED");
833 debugl1(cs,
"dch_l2l1 msg %04X unhandled", pr);
839 l1_msg(
struct IsdnCardState *cs,
int pr,
void *arg) {
870 debugl1(cs,
"l1msg %04X unhandled", pr);
892 st->l1.hardware =
cs;
893 st->protocol = cs->protocol;
894 st->l1.l1m.fsm = &l1fsm_s;
897 #ifdef HISAX_UINTERFACE
898 if (
test_bit(FLG_HW_L1_UINT, &cs->HW_Flags)) {
899 st->l1.l1m.fsm = &l1fsm_u;
904 st->l1.l1m.debug = cs->debug;
905 st->l1.l1m.userdata =
st;
906 st->l1.l1m.userint = 0;
907 st->l1.l1m.printdebug = l1m_debug;
911 st->l1.stlistp = &(cs->stlist);
912 st->l2.l2l1 = dch_l2l1;
914 cs->setstack_d(st, cs);
920 struct IsdnCardState *cs = st->l1.hardware;
922 st->l1.l1m.fsm = &l1fsm_b;
924 st->l1.l1m.debug = cs->debug;
925 st->l1.l1m.userdata =
st;
926 st->l1.l1m.userint = 0;
927 st->l1.l1m.printdebug = l1m_debug;