diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-08-05 22:19:24 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-08-05 22:19:24 +0000 |
commit | f6b94fa40501a4f3c1e5b5752b97f2a5c6abc7fb (patch) | |
tree | cfdd7d6f18d3dc9192e451633e5c2004fd99a099 /sys | |
parent | e75ef0ca9bbce8b9866fb47c6e423bf320241fa6 (diff) |
Use m_devget(4). From Artturi Alm.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/armv7/sunxi/sxie.c | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/sys/arch/armv7/sunxi/sxie.c b/sys/arch/armv7/sunxi/sxie.c index cdcc2819633..9382d21d25c 100644 --- a/sys/arch/armv7/sunxi/sxie.c +++ b/sys/arch/armv7/sunxi/sxie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sxie.c,v 1.18 2016/08/05 19:00:25 kettenis Exp $ */ +/* $OpenBSD: sxie.c,v 1.19 2016/08/05 22:19:23 kettenis Exp $ */ /* * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> * Copyright (c) 2013 Artturi Alm @@ -179,7 +179,6 @@ void sxie_init(struct sxie_softc *); void sxie_stop(struct sxie_softc *); void sxie_reset(struct sxie_softc *); void sxie_iff(struct sxie_softc *, struct ifnet *); -struct mbuf * sxie_newbuf(void); int sxie_intr(void *); void sxie_recv(struct sxie_softc *); int sxie_miibus_readreg(struct device *, int, int); @@ -602,10 +601,6 @@ trynext: goto err_out; } - m = sxie_newbuf(); - if (m == NULL) - goto err_out; - reg = SXIREAD4(sc, SXIE_RXIO); pktstat = (uint16_t)reg >> 16; pktlen = (int16_t)reg; /* length of useful data */ @@ -617,10 +612,6 @@ trynext: if (pktlen > SXIE_MAX_PKT_SIZE) pktlen = SXIE_MAX_PKT_SIZE; /* XXX is truncating ok? */ - m->m_pkthdr.len = m->m_len = pktlen; - /* XXX m->m_pkthdr.csum_flags ? */ - m_adj(m, ETHER_ALIGN); - /* read the actual packet from fifo XXX through 'align buffer'.. */ if (pktlen & 3) rlen = SXIE_ROUNDUP(pktlen, 4); @@ -628,7 +619,12 @@ trynext: rlen = pktlen; bus_space_read_multi_4(sc->sc_iot, sc->sc_ioh, SXIE_RXIO, (uint32_t *)&rxbuf[0], rlen >> 2); - memcpy(mtod(m, char *), (char *)&rxbuf[0], pktlen); + + m = m_devget(&rxbuf[0], pktlen, ETHER_ALIGN); + if (m == NULL) { + ifp->if_ierrors++; + goto err_out; + } ml_enqueue(&ml, m); goto trynext; @@ -680,24 +676,6 @@ sxie_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) return error; } -struct mbuf * -sxie_newbuf(void) -{ - struct mbuf *m; - - MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == NULL) - return (NULL); - - MCLGET(m, M_DONTWAIT); - if (!(m->m_flags & M_EXT)) { - m_freem(m); - return (NULL); - } - - return (m); -} - void sxie_iff(struct sxie_softc *sc, struct ifnet *ifp) { |