Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Do you work cdce(4)?



Hi! all,


Do you work cdce(4)?

My cdce(4) device don't works on -current.  I import some changes from
OpenBSD.  I look to work my cdce(4) device!!
However...

PING 192.168.11.21 (192.168.11.21): 56 data bytes
23 packets transmitted, 0 packets received, 100.0% packet loss
64 bytes from 192.168.11.21: icmp_seq=0 ttl=255 time=34119.864 ms
64 bytes from 192.168.11.21: icmp_seq=1 ttl=255 time=33114.676 ms
64 bytes from 192.168.11.21: icmp_seq=2 ttl=255 time=32099.732 ms
64 bytes from 192.168.11.21: icmp_seq=3 ttl=255 time=31100.383 ms
64 bytes from 192.168.11.21: icmp_seq=4 ttl=255 time=31059.437 ms
64 bytes from 192.168.11.21: icmp_seq=5 ttl=255 time=35753.030 ms
64 bytes from 192.168.11.21: icmp_seq=6 ttl=255 time=37527.451 ms
64 bytes from 192.168.11.21: icmp_seq=7 ttl=255 time=38173.662 ms
64 bytes from 192.168.11.21: icmp_seq=8 ttl=255 time=41592.309 ms
64 bytes from 192.168.11.21: icmp_seq=9 ttl=255 time=42293.502 ms
64 bytes from 192.168.11.21: icmp_seq=10 ttl=255 time=42455.717 ms

----192.168.11.21 PING Statistics----
41 packets transmitted, 11 packets received, 73.2% packet loss
round-trip min/avg/max/stddev = 31059.437/36299.069/42455.717/4406.596 ms


41 packets transmitted and 11 packets received.
And response time 30sec...  Maybe not loss packet.  ;-)

My environment)

  USL-5P(landisk) -- cdce(4) -- ehci@cardbus - OpenBlockS266(evbppc)

I can't test this patch on PC.  I don't have PC now.  ;-)

Thanks,
--
kiyohara

Index: if_cdce.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/if_cdce.c,v
retrieving revision 1.21
diff -u -r1.21 if_cdce.c
--- if_cdce.c   18 Apr 2009 14:58:04 -0000      1.21
+++ if_cdce.c   19 May 2009 15:19:57 -0000
@@ -103,6 +103,16 @@
 
 #include <dev/usb/if_cdcereg.h>
 
