Lines Matching refs:pvc
169 struct pvc_device *pvc = state(hdlc)->first_pvc;
171 while (pvc) {
172 if (pvc->dlci == dlci)
173 return pvc;
174 if (pvc->dlci > dlci)
176 pvc = pvc->next;
185 struct pvc_device *pvc, **pvc_p = &state(hdlc)->first_pvc;
195 pvc = kzalloc(sizeof(*pvc), GFP_ATOMIC);
197 printk(KERN_DEBUG "add_pvc: allocated pvc %p, frad %p\n", pvc, dev);
199 if (!pvc)
202 pvc->dlci = dlci;
203 pvc->frad = dev;
204 pvc->next = *pvc_p; /* Put it in the chain */
205 *pvc_p = pvc;
206 return pvc;
209 static inline int pvc_is_used(struct pvc_device *pvc)
211 return pvc->main || pvc->ether;
214 static inline void pvc_carrier(int on, struct pvc_device *pvc)
217 if (pvc->main)
218 if (!netif_carrier_ok(pvc->main))
219 netif_carrier_on(pvc->main);
220 if (pvc->ether)
221 if (!netif_carrier_ok(pvc->ether))
222 netif_carrier_on(pvc->ether);
224 if (pvc->main)
225 if (netif_carrier_ok(pvc->main))
226 netif_carrier_off(pvc->main);
227 if (pvc->ether)
228 if (netif_carrier_ok(pvc->ether))
229 netif_carrier_off(pvc->ether);
239 struct pvc_device *pvc = *pvc_p;
241 printk(KERN_DEBUG "freeing unused pvc: %p\n", pvc);
243 *pvc_p = pvc->next;
244 kfree(pvc);
251 static inline struct net_device **get_dev_p(struct pvc_device *pvc,
255 return &pvc->ether;
257 return &pvc->main;
325 struct pvc_device *pvc = dev->ml_priv;
327 if ((pvc->frad->flags & IFF_UP) == 0)
330 if (pvc->open_count++ == 0) {
331 hdlc_device *hdlc = dev_to_hdlc(pvc->frad);
334 pvc->state.active = netif_carrier_ok(pvc->frad);
336 pvc_carrier(pvc->state.active, pvc);
344 struct pvc_device *pvc = dev->ml_priv;
346 if (--pvc->open_count == 0) {
347 hdlc_device *hdlc = dev_to_hdlc(pvc->frad);
350 pvc->state.active = 0;
354 pvc->state.active = 0;
362 struct pvc_device *pvc = dev->ml_priv;
377 info.dlci = pvc->dlci;
378 memcpy(info.master, pvc->frad->name, IFNAMSIZ);
390 struct pvc_device *pvc = dev->ml_priv;
392 if (!pvc->state.active)
419 if (fr_hard_header(skb, pvc->dlci))
424 if (pvc->state.fecn) /* TX Congestion counter */
426 skb->dev = pvc->frad;
438 static inline void fr_log_dlci_active(struct pvc_device *pvc)
440 netdev_info(pvc->frad, "DLCI %d [%s%s%s]%s %s\n",
441 pvc->dlci,
442 pvc->main ? pvc->main->name : "",
443 pvc->main && pvc->ether ? " " : "",
444 pvc->ether ? pvc->ether->name : "",
445 pvc->state.new ? " new" : "",
446 !pvc->state.exist ? "deleted" :
447 pvc->state.active ? "active" : "inactive");
460 struct pvc_device *pvc = state(hdlc)->first_pvc;
503 while (pvc) {
509 if (state(hdlc)->reliable && !pvc->state.exist) {
510 pvc->state.exist = pvc->state.new = 1;
511 fr_log_dlci_active(pvc);
515 if (pvc->open_count && !pvc->state.active &&
516 pvc->state.exist && !pvc->state.new) {
517 pvc_carrier(1, pvc);
518 pvc->state.active = 1;
519 fr_log_dlci_active(pvc);
523 data[i] = pvc->dlci >> 8;
524 data[i + 1] = pvc->dlci & 0xFF;
526 data[i] = (pvc->dlci >> 4) & 0x3F;
527 data[i + 1] = ((pvc->dlci << 3) & 0x78) | 0x80;
531 if (pvc->state.new)
533 else if (pvc->state.active)
537 pvc = pvc->next;
553 struct pvc_device *pvc = state(hdlc)->first_pvc;
562 while (pvc) { /* Activate all PVCs */
563 pvc_carrier(1, pvc);
564 pvc->state.exist = pvc->state.active = 1;
565 pvc->state.new = 0;
566 pvc = pvc->next;
571 while (pvc) { /* Deactivate all PVCs */
572 pvc_carrier(0, pvc);
573 pvc->state.exist = pvc->state.active = 0;
574 pvc->state.new = 0;
576 pvc->state.bandwidth = 0;
577 pvc = pvc->next;
636 struct pvc_device *pvc;
732 pvc = state(hdlc)->first_pvc;
733 while (pvc) {
734 if (pvc->state.new) {
735 pvc->state.new = 0;
740 pvc = pvc->next;
765 pvc = state(hdlc)->first_pvc;
767 while (pvc) {
768 pvc->state.deleted = 1;
769 pvc = pvc->next;
805 pvc = add_pvc(dev, dlci);
807 if (!pvc && !no_ram) {
812 if (pvc) {
813 pvc->state.exist = 1;
814 pvc->state.deleted = 0;
815 if (active != pvc->state.active ||
816 new != pvc->state.new ||
817 bw != pvc->state.bandwidth ||
818 !pvc->state.exist) {
819 pvc->state.new = new;
820 pvc->state.active = active;
821 pvc->state.bandwidth = bw;
822 pvc_carrier(active, pvc);
823 fr_log_dlci_active(pvc);
830 pvc = state(hdlc)->first_pvc;
832 while (pvc) {
833 if (pvc->state.deleted && pvc->state.exist) {
834 pvc_carrier(0, pvc);
835 pvc->state.active = pvc->state.new = 0;
836 pvc->state.exist = 0;
837 pvc->state.bandwidth = 0;
838 fr_log_dlci_active(pvc);
840 pvc = pvc->next;
849 static int fr_snap_parse(struct sk_buff *skb, struct pvc_device *pvc)
855 if (!pvc->main)
857 skb->dev = pvc->main;
870 if (!pvc->ether)
875 skb->protocol = eth_type_trans(skb, pvc->ether);
896 struct pvc_device *pvc;
915 pvc = find_pvc(hdlc, dlci);
916 if (!pvc) {
924 if (pvc->state.fecn != fh->fecn) {
929 pvc->state.fecn ^= 1;
932 if (pvc->state.becn != fh->becn) {
937 pvc->state.becn ^= 1;
947 if (!pvc->main)
950 skb->dev = pvc->main;
955 if (!pvc->main)
958 skb->dev = pvc->main;
969 if (fr_snap_parse(skb, pvc))
984 if (pvc->state.becn)
1035 struct pvc_device *pvc = state(hdlc)->first_pvc;
1037 while (pvc) { /* Shutdown all PVCs for this FRAD */
1038 if (pvc->main)
1039 dev_close(pvc->main);
1040 if (pvc->ether)
1041 dev_close(pvc->ether);
1042 pvc = pvc->next;
1065 struct pvc_device *pvc;
1069 pvc = add_pvc(frad, dlci);
1070 if (!pvc) {
1075 if (*get_dev_p(pvc, type))
1078 used = pvc_is_used(pvc);
1084 dev = alloc_netdev(0, "pvc%d", NET_NAME_UNKNOWN, pvc_setup);
1107 dev->ml_priv = pvc;
1116 *get_dev_p(pvc, type) = dev;
1126 struct pvc_device *pvc;
1129 pvc = find_pvc(hdlc, dlci);
1130 if (!pvc)
1133 dev = *get_dev_p(pvc, type);
1141 *get_dev_p(pvc, type) = NULL;
1143 if (!pvc_is_used(pvc)) {
1154 struct pvc_device *pvc = state(hdlc)->first_pvc;
1160 while (pvc) {
1161 struct pvc_device *next = pvc->next;
1163 if (pvc->main)
1164 unregister_netdevice(pvc->main);
1166 if (pvc->ether)
1167 unregister_netdevice(pvc->ether);
1169 kfree(pvc);
1170 pvc = next;
1190 fr_proto_pvc pvc;
1261 if (copy_from_user(&pvc, ifs->ifs_ifsu.fr_pvc,
1265 if (pvc.dlci <= 0 || pvc.dlci >= 1024)
1276 return fr_add_pvc(dev, pvc.dlci, result);
1278 return fr_del_pvc(hdlc, pvc.dlci, result);