Lines Matching +full:data +full:- +full:active
1 // SPDX-License-Identifier: GPL-2.0-only
6 * Copyright (C) 1999 - 2006 Krzysztof Halasa <khc@pm.waw.pl>
13 (exist,new) -> 0,0 when "PVC create" or if "link unreliable"
14 0,x -> 1,1 if "link reliable" when sending FULL STATUS
15 1,1 -> 1,0 if received FULL STATUS ACK
17 (active) -> 0 when "ifconfig PVC down" or "link unreliable" or "PVC create"
18 -> 1 when "PVC up" and (exist,new) = 1,0
21 (exist,new,active) = FULL STATUS if "link reliable"
24 active = open and "link reliable"
27 CCITT LMI: ITU-T Q.933 Annex A
122 unsigned int active: 1; member
164 return (struct frad_state *)(hdlc->state); in state()
169 struct pvc_device *pvc = state(hdlc)->first_pvc; in find_pvc()
172 if (pvc->dlci == dlci) in find_pvc()
174 if (pvc->dlci > dlci) in find_pvc()
176 pvc = pvc->next; in find_pvc()
185 struct pvc_device *pvc, **pvc_p = &state(hdlc)->first_pvc; in add_pvc()
188 if ((*pvc_p)->dlci == dlci) in add_pvc()
190 if ((*pvc_p)->dlci > dlci) in add_pvc()
192 pvc_p = &(*pvc_p)->next; in add_pvc()
202 pvc->dlci = dlci; in add_pvc()
203 pvc->frad = dev; in add_pvc()
204 pvc->next = *pvc_p; /* Put it in the chain */ in add_pvc()
211 return pvc->main || pvc->ether; in pvc_is_used()
217 if (pvc->main) in pvc_carrier()
218 if (!netif_carrier_ok(pvc->main)) in pvc_carrier()
219 netif_carrier_on(pvc->main); in pvc_carrier()
220 if (pvc->ether) in pvc_carrier()
221 if (!netif_carrier_ok(pvc->ether)) in pvc_carrier()
222 netif_carrier_on(pvc->ether); in pvc_carrier()
224 if (pvc->main) in pvc_carrier()
225 if (netif_carrier_ok(pvc->main)) in pvc_carrier()
226 netif_carrier_off(pvc->main); in pvc_carrier()
227 if (pvc->ether) in pvc_carrier()
228 if (netif_carrier_ok(pvc->ether)) in pvc_carrier()
229 netif_carrier_off(pvc->ether); in pvc_carrier()
235 struct pvc_device **pvc_p = &state(hdlc)->first_pvc; in delete_unused_pvcs()
243 *pvc_p = pvc->next; in delete_unused_pvcs()
247 pvc_p = &(*pvc_p)->next; in delete_unused_pvcs()
255 return &pvc->ether; in get_dev_p()
257 return &pvc->main; in get_dev_p()
262 if (!skb->dev) { /* Control packets */ in fr_hard_header()
266 skb->data[3] = NLPID_CCITT_ANSI_LMI; in fr_hard_header()
271 skb->data[3] = NLPID_CISCO_LMI; in fr_hard_header()
275 return -EINVAL; in fr_hard_header()
278 } else if (skb->dev->type == ARPHRD_DLCI) { in fr_hard_header()
279 switch (skb->protocol) { in fr_hard_header()
282 skb->data[3] = NLPID_IP; in fr_hard_header()
287 skb->data[3] = NLPID_IPV6; in fr_hard_header()
292 skb->data[3] = FR_PAD; in fr_hard_header()
293 skb->data[4] = NLPID_SNAP; in fr_hard_header()
294 /* OUI 00-00-00 indicates an Ethertype follows */ in fr_hard_header()
295 skb->data[5] = 0x00; in fr_hard_header()
296 skb->data[6] = 0x00; in fr_hard_header()
297 skb->data[7] = 0x00; in fr_hard_header()
299 *(__be16 *)(skb->data + 8) = skb->protocol; in fr_hard_header()
302 } else if (skb->dev->type == ARPHRD_ETHER) { in fr_hard_header()
304 skb->data[3] = FR_PAD; in fr_hard_header()
305 skb->data[4] = NLPID_SNAP; in fr_hard_header()
306 /* OUI 00-80-C2 stands for the 802.1 organization */ in fr_hard_header()
307 skb->data[5] = 0x00; in fr_hard_header()
308 skb->data[6] = 0x80; in fr_hard_header()
309 skb->data[7] = 0xC2; in fr_hard_header()
310 /* PID 00-07 stands for Ethernet frames without FCS */ in fr_hard_header()
311 skb->data[8] = 0x00; in fr_hard_header()
312 skb->data[9] = 0x07; in fr_hard_header()
315 return -EINVAL; in fr_hard_header()
318 dlci_to_q922(skb->data, dlci); in fr_hard_header()
319 skb->data[2] = FR_UI; in fr_hard_header()
325 struct pvc_device *pvc = dev->ml_priv; in pvc_open()
327 if ((pvc->frad->flags & IFF_UP) == 0) in pvc_open()
328 return -EIO; /* Frad must be UP in order to activate PVC */ in pvc_open()
330 if (pvc->open_count++ == 0) { in pvc_open()
331 hdlc_device *hdlc = dev_to_hdlc(pvc->frad); in pvc_open()
333 if (state(hdlc)->settings.lmi == LMI_NONE) in pvc_open()
334 pvc->state.active = netif_carrier_ok(pvc->frad); in pvc_open()
336 pvc_carrier(pvc->state.active, pvc); in pvc_open()
337 state(hdlc)->dce_changed = 1; in pvc_open()
344 struct pvc_device *pvc = dev->ml_priv; in pvc_close()
346 if (--pvc->open_count == 0) { in pvc_close()
347 hdlc_device *hdlc = dev_to_hdlc(pvc->frad); in pvc_close()
349 if (state(hdlc)->settings.lmi == LMI_NONE) in pvc_close()
350 pvc->state.active = 0; in pvc_close()
352 if (state(hdlc)->settings.dce) { in pvc_close()
353 state(hdlc)->dce_changed = 1; in pvc_close()
354 pvc->state.active = 0; in pvc_close()
362 struct pvc_device *pvc = dev->ml_priv; in pvc_ioctl()
365 if (ifs->type == IF_GET_PROTO) { in pvc_ioctl()
366 if (dev->type == ARPHRD_ETHER) in pvc_ioctl()
367 ifs->type = IF_PROTO_FR_ETH_PVC; in pvc_ioctl()
369 ifs->type = IF_PROTO_FR_PVC; in pvc_ioctl()
371 if (ifs->size < sizeof(info)) { in pvc_ioctl()
372 /* data size wanted */ in pvc_ioctl()
373 ifs->size = sizeof(info); in pvc_ioctl()
374 return -ENOBUFS; in pvc_ioctl()
377 info.dlci = pvc->dlci; in pvc_ioctl()
378 memcpy(info.master, pvc->frad->name, IFNAMSIZ); in pvc_ioctl()
379 if (copy_to_user(ifs->ifs_ifsu.fr_pvc_info, in pvc_ioctl()
381 return -EFAULT; in pvc_ioctl()
385 return -EINVAL; in pvc_ioctl()
390 struct pvc_device *pvc = dev->ml_priv; in pvc_xmit()
392 if (!pvc->state.active) in pvc_xmit()
395 if (dev->type == ARPHRD_ETHER) { in pvc_xmit()
396 int pad = ETH_ZLEN - skb->len; in pvc_xmit()
405 /* We already requested the header space with dev->needed_headroom. in pvc_xmit()
407 * dev->needed_headroom into consideration. in pvc_xmit()
418 skb->dev = dev; in pvc_xmit()
419 if (fr_hard_header(skb, pvc->dlci)) in pvc_xmit()
422 dev->stats.tx_bytes += skb->len; in pvc_xmit()
423 dev->stats.tx_packets++; in pvc_xmit()
424 if (pvc->state.fecn) /* TX Congestion counter */ in pvc_xmit()
425 dev->stats.tx_compressed++; in pvc_xmit()
426 skb->dev = pvc->frad; in pvc_xmit()
427 skb->protocol = htons(ETH_P_HDLC); in pvc_xmit()
433 dev->stats.tx_dropped++; in pvc_xmit()
440 netdev_info(pvc->frad, "DLCI %d [%s%s%s]%s %s\n", in fr_log_dlci_active()
441 pvc->dlci, in fr_log_dlci_active()
442 pvc->main ? pvc->main->name : "", in fr_log_dlci_active()
443 pvc->main && pvc->ether ? " " : "", in fr_log_dlci_active()
444 pvc->ether ? pvc->ether->name : "", in fr_log_dlci_active()
445 pvc->state.new ? " new" : "", in fr_log_dlci_active()
446 !pvc->state.exist ? "deleted" : in fr_log_dlci_active()
447 pvc->state.active ? "active" : "inactive"); in fr_log_dlci_active()
460 struct pvc_device *pvc = state(hdlc)->first_pvc; in fr_lmi_send()
461 int lmi = state(hdlc)->settings.lmi; in fr_lmi_send()
462 int dce = state(hdlc)->settings.dce; in fr_lmi_send()
465 u8 *data; in fr_lmi_send() local
469 len += state(hdlc)->dce_pvc_count * (2 + stat_len); in fr_lmi_send()
480 memset(skb->data, 0, len); in fr_lmi_send()
487 data = skb_tail_pointer(skb); in fr_lmi_send()
488 data[i++] = LMI_CALLREF; in fr_lmi_send()
489 data[i++] = dce ? LMI_STATUS : LMI_STATUS_ENQUIRY; in fr_lmi_send()
491 data[i++] = LMI_ANSI_LOCKSHIFT; in fr_lmi_send()
492 data[i++] = lmi == LMI_CCITT ? LMI_CCITT_REPTYPE : in fr_lmi_send()
494 data[i++] = LMI_REPT_LEN; in fr_lmi_send()
495 data[i++] = fullrep ? LMI_FULLREP : LMI_INTEGRITY; in fr_lmi_send()
496 data[i++] = lmi == LMI_CCITT ? LMI_CCITT_ALIVE : LMI_ANSI_CISCO_ALIVE; in fr_lmi_send()
497 data[i++] = LMI_INTEG_LEN; in fr_lmi_send()
498 data[i++] = state(hdlc)->txseq = in fr_lmi_send()
499 fr_lmi_nextseq(state(hdlc)->txseq); in fr_lmi_send()
500 data[i++] = state(hdlc)->rxseq; in fr_lmi_send()
504 data[i++] = lmi == LMI_CCITT ? LMI_CCITT_PVCSTAT : in fr_lmi_send()
506 data[i++] = stat_len; in fr_lmi_send()
509 if (state(hdlc)->reliable && !pvc->state.exist) { in fr_lmi_send()
510 pvc->state.exist = pvc->state.new = 1; in fr_lmi_send()
515 if (pvc->open_count && !pvc->state.active && in fr_lmi_send()
516 pvc->state.exist && !pvc->state.new) { in fr_lmi_send()
518 pvc->state.active = 1; in fr_lmi_send()
523 data[i] = pvc->dlci >> 8; in fr_lmi_send()
524 data[i + 1] = pvc->dlci & 0xFF; in fr_lmi_send()
526 data[i] = (pvc->dlci >> 4) & 0x3F; in fr_lmi_send()
527 data[i + 1] = ((pvc->dlci << 3) & 0x78) | 0x80; in fr_lmi_send()
528 data[i + 2] = 0x80; in fr_lmi_send()
531 if (pvc->state.new) in fr_lmi_send()
532 data[i + 2] |= 0x08; in fr_lmi_send()
533 else if (pvc->state.active) in fr_lmi_send()
534 data[i + 2] |= 0x02; in fr_lmi_send()
537 pvc = pvc->next; in fr_lmi_send()
542 skb->priority = TC_PRIO_CONTROL; in fr_lmi_send()
543 skb->dev = dev; in fr_lmi_send()
544 skb->protocol = htons(ETH_P_HDLC); in fr_lmi_send()
553 struct pvc_device *pvc = state(hdlc)->first_pvc; in fr_set_link_state()
555 state(hdlc)->reliable = reliable; in fr_set_link_state()
558 state(hdlc)->n391cnt = 0; /* Request full status */ in fr_set_link_state()
559 state(hdlc)->dce_changed = 1; in fr_set_link_state()
561 if (state(hdlc)->settings.lmi == LMI_NONE) { in fr_set_link_state()
564 pvc->state.exist = pvc->state.active = 1; in fr_set_link_state()
565 pvc->state.new = 0; in fr_set_link_state()
566 pvc = pvc->next; in fr_set_link_state()
573 pvc->state.exist = pvc->state.active = 0; in fr_set_link_state()
574 pvc->state.new = 0; in fr_set_link_state()
575 if (!state(hdlc)->settings.dce) in fr_set_link_state()
576 pvc->state.bandwidth = 0; in fr_set_link_state()
577 pvc = pvc->next; in fr_set_link_state()
585 struct net_device *dev = st->dev; in fr_timer()
590 if (state(hdlc)->settings.dce) { in fr_timer()
591 reliable = state(hdlc)->request && in fr_timer()
592 time_before(jiffies, state(hdlc)->last_poll + in fr_timer()
593 state(hdlc)->settings.t392 * HZ); in fr_timer()
594 state(hdlc)->request = 0; in fr_timer()
596 state(hdlc)->last_errors <<= 1; /* Shift the list */ in fr_timer()
597 if (state(hdlc)->request) { in fr_timer()
598 if (state(hdlc)->reliable) in fr_timer()
600 state(hdlc)->last_errors |= 1; in fr_timer()
603 list = state(hdlc)->last_errors; in fr_timer()
604 for (i = 0; i < state(hdlc)->settings.n393; i++, list >>= 1) in fr_timer()
607 reliable = (cnt < state(hdlc)->settings.n392); in fr_timer()
610 if (state(hdlc)->reliable != reliable) { in fr_timer()
615 if (state(hdlc)->settings.dce) { in fr_timer()
616 state(hdlc)->timer.expires = jiffies + in fr_timer()
617 state(hdlc)->settings.t392 * HZ; in fr_timer()
619 if (state(hdlc)->n391cnt) in fr_timer()
620 state(hdlc)->n391cnt--; in fr_timer()
622 fr_lmi_send(dev, state(hdlc)->n391cnt == 0); in fr_timer()
624 state(hdlc)->last_poll = jiffies; in fr_timer()
625 state(hdlc)->request = 1; in fr_timer()
626 state(hdlc)->timer.expires = jiffies + in fr_timer()
627 state(hdlc)->settings.t391 * HZ; in fr_timer()
630 add_timer(&state(hdlc)->timer); in fr_timer()
638 int lmi = state(hdlc)->settings.lmi; in fr_lmi_recv()
639 int dce = state(hdlc)->settings.dce; in fr_lmi_recv()
642 if (skb->len < (lmi == LMI_ANSI ? LMI_ANSI_LENGTH : in fr_lmi_recv()
648 if (skb->data[3] != (lmi == LMI_CISCO ? NLPID_CISCO_LMI : in fr_lmi_recv()
650 netdev_info(dev, "Received non-LMI frame with LMI DLCI\n"); in fr_lmi_recv()
654 if (skb->data[4] != LMI_CALLREF) { in fr_lmi_recv()
656 skb->data[4]); in fr_lmi_recv()
660 if (skb->data[5] != (dce ? LMI_STATUS_ENQUIRY : LMI_STATUS)) { in fr_lmi_recv()
662 skb->data[5]); in fr_lmi_recv()
667 if (skb->data[6] != LMI_ANSI_LOCKSHIFT) { in fr_lmi_recv()
669 skb->data[6]); in fr_lmi_recv()
677 if (skb->data[i] != (lmi == LMI_CCITT ? LMI_CCITT_REPTYPE : in fr_lmi_recv()
680 skb->data[i]); in fr_lmi_recv()
684 if (skb->data[++i] != LMI_REPT_LEN) { in fr_lmi_recv()
686 skb->data[i]); in fr_lmi_recv()
690 reptype = skb->data[++i]; in fr_lmi_recv()
697 if (skb->data[++i] != (lmi == LMI_CCITT ? LMI_CCITT_ALIVE : in fr_lmi_recv()
700 skb->data[i]); in fr_lmi_recv()
704 if (skb->data[++i] != LMI_INTEG_LEN) { in fr_lmi_recv()
706 skb->data[i]); in fr_lmi_recv()
711 state(hdlc)->rxseq = skb->data[i++]; /* TX sequence from peer */ in fr_lmi_recv()
712 rxseq = skb->data[i++]; /* Should confirm our sequence */ in fr_lmi_recv()
714 txseq = state(hdlc)->txseq; in fr_lmi_recv()
717 state(hdlc)->last_poll = jiffies; in fr_lmi_recv()
720 if (!state(hdlc)->reliable) in fr_lmi_recv()
724 state(hdlc)->n391cnt = 0; in fr_lmi_recv()
729 if (state(hdlc)->fullrep_sent && !error) { in fr_lmi_recv()
730 /* Stop sending full report - the last one has been confirmed by DTE */ in fr_lmi_recv()
731 state(hdlc)->fullrep_sent = 0; in fr_lmi_recv()
732 pvc = state(hdlc)->first_pvc; in fr_lmi_recv()
734 if (pvc->state.new) { in fr_lmi_recv()
735 pvc->state.new = 0; in fr_lmi_recv()
737 /* Tell DTE that new PVC is now active */ in fr_lmi_recv()
738 state(hdlc)->dce_changed = 1; in fr_lmi_recv()
740 pvc = pvc->next; in fr_lmi_recv()
744 if (state(hdlc)->dce_changed) { in fr_lmi_recv()
746 state(hdlc)->fullrep_sent = 1; in fr_lmi_recv()
747 state(hdlc)->dce_changed = 0; in fr_lmi_recv()
750 state(hdlc)->request = 1; /* got request */ in fr_lmi_recv()
757 state(hdlc)->request = 0; /* got response, no request pending */ in fr_lmi_recv()
765 pvc = state(hdlc)->first_pvc; in fr_lmi_recv()
768 pvc->state.deleted = 1; in fr_lmi_recv()
769 pvc = pvc->next; in fr_lmi_recv()
773 while (skb->len >= i + 2 + stat_len) { in fr_lmi_recv()
776 unsigned int active, new; in fr_lmi_recv() local
778 if (skb->data[i] != (lmi == LMI_CCITT ? LMI_CCITT_PVCSTAT : in fr_lmi_recv()
781 skb->data[i]); in fr_lmi_recv()
785 if (skb->data[++i] != stat_len) { in fr_lmi_recv()
787 skb->data[i]); in fr_lmi_recv()
792 new = !!(skb->data[i + 2] & 0x08); in fr_lmi_recv()
793 active = !!(skb->data[i + 2] & 0x02); in fr_lmi_recv()
795 dlci = (skb->data[i] << 8) | skb->data[i + 1]; in fr_lmi_recv()
796 bw = (skb->data[i + 3] << 16) | in fr_lmi_recv()
797 (skb->data[i + 4] << 8) | in fr_lmi_recv()
798 (skb->data[i + 5]); in fr_lmi_recv()
800 dlci = ((skb->data[i] & 0x3F) << 4) | in fr_lmi_recv()
801 ((skb->data[i + 1] & 0x78) >> 3); in fr_lmi_recv()
813 pvc->state.exist = 1; in fr_lmi_recv()
814 pvc->state.deleted = 0; in fr_lmi_recv()
815 if (active != pvc->state.active || in fr_lmi_recv()
816 new != pvc->state.new || in fr_lmi_recv()
817 bw != pvc->state.bandwidth || in fr_lmi_recv()
818 !pvc->state.exist) { in fr_lmi_recv()
819 pvc->state.new = new; in fr_lmi_recv()
820 pvc->state.active = active; in fr_lmi_recv()
821 pvc->state.bandwidth = bw; in fr_lmi_recv()
822 pvc_carrier(active, pvc); in fr_lmi_recv()
830 pvc = state(hdlc)->first_pvc; in fr_lmi_recv()
833 if (pvc->state.deleted && pvc->state.exist) { in fr_lmi_recv()
835 pvc->state.active = pvc->state.new = 0; in fr_lmi_recv()
836 pvc->state.exist = 0; in fr_lmi_recv()
837 pvc->state.bandwidth = 0; in fr_lmi_recv()
840 pvc = pvc->next; in fr_lmi_recv()
844 state(hdlc)->n391cnt = state(hdlc)->settings.n391; in fr_lmi_recv()
851 /* OUI 00-00-00 indicates an Ethertype follows */ in fr_snap_parse()
852 if (skb->data[0] == 0x00 && in fr_snap_parse()
853 skb->data[1] == 0x00 && in fr_snap_parse()
854 skb->data[2] == 0x00) { in fr_snap_parse()
855 if (!pvc->main) in fr_snap_parse()
856 return -1; in fr_snap_parse()
857 skb->dev = pvc->main; in fr_snap_parse()
858 skb->protocol = *(__be16 *)(skb->data + 3); /* Ethertype */ in fr_snap_parse()
863 /* OUI 00-80-C2 stands for the 802.1 organization */ in fr_snap_parse()
864 } else if (skb->data[0] == 0x00 && in fr_snap_parse()
865 skb->data[1] == 0x80 && in fr_snap_parse()
866 skb->data[2] == 0xC2) { in fr_snap_parse()
867 /* PID 00-07 stands for Ethernet frames without FCS */ in fr_snap_parse()
868 if (skb->data[3] == 0x00 && in fr_snap_parse()
869 skb->data[4] == 0x07) { in fr_snap_parse()
870 if (!pvc->ether) in fr_snap_parse()
871 return -1; in fr_snap_parse()
873 if (skb->len < ETH_HLEN) in fr_snap_parse()
874 return -1; in fr_snap_parse()
875 skb->protocol = eth_type_trans(skb, pvc->ether); in fr_snap_parse()
880 return -1; in fr_snap_parse()
885 return -1; in fr_snap_parse()
891 struct net_device *frad = skb->dev; in fr_rx()
893 struct fr_hdr *fh = (struct fr_hdr *)skb->data; in fr_rx()
894 u8 *data = skb->data; in fr_rx() local
899 if (skb->len < 4 || fh->ea1 || !fh->ea2 || data[2] != FR_UI) in fr_rx()
902 dlci = q922_to_dlci(skb->data); in fr_rx()
905 (state(hdlc)->settings.lmi == LMI_ANSI || in fr_rx()
906 state(hdlc)->settings.lmi == LMI_CCITT)) || in fr_rx()
908 state(hdlc)->settings.lmi == LMI_CISCO)) { in fr_rx()
924 if (pvc->state.fecn != fh->fecn) { in fr_rx()
926 printk(KERN_DEBUG "%s: DLCI %d FECN O%s\n", frad->name, in fr_rx()
927 dlci, fh->fecn ? "N" : "FF"); in fr_rx()
929 pvc->state.fecn ^= 1; in fr_rx()
932 if (pvc->state.becn != fh->becn) { in fr_rx()
934 printk(KERN_DEBUG "%s: DLCI %d BECN O%s\n", frad->name, in fr_rx()
935 dlci, fh->becn ? "N" : "FF"); in fr_rx()
937 pvc->state.becn ^= 1; in fr_rx()
942 frad->stats.rx_dropped++; in fr_rx()
946 if (data[3] == NLPID_IP) { in fr_rx()
947 if (!pvc->main) in fr_rx()
949 skb_pull(skb, 4); /* Remove 4-byte header (hdr, UI, NLPID) */ in fr_rx()
950 skb->dev = pvc->main; in fr_rx()
951 skb->protocol = htons(ETH_P_IP); in fr_rx()
954 } else if (data[3] == NLPID_IPV6) { in fr_rx()
955 if (!pvc->main) in fr_rx()
957 skb_pull(skb, 4); /* Remove 4-byte header (hdr, UI, NLPID) */ in fr_rx()
958 skb->dev = pvc->main; in fr_rx()
959 skb->protocol = htons(ETH_P_IPV6); in fr_rx()
962 } else if (data[3] == FR_PAD) { in fr_rx()
963 if (skb->len < 5) in fr_rx()
965 if (data[4] == NLPID_SNAP) { /* A SNAP header follows */ in fr_rx()
967 if (skb->len < 5) /* Incomplete SNAP header */ in fr_rx()
977 data[3], skb->len); in fr_rx()
981 dev = skb->dev; in fr_rx()
982 dev->stats.rx_packets++; /* PVC traffic */ in fr_rx()
983 dev->stats.rx_bytes += skb->len; in fr_rx()
984 if (pvc->state.becn) in fr_rx()
985 dev->stats.rx_compressed++; in fr_rx()
990 frad->stats.rx_errors++; /* Mark error */ in fr_rx()
1002 if (state(hdlc)->settings.lmi != LMI_NONE) { in fr_start()
1003 state(hdlc)->reliable = 0; in fr_start()
1004 state(hdlc)->dce_changed = 1; in fr_start()
1005 state(hdlc)->request = 0; in fr_start()
1006 state(hdlc)->fullrep_sent = 0; in fr_start()
1007 state(hdlc)->last_errors = 0xFFFFFFFF; in fr_start()
1008 state(hdlc)->n391cnt = 0; in fr_start()
1009 state(hdlc)->txseq = state(hdlc)->rxseq = 0; in fr_start()
1011 state(hdlc)->dev = dev; in fr_start()
1012 timer_setup(&state(hdlc)->timer, fr_timer, 0); in fr_start()
1014 state(hdlc)->timer.expires = jiffies + HZ; in fr_start()
1015 add_timer(&state(hdlc)->timer); in fr_start()
1027 if (state(hdlc)->settings.lmi != LMI_NONE) in fr_stop()
1028 del_timer_sync(&state(hdlc)->timer); in fr_stop()
1035 struct pvc_device *pvc = state(hdlc)->first_pvc; in fr_close()
1038 if (pvc->main) in fr_close()
1039 dev_close(pvc->main); in fr_close()
1040 if (pvc->ether) in fr_close()
1041 dev_close(pvc->ether); in fr_close()
1042 pvc = pvc->next; in fr_close()
1048 dev->type = ARPHRD_DLCI; in pvc_setup()
1049 dev->flags = IFF_POINTOPOINT; in pvc_setup()
1050 dev->hard_header_len = 0; in pvc_setup()
1051 dev->addr_len = 2; in pvc_setup()
1072 return -ENOBUFS; in fr_add_pvc()
1076 return -EEXIST; in fr_add_pvc()
1089 return -ENOBUFS; in fr_add_pvc()
1093 dev->priv_flags &= ~IFF_TX_SKB_SHARING; in fr_add_pvc()
1099 dlci_to_q922(dev->broadcast, dlci); in fr_add_pvc()
1101 dev->netdev_ops = &pvc_ops; in fr_add_pvc()
1102 dev->mtu = HDLC_MAX_MTU; in fr_add_pvc()
1103 dev->min_mtu = 68; in fr_add_pvc()
1104 dev->max_mtu = HDLC_MAX_MTU; in fr_add_pvc()
1105 dev->needed_headroom = 10; in fr_add_pvc()
1106 dev->priv_flags |= IFF_NO_QUEUE; in fr_add_pvc()
1107 dev->ml_priv = pvc; in fr_add_pvc()
1112 return -EIO; in fr_add_pvc()
1115 dev->needs_free_netdev = true; in fr_add_pvc()
1118 state(hdlc)->dce_changed = 1; in fr_add_pvc()
1119 state(hdlc)->dce_pvc_count++; in fr_add_pvc()
1131 return -ENOENT; in fr_del_pvc()
1135 return -ENOENT; in fr_del_pvc()
1137 if (dev->flags & IFF_UP) in fr_del_pvc()
1138 return -EBUSY; /* PVC in use */ in fr_del_pvc()
1144 state(hdlc)->dce_pvc_count--; in fr_del_pvc()
1145 state(hdlc)->dce_changed = 1; in fr_del_pvc()
1154 struct pvc_device *pvc = state(hdlc)->first_pvc; in fr_destroy()
1156 state(hdlc)->first_pvc = NULL; /* All PVCs destroyed */ in fr_destroy()
1157 state(hdlc)->dce_pvc_count = 0; in fr_destroy()
1158 state(hdlc)->dce_changed = 1; in fr_destroy()
1161 struct pvc_device *next = pvc->next; in fr_destroy()
1163 if (pvc->main) in fr_destroy()
1164 unregister_netdevice(pvc->main); in fr_destroy()
1166 if (pvc->ether) in fr_destroy()
1167 unregister_netdevice(pvc->ether); in fr_destroy()
1186 fr_proto __user *fr_s = ifs->ifs_ifsu.fr; in fr_ioctl()
1193 switch (ifs->type) { in fr_ioctl()
1195 if (dev_to_hdlc(dev)->proto != &proto) /* Different proto */ in fr_ioctl()
1196 return -EINVAL; in fr_ioctl()
1197 ifs->type = IF_PROTO_FR; in fr_ioctl()
1198 if (ifs->size < size) { in fr_ioctl()
1199 ifs->size = size; /* data size wanted */ in fr_ioctl()
1200 return -ENOBUFS; in fr_ioctl()
1202 if (copy_to_user(fr_s, &state(hdlc)->settings, size)) in fr_ioctl()
1203 return -EFAULT; in fr_ioctl()
1208 return -EPERM; in fr_ioctl()
1210 if (dev->flags & IFF_UP) in fr_ioctl()
1211 return -EBUSY; in fr_ioctl()
1214 return -EFAULT; in fr_ioctl()
1231 return -EINVAL; in fr_ioctl()
1233 result = hdlc->attach(dev, ENCODING_NRZ, in fr_ioctl()
1238 if (dev_to_hdlc(dev)->proto != &proto) { /* Different proto */ in fr_ioctl()
1243 state(hdlc)->first_pvc = NULL; in fr_ioctl()
1244 state(hdlc)->dce_pvc_count = 0; in fr_ioctl()
1246 memcpy(&state(hdlc)->settings, &new_settings, size); in fr_ioctl()
1247 dev->type = ARPHRD_FRAD; in fr_ioctl()
1255 if (dev_to_hdlc(dev)->proto != &proto) /* Different proto */ in fr_ioctl()
1256 return -EINVAL; in fr_ioctl()
1259 return -EPERM; in fr_ioctl()
1261 if (copy_from_user(&pvc, ifs->ifs_ifsu.fr_pvc, in fr_ioctl()
1263 return -EFAULT; in fr_ioctl()
1266 return -EINVAL; /* Only 10 bits, DLCI 0 reserved */ in fr_ioctl()
1268 if (ifs->type == IF_PROTO_FR_ADD_ETH_PVC || in fr_ioctl()
1269 ifs->type == IF_PROTO_FR_DEL_ETH_PVC) in fr_ioctl()
1274 if (ifs->type == IF_PROTO_FR_ADD_PVC || in fr_ioctl()
1275 ifs->type == IF_PROTO_FR_ADD_ETH_PVC) in fr_ioctl()
1281 return -EINVAL; in fr_ioctl()
1299 MODULE_DESCRIPTION("Frame-Relay protocol support for generic HDLC");