Lines Matching +full:dac +full:- +full:mode +full:- +full:mask

1 /*-
2 * SPDX-License-Identifier: BSD-4-Clause
18 * 4. Neither the name of the author nor the names of any co-contributors
46 * combines a tri-speed ethernet MAC and PHY, with the following
54 * o 64-bit multicast hash table filter
66 * receive data buffers must be aligned on a 32-bit boundary. This is
67 * not a problem where the VT6122 is used as a LOM device in x86-based
71 * The other issue has to do with the way 64-bit addresses are handled.
74 * I/O registers. If you only have a 32-bit system, then this isn't
75 * an issue, but if you have a 64-bit system and more than 4GB of
77 * in the same 48-bit 'segment.'
243 * Enter EEPROM embedded programming mode. In order to in vge_eeprom_getword()
263 device_printf(sc->vge_dev, "EEPROM read timed out\n"); in vge_eeprom_getword()
271 /* Turn off EEPROM access mode. */ in vge_eeprom_getword()
317 device_printf(sc->vge_dev, "failed to idle MII autopoll\n"); in vge_miipoll_stop()
337 device_printf(sc->vge_dev, "failed to idle MII autopoll\n"); in vge_miipoll_start()
341 /* Now enable auto poll mode. */ in vge_miipoll_start()
354 device_printf(sc->vge_dev, "failed to start MII autopoll\n"); in vge_miipoll_start()
374 /* Wait for the read command bit to self-clear. */ in vge_miibus_readreg()
382 device_printf(sc->vge_dev, "MII read timed out\n"); in vge_miibus_readreg()
410 /* Wait for the write command bit to self-clear. */ in vge_miibus_writereg()
418 device_printf(sc->vge_dev, "MII write timed out\n"); in vge_miibus_writereg()
433 * Turn off all the mask bits. This tells the chip in vge_cam_clear()
454 sc->vge_camidx = 0; in vge_cam_clear()
462 if (sc->vge_camidx == VGE_CAM_MAXADDRS) in vge_cam_set()
470 CSR_WRITE_1(sc, VGE_CAMADDR, VGE_CAMADDR_ENABLE|sc->vge_camidx); in vge_cam_set()
487 device_printf(sc->vge_dev, "setting CAM filter failed\n"); in vge_cam_set()
492 /* Select the CAM mask page. */ in vge_cam_set()
496 /* Set the mask bit that enables this filter. */ in vge_cam_set()
497 CSR_SETBIT_1(sc, VGE_CAM0 + (sc->vge_camidx/8), in vge_cam_set()
498 1<<(sc->vge_camidx & 7)); in vge_cam_set()
500 sc->vge_camidx++; in vge_cam_set()
519 ifp = sc->vge_ifp; in vge_setvlan()
533 if (sc->vge_camidx == VGE_CAM_MAXADDRS) in vge_set_maddr()
550 hashes[1] |= (1 << (h - 32)); in vge_hash_maddr()
556 * Program the multicast filter. We use the 64-entry CAM filter
582 ifp = sc->vge_ifp; in vge_rxfilter()
601 if (sc->vge_camidx == VGE_CAM_MAXADDRS) { in vge_rxfilter()
628 device_printf(sc->vge_dev, "soft reset timed out\n"); in vge_reset()
647 while (t->vge_name != NULL) { in vge_probe()
648 if ((pci_get_vendor(dev) == t->vge_vid) && in vge_probe()
649 (pci_get_device(dev) == t->vge_did)) { in vge_probe()
650 device_set_desc(dev, t->vge_name); in vge_probe()
678 ctx->vge_busaddr = segs[0].ds_addr; in vge_dmamap_cb()
691 * It seems old PCI controllers do not support DAC. DAC in vge_dma_alloc()
694 * blindly overriding DAC configuration. PCIe based in vge_dma_alloc()
698 if ((sc->vge_flags & VGE_FLAG_PCIE) != 0) in vge_dma_alloc()
705 error = bus_dma_tag_create(bus_get_dma_tag(sc->vge_dev),/* parent */ in vge_dma_alloc()
715 &sc->vge_cdata.vge_ring_tag); in vge_dma_alloc()
717 device_printf(sc->vge_dev, in vge_dma_alloc()
723 error = bus_dma_tag_create(sc->vge_cdata.vge_ring_tag,/* parent */ in vge_dma_alloc()
733 &sc->vge_cdata.vge_tx_ring_tag); in vge_dma_alloc()
735 device_printf(sc->vge_dev, in vge_dma_alloc()
741 error = bus_dma_tag_create(sc->vge_cdata.vge_ring_tag,/* parent */ in vge_dma_alloc()
751 &sc->vge_cdata.vge_rx_ring_tag); in vge_dma_alloc()
753 device_printf(sc->vge_dev, in vge_dma_alloc()
759 error = bus_dmamem_alloc(sc->vge_cdata.vge_tx_ring_tag, in vge_dma_alloc()
760 (void **)&sc->vge_rdata.vge_tx_ring, in vge_dma_alloc()
762 &sc->vge_cdata.vge_tx_ring_map); in vge_dma_alloc()
764 device_printf(sc->vge_dev, in vge_dma_alloc()
770 error = bus_dmamap_load(sc->vge_cdata.vge_tx_ring_tag, in vge_dma_alloc()
771 sc->vge_cdata.vge_tx_ring_map, sc->vge_rdata.vge_tx_ring, in vge_dma_alloc()
774 device_printf(sc->vge_dev, in vge_dma_alloc()
778 sc->vge_rdata.vge_tx_ring_paddr = ctx.vge_busaddr; in vge_dma_alloc()
781 error = bus_dmamem_alloc(sc->vge_cdata.vge_rx_ring_tag, in vge_dma_alloc()
782 (void **)&sc->vge_rdata.vge_rx_ring, in vge_dma_alloc()
784 &sc->vge_cdata.vge_rx_ring_map); in vge_dma_alloc()
786 device_printf(sc->vge_dev, in vge_dma_alloc()
792 error = bus_dmamap_load(sc->vge_cdata.vge_rx_ring_tag, in vge_dma_alloc()
793 sc->vge_cdata.vge_rx_ring_map, sc->vge_rdata.vge_rx_ring, in vge_dma_alloc()
796 device_printf(sc->vge_dev, in vge_dma_alloc()
800 sc->vge_rdata.vge_rx_ring_paddr = ctx.vge_busaddr; in vge_dma_alloc()
803 tx_ring_end = sc->vge_rdata.vge_tx_ring_paddr + VGE_TX_LIST_SZ; in vge_dma_alloc()
804 rx_ring_end = sc->vge_rdata.vge_rx_ring_paddr + VGE_RX_LIST_SZ; in vge_dma_alloc()
806 VGE_ADDR_HI(sc->vge_rdata.vge_tx_ring_paddr)) || in vge_dma_alloc()
808 VGE_ADDR_HI(sc->vge_rdata.vge_rx_ring_paddr)) || in vge_dma_alloc()
810 device_printf(sc->vge_dev, "4GB boundary crossed, " in vge_dma_alloc()
811 "switching to 32bit DMA address mode.\n"); in vge_dma_alloc()
818 if ((sc->vge_flags & VGE_FLAG_PCIE) != 0) in vge_dma_alloc()
823 error = bus_dma_tag_create(bus_get_dma_tag(sc->vge_dev),/* parent */ in vge_dma_alloc()
833 &sc->vge_cdata.vge_buffer_tag); in vge_dma_alloc()
835 device_printf(sc->vge_dev, in vge_dma_alloc()
841 error = bus_dma_tag_create(sc->vge_cdata.vge_buffer_tag,/* parent */ in vge_dma_alloc()
851 &sc->vge_cdata.vge_tx_tag); in vge_dma_alloc()
853 device_printf(sc->vge_dev, "could not create Tx DMA tag.\n"); in vge_dma_alloc()
858 error = bus_dma_tag_create(sc->vge_cdata.vge_buffer_tag,/* parent */ in vge_dma_alloc()
868 &sc->vge_cdata.vge_rx_tag); in vge_dma_alloc()
870 device_printf(sc->vge_dev, "could not create Rx DMA tag.\n"); in vge_dma_alloc()
876 txd = &sc->vge_cdata.vge_txdesc[i]; in vge_dma_alloc()
877 txd->tx_m = NULL; in vge_dma_alloc()
878 txd->tx_dmamap = NULL; in vge_dma_alloc()
879 error = bus_dmamap_create(sc->vge_cdata.vge_tx_tag, 0, in vge_dma_alloc()
880 &txd->tx_dmamap); in vge_dma_alloc()
882 device_printf(sc->vge_dev, in vge_dma_alloc()
888 if ((error = bus_dmamap_create(sc->vge_cdata.vge_rx_tag, 0, in vge_dma_alloc()
889 &sc->vge_cdata.vge_rx_sparemap)) != 0) { in vge_dma_alloc()
890 device_printf(sc->vge_dev, in vge_dma_alloc()
895 rxd = &sc->vge_cdata.vge_rxdesc[i]; in vge_dma_alloc()
896 rxd->rx_m = NULL; in vge_dma_alloc()
897 rxd->rx_dmamap = NULL; in vge_dma_alloc()
898 error = bus_dmamap_create(sc->vge_cdata.vge_rx_tag, 0, in vge_dma_alloc()
899 &rxd->rx_dmamap); in vge_dma_alloc()
901 device_printf(sc->vge_dev, in vge_dma_alloc()
919 if (sc->vge_cdata.vge_tx_ring_tag != NULL) { in vge_dma_free()
920 if (sc->vge_rdata.vge_tx_ring_paddr) in vge_dma_free()
921 bus_dmamap_unload(sc->vge_cdata.vge_tx_ring_tag, in vge_dma_free()
922 sc->vge_cdata.vge_tx_ring_map); in vge_dma_free()
923 if (sc->vge_rdata.vge_tx_ring) in vge_dma_free()
924 bus_dmamem_free(sc->vge_cdata.vge_tx_ring_tag, in vge_dma_free()
925 sc->vge_rdata.vge_tx_ring, in vge_dma_free()
926 sc->vge_cdata.vge_tx_ring_map); in vge_dma_free()
927 sc->vge_rdata.vge_tx_ring = NULL; in vge_dma_free()
928 sc->vge_rdata.vge_tx_ring_paddr = 0; in vge_dma_free()
929 bus_dma_tag_destroy(sc->vge_cdata.vge_tx_ring_tag); in vge_dma_free()
930 sc->vge_cdata.vge_tx_ring_tag = NULL; in vge_dma_free()
933 if (sc->vge_cdata.vge_rx_ring_tag != NULL) { in vge_dma_free()
934 if (sc->vge_rdata.vge_rx_ring_paddr) in vge_dma_free()
935 bus_dmamap_unload(sc->vge_cdata.vge_rx_ring_tag, in vge_dma_free()
936 sc->vge_cdata.vge_rx_ring_map); in vge_dma_free()
937 if (sc->vge_rdata.vge_rx_ring) in vge_dma_free()
938 bus_dmamem_free(sc->vge_cdata.vge_rx_ring_tag, in vge_dma_free()
939 sc->vge_rdata.vge_rx_ring, in vge_dma_free()
940 sc->vge_cdata.vge_rx_ring_map); in vge_dma_free()
941 sc->vge_rdata.vge_rx_ring = NULL; in vge_dma_free()
942 sc->vge_rdata.vge_rx_ring_paddr = 0; in vge_dma_free()
943 bus_dma_tag_destroy(sc->vge_cdata.vge_rx_ring_tag); in vge_dma_free()
944 sc->vge_cdata.vge_rx_ring_tag = NULL; in vge_dma_free()
947 if (sc->vge_cdata.vge_tx_tag != NULL) { in vge_dma_free()
949 txd = &sc->vge_cdata.vge_txdesc[i]; in vge_dma_free()
950 if (txd->tx_dmamap != NULL) { in vge_dma_free()
951 bus_dmamap_destroy(sc->vge_cdata.vge_tx_tag, in vge_dma_free()
952 txd->tx_dmamap); in vge_dma_free()
953 txd->tx_dmamap = NULL; in vge_dma_free()
956 bus_dma_tag_destroy(sc->vge_cdata.vge_tx_tag); in vge_dma_free()
957 sc->vge_cdata.vge_tx_tag = NULL; in vge_dma_free()
960 if (sc->vge_cdata.vge_rx_tag != NULL) { in vge_dma_free()
962 rxd = &sc->vge_cdata.vge_rxdesc[i]; in vge_dma_free()
963 if (rxd->rx_dmamap != NULL) { in vge_dma_free()
964 bus_dmamap_destroy(sc->vge_cdata.vge_rx_tag, in vge_dma_free()
965 rxd->rx_dmamap); in vge_dma_free()
966 rxd->rx_dmamap = NULL; in vge_dma_free()
969 if (sc->vge_cdata.vge_rx_sparemap != NULL) { in vge_dma_free()
970 bus_dmamap_destroy(sc->vge_cdata.vge_rx_tag, in vge_dma_free()
971 sc->vge_cdata.vge_rx_sparemap); in vge_dma_free()
972 sc->vge_cdata.vge_rx_sparemap = NULL; in vge_dma_free()
974 bus_dma_tag_destroy(sc->vge_cdata.vge_rx_tag); in vge_dma_free()
975 sc->vge_cdata.vge_rx_tag = NULL; in vge_dma_free()
978 if (sc->vge_cdata.vge_buffer_tag != NULL) { in vge_dma_free()
979 bus_dma_tag_destroy(sc->vge_cdata.vge_buffer_tag); in vge_dma_free()
980 sc->vge_cdata.vge_buffer_tag = NULL; in vge_dma_free()
982 if (sc->vge_cdata.vge_ring_tag != NULL) { in vge_dma_free()
983 bus_dma_tag_destroy(sc->vge_cdata.vge_ring_tag); in vge_dma_free()
984 sc->vge_cdata.vge_ring_tag = NULL; in vge_dma_free()
1001 sc->vge_dev = dev; in vge_attach()
1003 mtx_init(&sc->vge_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, in vge_attach()
1005 callout_init_mtx(&sc->vge_watchdog, &sc->vge_mtx, 0); in vge_attach()
1013 sc->vge_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in vge_attach()
1016 if (sc->vge_res == NULL) { in vge_attach()
1023 sc->vge_flags |= VGE_FLAG_PCIE; in vge_attach()
1024 sc->vge_expcap = cap; in vge_attach()
1026 sc->vge_flags |= VGE_FLAG_JUMBO; in vge_attach()
1028 sc->vge_flags |= VGE_FLAG_PMCAP; in vge_attach()
1029 sc->vge_pmcap = cap; in vge_attach()
1037 sc->vge_flags |= VGE_FLAG_MSI; in vge_attach()
1047 sc->vge_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, in vge_attach()
1048 ((sc->vge_flags & VGE_FLAG_MSI) ? 0 : RF_SHAREABLE) | RF_ACTIVE); in vge_attach()
1049 if (sc->vge_irq == NULL) { in vge_attach()
1083 if ((sc->vge_flags & VGE_FLAG_PCIE) != 0) in vge_attach()
1084 sc->vge_phyaddr = 1; in vge_attach()
1086 sc->vge_phyaddr = CSR_READ_1(sc, VGE_MIICFG) & in vge_attach()
1095 ifp = sc->vge_ifp = if_alloc(IFT_ETHER); in vge_attach()
1098 error = mii_attach(dev, &sc->vge_miibus, ifp, vge_ifmedia_upd, in vge_attach()
1099 vge_ifmedia_sts, BMSR_DEFCAPMASK, sc->vge_phyaddr, MII_OFFSET_ANY, in vge_attach()
1115 if ((sc->vge_flags & VGE_FLAG_PMCAP) != 0) in vge_attach()
1122 if_setsendqlen(ifp, VGE_TX_DESC_CNT - 1); in vge_attach()
1134 error = bus_setup_intr(dev, sc->vge_irq, INTR_TYPE_NET|INTR_MPSAFE, in vge_attach()
1135 NULL, vge_intr, sc, &sc->vge_intrhand); in vge_attach()
1164 KASSERT(mtx_initialized(&sc->vge_mtx), ("vge mutex not initialized")); in vge_detach()
1165 ifp = sc->vge_ifp; in vge_detach()
1178 callout_drain(&sc->vge_watchdog); in vge_detach()
1180 if (sc->vge_miibus) in vge_detach()
1181 device_delete_child(dev, sc->vge_miibus); in vge_detach()
1184 if (sc->vge_intrhand) in vge_detach()
1185 bus_teardown_intr(dev, sc->vge_irq, sc->vge_intrhand); in vge_detach()
1186 if (sc->vge_irq) in vge_detach()
1188 sc->vge_flags & VGE_FLAG_MSI ? 1 : 0, sc->vge_irq); in vge_detach()
1189 if (sc->vge_flags & VGE_FLAG_MSI) in vge_detach()
1191 if (sc->vge_res) in vge_detach()
1193 PCIR_BAR(1), sc->vge_res); in vge_detach()
1198 mtx_destroy(&sc->vge_mtx); in vge_detach()
1209 rxd = &sc->vge_cdata.vge_rxdesc[prod]; in vge_discard_rxbuf()
1210 rxd->rx_desc->vge_sts = 0; in vge_discard_rxbuf()
1211 rxd->rx_desc->vge_ctl = 0; in vge_discard_rxbuf()
1221 if ((prod % VGE_RXCHUNK) == (VGE_RXCHUNK - 1)) { in vge_discard_rxbuf()
1222 for (i = VGE_RXCHUNK; i > 0; i--) { in vge_discard_rxbuf()
1223 rxd->rx_desc->vge_sts = htole32(VGE_RDSTS_OWN); in vge_discard_rxbuf()
1224 rxd = rxd->rxd_prev; in vge_discard_rxbuf()
1226 sc->vge_cdata.vge_rx_commit += VGE_RXCHUNK; in vge_discard_rxbuf()
1243 * This is part of an evil trick to deal with strict-alignment in vge_newbuf()
1245 * on 32-bit boundaries, but that will hose strict-alignment in vge_newbuf()
1247 * at the start of each buffer and for non-strict-alignment hosts, in vge_newbuf()
1252 m->m_len = m->m_pkthdr.len = MCLBYTES; in vge_newbuf()
1255 if (bus_dmamap_load_mbuf_sg(sc->vge_cdata.vge_rx_tag, in vge_newbuf()
1256 sc->vge_cdata.vge_rx_sparemap, m, segs, &nsegs, 0) != 0) { in vge_newbuf()
1262 rxd = &sc->vge_cdata.vge_rxdesc[prod]; in vge_newbuf()
1263 if (rxd->rx_m != NULL) { in vge_newbuf()
1264 bus_dmamap_sync(sc->vge_cdata.vge_rx_tag, rxd->rx_dmamap, in vge_newbuf()
1266 bus_dmamap_unload(sc->vge_cdata.vge_rx_tag, rxd->rx_dmamap); in vge_newbuf()
1268 map = rxd->rx_dmamap; in vge_newbuf()
1269 rxd->rx_dmamap = sc->vge_cdata.vge_rx_sparemap; in vge_newbuf()
1270 sc->vge_cdata.vge_rx_sparemap = map; in vge_newbuf()
1271 bus_dmamap_sync(sc->vge_cdata.vge_rx_tag, rxd->rx_dmamap, in vge_newbuf()
1273 rxd->rx_m = m; in vge_newbuf()
1275 rxd->rx_desc->vge_sts = 0; in vge_newbuf()
1276 rxd->rx_desc->vge_ctl = 0; in vge_newbuf()
1277 rxd->rx_desc->vge_addrlo = htole32(VGE_ADDR_LO(segs[0].ds_addr)); in vge_newbuf()
1278 rxd->rx_desc->vge_addrhi = htole32(VGE_ADDR_HI(segs[0].ds_addr) | in vge_newbuf()
1289 if ((prod % VGE_RXCHUNK) == (VGE_RXCHUNK - 1)) { in vge_newbuf()
1290 for (i = VGE_RXCHUNK; i > 0; i--) { in vge_newbuf()
1291 rxd->rx_desc->vge_sts = htole32(VGE_RDSTS_OWN); in vge_newbuf()
1292 rxd = rxd->rxd_prev; in vge_newbuf()
1294 sc->vge_cdata.vge_rx_commit += VGE_RXCHUNK; in vge_newbuf()
1309 sc->vge_cdata.vge_tx_prodidx = 0; in vge_tx_list_init()
1310 sc->vge_cdata.vge_tx_considx = 0; in vge_tx_list_init()
1311 sc->vge_cdata.vge_tx_cnt = 0; in vge_tx_list_init()
1313 rd = &sc->vge_rdata; in vge_tx_list_init()
1314 bzero(rd->vge_tx_ring, VGE_TX_LIST_SZ); in vge_tx_list_init()
1316 txd = &sc->vge_cdata.vge_txdesc[i]; in vge_tx_list_init()
1317 txd->tx_m = NULL; in vge_tx_list_init()
1318 txd->tx_desc = &rd->vge_tx_ring[i]; in vge_tx_list_init()
1321 bus_dmamap_sync(sc->vge_cdata.vge_tx_ring_tag, in vge_tx_list_init()
1322 sc->vge_cdata.vge_tx_ring_map, in vge_tx_list_init()
1337 sc->vge_cdata.vge_rx_prodidx = 0; in vge_rx_list_init()
1338 sc->vge_cdata.vge_head = NULL; in vge_rx_list_init()
1339 sc->vge_cdata.vge_tail = NULL; in vge_rx_list_init()
1340 sc->vge_cdata.vge_rx_commit = 0; in vge_rx_list_init()
1342 rd = &sc->vge_rdata; in vge_rx_list_init()
1343 bzero(rd->vge_rx_ring, VGE_RX_LIST_SZ); in vge_rx_list_init()
1345 rxd = &sc->vge_cdata.vge_rxdesc[i]; in vge_rx_list_init()
1346 rxd->rx_m = NULL; in vge_rx_list_init()
1347 rxd->rx_desc = &rd->vge_rx_ring[i]; in vge_rx_list_init()
1349 rxd->rxd_prev = in vge_rx_list_init()
1350 &sc->vge_cdata.vge_rxdesc[VGE_RX_DESC_CNT - 1]; in vge_rx_list_init()
1352 rxd->rxd_prev = &sc->vge_cdata.vge_rxdesc[i - 1]; in vge_rx_list_init()
1357 bus_dmamap_sync(sc->vge_cdata.vge_rx_ring_tag, in vge_rx_list_init()
1358 sc->vge_cdata.vge_rx_ring_map, in vge_rx_list_init()
1361 sc->vge_cdata.vge_rx_commit = 0; in vge_rx_list_init()
1376 ifp = sc->vge_ifp; in vge_freebufs()
1381 rxd = &sc->vge_cdata.vge_rxdesc[i]; in vge_freebufs()
1382 if (rxd->rx_m != NULL) { in vge_freebufs()
1383 bus_dmamap_sync(sc->vge_cdata.vge_rx_tag, in vge_freebufs()
1384 rxd->rx_dmamap, BUS_DMASYNC_POSTREAD); in vge_freebufs()
1385 bus_dmamap_unload(sc->vge_cdata.vge_rx_tag, in vge_freebufs()
1386 rxd->rx_dmamap); in vge_freebufs()
1387 m_freem(rxd->rx_m); in vge_freebufs()
1388 rxd->rx_m = NULL; in vge_freebufs()
1393 txd = &sc->vge_cdata.vge_txdesc[i]; in vge_freebufs()
1394 if (txd->tx_m != NULL) { in vge_freebufs()
1395 bus_dmamap_sync(sc->vge_cdata.vge_tx_tag, in vge_freebufs()
1396 txd->tx_dmamap, BUS_DMASYNC_POSTWRITE); in vge_freebufs()
1397 bus_dmamap_unload(sc->vge_cdata.vge_tx_tag, in vge_freebufs()
1398 txd->tx_dmamap); in vge_freebufs()
1399 m_freem(txd->tx_m); in vge_freebufs()
1400 txd->tx_m = NULL; in vge_freebufs()
1414 dst = src - 1; in vge_fixup_rx()
1416 for (i = 0; i < (m->m_len / sizeof(uint16_t) + 1); i++) in vge_fixup_rx()
1419 m->m_data -= ETHER_ALIGN; in vge_fixup_rx()
1439 ifp = sc->vge_ifp; in vge_rxeof()
1441 bus_dmamap_sync(sc->vge_cdata.vge_rx_ring_tag, in vge_rxeof()
1442 sc->vge_cdata.vge_rx_ring_map, in vge_rxeof()
1445 prod = sc->vge_cdata.vge_rx_prodidx; in vge_rxeof()
1449 cur_rx = &sc->vge_rdata.vge_rx_ring[prod]; in vge_rxeof()
1450 rxstat = le32toh(cur_rx->vge_sts); in vge_rxeof()
1453 count--; in vge_rxeof()
1455 rxctl = le32toh(cur_rx->vge_ctl); in vge_rxeof()
1457 rxd = &sc->vge_cdata.vge_rxdesc[prod]; in vge_rxeof()
1458 m = rxd->rx_m; in vge_rxeof()
1462 * either the first fragment in a multi-fragment receive, in vge_rxeof()
1473 m->m_len = MCLBYTES - VGE_RX_BUF_ALIGN; in vge_rxeof()
1474 if (sc->vge_cdata.vge_head == NULL) { in vge_rxeof()
1475 sc->vge_cdata.vge_head = m; in vge_rxeof()
1476 sc->vge_cdata.vge_tail = m; in vge_rxeof()
1478 m->m_flags &= ~M_PKTHDR; in vge_rxeof()
1479 sc->vge_cdata.vge_tail->m_next = m; in vge_rxeof()
1480 sc->vge_cdata.vge_tail = m; in vge_rxeof()
1493 * We also want to receive bad-checksummed frames and in vge_rxeof()
1494 * and frames with bad-length. in vge_rxeof()
1501 * If this is part of a multi-fragment packet, in vge_rxeof()
1517 if (sc->vge_cdata.vge_head != NULL) { in vge_rxeof()
1518 m->m_len = total_len % (MCLBYTES - VGE_RX_BUF_ALIGN); in vge_rxeof()
1525 if (m->m_len <= ETHER_CRC_LEN) { in vge_rxeof()
1526 sc->vge_cdata.vge_tail->m_len -= in vge_rxeof()
1527 (ETHER_CRC_LEN - m->m_len); in vge_rxeof()
1530 m->m_len -= ETHER_CRC_LEN; in vge_rxeof()
1531 m->m_flags &= ~M_PKTHDR; in vge_rxeof()
1532 sc->vge_cdata.vge_tail->m_next = m; in vge_rxeof()
1534 m = sc->vge_cdata.vge_head; in vge_rxeof()
1535 m->m_flags |= M_PKTHDR; in vge_rxeof()
1536 m->m_pkthdr.len = total_len - ETHER_CRC_LEN; in vge_rxeof()
1538 m->m_flags |= M_PKTHDR; in vge_rxeof()
1539 m->m_pkthdr.len = m->m_len = in vge_rxeof()
1540 (total_len - ETHER_CRC_LEN); in vge_rxeof()
1546 m->m_pkthdr.rcvif = ifp; in vge_rxeof()
1553 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; in vge_rxeof()
1555 m->m_pkthdr.csum_flags |= CSUM_IP_VALID; in vge_rxeof()
1560 m->m_pkthdr.csum_flags |= in vge_rxeof()
1562 m->m_pkthdr.csum_data = 0xffff; in vge_rxeof()
1568 * The 32-bit rxctl register is stored in little-endian. in vge_rxeof()
1569 * However, the 16-bit vlan tag is stored in big-endian, in vge_rxeof()
1572 m->m_pkthdr.ether_vtag = in vge_rxeof()
1574 m->m_flags |= M_VLANTAG; in vge_rxeof()
1580 sc->vge_cdata.vge_head = NULL; in vge_rxeof()
1581 sc->vge_cdata.vge_tail = NULL; in vge_rxeof()
1585 sc->vge_cdata.vge_rx_prodidx = prod; in vge_rxeof()
1586 bus_dmamap_sync(sc->vge_cdata.vge_rx_ring_tag, in vge_rxeof()
1587 sc->vge_cdata.vge_rx_ring_map, in vge_rxeof()
1590 if (sc->vge_cdata.vge_rx_commit != 0) { in vge_rxeof()
1592 sc->vge_cdata.vge_rx_commit); in vge_rxeof()
1593 sc->vge_cdata.vge_rx_commit = 0; in vge_rxeof()
1610 ifp = sc->vge_ifp; in vge_txeof()
1612 if (sc->vge_cdata.vge_tx_cnt == 0) in vge_txeof()
1615 bus_dmamap_sync(sc->vge_cdata.vge_tx_ring_tag, in vge_txeof()
1616 sc->vge_cdata.vge_tx_ring_map, in vge_txeof()
1623 cons = sc->vge_cdata.vge_tx_considx; in vge_txeof()
1624 prod = sc->vge_cdata.vge_tx_prodidx; in vge_txeof()
1626 cur_tx = &sc->vge_rdata.vge_tx_ring[cons]; in vge_txeof()
1627 txstat = le32toh(cur_tx->vge_sts); in vge_txeof()
1630 sc->vge_cdata.vge_tx_cnt--; in vge_txeof()
1633 txd = &sc->vge_cdata.vge_txdesc[cons]; in vge_txeof()
1634 bus_dmamap_sync(sc->vge_cdata.vge_tx_tag, txd->tx_dmamap, in vge_txeof()
1636 bus_dmamap_unload(sc->vge_cdata.vge_tx_tag, txd->tx_dmamap); in vge_txeof()
1638 KASSERT(txd->tx_m != NULL, ("%s: freeing NULL mbuf!\n", in vge_txeof()
1640 m_freem(txd->tx_m); in vge_txeof()
1641 txd->tx_m = NULL; in vge_txeof()
1642 txd->tx_desc->vge_frag[0].vge_addrhi = 0; in vge_txeof()
1644 bus_dmamap_sync(sc->vge_cdata.vge_tx_ring_tag, in vge_txeof()
1645 sc->vge_cdata.vge_tx_ring_map, in vge_txeof()
1647 sc->vge_cdata.vge_tx_considx = cons; in vge_txeof()
1648 if (sc->vge_cdata.vge_tx_cnt == 0) in vge_txeof()
1649 sc->vge_timer = 0; in vge_txeof()
1660 ifp = sc->vge_ifp; in vge_link_statchg()
1666 sc->vge_flags &= ~VGE_FLAG_LINK; in vge_link_statchg()
1667 if_link_state_change(sc->vge_ifp, in vge_link_statchg()
1670 sc->vge_flags |= VGE_FLAG_LINK; in vge_link_statchg()
1671 if_link_state_change(sc->vge_ifp, in vge_link_statchg()
1688 * Restart MII auto-polling because link state change interrupt in vge_link_statchg()
1751 ifp = sc->vge_ifp; in vge_intr()
1752 if ((sc->vge_flags & VGE_FLAG_SUSPENDED) != 0 || in vge_intr()
1798 /* Re-enable interrupts */ in vge_intr()
1822 if ((*m_head)->m_pkthdr.len < VGE_MIN_FRAMELEN) { in vge_encap()
1824 padlen = VGE_MIN_FRAMELEN - m->m_pkthdr.len; in vge_encap()
1847 bzero(mtod(m, char *) + m->m_pkthdr.len, padlen); in vge_encap()
1848 m->m_pkthdr.len += padlen; in vge_encap()
1849 m->m_len = m->m_pkthdr.len; in vge_encap()
1853 txd = &sc->vge_cdata.vge_txdesc[sc->vge_cdata.vge_tx_prodidx]; in vge_encap()
1855 error = bus_dmamap_load_mbuf_sg(sc->vge_cdata.vge_tx_tag, in vge_encap()
1856 txd->tx_dmamap, *m_head, txsegs, &nsegs, 0); in vge_encap()
1865 error = bus_dmamap_load_mbuf_sg(sc->vge_cdata.vge_tx_tag, in vge_encap()
1866 txd->tx_dmamap, *m_head, txsegs, &nsegs, 0); in vge_encap()
1874 bus_dmamap_sync(sc->vge_cdata.vge_tx_tag, txd->tx_dmamap, in vge_encap()
1881 if ((m->m_pkthdr.csum_flags & CSUM_IP) != 0) in vge_encap()
1883 if ((m->m_pkthdr.csum_flags & CSUM_TCP) != 0) in vge_encap()
1885 if ((m->m_pkthdr.csum_flags & CSUM_UDP) != 0) in vge_encap()
1889 if ((m->m_flags & M_VLANTAG) != 0) in vge_encap()
1890 cflags |= m->m_pkthdr.ether_vtag | VGE_TDCTL_VTAG; in vge_encap()
1891 txd->tx_desc->vge_sts = htole32(m->m_pkthdr.len << 16); in vge_encap()
1907 txd->tx_desc->vge_ctl = htole32(cflags | ((nsegs + 1) << 28) | in vge_encap()
1910 frag = &txd->tx_desc->vge_frag[i]; in vge_encap()
1911 frag->vge_addrlo = htole32(VGE_ADDR_LO(txsegs[i].ds_addr)); in vge_encap()
1912 frag->vge_addrhi = htole32(VGE_ADDR_HI(txsegs[i].ds_addr) | in vge_encap()
1916 sc->vge_cdata.vge_tx_cnt++; in vge_encap()
1917 VGE_TX_DESC_INC(sc->vge_cdata.vge_tx_prodidx); in vge_encap()
1923 txd->tx_desc->vge_ctl |= htole32(VGE_TDCTL_TIC); in vge_encap()
1924 txd->tx_desc->vge_sts |= htole32(VGE_TDSTS_OWN); in vge_encap()
1925 txd->tx_m = m; in vge_encap()
1957 if ((sc->vge_flags & VGE_FLAG_LINK) == 0 || in vge_start_locked()
1962 idx = sc->vge_cdata.vge_tx_prodidx; in vge_start_locked()
1965 sc->vge_cdata.vge_tx_cnt < VGE_TX_DESC_CNT - 1; ) { in vge_start_locked()
1982 txd = &sc->vge_cdata.vge_txdesc[idx]; in vge_start_locked()
1983 txd->tx_desc->vge_frag[0].vge_addrhi |= htole32(VGE_TXDESC_Q); in vge_start_locked()
1995 bus_dmamap_sync(sc->vge_cdata.vge_tx_ring_tag, in vge_start_locked()
1996 sc->vge_cdata.vge_tx_ring_map, in vge_start_locked()
2003 sc->vge_timer = 5; in vge_start_locked()
2020 if_t ifp = sc->vge_ifp; in vge_init_locked()
2041 device_printf(sc->vge_dev, "no memory for Rx buffers.\n"); in vge_init_locked()
2049 CSR_WRITE_1(sc, VGE_PAR0 + i, if_getlladdr(sc->vge_ifp)[i]); in vge_init_locked()
2078 VGE_ADDR_HI(sc->vge_rdata.vge_tx_ring_paddr)); in vge_init_locked()
2080 VGE_ADDR_LO(sc->vge_rdata.vge_tx_ring_paddr)); in vge_init_locked()
2081 CSR_WRITE_2(sc, VGE_TXDESCNUM, VGE_TX_DESC_CNT - 1); in vge_init_locked()
2084 VGE_ADDR_LO(sc->vge_rdata.vge_rx_ring_paddr)); in vge_init_locked()
2085 CSR_WRITE_2(sc, VGE_RXDESCNUM, VGE_RX_DESC_CNT - 1); in vge_init_locked()
2111 * Disable hald-duplex flow control in vge_init_locked()
2141 sc->vge_flags &= ~VGE_FLAG_LINK; in vge_init_locked()
2146 callout_reset(&sc->vge_watchdog, hz, vge_watchdog, sc); in vge_init_locked()
2173 mii = device_get_softc(sc->vge_miibus); in vge_ifmedia_upd_locked()
2174 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) in vge_ifmedia_upd_locked()
2192 mii = device_get_softc(sc->vge_miibus); in vge_ifmedia_sts()
2200 ifmr->ifm_active = mii->mii_media_active; in vge_ifmedia_sts()
2201 ifmr->ifm_status = mii->mii_media_status; in vge_ifmedia_sts()
2211 mii = device_get_softc(sc->vge_miibus); in vge_setmedia()
2212 ife = mii->mii_media.ifm_cur; in vge_setmedia()
2215 * If the user manually selects a media mode, we need to turn in vge_setmedia()
2216 * on the forced MAC mode bit in the DIAGCTL register. If the in vge_setmedia()
2217 * user happens to choose a full duplex mode, we also need to in vge_setmedia()
2219 * 10Mbps and 100Mbps speeds. In autoselect mode, forced MAC in vge_setmedia()
2220 * mode is disabled, and in 1000baseT mode, full duplex is in vge_setmedia()
2221 * always implied, so we turn on the forced mode bit but leave in vge_setmedia()
2225 switch (IFM_SUBTYPE(ife->ifm_media)) { in vge_setmedia()
2237 if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { in vge_setmedia()
2244 device_printf(sc->vge_dev, "unknown media type: %x\n", in vge_setmedia()
2245 IFM_SUBTYPE(ife->ifm_media)); in vge_setmedia()
2256 int error = 0, mask; in vge_ioctl() local
2261 if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > VGE_JUMBO_MTU) in vge_ioctl()
2263 else if (if_getmtu(ifp) != ifr->ifr_mtu) { in vge_ioctl()
2264 if (ifr->ifr_mtu > ETHERMTU && in vge_ioctl()
2265 (sc->vge_flags & VGE_FLAG_JUMBO) == 0) in vge_ioctl()
2268 if_setmtu(ifp, ifr->ifr_mtu); in vge_ioctl()
2276 ((if_getflags(ifp) ^ sc->vge_if_flags) & in vge_ioctl()
2283 sc->vge_if_flags = if_getflags(ifp); in vge_ioctl()
2295 mii = device_get_softc(sc->vge_miibus); in vge_ioctl()
2296 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); in vge_ioctl()
2299 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in vge_ioctl()
2301 if (mask & IFCAP_POLLING) { in vge_ioctl()
2302 if (ifr->ifr_reqcap & IFCAP_POLLING) { in vge_ioctl()
2326 if ((mask & IFCAP_TXCSUM) != 0 && in vge_ioctl()
2334 if ((mask & IFCAP_RXCSUM) != 0 && in vge_ioctl()
2337 if ((mask & IFCAP_WOL_UCAST) != 0 && in vge_ioctl()
2340 if ((mask & IFCAP_WOL_MCAST) != 0 && in vge_ioctl()
2343 if ((mask & IFCAP_WOL_MAGIC) != 0 && in vge_ioctl()
2346 if ((mask & IFCAP_VLAN_HWCSUM) != 0 && in vge_ioctl()
2349 if ((mask & IFCAP_VLAN_HWTAGGING) != 0 && in vge_ioctl()
2374 callout_reset(&sc->vge_watchdog, hz, vge_watchdog, sc); in vge_watchdog()
2375 if (sc->vge_timer == 0 || --sc->vge_timer > 0) in vge_watchdog()
2378 ifp = sc->vge_ifp; in vge_watchdog()
2399 ifp = sc->vge_ifp; in vge_stop()
2400 sc->vge_timer = 0; in vge_stop()
2401 callout_stop(&sc->vge_watchdog); in vge_stop()
2433 sc->vge_flags |= VGE_FLAG_SUSPENDED; in vge_suspend()
2441 * doesn't, re-enable busmastering, and restart the interface if
2453 if ((sc->vge_flags & VGE_FLAG_PMCAP) != 0) { in vge_resume()
2455 pmstat = pci_read_config(sc->vge_dev, in vge_resume()
2456 sc->vge_pmcap + PCIR_POWER_STATUS, 2); in vge_resume()
2459 pci_write_config(sc->vge_dev, in vge_resume()
2460 sc->vge_pmcap + PCIR_POWER_STATUS, pmstat, 2); in vge_resume()
2464 /* Restart MII auto-polling. */ in vge_resume()
2466 ifp = sc->vge_ifp; in vge_resume()
2472 sc->vge_flags &= ~VGE_FLAG_SUSPENDED; in vge_resume()
2500 stats = &sc->vge_stats; in vge_sysctl_node()
2501 ctx = device_get_sysctl_ctx(sc->vge_dev); in vge_sysctl_node()
2502 child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->vge_dev)); in vge_sysctl_node()
2505 CTLFLAG_RW, &sc->vge_int_holdoff, 0, "interrupt holdoff"); in vge_sysctl_node()
2507 CTLFLAG_RW, &sc->vge_rx_coal_pkt, 0, "rx coalescing packet"); in vge_sysctl_node()
2509 CTLFLAG_RW, &sc->vge_tx_coal_pkt, 0, "tx coalescing packet"); in vge_sysctl_node()
2512 sc->vge_int_holdoff = VGE_INT_HOLDOFF_DEFAULT; in vge_sysctl_node()
2513 resource_int_value(device_get_name(sc->vge_dev), in vge_sysctl_node()
2514 device_get_unit(sc->vge_dev), "int_holdoff", &sc->vge_int_holdoff); in vge_sysctl_node()
2515 sc->vge_rx_coal_pkt = VGE_RX_COAL_PKT_DEFAULT; in vge_sysctl_node()
2516 resource_int_value(device_get_name(sc->vge_dev), in vge_sysctl_node()
2517 device_get_unit(sc->vge_dev), "rx_coal_pkt", &sc->vge_rx_coal_pkt); in vge_sysctl_node()
2518 sc->vge_tx_coal_pkt = VGE_TX_COAL_PKT_DEFAULT; in vge_sysctl_node()
2519 resource_int_value(device_get_name(sc->vge_dev), in vge_sysctl_node()
2520 device_get_unit(sc->vge_dev), "tx_coal_pkt", &sc->vge_tx_coal_pkt); in vge_sysctl_node()
2531 &stats->rx_frames, "frames"); in vge_sysctl_node()
2533 &stats->rx_good_frames, "Good frames"); in vge_sysctl_node()
2535 &stats->rx_fifo_oflows, "FIFO overflows"); in vge_sysctl_node()
2537 &stats->rx_runts, "Too short frames"); in vge_sysctl_node()
2539 &stats->rx_runts_errs, "Too short frames with errors"); in vge_sysctl_node()
2541 &stats->rx_pkts_64, "64 bytes frames"); in vge_sysctl_node()
2543 &stats->rx_pkts_65_127, "65 to 127 bytes frames"); in vge_sysctl_node()
2545 &stats->rx_pkts_128_255, "128 to 255 bytes frames"); in vge_sysctl_node()
2547 &stats->rx_pkts_256_511, "256 to 511 bytes frames"); in vge_sysctl_node()
2549 &stats->rx_pkts_512_1023, "512 to 1023 bytes frames"); in vge_sysctl_node()
2551 &stats->rx_pkts_1024_1518, "1024 to 1518 bytes frames"); in vge_sysctl_node()
2553 &stats->rx_pkts_1519_max, "1519 to max frames"); in vge_sysctl_node()
2555 &stats->rx_pkts_1519_max_errs, "1519 to max frames with error"); in vge_sysctl_node()
2557 &stats->rx_jumbos, "Jumbo frames"); in vge_sysctl_node()
2559 &stats->rx_crcerrs, "CRC errors"); in vge_sysctl_node()
2561 &stats->rx_pause_frames, "Pause frames"); in vge_sysctl_node()
2563 &stats->rx_alignerrs, "Alignment errors"); in vge_sysctl_node()
2565 &stats->rx_nobufs, "Frames with no buffer event"); in vge_sysctl_node()
2567 &stats->rx_symerrs, "Frames with symbol errors"); in vge_sysctl_node()
2569 &stats->rx_lenerrs, "Frames with length mismatched"); in vge_sysctl_node()
2576 &stats->tx_good_frames, "Good frames"); in vge_sysctl_node()
2578 &stats->tx_pkts_64, "64 bytes frames"); in vge_sysctl_node()
2580 &stats->tx_pkts_65_127, "65 to 127 bytes frames"); in vge_sysctl_node()
2582 &stats->tx_pkts_128_255, "128 to 255 bytes frames"); in vge_sysctl_node()
2584 &stats->tx_pkts_256_511, "256 to 511 bytes frames"); in vge_sysctl_node()
2586 &stats->tx_pkts_512_1023, "512 to 1023 bytes frames"); in vge_sysctl_node()
2588 &stats->tx_pkts_1024_1518, "1024 to 1518 bytes frames"); in vge_sysctl_node()
2590 &stats->tx_jumbos, "Jumbo frames"); in vge_sysctl_node()
2592 &stats->tx_colls, "Collisions"); in vge_sysctl_node()
2594 &stats->tx_latecolls, "Late collisions"); in vge_sysctl_node()
2596 &stats->tx_pause, "Pause frames"); in vge_sysctl_node()
2599 &stats->tx_sqeerrs, "SQE errors"); in vge_sysctl_node()
2616 for (i = VGE_TIMEOUT; i > 0; i--) { in vge_stats_clear()
2622 device_printf(sc->vge_dev, "MIB clear timed out!\n"); in vge_stats_clear()
2637 stats = &sc->vge_stats; in vge_stats_update()
2638 ifp = sc->vge_ifp; in vge_stats_update()
2642 for (i = VGE_TIMEOUT; i > 0; i--) { in vge_stats_update()
2648 device_printf(sc->vge_dev, "MIB counter dump timed out!\n"); in vge_stats_update()
2668 stats->rx_frames += mib[VGE_MIB_RX_FRAMES]; in vge_stats_update()
2669 stats->rx_good_frames += mib[VGE_MIB_RX_GOOD_FRAMES]; in vge_stats_update()
2670 stats->rx_fifo_oflows += mib[VGE_MIB_RX_FIFO_OVERRUNS]; in vge_stats_update()
2671 stats->rx_runts += mib[VGE_MIB_RX_RUNTS]; in vge_stats_update()
2672 stats->rx_runts_errs += mib[VGE_MIB_RX_RUNTS_ERRS]; in vge_stats_update()
2673 stats->rx_pkts_64 += mib[VGE_MIB_RX_PKTS_64]; in vge_stats_update()
2674 stats->rx_pkts_65_127 += mib[VGE_MIB_RX_PKTS_65_127]; in vge_stats_update()
2675 stats->rx_pkts_128_255 += mib[VGE_MIB_RX_PKTS_128_255]; in vge_stats_update()
2676 stats->rx_pkts_256_511 += mib[VGE_MIB_RX_PKTS_256_511]; in vge_stats_update()
2677 stats->rx_pkts_512_1023 += mib[VGE_MIB_RX_PKTS_512_1023]; in vge_stats_update()
2678 stats->rx_pkts_1024_1518 += mib[VGE_MIB_RX_PKTS_1024_1518]; in vge_stats_update()
2679 stats->rx_pkts_1519_max += mib[VGE_MIB_RX_PKTS_1519_MAX]; in vge_stats_update()
2680 stats->rx_pkts_1519_max_errs += mib[VGE_MIB_RX_PKTS_1519_MAX_ERRS]; in vge_stats_update()
2681 stats->rx_jumbos += mib[VGE_MIB_RX_JUMBOS]; in vge_stats_update()
2682 stats->rx_crcerrs += mib[VGE_MIB_RX_CRCERRS]; in vge_stats_update()
2683 stats->rx_pause_frames += mib[VGE_MIB_RX_PAUSE]; in vge_stats_update()
2684 stats->rx_alignerrs += mib[VGE_MIB_RX_ALIGNERRS]; in vge_stats_update()
2685 stats->rx_nobufs += mib[VGE_MIB_RX_NOBUFS]; in vge_stats_update()
2686 stats->rx_symerrs += mib[VGE_MIB_RX_SYMERRS]; in vge_stats_update()
2687 stats->rx_lenerrs += mib[VGE_MIB_RX_LENERRS]; in vge_stats_update()
2690 stats->tx_good_frames += mib[VGE_MIB_TX_GOOD_FRAMES]; in vge_stats_update()
2691 stats->tx_pkts_64 += mib[VGE_MIB_TX_PKTS_64]; in vge_stats_update()
2692 stats->tx_pkts_65_127 += mib[VGE_MIB_TX_PKTS_65_127]; in vge_stats_update()
2693 stats->tx_pkts_128_255 += mib[VGE_MIB_TX_PKTS_128_255]; in vge_stats_update()
2694 stats->tx_pkts_256_511 += mib[VGE_MIB_TX_PKTS_256_511]; in vge_stats_update()
2695 stats->tx_pkts_512_1023 += mib[VGE_MIB_TX_PKTS_512_1023]; in vge_stats_update()
2696 stats->tx_pkts_1024_1518 += mib[VGE_MIB_TX_PKTS_1024_1518]; in vge_stats_update()
2697 stats->tx_jumbos += mib[VGE_MIB_TX_JUMBOS]; in vge_stats_update()
2698 stats->tx_colls += mib[VGE_MIB_TX_COLLS]; in vge_stats_update()
2699 stats->tx_pause += mib[VGE_MIB_TX_PAUSE]; in vge_stats_update()
2701 stats->tx_sqeerrs += mib[VGE_MIB_TX_SQEERRS]; in vge_stats_update()
2703 stats->tx_latecolls += mib[VGE_MIB_TX_LATECOLLS]; in vge_stats_update()
2736 * It's possible to use single-shot timer in VGE_CRS1 register in vge_intr_holdoff()
2741 * what single-shot timer value should be used in advance so in vge_intr_holdoff()
2746 CSR_WRITE_1(sc, VGE_TXSUPPTHR, sc->vge_tx_coal_pkt); in vge_intr_holdoff()
2750 CSR_WRITE_1(sc, VGE_RXSUPPTHR, sc->vge_rx_coal_pkt); in vge_intr_holdoff()
2755 if (sc->vge_tx_coal_pkt <= 0) in vge_intr_holdoff()
2759 if (sc->vge_rx_coal_pkt <= 0) in vge_intr_holdoff()
2765 if (sc->vge_int_holdoff > 0) { in vge_intr_holdoff()
2769 VGE_INT_HOLDOFF_USEC(sc->vge_int_holdoff)); in vge_intr_holdoff()
2783 mii = device_get_softc(sc->vge_miibus); in vge_setlinkspeed()
2786 if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == in vge_setlinkspeed()
2788 switch IFM_SUBTYPE(mii->mii_media_active) { in vge_setlinkspeed()
2801 vge_miibus_writereg(sc->vge_dev, sc->vge_phyaddr, MII_100T2CR, 0); in vge_setlinkspeed()
2802 vge_miibus_writereg(sc->vge_dev, sc->vge_phyaddr, MII_ANAR, in vge_setlinkspeed()
2804 vge_miibus_writereg(sc->vge_dev, sc->vge_phyaddr, MII_BMCR, in vge_setlinkspeed()
2811 if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) in vge_setlinkspeed()
2813 switch (IFM_SUBTYPE(mii->mii_media_active)) { in vge_setlinkspeed()
2826 device_printf(sc->vge_dev, "establishing link failed, " in vge_setlinkspeed()
2830 * No link, force MAC to have 100Mbps, full-duplex link. in vge_setlinkspeed()
2833 mii->mii_media_status = IFM_AVALID | IFM_ACTIVE; in vge_setlinkspeed()
2834 mii->mii_media_active = IFM_ETHER | IFM_100_TX | IFM_FDX; in vge_setlinkspeed()
2846 if ((sc->vge_flags & VGE_FLAG_PMCAP) == 0) { in vge_setwol()
2848 vge_miibus_writereg(sc->vge_dev, sc->vge_phyaddr, MII_BMCR, in vge_setwol()
2854 ifp = sc->vge_ifp; in vge_setwol()
2874 /* Disable MII auto-polling. */ in vge_setwol()
2893 pmstat = pci_read_config(sc->vge_dev, sc->vge_pmcap + in vge_setwol()
2898 pci_write_config(sc->vge_dev, sc->vge_pmcap + PCIR_POWER_STATUS, in vge_setwol()