From owner-p4-projects@FreeBSD.ORG Tue Sep 2 20:04:51 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4133D1065675; Tue, 2 Sep 2008 20:04:51 +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 043DB1065670 for ; Tue, 2 Sep 2008 20:04:51 +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 E5E418FC19 for ; Tue, 2 Sep 2008 20:04:50 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m82K4oe3034099 for ; Tue, 2 Sep 2008 20:04:50 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m82K4oDI034097 for perforce@freebsd.org; Tue, 2 Sep 2008 20:04:50 GMT (envelope-from hselasky@FreeBSD.org) Date: Tue, 2 Sep 2008 20:04:50 GMT Message-Id: <200809022004.m82K4oDI034097@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 149077 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: Tue, 02 Sep 2008 20:04:51 -0000 http://perforce.freebsd.org/chv.cgi?CH=149077 Change 149077 by hselasky@hselasky_laptop001 on 2008/09/02 20:04:07 Fix some clear stall bugs in "if_cdce" and add support for the Mobile Direct Line Model, which means USB ethernet for cellphones. Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_cdce2.c#7 edit .. //depot/projects/usb/src/sys/dev/usb2/ethernet/if_cdce2_reg.h#4 edit .. //depot/projects/usb/src/sys/dev/usb2/include/usb2_standard.h#6 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/ethernet/if_cdce2.c#7 (text+ko) ==== @@ -76,11 +76,8 @@ static device_resume_t cdce_resume; static usb2_handle_request_t cdce_handle_request; -static usb2_callback_t cdce_bulk_write_clear_stall_callback; static usb2_callback_t cdce_bulk_write_callback; -static usb2_callback_t cdce_bulk_read_clear_stall_callback; static usb2_callback_t cdce_bulk_read_callback; -static usb2_callback_t cdce_intr_read_clear_stall_callback; static usb2_callback_t cdce_intr_read_callback; static usb2_callback_t cdce_intr_write_callback; @@ -145,32 +142,6 @@ }, [2] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .if_index = 0, - /* Host Mode Only */ - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.interval = 50, /* 50ms */ - .mh.flags = {}, - .mh.callback = &cdce_bulk_write_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - }, - - [3] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .if_index = 0, - /* Host Mode Only */ - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.interval = 50, /* 50ms */ - .mh.flags = {}, - .mh.callback = &cdce_bulk_read_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - }, - - [4] = { .type = UE_INTERRUPT, .endpoint = UE_ADDR_ANY, .direction = UE_DIR_IN, @@ -186,19 +157,6 @@ .md.callback = &cdce_intr_write_callback, .md.timeout = 10000, /* 10 seconds */ }, - - [5] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .if_index = 1, - /* Host Mode Only */ - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.interval = 50, /* 50ms */ - .mh.flags = {}, - .mh.callback = &cdce_intr_read_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - }, }; static device_method_t cdce_methods[] = { @@ -225,12 +183,13 @@ static devclass_t cdce_devclass; DRIVER_MODULE(cdce, ushub, cdce_driver, cdce_devclass, NULL, 0); -MODULE_VERSION(cdce, 0); +MODULE_VERSION(cdce, 1); MODULE_DEPEND(cdce, usb2_core, 1, 1, 1); MODULE_DEPEND(cdce, ether, 1, 1, 1); static const struct usb2_device_id cdce_devs[] = { {USB_IF_CSI(UICLASS_CDC, UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL, 0)}, + {USB_IF_CSI(UICLASS_CDC, UISUBCLASS_MOBILE_DIRECT_LINE_MODEL, 0)}, {USB_VPI(USB_VENDOR_ACERLABS, USB_PRODUCT_ACERLABS_M5632, CDCE_FLAG_NO_UNION)}, {USB_VPI(USB_VENDOR_AMBIT, USB_PRODUCT_AMBIT_NTL_250, CDCE_FLAG_NO_UNION)}, @@ -514,7 +473,7 @@ /* start the interrupt transfer, if any */ mtx_lock(&sc->sc_mtx); - usb2_transfer_start(sc->sc_xfer[4]); + usb2_transfer_start(sc->sc_xfer[2]); mtx_unlock(&sc->sc_mtx); return (0); /* success */ @@ -640,19 +599,6 @@ } static void -cdce_bulk_write_clear_stall_callback(struct usb2_xfer *xfer) -{ - struct cdce_softc *sc = xfer->priv_sc; - struct usb2_xfer *xfer_other = sc->sc_xfer[0]; - - if (usb2_clear_stall_callback(xfer, xfer_other)) { - DPRINTF("stall cleared\n"); - usb2_transfer_start(xfer_other); - } - return; -} - -static void cdce_bulk_write_512x4_callback(struct usb2_xfer *xfer) { struct cdce_softc *sc = xfer->priv_sc; @@ -677,12 +623,6 @@ case USB_ST_SETUP: tr_setup: - if (xfer->flags.stall_pipe && - (xfer->flags_int.usb2_mode == USB_MODE_HOST)) { - /* try to clear stall */ - usb2_transfer_start(sc->sc_xfer[2]); - break; - } x = 0; /* number of frames */ y = 1; /* number of fragments */ @@ -784,6 +724,8 @@ struct mbuf *mt; uint32_t crc; + DPRINTFN(1, "\n"); + switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: DPRINTFN(11, "transfer complete: " @@ -797,11 +739,6 @@ case USB_ST_SETUP: tr_setup: - if (xfer->flags.stall_pipe && - (xfer->flags_int.usb2_mode == USB_MODE_HOST)) { - usb2_transfer_start(sc->sc_xfer[2]); - break; - } IFQ_DRV_DEQUEUE(&ifp->if_snd, m); if (m == NULL) { @@ -925,8 +862,6 @@ */ usb2_transfer_stop(sc->sc_xfer[0]); usb2_transfer_stop(sc->sc_xfer[1]); - usb2_transfer_stop(sc->sc_xfer[2]); - usb2_transfer_stop(sc->sc_xfer[3]); return; } @@ -1023,19 +958,6 @@ } static void -cdce_bulk_read_clear_stall_callback(struct usb2_xfer *xfer) -{ - struct cdce_softc *sc = xfer->priv_sc; - struct usb2_xfer *xfer_other = sc->sc_xfer[1]; - - if (usb2_clear_stall_callback(xfer, xfer_other)) { - DPRINTF("stall cleared\n"); - usb2_transfer_start(xfer_other); - } - return; -} - -static void cdce_bulk_read_512x4_callback(struct usb2_xfer *xfer) { struct cdce_softc *sc = xfer->priv_sc; @@ -1089,15 +1011,8 @@ case USB_ST_SETUP: tr_setup: if (xfer->flags.stall_pipe) { - /* we are done */ sc->sc_flags &= ~CDCE_FLAG_RX_DATA; - - if (xfer->flags_int.usb2_mode == USB_MODE_HOST) { - usb2_transfer_start(sc->sc_xfer[3]); - free_mq = 1; - break; - } } /* we expect a Multi Frame Ethernet Header */ if (!(sc->sc_flags & CDCE_FLAG_RX_DATA)) { @@ -1292,13 +1207,6 @@ } case USB_ST_SETUP: tr_setup: - if (xfer->flags.stall_pipe) { - - if (xfer->flags_int.usb2_mode == USB_MODE_HOST) { - usb2_transfer_start(sc->sc_xfer[3]); - break; - } - } m = usb2_ether_get_mbuf(); if (m == NULL) { @@ -1381,23 +1289,9 @@ } static void -cdce_intr_read_clear_stall_callback(struct usb2_xfer *xfer) -{ - struct cdce_softc *sc = xfer->priv_sc; - struct usb2_xfer *xfer_other = sc->sc_xfer[4]; - - if (usb2_clear_stall_callback(xfer, xfer_other)) { - DPRINTF("stall cleared\n"); - usb2_transfer_start(xfer_other); - } - return; -} - -static void cdce_intr_read_callback(struct usb2_xfer *xfer) { - struct cdce_softc *sc = xfer->priv_sc; - + ; /* style fix */ switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: @@ -1408,13 +1302,8 @@ case USB_ST_SETUP: tr_setup: - if (xfer->flags.stall_pipe && - (xfer->flags_int.usb2_mode == USB_MODE_HOST)) { - usb2_transfer_start(sc->sc_xfer[5]); - } else { - xfer->frlengths[0] = xfer->max_data_length; - usb2_start_hardware(xfer); - } + xfer->frlengths[0] = xfer->max_data_length; + usb2_start_hardware(xfer); break; default: /* Error */ @@ -1431,8 +1320,7 @@ static void cdce_intr_write_callback(struct usb2_xfer *xfer) { - struct cdce_softc *sc = xfer->priv_sc; - + ; /* style fix */ switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: @@ -1440,15 +1328,10 @@ case USB_ST_SETUP: tr_setup: - if (xfer->flags.stall_pipe && - (xfer->flags_int.usb2_mode == USB_MODE_HOST)) { - usb2_transfer_start(sc->sc_xfer[5]); - } else { #if 0 - xfer->frlengths[0] = XXX; - usb2_start_hardware(xfer); + xfer->frlengths[0] = XXX; + usb2_start_hardware(xfer); #endif - } break; default: /* Error */ ==== //depot/projects/usb/src/sys/dev/usb2/ethernet/if_cdce2_reg.h#4 (text+ko) ==== @@ -35,7 +35,7 @@ #ifndef _USB_IF_CDCEREG_H_ #define _USB_IF_CDCEREG_H_ -#define CDCE_N_TRANSFER 6 /* units */ +#define CDCE_N_TRANSFER 3 /* units */ #define CDCE_IND_SIZE_MAX 32 /* bytes */ #define CDCE_512X4_IFQ_MAXLEN MAX((2*CDCE_512X4_FRAMES_MAX), IFQ_MAXLEN) ==== //depot/projects/usb/src/sys/dev/usb2/include/usb2_standard.h#6 (text+ko) ==== @@ -267,6 +267,12 @@ #define UISUBCLASS_CAPI_CONTROLMODEL 5 #define UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6 #define UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7 +#define UISUBCLASS_WIRELESS_HANDSET_CM 8 +#define UISUBCLASS_DEVICE_MGMT 9 +#define UISUBCLASS_MOBILE_DIRECT_LINE_MODEL 10 +#define UISUBCLASS_OBEX 11 +#define UISUBCLASS_ETHERNET_EMULATION_MODEL 12 + #define UIPROTO_CDC_AT 1 #define UIPROTO_CDC_ETH_512X4 0x76 /* FreeBSD specific */