Lines Matching +full:sram +full:- +full:others

3 /*-
4 * SPDX-License-Identifier: BSD-4-Clause
20 * 4. Neither the name of the author nor the names of any co-contributors
36 /*-
54 * SysKonnect SK-NET gigabit ethernet driver for FreeBSD. Supports
55 * the SK-984x series adapters, both single port and dual port.
58 * https://www.freebsd.org/~wpaul/SysKonnect/xmacii_datasheet_rev_c_9-29.pdf
63 * convenience to others until Vitesse corrects this problem:
65 * https://people.freebsd.org/~wpaul/SysKonnect/xmacii_datasheet_rev_c_9-29.pdf
77 * 2MB of SRAM on board depending on the configuration.
176 "D-Link DGE-530T Gigabit Ethernet"
181 "D-Link DGE-530T Gigabit Ethernet"
269 * It seems that SK-NET GENESIS supports very simple checksum offload
335 { -1, 0, 0 }
341 { -1, 0, 0 }
440 switch(sc_if->sk_softc->sk_type) { in sk_miibus_readreg()
467 switch(sc_if->sk_softc->sk_type) { in sk_miibus_writereg()
493 switch(sc_if->sk_softc->sk_type) { in sk_miibus_statchg()
515 if (sc_if->sk_phytype != SK_PHYTYPE_XMAC) { in sk_xmac_miibus_readreg()
524 if_printf(sc_if->sk_ifp, "phy failed to come ready\n"); in sk_xmac_miibus_readreg()
546 if_printf(sc_if->sk_ifp, "phy failed to come ready\n"); in sk_xmac_miibus_writereg()
557 if_printf(sc_if->sk_ifp, "phy write timed out\n"); in sk_xmac_miibus_writereg()
567 mii = device_get_softc(sc_if->sk_miibus); in sk_xmac_miibus_statchg()
573 if (sc_if->sk_phytype != SK_PHYTYPE_XMAC) { in sk_xmac_miibus_statchg()
574 if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX) { in sk_xmac_miibus_statchg()
588 if (sc_if->sk_phytype != SK_PHYTYPE_MARV_COPPER && in sk_marv_miibus_readreg()
589 sc_if->sk_phytype != SK_PHYTYPE_MARV_FIBER) { in sk_marv_miibus_readreg()
604 if_printf(sc_if->sk_ifp, "phy failed to come ready\n"); in sk_marv_miibus_readreg()
628 if_printf(sc_if->sk_ifp, "phy write timeout\n"); in sk_marv_miibus_writereg()
649 return (~crc & ((1 << HASH_BITS) - 1)); in sk_xmchash()
673 sc = sc_if->sk_softc; in sk_rxfilter()
674 if (sc->sk_type == SK_GENESIS) in sk_rxfilter()
697 sk_setfilt(ctx->sc_if, (uint16_t *)LLADDR(sdl), cnt + 1); in sk_add_maddr_genesis()
698 ctx->mode |= XM_MODE_RX_USE_PERFECT; in sk_add_maddr_genesis()
703 ctx->hashes[0] |= (1 << h); in sk_add_maddr_genesis()
705 ctx->hashes[1] |= (1 << (h - 32)); in sk_add_maddr_genesis()
706 ctx->mode |= XM_MODE_RX_USE_HASH; in sk_add_maddr_genesis()
714 if_t ifp = sc_if->sk_ifp; in sk_rxfilter_genesis()
767 ifp = sc_if->sk_ifp; in sk_rxfilter_yukon()
797 sc_if->sk_cdata.sk_rx_cons = 0; in sk_init_rx_ring()
801 rd = &sc_if->sk_rdata; in sk_init_rx_ring()
802 bzero(rd->sk_rx_ring, sizeof(struct sk_rx_desc) * SK_RX_RING_CNT); in sk_init_rx_ring()
806 if (i == (SK_RX_RING_CNT - 1)) in sk_init_rx_ring()
810 rd->sk_rx_ring[i].sk_next = htole32(SK_ADDR_LO(addr)); in sk_init_rx_ring()
811 rd->sk_rx_ring[i].sk_csum_start = htole32(csum_start); in sk_init_rx_ring()
814 bus_dmamap_sync(sc_if->sk_cdata.sk_rx_ring_tag, in sk_init_rx_ring()
815 sc_if->sk_cdata.sk_rx_ring_map, in sk_init_rx_ring()
829 sc_if->sk_cdata.sk_jumbo_rx_cons = 0; in sk_init_jumbo_rx_ring()
833 rd = &sc_if->sk_rdata; in sk_init_jumbo_rx_ring()
834 bzero(rd->sk_jumbo_rx_ring, in sk_init_jumbo_rx_ring()
839 if (i == (SK_JUMBO_RX_RING_CNT - 1)) in sk_init_jumbo_rx_ring()
843 rd->sk_jumbo_rx_ring[i].sk_next = htole32(SK_ADDR_LO(addr)); in sk_init_jumbo_rx_ring()
844 rd->sk_jumbo_rx_ring[i].sk_csum_start = htole32(csum_start); in sk_init_jumbo_rx_ring()
847 bus_dmamap_sync(sc_if->sk_cdata.sk_jumbo_rx_ring_tag, in sk_init_jumbo_rx_ring()
848 sc_if->sk_cdata.sk_jumbo_rx_ring_map, in sk_init_jumbo_rx_ring()
862 STAILQ_INIT(&sc_if->sk_cdata.sk_txfreeq); in sk_init_tx_ring()
863 STAILQ_INIT(&sc_if->sk_cdata.sk_txbusyq); in sk_init_tx_ring()
865 sc_if->sk_cdata.sk_tx_prod = 0; in sk_init_tx_ring()
866 sc_if->sk_cdata.sk_tx_cons = 0; in sk_init_tx_ring()
867 sc_if->sk_cdata.sk_tx_cnt = 0; in sk_init_tx_ring()
869 rd = &sc_if->sk_rdata; in sk_init_tx_ring()
870 bzero(rd->sk_tx_ring, sizeof(struct sk_tx_desc) * SK_TX_RING_CNT); in sk_init_tx_ring()
872 if (i == (SK_TX_RING_CNT - 1)) in sk_init_tx_ring()
876 rd->sk_tx_ring[i].sk_next = htole32(SK_ADDR_LO(addr)); in sk_init_tx_ring()
877 txd = &sc_if->sk_cdata.sk_txdesc[i]; in sk_init_tx_ring()
878 STAILQ_INSERT_TAIL(&sc_if->sk_cdata.sk_txfreeq, txd, tx_q); in sk_init_tx_ring()
881 bus_dmamap_sync(sc_if->sk_cdata.sk_tx_ring_tag, in sk_init_tx_ring()
882 sc_if->sk_cdata.sk_tx_ring_map, in sk_init_tx_ring()
893 r = &sc_if->sk_rdata.sk_rx_ring[idx]; in sk_discard_rxbuf()
894 rxd = &sc_if->sk_cdata.sk_rxdesc[idx]; in sk_discard_rxbuf()
895 m = rxd->rx_m; in sk_discard_rxbuf()
896 r->sk_ctl = htole32(m->m_len | SK_RXSTAT | SK_OPCODE_CSUM); in sk_discard_rxbuf()
906 r = &sc_if->sk_rdata.sk_jumbo_rx_ring[idx]; in sk_discard_jumbo_rxbuf()
907 rxd = &sc_if->sk_cdata.sk_jumbo_rxdesc[idx]; in sk_discard_jumbo_rxbuf()
908 m = rxd->rx_m; in sk_discard_jumbo_rxbuf()
909 r->sk_ctl = htole32(m->m_len | SK_RXSTAT | SK_OPCODE_CSUM); in sk_discard_jumbo_rxbuf()
925 m->m_len = m->m_pkthdr.len = MCLBYTES; in sk_newbuf()
928 if (bus_dmamap_load_mbuf_sg(sc_if->sk_cdata.sk_rx_tag, in sk_newbuf()
929 sc_if->sk_cdata.sk_rx_sparemap, m, segs, &nsegs, 0) != 0) { in sk_newbuf()
935 rxd = &sc_if->sk_cdata.sk_rxdesc[idx]; in sk_newbuf()
936 if (rxd->rx_m != NULL) { in sk_newbuf()
937 bus_dmamap_sync(sc_if->sk_cdata.sk_rx_tag, rxd->rx_dmamap, in sk_newbuf()
939 bus_dmamap_unload(sc_if->sk_cdata.sk_rx_tag, rxd->rx_dmamap); in sk_newbuf()
941 map = rxd->rx_dmamap; in sk_newbuf()
942 rxd->rx_dmamap = sc_if->sk_cdata.sk_rx_sparemap; in sk_newbuf()
943 sc_if->sk_cdata.sk_rx_sparemap = map; in sk_newbuf()
944 bus_dmamap_sync(sc_if->sk_cdata.sk_rx_tag, rxd->rx_dmamap, in sk_newbuf()
946 rxd->rx_m = m; in sk_newbuf()
947 r = &sc_if->sk_rdata.sk_rx_ring[idx]; in sk_newbuf()
948 r->sk_data_lo = htole32(SK_ADDR_LO(segs[0].ds_addr)); in sk_newbuf()
949 r->sk_data_hi = htole32(SK_ADDR_HI(segs[0].ds_addr)); in sk_newbuf()
950 r->sk_ctl = htole32(segs[0].ds_len | SK_RXSTAT | SK_OPCODE_CSUM); in sk_newbuf()
968 m->m_pkthdr.len = m->m_len = MJUM9BYTES; in sk_jumbo_newbuf()
976 if (bus_dmamap_load_mbuf_sg(sc_if->sk_cdata.sk_jumbo_rx_tag, in sk_jumbo_newbuf()
977 sc_if->sk_cdata.sk_jumbo_rx_sparemap, m, segs, &nsegs, 0) != 0) { in sk_jumbo_newbuf()
983 rxd = &sc_if->sk_cdata.sk_jumbo_rxdesc[idx]; in sk_jumbo_newbuf()
984 if (rxd->rx_m != NULL) { in sk_jumbo_newbuf()
985 bus_dmamap_sync(sc_if->sk_cdata.sk_jumbo_rx_tag, rxd->rx_dmamap, in sk_jumbo_newbuf()
987 bus_dmamap_unload(sc_if->sk_cdata.sk_jumbo_rx_tag, in sk_jumbo_newbuf()
988 rxd->rx_dmamap); in sk_jumbo_newbuf()
990 map = rxd->rx_dmamap; in sk_jumbo_newbuf()
991 rxd->rx_dmamap = sc_if->sk_cdata.sk_jumbo_rx_sparemap; in sk_jumbo_newbuf()
992 sc_if->sk_cdata.sk_jumbo_rx_sparemap = map; in sk_jumbo_newbuf()
993 bus_dmamap_sync(sc_if->sk_cdata.sk_jumbo_rx_tag, rxd->rx_dmamap, in sk_jumbo_newbuf()
995 rxd->rx_m = m; in sk_jumbo_newbuf()
996 r = &sc_if->sk_rdata.sk_jumbo_rx_ring[idx]; in sk_jumbo_newbuf()
997 r->sk_data_lo = htole32(SK_ADDR_LO(segs[0].ds_addr)); in sk_jumbo_newbuf()
998 r->sk_data_hi = htole32(SK_ADDR_HI(segs[0].ds_addr)); in sk_jumbo_newbuf()
999 r->sk_ctl = htole32(segs[0].ds_len | SK_RXSTAT | SK_OPCODE_CSUM); in sk_jumbo_newbuf()
1013 mii = device_get_softc(sc_if->sk_miibus); in sk_ifmedia_upd()
1030 mii = device_get_softc(sc_if->sk_miibus); in sk_ifmedia_sts()
1033 ifmr->ifm_active = mii->mii_media_active; in sk_ifmedia_sts()
1034 ifmr->ifm_status = mii->mii_media_status; in sk_ifmedia_sts()
1050 if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > SK_JUMBO_MTU) in sk_ioctl()
1052 else if (if_getmtu(ifp) != ifr->ifr_mtu) { in sk_ioctl()
1053 if (sc_if->sk_jumbo_disable != 0 && in sk_ioctl()
1054 ifr->ifr_mtu > SK_MAX_FRAMELEN) in sk_ioctl()
1058 if_setmtu(ifp, ifr->ifr_mtu); in sk_ioctl()
1071 if ((if_getflags(ifp) ^ sc_if->sk_if_flags) in sk_ioctl()
1080 sc_if->sk_if_flags = if_getflags(ifp); in sk_ioctl()
1092 mii = device_get_softc(sc_if->sk_miibus); in sk_ioctl()
1093 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); in sk_ioctl()
1097 if (sc_if->sk_softc->sk_type == SK_GENESIS) { in sk_ioctl()
1101 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in sk_ioctl()
1132 while(t->sk_name != NULL) { in skc_probe()
1133 if ((pci_get_vendor(dev) == t->sk_vid) && in skc_probe()
1134 (pci_get_device(dev) == t->sk_did)) { in skc_probe()
1139 if ((t->sk_vid == VENDORID_LINKSYS) && in skc_probe()
1140 (t->sk_did == DEVICEID_LINKSYS_EG1032) && in skc_probe()
1146 device_set_desc(dev, t->sk_name); in skc_probe()
1164 if (SK_YUKON_FAMILY(sc->sk_type)) in sk_reset()
1171 if (SK_YUKON_FAMILY(sc->sk_type)) in sk_reset()
1174 if (sc->sk_type == SK_GENESIS) { in sk_reset()
1193 * ticks-per-microsecond. in sk_reset()
1195 switch (sc->sk_type) { in sk_reset()
1197 sc->sk_int_ticks = SK_IMTIMER_TICKS_GENESIS; in sk_reset()
1200 sc->sk_int_ticks = SK_IMTIMER_TICKS_YUKON; in sk_reset()
1204 device_printf(sc->sk_dev, "interrupt moderation is %d us\n", in sk_reset()
1205 sc->sk_int_mod); in sk_reset()
1206 sk_win_write_4(sc, SK_IMTIMERINIT, SK_IM_USECS(sc->sk_int_mod, in sk_reset()
1207 sc->sk_int_ticks)); in sk_reset()
1228 switch (sc->sk_type) { in sk_probe()
1265 sc_if->sk_if_dev = dev; in sk_attach()
1266 sc_if->sk_port = port; in sk_attach()
1267 sc_if->sk_softc = sc; in sk_attach()
1268 sc->sk_if[port] = sc_if; in sk_attach()
1270 sc_if->sk_tx_bmu = SK_BMU_TXS_CSR0; in sk_attach()
1272 sc_if->sk_tx_bmu = SK_BMU_TXS_CSR1; in sk_attach()
1274 callout_init_mtx(&sc_if->sk_tick_ch, &sc_if->sk_softc->sk_mtx, 0); in sk_attach()
1275 callout_init_mtx(&sc_if->sk_watchdog_ch, &sc_if->sk_softc->sk_mtx, 0); in sk_attach()
1283 ifp = sc_if->sk_ifp = if_alloc(IFT_ETHER); in sk_attach()
1288 * SK_GENESIS has a bug in checksum offload - From linux. in sk_attach()
1290 if (sc_if->sk_softc->sk_type != SK_GENESIS) { in sk_attach()
1311 if_setsendqlen(ifp, SK_TX_RING_CNT - 1); in sk_attach()
1330 device_printf(sc_if->sk_if_dev, in sk_attach()
1347 * amount of SRAM on it, somewhere between 512K and 2MB. We in sk_attach()
1359 chunk = sc->sk_ramsize / 2; in sk_attach()
1360 val = sc->sk_rboff / sizeof(u_int64_t); in sk_attach()
1361 sc_if->sk_rx_ramstart = val; in sk_attach()
1363 sc_if->sk_rx_ramend = val - 1; in sk_attach()
1364 sc_if->sk_tx_ramstart = val; in sk_attach()
1366 sc_if->sk_tx_ramend = val - 1; in sk_attach()
1370 chunk = sc->sk_ramsize / 4; in sk_attach()
1371 val = (sc->sk_rboff + (chunk * 2 * sc_if->sk_port)) / in sk_attach()
1373 sc_if->sk_rx_ramstart = val; in sk_attach()
1375 sc_if->sk_rx_ramend = val - 1; in sk_attach()
1376 sc_if->sk_tx_ramstart = val; in sk_attach()
1378 sc_if->sk_tx_ramend = val - 1; in sk_attach()
1382 sc_if->sk_phytype = sk_win_read_1(sc, SK_EPROM1) & 0xF; in sk_attach()
1383 if (!SK_YUKON_FAMILY(sc->sk_type)) { in sk_attach()
1384 switch(sc_if->sk_phytype) { in sk_attach()
1386 sc_if->sk_phyaddr = SK_PHYADDR_XMAC; in sk_attach()
1389 sc_if->sk_phyaddr = SK_PHYADDR_BCOM; in sk_attach()
1392 device_printf(sc->sk_dev, "unsupported PHY type: %d\n", in sk_attach()
1393 sc_if->sk_phytype); in sk_attach()
1399 if (sc_if->sk_phytype < SK_PHYTYPE_MARV_COPPER && in sk_attach()
1400 sc->sk_pmd != 'S') { in sk_attach()
1402 sc_if->sk_phytype = SK_PHYTYPE_MARV_COPPER; in sk_attach()
1403 sc->sk_coppertype = 1; in sk_attach()
1406 sc_if->sk_phyaddr = SK_PHYADDR_MARV; in sk_attach()
1408 if (!(sc->sk_coppertype)) in sk_attach()
1409 sc_if->sk_phytype = SK_PHYTYPE_MARV_FIBER; in sk_attach()
1438 switch (sc->sk_type) { in sk_attach()
1441 if (sc_if->sk_phytype == SK_PHYTYPE_XMAC) in sk_attach()
1453 error = mii_attach(dev, &sc_if->sk_miibus, ifp, sk_ifmedia_upd, in sk_attach()
1456 device_printf(sc_if->sk_if_dev, "attaching PHYs failed\n"); in sk_attach()
1464 sc->sk_if[port] = NULL; in sk_attach()
1485 sc->sk_dev = dev; in skc_attach()
1487 mtx_init(&sc->sk_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, in skc_attach()
1489 mtx_init(&sc->sk_mii_mtx, "sk_mii_mutex", NULL, MTX_DEF); in skc_attach()
1497 sc->sk_res_spec = sk_res_spec_io; in skc_attach()
1499 sc->sk_res_spec = sk_res_spec_mem; in skc_attach()
1501 error = bus_alloc_resources(dev, sc->sk_res_spec, sc->sk_res); in skc_attach()
1503 if (sc->sk_res_spec == sk_res_spec_mem) in skc_attach()
1504 sc->sk_res_spec = sk_res_spec_io; in skc_attach()
1506 sc->sk_res_spec = sk_res_spec_mem; in skc_attach()
1507 error = bus_alloc_resources(dev, sc->sk_res_spec, sc->sk_res); in skc_attach()
1510 sc->sk_res_spec == sk_res_spec_mem ? "memory" : in skc_attach()
1516 sc->sk_type = sk_win_read_1(sc, SK_CHIPVER); in skc_attach()
1517 sc->sk_rev = (sk_win_read_1(sc, SK_CONFIG) >> 4) & 0xf; in skc_attach()
1520 if (sc->sk_type != SK_GENESIS && !SK_YUKON_FAMILY(sc->sk_type)) { in skc_attach()
1522 sc->sk_type, sc->sk_rev); in skc_attach()
1531 &sc->sk_int_mod, 0, sysctl_hw_sk_int_mod, "I", in skc_attach()
1535 sc->sk_int_mod = SK_IM_DEFAULT; in skc_attach()
1537 "int_mod", &sc->sk_int_mod); in skc_attach()
1539 if (sc->sk_int_mod < SK_IM_MIN || in skc_attach()
1540 sc->sk_int_mod > SK_IM_MAX) { in skc_attach()
1543 sc->sk_int_mod = SK_IM_DEFAULT; in skc_attach()
1551 if (sc->sk_type == SK_GENESIS) { in skc_attach()
1555 sc->sk_ramsize = 0x80000; in skc_attach()
1556 sc->sk_rboff = SK_RBOFF_0; in skc_attach()
1559 sc->sk_ramsize = 0x100000; in skc_attach()
1560 sc->sk_rboff = SK_RBOFF_80000; in skc_attach()
1563 sc->sk_ramsize = 0x100000; in skc_attach()
1564 sc->sk_rboff = SK_RBOFF_0; in skc_attach()
1567 sc->sk_ramsize = 0x200000; in skc_attach()
1568 sc->sk_rboff = SK_RBOFF_0; in skc_attach()
1577 sc->sk_ramsize = 0x20000; in skc_attach()
1579 sc->sk_ramsize = skrs * (1<<12); in skc_attach()
1580 sc->sk_rboff = SK_RBOFF_0; in skc_attach()
1584 sc->sk_pmd = sk_win_read_1(sc, SK_PMDTYPE); in skc_attach()
1586 if (sc->sk_pmd == 'T' || sc->sk_pmd == '1') in skc_attach()
1587 sc->sk_coppertype = 1; in skc_attach()
1589 sc->sk_coppertype = 0; in skc_attach()
1605 switch (sc->sk_type) { in skc_attach()
1625 if (sc->sk_type == SK_YUKON || sc->sk_type == SK_YUKON_LP) { in skc_attach()
1637 sc->sk_type = SK_YUKON_LITE; in skc_attach()
1638 sc->sk_rev = SK_YUKON_LITE_REV_A0; in skc_attach()
1648 sc->sk_type, sc->sk_rev); in skc_attach()
1653 if (sc->sk_type == SK_YUKON_LITE) { in skc_attach()
1654 switch (sc->sk_rev) { in skc_attach()
1675 pname, revstr, sc->sk_rev); in skc_attach()
1678 device_printf(dev, "chip ver = 0x%02x\n", sc->sk_type); in skc_attach()
1679 device_printf(dev, "chip rev = 0x%02x\n", sc->sk_rev); in skc_attach()
1681 device_printf(dev, "SRAM size = 0x%06x\n", sc->sk_ramsize); in skc_attach()
1684 sc->sk_devs[SK_PORT_A] = device_add_child(dev, "sk", DEVICE_UNIT_ANY); in skc_attach()
1685 if (sc->sk_devs[SK_PORT_A] == NULL) { in skc_attach()
1698 device_set_ivars(sc->sk_devs[SK_PORT_A], port); in skc_attach()
1701 sc->sk_devs[SK_PORT_B] = device_add_child(dev, "sk", DEVICE_UNIT_ANY); in skc_attach()
1702 if (sc->sk_devs[SK_PORT_B] == NULL) { in skc_attach()
1715 device_set_ivars(sc->sk_devs[SK_PORT_B], port); in skc_attach()
1724 error = bus_setup_intr(dev, sc->sk_res[1], INTR_TYPE_NET|INTR_MPSAFE, in skc_attach()
1725 NULL, sk_intr, sc, &sc->sk_intrhand); in skc_attach()
1759 KASSERT(mtx_initialized(&sc_if->sk_softc->sk_mtx), in sk_detach()
1763 ifp = sc_if->sk_ifp; in sk_detach()
1769 callout_drain(&sc_if->sk_tick_ch); in sk_detach()
1770 callout_drain(&sc_if->sk_watchdog_ch); in sk_detach()
1780 if (sc_if->sk_miibus != NULL) in sk_detach()
1781 device_delete_child(dev, sc_if->sk_miibus); in sk_detach()
1799 KASSERT(mtx_initialized(&sc->sk_mtx), ("sk mutex not initialized")); in skc_detach()
1802 if (sc->sk_devs[SK_PORT_A] != NULL) { in skc_detach()
1803 device_delete_child(dev, sc->sk_devs[SK_PORT_A]); in skc_detach()
1805 if (sc->sk_devs[SK_PORT_B] != NULL) { in skc_detach()
1806 device_delete_child(dev, sc->sk_devs[SK_PORT_B]); in skc_detach()
1811 if (sc->sk_intrhand) in skc_detach()
1812 bus_teardown_intr(dev, sc->sk_res[1], sc->sk_intrhand); in skc_detach()
1813 bus_release_resources(dev, sc->sk_res_spec, sc->sk_res); in skc_detach()
1815 mtx_destroy(&sc->sk_mii_mtx); in skc_detach()
1816 mtx_destroy(&sc->sk_mtx); in skc_detach()
1841 ctx->sk_busaddr = segs[0].ds_addr; in sk_dmamap_cb()
1871 bus_get_dma_tag(sc_if->sk_if_dev),/* parent */ in sk_dma_alloc()
1881 &sc_if->sk_cdata.sk_parent_tag); in sk_dma_alloc()
1883 device_printf(sc_if->sk_if_dev, in sk_dma_alloc()
1889 error = bus_dma_tag_create(sc_if->sk_cdata.sk_parent_tag,/* parent */ in sk_dma_alloc()
1899 &sc_if->sk_cdata.sk_tx_ring_tag); in sk_dma_alloc()
1901 device_printf(sc_if->sk_if_dev, in sk_dma_alloc()
1907 error = bus_dma_tag_create(sc_if->sk_cdata.sk_parent_tag,/* parent */ in sk_dma_alloc()
1917 &sc_if->sk_cdata.sk_rx_ring_tag); in sk_dma_alloc()
1919 device_printf(sc_if->sk_if_dev, in sk_dma_alloc()
1925 error = bus_dma_tag_create(sc_if->sk_cdata.sk_parent_tag,/* parent */ in sk_dma_alloc()
1935 &sc_if->sk_cdata.sk_tx_tag); in sk_dma_alloc()
1937 device_printf(sc_if->sk_if_dev, in sk_dma_alloc()
1943 error = bus_dma_tag_create(sc_if->sk_cdata.sk_parent_tag,/* parent */ in sk_dma_alloc()
1953 &sc_if->sk_cdata.sk_rx_tag); in sk_dma_alloc()
1955 device_printf(sc_if->sk_if_dev, in sk_dma_alloc()
1961 error = bus_dmamem_alloc(sc_if->sk_cdata.sk_tx_ring_tag, in sk_dma_alloc()
1962 (void **)&sc_if->sk_rdata.sk_tx_ring, BUS_DMA_NOWAIT | in sk_dma_alloc()
1963 BUS_DMA_COHERENT | BUS_DMA_ZERO, &sc_if->sk_cdata.sk_tx_ring_map); in sk_dma_alloc()
1965 device_printf(sc_if->sk_if_dev, in sk_dma_alloc()
1971 error = bus_dmamap_load(sc_if->sk_cdata.sk_tx_ring_tag, in sk_dma_alloc()
1972 sc_if->sk_cdata.sk_tx_ring_map, sc_if->sk_rdata.sk_tx_ring, in sk_dma_alloc()
1975 device_printf(sc_if->sk_if_dev, in sk_dma_alloc()
1979 sc_if->sk_rdata.sk_tx_ring_paddr = ctx.sk_busaddr; in sk_dma_alloc()
1982 error = bus_dmamem_alloc(sc_if->sk_cdata.sk_rx_ring_tag, in sk_dma_alloc()
1983 (void **)&sc_if->sk_rdata.sk_rx_ring, BUS_DMA_NOWAIT | in sk_dma_alloc()
1984 BUS_DMA_COHERENT | BUS_DMA_ZERO, &sc_if->sk_cdata.sk_rx_ring_map); in sk_dma_alloc()
1986 device_printf(sc_if->sk_if_dev, in sk_dma_alloc()
1992 error = bus_dmamap_load(sc_if->sk_cdata.sk_rx_ring_tag, in sk_dma_alloc()
1993 sc_if->sk_cdata.sk_rx_ring_map, sc_if->sk_rdata.sk_rx_ring, in sk_dma_alloc()
1996 device_printf(sc_if->sk_if_dev, in sk_dma_alloc()
2000 sc_if->sk_rdata.sk_rx_ring_paddr = ctx.sk_busaddr; in sk_dma_alloc()
2004 txd = &sc_if->sk_cdata.sk_txdesc[i]; in sk_dma_alloc()
2005 txd->tx_m = NULL; in sk_dma_alloc()
2006 txd->tx_dmamap = NULL; in sk_dma_alloc()
2007 error = bus_dmamap_create(sc_if->sk_cdata.sk_tx_tag, 0, in sk_dma_alloc()
2008 &txd->tx_dmamap); in sk_dma_alloc()
2010 device_printf(sc_if->sk_if_dev, in sk_dma_alloc()
2017 if ((error = bus_dmamap_create(sc_if->sk_cdata.sk_rx_tag, 0, in sk_dma_alloc()
2018 &sc_if->sk_cdata.sk_rx_sparemap)) != 0) { in sk_dma_alloc()
2019 device_printf(sc_if->sk_if_dev, in sk_dma_alloc()
2024 rxd = &sc_if->sk_cdata.sk_rxdesc[i]; in sk_dma_alloc()
2025 rxd->rx_m = NULL; in sk_dma_alloc()
2026 rxd->rx_dmamap = NULL; in sk_dma_alloc()
2027 error = bus_dmamap_create(sc_if->sk_cdata.sk_rx_tag, 0, in sk_dma_alloc()
2028 &rxd->rx_dmamap); in sk_dma_alloc()
2030 device_printf(sc_if->sk_if_dev, in sk_dma_alloc()
2048 device_printf(sc_if->sk_if_dev, "disabling jumbo frame support\n"); in sk_dma_jumbo_alloc()
2049 sc_if->sk_jumbo_disable = 1; in sk_dma_jumbo_alloc()
2053 error = bus_dma_tag_create(sc_if->sk_cdata.sk_parent_tag,/* parent */ in sk_dma_jumbo_alloc()
2063 &sc_if->sk_cdata.sk_jumbo_rx_ring_tag); in sk_dma_jumbo_alloc()
2065 device_printf(sc_if->sk_if_dev, in sk_dma_jumbo_alloc()
2071 error = bus_dma_tag_create(sc_if->sk_cdata.sk_parent_tag,/* parent */ in sk_dma_jumbo_alloc()
2081 &sc_if->sk_cdata.sk_jumbo_rx_tag); in sk_dma_jumbo_alloc()
2083 device_printf(sc_if->sk_if_dev, in sk_dma_jumbo_alloc()
2089 error = bus_dmamem_alloc(sc_if->sk_cdata.sk_jumbo_rx_ring_tag, in sk_dma_jumbo_alloc()
2090 (void **)&sc_if->sk_rdata.sk_jumbo_rx_ring, BUS_DMA_NOWAIT | in sk_dma_jumbo_alloc()
2092 &sc_if->sk_cdata.sk_jumbo_rx_ring_map); in sk_dma_jumbo_alloc()
2094 device_printf(sc_if->sk_if_dev, in sk_dma_jumbo_alloc()
2100 error = bus_dmamap_load(sc_if->sk_cdata.sk_jumbo_rx_ring_tag, in sk_dma_jumbo_alloc()
2101 sc_if->sk_cdata.sk_jumbo_rx_ring_map, in sk_dma_jumbo_alloc()
2102 sc_if->sk_rdata.sk_jumbo_rx_ring, SK_JUMBO_RX_RING_SZ, sk_dmamap_cb, in sk_dma_jumbo_alloc()
2105 device_printf(sc_if->sk_if_dev, in sk_dma_jumbo_alloc()
2109 sc_if->sk_rdata.sk_jumbo_rx_ring_paddr = ctx.sk_busaddr; in sk_dma_jumbo_alloc()
2112 if ((error = bus_dmamap_create(sc_if->sk_cdata.sk_jumbo_rx_tag, 0, in sk_dma_jumbo_alloc()
2113 &sc_if->sk_cdata.sk_jumbo_rx_sparemap)) != 0) { in sk_dma_jumbo_alloc()
2114 device_printf(sc_if->sk_if_dev, in sk_dma_jumbo_alloc()
2119 jrxd = &sc_if->sk_cdata.sk_jumbo_rxdesc[i]; in sk_dma_jumbo_alloc()
2120 jrxd->rx_m = NULL; in sk_dma_jumbo_alloc()
2121 jrxd->rx_dmamap = NULL; in sk_dma_jumbo_alloc()
2122 error = bus_dmamap_create(sc_if->sk_cdata.sk_jumbo_rx_tag, 0, in sk_dma_jumbo_alloc()
2123 &jrxd->rx_dmamap); in sk_dma_jumbo_alloc()
2125 device_printf(sc_if->sk_if_dev, in sk_dma_jumbo_alloc()
2135 device_printf(sc_if->sk_if_dev, "disabling jumbo frame support due to " in sk_dma_jumbo_alloc()
2137 sc_if->sk_jumbo_disable = 1; in sk_dma_jumbo_alloc()
2149 if (sc_if->sk_cdata.sk_tx_ring_tag) { in sk_dma_free()
2150 if (sc_if->sk_rdata.sk_tx_ring_paddr) in sk_dma_free()
2151 bus_dmamap_unload(sc_if->sk_cdata.sk_tx_ring_tag, in sk_dma_free()
2152 sc_if->sk_cdata.sk_tx_ring_map); in sk_dma_free()
2153 if (sc_if->sk_rdata.sk_tx_ring) in sk_dma_free()
2154 bus_dmamem_free(sc_if->sk_cdata.sk_tx_ring_tag, in sk_dma_free()
2155 sc_if->sk_rdata.sk_tx_ring, in sk_dma_free()
2156 sc_if->sk_cdata.sk_tx_ring_map); in sk_dma_free()
2157 sc_if->sk_rdata.sk_tx_ring = NULL; in sk_dma_free()
2158 sc_if->sk_rdata.sk_tx_ring_paddr = 0; in sk_dma_free()
2159 bus_dma_tag_destroy(sc_if->sk_cdata.sk_tx_ring_tag); in sk_dma_free()
2160 sc_if->sk_cdata.sk_tx_ring_tag = NULL; in sk_dma_free()
2163 if (sc_if->sk_cdata.sk_rx_ring_tag) { in sk_dma_free()
2164 if (sc_if->sk_rdata.sk_rx_ring_paddr) in sk_dma_free()
2165 bus_dmamap_unload(sc_if->sk_cdata.sk_rx_ring_tag, in sk_dma_free()
2166 sc_if->sk_cdata.sk_rx_ring_map); in sk_dma_free()
2167 if (sc_if->sk_rdata.sk_rx_ring) in sk_dma_free()
2168 bus_dmamem_free(sc_if->sk_cdata.sk_rx_ring_tag, in sk_dma_free()
2169 sc_if->sk_rdata.sk_rx_ring, in sk_dma_free()
2170 sc_if->sk_cdata.sk_rx_ring_map); in sk_dma_free()
2171 sc_if->sk_rdata.sk_rx_ring = NULL; in sk_dma_free()
2172 sc_if->sk_rdata.sk_rx_ring_paddr = 0; in sk_dma_free()
2173 bus_dma_tag_destroy(sc_if->sk_cdata.sk_rx_ring_tag); in sk_dma_free()
2174 sc_if->sk_cdata.sk_rx_ring_tag = NULL; in sk_dma_free()
2177 if (sc_if->sk_cdata.sk_tx_tag) { in sk_dma_free()
2179 txd = &sc_if->sk_cdata.sk_txdesc[i]; in sk_dma_free()
2180 if (txd->tx_dmamap) { in sk_dma_free()
2181 bus_dmamap_destroy(sc_if->sk_cdata.sk_tx_tag, in sk_dma_free()
2182 txd->tx_dmamap); in sk_dma_free()
2183 txd->tx_dmamap = NULL; in sk_dma_free()
2186 bus_dma_tag_destroy(sc_if->sk_cdata.sk_tx_tag); in sk_dma_free()
2187 sc_if->sk_cdata.sk_tx_tag = NULL; in sk_dma_free()
2190 if (sc_if->sk_cdata.sk_rx_tag) { in sk_dma_free()
2192 rxd = &sc_if->sk_cdata.sk_rxdesc[i]; in sk_dma_free()
2193 if (rxd->rx_dmamap) { in sk_dma_free()
2194 bus_dmamap_destroy(sc_if->sk_cdata.sk_rx_tag, in sk_dma_free()
2195 rxd->rx_dmamap); in sk_dma_free()
2196 rxd->rx_dmamap = NULL; in sk_dma_free()
2199 if (sc_if->sk_cdata.sk_rx_sparemap) { in sk_dma_free()
2200 bus_dmamap_destroy(sc_if->sk_cdata.sk_rx_tag, in sk_dma_free()
2201 sc_if->sk_cdata.sk_rx_sparemap); in sk_dma_free()
2202 sc_if->sk_cdata.sk_rx_sparemap = NULL; in sk_dma_free()
2204 bus_dma_tag_destroy(sc_if->sk_cdata.sk_rx_tag); in sk_dma_free()
2205 sc_if->sk_cdata.sk_rx_tag = NULL; in sk_dma_free()
2208 if (sc_if->sk_cdata.sk_parent_tag) { in sk_dma_free()
2209 bus_dma_tag_destroy(sc_if->sk_cdata.sk_parent_tag); in sk_dma_free()
2210 sc_if->sk_cdata.sk_parent_tag = NULL; in sk_dma_free()
2221 if (sc_if->sk_cdata.sk_jumbo_rx_ring_tag) { in sk_dma_jumbo_free()
2222 if (sc_if->sk_rdata.sk_jumbo_rx_ring_paddr) in sk_dma_jumbo_free()
2223 bus_dmamap_unload(sc_if->sk_cdata.sk_jumbo_rx_ring_tag, in sk_dma_jumbo_free()
2224 sc_if->sk_cdata.sk_jumbo_rx_ring_map); in sk_dma_jumbo_free()
2225 if (sc_if->sk_rdata.sk_jumbo_rx_ring) in sk_dma_jumbo_free()
2226 bus_dmamem_free(sc_if->sk_cdata.sk_jumbo_rx_ring_tag, in sk_dma_jumbo_free()
2227 sc_if->sk_rdata.sk_jumbo_rx_ring, in sk_dma_jumbo_free()
2228 sc_if->sk_cdata.sk_jumbo_rx_ring_map); in sk_dma_jumbo_free()
2229 sc_if->sk_rdata.sk_jumbo_rx_ring = NULL; in sk_dma_jumbo_free()
2230 sc_if->sk_rdata.sk_jumbo_rx_ring_paddr = 0; in sk_dma_jumbo_free()
2231 bus_dma_tag_destroy(sc_if->sk_cdata.sk_jumbo_rx_ring_tag); in sk_dma_jumbo_free()
2232 sc_if->sk_cdata.sk_jumbo_rx_ring_tag = NULL; in sk_dma_jumbo_free()
2236 if (sc_if->sk_cdata.sk_jumbo_rx_tag) { in sk_dma_jumbo_free()
2238 jrxd = &sc_if->sk_cdata.sk_jumbo_rxdesc[i]; in sk_dma_jumbo_free()
2239 if (jrxd->rx_dmamap) { in sk_dma_jumbo_free()
2241 sc_if->sk_cdata.sk_jumbo_rx_tag, in sk_dma_jumbo_free()
2242 jrxd->rx_dmamap); in sk_dma_jumbo_free()
2243 jrxd->rx_dmamap = NULL; in sk_dma_jumbo_free()
2246 if (sc_if->sk_cdata.sk_jumbo_rx_sparemap) { in sk_dma_jumbo_free()
2247 bus_dmamap_destroy(sc_if->sk_cdata.sk_jumbo_rx_tag, in sk_dma_jumbo_free()
2248 sc_if->sk_cdata.sk_jumbo_rx_sparemap); in sk_dma_jumbo_free()
2249 sc_if->sk_cdata.sk_jumbo_rx_sparemap = NULL; in sk_dma_jumbo_free()
2251 bus_dma_tag_destroy(sc_if->sk_cdata.sk_jumbo_rx_tag); in sk_dma_jumbo_free()
2252 sc_if->sk_cdata.sk_jumbo_rx_tag = NULL; in sk_dma_jumbo_free()
2264 for(; m && m->m_len == 0; m = m->m_next) in sk_txcksum()
2266 if (m == NULL || m->m_len < ETHER_HDR_LEN) { in sk_txcksum()
2271 if (m->m_len < ETHER_HDR_LEN + sizeof(u_int32_t)) { in sk_txcksum()
2272 if (m->m_len != ETHER_HDR_LEN) { in sk_txcksum()
2278 for(m = m->m_next; m && m->m_len == 0; m = m->m_next) in sk_txcksum()
2291 offset = (ip->ip_hl << 2) + ETHER_HDR_LEN; in sk_txcksum()
2294 f->sk_csum_startval = 0; in sk_txcksum()
2295 f->sk_csum_start = htole32(((offset + m->m_pkthdr.csum_data) & 0xffff) | in sk_txcksum()
2311 if ((txd = STAILQ_FIRST(&sc_if->sk_cdata.sk_txfreeq)) == NULL) in sk_encap()
2314 error = bus_dmamap_load_mbuf_sg(sc_if->sk_cdata.sk_tx_tag, in sk_encap()
2315 txd->tx_dmamap, *m_head, txsegs, &nseg, 0); in sk_encap()
2324 error = bus_dmamap_load_mbuf_sg(sc_if->sk_cdata.sk_tx_tag, in sk_encap()
2325 txd->tx_dmamap, *m_head, txsegs, &nseg, 0); in sk_encap()
2338 if (sc_if->sk_cdata.sk_tx_cnt + nseg >= SK_TX_RING_CNT) { in sk_encap()
2339 bus_dmamap_unload(sc_if->sk_cdata.sk_tx_tag, txd->tx_dmamap); in sk_encap()
2344 if ((m->m_pkthdr.csum_flags & if_gethwassist(sc_if->sk_ifp)) != 0) in sk_encap()
2348 si = frag = sc_if->sk_cdata.sk_tx_prod; in sk_encap()
2350 f = &sc_if->sk_rdata.sk_tx_ring[frag]; in sk_encap()
2351 f->sk_data_lo = htole32(SK_ADDR_LO(txsegs[i].ds_addr)); in sk_encap()
2352 f->sk_data_hi = htole32(SK_ADDR_HI(txsegs[i].ds_addr)); in sk_encap()
2356 sk_txcksum(sc_if->sk_ifp, m, f); in sk_encap()
2360 f->sk_ctl = htole32(sk_ctl); in sk_encap()
2361 sc_if->sk_cdata.sk_tx_cnt++; in sk_encap()
2364 sc_if->sk_cdata.sk_tx_prod = frag; in sk_encap()
2367 frag = (frag + SK_TX_RING_CNT - 1) % SK_TX_RING_CNT; in sk_encap()
2368 f = &sc_if->sk_rdata.sk_tx_ring[frag]; in sk_encap()
2369 f->sk_ctl |= htole32(SK_TXCTL_LASTFRAG | SK_TXCTL_EOF_INTR); in sk_encap()
2372 f = &sc_if->sk_rdata.sk_tx_ring[si]; in sk_encap()
2373 f->sk_ctl |= htole32(SK_TXCTL_OWN); in sk_encap()
2375 STAILQ_REMOVE_HEAD(&sc_if->sk_cdata.sk_txfreeq, tx_q); in sk_encap()
2376 STAILQ_INSERT_TAIL(&sc_if->sk_cdata.sk_txbusyq, txd, tx_q); in sk_encap()
2377 txd->tx_m = m; in sk_encap()
2380 bus_dmamap_sync(sc_if->sk_cdata.sk_tx_tag, txd->tx_dmamap, in sk_encap()
2382 bus_dmamap_sync(sc_if->sk_cdata.sk_tx_ring_tag, in sk_encap()
2383 sc_if->sk_cdata.sk_tx_ring_map, in sk_encap()
2412 sc = sc_if->sk_softc; in sk_start_locked()
2417 sc_if->sk_cdata.sk_tx_cnt < SK_TX_RING_CNT - 1; ) { in sk_start_locked()
2445 CSR_WRITE_4(sc, sc_if->sk_tx_bmu, SK_TXBMU_TX_START); in sk_start_locked()
2448 sc_if->sk_watchdog_timer = 5; in sk_start_locked()
2463 if (sc_if->sk_watchdog_timer == 0 || --sc_if->sk_watchdog_timer) in sk_watchdog()
2471 if (sc_if->sk_cdata.sk_tx_cnt != 0) { in sk_watchdog()
2472 if_printf(sc_if->sk_ifp, "watchdog timeout\n"); in sk_watchdog()
2479 callout_reset(&sc_if->sk_watchdog_ch, hz, sk_watchdog, ifp); in sk_watchdog()
2516 sc_if0 = sc->sk_if[SK_PORT_A]; in skc_suspend()
2517 sc_if1 = sc->sk_if[SK_PORT_B]; in skc_suspend()
2519 ifp0 = sc_if0->sk_ifp; in skc_suspend()
2521 ifp1 = sc_if1->sk_ifp; in skc_suspend()
2526 sc->sk_suspended = 1; in skc_suspend()
2544 sc_if0 = sc->sk_if[SK_PORT_A]; in skc_resume()
2545 sc_if1 = sc->sk_if[SK_PORT_B]; in skc_resume()
2547 ifp0 = sc_if0->sk_ifp; in skc_resume()
2549 ifp1 = sc_if1->sk_ifp; in skc_resume()
2554 sc->sk_suspended = 0; in skc_resume()
2562 * According to the data sheet from SK-NET GENESIS the hardware can compute
2583 pktlen = m->m_pkthdr.len; in sk_rxcksum()
2587 if (eh->ether_type != htons(ETHERTYPE_IP)) in sk_rxcksum()
2590 if (ip->ip_v != IPVERSION) in sk_rxcksum()
2592 hlen = ip->ip_hl << 2; in sk_rxcksum()
2593 pktlen -= sizeof(struct ether_header); in sk_rxcksum()
2596 if (ntohs(ip->ip_len) < hlen) in sk_rxcksum()
2598 if (ntohs(ip->ip_len) != pktlen) in sk_rxcksum()
2605 len = hlen - sizeof(struct ip); in sk_rxcksum()
2619 m->m_pkthdr.csum_flags = CSUM_IP_CHECKED; in sk_rxcksum()
2621 m->m_pkthdr.csum_flags |= CSUM_IP_VALID; in sk_rxcksum()
2628 if (sc->sk_type == SK_GENESIS) { in sk_rxvalid()
2655 sc = sc_if->sk_softc; in sk_rxeof()
2656 ifp = sc_if->sk_ifp; in sk_rxeof()
2660 bus_dmamap_sync(sc_if->sk_cdata.sk_rx_ring_tag, in sk_rxeof()
2661 sc_if->sk_cdata.sk_rx_ring_map, BUS_DMASYNC_POSTREAD); in sk_rxeof()
2664 for (cons = sc_if->sk_cdata.sk_rx_cons; prog < SK_RX_RING_CNT; in sk_rxeof()
2666 cur_rx = &sc_if->sk_rdata.sk_rx_ring[cons]; in sk_rxeof()
2667 sk_ctl = le32toh(cur_rx->sk_ctl); in sk_rxeof()
2670 rxd = &sc_if->sk_cdata.sk_rxdesc[cons]; in sk_rxeof()
2671 rxstat = le32toh(cur_rx->sk_xmac_rxstat); in sk_rxeof()
2684 m = rxd->rx_m; in sk_rxeof()
2685 csum = le32toh(cur_rx->sk_csum); in sk_rxeof()
2692 m->m_pkthdr.rcvif = ifp; in sk_rxeof()
2693 m->m_pkthdr.len = m->m_len = SK_RXBYTES(sk_ctl); in sk_rxeof()
2703 sc_if->sk_cdata.sk_rx_cons = cons; in sk_rxeof()
2704 bus_dmamap_sync(sc_if->sk_cdata.sk_rx_ring_tag, in sk_rxeof()
2705 sc_if->sk_cdata.sk_rx_ring_map, in sk_rxeof()
2721 sc = sc_if->sk_softc; in sk_jumbo_rxeof()
2722 ifp = sc_if->sk_ifp; in sk_jumbo_rxeof()
2726 bus_dmamap_sync(sc_if->sk_cdata.sk_jumbo_rx_ring_tag, in sk_jumbo_rxeof()
2727 sc_if->sk_cdata.sk_jumbo_rx_ring_map, BUS_DMASYNC_POSTREAD); in sk_jumbo_rxeof()
2730 for (cons = sc_if->sk_cdata.sk_jumbo_rx_cons; in sk_jumbo_rxeof()
2733 cur_rx = &sc_if->sk_rdata.sk_jumbo_rx_ring[cons]; in sk_jumbo_rxeof()
2734 sk_ctl = le32toh(cur_rx->sk_ctl); in sk_jumbo_rxeof()
2737 jrxd = &sc_if->sk_cdata.sk_jumbo_rxdesc[cons]; in sk_jumbo_rxeof()
2738 rxstat = le32toh(cur_rx->sk_xmac_rxstat); in sk_jumbo_rxeof()
2751 m = jrxd->rx_m; in sk_jumbo_rxeof()
2752 csum = le32toh(cur_rx->sk_csum); in sk_jumbo_rxeof()
2759 m->m_pkthdr.rcvif = ifp; in sk_jumbo_rxeof()
2760 m->m_pkthdr.len = m->m_len = SK_RXBYTES(sk_ctl); in sk_jumbo_rxeof()
2770 sc_if->sk_cdata.sk_jumbo_rx_cons = cons; in sk_jumbo_rxeof()
2771 bus_dmamap_sync(sc_if->sk_cdata.sk_jumbo_rx_ring_tag, in sk_jumbo_rxeof()
2772 sc_if->sk_cdata.sk_jumbo_rx_ring_map, in sk_jumbo_rxeof()
2785 ifp = sc_if->sk_ifp; in sk_txeof()
2787 txd = STAILQ_FIRST(&sc_if->sk_cdata.sk_txbusyq); in sk_txeof()
2790 bus_dmamap_sync(sc_if->sk_cdata.sk_tx_ring_tag, in sk_txeof()
2791 sc_if->sk_cdata.sk_tx_ring_map, BUS_DMASYNC_POSTREAD); in sk_txeof()
2796 for (idx = sc_if->sk_cdata.sk_tx_cons;; SK_INC(idx, SK_TX_RING_CNT)) { in sk_txeof()
2797 if (sc_if->sk_cdata.sk_tx_cnt <= 0) in sk_txeof()
2799 cur_tx = &sc_if->sk_rdata.sk_tx_ring[idx]; in sk_txeof()
2800 sk_ctl = le32toh(cur_tx->sk_ctl); in sk_txeof()
2803 sc_if->sk_cdata.sk_tx_cnt--; in sk_txeof()
2807 bus_dmamap_sync(sc_if->sk_cdata.sk_tx_tag, txd->tx_dmamap, in sk_txeof()
2809 bus_dmamap_unload(sc_if->sk_cdata.sk_tx_tag, txd->tx_dmamap); in sk_txeof()
2812 m_freem(txd->tx_m); in sk_txeof()
2813 txd->tx_m = NULL; in sk_txeof()
2814 STAILQ_REMOVE_HEAD(&sc_if->sk_cdata.sk_txbusyq, tx_q); in sk_txeof()
2815 STAILQ_INSERT_TAIL(&sc_if->sk_cdata.sk_txfreeq, txd, tx_q); in sk_txeof()
2816 txd = STAILQ_FIRST(&sc_if->sk_cdata.sk_txbusyq); in sk_txeof()
2818 sc_if->sk_cdata.sk_tx_cons = idx; in sk_txeof()
2819 sc_if->sk_watchdog_timer = sc_if->sk_cdata.sk_tx_cnt > 0 ? 5 : 0; in sk_txeof()
2821 bus_dmamap_sync(sc_if->sk_cdata.sk_tx_ring_tag, in sk_txeof()
2822 sc_if->sk_cdata.sk_tx_ring_map, in sk_txeof()
2835 ifp = sc_if->sk_ifp; in sk_tick()
2836 mii = device_get_softc(sc_if->sk_miibus); in sk_tick()
2841 if (sc_if->sk_phytype == SK_PHYTYPE_BCOM) { in sk_tick()
2859 callout_reset(&sc_if->sk_tick_ch, hz, sk_tick, sc_if); in sk_tick()
2867 callout_stop(&sc_if->sk_tick_ch); in sk_tick()
2877 mii = device_get_softc(sc_if->sk_miibus); in sk_yukon_tick()
2880 callout_reset(&sc_if->sk_tick_ch, hz, sk_yukon_tick, sc_if); in sk_yukon_tick()
2889 mii = device_get_softc(sc_if->sk_miibus); in sk_intr_bcom()
2890 ifp = sc_if->sk_ifp; in sk_intr_bcom()
2910 if (!(lstat & BRGPHY_AUXSTS_LINK) && sc_if->sk_link) { in sk_intr_bcom()
2915 sc_if->sk_link = 0; in sk_intr_bcom()
2920 sc_if->sk_link = 1; in sk_intr_bcom()
2927 callout_reset(&sc_if->sk_tick_ch, hz, sk_tick, sc_if); in sk_intr_bcom()
2947 if (sc_if->sk_phytype == SK_PHYTYPE_XMAC) { in sk_intr_xmac()
2950 callout_reset(&sc_if->sk_tick_ch, hz, sk_tick, sc_if); in sk_intr_xmac()
2954 callout_reset(&sc_if->sk_tick_ch, hz, sk_tick, sc_if); in sk_intr_xmac()
2998 if (status == 0 || status == 0xffffffff || sc->sk_suspended) in sk_intr()
3001 sc_if0 = sc->sk_if[SK_PORT_A]; in sk_intr()
3002 sc_if1 = sc->sk_if[SK_PORT_B]; in sk_intr()
3005 ifp0 = sc_if0->sk_ifp; in sk_intr()
3007 ifp1 = sc_if1->sk_ifp; in sk_intr()
3009 for (; (status &= sc->sk_intrmask) != 0;) { in sk_intr()
3041 if (sc->sk_type == SK_GENESIS) in sk_intr()
3049 if (sc->sk_type == SK_GENESIS) in sk_intr()
3057 sc_if0->sk_phytype == SK_PHYTYPE_BCOM) in sk_intr()
3060 sc_if1->sk_phytype == SK_PHYTYPE_BCOM) in sk_intr()
3066 CSR_WRITE_4(sc, SK_IMR, sc->sk_intrmask); in sk_intr()
3091 sc = sc_if->sk_softc; in sk_init_xmac()
3092 ifp = sc_if->sk_ifp; in sk_init_xmac()
3102 sc_if->sk_xmac_rev = XM_XMAC_REV(SK_XM_READ_4(sc_if, XM_DEVID)); in sk_init_xmac()
3109 if (sc_if->sk_phytype == SK_PHYTYPE_BCOM) { in sk_init_xmac()
3115 if (sc_if->sk_port == SK_PORT_A) in sk_init_xmac()
3147 bcopy(if_getlladdr(sc_if->sk_ifp), eaddr, ETHER_ADDR_LEN); in sk_init_xmac()
3198 if (sc_if->sk_phytype == SK_PHYTYPE_XMAC) in sk_init_xmac()
3204 switch(sc_if->sk_xmac_rev) { in sk_init_xmac()
3233 sc_if->sk_link = 1; in sk_init_xmac()
3250 sc = sc_if->sk_softc; in sk_init_yukon()
3251 ifp = sc_if->sk_ifp; in sk_init_yukon()
3253 if (sc->sk_type == SK_YUKON_LITE && in sk_init_yukon()
3254 sc->sk_rev >= SK_YUKON_LITE_REV_A3) { in sk_init_yukon()
3270 if (sc->sk_type == SK_YUKON_LITE && in sk_init_yukon()
3271 sc->sk_rev >= SK_YUKON_LITE_REV_A3) { in sk_init_yukon()
3284 if (sc->sk_coppertype) in sk_init_yukon()
3322 eaddr = if_getlladdr(sc_if->sk_ifp); in sk_init_yukon()
3349 /* Disable RX MAC FIFO Flush for YUKON-Lite Rev. A0 only */ in sk_init_yukon()
3350 if (sc->sk_type == SK_YUKON_LITE && sc->sk_rev == SK_YUKON_LITE_REV_A0) in sk_init_yukon()
3395 ifp = sc_if->sk_ifp; in sk_init_locked()
3396 sc = sc_if->sk_softc; in sk_init_locked()
3397 mii = device_get_softc(sc_if->sk_miibus); in sk_init_locked()
3405 if (sc->sk_type == SK_GENESIS) { in sk_init_locked()
3423 * SK-NET GENESIS data sheet says that possibility of losing Start in sk_init_locked()
3442 switch (sc->sk_type) { in sk_init_locked()
3454 if (sc->sk_type == SK_GENESIS) { in sk_init_locked()
3471 SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_START, sc_if->sk_rx_ramstart); in sk_init_locked()
3472 SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_WR_PTR, sc_if->sk_rx_ramstart); in sk_init_locked()
3473 SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_RD_PTR, sc_if->sk_rx_ramstart); in sk_init_locked()
3474 SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_END, sc_if->sk_rx_ramend); in sk_init_locked()
3479 SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_START, sc_if->sk_tx_ramstart); in sk_init_locked()
3480 SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_WR_PTR, sc_if->sk_tx_ramstart); in sk_init_locked()
3481 SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_RD_PTR, sc_if->sk_tx_ramstart); in sk_init_locked()
3482 SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_END, sc_if->sk_tx_ramend); in sk_init_locked()
3511 device_printf(sc_if->sk_if_dev, in sk_init_locked()
3520 if (imr != SK_IM_USECS(sc->sk_int_mod, sc->sk_int_ticks)) { in sk_init_locked()
3521 sk_win_write_4(sc, SK_IMTIMERINIT, SK_IM_USECS(sc->sk_int_mod, in sk_init_locked()
3522 sc->sk_int_ticks)); in sk_init_locked()
3524 device_printf(sc_if->sk_if_dev, in sk_init_locked()
3526 sc->sk_int_mod); in sk_init_locked()
3531 if (sc_if->sk_port == SK_PORT_A) in sk_init_locked()
3532 sc->sk_intrmask |= SK_INTRS1; in sk_init_locked()
3534 sc->sk_intrmask |= SK_INTRS2; in sk_init_locked()
3536 sc->sk_intrmask |= SK_ISR_EXTERNAL_REG; in sk_init_locked()
3538 CSR_WRITE_4(sc, SK_IMR, sc->sk_intrmask); in sk_init_locked()
3543 switch(sc->sk_type) { in sk_init_locked()
3564 CSR_WRITE_4(sc, sc_if->sk_tx_bmu, SK_TXBMU_TX_START); in sk_init_locked()
3569 switch (sc->sk_type) { in sk_init_locked()
3573 callout_reset(&sc_if->sk_tick_ch, hz, sk_yukon_tick, sc_if); in sk_init_locked()
3577 callout_reset(&sc_if->sk_watchdog_ch, hz, sk_watchdog, ifp); in sk_init_locked()
3594 sc = sc_if->sk_softc; in sk_stop()
3595 ifp = sc_if->sk_ifp; in sk_stop()
3597 callout_stop(&sc_if->sk_tick_ch); in sk_stop()
3598 callout_stop(&sc_if->sk_watchdog_ch); in sk_stop()
3603 CSR_WRITE_4(sc, sc_if->sk_tx_bmu, SK_TXBMU_TX_STOP); in sk_stop()
3605 val = CSR_READ_4(sc, sc_if->sk_tx_bmu); in sk_stop()
3611 device_printf(sc_if->sk_if_dev, in sk_stop()
3622 device_printf(sc_if->sk_if_dev, in sk_stop()
3625 if (sc_if->sk_phytype == SK_PHYTYPE_BCOM) { in sk_stop()
3628 if (sc_if->sk_port == SK_PORT_A) { in sk_stop()
3640 switch (sc->sk_type) { in sk_stop()
3663 if (sc_if->sk_port == SK_PORT_A) in sk_stop()
3664 sc->sk_intrmask &= ~SK_INTRS1; in sk_stop()
3666 sc->sk_intrmask &= ~SK_INTRS2; in sk_stop()
3667 CSR_WRITE_4(sc, SK_IMR, sc->sk_intrmask); in sk_stop()
3674 rxd = &sc_if->sk_cdata.sk_rxdesc[i]; in sk_stop()
3675 if (rxd->rx_m != NULL) { in sk_stop()
3676 bus_dmamap_sync(sc_if->sk_cdata.sk_rx_tag, in sk_stop()
3677 rxd->rx_dmamap, BUS_DMASYNC_POSTREAD); in sk_stop()
3678 bus_dmamap_unload(sc_if->sk_cdata.sk_rx_tag, in sk_stop()
3679 rxd->rx_dmamap); in sk_stop()
3680 m_freem(rxd->rx_m); in sk_stop()
3681 rxd->rx_m = NULL; in sk_stop()
3685 jrxd = &sc_if->sk_cdata.sk_jumbo_rxdesc[i]; in sk_stop()
3686 if (jrxd->rx_m != NULL) { in sk_stop()
3687 bus_dmamap_sync(sc_if->sk_cdata.sk_jumbo_rx_tag, in sk_stop()
3688 jrxd->rx_dmamap, BUS_DMASYNC_POSTREAD); in sk_stop()
3689 bus_dmamap_unload(sc_if->sk_cdata.sk_jumbo_rx_tag, in sk_stop()
3690 jrxd->rx_dmamap); in sk_stop()
3691 m_freem(jrxd->rx_m); in sk_stop()
3692 jrxd->rx_m = NULL; in sk_stop()
3696 txd = &sc_if->sk_cdata.sk_txdesc[i]; in sk_stop()
3697 if (txd->tx_m != NULL) { in sk_stop()
3698 bus_dmamap_sync(sc_if->sk_cdata.sk_tx_tag, in sk_stop()
3699 txd->tx_dmamap, BUS_DMASYNC_POSTWRITE); in sk_stop()
3700 bus_dmamap_unload(sc_if->sk_cdata.sk_tx_tag, in sk_stop()
3701 txd->tx_dmamap); in sk_stop()
3702 m_freem(txd->tx_m); in sk_stop()
3703 txd->tx_m = NULL; in sk_stop()
3721 if (error || !req->newptr) in sysctl_int_range()