m->m_pkthdr.len = m->m_len = total_len;
static void mx_rxeof(sc)	struct mx_softc		*sc;{        struct ether_header	*eh;        struct mbuf		*m;        struct ifnet		*ifp;	struct mx_chain_onefrag	*cur_rx;	int			total_len = 0;	u_int32_t		rxstat;	ifp = &sc->arpcom.ac_if;	while(!((rxstat = sc->mx_cdata.mx_rx_head->mx_ptr->mx_status) &							MX_RXSTAT_OWN)) {		cur_rx = sc->mx_cdata.mx_rx_head;		sc->mx_cdata.mx_rx_head = cur_rx->mx_nextdesc;		/*		 * If an error occurs, update stats, clear the		 * status word and leave the mbuf cluster in place:		 * it should simply get re-used next time this descriptor	 	 * comes up in the ring.		 */		if (rxstat & MX_RXSTAT_RXERR) {			ifp->if_ierrors++;			if (rxstat & MX_RXSTAT_COLLSEEN)				ifp->if_collisions++;			cur_rx->mx_ptr->mx_status = MX_RXSTAT;			cur_rx->mx_ptr->mx_ctl =				MX_RXCTL_RLINK | (MCLBYTES - 1);			continue;		}		/* No errors; receive the packet. */			m = cur_rx->mx_mbuf;		total_len = MX_RXBYTES(cur_rx->mx_ptr->mx_status);		/*		 * XXX The Macronix chips includes the CRC with every		 * received frame, and there's no way to turn this		 * behavior off (at least, I can't find anything in	 	 * the manual that explains how to do it) so we have		 * to trim off the CRC manually.		 */		total_len -= ETHER_CRC_LEN;		/*		 * Try to conjure up a new mbuf cluster. If that		 * fails, it means we have an out of memory condition and		 * should leave the buffer in place and continue. This will		 * result in a lost packet, but there's little else we		 * can do in this situation.		 */		if (mx_newbuf(sc, cur_rx) == ENOBUFS) {			ifp->if_ierrors++;			cur_rx->mx_ptr->mx_status = MX_RXSTAT;			cur_rx->mx_ptr->mx_ctl =					MX_RXCTL_RLINK | (MCLBYTES - 1);			continue;		}		ifp->if_ipackets++;		eh = mtod(m, struct ether_header *);		m->m_pkthdr.rcvif = ifp;		m->m_pkthdr.len = m->m_len = total_len;#if NBPFILTER > 0		/*		 * Handle BPF listeners. Let the BPF user see the packet, but		 * don't pass it up to the ether_input() layer unless it's		 * a broadcast packet, multicast packet, matches our ethernet		 * address or the interface is in promiscuous mode.		 */		if (ifp->if_bpf)			bpf_mtap(ifp->if_bpf, m);#endif		/* Remove header from mbuf and pass it on. */		m_adj(m, sizeof(struct ether_header));		ether_input(ifp, eh, m);	}	return;}