-/* $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
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);
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 */
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);
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;
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)
{