From: kettenis Date: Fri, 5 Aug 2016 22:19:23 +0000 (+0000) Subject: Use m_devget(4). From Artturi Alm. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e1c7efcd7a96f7c55b2229aae1a8f869b45780b6;p=openbsd Use m_devget(4). From Artturi Alm. --- 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 * 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) {