Lines Matching full:l2
92 struct layer2 *l2 = fi->userdata; in l2m_debug() local
104 printk(KERN_DEBUG "%s l2 (sapi %d tei %d): %pV\n", in l2m_debug()
105 mISDNDevName4ch(&l2->ch), l2->sapi, l2->tei, &vaf); in l2m_debug()
111 l2headersize(struct layer2 *l2, int ui) in l2headersize() argument
113 return ((test_bit(FLG_MOD128, &l2->flag) && (!ui)) ? 2 : 1) + in l2headersize()
114 (test_bit(FLG_LAPD, &l2->flag) ? 2 : 1); in l2headersize()
118 l2addrsize(struct layer2 *l2) in l2addrsize() argument
120 return test_bit(FLG_LAPD, &l2->flag) ? 2 : 1; in l2addrsize()
124 l2_newid(struct layer2 *l2) in l2_newid() argument
128 id = l2->next_id++; in l2_newid()
130 l2->next_id = 1; in l2_newid()
132 id |= l2->tei << 8; in l2_newid()
133 id |= l2->sapi; in l2_newid()
138 l2up(struct layer2 *l2, u_int prim, struct sk_buff *skb) in l2up() argument
142 if (!l2->up) in l2up()
145 mISDN_HEAD_ID(skb) = (l2->ch.nr << 16) | l2->ch.addr; in l2up()
146 err = l2->up->send(l2->up, skb); in l2up()
149 mISDNDevName4ch(&l2->ch), err); in l2up()
155 l2up_create(struct layer2 *l2, u_int prim, int len, void *arg) in l2up_create() argument
161 if (!l2->up) in l2up_create()
168 hh->id = (l2->ch.nr << 16) | l2->ch.addr; in l2up_create()
171 err = l2->up->send(l2->up, skb); in l2up_create()
174 mISDNDevName4ch(&l2->ch), err); in l2up_create()
180 l2down_skb(struct layer2 *l2, struct sk_buff *skb) { in l2down_skb() argument
183 ret = l2->ch.recv(l2->ch.peer, skb); in l2down_skb()
186 mISDNDevName4ch(&l2->ch), ret); in l2down_skb()
191 l2down_raw(struct layer2 *l2, struct sk_buff *skb) in l2down_raw() argument
196 if (test_and_set_bit(FLG_L1_NOTREADY, &l2->flag)) { in l2down_raw()
197 skb_queue_tail(&l2->down_queue, skb); in l2down_raw()
200 l2->down_id = mISDN_HEAD_ID(skb); in l2down_raw()
202 return l2down_skb(l2, skb); in l2down_raw()
206 l2down(struct layer2 *l2, u_int prim, u_int id, struct sk_buff *skb) in l2down() argument
212 return l2down_raw(l2, skb); in l2down()
216 l2down_create(struct layer2 *l2, u_int prim, u_int id, int len, void *arg) in l2down_create() argument
230 err = l2down_raw(l2, skb); in l2down_create()
237 ph_data_confirm(struct layer2 *l2, struct mISDNhead *hh, struct sk_buff *skb) { in ph_data_confirm() argument
241 if (test_bit(FLG_L1_NOTREADY, &l2->flag)) { in ph_data_confirm()
242 if (hh->id == l2->down_id) { in ph_data_confirm()
243 nskb = skb_dequeue(&l2->down_queue); in ph_data_confirm()
245 l2->down_id = mISDN_HEAD_ID(nskb); in ph_data_confirm()
246 if (l2down_skb(l2, nskb)) { in ph_data_confirm()
248 l2->down_id = MISDN_ID_NONE; in ph_data_confirm()
251 l2->down_id = MISDN_ID_NONE; in ph_data_confirm()
256 if (l2->down_id == MISDN_ID_NONE) { in ph_data_confirm()
257 test_and_clear_bit(FLG_L1_NOTREADY, &l2->flag); in ph_data_confirm()
258 mISDN_FsmEvent(&l2->l2m, EV_L2_ACK_PULL, NULL); in ph_data_confirm()
262 if (!test_and_set_bit(FLG_L1_NOTREADY, &l2->flag)) { in ph_data_confirm()
263 nskb = skb_dequeue(&l2->down_queue); in ph_data_confirm()
265 l2->down_id = mISDN_HEAD_ID(nskb); in ph_data_confirm()
266 if (l2down_skb(l2, nskb)) { in ph_data_confirm()
268 l2->down_id = MISDN_ID_NONE; in ph_data_confirm()
269 test_and_clear_bit(FLG_L1_NOTREADY, &l2->flag); in ph_data_confirm()
272 test_and_clear_bit(FLG_L1_NOTREADY, &l2->flag); in ph_data_confirm()
280 struct layer2 *l2 = fi->userdata; in l2_timeout() local
286 printk(KERN_WARNING "%s: L2(%d,%d) nr:%x timer %s no skb\n", in l2_timeout()
287 mISDNDevName4ch(&l2->ch), l2->sapi, l2->tei, in l2_timeout()
288 l2->ch.nr, event == EV_L2_T200 ? "T200" : "T203"); in l2_timeout()
293 hh->id = l2->ch.nr; in l2_timeout()
295 printk(KERN_DEBUG "%s: L2(%d,%d) nr:%x timer %s expired\n", in l2_timeout()
296 mISDNDevName4ch(&l2->ch), l2->sapi, l2->tei, in l2_timeout()
297 l2->ch.nr, event == EV_L2_T200 ? "T200" : "T203"); in l2_timeout()
298 if (l2->ch.st) in l2_timeout()
299 l2->ch.st->own.recv(&l2->ch.st->own, skb); in l2_timeout()
303 l2mgr(struct layer2 *l2, u_int prim, void *arg) { in l2mgr() argument
307 mISDNDevName4ch(&l2->ch), l2->id, prim, (char)c); in l2mgr()
308 if (test_bit(FLG_LAPD, &l2->flag) && in l2mgr()
309 !test_bit(FLG_FIXED_TEI, &l2->flag)) { in l2mgr()
315 l2_tei(l2, prim, (u_long)arg); in l2mgr()
323 set_peer_busy(struct layer2 *l2) { in set_peer_busy() argument
324 test_and_set_bit(FLG_PEER_BUSY, &l2->flag); in set_peer_busy()
325 if (skb_queue_len(&l2->i_queue) || skb_queue_len(&l2->ui_queue)) in set_peer_busy()
326 test_and_set_bit(FLG_L2BLOCK, &l2->flag); in set_peer_busy()
330 clear_peer_busy(struct layer2 *l2) { in clear_peer_busy() argument
331 if (test_and_clear_bit(FLG_PEER_BUSY, &l2->flag)) in clear_peer_busy()
332 test_and_clear_bit(FLG_L2BLOCK, &l2->flag); in clear_peer_busy()
336 InitWin(struct layer2 *l2) in InitWin() argument
341 l2->windowar[i] = NULL; in InitWin()
345 freewin(struct layer2 *l2) in freewin() argument
350 if (l2->windowar[i]) { in freewin()
352 dev_kfree_skb(l2->windowar[i]); in freewin()
353 l2->windowar[i] = NULL; in freewin()
360 ReleaseWin(struct layer2 *l2) in ReleaseWin() argument
362 int cnt = freewin(l2); in ReleaseWin()
370 cansend(struct layer2 *l2) in cansend() argument
374 if (test_bit(FLG_MOD128, &l2->flag)) in cansend()
375 p1 = (l2->vs - l2->va) % 128; in cansend()
377 p1 = (l2->vs - l2->va) % 8; in cansend()
378 return (p1 < l2->window) && !test_bit(FLG_PEER_BUSY, &l2->flag); in cansend()
382 clear_exception(struct layer2 *l2) in clear_exception() argument
384 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); in clear_exception()
385 test_and_clear_bit(FLG_REJEXC, &l2->flag); in clear_exception()
386 test_and_clear_bit(FLG_OWN_BUSY, &l2->flag); in clear_exception()
387 clear_peer_busy(l2); in clear_exception()
391 sethdraddr(struct layer2 *l2, u_char *header, int rsp) in sethdraddr() argument
396 if (test_bit(FLG_LAPD, &l2->flag)) { in sethdraddr()
397 if (test_bit(FLG_LAPD_NET, &l2->flag)) in sethdraddr()
399 *ptr++ = (l2->sapi << 2) | (crbit ? 2 : 0); in sethdraddr()
400 *ptr++ = (l2->tei << 1) | 1; in sethdraddr()
403 if (test_bit(FLG_ORIG, &l2->flag)) in sethdraddr()
406 *ptr++ = l2->addr.B; in sethdraddr()
408 *ptr++ = l2->addr.A; in sethdraddr()
414 enqueue_super(struct layer2 *l2, struct sk_buff *skb) in enqueue_super() argument
416 if (l2down(l2, PH_DATA_REQ, l2_newid(l2), skb)) in enqueue_super()
421 enqueue_ui(struct layer2 *l2, struct sk_buff *skb) in enqueue_ui() argument
423 if (l2->tm) in enqueue_ui()
424 l2_tei(l2, MDL_STATUS_UI_IND, 0); in enqueue_ui()
425 if (l2down(l2, PH_DATA_REQ, l2_newid(l2), skb)) in enqueue_ui()
454 IsRR(u_char *data, struct layer2 *l2) in IsRR() argument
456 if (test_bit(FLG_MOD128, &l2->flag)) in IsRR()
463 IsSFrame(u_char *data, struct layer2 *l2) in IsSFrame() argument
467 if (!test_bit(FLG_MOD128, &l2->flag)) in IsSFrame()
473 IsSABME(u_char *data, struct layer2 *l2) in IsSABME() argument
477 return test_bit(FLG_MOD128, &l2->flag) ? d == SABME : d == SABM; in IsSABME()
481 IsREJ(u_char *data, struct layer2 *l2) in IsREJ() argument
483 return test_bit(FLG_MOD128, &l2->flag) ? in IsREJ()
494 IsRNR(u_char *data, struct layer2 *l2) in IsRNR() argument
496 return test_bit(FLG_MOD128, &l2->flag) ? in IsRNR()
501 iframe_error(struct layer2 *l2, struct sk_buff *skb) in iframe_error() argument
506 i = l2addrsize(l2) + (test_bit(FLG_MOD128, &l2->flag) ? 2 : 1); in iframe_error()
507 if (test_bit(FLG_ORIG, &l2->flag)) in iframe_error()
513 if ((skb->len - i) > l2->maxlen) in iframe_error()
519 super_error(struct layer2 *l2, struct sk_buff *skb) in super_error() argument
521 if (skb->len != l2addrsize(l2) + in super_error()
522 (test_bit(FLG_MOD128, &l2->flag) ? 2 : 1)) in super_error()
528 unnum_error(struct layer2 *l2, struct sk_buff *skb, int wantrsp) in unnum_error() argument
531 if (test_bit(FLG_ORIG, &l2->flag)) in unnum_error()
535 if (skb->len != l2addrsize(l2) + 1) in unnum_error()
541 UI_error(struct layer2 *l2, struct sk_buff *skb) in UI_error() argument
544 if (test_bit(FLG_ORIG, &l2->flag)) in UI_error()
548 if (skb->len > l2->maxlen + l2addrsize(l2) + 1) in UI_error()
554 FRMR_error(struct layer2 *l2, struct sk_buff *skb) in FRMR_error() argument
556 u_int headers = l2addrsize(l2) + 1; in FRMR_error()
560 if (test_bit(FLG_ORIG, &l2->flag)) in FRMR_error()
564 if (test_bit(FLG_MOD128, &l2->flag)) { in FRMR_error()
568 l2m_debug(&l2->l2m, in FRMR_error()
575 l2m_debug(&l2->l2m, in FRMR_error()
583 legalnr(struct layer2 *l2, unsigned int nr) in legalnr() argument
585 if (test_bit(FLG_MOD128, &l2->flag)) in legalnr()
586 return ((nr - l2->va) % 128) <= ((l2->vs - l2->va) % 128); in legalnr()
588 return ((nr - l2->va) % 8) <= ((l2->vs - l2->va) % 8); in legalnr()
592 setva(struct layer2 *l2, unsigned int nr) in setva() argument
596 while (l2->va != nr) { in setva()
597 l2->va++; in setva()
598 if (test_bit(FLG_MOD128, &l2->flag)) in setva()
599 l2->va %= 128; in setva()
601 l2->va %= 8; in setva()
602 if (l2->windowar[l2->sow]) { in setva()
603 skb_trim(l2->windowar[l2->sow], 0); in setva()
604 skb_queue_tail(&l2->tmp_queue, l2->windowar[l2->sow]); in setva()
605 l2->windowar[l2->sow] = NULL; in setva()
607 l2->sow = (l2->sow + 1) % l2->window; in setva()
609 skb = skb_dequeue(&l2->tmp_queue); in setva()
612 skb = skb_dequeue(&l2->tmp_queue); in setva()
617 send_uframe(struct layer2 *l2, struct sk_buff *skb, u_char cmd, u_char cr) in send_uframe() argument
622 i = sethdraddr(l2, tmp, cr); in send_uframe()
630 mISDNDevName4ch(&l2->ch), __func__); in send_uframe()
635 enqueue_super(l2, skb); in send_uframe()
640 get_PollFlag(struct layer2 *l2, struct sk_buff *skb) in get_PollFlag() argument
642 return skb->data[l2addrsize(l2)] & 0x10; in get_PollFlag()
646 get_PollFlagFree(struct layer2 *l2, struct sk_buff *skb) in get_PollFlagFree() argument
650 PF = get_PollFlag(l2, skb); in get_PollFlagFree()
656 start_t200(struct layer2 *l2, int i) in start_t200() argument
658 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, i); in start_t200()
659 test_and_set_bit(FLG_T200_RUN, &l2->flag); in start_t200()
663 restart_t200(struct layer2 *l2, int i) in restart_t200() argument
665 mISDN_FsmRestartTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, i); in restart_t200()
666 test_and_set_bit(FLG_T200_RUN, &l2->flag); in restart_t200()
670 stop_t200(struct layer2 *l2, int i) in stop_t200() argument
672 if (test_and_clear_bit(FLG_T200_RUN, &l2->flag)) in stop_t200()
673 mISDN_FsmDelTimer(&l2->t200, i); in stop_t200()
677 st5_dl_release_l2l3(struct layer2 *l2) in st5_dl_release_l2l3() argument
681 if (test_and_clear_bit(FLG_PEND_REL, &l2->flag)) in st5_dl_release_l2l3()
685 l2up_create(l2, pr, 0, NULL); in st5_dl_release_l2l3()
689 lapb_dl_release_l2l3(struct layer2 *l2, int f) in lapb_dl_release_l2l3() argument
691 if (test_bit(FLG_LAPB, &l2->flag)) in lapb_dl_release_l2l3()
692 l2down_create(l2, PH_DEACTIVATE_REQ, l2_newid(l2), 0, NULL); in lapb_dl_release_l2l3()
693 l2up_create(l2, f, 0, NULL); in lapb_dl_release_l2l3()
699 struct layer2 *l2 = fi->userdata; in establishlink() local
702 clear_exception(l2); in establishlink()
703 l2->rc = 0; in establishlink()
704 cmd = (test_bit(FLG_MOD128, &l2->flag) ? SABME : SABM) | 0x10; in establishlink()
705 send_uframe(l2, NULL, cmd, CMD); in establishlink()
706 mISDN_FsmDelTimer(&l2->t203, 1); in establishlink()
707 restart_t200(l2, 1); in establishlink()
708 test_and_clear_bit(FLG_PEND_REL, &l2->flag); in establishlink()
709 freewin(l2); in establishlink()
717 struct layer2 *l2 = fi->userdata; in l2_mdl_error_ua() local
719 if (get_PollFlagFree(l2, skb)) in l2_mdl_error_ua()
720 l2mgr(l2, MDL_ERROR_IND, (void *) 'C'); in l2_mdl_error_ua()
722 l2mgr(l2, MDL_ERROR_IND, (void *) 'D'); in l2_mdl_error_ua()
730 struct layer2 *l2 = fi->userdata; in l2_mdl_error_dm() local
732 if (get_PollFlagFree(l2, skb)) in l2_mdl_error_dm()
733 l2mgr(l2, MDL_ERROR_IND, (void *) 'B'); in l2_mdl_error_dm()
735 l2mgr(l2, MDL_ERROR_IND, (void *) 'E'); in l2_mdl_error_dm()
737 test_and_clear_bit(FLG_L3_INIT, &l2->flag); in l2_mdl_error_dm()
745 struct layer2 *l2 = fi->userdata; in l2_st8_mdl_error_dm() local
747 if (get_PollFlagFree(l2, skb)) in l2_st8_mdl_error_dm()
748 l2mgr(l2, MDL_ERROR_IND, (void *) 'B'); in l2_st8_mdl_error_dm()
750 l2mgr(l2, MDL_ERROR_IND, (void *) 'E'); in l2_st8_mdl_error_dm()
752 test_and_clear_bit(FLG_L3_INIT, &l2->flag); in l2_st8_mdl_error_dm()
765 struct layer2 *l2 = fi->userdata; in l2_mdl_assign() local
769 l2_tei(l2, MDL_ASSIGN_IND, 0); in l2_mdl_assign()
775 struct layer2 *l2 = fi->userdata; in l2_queue_ui_assign() local
778 skb_queue_tail(&l2->ui_queue, skb); in l2_queue_ui_assign()
780 l2_tei(l2, MDL_ASSIGN_IND, 0); in l2_queue_ui_assign()
786 struct layer2 *l2 = fi->userdata; in l2_queue_ui() local
789 skb_queue_tail(&l2->ui_queue, skb); in l2_queue_ui()
793 tx_ui(struct layer2 *l2) in tx_ui() argument
799 i = sethdraddr(l2, header, CMD); in tx_ui()
800 if (test_bit(FLG_LAPD_NET, &l2->flag)) in tx_ui()
803 while ((skb = skb_dequeue(&l2->ui_queue))) { in tx_ui()
805 enqueue_ui(l2, skb); in tx_ui()
812 struct layer2 *l2 = fi->userdata; in l2_send_ui() local
815 skb_queue_tail(&l2->ui_queue, skb); in l2_send_ui()
816 tx_ui(l2); in l2_send_ui()
822 struct layer2 *l2 = fi->userdata; in l2_got_ui() local
825 skb_pull(skb, l2headersize(l2, 1)); in l2_got_ui()
830 if (l2->tm) in l2_got_ui()
831 l2_tei(l2, MDL_STATUS_UI_IND, 0); in l2_got_ui()
832 l2up(l2, DL_UNITDATA_IND, skb); in l2_got_ui()
839 struct layer2 *l2 = fi->userdata; in l2_establish() local
842 test_and_set_bit(FLG_L3_INIT, &l2->flag); in l2_establish()
850 struct layer2 *l2 = fi->userdata; in l2_discard_i_setl3() local
852 skb_queue_purge(&l2->i_queue); in l2_discard_i_setl3()
853 test_and_set_bit(FLG_L3_INIT, &l2->flag); in l2_discard_i_setl3()
854 test_and_clear_bit(FLG_PEND_REL, &l2->flag); in l2_discard_i_setl3()
862 struct layer2 *l2 = fi->userdata; in l2_l3_reestablish() local
864 skb_queue_purge(&l2->i_queue); in l2_l3_reestablish()
866 test_and_set_bit(FLG_L3_INIT, &l2->flag); in l2_l3_reestablish()
873 struct layer2 *l2 = fi->userdata; in l2_release() local
877 l2up(l2, DL_RELEASE_CNF, skb); in l2_release()
884 struct layer2 *l2 = fi->userdata; in l2_pend_rel() local
886 test_and_set_bit(FLG_PEND_REL, &l2->flag); in l2_pend_rel()
893 struct layer2 *l2 = fi->userdata; in l2_disconnect() local
896 skb_queue_purge(&l2->i_queue); in l2_disconnect()
897 freewin(l2); in l2_disconnect()
899 l2->rc = 0; in l2_disconnect()
900 send_uframe(l2, NULL, DISC | 0x10, CMD); in l2_disconnect()
901 mISDN_FsmDelTimer(&l2->t203, 1); in l2_disconnect()
902 restart_t200(l2, 2); in l2_disconnect()
909 struct layer2 *l2 = fi->userdata; in l2_start_multi() local
912 l2->vs = 0; in l2_start_multi()
913 l2->va = 0; in l2_start_multi()
914 l2->vr = 0; in l2_start_multi()
915 l2->sow = 0; in l2_start_multi()
916 clear_exception(l2); in l2_start_multi()
917 send_uframe(l2, NULL, UA | get_PollFlag(l2, skb), RSP); in l2_start_multi()
919 mISDN_FsmAddTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 3); in l2_start_multi()
921 l2up(l2, DL_ESTABLISH_IND, skb); in l2_start_multi()
922 if (l2->tm) in l2_start_multi()
923 l2_tei(l2, MDL_STATUS_UP_IND, 0); in l2_start_multi()
929 struct layer2 *l2 = fi->userdata; in l2_send_UA() local
932 send_uframe(l2, skb, UA | get_PollFlag(l2, skb), RSP); in l2_send_UA()
938 struct layer2 *l2 = fi->userdata; in l2_send_DM() local
941 send_uframe(l2, skb, DM | get_PollFlag(l2, skb), RSP); in l2_send_DM()
947 struct layer2 *l2 = fi->userdata; in l2_restart_multi() local
951 send_uframe(l2, skb, UA | get_PollFlag(l2, skb), RSP); in l2_restart_multi()
953 l2mgr(l2, MDL_ERROR_IND, (void *) 'F'); in l2_restart_multi()
955 if (l2->vs != l2->va) { in l2_restart_multi()
956 skb_queue_purge(&l2->i_queue); in l2_restart_multi()
960 clear_exception(l2); in l2_restart_multi()
961 l2->vs = 0; in l2_restart_multi()
962 l2->va = 0; in l2_restart_multi()
963 l2->vr = 0; in l2_restart_multi()
964 l2->sow = 0; in l2_restart_multi()
966 stop_t200(l2, 3); in l2_restart_multi()
967 mISDN_FsmRestartTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 3); in l2_restart_multi()
970 l2up_create(l2, DL_ESTABLISH_IND, 0, NULL); in l2_restart_multi()
971 /* mISDN_queue_data(&l2->inst, l2->inst.id | MSG_BROADCAST, in l2_restart_multi()
975 if (skb_queue_len(&l2->i_queue) && cansend(l2)) in l2_restart_multi()
982 struct layer2 *l2 = fi->userdata; in l2_stop_multi() local
986 mISDN_FsmDelTimer(&l2->t203, 3); in l2_stop_multi()
987 stop_t200(l2, 4); in l2_stop_multi()
989 send_uframe(l2, skb, UA | get_PollFlag(l2, skb), RSP); in l2_stop_multi()
990 skb_queue_purge(&l2->i_queue); in l2_stop_multi()
991 freewin(l2); in l2_stop_multi()
992 lapb_dl_release_l2l3(l2, DL_RELEASE_IND); in l2_stop_multi()
993 if (l2->tm) in l2_stop_multi()
994 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_stop_multi()
1000 struct layer2 *l2 = fi->userdata; in l2_connected() local
1004 if (!get_PollFlag(l2, skb)) { in l2_connected()
1009 if (test_and_clear_bit(FLG_PEND_REL, &l2->flag)) in l2_connected()
1011 if (test_and_clear_bit(FLG_L3_INIT, &l2->flag)) { in l2_connected()
1013 } else if (l2->vs != l2->va) { in l2_connected()
1014 skb_queue_purge(&l2->i_queue); in l2_connected()
1017 stop_t200(l2, 5); in l2_connected()
1018 l2->vr = 0; in l2_connected()
1019 l2->vs = 0; in l2_connected()
1020 l2->va = 0; in l2_connected()
1021 l2->sow = 0; in l2_connected()
1023 mISDN_FsmAddTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 4); in l2_connected()
1025 l2up_create(l2, pr, 0, NULL); in l2_connected()
1027 if (skb_queue_len(&l2->i_queue) && cansend(l2)) in l2_connected()
1030 if (l2->tm) in l2_connected()
1031 l2_tei(l2, MDL_STATUS_UP_IND, 0); in l2_connected()
1037 struct layer2 *l2 = fi->userdata; in l2_released() local
1040 if (!get_PollFlag(l2, skb)) { in l2_released()
1045 stop_t200(l2, 6); in l2_released()
1046 lapb_dl_release_l2l3(l2, DL_RELEASE_CNF); in l2_released()
1048 if (l2->tm) in l2_released()
1049 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_released()
1055 struct layer2 *l2 = fi->userdata; in l2_reestablish() local
1058 if (!get_PollFlagFree(l2, skb)) { in l2_reestablish()
1060 test_and_set_bit(FLG_L3_INIT, &l2->flag); in l2_reestablish()
1067 struct layer2 *l2 = fi->userdata; in l2_st5_dm_release() local
1070 if (get_PollFlagFree(l2, skb)) { in l2_st5_dm_release()
1071 stop_t200(l2, 7); in l2_st5_dm_release()
1072 if (!test_bit(FLG_L3_INIT, &l2->flag)) in l2_st5_dm_release()
1073 skb_queue_purge(&l2->i_queue); in l2_st5_dm_release()
1074 if (test_bit(FLG_LAPB, &l2->flag)) in l2_st5_dm_release()
1075 l2down_create(l2, PH_DEACTIVATE_REQ, in l2_st5_dm_release()
1076 l2_newid(l2), 0, NULL); in l2_st5_dm_release()
1077 st5_dl_release_l2l3(l2); in l2_st5_dm_release()
1079 if (l2->tm) in l2_st5_dm_release()
1080 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_st5_dm_release()
1087 struct layer2 *l2 = fi->userdata; in l2_st6_dm_release() local
1090 if (get_PollFlagFree(l2, skb)) { in l2_st6_dm_release()
1091 stop_t200(l2, 8); in l2_st6_dm_release()
1092 lapb_dl_release_l2l3(l2, DL_RELEASE_CNF); in l2_st6_dm_release()
1094 if (l2->tm) in l2_st6_dm_release()
1095 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_st6_dm_release()
1100 enquiry_cr(struct layer2 *l2, u_char typ, u_char cr, u_char pf) in enquiry_cr() argument
1106 i = sethdraddr(l2, tmp, cr); in enquiry_cr()
1107 if (test_bit(FLG_MOD128, &l2->flag)) { in enquiry_cr()
1109 tmp[i++] = (l2->vr << 1) | (pf ? 1 : 0); in enquiry_cr()
1111 tmp[i++] = (l2->vr << 5) | typ | (pf ? 0x10 : 0); in enquiry_cr()
1115 mISDNDevName4ch(&l2->ch), __func__); in enquiry_cr()
1119 enqueue_super(l2, skb); in enquiry_cr()
1123 enquiry_response(struct layer2 *l2) in enquiry_response() argument
1125 if (test_bit(FLG_OWN_BUSY, &l2->flag)) in enquiry_response()
1126 enquiry_cr(l2, RNR, RSP, 1); in enquiry_response()
1128 enquiry_cr(l2, RR, RSP, 1); in enquiry_response()
1129 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); in enquiry_response()
1133 transmit_enquiry(struct layer2 *l2) in transmit_enquiry() argument
1135 if (test_bit(FLG_OWN_BUSY, &l2->flag)) in transmit_enquiry()
1136 enquiry_cr(l2, RNR, CMD, 1); in transmit_enquiry()
1138 enquiry_cr(l2, RR, CMD, 1); in transmit_enquiry()
1139 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); in transmit_enquiry()
1140 start_t200(l2, 9); in transmit_enquiry()
1147 struct layer2 *l2 = fi->userdata; in nrerrorrecovery() local
1149 l2mgr(l2, MDL_ERROR_IND, (void *) 'J'); in nrerrorrecovery()
1151 test_and_clear_bit(FLG_L3_INIT, &l2->flag); in nrerrorrecovery()
1155 invoke_retransmission(struct layer2 *l2, unsigned int nr) in invoke_retransmission() argument
1159 if (l2->vs != nr) { in invoke_retransmission()
1160 while (l2->vs != nr) { in invoke_retransmission()
1161 (l2->vs)--; in invoke_retransmission()
1162 if (test_bit(FLG_MOD128, &l2->flag)) { in invoke_retransmission()
1163 l2->vs %= 128; in invoke_retransmission()
1164 p1 = (l2->vs - l2->va) % 128; in invoke_retransmission()
1166 l2->vs %= 8; in invoke_retransmission()
1167 p1 = (l2->vs - l2->va) % 8; in invoke_retransmission()
1169 p1 = (p1 + l2->sow) % l2->window; in invoke_retransmission()
1170 if (l2->windowar[p1]) in invoke_retransmission()
1171 skb_queue_head(&l2->i_queue, l2->windowar[p1]); in invoke_retransmission()
1175 mISDNDevName4ch(&l2->ch), p1); in invoke_retransmission()
1176 l2->windowar[p1] = NULL; in invoke_retransmission()
1178 mISDN_FsmEvent(&l2->l2m, EV_L2_ACK_PULL, NULL); in invoke_retransmission()
1185 struct layer2 *l2 = fi->userdata; in l2_st7_got_super() local
1191 if (test_bit(FLG_ORIG, &l2->flag)) in l2_st7_got_super()
1194 skb_pull(skb, l2addrsize(l2)); in l2_st7_got_super()
1195 if (IsRNR(skb->data, l2)) { in l2_st7_got_super()
1196 set_peer_busy(l2); in l2_st7_got_super()
1199 clear_peer_busy(l2); in l2_st7_got_super()
1200 if (IsREJ(skb->data, l2)) in l2_st7_got_super()
1203 if (test_bit(FLG_MOD128, &l2->flag)) { in l2_st7_got_super()
1214 l2mgr(l2, MDL_ERROR_IND, (void *) 'A'); in l2_st7_got_super()
1216 enquiry_response(l2); in l2_st7_got_super()
1218 if (legalnr(l2, nr)) { in l2_st7_got_super()
1220 setva(l2, nr); in l2_st7_got_super()
1221 invoke_retransmission(l2, nr); in l2_st7_got_super()
1222 stop_t200(l2, 10); in l2_st7_got_super()
1223 if (mISDN_FsmAddTimer(&l2->t203, l2->T203, in l2_st7_got_super()
1225 l2m_debug(&l2->l2m, "Restart T203 ST7 REJ"); in l2_st7_got_super()
1226 } else if ((nr == l2->vs) && (typ == RR)) { in l2_st7_got_super()
1227 setva(l2, nr); in l2_st7_got_super()
1228 stop_t200(l2, 11); in l2_st7_got_super()
1229 mISDN_FsmRestartTimer(&l2->t203, l2->T203, in l2_st7_got_super()
1231 } else if ((l2->va != nr) || (typ == RNR)) { in l2_st7_got_super()
1232 setva(l2, nr); in l2_st7_got_super()
1234 mISDN_FsmDelTimer(&l2->t203, 9); in l2_st7_got_super()
1235 restart_t200(l2, 12); in l2_st7_got_super()
1237 if (skb_queue_len(&l2->i_queue) && (typ == RR)) in l2_st7_got_super()
1246 struct layer2 *l2 = fi->userdata; in l2_feed_i_if_reest() local
1249 if (!test_bit(FLG_L3_INIT, &l2->flag)) in l2_feed_i_if_reest()
1250 skb_queue_tail(&l2->i_queue, skb); in l2_feed_i_if_reest()
1258 struct layer2 *l2 = fi->userdata; in l2_feed_i_pull() local
1261 skb_queue_tail(&l2->i_queue, skb); in l2_feed_i_pull()
1268 struct layer2 *l2 = fi->userdata; in l2_feed_iqueue() local
1271 skb_queue_tail(&l2->i_queue, skb); in l2_feed_iqueue()
1277 struct layer2 *l2 = fi->userdata; in l2_got_iframe() local
1282 i = l2addrsize(l2); in l2_got_iframe()
1283 if (test_bit(FLG_MOD128, &l2->flag)) { in l2_got_iframe()
1292 if (test_bit(FLG_OWN_BUSY, &l2->flag)) { in l2_got_iframe()
1295 enquiry_response(l2); in l2_got_iframe()
1297 if (l2->vr == ns) { in l2_got_iframe()
1298 l2->vr++; in l2_got_iframe()
1299 if (test_bit(FLG_MOD128, &l2->flag)) in l2_got_iframe()
1300 l2->vr %= 128; in l2_got_iframe()
1302 l2->vr %= 8; in l2_got_iframe()
1303 test_and_clear_bit(FLG_REJEXC, &l2->flag); in l2_got_iframe()
1305 enquiry_response(l2); in l2_got_iframe()
1307 test_and_set_bit(FLG_ACK_PEND, &l2->flag); in l2_got_iframe()
1308 skb_pull(skb, l2headersize(l2, 0)); in l2_got_iframe()
1309 l2up(l2, DL_DATA_IND, skb); in l2_got_iframe()
1313 if (test_and_set_bit(FLG_REJEXC, &l2->flag)) { in l2_got_iframe()
1315 enquiry_response(l2); in l2_got_iframe()
1317 enquiry_cr(l2, REJ, RSP, PollFlag); in l2_got_iframe()
1318 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); in l2_got_iframe()
1322 if (legalnr(l2, nr)) { in l2_got_iframe()
1323 if (!test_bit(FLG_PEER_BUSY, &l2->flag) && in l2_got_iframe()
1325 if (nr == l2->vs) { in l2_got_iframe()
1326 stop_t200(l2, 13); in l2_got_iframe()
1327 mISDN_FsmRestartTimer(&l2->t203, l2->T203, in l2_got_iframe()
1329 } else if (nr != l2->va) in l2_got_iframe()
1330 restart_t200(l2, 14); in l2_got_iframe()
1332 setva(l2, nr); in l2_got_iframe()
1337 if (skb_queue_len(&l2->i_queue) && (fi->state == ST_L2_7)) in l2_got_iframe()
1339 if (test_and_clear_bit(FLG_ACK_PEND, &l2->flag)) in l2_got_iframe()
1340 enquiry_cr(l2, RR, RSP, 0); in l2_got_iframe()
1346 struct layer2 *l2 = fi->userdata; in l2_got_tei() local
1349 l2->tei = (signed char)(long)arg; in l2_got_tei()
1350 set_channel_address(&l2->ch, l2->sapi, l2->tei); in l2_got_tei()
1352 l2up_create(l2, DL_INFORMATION_IND, sizeof(info), &info); in l2_got_tei()
1355 test_and_set_bit(FLG_L3_INIT, &l2->flag); in l2_got_tei()
1358 if (skb_queue_len(&l2->ui_queue)) in l2_got_tei()
1359 tx_ui(l2); in l2_got_tei()
1365 struct layer2 *l2 = fi->userdata; in l2_st5_tout_200() local
1367 if (test_bit(FLG_LAPD, &l2->flag) && in l2_st5_tout_200()
1368 test_bit(FLG_DCHAN_BUSY, &l2->flag)) { in l2_st5_tout_200()
1369 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); in l2_st5_tout_200()
1370 } else if (l2->rc == l2->N200) { in l2_st5_tout_200()
1372 test_and_clear_bit(FLG_T200_RUN, &l2->flag); in l2_st5_tout_200()
1373 skb_queue_purge(&l2->i_queue); in l2_st5_tout_200()
1374 l2mgr(l2, MDL_ERROR_IND, (void *) 'G'); in l2_st5_tout_200()
1375 if (test_bit(FLG_LAPB, &l2->flag)) in l2_st5_tout_200()
1376 l2down_create(l2, PH_DEACTIVATE_REQ, in l2_st5_tout_200()
1377 l2_newid(l2), 0, NULL); in l2_st5_tout_200()
1378 st5_dl_release_l2l3(l2); in l2_st5_tout_200()
1379 if (l2->tm) in l2_st5_tout_200()
1380 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_st5_tout_200()
1382 l2->rc++; in l2_st5_tout_200()
1383 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); in l2_st5_tout_200()
1384 send_uframe(l2, NULL, (test_bit(FLG_MOD128, &l2->flag) ? in l2_st5_tout_200()
1392 struct layer2 *l2 = fi->userdata; in l2_st6_tout_200() local
1394 if (test_bit(FLG_LAPD, &l2->flag) && in l2_st6_tout_200()
1395 test_bit(FLG_DCHAN_BUSY, &l2->flag)) { in l2_st6_tout_200()
1396 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); in l2_st6_tout_200()
1397 } else if (l2->rc == l2->N200) { in l2_st6_tout_200()
1399 test_and_clear_bit(FLG_T200_RUN, &l2->flag); in l2_st6_tout_200()
1400 l2mgr(l2, MDL_ERROR_IND, (void *) 'H'); in l2_st6_tout_200()
1401 lapb_dl_release_l2l3(l2, DL_RELEASE_CNF); in l2_st6_tout_200()
1402 if (l2->tm) in l2_st6_tout_200()
1403 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_st6_tout_200()
1405 l2->rc++; in l2_st6_tout_200()
1406 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, in l2_st6_tout_200()
1408 send_uframe(l2, NULL, DISC | 0x10, CMD); in l2_st6_tout_200()
1415 struct layer2 *l2 = fi->userdata; in l2_st7_tout_200() local
1417 if (test_bit(FLG_LAPD, &l2->flag) && in l2_st7_tout_200()
1418 test_bit(FLG_DCHAN_BUSY, &l2->flag)) { in l2_st7_tout_200()
1419 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); in l2_st7_tout_200()
1422 test_and_clear_bit(FLG_T200_RUN, &l2->flag); in l2_st7_tout_200()
1423 l2->rc = 0; in l2_st7_tout_200()
1425 transmit_enquiry(l2); in l2_st7_tout_200()
1426 l2->rc++; in l2_st7_tout_200()
1432 struct layer2 *l2 = fi->userdata; in l2_st8_tout_200() local
1434 if (test_bit(FLG_LAPD, &l2->flag) && in l2_st8_tout_200()
1435 test_bit(FLG_DCHAN_BUSY, &l2->flag)) { in l2_st8_tout_200()
1436 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 9); in l2_st8_tout_200()
1439 test_and_clear_bit(FLG_T200_RUN, &l2->flag); in l2_st8_tout_200()
1440 if (l2->rc == l2->N200) { in l2_st8_tout_200()
1441 l2mgr(l2, MDL_ERROR_IND, (void *) 'I'); in l2_st8_tout_200()
1443 test_and_clear_bit(FLG_L3_INIT, &l2->flag); in l2_st8_tout_200()
1445 transmit_enquiry(l2); in l2_st8_tout_200()
1446 l2->rc++; in l2_st8_tout_200()
1453 struct layer2 *l2 = fi->userdata; in l2_st7_tout_203() local
1455 if (test_bit(FLG_LAPD, &l2->flag) && in l2_st7_tout_203()
1456 test_bit(FLG_DCHAN_BUSY, &l2->flag)) { in l2_st7_tout_203()
1457 mISDN_FsmAddTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 9); in l2_st7_tout_203()
1461 transmit_enquiry(l2); in l2_st7_tout_203()
1462 l2->rc = 0; in l2_st7_tout_203()
1468 struct layer2 *l2 = fi->userdata; in l2_pull_iqueue() local
1473 if (!cansend(l2)) in l2_pull_iqueue()
1476 skb = skb_dequeue(&l2->i_queue); in l2_pull_iqueue()
1479 i = sethdraddr(l2, header, CMD); in l2_pull_iqueue()
1480 if (test_bit(FLG_MOD128, &l2->flag)) { in l2_pull_iqueue()
1481 header[i++] = l2->vs << 1; in l2_pull_iqueue()
1482 header[i++] = l2->vr << 1; in l2_pull_iqueue()
1484 header[i++] = (l2->vr << 5) | (l2->vs << 1); in l2_pull_iqueue()
1488 mISDNDevName4ch(&l2->ch), i); in l2_pull_iqueue()
1489 skb_queue_head(&l2->i_queue, skb); in l2_pull_iqueue()
1492 if (test_bit(FLG_MOD128, &l2->flag)) { in l2_pull_iqueue()
1493 p1 = (l2->vs - l2->va) % 128; in l2_pull_iqueue()
1494 l2->vs = (l2->vs + 1) % 128; in l2_pull_iqueue()
1496 p1 = (l2->vs - l2->va) % 8; in l2_pull_iqueue()
1497 l2->vs = (l2->vs + 1) % 8; in l2_pull_iqueue()
1499 p1 = (p1 + l2->sow) % l2->window; in l2_pull_iqueue()
1500 if (l2->windowar[p1]) { in l2_pull_iqueue()
1501 printk(KERN_WARNING "%s: l2 try overwrite ack queue entry %d\n", in l2_pull_iqueue()
1502 mISDNDevName4ch(&l2->ch), p1); in l2_pull_iqueue()
1503 dev_kfree_skb(l2->windowar[p1]); in l2_pull_iqueue()
1505 l2->windowar[p1] = skb; in l2_pull_iqueue()
1507 l2down(l2, PH_DATA_REQ, l2_newid(l2), nskb); in l2_pull_iqueue()
1508 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); in l2_pull_iqueue()
1509 if (!test_and_set_bit(FLG_T200_RUN, &l2->flag)) { in l2_pull_iqueue()
1510 mISDN_FsmDelTimer(&l2->t203, 13); in l2_pull_iqueue()
1511 mISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 11); in l2_pull_iqueue()
1518 struct layer2 *l2 = fi->userdata; in l2_st8_got_super() local
1524 if (test_bit(FLG_ORIG, &l2->flag)) in l2_st8_got_super()
1527 skb_pull(skb, l2addrsize(l2)); in l2_st8_got_super()
1529 if (IsRNR(skb->data, l2)) { in l2_st8_got_super()
1530 set_peer_busy(l2); in l2_st8_got_super()
1533 clear_peer_busy(l2); in l2_st8_got_super()
1535 if (test_bit(FLG_MOD128, &l2->flag)) { in l2_st8_got_super()
1544 if (legalnr(l2, nr)) { in l2_st8_got_super()
1546 restart_t200(l2, 15); in l2_st8_got_super()
1548 stop_t200(l2, 16); in l2_st8_got_super()
1549 mISDN_FsmAddTimer(&l2->t203, l2->T203, in l2_st8_got_super()
1551 setva(l2, nr); in l2_st8_got_super()
1553 invoke_retransmission(l2, nr); in l2_st8_got_super()
1555 if (skb_queue_len(&l2->i_queue) && cansend(l2)) in l2_st8_got_super()
1561 enquiry_response(l2); in l2_st8_got_super()
1562 if (legalnr(l2, nr)) in l2_st8_got_super()
1563 setva(l2, nr); in l2_st8_got_super()
1572 struct layer2 *l2 = fi->userdata; in l2_got_FRMR() local
1575 skb_pull(skb, l2addrsize(l2) + 1); in l2_got_FRMR()
1579 l2mgr(l2, MDL_ERROR_IND, (void *) 'K'); in l2_got_FRMR()
1581 test_and_clear_bit(FLG_L3_INIT, &l2->flag); in l2_got_FRMR()
1589 struct layer2 *l2 = fi->userdata; in l2_st24_tei_remove() local
1591 skb_queue_purge(&l2->ui_queue); in l2_st24_tei_remove()
1592 l2->tei = GROUP_TEI; in l2_st24_tei_remove()
1599 struct layer2 *l2 = fi->userdata; in l2_st3_tei_remove() local
1601 skb_queue_purge(&l2->ui_queue); in l2_st3_tei_remove()
1602 l2->tei = GROUP_TEI; in l2_st3_tei_remove()
1603 l2up_create(l2, DL_RELEASE_IND, 0, NULL); in l2_st3_tei_remove()
1610 struct layer2 *l2 = fi->userdata; in l2_st5_tei_remove() local
1612 skb_queue_purge(&l2->i_queue); in l2_st5_tei_remove()
1613 skb_queue_purge(&l2->ui_queue); in l2_st5_tei_remove()
1614 freewin(l2); in l2_st5_tei_remove()
1615 l2->tei = GROUP_TEI; in l2_st5_tei_remove()
1616 stop_t200(l2, 17); in l2_st5_tei_remove()
1617 st5_dl_release_l2l3(l2); in l2_st5_tei_remove()
1624 struct layer2 *l2 = fi->userdata; in l2_st6_tei_remove() local
1626 skb_queue_purge(&l2->ui_queue); in l2_st6_tei_remove()
1627 l2->tei = GROUP_TEI; in l2_st6_tei_remove()
1628 stop_t200(l2, 18); in l2_st6_tei_remove()
1629 l2up_create(l2, DL_RELEASE_IND, 0, NULL); in l2_st6_tei_remove()
1636 struct layer2 *l2 = fi->userdata; in l2_tei_remove() local
1638 skb_queue_purge(&l2->i_queue); in l2_tei_remove()
1639 skb_queue_purge(&l2->ui_queue); in l2_tei_remove()
1640 freewin(l2); in l2_tei_remove()
1641 l2->tei = GROUP_TEI; in l2_tei_remove()
1642 stop_t200(l2, 17); in l2_tei_remove()
1643 mISDN_FsmDelTimer(&l2->t203, 19); in l2_tei_remove()
1644 l2up_create(l2, DL_RELEASE_IND, 0, NULL); in l2_tei_remove()
1645 /* mISDN_queue_data(&l2->inst, l2->inst.id | MSG_BROADCAST, in l2_tei_remove()
1655 struct layer2 *l2 = fi->userdata; in l2_st14_persistent_da() local
1658 skb_queue_purge(&l2->i_queue); in l2_st14_persistent_da()
1659 skb_queue_purge(&l2->ui_queue); in l2_st14_persistent_da()
1660 if (test_and_clear_bit(FLG_ESTAB_PEND, &l2->flag)) in l2_st14_persistent_da()
1661 l2up(l2, DL_RELEASE_IND, skb); in l2_st14_persistent_da()
1669 struct layer2 *l2 = fi->userdata; in l2_st5_persistent_da() local
1672 skb_queue_purge(&l2->i_queue); in l2_st5_persistent_da()
1673 skb_queue_purge(&l2->ui_queue); in l2_st5_persistent_da()
1674 freewin(l2); in l2_st5_persistent_da()
1675 stop_t200(l2, 19); in l2_st5_persistent_da()
1676 st5_dl_release_l2l3(l2); in l2_st5_persistent_da()
1678 if (l2->tm) in l2_st5_persistent_da()
1679 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_st5_persistent_da()
1686 struct layer2 *l2 = fi->userdata; in l2_st6_persistent_da() local
1689 skb_queue_purge(&l2->ui_queue); in l2_st6_persistent_da()
1690 stop_t200(l2, 20); in l2_st6_persistent_da()
1691 l2up(l2, DL_RELEASE_CNF, skb); in l2_st6_persistent_da()
1693 if (l2->tm) in l2_st6_persistent_da()
1694 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_st6_persistent_da()
1700 struct layer2 *l2 = fi->userdata; in l2_persistent_da() local
1703 skb_queue_purge(&l2->i_queue); in l2_persistent_da()
1704 skb_queue_purge(&l2->ui_queue); in l2_persistent_da()
1705 freewin(l2); in l2_persistent_da()
1706 stop_t200(l2, 19); in l2_persistent_da()
1707 mISDN_FsmDelTimer(&l2->t203, 19); in l2_persistent_da()
1708 l2up(l2, DL_RELEASE_IND, skb); in l2_persistent_da()
1710 if (l2->tm) in l2_persistent_da()
1711 l2_tei(l2, MDL_STATUS_DOWN_IND, 0); in l2_persistent_da()
1717 struct layer2 *l2 = fi->userdata; in l2_set_own_busy() local
1720 if (!test_and_set_bit(FLG_OWN_BUSY, &l2->flag)) { in l2_set_own_busy()
1721 enquiry_cr(l2, RNR, RSP, 0); in l2_set_own_busy()
1722 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); in l2_set_own_busy()
1730 struct layer2 *l2 = fi->userdata; in l2_clear_own_busy() local
1733 if (!test_and_clear_bit(FLG_OWN_BUSY, &l2->flag)) { in l2_clear_own_busy()
1734 enquiry_cr(l2, RR, RSP, 0); in l2_clear_own_busy()
1735 test_and_clear_bit(FLG_ACK_PEND, &l2->flag); in l2_clear_own_busy()
1743 struct layer2 *l2 = fi->userdata; in l2_frame_error() local
1745 l2mgr(l2, MDL_ERROR_IND, arg); in l2_frame_error()
1751 struct layer2 *l2 = fi->userdata; in l2_frame_error_reest() local
1753 l2mgr(l2, MDL_ERROR_IND, arg); in l2_frame_error_reest()
1755 test_and_clear_bit(FLG_L3_INIT, &l2->flag); in l2_frame_error_reest()
1856 ph_data_indication(struct layer2 *l2, struct mISDNhead *hh, struct sk_buff *skb) in ph_data_indication() argument
1864 l = l2addrsize(l2); in ph_data_indication()
1866 mISDN_FsmEvent(&l2->l2m, EV_L2_FRAME_ERROR, (void *) 'N'); in ph_data_indication()
1869 if (test_bit(FLG_LAPD, &l2->flag)) { /* Maybe not needed */ in ph_data_indication()
1874 "%s l2 D-channel frame wrong EA0/EA1\n", in ph_data_indication()
1875 mISDNDevName4ch(&l2->ch)); in ph_data_indication()
1880 if (psapi != l2->sapi) { in ph_data_indication()
1884 mISDNDevName4ch(&l2->ch), psapi, in ph_data_indication()
1885 l2->sapi); in ph_data_indication()
1889 if ((ptei != l2->tei) && (ptei != GROUP_TEI)) { in ph_data_indication()
1893 mISDNDevName4ch(&l2->ch), ptei, l2->tei); in ph_data_indication()
1900 c = iframe_error(l2, skb); in ph_data_indication()
1902 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_I, skb); in ph_data_indication()
1903 } else if (IsSFrame(datap, l2)) { /* S-Frame */ in ph_data_indication()
1904 c = super_error(l2, skb); in ph_data_indication()
1906 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_SUPER, skb); in ph_data_indication()
1908 c = UI_error(l2, skb); in ph_data_indication()
1910 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_UI, skb); in ph_data_indication()
1911 } else if (IsSABME(datap, l2)) { in ph_data_indication()
1912 c = unnum_error(l2, skb, CMD); in ph_data_indication()
1914 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_SABME, skb); in ph_data_indication()
1916 c = unnum_error(l2, skb, RSP); in ph_data_indication()
1918 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_UA, skb); in ph_data_indication()
1920 c = unnum_error(l2, skb, CMD); in ph_data_indication()
1922 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DISC, skb); in ph_data_indication()
1924 c = unnum_error(l2, skb, RSP); in ph_data_indication()
1926 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DM, skb); in ph_data_indication()
1928 c = FRMR_error(l2, skb); in ph_data_indication()
1930 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_FRMR, skb); in ph_data_indication()
1934 printk(KERN_WARNING "%s:l2 D-channel frame error %c\n", in ph_data_indication()
1935 mISDNDevName4ch(&l2->ch), c); in ph_data_indication()
1936 mISDN_FsmEvent(&l2->l2m, EV_L2_FRAME_ERROR, (void *)(long)c); in ph_data_indication()
1944 struct layer2 *l2 = container_of(ch, struct layer2, ch); in l2_send() local
1950 __func__, mISDNDevName4ch(&l2->ch), hh->prim, hh->id, in l2_send()
1951 l2->sapi, l2->tei); in l2_send()
1958 mISDNDevName4ch(&l2->ch), hh->prim, hh->id); in l2_send()
1962 ret = ph_data_indication(l2, hh, skb); in l2_send()
1965 ret = ph_data_confirm(l2, hh, skb); in l2_send()
1968 test_and_set_bit(FLG_L1_ACTIV, &l2->flag); in l2_send()
1969 l2up_create(l2, MPH_ACTIVATE_IND, 0, NULL); in l2_send()
1970 if (test_and_clear_bit(FLG_ESTAB_PEND, &l2->flag)) in l2_send()
1971 ret = mISDN_FsmEvent(&l2->l2m, in l2_send()
1975 test_and_clear_bit(FLG_L1_ACTIV, &l2->flag); in l2_send()
1976 l2up_create(l2, MPH_DEACTIVATE_IND, 0, NULL); in l2_send()
1977 ret = mISDN_FsmEvent(&l2->l2m, EV_L1_DEACTIVATE, skb); in l2_send()
1980 if (!l2->up) in l2_send()
1982 ret = l2->up->send(l2->up, skb); in l2_send()
1985 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DL_DATA, skb); in l2_send()
1988 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DL_UNITDATA, skb); in l2_send()
1991 if (test_bit(FLG_LAPB, &l2->flag)) in l2_send()
1992 test_and_set_bit(FLG_ORIG, &l2->flag); in l2_send()
1993 if (test_bit(FLG_L1_ACTIV, &l2->flag)) { in l2_send()
1994 if (test_bit(FLG_LAPD, &l2->flag) || in l2_send()
1995 test_bit(FLG_ORIG, &l2->flag)) in l2_send()
1996 ret = mISDN_FsmEvent(&l2->l2m, in l2_send()
1999 if (test_bit(FLG_LAPD, &l2->flag) || in l2_send()
2000 test_bit(FLG_ORIG, &l2->flag)) { in l2_send()
2002 &l2->flag); in l2_send()
2004 ret = l2down(l2, PH_ACTIVATE_REQ, l2_newid(l2), in l2_send()
2009 if (test_bit(FLG_LAPB, &l2->flag)) in l2_send()
2010 l2down_create(l2, PH_DEACTIVATE_REQ, in l2_send()
2011 l2_newid(l2), 0, NULL); in l2_send()
2012 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_DL_RELEASE_REQ, in l2_send()
2016 mISDN_FsmEvent(&l2->l2m, EV_L2_T200I, NULL); in l2_send()
2019 mISDN_FsmEvent(&l2->l2m, EV_L2_T203I, NULL); in l2_send()
2023 l2m_debug(&l2->l2m, "l2 unknown pr %04x", in l2_send()
2034 tei_l2(struct layer2 *l2, u_int cmd, u_long arg) in tei_l2() argument
2040 mISDNDevName4ch(&l2->ch), cmd, __func__); in tei_l2()
2043 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_MDL_ASSIGN, (void *)arg); in tei_l2()
2046 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_MDL_REMOVE, NULL); in tei_l2()
2049 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_MDL_ERROR, NULL); in tei_l2()
2054 mISDNDevName4ch(&l2->ch)); in tei_l2()
2055 ret = mISDN_FsmEvent(&l2->l2m, EV_L2_MDL_ERROR, NULL); in tei_l2()
2062 release_l2(struct layer2 *l2) in release_l2() argument
2064 mISDN_FsmDelTimer(&l2->t200, 21); in release_l2()
2065 mISDN_FsmDelTimer(&l2->t203, 16); in release_l2()
2066 skb_queue_purge(&l2->i_queue); in release_l2()
2067 skb_queue_purge(&l2->ui_queue); in release_l2()
2068 skb_queue_purge(&l2->down_queue); in release_l2()
2069 ReleaseWin(l2); in release_l2()
2070 if (test_bit(FLG_LAPD, &l2->flag)) { in release_l2()
2071 TEIrelease(l2); in release_l2()
2072 if (l2->ch.st) in release_l2()
2073 l2->ch.st->dev->D.ctrl(&l2->ch.st->dev->D, in release_l2()
2076 kfree(l2); in release_l2()
2082 struct layer2 *l2 = container_of(ch, struct layer2, ch); in l2_ctrl() local
2091 if (test_bit(FLG_LAPD, &l2->flag)) { in l2_ctrl()
2092 set_channel_address(&l2->ch, l2->sapi, l2->tei); in l2_ctrl()
2094 l2up_create(l2, DL_INFORMATION_IND, in l2_ctrl()
2099 if (l2->ch.peer) in l2_ctrl()
2100 l2->ch.peer->ctrl(l2->ch.peer, CLOSE_CHANNEL, NULL); in l2_ctrl()
2101 release_l2(l2); in l2_ctrl()
2111 struct layer2 *l2; in create_l2() local
2114 l2 = kzalloc(sizeof(struct layer2), GFP_KERNEL); in create_l2()
2115 if (!l2) { in create_l2()
2119 l2->next_id = 1; in create_l2()
2120 l2->down_id = MISDN_ID_NONE; in create_l2()
2121 l2->up = ch; in create_l2()
2122 l2->ch.st = ch->st; in create_l2()
2123 l2->ch.send = l2_send; in create_l2()
2124 l2->ch.ctrl = l2_ctrl; in create_l2()
2127 test_and_set_bit(FLG_LAPD, &l2->flag); in create_l2()
2128 test_and_set_bit(FLG_LAPD_NET, &l2->flag); in create_l2()
2129 test_and_set_bit(FLG_MOD128, &l2->flag); in create_l2()
2130 l2->sapi = sapi; in create_l2()
2131 l2->maxlen = MAX_DFRAME_LEN; in create_l2()
2133 l2->window = 7; in create_l2()
2135 l2->window = 1; in create_l2()
2137 test_and_set_bit(FLG_PTP, &l2->flag); in create_l2()
2139 test_and_set_bit(FLG_FIXED_TEI, &l2->flag); in create_l2()
2140 l2->tei = tei; in create_l2()
2141 l2->T200 = 1000; in create_l2()
2142 l2->N200 = 3; in create_l2()
2143 l2->T203 = 10000; in create_l2()
2149 l2->ch.st->dev->D.ctrl(&l2->ch.st->dev->D, OPEN_CHANNEL, &rq); in create_l2()
2152 test_and_set_bit(FLG_LAPD, &l2->flag); in create_l2()
2153 test_and_set_bit(FLG_MOD128, &l2->flag); in create_l2()
2154 test_and_set_bit(FLG_ORIG, &l2->flag); in create_l2()
2155 l2->sapi = sapi; in create_l2()
2156 l2->maxlen = MAX_DFRAME_LEN; in create_l2()
2158 l2->window = 7; in create_l2()
2160 l2->window = 1; in create_l2()
2162 test_and_set_bit(FLG_PTP, &l2->flag); in create_l2()
2164 test_and_set_bit(FLG_FIXED_TEI, &l2->flag); in create_l2()
2165 l2->tei = tei; in create_l2()
2166 l2->T200 = 1000; in create_l2()
2167 l2->N200 = 3; in create_l2()
2168 l2->T203 = 10000; in create_l2()
2174 l2->ch.st->dev->D.ctrl(&l2->ch.st->dev->D, OPEN_CHANNEL, &rq); in create_l2()
2177 test_and_set_bit(FLG_LAPB, &l2->flag); in create_l2()
2178 l2->window = 7; in create_l2()
2179 l2->maxlen = MAX_DATA_SIZE; in create_l2()
2180 l2->T200 = 1000; in create_l2()
2181 l2->N200 = 4; in create_l2()
2182 l2->T203 = 5000; in create_l2()
2183 l2->addr.A = 3; in create_l2()
2184 l2->addr.B = 1; in create_l2()
2189 kfree(l2); in create_l2()
2192 skb_queue_head_init(&l2->i_queue); in create_l2()
2193 skb_queue_head_init(&l2->ui_queue); in create_l2()
2194 skb_queue_head_init(&l2->down_queue); in create_l2()
2195 skb_queue_head_init(&l2->tmp_queue); in create_l2()
2196 InitWin(l2); in create_l2()
2197 l2->l2m.fsm = &l2fsm; in create_l2()
2198 if (test_bit(FLG_LAPB, &l2->flag) || in create_l2()
2199 test_bit(FLG_FIXED_TEI, &l2->flag) || in create_l2()
2200 test_bit(FLG_LAPD_NET, &l2->flag)) in create_l2()
2201 l2->l2m.state = ST_L2_4; in create_l2()
2203 l2->l2m.state = ST_L2_1; in create_l2()
2204 l2->l2m.debug = *debug; in create_l2()
2205 l2->l2m.userdata = l2; in create_l2()
2206 l2->l2m.userint = 0; in create_l2()
2207 l2->l2m.printdebug = l2m_debug; in create_l2()
2209 mISDN_FsmInitTimer(&l2->l2m, &l2->t200); in create_l2()
2210 mISDN_FsmInitTimer(&l2->l2m, &l2->t203); in create_l2()
2211 return l2; in create_l2()
2217 struct layer2 *l2; in x75create() local
2221 l2 = create_l2(crq->ch, crq->protocol, 0, 0, 0); in x75create()
2222 if (!l2) in x75create()
2224 crq->ch = &l2->ch; in x75create()