* Al Longyear <longyear@netcom.com>
* Extensively rewritten by Paul Mackerras <paulus@cs.anu.edu.au>
*
- * ==FILEVERSION 980704==
+ * ==FILEVERSION 981004==
*
* NOTE TO MAINTAINERS:
* If you modify this file at all, please set the number above to the
#define PPP_MAX_RCV_QLEN 32 /* max # frames we queue up for pppd */
-/* $Id: ppp.c,v 1.19 1998/07/07 04:27:37 paulus Exp $ */
+/* $Id: ppp.c,v 1.20 1999/01/19 23:57:44 paulus Exp $ */
#include <linux/version.h>
#include <linux/config.h>
#include <linux/kerneld.h>
#endif
+#define PPP_VERSION "2.3.5"
+
#if LINUX_VERSION_CODE >= VERSION(2,1,4)
#if LINUX_VERSION_CODE >= VERSION(2,1,5)
static void ppp_output_wakeup(struct ppp *ppp);
static void ppp_send_ctrl(struct ppp *ppp, struct sk_buff *skb);
static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb);
+static void ppp_send_frames(struct ppp *ppp);
static struct sk_buff *ppp_vj_compress(struct ppp *ppp, struct sk_buff *skb);
static struct ppp *ppp_find (int pid_value);
return;
if (ppp->backup_tty) {
ppp->tty = ppp->backup_tty;
+ if (ppp_tty_push(ppp))
+ ppp_output_wakeup(ppp);
} else {
ppp->tty = 0;
ppp->sc_xfer = 0;
ppp_async_release(ppp);
ppp_release(ppp);
- ppp->inuse = 0;
MOD_DEC_USE_COUNT;
}
}
/*
* Copy the received data from the buffer to the caller's area.
*/
- err = COPY_TO_USER(buf, skb->data, len);
- if (err == 0)
- err = len;
+ err = len;
+ if (COPY_TO_USER(buf, skb->data, len))
+ err = -EFAULT;
out:
kfree_skb(skb);
return -EINVAL;
}
- return COPY_TO_USER((void *) ifr->ifr_ifru.ifru_data, &u, nb);
+ if (COPY_TO_USER((void *) ifr->ifr_ifru.ifru_data, &u, nb))
+ return -EFAULT;
+ return 0;
}
/*
break;
if (temp_i < PPP_MRU)
temp_i = PPP_MRU;
+ ppp->mru = temp_i;
if (ppp->flags & SC_DEBUG)
printk(KERN_INFO
"ppp_ioctl: set mru to %x\n", temp_i);
/*
* Fetch the compression parameters
*/
+ error = -EFAULT;
if (COPY_FROM_USER(&data, odp, sizeof (data)))
- return -EFAULT;
+ goto out;
nb = data.length;
ptr = data.ptr;
nb = CCP_MAX_OPTION_LENGTH;
if (COPY_FROM_USER(ccp_option, ptr, nb))
- return -EFAULT;
+ goto out;
+ error = -EINVAL;
if (ccp_option[1] < 2) /* preliminary check on the length byte */
- return -EINVAL;
+ goto out;
save_flags(flags);
cli();
"%s: no compressor for [%x %x %x], %x\n",
ppp->name, ccp_option[0], ccp_option[1],
ccp_option[2], nb);
- return -EINVAL; /* compressor not loaded */
+ goto out; /* compressor not loaded */
}
/*
ppp->sc_xcomp = cp;
ppp->sc_xc_state = cp->comp_alloc(ccp_option, nb);
-
if (ppp->sc_xc_state == NULL) {
if (ppp->flags & SC_DEBUG)
printk(KERN_DEBUG "%s: comp_alloc failed\n",
error = -ENOBUFS;
}
}
-
+out:
return error;
}
*/
skb->dev = ppp2dev(ppp); /* We are the device */
skb->protocol = htons(proto);
- skb->mac.raw = skb->data;
skb_pull(skb, PPP_HDRLEN); /* pull off ppp header */
+ skb->mac.raw = skb->data;
ppp->last_recv = jiffies;
#if LINUX_VERSION_CODE < VERSION(2,1,15)
skb->free = 1;
/*
* Compress and send an frame to the peer.
- * Should be called with dev->tbusy == 1, having been set by the caller.
- * That is, we use dev->tbusy as a lock to prevent reentry of this
+ * Should be called with xmit_busy == 1, having been set by the caller.
+ * That is, we use xmit_busy as a lock to prevent reentry of this
* procedure.
*/
static void
if (new_skb == NULL) {
printk(KERN_ERR "ppp_send_frame: no memory\n");
kfree_skb(skb);
- ppp->dev.tbusy = 0;
+ ppp->xmit_busy = 0;
return;
}
ret = ppp_async_send(ppp, skb);
if (ret > 0) {
/* we can release the lock */
- ppp->dev.tbusy = 0;
+ ppp->xmit_busy = 0;
} else if (ret < 0) {
- /* this can't happen, since the caller got the tbusy lock */
+ /* can't happen, since the caller got the xmit_busy lock */
printk(KERN_ERR "ppp: ppp_async_send didn't accept pkt\n");
}
}
{
struct sk_buff *skb;
- while (!test_and_set_bit(0, &ppp->dev.tbusy)) {
+ while (!test_and_set_bit(0, &ppp->xmit_busy)) {
skb = skb_dequeue(&ppp->xmt_q);
if (skb == NULL) {
- ppp->dev.tbusy = 0;
- mark_bh(NET_BH);
+ ppp->xmit_busy = 0;
break;
}
ppp_send_frame(ppp, skb);
}
+ if (!ppp->xmit_busy && ppp->dev.tbusy) {
+ ppp->dev.tbusy = 0;
+ mark_bh(NET_BH);
+ }
}
/*
{
CHECK_PPP_VOID();
- if (!ppp->dev.tbusy) {
- printk(KERN_ERR "ppp_output_wakeup called but tbusy==0\n");
+ if (!ppp->xmit_busy) {
+ printk(KERN_ERR "ppp_output_wakeup called but xmit_busy==0\n");
return;
}
- ppp->dev.tbusy = 0;
+ ppp->xmit_busy = 0;
ppp_send_frames(ppp);
}
* The dev->tbusy field acts as a lock to allow only
* one packet to be processed at a time. If we can't
* get the lock, try again later.
+ * We deliberately queue as little as possible inside
+ * the ppp driver in order to minimize the latency
+ * for high-priority packets.
*/
- if (test_and_set_bit(0, &dev->tbusy))
+ if (test_and_set_bit(0, &ppp->xmit_busy)) {
+ dev->tbusy = 1; /* can't take it now */
return 1;
+ }
+ dev->tbusy = 0;
/*
* Put the 4-byte PPP header on the packet.
printk(KERN_ERR "%s: skb hdr alloc failed\n",
ppp->name);
dev_kfree_skb(skb);
- dev->tbusy = 0;
+ ppp->xmit_busy = 0;
+ ppp_send_frames(ppp);
return 0;
}
skb_reserve(new_skb, PPP_HDRLEN);
hdr[3] = proto;
ppp_send_frame(ppp, skb);
+ if (!ppp->xmit_busy)
+ ppp_send_frames(ppp);
return 0;
}
ppp->last_xmit = jiffies;
ppp->last_recv = jiffies;
+ ppp->xmit_busy = 0;
/* clear statistics */
memset(&ppp->stats, 0, sizeof (struct pppstat));
kfree_skb(skb);
while ((skb = skb_dequeue(&ppp->xmt_q)) != NULL)
kfree_skb(skb);
+
+ ppp->inuse = 0;
+ if (ppp->dev.tbusy) {
+ ppp->dev.tbusy = 0;
+ mark_bh(NET_BH);
+ }
}
/*