+#define ETHER_ALIGN    2
+
+#ifdef CDCE_DEBUG
+#define DPRINTFN(n, x) do { if (cdcedebug > (n)) printf x; } while (0)
+int cdcedebug = 0;
+#else
+#define DPRINTFN(n, x)
+#endif
+#define DPRINTF(x)     DPRINTFN(0, x)
+
 Static int      cdce_tx_list_init(struct cdce_softc *);
 Static int      cdce_rx_list_init(struct cdce_softc *);
 Static int      cdce_newbuf(struct cdce_softc *, struct cdce_chain *,
@@ -115,6 +125,7 @@
 Static void     cdce_init(void *);
 Static void     cdce_watchdog(struct ifnet *);
 Static void     cdce_stop(struct cdce_softc *);
+Static void     cdce_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
 Static uint32_t         cdce_crc32(const void *, size_t);
 
 Static const struct cdce_type cdce_devs[] = {
@@ -146,18 +157,20 @@
 USB_ATTACH(cdce)
 {
        USB_IFATTACH_START(cdce, sc, uaa);
-       char                             *devinfop;
-       int                              s;
+       char                            *devinfop;
        struct ifnet                    *ifp;
        usbd_device_handle               dev = uaa->device;
-       const struct cdce_type          *t;
+       usbd_desc_iter_t                 iter;
+       usb_config_descriptor_t         *cd;
        usb_interface_descriptor_t      *id;
        usb_endpoint_descriptor_t       *ed;
+       const usb_cdc_header_descriptor_t *desc;
        const usb_cdc_union_descriptor_t *ud;
-       int                              data_ifcno;
-       int                              i;
+       const usb_cdc_ethernet_descriptor_t *ue = NULL;
+       const struct cdce_type          *t;
+       int                              data_ifcno = -1, ctl_ifcno = -1;
+       int                              numalts, i, j, s;
        u_char                           eaddr[ETHER_ADDR_LEN];
-       const usb_cdc_ethernet_descriptor_t *ue;
        char                             eaddr_str[USB_MAX_ENCODED_STRING_LEN];
 
        devinfop = usbd_devinfo_alloc(dev, 0);
@@ -168,31 +181,53 @@
 
        sc->cdce_udev = uaa->device;
        sc->cdce_ctl_iface = uaa->iface;
+       id = usbd_get_interface_descriptor(sc->cdce_ctl_iface);
+       ctl_ifcno = id->bInterfaceNumber;
 
        t = cdce_lookup(uaa->vendor, uaa->product);
        if (t)
                sc->cdce_flags = t->cdce_flags;
 
-       if (sc->cdce_flags & CDCE_NO_UNION)
-               sc->cdce_data_iface = sc->cdce_ctl_iface;
-       else {
-               ud = (const usb_cdc_union_descriptor_t 
*)usb_find_desc(sc->cdce_udev,
-                   UDESC_CS_INTERFACE, UDESCSUB_CDC_UNION);
-               if (ud == NULL) {
-                       aprint_error_dev(self, "no union descriptor\n");
-                       USB_ATTACH_ERROR_RETURN;
+       /* Get the data interface no. and capabilities */
+       usb_desc_iter_init(dev, &iter);
+       while ((desc =
+           (const usb_cdc_header_descriptor_t *)usb_desc_iter_next(&iter))) {
+               if (desc->bDescriptorType != UDESC_CS_INTERFACE)
+                       continue;
+               switch (desc->bDescriptorSubtype) {
+               case UDESCSUB_CDC_UNION:
+                       ud = (const usb_cdc_union_descriptor_t *)desc;
+                       if (!(sc->cdce_flags & CDCE_NO_UNION) &&
+                           ud->bMasterInterface == ctl_ifcno)
+                               data_ifcno = ud->bSlaveInterface[0];
+                       if ((sc->cdce_flags & CDCE_NO_UNION) &&
+                           ud->bSlaveInterface[0] == ctl_ifcno)
+                               data_ifcno = ud->bMasterInterface;
+                       break;
+
+               case UDESCSUB_CDC_ENF:
+                       if (ue) {
+                               aprint_error_dev(self,
+                                   "extra ethernet descriptor\n");
+                               return;
+                       }
+                       ue = (const usb_cdc_ethernet_descriptor_t *)desc;
                }
-               data_ifcno = ud->bSlaveInterface[0];
+       }
 
+       if (data_ifcno == -1) {
+               DPRINTF(("cdce_attach: no union interface\n"));
+               sc->cdce_data_iface = sc->cdce_ctl_iface;
+       } else {
+               DPRINTF(("cdce_attach: union interface: ctl=%d, data=%d\n",
+                   ctl_ifcno, data_ifcno));
                for (i = 0; i < uaa->nifaces; i++) {
-                       if (uaa->ifaces[i] != NULL) {
-                               id = usbd_get_interface_descriptor(
-                                   uaa->ifaces[i]);
-                               if (id != NULL && id->bInterfaceNumber ==
-                                   data_ifcno) {
-                                       sc->cdce_data_iface = uaa->ifaces[i];
-                                       uaa->ifaces[i] = NULL;
-                               }
+                       if (uaa->ifaces[i] == NULL)
+                               continue;
+                       id = usbd_get_interface_descriptor(uaa->ifaces[i]);
+                       if (id != NULL && id->bInterfaceNumber == data_ifcno) {
+                               sc->cdce_data_iface = uaa->ifaces[i];
+                               uaa->ifaces[i] = NULL;
                        }
                }
        }
@@ -202,28 +237,67 @@
                USB_ATTACH_ERROR_RETURN;
        }
 
-       /* Find endpoints. */
-       id = usbd_get_interface_descriptor(sc->cdce_data_iface);
-       sc->cdce_bulkin_no = sc->cdce_bulkout_no = -1;
-       for (i = 0; i < id->bNumEndpoints; i++) {
-               ed = usbd_interface2endpoint_descriptor(sc->cdce_data_iface, i);
+       id = usbd_get_interface_descriptor(sc->cdce_ctl_iface);
+       sc->cdce_intr_no = -1;
+       for (i = 0; i < id->bNumEndpoints && sc->cdce_intr_no == -1; i++) {
+               ed = usbd_interface2endpoint_descriptor(sc->cdce_ctl_iface, i);
                if (!ed) {
                        aprint_error_dev(self,
-                           "could not read endpoint descriptor\n");
-                       USB_ATTACH_ERROR_RETURN;
+                           "no descriptor for interrupt endpoint %d\n", i);
+                       return;
                }
                if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
-                   UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
-                       sc->cdce_bulkin_no = ed->bEndpointAddress;
-               } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
-                   UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
-                       sc->cdce_bulkout_no = ed->bEndpointAddress;
-               } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
                    UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) {
-                       /* XXX: CDC spec defines an interrupt pipe, but it is 
not
-                        * needed for simple host-to-host applications. */
-               } else {
-                       aprint_error_dev(self, "unexpected endpoint\n");
+                       sc->cdce_intr_no = ed->bEndpointAddress;
+                       sc->cdce_intr_size = sizeof(sc->cdce_intr_buf);
+               }
+       }
+
+       id = usbd_get_interface_descriptor(sc->cdce_data_iface);
+       cd = usbd_get_config_descriptor(sc->cdce_udev);
+       numalts = usbd_get_no_alts(cd, id->bInterfaceNumber);
+       for (j = 0; j < numalts; j++) {
+               if (usbd_set_interface(sc->cdce_data_iface, j)) {
+                       aprint_error_dev(self,
+                           "interface alternate setting %d failed\n", j);
+                       return;
+               }
+               /* Find endpoints. */
+               id = usbd_get_interface_descriptor(sc->cdce_data_iface);
+               sc->cdce_bulkin_no = sc->cdce_bulkout_no = -1;
+               for (i = 0; i < id->bNumEndpoints; i++) {
+                       ed = usbd_interface2endpoint_descriptor(
+                           sc->cdce_data_iface, i);
+                       if (!ed) {
+                               aprint_error_dev(self,
+                                   "could not read endpoint descriptor\n");
+                               USB_ATTACH_ERROR_RETURN;
+                       }
+                       if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
+                           UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK)
+                               sc->cdce_bulkin_no = ed->bEndpointAddress;
+                       else if (
+                           UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
+                           UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK)
+                               sc->cdce_bulkout_no = ed->bEndpointAddress;
+                       else if (
+                           UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
+                           UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT)
+                               /* XXX:
+                                * CDC spec defines an interrupt pipe, but it
+                                * is not needed for simple host-to-host
+                                * applications.
+                                */
+                               ;
+                       else
+                               aprint_error_dev(self, "unexpected endpoint\n");
+               }
+
+               if (sc->cdce_bulkin_no != -1 && sc->cdce_bulkout_no != -1) {
+                       DPRINTF(("cdce_attach: intr=0x%x, in=0x%x, out=0x%x\n",
+                           sc->cdce_intr_no, sc->cdce_bulkin_no,
+                           sc->cdce_bulkout_no));
+                       break;
                }
        }
 
@@ -231,21 +305,18 @@
                aprint_error_dev(self, "could not find data bulk in\n");
                USB_ATTACH_ERROR_RETURN;
        }
