Lines Matching +full:dp +full:- +full:usb
3 /*-
4 * SPDX-License-Identifier: BSD-4-Clause
6 * Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul <wpaul@windriver.com>
7 * Copyright (c) 2003-2005 Craig Boston
23 * 4. Neither the name of the author nor the names of any co-contributors
41 * USB Communication Device Class (Ethernet Networking Control Model)
42 * http://www.usb.org/developers/devclass_docs/usbcdc11.pdf
46 * USB Network Control Model (NCM)
47 * http://www.usb.org/developers/devclass_docs/NCM10.zip
73 #include <dev/usb/usb.h>
74 #include <dev/usb/usbdi.h>
75 #include <dev/usb/usbdi_util.h>
76 #include <dev/usb/usb_cdc.h>
80 #include <dev/usb/usb_debug.h>
81 #include <dev/usb/usb_process.h>
82 #include <dev/usb/usb_msctest.h>
85 #include <dev/usb/net/usb_ethernet.h>
86 #include <dev/usb/net/if_cdcereg.h>
124 "USB CDC-Ethernet");
240 /* USB interface */
307 MODULE_DEPEND(cdce, usb, 1, 1, 1);
324 /*------------------------------------------------------------------------*
330 *------------------------------------------------------------------------*/
340 ufd = usbd_find_descriptor(sc->sc_ue.ue_udev, NULL, in cdce_ncm_init()
341 sc->sc_ifaces_index[1], UDESC_CS_INTERFACE, 0xFF, in cdce_ncm_init()
346 if (ufd->bLength < sizeof(*ufd)) in cdce_ncm_init()
355 req.wIndex[0] = sc->sc_ifaces_index[1]; in cdce_ncm_init()
359 err = usbd_do_request_flags(sc->sc_ue.ue_udev, NULL, &req, in cdce_ncm_init()
366 if (usbd_get_mode(sc->sc_ue.ue_udev) == USB_MODE_HOST) { in cdce_ncm_init()
367 sc->sc_ncm.rx_max = UGETDW(temp.dwNtbInMaxSize); in cdce_ncm_init()
368 sc->sc_ncm.tx_max = UGETDW(temp.dwNtbOutMaxSize); in cdce_ncm_init()
369 sc->sc_ncm.tx_remainder = UGETW(temp.wNdpOutPayloadRemainder); in cdce_ncm_init()
370 sc->sc_ncm.tx_modulus = UGETW(temp.wNdpOutDivisor); in cdce_ncm_init()
371 sc->sc_ncm.tx_struct_align = UGETW(temp.wNdpOutAlignment); in cdce_ncm_init()
372 sc->sc_ncm.tx_nframe = UGETW(temp.wNtbOutMaxDatagrams); in cdce_ncm_init()
374 sc->sc_ncm.rx_max = UGETDW(temp.dwNtbOutMaxSize); in cdce_ncm_init()
375 sc->sc_ncm.tx_max = UGETDW(temp.dwNtbInMaxSize); in cdce_ncm_init()
376 sc->sc_ncm.tx_remainder = UGETW(temp.wNdpInPayloadRemainder); in cdce_ncm_init()
377 sc->sc_ncm.tx_modulus = UGETW(temp.wNdpInDivisor); in cdce_ncm_init()
378 sc->sc_ncm.tx_struct_align = UGETW(temp.wNdpInAlignment); in cdce_ncm_init()
379 sc->sc_ncm.tx_nframe = UGETW(temp.wNtbOutMaxDatagrams); in cdce_ncm_init()
384 if ((sc->sc_ncm.rx_max < 32) || in cdce_ncm_init()
385 (sc->sc_ncm.rx_max > CDCE_NCM_RX_MAXLEN)) { in cdce_ncm_init()
387 sc->sc_ncm.rx_max = CDCE_NCM_RX_MAXLEN; in cdce_ncm_init()
392 if ((sc->sc_ncm.tx_max < 32) || in cdce_ncm_init()
393 (sc->sc_ncm.tx_max > CDCE_NCM_TX_MAXLEN)) { in cdce_ncm_init()
395 sc->sc_ncm.tx_max = CDCE_NCM_TX_MAXLEN; in cdce_ncm_init()
400 * - power of two in cdce_ncm_init()
401 * - not greater than the maximum transmit length in cdce_ncm_init()
402 * - not less than four bytes in cdce_ncm_init()
404 if ((sc->sc_ncm.tx_struct_align < 4) || in cdce_ncm_init()
405 (sc->sc_ncm.tx_struct_align != in cdce_ncm_init()
406 ((-sc->sc_ncm.tx_struct_align) & sc->sc_ncm.tx_struct_align)) || in cdce_ncm_init()
407 (sc->sc_ncm.tx_struct_align >= sc->sc_ncm.tx_max)) { in cdce_ncm_init()
409 sc->sc_ncm.tx_struct_align = 4; in cdce_ncm_init()
414 * - power of two in cdce_ncm_init()
415 * - not greater than the maximum transmit length in cdce_ncm_init()
416 * - not less than four bytes in cdce_ncm_init()
418 if ((sc->sc_ncm.tx_modulus < 4) || in cdce_ncm_init()
419 (sc->sc_ncm.tx_modulus != in cdce_ncm_init()
420 ((-sc->sc_ncm.tx_modulus) & sc->sc_ncm.tx_modulus)) || in cdce_ncm_init()
421 (sc->sc_ncm.tx_modulus >= sc->sc_ncm.tx_max)) { in cdce_ncm_init()
423 sc->sc_ncm.tx_modulus = 4; in cdce_ncm_init()
428 if ((sc->sc_ncm.tx_remainder >= sc->sc_ncm.tx_modulus)) { in cdce_ncm_init()
430 sc->sc_ncm.tx_remainder = 0; in cdce_ncm_init()
438 sc->sc_ncm.tx_remainder = in cdce_ncm_init()
439 (sc->sc_ncm.tx_remainder - ETHER_HDR_LEN) & in cdce_ncm_init()
440 (sc->sc_ncm.tx_modulus - 1); in cdce_ncm_init()
444 if (sc->sc_ncm.tx_nframe == 0 || in cdce_ncm_init()
445 sc->sc_ncm.tx_nframe > (CDCE_NCM_SUBFRAMES_MAX - 1)) { in cdce_ncm_init()
447 "subframes: %u units\n", CDCE_NCM_SUBFRAMES_MAX - 1); in cdce_ncm_init()
449 sc->sc_ncm.tx_nframe = (CDCE_NCM_SUBFRAMES_MAX - 1); in cdce_ncm_init()
457 req.wIndex[0] = sc->sc_ifaces_index[1]; in cdce_ncm_init()
461 (ufd->bmNetworkCapabilities & UCDC_NCM_CAP_MAX_DGRAM)) { in cdce_ncm_init()
463 USETDW(value, sc->sc_ncm.rx_max); in cdce_ncm_init()
464 USETW(value + 4, (CDCE_NCM_SUBFRAMES_MAX - 1)); in cdce_ncm_init()
468 USETDW(value, sc->sc_ncm.rx_max); in cdce_ncm_init()
471 err = usbd_do_request_flags(sc->sc_ue.ue_udev, NULL, &req, in cdce_ncm_init()
475 "to %u failed.\n", sc->sc_ncm.rx_max); in cdce_ncm_init()
481 req.wIndex[0] = sc->sc_ifaces_index[1]; in cdce_ncm_init()
485 err = usbd_do_request_flags(sc->sc_ue.ue_udev, NULL, &req, in cdce_ncm_init()
493 USETW(req.wValue, 0); /* NTB-16 */ in cdce_ncm_init()
494 req.wIndex[0] = sc->sc_ifaces_index[1]; in cdce_ncm_init()
498 err = usbd_do_request_flags(sc->sc_ue.ue_udev, NULL, &req, in cdce_ncm_init()
501 DPRINTFN(1, "Setting NTB format to 16-bit failed.\n"); in cdce_ncm_init()
515 if (uaa->dev_state != UAA_DEV_READY) in cdce_test_autoinst()
521 id = iface->idesc; in cdce_test_autoinst()
522 if (id == NULL || id->bInterfaceClass != UICLASS_MASS) in cdce_test_autoinst()
529 uaa->dev_state = UAA_DEV_EJECTING; in cdce_test_autoinst()
565 /* no-op */ in cdce_attach_post()
583 if ((sc->sc_flags & CDCE_FLAG_VLAN) == CDCE_FLAG_VLAN) in cdce_attach_post_sub()
589 ifmedia_init(&sc->sc_media, IFM_IMASK, cdce_media_change_cb, in cdce_attach_post_sub()
591 ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL); in cdce_attach_post_sub()
592 ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO); in cdce_attach_post_sub()
593 sc->sc_media.ifm_media = sc->sc_media.ifm_cur->ifm_media; in cdce_attach_post_sub()
605 struct usb_ether *ue = &sc->sc_ue; in cdce_attach()
618 sc->sc_flags = USB_GET_DRIVER_INFO(uaa); in cdce_attach()
619 sc->sc_ue.ue_udev = uaa->device; in cdce_attach()
623 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF); in cdce_attach()
626 (uaa->device, NULL, uaa->info.bIfaceIndex, in cdce_attach()
629 if ((ud == NULL) || (ud->bLength < sizeof(*ud)) || in cdce_attach()
630 (sc->sc_flags & CDCE_FLAG_NO_UNION)) { in cdce_attach()
632 sc->sc_ifaces_index[0] = uaa->info.bIfaceIndex; in cdce_attach()
633 sc->sc_ifaces_index[1] = uaa->info.bIfaceIndex; in cdce_attach()
636 data_iface_no = ud->bSlaveInterface[0]; in cdce_attach()
639 iface = usbd_get_iface(uaa->device, i); in cdce_attach()
644 if (id && (id->bInterfaceNumber == data_iface_no)) { in cdce_attach()
645 sc->sc_ifaces_index[0] = i; in cdce_attach()
646 sc->sc_ifaces_index[1] = uaa->info.bIfaceIndex; in cdce_attach()
647 usbd_set_parent_iface(uaa->device, i, uaa->info.bIfaceIndex); in cdce_attach()
684 error = usbd_set_alt_interface_index(uaa->device, in cdce_attach()
685 sc->sc_ifaces_index[0], i); in cdce_attach()
692 error = usbd_transfer_setup(uaa->device, in cdce_attach()
693 sc->sc_ifaces_index, sc->sc_xfer, in cdce_attach()
694 pcfg, CDCE_N_TRANSFER, sc, &sc->sc_mtx); in cdce_attach()
707 (uaa->device, NULL, uaa->info.bIfaceIndex, in cdce_attach()
710 if ((ued == NULL) || (ued->bLength < sizeof(*ued))) { in cdce_attach()
717 DPRINTF("max segsize: %d\n", UGETW(ued->wMaxSegmentSize)); in cdce_attach()
718 if (UGETW(ued->wMaxSegmentSize) >= (ETHER_MAX_LEN - ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN)) in cdce_attach()
719 sc->sc_flags |= CDCE_FLAG_VLAN; in cdce_attach()
721 error = usbd_req_get_string_any(uaa->device, NULL, in cdce_attach()
722 eaddr_str, sizeof(eaddr_str), ued->iMacAddress); in cdce_attach()
730 sc->sc_ue.ue_eaddr[0] = 0x2a; in cdce_attach()
731 memcpy(&sc->sc_ue.ue_eaddr[1], &seed, sizeof(uint32_t)); in cdce_attach()
732 sc->sc_ue.ue_eaddr[5] = device_get_unit(dev); in cdce_attach()
735 memset(sc->sc_ue.ue_eaddr, 0, sizeof(sc->sc_ue.ue_eaddr)); in cdce_attach()
741 c -= '0'; in cdce_attach()
743 c -= 'A' - 10; in cdce_attach()
751 sc->sc_ue.ue_eaddr[i / 2] |= c; in cdce_attach()
754 if (uaa->usb_mode == USB_MODE_DEVICE) { in cdce_attach()
758 sc->sc_ue.ue_eaddr[5] ^= 0xFF; in cdce_attach()
762 ue->ue_sc = sc; in cdce_attach()
763 ue->ue_dev = dev; in cdce_attach()
764 ue->ue_udev = uaa->device; in cdce_attach()
765 ue->ue_mtx = &sc->sc_mtx; in cdce_attach()
766 ue->ue_methods = &cdce_ue_methods; in cdce_attach()
784 struct usb_ether *ue = &sc->sc_ue; in cdce_detach()
786 /* stop all USB transfers first */ in cdce_detach()
787 usbd_transfer_unsetup(sc->sc_xfer, CDCE_N_TRANSFER); in cdce_detach()
789 mtx_destroy(&sc->sc_mtx); in cdce_detach()
791 ifmedia_removeall(&sc->sc_media); in cdce_detach()
802 * Start the USB transfers, if not already started: in cdce_start()
804 usbd_transfer_start(sc->sc_xfer[CDCE_BULK_TX]); in cdce_start()
805 usbd_transfer_start(sc->sc_xfer[CDCE_BULK_RX]); in cdce_start()
821 error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, command); in cdce_ioctl()
857 ifmr->ifm_active = IFM_ETHER; in cdce_media_status_cb()
858 ifmr->ifm_status = IFM_AVALID; in cdce_media_status_cb()
859 ifmr->ifm_status |= in cdce_media_status_cb()
867 if_t ifp = uether_getifp(&sc->sc_ue); in cdce_bulk_write_callback()
886 cdce_free_queue(sc->sc_tx_buf, CDCE_FRAMES_MAX); in cdce_bulk_write_callback()
897 if (sc->sc_flags & CDCE_FLAG_ZAURUS) { in cdce_bulk_write_callback()
899 * Zaurus wants a 32-bit CRC appended in cdce_bulk_write_callback()
903 crc = cdce_m_crc32(m, 0, m->m_pkthdr.len); in cdce_bulk_write_callback()
912 if (m->m_len != m->m_pkthdr.len) { in cdce_bulk_write_callback()
921 if (m->m_pkthdr.len > MCLBYTES) { in cdce_bulk_write_callback()
922 m->m_pkthdr.len = MCLBYTES; in cdce_bulk_write_callback()
924 sc->sc_tx_buf[x] = m; in cdce_bulk_write_callback()
925 usbd_xfer_set_frame_data(xfer, x, m->m_data, m->m_len); in cdce_bulk_write_callback()
945 cdce_free_queue(sc->sc_tx_buf, CDCE_FRAMES_MAX); in cdce_bulk_write_callback()
951 if (usbd_get_mode(sc->sc_ue.ue_udev) == USB_MODE_HOST) { in cdce_bulk_write_callback()
990 usbd_transfer_start(sc->sc_xfer[CDCE_INTR_RX]); in cdce_init()
991 usbd_transfer_start(sc->sc_xfer[CDCE_INTR_TX]); in cdce_init()
994 * Stall data write direction, which depends on USB mode. in cdce_init()
996 * Some USB host stacks (e.g. Mac OS X) don't clears stall in cdce_init()
999 if (usbd_get_mode(sc->sc_ue.ue_udev) == USB_MODE_HOST) in cdce_init()
1000 usbd_xfer_set_stall(sc->sc_xfer[CDCE_BULK_TX]); in cdce_init()
1019 usbd_transfer_stop(sc->sc_xfer[CDCE_BULK_RX]); in cdce_stop()
1020 usbd_transfer_stop(sc->sc_xfer[CDCE_BULK_TX]); in cdce_stop()
1021 usbd_transfer_stop(sc->sc_xfer[CDCE_INTR_RX]); in cdce_stop()
1022 usbd_transfer_stop(sc->sc_xfer[CDCE_INTR_TX]); in cdce_stop()
1056 req.wIndex[0] = sc->sc_ifaces_index[1]; in cdce_set_filter()
1065 usbd_do_request(sc->sc_ue.ue_udev, &sc->sc_mtx, &req, NULL); in cdce_set_filter()
1100 m = sc->sc_rx_buf[x]; in cdce_bulk_read_callback()
1101 sc->sc_rx_buf[x] = NULL; in cdce_bulk_read_callback()
1105 if ((sc->sc_flags & CDCE_FLAG_ZAURUS) && len >= 14) in cdce_bulk_read_callback()
1106 len -= 4; in cdce_bulk_read_callback()
1113 uether_rxmbuf(&sc->sc_ue, m, len); in cdce_bulk_read_callback()
1120 * when the USB hardware supports it. in cdce_bulk_read_callback()
1123 if (sc->sc_rx_buf[x] == NULL) { in cdce_bulk_read_callback()
1127 sc->sc_rx_buf[x] = m; in cdce_bulk_read_callback()
1129 m = sc->sc_rx_buf[x]; in cdce_bulk_read_callback()
1132 usbd_xfer_set_frame_data(xfer, x, m->m_data, m->m_len); in cdce_bulk_read_callback()
1138 uether_rxflush(&sc->sc_ue); in cdce_bulk_read_callback()
1147 if (usbd_get_mode(sc->sc_ue.ue_udev) == USB_MODE_HOST) { in cdce_bulk_read_callback()
1156 /* need to free the RX-mbufs when we are cancelled */ in cdce_bulk_read_callback()
1157 cdce_free_queue(sc->sc_rx_buf, CDCE_FRAMES_MAX); in cdce_bulk_read_callback()
1174 ifp = uether_getifp(&sc->sc_ue); in cdce_intr_read_callback()
1187 while (actlen - off >= UCDC_NOTIFICATION_LENGTH) { in cdce_intr_read_callback()
1239 if (usbd_get_mode(sc->sc_ue.ue_udev) == USB_MODE_HOST) in cdce_intr_read_callback()
1263 switch (sc->sc_notify_state) { in cdce_intr_write_callback()
1265 sc->sc_notify_state = CDCE_NOTIFY_SPEED_CHANGE; in cdce_intr_write_callback()
1268 sc->sc_notify_state = CDCE_NOTIFY_DONE; in cdce_intr_write_callback()
1278 * Inform host about connection. Required according to USB CDC in cdce_intr_write_callback()
1279 * specification and communicating to Mac OS X USB host stack. in cdce_intr_write_callback()
1282 if (sc->sc_notify_state == CDCE_NOTIFY_NETWORK_CONNECTION) { in cdce_intr_write_callback()
1285 req.wIndex[0] = sc->sc_ifaces_index[1]; in cdce_intr_write_callback()
1296 } else if (sc->sc_notify_state == CDCE_NOTIFY_SPEED_CHANGE) { in cdce_intr_write_callback()
1299 req.wIndex[0] = sc->sc_ifaces_index[1]; in cdce_intr_write_callback()
1305 if (usbd_get_speed(sc->sc_ue.ue_udev) != USB_SPEED_FULL) in cdce_intr_write_callback()
1323 if (usbd_get_mode(sc->sc_ue.ue_udev) == USB_MODE_HOST) { in cdce_intr_write_callback()
1346 if (req->bmRequestType == UT_WRITE_CLASS_INTERFACE && \ in cdce_handle_request()
1347 req->bRequest == UCDC_NCM_SET_ETHERNET_PACKET_FILTER) { in cdce_handle_request()
1349 mtx_lock(&sc->sc_mtx); in cdce_handle_request()
1350 sc->sc_notify_state = CDCE_NOTIFY_SPEED_CHANGE; in cdce_handle_request()
1351 usbd_transfer_start(sc->sc_xfer[CDCE_INTR_TX]); in cdce_handle_request()
1352 mtx_unlock(&sc->sc_mtx); in cdce_handle_request()
1371 usbd_frame_zero(pc, start, end - start); in cdce_ncm_tx_zero()
1378 if_t ifp = uether_getifp(&sc->sc_ue); in cdce_ncm_fill_tx_frames()
1389 offset = sizeof(sc->sc_ncm.hdr) + in cdce_ncm_fill_tx_frames()
1390 sizeof(sc->sc_ncm.dpt) + sizeof(sc->sc_ncm.dp); in cdce_ncm_fill_tx_frames()
1396 offset = CDCE_NCM_ALIGN(sc->sc_ncm.tx_remainder, in cdce_ncm_fill_tx_frames()
1397 offset, sc->sc_ncm.tx_modulus); in cdce_ncm_fill_tx_frames()
1405 for (n = 0; n != sc->sc_ncm.tx_nframe; n++) { in cdce_ncm_fill_tx_frames()
1408 if (offset >= sc->sc_ncm.tx_max) in cdce_ncm_fill_tx_frames()
1413 rem = sc->sc_ncm.tx_max - offset; in cdce_ncm_fill_tx_frames()
1423 if (m->m_pkthdr.len > (int)rem) { in cdce_ncm_fill_tx_frames()
1429 n--; in cdce_ncm_fill_tx_frames()
1436 usbd_m_copy_in(pc, offset, m, 0, m->m_pkthdr.len); in cdce_ncm_fill_tx_frames()
1438 USETW(sc->sc_ncm.dp[n].wFrameLength, m->m_pkthdr.len); in cdce_ncm_fill_tx_frames()
1439 USETW(sc->sc_ncm.dp[n].wFrameIndex, offset); in cdce_ncm_fill_tx_frames()
1442 offset += m->m_pkthdr.len; in cdce_ncm_fill_tx_frames()
1448 offset = CDCE_NCM_ALIGN(sc->sc_ncm.tx_remainder, in cdce_ncm_fill_tx_frames()
1449 offset, sc->sc_ncm.tx_modulus); in cdce_ncm_fill_tx_frames()
1464 /* Pre-increment interface counter */ in cdce_ncm_fill_tx_frames()
1472 rem = (sizeof(sc->sc_ncm.dpt) + (4 * n) + 4); in cdce_ncm_fill_tx_frames()
1474 USETW(sc->sc_ncm.dpt.wLength, rem); in cdce_ncm_fill_tx_frames()
1478 USETW(sc->sc_ncm.dp[n].wFrameLength, 0); in cdce_ncm_fill_tx_frames()
1479 USETW(sc->sc_ncm.dp[n].wFrameIndex, 0); in cdce_ncm_fill_tx_frames()
1488 if (offset >= sc->sc_ncm.tx_max) in cdce_ncm_fill_tx_frames()
1489 offset = sc->sc_ncm.tx_max; in cdce_ncm_fill_tx_frames()
1499 /* Fill out 16-bit header */ in cdce_ncm_fill_tx_frames()
1500 sc->sc_ncm.hdr.dwSignature[0] = 'N'; in cdce_ncm_fill_tx_frames()
1501 sc->sc_ncm.hdr.dwSignature[1] = 'C'; in cdce_ncm_fill_tx_frames()
1502 sc->sc_ncm.hdr.dwSignature[2] = 'M'; in cdce_ncm_fill_tx_frames()
1503 sc->sc_ncm.hdr.dwSignature[3] = 'H'; in cdce_ncm_fill_tx_frames()
1504 USETW(sc->sc_ncm.hdr.wHeaderLength, sizeof(sc->sc_ncm.hdr)); in cdce_ncm_fill_tx_frames()
1505 USETW(sc->sc_ncm.hdr.wBlockLength, offset); in cdce_ncm_fill_tx_frames()
1506 USETW(sc->sc_ncm.hdr.wSequence, sc->sc_ncm.tx_seq); in cdce_ncm_fill_tx_frames()
1507 USETW(sc->sc_ncm.hdr.wDptIndex, sizeof(sc->sc_ncm.hdr)); in cdce_ncm_fill_tx_frames()
1509 sc->sc_ncm.tx_seq++; in cdce_ncm_fill_tx_frames()
1511 /* Fill out 16-bit frame table header */ in cdce_ncm_fill_tx_frames()
1512 sc->sc_ncm.dpt.dwSignature[0] = 'N'; in cdce_ncm_fill_tx_frames()
1513 sc->sc_ncm.dpt.dwSignature[1] = 'C'; in cdce_ncm_fill_tx_frames()
1514 sc->sc_ncm.dpt.dwSignature[2] = 'M'; in cdce_ncm_fill_tx_frames()
1515 sc->sc_ncm.dpt.dwSignature[3] = '0'; in cdce_ncm_fill_tx_frames()
1516 USETW(sc->sc_ncm.dpt.wNextNdpIndex, 0); /* reserved */ in cdce_ncm_fill_tx_frames()
1518 usbd_copy_in(pc, 0, &(sc->sc_ncm.hdr), sizeof(sc->sc_ncm.hdr)); in cdce_ncm_fill_tx_frames()
1519 usbd_copy_in(pc, sizeof(sc->sc_ncm.hdr), &(sc->sc_ncm.dpt), in cdce_ncm_fill_tx_frames()
1520 sizeof(sc->sc_ncm.dpt)); in cdce_ncm_fill_tx_frames()
1521 usbd_copy_in(pc, sizeof(sc->sc_ncm.hdr) + sizeof(sc->sc_ncm.dpt), in cdce_ncm_fill_tx_frames()
1522 &(sc->sc_ncm.dp), sizeof(sc->sc_ncm.dp)); in cdce_ncm_fill_tx_frames()
1530 if_t ifp = uether_getifp(&sc->sc_ue); in cdce_ncm_bulk_write_callback()
1572 if (usbd_get_mode(sc->sc_ue.ue_udev) == USB_MODE_HOST) { in cdce_ncm_bulk_write_callback()
1588 if_t ifp = uether_getifp(&sc->sc_ue); in cdce_ncm_bulk_read_callback()
1607 if (actlen < (int)(sizeof(sc->sc_ncm.hdr) + in cdce_ncm_bulk_read_callback()
1608 sizeof(sc->sc_ncm.dpt))) { in cdce_ncm_bulk_read_callback()
1612 usbd_copy_out(pc, 0, &(sc->sc_ncm.hdr), in cdce_ncm_bulk_read_callback()
1613 sizeof(sc->sc_ncm.hdr)); in cdce_ncm_bulk_read_callback()
1615 if ((sc->sc_ncm.hdr.dwSignature[0] != 'N') || in cdce_ncm_bulk_read_callback()
1616 (sc->sc_ncm.hdr.dwSignature[1] != 'C') || in cdce_ncm_bulk_read_callback()
1617 (sc->sc_ncm.hdr.dwSignature[2] != 'M') || in cdce_ncm_bulk_read_callback()
1618 (sc->sc_ncm.hdr.dwSignature[3] != 'H')) { in cdce_ncm_bulk_read_callback()
1621 sc->sc_ncm.hdr.dwSignature[0], in cdce_ncm_bulk_read_callback()
1622 sc->sc_ncm.hdr.dwSignature[1], in cdce_ncm_bulk_read_callback()
1623 sc->sc_ncm.hdr.dwSignature[2], in cdce_ncm_bulk_read_callback()
1624 sc->sc_ncm.hdr.dwSignature[3]); in cdce_ncm_bulk_read_callback()
1627 temp = UGETW(sc->sc_ncm.hdr.wBlockLength); in cdce_ncm_bulk_read_callback()
1633 temp = UGETW(sc->sc_ncm.hdr.wDptIndex); in cdce_ncm_bulk_read_callback()
1634 if ((int)(temp + sizeof(sc->sc_ncm.dpt)) > actlen) { in cdce_ncm_bulk_read_callback()
1638 usbd_copy_out(pc, temp, &(sc->sc_ncm.dpt), in cdce_ncm_bulk_read_callback()
1639 sizeof(sc->sc_ncm.dpt)); in cdce_ncm_bulk_read_callback()
1641 if ((sc->sc_ncm.dpt.dwSignature[0] != 'N') || in cdce_ncm_bulk_read_callback()
1642 (sc->sc_ncm.dpt.dwSignature[1] != 'C') || in cdce_ncm_bulk_read_callback()
1643 (sc->sc_ncm.dpt.dwSignature[2] != 'M') || in cdce_ncm_bulk_read_callback()
1644 (sc->sc_ncm.dpt.dwSignature[3] != '0')) { in cdce_ncm_bulk_read_callback()
1647 sc->sc_ncm.dpt.dwSignature[0], in cdce_ncm_bulk_read_callback()
1648 sc->sc_ncm.dpt.dwSignature[1], in cdce_ncm_bulk_read_callback()
1649 sc->sc_ncm.dpt.dwSignature[2], in cdce_ncm_bulk_read_callback()
1650 sc->sc_ncm.dpt.dwSignature[3]); in cdce_ncm_bulk_read_callback()
1653 nframes = UGETW(sc->sc_ncm.dpt.wLength) / 4; in cdce_ncm_bulk_read_callback()
1657 nframes -= (2 + 1); in cdce_ncm_bulk_read_callback()
1663 temp += sizeof(sc->sc_ncm.dpt); in cdce_ncm_bulk_read_callback()
1673 usbd_copy_out(pc, temp, &(sc->sc_ncm.dp), (4 * nframes)); in cdce_ncm_bulk_read_callback()
1678 offset = UGETW(sc->sc_ncm.dp[x].wFrameIndex); in cdce_ncm_bulk_read_callback()
1679 temp = UGETW(sc->sc_ncm.dp[x].wFrameLength); in cdce_ncm_bulk_read_callback()
1683 (temp > (MCLBYTES - ETHER_ALIGN))) { in cdce_ncm_bulk_read_callback()
1694 } else if (temp > (int)(MHLEN - ETHER_ALIGN)) { in cdce_ncm_bulk_read_callback()
1705 m->m_len = m->m_pkthdr.len = temp + ETHER_ALIGN; in cdce_ncm_bulk_read_callback()
1708 usbd_copy_out(pc, offset, m->m_data, temp); in cdce_ncm_bulk_read_callback()
1711 uether_rxmbuf(&sc->sc_ue, m, temp); in cdce_ncm_bulk_read_callback()
1723 usbd_xfer_set_frame_len(xfer, 0, sc->sc_ncm.rx_max); in cdce_ncm_bulk_read_callback()
1726 uether_rxflush(&sc->sc_ue); /* must be last */ in cdce_ncm_bulk_read_callback()
1735 if (usbd_get_mode(sc->sc_ue.ue_udev) == USB_MODE_HOST) { in cdce_ncm_bulk_read_callback()