Lines Matching refs:ap
93 static struct sk_buff* ppp_sync_txmunge(struct syncppp *ap, struct sk_buff *);
98 static int ppp_sync_push(struct syncppp *ap);
99 static void ppp_sync_flush_output(struct syncppp *ap);
100 static void ppp_sync_input(struct syncppp *ap, const unsigned char *buf,
140 struct syncppp *ap; in sp_get() local
143 ap = tty->disc_data; in sp_get()
144 if (ap != NULL) in sp_get()
145 refcount_inc(&ap->refcnt); in sp_get()
147 return ap; in sp_get()
150 static void sp_put(struct syncppp *ap) in sp_put() argument
152 if (refcount_dec_and_test(&ap->refcnt)) in sp_put()
153 complete(&ap->dead_cmp); in sp_put()
162 struct syncppp *ap; in ppp_sync_open() local
169 ap = kzalloc(sizeof(*ap), GFP_KERNEL); in ppp_sync_open()
171 if (!ap) in ppp_sync_open()
175 ap->tty = tty; in ppp_sync_open()
176 ap->mru = PPP_MRU; in ppp_sync_open()
177 spin_lock_init(&ap->xmit_lock); in ppp_sync_open()
178 spin_lock_init(&ap->recv_lock); in ppp_sync_open()
179 ap->xaccm[0] = ~0U; in ppp_sync_open()
180 ap->xaccm[3] = 0x60000000U; in ppp_sync_open()
181 ap->raccm = ~0U; in ppp_sync_open()
183 skb_queue_head_init(&ap->rqueue); in ppp_sync_open()
184 tasklet_init(&ap->tsk, ppp_sync_process, (unsigned long) ap); in ppp_sync_open()
186 refcount_set(&ap->refcnt, 1); in ppp_sync_open()
187 init_completion(&ap->dead_cmp); in ppp_sync_open()
189 ap->chan.private = ap; in ppp_sync_open()
190 ap->chan.ops = &sync_ops; in ppp_sync_open()
191 ap->chan.mtu = PPP_MRU; in ppp_sync_open()
192 ap->chan.hdrlen = 2; /* for A/C bytes */ in ppp_sync_open()
194 ap->chan.speed = speed; in ppp_sync_open()
195 err = ppp_register_channel(&ap->chan); in ppp_sync_open()
199 tty->disc_data = ap; in ppp_sync_open()
204 kfree(ap); in ppp_sync_open()
220 struct syncppp *ap; in ppp_sync_close() local
223 ap = tty->disc_data; in ppp_sync_close()
226 if (!ap) in ppp_sync_close()
236 if (!refcount_dec_and_test(&ap->refcnt)) in ppp_sync_close()
237 wait_for_completion(&ap->dead_cmp); in ppp_sync_close()
238 tasklet_kill(&ap->tsk); in ppp_sync_close()
240 ppp_unregister_channel(&ap->chan); in ppp_sync_close()
241 skb_queue_purge(&ap->rqueue); in ppp_sync_close()
242 kfree_skb(ap->tpkt); in ppp_sync_close()
243 kfree(ap); in ppp_sync_close()
284 struct syncppp *ap = sp_get(tty); in ppp_synctty_ioctl() local
288 if (!ap) in ppp_synctty_ioctl()
294 if (put_user(ppp_channel_index(&ap->chan), p)) in ppp_synctty_ioctl()
301 if (put_user(ppp_unit_number(&ap->chan), p)) in ppp_synctty_ioctl()
309 ppp_sync_flush_output(ap); in ppp_synctty_ioctl()
325 sp_put(ap); in ppp_synctty_ioctl()
341 struct syncppp *ap = sp_get(tty); in ppp_sync_receive() local
344 if (!ap) in ppp_sync_receive()
346 spin_lock_irqsave(&ap->recv_lock, flags); in ppp_sync_receive()
347 ppp_sync_input(ap, buf, cflags, count); in ppp_sync_receive()
348 spin_unlock_irqrestore(&ap->recv_lock, flags); in ppp_sync_receive()
349 if (!skb_queue_empty(&ap->rqueue)) in ppp_sync_receive()
350 tasklet_schedule(&ap->tsk); in ppp_sync_receive()
351 sp_put(ap); in ppp_sync_receive()
358 struct syncppp *ap = sp_get(tty); in ppp_sync_wakeup() local
361 if (!ap) in ppp_sync_wakeup()
363 set_bit(XMIT_WAKEUP, &ap->xmit_flags); in ppp_sync_wakeup()
364 tasklet_schedule(&ap->tsk); in ppp_sync_wakeup()
365 sp_put(ap); in ppp_sync_wakeup()
402 struct syncppp *ap = chan->private; in ppp_sync_ioctl() local
411 val = ap->flags | ap->rbits; in ppp_sync_ioctl()
419 ap->flags = val & ~SC_RCV_BITS; in ppp_sync_ioctl()
420 spin_lock_irq(&ap->recv_lock); in ppp_sync_ioctl()
421 ap->rbits = val & SC_RCV_BITS; in ppp_sync_ioctl()
422 spin_unlock_irq(&ap->recv_lock); in ppp_sync_ioctl()
427 if (put_user(ap->xaccm[0], p)) in ppp_sync_ioctl()
432 if (get_user(ap->xaccm[0], p)) in ppp_sync_ioctl()
438 if (put_user(ap->raccm, p)) in ppp_sync_ioctl()
443 if (get_user(ap->raccm, p)) in ppp_sync_ioctl()
449 if (copy_to_user(argp, ap->xaccm, sizeof(ap->xaccm))) in ppp_sync_ioctl()
458 memcpy(ap->xaccm, accm, sizeof(ap->xaccm)); in ppp_sync_ioctl()
463 if (put_user(ap->mru, (int __user *) argp)) in ppp_sync_ioctl()
472 ap->mru = val; in ppp_sync_ioctl()
489 struct syncppp *ap = (struct syncppp *) arg; in ppp_sync_process() local
493 while ((skb = skb_dequeue(&ap->rqueue)) != NULL) { in ppp_sync_process()
496 ppp_input_error(&ap->chan, 0); in ppp_sync_process()
500 ppp_input(&ap->chan, skb); in ppp_sync_process()
504 if (test_bit(XMIT_WAKEUP, &ap->xmit_flags) && ppp_sync_push(ap)) in ppp_sync_process()
505 ppp_output_wakeup(&ap->chan); in ppp_sync_process()
513 ppp_sync_txmunge(struct syncppp *ap, struct sk_buff *skb) in ppp_sync_txmunge() argument
529 if (data[0] == 0 && (ap->flags & SC_COMP_PROT) && !islcp) in ppp_sync_txmunge()
533 if ((ap->flags & SC_COMP_AC) == 0 || islcp) { in ppp_sync_txmunge()
551 ap->last_xmit = jiffies; in ppp_sync_txmunge()
553 if (skb && ap->flags & SC_LOG_OUTPKT) in ppp_sync_txmunge()
572 struct syncppp *ap = chan->private; in ppp_sync_send() local
574 ppp_sync_push(ap); in ppp_sync_send()
576 if (test_and_set_bit(XMIT_FULL, &ap->xmit_flags)) in ppp_sync_send()
578 skb = ppp_sync_txmunge(ap, skb); in ppp_sync_send()
580 ap->tpkt = skb; in ppp_sync_send()
582 clear_bit(XMIT_FULL, &ap->xmit_flags); in ppp_sync_send()
584 ppp_sync_push(ap); in ppp_sync_send()
592 ppp_sync_push(struct syncppp *ap) in ppp_sync_push() argument
595 struct tty_struct *tty = ap->tty; in ppp_sync_push()
598 if (!spin_trylock_bh(&ap->xmit_lock)) in ppp_sync_push()
601 if (test_and_clear_bit(XMIT_WAKEUP, &ap->xmit_flags)) in ppp_sync_push()
603 if (!tty_stuffed && ap->tpkt) { in ppp_sync_push()
605 sent = tty->ops->write(tty, ap->tpkt->data, ap->tpkt->len); in ppp_sync_push()
608 if (sent < ap->tpkt->len) { in ppp_sync_push()
611 consume_skb(ap->tpkt); in ppp_sync_push()
612 ap->tpkt = NULL; in ppp_sync_push()
613 clear_bit(XMIT_FULL, &ap->xmit_flags); in ppp_sync_push()
619 spin_unlock_bh(&ap->xmit_lock); in ppp_sync_push()
620 if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags) || in ppp_sync_push()
621 (!tty_stuffed && ap->tpkt))) in ppp_sync_push()
623 if (!spin_trylock_bh(&ap->xmit_lock)) in ppp_sync_push()
629 if (ap->tpkt) { in ppp_sync_push()
630 kfree_skb(ap->tpkt); in ppp_sync_push()
631 ap->tpkt = NULL; in ppp_sync_push()
632 clear_bit(XMIT_FULL, &ap->xmit_flags); in ppp_sync_push()
635 spin_unlock_bh(&ap->xmit_lock); in ppp_sync_push()
644 ppp_sync_flush_output(struct syncppp *ap) in ppp_sync_flush_output() argument
648 spin_lock_bh(&ap->xmit_lock); in ppp_sync_flush_output()
649 if (ap->tpkt != NULL) { in ppp_sync_flush_output()
650 kfree_skb(ap->tpkt); in ppp_sync_flush_output()
651 ap->tpkt = NULL; in ppp_sync_flush_output()
652 clear_bit(XMIT_FULL, &ap->xmit_flags); in ppp_sync_flush_output()
655 spin_unlock_bh(&ap->xmit_lock); in ppp_sync_flush_output()
657 ppp_output_wakeup(&ap->chan); in ppp_sync_flush_output()
671 ppp_sync_input(struct syncppp *ap, const unsigned char *buf, in ppp_sync_input() argument
680 if (ap->flags & SC_LOG_INPKT) in ppp_sync_input()
684 skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2); in ppp_sync_input()
720 skb_queue_tail(&ap->rqueue, skb); in ppp_sync_input()
727 skb_queue_tail(&ap->rqueue, skb); in ppp_sync_input()