-       if (sc->cdce_bulkout_no == -1 ) {
+       if (sc->cdce_bulkout_no == -1) {
                aprint_error_dev(self, "could not find data bulk out\n");
                USB_ATTACH_ERROR_RETURN;
        }
 
-       ue = (const usb_cdc_ethernet_descriptor_t *)usb_find_desc(dev,
-            UDESC_INTERFACE, UDESCSUB_CDC_ENF);
        if (!ue || usbd_get_string(dev, ue->iMacAddress, eaddr_str)) {
                aprint_normal_dev(self, "faking address\n");
                eaddr[0]= 0x2a;
-               memcpy(&eaddr[1], &hardclock_ticks, sizeof(u_int32_t));
-               eaddr[5] = (u_int8_t)(device_unit(sc->cdce_dev));
-       } else {
+               memcpy(&eaddr[1], &hardclock_ticks, sizeof(uint32_t));
+               eaddr[5] = (uint8_t)(device_unit(sc->cdce_dev));
+       } else
                (void)ether_nonstatic_aton(eaddr, eaddr_str);
-       }
 
        s = splnet();
 
@@ -341,7 +412,7 @@
        m_copydata(m, 0, m->m_pkthdr.len, c->cdce_buf);
        if (sc->cdce_flags & CDCE_ZAURUS) {
                /* Zaurus wants a 32-bit CRC appended to every frame */
-               u_int32_t crc;
+               uint32_t crc;
 
                crc = cdce_crc32(c->cdce_buf, m->m_pkthdr.len);
                memcpy(c->cdce_buf + m->m_pkthdr.len, &crc, 4);
@@ -350,7 +421,8 @@
        c->cdce_mbuf = m;
 
        usbd_setup_xfer(c->cdce_xfer, sc->cdce_bulkout_pipe, c, c->cdce_buf,
-           m->m_pkthdr.len + extra, USBD_NO_COPY, 10000, cdce_txeof);
+           m->m_pkthdr.len + extra, USBD_FORCE_SHORT_XFER | USBD_NO_COPY,
+           10000, cdce_txeof);
        err = usbd_transfer(c->cdce_xfer);
        if (err != USBD_IN_PROGRESS) {
                cdce_stop(sc);
@@ -374,34 +446,49 @@
        if (sc->cdce_bulkin_pipe != NULL) {
                err = usbd_abort_pipe(sc->cdce_bulkin_pipe);
                if (err)
-                       printf("%s: abort rx pipe failed: %s\n",
-                           USBDEVNAME(sc->cdce_dev), usbd_errstr(err));
+                       aprint_error_ifnet(ifp, "abort rx pipe failed: %s\n",
+                           usbd_errstr(err));
                err = usbd_close_pipe(sc->cdce_bulkin_pipe);
                if (err)
-                       printf("%s: close rx pipe failed: %s\n",
-                           USBDEVNAME(sc->cdce_dev), usbd_errstr(err));
+                       aprint_error_ifnet(ifp, "close rx pipe failed: %s\n",
+                           usbd_errstr(err));
                sc->cdce_bulkin_pipe = NULL;
        }
 
        if (sc->cdce_bulkout_pipe != NULL) {
                err = usbd_abort_pipe(sc->cdce_bulkout_pipe);
                if (err)
-                       printf("%s: abort tx pipe failed: %s\n",
-                           USBDEVNAME(sc->cdce_dev), usbd_errstr(err));
+                       aprint_error_ifnet(ifp, "abort tx pipe failed: %s\n",
+                           usbd_errstr(err));
                err = usbd_close_pipe(sc->cdce_bulkout_pipe);
                if (err)
-                       printf("%s: close tx pipe failed: %s\n",
-                           USBDEVNAME(sc->cdce_dev), usbd_errstr(err));
+                       aprint_error_ifnet(ifp, "close tx pipe failed: %s\n",
+                           usbd_errstr(err));
                sc->cdce_bulkout_pipe = NULL;
        }
 
+       if (sc->cdce_intr_pipe != NULL) {
+               err = usbd_abort_pipe(sc->cdce_intr_pipe);
+               if (err)
+                       aprint_error_ifnet(ifp,
+                           "abort interrupt pipe failed: %s\n",
+                           usbd_errstr(err));
+               err = usbd_close_pipe(sc->cdce_intr_pipe);
+               if (err)
+                       aprint_error_ifnet(ifp,
+                           "close interrupt pipe failed: %s\n",
+                           usbd_errstr(err));
+               sc->cdce_intr_pipe = NULL;
+       }
+
        for (i = 0; i < CDCE_RX_LIST_CNT; i++) {
                if (sc->cdce_cdata.cdce_rx_chain[i].cdce_mbuf != NULL) {
                        m_freem(sc->cdce_cdata.cdce_rx_chain[i].cdce_mbuf);
                        sc->cdce_cdata.cdce_rx_chain[i].cdce_mbuf = NULL;
                }
                if (sc->cdce_cdata.cdce_rx_chain[i].cdce_xfer != NULL) {
-                       
usbd_free_xfer(sc->cdce_cdata.cdce_rx_chain[i].cdce_xfer);
+                       usbd_free_xfer(
+                           sc->cdce_cdata.cdce_rx_chain[i].cdce_xfer);
                        sc->cdce_cdata.cdce_rx_chain[i].cdce_xfer = NULL;
                }
        }
@@ -412,7 +499,8 @@
                        sc->cdce_cdata.cdce_tx_chain[i].cdce_mbuf = NULL;
                }
                if (sc->cdce_cdata.cdce_tx_chain[i].cdce_xfer != NULL) {
-                       
usbd_free_xfer(sc->cdce_cdata.cdce_tx_chain[i].cdce_xfer);
+                       usbd_free_xfer(
+                           sc->cdce_cdata.cdce_tx_chain[i].cdce_xfer);
                        sc->cdce_cdata.cdce_tx_chain[i].cdce_xfer = NULL;
                }
        }
