2 * Copyright (c) 2011 Anybots Inc
3 * written by Akinori Furukoshi <moonlightakkiy@yahoo.ca>
4 * - ucom part is based on u3g.c
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/queue.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
37 #include <sys/module.h>
38 #include <sys/sockio.h>
39 #include <sys/socket.h>
41 #include <sys/mutex.h>
42 #include <sys/condvar.h>
43 #include <sys/sysctl.h>
44 #include <sys/malloc.h>
45 #include <sys/taskqueue.h>
47 #include <machine/bus.h>
50 #include <net/if_types.h>
51 #include <net/netisr.h>
53 #include <net/ethernet.h>
55 #include <netinet/in.h>
56 #include <netinet/ip.h>
57 #include <netinet/ip6.h>
58 #include <netinet/udp.h>
60 #include <net80211/ieee80211_ioctl.h>
62 #include <dev/usb/usb.h>
63 #include <dev/usb/usbdi.h>
64 #include <dev/usb/usbdi_util.h>
65 #include <dev/usb/usb_cdc.h>
68 #define USB_DEBUG_VAR usie_debug
69 #include <dev/usb/usb_debug.h>
70 #include <dev/usb/usb_process.h>
71 #include <dev/usb/usb_msctest.h>
73 #include <dev/usb/serial/usb_serial.h>
75 #include <dev/usb/net/if_usievar.h>
78 static int usie_debug = 0;
80 static SYSCTL_NODE(_hw_usb, OID_AUTO, usie, CTLFLAG_RW, 0, "sierra USB modem");
81 SYSCTL_INT(_hw_usb_usie, OID_AUTO, debug, CTLFLAG_RW, &usie_debug, 0,
85 /* Sierra Wireless Direct IP modems */
86 static const STRUCT_USB_HOST_ID usie_devs[] = {
87 #define USIE_DEV(v, d) { \
88 USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##d) }
89 USIE_DEV(SIERRA, MC8700),
90 USIE_DEV(SIERRA, TRUINSTALL),
91 USIE_DEV(AIRPRIME, USB308),
95 static device_probe_t usie_probe;
96 static device_attach_t usie_attach;
97 static device_detach_t usie_detach;
99 static void usie_uc_update_line_state(struct ucom_softc *, uint8_t);
100 static void usie_uc_cfg_get_status(struct ucom_softc *, uint8_t *, uint8_t *);
101 static void usie_uc_cfg_set_dtr(struct ucom_softc *, uint8_t);
102 static void usie_uc_cfg_set_rts(struct ucom_softc *, uint8_t);
103 static void usie_uc_cfg_open(struct ucom_softc *);
104 static void usie_uc_cfg_close(struct ucom_softc *);
105 static void usie_uc_start_read(struct ucom_softc *);
106 static void usie_uc_stop_read(struct ucom_softc *);
107 static void usie_uc_start_write(struct ucom_softc *);
108 static void usie_uc_stop_write(struct ucom_softc *);
110 static usb_callback_t usie_uc_tx_callback;
111 static usb_callback_t usie_uc_rx_callback;
112 static usb_callback_t usie_uc_status_callback;
113 static usb_callback_t usie_if_tx_callback;
114 static usb_callback_t usie_if_rx_callback;
115 static usb_callback_t usie_if_status_callback;
117 static void usie_if_sync_to(void *);
118 static void usie_if_sync_cb(void *, int);
119 static void usie_if_status_cb(void *, int);
121 static void usie_if_start(struct ifnet *, struct ifaltq_subque *);
122 static int usie_if_output(struct ifnet *, struct mbuf *, struct sockaddr *, struct route *);
123 static void usie_if_init(void *);
124 static void usie_if_stop(struct usie_softc *);
125 static int usie_if_ioctl(struct ifnet *, u_long, caddr_t);
127 static int usie_do_request(struct usie_softc *, struct usb_device_request *, void *);
128 static int usie_if_cmd(struct usie_softc *, uint8_t);
129 static void usie_cns_req(struct usie_softc *, uint32_t, uint16_t);
130 static void usie_cns_rsp(struct usie_softc *, struct usie_cns *);
131 static void usie_hip_rsp(struct usie_softc *, uint8_t *, uint32_t);
132 static int usie_driver_loaded(struct module *, int, void *);
134 static const struct usb_config usie_uc_config[USIE_UC_N_XFER] = {
136 .type = UE_INTERRUPT,
137 .endpoint = UE_ADDR_ANY,
138 .direction = UE_DIR_IN,
139 .bufsize = 0, /* use wMaxPacketSize */
140 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
141 .callback = &usie_uc_status_callback,
145 .endpoint = UE_ADDR_ANY,
146 .direction = UE_DIR_IN,
147 .bufsize = USIE_BUFSIZE,
148 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,.proxy_buffer = 1,},
149 .callback = &usie_uc_rx_callback,
153 .endpoint = UE_ADDR_ANY,
154 .direction = UE_DIR_OUT,
155 .bufsize = USIE_BUFSIZE,
156 .flags = {.pipe_bof = 1,.force_short_xfer = 1,},
157 .callback = &usie_uc_tx_callback,
161 static const struct usb_config usie_if_config[USIE_IF_N_XFER] = {
163 .type = UE_INTERRUPT,
164 .endpoint = UE_ADDR_ANY,
165 .direction = UE_DIR_IN,
166 .bufsize = 0, /* use wMaxPacketSize */
167 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
168 .callback = &usie_if_status_callback,
172 .endpoint = UE_ADDR_ANY,
173 .direction = UE_DIR_IN,
174 .bufsize = USIE_BUFSIZE,
175 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
176 .callback = &usie_if_rx_callback,
180 .endpoint = UE_ADDR_ANY,
181 .direction = UE_DIR_OUT,
182 .bufsize = MAX(USIE_BUFSIZE, MCLBYTES),
183 .flags = {.pipe_bof = 1,.force_short_xfer = 1,},
184 .callback = &usie_if_tx_callback,
188 static device_method_t usie_methods[] = {
189 DEVMETHOD(device_probe, usie_probe),
190 DEVMETHOD(device_attach, usie_attach),
191 DEVMETHOD(device_detach, usie_detach),
195 static driver_t usie_driver = {
197 .methods = usie_methods,
198 .size = sizeof(struct usie_softc),
201 static devclass_t usie_devclass;
202 static eventhandler_tag usie_etag;
204 DRIVER_MODULE(usie, uhub, usie_driver, usie_devclass, usie_driver_loaded, NULL);
205 MODULE_DEPEND(usie, ucom, 1, 1, 1);
206 MODULE_DEPEND(usie, usb, 1, 1, 1);
207 MODULE_VERSION(usie, 1);
209 static const struct ucom_callback usie_uc_callback = {
210 .ucom_cfg_get_status = &usie_uc_cfg_get_status,
211 .ucom_cfg_set_dtr = &usie_uc_cfg_set_dtr,
212 .ucom_cfg_set_rts = &usie_uc_cfg_set_rts,
213 .ucom_cfg_open = &usie_uc_cfg_open,
214 .ucom_cfg_close = &usie_uc_cfg_close,
215 .ucom_start_read = &usie_uc_start_read,
216 .ucom_stop_read = &usie_uc_stop_read,
217 .ucom_start_write = &usie_uc_start_write,
218 .ucom_stop_write = &usie_uc_stop_write,
222 usie_autoinst(void *arg, struct usb_device *udev,
223 struct usb_attach_arg *uaa)
225 struct usb_interface *iface;
226 struct usb_interface_descriptor *id;
227 struct usb_device_request req;
230 if (uaa->dev_state != UAA_DEV_READY)
233 iface = usbd_get_iface(udev, 0);
238 if (id == NULL || id->bInterfaceClass != UICLASS_MASS)
241 if (usbd_lookup_id_by_uaa(usie_devs, sizeof(usie_devs), uaa) != 0)
242 return; /* no device match */
245 DPRINTF("Ejecting %s %s\n",
246 usb_get_manufacturer(udev),
247 usb_get_product(udev));
249 req.bmRequestType = UT_VENDOR;
250 req.bRequest = UR_SET_INTERFACE;
251 USETW(req.wValue, UF_DEVICE_REMOTE_WAKEUP);
252 USETW(req.wIndex, UHF_PORT_CONNECTION);
253 USETW(req.wLength, 0);
255 /* at this moment there is no mutex */
256 err = usbd_do_request_flags(udev, NULL, &req,
257 NULL, 0, NULL, 250 /* ms */ );
259 /* success, mark the udev as disappearing */
261 uaa->dev_state = UAA_DEV_EJECTING;
265 usie_probe(device_t self)
267 struct usb_attach_arg *uaa = device_get_ivars(self);
269 if (uaa->usb_mode != USB_MODE_HOST)
271 if (uaa->info.bConfigIndex != USIE_CNFG_INDEX)
273 if (uaa->info.bIfaceIndex != USIE_IFACE_INDEX)
275 if (uaa->info.bInterfaceClass != UICLASS_VENDOR)
278 return (usbd_lookup_id_by_uaa(usie_devs, sizeof(usie_devs), uaa));
282 usie_attach(device_t self)
284 struct usie_softc *sc = device_get_softc(self);
285 struct usb_attach_arg *uaa = device_get_ivars(self);
287 struct usb_interface *iface;
288 struct usb_interface_descriptor *id;
289 struct usb_device_request req;
296 device_set_usb_desc(self);
297 sc->sc_udev = uaa->device;
300 mtx_init(&sc->sc_mtx, "usie", MTX_NETWORK_LOCK, MTX_DEF);
302 TASK_INIT(&sc->sc_if_status_task, 0, usie_if_status_cb, sc);
303 TASK_INIT(&sc->sc_if_sync_task, 0, usie_if_sync_cb, sc);
305 usb_callout_init_mtx(&sc->sc_if_sync_ch, &sc->sc_mtx, 0);
307 mtx_lock(&sc->sc_mtx);
309 /* set power mode to D0 */
310 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
311 req.bRequest = USIE_POWER;
312 USETW(req.wValue, 0);
313 USETW(req.wIndex, 0);
314 USETW(req.wLength, 0);
315 if (usie_do_request(sc, &req, NULL)) {
316 mtx_unlock(&sc->sc_mtx);
321 req.bmRequestType = UT_READ_VENDOR_DEVICE;
322 req.bRequest = USIE_FW_ATTR;
323 USETW(req.wValue, 0);
324 USETW(req.wIndex, 0);
325 USETW(req.wLength, sizeof(fwattr));
326 if (usie_do_request(sc, &req, &fwattr)) {
327 mtx_unlock(&sc->sc_mtx);
330 mtx_unlock(&sc->sc_mtx);
332 /* check DHCP supports */
333 DPRINTF("fwattr=%x\n", fwattr);
334 if (!(fwattr & USIE_FW_DHCP)) {
335 device_printf(self, "DHCP is not supported. A firmware upgrade might be needed.\n");
338 /* find available interfaces */
340 for (ifidx = 0; ifidx < USIE_IFACE_MAX; ifidx++) {
341 iface = usbd_get_iface(uaa->device, ifidx);
345 id = usbd_get_interface_descriptor(iface);
346 if ((id == NULL) || (id->bInterfaceClass != UICLASS_VENDOR))
349 /* setup Direct IP transfer */
350 if (id->bInterfaceNumber >= 7 && id->bNumEndpoints == 3) {
351 sc->sc_if_ifnum = id->bInterfaceNumber;
354 DPRINTF("ifnum=%d, ifidx=%d\n",
355 sc->sc_if_ifnum, ifidx);
357 err = usbd_transfer_setup(uaa->device,
358 &iface_index, sc->sc_if_xfer, usie_if_config,
359 USIE_IF_N_XFER, sc, &sc->sc_mtx);
365 "could not allocate USB transfers on "
366 "iface_index=%d, err=%s\n",
367 iface_index, usbd_errstr(err));
372 if (sc->sc_nucom >= USIE_UCOM_MAX)
375 usbd_set_parent_iface(uaa->device, ifidx,
376 uaa->info.bIfaceIndex);
378 DPRINTF("NumEndpoints=%d bInterfaceNumber=%d\n",
379 id->bNumEndpoints, id->bInterfaceNumber);
381 if (id->bNumEndpoints == 2) {
382 sc->sc_uc_xfer[sc->sc_nucom][0] = NULL;
387 err = usbd_transfer_setup(uaa->device, &ifidx,
388 sc->sc_uc_xfer[sc->sc_nucom] + start,
389 usie_uc_config + start, USIE_UC_N_XFER - start,
390 &sc->sc_ucom[sc->sc_nucom], &sc->sc_mtx);
393 DPRINTF("usbd_transfer_setup error=%s\n", usbd_errstr(err));
397 mtx_lock(&sc->sc_mtx);
398 for (; start < USIE_UC_N_XFER; start++)
399 usbd_xfer_set_stall(sc->sc_uc_xfer[sc->sc_nucom][start]);
400 mtx_unlock(&sc->sc_mtx);
402 sc->sc_uc_ifnum[sc->sc_nucom] = id->bInterfaceNumber;
404 sc->sc_nucom++; /* found a port */
407 if (sc->sc_nucom == 0) {
408 device_printf(self, "no comports found\n");
412 err = ucom_attach(&sc->sc_super_ucom, sc->sc_ucom,
413 sc->sc_nucom, sc, &usie_uc_callback, &sc->sc_mtx);
416 DPRINTF("ucom_attach failed\n");
419 DPRINTF("Found %d interfaces.\n", sc->sc_nucom);
421 /* setup ifnet (Direct IP) */
422 sc->sc_ifp = ifp = if_alloc(IFT_OTHER);
425 device_printf(self, "Could not allocate a network interface\n");
428 if_initname(ifp, "usie", device_get_unit(self));
431 ifp->if_mtu = USIE_MTU_MAX;
432 ifp->if_flags |= IFF_NOARP;
433 ifp->if_init = usie_if_init;
434 ifp->if_ioctl = usie_if_ioctl;
435 ifp->if_start = usie_if_start;
436 ifp->if_output = usie_if_output;
437 IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
438 ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
439 IFQ_SET_READY(&ifp->if_snd);
442 bpfattach(ifp, DLT_RAW, 0);
444 if (fwattr & USIE_PM_AUTO) {
445 usbd_set_power_mode(uaa->device, USB_POWER_MODE_SAVE);
446 DPRINTF("enabling automatic suspend and resume\n");
448 usbd_set_power_mode(uaa->device, USB_POWER_MODE_ON);
449 DPRINTF("USB power is always ON\n");
452 DPRINTF("device attached\n");
461 usie_detach(device_t self)
463 struct usie_softc *sc = device_get_softc(self);
467 if (sc->sc_ifp != NULL) {
469 usbd_transfer_unsetup(sc->sc_if_xfer, USIE_IF_N_XFER);
470 bpfdetach(sc->sc_ifp);
471 if_detach(sc->sc_ifp);
476 if (sc->sc_nucom > 0)
477 ucom_detach(&sc->sc_super_ucom, sc->sc_ucom);
479 /* stop all USB transfers */
480 usbd_transfer_unsetup(sc->sc_if_xfer, USIE_IF_N_XFER);
482 for (x = 0; x != USIE_UCOM_MAX; x++)
483 usbd_transfer_unsetup(sc->sc_uc_xfer[x], USIE_UC_N_XFER);
485 mtx_destroy(&sc->sc_mtx);
491 usie_uc_update_line_state(struct ucom_softc *ucom, uint8_t ls)
493 struct usie_softc *sc = ucom->sc_parent;
494 struct usb_device_request req;
496 if (sc->sc_uc_xfer[ucom->sc_subunit][USIE_UC_STATUS] == NULL)
499 req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
500 req.bRequest = USIE_LINK_STATE;
501 USETW(req.wValue, ls);
502 USETW(req.wIndex, sc->sc_uc_ifnum[ucom->sc_subunit]);
503 USETW(req.wLength, 0);
505 DPRINTF("sc_uc_ifnum=%d\n", sc->sc_uc_ifnum[ucom->sc_subunit]);
507 usie_do_request(sc, &req, NULL);
511 usie_uc_cfg_get_status(struct ucom_softc *ucom, uint8_t *lsr, uint8_t *msr)
513 struct usie_softc *sc = ucom->sc_parent;
520 usie_uc_cfg_set_dtr(struct ucom_softc *ucom, uint8_t flag)
524 dtr = flag ? USIE_LS_DTR : 0;
525 usie_uc_update_line_state(ucom, dtr);
529 usie_uc_cfg_set_rts(struct ucom_softc *ucom, uint8_t flag)
533 rts = flag ? USIE_LS_RTS : 0;
534 usie_uc_update_line_state(ucom, rts);
538 usie_uc_cfg_open(struct ucom_softc *ucom)
540 struct usie_softc *sc = ucom->sc_parent;
542 /* usbd_transfer_start() is NULL safe */
544 usbd_transfer_start(sc->sc_uc_xfer[ucom->sc_subunit][USIE_UC_STATUS]);
548 usie_uc_cfg_close(struct ucom_softc *ucom)
550 struct usie_softc *sc = ucom->sc_parent;
552 usbd_transfer_stop(sc->sc_uc_xfer[ucom->sc_subunit][USIE_UC_STATUS]);
556 usie_uc_start_read(struct ucom_softc *ucom)
558 struct usie_softc *sc = ucom->sc_parent;
560 usbd_transfer_start(sc->sc_uc_xfer[ucom->sc_subunit][USIE_UC_RX]);
564 usie_uc_stop_read(struct ucom_softc *ucom)
566 struct usie_softc *sc = ucom->sc_parent;
568 usbd_transfer_stop(sc->sc_uc_xfer[ucom->sc_subunit][USIE_UC_RX]);
572 usie_uc_start_write(struct ucom_softc *ucom)
574 struct usie_softc *sc = ucom->sc_parent;
576 usbd_transfer_start(sc->sc_uc_xfer[ucom->sc_subunit][USIE_UC_TX]);
580 usie_uc_stop_write(struct ucom_softc *ucom)
582 struct usie_softc *sc = ucom->sc_parent;
584 usbd_transfer_stop(sc->sc_uc_xfer[ucom->sc_subunit][USIE_UC_TX]);
588 usie_uc_rx_callback(struct usb_xfer *xfer, usb_error_t error)
590 struct ucom_softc *ucom = usbd_xfer_softc(xfer);
591 struct usie_softc *sc = ucom->sc_parent;
592 struct usb_page_cache *pc;
595 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
597 switch (USB_GET_STATE(xfer)) {
598 case USB_ST_TRANSFERRED:
599 pc = usbd_xfer_get_frame(xfer, 0);
601 /* handle CnS response */
602 if (ucom == sc->sc_ucom && actlen >= USIE_HIPCNS_MIN) {
604 DPRINTF("transferred=%u\n", actlen);
606 /* check if it is really CnS reply */
607 usbd_copy_out(pc, 0, sc->sc_resp_temp, 1);
609 if (sc->sc_resp_temp[0] == USIE_HIP_FRM_CHR) {
612 if (actlen > USIE_BUFSIZE)
613 actlen = USIE_BUFSIZE;
615 /* get complete message */
616 usbd_copy_out(pc, 0, sc->sc_resp_temp, actlen);
617 usie_hip_rsp(sc, sc->sc_resp_temp, actlen);
619 /* need to fall though */
622 /* else call ucom_put_data() */
624 /* standard ucom transfer */
625 ucom_put_data(ucom, pc, 0, actlen);
630 usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
631 usbd_transfer_submit(xfer);
635 if (error != USB_ERR_CANCELLED) {
636 usbd_xfer_set_stall(xfer);
644 usie_uc_tx_callback(struct usb_xfer *xfer, usb_error_t error)
646 struct ucom_softc *ucom = usbd_xfer_softc(xfer);
647 struct usb_page_cache *pc;
650 switch (USB_GET_STATE(xfer)) {
651 case USB_ST_TRANSFERRED:
654 pc = usbd_xfer_get_frame(xfer, 0);
656 /* handle CnS request */
657 struct mbuf *m = usbd_xfer_get_priv(xfer);
660 usbd_m_copy_in(pc, 0, m, 0, m->m_pkthdr.len);
661 usbd_xfer_set_frame_len(xfer, 0, m->m_pkthdr.len);
662 usbd_xfer_set_priv(xfer, NULL);
663 usbd_transfer_submit(xfer);
667 /* standard ucom transfer */
668 if (ucom_get_data(ucom, pc, 0, USIE_BUFSIZE, &actlen)) {
669 usbd_xfer_set_frame_len(xfer, 0, actlen);
670 usbd_transfer_submit(xfer);
675 if (error != USB_ERR_CANCELLED) {
676 usbd_xfer_set_stall(xfer);
684 usie_uc_status_callback(struct usb_xfer *xfer, usb_error_t error)
686 struct usb_page_cache *pc;
688 struct usb_device_request req;
694 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
696 switch (USB_GET_STATE(xfer)) {
697 case USB_ST_TRANSFERRED:
698 DPRINTFN(4, "info received, actlen=%u\n", actlen);
700 if (actlen < sizeof(st)) {
701 DPRINTF("data too short actlen=%u\n", actlen);
704 pc = usbd_xfer_get_frame(xfer, 0);
705 usbd_copy_out(pc, 0, &st, sizeof(st));
707 if (st.req.bmRequestType == 0xa1 && st.req.bRequest == 0x20) {
708 struct ucom_softc *ucom = usbd_xfer_softc(xfer);
709 struct usie_softc *sc = ucom->sc_parent;
711 param = le16toh(st.param);
712 DPRINTF("param=%x\n", param);
713 sc->sc_msr = sc->sc_lsr = 0;
714 sc->sc_msr |= (param & USIE_DCD) ? SER_DCD : 0;
715 sc->sc_msr |= (param & USIE_DSR) ? SER_DSR : 0;
716 sc->sc_msr |= (param & USIE_RI) ? SER_RI : 0;
717 sc->sc_msr |= (param & USIE_CTS) ? 0 : SER_CTS;
718 sc->sc_msr |= (param & USIE_RTS) ? SER_RTS : 0;
719 sc->sc_msr |= (param & USIE_DTR) ? SER_DTR : 0;
724 usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
725 usbd_transfer_submit(xfer);
729 DPRINTF("USB transfer error, %s\n",
732 if (error != USB_ERR_CANCELLED) {
733 usbd_xfer_set_stall(xfer);
741 usie_if_rx_callback(struct usb_xfer *xfer, usb_error_t error)
743 struct usie_softc *sc = usbd_xfer_softc(xfer);
744 struct ifnet *ifp = sc->sc_ifp;
746 struct mbuf *m = NULL;
747 struct usie_desc *rxd;
757 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
759 switch (USB_GET_STATE(xfer)) {
760 case USB_ST_TRANSFERRED:
761 DPRINTFN(15, "rx done, actlen=%u\n", actlen);
763 if (actlen < sizeof(struct usie_hip)) {
764 DPRINTF("data too short %u\n", actlen);
774 if (sc->sc_rxm == NULL) {
775 sc->sc_rxm = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR,
776 MJUMPAGESIZE /* could be bigger than MCLBYTES */ );
778 if (sc->sc_rxm == NULL) {
779 DPRINTF("could not allocate Rx mbuf\n");
781 usbd_xfer_set_stall(xfer);
782 usbd_xfer_set_frames(xfer, 0);
785 * Directly loading a mbuf cluster into DMA to
786 * save some data copying. This works because
787 * there is only one cluster.
789 usbd_xfer_set_frame_data(xfer, 0,
790 mtod(sc->sc_rxm, caddr_t), MIN(MJUMPAGESIZE, USIE_RXSZ_MAX));
791 usbd_xfer_set_frames(xfer, 1);
793 usbd_transfer_submit(xfer);
797 DPRINTF("USB transfer error, %s\n", usbd_errstr(error));
799 if (error != USB_ERR_CANCELLED) {
800 /* try to clear stall first */
801 usbd_xfer_set_stall(xfer);
805 if (sc->sc_rxm != NULL) {
815 mtx_unlock(&sc->sc_mtx);
817 m->m_pkthdr.len = m->m_len = actlen;
821 /* HW can aggregate multiple frames in a single USB xfer */
823 rxd = mtod(m, struct usie_desc *);
825 len = be16toh(rxd->hip.len) & USIE_HIP_IP_LEN_MASK;
826 pad = (rxd->hip.id & USIE_HIP_PAD) ? 1 : 0;
827 ipl = (len - pad - ETHER_HDR_LEN);
829 DPRINTF("Corrupt frame\n");
833 diff = sizeof(struct usie_desc) + ipl + pad;
835 if (((rxd->hip.id & USIE_HIP_MASK) != USIE_HIP_IP) ||
836 (be16toh(rxd->desc_type) & USIE_TYPE_MASK) != USIE_IP_RX) {
837 DPRINTF("received wrong type of packet\n");
839 m->m_pkthdr.len = (m->m_len -= diff);
841 if (m->m_pkthdr.len > 0)
846 switch (be16toh(rxd->ethhdr.ether_type)) {
856 DPRINTF("unsupported ether type\n");
861 /* the last packet */
862 if (m->m_pkthdr.len <= diff) {
863 m->m_data += (sizeof(struct usie_desc) + pad);
864 m->m_pkthdr.len = m->m_len = ipl;
865 m->m_pkthdr.rcvif = ifp;
866 BPF_MTAP(sc->sc_ifp, m);
867 netisr_dispatch(ipv, m);
870 /* copy aggregated frames to another mbuf */
871 m0 = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
872 if (__predict_false(m0 == NULL)) {
873 DPRINTF("could not allocate mbuf\n");
878 m_copydata(m, sizeof(struct usie_desc) + pad, ipl, mtod(m0, caddr_t));
879 m0->m_pkthdr.rcvif = ifp;
880 m0->m_pkthdr.len = m0->m_len = ipl;
882 BPF_MTAP(sc->sc_ifp, m0);
883 netisr_dispatch(ipv, m0);
886 m->m_pkthdr.len = (m->m_len -= diff);
889 mtx_lock(&sc->sc_mtx);
891 ifp->if_ierrors += err;
892 ifp->if_ipackets += pkt;
896 usie_if_tx_callback(struct usb_xfer *xfer, usb_error_t error)
898 struct usie_softc *sc = usbd_xfer_softc(xfer);
899 struct usb_page_cache *pc;
900 struct ifnet *ifp = sc->sc_ifp;
904 switch (USB_GET_STATE(xfer)) {
905 case USB_ST_TRANSFERRED:
906 DPRINTFN(11, "transfer complete\n");
907 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
914 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
917 IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
921 if (m->m_pkthdr.len > (MCLBYTES - ETHER_HDR_LEN +
922 ETHER_CRC_LEN - sizeof(sc->sc_txd))) {
923 DPRINTF("packet len is too big: %d\n",
927 pc = usbd_xfer_get_frame(xfer, 0);
929 sc->sc_txd.hip.len = htobe16(m->m_pkthdr.len +
930 ETHER_HDR_LEN + ETHER_CRC_LEN);
931 size = sizeof(sc->sc_txd);
933 usbd_copy_in(pc, 0, &sc->sc_txd, size);
934 usbd_m_copy_in(pc, size, m, 0, m->m_pkthdr.len);
935 usbd_xfer_set_frame_len(xfer, 0, m->m_pkthdr.len +
936 size + ETHER_CRC_LEN);
942 usbd_transfer_submit(xfer);
946 DPRINTF("USB transfer error, %s\n",
950 if (error != USB_ERR_CANCELLED) {
951 usbd_xfer_set_stall(xfer);
960 usie_if_status_callback(struct usb_xfer *xfer, usb_error_t error)
962 struct usie_softc *sc = usbd_xfer_softc(xfer);
963 struct usb_page_cache *pc;
964 struct usb_cdc_notification cdc;
967 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
969 switch (USB_GET_STATE(xfer)) {
970 case USB_ST_TRANSFERRED:
971 DPRINTFN(4, "info received, actlen=%d\n", actlen);
973 /* usb_cdc_notification - .data[16] */
974 if (actlen < (sizeof(cdc) - 16)) {
975 DPRINTF("data too short %d\n", actlen);
978 pc = usbd_xfer_get_frame(xfer, 0);
979 usbd_copy_out(pc, 0, &cdc, (sizeof(cdc) - 16));
981 DPRINTFN(4, "bNotification=%x\n", cdc.bNotification);
983 if (cdc.bNotification & UCDC_N_RESPONSE_AVAILABLE) {
984 taskqueue_enqueue(taskqueue_thread,
985 &sc->sc_if_status_task);
990 usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
991 usbd_transfer_submit(xfer);
995 DPRINTF("USB transfer error, %s\n",
998 if (error != USB_ERR_CANCELLED) {
999 usbd_xfer_set_stall(xfer);
1007 usie_if_sync_to(void *arg)
1009 struct usie_softc *sc = arg;
1011 taskqueue_enqueue(taskqueue_thread, &sc->sc_if_sync_task);
1015 usie_if_sync_cb(void *arg, int pending)
1017 struct usie_softc *sc = arg;
1019 mtx_lock(&sc->sc_mtx);
1022 usie_if_cmd(sc, USIE_HIP_SYNC2M);
1023 usie_if_cmd(sc, USIE_HIP_SYNC2M);
1025 usb_callout_reset(&sc->sc_if_sync_ch, 2 * hz, usie_if_sync_to, sc);
1027 mtx_unlock(&sc->sc_mtx);
1031 usie_if_status_cb(void *arg, int pending)
1033 struct usie_softc *sc = arg;
1034 struct ifnet *ifp = sc->sc_ifp;
1035 struct usb_device_request req;
1036 struct usie_hip *hip;
1037 struct usie_lsi *lsi;
1042 mtx_lock(&sc->sc_mtx);
1044 req.bmRequestType = UT_READ_CLASS_INTERFACE;
1045 req.bRequest = UCDC_GET_ENCAPSULATED_RESPONSE;
1046 USETW(req.wValue, 0);
1047 USETW(req.wIndex, sc->sc_if_ifnum);
1048 USETW(req.wLength, sizeof(sc->sc_status_temp));
1050 for (ntries = 0; ntries != 10; ntries++) {
1053 err = usbd_do_request_flags(sc->sc_udev,
1054 &sc->sc_mtx, &req, sc->sc_status_temp, USB_SHORT_XFER_OK,
1055 &actlen, USB_DEFAULT_TIMEOUT);
1060 DPRINTF("Control request failed: %s %d/10\n",
1061 usbd_errstr(err), ntries);
1063 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(10));
1067 mtx_unlock(&sc->sc_mtx);
1068 DPRINTF("Timeout\n");
1072 hip = (struct usie_hip *)sc->sc_status_temp;
1074 pad = (hip->id & USIE_HIP_PAD) ? 1 : 0;
1076 DPRINTF("hip.id=%x hip.len=%d actlen=%u pad=%d\n",
1077 hip->id, be16toh(hip->len), actlen, pad);
1079 switch (hip->id & USIE_HIP_MASK) {
1080 case USIE_HIP_SYNC2H:
1081 usie_if_cmd(sc, USIE_HIP_SYNC2M);
1083 case USIE_HIP_RESTR:
1084 usb_callout_stop(&sc->sc_if_sync_ch);
1087 lsi = (struct usie_lsi *)(
1088 sc->sc_status_temp + sizeof(struct usie_hip) + pad);
1090 DPRINTF("lsi.proto=%x lsi.len=%d\n", lsi->proto,
1093 if (lsi->proto != USIE_LSI_UMTS)
1096 if (lsi->area == USIE_LSI_AREA_NO ||
1097 lsi->area == USIE_LSI_AREA_NODATA) {
1098 device_printf(sc->sc_dev, "no service available\n");
1101 if (lsi->state == USIE_LSI_STATE_IDLE) {
1102 DPRINTF("lsi.state=%x\n", lsi->state);
1105 DPRINTF("ctx=%x\n", hip->param);
1106 sc->sc_txd.hip.param = hip->param;
1108 sc->sc_net.addr_len = lsi->pdp_addr_len;
1109 memcpy(&sc->sc_net.dns1_addr, &lsi->dns1_addr, 16);
1110 memcpy(&sc->sc_net.dns2_addr, &lsi->dns2_addr, 16);
1111 memcpy(sc->sc_net.pdp_addr, lsi->pdp_addr, 16);
1112 memcpy(sc->sc_net.gw_addr, lsi->gw_addr, 16);
1113 ifp->if_flags |= IFF_UP;
1114 ifp->if_drv_flags |= IFF_DRV_RUNNING;
1116 device_printf(sc->sc_dev, "IP Addr=%d.%d.%d.%d\n",
1117 *lsi->pdp_addr, *(lsi->pdp_addr + 1),
1118 *(lsi->pdp_addr + 2), *(lsi->pdp_addr + 3));
1119 device_printf(sc->sc_dev, "Gateway Addr=%d.%d.%d.%d\n",
1120 *lsi->gw_addr, *(lsi->gw_addr + 1),
1121 *(lsi->gw_addr + 2), *(lsi->gw_addr + 3));
1122 device_printf(sc->sc_dev, "Prim NS Addr=%d.%d.%d.%d\n",
1123 *lsi->dns1_addr, *(lsi->dns1_addr + 1),
1124 *(lsi->dns1_addr + 2), *(lsi->dns1_addr + 3));
1125 device_printf(sc->sc_dev, "Scnd NS Addr=%d.%d.%d.%d\n",
1126 *lsi->dns2_addr, *(lsi->dns2_addr + 1),
1127 *(lsi->dns2_addr + 2), *(lsi->dns2_addr + 3));
1129 usie_cns_req(sc, USIE_CNS_ID_RSSI, USIE_CNS_OB_RSSI);
1133 /* ignore, workaround for sloppy windows */
1136 DPRINTF("undefined msgid: %x\n", hip->id);
1140 mtx_unlock(&sc->sc_mtx);
1144 usie_if_start(struct ifnet *ifp, struct ifaltq_subque *ifsq)
1146 struct usie_softc *sc = ifp->if_softc;
1148 ASSERT_ALTQ_SQ_DEFAULT(ifp, ifsq);
1150 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
1151 DPRINTF("Not running\n");
1154 mtx_lock(&sc->sc_mtx);
1155 usbd_transfer_start(sc->sc_if_xfer[USIE_IF_TX]);
1156 mtx_unlock(&sc->sc_mtx);
1158 DPRINTFN(3, "interface started\n");
1162 usie_if_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
1167 DPRINTF("proto=%x\n", dst->sa_family);
1169 switch (dst->sa_family) {
1177 /* silently drop dhclient packets */
1182 /* drop other packet types */
1185 return (EAFNOSUPPORT);
1188 err = (ifp->if_transmit)(ifp, m);
1199 usie_if_init(void *arg)
1201 struct usie_softc *sc = arg;
1202 struct ifnet *ifp = sc->sc_ifp;
1205 mtx_lock(&sc->sc_mtx);
1207 /* write tx descriptor */
1208 sc->sc_txd.hip.id = USIE_HIP_CTX;
1209 sc->sc_txd.hip.param = 0; /* init value */
1210 sc->sc_txd.desc_type = htobe16(USIE_IP_TX);
1212 for (i = 0; i != USIE_IF_N_XFER; i++)
1213 usbd_xfer_set_stall(sc->sc_if_xfer[i]);
1215 usbd_transfer_start(sc->sc_uc_xfer[USIE_HIP_IF][USIE_UC_RX]);
1216 usbd_transfer_start(sc->sc_if_xfer[USIE_IF_STATUS]);
1217 usbd_transfer_start(sc->sc_if_xfer[USIE_IF_RX]);
1219 /* if not running, initiate the modem */
1220 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
1221 usie_cns_req(sc, USIE_CNS_ID_INIT, USIE_CNS_OB_LINK_UPDATE);
1223 mtx_unlock(&sc->sc_mtx);
1225 DPRINTF("ifnet initialized\n");
1229 usie_if_stop(struct usie_softc *sc)
1231 usb_callout_drain(&sc->sc_if_sync_ch);
1233 mtx_lock(&sc->sc_mtx);
1235 /* usie_cns_req() clears IFF_* flags */
1236 usie_cns_req(sc, USIE_CNS_ID_STOP, USIE_CNS_OB_LINK_UPDATE);
1238 usbd_transfer_stop(sc->sc_if_xfer[USIE_IF_TX]);
1239 usbd_transfer_stop(sc->sc_if_xfer[USIE_IF_RX]);
1240 usbd_transfer_stop(sc->sc_if_xfer[USIE_IF_STATUS]);
1242 /* shutdown device */
1243 usie_if_cmd(sc, USIE_HIP_DOWN);
1245 mtx_unlock(&sc->sc_mtx);
1249 usie_if_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
1251 struct usie_softc *sc = ifp->if_softc;
1252 struct ieee80211req *ireq;
1253 struct ieee80211req_sta_info si;
1254 struct ifmediareq *ifmr;
1258 if (ifp->if_flags & IFF_UP) {
1259 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
1262 if (ifp->if_drv_flags & IFF_DRV_RUNNING)
1268 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
1269 device_printf(sc->sc_dev,
1270 "Connect to the network first.\n");
1273 mtx_lock(&sc->sc_mtx);
1274 usie_cns_req(sc, USIE_CNS_ID_RSSI, USIE_CNS_OB_RSSI);
1275 mtx_unlock(&sc->sc_mtx);
1279 ireq = (struct ieee80211req *)data;
1281 if (ireq->i_type != IEEE80211_IOC_STA_INFO)
1284 memset(&si, 0, sizeof(si));
1285 si.isi_len = sizeof(si);
1287 * ifconfig expects RSSI in 0.5dBm units
1288 * relative to the noise floor.
1290 si.isi_rssi = 2 * sc->sc_rssi;
1291 if (copyout(&si, (uint8_t *)ireq->i_data + 8,
1292 sizeof(struct ieee80211req_sta_info)))
1293 DPRINTF("copyout failed\n");
1297 case SIOCGIFMEDIA: /* to fool ifconfig */
1298 ifmr = (struct ifmediareq *)data;
1299 ifmr->ifm_count = 1;
1304 case SIOCSIFDSTADDR:
1314 usie_do_request(struct usie_softc *sc, struct usb_device_request *req,
1320 mtx_assert(&sc->sc_mtx, MA_OWNED);
1322 for (ntries = 0; ntries != 10; ntries++) {
1323 err = usbd_do_request(sc->sc_udev,
1324 &sc->sc_mtx, req, data);
1328 DPRINTF("Control request failed: %s %d/10\n",
1329 usbd_errstr(err), ntries);
1331 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(10));
1337 usie_if_cmd(struct usie_softc *sc, uint8_t cmd)
1339 struct usb_device_request req;
1340 struct usie_hip msg;
1346 req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
1347 req.bRequest = UCDC_SEND_ENCAPSULATED_COMMAND;
1348 USETW(req.wValue, 0);
1349 USETW(req.wIndex, sc->sc_if_ifnum);
1350 USETW(req.wLength, sizeof(msg));
1352 DPRINTF("cmd=%x\n", cmd);
1354 return (usie_do_request(sc, &req, &msg));
1358 usie_cns_req(struct usie_softc *sc, uint32_t id, uint16_t obj)
1360 struct ifnet *ifp = sc->sc_ifp;
1362 struct usb_xfer *xfer;
1363 struct usie_hip *hip;
1364 struct usie_cns *cns;
1369 m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
1370 if (__predict_false(m == NULL)) {
1371 DPRINTF("could not allocate mbuf\n");
1375 /* to align usie_hip{} on 32 bit */
1377 param = mtod(m, uint8_t *);
1378 *param++ = USIE_HIP_FRM_CHR;
1379 hip = (struct usie_hip *)param;
1380 cns = (struct usie_cns *)(hip + 1);
1382 tmp = param + USIE_HIPCNS_MIN - 2;
1385 case USIE_CNS_OB_LINK_UPDATE:
1387 cns->op = USIE_CNS_OP_SET;
1388 *tmp++ = 1; /* profile ID, always use 1 for now */
1389 *tmp++ = id == USIE_CNS_ID_INIT ? 1 : 0;
1392 case USIE_CNS_OB_PROF_WRITE:
1394 cns->op = USIE_CNS_OP_SET;
1395 *tmp++ = 1; /* profile ID, always use 1 for now */
1397 memcpy(tmp, &sc->sc_net, 34);
1398 memset(tmp + 35, 0, 245 - 36);
1402 case USIE_CNS_OB_RSSI:
1404 cns->op = USIE_CNS_OP_REQ;
1408 DPRINTF("unsupported CnS object type\n");
1411 *tmp = USIE_HIP_FRM_CHR;
1413 hip->len = htobe16(sizeof(struct usie_cns) + cns_len);
1414 hip->id = USIE_HIP_CNS2M;
1415 hip->param = 0; /* none for CnS */
1417 cns->obj = htobe16(obj);
1418 cns->id = htobe32(id);
1420 cns->rsv0 = cns->rsv1 = 0; /* always '0' */
1422 param = (uint8_t *)(cns + 1);
1424 DPRINTF("param: %16D\n", param, ":");
1426 m->m_pkthdr.len = m->m_len = USIE_HIPCNS_MIN + cns_len + 2;
1428 xfer = sc->sc_uc_xfer[USIE_HIP_IF][USIE_UC_TX];
1430 if (usbd_xfer_get_priv(xfer) == NULL) {
1431 usbd_xfer_set_priv(xfer, m);
1432 usbd_transfer_start(xfer);
1434 DPRINTF("Dropped CNS event\n");
1440 usie_cns_rsp(struct usie_softc *sc, struct usie_cns *cns)
1442 struct ifnet *ifp = sc->sc_ifp;
1444 DPRINTF("received CnS\n");
1446 switch (be16toh(cns->obj)) {
1447 case USIE_CNS_OB_LINK_UPDATE:
1448 if (be32toh(cns->id) & USIE_CNS_ID_INIT)
1449 usie_if_sync_to(sc);
1450 else if (be32toh(cns->id) & USIE_CNS_ID_STOP) {
1451 ifp->if_flags &= ~IFF_UP;
1452 ifp->if_drv_flags &=
1453 ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
1455 DPRINTF("undefined link update\n");
1458 case USIE_CNS_OB_RSSI:
1459 sc->sc_rssi = be16toh(*(int16_t *)(cns + 1));
1460 if (sc->sc_rssi <= 0)
1461 device_printf(sc->sc_dev, "No signal\n");
1463 device_printf(sc->sc_dev, "RSSI=%ddBm\n",
1468 case USIE_CNS_OB_PROF_WRITE:
1471 case USIE_CNS_OB_PDP_READ:
1475 DPRINTF("undefined CnS\n");
1481 usie_hip_rsp(struct usie_softc *sc, uint8_t *rsp, uint32_t len)
1483 struct usie_hip *hip;
1484 struct usie_cns *cns;
1488 uint8_t tmp[USIE_HIPCNS_MAX] __aligned(4);
1490 for (off = 0; (off + USIE_HIPCNS_MIN) <= len; off++) {
1494 while ((off < len) && (rsp[off] == USIE_HIP_FRM_CHR))
1497 /* Unstuff the bytes */
1498 for (i = j = 0; ((i + off) < len) &&
1499 (j < USIE_HIPCNS_MAX); i++) {
1501 if (rsp[i + off] == USIE_HIP_FRM_CHR)
1504 if (rsp[i + off] == USIE_HIP_ESC_CHR) {
1505 if ((i + off + 1) >= len)
1507 tmp[j++] = rsp[i++ + off + 1] ^ 0x20;
1509 tmp[j++] = rsp[i + off];
1515 DPRINTF("frame len=%d\n", j);
1517 if (j < sizeof(struct usie_hip)) {
1518 DPRINTF("too little data\n");
1522 * Make sure we are not reading the stack if something
1525 memset(tmp + j, 0, sizeof(tmp) - j);
1527 hip = (struct usie_hip *)tmp;
1529 DPRINTF("hip: len=%d msgID=%02x, param=%02x\n",
1530 be16toh(hip->len), hip->id, hip->param);
1532 pad = (hip->id & USIE_HIP_PAD) ? 1 : 0;
1534 if ((hip->id & USIE_HIP_MASK) == USIE_HIP_CNS2H) {
1535 cns = (struct usie_cns *)(((uint8_t *)(hip + 1)) + pad);
1537 if (j < (sizeof(struct usie_cns) +
1538 sizeof(struct usie_hip) + pad)) {
1539 DPRINTF("too little data\n");
1542 DPRINTF("cns: obj=%04x, op=%02x, rsv0=%02x, "
1543 "app=%08x, rsv1=%02x, len=%d\n",
1544 be16toh(cns->obj), cns->op, cns->rsv0,
1545 be32toh(cns->id), cns->rsv1, cns->len);
1547 if (cns->op & USIE_CNS_OP_ERR)
1548 DPRINTF("CnS error response\n");
1550 usie_cns_rsp(sc, cns);
1552 i = sizeof(struct usie_hip) + pad + sizeof(struct usie_cns);
1555 i = sizeof(struct usie_hip) + pad;
1556 j = be16toh(hip->len);
1559 if (usie_debug == 0)
1562 while (i < USIE_HIPCNS_MAX && j > 0) {
1563 DPRINTF("param[0x%02x] = 0x%02x\n", i, tmp[i]);
1572 usie_driver_loaded(struct module *mod, int what, void *arg)
1576 /* register autoinstall handler */
1577 usie_etag = EVENTHANDLER_REGISTER(usb_dev_configured,
1578 usie_autoinst, NULL, EVENTHANDLER_PRI_ANY);
1581 EVENTHANDLER_DEREGISTER(usb_dev_configured, usie_etag);
1584 return (EOPNOTSUPP);