Lines Matching +full:usb +full:- +full:misc +full:- +full:reg

1 /*-
2 * Copyright (c) 2015-2016 Kevin Lo <kevlo@FreeBSD.org>
51 #include <dev/usb/usb.h>
52 #include <dev/usb/usbdi.h>
53 #include <dev/usb/usbdi_util.h>
57 #include <dev/usb/usb_debug.h>
58 #include <dev/usb/usb_process.h>
60 #include <dev/usb/net/usb_ethernet.h>
61 #include <dev/usb/net/if_urereg.h>
71 "USB ure");
195 MODULE_DEPEND(ure, usb, 1, 1, 1);
214 #define URE_SETBIT_1(sc, reg, index, x) \ argument
215 ure_write_1(sc, reg, index, ure_read_1(sc, reg, index) | (x))
216 #define URE_SETBIT_2(sc, reg, index, x) \ argument
217 ure_write_2(sc, reg, index, ure_read_2(sc, reg, index) | (x))
218 #define URE_SETBIT_4(sc, reg, index, x) \ argument
219 ure_write_4(sc, reg, index, ure_read_4(sc, reg, index) | (x))
221 #define URE_CLRBIT_1(sc, reg, index, x) \ argument
222 ure_write_1(sc, reg, index, ure_read_1(sc, reg, index) & ~(x))
223 #define URE_CLRBIT_2(sc, reg, index, x) \ argument
224 ure_write_2(sc, reg, index, ure_read_2(sc, reg, index) & ~(x))
225 #define URE_CLRBIT_4(sc, reg, index, x) \ argument
226 ure_write_4(sc, reg, index, ure_read_4(sc, reg, index) & ~(x))
245 return (uether_do_request(&sc->sc_ue, &req, buf, 1000)); in ure_ctl()
265 ure_read_1(struct ure_softc *sc, uint16_t reg, uint16_t index) in ure_read_1() argument
271 shift = (reg & 3) << 3; in ure_read_1()
272 reg &= ~3; in ure_read_1()
274 ure_read_mem(sc, reg, index, &temp, 4); in ure_read_1()
282 ure_read_2(struct ure_softc *sc, uint16_t reg, uint16_t index) in ure_read_2() argument
288 shift = (reg & 2) << 3; in ure_read_2()
289 reg &= ~3; in ure_read_2()
291 ure_read_mem(sc, reg, index, &temp, 4); in ure_read_2()
299 ure_read_4(struct ure_softc *sc, uint16_t reg, uint16_t index) in ure_read_4() argument
303 ure_read_mem(sc, reg, index, &temp, 4); in ure_read_4()
308 ure_write_1(struct ure_softc *sc, uint16_t reg, uint16_t index, uint32_t val) in ure_write_1() argument
315 shift = reg & 3; in ure_write_1()
318 if (reg & 3) { in ure_write_1()
321 reg &= ~3; in ure_write_1()
325 return (ure_write_mem(sc, reg, index | byen, &temp, 4)); in ure_write_1()
329 ure_write_2(struct ure_softc *sc, uint16_t reg, uint16_t index, uint32_t val) in ure_write_2() argument
336 shift = reg & 2; in ure_write_2()
339 if (reg & 2) { in ure_write_2()
342 reg &= ~3; in ure_write_2()
346 return (ure_write_mem(sc, reg, index | byen, &temp, 4)); in ure_write_2()
350 ure_write_4(struct ure_softc *sc, uint16_t reg, uint16_t index, uint32_t val) in ure_write_4() argument
355 return (ure_write_mem(sc, reg, index | URE_BYTE_EN_DWORD, &temp, 4)); in ure_write_4()
361 uint16_t reg; in ure_ocp_reg_read() local
364 reg = (addr & 0x0fff) | 0xb000; in ure_ocp_reg_read()
366 return (ure_read_2(sc, reg, URE_MCU_TYPE_PLA)); in ure_ocp_reg_read()
372 uint16_t reg; in ure_ocp_reg_write() local
375 reg = (addr & 0x0fff) | 0xb000; in ure_ocp_reg_write()
377 ure_write_2(sc, reg, URE_MCU_TYPE_PLA, data); in ure_ocp_reg_write()
388 ure_miibus_readreg(device_t dev, int phy, int reg) in ure_miibus_readreg() argument
395 locked = mtx_owned(&sc->sc_mtx); in ure_miibus_readreg()
400 if (reg == URE_GMEDIASTAT) { in ure_miibus_readreg()
406 val = ure_ocp_reg_read(sc, URE_OCP_BASE_MII + reg * 2); in ure_miibus_readreg()
414 ure_miibus_writereg(device_t dev, int phy, int reg, int val) in ure_miibus_writereg() argument
420 if (sc->sc_phyno != phy) in ure_miibus_writereg()
423 locked = mtx_owned(&sc->sc_mtx); in ure_miibus_writereg()
427 ure_ocp_reg_write(sc, URE_OCP_BASE_MII + reg * 2, val); in ure_miibus_writereg()
444 locked = mtx_owned(&sc->sc_mtx); in ure_miibus_statchg()
448 ifp = uether_getifp(&sc->sc_ue); in ure_miibus_statchg()
453 sc->sc_flags &= ~URE_FLAG_LINK; in ure_miibus_statchg()
454 if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == in ure_miibus_statchg()
456 switch (IFM_SUBTYPE(mii->mii_media_active)) { in ure_miibus_statchg()
459 sc->sc_flags |= URE_FLAG_LINK; in ure_miibus_statchg()
460 sc->sc_rxstarted = 0; in ure_miibus_statchg()
463 if ((sc->sc_flags & URE_FLAG_8152) != 0) in ure_miibus_statchg()
465 sc->sc_flags |= URE_FLAG_LINK; in ure_miibus_statchg()
466 sc->sc_rxstarted = 0; in ure_miibus_statchg()
474 if ((sc->sc_flags & URE_FLAG_LINK) == 0) in ure_miibus_statchg()
490 if (uaa->usb_mode != USB_MODE_HOST) in ure_probe()
492 if (uaa->info.bIfaceIndex != URE_IFACE_IDX) in ure_probe()
507 struct usb_ether *ue = &sc->sc_ue; in ure_attach()
514 sc->sc_flags = USB_GET_DRIVER_INFO(uaa); in ure_attach()
516 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF); in ure_attach()
520 if (sc->sc_flags & (URE_FLAG_8153 | URE_FLAG_8153B)) in ure_attach()
521 sc->sc_rxbufsz = URE_8153_RX_BUFSZ; in ure_attach()
522 else if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) in ure_attach()
523 sc->sc_rxbufsz = URE_8156_RX_BUFSZ; in ure_attach()
525 sc->sc_rxbufsz = URE_8152_RX_BUFSZ; in ure_attach()
532 .bufsize = sc->sc_rxbufsz, in ure_attach()
538 error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_rx_xfer, in ure_attach()
539 ure_config_rx, URE_MAX_RX, sc, &sc->sc_mtx); in ure_attach()
541 device_printf(dev, "allocating USB RX transfers failed\n"); in ure_attach()
556 error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_tx_xfer, in ure_attach()
557 ure_config_tx, URE_MAX_TX, sc, &sc->sc_mtx); in ure_attach()
559 usbd_transfer_unsetup(sc->sc_rx_xfer, URE_MAX_RX); in ure_attach()
560 device_printf(dev, "allocating USB TX transfers failed\n"); in ure_attach()
564 ue->ue_sc = sc; in ure_attach()
565 ue->ue_dev = dev; in ure_attach()
566 ue->ue_udev = uaa->device; in ure_attach()
567 ue->ue_mtx = &sc->sc_mtx; in ure_attach()
568 ue->ue_methods = &ure_ue_methods; in ure_attach()
586 struct usb_ether *ue = &sc->sc_ue; in ure_detach()
588 usbd_transfer_unsetup(sc->sc_tx_xfer, URE_MAX_TX); in ure_detach()
589 usbd_transfer_unsetup(sc->sc_rx_xfer, URE_MAX_RX); in ure_detach()
591 mtx_destroy(&sc->sc_mtx); in ure_detach()
597 * Copy from USB buffers to a new mbuf chain with pkt header.
617 m->m_pkthdr.len = len; in ure_makembuf()
619 for (mb = m; len > 0; mb = mb->m_next) { in ure_makembuf()
623 mb->m_len = tlen; in ure_makembuf()
626 len -= tlen; in ure_makembuf()
636 struct usb_ether *ue = &sc->sc_ue; in ure_bulk_read_callback()
652 DEVPRINTFN(13, sc->sc_ue.ue_dev, "rcb start\n"); in ure_bulk_read_callback()
661 actlen -= sizeof(pkt); in ure_bulk_read_callback()
665 DEVPRINTFN(13, sc->sc_ue.ue_dev, in ure_bulk_read_callback()
669 DEVPRINTFN(13, sc->sc_ue.ue_dev, "len: %d\n", len); in ure_bulk_read_callback()
690 m = ure_makembuf(pc, off, len - ETHER_CRC_LEN); in ure_bulk_read_callback()
700 m->m_pkthdr.ether_vtag = in ure_bulk_read_callback()
703 m->m_flags |= M_VLANTAG; in ure_bulk_read_callback()
709 uether_rxmbuf(ue, m, len - ETHER_CRC_LEN); in ure_bulk_read_callback()
713 actlen -= roundup(len, URE_RXPKT_ALIGN); in ure_bulk_read_callback()
715 DEVPRINTFN(13, sc->sc_ue.ue_dev, "rcb end\n"); in ure_bulk_read_callback()
742 if_t ifp = uether_getifp(&sc->sc_ue); in ure_bulk_write_callback()
759 if ((sc->sc_flags & URE_FLAG_LINK) == 0) { in ure_bulk_write_callback()
778 len = m->m_pkthdr.len; in ure_bulk_write_callback()
780 device_printf(sc->sc_ue.ue_dev, in ure_bulk_write_callback()
799 if (m->m_flags & M_VLANTAG) { in ure_bulk_write_callback()
801 bswap16(m->m_pkthdr.ether_vtag & in ure_bulk_write_callback()
805 device_printf(sc->sc_ue.ue_dev, in ure_bulk_write_callback()
811 DEVPRINTFN(13, sc->sc_ue.ue_dev, in ure_bulk_write_callback()
813 m->m_pkthdr.csum_flags, le32toh(txpkt.ure_pktlen), in ure_bulk_write_callback()
819 rem -= sizeof(txpkt); in ure_bulk_write_callback()
824 rem -= roundup(len, URE_TXPKT_ALIGN); in ure_bulk_write_callback()
856 DEVPRINTFN(12, sc->sc_ue.ue_dev, in ure_bulk_write_callback()
874 sc->sc_ver = ver; in ure_read_chipver()
877 sc->sc_chip |= URE_CHIP_VER_4C00; in ure_read_chipver()
878 sc->sc_flags = URE_FLAG_8152; in ure_read_chipver()
881 sc->sc_chip |= URE_CHIP_VER_4C10; in ure_read_chipver()
882 sc->sc_flags = URE_FLAG_8152; in ure_read_chipver()
885 sc->sc_chip |= URE_CHIP_VER_5C00; in ure_read_chipver()
886 sc->sc_flags = URE_FLAG_8153; in ure_read_chipver()
889 sc->sc_chip |= URE_CHIP_VER_5C10; in ure_read_chipver()
890 sc->sc_flags = URE_FLAG_8153; in ure_read_chipver()
893 sc->sc_chip |= URE_CHIP_VER_5C20; in ure_read_chipver()
894 sc->sc_flags = URE_FLAG_8153; in ure_read_chipver()
897 sc->sc_chip |= URE_CHIP_VER_5C30; in ure_read_chipver()
898 sc->sc_flags = URE_FLAG_8153; in ure_read_chipver()
901 sc->sc_flags = URE_FLAG_8153B; in ure_read_chipver()
902 sc->sc_chip |= URE_CHIP_VER_6000; in ure_read_chipver()
905 sc->sc_flags = URE_FLAG_8153B; in ure_read_chipver()
906 sc->sc_chip |= URE_CHIP_VER_6010; in ure_read_chipver()
909 sc->sc_flags = URE_FLAG_8156; in ure_read_chipver()
910 sc->sc_chip |= URE_CHIP_VER_7020; in ure_read_chipver()
913 sc->sc_flags = URE_FLAG_8156; in ure_read_chipver()
914 sc->sc_chip |= URE_CHIP_VER_7030; in ure_read_chipver()
917 sc->sc_flags = URE_FLAG_8156B; in ure_read_chipver()
918 sc->sc_chip |= URE_CHIP_VER_7400; in ure_read_chipver()
921 sc->sc_flags = URE_FLAG_8156B; in ure_read_chipver()
922 sc->sc_chip |= URE_CHIP_VER_7410; in ure_read_chipver()
925 device_printf(sc->sc_ue.ue_dev, in ure_read_chipver()
940 sbuf_printf(&sb, "%04x", sc->sc_ver); in ure_sysctl_chipver()
953 sc->sc_rxstarted = 0; in ure_attach_post()
954 sc->sc_phyno = 0; in ure_attach_post()
960 if (sc->sc_flags & URE_FLAG_8152) in ure_attach_post()
962 else if (sc->sc_flags & (URE_FLAG_8153B | URE_FLAG_8156 | URE_FLAG_8156B)) in ure_attach_post()
967 if ((sc->sc_chip & URE_CHIP_VER_4C00) || in ure_attach_post()
968 (sc->sc_chip & URE_CHIP_VER_4C10)) in ure_attach_post()
970 ue->ue_eaddr, 8); in ure_attach_post()
973 ue->ue_eaddr, 8); in ure_attach_post()
975 if (ETHER_IS_ZERO(sc->sc_ue.ue_eaddr)) { in ure_attach_post()
976 device_printf(sc->sc_ue.ue_dev, "MAC assigned randomly\n"); in ure_attach_post()
977 arc4rand(sc->sc_ue.ue_eaddr, ETHER_ADDR_LEN, 0); in ure_attach_post()
978 sc->sc_ue.ue_eaddr[0] &= ~0x01; /* unicast */ in ure_attach_post()
979 sc->sc_ue.ue_eaddr[0] |= 0x02; /* locally administered */ in ure_attach_post()
993 ifp = ue->ue_ifp; in ure_attach_post_sub()
1014 if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { in ure_attach_post_sub()
1015 ifmedia_init(&sc->sc_ifmedia, IFM_IMASK, ure_ifmedia_upd, in ure_attach_post_sub()
1018 ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_AUTO, 0, NULL); in ure_attach_post_sub()
1019 ifmedia_set(&sc->sc_ifmedia, IFM_ETHER | IFM_AUTO); in ure_attach_post_sub()
1020 sc->sc_ifmedia.ifm_media = IFM_ETHER | IFM_AUTO; in ure_attach_post_sub()
1024 error = mii_attach(ue->ue_dev, &ue->ue_miibus, ifp, in ure_attach_post_sub()
1025 uether_ifmedia_upd, ue->ue_methods->ue_mii_sts, in ure_attach_post_sub()
1026 BMSR_DEFCAPMASK, sc->sc_phyno, MII_OFFSET_ANY, 0); in ure_attach_post_sub()
1030 sctx = device_get_sysctl_ctx(sc->sc_ue.ue_dev); in ure_attach_post_sub()
1031 soid = device_get_sysctl_tree(sc->sc_ue.ue_dev); in ure_attach_post_sub()
1046 uint32_t reg; in ure_init() local
1056 if (sc->sc_flags & (URE_FLAG_8153B | URE_FLAG_8156 | URE_FLAG_8156B)) in ure_init()
1068 if (sc->sc_flags & URE_FLAG_8153) { in ure_init()
1069 switch (usbd_get_speed(sc->sc_ue.ue_udev)) { in ure_init()
1071 reg = URE_COALESCE_SUPER / 8; in ure_init()
1074 reg = URE_COALESCE_HIGH / 8; in ure_init()
1077 reg = URE_COALESCE_SLOW / 8; in ure_init()
1080 ure_write_2(sc, URE_USB_RX_EARLY_AGG, URE_MCU_TYPE_USB, reg); in ure_init()
1081 reg = URE_8153_RX_BUFSZ - (URE_FRAMELEN(if_getmtu(ifp)) + in ure_init()
1083 ure_write_2(sc, URE_USB_RX_EARLY_SIZE, URE_MCU_TYPE_USB, reg / 4); in ure_init()
1084 } else if (sc->sc_flags & URE_FLAG_8153B) { in ure_init()
1087 reg = URE_8153_RX_BUFSZ - (URE_FRAMELEN(if_getmtu(ifp)) + in ure_init()
1089 ure_write_2(sc, URE_USB_RX_EARLY_SIZE, URE_MCU_TYPE_USB, reg / 8); in ure_init()
1092 } else if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { in ure_init()
1095 reg = URE_8156_RX_BUFSZ - (URE_FRAMELEN(if_getmtu(ifp)) + in ure_init()
1097 ure_write_2(sc, URE_USB_RX_EARLY_SIZE, URE_MCU_TYPE_USB, reg / 8); in ure_init()
1102 if (sc->sc_flags & URE_FLAG_8156B) { in ure_init()
1104 uether_pause(&sc->sc_ue, hz / 500); in ure_init()
1115 DEVPRINTFN(12, sc->sc_ue.ue_dev, "enabled hw vlan tag\n"); in ure_init()
1118 DEVPRINTFN(12, sc->sc_ue.ue_dev, "disabled hw vlan tag\n"); in ure_init()
1131 usbd_xfer_set_stall(sc->sc_tx_xfer[0]); in ure_init()
1151 DEVPRINTFN(13, sc->sc_ue.ue_dev, in ure_tick()
1152 "rx[%d] = %d\n", i, USB_GET_STATE(sc->sc_rx_xfer[i])); in ure_tick()
1155 DEVPRINTFN(13, sc->sc_ue.ue_dev, in ure_tick()
1156 "tx[%d] = %d\n", i, USB_GET_STATE(sc->sc_tx_xfer[i])); in ure_tick()
1158 if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { in ure_tick()
1163 if ((sc->sc_flags & URE_FLAG_LINK) == 0 in ure_tick()
1164 && mii->mii_media_status & IFM_ACTIVE && in ure_tick()
1165 IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { in ure_tick()
1166 sc->sc_flags |= URE_FLAG_LINK; in ure_tick()
1167 sc->sc_rxstarted = 0; in ure_tick()
1182 hashes[1] |= (1 << (h - 32)); in ure_hash_maddr()
1187 * Program the 64-bit multicast hash filter.
1220 DEVPRINTFN(14, ue->ue_dev, "rxfilt: RCR: %#x\n", in ure_rxfilter()
1235 if (!sc->sc_rxstarted) { in ure_start()
1236 sc->sc_rxstarted = 1; in ure_start()
1238 usbd_transfer_start(sc->sc_rx_xfer[i]); in ure_start()
1242 usbd_transfer_start(sc->sc_tx_xfer[i]); in ure_start()
1256 uether_pause(&sc->sc_ue, hz / 100); in ure_reset()
1259 device_printf(sc->sc_ue.ue_dev, "reset never completed\n"); in ure_reset()
1273 int reg; in ure_ifmedia_upd() local
1278 if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { in ure_ifmedia_upd()
1279 ifm = &sc->sc_ifmedia; in ure_ifmedia_upd()
1280 if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) in ure_ifmedia_upd()
1283 locked = mtx_owned(&sc->sc_mtx); in ure_ifmedia_upd()
1286 reg = ure_ocp_reg_read(sc, 0xa5d4); in ure_ifmedia_upd()
1287 reg &= ~URE_ADV_2500TFDX; in ure_ifmedia_upd()
1290 switch (IFM_SUBTYPE(ifm->ifm_media)) { in ure_ifmedia_upd()
1294 reg |= URE_ADV_2500TFDX; in ure_ifmedia_upd()
1299 reg |= URE_ADV_2500TFDX; in ure_ifmedia_upd()
1316 device_printf(sc->sc_ue.ue_dev, "unsupported media type\n"); in ure_ifmedia_upd()
1325 ure_ocp_reg_write(sc, 0xa5d4, reg); in ure_ifmedia_upd()
1336 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) in ure_ifmedia_upd()
1353 if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { in ure_ifmedia_sts()
1355 ifmr->ifm_status = IFM_AVALID; in ure_ifmedia_sts()
1357 ifmr->ifm_status |= IFM_ACTIVE; in ure_ifmedia_sts()
1362 ifmr->ifm_active |= IFM_FDX; in ure_ifmedia_sts()
1364 ifmr->ifm_active |= IFM_HDX; in ure_ifmedia_sts()
1366 ifmr->ifm_active |= IFM_10_T; in ure_ifmedia_sts()
1368 ifmr->ifm_active |= IFM_100_TX; in ure_ifmedia_sts()
1370 ifmr->ifm_active |= IFM_1000_T; in ure_ifmedia_sts()
1372 ifmr->ifm_active |= IFM_2500_T; in ure_ifmedia_sts()
1382 ifmr->ifm_active = mii->mii_media_active; in ure_ifmedia_sts()
1383 ifmr->ifm_status = mii->mii_media_status; in ure_ifmedia_sts()
1390 ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_10_T, 0, NULL); in ure_add_media_types()
1391 ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_10_T | IFM_FDX, 0, NULL); in ure_add_media_types()
1392 ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_100_TX, 0, NULL); in ure_add_media_types()
1393 ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_100_TX | IFM_FDX, 0, NULL); in ure_add_media_types()
1394 ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL); in ure_add_media_types()
1395 ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_2500_T | IFM_FDX, 0, NULL); in ure_add_media_types()
1401 if_t ifp = uether_getifp(&sc->sc_ue); in ure_link_state()
1427 sc->sc_flags |= URE_FLAG_LINK; in ure_get_link_status()
1430 sc->sc_flags &= ~URE_FLAG_LINK; in ure_get_link_status()
1450 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in ure_ioctl()
1487 if (ifr->ifr_mtu < ETHERMIN || in ure_ioctl()
1488 ifr->ifr_mtu > (4096 - ETHER_HDR_LEN - in ure_ioctl()
1489 ETHER_VLAN_ENCAP_LEN - ETHER_CRC_LEN)) { in ure_ioctl()
1494 if (if_getmtu(ifp) != ifr->ifr_mtu) in ure_ioctl()
1495 if_setmtu(ifp, ifr->ifr_mtu); in ure_ioctl()
1501 if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) in ure_ioctl()
1502 error = ifmedia_ioctl(ifp, ifr, &sc->sc_ifmedia, cmd); in ure_ioctl()
1522 if (sc->sc_chip & URE_CHIP_VER_4C00) { in ure_rtl8152_init()
1571 uether_pause(&sc->sc_ue, hz / 100); in ure_rtl8153_init()
1574 device_printf(sc->sc_ue.ue_dev, in ure_rtl8153_init()
1582 uether_pause(&sc->sc_ue, hz / 100); in ure_rtl8153_init()
1585 device_printf(sc->sc_ue.ue_dev, in ure_rtl8153_init()
1590 if (sc->sc_chip & URE_CHIP_VER_5C10) { in ure_rtl8153_init()
1597 } else if (sc->sc_chip & URE_CHIP_VER_5C20) in ure_rtl8153_init()
1600 if (sc->sc_chip & (URE_CHIP_VER_5C20 | URE_CHIP_VER_5C30)) { in ure_rtl8153_init()
1616 if ((sc->sc_chip & URE_CHIP_VER_5C10) && in ure_rtl8153_init()
1617 usbd_get_speed(sc->sc_ue.ue_udev) != USB_SPEED_SUPER) in ure_rtl8153_init()
1652 if (!(sc->sc_chip & (URE_CHIP_VER_5C00 | URE_CHIP_VER_5C10))) in ure_rtl8153_init()
1664 if (sc->sc_chip & (URE_CHIP_VER_5C00 | URE_CHIP_VER_5C10 | in ure_rtl8153_init()
1669 if (sc->sc_chip & URE_CHIP_VER_5C00) { in ure_rtl8153_init()
1699 if (!(sc->sc_chip & (URE_CHIP_VER_5C00 | URE_CHIP_VER_5C10))) in ure_rtl8153_init()
1716 if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { in ure_rtl8153b_init()
1722 if (sc->sc_flags & URE_FLAG_8156B) { in ure_rtl8153b_init()
1732 if (sc->sc_chip == URE_CHIP_VER_7410) { in ure_rtl8153b_init()
1738 uether_pause(&sc->sc_ue, hz / 1000); in ure_rtl8153b_init()
1747 uether_pause(&sc->sc_ue, hz / 100); in ure_rtl8153b_init()
1750 device_printf(sc->sc_ue.ue_dev, in ure_rtl8153b_init()
1755 (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B))) { in ure_rtl8153b_init()
1758 if (sc->sc_flags & URE_FLAG_8156B) in ure_rtl8153b_init()
1799 if (usbd_get_speed(sc->sc_ue.ue_udev) == USB_SPEED_SUPER) in ure_rtl8153b_init()
1802 if (sc->sc_flags & URE_FLAG_8156B) { in ure_rtl8153b_init()
1828 if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { in ure_rtl8153b_init()
1842 if (sc->sc_flags & URE_FLAG_8156) in ure_rtl8153b_init()
1852 if_t ifp = uether_getifp(&sc->sc_ue); in ure_rtl8153b_nic_reset()
1870 …DEVPRINTFN(14, sc->sc_ue.ue_dev, "rtl8153b_nic_reset: RCR: %#x\n", ure_read_4(sc, URE_PLA_RCR, URE… in ure_rtl8153b_nic_reset()
1881 if (sc->sc_flags & URE_FLAG_8153B) { in ure_rtl8153b_nic_reset()
1886 uether_pause(&sc->sc_ue, hz / 100); in ure_rtl8153b_nic_reset()
1889 device_printf(sc->sc_ue.ue_dev, in ure_rtl8153b_nic_reset()
1897 uether_pause(&sc->sc_ue, hz / 100); in ure_rtl8153b_nic_reset()
1900 device_printf(sc->sc_ue.ue_dev, in ure_rtl8153b_nic_reset()
1915 if (sc->sc_flags & URE_FLAG_8153B) { in ure_rtl8153b_nic_reset()
1921 if (sc->sc_flags & URE_FLAG_8156) { in ure_rtl8153b_nic_reset()
1924 } else if (sc->sc_flags & URE_FLAG_8156B) { in ure_rtl8153b_nic_reset()
1930 if (sc->sc_flags & URE_FLAG_8153B) { in ure_rtl8153b_nic_reset()
1942 if (sc->sc_flags & URE_FLAG_8153B) { in ure_rtl8153b_nic_reset()
1944 } else if (sc->sc_flags & URE_FLAG_8156) { in ure_rtl8153b_nic_reset()
1947 } else if (sc->sc_flags & URE_FLAG_8156B) { in ure_rtl8153b_nic_reset()
1955 if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) in ure_rtl8153b_nic_reset()
1960 if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) { in ure_rtl8153b_nic_reset()
1966 if (usbd_get_speed(sc->sc_ue.ue_udev) == USB_SPEED_SUPER) in ure_rtl8153b_nic_reset()
1979 sc->sc_flags &= ~URE_FLAG_LINK; in ure_stop()
1980 sc->sc_rxstarted = 0; in ure_stop()
1986 usbd_transfer_stop(sc->sc_rx_xfer[i]); in ure_stop()
1988 usbd_transfer_stop(sc->sc_tx_xfer[i]); in ure_stop()
1995 if (sc->sc_flags & (URE_FLAG_8153B | URE_FLAG_8156 | URE_FLAG_8156B)) in ure_disable_teredo()
2018 uether_pause(&sc->sc_ue, hz / 1000); in ure_enable_aldps()
2043 uether_pause(&sc->sc_ue, hz / 100); in ure_phy_status()
2046 device_printf(sc->sc_ue.ue_dev, in ure_phy_status()
2062 …DEVPRINTFN(14, sc->sc_ue.ue_dev, "rtl8152_nic_reset: RCR: %#x\n", ure_read_4(sc, URE_PLA_RCR, URE_… in ure_rtl8152_nic_reset()
2076 uether_pause(&sc->sc_ue, hz / 100); in ure_rtl8152_nic_reset()
2079 device_printf(sc->sc_ue.ue_dev, in ure_rtl8152_nic_reset()
2086 uether_pause(&sc->sc_ue, hz / 100); in ure_rtl8152_nic_reset()
2089 device_printf(sc->sc_ue.ue_dev, in ure_rtl8152_nic_reset()
2099 if (usbd_get_speed(sc->sc_ue.ue_udev) == USB_SPEED_FULL) { in ure_rtl8152_nic_reset()
2121 uint32_t csum, misc; in ure_rxcsum() local
2124 m->m_pkthdr.csum_flags = 0; in ure_rxcsum()
2129 csum = le32toh(rp->ure_csum); in ure_rxcsum()
2130 misc = le32toh(rp->ure_misc); in ure_rxcsum()
2140 tcp = rp->ure_csum & URE_RXPKT_TCP_CS; in ure_rxcsum()
2141 udp = rp->ure_csum & URE_RXPKT_UDP_CS; in ure_rxcsum()
2144 !(misc & URE_RXPKT_IP_F))) { in ure_rxcsum()
2148 (tcp && !(misc & URE_RXPKT_TCP_F)) || in ure_rxcsum()
2149 (udp && !(misc & URE_RXPKT_UDP_F)))) { in ure_rxcsum()
2151 m->m_pkthdr.csum_data = 0xFFFF; in ure_rxcsum()
2154 m->m_pkthdr.csum_flags = flags; in ure_rxcsum()
2173 uint32_t reg; in ure_txcsum() local
2178 flags = m->m_pkthdr.csum_flags; in ure_txcsum()
2182 if (__predict_true(m->m_len >= (int)sizeof(*eh))) { in ure_txcsum()
2184 type = eh->ether_type; in ure_txcsum()
2195 /* XXX - what about QinQ? */ in ure_txcsum()
2202 reg = 0; in ure_txcsum()
2205 reg |= URE_TXPKT_IPV4_CS; in ure_txcsum()
2207 data = m->m_pkthdr.csum_data; in ure_txcsum()
2214 reg |= URE_TXPKT_IPV4_CS; in ure_txcsum()
2216 reg |= URE_TXPKT_TCP_CS; in ure_txcsum()
2218 reg |= URE_TXPKT_UDP_CS; in ure_txcsum()
2219 reg |= l4off << URE_L4_OFFSET_SHIFT; in ure_txcsum()
2227 reg |= URE_TXPKT_IPV6_CS; in ure_txcsum()
2229 reg |= URE_TXPKT_TCP_CS; in ure_txcsum()
2231 reg |= URE_TXPKT_UDP_CS; in ure_txcsum()
2232 reg |= l4off << URE_L4_OFFSET_SHIFT; in ure_txcsum()
2235 *regout = reg; in ure_txcsum()