Lines Matching refs:l2

101 	struct layer2 *l2 = fi->userdata;  in l2m_debug()  local
114 mISDNDevName4ch(&l2->ch), l2->sapi, l2->tei, &vaf); in l2m_debug()
120 l2headersize(struct layer2 *l2, int ui) in l2headersize() argument
122 return ((test_bit(FLG_MOD128, &l2->flag) && (!ui)) ? 2 : 1) + in l2headersize()
123 (test_bit(FLG_LAPD, &l2->flag) ? 2 : 1); in l2headersize()
127 l2addrsize(struct layer2 *l2) in l2addrsize() argument
129 return test_bit(FLG_LAPD, &l2->flag) ? 2 : 1; in l2addrsize()
133 l2_newid(struct layer2 *l2) in l2_newid() argument
137 id = l2->next_id++; in l2_newid()
139 l2->next_id = 1; in l2_newid()
141 id |= l2->tei << 8; in l2_newid()
142 id |= l2->sapi; in l2_newid()
147 l2up(struct layer2 *l2, u_int prim, struct sk_buff *skb) in l2up() argument
151 if (!l2->up) in l2up()
154 mISDN_HEAD_ID(skb) = (l2->ch.nr << 16) | l2->ch.addr; in l2up()
155 err = l2->up->send(l2->up, skb); in l2up()
158 mISDNDevName4ch(&l2->ch), err); in l2up()
164 l2up_create(struct layer2 *l2, u_int prim, int len, void *arg) in l2up_create() argument
170 if (!l2->up) in l2up_create()
177 hh->id = (l2->ch.nr << 16) | l2->ch.addr; in l2up_create()
180 err = l2->up->send(l2->up, skb); in l2up_create()
183 mISDNDevName4ch(&l2->ch), err); in l2up_create()
189 l2down_skb(struct layer2 *l2, struct sk_buff *skb) { in l2down_skb() argument
192 ret = l2->ch.recv(l2->ch.peer, skb); in l2down_skb()
195 mISDNDevName4ch(&l2->ch), ret); in l2down_skb()
200 l2down_raw(struct layer2 *l2, struct sk_buff *skb) in l2down_raw() argument
205 if (test_and_set_bit(FLG_L1_NOTREADY, &l2->flag)) { in l2down_raw()
206 skb_queue_tail(&l2->down_queue, skb); in l2down_raw()
209 l2->down_id = mISDN_HEAD_ID(skb); in l2down_raw()
211 return l2down_skb(l2, skb); in l2down_raw()
215 l2down(struct layer2 *l2, u_int prim, u_int id, struct sk_buff *skb) in l2down() argument
221 return l2down_raw(l2, skb); in l2down()
225 l2down_create(struct layer2 *l2, u_int prim, u_int id, int len, void *arg) in l2down_create() argument
239 err = l2down_raw(l2, skb); in l2down_create()
246 ph_data_confirm(struct layer2 *l2, struct mISDNhead *hh, struct sk_buff *skb) { in ph_data_confirm() argument
250 if (test_bit(FLG_L1_NOTREADY, &l2->flag)) { in ph_data_confirm()
251 if (hh->id == l2->down_id) { in ph_data_confirm()
252 nskb = skb_dequeue(&l2->down_queue); in ph_data_confirm()
254 l2->down_id = mISDN_HEAD_ID(nskb); in ph_data_confirm()
255 if (l2down_skb(l2, nskb)) { in ph_data_confirm()
257 l2->down_id = MISDN_ID_NONE; in ph_data_confirm()
260 l2->down_id = MISDN_ID_NONE; in ph_data_confirm()
265 if (l2->down_id == MISDN_ID_NONE) { in ph_data_confirm()
266 test_and_clear_bit(FLG_L1_NOTREADY, &l2->flag); in ph_data_confirm()
267 mISDN_FsmEvent(&l2->l2m, EV_L2_ACK_PULL, NULL); in ph_data_confirm()
271 if (!test_and_set_bit(FLG_L1_NOTREADY, &l2->flag)) { in ph_data_confirm()
272 nskb = skb_dequeue(&l2->down_queue); in ph_data_confirm()
274 l2->down_id = mISDN_HEAD_ID(nskb); in ph_data_confirm()
275 if (l2down_skb(l2, nskb)) { in ph_data_confirm()
277 l2->down_id = MISDN_ID_NONE; in ph_data_confirm()
278 test_and_clear_bit(FLG_L1_NOTREADY, &l2->flag); in ph_data_confirm()
281 test_and_clear_bit(FLG_L1_NOTREADY, &l2->flag); in ph_data_confirm()
289 struct layer2 *l2 = fi->userdata; in l2_timeout() local
296 mISDNDevName4ch(&l2->ch), l2->sapi, l2->tei, in l2_timeout()
297 l2->ch.nr, event == EV_L2_T200 ? "T200" : "T203"); in l2_timeout()
302 hh->id = l2->ch.nr; in l2_timeout()
305 mISDNDevName4ch(&l2->ch), l2->sapi, l2->tei, in l2_timeout()
306 l2->ch.nr, event == EV_L2_T200 ? "T200" : "T203"); in l2_timeout()
307 if (l2->ch.st) in l2_timeout()
308 l2->ch.st->own.recv(&l2->ch.st->own, skb); in l2_timeout()
312 l2mgr(struct layer2 *l2, u_int prim, void *arg) { in l2mgr() argument
316 mISDNDevName4ch(&l2->ch), l2->id, prim, (char)c); in l2mgr()
317 if (test_bit(FLG_LAPD, &l2->flag) && in l2mgr()
318 !test_bit(FLG_FIXED_TEI, &l2->flag)) { in l2mgr()
324 l2_tei(l2, prim, (u_long)arg); in l2mgr()
332 set_peer_busy(struct layer2 *l2) { in set_peer_busy() argument
333 test_and_set_bit(FLG_PEER_BUSY, &l2->flag); in set_peer_busy()
334 if (skb_queue_len(&l2->i_queue) || skb_queue_len(&l2->ui_queue)) in set_peer_busy()
335 test_and_set_bit(FLG_L2BLOCK, &l2->flag); in set_peer_busy()
339 clear_peer_busy(struct layer2 *l2) { in clear_peer_busy() argument
340 if (test_and_clear_bit(FLG_PEER_BUSY, &l2->flag)) in clear_peer_busy()
341 test_and_clear_bit(FLG_L2BLOCK, &l2->flag); in clear_peer_busy()
345 InitWin(struct layer2 *l2) in InitWin() argument
350 l2->windowar[i] = NULL; in InitWin()
354 freewin(struct layer2 *l2) in freewin() argument
359 if (l2->windowar[i]) { in freewin()
361 dev_kfree_skb(l2->windowar[i]); in freewin()
362 l2->windowar[i] = NULL; in freewin()
369 ReleaseWin(struct layer2 *l2) in ReleaseWin() argument
371 int cnt = freewin(l2); in ReleaseWin()
379 cansend(struct layer2 *l2) in cansend() argument
383 if (test_bit(FLG_MOD128, &l2->flag)) in cansend()
384 p1 = (l2->vs - l2->va) % 128; in cansend()
386 p1 = (l2->vs - l2->va) % 8; in cansend()
387 return (p1 < l2->window) && !test_bit(FLG_PEER_BUSY, &l2->flag); in cansend()
391 clear_exception(struct layer2 *l2) in clear_exception() argument
393 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); in clear_exception()
394 test_and_clear_bit(FLG_REJEXC, &l2->flag); in clear_exception()
395 test_and_clear_bit(FLG_OWN_BUSY, &l2->flag); in clear_exception()
396 clear_peer_busy(l2); in clear_exception()
400 sethdraddr(struct layer2 *l2, u_char *header, int rsp) in sethdraddr() argument
405 if (test_bit(FLG_LAPD, &l2->flag)) { in sethdraddr()
406 if (test_bit(FLG_LAPD_NET, &l2->flag)) in sethdraddr()
408 *ptr++ = (l2->sapi << 2) | (crbit ? 2 : 0); in sethdraddr()
409 *ptr++ = (l2->tei << 1) | 1; in sethdraddr()
412 if (test_bit(FLG_ORIG, &l2->flag)) in sethdraddr()
415 *ptr++ = l2->addr.B; in sethdraddr()
417 *ptr++ = l2->addr.A; in sethdraddr()
423 enqueue_super(struct layer2 *l2, struct sk_buff *skb) in enqueue_super() argument
425 if (l2down(l2, PH_DATA_REQ, l2_newid(l2), skb)) in enqueue_super()
430 enqueue_ui(struct layer2 *l2, struct sk_buff *skb) in enqueue_ui() argument
432 if (l2->tm) in enqueue_ui()
433 l2_tei(l2, MDL_STATUS_UI_IND, 0); in enqueue_ui()
434 if (l2down(l2, PH_DATA_REQ, l2_newid(l2), skb)) in enqueue_ui()
463 IsRR(u_char *data, struct layer2 *l2) in IsRR() argument
465 if (test_bit(FLG_MOD128, &l2->flag)) in IsRR()
472 IsSFrame(u_char *data, struct layer2 *l2) in IsSFrame() argument
476 if (!test_bit(FLG_MOD128, &l2->flag)) in IsSFrame()
482 IsSABME(u_char *data, struct layer2 *l2) in IsSABME() argument
486 return test_bit(FLG_MOD128, &l2->flag) ? d == SABME : d == SABM; in IsSABME()
490 IsREJ(u_char *data, struct layer2 *l2) in IsREJ() argument
492 return test_bit(FLG_MOD128, &l2->flag) ? in IsREJ()
503 IsRNR(u_char *data, struct layer2 *l2) in IsRNR() argument
505 return test_bit(FLG_MOD128, &l2->flag) ? in IsRNR()
510 iframe_error(struct layer2 *l2, struct sk_buff *skb) in iframe_error() argument
515 i = l2addrsize(l2) + (test_bit(FLG_MOD128, &l2->flag) ? 2 : 1); in iframe_error()
516 if (test_bit(FLG_ORIG, &l2->flag)) in iframe_error()
522 if ((skb->len - i) > l2->maxlen) in iframe_error()
528 super_error(struct layer2 *l2, struct sk_buff *skb) in super_error() argument
530 if (skb->len != l2addrsize(l2) + in super_error()
531 (test_bit(FLG_MOD128, &l2->flag) ? 2 : 1)) in super_error()
537 unnum_error(struct layer2 *l2, struct sk_buff *skb, int wantrsp) in unnum_error() argument
540 if (test_bit(FLG_ORIG, &l2->flag)) in unnum_error()
544 if (skb->len != l2addrsize(l2) + 1) in unnum_error()
550 UI_error(struct layer2 *l2, struct sk_buff *skb) in UI_error() argument
553 if (test_bit(FLG_ORIG, &l2->flag)) in UI_error()
557 if (skb->len > l2->maxlen + l2addrsize(l2) + 1) in UI_error()
563 FRMR_error(struct layer2 *l2, struct sk_buff *skb) in FRMR_error() argument
565 u_int headers = l2addrsize(l2) + 1; in FRMR_error()
569 if (test_bit(FLG_ORIG, &l2->flag)) in FRMR_error()
573 if (test_bit(FLG_MOD128, &l2->flag)) { in FRMR_error()
577 l2m_debug(&l2->l2m, in FRMR_error()
584 l2m_debug(&l2->l2m, in FRMR_error()
592 legalnr(struct layer2 *l2, unsigned int nr) in legalnr() argument
594 if (test_bit(FLG_MOD128, &l2->flag)) in legalnr()
595 return ((nr - l2->va) % 128) <= ((l2->vs - l2->va) % 128); in legalnr()
597 return ((nr - l2->va) % 8) <= ((l2->vs - l2->va) % 8); in legalnr()
601 setva(struct layer2 *l2, unsigned int nr) in setva() argument
605 while (l2->va != nr) { in setva()
606 l2->va++; in setva()
607 if (test_bit(FLG_MOD128, &l2->flag)) in setva()
608 l2->va %= 128; in setva()
610 l2->va %= 8; in setva()
611 if (l2->windowar[l2->sow]) { in setva()
612 skb_trim(l2->windowar[l2->sow], 0); in setva()
613 skb_queue_tail(&l2->tmp_queue, l2->windowar[l2->sow]); in setva()
614 l2->windowar[l2->sow] = NULL; in setva()
616 l2->sow = (l2->sow + 1) % l2->window; in setva()
618 skb = skb_dequeue(&l2->tmp_queue); in setva()
621 skb = skb_dequeue(&l2->tmp_queue); in setva()
626 send_uframe(struct layer2 *l2, struct sk_buff *skb, u_char cmd, u_char cr) in send_uframe() argument
631 i = sethdraddr(l2, tmp, cr); in send_uframe()
639 mISDNDevName4ch(&l2->ch), __func__); in send_uframe()
644 enqueue_super(l2, skb); in send_uframe()
649 get_PollFlag(struct layer2 *l2, struct sk_buff *skb) in get_PollFlag() argument
651 return skb->data[l2addrsize(l2)] & 0x10; in get_PollFlag()
655 get_PollFlagFree(struct layer2 *l2, struct sk_buff *skb) in get_PollFlagFree() argument
659 PF = get_PollFlag(l2, skb); in get_PollFlagFree()
665 start_t200(struct layer2 *l2, int i) in start_t200() argument
667 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, i); in start_t200()
668 test_and_set_bit(FLG_T200_RUN, &l2->flag); in start_t200()
672 restart_t200(struct layer2 *l2, int i) in restart_t200() argument
674 mISDN_FsmRestartTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, i); in restart_t200()
675 test_and_set_bit(FLG_T200_RUN, &l2->flag); in restart_t200()
679 stop_t200(struct layer2 *l2, int i) in stop_t200() argument
681 if (test_and_clear_bit(FLG_T200_RUN, &l2->flag)) in stop_t200()
682 mISDN_FsmDelTimer(&l2->t200, i); in stop_t200()
686 st5_dl_release_l2l3(struct layer2 *l2) in st5_dl_release_l2l3() argument
690 if (test_and_clear_bit(FLG_PEND_REL, &l2->flag)) in st5_dl_release_l2l3()
694 l2up_create(l2, pr, 0, NULL); in st5_dl_release_l2l3()
698 lapb_dl_release_l2l3(struct layer2 *l2, int f) in lapb_dl_release_l2l3() argument
700 if (test_bit(FLG_LAPB, &l2->flag)) in lapb_dl_release_l2l3()
701 l2down_create(l2, PH_DEACTIVATE_REQ, l2_newid(l2), 0, NULL); in lapb_dl_release_l2l3()
702 l2up_create(l2, f, 0, NULL); in lapb_dl_release_l2l3()
708 struct layer2 *l2 = fi->userdata; in establishlink() local
711 clear_exception(l2); in establishlink()
712 l2->rc = 0; in establishlink()
713 cmd = (test_bit(FLG_MOD128, &l2->flag) ? SABME : SABM) | 0x10; in establishlink()
714 send_uframe(l2, NULL, cmd, CMD); in establishlink()
715 mISDN_FsmDelTimer(&l2->t203, 1); in establishlink()
716 restart_t200(l2, 1); in establishlink()
717 test_and_clear_bit(FLG_PEND_REL, &l2->flag); in establishlink()
718 freewin(l2); in establishlink()
726 struct layer2 *l2 = fi->userdata; in l2_mdl_error_ua() local
728 if (get_PollFlagFree(l2, skb)) in l2_mdl_error_ua()
729 l2mgr(l2, MDL_ERROR_IND, (void *) 'C'); in l2_mdl_error_ua()
731 l2mgr(l2, MDL_ERROR_IND, (void *) 'D'); in l2_mdl_error_ua()
739 struct layer2 *l2 = fi->userdata; in l2_mdl_error_dm() local
741 if (get_PollFlagFree(l2, skb)) in l2_mdl_error_dm()
742 l2mgr(l2, MDL_ERROR_IND, (void *) 'B'); in l2_mdl_error_dm()
744 l2mgr(l2, MDL_ERROR_IND, (void *) 'E'); in l2_mdl_error_dm()
746 test_and_clear_bit(FLG_L3_INIT, &l2->flag); in l2_mdl_error_dm()
754 struct layer2 *l2 = fi->userdata; in l2_st8_mdl_error_dm() local
756 if (get_PollFlagFree(l2, skb)) in l2_st8_mdl_error_dm()
757 l2mgr(l2, MDL_ERROR_IND, (void *) 'B'); in l2_st8_mdl_error_dm()
759 l2mgr(l2, MDL_ERROR_IND, (void *) 'E'); in l2_st8_mdl_error_dm()
761 test_and_clear_bit(FLG_L3_INIT, &l2->flag); in l2_st8_mdl_error_dm()
774 struct layer2 *l2 = fi->userdata; in l2_mdl_assign() local
778 l2_tei(l2, MDL_ASSIGN_IND, 0); in l2_mdl_assign()
784 struct layer2 *l2 = fi->userdata; in l2_queue_ui_assign() local
787 skb_queue_tail(&l2->ui_queue, skb); in l2_queue_ui_assign()
789 l2_tei(l2, MDL_ASSIGN_IND, 0); in l2_queue_ui_assign()
795 struct layer2 *l2 = fi->userdata; in l2_queue_ui() local
798 skb_queue_tail(&l2->ui_queue, skb); in l2_queue_ui()
802 tx_ui(struct layer2 *l2) in tx_ui() argument
808 i = sethdraddr(l2, header, CMD); in tx_ui()
809 if (test_bit(FLG_LAPD_NET, &l2->flag)) in tx_ui()
812 while ((skb = skb_dequeue(&l2->ui_queue))) { in tx_ui()
814 enqueue_ui(l2, skb); in tx_ui()
821 struct layer2 *l2 = fi->userdata; in l2_send_ui() local
824 skb_queue_tail(&l2->ui_queue, skb); in l2_send_ui()
825 tx_ui(l2); in l2_send_ui()
831 struct layer2 *l2 = fi->userdata; in l2_got_ui() local
834 skb_pull(skb, l2headersize(l2, 1)); in l2_got_ui()
839 if (l2->tm) in l2_got_ui()
840 l2_tei(l2, MDL_STATUS_UI_IND, 0); in l2_got_ui()
841 l2up(l2, DL_UNITDATA_IND, skb); in l2_got_ui()
848 struct layer2 *l2 = fi->userdata; in l2_establish() local
851 test_and_set_bit(FLG_L3_INIT, &l2->flag); in l2_establish()
859 struct layer2 *l2 = fi->userdata; in l2_discard_i_setl3() local
861 skb_queue_purge(&l2->i_queue); in l2_discard_i_setl3()
862 test_and_set_bit(FLG_L3_INIT, &l2->flag); in l2_discard_i_setl3()
863 test_and_clear_bit(FLG_PEND_REL, &l2->flag); in l2_discard_i_setl3()
871 struct layer2 *l2 = fi->userdata; in l2_l3_reestablish() local
873 skb_queue_purge(&l2->i_queue); in l2_l3_reestablish()
875 test_and_set_bit(FLG_L3_INIT, &l2->flag); in l2_l3_reestablish()
882 struct layer2 *l2 = fi->userdata; in l2_release() local
886 l2up(l2, DL_RELEASE_CNF, skb); in l2_release()
893 struct layer2 *l2 = fi->userdata; in l2_pend_rel() local
895 test_and_set_bit(FLG_PEND_REL, &l2->flag); in l2_pend_rel()
902 struct layer2 *l2 = fi->userdata; in l2_disconnect() local
905 skb_queue_purge(&l2->i_queue); in l2_disconnect()
906 freewin(l2); in l2_disconnect()
908 l2->rc = 0; in l2_disconnect()
909 send_uframe(l2, NULL, DISC | 0x10, CMD); in l2_disconnect()
910 mISDN_FsmDelTimer(&l2->t203, 1); in l2_disconnect()
911 restart_t200(l2, 2); in l2_disconnect()
919 struct layer2 *l2 = fi->userdata; in l2_start_multi() local
922 l2->vs = 0; in l2_start_multi()
923 l2->va = 0; in l2_start_multi()
924 l2->vr = 0; in l2_start_multi()
925 l2->sow = 0; in l2_start_multi()
926 clear_exception(l2); in l2_start_multi()
927 send_uframe(l2, NULL, UA | get_PollFlag(l2, skb), RSP); in l2_start_multi()
929 mISDN_FsmAddTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 3); in l2_start_multi()
931 l2up(l2, DL_ESTABLISH_IND, skb); in l2_start_multi()
932 if (l2->tm) in l2_start_multi()
933 l2_tei(l2, MDL_STATUS_UP_IND, 0); in l2_start_multi()
939 struct layer2 *l2 = fi->userdata; in l2_send_UA() local
942 send_uframe(l2, skb, UA | get_PollFlag(l2, skb), RSP); in l2_send_UA()
948 struct layer2 *l2 = fi->userdata; in l2_send_DM() local
951 send_uframe(l2, skb, DM | get_PollFlag(l2, skb), RSP); in l2_send_DM()
957 struct layer2 *l2 = fi->userdata; in l2_restart_multi() local
961 send_uframe(l2, skb, UA | get_PollFlag(l2, skb), RSP); in l2_restart_multi()
963 l2mgr(l2, MDL_ERROR_IND, (void *) 'F'); in l2_restart_multi()
965 if (l2->vs != l2->va) { in l2_restart_multi()
966 skb_queue_purge(&l2->i_queue); in l2_restart_multi()
970 clear_exception(l2); in l2_restart_multi()
971 l2->vs = 0; in l2_restart_multi()
972 l2->va = 0; in l2_restart_multi()
973 l2->vr = 0; in l2_restart_multi()
974 l2->sow = 0; in l2_restart_multi()
976 stop_t200(l2, 3); in l2_restart_multi()
977 mISDN_FsmRestartTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 3); in l2_restart_multi()
980 l2up_create(l2, DL_ESTABLISH_IND, 0, NULL); in l2_restart_multi()
985 if (skb_queue_len(&l2->i_queue) && cansend(l2)) in l2_restart_multi()
992 struct layer2 *l2 = fi->userdata; in l2_stop_multi() local
996 mISDN_FsmDelTimer(&l2->t203, 3); in l2_stop_multi()
997 stop_t200(l2, 4); in l2_stop_multi()
999 send_uframe(l2, skb, UA | get_PollFlag(l2, skb), RSP); in l2_stop_multi()
1000 skb_queue_purge(&l2->i_queue); in l2_stop_multi()
1001 freewin(l2); in l2_stop_multi()
1002 lapb_dl_release_l2l3(l2, DL_RELEASE_IND); in l2_stop_multi()
1003 if (l2->tm) in l2_stop_multi()
1004 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_stop_multi()
1010 struct layer2 *l2 = fi->userdata; in l2_connected() local
1014 if (!get_PollFlag(l2, skb)) { in l2_connected()
1019 if (test_and_clear_bit(FLG_PEND_REL, &l2->flag)) in l2_connected()
1021 if (test_and_clear_bit(FLG_L3_INIT, &l2->flag)) { in l2_connected()
1023 } else if (l2->vs != l2->va) { in l2_connected()
1024 skb_queue_purge(&l2->i_queue); in l2_connected()
1027 stop_t200(l2, 5); in l2_connected()
1028 l2->vr = 0; in l2_connected()
1029 l2->vs = 0; in l2_connected()
1030 l2->va = 0; in l2_connected()
1031 l2->sow = 0; in l2_connected()
1033 mISDN_FsmAddTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 4); in l2_connected()
1035 l2up_create(l2, pr, 0, NULL); in l2_connected()
1037 if (skb_queue_len(&l2->i_queue) && cansend(l2)) in l2_connected()
1040 if (l2->tm) in l2_connected()
1041 l2_tei(l2, MDL_STATUS_UP_IND, 0); in l2_connected()
1047 struct layer2 *l2 = fi->userdata; in l2_released() local
1050 if (!get_PollFlag(l2, skb)) { in l2_released()
1055 stop_t200(l2, 6); in l2_released()
1056 lapb_dl_release_l2l3(l2, DL_RELEASE_CNF); in l2_released()
1058 if (l2->tm) in l2_released()
1059 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_released()
1065 struct layer2 *l2 = fi->userdata; in l2_reestablish() local
1068 if (!get_PollFlagFree(l2, skb)) { in l2_reestablish()
1070 test_and_set_bit(FLG_L3_INIT, &l2->flag); in l2_reestablish()
1077 struct layer2 *l2 = fi->userdata; in l2_st5_dm_release() local
1080 if (get_PollFlagFree(l2, skb)) { in l2_st5_dm_release()
1081 stop_t200(l2, 7); in l2_st5_dm_release()
1082 if (!test_bit(FLG_L3_INIT, &l2->flag)) in l2_st5_dm_release()
1083 skb_queue_purge(&l2->i_queue); in l2_st5_dm_release()
1084 if (test_bit(FLG_LAPB, &l2->flag)) in l2_st5_dm_release()
1085 l2down_create(l2, PH_DEACTIVATE_REQ, in l2_st5_dm_release()
1086 l2_newid(l2), 0, NULL); in l2_st5_dm_release()
1087 st5_dl_release_l2l3(l2); in l2_st5_dm_release()
1089 if (l2->tm) in l2_st5_dm_release()
1090 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_st5_dm_release()
1097 struct layer2 *l2 = fi->userdata; in l2_st6_dm_release() local
1100 if (get_PollFlagFree(l2, skb)) { in l2_st6_dm_release()
1101 stop_t200(l2, 8); in l2_st6_dm_release()
1102 lapb_dl_release_l2l3(l2, DL_RELEASE_CNF); in l2_st6_dm_release()
1104 if (l2->tm) in l2_st6_dm_release()
1105 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_st6_dm_release()
1110 enquiry_cr(struct layer2 *l2, u_char typ, u_char cr, u_char pf) in enquiry_cr() argument
1116 i = sethdraddr(l2, tmp, cr); in enquiry_cr()
1117 if (test_bit(FLG_MOD128, &l2->flag)) { in enquiry_cr()
1119 tmp[i++] = (l2->vr << 1) | (pf ? 1 : 0); in enquiry_cr()
1121 tmp[i++] = (l2->vr << 5) | typ | (pf ? 0x10 : 0); in enquiry_cr()
1125 mISDNDevName4ch(&l2->ch), __func__); in enquiry_cr()
1129 enqueue_super(l2, skb); in enquiry_cr()
1133 enquiry_response(struct layer2 *l2) in enquiry_response() argument
1135 if (test_bit(FLG_OWN_BUSY, &l2->flag)) in enquiry_response()
1136 enquiry_cr(l2, RNR, RSP, 1); in enquiry_response()
1138 enquiry_cr(l2, RR, RSP, 1); in enquiry_response()
1139 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); in enquiry_response()
1143 transmit_enquiry(struct layer2 *l2) in transmit_enquiry() argument
1145 if (test_bit(FLG_OWN_BUSY, &l2->flag)) in transmit_enquiry()
1146 enquiry_cr(l2, RNR, CMD, 1); in transmit_enquiry()
1148 enquiry_cr(l2, RR, CMD, 1); in transmit_enquiry()
1149 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); in transmit_enquiry()
1150 start_t200(l2, 9); in transmit_enquiry()
1157 struct layer2 *l2 = fi->userdata; in nrerrorrecovery() local
1159 l2mgr(l2, MDL_ERROR_IND, (void *) 'J'); in nrerrorrecovery()
1161 test_and_clear_bit(FLG_L3_INIT, &l2->flag); in nrerrorrecovery()
1165 invoke_retransmission(struct layer2 *l2, unsigned int nr) in invoke_retransmission() argument
1169 if (l2->vs != nr) { in invoke_retransmission()
1170 while (l2->vs != nr) { in invoke_retransmission()
1171 (l2->vs)--; in invoke_retransmission()
1172 if (test_bit(FLG_MOD128, &l2->flag)) { in invoke_retransmission()
1173 l2->vs %= 128; in invoke_retransmission()
1174 p1 = (l2->vs - l2->va) % 128; in invoke_retransmission()
1176 l2->vs %= 8; in invoke_retransmission()
1177 p1 = (l2->vs - l2->va) % 8; in invoke_retransmission()
1179 p1 = (p1 + l2->sow) % l2->window; in invoke_retransmission()
1180 if (l2->windowar[p1]) in invoke_retransmission()
1181 skb_queue_head(&l2->i_queue, l2->windowar[p1]); in invoke_retransmission()
1185 mISDNDevName4ch(&l2->ch), p1); in invoke_retransmission()
1186 l2->windowar[p1] = NULL; in invoke_retransmission()
1188 mISDN_FsmEvent(&l2->l2m, EV_L2_ACK_PULL, NULL); in invoke_retransmission()
1195 struct layer2 *l2 = fi->userdata; in l2_st7_got_super() local
1201 if (test_bit(FLG_ORIG, &l2->flag)) in l2_st7_got_super()
1204 skb_pull(skb, l2addrsize(l2)); in l2_st7_got_super()
1205 if (IsRNR(skb->data, l2)) { in l2_st7_got_super()
1206 set_peer_busy(l2); in l2_st7_got_super()
1209 clear_peer_busy(l2); in l2_st7_got_super()
1210 if (IsREJ(skb->data, l2)) in l2_st7_got_super()
1213 if (test_bit(FLG_MOD128, &l2->flag)) { in l2_st7_got_super()
1224 l2mgr(l2, MDL_ERROR_IND, (void *) 'A'); in l2_st7_got_super()
1226 enquiry_response(l2); in l2_st7_got_super()
1228 if (legalnr(l2, nr)) { in l2_st7_got_super()
1230 setva(l2, nr); in l2_st7_got_super()
1231 invoke_retransmission(l2, nr); in l2_st7_got_super()
1232 stop_t200(l2, 10); in l2_st7_got_super()
1233 if (mISDN_FsmAddTimer(&l2->t203, l2->T203, in l2_st7_got_super()
1235 l2m_debug(&l2->l2m, "Restart T203 ST7 REJ"); in l2_st7_got_super()
1236 } else if ((nr == l2->vs) && (typ == RR)) { in l2_st7_got_super()
1237 setva(l2, nr); in l2_st7_got_super()
1238 stop_t200(l2, 11); in l2_st7_got_super()
1239 mISDN_FsmRestartTimer(&l2->t203, l2->T203, in l2_st7_got_super()
1241 } else if ((l2->va != nr) || (typ == RNR)) { in l2_st7_got_super()
1242 setva(l2, nr); in l2_st7_got_super()
1244 mISDN_FsmDelTimer(&l2->t203, 9); in l2_st7_got_super()
1245 restart_t200(l2, 12); in l2_st7_got_super()
1247 if (skb_queue_len(&l2->i_queue) && (typ == RR)) in l2_st7_got_super()
1256 struct layer2 *l2 = fi->userdata; in l2_feed_i_if_reest() local
1259 if (!test_bit(FLG_L3_INIT, &l2->flag)) in l2_feed_i_if_reest()
1260 skb_queue_tail(&l2->i_queue, skb); in l2_feed_i_if_reest()
1268 struct layer2 *l2 = fi->userdata; in l2_feed_i_pull() local
1271 skb_queue_tail(&l2->i_queue, skb); in l2_feed_i_pull()
1278 struct layer2 *l2 = fi->userdata; in l2_feed_iqueue() local
1281 skb_queue_tail(&l2->i_queue, skb); in l2_feed_iqueue()
1287 struct layer2 *l2 = fi->userdata; in l2_got_iframe() local
1292 i = l2addrsize(l2); in l2_got_iframe()
1293 if (test_bit(FLG_MOD128, &l2->flag)) { in l2_got_iframe()
1302 if (test_bit(FLG_OWN_BUSY, &l2->flag)) { in l2_got_iframe()
1305 enquiry_response(l2); in l2_got_iframe()
1307 if (l2->vr == ns) { in l2_got_iframe()
1308 l2->vr++; in l2_got_iframe()
1309 if (test_bit(FLG_MOD128, &l2->flag)) in l2_got_iframe()
1310 l2->vr %= 128; in l2_got_iframe()
1312 l2->vr %= 8; in l2_got_iframe()
1313 test_and_clear_bit(FLG_REJEXC, &l2->flag); in l2_got_iframe()
1315 enquiry_response(l2); in l2_got_iframe()
1317 test_and_set_bit(FLG_ACK_PEND, &l2->flag); in l2_got_iframe()
1318 skb_pull(skb, l2headersize(l2, 0)); in l2_got_iframe()
1319 l2up(l2, DL_DATA_IND, skb); in l2_got_iframe()
1323 if (test_and_set_bit(FLG_REJEXC, &l2->flag)) { in l2_got_iframe()
1325 enquiry_response(l2); in l2_got_iframe()
1327 enquiry_cr(l2, REJ, RSP, PollFlag); in l2_got_iframe()
1328 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); in l2_got_iframe()
1332 if (legalnr(l2, nr)) { in l2_got_iframe()
1333 if (!test_bit(FLG_PEER_BUSY, &l2->flag) && in l2_got_iframe()
1335 if (nr == l2->vs) { in l2_got_iframe()
1336 stop_t200(l2, 13); in l2_got_iframe()
1337 mISDN_FsmRestartTimer(&l2->t203, l2->T203, in l2_got_iframe()
1339 } else if (nr != l2->va) in l2_got_iframe()
1340 restart_t200(l2, 14); in l2_got_iframe()
1342 setva(l2, nr); in l2_got_iframe()
1347 if (skb_queue_len(&l2->i_queue) && (fi->state == ST_L2_7)) in l2_got_iframe()
1349 if (test_and_clear_bit(FLG_ACK_PEND, &l2->flag)) in l2_got_iframe()
1350 enquiry_cr(l2, RR, RSP, 0); in l2_got_iframe()
1356 struct layer2 *l2 = fi->userdata; in l2_got_tei() local
1359 l2->tei = (signed char)(long)arg; in l2_got_tei()
1360 set_channel_address(&l2->ch, l2->sapi, l2->tei); in l2_got_tei()
1362 l2up_create(l2, DL_INFORMATION_IND, sizeof(info), &info); in l2_got_tei()
1365 test_and_set_bit(FLG_L3_INIT, &l2->flag); in l2_got_tei()
1368 if (skb_queue_len(&l2->ui_queue)) in l2_got_tei()
1369 tx_ui(l2); in l2_got_tei()
1375 struct layer2 *l2 = fi->userdata; in l2_st5_tout_200() local
1377 if (test_bit(FLG_LAPD, &l2->flag) && in l2_st5_tout_200()
1378 test_bit(FLG_DCHAN_BUSY, &l2->flag)) { in l2_st5_tout_200()
1379 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); in l2_st5_tout_200()
1380 } else if (l2->rc == l2->N200) { in l2_st5_tout_200()
1382 test_and_clear_bit(FLG_T200_RUN, &l2->flag); in l2_st5_tout_200()
1383 skb_queue_purge(&l2->i_queue); in l2_st5_tout_200()
1384 l2mgr(l2, MDL_ERROR_IND, (void *) 'G'); in l2_st5_tout_200()
1385 if (test_bit(FLG_LAPB, &l2->flag)) in l2_st5_tout_200()
1386 l2down_create(l2, PH_DEACTIVATE_REQ, in l2_st5_tout_200()
1387 l2_newid(l2), 0, NULL); in l2_st5_tout_200()
1388 st5_dl_release_l2l3(l2); in l2_st5_tout_200()
1389 if (l2->tm) in l2_st5_tout_200()
1390 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_st5_tout_200()
1392 l2->rc++; in l2_st5_tout_200()
1393 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); in l2_st5_tout_200()
1394 send_uframe(l2, NULL, (test_bit(FLG_MOD128, &l2->flag) ? in l2_st5_tout_200()
1402 struct layer2 *l2 = fi->userdata; in l2_st6_tout_200() local
1404 if (test_bit(FLG_LAPD, &l2->flag) && in l2_st6_tout_200()
1405 test_bit(FLG_DCHAN_BUSY, &l2->flag)) { in l2_st6_tout_200()
1406 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); in l2_st6_tout_200()
1407 } else if (l2->rc == l2->N200) { in l2_st6_tout_200()
1409 test_and_clear_bit(FLG_T200_RUN, &l2->flag); in l2_st6_tout_200()
1410 l2mgr(l2, MDL_ERROR_IND, (void *) 'H'); in l2_st6_tout_200()
1411 lapb_dl_release_l2l3(l2, DL_RELEASE_CNF); in l2_st6_tout_200()
1412 if (l2->tm) in l2_st6_tout_200()
1413 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_st6_tout_200()
1415 l2->rc++; in l2_st6_tout_200()
1416 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, in l2_st6_tout_200()
1418 send_uframe(l2, NULL, DISC | 0x10, CMD); in l2_st6_tout_200()
1425 struct layer2 *l2 = fi->userdata; in l2_st7_tout_200() local
1427 if (test_bit(FLG_LAPD, &l2->flag) && in l2_st7_tout_200()
1428 test_bit(FLG_DCHAN_BUSY, &l2->flag)) { in l2_st7_tout_200()
1429 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); in l2_st7_tout_200()
1432 test_and_clear_bit(FLG_T200_RUN, &l2->flag); in l2_st7_tout_200()
1433 l2->rc = 0; in l2_st7_tout_200()
1435 transmit_enquiry(l2); in l2_st7_tout_200()
1436 l2->rc++; in l2_st7_tout_200()
1442 struct layer2 *l2 = fi->userdata; in l2_st8_tout_200() local
1444 if (test_bit(FLG_LAPD, &l2->flag) && in l2_st8_tout_200()
1445 test_bit(FLG_DCHAN_BUSY, &l2->flag)) { in l2_st8_tout_200()
1446 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); in l2_st8_tout_200()
1449 test_and_clear_bit(FLG_T200_RUN, &l2->flag); in l2_st8_tout_200()
1450 if (l2->rc == l2->N200) { in l2_st8_tout_200()
1451 l2mgr(l2, MDL_ERROR_IND, (void *) 'I'); in l2_st8_tout_200()
1453 test_and_clear_bit(FLG_L3_INIT, &l2->flag); in l2_st8_tout_200()
1455 transmit_enquiry(l2); in l2_st8_tout_200()
1456 l2->rc++; in l2_st8_tout_200()
1463 struct layer2 *l2 = fi->userdata; in l2_st7_tout_203() local
1465 if (test_bit(FLG_LAPD, &l2->flag) && in l2_st7_tout_203()
1466 test_bit(FLG_DCHAN_BUSY, &l2->flag)) { in l2_st7_tout_203()
1467 mISDN_FsmAddTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 9); in l2_st7_tout_203()
1471 transmit_enquiry(l2); in l2_st7_tout_203()
1472 l2->rc = 0; in l2_st7_tout_203()
1478 struct layer2 *l2 = fi->userdata; in l2_pull_iqueue() local
1483 if (!cansend(l2)) in l2_pull_iqueue()
1486 skb = skb_dequeue(&l2->i_queue); in l2_pull_iqueue()
1490 if (test_bit(FLG_MOD128, &l2->flag)) in l2_pull_iqueue()
1491 p1 = (l2->vs - l2->va) % 128; in l2_pull_iqueue()
1493 p1 = (l2->vs - l2->va) % 8; in l2_pull_iqueue()
1494 p1 = (p1 + l2->sow) % l2->window; in l2_pull_iqueue()
1495 if (l2->windowar[p1]) { in l2_pull_iqueue()
1497 mISDNDevName4ch(&l2->ch), p1); in l2_pull_iqueue()
1498 dev_kfree_skb(l2->windowar[p1]); in l2_pull_iqueue()
1500 l2->windowar[p1] = skb; in l2_pull_iqueue()
1501 i = sethdraddr(l2, header, CMD); in l2_pull_iqueue()
1502 if (test_bit(FLG_MOD128, &l2->flag)) { in l2_pull_iqueue()
1503 header[i++] = l2->vs << 1; in l2_pull_iqueue()
1504 header[i++] = l2->vr << 1; in l2_pull_iqueue()
1505 l2->vs = (l2->vs + 1) % 128; in l2_pull_iqueue()
1507 header[i++] = (l2->vr << 5) | (l2->vs << 1); in l2_pull_iqueue()
1508 l2->vs = (l2->vs + 1) % 8; in l2_pull_iqueue()
1518 mISDNDevName4ch(&l2->ch), i, p1); in l2_pull_iqueue()
1524 mISDNDevName4ch(&l2->ch), __func__); in l2_pull_iqueue()
1531 l2down(l2, PH_DATA_REQ, l2_newid(l2), nskb); in l2_pull_iqueue()
1532 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); in l2_pull_iqueue()
1533 if (!test_and_set_bit(FLG_T200_RUN, &l2->flag)) { in l2_pull_iqueue()
1534 mISDN_FsmDelTimer(&l2->t203, 13); in l2_pull_iqueue()
1535 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 11); in l2_pull_iqueue()
1542 struct layer2 *l2 = fi->userdata; in l2_st8_got_super() local
1548 if (test_bit(FLG_ORIG, &l2->flag)) in l2_st8_got_super()
1551 skb_pull(skb, l2addrsize(l2)); in l2_st8_got_super()
1553 if (IsRNR(skb->data, l2)) { in l2_st8_got_super()
1554 set_peer_busy(l2); in l2_st8_got_super()
1557 clear_peer_busy(l2); in l2_st8_got_super()
1559 if (test_bit(FLG_MOD128, &l2->flag)) { in l2_st8_got_super()
1568 if (legalnr(l2, nr)) { in l2_st8_got_super()
1570 restart_t200(l2, 15); in l2_st8_got_super()
1572 stop_t200(l2, 16); in l2_st8_got_super()
1573 mISDN_FsmAddTimer(&l2->t203, l2->T203, in l2_st8_got_super()
1575 setva(l2, nr); in l2_st8_got_super()
1577 invoke_retransmission(l2, nr); in l2_st8_got_super()
1579 if (skb_queue_len(&l2->i_queue) && cansend(l2)) in l2_st8_got_super()
1585 enquiry_response(l2); in l2_st8_got_super()
1586 if (legalnr(l2, nr)) in l2_st8_got_super()
1587 setva(l2, nr); in l2_st8_got_super()
1596 struct layer2 *l2 = fi->userdata; in l2_got_FRMR() local
1599 skb_pull(skb, l2addrsize(l2) + 1); in l2_got_FRMR()
1603 l2mgr(l2, MDL_ERROR_IND, (void *) 'K'); in l2_got_FRMR()
1605 test_and_clear_bit(FLG_L3_INIT, &l2->flag); in l2_got_FRMR()
1613 struct layer2 *l2 = fi->userdata; in l2_st24_tei_remove() local
1615 skb_queue_purge(&l2->ui_queue); in l2_st24_tei_remove()
1616 l2->tei = GROUP_TEI; in l2_st24_tei_remove()
1623 struct layer2 *l2 = fi->userdata; in l2_st3_tei_remove() local
1625 skb_queue_purge(&l2->ui_queue); in l2_st3_tei_remove()
1626 l2->tei = GROUP_TEI; in l2_st3_tei_remove()
1627 l2up_create(l2, DL_RELEASE_IND, 0, NULL); in l2_st3_tei_remove()
1634 struct layer2 *l2 = fi->userdata; in l2_st5_tei_remove() local
1636 skb_queue_purge(&l2->i_queue); in l2_st5_tei_remove()
1637 skb_queue_purge(&l2->ui_queue); in l2_st5_tei_remove()
1638 freewin(l2); in l2_st5_tei_remove()
1639 l2->tei = GROUP_TEI; in l2_st5_tei_remove()
1640 stop_t200(l2, 17); in l2_st5_tei_remove()
1641 st5_dl_release_l2l3(l2); in l2_st5_tei_remove()
1648 struct layer2 *l2 = fi->userdata; in l2_st6_tei_remove() local
1650 skb_queue_purge(&l2->ui_queue); in l2_st6_tei_remove()
1651 l2->tei = GROUP_TEI; in l2_st6_tei_remove()
1652 stop_t200(l2, 18); in l2_st6_tei_remove()
1653 l2up_create(l2, DL_RELEASE_IND, 0, NULL); in l2_st6_tei_remove()
1660 struct layer2 *l2 = fi->userdata; in l2_tei_remove() local
1662 skb_queue_purge(&l2->i_queue); in l2_tei_remove()
1663 skb_queue_purge(&l2->ui_queue); in l2_tei_remove()
1664 freewin(l2); in l2_tei_remove()
1665 l2->tei = GROUP_TEI; in l2_tei_remove()
1666 stop_t200(l2, 17); in l2_tei_remove()
1667 mISDN_FsmDelTimer(&l2->t203, 19); in l2_tei_remove()
1668 l2up_create(l2, DL_RELEASE_IND, 0, NULL); in l2_tei_remove()
1679 struct layer2 *l2 = fi->userdata; in l2_st14_persistent_da() local
1682 skb_queue_purge(&l2->i_queue); in l2_st14_persistent_da()
1683 skb_queue_purge(&l2->ui_queue); in l2_st14_persistent_da()
1684 if (test_and_clear_bit(FLG_ESTAB_PEND, &l2->flag)) in l2_st14_persistent_da()
1685 l2up(l2, DL_RELEASE_IND, skb); in l2_st14_persistent_da()
1693 struct layer2 *l2 = fi->userdata; in l2_st5_persistent_da() local
1696 skb_queue_purge(&l2->i_queue); in l2_st5_persistent_da()
1697 skb_queue_purge(&l2->ui_queue); in l2_st5_persistent_da()
1698 freewin(l2); in l2_st5_persistent_da()
1699 stop_t200(l2, 19); in l2_st5_persistent_da()
1700 st5_dl_release_l2l3(l2); in l2_st5_persistent_da()
1702 if (l2->tm) in l2_st5_persistent_da()
1703 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_st5_persistent_da()
1710 struct layer2 *l2 = fi->userdata; in l2_st6_persistent_da() local
1713 skb_queue_purge(&l2->ui_queue); in l2_st6_persistent_da()
1714 stop_t200(l2, 20); in l2_st6_persistent_da()
1715 l2up(l2, DL_RELEASE_CNF, skb); in l2_st6_persistent_da()
1717 if (l2->tm) in l2_st6_persistent_da()
1718 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_st6_persistent_da()
1724 struct layer2 *l2 = fi->userdata; in l2_persistent_da() local
1727 skb_queue_purge(&l2->i_queue); in l2_persistent_da()
1728 skb_queue_purge(&l2->ui_queue); in l2_persistent_da()
1729 freewin(l2); in l2_persistent_da()
1730 stop_t200(l2, 19); in l2_persistent_da()
1731 mISDN_FsmDelTimer(&l2->t203, 19); in l2_persistent_da()
1732 l2up(l2, DL_RELEASE_IND, skb); in l2_persistent_da()
1734 if (l2->tm) in l2_persistent_da()
1735 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_persistent_da()
1741 struct layer2 *l2 = fi->userdata; in l2_set_own_busy() local
1744 if (!test_and_set_bit(FLG_OWN_BUSY, &l2->flag)) { in l2_set_own_busy()
1745 enquiry_cr(l2, RNR, RSP, 0); in l2_set_own_busy()
1746 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); in l2_set_own_busy()
1755 struct layer2 *l2 = fi->userdata; in l2_clear_own_busy() local
1758 if (!test_and_clear_bit(FLG_OWN_BUSY, &l2->flag)) { in l2_clear_own_busy()
1759 enquiry_cr(l2, RR, RSP, 0); in l2_clear_own_busy()
1760 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); in l2_clear_own_busy()
1769 struct layer2 *l2 = fi->userdata; in l2_frame_error() local
1771 l2mgr(l2, MDL_ERROR_IND, arg); in l2_frame_error()
1777 struct layer2 *l2 = fi->userdata; in l2_frame_error_reest() local
1779 l2mgr(l2, MDL_ERROR_IND, arg); in l2_frame_error_reest()
1781 test_and_clear_bit(FLG_L3_INIT, &l2->flag); in l2_frame_error_reest()
1882 ph_data_indication(struct layer2 *l2, struct mISDNhead *hh, struct sk_buff *skb) in ph_data_indication() argument
1890 l = l2addrsize(l2); in ph_data_indication()
1892 mISDN_FsmEvent(&l2->l2m, EV_L2_FRAME_ERROR, (void *) 'N'); in ph_data_indication()
1895 if (test_bit(FLG_LAPD, &l2->flag)) { /* Maybe not needed */ in ph_data_indication()
1901 mISDNDevName4ch(&l2->ch)); in ph_data_indication()
1906 if (psapi != l2->sapi) { in ph_data_indication()
1910 mISDNDevName4ch(&l2->ch), psapi, in ph_data_indication()
1911 l2->sapi); in ph_data_indication()
1915 if ((ptei != l2->tei) && (ptei != GROUP_TEI)) { in ph_data_indication()
1919 mISDNDevName4ch(&l2->ch), ptei, l2->tei); in ph_data_indication()
1926 c = iframe_error(l2, skb); in ph_data_indication()
1928 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_I, skb); in ph_data_indication()
1929 } else if (IsSFrame(datap, l2)) { /* S-Frame */ in ph_data_indication()
1930 c = super_error(l2, skb); in ph_data_indication()
1932 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_SUPER, skb); in ph_data_indication()
1934 c = UI_error(l2, skb); in ph_data_indication()
1936 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_UI, skb); in ph_data_indication()
1937 } else if (IsSABME(datap, l2)) { in ph_data_indication()
1938 c = unnum_error(l2, skb, CMD); in ph_data_indication()
1940 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_SABME, skb); in ph_data_indication()
1942 c = unnum_error(l2, skb, RSP); in ph_data_indication()
1944 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_UA, skb); in ph_data_indication()
1946 c = unnum_error(l2, skb, CMD); in ph_data_indication()
1948 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DISC, skb); in ph_data_indication()
1950 c = unnum_error(l2, skb, RSP); in ph_data_indication()
1952 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DM, skb); in ph_data_indication()
1954 c = FRMR_error(l2, skb); in ph_data_indication()
1956 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_FRMR, skb); in ph_data_indication()
1961 mISDNDevName4ch(&l2->ch), c); in ph_data_indication()
1962 mISDN_FsmEvent(&l2->l2m, EV_L2_FRAME_ERROR, (void *)(long)c); in ph_data_indication()
1970 struct layer2 *l2 = container_of(ch, struct layer2, ch); in l2_send() local
1976 __func__, mISDNDevName4ch(&l2->ch), hh->prim, hh->id, in l2_send()
1977 l2->sapi, l2->tei); in l2_send()
1984 mISDNDevName4ch(&l2->ch), hh->prim, hh->id); in l2_send()
1988 ret = ph_data_indication(l2, hh, skb); in l2_send()
1991 ret = ph_data_confirm(l2, hh, skb); in l2_send()
1994 test_and_set_bit(FLG_L1_ACTIV, &l2->flag); in l2_send()
1995 l2up_create(l2, MPH_ACTIVATE_IND, 0, NULL); in l2_send()
1996 if (test_and_clear_bit(FLG_ESTAB_PEND, &l2->flag)) in l2_send()
1997 ret = mISDN_FsmEvent(&l2->l2m, in l2_send()
2001 test_and_clear_bit(FLG_L1_ACTIV, &l2->flag); in l2_send()
2002 l2up_create(l2, MPH_DEACTIVATE_IND, 0, NULL); in l2_send()
2003 ret = mISDN_FsmEvent(&l2->l2m, EV_L1_DEACTIVATE, skb); in l2_send()
2006 if (!l2->up) in l2_send()
2008 ret = l2->up->send(l2->up, skb); in l2_send()
2011 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DL_DATA, skb); in l2_send()
2014 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DL_UNITDATA, skb); in l2_send()
2017 if (test_bit(FLG_LAPB, &l2->flag)) in l2_send()
2018 test_and_set_bit(FLG_ORIG, &l2->flag); in l2_send()
2019 if (test_bit(FLG_L1_ACTIV, &l2->flag)) { in l2_send()
2020 if (test_bit(FLG_LAPD, &l2->flag) || in l2_send()
2021 test_bit(FLG_ORIG, &l2->flag)) in l2_send()
2022 ret = mISDN_FsmEvent(&l2->l2m, in l2_send()
2025 if (test_bit(FLG_LAPD, &l2->flag) || in l2_send()
2026 test_bit(FLG_ORIG, &l2->flag)) { in l2_send()
2028 &l2->flag); in l2_send()
2030 ret = l2down(l2, PH_ACTIVATE_REQ, l2_newid(l2), in l2_send()
2035 if (test_bit(FLG_LAPB, &l2->flag)) in l2_send()
2036 l2down_create(l2, PH_DEACTIVATE_REQ, in l2_send()
2037 l2_newid(l2), 0, NULL); in l2_send()
2038 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DL_RELEASE_REQ, in l2_send()
2042 mISDN_FsmEvent(&l2->l2m, EV_L2_T200I, NULL); in l2_send()
2045 mISDN_FsmEvent(&l2->l2m, EV_L2_T203I, NULL); in l2_send()
2049 l2m_debug(&l2->l2m, "l2 unknown pr %04x", in l2_send()
2060 tei_l2(struct layer2 *l2, u_int cmd, u_long arg) in tei_l2() argument
2066 mISDNDevName4ch(&l2->ch), cmd, __func__); in tei_l2()
2069 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_MDL_ASSIGN, (void *)arg); in tei_l2()
2072 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_MDL_REMOVE, NULL); in tei_l2()
2075 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_MDL_ERROR, NULL); in tei_l2()
2080 mISDNDevName4ch(&l2->ch)); in tei_l2()
2081 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_MDL_ERROR, NULL); in tei_l2()
2088 release_l2(struct layer2 *l2) in release_l2() argument
2090 mISDN_FsmDelTimer(&l2->t200, 21); in release_l2()
2091 mISDN_FsmDelTimer(&l2->t203, 16); in release_l2()
2092 skb_queue_purge(&l2->i_queue); in release_l2()
2093 skb_queue_purge(&l2->ui_queue); in release_l2()
2094 skb_queue_purge(&l2->down_queue); in release_l2()
2095 ReleaseWin(l2); in release_l2()
2096 if (test_bit(FLG_LAPD, &l2->flag)) { in release_l2()
2097 TEIrelease(l2); in release_l2()
2098 if (l2->ch.st) in release_l2()
2099 l2->ch.st->dev->D.ctrl(&l2->ch.st->dev->D, in release_l2()
2102 kfree(l2); in release_l2()
2108 struct layer2 *l2 = container_of(ch, struct layer2, ch); in l2_ctrl() local
2117 if (test_bit(FLG_LAPD, &l2->flag)) { in l2_ctrl()
2118 set_channel_address(&l2->ch, l2->sapi, l2->tei); in l2_ctrl()
2120 l2up_create(l2, DL_INFORMATION_IND, in l2_ctrl()
2125 if (l2->ch.peer) in l2_ctrl()
2126 l2->ch.peer->ctrl(l2->ch.peer, CLOSE_CHANNEL, NULL); in l2_ctrl()
2127 release_l2(l2); in l2_ctrl()
2137 struct layer2 *l2; in create_l2() local
2140 l2 = kzalloc(sizeof(struct layer2), GFP_KERNEL); in create_l2()
2141 if (!l2) { in create_l2()
2145 l2->next_id = 1; in create_l2()
2146 l2->down_id = MISDN_ID_NONE; in create_l2()
2147 l2->up = ch; in create_l2()
2148 l2->ch.st = ch->st; in create_l2()
2149 l2->ch.send = l2_send; in create_l2()
2150 l2->ch.ctrl = l2_ctrl; in create_l2()
2153 test_and_set_bit(FLG_LAPD, &l2->flag); in create_l2()
2154 test_and_set_bit(FLG_LAPD_NET, &l2->flag); in create_l2()
2155 test_and_set_bit(FLG_MOD128, &l2->flag); in create_l2()
2156 l2->sapi = sapi; in create_l2()
2157 l2->maxlen = MAX_DFRAME_LEN; in create_l2()
2159 l2->window = 7; in create_l2()
2161 l2->window = 1; in create_l2()
2163 test_and_set_bit(FLG_PTP, &l2->flag); in create_l2()
2165 test_and_set_bit(FLG_FIXED_TEI, &l2->flag); in create_l2()
2166 l2->tei = tei; in create_l2()
2167 l2->T200 = 1000; in create_l2()
2168 l2->N200 = 3; in create_l2()
2169 l2->T203 = 10000; in create_l2()
2175 l2->ch.st->dev->D.ctrl(&l2->ch.st->dev->D, OPEN_CHANNEL, &rq); in create_l2()
2178 test_and_set_bit(FLG_LAPD, &l2->flag); in create_l2()
2179 test_and_set_bit(FLG_MOD128, &l2->flag); in create_l2()
2180 test_and_set_bit(FLG_ORIG, &l2->flag); in create_l2()
2181 l2->sapi = sapi; in create_l2()
2182 l2->maxlen = MAX_DFRAME_LEN; in create_l2()
2184 l2->window = 7; in create_l2()
2186 l2->window = 1; in create_l2()
2188 test_and_set_bit(FLG_PTP, &l2->flag); in create_l2()
2190 test_and_set_bit(FLG_FIXED_TEI, &l2->flag); in create_l2()
2191 l2->tei = tei; in create_l2()
2192 l2->T200 = 1000; in create_l2()
2193 l2->N200 = 3; in create_l2()
2194 l2->T203 = 10000; in create_l2()
2200 l2->ch.st->dev->D.ctrl(&l2->ch.st->dev->D, OPEN_CHANNEL, &rq); in create_l2()
2203 test_and_set_bit(FLG_LAPB, &l2->flag); in create_l2()
2204 l2->window = 7; in create_l2()
2205 l2->maxlen = MAX_DATA_SIZE; in create_l2()
2206 l2->T200 = 1000; in create_l2()
2207 l2->N200 = 4; in create_l2()
2208 l2->T203 = 5000; in create_l2()
2209 l2->addr.A = 3; in create_l2()
2210 l2->addr.B = 1; in create_l2()
2215 kfree(l2); in create_l2()
2218 skb_queue_head_init(&l2->i_queue); in create_l2()
2219 skb_queue_head_init(&l2->ui_queue); in create_l2()
2220 skb_queue_head_init(&l2->down_queue); in create_l2()
2221 skb_queue_head_init(&l2->tmp_queue); in create_l2()
2222 InitWin(l2); in create_l2()
2223 l2->l2m.fsm = &l2fsm; in create_l2()
2224 if (test_bit(FLG_LAPB, &l2->flag) || in create_l2()
2225 test_bit(FLG_FIXED_TEI, &l2->flag) || in create_l2()
2226 test_bit(FLG_LAPD_NET, &l2->flag)) in create_l2()
2227 l2->l2m.state = ST_L2_4; in create_l2()
2229 l2->l2m.state = ST_L2_1; in create_l2()
2230 l2->l2m.debug = *debug; in create_l2()
2231 l2->l2m.userdata = l2; in create_l2()
2232 l2->l2m.userint = 0; in create_l2()
2233 l2->l2m.printdebug = l2m_debug; in create_l2()
2235 mISDN_FsmInitTimer(&l2->l2m, &l2->t200); in create_l2()
2236 mISDN_FsmInitTimer(&l2->l2m, &l2->t203); in create_l2()
2237 return l2; in create_l2()
2243 struct layer2 *l2; in x75create() local
2247 l2 = create_l2(crq->ch, crq->protocol, 0, 0, 0); in x75create()
2248 if (!l2) in x75create()
2250 crq->ch = &l2->ch; in x75create()