Lines Matching refs:hdlc
171 static inline struct frad_state* state(hdlc_device *hdlc) in state() argument
173 return(struct frad_state *)(hdlc->state); in state()
177 static inline struct pvc_device *find_pvc(hdlc_device *hdlc, u16 dlci) in find_pvc() argument
179 struct pvc_device *pvc = state(hdlc)->first_pvc; in find_pvc()
195 hdlc_device *hdlc = dev_to_hdlc(dev); in add_pvc() local
196 struct pvc_device *pvc, **pvc_p = &state(hdlc)->first_pvc; in add_pvc()
247 static inline void delete_unused_pvcs(hdlc_device *hdlc) in delete_unused_pvcs() argument
249 struct pvc_device **pvc_p = &state(hdlc)->first_pvc; in delete_unused_pvcs()
358 hdlc_device *hdlc = dev_to_hdlc(pvc->frad); in pvc_open() local
359 if (state(hdlc)->settings.lmi == LMI_NONE) in pvc_open()
363 state(hdlc)->dce_changed = 1; in pvc_open()
375 hdlc_device *hdlc = dev_to_hdlc(pvc->frad); in pvc_close() local
376 if (state(hdlc)->settings.lmi == LMI_NONE) in pvc_close()
379 if (state(hdlc)->settings.dce) { in pvc_close()
380 state(hdlc)->dce_changed = 1; in pvc_close()
479 hdlc_device *hdlc = dev_to_hdlc(dev); in fr_lmi_send() local
481 struct pvc_device *pvc = state(hdlc)->first_pvc; in fr_lmi_send()
482 int lmi = state(hdlc)->settings.lmi; in fr_lmi_send()
483 int dce = state(hdlc)->settings.dce; in fr_lmi_send()
490 len += state(hdlc)->dce_pvc_count * (2 + stat_len); in fr_lmi_send()
520 data[i++] = state(hdlc)->txseq = in fr_lmi_send()
521 fr_lmi_nextseq(state(hdlc)->txseq); in fr_lmi_send()
522 data[i++] = state(hdlc)->rxseq; in fr_lmi_send()
531 if (state(hdlc)->reliable && !pvc->state.exist) { in fr_lmi_send()
576 hdlc_device *hdlc = dev_to_hdlc(dev); in fr_set_link_state() local
577 struct pvc_device *pvc = state(hdlc)->first_pvc; in fr_set_link_state()
579 state(hdlc)->reliable = reliable; in fr_set_link_state()
582 state(hdlc)->n391cnt = 0; /* Request full status */ in fr_set_link_state()
583 state(hdlc)->dce_changed = 1; in fr_set_link_state()
585 if (state(hdlc)->settings.lmi == LMI_NONE) { in fr_set_link_state()
599 if (!state(hdlc)->settings.dce) in fr_set_link_state()
610 hdlc_device *hdlc = dev_to_hdlc(dev); in fr_timer() local
614 if (state(hdlc)->settings.dce) { in fr_timer()
615 reliable = state(hdlc)->request && in fr_timer()
616 time_before(jiffies, state(hdlc)->last_poll + in fr_timer()
617 state(hdlc)->settings.t392 * HZ); in fr_timer()
618 state(hdlc)->request = 0; in fr_timer()
620 state(hdlc)->last_errors <<= 1; /* Shift the list */ in fr_timer()
621 if (state(hdlc)->request) { in fr_timer()
622 if (state(hdlc)->reliable) in fr_timer()
624 state(hdlc)->last_errors |= 1; in fr_timer()
627 list = state(hdlc)->last_errors; in fr_timer()
628 for (i = 0; i < state(hdlc)->settings.n393; i++, list >>= 1) in fr_timer()
631 reliable = (cnt < state(hdlc)->settings.n392); in fr_timer()
634 if (state(hdlc)->reliable != reliable) { in fr_timer()
639 if (state(hdlc)->settings.dce) in fr_timer()
640 state(hdlc)->timer.expires = jiffies + in fr_timer()
641 state(hdlc)->settings.t392 * HZ; in fr_timer()
643 if (state(hdlc)->n391cnt) in fr_timer()
644 state(hdlc)->n391cnt--; in fr_timer()
646 fr_lmi_send(dev, state(hdlc)->n391cnt == 0); in fr_timer()
648 state(hdlc)->last_poll = jiffies; in fr_timer()
649 state(hdlc)->request = 1; in fr_timer()
650 state(hdlc)->timer.expires = jiffies + in fr_timer()
651 state(hdlc)->settings.t391 * HZ; in fr_timer()
654 state(hdlc)->timer.function = fr_timer; in fr_timer()
655 state(hdlc)->timer.data = arg; in fr_timer()
656 add_timer(&state(hdlc)->timer); in fr_timer()
662 hdlc_device *hdlc = dev_to_hdlc(dev); in fr_lmi_recv() local
665 int lmi = state(hdlc)->settings.lmi; in fr_lmi_recv()
666 int dce = state(hdlc)->settings.dce; in fr_lmi_recv()
737 state(hdlc)->rxseq = skb->data[i++]; /* TX sequence from peer */ in fr_lmi_recv()
740 txseq = state(hdlc)->txseq; in fr_lmi_recv()
743 state(hdlc)->last_poll = jiffies; in fr_lmi_recv()
746 if (!state(hdlc)->reliable) in fr_lmi_recv()
750 state(hdlc)->n391cnt = 0; in fr_lmi_recv()
755 if (state(hdlc)->fullrep_sent && !error) { in fr_lmi_recv()
757 state(hdlc)->fullrep_sent = 0; in fr_lmi_recv()
758 pvc = state(hdlc)->first_pvc; in fr_lmi_recv()
764 state(hdlc)->dce_changed = 1; in fr_lmi_recv()
770 if (state(hdlc)->dce_changed) { in fr_lmi_recv()
772 state(hdlc)->fullrep_sent = 1; in fr_lmi_recv()
773 state(hdlc)->dce_changed = 0; in fr_lmi_recv()
776 state(hdlc)->request = 1; /* got request */ in fr_lmi_recv()
783 state(hdlc)->request = 0; /* got response, no request pending */ in fr_lmi_recv()
791 pvc = state(hdlc)->first_pvc; in fr_lmi_recv()
856 pvc = state(hdlc)->first_pvc; in fr_lmi_recv()
870 state(hdlc)->n391cnt = state(hdlc)->settings.n391; in fr_lmi_recv()
879 hdlc_device *hdlc = dev_to_hdlc(frad); in fr_rx() local
892 (state(hdlc)->settings.lmi == LMI_ANSI || in fr_rx()
893 state(hdlc)->settings.lmi == LMI_CCITT)) || in fr_rx()
895 state(hdlc)->settings.lmi == LMI_CISCO)) { in fr_rx()
902 pvc = find_pvc(hdlc, dlci); in fr_rx()
1000 hdlc_device *hdlc = dev_to_hdlc(dev); in fr_start() local
1004 if (state(hdlc)->settings.lmi != LMI_NONE) { in fr_start()
1005 state(hdlc)->reliable = 0; in fr_start()
1006 state(hdlc)->dce_changed = 1; in fr_start()
1007 state(hdlc)->request = 0; in fr_start()
1008 state(hdlc)->fullrep_sent = 0; in fr_start()
1009 state(hdlc)->last_errors = 0xFFFFFFFF; in fr_start()
1010 state(hdlc)->n391cnt = 0; in fr_start()
1011 state(hdlc)->txseq = state(hdlc)->rxseq = 0; in fr_start()
1013 init_timer(&state(hdlc)->timer); in fr_start()
1015 state(hdlc)->timer.expires = jiffies + HZ; in fr_start()
1016 state(hdlc)->timer.function = fr_timer; in fr_start()
1017 state(hdlc)->timer.data = (unsigned long)dev; in fr_start()
1018 add_timer(&state(hdlc)->timer); in fr_start()
1026 hdlc_device *hdlc = dev_to_hdlc(dev); in fr_stop() local
1030 if (state(hdlc)->settings.lmi != LMI_NONE) in fr_stop()
1031 del_timer_sync(&state(hdlc)->timer); in fr_stop()
1038 hdlc_device *hdlc = dev_to_hdlc(dev); in fr_close() local
1039 struct pvc_device *pvc = state(hdlc)->first_pvc; in fr_close()
1070 hdlc_device *hdlc = dev_to_hdlc(frad); in fr_add_pvc() local
1093 delete_unused_pvcs(hdlc); in fr_add_pvc()
1111 delete_unused_pvcs(hdlc); in fr_add_pvc()
1118 state(hdlc)->dce_changed = 1; in fr_add_pvc()
1119 state(hdlc)->dce_pvc_count++; in fr_add_pvc()
1126 static int fr_del_pvc(hdlc_device *hdlc, unsigned int dlci, int type) in fr_del_pvc() argument
1131 if ((pvc = find_pvc(hdlc, dlci)) == NULL) in fr_del_pvc()
1144 state(hdlc)->dce_pvc_count--; in fr_del_pvc()
1145 state(hdlc)->dce_changed = 1; in fr_del_pvc()
1147 delete_unused_pvcs(hdlc); in fr_del_pvc()
1155 hdlc_device *hdlc = dev_to_hdlc(frad); in fr_destroy() local
1156 struct pvc_device *pvc = state(hdlc)->first_pvc; in fr_destroy()
1157 state(hdlc)->first_pvc = NULL; /* All PVCs destroyed */ in fr_destroy()
1158 state(hdlc)->dce_pvc_count = 0; in fr_destroy()
1159 state(hdlc)->dce_changed = 1; in fr_destroy()
1192 hdlc_device *hdlc = dev_to_hdlc(dev); in fr_ioctl() local
1205 if (copy_to_user(fr_s, &state(hdlc)->settings, size)) in fr_ioctl()
1236 result=hdlc->attach(dev, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT); in fr_ioctl()
1245 state(hdlc)->first_pvc = NULL; in fr_ioctl()
1246 state(hdlc)->dce_pvc_count = 0; in fr_ioctl()
1248 memcpy(&state(hdlc)->settings, &new_settings, size); in fr_ioctl()
1279 return fr_del_pvc(hdlc, pvc.dlci, result); in fr_ioctl()