Lines Matching +full:my +full:- +full:dma +full:- +full:window
1 /*-
2 * SPDX-License-Identifier: BSD-4-Clause
18 * 4. Neither the name of the author nor the names of any co-contributors
40 * bus-master chips (3c90x cards and embedded controllers) including
43 * 3Com 3c900-TPO 10Mbps/RJ-45
44 * 3Com 3c900-COMBO 10Mbps/RJ-45,AUI,BNC
45 * 3Com 3c905-TX 10/100Mbps/RJ-45
46 * 3Com 3c905-T4 10/100Mbps/RJ-45
47 * 3Com 3c900B-TPO 10Mbps/RJ-45
48 * 3Com 3c900B-COMBO 10Mbps/RJ-45,AUI,BNC
49 * 3Com 3c900B-TPC 10Mbps/RJ-45,BNC
50 * 3Com 3c900B-FL 10Mbps/Fiber-optic
51 * 3Com 3c905B-COMBO 10/100Mbps/RJ-45,AUI,BNC
52 * 3Com 3c905B-TX 10/100Mbps/RJ-45
53 * 3Com 3c905B-FL/FX 10/100Mbps/Fiber-optic
54 * 3Com 3c905C-TX 10/100Mbps/RJ-45 (Tornado ASIC)
55 * 3Com 3c980-TX 10/100Mbps server adapter (Hurricane ASIC)
56 * 3Com 3c980C-TX 10/100Mbps server adapter (Tornado ASIC)
57 * 3Com 3cSOHO100-TX 10/100Mbps/RJ-45 (Hurricane ASIC)
58 * 3Com 3c450-TX 10/100Mbps/RJ-45 (Tornado ASIC)
59 * 3Com 3c555 10/100Mbps/RJ-45 (MiniPCI, Laptop Hurricane)
60 * 3Com 3c556 10/100Mbps/RJ-45 (MiniPCI, Hurricane ASIC)
61 * 3Com 3c556B 10/100Mbps/RJ-45 (MiniPCI, Hurricane ASIC)
62 * 3Com 3c575TX 10/100Mbps/RJ-45 (Cardbus, Hurricane ASIC)
63 * 3Com 3c575B 10/100Mbps/RJ-45 (Cardbus, Hurricane ASIC)
64 * 3Com 3c575C 10/100Mbps/RJ-45 (Cardbus, Hurricane ASIC)
65 * 3Com 3cxfem656 10/100Mbps/RJ-45 (Cardbus, Hurricane ASIC)
66 * 3Com 3cxfem656b 10/100Mbps/RJ-45 (Cardbus, Hurricane ASIC)
67 * 3Com 3cxfem656c 10/100Mbps/RJ-45 (Cardbus, Tornado ASIC)
68 * Dell Optiplex GX1 on-board 3c918 10/100Mbps/RJ-45
69 * Dell on-board 3c920 10/100Mbps/RJ-45
70 * Dell Precision on-board 3c905B 10/100Mbps/RJ-45
71 * Dell Latitude laptop docking station embedded 3c905-TX
78 * The 3c90x series chips use a bus-master DMA interface for transferring
81 * you could only DMA packets to/from a contiguous memory buffer. For
87 * By contrast, the 3c90x cards support a fragment-based bus master
96 * Since using bus master DMA is a big win, we use this driver to
149 * - TX Checksumming will occasionally produce corrupt packets
150 * - TX Checksumming seems to reduce performance
168 "3Com 3c900-TPO Etherlink XL" },
170 "3Com 3c900-COMBO Etherlink XL" },
172 "3Com 3c905-TX Fast Etherlink XL" },
174 "3Com 3c905-T4 Fast Etherlink XL" },
176 "3Com 3c900B-TPO Etherlink XL" },
178 "3Com 3c900B-COMBO Etherlink XL" },
180 "3Com 3c900B-TPC Etherlink XL" },
182 "3Com 3c900B-FL Etherlink XL" },
184 "3Com 3c905B-TX Fast Etherlink XL" },
186 "3Com 3c905B-T4 Fast Etherlink XL" },
188 "3Com 3c905B-FX/SC Fast Etherlink XL" },
190 "3Com 3c905B-COMBO Fast Etherlink XL" },
192 "3Com 3c905C-TX Fast Etherlink XL" },
194 "3Com 3c920B-EMB Integrated Fast Etherlink XL" },
196 "3Com 3c920B-EMB-WNM Integrated Fast Etherlink XL" },
202 "3Com 3cSOHO100-TX OfficeConnect" },
204 "3Com 3c450-TX HomeConnect" },
289 * MII bit-bang glue
333 nitems(xl_devs) - 1);
341 *paddr = segs->ds_addr; in xl_dma_map_addr()
362 if (i == XL_TIMEOUT && bus_child_present(sc->xl_dev)) in xl_wait()
363 device_printf(sc->xl_dev, "command never completed!\n"); in xl_wait()
368 * PHYs (3c905-TX, 3c905-T4, 3c905B-T4) and those with built-in
369 * autoneg logic that's faked up to look like a PHY (3c905B-TX).
377 * Read the MII serial port for the MII bit-bang module.
387 /* We're already in window 4. */ in xl_mii_bitbang_read()
396 * Write the MII serial port for the MII bit-bang module.
405 /* We're already in window 4. */ in xl_mii_bitbang_write()
418 /* Select the window 4. */ in xl_miibus_readreg()
431 /* Select the window 4. */ in xl_miibus_writereg()
447 mii = device_get_softc(sc->xl_miibus); in xl_miibus_statchg()
454 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) { in xl_miibus_statchg()
456 if (sc->xl_type == XL_TYPE_905B) { in xl_miibus_statchg()
457 if ((IFM_OPTIONS(mii->mii_media_active) & in xl_miibus_statchg()
465 if (sc->xl_type == XL_TYPE_905B) in xl_miibus_statchg()
472 * Special support for the 3c905B-COMBO. This card has 10/100 support
474 * plus some non-MII media settings. In order to allow this, we have to
489 mii = device_get_softc(sc->xl_miibus); in xl_miibus_mediainit()
490 ifm = &mii->mii_media; in xl_miibus_mediainit()
492 if (sc->xl_media & (XL_MEDIAOPT_AUI | XL_MEDIAOPT_10FL)) { in xl_miibus_mediainit()
496 if (sc->xl_type == XL_TYPE_905B && in xl_miibus_mediainit()
497 sc->xl_media == XL_MEDIAOPT_10FL) { in xl_miibus_mediainit()
499 device_printf(sc->xl_dev, "found 10baseFL\n"); in xl_miibus_mediainit()
503 if (sc->xl_caps & XL_CAPS_FULL_DUPLEX) in xl_miibus_mediainit()
508 device_printf(sc->xl_dev, "found AUI\n"); in xl_miibus_mediainit()
513 if (sc->xl_media & XL_MEDIAOPT_BNC) { in xl_miibus_mediainit()
515 device_printf(sc->xl_dev, "found BNC\n"); in xl_miibus_mediainit()
537 device_printf(sc->xl_dev, "eeprom failed to come ready\n"); in xl_eeprom_wait()
566 if (sc->xl_flags & XL_FLAG_EEPROM_OFFSET_30) in xl_read_eeprom()
570 if (sc->xl_flags & XL_FLAG_8BITROM) in xl_read_eeprom()
594 if (sc->xl_type == XL_TYPE_905B) in xl_rxfilter()
622 ifp = sc->xl_ifp; in xl_rxfilter_90x()
642 if_foreach_llmaddr(sc->xl_ifp, xl_check_maddr_90x, &rxfilt); in xl_rxfilter_90x()
650 * Note: the 3c905B currently only supports a 64-bit
653 * will have a 256-bit hash table, hence the routine
682 ifp = sc->xl_ifp; in xl_rxfilter_90xB()
708 if (if_foreach_llmaddr(sc->xl_ifp, xl_check_maddr_90xB, sc) > 0) in xl_rxfilter_90xB()
726 if (sc->xl_media & XL_MEDIAOPT_MII || in xl_setcfg()
727 sc->xl_media & XL_MEDIAOPT_BT4) in xl_setcfg()
729 if (sc->xl_media & XL_MEDIAOPT_BTX) in xl_setcfg()
750 if (sc->xl_media & XL_MEDIAOPT_BT) { in xl_setmode()
753 sc->xl_xcvr = XL_XCVR_10BT; in xl_setmode()
762 if (sc->xl_media & XL_MEDIAOPT_BFX) { in xl_setmode()
765 sc->xl_xcvr = XL_XCVR_100BFX; in xl_setmode()
773 if (sc->xl_media & (XL_MEDIAOPT_AUI|XL_MEDIAOPT_10FL)) { in xl_setmode()
776 sc->xl_xcvr = XL_XCVR_AUI; in xl_setmode()
785 sc->xl_xcvr = XL_XCVR_AUI; in xl_setmode()
794 if (sc->xl_media & XL_MEDIAOPT_BNC) { in xl_setmode()
797 sc->xl_xcvr = XL_XCVR_COAX; in xl_setmode()
829 device_printf(sc->xl_dev, "selecting %s, %s duplex\n", pmsg, dmsg); in xl_setmode()
841 ((sc->xl_flags & XL_FLAG_WEIRDRESET) ? in xl_reset()
847 * other registers. With my 3c575C CardBus card, failing to do in xl_reset()
851 if (sc->xl_flags & XL_FLAG_USE_MMIO) in xl_reset()
861 device_printf(sc->xl_dev, "reset didn't complete\n"); in xl_reset()
876 if (sc->xl_flags & XL_FLAG_INVERT_LED_PWR || in xl_reset()
877 sc->xl_flags & XL_FLAG_INVERT_MII_PWR) { in xl_reset()
881 ((sc->xl_flags & XL_FLAG_INVERT_LED_PWR) ? in xl_reset()
883 ((sc->xl_flags & XL_FLAG_INVERT_MII_PWR) ? in xl_reset()
902 while (t->xl_name != NULL) { in xl_probe()
903 if ((pci_get_vendor(dev) == t->xl_vid) && in xl_probe()
904 (pci_get_device(dev) == t->xl_did)) { in xl_probe()
905 device_set_desc(dev, t->xl_name); in xl_probe()
919 * one Dell Latitude laptop docking station with an integrated 3c905-TX
936 if (sc->xl_media & (XL_MEDIAOPT_MASK & ~XL_MEDIAOPT_VCO)) { in xl_mediacheck()
941 if (sc->xl_xcvr <= XL_XCVR_AUTO) in xl_mediacheck()
944 device_printf(sc->xl_dev, in xl_mediacheck()
945 "bogus xcvr value in EEPROM (%x)\n", sc->xl_xcvr); in xl_mediacheck()
946 device_printf(sc->xl_dev, in xl_mediacheck()
950 if (sc->xl_type == XL_TYPE_905B && in xl_mediacheck()
951 sc->xl_media & XL_MEDIAOPT_10FL) in xl_mediacheck()
953 device_printf(sc->xl_dev, in xl_mediacheck()
955 device_printf(sc->xl_dev, in xl_mediacheck()
957 device_printf(sc->xl_dev, in xl_mediacheck()
977 case TC_DEVICEID_BOOMERANG_10BT: /* 3c900-TPO */ in xl_choose_xcvr()
978 case TC_DEVICEID_KRAKATOA_10BT: /* 3c900B-TPO */ in xl_choose_xcvr()
979 sc->xl_media = XL_MEDIAOPT_BT; in xl_choose_xcvr()
980 sc->xl_xcvr = XL_XCVR_10BT; in xl_choose_xcvr()
982 device_printf(sc->xl_dev, in xl_choose_xcvr()
985 case TC_DEVICEID_BOOMERANG_10BT_COMBO: /* 3c900-COMBO */ in xl_choose_xcvr()
986 case TC_DEVICEID_KRAKATOA_10BT_COMBO: /* 3c900B-COMBO */ in xl_choose_xcvr()
987 sc->xl_media = XL_MEDIAOPT_BT|XL_MEDIAOPT_BNC|XL_MEDIAOPT_AUI; in xl_choose_xcvr()
988 sc->xl_xcvr = XL_XCVR_10BT; in xl_choose_xcvr()
990 device_printf(sc->xl_dev, in xl_choose_xcvr()
993 case TC_DEVICEID_KRAKATOA_10BT_TPC: /* 3c900B-TPC */ in xl_choose_xcvr()
994 sc->xl_media = XL_MEDIAOPT_BT|XL_MEDIAOPT_BNC; in xl_choose_xcvr()
995 sc->xl_xcvr = XL_XCVR_10BT; in xl_choose_xcvr()
997 device_printf(sc->xl_dev, "guessing TPC (BNC/TP)\n"); in xl_choose_xcvr()
999 case TC_DEVICEID_CYCLONE_10FL: /* 3c900B-FL */ in xl_choose_xcvr()
1000 sc->xl_media = XL_MEDIAOPT_10FL; in xl_choose_xcvr()
1001 sc->xl_xcvr = XL_XCVR_AUI; in xl_choose_xcvr()
1003 device_printf(sc->xl_dev, "guessing 10baseFL\n"); in xl_choose_xcvr()
1005 case TC_DEVICEID_BOOMERANG_10_100BT: /* 3c905-TX */ in xl_choose_xcvr()
1015 case TC_DEVICEID_TORNADO_10_100BT_920B: /* 3c920B-EMB */ in xl_choose_xcvr()
1016 case TC_DEVICEID_TORNADO_10_100BT_920B_WNM: /* 3c920B-EMB-WNM */ in xl_choose_xcvr()
1017 sc->xl_media = XL_MEDIAOPT_MII; in xl_choose_xcvr()
1018 sc->xl_xcvr = XL_XCVR_MII; in xl_choose_xcvr()
1020 device_printf(sc->xl_dev, "guessing MII\n"); in xl_choose_xcvr()
1022 case TC_DEVICEID_BOOMERANG_100BT4: /* 3c905-T4 */ in xl_choose_xcvr()
1023 case TC_DEVICEID_CYCLONE_10_100BT4: /* 3c905B-T4 */ in xl_choose_xcvr()
1024 sc->xl_media = XL_MEDIAOPT_BT4; in xl_choose_xcvr()
1025 sc->xl_xcvr = XL_XCVR_MII; in xl_choose_xcvr()
1027 device_printf(sc->xl_dev, "guessing 100baseT4/MII\n"); in xl_choose_xcvr()
1029 case TC_DEVICEID_HURRICANE_10_100BT: /* 3c905B-TX */ in xl_choose_xcvr()
1030 case TC_DEVICEID_HURRICANE_10_100BT_SERV:/*3c980-TX */ in xl_choose_xcvr()
1031 case TC_DEVICEID_TORNADO_10_100BT_SERV: /* 3c980C-TX */ in xl_choose_xcvr()
1032 case TC_DEVICEID_HURRICANE_SOHO100TX: /* 3cSOHO100-TX */ in xl_choose_xcvr()
1033 case TC_DEVICEID_TORNADO_10_100BT: /* 3c905C-TX */ in xl_choose_xcvr()
1034 case TC_DEVICEID_TORNADO_HOMECONNECT: /* 3c450-TX */ in xl_choose_xcvr()
1035 sc->xl_media = XL_MEDIAOPT_BTX; in xl_choose_xcvr()
1036 sc->xl_xcvr = XL_XCVR_AUTO; in xl_choose_xcvr()
1038 device_printf(sc->xl_dev, "guessing 10/100 internal\n"); in xl_choose_xcvr()
1040 case TC_DEVICEID_CYCLONE_10_100_COMBO: /* 3c905B-COMBO */ in xl_choose_xcvr()
1041 sc->xl_media = XL_MEDIAOPT_BTX|XL_MEDIAOPT_BNC|XL_MEDIAOPT_AUI; in xl_choose_xcvr()
1042 sc->xl_xcvr = XL_XCVR_AUTO; in xl_choose_xcvr()
1044 device_printf(sc->xl_dev, in xl_choose_xcvr()
1048 device_printf(sc->xl_dev, in xl_choose_xcvr()
1049 "unknown device ID: %x -- defaulting to 10baseT\n", devid); in xl_choose_xcvr()
1050 sc->xl_media = XL_MEDIAOPT_BT; in xl_choose_xcvr()
1071 sc->xl_dev = dev; in xl_attach()
1073 mtx_init(&sc->xl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, in xl_attach()
1075 ifmedia_init(&sc->ifmedia, 0, xl_ifmedia_upd, xl_ifmedia_sts); in xl_attach()
1079 sc->xl_flags = 0; in xl_attach()
1081 sc->xl_flags |= XL_FLAG_EEPROM_OFFSET_30 | XL_FLAG_PHYOK; in xl_attach()
1084 sc->xl_flags |= XL_FLAG_FUNCREG | XL_FLAG_PHYOK | in xl_attach()
1089 sc->xl_flags |= XL_FLAG_8BITROM; in xl_attach()
1091 sc->xl_flags |= XL_FLAG_NO_XCVR_PWR; in xl_attach()
1097 sc->xl_flags |= XL_FLAG_FUNCREG; in xl_attach()
1103 sc->xl_flags |= XL_FLAG_PHYOK | XL_FLAG_EEPROM_OFFSET_30 | in xl_attach()
1106 sc->xl_flags |= XL_FLAG_FUNCREG | XL_FLAG_PHYOK; in xl_attach()
1108 sc->xl_flags |= XL_FLAG_INVERT_LED_PWR; in xl_attach()
1110 sc->xl_flags |= XL_FLAG_INVERT_MII_PWR; in xl_attach()
1112 sc->xl_flags |= XL_FLAG_INVERT_MII_PWR; in xl_attach()
1115 sc->xl_flags |= XL_FLAG_INVERT_MII_PWR | in xl_attach()
1119 sc->xl_flags |= XL_FLAG_PHYOK; in xl_attach()
1122 case TC_DEVICEID_BOOMERANG_10_100BT: /* 3c905-TX */ in xl_attach()
1126 sc->xl_flags |= XL_FLAG_NO_MMIO; in xl_attach()
1137 if ((sc->xl_flags & XL_FLAG_NO_MMIO) == 0) { in xl_attach()
1141 sc->xl_res = bus_alloc_resource_any(dev, res, &rid, RF_ACTIVE); in xl_attach()
1144 if (sc->xl_res != NULL) { in xl_attach()
1145 sc->xl_flags |= XL_FLAG_USE_MMIO; in xl_attach()
1151 sc->xl_res = bus_alloc_resource_any(dev, res, &rid, RF_ACTIVE); in xl_attach()
1152 if (sc->xl_res == NULL) { in xl_attach()
1161 sc->xl_btag = rman_get_bustag(sc->xl_res); in xl_attach()
1162 sc->xl_bhandle = rman_get_bushandle(sc->xl_res); in xl_attach()
1164 if (sc->xl_flags & XL_FLAG_FUNCREG) { in xl_attach()
1166 sc->xl_fres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in xl_attach()
1169 if (sc->xl_fres == NULL) { in xl_attach()
1175 sc->xl_ftag = rman_get_bustag(sc->xl_fres); in xl_attach()
1176 sc->xl_fhandle = rman_get_bushandle(sc->xl_fres); in xl_attach()
1181 sc->xl_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, in xl_attach()
1183 if (sc->xl_irq == NULL) { in xl_attach()
1190 ifp = sc->xl_ifp = if_alloc(IFT_ETHER); in xl_attach()
1208 callout_init_mtx(&sc->xl_tick_callout, &sc->xl_mtx, 0); in xl_attach()
1209 NET_TASK_INIT(&sc->xl_task, 0, xl_rxeof_task, sc); in xl_attach()
1212 * Now allocate a tag for the DMA descriptor lists and a chunk in xl_attach()
1213 * of DMA-able memory based on the tag. Also obtain the DMA in xl_attach()
1221 &sc->xl_ldata.xl_rx_tag); in xl_attach()
1223 device_printf(dev, "failed to allocate rx dma tag\n"); in xl_attach()
1227 error = bus_dmamem_alloc(sc->xl_ldata.xl_rx_tag, in xl_attach()
1228 (void **)&sc->xl_ldata.xl_rx_list, BUS_DMA_NOWAIT | in xl_attach()
1229 BUS_DMA_COHERENT | BUS_DMA_ZERO, &sc->xl_ldata.xl_rx_dmamap); in xl_attach()
1232 bus_dma_tag_destroy(sc->xl_ldata.xl_rx_tag); in xl_attach()
1233 sc->xl_ldata.xl_rx_tag = NULL; in xl_attach()
1237 error = bus_dmamap_load(sc->xl_ldata.xl_rx_tag, in xl_attach()
1238 sc->xl_ldata.xl_rx_dmamap, sc->xl_ldata.xl_rx_list, in xl_attach()
1240 &sc->xl_ldata.xl_rx_dmaaddr, BUS_DMA_NOWAIT); in xl_attach()
1242 device_printf(dev, "cannot get dma address of the rx ring!\n"); in xl_attach()
1243 bus_dmamem_free(sc->xl_ldata.xl_rx_tag, sc->xl_ldata.xl_rx_list, in xl_attach()
1244 sc->xl_ldata.xl_rx_dmamap); in xl_attach()
1245 bus_dma_tag_destroy(sc->xl_ldata.xl_rx_tag); in xl_attach()
1246 sc->xl_ldata.xl_rx_tag = NULL; in xl_attach()
1253 &sc->xl_ldata.xl_tx_tag); in xl_attach()
1255 device_printf(dev, "failed to allocate tx dma tag\n"); in xl_attach()
1259 error = bus_dmamem_alloc(sc->xl_ldata.xl_tx_tag, in xl_attach()
1260 (void **)&sc->xl_ldata.xl_tx_list, BUS_DMA_NOWAIT | in xl_attach()
1261 BUS_DMA_COHERENT | BUS_DMA_ZERO, &sc->xl_ldata.xl_tx_dmamap); in xl_attach()
1264 bus_dma_tag_destroy(sc->xl_ldata.xl_tx_tag); in xl_attach()
1265 sc->xl_ldata.xl_tx_tag = NULL; in xl_attach()
1269 error = bus_dmamap_load(sc->xl_ldata.xl_tx_tag, in xl_attach()
1270 sc->xl_ldata.xl_tx_dmamap, sc->xl_ldata.xl_tx_list, in xl_attach()
1272 &sc->xl_ldata.xl_tx_dmaaddr, BUS_DMA_NOWAIT); in xl_attach()
1274 device_printf(dev, "cannot get dma address of the tx ring!\n"); in xl_attach()
1275 bus_dmamem_free(sc->xl_ldata.xl_tx_tag, sc->xl_ldata.xl_tx_list, in xl_attach()
1276 sc->xl_ldata.xl_tx_dmamap); in xl_attach()
1277 bus_dma_tag_destroy(sc->xl_ldata.xl_tx_tag); in xl_attach()
1278 sc->xl_ldata.xl_tx_tag = NULL; in xl_attach()
1283 * Allocate a DMA tag for the mapping of mbufs. in xl_attach()
1288 NULL, &sc->xl_mtag); in xl_attach()
1290 device_printf(dev, "failed to allocate mbuf dma tag\n"); in xl_attach()
1294 /* We need a spare DMA map for the RX ring. */ in xl_attach()
1295 error = bus_dmamap_create(sc->xl_mtag, 0, &sc->xl_tmpmap); in xl_attach()
1303 * Note: my 3c575C CardBus card lies. It returns a value in xl_attach()
1309 xl_read_eeprom(sc, (caddr_t)&sc->xl_caps, XL_EE_CAPS, 1, 0); in xl_attach()
1310 if (sc->xl_caps & XL_CAPS_NO_TXLENGTH || in xl_attach()
1311 !(sc->xl_caps & XL_CAPS_LARGE_PKTS)) in xl_attach()
1312 sc->xl_type = XL_TYPE_905B; in xl_attach()
1314 sc->xl_type = XL_TYPE_90X; in xl_attach()
1317 if ((sc->xl_caps & XL_CAPS_PWRMGMT) != 0 && in xl_attach()
1319 sc->xl_pmcap = pmcap; in xl_attach()
1320 sc->xl_flags |= XL_FLAG_WOL; in xl_attach()
1329 sc->xl_tx_thresh = XL_MIN_FRAMELEN; in xl_attach()
1334 if (sc->xl_type == XL_TYPE_905B) { in xl_attach()
1342 if ((sc->xl_flags & XL_FLAG_WOL) != 0) in xl_attach()
1350 if_setsendqlen(ifp, XL_TX_LIST_CNT - 1); in xl_attach()
1359 sc->xl_media = CSR_READ_2(sc, XL_W3_MEDIA_OPT); in xl_attach()
1361 device_printf(dev, "media options word: %x\n", sc->xl_media); in xl_attach()
1364 sc->xl_xcvr = xcvr[0] | xcvr[1] << 16; in xl_attach()
1365 sc->xl_xcvr &= XL_ICFG_CONNECTOR_MASK; in xl_attach()
1366 sc->xl_xcvr >>= XL_ICFG_CONNECTOR_BITS; in xl_attach()
1370 if (sc->xl_media & XL_MEDIAOPT_MII || in xl_attach()
1371 sc->xl_media & XL_MEDIAOPT_BTX || in xl_attach()
1372 sc->xl_media & XL_MEDIAOPT_BT4) { in xl_attach()
1383 if ((sc->xl_flags & XL_FLAG_PHYOK) == 0) in xl_attach()
1385 error = mii_attach(dev, &sc->xl_miibus, ifp, xl_ifmedia_upd, in xl_attach()
1387 sc->xl_type == XL_TYPE_905B ? MIIF_DOPAUSE : 0); in xl_attach()
1400 if (sc->xl_xcvr == XL_XCVR_AUTO) in xl_attach()
1406 if (sc->xl_media & XL_MEDIAOPT_BT) { in xl_attach()
1409 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T, 0, NULL); in xl_attach()
1410 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T|IFM_HDX, 0, NULL); in xl_attach()
1411 if (sc->xl_caps & XL_CAPS_FULL_DUPLEX) in xl_attach()
1412 ifmedia_add(&sc->ifmedia, in xl_attach()
1416 if (sc->xl_media & (XL_MEDIAOPT_AUI|XL_MEDIAOPT_10FL)) { in xl_attach()
1420 if (sc->xl_type == XL_TYPE_905B && in xl_attach()
1421 sc->xl_media == XL_MEDIAOPT_10FL) { in xl_attach()
1424 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_FL, 0, NULL); in xl_attach()
1425 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_FL|IFM_HDX, in xl_attach()
1427 if (sc->xl_caps & XL_CAPS_FULL_DUPLEX) in xl_attach()
1428 ifmedia_add(&sc->ifmedia, in xl_attach()
1433 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_5, 0, NULL); in xl_attach()
1437 if (sc->xl_media & XL_MEDIAOPT_BNC) { in xl_attach()
1440 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_2, 0, NULL); in xl_attach()
1443 if (sc->xl_media & XL_MEDIAOPT_BFX) { in xl_attach()
1446 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_100_FX, 0, NULL); in xl_attach()
1452 if (sc->xl_miibus == NULL) in xl_attach()
1453 ifmedia_set(&sc->ifmedia, media); in xl_attach()
1456 if (sc->xl_flags & XL_FLAG_NO_XCVR_PWR) { in xl_attach()
1466 error = bus_setup_intr(dev, sc->xl_irq, INTR_TYPE_NET | INTR_MPSAFE, in xl_attach()
1467 NULL, xl_intr, sc, &sc->xl_intrhand); in xl_attach()
1484 * acquires/releases the non-recursible driver mutex to
1493 switch (sc->xl_xcvr) { in xl_choose_media()
1499 if (sc->xl_type == XL_TYPE_905B && in xl_choose_media()
1500 sc->xl_media == XL_MEDIAOPT_10FL) { in xl_choose_media()
1521 device_printf(sc->xl_dev, "unknown XCVR type: %d\n", in xl_choose_media()
1522 sc->xl_xcvr); in xl_choose_media()
1549 ifp = sc->xl_ifp; in xl_detach()
1551 KASSERT(mtx_initialized(&sc->xl_mtx), ("xl mutex not initialized")); in xl_detach()
1558 if (sc->xl_flags & XL_FLAG_USE_MMIO) { in xl_detach()
1571 taskqueue_drain(taskqueue_swi, &sc->xl_task); in xl_detach()
1572 callout_drain(&sc->xl_tick_callout); in xl_detach()
1575 if (sc->xl_miibus) in xl_detach()
1576 device_delete_child(dev, sc->xl_miibus); in xl_detach()
1578 ifmedia_removeall(&sc->ifmedia); in xl_detach()
1580 if (sc->xl_intrhand) in xl_detach()
1581 bus_teardown_intr(dev, sc->xl_irq, sc->xl_intrhand); in xl_detach()
1582 if (sc->xl_irq) in xl_detach()
1583 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->xl_irq); in xl_detach()
1584 if (sc->xl_fres != NULL) in xl_detach()
1586 XL_PCI_FUNCMEM, sc->xl_fres); in xl_detach()
1587 if (sc->xl_res) in xl_detach()
1588 bus_release_resource(dev, res, rid, sc->xl_res); in xl_detach()
1593 if (sc->xl_mtag) { in xl_detach()
1594 bus_dmamap_destroy(sc->xl_mtag, sc->xl_tmpmap); in xl_detach()
1595 bus_dma_tag_destroy(sc->xl_mtag); in xl_detach()
1597 if (sc->xl_ldata.xl_rx_tag) { in xl_detach()
1598 bus_dmamap_unload(sc->xl_ldata.xl_rx_tag, in xl_detach()
1599 sc->xl_ldata.xl_rx_dmamap); in xl_detach()
1600 bus_dmamem_free(sc->xl_ldata.xl_rx_tag, sc->xl_ldata.xl_rx_list, in xl_detach()
1601 sc->xl_ldata.xl_rx_dmamap); in xl_detach()
1602 bus_dma_tag_destroy(sc->xl_ldata.xl_rx_tag); in xl_detach()
1604 if (sc->xl_ldata.xl_tx_tag) { in xl_detach()
1605 bus_dmamap_unload(sc->xl_ldata.xl_tx_tag, in xl_detach()
1606 sc->xl_ldata.xl_tx_dmamap); in xl_detach()
1607 bus_dmamem_free(sc->xl_ldata.xl_tx_tag, sc->xl_ldata.xl_tx_list, in xl_detach()
1608 sc->xl_ldata.xl_tx_dmamap); in xl_detach()
1609 bus_dma_tag_destroy(sc->xl_ldata.xl_tx_tag); in xl_detach()
1612 mtx_destroy(&sc->xl_mtx); in xl_detach()
1629 cd = &sc->xl_cdata; in xl_list_tx_init()
1630 ld = &sc->xl_ldata; in xl_list_tx_init()
1632 cd->xl_tx_chain[i].xl_ptr = &ld->xl_tx_list[i]; in xl_list_tx_init()
1633 error = bus_dmamap_create(sc->xl_mtag, 0, in xl_list_tx_init()
1634 &cd->xl_tx_chain[i].xl_map); in xl_list_tx_init()
1637 cd->xl_tx_chain[i].xl_phys = ld->xl_tx_dmaaddr + in xl_list_tx_init()
1639 if (i == (XL_TX_LIST_CNT - 1)) in xl_list_tx_init()
1640 cd->xl_tx_chain[i].xl_next = NULL; in xl_list_tx_init()
1642 cd->xl_tx_chain[i].xl_next = &cd->xl_tx_chain[i + 1]; in xl_list_tx_init()
1645 cd->xl_tx_free = &cd->xl_tx_chain[0]; in xl_list_tx_init()
1646 cd->xl_tx_tail = cd->xl_tx_head = NULL; in xl_list_tx_init()
1648 bus_dmamap_sync(ld->xl_tx_tag, ld->xl_tx_dmamap, BUS_DMASYNC_PREWRITE); in xl_list_tx_init()
1664 cd = &sc->xl_cdata; in xl_list_tx_init_90xB()
1665 ld = &sc->xl_ldata; in xl_list_tx_init_90xB()
1667 cd->xl_tx_chain[i].xl_ptr = &ld->xl_tx_list[i]; in xl_list_tx_init_90xB()
1668 error = bus_dmamap_create(sc->xl_mtag, 0, in xl_list_tx_init_90xB()
1669 &cd->xl_tx_chain[i].xl_map); in xl_list_tx_init_90xB()
1672 cd->xl_tx_chain[i].xl_phys = ld->xl_tx_dmaaddr + in xl_list_tx_init_90xB()
1674 if (i == (XL_TX_LIST_CNT - 1)) in xl_list_tx_init_90xB()
1675 cd->xl_tx_chain[i].xl_next = &cd->xl_tx_chain[0]; in xl_list_tx_init_90xB()
1677 cd->xl_tx_chain[i].xl_next = &cd->xl_tx_chain[i + 1]; in xl_list_tx_init_90xB()
1679 cd->xl_tx_chain[i].xl_prev = in xl_list_tx_init_90xB()
1680 &cd->xl_tx_chain[XL_TX_LIST_CNT - 1]; in xl_list_tx_init_90xB()
1682 cd->xl_tx_chain[i].xl_prev = in xl_list_tx_init_90xB()
1683 &cd->xl_tx_chain[i - 1]; in xl_list_tx_init_90xB()
1686 bzero(ld->xl_tx_list, XL_TX_LIST_SZ); in xl_list_tx_init_90xB()
1687 ld->xl_tx_list[0].xl_status = htole32(XL_TXSTAT_EMPTY); in xl_list_tx_init_90xB()
1689 cd->xl_tx_prod = 1; in xl_list_tx_init_90xB()
1690 cd->xl_tx_cons = 1; in xl_list_tx_init_90xB()
1691 cd->xl_tx_cnt = 0; in xl_list_tx_init_90xB()
1693 bus_dmamap_sync(ld->xl_tx_tag, ld->xl_tx_dmamap, BUS_DMASYNC_PREWRITE); in xl_list_tx_init_90xB()
1712 cd = &sc->xl_cdata; in xl_list_rx_init()
1713 ld = &sc->xl_ldata; in xl_list_rx_init()
1716 cd->xl_rx_chain[i].xl_ptr = &ld->xl_rx_list[i]; in xl_list_rx_init()
1717 error = bus_dmamap_create(sc->xl_mtag, 0, in xl_list_rx_init()
1718 &cd->xl_rx_chain[i].xl_map); in xl_list_rx_init()
1721 error = xl_newbuf(sc, &cd->xl_rx_chain[i]); in xl_list_rx_init()
1724 if (i == (XL_RX_LIST_CNT - 1)) in xl_list_rx_init()
1728 nextptr = ld->xl_rx_dmaaddr + in xl_list_rx_init()
1730 cd->xl_rx_chain[i].xl_next = &cd->xl_rx_chain[next]; in xl_list_rx_init()
1731 ld->xl_rx_list[i].xl_next = htole32(nextptr); in xl_list_rx_init()
1734 bus_dmamap_sync(ld->xl_rx_tag, ld->xl_rx_dmamap, BUS_DMASYNC_PREWRITE); in xl_list_rx_init()
1735 cd->xl_rx_head = &cd->xl_rx_chain[0]; in xl_list_rx_init()
1743 * the old DMA map untouched so that it can be reused.
1759 m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; in xl_newbuf()
1764 error = bus_dmamap_load_mbuf_sg(sc->xl_mtag, sc->xl_tmpmap, m_new, in xl_newbuf()
1768 device_printf(sc->xl_dev, "can't map mbuf (error %d)\n", in xl_newbuf()
1773 ("%s: too many DMA segments (%d)", __func__, nseg)); in xl_newbuf()
1775 bus_dmamap_unload(sc->xl_mtag, c->xl_map); in xl_newbuf()
1776 map = c->xl_map; in xl_newbuf()
1777 c->xl_map = sc->xl_tmpmap; in xl_newbuf()
1778 sc->xl_tmpmap = map; in xl_newbuf()
1779 c->xl_mbuf = m_new; in xl_newbuf()
1780 c->xl_ptr->xl_frag.xl_len = htole32(m_new->m_len | XL_LAST_FRAG); in xl_newbuf()
1781 c->xl_ptr->xl_frag.xl_addr = htole32(segs->ds_addr); in xl_newbuf()
1782 c->xl_ptr->xl_status = 0; in xl_newbuf()
1783 bus_dmamap_sync(sc->xl_mtag, c->xl_map, BUS_DMASYNC_PREREAD); in xl_newbuf()
1795 pos = sc->xl_cdata.xl_rx_head; in xl_rx_resync()
1798 if (pos->xl_ptr->xl_status) in xl_rx_resync()
1800 pos = pos->xl_next; in xl_rx_resync()
1806 sc->xl_cdata.xl_rx_head = pos; in xl_rx_resync()
1819 if_t ifp = sc->xl_ifp; in xl_rxeof()
1827 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, sc->xl_ldata.xl_rx_dmamap, in xl_rxeof()
1829 while ((rxstat = le32toh(sc->xl_cdata.xl_rx_head->xl_ptr->xl_status))) { in xl_rxeof()
1832 if (sc->rxcycles <= 0) in xl_rxeof()
1834 sc->rxcycles--; in xl_rxeof()
1837 cur_rx = sc->xl_cdata.xl_rx_head; in xl_rxeof()
1838 sc->xl_cdata.xl_rx_head = cur_rx->xl_next; in xl_rxeof()
1854 * it should simply get re-used next time this descriptor in xl_rxeof()
1859 cur_rx->xl_ptr->xl_status = 0; in xl_rxeof()
1860 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, in xl_rxeof()
1861 sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); in xl_rxeof()
1871 device_printf(sc->xl_dev, in xl_rxeof()
1872 "bad receive status -- packet dropped\n"); in xl_rxeof()
1874 cur_rx->xl_ptr->xl_status = 0; in xl_rxeof()
1875 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, in xl_rxeof()
1876 sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); in xl_rxeof()
1881 bus_dmamap_sync(sc->xl_mtag, cur_rx->xl_map, in xl_rxeof()
1883 m = cur_rx->xl_mbuf; in xl_rxeof()
1894 cur_rx->xl_ptr->xl_status = 0; in xl_rxeof()
1895 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, in xl_rxeof()
1896 sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); in xl_rxeof()
1899 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, in xl_rxeof()
1900 sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); in xl_rxeof()
1903 m->m_pkthdr.rcvif = ifp; in xl_rxeof()
1904 m->m_pkthdr.len = m->m_len = total_len; in xl_rxeof()
1909 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; in xl_rxeof()
1911 m->m_pkthdr.csum_flags |= CSUM_IP_VALID; in xl_rxeof()
1916 m->m_pkthdr.csum_flags |= in xl_rxeof()
1918 m->m_pkthdr.csum_data = 0xffff; in xl_rxeof()
1951 CSR_WRITE_4(sc, XL_UPLIST_PTR, sc->xl_ldata.xl_rx_dmaaddr); in xl_rxeof()
1952 sc->xl_cdata.xl_rx_head = &sc->xl_cdata.xl_rx_chain[0]; in xl_rxeof()
1968 if (if_getdrvflags(sc->xl_ifp) & IFF_DRV_RUNNING) in xl_rxeof_task()
1981 if_t ifp = sc->xl_ifp; in xl_txeof()
1994 while (sc->xl_cdata.xl_tx_head != NULL) { in xl_txeof()
1995 cur_tx = sc->xl_cdata.xl_tx_head; in xl_txeof()
2000 sc->xl_cdata.xl_tx_head = cur_tx->xl_next; in xl_txeof()
2001 bus_dmamap_sync(sc->xl_mtag, cur_tx->xl_map, in xl_txeof()
2003 bus_dmamap_unload(sc->xl_mtag, cur_tx->xl_map); in xl_txeof()
2004 m_freem(cur_tx->xl_mbuf); in xl_txeof()
2005 cur_tx->xl_mbuf = NULL; in xl_txeof()
2009 cur_tx->xl_next = sc->xl_cdata.xl_tx_free; in xl_txeof()
2010 sc->xl_cdata.xl_tx_free = cur_tx; in xl_txeof()
2013 if (sc->xl_cdata.xl_tx_head == NULL) { in xl_txeof()
2014 sc->xl_wdog_timer = 0; in xl_txeof()
2015 sc->xl_cdata.xl_tx_tail = NULL; in xl_txeof()
2020 sc->xl_cdata.xl_tx_head->xl_phys); in xl_txeof()
2030 if_t ifp = sc->xl_ifp; in xl_txeof_90xB()
2035 bus_dmamap_sync(sc->xl_ldata.xl_tx_tag, sc->xl_ldata.xl_tx_dmamap, in xl_txeof_90xB()
2037 idx = sc->xl_cdata.xl_tx_cons; in xl_txeof_90xB()
2038 while (idx != sc->xl_cdata.xl_tx_prod) { in xl_txeof_90xB()
2039 cur_tx = &sc->xl_cdata.xl_tx_chain[idx]; in xl_txeof_90xB()
2041 if (!(le32toh(cur_tx->xl_ptr->xl_status) & in xl_txeof_90xB()
2045 if (cur_tx->xl_mbuf != NULL) { in xl_txeof_90xB()
2046 bus_dmamap_sync(sc->xl_mtag, cur_tx->xl_map, in xl_txeof_90xB()
2048 bus_dmamap_unload(sc->xl_mtag, cur_tx->xl_map); in xl_txeof_90xB()
2049 m_freem(cur_tx->xl_mbuf); in xl_txeof_90xB()
2050 cur_tx->xl_mbuf = NULL; in xl_txeof_90xB()
2055 sc->xl_cdata.xl_tx_cnt--; in xl_txeof_90xB()
2059 if (sc->xl_cdata.xl_tx_cnt == 0) in xl_txeof_90xB()
2060 sc->xl_wdog_timer = 0; in xl_txeof_90xB()
2061 sc->xl_cdata.xl_tx_cons = idx; in xl_txeof_90xB()
2083 device_printf(sc->xl_dev, in xl_txeoc()
2087 if (sc->xl_type == XL_TYPE_905B) { in xl_txeoc()
2088 if (sc->xl_cdata.xl_tx_cnt) { in xl_txeoc()
2092 i = sc->xl_cdata.xl_tx_cons; in xl_txeoc()
2093 c = &sc->xl_cdata.xl_tx_chain[i]; in xl_txeoc()
2095 c->xl_phys); in xl_txeoc()
2097 sc->xl_wdog_timer = 5; in xl_txeoc()
2100 if (sc->xl_cdata.xl_tx_head != NULL) { in xl_txeoc()
2102 sc->xl_cdata.xl_tx_head->xl_phys); in xl_txeoc()
2103 sc->xl_wdog_timer = 5; in xl_txeoc()
2112 sc->xl_tx_thresh < XL_PACKET_SIZE) { in xl_txeoc()
2113 sc->xl_tx_thresh += XL_MIN_FRAMELEN; in xl_txeoc()
2114 device_printf(sc->xl_dev, in xl_txeoc()
2115 "tx underrun, increasing tx start threshold to %d bytes\n", sc->xl_tx_thresh); in xl_txeoc()
2118 XL_CMD_TX_SET_START|sc->xl_tx_thresh); in xl_txeoc()
2119 if (sc->xl_type == XL_TYPE_905B) { in xl_txeoc()
2141 if_t ifp = sc->xl_ifp; in xl_intr()
2170 if (sc->xl_type == XL_TYPE_905B) in xl_intr()
2193 if (sc->xl_type == XL_TYPE_905B) in xl_intr()
2224 sc->rxcycles = count; in xl_poll_locked()
2226 if (sc->xl_type == XL_TYPE_905B) in xl_poll_locked()
2232 if (sc->xl_type == XL_TYPE_905B) in xl_poll_locked()
2272 if (sc->xl_miibus != NULL) { in xl_tick()
2273 mii = device_get_softc(sc->xl_miibus); in xl_tick()
2281 callout_reset(&sc->xl_tick_callout, hz, xl_tick, sc); in xl_tick()
2287 if_t ifp = sc->xl_ifp; in xl_stats_update()
2313 * in window 4 (BadSSD). We have to read this too in order in xl_stats_update()
2330 if_t ifp = sc->xl_ifp; in xl_encap()
2336 error = bus_dmamap_load_mbuf_sg(sc->xl_mtag, c->xl_map, *m_head, in xl_encap()
2337 sc->xl_cdata.xl_tx_segs, &nseg, BUS_DMA_NOWAIT); in xl_encap()
2361 error = bus_dmamap_load_mbuf_sg(sc->xl_mtag, c->xl_map, in xl_encap()
2362 *m_head, sc->xl_cdata.xl_tx_segs, &nseg, BUS_DMA_NOWAIT); in xl_encap()
2372 ("%s: too many DMA segments (%d)", __func__, nseg)); in xl_encap()
2378 bus_dmamap_sync(sc->xl_mtag, c->xl_map, BUS_DMASYNC_PREWRITE); in xl_encap()
2382 KASSERT(sc->xl_cdata.xl_tx_segs[i].ds_len <= MCLBYTES, in xl_encap()
2384 c->xl_ptr->xl_frag[i].xl_addr = in xl_encap()
2385 htole32(sc->xl_cdata.xl_tx_segs[i].ds_addr); in xl_encap()
2386 c->xl_ptr->xl_frag[i].xl_len = in xl_encap()
2387 htole32(sc->xl_cdata.xl_tx_segs[i].ds_len); in xl_encap()
2388 total_len += sc->xl_cdata.xl_tx_segs[i].ds_len; in xl_encap()
2390 c->xl_ptr->xl_frag[nseg - 1].xl_len |= htole32(XL_LAST_FRAG); in xl_encap()
2392 if (sc->xl_type == XL_TYPE_905B) { in xl_encap()
2396 if ((*m_head)->m_pkthdr.csum_flags) { in xl_encap()
2397 if ((*m_head)->m_pkthdr.csum_flags & CSUM_IP) in xl_encap()
2399 if ((*m_head)->m_pkthdr.csum_flags & CSUM_TCP) in xl_encap()
2401 if ((*m_head)->m_pkthdr.csum_flags & CSUM_UDP) in xl_encap()
2407 c->xl_ptr->xl_status = htole32(status); in xl_encap()
2408 c->xl_ptr->xl_next = 0; in xl_encap()
2410 c->xl_mbuf = *m_head; in xl_encap()
2428 if (sc->xl_type == XL_TYPE_905B) in xl_start()
2454 if (sc->xl_cdata.xl_tx_free == NULL) { in xl_start_locked()
2457 if (sc->xl_cdata.xl_tx_free == NULL) { in xl_start_locked()
2463 start_tx = sc->xl_cdata.xl_tx_free; in xl_start_locked()
2466 sc->xl_cdata.xl_tx_free != NULL;) { in xl_start_locked()
2473 cur_tx = sc->xl_cdata.xl_tx_free; in xl_start_locked()
2486 sc->xl_cdata.xl_tx_free = cur_tx->xl_next; in xl_start_locked()
2487 cur_tx->xl_next = NULL; in xl_start_locked()
2491 prev->xl_next = cur_tx; in xl_start_locked()
2492 prev->xl_ptr->xl_next = htole32(cur_tx->xl_phys); in xl_start_locked()
2500 BPF_MTAP(ifp, cur_tx->xl_mbuf); in xl_start_locked()
2516 cur_tx->xl_ptr->xl_status |= htole32(XL_TXSTAT_DL_INTR); in xl_start_locked()
2525 if (sc->xl_cdata.xl_tx_head != NULL) { in xl_start_locked()
2526 sc->xl_cdata.xl_tx_tail->xl_next = start_tx; in xl_start_locked()
2527 sc->xl_cdata.xl_tx_tail->xl_ptr->xl_next = in xl_start_locked()
2528 htole32(start_tx->xl_phys); in xl_start_locked()
2529 sc->xl_cdata.xl_tx_tail->xl_ptr->xl_status &= in xl_start_locked()
2531 sc->xl_cdata.xl_tx_tail = cur_tx; in xl_start_locked()
2533 sc->xl_cdata.xl_tx_head = start_tx; in xl_start_locked()
2534 sc->xl_cdata.xl_tx_tail = cur_tx; in xl_start_locked()
2536 bus_dmamap_sync(sc->xl_ldata.xl_tx_tag, sc->xl_ldata.xl_tx_dmamap, in xl_start_locked()
2539 CSR_WRITE_4(sc, XL_DOWNLIST_PTR, start_tx->xl_phys); in xl_start_locked()
2548 sc->xl_wdog_timer = 5; in xl_start_locked()
2565 taskqueue_enqueue(taskqueue_swi, &sc->xl_task); in xl_start_locked()
2583 idx = sc->xl_cdata.xl_tx_prod; in xl_start_90xB_locked()
2584 start_tx = &sc->xl_cdata.xl_tx_chain[idx]; in xl_start_90xB_locked()
2587 sc->xl_cdata.xl_tx_chain[idx].xl_mbuf == NULL;) { in xl_start_90xB_locked()
2588 if ((XL_TX_LIST_CNT - sc->xl_cdata.xl_tx_cnt) < 3) { in xl_start_90xB_locked()
2598 cur_tx = &sc->xl_cdata.xl_tx_chain[idx]; in xl_start_90xB_locked()
2613 prev->xl_ptr->xl_next = htole32(cur_tx->xl_phys); in xl_start_90xB_locked()
2620 BPF_MTAP(ifp, cur_tx->xl_mbuf); in xl_start_90xB_locked()
2623 sc->xl_cdata.xl_tx_cnt++; in xl_start_90xB_locked()
2639 cur_tx->xl_ptr->xl_status |= htole32(XL_TXSTAT_DL_INTR); in xl_start_90xB_locked()
2642 sc->xl_cdata.xl_tx_prod = idx; in xl_start_90xB_locked()
2643 start_tx->xl_prev->xl_ptr->xl_next = htole32(start_tx->xl_phys); in xl_start_90xB_locked()
2644 bus_dmamap_sync(sc->xl_ldata.xl_tx_tag, sc->xl_ldata.xl_tx_dmamap, in xl_start_90xB_locked()
2650 sc->xl_wdog_timer = 5; in xl_start_90xB_locked()
2666 if_t ifp = sc->xl_ifp; in xl_init_locked()
2682 if (sc->xl_miibus == NULL) { in xl_init_locked()
2690 if (sc->xl_miibus != NULL) in xl_init_locked()
2691 mii = device_get_softc(sc->xl_miibus); in xl_init_locked()
2697 if ((sc->xl_flags & XL_FLAG_WOL) != 0) { in xl_init_locked()
2706 if_getlladdr(sc->xl_ifp)[i]); in xl_init_locked()
2722 device_printf(sc->xl_dev, "initialization of the rx ring failed (%d)\n", in xl_init_locked()
2729 if (sc->xl_type == XL_TYPE_905B) in xl_init_locked()
2734 device_printf(sc->xl_dev, "initialization of the tx ring failed (%d)\n", in xl_init_locked()
2749 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_TX_SET_START|sc->xl_tx_thresh); in xl_init_locked()
2758 * the register at offset 9 in window 5. in xl_init_locked()
2760 if (sc->xl_type == XL_TYPE_905B) { in xl_init_locked()
2780 CSR_WRITE_4(sc, XL_UPLIST_PTR, sc->xl_ldata.xl_rx_dmaaddr); in xl_init_locked()
2784 if (sc->xl_type == XL_TYPE_905B) { in xl_init_locked()
2791 sc->xl_cdata.xl_tx_chain[0].xl_phys); in xl_init_locked()
2798 * the DC-DC converter. in xl_init_locked()
2801 if (sc->xl_xcvr == XL_XCVR_COAX) in xl_init_locked()
2813 if (sc->xl_type == XL_TYPE_905B) in xl_init_locked()
2841 if (sc->xl_flags & XL_FLAG_FUNCREG) in xl_init_locked()
2842 bus_space_write_4(sc->xl_ftag, sc->xl_fhandle, 4, 0x8000); in xl_init_locked()
2858 /* Select window 7 for normal operations. */ in xl_init_locked()
2864 sc->xl_wdog_timer = 0; in xl_init_locked()
2865 callout_reset(&sc->xl_tick_callout, hz, xl_tick, sc); in xl_init_locked()
2880 if (sc->xl_miibus != NULL) in xl_ifmedia_upd()
2881 mii = device_get_softc(sc->xl_miibus); in xl_ifmedia_upd()
2883 ifm = &sc->ifmedia; in xl_ifmedia_upd()
2885 ifm = &mii->mii_media; in xl_ifmedia_upd()
2887 switch (IFM_SUBTYPE(ifm->ifm_media)) { in xl_ifmedia_upd()
2892 xl_setmode(sc, ifm->ifm_media); in xl_ifmedia_upd()
2897 if (sc->xl_media & XL_MEDIAOPT_MII || in xl_ifmedia_upd()
2898 sc->xl_media & XL_MEDIAOPT_BTX || in xl_ifmedia_upd()
2899 sc->xl_media & XL_MEDIAOPT_BT4) { in xl_ifmedia_upd()
2903 xl_setmode(sc, ifm->ifm_media); in xl_ifmedia_upd()
2924 if (sc->xl_miibus != NULL) in xl_ifmedia_sts()
2925 mii = device_get_softc(sc->xl_miibus); in xl_ifmedia_sts()
2934 ifmr->ifm_active = IFM_ETHER; in xl_ifmedia_sts()
2935 ifmr->ifm_status = IFM_AVALID; in xl_ifmedia_sts()
2938 ifmr->ifm_status |= IFM_ACTIVE; in xl_ifmedia_sts()
2942 ifmr->ifm_active = IFM_ETHER|IFM_10_T; in xl_ifmedia_sts()
2944 ifmr->ifm_active |= IFM_FDX; in xl_ifmedia_sts()
2946 ifmr->ifm_active |= IFM_HDX; in xl_ifmedia_sts()
2949 if (sc->xl_type == XL_TYPE_905B && in xl_ifmedia_sts()
2950 sc->xl_media == XL_MEDIAOPT_10FL) { in xl_ifmedia_sts()
2951 ifmr->ifm_active = IFM_ETHER|IFM_10_FL; in xl_ifmedia_sts()
2953 ifmr->ifm_active |= IFM_FDX; in xl_ifmedia_sts()
2955 ifmr->ifm_active |= IFM_HDX; in xl_ifmedia_sts()
2957 ifmr->ifm_active = IFM_ETHER|IFM_10_5; in xl_ifmedia_sts()
2960 ifmr->ifm_active = IFM_ETHER|IFM_10_2; in xl_ifmedia_sts()
2971 ifmr->ifm_active = mii->mii_media_active; in xl_ifmedia_sts()
2972 ifmr->ifm_status = mii->mii_media_status; in xl_ifmedia_sts()
2976 ifmr->ifm_active = IFM_ETHER|IFM_100_FX; in xl_ifmedia_sts()
2999 (if_getflags(ifp) ^ sc->xl_if_flags) & in xl_ioctl()
3008 sc->xl_if_flags = if_getflags(ifp); in xl_ioctl()
3021 if (sc->xl_miibus != NULL) in xl_ioctl()
3022 mii = device_get_softc(sc->xl_miibus); in xl_ioctl()
3025 &sc->ifmedia, command); in xl_ioctl()
3028 &mii->mii_media, command); in xl_ioctl()
3031 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in xl_ioctl()
3053 if (sc->xl_flags & XL_FLAG_FUNCREG) in xl_ioctl()
3054 bus_space_write_4(sc->xl_ftag, in xl_ioctl()
3055 sc->xl_fhandle, 4, 0x8000); in xl_ioctl()
3088 if_t ifp = sc->xl_ifp; in xl_watchdog()
3094 if (sc->xl_wdog_timer == 0 || --sc->xl_wdog_timer != 0) in xl_watchdog()
3100 if (sc->xl_type == XL_TYPE_905B) { in xl_watchdog()
3102 if (sc->xl_cdata.xl_tx_cnt == 0) in xl_watchdog()
3106 if (sc->xl_cdata.xl_tx_head == NULL) in xl_watchdog()
3110 device_printf(sc->xl_dev, in xl_watchdog()
3111 "watchdog timeout (missed Tx interrupts) -- recovering\n"); in xl_watchdog()
3118 device_printf(sc->xl_dev, "watchdog timeout\n"); in xl_watchdog()
3121 device_printf(sc->xl_dev, in xl_watchdog()
3122 "no carrier - transceiver cable problem?\n"); in xl_watchdog()
3128 if (sc->xl_type == XL_TYPE_905B) in xl_watchdog()
3145 if_t ifp = sc->xl_ifp; in xl_stop()
3149 sc->xl_wdog_timer = 0; in xl_stop()
3170 if (sc->xl_flags & XL_FLAG_FUNCREG) in xl_stop()
3171 bus_space_write_4(sc->xl_ftag, sc->xl_fhandle, 4, 0x8000); in xl_stop()
3174 callout_stop(&sc->xl_tick_callout); in xl_stop()
3180 if (sc->xl_cdata.xl_rx_chain[i].xl_mbuf != NULL) { in xl_stop()
3181 bus_dmamap_unload(sc->xl_mtag, in xl_stop()
3182 sc->xl_cdata.xl_rx_chain[i].xl_map); in xl_stop()
3183 bus_dmamap_destroy(sc->xl_mtag, in xl_stop()
3184 sc->xl_cdata.xl_rx_chain[i].xl_map); in xl_stop()
3185 m_freem(sc->xl_cdata.xl_rx_chain[i].xl_mbuf); in xl_stop()
3186 sc->xl_cdata.xl_rx_chain[i].xl_mbuf = NULL; in xl_stop()
3189 if (sc->xl_ldata.xl_rx_list != NULL) in xl_stop()
3190 bzero(sc->xl_ldata.xl_rx_list, XL_RX_LIST_SZ); in xl_stop()
3195 if (sc->xl_cdata.xl_tx_chain[i].xl_mbuf != NULL) { in xl_stop()
3196 bus_dmamap_unload(sc->xl_mtag, in xl_stop()
3197 sc->xl_cdata.xl_tx_chain[i].xl_map); in xl_stop()
3198 bus_dmamap_destroy(sc->xl_mtag, in xl_stop()
3199 sc->xl_cdata.xl_tx_chain[i].xl_map); in xl_stop()
3200 m_freem(sc->xl_cdata.xl_tx_chain[i].xl_mbuf); in xl_stop()
3201 sc->xl_cdata.xl_tx_chain[i].xl_mbuf = NULL; in xl_stop()
3204 if (sc->xl_ldata.xl_tx_list != NULL) in xl_stop()
3205 bzero(sc->xl_ldata.xl_tx_list, XL_TX_LIST_SZ); in xl_stop()
3243 ifp = sc->xl_ifp; in xl_resume()
3263 if ((sc->xl_flags & XL_FLAG_WOL) == 0) in xl_setwol()
3266 ifp = sc->xl_ifp; in xl_setwol()
3278 pmstat = pci_read_config(sc->xl_dev, in xl_setwol()
3279 sc->xl_pmcap + PCIR_POWER_STATUS, 2); in xl_setwol()
3284 pci_write_config(sc->xl_dev, in xl_setwol()
3285 sc->xl_pmcap + PCIR_POWER_STATUS, pmstat, 2); in xl_setwol()