@@ -475,6 +563,8 @@
 
        default:
                error = ether_ioctl(ifp, command, data);
+               if (error == ENETRESET)
+                       error = 0;
                break;
        }
 
@@ -492,7 +582,7 @@
                return;
 
        ifp->if_oerrors++;
-       printf("%s: watchdog timeout\n", USBDEVNAME(sc->cdce_dev));
+       aprint_error_ifnet(ifp, "watchdog timeout\n");
 }
 
 Static void
@@ -509,14 +599,29 @@
 
        s = splnet();
 
+       if (sc->cdce_intr_no != -1 && sc->cdce_intr_pipe == NULL) {
+               DPRINTFN(1, ("cdce_init: establish interrupt pipe\n"));
+               err = usbd_open_pipe_intr(sc->cdce_ctl_iface, sc->cdce_intr_no,
+                   USBD_SHORT_XFER_OK, &sc->cdce_intr_pipe, sc,
+                   &sc->cdce_intr_buf, sc->cdce_intr_size, cdce_intr,
+                   USBD_DEFAULT_INTERVAL);
+               if (err) {
+                       aprint_error_ifnet(ifp,
+                           "open interrupt pipe failed: %s\n",
+                           usbd_errstr(err));
+                       splx(s);
+                       return;
+               }
+       }
+
        if (cdce_tx_list_init(sc) == ENOBUFS) {
-               printf("%s: tx list init failed\n", USBDEVNAME(sc->cdce_dev));
+               aprint_error_ifnet(ifp, "tx list init failed\n");
                splx(s);
                return;
        }
 
        if (cdce_rx_list_init(sc) == ENOBUFS) {
-               printf("%s: rx list init failed\n", USBDEVNAME(sc->cdce_dev));
+               aprint_error_ifnet(ifp, "rx list init failed\n");
                splx(s);
                return;
        }
