-/*
- * Lock the indicated transmit buffer
- */
-
-extern inline int
-lock_buffer (register struct ppp_buffer *buf)
-{
- unsigned long state;
- unsigned long flags;
-/*
- * Save the current state and if free then set it to the "busy" state
- */
- CHECK_BUF_MAGIC(buf);
- save_flags (flags);
- cli ();
- state = buf->locked;
- if (state == 0)
- buf->locked = 2;
-
- restore_flags (flags);
- return (state);
-}
-
-/*
- * MTU has been changed by the IP layer. Unfortunately we are not told
- * about this, but we spot it ourselves and fix things up. We could be
- * in an upcall from the tty driver, or in an ip packet queue.
- */
-
-static int
-ppp_changedmtu (struct ppp *ppp, int new_mtu, int new_mru)
-{
- struct device *dev;
- unsigned long flags;
-
- struct ppp_buffer *new_rbuf;
- struct ppp_buffer *new_wbuf;
- struct ppp_buffer *new_cbuf;
- struct ppp_buffer *new_tbuf;
-
- struct ppp_buffer *old_rbuf;
- struct ppp_buffer *old_wbuf;
- struct ppp_buffer *old_cbuf;
- struct ppp_buffer *old_tbuf;
-
- int mtu, mru;
-/*
- * Allocate the buffer from the kernel for the data
- */
- CHECK_PPP(0);
- dev = ppp2dev (ppp);
- if (ppp->flags & SC_DEBUG)
- printk(KERN_DEBUG "%s: changedmtu %d %d\n", ppp->name,
- new_mtu, new_mru);
- mru = new_mru;
- /* allow for possible escaping of every character */
- mtu = (new_mtu * 2) + 20;
-
- /* RFC 1331, section 7.2 says the minimum value is 1500 bytes */
- if (mru < PPP_MRU)
- mru = PPP_MRU;
-
- mru += 10;
-
- new_wbuf = ppp_alloc_buf (mtu+PPP_HDRLEN, BUFFER_TYPE_DEV_WR);
- new_tbuf = ppp_alloc_buf ((PPP_MTU * 2) + 24, BUFFER_TYPE_TTY_WR);
- new_rbuf = ppp_alloc_buf (mru + 84, BUFFER_TYPE_DEV_RD);
- new_cbuf = ppp_alloc_buf (mru+PPP_HDRLEN, BUFFER_TYPE_VJ);
-/*
- * If the buffers failed to allocate then complain and release the partial
- * allocations.
- */
- if (new_wbuf == NULL || new_tbuf == NULL ||
- new_rbuf == NULL || new_cbuf == NULL) {
- printk (KERN_ERR "ppp: failed to allocate new buffers\n");
-
- ppp_free_buf (new_wbuf);
- ppp_free_buf (new_tbuf);
- ppp_free_buf (new_rbuf);
- ppp_free_buf (new_cbuf);
- return 0;
- }
-/*
- * Update the pointers to the new buffer structures.
- */
- save_flags(flags);
- cli ();
- old_wbuf = ppp->wbuf;
- old_rbuf = ppp->rbuf;
- old_cbuf = ppp->cbuf;
- old_tbuf = ppp->tbuf;
-
- ppp->wbuf = new_wbuf;
- ppp->rbuf = new_rbuf;
- ppp->cbuf = new_cbuf;
- ppp->tbuf = new_tbuf;
-
- if (old_wbuf)
- new_wbuf->locked = old_wbuf->locked;
-
- ppp->rbuf->size -= 80; /* reserve space for vj header expansion */
-
- dev->mem_start = (unsigned long) buf_base (new_wbuf);
- dev->mem_end = (unsigned long) (dev->mem_start + mtu);
- dev->rmem_start = (unsigned long) buf_base (new_rbuf);
- dev->rmem_end = (unsigned long) (dev->rmem_start + mru);
-/*
- * Update the parameters for the new buffer sizes
- */
- ppp->toss = 0xE0; /* To ignore characters until new FLAG */
- ppp->escape = 0; /* No pending escape character */
-
- dev->mtu =
- ppp->mtu = new_mtu;
- ppp->mru = new_mru;
-
- ppp->s1buf = NULL;
- ppp->s2buf = NULL;
- ppp->xbuf = NULL;
-
- ppp->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
- ppp->flags &= ~SC_XMIT_BUSY;
-
- restore_flags(flags);
-/*
- * Release old buffer pointers
- */
- ppp_free_buf (old_rbuf);
- ppp_free_buf (old_wbuf);
- ppp_free_buf (old_cbuf);
- ppp_free_buf (old_tbuf);
- return 1;
-}
-
-/*
- * CCP is down; free (de)compressor state if necessary.
- */
-
-static void
-ppp_ccp_closed (struct ppp *ppp)
-{
- unsigned long flags;
-
- save_flags(flags);
- cli();
- ppp->flags &= ~(SC_CCP_OPEN | SC_CCP_UP | SC_COMP_RUN | SC_DECOMP_RUN);
- restore_flags(flags);
- if (ppp->flags & SC_DEBUG)
- printk(KERN_DEBUG "%s: ccp closed\n", ppp->name);
- if (ppp->sc_xc_state) {
- (*ppp->sc_xcomp->comp_free) (ppp->sc_xc_state);
- ppp->sc_xc_state = NULL;
- }
-
- if (ppp->sc_rc_state) {
- (*ppp->sc_rcomp->decomp_free) (ppp->sc_rc_state);
- ppp->sc_rc_state = NULL;
- }
-}
-
-/*
- * Called to release all of the information in the current PPP structure.
- *
- * It is called when the ppp device goes down or if it is unable to go
- * up.
- */
-
-static void
-ppp_release (struct ppp *ppp)
-{
- struct tty_struct *tty;
- struct device *dev;
-
- CHECK_PPP_MAGIC(ppp);
- tty = ppp2tty (ppp);
- dev = ppp2dev (ppp);
-
- if (ppp->flags & SC_DEBUG)
- printk(KERN_DEBUG "%s released\n", ppp->name);
-
- ppp_ccp_closed (ppp);