Sync if if_sl.c,v 1.66:

Move the VJ uncompress code into the software interrupt.
This commit is contained in:
thorpej 2001-01-11 22:56:51 +00:00
parent e94e4a6d47
commit 455e3228dd
1 changed files with 111 additions and 99 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_strip.c,v 1.29 2001/01/11 22:31:49 thorpej Exp $ */
/* $NetBSD: if_strip.c,v 1.30 2001/01/11 22:56:51 thorpej Exp $ */
/* from: NetBSD: if_sl.c,v 1.38 1996/02/13 22:00:23 christos Exp $ */
/*
@ -1077,43 +1077,25 @@ strip_btom(sc, len)
{
struct mbuf *m;
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
/*
* Allocate a new input buffer and swap.
*/
m = sc->sc_mbuf;
MGETHDR(sc->sc_mbuf, M_DONTWAIT, MT_DATA);
if (sc->sc_mbuf == NULL) {
sc->sc_mbuf = m;
return (NULL);
/*
* We always prepend enough space for the SLIP "header".
*/
sc->sc_pktstart -= SLIP_HDRLEN;
len += SLIP_HDRLEN;
/*
* If the packet will fit into the header mbuf we allocated
* above, copy it there and re-use the input buffer we already
* have.
*/
if (len < MHLEN)
memcpy(mtod(m, caddr_t), sc->sc_pktstart, len);
else {
/*
* Allocate a new input buffer and swap.
*/
m = sc->sc_mbuf;
MGETHDR(sc->sc_mbuf, M_DONTWAIT, MT_DATA);
if (sc->sc_mbuf == NULL) {
sc->sc_mbuf = m;
return (NULL);
}
MCLGET(sc->sc_mbuf, M_DONTWAIT);
if ((sc->sc_mbuf->m_flags & M_EXT) == 0) {
sc->sc_mbuf = m;
return (NULL);
}
sc->sc_ep = (u_char *) sc->sc_mbuf->m_ext.ext_buf +
sc->sc_mbuf->m_ext.ext_size;
m->m_data = sc->sc_pktstart;
}
MCLGET(sc->sc_mbuf, M_DONTWAIT);
if ((sc->sc_mbuf->m_flags & M_EXT) == 0) {
m_freem(sc->sc_mbuf);
sc->sc_mbuf = m;
return (NULL);
}
sc->sc_ep = (u_char *) sc->sc_mbuf->m_ext.ext_buf +
sc->sc_mbuf->m_ext.ext_size;
m->m_data = sc->sc_pktstart;
m->m_pkthdr.len = m->m_len = len;
m->m_pkthdr.rcvif = &sc->sc_if;
@ -1137,9 +1119,6 @@ stripinput(c, tp)
struct mbuf *m;
int len;
int s;
#if NBPFILTER > 0
u_char chdr[CHDR_LEN];
#endif
tk_nin++;
sc = (struct strip_softc *)tp->t_sc;
@ -1215,72 +1194,14 @@ stripinput(c, tp)
/* less than min length packet - ignore */
goto newpack;
#if NBPFILTER > 0
if (sc->sc_if.if_bpf) {
/*
* Save the compressed header, so we
* can tack it on later. Note that we
* will end up copying garbage in some
* cases but this is okay. We remember
* where the buffer started so we can
* compute the new header length.
*/
bcopy(sc->sc_pktstart, chdr, CHDR_LEN);
}
#endif
if ((c = (*sc->sc_pktstart & 0xf0)) != (IPVERSION << 4)) {
if (c & 0x80)
c = TYPE_COMPRESSED_TCP;
else if (c == TYPE_UNCOMPRESSED_TCP)
*sc->sc_pktstart &= 0x4f; /* XXX */
/*
* We've got something that's not an IP packet.
* If compression is enabled, try to decompress it.
* Otherwise, if `auto-enable' compression is on and
* it's a reasonable packet, decompress it and then
* enable compression. Otherwise, drop it.
*/
if (sc->sc_if.if_flags & SC_COMPRESS) {
len = sl_uncompress_tcp(&sc->sc_pktstart, len,
(u_int)c, &sc->sc_comp);
if (len <= 0)
goto error;
} else if ((sc->sc_if.if_flags & SC_AUTOCOMP) &&
c == TYPE_UNCOMPRESSED_TCP && len >= 40) {
len = sl_uncompress_tcp(&sc->sc_pktstart, len,
(u_int)c, &sc->sc_comp);
if (len <= 0)
goto error;
sc->sc_if.if_flags |= SC_COMPRESS;
} else
goto error;
}
m = strip_btom(sc, len);
if (m == NULL)
goto error;
#if NBPFILTER > 0
if (sc->sc_if.if_bpf) {
/*
* Put the SLIP pseudo-"link header" in place.
* Note the space for it has already been
* allocated in strip_btom().
*/
u_char *hp = mtod(m, u_char *);
hp[SLX_DIR] = SLIPDIR_IN;
memcpy(&hp[SLX_CHDR], chdr, CHDR_LEN);
}
#endif
IF_ENQUEUE(&sc->sc_inq, m);
s = splimp();
schednetisr(NETISR_STRIP);
splx(s);
goto newpack;
error:
@ -1296,7 +1217,11 @@ stripintr(void)
{
struct strip_softc *sc;
struct mbuf *m;
int i, s;
int i, s, len;
u_char *pktstart, c;
#if NBPFILTER > 0
u_char chdr[CHDR_LEN];
#endif
for (i = 0; i < NSTRIP; i++) {
sc = &strip_softc[i];
@ -1306,16 +1231,103 @@ stripintr(void)
splx(s);
if (m == NULL)
break;
pktstart = mtod(m, u_char *);
len = m->m_pkthdr.len;
#if NBPFILTER > 0
if (sc->sc_if.if_bpf) {
/*
* Save the compressed header, so we
* can tack it on later. Note that we
* will end up copying garbage in come
* cases but this is okay. We remember
* where the buffer started so we can
* compute the new header length.
*/
memcpy(chdr, pktstart, CHDR_LEN);
}
#endif /* NBPFILTER > 0 */
if ((c = (*pktstart & 0xf0)) != (IPVERSION << 4)) {
if (c & 0x80)
c = TYPE_COMPRESSED_TCP;
else if (c == TYPE_UNCOMPRESSED_TCP)
*pktstart &= 0x4f; /* XXX */
/*
* We've got something that's not an IP
* packet. If compression is enabled,
* try to decompress it. Otherwise, if
* `auto-enable' compression is on and
* it's a reasonable packet, decompress
* it and then enable compression.
* Otherwise, drop it.
*/
if (sc->sc_if.if_flags & SC_COMPRESS) {
len = sl_uncompress_tcp(&pktstart, len,
(u_int)c, &sc->sc_comp);
if (len <= 0) {
m_freem(m);
continue;
}
} else if ((sc->sc_if.if_flags & SC_AUTOCOMP) &&
c == TYPE_UNCOMPRESSED_TCP && len >= 40) {
len = sl_uncompress_tcp(&pktstart, len,
(u_int)c, &sc->sc_comp);
if (len <= 0) {
m_freem(m);
continue;
}
sc->sc_if.if_flags |= SC_COMPRESS;
} else {
m_freem(m);
continue;
}
}
m->m_data = (caddr_t) pktstart;
m->m_pkthdr.len = m->m_len = len;
#if NPBFILTER > 0
if (sc->sc_if.if_bpf) {
/*
* Put the SLIP pseudo-"link header" in place.
* Note this M_PREPEND() should never fail,
* swince we know we always have enough space
* in the input buffer.
*/
u_char *hp;
M_PREPEND(m, SLIP_HDRLEN, M_DONTWAIT);
if (m == NULL)
continue;
hp = mtod(m, u_char *);
hp[SLX_DIR] = SLIPDIR_IN;
memcpy(&hp[SLX_CHDR], chdr, CHDR_LEN);
s = splnet();
bpf_mtap(sc->sc_if.if_bpf, m);
splx(s);
m_adj(m, SLIP_HDRLEN);
}
#endif
m_adj(m, SLIP_HDRLEN);
/*
* If the packet will fit into a single
* header mbuf, copy it into one, to save
* memory.
*/
if (m->m_pkthdr.len < MHLEN) {
struct mbuf *n;
MGETHDR(n, M_DONTWAIT, MT_DATA);
M_COPY_PKTHDR(n, m);
memcpy(mtod(n, caddr_t), mtod(m, caddr_t),
m->m_pkthdr.len);
n->m_len = m->m_len;
m_freem(m);
m = n;
}
sc->sc_if.if_ipackets++;
sc->sc_if.if_lastchange = time;
s = splimp();
if (IF_QFULL(&ipintrq)) {
IF_DROP(&ipintrq);