@@ -526,7 +631,7 @@
        err = usbd_open_pipe(sc->cdce_data_iface, sc->cdce_bulkin_no,
            USBD_EXCLUSIVE_USE, &sc->cdce_bulkin_pipe);
        if (err) {
-               printf("%s: open rx pipe failed: %s\n", 
USBDEVNAME(sc->cdce_dev),
+               aprint_error_ifnet(ifp, "open rx pipe failed: %s\n",
                    usbd_errstr(err));
                splx(s);
                return;
@@ -535,7 +640,7 @@
        err = usbd_open_pipe(sc->cdce_data_iface, sc->cdce_bulkout_no,
            USBD_EXCLUSIVE_USE, &sc->cdce_bulkout_pipe);
        if (err) {
-               printf("%s: open tx pipe failed: %s\n", 
USBDEVNAME(sc->cdce_dev),
+               aprint_error_ifnet(ifp, "open tx pipe failed: %s\n",
                    usbd_errstr(err));
                splx(s);
                return;
@@ -563,14 +668,14 @@
        if (m == NULL) {
                MGETHDR(m_new, M_DONTWAIT, MT_DATA);
                if (m_new == NULL) {
-                       printf("%s: no memory for rx list "
-                           "-- packet dropped!\n", USBDEVNAME(sc->cdce_dev));
+                       aprint_error_dev(sc->cdce_dev,
+                           "no memory for rx list -- packet dropped!\n");
                        return (ENOBUFS);
                }
                MCLGET(m_new, M_DONTWAIT);
                if (!(m_new->m_flags & M_EXT)) {
-                       printf("%s: no memory for rx list "
-                           "-- packet dropped!\n", USBDEVNAME(sc->cdce_dev));
+                       aprint_error_dev(sc->cdce_dev,
+                           "no memory for rx list -- packet dropped!\n");
                        m_freem(m_new);
                        return (ENOBUFS);
                }
@@ -580,6 +685,7 @@
                m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
                m_new->m_data = m_new->m_ext.ext_buf;
        }
+       m_adj(m_new, ETHER_ALIGN);
        c->cdce_mbuf = m_new;
        return (0);
 }
@@ -602,7 +708,8 @@
                        c->cdce_xfer = usbd_alloc_xfer(sc->cdce_udev);
                        if (c->cdce_xfer == NULL)
                                return (ENOBUFS);
-                       c->cdce_buf = usbd_alloc_buffer(c->cdce_xfer, 
CDCE_BUFSZ);
+                       c->cdce_buf =
+                           usbd_alloc_buffer(c->cdce_xfer, CDCE_BUFSZ);
                        if (c->cdce_buf == NULL)
                                return (ENOBUFS);
                }
@@ -628,7 +735,8 @@
                        c->cdce_xfer = usbd_alloc_xfer(sc->cdce_udev);
                        if (c->cdce_xfer == NULL)
                                return (ENOBUFS);
-                       c->cdce_buf = usbd_alloc_buffer(c->cdce_xfer, 
CDCE_BUFSZ);
+                       c->cdce_buf =
+                           usbd_alloc_buffer(c->cdce_xfer, CDCE_BUFSZ);
                        if (c->cdce_buf == NULL)
                                return (ENOBUFS);
                }
@@ -654,8 +762,8 @@
                if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
                        return;
                if (sc->cdce_rxeof_errors == 0)
-                       printf("%s: usb error on rx: %s\n",
-                           USBDEVNAME(sc->cdce_dev), usbd_errstr(status));
+                       aprint_error_dev(sc->cdce_dev, "usb error on rx: %s\n",
+                           usbd_errstr(status));
                if (status == USBD_STALLED)
                        usbd_clear_endpoint_stall_async(sc->cdce_bulkin_pipe);
                DELAY(sc->cdce_rxeof_errors * 10000);
@@ -732,7 +840,7 @@
                        return;
                }
                ifp->if_oerrors++;
