diff options
Diffstat (limited to 'sys/dev/usb/net/if_udav.c')
-rw-r--r-- | sys/dev/usb/net/if_udav.c | 97 |
1 files changed, 57 insertions, 40 deletions
diff --git a/sys/dev/usb/net/if_udav.c b/sys/dev/usb/net/if_udav.c index be9af1521e3b..926b0a3e60ea 100644 --- a/sys/dev/usb/net/if_udav.c +++ b/sys/dev/usb/net/if_udav.c @@ -46,20 +46,34 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include "usbdevs.h" +#include <sys/stdint.h> +#include <sys/stddef.h> +#include <sys/param.h> +#include <sys/queue.h> +#include <sys/types.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/bus.h> +#include <sys/linker_set.h> +#include <sys/module.h> +#include <sys/lock.h> +#include <sys/mutex.h> +#include <sys/condvar.h> +#include <sys/sysctl.h> +#include <sys/sx.h> +#include <sys/unistd.h> +#include <sys/callout.h> +#include <sys/malloc.h> +#include <sys/priv.h> + #include <dev/usb/usb.h> -#include <dev/usb/usb_mfunc.h> -#include <dev/usb/usb_error.h> +#include <dev/usb/usbdi.h> +#include <dev/usb/usbdi_util.h> +#include "usbdevs.h" #define USB_DEBUG_VAR udav_debug - -#include <dev/usb/usb_core.h> -#include <dev/usb/usb_lookup.h> -#include <dev/usb/usb_process.h> #include <dev/usb/usb_debug.h> -#include <dev/usb/usb_request.h> -#include <dev/usb/usb_busdma.h> -#include <dev/usb/usb_util.h> +#include <dev/usb/usb_process.h> #include <dev/usb/net/usb_ethernet.h> #include <dev/usb/net/if_udavreg.h> @@ -420,7 +434,7 @@ udav_init(struct usb_ether *ue) UDAV_SETBIT(sc, UDAV_GPCR, UDAV_GPCR_GEP_CNTL0); UDAV_CLRBIT(sc, UDAV_GPR, UDAV_GPR_GEPIO0); - usbd_transfer_set_stall(sc->sc_xfer[UDAV_BULK_DT_WR]); + usbd_xfer_set_stall(sc->sc_xfer[UDAV_BULK_DT_WR]); ifp->if_drv_flags |= IFF_DRV_RUNNING; udav_start(ue); @@ -531,10 +545,11 @@ udav_start(struct usb_ether *ue) } static void -udav_bulk_write_callback(struct usb_xfer *xfer) +udav_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) { - struct udav_softc *sc = xfer->priv_sc; + struct udav_softc *sc = usbd_xfer_softc(xfer); struct ifnet *ifp = uether_getifp(&sc->sc_ue); + struct usb_page_cache *pc; struct mbuf *m; int extra_len; int temp_len; @@ -577,15 +592,12 @@ tr_setup: temp_len += 2; - usbd_copy_in(xfer->frbuffers, 0, buf, 2); - - usbd_m_copy_in(xfer->frbuffers, 2, - m, 0, m->m_pkthdr.len); + pc = usbd_xfer_get_frame(xfer, 0); + usbd_copy_in(pc, 0, buf, 2); + usbd_m_copy_in(pc, 2, m, 0, m->m_pkthdr.len); - if (extra_len) { - usbd_frame_zero(xfer->frbuffers, temp_len - extra_len, - extra_len); - } + if (extra_len) + usbd_frame_zero(pc, temp_len - extra_len, extra_len); /* * if there's a BPF listener, bounce a copy * of this frame to him: @@ -594,19 +606,19 @@ tr_setup: m_freem(m); - xfer->frlengths[0] = temp_len; + usbd_xfer_set_frame_len(xfer, 0, temp_len); usbd_transfer_submit(xfer); return; default: /* Error */ DPRINTFN(11, "transfer error, %s\n", - usbd_errstr(xfer->error)); + usbd_errstr(error)); ifp->if_oerrors++; - if (xfer->error != USB_ERR_CANCELLED) { + if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ - xfer->flags.stall_pipe = 1; + usbd_xfer_set_stall(xfer); goto tr_setup; } return; @@ -614,24 +626,29 @@ tr_setup: } static void -udav_bulk_read_callback(struct usb_xfer *xfer) +udav_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error) { - struct udav_softc *sc = xfer->priv_sc; + struct udav_softc *sc = usbd_xfer_softc(xfer); struct usb_ether *ue = &sc->sc_ue; struct ifnet *ifp = uether_getifp(ue); + struct usb_page_cache *pc; struct udav_rxpkt stat; int len; + int actlen; + + usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: - if (xfer->actlen < sizeof(stat) + ETHER_CRC_LEN) { + if (actlen < sizeof(stat) + ETHER_CRC_LEN) { ifp->if_ierrors++; goto tr_setup; } - usbd_copy_out(xfer->frbuffers, 0, &stat, sizeof(stat)); - xfer->actlen -= sizeof(stat); - len = min(xfer->actlen, le16toh(stat.pktlen)); + pc = usbd_xfer_get_frame(xfer, 0); + usbd_copy_out(pc, 0, &stat, sizeof(stat)); + actlen -= sizeof(stat); + len = min(actlen, le16toh(stat.pktlen)); len -= ETHER_CRC_LEN; if (stat.rxstat & UDAV_RSR_LCS) { @@ -642,22 +659,22 @@ udav_bulk_read_callback(struct usb_xfer *xfer) ifp->if_ierrors++; goto tr_setup; } - uether_rxbuf(ue, xfer->frbuffers, sizeof(stat), len); + uether_rxbuf(ue, pc, sizeof(stat), len); /* FALLTHROUGH */ case USB_ST_SETUP: tr_setup: - xfer->frlengths[0] = xfer->max_data_length; + usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer)); usbd_transfer_submit(xfer); uether_rxflush(ue); return; default: /* Error */ DPRINTF("bulk read error, %s\n", - usbd_errstr(xfer->error)); + usbd_errstr(error)); - if (xfer->error != USB_ERR_CANCELLED) { + if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ - xfer->flags.stall_pipe = 1; + usbd_xfer_set_stall(xfer); goto tr_setup; } return; @@ -665,20 +682,20 @@ tr_setup: } static void -udav_intr_callback(struct usb_xfer *xfer) +udav_intr_callback(struct usb_xfer *xfer, usb_error_t error) { switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: case USB_ST_SETUP: tr_setup: - xfer->frlengths[0] = xfer->max_data_length; + usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer)); usbd_transfer_submit(xfer); return; default: /* Error */ - if (xfer->error != USB_ERR_CANCELLED) { + if (error != USB_ERR_CANCELLED) { /* try to clear stall first */ - xfer->flags.stall_pipe = 1; + usbd_xfer_set_stall(xfer); goto tr_setup; } return; |