Lines Matching full:ap

97 static int ppp_async_encode(struct asyncppp *ap);
99 static int ppp_async_push(struct asyncppp *ap);
100 static void ppp_async_flush_output(struct asyncppp *ap);
101 static void ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
107 static void async_lcp_peek(struct asyncppp *ap, unsigned char *data,
135 struct asyncppp *ap; in ap_get() local
138 ap = tty->disc_data; in ap_get()
139 if (ap != NULL) in ap_get()
140 refcount_inc(&ap->refcnt); in ap_get()
142 return ap; in ap_get()
145 static void ap_put(struct asyncppp *ap) in ap_put() argument
147 if (refcount_dec_and_test(&ap->refcnt)) in ap_put()
148 complete(&ap->dead); in ap_put()
158 struct asyncppp *ap; in ppp_asynctty_open() local
166 ap = kzalloc(sizeof(*ap), GFP_KERNEL); in ppp_asynctty_open()
167 if (!ap) in ppp_asynctty_open()
171 ap->tty = tty; in ppp_asynctty_open()
172 ap->mru = PPP_MRU; in ppp_asynctty_open()
173 spin_lock_init(&ap->xmit_lock); in ppp_asynctty_open()
174 spin_lock_init(&ap->recv_lock); in ppp_asynctty_open()
175 ap->xaccm[0] = ~0U; in ppp_asynctty_open()
176 ap->xaccm[3] = 0x60000000U; in ppp_asynctty_open()
177 ap->raccm = ~0U; in ppp_asynctty_open()
178 ap->optr = ap->obuf; in ppp_asynctty_open()
179 ap->olim = ap->obuf; in ppp_asynctty_open()
180 ap->lcp_fcs = -1; in ppp_asynctty_open()
182 skb_queue_head_init(&ap->rqueue); in ppp_asynctty_open()
183 tasklet_setup(&ap->tsk, ppp_async_process); in ppp_asynctty_open()
185 refcount_set(&ap->refcnt, 1); in ppp_asynctty_open()
186 init_completion(&ap->dead); in ppp_asynctty_open()
188 ap->chan.private = ap; in ppp_asynctty_open()
189 ap->chan.ops = &async_ops; in ppp_asynctty_open()
190 ap->chan.mtu = PPP_MRU; in ppp_asynctty_open()
192 ap->chan.speed = speed; in ppp_asynctty_open()
193 err = ppp_register_channel(&ap->chan); in ppp_asynctty_open()
197 tty->disc_data = ap; in ppp_asynctty_open()
202 kfree(ap); in ppp_asynctty_open()
218 struct asyncppp *ap; in ppp_asynctty_close() local
221 ap = tty->disc_data; in ppp_asynctty_close()
224 if (!ap) in ppp_asynctty_close()
228 * We have now ensured that nobody can start using ap from now in ppp_asynctty_close()
234 if (!refcount_dec_and_test(&ap->refcnt)) in ppp_asynctty_close()
235 wait_for_completion(&ap->dead); in ppp_asynctty_close()
236 tasklet_kill(&ap->tsk); in ppp_asynctty_close()
238 ppp_unregister_channel(&ap->chan); in ppp_asynctty_close()
239 kfree_skb(ap->rpkt); in ppp_asynctty_close()
240 skb_queue_purge(&ap->rqueue); in ppp_asynctty_close()
241 kfree_skb(ap->tpkt); in ppp_asynctty_close()
242 kfree(ap); in ppp_asynctty_close()
286 struct asyncppp *ap = ap_get(tty); in ppp_asynctty_ioctl() local
290 if (!ap) in ppp_asynctty_ioctl()
296 if (put_user(ppp_channel_index(&ap->chan), p)) in ppp_asynctty_ioctl()
303 if (put_user(ppp_unit_number(&ap->chan), p)) in ppp_asynctty_ioctl()
311 ppp_async_flush_output(ap); in ppp_asynctty_ioctl()
327 ap_put(ap); in ppp_asynctty_ioctl()
336 struct asyncppp *ap = ap_get(tty); in ppp_asynctty_receive() local
339 if (!ap) in ppp_asynctty_receive()
341 spin_lock_irqsave(&ap->recv_lock, flags); in ppp_asynctty_receive()
342 ppp_async_input(ap, buf, cflags, count); in ppp_asynctty_receive()
343 spin_unlock_irqrestore(&ap->recv_lock, flags); in ppp_asynctty_receive()
344 if (!skb_queue_empty(&ap->rqueue)) in ppp_asynctty_receive()
345 tasklet_schedule(&ap->tsk); in ppp_asynctty_receive()
346 ap_put(ap); in ppp_asynctty_receive()
353 struct asyncppp *ap = ap_get(tty); in ppp_asynctty_wakeup() local
356 if (!ap) in ppp_asynctty_wakeup()
358 set_bit(XMIT_WAKEUP, &ap->xmit_flags); in ppp_asynctty_wakeup()
359 tasklet_schedule(&ap->tsk); in ppp_asynctty_wakeup()
360 ap_put(ap); in ppp_asynctty_wakeup()
396 struct asyncppp *ap = chan->private; in ppp_async_ioctl() local
405 val = ap->flags | ap->rbits; in ppp_async_ioctl()
413 ap->flags = val & ~SC_RCV_BITS; in ppp_async_ioctl()
414 spin_lock_irq(&ap->recv_lock); in ppp_async_ioctl()
415 ap->rbits = val & SC_RCV_BITS; in ppp_async_ioctl()
416 spin_unlock_irq(&ap->recv_lock); in ppp_async_ioctl()
421 if (put_user(ap->xaccm[0], (u32 __user *)argp)) in ppp_async_ioctl()
426 if (get_user(ap->xaccm[0], (u32 __user *)argp)) in ppp_async_ioctl()
432 if (put_user(ap->raccm, (u32 __user *)argp)) in ppp_async_ioctl()
437 if (get_user(ap->raccm, (u32 __user *)argp)) in ppp_async_ioctl()
443 if (copy_to_user(argp, ap->xaccm, sizeof(ap->xaccm))) in ppp_async_ioctl()
452 memcpy(ap->xaccm, accm, sizeof(ap->xaccm)); in ppp_async_ioctl()
457 if (put_user(ap->mru, p)) in ppp_async_ioctl()
470 ap->mru = val; in ppp_async_ioctl()
488 struct asyncppp *ap = from_tasklet(ap, t, tsk); in ppp_async_process() local
492 while ((skb = skb_dequeue(&ap->rqueue)) != NULL) { in ppp_async_process()
494 ppp_input_error(&ap->chan, 0); in ppp_async_process()
495 ppp_input(&ap->chan, skb); in ppp_async_process()
499 if (test_bit(XMIT_WAKEUP, &ap->xmit_flags) && ppp_async_push(ap)) in ppp_async_process()
500 ppp_output_wakeup(&ap->chan); in ppp_async_process()
511 * Assumes ap->tpkt != 0 on entry.
515 #define PUT_BYTE(ap, buf, c, islcp) do { \ argument
516 if ((islcp && c < 0x20) || (ap->xaccm[c >> 5] & (1 << (c & 0x1f)))) {\
524 ppp_async_encode(struct asyncppp *ap) in ppp_async_encode() argument
531 buf = ap->obuf; in ppp_async_encode()
532 ap->olim = buf; in ppp_async_encode()
533 ap->optr = buf; in ppp_async_encode()
534 i = ap->tpkt_pos; in ppp_async_encode()
535 data = ap->tpkt->data; in ppp_async_encode()
536 count = ap->tpkt->len; in ppp_async_encode()
537 fcs = ap->tfcs; in ppp_async_encode()
549 async_lcp_peek(ap, data, count, 0); in ppp_async_encode()
556 time_after_eq(jiffies, ap->last_xmit + flag_time)) in ppp_async_encode()
558 ap->last_xmit = jiffies; in ppp_async_encode()
564 if ((ap->flags & SC_COMP_AC) == 0 || islcp) { in ppp_async_encode()
565 PUT_BYTE(ap, buf, 0xff, islcp); in ppp_async_encode()
567 PUT_BYTE(ap, buf, 0x03, islcp); in ppp_async_encode()
577 buflim = ap->obuf + OBUFSIZE - 6; in ppp_async_encode()
580 if (i == 1 && c == 0 && (ap->flags & SC_COMP_PROT)) in ppp_async_encode()
583 PUT_BYTE(ap, buf, c, islcp); in ppp_async_encode()
590 ap->olim = buf; in ppp_async_encode()
591 ap->tpkt_pos = i; in ppp_async_encode()
592 ap->tfcs = fcs; in ppp_async_encode()
601 PUT_BYTE(ap, buf, c, islcp); in ppp_async_encode()
603 PUT_BYTE(ap, buf, c, islcp); in ppp_async_encode()
605 ap->olim = buf; in ppp_async_encode()
607 consume_skb(ap->tpkt); in ppp_async_encode()
608 ap->tpkt = NULL; in ppp_async_encode()
625 struct asyncppp *ap = chan->private; in ppp_async_send() local
627 ppp_async_push(ap); in ppp_async_send()
629 if (test_and_set_bit(XMIT_FULL, &ap->xmit_flags)) in ppp_async_send()
631 ap->tpkt = skb; in ppp_async_send()
632 ap->tpkt_pos = 0; in ppp_async_send()
634 ppp_async_push(ap); in ppp_async_send()
642 ppp_async_push(struct asyncppp *ap) in ppp_async_push() argument
645 struct tty_struct *tty = ap->tty; in ppp_async_push()
657 if (test_and_set_bit(XMIT_BUSY, &ap->xmit_flags)) in ppp_async_push()
659 spin_lock_bh(&ap->xmit_lock); in ppp_async_push()
661 if (test_and_clear_bit(XMIT_WAKEUP, &ap->xmit_flags)) in ppp_async_push()
663 if (!tty_stuffed && ap->optr < ap->olim) { in ppp_async_push()
664 avail = ap->olim - ap->optr; in ppp_async_push()
666 sent = tty->ops->write(tty, ap->optr, avail); in ppp_async_push()
669 ap->optr += sent; in ppp_async_push()
674 if (ap->optr >= ap->olim && ap->tpkt) { in ppp_async_push()
675 if (ppp_async_encode(ap)) { in ppp_async_push()
676 /* finished processing ap->tpkt */ in ppp_async_push()
677 clear_bit(XMIT_FULL, &ap->xmit_flags); in ppp_async_push()
691 clear_bit(XMIT_BUSY, &ap->xmit_flags); in ppp_async_push()
693 if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags) || in ppp_async_push()
694 (!tty_stuffed && ap->tpkt))) in ppp_async_push()
697 if (test_and_set_bit(XMIT_BUSY, &ap->xmit_flags)) in ppp_async_push()
700 spin_unlock_bh(&ap->xmit_lock); in ppp_async_push()
704 clear_bit(XMIT_BUSY, &ap->xmit_flags); in ppp_async_push()
705 if (ap->tpkt) { in ppp_async_push()
706 kfree_skb(ap->tpkt); in ppp_async_push()
707 ap->tpkt = NULL; in ppp_async_push()
708 clear_bit(XMIT_FULL, &ap->xmit_flags); in ppp_async_push()
711 ap->optr = ap->olim; in ppp_async_push()
712 spin_unlock_bh(&ap->xmit_lock); in ppp_async_push()
722 ppp_async_flush_output(struct asyncppp *ap) in ppp_async_flush_output() argument
726 spin_lock_bh(&ap->xmit_lock); in ppp_async_flush_output()
727 ap->optr = ap->olim; in ppp_async_flush_output()
728 if (ap->tpkt != NULL) { in ppp_async_flush_output()
729 kfree_skb(ap->tpkt); in ppp_async_flush_output()
730 ap->tpkt = NULL; in ppp_async_flush_output()
731 clear_bit(XMIT_FULL, &ap->xmit_flags); in ppp_async_flush_output()
734 spin_unlock_bh(&ap->xmit_lock); in ppp_async_flush_output()
736 ppp_output_wakeup(&ap->chan); in ppp_async_flush_output()
745 scan_ordinary(struct asyncppp *ap, const unsigned char *buf, int count) in scan_ordinary() argument
752 (c < 0x20 && (ap->raccm & (1 << c)) != 0)) in scan_ordinary()
760 process_input_packet(struct asyncppp *ap) in process_input_packet() argument
766 skb = ap->rpkt; in process_input_packet()
767 if (ap->state & (SC_TOSS | SC_ESCAPE)) in process_input_packet()
802 async_lcp_peek(ap, p, skb->len, 1); in process_input_packet()
806 skb->cb[0] = ap->state; in process_input_packet()
807 skb_queue_tail(&ap->rqueue, skb); in process_input_packet()
808 ap->rpkt = NULL; in process_input_packet()
809 ap->state = 0; in process_input_packet()
814 ap->state = SC_PREV_ERROR; in process_input_packet()
826 ppp_async_input(struct asyncppp *ap, const u8 *buf, const u8 *flags, int count) in ppp_async_input() argument
833 if (~ap->rbits & SC_RCV_BITS) { in ppp_async_input()
843 ap->rbits |= s; in ppp_async_input()
848 if ((ap->state & SC_ESCAPE) && buf[0] == PPP_ESCAPE) in ppp_async_input()
851 n = scan_ordinary(ap, buf, count); in ppp_async_input()
854 if (flags && (ap->state & SC_TOSS) == 0) { in ppp_async_input()
862 ap->state |= SC_TOSS; in ppp_async_input()
864 } else if (n > 0 && (ap->state & SC_TOSS) == 0) { in ppp_async_input()
866 skb = ap->rpkt; in ppp_async_input()
868 skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2); in ppp_async_input()
871 ap->rpkt = skb; in ppp_async_input()
885 ap->state |= SC_TOSS; in ppp_async_input()
888 if (ap->state & SC_ESCAPE) { in ppp_async_input()
890 ap->state &= ~SC_ESCAPE; in ppp_async_input()
900 ap->state |= SC_TOSS; in ppp_async_input()
902 process_input_packet(ap); in ppp_async_input()
904 ap->state |= SC_ESCAPE; in ppp_async_input()
905 } else if (I_IXON(ap->tty)) { in ppp_async_input()
906 if (c == START_CHAR(ap->tty)) in ppp_async_input()
907 start_tty(ap->tty); in ppp_async_input()
908 else if (c == STOP_CHAR(ap->tty)) in ppp_async_input()
909 stop_tty(ap->tty); in ppp_async_input()
923 ap->state |= SC_TOSS; in ppp_async_input()
944 static void async_lcp_peek(struct asyncppp *ap, unsigned char *data, in async_lcp_peek() argument
972 ap->lcp_fcs = fcs; in async_lcp_peek()
977 fcs ^= ap->lcp_fcs; in async_lcp_peek()
978 ap->lcp_fcs = -1; in async_lcp_peek()
993 ap->mru = val; in async_lcp_peek()
995 ap->chan.mtu = val; in async_lcp_peek()
1000 ap->raccm = val; in async_lcp_peek()
1002 ap->xaccm[0] = val; in async_lcp_peek()