Lines Matching +full:strobe +full:- +full:pos
1 /*-
2 * SPDX-License-Identifier: BSD-4-Clause
18 * 4. Neither the name of the author nor the names of any co-contributors
41 * Macronix/Lite-On 82c115 PNIC II (www.macronix.com)
42 * Lite-On 82c168/82c169 PNIC (www.litecom.com)
179 "Compex RL100-TX 10/100BaseTX" },
181 "Compex RL100-TX 10/100BaseTX" },
185 "Macronix 98715AEC-C 10/100BaseTX" },
203 "Neteasy DRP-32TXD Cardbus 10/100" },
213 "PlaneX FNW-3602-T CardBus 10/100" },
217 "Microsoft MN-120 CardBus 10/100" },
219 "Microsoft MN-130 10/100" },
302 * MII bit-bang glue
353 nitems(dc_devs) - 1);
370 for (idx = (300 / 33) + 1; idx > 0; idx--) in dc_delay()
392 for (i = 3; i--;) { in dc_eeprom_width()
420 sc->dc_romwidth = 6; in dc_eeprom_width()
422 sc->dc_romwidth = i; in dc_eeprom_width()
475 for (i = 3; i--; ) { in dc_eeprom_putbyte()
488 * Feed in each bit and strobe the clock. in dc_eeprom_putbyte()
490 for (i = sc->dc_romwidth; i--;) { in dc_eeprom_putbyte()
506 * The PNIC 82c168/82c169 has its own non-standard way to read
529 * The Xircom X3201 has its own non-standard way to read
619 * Write the MII serial port for the MII bit-bang module.
634 * Read the MII serial port for the MII bit-bang module.
659 if (sc->dc_pmode != DC_PMODE_MII) { in dc_miibus_readreg()
660 if (phy == (MII_NPHY - 1)) { in dc_miibus_readreg()
697 if (sc->dc_type == DC_TYPE_ULI_M5263) { in dc_miibus_readreg()
749 if (sc->dc_type == DC_TYPE_98713) { in dc_miibus_readreg()
754 if (sc->dc_type == DC_TYPE_98713) in dc_miibus_readreg()
778 if (sc->dc_type == DC_TYPE_ULI_M5263) { in dc_miibus_writereg()
822 if (sc->dc_type == DC_TYPE_98713) { in dc_miibus_writereg()
827 if (sc->dc_type == DC_TYPE_98713) in dc_miibus_writereg()
843 mii = device_get_softc(sc->dc_miibus); in dc_miibus_statchg()
844 ifp = sc->dc_ifp; in dc_miibus_statchg()
849 ifm = &mii->mii_media; in dc_miibus_statchg()
850 if (DC_IS_DAVICOM(sc) && IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) { in dc_miibus_statchg()
851 dc_setcfg(sc, ifm->ifm_media); in dc_miibus_statchg()
854 dc_setcfg(sc, mii->mii_media_active); in dc_miibus_statchg()
856 sc->dc_link = 0; in dc_miibus_statchg()
857 if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == in dc_miibus_statchg()
859 switch (IFM_SUBTYPE(mii->mii_media_active)) { in dc_miibus_statchg()
862 sc->dc_link = 1; in dc_miibus_statchg()
887 mii = device_get_softc(sc->dc_miibus); in dc_miibus_mediainit()
888 ifm = &mii->mii_media; in dc_miibus_mediainit()
907 * The hash table on the PNIC II and the MX98715AEC-C/D/E in dc_mchash_le()
910 if (sc->dc_flags & DC_128BIT_HASH) in dc_mchash_le()
911 return (crc & ((1 << DC_BITS_128) - 1)); in dc_mchash_le()
914 if (sc->dc_flags & DC_64BIT_HASH) in dc_mchash_le()
915 return (crc & ((1 << DC_BITS_64) - 1)); in dc_mchash_le()
927 return (crc & ((1 << DC_BITS_512) - 1)); in dc_mchash_le()
946 * 21143-style RX filter setup routine. Filter programming is done by
951 * address (our node address) and a 512-bit hash filter for multicast
962 sc->dc_cdata.dc_sbuf[h >> 4] |= htole32(1 << (h & 0xF)); in dc_hash_maddr_21143()
976 ifp = sc->dc_ifp; in dc_setfilt_21143()
978 i = sc->dc_cdata.dc_tx_prod; in dc_setfilt_21143()
979 DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT); in dc_setfilt_21143()
980 sc->dc_cdata.dc_tx_cnt++; in dc_setfilt_21143()
981 sframe = &sc->dc_ldata.dc_tx_list[i]; in dc_setfilt_21143()
982 sp = sc->dc_cdata.dc_sbuf; in dc_setfilt_21143()
985 sframe->dc_data = htole32(DC_ADDR_LO(sc->dc_saddr)); in dc_setfilt_21143()
986 sframe->dc_ctl = htole32(DC_SFRAME_LEN | DC_TXCTL_SETUP | in dc_setfilt_21143()
989 sc->dc_cdata.dc_tx_chain[i] = (struct mbuf *)sc->dc_cdata.dc_sbuf; in dc_setfilt_21143()
1010 bcopy(if_getlladdr(sc->dc_ifp), eaddr, ETHER_ADDR_LEN); in dc_setfilt_21143()
1015 sframe->dc_status = htole32(DC_TXSTAT_OWN); in dc_setfilt_21143()
1016 bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, BUS_DMASYNC_PREREAD | in dc_setfilt_21143()
1018 bus_dmamap_sync(sc->dc_stag, sc->dc_smap, BUS_DMASYNC_PREWRITE); in dc_setfilt_21143()
1029 sc->dc_wdog_timer = 5; in dc_setfilt_21143()
1042 hashes[1] |= (1 << (h - 32)); in dc_hash_maddr_admtek_be()
1058 h = dc_mchash_le(ctx->sc, LLADDR(sdl)); in dc_hash_maddr_admtek_le()
1060 ctx->hashes[0] |= (1 << h); in dc_hash_maddr_admtek_le()
1062 ctx->hashes[1] |= (1 << (h - 32)); in dc_hash_maddr_admtek_le()
1074 ifp = sc->dc_ifp; in dc_setfilt_admtek()
1077 bcopy(if_getlladdr(sc->dc_ifp), eaddr, ETHER_ADDR_LEN); in dc_setfilt_admtek()
1121 ifp = sc->dc_ifp; in dc_setfilt_asix()
1124 bcopy(if_getlladdr(sc->dc_ifp), eaddr, ETHER_ADDR_LEN); in dc_setfilt_asix()
1197 ifp = sc->dc_ifp; in dc_setfilt_uli()
1199 i = sc->dc_cdata.dc_tx_prod; in dc_setfilt_uli()
1200 DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT); in dc_setfilt_uli()
1201 sc->dc_cdata.dc_tx_cnt++; in dc_setfilt_uli()
1202 sframe = &sc->dc_ldata.dc_tx_list[i]; in dc_setfilt_uli()
1203 sp = sc->dc_cdata.dc_sbuf; in dc_setfilt_uli()
1206 sframe->dc_data = htole32(DC_ADDR_LO(sc->dc_saddr)); in dc_setfilt_uli()
1207 sframe->dc_ctl = htole32(DC_SFRAME_LEN | DC_TXCTL_SETUP | in dc_setfilt_uli()
1210 sc->dc_cdata.dc_tx_chain[i] = (struct mbuf *)sc->dc_cdata.dc_sbuf; in dc_setfilt_uli()
1213 bcopy(if_getlladdr(sc->dc_ifp), eaddr, ETHER_ADDR_LEN); in dc_setfilt_uli()
1251 sframe->dc_status = htole32(DC_TXSTAT_OWN); in dc_setfilt_uli()
1252 bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, BUS_DMASYNC_PREREAD | in dc_setfilt_uli()
1254 bus_dmamap_sync(sc->dc_stag, sc->dc_smap, BUS_DMASYNC_PREWRITE); in dc_setfilt_uli()
1262 sc->dc_wdog_timer = 5; in dc_setfilt_uli()
1272 sc->dc_cdata.dc_sbuf[h >> 4] |= htole32(1 << (h & 0xF)); in dc_hash_maddr_xircom()
1285 ifp = sc->dc_ifp; in dc_setfilt_xircom()
1288 i = sc->dc_cdata.dc_tx_prod; in dc_setfilt_xircom()
1289 DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT); in dc_setfilt_xircom()
1290 sc->dc_cdata.dc_tx_cnt++; in dc_setfilt_xircom()
1291 sframe = &sc->dc_ldata.dc_tx_list[i]; in dc_setfilt_xircom()
1292 sp = sc->dc_cdata.dc_sbuf; in dc_setfilt_xircom()
1295 sframe->dc_data = htole32(DC_ADDR_LO(sc->dc_saddr)); in dc_setfilt_xircom()
1296 sframe->dc_ctl = htole32(DC_SFRAME_LEN | DC_TXCTL_SETUP | in dc_setfilt_xircom()
1299 sc->dc_cdata.dc_tx_chain[i] = (struct mbuf *)sc->dc_cdata.dc_sbuf; in dc_setfilt_xircom()
1320 bcopy(if_getlladdr(sc->dc_ifp), eaddr, ETHER_ADDR_LEN); in dc_setfilt_xircom()
1327 sframe->dc_status = htole32(DC_TXSTAT_OWN); in dc_setfilt_xircom()
1328 bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, BUS_DMASYNC_PREREAD | in dc_setfilt_xircom()
1330 bus_dmamap_sync(sc->dc_stag, sc->dc_smap, BUS_DMASYNC_PREWRITE); in dc_setfilt_xircom()
1338 sc->dc_wdog_timer = 5; in dc_setfilt_xircom()
1376 if (i == DC_TIMEOUT && bus_child_present(sc->dc_dev)) { in dc_netcfg_wait()
1378 device_printf(sc->dc_dev, in dc_netcfg_wait()
1383 device_printf(sc->dc_dev, in dc_netcfg_wait()
1389 * In order to fiddle with the 'full-duplex' and '100Mbps' bits in
1410 if (sc->dc_pmode == DC_PMODE_MII) { in dc_setcfg()
1422 if (sc->dc_type == DC_TYPE_98713) in dc_setcfg()
1443 if (sc->dc_pmode == DC_PMODE_MII) { in dc_setcfg()
1455 if (sc->dc_type == DC_TYPE_98713) in dc_setcfg()
1492 sc->dc_link = 1; in dc_setcfg()
1500 if (sc->dc_pmode == DC_PMODE_SYM && DC_IS_PNIC(sc)) in dc_setcfg()
1504 if (sc->dc_pmode == DC_PMODE_SYM && DC_IS_PNIC(sc)) in dc_setcfg()
1533 device_printf(sc->dc_dev, "reset never completed!\n"); in dc_reset()
1566 while (t->dc_name != NULL) { in dc_devtype()
1567 if (devid == t->dc_devid && rev >= t->dc_minrev) in dc_devtype()
1592 device_set_desc(dev, t->dc_name); in dc_probe()
1607 m = sc->dc_mi; in dc_apply_fixup()
1610 if (m->dc_media == media) in dc_apply_fixup()
1612 m = m->dc_next; in dc_apply_fixup()
1618 for (i = 0, p = m->dc_reset_ptr; i < m->dc_reset_len; i++, p += 2) { in dc_apply_fixup()
1623 for (i = 0, p = m->dc_gp_ptr; i < m->dc_gp_len; i++, p += 2) { in dc_apply_fixup()
1636 device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); in dc_decode_leaf_sia()
1639 switch (l->dc_sia_code & ~DC_SIA_CODE_EXT) { in dc_decode_leaf_sia()
1641 m->dc_media = IFM_10_T; in dc_decode_leaf_sia()
1644 m->dc_media = IFM_10_T | IFM_FDX; in dc_decode_leaf_sia()
1647 m->dc_media = IFM_10_2; in dc_decode_leaf_sia()
1650 m->dc_media = IFM_10_5; in dc_decode_leaf_sia()
1661 if (l->dc_sia_code & DC_SIA_CODE_EXT) { in dc_decode_leaf_sia()
1662 m->dc_gp_len = 2; in dc_decode_leaf_sia()
1663 m->dc_gp_ptr = in dc_decode_leaf_sia()
1664 (uint8_t *)&l->dc_un.dc_sia_ext.dc_sia_gpio_ctl; in dc_decode_leaf_sia()
1666 m->dc_gp_len = 2; in dc_decode_leaf_sia()
1667 m->dc_gp_ptr = in dc_decode_leaf_sia()
1668 (uint8_t *)&l->dc_un.dc_sia_noext.dc_sia_gpio_ctl; in dc_decode_leaf_sia()
1671 m->dc_next = sc->dc_mi; in dc_decode_leaf_sia()
1672 sc->dc_mi = m; in dc_decode_leaf_sia()
1674 sc->dc_pmode = DC_PMODE_SIA; in dc_decode_leaf_sia()
1685 device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); in dc_decode_leaf_sym()
1688 if (l->dc_sym_code == DC_SYM_CODE_100BT) in dc_decode_leaf_sym()
1689 m->dc_media = IFM_100_TX; in dc_decode_leaf_sym()
1691 if (l->dc_sym_code == DC_SYM_CODE_100BT_FDX) in dc_decode_leaf_sym()
1692 m->dc_media = IFM_100_TX | IFM_FDX; in dc_decode_leaf_sym()
1694 m->dc_gp_len = 2; in dc_decode_leaf_sym()
1695 m->dc_gp_ptr = (uint8_t *)&l->dc_sym_gpio_ctl; in dc_decode_leaf_sym()
1697 m->dc_next = sc->dc_mi; in dc_decode_leaf_sym()
1698 sc->dc_mi = m; in dc_decode_leaf_sym()
1700 sc->dc_pmode = DC_PMODE_SYM; in dc_decode_leaf_sym()
1712 device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); in dc_decode_leaf_mii()
1716 m->dc_media = IFM_AUTO; in dc_decode_leaf_mii()
1717 m->dc_gp_len = l->dc_gpr_len; in dc_decode_leaf_mii()
1721 m->dc_gp_ptr = p; in dc_decode_leaf_mii()
1722 p += 2 * l->dc_gpr_len; in dc_decode_leaf_mii()
1723 m->dc_reset_len = *p; in dc_decode_leaf_mii()
1725 m->dc_reset_ptr = p; in dc_decode_leaf_mii()
1727 m->dc_next = sc->dc_mi; in dc_decode_leaf_mii()
1728 sc->dc_mi = m; in dc_decode_leaf_mii()
1738 sc->dc_srom = malloc(size, M_DEVBUF, M_NOWAIT | M_ZERO); in dc_read_srom()
1739 if (sc->dc_srom == NULL) { in dc_read_srom()
1740 device_printf(sc->dc_dev, "Could not allocate SROM buffer\n"); in dc_read_srom()
1743 dc_read_eeprom(sc, (caddr_t)sc->dc_srom, 0, (size / 2), 0); in dc_read_srom()
1756 loff = sc->dc_srom[27]; in dc_parse_21143_srom()
1757 lhdr = (struct dc_leaf_hdr *)&(sc->dc_srom[loff]); in dc_parse_21143_srom()
1760 ptr += sizeof(struct dc_leaf_hdr) - 1; in dc_parse_21143_srom()
1764 for (i = 0; i < lhdr->dc_mcnt; i++) { in dc_parse_21143_srom()
1766 if (hdr->dc_type == DC_EBLOCK_MII) in dc_parse_21143_srom()
1769 ptr += (hdr->dc_len & 0x7F); in dc_parse_21143_srom()
1778 ptr += sizeof(struct dc_leaf_hdr) - 1; in dc_parse_21143_srom()
1780 for (i = 0; i < lhdr->dc_mcnt; i++) { in dc_parse_21143_srom()
1782 switch (hdr->dc_type) { in dc_parse_21143_srom()
1800 ptr += (hdr->dc_len & 0x7F); in dc_parse_21143_srom()
1814 *paddr = segs->ds_addr; in dc_dma_map_addr()
1822 error = bus_dma_tag_create(bus_get_dma_tag(sc->dc_dev), 1, 0, in dc_dma_alloc()
1825 NULL, NULL, &sc->dc_ptag); in dc_dma_alloc()
1827 device_printf(sc->dc_dev, in dc_dma_alloc()
1833 error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, in dc_dma_alloc()
1835 DC_RX_LIST_SZ, 0, NULL, NULL, &sc->dc_rx_ltag); in dc_dma_alloc()
1837 device_printf(sc->dc_dev, "failed to create RX list DMA tag\n"); in dc_dma_alloc()
1841 error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, in dc_dma_alloc()
1843 DC_TX_LIST_SZ, 0, NULL, NULL, &sc->dc_tx_ltag); in dc_dma_alloc()
1845 device_printf(sc->dc_dev, "failed to create TX list DMA tag\n"); in dc_dma_alloc()
1850 error = bus_dmamem_alloc(sc->dc_rx_ltag, in dc_dma_alloc()
1851 (void **)&sc->dc_ldata.dc_rx_list, BUS_DMA_NOWAIT | in dc_dma_alloc()
1852 BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->dc_rx_lmap); in dc_dma_alloc()
1854 device_printf(sc->dc_dev, in dc_dma_alloc()
1858 error = bus_dmamap_load(sc->dc_rx_ltag, sc->dc_rx_lmap, in dc_dma_alloc()
1859 sc->dc_ldata.dc_rx_list, DC_RX_LIST_SZ, dc_dma_map_addr, in dc_dma_alloc()
1860 &sc->dc_ldata.dc_rx_list_paddr, BUS_DMA_NOWAIT); in dc_dma_alloc()
1862 device_printf(sc->dc_dev, in dc_dma_alloc()
1867 error = bus_dmamem_alloc(sc->dc_tx_ltag, in dc_dma_alloc()
1868 (void **)&sc->dc_ldata.dc_tx_list, BUS_DMA_NOWAIT | in dc_dma_alloc()
1869 BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->dc_tx_lmap); in dc_dma_alloc()
1871 device_printf(sc->dc_dev, in dc_dma_alloc()
1875 error = bus_dmamap_load(sc->dc_tx_ltag, sc->dc_tx_lmap, in dc_dma_alloc()
1876 sc->dc_ldata.dc_tx_list, DC_TX_LIST_SZ, dc_dma_map_addr, in dc_dma_alloc()
1877 &sc->dc_ldata.dc_tx_list_paddr, BUS_DMA_NOWAIT); in dc_dma_alloc()
1879 device_printf(sc->dc_dev, in dc_dma_alloc()
1888 error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, in dc_dma_alloc()
1891 0, NULL, NULL, &sc->dc_stag); in dc_dma_alloc()
1893 device_printf(sc->dc_dev, in dc_dma_alloc()
1897 error = bus_dmamem_alloc(sc->dc_stag, (void **)&sc->dc_cdata.dc_sbuf, in dc_dma_alloc()
1898 BUS_DMA_NOWAIT, &sc->dc_smap); in dc_dma_alloc()
1900 device_printf(sc->dc_dev, in dc_dma_alloc()
1904 error = bus_dmamap_load(sc->dc_stag, sc->dc_smap, sc->dc_cdata.dc_sbuf, in dc_dma_alloc()
1905 DC_SFRAME_LEN, dc_dma_map_addr, &sc->dc_saddr, BUS_DMA_NOWAIT); in dc_dma_alloc()
1907 device_printf(sc->dc_dev, in dc_dma_alloc()
1913 error = bus_dma_tag_create(sc->dc_ptag, DC_RXBUF_ALIGN, 0, in dc_dma_alloc()
1915 MCLBYTES, 1, MCLBYTES, 0, NULL, NULL, &sc->dc_rx_mtag); in dc_dma_alloc()
1917 device_printf(sc->dc_dev, "failed to create RX mbuf tag\n"); in dc_dma_alloc()
1922 error = bus_dma_tag_create(sc->dc_ptag, 1, 0, in dc_dma_alloc()
1925 0, NULL, NULL, &sc->dc_tx_mtag); in dc_dma_alloc()
1927 device_printf(sc->dc_dev, "failed to create TX mbuf tag\n"); in dc_dma_alloc()
1933 error = bus_dmamap_create(sc->dc_tx_mtag, 0, in dc_dma_alloc()
1934 &sc->dc_cdata.dc_tx_map[i]); in dc_dma_alloc()
1936 device_printf(sc->dc_dev, in dc_dma_alloc()
1942 error = bus_dmamap_create(sc->dc_rx_mtag, 0, in dc_dma_alloc()
1943 &sc->dc_cdata.dc_rx_map[i]); in dc_dma_alloc()
1945 device_printf(sc->dc_dev, in dc_dma_alloc()
1950 error = bus_dmamap_create(sc->dc_rx_mtag, 0, &sc->dc_sparemap); in dc_dma_alloc()
1952 device_printf(sc->dc_dev, in dc_dma_alloc()
1967 if (sc->dc_rx_mtag != NULL) { in dc_dma_free()
1969 if (sc->dc_cdata.dc_rx_map[i] != NULL) in dc_dma_free()
1970 bus_dmamap_destroy(sc->dc_rx_mtag, in dc_dma_free()
1971 sc->dc_cdata.dc_rx_map[i]); in dc_dma_free()
1973 if (sc->dc_sparemap != NULL) in dc_dma_free()
1974 bus_dmamap_destroy(sc->dc_rx_mtag, sc->dc_sparemap); in dc_dma_free()
1975 bus_dma_tag_destroy(sc->dc_rx_mtag); in dc_dma_free()
1979 if (sc->dc_rx_mtag != NULL) { in dc_dma_free()
1981 if (sc->dc_cdata.dc_tx_map[i] != NULL) in dc_dma_free()
1982 bus_dmamap_destroy(sc->dc_tx_mtag, in dc_dma_free()
1983 sc->dc_cdata.dc_tx_map[i]); in dc_dma_free()
1985 bus_dma_tag_destroy(sc->dc_tx_mtag); in dc_dma_free()
1989 if (sc->dc_rx_ltag) { in dc_dma_free()
1990 if (sc->dc_ldata.dc_rx_list_paddr != 0) in dc_dma_free()
1991 bus_dmamap_unload(sc->dc_rx_ltag, sc->dc_rx_lmap); in dc_dma_free()
1992 if (sc->dc_ldata.dc_rx_list != NULL) in dc_dma_free()
1993 bus_dmamem_free(sc->dc_rx_ltag, sc->dc_ldata.dc_rx_list, in dc_dma_free()
1994 sc->dc_rx_lmap); in dc_dma_free()
1995 bus_dma_tag_destroy(sc->dc_rx_ltag); in dc_dma_free()
1999 if (sc->dc_tx_ltag) { in dc_dma_free()
2000 if (sc->dc_ldata.dc_tx_list_paddr != 0) in dc_dma_free()
2001 bus_dmamap_unload(sc->dc_tx_ltag, sc->dc_tx_lmap); in dc_dma_free()
2002 if (sc->dc_ldata.dc_tx_list != NULL) in dc_dma_free()
2003 bus_dmamem_free(sc->dc_tx_ltag, sc->dc_ldata.dc_tx_list, in dc_dma_free()
2004 sc->dc_tx_lmap); in dc_dma_free()
2005 bus_dma_tag_destroy(sc->dc_tx_ltag); in dc_dma_free()
2009 if (sc->dc_stag) { in dc_dma_free()
2010 if (sc->dc_saddr != 0) in dc_dma_free()
2011 bus_dmamap_unload(sc->dc_stag, sc->dc_smap); in dc_dma_free()
2012 if (sc->dc_cdata.dc_sbuf != NULL) in dc_dma_free()
2013 bus_dmamem_free(sc->dc_stag, sc->dc_cdata.dc_sbuf, in dc_dma_free()
2014 sc->dc_smap); in dc_dma_free()
2015 bus_dma_tag_destroy(sc->dc_stag); in dc_dma_free()
2037 sc->dc_dev = dev; in dc_attach()
2039 mtx_init(&sc->dc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, in dc_attach()
2048 sc->dc_res = bus_alloc_resource_any(dev, DC_RES, &rid, RF_ACTIVE); in dc_attach()
2050 if (sc->dc_res == NULL) { in dc_attach()
2056 sc->dc_btag = rman_get_bustag(sc->dc_res); in dc_attach()
2057 sc->dc_bhandle = rman_get_bushandle(sc->dc_res); in dc_attach()
2061 sc->dc_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, in dc_attach()
2064 if (sc->dc_irq == NULL) { in dc_attach()
2071 sc->dc_info = dc_devtype(dev); in dc_attach()
2076 if (sc->dc_info->dc_devid != in dc_attach()
2078 sc->dc_info->dc_devid != in dc_attach()
2082 switch (sc->dc_info->dc_devid) { in dc_attach()
2084 sc->dc_type = DC_TYPE_21143; in dc_attach()
2085 sc->dc_flags |= DC_TX_POLL | DC_TX_USE_TX_INTR; in dc_attach()
2086 sc->dc_flags |= DC_REDUCED_MII_POLL; in dc_attach()
2088 error = dc_read_srom(sc, sc->dc_romwidth); in dc_attach()
2095 sc->dc_type = DC_TYPE_DM9102; in dc_attach()
2096 sc->dc_flags |= DC_TX_COALESCE | DC_TX_INTR_ALWAYS; in dc_attach()
2097 sc->dc_flags |= DC_REDUCED_MII_POLL | DC_TX_STORENFWD; in dc_attach()
2098 sc->dc_flags |= DC_TX_ALIGN; in dc_attach()
2099 sc->dc_pmode = DC_PMODE_MII; in dc_attach()
2105 sc->dc_type = DC_TYPE_AL981; in dc_attach()
2106 sc->dc_flags |= DC_TX_USE_TX_INTR; in dc_attach()
2107 sc->dc_flags |= DC_TX_ADMTEK_WAR; in dc_attach()
2108 sc->dc_pmode = DC_PMODE_MII; in dc_attach()
2109 error = dc_read_srom(sc, sc->dc_romwidth); in dc_attach()
2128 sc->dc_type = DC_TYPE_AN983; in dc_attach()
2129 sc->dc_flags |= DC_64BIT_HASH; in dc_attach()
2130 sc->dc_flags |= DC_TX_USE_TX_INTR; in dc_attach()
2131 sc->dc_flags |= DC_TX_ADMTEK_WAR; in dc_attach()
2132 sc->dc_pmode = DC_PMODE_MII; in dc_attach()
2133 /* Don't read SROM for - auto-loaded on reset */ in dc_attach()
2138 sc->dc_type = DC_TYPE_98713; in dc_attach()
2141 sc->dc_type = DC_TYPE_98713A; in dc_attach()
2142 sc->dc_flags |= DC_21143_NWAY; in dc_attach()
2144 sc->dc_flags |= DC_REDUCED_MII_POLL; in dc_attach()
2145 sc->dc_flags |= DC_TX_POLL | DC_TX_USE_TX_INTR; in dc_attach()
2150 * Macronix MX98715AEC-C/D/E parts have only a in dc_attach()
2151 * 128-bit hash table. We need to deal with these in dc_attach()
2158 sc->dc_flags |= DC_128BIT_HASH; in dc_attach()
2159 sc->dc_type = DC_TYPE_987x5; in dc_attach()
2160 sc->dc_flags |= DC_TX_POLL | DC_TX_USE_TX_INTR; in dc_attach()
2161 sc->dc_flags |= DC_REDUCED_MII_POLL | DC_21143_NWAY; in dc_attach()
2164 sc->dc_type = DC_TYPE_987x5; in dc_attach()
2165 sc->dc_flags |= DC_TX_POLL | DC_TX_USE_TX_INTR; in dc_attach()
2166 sc->dc_flags |= DC_REDUCED_MII_POLL | DC_21143_NWAY; in dc_attach()
2169 sc->dc_type = DC_TYPE_PNICII; in dc_attach()
2170 sc->dc_flags |= DC_TX_POLL | DC_TX_USE_TX_INTR | DC_128BIT_HASH; in dc_attach()
2171 sc->dc_flags |= DC_REDUCED_MII_POLL | DC_21143_NWAY; in dc_attach()
2174 sc->dc_type = DC_TYPE_PNIC; in dc_attach()
2175 sc->dc_flags |= DC_TX_STORENFWD | DC_TX_INTR_ALWAYS; in dc_attach()
2176 sc->dc_flags |= DC_PNIC_RX_BUG_WAR; in dc_attach()
2177 sc->dc_pnic_rx_buf = malloc(DC_RXLEN * 5, M_DEVBUF, M_NOWAIT); in dc_attach()
2178 if (sc->dc_pnic_rx_buf == NULL) { in dc_attach()
2179 device_printf(sc->dc_dev, in dc_attach()
2185 sc->dc_pmode = DC_PMODE_SYM; in dc_attach()
2188 sc->dc_type = DC_TYPE_ASIX; in dc_attach()
2189 sc->dc_flags |= DC_TX_USE_TX_INTR | DC_TX_INTR_FIRSTFRAG; in dc_attach()
2190 sc->dc_flags |= DC_REDUCED_MII_POLL; in dc_attach()
2191 sc->dc_pmode = DC_PMODE_MII; in dc_attach()
2194 sc->dc_type = DC_TYPE_XIRCOM; in dc_attach()
2195 sc->dc_flags |= DC_TX_INTR_ALWAYS | DC_TX_COALESCE | in dc_attach()
2202 sc->dc_pmode = DC_PMODE_MII; in dc_attach()
2205 sc->dc_type = DC_TYPE_CONEXANT; in dc_attach()
2206 sc->dc_flags |= DC_TX_INTR_ALWAYS; in dc_attach()
2207 sc->dc_flags |= DC_REDUCED_MII_POLL; in dc_attach()
2208 sc->dc_pmode = DC_PMODE_MII; in dc_attach()
2209 error = dc_read_srom(sc, sc->dc_romwidth); in dc_attach()
2215 if (sc->dc_info->dc_devid == in dc_attach()
2217 sc->dc_type = DC_TYPE_ULI_M5261; in dc_attach()
2219 sc->dc_type = DC_TYPE_ULI_M5263; in dc_attach()
2221 sc->dc_flags |= DC_TX_INTR_ALWAYS | DC_TX_COALESCE | in dc_attach()
2223 sc->dc_pmode = DC_PMODE_MII; in dc_attach()
2224 error = dc_read_srom(sc, sc->dc_romwidth); in dc_attach()
2230 sc->dc_info->dc_devid); in dc_attach()
2236 sc->dc_cachesize = 0; in dc_attach()
2238 sc->dc_cachesize = pci_get_cachelnsz(dev); in dc_attach()
2253 * will *always* be using MII media, so that's a no-brainer. in dc_attach()
2262 if (sc->dc_type == DC_TYPE_98713) in dc_attach()
2263 sc->dc_pmode = DC_PMODE_MII; in dc_attach()
2265 sc->dc_pmode = DC_PMODE_SYM; in dc_attach()
2266 } else if (!sc->dc_pmode) in dc_attach()
2267 sc->dc_pmode = DC_PMODE_MII; in dc_attach()
2272 switch(sc->dc_type) { in dc_attach()
2304 bcopy(sc->dc_srom + DC_CONEXANT_EE_NODEADDR, &eaddr, in dc_attach()
2319 srom = (uint16_t *)sc->dc_srom; in dc_attach()
2349 bcopy(eaddr, sc->dc_eaddr, sizeof(eaddr)); in dc_attach()
2352 * find station address for chip 0. Some multi-port controllers in dc_attach()
2356 if ((sc->dc_eaddr[0] == 0 && (sc->dc_eaddr[1] & ~0xffff) == 0) || in dc_attach()
2357 (sc->dc_eaddr[0] == 0xffffffff && in dc_attach()
2358 (sc->dc_eaddr[1] & 0xffff) == 0xffff)) { in dc_attach()
2361 bcopy(sc->dc_eaddr, eaddr, sizeof(eaddr)); in dc_attach()
2363 if (DC_IS_INTEL(sc) && sc->dc_srom != NULL) { in dc_attach()
2364 while (sc->dc_mi != NULL) { in dc_attach()
2365 m = sc->dc_mi->dc_next; in dc_attach()
2366 free(sc->dc_mi, M_DEVBUF); in dc_attach()
2367 sc->dc_mi = m; in dc_attach()
2382 ifp = sc->dc_ifp = if_alloc(IFT_ETHER); in dc_attach()
2389 if_setsendqlen(ifp, DC_TX_LIST_CNT - 1); in dc_attach()
2402 tmp = sc->dc_pmode; in dc_attach()
2403 sc->dc_pmode = DC_PMODE_MII; in dc_attach()
2440 error = mii_attach(dev, &sc->dc_miibus, ifp, dc_ifmedia_upd, in dc_attach()
2444 sc->dc_pmode = tmp; in dc_attach()
2445 if (sc->dc_pmode != DC_PMODE_SIA) in dc_attach()
2446 sc->dc_pmode = DC_PMODE_SYM; in dc_attach()
2447 sc->dc_flags |= DC_21143_NWAY; in dc_attach()
2449 * For non-MII cards, we need to have the 21143 in dc_attach()
2457 sc->dc_flags |= DC_TULIP_LEDS; in dc_attach()
2458 error = mii_attach(dev, &sc->dc_miibus, ifp, dc_ifmedia_upd, in dc_attach()
2485 callout_init_mtx(&sc->dc_stat_ch, &sc->dc_mtx, 0); in dc_attach()
2486 callout_init_mtx(&sc->dc_wdog_ch, &sc->dc_mtx, 0); in dc_attach()
2494 error = bus_setup_intr(dev, sc->dc_irq, INTR_TYPE_NET | INTR_MPSAFE, in dc_attach()
2495 NULL, dc_intr, sc, &sc->dc_intrhand); in dc_attach()
2524 KASSERT(mtx_initialized(&sc->dc_mtx), ("dc mutex not initialized")); in dc_detach()
2526 ifp = sc->dc_ifp; in dc_detach()
2538 callout_drain(&sc->dc_stat_ch); in dc_detach()
2539 callout_drain(&sc->dc_wdog_ch); in dc_detach()
2544 if (sc->dc_intrhand) in dc_detach()
2545 bus_teardown_intr(dev, sc->dc_irq, sc->dc_intrhand); in dc_detach()
2546 if (sc->dc_irq) in dc_detach()
2547 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->dc_irq); in dc_detach()
2548 if (sc->dc_res) in dc_detach()
2549 bus_release_resource(dev, DC_RES, DC_RID, sc->dc_res); in dc_detach()
2556 free(sc->dc_pnic_rx_buf, M_DEVBUF); in dc_detach()
2558 while (sc->dc_mi != NULL) { in dc_detach()
2559 m = sc->dc_mi->dc_next; in dc_detach()
2560 free(sc->dc_mi, M_DEVBUF); in dc_detach()
2561 sc->dc_mi = m; in dc_detach()
2563 free(sc->dc_srom, M_DEVBUF); in dc_detach()
2565 mtx_destroy(&sc->dc_mtx); in dc_detach()
2580 cd = &sc->dc_cdata; in dc_list_tx_init()
2581 ld = &sc->dc_ldata; in dc_list_tx_init()
2583 if (i == DC_TX_LIST_CNT - 1) in dc_list_tx_init()
2587 ld->dc_tx_list[i].dc_status = 0; in dc_list_tx_init()
2588 ld->dc_tx_list[i].dc_ctl = 0; in dc_list_tx_init()
2589 ld->dc_tx_list[i].dc_data = 0; in dc_list_tx_init()
2590 ld->dc_tx_list[i].dc_next = htole32(DC_TXDESC(sc, nexti)); in dc_list_tx_init()
2591 cd->dc_tx_chain[i] = NULL; in dc_list_tx_init()
2594 cd->dc_tx_prod = cd->dc_tx_cons = cd->dc_tx_cnt = 0; in dc_list_tx_init()
2595 cd->dc_tx_pkts = 0; in dc_list_tx_init()
2596 bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, in dc_list_tx_init()
2613 cd = &sc->dc_cdata; in dc_list_rx_init()
2614 ld = &sc->dc_ldata; in dc_list_rx_init()
2619 if (i == DC_RX_LIST_CNT - 1) in dc_list_rx_init()
2623 ld->dc_rx_list[i].dc_next = htole32(DC_RXDESC(sc, nexti)); in dc_list_rx_init()
2626 cd->dc_rx_prod = 0; in dc_list_rx_init()
2627 bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, in dc_list_rx_init()
2646 m->m_len = m->m_pkthdr.len = MCLBYTES; in dc_newbuf()
2654 if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) in dc_newbuf()
2655 bzero(mtod(m, char *), m->m_len); in dc_newbuf()
2657 error = bus_dmamap_load_mbuf_sg(sc->dc_rx_mtag, sc->dc_sparemap, in dc_newbuf()
2665 if (sc->dc_cdata.dc_rx_chain[i] != NULL) in dc_newbuf()
2666 bus_dmamap_unload(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i]); in dc_newbuf()
2668 map = sc->dc_cdata.dc_rx_map[i]; in dc_newbuf()
2669 sc->dc_cdata.dc_rx_map[i] = sc->dc_sparemap; in dc_newbuf()
2670 sc->dc_sparemap = map; in dc_newbuf()
2671 sc->dc_cdata.dc_rx_chain[i] = m; in dc_newbuf()
2672 bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], in dc_newbuf()
2675 sc->dc_ldata.dc_rx_list[i].dc_ctl = htole32(DC_RXCTL_RLINK | DC_RXLEN); in dc_newbuf()
2676 sc->dc_ldata.dc_rx_list[i].dc_data = in dc_newbuf()
2678 sc->dc_ldata.dc_rx_list[i].dc_status = htole32(DC_RXSTAT_OWN); in dc_newbuf()
2679 bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, in dc_newbuf()
2698 * - We know there will always be somewhere between one and three extra
2701 * - We know the desired received frame will always be at the end of the
2704 * - We know the size of the desired received frame because it will be
2709 * - When we allocate buffers for the receive ring, we bzero() them.
2713 * - We also force the PNIC chip to upload frames that include the
2716 * - We gather all of the bogus frame data into a single buffer.
2718 * - We then position a pointer at the end of this buffer and scan
2719 * backwards until we encounter the first non-zero byte of data.
2725 * - We know the size of the actual received frame, so we subtract
2729 * - We copy this into an mbuf and pass it on, along with the actual
2747 i = sc->dc_pnic_rx_bug_save; in dc_pnic_rx_bug_war()
2748 cur_rx = &sc->dc_ldata.dc_rx_list[idx]; in dc_pnic_rx_bug_war()
2749 ptr = sc->dc_pnic_rx_buf; in dc_pnic_rx_bug_war()
2754 c = &sc->dc_ldata.dc_rx_list[i]; in dc_pnic_rx_bug_war()
2755 rxstat = le32toh(c->dc_status); in dc_pnic_rx_bug_war()
2756 m = sc->dc_cdata.dc_rx_chain[i]; in dc_pnic_rx_bug_war()
2769 /* Scan backwards until we hit a non-zero byte. */ in dc_pnic_rx_bug_war()
2771 ptr--; in dc_pnic_rx_bug_war()
2775 ptr -= 1; in dc_pnic_rx_bug_war()
2778 ptr -= total_len; in dc_pnic_rx_bug_war()
2779 if (ptr < sc->dc_pnic_rx_buf) in dc_pnic_rx_bug_war()
2780 ptr = sc->dc_pnic_rx_buf; in dc_pnic_rx_bug_war()
2788 cur_rx->dc_status = htole32(rxstat | DC_RXSTAT_FIRSTFRAG); in dc_pnic_rx_bug_war()
2806 int i, pos; in dc_rx_resync() local
2808 pos = sc->dc_cdata.dc_rx_prod; in dc_rx_resync()
2811 cur_rx = &sc->dc_ldata.dc_rx_list[pos]; in dc_rx_resync()
2812 if (!(le32toh(cur_rx->dc_status) & DC_RXSTAT_OWN)) in dc_rx_resync()
2814 DC_INC(pos, DC_RX_LIST_CNT); in dc_rx_resync()
2822 sc->dc_cdata.dc_rx_prod = pos; in dc_rx_resync()
2832 if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) { in dc_discard_rxbuf()
2833 m = sc->dc_cdata.dc_rx_chain[i]; in dc_discard_rxbuf()
2834 bzero(mtod(m, char *), m->m_len); in dc_discard_rxbuf()
2837 sc->dc_ldata.dc_rx_list[i].dc_ctl = htole32(DC_RXCTL_RLINK | DC_RXLEN); in dc_discard_rxbuf()
2838 sc->dc_ldata.dc_rx_list[i].dc_status = htole32(DC_RXSTAT_OWN); in dc_discard_rxbuf()
2839 bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_PREREAD | in dc_discard_rxbuf()
2858 ifp = sc->dc_ifp; in dc_rxeof()
2861 bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_POSTREAD | in dc_rxeof()
2863 for (i = sc->dc_cdata.dc_rx_prod; in dc_rxeof()
2868 if (sc->rxcycles <= 0) in dc_rxeof()
2870 sc->rxcycles--; in dc_rxeof()
2873 cur_rx = &sc->dc_ldata.dc_rx_list[i]; in dc_rxeof()
2874 rxstat = le32toh(cur_rx->dc_status); in dc_rxeof()
2877 m = sc->dc_cdata.dc_rx_chain[i]; in dc_rxeof()
2878 bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], in dc_rxeof()
2883 if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) { in dc_rxeof()
2886 sc->dc_pnic_rx_bug_save = i; in dc_rxeof()
2890 rxstat = le32toh(cur_rx->dc_status); in dc_rxeof()
2898 * it should simply get re-used next time this descriptor in dc_rxeof()
2922 total_len -= ETHER_CRC_LEN; in dc_rxeof()
2938 m->m_pkthdr.rcvif = ifp; in dc_rxeof()
2939 m->m_pkthdr.len = m->m_len = total_len; in dc_rxeof()
2961 sc->dc_cdata.dc_rx_prod = i; in dc_rxeof()
2977 if (sc->dc_cdata.dc_tx_cnt == 0) in dc_txeof()
2980 ifp = sc->dc_ifp; in dc_txeof()
2986 bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, BUS_DMASYNC_POSTREAD | in dc_txeof()
2989 for (idx = sc->dc_cdata.dc_tx_cons; idx != sc->dc_cdata.dc_tx_prod; in dc_txeof()
2990 DC_INC(idx, DC_TX_LIST_CNT), sc->dc_cdata.dc_tx_cnt--) { in dc_txeof()
2991 cur_tx = &sc->dc_ldata.dc_tx_list[idx]; in dc_txeof()
2992 txstat = le32toh(cur_tx->dc_status); in dc_txeof()
2993 ctl = le32toh(cur_tx->dc_ctl); in dc_txeof()
2998 if (sc->dc_cdata.dc_tx_chain[idx] == NULL) in dc_txeof()
3002 cur_tx->dc_ctl = htole32(ctl & ~DC_TXCTL_SETUP); in dc_txeof()
3004 bus_dmamap_sync(sc->dc_stag, sc->dc_smap, in dc_txeof()
3019 sc->dc_cdata.dc_tx_chain[idx] = NULL; in dc_txeof()
3032 if (/*sc->dc_type == DC_TYPE_21143 &&*/ in dc_txeof()
3033 sc->dc_pmode == DC_PMODE_MII && in dc_txeof()
3038 if (/*sc->dc_type == DC_TYPE_21143 &&*/ in dc_txeof()
3039 sc->dc_pmode == DC_PMODE_MII && in dc_txeof()
3060 bus_dmamap_sync(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], in dc_txeof()
3062 bus_dmamap_unload(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx]); in dc_txeof()
3063 m_freem(sc->dc_cdata.dc_tx_chain[idx]); in dc_txeof()
3064 sc->dc_cdata.dc_tx_chain[idx] = NULL; in dc_txeof()
3066 sc->dc_cdata.dc_tx_cons = idx; in dc_txeof()
3068 if (sc->dc_cdata.dc_tx_cnt <= DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { in dc_txeof()
3070 if (sc->dc_cdata.dc_tx_cnt == 0) in dc_txeof()
3071 sc->dc_wdog_timer = 0; in dc_txeof()
3074 bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, in dc_txeof()
3088 ifp = sc->dc_ifp; in dc_tick()
3089 mii = device_get_softc(sc->dc_miibus); in dc_tick()
3095 if (sc->dc_flags & DC_TX_USE_TX_INTR) in dc_tick()
3098 if (sc->dc_flags & DC_REDUCED_MII_POLL) { in dc_tick()
3099 if (sc->dc_flags & DC_21143_NWAY) { in dc_tick()
3101 if (IFM_SUBTYPE(mii->mii_media_active) == in dc_tick()
3103 sc->dc_link = 0; in dc_tick()
3106 if (IFM_SUBTYPE(mii->mii_media_active) == in dc_tick()
3108 sc->dc_link = 0; in dc_tick()
3111 if (sc->dc_link == 0) in dc_tick()
3120 sc->dc_cdata.dc_tx_cnt == 0) in dc_tick()
3145 if (sc->dc_link != 0 && !if_sendq_empty(ifp)) in dc_tick()
3148 if (sc->dc_flags & DC_21143_NWAY && !sc->dc_link) in dc_tick()
3149 callout_reset(&sc->dc_stat_ch, hz/10, dc_tick, sc); in dc_tick()
3151 callout_reset(&sc->dc_stat_ch, hz, dc_tick, sc); in dc_tick()
3166 device_printf(sc->dc_dev, "TX underrun -- "); in dc_tx_underrun()
3167 if ((sc->dc_flags & DC_TX_STORENFWD) == 0) { in dc_tx_underrun()
3168 if (sc->dc_txthresh + DC_TXTHRESH_INC > DC_TXTHRESH_MAX) { in dc_tx_underrun()
3173 sc->dc_txthresh += DC_TXTHRESH_INC; in dc_tx_underrun()
3175 netcfg |= sc->dc_txthresh; in dc_tx_underrun()
3193 device_printf(sc->dc_dev, in dc_tx_underrun()
3209 if_setdrvflagbits(sc->dc_ifp, 0, IFF_DRV_RUNNING); in dc_tx_underrun()
3230 sc->rxcycles = count; in dc_poll()
3259 if (status & DC_ISR_TX_IDLE && sc->dc_cdata.dc_tx_cnt) in dc_poll()
3286 if (sc->suspended) in dc_intr()
3295 ifp = sc->dc_ifp; in dc_intr()
3305 for (n = 16; n > 0; n--) { in dc_intr()
3323 if (sc->dc_cdata.dc_tx_cnt) { in dc_intr()
3356 /* Re-enable interrupts. */ in dc_intr()
3378 if (sc->dc_flags & DC_TX_COALESCE && in dc_encap()
3379 ((*m_head)->m_next != NULL || sc->dc_flags & DC_TX_ALIGN)) { in dc_encap()
3390 for (m = *m_head; m != NULL; m = m->m_next) in dc_encap()
3393 DC_TX_LIST_CNT - i + sc->dc_cdata.dc_tx_cnt <= in dc_encap()
3408 idx = sc->dc_cdata.dc_tx_prod; in dc_encap()
3409 error = bus_dmamap_load_mbuf_sg(sc->dc_tx_mtag, in dc_encap()
3410 sc->dc_cdata.dc_tx_map[idx], *m_head, segs, &nseg, 0); in dc_encap()
3419 error = bus_dmamap_load_mbuf_sg(sc->dc_tx_mtag, in dc_encap()
3420 sc->dc_cdata.dc_tx_map[idx], *m_head, segs, &nseg, 0); in dc_encap()
3437 if (sc->dc_cdata.dc_tx_cnt + nseg > DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { in dc_encap()
3438 bus_dmamap_unload(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx]); in dc_encap()
3441 bus_dmamap_sync(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], in dc_encap()
3444 first = cur = frag = sc->dc_cdata.dc_tx_prod; in dc_encap()
3446 if ((sc->dc_flags & DC_TX_ADMTEK_WAR) && in dc_encap()
3447 (frag == (DC_TX_LIST_CNT - 1)) && in dc_encap()
3448 (first != sc->dc_cdata.dc_tx_first)) { in dc_encap()
3449 bus_dmamap_unload(sc->dc_tx_mtag, in dc_encap()
3450 sc->dc_cdata.dc_tx_map[first]); in dc_encap()
3456 f = &sc->dc_ldata.dc_tx_list[frag]; in dc_encap()
3457 f->dc_ctl = htole32(DC_TXCTL_TLINK | segs[i].ds_len); in dc_encap()
3459 f->dc_status = 0; in dc_encap()
3460 f->dc_ctl |= htole32(DC_TXCTL_FIRSTFRAG); in dc_encap()
3462 f->dc_status = htole32(DC_TXSTAT_OWN); in dc_encap()
3463 f->dc_data = htole32(DC_ADDR_LO(segs[i].ds_addr)); in dc_encap()
3468 sc->dc_cdata.dc_tx_prod = frag; in dc_encap()
3469 sc->dc_cdata.dc_tx_cnt += nseg; in dc_encap()
3470 sc->dc_cdata.dc_tx_chain[cur] = *m_head; in dc_encap()
3471 sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_LASTFRAG); in dc_encap()
3472 if (sc->dc_flags & DC_TX_INTR_FIRSTFRAG) in dc_encap()
3473 sc->dc_ldata.dc_tx_list[first].dc_ctl |= in dc_encap()
3475 if (sc->dc_flags & DC_TX_INTR_ALWAYS) in dc_encap()
3476 sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); in dc_encap()
3477 if (sc->dc_flags & DC_TX_USE_TX_INTR && in dc_encap()
3478 ++sc->dc_cdata.dc_tx_pkts >= 8) { in dc_encap()
3479 sc->dc_cdata.dc_tx_pkts = 0; in dc_encap()
3480 sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); in dc_encap()
3482 sc->dc_ldata.dc_tx_list[first].dc_status = htole32(DC_TXSTAT_OWN); in dc_encap()
3484 bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, in dc_encap()
3491 map = sc->dc_cdata.dc_tx_map[cur]; in dc_encap()
3492 sc->dc_cdata.dc_tx_map[cur] = sc->dc_cdata.dc_tx_map[first]; in dc_encap()
3493 sc->dc_cdata.dc_tx_map[first] = map; in dc_encap()
3528 IFF_DRV_RUNNING || sc->dc_link == 0) in dc_start_locked()
3531 sc->dc_cdata.dc_tx_first = sc->dc_cdata.dc_tx_prod; in dc_start_locked()
3537 if (sc->dc_cdata.dc_tx_cnt > DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { in dc_start_locked()
3563 if (!(sc->dc_flags & DC_TX_POLL)) in dc_start_locked()
3569 sc->dc_wdog_timer = 5; in dc_start_locked()
3586 if_t ifp = sc->dc_ifp; in dc_init_locked()
3595 mii = device_get_softc(sc->dc_miibus); in dc_init_locked()
3603 ifm = &mii->mii_media; in dc_init_locked()
3604 dc_apply_fixup(sc, ifm->ifm_media); in dc_init_locked()
3624 if (sc->dc_flags & DC_TX_POLL) in dc_init_locked()
3626 switch(sc->dc_cachesize) { in dc_init_locked()
3642 if (sc->dc_flags & DC_TX_STORENFWD) in dc_init_locked()
3645 if (sc->dc_txthresh > DC_TXTHRESH_MAX) { in dc_init_locked()
3649 DC_SETBIT(sc, DC_NETCFG, sc->dc_txthresh); in dc_init_locked()
3666 if (sc->dc_type == DC_TYPE_98713) in dc_init_locked()
3690 device_printf(sc->dc_dev, in dc_init_locked()
3736 if (sc->dc_flags & DC_TULIP_LEDS) { in dc_init_locked()
3763 if (IFM_SUBTYPE(mii->mii_media.ifm_media) == IFM_HPNA_1) in dc_init_locked()
3764 sc->dc_link = 1; in dc_init_locked()
3766 if (sc->dc_flags & DC_21143_NWAY) in dc_init_locked()
3767 callout_reset(&sc->dc_stat_ch, hz/10, dc_tick, sc); in dc_init_locked()
3769 callout_reset(&sc->dc_stat_ch, hz, dc_tick, sc); in dc_init_locked()
3772 sc->dc_wdog_timer = 0; in dc_init_locked()
3773 callout_reset(&sc->dc_wdog_ch, hz, dc_watchdog, sc); in dc_init_locked()
3801 sc->dc_link = 0; in dc_ifmedia_upd_locked()
3802 mii = device_get_softc(sc->dc_miibus); in dc_ifmedia_upd_locked()
3805 ifm = &mii->mii_media; in dc_ifmedia_upd_locked()
3807 dc_setcfg(sc, ifm->ifm_media); in dc_ifmedia_upd_locked()
3809 IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) in dc_ifmedia_upd_locked()
3810 dc_setcfg(sc, ifm->ifm_media); in dc_ifmedia_upd_locked()
3827 mii = device_get_softc(sc->dc_miibus); in dc_ifmedia_sts()
3830 ifm = &mii->mii_media; in dc_ifmedia_sts()
3832 if (IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) { in dc_ifmedia_sts()
3833 ifmr->ifm_active = ifm->ifm_media; in dc_ifmedia_sts()
3834 ifmr->ifm_status = 0; in dc_ifmedia_sts()
3839 ifmr->ifm_active = mii->mii_media_active; in dc_ifmedia_sts()
3840 ifmr->ifm_status = mii->mii_media_status; in dc_ifmedia_sts()
3856 int need_setfilt = (if_getflags(ifp) ^ sc->dc_if_flags) & in dc_ioctl()
3870 sc->dc_if_flags = if_getflags(ifp); in dc_ioctl()
3882 mii = device_get_softc(sc->dc_miibus); in dc_ioctl()
3883 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); in dc_ioctl()
3887 if (ifr->ifr_reqcap & IFCAP_POLLING && in dc_ioctl()
3899 if (!(ifr->ifr_reqcap & IFCAP_POLLING) && in dc_ioctl()
3927 if (sc->dc_wdog_timer == 0 || --sc->dc_wdog_timer != 0) { in dc_watchdog()
3928 callout_reset(&sc->dc_wdog_ch, hz, dc_watchdog, sc); in dc_watchdog()
3932 ifp = sc->dc_ifp; in dc_watchdog()
3934 device_printf(sc->dc_dev, "watchdog timeout\n"); in dc_watchdog()
3958 ifp = sc->dc_ifp; in dc_stop()
3959 ld = &sc->dc_ldata; in dc_stop()
3960 cd = &sc->dc_cdata; in dc_stop()
3962 callout_stop(&sc->dc_stat_ch); in dc_stop()
3963 callout_stop(&sc->dc_wdog_ch); in dc_stop()
3964 sc->dc_wdog_timer = 0; in dc_stop()
3965 sc->dc_link = 0; in dc_stop()
3985 if (cd->dc_rx_chain[i] != NULL) { in dc_stop()
3986 bus_dmamap_sync(sc->dc_rx_mtag, in dc_stop()
3987 cd->dc_rx_map[i], BUS_DMASYNC_POSTREAD); in dc_stop()
3988 bus_dmamap_unload(sc->dc_rx_mtag, in dc_stop()
3989 cd->dc_rx_map[i]); in dc_stop()
3990 m_freem(cd->dc_rx_chain[i]); in dc_stop()
3991 cd->dc_rx_chain[i] = NULL; in dc_stop()
3994 bzero(ld->dc_rx_list, DC_RX_LIST_SZ); in dc_stop()
3995 bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, in dc_stop()
4002 if (cd->dc_tx_chain[i] != NULL) { in dc_stop()
4003 ctl = le32toh(ld->dc_tx_list[i].dc_ctl); in dc_stop()
4005 bus_dmamap_sync(sc->dc_stag, sc->dc_smap, in dc_stop()
4008 bus_dmamap_sync(sc->dc_tx_mtag, in dc_stop()
4009 cd->dc_tx_map[i], BUS_DMASYNC_POSTWRITE); in dc_stop()
4010 bus_dmamap_unload(sc->dc_tx_mtag, in dc_stop()
4011 cd->dc_tx_map[i]); in dc_stop()
4012 m_freem(cd->dc_tx_chain[i]); in dc_stop()
4014 cd->dc_tx_chain[i] = NULL; in dc_stop()
4017 bzero(ld->dc_tx_list, DC_TX_LIST_SZ); in dc_stop()
4018 bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, in dc_stop()
4035 sc->suspended = 1; in dc_suspend()
4043 * doesn't, re-enable busmastering, and restart the interface if
4053 ifp = sc->dc_ifp; in dc_resume()
4060 sc->suspended = 0; in dc_resume()
4098 if (child == sc->dc_dev) in dc_check_multiport()
4100 if (device_get_parent(child) != device_get_parent(sc->dc_dev)) in dc_check_multiport()
4102 if (unit > device_get_unit(sc->dc_dev)) in dc_check_multiport()
4107 device_printf(sc->dc_dev, in dc_check_multiport()
4110 bcopy(dsc->dc_eaddr, sc->dc_eaddr, ETHER_ADDR_LEN); in dc_check_multiport()
4111 eaddr = (uint8_t *)sc->dc_eaddr; in dc_check_multiport()
4114 if (DC_IS_INTEL(sc) && dsc->dc_srom != NULL && in dc_check_multiport()
4115 sc->dc_romwidth != 0) { in dc_check_multiport()
4116 free(sc->dc_srom, M_DEVBUF); in dc_check_multiport()
4117 sc->dc_romwidth = dsc->dc_romwidth; in dc_check_multiport()
4118 sc->dc_srom = malloc(DC_ROM_SIZE(sc->dc_romwidth), in dc_check_multiport()
4120 if (sc->dc_srom == NULL) { in dc_check_multiport()
4121 device_printf(sc->dc_dev, in dc_check_multiport()
4125 bcopy(dsc->dc_srom, sc->dc_srom, in dc_check_multiport()
4126 DC_ROM_SIZE(sc->dc_romwidth)); in dc_check_multiport()