-               printf("%s: usb error on tx: %s\n", USBDEVNAME(sc->cdce_dev),
+               aprint_error_dev(sc->cdce_dev, "usb error on tx: %s\n",
                    usbd_errstr(status));
                if (status == USBD_STALLED)
                        usbd_clear_endpoint_stall_async(sc->cdce_bulkout_pipe);
@@ -776,6 +884,52 @@
        return (0);
 }
 
+Static void
+cdce_intr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status)
+{
+       struct cdce_softc *sc = addr;
+       usb_cdc_notification_t *buf = &sc->cdce_intr_buf;
+       usb_cdc_connection_speed_t *speed;
+       uint32_t count;
+
+       if (status == USBD_CANCELLED)
+               return;
+
+       if (status != USBD_NORMAL_COMPLETION) {
+               DPRINTFN(2, ("cdce_intr: status=%d\n", status));
+               if (status == USBD_STALLED)
+                       usbd_clear_endpoint_stall_async(sc->cdce_intr_pipe);
+               return;
+       }
+
+       usbd_get_xfer_status(xfer, NULL, NULL, &count, NULL);
+
+       if (buf->bmRequestType == UCDC_NOTIFICATION) {
+               switch (buf->bNotification) {
+               case UCDC_N_NETWORK_CONNECTION:
+                       DPRINTFN(1, ("cdce_intr: network %s\n",
+                           UGETW(buf->wValue) ? "connected" : "disconnected"));
+                       break;
+               case UCDC_N_CONNECTION_SPEED_CHANGE:
+                       speed = (usb_cdc_connection_speed_t *)&buf->data;
+                       DPRINTFN(1, ("cdce_intr: up=%d, down=%d\n",
+                           UGETDW(speed->dwUSBitRate),
+                           UGETDW(speed->dwDSBitRate)));
+                       break;
+               default:
+                       DPRINTF(("cdce_intr: bNotification 0x%x\n",
+                           buf->bNotification));
+               }
+       }
+#ifdef CDCE_DEBUG
+       else {
+               printf("cdce_intr: bmRequestType=%d ", buf->bmRequestType);
+               printf("wValue=%d wIndex=%d wLength=%d\n", UGETW(buf->wValue),
+                   UGETW(buf->wIndex), UGETW(buf->wLength));
+       }
+#endif
+}
+
 
 /*  COPYRIGHT (C) 1986 Gary S. Brown.  You may use this program, or
  *  code or tables extracted from it, as desired without restriction.
@@ -839,5 +993,5 @@
        while (size--)
                crc = cdce_crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
 
-       return (crc ^ ~0U);
+       return (htole32(crc) ^ ~0U);
 }
Index: if_cdcereg.h
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/if_cdcereg.h,v
retrieving revision 1.3
diff -u -r1.3 if_cdcereg.h
--- if_cdcereg.h        22 May 2008 01:21:18 -0000      1.3
+++ if_cdcereg.h        19 May 2009 15:19:57 -0000
@@ -75,6 +75,10 @@
        usbd_device_handle       cdce_udev;
        usbd_interface_handle    cdce_ctl_iface;
        usbd_interface_handle    cdce_data_iface;
+       int                      cdce_intr_no;
+       usbd_pipe_handle         cdce_intr_pipe;
+       usb_cdc_notification_t   cdce_intr_buf;
+       int                      cdce_intr_size;
        int                      cdce_bulkin_no;
        usbd_pipe_handle         cdce_bulkin_pipe;
        int                      cdce_bulkout_no;


Home | Main Index | Thread Index | Old Index