epget(sc, totlen)
epget(sc, eh, totlen)
epget(sc, totlen)	struct ep_softc *sc;	int totlen;{	bus_chipset_tag_t bc = sc->sc_bc;	bus_io_handle_t ioh = sc->sc_ioh;	struct ifnet *ifp = &sc->sc_arpcom.ac_if;	struct mbuf *top, **mp, *m;	int len;	int sh;	m = sc->mb[sc->next_mb];	sc->mb[sc->next_mb] = 0;	if (m == 0) {		MGETHDR(m, M_DONTWAIT, MT_DATA);		if (m == 0)			return 0;	} else {		/* If the queue is no longer full, refill. */		if (sc->last_mb == sc->next_mb)			timeout(epmbuffill, sc, 1);		/* Convert one of our saved mbuf's. */		sc->next_mb = (sc->next_mb + 1) % MAX_MBS;		m->m_data = m->m_pktdat;		m->m_flags = M_PKTHDR;	}	m->m_pkthdr.rcvif = ifp;	m->m_pkthdr.len = totlen;	len = MHLEN;	top = 0;	mp = &top;	/*	 * We read the packet at splhigh() so that an interrupt from another	 * device doesn't cause the card's buffer to overflow while we're	 * reading it.  We may still lose packets at other times.	 */	sh = splhigh();	while (totlen > 0) {		if (top) {			m = sc->mb[sc->next_mb];			sc->mb[sc->next_mb] = 0;			if (m == 0) {				MGET(m, M_DONTWAIT, MT_DATA);				if (m == 0) {					splx(sh);					m_freem(top);					return 0;				}			} else {				sc->next_mb = (sc->next_mb + 1) % MAX_MBS;			}			len = MLEN;		}		if (totlen >= MINCLSIZE) {			MCLGET(m, M_DONTWAIT);			if (m->m_flags & M_EXT)				len = MCLBYTES;		}		len = min(totlen, len);		if (EP_IS_BUS_32(sc->bustype)) {			if (len > 3) {				len &= ~3;				bus_io_read_multi_4(bc, ioh,				    EP_W1_RX_PIO_RD_1, mtod(m, u_int32_t *),				    len / 4);			} else				bus_io_read_multi_1(bc, ioh,				    EP_W1_RX_PIO_RD_1, mtod(m, u_int8_t *),				    len);		} else {			if (len > 1) {				len &= ~1;				bus_io_read_multi_2(bc, ioh,				    EP_W1_RX_PIO_RD_1, mtod(m, u_int16_t *),				    len / 2);			} else				*(mtod(m, u_int8_t *)) =				    bus_io_read_1(bc, ioh, EP_W1_RX_PIO_RD_1);		}		m->m_len = len;		totlen -= len;		*mp = m;		mp = &m->m_next;	}	bus_io_write_2(bc, ioh, EP_COMMAND, RX_DISCARD_TOP_PACK);	while (bus_io_read_2(bc, ioh, EP_STATUS) & S_COMMAND_IN_PROGRESS)		;	splx(sh);	return top;}