if (ni == ic->ic_bss) ieee80211_unref_node(&ni); else ieee80211_free_node(ic, ni);
ieee80211_release_node(ic, ni);
atu_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status){	struct atu_chain	*c = (struct atu_chain *)priv;	struct atu_softc	*sc = c->atu_sc;	struct ieee80211com	*ic = &sc->sc_ic;	struct ifnet		*ifp = &ic->ic_if;	struct atu_rx_hdr	*h;	struct ieee80211_frame	*wh;	struct ieee80211_node	*ni;	struct mbuf		*m;	u_int32_t		len;	int			s;	DPRINTFN(25, ("%s: atu_rxeof\n", USBDEVNAME(sc->atu_dev)));	if (sc->sc_state != ATU_S_OK)		return;	if ((ifp->if_flags & (IFF_RUNNING|IFF_UP)) != (IFF_RUNNING|IFF_UP))		goto done;	if (status != USBD_NORMAL_COMPLETION) {		DPRINTF(("%s: status != USBD_NORMAL_COMPLETION\n",		    USBDEVNAME(sc->atu_dev)));		if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {			return;		}#if 0		if (status == USBD_IOERROR) {			DPRINTF(("%s: rx: EEK! lost device?\n",			    USBDEVNAME(sc->atu_dev)));			/*			 * My experience with USBD_IOERROR is that trying to			 * restart the transfer will always fail and we'll			 * keep on looping restarting transfers untill someone			 * pulls the plug of the device.			 * So we don't restart the transfer, but just let it			 * die... If someone knows of a situation where we can			 * recover from USBD_IOERROR, let me know.			 */			splx(s);			return;		}#endif /* 0 */		if (usbd_ratecheck(&sc->atu_rx_notice)) {			DPRINTF(("%s: usb error on rx: %s\n",			    USBDEVNAME(sc->atu_dev), usbd_errstr(status)));		}		if (status == USBD_STALLED)			usbd_clear_endpoint_stall(			    sc->atu_ep[ATU_ENDPT_RX]);		goto done;	}	usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL);	if (len <= 1) {		DPRINTF(("%s: atu_rxeof: too short\n",		    USBDEVNAME(sc->atu_dev)));		goto done;	}	h = (struct atu_rx_hdr *)c->atu_buf;	len = UGETW(h->length) - 4; /* XXX magic number */	m = c->atu_mbuf;	memcpy(mtod(m, char *), c->atu_buf + ATU_RX_HDRLEN, len);	m->m_pkthdr.rcvif = ifp;	m->m_pkthdr.len = m->m_len = len;	wh = mtod(m, struct ieee80211_frame *);	ni = ieee80211_find_rxnode(ic, wh);	ifp->if_ipackets++;	s = splnet();	if (atu_newbuf(sc, c, NULL) == ENOBUFS) {		ifp->if_ierrors++;		goto done1; /* XXX if we can't allocate, why restart it? */	}#if NBPFILTER > 0	if (ifp->if_bpf)		bpf_mtap(ifp->if_bpf, m);#endif	ieee80211_input(ifp, m, ni, h->rssi, UGETDW(h->rx_time));	if (ni == ic->ic_bss)		ieee80211_unref_node(&ni);	else		ieee80211_free_node(ic, ni);done1:	splx(s);done:	/* Setup new transfer. */	usbd_setup_xfer(c->atu_xfer, sc->atu_ep[ATU_ENDPT_RX], c, c->atu_buf,	    ATU_RX_BUFSZ, USBD_SHORT_XFER_OK | USBD_NO_COPY, USBD_NO_TIMEOUT,		atu_rxeof);	usbd_transfer(c->atu_xfer);}