From owner-p4-projects@FreeBSD.ORG Wed Feb 4 11:26:11 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4779E1065673; Wed, 4 Feb 2009 11:26:11 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 046CD1065670 for ; Wed, 4 Feb 2009 11:26:11 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id E43C98FC0C for ; Wed, 4 Feb 2009 11:26:10 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n14BQAqE006432 for ; Wed, 4 Feb 2009 11:26:10 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n14BQAOI006430 for perforce@freebsd.org; Wed, 4 Feb 2009 11:26:10 GMT (envelope-from hselasky@FreeBSD.org) Date: Wed, 4 Feb 2009 11:26:10 GMT Message-Id: <200902041126.n14BQAOI006430@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 157131 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Feb 2009 11:26:12 -0000 http://perforce.freebsd.org/chv.cgi?CH=157131 Change 157131 by hselasky@hselasky_laptop001 on 2009/02/04 11:26:09 USB Ethernet cleanup patches by me: - use factored out clear stall code instead of having per-driver clear stall transfers. Remove unused clear stall flags. - only clear stall data write transfers at startup. - fix one or two comments - add new global function to USB core: usb2_get_mode() which returns the current USB device mode. - some minor nits Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_core.h#34 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.c#51 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_aue2.c#21 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_auereg.h#4 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_axe2.c#21 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_axereg.h#4 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_cdce2.c#19 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_cdcereg.h#4 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_cue2.c#20 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_cuereg.h#4 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_kue2.c#20 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_kuereg.h#4 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_rue2.c#20 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_ruereg.h#4 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_udav2.c#20 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_udavreg.h#4 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_core.h#34 (text+ko) ==== @@ -434,6 +434,7 @@ uint8_t usb2_get_interface_altindex(struct usb2_interface *iface); usb2_error_t usb2_set_alt_interface_index(struct usb2_device *udev, uint8_t iface_index, uint8_t alt_index); +uint8_t usb2_get_mode(struct usb2_device *udev); uint8_t usb2_get_speed(struct usb2_device *udev); uint32_t usb2_get_isoc_fps(struct usb2_device *udev); usb2_error_t usb2_transfer_setup(struct usb2_device *udev, ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_device.c#51 (text+ko) ==== @@ -1952,6 +1952,20 @@ } } +/* + * Returns: + * See: USB_MODE_XXX + */ +uint8_t +usb2_get_mode(struct usb2_device *udev) +{ + return (udev->flags.usb2_mode); +} + +/* + * Returns: + * See: USB_SPEED_XXX + */ uint8_t usb2_get_speed(struct usb2_device *udev) { ==== //depot/projects/usb/src/sys/dev/usb2/ethernet/if_aue2.c#21 (text+ko) ==== @@ -178,11 +178,8 @@ static miibus_writereg_t aue_miibus_writereg; static miibus_statchg_t aue_miibus_statchg; -static usb2_callback_t aue_intr_clear_stall_callback; static usb2_callback_t aue_intr_callback; -static usb2_callback_t aue_bulk_read_clear_stall_callback; static usb2_callback_t aue_bulk_read_callback; -static usb2_callback_t aue_bulk_write_clear_stall_callback; static usb2_callback_t aue_bulk_write_callback; static usb2_ether_fn_t aue_attach_post; @@ -227,28 +224,6 @@ .mh.callback = aue_bulk_read_callback, }, - [AUE_BULK_CS_WR] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.flags = {}, - .mh.callback = aue_bulk_write_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - .mh.interval = 50, /* 50ms */ - }, - - [AUE_BULK_CS_RD] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.flags = {}, - .mh.callback = aue_bulk_read_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - .mh.interval = 50, /* 50ms */ - }, - [AUE_INTR_DT_RD] = { .type = UE_INTERRUPT, .endpoint = UE_ADDR_ANY, @@ -257,17 +232,6 @@ .mh.bufsize = 0, /* use wMaxPacketSize */ .mh.callback = aue_intr_callback, }, - - [AUE_INTR_CS_RD] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.flags = {}, - .mh.callback = aue_intr_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - .mh.interval = 50, /* 50ms */ - }, }; static device_method_t aue_methods[] = { @@ -749,19 +713,6 @@ } static void -aue_intr_clear_stall_callback(struct usb2_xfer *xfer) -{ - struct aue_softc *sc = xfer->priv_sc; - struct usb2_xfer *xfer_other = sc->sc_xfer[AUE_INTR_DT_RD]; - - if (usb2_clear_stall_callback(xfer, xfer_other)) { - DPRINTF("stall cleared\n"); - sc->sc_flags &= ~AUE_FLAG_INTR_STALL; - usb2_transfer_start(xfer_other); - } -} - -static void aue_intr_callback(struct usb2_xfer *xfer) { struct aue_softc *sc = xfer->priv_sc; @@ -784,38 +735,22 @@ } /* FALLTHROUGH */ case USB_ST_SETUP: - if (sc->sc_flags & AUE_FLAG_INTR_STALL) { - usb2_transfer_start(sc->sc_xfer[AUE_INTR_CS_RD]); - } else { - xfer->frlengths[0] = xfer->max_data_length; - usb2_start_hardware(xfer); - } +tr_setup: + xfer->frlengths[0] = xfer->max_data_length; + usb2_start_hardware(xfer); return; default: /* Error */ if (xfer->error != USB_ERR_CANCELLED) { - /* start clear stall */ - sc->sc_flags |= AUE_FLAG_INTR_STALL; - usb2_transfer_start(sc->sc_xfer[AUE_INTR_CS_RD]); + /* try to clear stall first */ + xfer->flags.stall_pipe = 1; + goto tr_setup; } return; } } static void -aue_bulk_read_clear_stall_callback(struct usb2_xfer *xfer) -{ - struct aue_softc *sc = xfer->priv_sc; - struct usb2_xfer *xfer_other = sc->sc_xfer[AUE_BULK_DT_RD]; - - if (usb2_clear_stall_callback(xfer, xfer_other)) { - DPRINTF("stall cleared\n"); - sc->sc_flags &= ~AUE_FLAG_READ_STALL; - usb2_transfer_start(xfer_other); - } -} - -static void aue_bulk_read_callback(struct usb2_xfer *xfer) { struct aue_softc *sc = xfer->priv_sc; @@ -859,43 +794,25 @@ /* FALLTHROUGH */ case USB_ST_SETUP: tr_setup: - - if (sc->sc_flags & AUE_FLAG_READ_STALL) { - usb2_transfer_start(sc->sc_xfer[AUE_BULK_CS_RD]); - } else { - xfer->frlengths[0] = xfer->max_data_length; - usb2_start_hardware(xfer); - } + xfer->frlengths[0] = xfer->max_data_length; + usb2_start_hardware(xfer); usb2_ether_rxflush(ue); return; default: /* Error */ + DPRINTF("bulk read error, %s\n", + usb2_errstr(xfer->error)); + if (xfer->error != USB_ERR_CANCELLED) { /* try to clear stall first */ - sc->sc_flags |= AUE_FLAG_READ_STALL; - usb2_transfer_start(sc->sc_xfer[AUE_BULK_CS_RD]); + xfer->flags.stall_pipe = 1; + goto tr_setup; } - DPRINTF("bulk read error, %s\n", - usb2_errstr(xfer->error)); return; - } } static void -aue_bulk_write_clear_stall_callback(struct usb2_xfer *xfer) -{ - struct aue_softc *sc = xfer->priv_sc; - struct usb2_xfer *xfer_other = sc->sc_xfer[AUE_BULK_DT_WR]; - - if (usb2_clear_stall_callback(xfer, xfer_other)) { - DPRINTF("stall cleared\n"); - sc->sc_flags &= ~AUE_FLAG_WRITE_STALL; - usb2_transfer_start(xfer_other); - } -} - -static void aue_bulk_write_callback(struct usb2_xfer *xfer) { struct aue_softc *sc = xfer->priv_sc; @@ -910,25 +827,19 @@ /* FALLTHROUGH */ case USB_ST_SETUP: - - if (sc->sc_flags & AUE_FLAG_WRITE_STALL) { - usb2_transfer_start(sc->sc_xfer[AUE_BULK_CS_WR]); - goto done; - } +tr_setup: if ((sc->sc_flags & AUE_FLAG_LINK) == 0) { /* * don't send anything if there is no link ! */ - goto done; + return; } IFQ_DRV_DEQUEUE(&ifp->if_snd, m); - if (m == NULL) { - goto done; - } - if (m->m_pkthdr.len > MCLBYTES) { + if (m == NULL) + return; + if (m->m_pkthdr.len > MCLBYTES) m->m_pkthdr.len = MCLBYTES; - } if (sc->sc_flags & AUE_FLAG_VER_2) { xfer->frlengths[0] = m->m_pkthdr.len; @@ -941,10 +852,12 @@ xfer->frlengths[0] = (m->m_pkthdr.len + 2); /* - * The ADMtek documentation says that the packet length is - * supposed to be specified in the first two bytes of the - * transfer, however it actually seems to ignore this info - * and base the frame size on the bulk transfer length. + * The ADMtek documentation says that the + * packet length is supposed to be specified + * in the first two bytes of the transfer, + * however it actually seems to ignore this + * info and base the frame size on the bulk + * transfer length. */ buf[0] = (uint8_t)(m->m_pkthdr.len); buf[1] = (uint8_t)(m->m_pkthdr.len >> 8); @@ -964,22 +877,20 @@ m_freem(m); usb2_start_hardware(xfer); - -done: return; default: /* Error */ DPRINTFN(11, "transfer error, %s\n", usb2_errstr(xfer->error)); + ifp->if_oerrors++; + if (xfer->error != USB_ERR_CANCELLED) { /* try to clear stall first */ - sc->sc_flags |= AUE_FLAG_WRITE_STALL; - usb2_transfer_start(sc->sc_xfer[AUE_BULK_CS_WR]); + xfer->flags.stall_pipe = 1; + goto tr_setup; } - ifp->if_oerrors++; return; - } } @@ -1042,7 +953,7 @@ AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_TX_ENB); AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_EP3_CLR); - sc->sc_flags |= AUE_FLAG_READ_STALL | AUE_FLAG_WRITE_STALL; + usb2_transfer_set_stall(sc->sc_xfer[AUE_BULK_DT_WR]); ifp->if_drv_flags |= IFF_DRV_RUNNING; aue_start(ue); @@ -1121,10 +1032,7 @@ */ usb2_transfer_stop(sc->sc_xfer[AUE_BULK_DT_WR]); usb2_transfer_stop(sc->sc_xfer[AUE_BULK_DT_RD]); - usb2_transfer_stop(sc->sc_xfer[AUE_BULK_CS_WR]); - usb2_transfer_stop(sc->sc_xfer[AUE_BULK_CS_RD]); usb2_transfer_stop(sc->sc_xfer[AUE_INTR_DT_RD]); - usb2_transfer_stop(sc->sc_xfer[AUE_INTR_CS_RD]); aue_csr_write_1(sc, AUE_CTL0, 0); aue_csr_write_1(sc, AUE_CTL1, 0); ==== //depot/projects/usb/src/sys/dev/usb2/ethernet/if_auereg.h#4 (text+ko) ==== @@ -63,11 +63,8 @@ enum { AUE_BULK_DT_WR, AUE_BULK_DT_RD, - AUE_BULK_CS_WR, - AUE_BULK_CS_RD, AUE_INTR_DT_RD, - AUE_INTR_CS_RD, - AUE_N_TRANSFER = 6, + AUE_N_TRANSFER, }; #define AUE_INTR_PKTLEN 0x8 @@ -214,9 +211,6 @@ #define AUE_FLAG_PNA 0x0002 /* has Home PNA */ #define AUE_FLAG_PII 0x0004 /* Pegasus II chip */ #define AUE_FLAG_LINK 0x0008 /* wait for link to come up */ -#define AUE_FLAG_READ_STALL 0x0010 /* wait for clearing of stall */ -#define AUE_FLAG_WRITE_STALL 0x0020 /* wait for clearing of stall */ -#define AUE_FLAG_INTR_STALL 0x0040 /* wait for clearing of stall */ #define AUE_FLAG_VER_2 0x0200 /* chip is version 2 */ #define AUE_FLAG_DUAL_PHY 0x0400 /* chip has two transcivers */ }; ==== //depot/projects/usb/src/sys/dev/usb2/ethernet/if_axe2.c#21 (text+ko) ==== @@ -101,7 +101,7 @@ * 1 4096 bytes * 2 8192 bytes * 3 16384 bytes - * use the largest your system can handle without usb stalling. + * use the largest your system can handle without USB stalling. * * NB: 88772 parts appear to generate lots of input errors with * a 2K rx buffer and 8K is only slightly faster than 4K on an @@ -153,11 +153,8 @@ static device_detach_t axe_detach; static device_shutdown_t axe_shutdown; -static usb2_callback_t axe_intr_clear_stall_callback; static usb2_callback_t axe_intr_callback; -static usb2_callback_t axe_bulk_read_clear_stall_callback; static usb2_callback_t axe_bulk_read_callback; -static usb2_callback_t axe_bulk_write_clear_stall_callback; static usb2_callback_t axe_bulk_write_callback; static miibus_readreg_t axe_miibus_readreg; @@ -204,28 +201,6 @@ .mh.timeout = 0, /* no timeout */ }, - [AXE_BULK_CS_WR] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.flags = {}, - .mh.callback = axe_bulk_write_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - .mh.interval = 50, /* 50ms */ - }, - - [AXE_BULK_CS_RD] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.flags = {}, - .mh.callback = axe_bulk_read_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - .mh.interval = 50, /* 50ms */ - }, - [AXE_INTR_DT_RD] = { .type = UE_INTERRUPT, .endpoint = UE_ADDR_ANY, @@ -234,17 +209,6 @@ .mh.bufsize = 0, /* use wMaxPacketSize */ .mh.callback = axe_intr_callback, }, - - [AXE_INTR_CS_RD] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.flags = {}, - .mh.callback = axe_intr_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - .mh.interval = 50, /* 50ms */ - }, }; static device_method_t axe_methods[] = { @@ -739,57 +703,26 @@ } static void -axe_intr_clear_stall_callback(struct usb2_xfer *xfer) -{ - struct axe_softc *sc = xfer->priv_sc; - struct usb2_xfer *xfer_other = sc->sc_xfer[AXE_INTR_DT_RD]; - - if (usb2_clear_stall_callback(xfer, xfer_other)) { - DPRINTF("stall cleared\n"); - sc->sc_flags &= ~AXE_FLAG_INTR_STALL; - usb2_transfer_start(xfer_other); - } -} - -static void axe_intr_callback(struct usb2_xfer *xfer) { - struct axe_softc *sc = xfer->priv_sc; - switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: case USB_ST_SETUP: - if (sc->sc_flags & AXE_FLAG_INTR_STALL) { - usb2_transfer_start(sc->sc_xfer[AXE_INTR_CS_RD]); - } else { - xfer->frlengths[0] = xfer->max_data_length; - usb2_start_hardware(xfer); - } +tr_setup: + xfer->frlengths[0] = xfer->max_data_length; + usb2_start_hardware(xfer); return; default: /* Error */ if (xfer->error != USB_ERR_CANCELLED) { - /* start clear stall */ - sc->sc_flags |= AXE_FLAG_INTR_STALL; - usb2_transfer_start(sc->sc_xfer[AXE_INTR_CS_RD]); + /* try to clear stall first */ + xfer->flags.stall_pipe = 1; + goto tr_setup; } return; } } -static void -axe_bulk_read_clear_stall_callback(struct usb2_xfer *xfer) -{ - struct axe_softc *sc = xfer->priv_sc; - struct usb2_xfer *xfer_other = sc->sc_xfer[AXE_BULK_DT_RD]; - - if (usb2_clear_stall_callback(xfer, xfer_other)) { - DPRINTF("stall cleared\n"); - sc->sc_flags &= ~AXE_FLAG_READ_STALL; - usb2_transfer_start(xfer_other); - } -} - #if (AXE_BULK_BUF_SIZE >= 0x10000) #error "Please update axe_bulk_read_callback()!" #endif @@ -853,40 +786,25 @@ /* FALLTHROUGH */ case USB_ST_SETUP: tr_setup: - if (sc->sc_flags & AXE_FLAG_READ_STALL) { - usb2_transfer_start(sc->sc_xfer[AXE_BULK_CS_RD]); - } else { - xfer->frlengths[0] = xfer->max_data_length; - usb2_start_hardware(xfer); - } + xfer->frlengths[0] = xfer->max_data_length; + usb2_start_hardware(xfer); usb2_ether_rxflush(ue); return; default: /* Error */ + DPRINTF("bulk read error, %s\n", + usb2_errstr(xfer->error)); + if (xfer->error != USB_ERR_CANCELLED) { /* try to clear stall first */ - sc->sc_flags |= AXE_FLAG_READ_STALL; - usb2_transfer_start(sc->sc_xfer[AXE_BULK_CS_RD]); + xfer->flags.stall_pipe = 1; + goto tr_setup; } - DPRINTF("bulk read error, %s\n", usb2_errstr(xfer->error)); return; } } -static void -axe_bulk_write_clear_stall_callback(struct usb2_xfer *xfer) -{ - struct axe_softc *sc = xfer->priv_sc; - struct usb2_xfer *xfer_other = sc->sc_xfer[AXE_BULK_DT_WR]; - - if (usb2_clear_stall_callback(xfer, xfer_other)) { - DPRINTF("stall cleared\n"); - sc->sc_flags &= ~AXE_FLAG_WRITE_STALL; - usb2_transfer_start(xfer_other); - } -} - #if ((AXE_BULK_BUF_SIZE >= 0x10000) || (AXE_BULK_BUF_SIZE < (MCLBYTES+4))) #error "Please update axe_bulk_write_callback()!" #endif @@ -906,16 +824,12 @@ ifp->if_opackets++; /* FALLTHROUGH */ case USB_ST_SETUP: - - if (sc->sc_flags & AXE_FLAG_WRITE_STALL) { - usb2_transfer_start(sc->sc_xfer[AXE_BULK_CS_WR]); - goto done; - } +tr_setup: if ((sc->sc_flags & AXE_FLAG_LINK) == 0) { /* * don't send anything if there is no link ! */ - goto done; + return; } pos = 0; @@ -926,8 +840,7 @@ if (m == NULL) { if (pos > 0) break; /* send out data */ - else - goto done; + return; } if (m->m_pkthdr.len > MCLBYTES) { m->m_pkthdr.len = MCLBYTES; @@ -975,20 +888,19 @@ xfer->frlengths[0] = pos; usb2_start_hardware(xfer); - -done: return; default: /* Error */ DPRINTFN(11, "transfer error, %s\n", usb2_errstr(xfer->error)); + ifp->if_oerrors++; + if (xfer->error != USB_ERR_CANCELLED) { /* try to clear stall first */ - sc->sc_flags |= AXE_FLAG_WRITE_STALL; - usb2_transfer_start(sc->sc_xfer[AXE_BULK_CS_WR]); + xfer->flags.stall_pipe = 1; + goto tr_setup; } - ifp->if_oerrors++; return; } @@ -1071,7 +983,7 @@ /* Load the multicast filter. */ axe_setmulti(ue); - sc->sc_flags |= AXE_FLAG_READ_STALL | AXE_FLAG_WRITE_STALL; + usb2_transfer_set_stall(sc->sc_xfer[AXE_BULK_DT_WR]); ifp->if_drv_flags |= IFF_DRV_RUNNING; axe_start(ue); @@ -1115,10 +1027,7 @@ */ usb2_transfer_stop(sc->sc_xfer[AXE_BULK_DT_WR]); usb2_transfer_stop(sc->sc_xfer[AXE_BULK_DT_RD]); - usb2_transfer_stop(sc->sc_xfer[AXE_BULK_CS_WR]); - usb2_transfer_stop(sc->sc_xfer[AXE_BULK_CS_RD]); usb2_transfer_stop(sc->sc_xfer[AXE_INTR_DT_RD]); - usb2_transfer_stop(sc->sc_xfer[AXE_INTR_CS_RD]); axe_reset(sc); } ==== //depot/projects/usb/src/sys/dev/usb2/ethernet/if_axereg.h#4 (text+ko) ==== @@ -172,11 +172,8 @@ enum { AXE_BULK_DT_WR, AXE_BULK_DT_RD, - AXE_BULK_CS_WR, - AXE_BULK_CS_RD, AXE_INTR_DT_RD, - AXE_INTR_CS_RD, - AXE_N_TRANSFER = 6, + AXE_N_TRANSFER, }; struct axe_softc { @@ -187,9 +184,6 @@ int sc_flags; #define AXE_FLAG_LINK 0x0001 -#define AXE_FLAG_INTR_STALL 0x0002 -#define AXE_FLAG_READ_STALL 0x0004 -#define AXE_FLAG_WRITE_STALL 0x0008 #define AXE_FLAG_772 0x1000 /* AX88772 */ #define AXE_FLAG_178 0x2000 /* AX88178 */ ==== //depot/projects/usb/src/sys/dev/usb2/ethernet/if_cdce2.c#19 (text+ko) ==== @@ -557,11 +557,17 @@ ifp->if_drv_flags |= IFF_DRV_RUNNING; - /* - * start all the transfers - */ + /* start interrupt transfer */ + usb2_transfer_start(sc->sc_xfer[CDCE_INTR]); + + /* stall data write direction, which depends on USB mode */ + if (usb2_get_mode(sc->sc_ue.ue_udev) == USB_MODE_HOST) + usb2_transfer_set_stall(sc->sc_xfer[CDCE_BULK_A]); + else + usb2_transfer_set_stall(sc->sc_xfer[CDCE_BULK_B]); + + /* start data transfers */ cdce_start(ue); - usb2_transfer_start(sc->sc_xfer[CDCE_INTR]); } static void ==== //depot/projects/usb/src/sys/dev/usb2/ethernet/if_cdcereg.h#4 (text+ko) ==== @@ -42,7 +42,7 @@ CDCE_BULK_A, CDCE_BULK_B, CDCE_INTR, - CDCE_N_TRANSFER = 3, + CDCE_N_TRANSFER, }; struct cdce_softc { @@ -52,7 +52,7 @@ struct mbuf *sc_rx_buf[CDCE_FRAMES_MAX]; struct mbuf *sc_tx_buf[CDCE_FRAMES_MAX]; - uint16_t sc_flags; + int sc_flags; #define CDCE_FLAG_ZAURUS 0x0001 #define CDCE_FLAG_NO_UNION 0x0002 #define CDCE_FLAG_RX_DATA 0x0010 ==== //depot/projects/usb/src/sys/dev/usb2/ethernet/if_cue2.c#20 (text+ko) ==== @@ -88,9 +88,7 @@ static device_detach_t cue_detach; static device_shutdown_t cue_shutdown; -static usb2_callback_t cue_bulk_read_clear_stall_callback; static usb2_callback_t cue_bulk_read_callback; -static usb2_callback_t cue_bulk_write_clear_stall_callback; static usb2_callback_t cue_bulk_write_callback; static usb2_ether_fn_t cue_attach_post; @@ -137,28 +135,6 @@ .mh.flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, .mh.callback = cue_bulk_read_callback, }, - - [CUE_BULK_CS_WR] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.flags = {}, - .mh.callback = cue_bulk_write_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - .mh.interval = 50, /* 50ms */ - }, - - [CUE_BULK_CS_RD] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.flags = {}, - .mh.callback = cue_bulk_read_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - .mh.interval = 50, /* 50ms */ - }, }; static device_method_t cue_methods[] = { @@ -452,19 +428,6 @@ } static void -cue_bulk_read_clear_stall_callback(struct usb2_xfer *xfer) -{ - struct cue_softc *sc = xfer->priv_sc; - struct usb2_xfer *xfer_other = sc->sc_xfer[CUE_BULK_DT_RD]; - - if (usb2_clear_stall_callback(xfer, xfer_other)) { - DPRINTF("stall cleared\n"); - sc->sc_flags &= ~CUE_FLAG_READ_STALL; - usb2_transfer_start(xfer_other); - } -} - -static void cue_bulk_read_callback(struct usb2_xfer *xfer) { struct cue_softc *sc = xfer->priv_sc; @@ -489,43 +452,26 @@ /* FALLTHROUGH */ case USB_ST_SETUP: tr_setup: - - if (sc->sc_flags & CUE_FLAG_READ_STALL) { - usb2_transfer_start(sc->sc_xfer[CUE_BULK_CS_RD]); - } else { - xfer->frlengths[0] = xfer->max_data_length; - usb2_start_hardware(xfer); - } + xfer->frlengths[0] = xfer->max_data_length; + usb2_start_hardware(xfer); usb2_ether_rxflush(ue); return; default: /* Error */ + DPRINTF("bulk read error, %s\n", + usb2_errstr(xfer->error)); + if (xfer->error != USB_ERR_CANCELLED) { /* try to clear stall first */ - sc->sc_flags |= CUE_FLAG_READ_STALL; - usb2_transfer_start(sc->sc_xfer[CUE_BULK_CS_RD]); + xfer->flags.stall_pipe = 1; + goto tr_setup; } - DPRINTF("bulk read error, %s\n", - usb2_errstr(xfer->error)); return; } } static void -cue_bulk_write_clear_stall_callback(struct usb2_xfer *xfer) -{ - struct cue_softc *sc = xfer->priv_sc; - struct usb2_xfer *xfer_other = sc->sc_xfer[CUE_BULK_DT_WR]; - - if (usb2_clear_stall_callback(xfer, xfer_other)) { - DPRINTF("stall cleared\n"); - sc->sc_flags &= ~CUE_FLAG_WRITE_STALL; - usb2_transfer_start(xfer_other); - } -} - -static void cue_bulk_write_callback(struct usb2_xfer *xfer) { struct cue_softc *sc = xfer->priv_sc; @@ -540,19 +486,13 @@ /* FALLTHROUGH */ case USB_ST_SETUP: - - if (sc->sc_flags & CUE_FLAG_WRITE_STALL) { - usb2_transfer_start(sc->sc_xfer[CUE_BULK_CS_WR]); - goto done; - } +tr_setup: IFQ_DRV_DEQUEUE(&ifp->if_snd, m); - if (m == NULL) { - goto done; - } - if (m->m_pkthdr.len > MCLBYTES) { + if (m == NULL) + return; + if (m->m_pkthdr.len > MCLBYTES) m->m_pkthdr.len = MCLBYTES; - } xfer->frlengths[0] = (m->m_pkthdr.len + 2); /* the first two bytes are the frame length */ @@ -575,21 +515,20 @@ usb2_start_hardware(xfer); -done: return; default: /* Error */ DPRINTFN(11, "transfer error, %s\n", usb2_errstr(xfer->error)); + ifp->if_oerrors++; + if (xfer->error != USB_ERR_CANCELLED) { /* try to clear stall first */ - sc->sc_flags |= CUE_FLAG_WRITE_STALL; - usb2_transfer_start(sc->sc_xfer[CUE_BULK_CS_WR]); + xfer->flags.stall_pipe = 1; + goto tr_setup; } - ifp->if_oerrors++; return; - } } @@ -661,7 +600,7 @@ /* Program the LED operation. */ cue_csr_write_1(sc, CUE_LEDCTL, CUE_LEDCTL_FOLLOW_LINK); - sc->sc_flags |= CUE_FLAG_READ_STALL | CUE_FLAG_WRITE_STALL; + usb2_transfer_set_stall(sc->sc_xfer[CUE_BULK_DT_WR]); ifp->if_drv_flags |= IFF_DRV_RUNNING; cue_start(ue); @@ -686,8 +625,6 @@ */ usb2_transfer_stop(sc->sc_xfer[CUE_BULK_DT_WR]); usb2_transfer_stop(sc->sc_xfer[CUE_BULK_DT_RD]); - usb2_transfer_stop(sc->sc_xfer[CUE_BULK_CS_WR]); - usb2_transfer_stop(sc->sc_xfer[CUE_BULK_CS_RD]); cue_csr_write_1(sc, CUE_ETHCTL, 0); cue_reset(sc); ==== //depot/projects/usb/src/sys/dev/usb2/ethernet/if_cuereg.h#4 (text+ko) ==== @@ -115,9 +115,7 @@ enum { CUE_BULK_DT_WR, CUE_BULK_DT_RD, - CUE_BULK_CS_WR, - CUE_BULK_CS_RD, - CUE_N_TRANSFER = 4, + CUE_N_TRANSFER, }; struct cue_softc { @@ -126,11 +124,7 @@ struct usb2_xfer *sc_xfer[CUE_N_TRANSFER]; int sc_flags; -#define CUE_FLAG_READ_STALL 0x0010 /* wait for clearing of stall */ -#define CUE_FLAG_WRITE_STALL 0x0020 /* wait for clearing of stall */ -#define CUE_FLAG_LINK 0x0040 /* got a link */ -#define CUE_FLAG_DETACH 0x0080 /* card gone */ -#define CUE_FLAG_INTR_STALL 0x0100 /* wait for clearing of stall */ +#define CUE_FLAG_LINK 0x0001 /* got a link */ }; #define CUE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) ==== //depot/projects/usb/src/sys/dev/usb2/ethernet/if_kue2.c#20 (text+ko) ==== @@ -131,9 +131,7 @@ static device_detach_t kue_detach; static device_shutdown_t kue_shutdown; -static usb2_callback_t kue_bulk_read_clear_stall_callback; static usb2_callback_t kue_bulk_read_callback; -static usb2_callback_t kue_bulk_write_clear_stall_callback; static usb2_callback_t kue_bulk_write_callback; static usb2_ether_fn_t kue_attach_post; @@ -180,28 +178,6 @@ .mh.callback = kue_bulk_read_callback, .mh.timeout = 0, /* no timeout */ }, - - [KUE_BULK_CS_WR] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.flags = {}, - .mh.callback = kue_bulk_write_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - .mh.interval = 50, /* 50ms */ - }, - - [KUE_BULK_CS_RD] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.flags = {}, - .mh.callback = kue_bulk_read_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - .mh.interval = 50, /* 50ms */ - }, }; static device_method_t kue_methods[] = { @@ -540,19 +516,6 @@ * the higher level protocols. */ static void -kue_bulk_read_clear_stall_callback(struct usb2_xfer *xfer) -{ - struct kue_softc *sc = xfer->priv_sc; - struct usb2_xfer *xfer_other = sc->sc_xfer[KUE_BULK_DT_RD]; - - if (usb2_clear_stall_callback(xfer, xfer_other)) { - DPRINTF("stall cleared\n"); - sc->sc_flags &= ~KUE_FLAG_READ_STALL; - usb2_transfer_start(xfer_other); - } -} - -static void kue_bulk_read_callback(struct usb2_xfer *xfer) { struct kue_softc *sc = xfer->priv_sc; @@ -577,43 +540,26 @@ /* FALLTHROUGH */ case USB_ST_SETUP: tr_setup: - - if (sc->sc_flags & KUE_FLAG_READ_STALL) { - usb2_transfer_start(sc->sc_xfer[KUE_BULK_CS_RD]); - } else { - xfer->frlengths[0] = xfer->max_data_length; - usb2_start_hardware(xfer); - } + xfer->frlengths[0] = xfer->max_data_length; + usb2_start_hardware(xfer); usb2_ether_rxflush(ue); return; default: /* Error */ + DPRINTF("bulk read error, %s\n", + usb2_errstr(xfer->error)); + if (xfer->error != USB_ERR_CANCELLED) { /* try to clear stall first */ - sc->sc_flags |= KUE_FLAG_READ_STALL; - usb2_transfer_start(sc->sc_xfer[KUE_BULK_CS_RD]); + xfer->flags.stall_pipe = 1; + goto tr_setup; } - DPRINTF("bulk read error, %s\n", - usb2_errstr(xfer->error)); return; >>> TRUNCATED FOR MAIL (1000 lines) <<<