Lines Matching +full:idle +full:- +full:wait +full:- +full:delay
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
91 { -1, 0, 0 }
95 { -1, 0, 0 }
99 { -1, 0, 0 }
189 bus_read_4((sc)->mem[0], (reg))
191 bus_read_2((sc)->mem[0], (reg))
193 bus_read_1((sc)->mem[0], (reg))
195 bus_write_4((sc)->mem[0], (reg), (val))
197 bus_write_2((sc)->mem[0], (reg), (val))
199 bus_write_1((sc)->mem[0], (reg), (val))
201 ae_miibus_readreg(sc->dev, 0, reg)
203 ae_miibus_writereg(sc->dev, 0, reg, val)
247 sc->dev = dev; in ae_attach()
252 mtx_init(&sc->mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, MTX_DEF); in ae_attach()
253 callout_init_mtx(&sc->tick_ch, &sc->mtx, 0); in ae_attach()
254 TASK_INIT(&sc->int_task, 0, ae_int_task, sc); in ae_attach()
255 TASK_INIT(&sc->link_task, 0, ae_link_task, sc); in ae_attach()
259 sc->spec_mem = ae_res_spec_mem; in ae_attach()
262 * Allocate memory-mapped registers. in ae_attach()
264 error = bus_alloc_resources(dev, sc->spec_mem, sc->mem); in ae_attach()
267 sc->spec_mem = NULL; in ae_attach()
292 sc->spec_irq = ae_res_spec_msi; in ae_attach()
293 error = bus_alloc_resources(dev, sc->spec_irq, sc->irq); in ae_attach()
296 sc->spec_irq = NULL; in ae_attach()
299 sc->flags |= AE_FLAG_MSI; in ae_attach()
303 if (sc->spec_irq == NULL) { in ae_attach()
304 sc->spec_irq = ae_res_spec_irq; in ae_attach()
305 error = bus_alloc_resources(dev, sc->spec_irq, sc->irq); in ae_attach()
308 sc->spec_irq = NULL; in ae_attach()
328 ifp = sc->ifp = if_alloc(IFT_ETHER); in ae_attach()
341 sc->flags |= AE_FLAG_PMG; in ae_attach()
348 error = mii_attach(dev, &sc->miibus, ifp, ae_mediachange, in ae_attach()
356 ether_ifattach(ifp, sc->eaddr); in ae_attach()
363 sc->tq = taskqueue_create_fast("ae_taskq", M_WAITOK, in ae_attach()
364 taskqueue_thread_enqueue, &sc->tq); in ae_attach()
365 taskqueue_start_threads(&sc->tq, 1, PI_NET, "%s taskq", in ae_attach()
366 device_get_nameunit(sc->dev)); in ae_attach()
371 error = bus_setup_intr(dev, sc->irq[0], INTR_TYPE_NET | INTR_MPSAFE, in ae_attach()
372 ae_intr, NULL, sc, &sc->intrhand); in ae_attach()
375 taskqueue_free(sc->tq); in ae_attach()
376 sc->tq = NULL; in ae_attach()
399 ae_stats = &sc->stats; in ae_init_tunables()
401 ctx = device_get_sysctl_ctx(sc->dev); in ae_init_tunables()
402 root = device_get_sysctl_tree(sc->dev); in ae_init_tunables()
412 "broadcast frames", &ae_stats->rx_bcast); in ae_init_tunables()
414 "multicast frames", &ae_stats->rx_mcast); in ae_init_tunables()
416 "PAUSE frames", &ae_stats->rx_pause); in ae_init_tunables()
418 "control frames", &ae_stats->rx_ctrl); in ae_init_tunables()
420 "frames with CRC errors", &ae_stats->rx_crcerr); in ae_init_tunables()
422 "frames with invalid opcode", &ae_stats->rx_codeerr); in ae_init_tunables()
424 "runt frames", &ae_stats->rx_runt); in ae_init_tunables()
426 "fragmented frames", &ae_stats->rx_frag); in ae_init_tunables()
428 "frames with alignment errors", &ae_stats->rx_align); in ae_init_tunables()
430 "frames truncated due to Rx FIFO inderrun", &ae_stats->rx_trunc); in ae_init_tunables()
438 "broadcast frames", &ae_stats->tx_bcast); in ae_init_tunables()
440 "multicast frames", &ae_stats->tx_mcast); in ae_init_tunables()
442 "PAUSE frames", &ae_stats->tx_pause); in ae_init_tunables()
444 "control frames", &ae_stats->tx_ctrl); in ae_init_tunables()
446 "deferrals occuried", &ae_stats->tx_defer); in ae_init_tunables()
448 "excessive deferrals occuried", &ae_stats->tx_excdefer); in ae_init_tunables()
450 "single collisions occuried", &ae_stats->tx_singlecol); in ae_init_tunables()
452 "multiple collisions occuried", &ae_stats->tx_multicol); in ae_init_tunables()
454 "late collisions occuried", &ae_stats->tx_latecol); in ae_init_tunables()
456 "transmit aborts due collisions", &ae_stats->tx_abortcol); in ae_init_tunables()
458 "Tx FIFO underruns", &ae_stats->tx_underrun); in ae_init_tunables()
474 DELAY(1000); /* XXX: pause(9) ? */ in ae_phy_reset()
486 bus_barrier(sc->mem[0], AE_MASTER_REG, 4, in ae_reset()
490 * Wait for reset to complete. in ae_reset()
495 DELAY(10); in ae_reset()
498 device_printf(sc->dev, "reset timeout.\n"); in ae_reset()
503 * Wait for everything to enter idle state. in ae_reset()
508 DELAY(100); in ae_reset()
511 device_printf(sc->dev, "could not enter idle state.\n"); in ae_reset()
552 ifp = sc->ifp; in ae_init_locked()
555 mii = device_get_softc(sc->miibus); in ae_init_locked()
577 bzero(sc->rxd_base_dma, AE_RXD_COUNT_DEFAULT * 1536 + AE_RXD_PADDING); in ae_init_locked()
578 bzero(sc->txd_base, AE_TXD_BUFSIZE_DEFAULT); in ae_init_locked()
579 bzero(sc->txs_base, AE_TXS_COUNT_DEFAULT * 4); in ae_init_locked()
583 addr = sc->dma_rxd_busaddr; in ae_init_locked()
586 addr = sc->dma_txd_busaddr; in ae_init_locked()
588 addr = sc->dma_txs_busaddr; in ae_init_locked()
612 * Configure half-duplex operation. in ae_init_locked()
645 * Configure cut-through threshold. in ae_init_locked()
660 sc->txd_cur = sc->rxd_cur = 0; in ae_init_locked()
661 sc->txs_ack = sc->txd_ack = 0; in ae_init_locked()
662 sc->rxd_cur = 0; in ae_init_locked()
663 AE_WRITE_2(sc, AE_MB_TXD_IDX_REG, sc->txd_cur); in ae_init_locked()
664 AE_WRITE_2(sc, AE_MB_RXD_IDX_REG, sc->rxd_cur); in ae_init_locked()
666 sc->tx_inproc = 0; /* Number of packets the chip processes now. */ in ae_init_locked()
667 sc->flags |= AE_FLAG_TXAVAIL; /* Free Tx's available. */ in ae_init_locked()
680 device_printf(sc->dev, "Initialization failed.\n"); in ae_init_locked()
725 sc->flags &= ~AE_FLAG_LINK; in ae_init_locked()
728 callout_reset(&sc->tick_ch, hz, ae_tick, sc); in ae_init_locked()
734 device_printf(sc->dev, "Initialization complete.\n"); in ae_init_locked()
748 ifp = sc->ifp; in ae_detach()
751 sc->flags |= AE_FLAG_DETACH; in ae_detach()
754 callout_drain(&sc->tick_ch); in ae_detach()
755 taskqueue_drain(sc->tq, &sc->int_task); in ae_detach()
756 taskqueue_drain(taskqueue_swi, &sc->link_task); in ae_detach()
759 if (sc->tq != NULL) { in ae_detach()
760 taskqueue_drain(sc->tq, &sc->int_task); in ae_detach()
761 taskqueue_free(sc->tq); in ae_detach()
762 sc->tq = NULL; in ae_detach()
764 if (sc->miibus != NULL) { in ae_detach()
765 device_delete_child(dev, sc->miibus); in ae_detach()
766 sc->miibus = NULL; in ae_detach()
768 bus_generic_detach(sc->dev); in ae_detach()
770 if (sc->intrhand != NULL) { in ae_detach()
771 bus_teardown_intr(dev, sc->irq[0], sc->intrhand); in ae_detach()
772 sc->intrhand = NULL; in ae_detach()
776 sc->ifp = NULL; in ae_detach()
778 if (sc->spec_irq != NULL) in ae_detach()
779 bus_release_resources(dev, sc->spec_irq, sc->irq); in ae_detach()
780 if (sc->spec_mem != NULL) in ae_detach()
781 bus_release_resources(dev, sc->spec_mem, sc->mem); in ae_detach()
782 if ((sc->flags & AE_FLAG_MSI) != 0) in ae_detach()
784 mtx_destroy(&sc->mtx); in ae_detach()
809 * Wait for operation to complete. in ae_miibus_readreg()
812 DELAY(2); in ae_miibus_readreg()
818 device_printf(sc->dev, "phy read timeout: %d.\n", reg); in ae_miibus_readreg()
845 * Wait for operation to complete. in ae_miibus_writereg()
848 DELAY(2); in ae_miibus_writereg()
854 device_printf(sc->dev, "phy write timeout: %d.\n", reg); in ae_miibus_writereg()
865 taskqueue_enqueue(taskqueue_swi, &sc->link_task); in ae_miibus_statchg()
878 mii = device_get_softc(sc->miibus); in ae_mediastatus()
880 ifmr->ifm_status = mii->mii_media_status; in ae_mediastatus()
881 ifmr->ifm_active = mii->mii_media_active; in ae_mediastatus()
897 mii = device_get_softc(sc->miibus); in ae_mediachange()
898 LIST_FOREACH(mii_sc, &mii->mii_phys, mii_list) in ae_mediachange()
922 error = pci_find_cap(sc->dev, PCIY_VPD, vpdc); in ae_check_eeprom_present()
941 DELAY(2000); in ae_vpd_read_word()
947 device_printf(sc->dev, "timeout reading VPD register %d.\n", in ae_vpd_read_word()
1011 device_printf(sc->dev, in ae_get_vpd_eaddr()
1031 device_printf(sc->dev, in ae_get_reg_eaddr()
1052 device_printf(sc->dev, in ae_retrieve_address()
1059 sc->eaddr[0] = 0x02; /* U/L bit set. */ in ae_retrieve_address()
1060 sc->eaddr[1] = 0x1f; in ae_retrieve_address()
1061 sc->eaddr[2] = 0xc6; in ae_retrieve_address()
1062 sc->eaddr[3] = (eaddr[0] >> 16) & 0xff; in ae_retrieve_address()
1063 sc->eaddr[4] = (eaddr[0] >> 8) & 0xff; in ae_retrieve_address()
1064 sc->eaddr[5] = (eaddr[0] >> 0) & 0xff; in ae_retrieve_address()
1066 sc->eaddr[0] = (eaddr[1] >> 8) & 0xff; in ae_retrieve_address()
1067 sc->eaddr[1] = (eaddr[1] >> 0) & 0xff; in ae_retrieve_address()
1068 sc->eaddr[2] = (eaddr[0] >> 24) & 0xff; in ae_retrieve_address()
1069 sc->eaddr[3] = (eaddr[0] >> 16) & 0xff; in ae_retrieve_address()
1070 sc->eaddr[4] = (eaddr[0] >> 8) & 0xff; in ae_retrieve_address()
1071 sc->eaddr[5] = (eaddr[0] >> 0) & 0xff; in ae_retrieve_address()
1096 error = bus_dma_tag_create(bus_get_dma_tag(sc->dev), in ae_alloc_rings()
1100 &sc->dma_parent_tag); in ae_alloc_rings()
1102 device_printf(sc->dev, "could not creare parent DMA tag.\n"); in ae_alloc_rings()
1109 error = bus_dma_tag_create(sc->dma_parent_tag, in ae_alloc_rings()
1113 &sc->dma_txd_tag); in ae_alloc_rings()
1115 device_printf(sc->dev, "could not creare TxD DMA tag.\n"); in ae_alloc_rings()
1122 error = bus_dma_tag_create(sc->dma_parent_tag, in ae_alloc_rings()
1126 &sc->dma_txs_tag); in ae_alloc_rings()
1128 device_printf(sc->dev, "could not creare TxS DMA tag.\n"); in ae_alloc_rings()
1135 error = bus_dma_tag_create(sc->dma_parent_tag, in ae_alloc_rings()
1139 &sc->dma_rxd_tag); in ae_alloc_rings()
1141 device_printf(sc->dev, "could not creare TxS DMA tag.\n"); in ae_alloc_rings()
1148 error = bus_dmamem_alloc(sc->dma_txd_tag, (void **)&sc->txd_base, in ae_alloc_rings()
1150 &sc->dma_txd_map); in ae_alloc_rings()
1152 device_printf(sc->dev, in ae_alloc_rings()
1156 error = bus_dmamap_load(sc->dma_txd_tag, sc->dma_txd_map, sc->txd_base, in ae_alloc_rings()
1159 device_printf(sc->dev, in ae_alloc_rings()
1163 sc->dma_txd_busaddr = busaddr; in ae_alloc_rings()
1168 error = bus_dmamem_alloc(sc->dma_txs_tag, (void **)&sc->txs_base, in ae_alloc_rings()
1170 &sc->dma_txs_map); in ae_alloc_rings()
1172 device_printf(sc->dev, in ae_alloc_rings()
1176 error = bus_dmamap_load(sc->dma_txs_tag, sc->dma_txs_map, sc->txs_base, in ae_alloc_rings()
1179 device_printf(sc->dev, in ae_alloc_rings()
1183 sc->dma_txs_busaddr = busaddr; in ae_alloc_rings()
1188 error = bus_dmamem_alloc(sc->dma_rxd_tag, (void **)&sc->rxd_base_dma, in ae_alloc_rings()
1190 &sc->dma_rxd_map); in ae_alloc_rings()
1192 device_printf(sc->dev, in ae_alloc_rings()
1196 error = bus_dmamap_load(sc->dma_rxd_tag, sc->dma_rxd_map, in ae_alloc_rings()
1197 sc->rxd_base_dma, AE_RXD_COUNT_DEFAULT * 1536 + AE_RXD_PADDING, in ae_alloc_rings()
1200 device_printf(sc->dev, in ae_alloc_rings()
1204 sc->dma_rxd_busaddr = busaddr + AE_RXD_PADDING; in ae_alloc_rings()
1205 sc->rxd_base = (ae_rxd_t *)(sc->rxd_base_dma + AE_RXD_PADDING); in ae_alloc_rings()
1214 if (sc->dma_txd_tag != NULL) { in ae_dma_free()
1215 if (sc->dma_txd_busaddr != 0) in ae_dma_free()
1216 bus_dmamap_unload(sc->dma_txd_tag, sc->dma_txd_map); in ae_dma_free()
1217 if (sc->txd_base != NULL) in ae_dma_free()
1218 bus_dmamem_free(sc->dma_txd_tag, sc->txd_base, in ae_dma_free()
1219 sc->dma_txd_map); in ae_dma_free()
1220 bus_dma_tag_destroy(sc->dma_txd_tag); in ae_dma_free()
1221 sc->dma_txd_tag = NULL; in ae_dma_free()
1222 sc->txd_base = NULL; in ae_dma_free()
1223 sc->dma_txd_busaddr = 0; in ae_dma_free()
1225 if (sc->dma_txs_tag != NULL) { in ae_dma_free()
1226 if (sc->dma_txs_busaddr != 0) in ae_dma_free()
1227 bus_dmamap_unload(sc->dma_txs_tag, sc->dma_txs_map); in ae_dma_free()
1228 if (sc->txs_base != NULL) in ae_dma_free()
1229 bus_dmamem_free(sc->dma_txs_tag, sc->txs_base, in ae_dma_free()
1230 sc->dma_txs_map); in ae_dma_free()
1231 bus_dma_tag_destroy(sc->dma_txs_tag); in ae_dma_free()
1232 sc->dma_txs_tag = NULL; in ae_dma_free()
1233 sc->txs_base = NULL; in ae_dma_free()
1234 sc->dma_txs_busaddr = 0; in ae_dma_free()
1236 if (sc->dma_rxd_tag != NULL) { in ae_dma_free()
1237 if (sc->dma_rxd_busaddr != 0) in ae_dma_free()
1238 bus_dmamap_unload(sc->dma_rxd_tag, sc->dma_rxd_map); in ae_dma_free()
1239 if (sc->rxd_base_dma != NULL) in ae_dma_free()
1240 bus_dmamem_free(sc->dma_rxd_tag, sc->rxd_base_dma, in ae_dma_free()
1241 sc->dma_rxd_map); in ae_dma_free()
1242 bus_dma_tag_destroy(sc->dma_rxd_tag); in ae_dma_free()
1243 sc->dma_rxd_tag = NULL; in ae_dma_free()
1244 sc->rxd_base_dma = NULL; in ae_dma_free()
1245 sc->dma_rxd_busaddr = 0; in ae_dma_free()
1247 if (sc->dma_parent_tag != NULL) { in ae_dma_free()
1248 bus_dma_tag_destroy(sc->dma_parent_tag); in ae_dma_free()
1249 sc->dma_parent_tag = NULL; in ae_dma_free()
1281 DELAY(1000); in ae_powersave_disable()
1315 ifp = sc->ifp; in ae_pm_init()
1316 if ((sc->flags & AE_FLAG_PMG) == 0) { in ae_pm_init()
1326 mii = device_get_softc(sc->miibus); in ae_pm_init()
1328 if ((mii->mii_media_status & IFM_AVALID) != 0 && in ae_pm_init()
1329 (mii->mii_media_status & IFM_ACTIVE) != 0) { in ae_pm_init()
1343 if ((IFM_OPTIONS(mii->mii_media_active) & \ in ae_pm_init()
1370 if (pci_find_cap(sc->dev, PCIY_PMG, &pmc) == 0) { in ae_pm_init()
1371 pmstat = pci_read_config(sc->dev, pmc + PCIR_POWER_STATUS, 2); in ae_pm_init()
1375 pci_write_config(sc->dev, pmc + PCIR_POWER_STATUS, pmstat, 2); in ae_pm_init()
1404 if ((if_getflags(sc->ifp) & IFF_UP) != 0) in ae_resume()
1416 if (sc->txd_cur >= sc->txd_ack) in ae_tx_avail_size()
1417 avail = AE_TXD_BUFSIZE_DEFAULT - (sc->txd_cur - sc->txd_ack); in ae_tx_avail_size()
1419 avail = sc->txd_ack - sc->txd_cur; in ae_tx_avail_size()
1435 len = m0->m_pkthdr.len; in ae_encap()
1437 if ((sc->flags & AE_FLAG_TXAVAIL) == 0 || in ae_encap()
1440 if_printf(sc->ifp, "No free Tx available.\n"); in ae_encap()
1445 hdr = (ae_txd_t *)(sc->txd_base + sc->txd_cur); in ae_encap()
1448 sc->txd_cur = (sc->txd_cur + sizeof(ae_txd_t)) % AE_TXD_BUFSIZE_DEFAULT; in ae_encap()
1450 to_end = AE_TXD_BUFSIZE_DEFAULT - sc->txd_cur; in ae_encap()
1452 m_copydata(m0, 0, len, (caddr_t)(sc->txd_base + sc->txd_cur)); in ae_encap()
1454 m_copydata(m0, 0, to_end, (caddr_t)(sc->txd_base + in ae_encap()
1455 sc->txd_cur)); in ae_encap()
1456 m_copydata(m0, to_end, len - to_end, (caddr_t)sc->txd_base); in ae_encap()
1462 if ((m0->m_flags & M_VLANTAG) != 0) { in ae_encap()
1463 hdr->vlan = htole16(AE_TXD_VLAN(m0->m_pkthdr.ether_vtag)); in ae_encap()
1464 hdr->len = htole16(len | AE_TXD_INSERT_VTAG); in ae_encap()
1466 hdr->len = htole16(len); in ae_encap()
1470 * Set current TxD position and round up to a 4-byte boundary. in ae_encap()
1472 sc->txd_cur = ((sc->txd_cur + len + 3) & ~3) % AE_TXD_BUFSIZE_DEFAULT; in ae_encap()
1473 if (sc->txd_cur == sc->txd_ack) in ae_encap()
1474 sc->flags &= ~AE_FLAG_TXAVAIL; in ae_encap()
1476 if_printf(sc->ifp, "New txd_cur = %d.\n", sc->txd_cur); in ae_encap()
1482 sc->txs_base[sc->txs_cur].flags &= ~htole16(AE_TXS_UPDATE); in ae_encap()
1483 sc->txs_cur = (sc->txs_cur + 1) % AE_TXS_COUNT_DEFAULT; in ae_encap()
1484 if (sc->txs_cur == sc->txs_ack) in ae_encap()
1485 sc->flags &= ~AE_FLAG_TXAVAIL; in ae_encap()
1490 bus_dmamap_sync(sc->dma_txd_tag, sc->dma_txd_map, BUS_DMASYNC_PREREAD | in ae_encap()
1492 bus_dmamap_sync(sc->dma_txs_tag, sc->dma_txs_map, in ae_encap()
1526 IFF_DRV_RUNNING || (sc->flags & AE_FLAG_LINK) == 0) in ae_start_locked()
1547 sc->tx_inproc++; in ae_start_locked()
1556 AE_WRITE_2(sc, AE_MB_TXD_IDX_REG, sc->txd_cur / 4); in ae_start_locked()
1557 sc->wd_timer = AE_TX_TIMEOUT; /* Load watchdog. */ in ae_start_locked()
1560 if_printf(ifp, "Tx pos now is %d.\n", sc->txd_cur); in ae_start_locked()
1577 ifp = sc->ifp; in ae_link_task()
1578 mii = device_get_softc(sc->miibus); in ae_link_task()
1585 sc->flags &= ~AE_FLAG_LINK; in ae_link_task()
1586 if ((mii->mii_media_status & (IFM_AVALID | IFM_ACTIVE)) == in ae_link_task()
1588 switch(IFM_SUBTYPE(mii->mii_media_active)) { in ae_link_task()
1591 sc->flags |= AE_FLAG_LINK; in ae_link_task()
1604 if ((sc->flags & AE_FLAG_LINK) != 0) { in ae_link_task()
1647 * Wait for IDLE state. in ae_stop_rxmac()
1653 DELAY(100); in ae_stop_rxmac()
1656 device_printf(sc->dev, "timed out while stopping Rx MAC.\n"); in ae_stop_rxmac()
1683 * Wait for IDLE state. in ae_stop_txmac()
1689 DELAY(100); in ae_stop_txmac()
1692 device_printf(sc->dev, "timed out while stopping Tx MAC.\n"); in ae_stop_txmac()
1703 mii = device_get_softc(sc->miibus); in ae_mac_config()
1708 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) in ae_mac_config()
1731 taskqueue_enqueue(sc->tq, &sc->int_task); in ae_intr()
1747 ifp = sc->ifp; in ae_int_task()
1777 * Re-enable interrupts. in ae_int_task()
1781 if ((sc->flags & AE_FLAG_TXAVAIL) != 0) { in ae_int_task()
1800 ifp = sc->ifp; in ae_tx_intr()
1809 bus_dmamap_sync(sc->dma_txd_tag, sc->dma_txd_map, in ae_tx_intr()
1811 bus_dmamap_sync(sc->dma_txs_tag, sc->dma_txs_map, in ae_tx_intr()
1815 txs = sc->txs_base + sc->txs_ack; in ae_tx_intr()
1816 flags = le16toh(txs->flags); in ae_tx_intr()
1819 txs->flags = htole16(flags & ~AE_TXS_UPDATE); in ae_tx_intr()
1821 ae_update_stats_tx(flags, &sc->stats); in ae_tx_intr()
1826 sc->txs_ack = (sc->txs_ack + 1) % AE_TXS_COUNT_DEFAULT; in ae_tx_intr()
1827 sc->flags |= AE_FLAG_TXAVAIL; in ae_tx_intr()
1829 txd = (ae_txd_t *)(sc->txd_base + sc->txd_ack); in ae_tx_intr()
1830 if (txs->len != txd->len) in ae_tx_intr()
1831 device_printf(sc->dev, "Size mismatch: TxS:%d TxD:%d\n", in ae_tx_intr()
1832 le16toh(txs->len), le16toh(txd->len)); in ae_tx_intr()
1835 * Move txd ack and align on 4-byte boundary. in ae_tx_intr()
1837 sc->txd_ack = ((sc->txd_ack + le16toh(txd->len) + in ae_tx_intr()
1845 sc->tx_inproc--; in ae_tx_intr()
1848 if ((sc->flags & AE_FLAG_TXAVAIL) != 0) in ae_tx_intr()
1850 if (sc->tx_inproc < 0) { in ae_tx_intr()
1852 sc->tx_inproc = 0; in ae_tx_intr()
1855 if (sc->tx_inproc == 0) in ae_tx_intr()
1856 sc->wd_timer = 0; /* Unarm watchdog. */ in ae_tx_intr()
1861 bus_dmamap_sync(sc->dma_txd_tag, sc->dma_txd_map, in ae_tx_intr()
1863 bus_dmamap_sync(sc->dma_txs_tag, sc->dma_txs_map, in ae_tx_intr()
1877 ifp = sc->ifp; in ae_rxeof()
1878 flags = le16toh(rxd->flags); in ae_rxeof()
1883 size = le16toh(rxd->len) - ETHER_CRC_LEN; in ae_rxeof()
1884 if (size < (ETHER_MIN_LEN - ETHER_CRC_LEN - ETHER_VLAN_ENCAP_LEN)) { in ae_rxeof()
1890 m = m_devget(&rxd->data[0], size, ETHER_ALIGN, ifp, NULL); in ae_rxeof()
1898 m->m_pkthdr.ether_vtag = AE_RXD_VLAN(le16toh(rxd->vlan)); in ae_rxeof()
1899 m->m_flags |= M_VLANTAG; in ae_rxeof()
1923 ifp = sc->ifp; in ae_rx_intr()
1928 bus_dmamap_sync(sc->dma_rxd_tag, sc->dma_rxd_map, in ae_rx_intr()
1932 rxd = (ae_rxd_t *)(sc->rxd_base + sc->rxd_cur); in ae_rx_intr()
1933 flags = le16toh(rxd->flags); in ae_rx_intr()
1936 rxd->flags = htole16(flags & ~AE_RXD_UPDATE); in ae_rx_intr()
1938 ae_update_stats_rx(flags, &sc->stats); in ae_rx_intr()
1943 sc->rxd_cur = (sc->rxd_cur + 1) % AE_RXD_COUNT_DEFAULT; in ae_rx_intr()
1952 bus_dmamap_sync(sc->dma_rxd_tag, sc->dma_rxd_map, in ae_rx_intr()
1957 AE_WRITE_2(sc, AE_MB_RXD_IDX_REG, sc->rxd_cur); in ae_rx_intr()
1968 ifp = sc->ifp; in ae_watchdog()
1970 if (sc->wd_timer == 0 || --sc->wd_timer != 0) in ae_watchdog()
1973 if ((sc->flags & AE_FLAG_LINK) == 0) in ae_watchdog()
1976 if_printf(ifp, "watchdog timeout - resetting.\n"); in ae_watchdog()
1995 mii = device_get_softc(sc->miibus); in ae_tick()
1998 callout_reset(&sc->tick_ch, hz, ae_tick, sc); in ae_tick()
2008 ifp = sc->ifp; in ae_rxvlan()
2038 ifp = sc->ifp; in ae_rxfilter()
2086 if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ETHERMTU) in ae_ioctl()
2088 else if (if_getmtu(ifp) != ifr->ifr_mtu) { in ae_ioctl()
2090 if_setmtu(ifp, ifr->ifr_mtu); in ae_ioctl()
2102 if (((if_getflags(ifp) ^ sc->if_flags) in ae_ioctl()
2106 if ((sc->flags & AE_FLAG_DETACH) == 0) in ae_ioctl()
2113 sc->if_flags = if_getflags(ifp); in ae_ioctl()
2125 mii = device_get_softc(sc->miibus); in ae_ioctl()
2126 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, cmd); in ae_ioctl()
2130 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in ae_ioctl()
2154 ifp = sc->ifp; in ae_stop()
2156 sc->flags &= ~AE_FLAG_LINK; in ae_stop()
2157 sc->wd_timer = 0; /* Cancel watchdog. */ in ae_stop()
2158 callout_stop(&sc->tick_ch); in ae_stop()
2179 * Wait for everything to enter idle state. in ae_stop()
2184 DELAY(100); in ae_stop()
2187 device_printf(sc->dev, "could not enter idle state in stop.\n"); in ae_stop()
2195 stats->tx_bcast++; in ae_update_stats_tx()
2197 stats->tx_mcast++; in ae_update_stats_tx()
2199 stats->tx_pause++; in ae_update_stats_tx()
2201 stats->tx_ctrl++; in ae_update_stats_tx()
2203 stats->tx_defer++; in ae_update_stats_tx()
2205 stats->tx_excdefer++; in ae_update_stats_tx()
2207 stats->tx_singlecol++; in ae_update_stats_tx()
2209 stats->tx_multicol++; in ae_update_stats_tx()
2211 stats->tx_latecol++; in ae_update_stats_tx()
2213 stats->tx_abortcol++; in ae_update_stats_tx()
2215 stats->tx_underrun++; in ae_update_stats_tx()
2223 stats->rx_bcast++; in ae_update_stats_rx()
2225 stats->rx_mcast++; in ae_update_stats_rx()
2227 stats->rx_pause++; in ae_update_stats_rx()
2229 stats->rx_ctrl++; in ae_update_stats_rx()
2231 stats->rx_crcerr++; in ae_update_stats_rx()
2233 stats->rx_codeerr++; in ae_update_stats_rx()
2235 stats->rx_runt++; in ae_update_stats_rx()
2237 stats->rx_frag++; in ae_update_stats_rx()
2239 stats->rx_trunc++; in ae_update_stats_rx()
2241 stats->rx_align++; in ae_update_stats_rx()