Lines Matching full:pch
263 static void ppp_channel_push(struct channel *pch);
265 struct channel *pch);
272 struct channel *pch);
287 static int ppp_connect_channel(struct channel *pch, int unit);
288 static int ppp_disconnect_channel(struct channel *pch);
289 static void ppp_destroy_channel(struct channel *pch);
624 static int ppp_bridge_channels(struct channel *pch, struct channel *pchb) in ppp_bridge_channels() argument
626 write_lock_bh(&pch->upl); in ppp_bridge_channels()
627 if (pch->ppp || in ppp_bridge_channels()
628 rcu_dereference_protected(pch->bridge, lockdep_is_held(&pch->upl))) { in ppp_bridge_channels()
629 write_unlock_bh(&pch->upl); in ppp_bridge_channels()
633 rcu_assign_pointer(pch->bridge, pchb); in ppp_bridge_channels()
634 write_unlock_bh(&pch->upl); in ppp_bridge_channels()
642 refcount_inc(&pch->file.refcnt); in ppp_bridge_channels()
643 rcu_assign_pointer(pchb->bridge, pch); in ppp_bridge_channels()
649 write_lock_bh(&pch->upl); in ppp_bridge_channels()
650 /* Re-read pch->bridge with upl held in case it was modified concurrently */ in ppp_bridge_channels()
651 pchb = rcu_dereference_protected(pch->bridge, lockdep_is_held(&pch->upl)); in ppp_bridge_channels()
652 RCU_INIT_POINTER(pch->bridge, NULL); in ppp_bridge_channels()
653 write_unlock_bh(&pch->upl); in ppp_bridge_channels()
663 static int ppp_unbridge_channels(struct channel *pch) in ppp_unbridge_channels() argument
667 write_lock_bh(&pch->upl); in ppp_unbridge_channels()
668 pchb = rcu_dereference_protected(pch->bridge, lockdep_is_held(&pch->upl)); in ppp_unbridge_channels()
670 write_unlock_bh(&pch->upl); in ppp_unbridge_channels()
673 RCU_INIT_POINTER(pch->bridge, NULL); in ppp_unbridge_channels()
674 write_unlock_bh(&pch->upl); in ppp_unbridge_channels()
676 /* Only modify pchb if phcb->bridge points back to pch. in ppp_unbridge_channels()
683 if (pchbb == pch) in ppp_unbridge_channels()
689 if (pchbb == pch) in ppp_unbridge_channels()
690 if (refcount_dec_and_test(&pch->file.refcnt)) in ppp_unbridge_channels()
691 ppp_destroy_channel(pch); in ppp_unbridge_channels()
734 struct channel *pch, *pchb; in ppp_ioctl() local
738 pch = PF_TO_CHANNEL(pf); in ppp_ioctl()
744 err = ppp_connect_channel(pch, unit); in ppp_ioctl()
748 err = ppp_disconnect_channel(pch); in ppp_ioctl()
766 err = ppp_bridge_channels(pch, pchb); in ppp_ioctl()
773 err = ppp_unbridge_channels(pch); in ppp_ioctl()
777 down_read(&pch->chan_sem); in ppp_ioctl()
778 chan = pch->chan; in ppp_ioctl()
782 up_read(&pch->chan_sem); in ppp_ioctl()
1585 struct channel *pch; in ppp_fill_forward_path() local
1593 pch = list_first_entry(&ppp->channels, struct channel, clist); in ppp_fill_forward_path()
1594 chan = pch->chan; in ppp_fill_forward_path()
1862 struct channel *pch; in ppp_push() local
1879 pch = list_entry(list, struct channel, clist); in ppp_push()
1881 spin_lock(&pch->downl); in ppp_push()
1882 if (pch->chan) { in ppp_push()
1883 if (pch->chan->ops->start_xmit(pch->chan, skb)) in ppp_push()
1890 spin_unlock(&pch->downl); in ppp_push()
1926 struct channel *pch; in ppp_mp_explode() local
1940 list_for_each_entry(pch, &ppp->channels, clist) { in ppp_mp_explode()
1941 if (pch->chan) { in ppp_mp_explode()
1942 pch->avail = 1; in ppp_mp_explode()
1944 pch->speed = pch->chan->speed; in ppp_mp_explode()
1946 pch->avail = 0; in ppp_mp_explode()
1948 if (pch->avail) { in ppp_mp_explode()
1949 if (skb_queue_empty(&pch->file.xq) || in ppp_mp_explode()
1950 !pch->had_frag) { in ppp_mp_explode()
1951 if (pch->speed == 0) in ppp_mp_explode()
1954 totspeed += pch->speed; in ppp_mp_explode()
1956 pch->avail = 2; in ppp_mp_explode()
1960 if (!pch->had_frag && i < ppp->nxchan) in ppp_mp_explode()
2003 pch = list_entry(list, struct channel, clist); in ppp_mp_explode()
2005 if (!pch->avail) in ppp_mp_explode()
2012 if (pch->avail == 1) { in ppp_mp_explode()
2016 pch->avail = 1; in ppp_mp_explode()
2020 spin_lock(&pch->downl); in ppp_mp_explode()
2021 if (pch->chan == NULL) { in ppp_mp_explode()
2023 if (pch->speed == 0) in ppp_mp_explode()
2026 totspeed -= pch->speed; in ppp_mp_explode()
2028 spin_unlock(&pch->downl); in ppp_mp_explode()
2029 pch->avail = 0; in ppp_mp_explode()
2046 if (pch->speed == 0) { in ppp_mp_explode()
2054 ((totspeed*totfree)/pch->speed)) - hdrlen; in ppp_mp_explode()
2056 flen += ((totfree - nzero)*pch->speed)/totspeed; in ppp_mp_explode()
2057 nbigger -= ((totfree - nzero)*pch->speed)/ in ppp_mp_explode()
2078 pch->avail = 2; in ppp_mp_explode()
2079 spin_unlock(&pch->downl); in ppp_mp_explode()
2088 mtu = pch->chan->mtu - (hdrlen - 2); in ppp_mp_explode()
2115 chan = pch->chan; in ppp_mp_explode()
2116 if (!skb_queue_empty(&pch->file.xq) || in ppp_mp_explode()
2118 skb_queue_tail(&pch->file.xq, frag); in ppp_mp_explode()
2119 pch->had_frag = 1; in ppp_mp_explode()
2124 spin_unlock(&pch->downl); in ppp_mp_explode()
2131 spin_unlock(&pch->downl); in ppp_mp_explode()
2141 static void __ppp_channel_push(struct channel *pch) in __ppp_channel_push() argument
2146 spin_lock(&pch->downl); in __ppp_channel_push()
2147 if (pch->chan) { in __ppp_channel_push()
2148 while (!skb_queue_empty(&pch->file.xq)) { in __ppp_channel_push()
2149 skb = skb_dequeue(&pch->file.xq); in __ppp_channel_push()
2150 if (!pch->chan->ops->start_xmit(pch->chan, skb)) { in __ppp_channel_push()
2152 skb_queue_head(&pch->file.xq, skb); in __ppp_channel_push()
2158 skb_queue_purge(&pch->file.xq); in __ppp_channel_push()
2160 spin_unlock(&pch->downl); in __ppp_channel_push()
2162 if (skb_queue_empty(&pch->file.xq)) { in __ppp_channel_push()
2163 ppp = pch->ppp; in __ppp_channel_push()
2169 static void ppp_channel_push(struct channel *pch) in ppp_channel_push() argument
2171 read_lock_bh(&pch->upl); in ppp_channel_push()
2172 if (pch->ppp) { in ppp_channel_push()
2173 (*this_cpu_ptr(pch->ppp->xmit_recursion))++; in ppp_channel_push()
2174 __ppp_channel_push(pch); in ppp_channel_push()
2175 (*this_cpu_ptr(pch->ppp->xmit_recursion))--; in ppp_channel_push()
2177 __ppp_channel_push(pch); in ppp_channel_push()
2179 read_unlock_bh(&pch->upl); in ppp_channel_push()
2193 ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) in ppp_do_recv() argument
2197 ppp_receive_frame(ppp, skb, pch); in ppp_do_recv()
2248 static bool ppp_channel_bridge_input(struct channel *pch, struct sk_buff *skb) in ppp_channel_bridge_input() argument
2253 pchb = rcu_dereference(pch->bridge); in ppp_channel_bridge_input()
2264 skb_scrub_packet(skb, !net_eq(pch->chan_net, pchb->chan_net)); in ppp_channel_bridge_input()
2280 struct channel *pch = chan->ppp; in ppp_input() local
2283 if (!pch) { in ppp_input()
2289 if (ppp_channel_bridge_input(pch, skb)) in ppp_input()
2292 read_lock_bh(&pch->upl); in ppp_input()
2295 if (pch->ppp) { in ppp_input()
2296 ++pch->ppp->dev->stats.rx_length_errors; in ppp_input()
2297 ppp_receive_error(pch->ppp); in ppp_input()
2303 if (!pch->ppp || proto >= 0xc000 || proto == PPP_CCPFRAG) { in ppp_input()
2305 skb_queue_tail(&pch->file.rq, skb); in ppp_input()
2307 while (pch->file.rq.qlen > PPP_MAX_RQLEN && in ppp_input()
2308 (skb = skb_dequeue(&pch->file.rq))) in ppp_input()
2310 wake_up_interruptible(&pch->file.rwait); in ppp_input()
2312 ppp_do_recv(pch->ppp, skb, pch); in ppp_input()
2316 read_unlock_bh(&pch->upl); in ppp_input()
2323 struct channel *pch = chan->ppp; in ppp_input_error() local
2326 if (!pch) in ppp_input_error()
2329 read_lock_bh(&pch->upl); in ppp_input_error()
2330 if (pch->ppp) { in ppp_input_error()
2335 ppp_do_recv(pch->ppp, skb, pch); in ppp_input_error()
2338 read_unlock_bh(&pch->upl); in ppp_input_error()
2346 ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) in ppp_receive_frame() argument
2354 ppp_receive_mp_frame(ppp, skb, pch); in ppp_receive_frame()
2590 ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) in ppp_receive_mp_frame() argument
2628 pch->lastseq = seq; in ppp_receive_mp_frame()
2879 struct channel *pch; in ppp_register_net_channel() local
2882 pch = kzalloc(sizeof(struct channel), GFP_KERNEL); in ppp_register_net_channel()
2883 if (!pch) in ppp_register_net_channel()
2888 pch->ppp = NULL; in ppp_register_net_channel()
2889 pch->chan = chan; in ppp_register_net_channel()
2890 pch->chan_net = get_net_track(net, &pch->ns_tracker, GFP_KERNEL); in ppp_register_net_channel()
2891 chan->ppp = pch; in ppp_register_net_channel()
2892 init_ppp_file(&pch->file, CHANNEL); in ppp_register_net_channel()
2893 pch->file.hdrlen = chan->hdrlen; in ppp_register_net_channel()
2895 pch->lastseq = -1; in ppp_register_net_channel()
2897 init_rwsem(&pch->chan_sem); in ppp_register_net_channel()
2898 spin_lock_init(&pch->downl); in ppp_register_net_channel()
2899 rwlock_init(&pch->upl); in ppp_register_net_channel()
2902 pch->file.index = ++pn->last_channel_index; in ppp_register_net_channel()
2903 list_add(&pch->list, &pn->new_channels); in ppp_register_net_channel()
2915 struct channel *pch = chan->ppp; in ppp_channel_index() local
2917 if (pch) in ppp_channel_index()
2918 return pch->file.index; in ppp_channel_index()
2927 struct channel *pch = chan->ppp; in ppp_unit_number() local
2930 if (pch) { in ppp_unit_number()
2931 read_lock_bh(&pch->upl); in ppp_unit_number()
2932 if (pch->ppp) in ppp_unit_number()
2933 unit = pch->ppp->file.index; in ppp_unit_number()
2934 read_unlock_bh(&pch->upl); in ppp_unit_number()
2944 struct channel *pch = chan->ppp; in ppp_dev_name() local
2947 if (pch) { in ppp_dev_name()
2948 read_lock_bh(&pch->upl); in ppp_dev_name()
2949 if (pch->ppp && pch->ppp->dev) in ppp_dev_name()
2950 name = pch->ppp->dev->name; in ppp_dev_name()
2951 read_unlock_bh(&pch->upl); in ppp_dev_name()
2964 struct channel *pch = chan->ppp; in ppp_unregister_channel() local
2967 if (!pch) in ppp_unregister_channel()
2976 down_write(&pch->chan_sem); in ppp_unregister_channel()
2977 spin_lock_bh(&pch->downl); in ppp_unregister_channel()
2978 pch->chan = NULL; in ppp_unregister_channel()
2979 spin_unlock_bh(&pch->downl); in ppp_unregister_channel()
2980 up_write(&pch->chan_sem); in ppp_unregister_channel()
2981 ppp_disconnect_channel(pch); in ppp_unregister_channel()
2983 pn = ppp_pernet(pch->chan_net); in ppp_unregister_channel()
2985 list_del(&pch->list); in ppp_unregister_channel()
2988 ppp_unbridge_channels(pch); in ppp_unregister_channel()
2990 pch->file.dead = 1; in ppp_unregister_channel()
2991 wake_up_interruptible(&pch->file.rwait); in ppp_unregister_channel()
2993 if (refcount_dec_and_test(&pch->file.refcnt)) in ppp_unregister_channel()
2994 ppp_destroy_channel(pch); in ppp_unregister_channel()
3004 struct channel *pch = chan->ppp; in ppp_output_wakeup() local
3006 if (!pch) in ppp_output_wakeup()
3008 ppp_channel_push(pch); in ppp_output_wakeup()
3429 struct channel *pch; in ppp_find_channel() local
3431 list_for_each_entry(pch, &pn->new_channels, list) { in ppp_find_channel()
3432 if (pch->file.index == unit) { in ppp_find_channel()
3433 list_move(&pch->list, &pn->all_channels); in ppp_find_channel()
3434 return pch; in ppp_find_channel()
3438 list_for_each_entry(pch, &pn->all_channels, list) { in ppp_find_channel()
3439 if (pch->file.index == unit) in ppp_find_channel()
3440 return pch; in ppp_find_channel()
3450 ppp_connect_channel(struct channel *pch, int unit) in ppp_connect_channel() argument
3457 pn = ppp_pernet(pch->chan_net); in ppp_connect_channel()
3463 write_lock_bh(&pch->upl); in ppp_connect_channel()
3465 if (pch->ppp || in ppp_connect_channel()
3466 rcu_dereference_protected(pch->bridge, lockdep_is_held(&pch->upl))) in ppp_connect_channel()
3470 spin_lock_bh(&pch->downl); in ppp_connect_channel()
3471 if (!pch->chan) { in ppp_connect_channel()
3473 spin_unlock_bh(&pch->downl); in ppp_connect_channel()
3478 spin_unlock_bh(&pch->downl); in ppp_connect_channel()
3479 if (pch->file.hdrlen > ppp->file.hdrlen) in ppp_connect_channel()
3480 ppp->file.hdrlen = pch->file.hdrlen; in ppp_connect_channel()
3481 hdrlen = pch->file.hdrlen + 2; /* for protocol bytes */ in ppp_connect_channel()
3484 list_add_tail(&pch->clist, &ppp->channels); in ppp_connect_channel()
3486 pch->ppp = ppp; in ppp_connect_channel()
3492 write_unlock_bh(&pch->upl); in ppp_connect_channel()
3502 ppp_disconnect_channel(struct channel *pch) in ppp_disconnect_channel() argument
3507 write_lock_bh(&pch->upl); in ppp_disconnect_channel()
3508 ppp = pch->ppp; in ppp_disconnect_channel()
3509 pch->ppp = NULL; in ppp_disconnect_channel()
3510 write_unlock_bh(&pch->upl); in ppp_disconnect_channel()
3514 list_del(&pch->clist); in ppp_disconnect_channel()
3528 static void ppp_destroy_channel(struct channel *pch) in ppp_destroy_channel() argument
3530 put_net_track(pch->chan_net, &pch->ns_tracker); in ppp_destroy_channel()
3531 pch->chan_net = NULL; in ppp_destroy_channel()
3535 if (!pch->file.dead) { in ppp_destroy_channel()
3537 pr_err("ppp: destroying undead channel %p !\n", pch); in ppp_destroy_channel()
3540 skb_queue_purge(&pch->file.xq); in ppp_destroy_channel()
3541 skb_queue_purge(&pch->file.rq); in ppp_destroy_channel()
3542 kfree(pch); in ppp_destroy_channel()