--- Net2/net/if_sl.c 2018/04/24 18:13:17 1.1.1.4 +++ Net2/net/if_sl.c 2018/04/24 18:21:41 1.1.1.5 @@ -30,7 +30,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)if_sl.c 7.22 (Berkeley) 4/20/91 + * from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp + * + * from: @(#)if_sl.c 7.22 (Berkeley) 4/20/91 + * if_sl.c,v 1.8 1993/05/22 11:42:11 cgd Exp */ /* @@ -64,9 +67,6 @@ * interrupts and network activity; thus, splimp must be >= spltty. */ -/* $Header: /var/lib/cvsd/net2/Net2/net/if_sl.c,v 1.1.1.4 2018/04/24 18:13:17 root Exp $ */ -/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */ - #include "sl.h" #if NSL > 0 @@ -249,9 +249,8 @@ slinit(sc) * Attach the given tty to the first available sl unit. */ /* ARGSUSED */ -slopen(dev, tp) - dev_t dev; - register struct tty *tp; +int +slopen(dev_t dev, struct tty *tp) { struct proc *p = curproc; /* XXX */ register struct sl_softc *sc; @@ -282,8 +281,10 @@ slopen(dev, tp) * Detach the tty from the sl unit. * Mimics part of ttyclose(). */ -slclose(tp) +void +slclose(tp, flag) struct tty *tp; + int flag; { register struct sl_softc *sc; int s; @@ -394,7 +395,7 @@ sloutput(ifp, m, dst) } IF_ENQUEUE(ifq, m); sc->sc_if.if_lastchange = time; - if (RB_LEN(&sc->sc_ttyp->t_out) == 0) + if (sc->sc_ttyp->t_outq.c_cc == 0) slstart(sc->sc_ttyp); splx(s); return (0); @@ -405,6 +406,7 @@ sloutput(ifp, m, dst) * to send from the interface queue and map it to * the interface before starting output. */ +void slstart(tp) register struct tty *tp; { @@ -425,9 +427,9 @@ slstart(tp) * We are being called in lieu of ttstart and must do what * it would. */ - if (RB_LEN(&tp->t_out) != 0) { + if (tp->t_outq.c_cc != 0) { (*tp->t_oproc)(tp); - if (RB_LEN(&tp->t_out) > SLIP_HIWAT) + if (tp->t_outq.c_cc > SLIP_HIWAT) return; } /* @@ -440,11 +442,11 @@ slstart(tp) * Do not remove the packet from the IP queue if it * doesn't look like the packet will fit into the * current COM output queue, with a packet full of - * escapes this could be as bad as SLMTU*2. The value - * of RBSZ in tty.h also has to be upped to be at least - * SLMTU*2. + * escapes this could be as bad as SLMTU*2. The size + * of the ring buffer must be at least SLMTU*2 to + * avoid deadlock. */ - if (RBSZ - RB_LEN(&tp->t_out) < 2 * SLMTU + 2) + if (tp->t_outq.c_cn - tp->t_outq.c_cc < 2 * SLMTU) return; /* @@ -507,9 +509,9 @@ slstart(tp) * will flush any accumulated garbage. We do this whenever * the line may have been idle for some time. */ - if (RB_LEN(&tp->t_out) == 0) { + if (tp->t_outq.c_cc == 0) { ++sc->sc_bytessent; - (void) putc(FRAME_END, &tp->t_out); + (void) putc(FRAME_END, &tp->t_outq); } while (m) { @@ -534,13 +536,12 @@ slstart(tp) out: if (cp > bp) { /* - * Put the non-special bytes + * Put n characters at once * into the tty output queue. */ - sc->sc_bytessent += rb_write( - &tp->t_out, - (char *) bp, - cp - bp); + if (b_to_q((u_char *)bp, cp - bp, &tp->t_outq)) + break; + sc->sc_bytessent += cp - bp; } /* * If there are characters left in the mbuf, @@ -548,12 +549,12 @@ slstart(tp) * Put it out in a different form. */ if (cp < ep) { - if (putc(FRAME_ESCAPE, &tp->t_out)) + if (putc(FRAME_ESCAPE, &tp->t_outq)) break; if (putc(*cp++ == FRAME_ESCAPE ? TRANS_FRAME_ESCAPE : TRANS_FRAME_END, - &tp->t_out)) { - (void) unputc(&tp->t_out); + &tp->t_outq)) { + (void) unputc(&tp->t_outq); break; } sc->sc_bytessent += 2; @@ -563,7 +564,7 @@ slstart(tp) m = m2; } - if (putc(FRAME_END, &tp->t_out)) { + if (putc(FRAME_END, &tp->t_outq)) { /* * Not enough room. Remove a char to make room * and end the packet normally. @@ -571,8 +572,8 @@ slstart(tp) * a day) you probably do not have enough clists * and you should increase "nclist" in param.c. */ - (void) unputc(&tp->t_out); - (void) putc(FRAME_END, &tp->t_out); + (void) unputc(&tp->t_outq); + (void) putc(FRAME_END, &tp->t_outq); sc->sc_if.if_collisions++; } else { ++sc->sc_bytessent; @@ -628,6 +629,7 @@ sl_btom(sc, len) /* * tty interface receiver interrupt. */ +void slinput(c, tp) register int c; register struct tty *tp;