Lines Matching +full:dma +full:- +full:poll +full:- +full:cnt
1 /*-
2 * SPDX-License-Identifier: BSD-4-Clause
4 * Copyright (c) 1997, 1998-2003
18 * 4. Neither the name of the author nor the names of any co-contributors
55 * o Descriptor based DMA mechanism. Each descriptor represents
59 * o 64-bit DMA
63 * o High and normal priority transmit DMA rings
69 * Like the 8139, the 8139C+ also has a built-in 10/100 PHY. The C+
74 * The 8169 is a 64-bit 10/100/1000 gigabit ethernet MAC. It has almost the
85 * o RX and TX DMA rings can have up to 1024 descriptors
93 * have a built-in PHY. Most reference boards use a Marvell 88E1000 'Alaska'
96 * The 8169S/8110S 10/100/1000 devices have built-in copper gigE PHYs
97 * (the 'S' stands for 'single-chip'). These devices have the same
98 * programming API as the older 8169, but also have some vendor-specific
99 * registers for the on-board PHY. The 8110S is a LAN-on-motherboard
100 * part designed to be pin-compatible with the RealTek 8100 10/100 chip.
178 "D-Link DGE-528(T) Gigabit Ethernet Adapter" },
180 "D-Link DGE-530(T) Gigabit Ethernet Adapter" },
192 "TP-Link TG-3468 v2 (RTL8168) Gigabit Ethernet" },
196 "RealTek 8169SC/8110SC Single-chip Gigabit Ethernet" },
198 "Corega CG-LAPCIGT (RTL8169S) Gigabit Ethernet" },
208 { RL_HWREV_8139AG, RL_8139, "A-G", RL_MTU },
243 { RL_HWREV_8168E_VL, RL_8169, "8168E/8111E-VL", RL_JUMBO_MTU_6K},
357 nitems(re_devs) - 1);
375 d = addr | (RL_9346_READ << sc->rl_eewidth); in re_eeprom_putbyte()
381 for (i = 1 << (sc->rl_eewidth + 3); i; i >>= 1) { in re_eeprom_putbyte()
428 re_read_eeprom(struct rl_softc *sc, caddr_t dest, int off, int cnt) in re_read_eeprom() argument
437 for (i = 0; i < cnt; i++) { in re_read_eeprom()
474 device_printf(sc->rl_dev, "PHY read failed\n"); in re_gmii_readreg()
506 device_printf(sc->rl_dev, "PHY write failed\n"); in re_gmii_writereg()
527 if (sc->rl_type == RL_8169) { in re_miibus_readreg()
561 device_printf(sc->rl_dev, "bad phy register\n"); in re_miibus_readreg()
565 if (sc->rl_type == RL_8139CPLUS && re8139_reg == RL_BMCR) { in re_miibus_readreg()
581 if (sc->rl_type == RL_8169) { in re_miibus_writereg()
589 if (sc->rl_type == RL_8139CPLUS) { in re_miibus_writereg()
611 device_printf(sc->rl_dev, "bad phy register\n"); in re_miibus_writereg()
626 mii = device_get_softc(sc->rl_miibus); in re_miibus_statchg()
627 ifp = sc->rl_ifp; in re_miibus_statchg()
632 sc->rl_flags &= ~RL_FLAG_LINK; in re_miibus_statchg()
633 if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == in re_miibus_statchg()
635 switch (IFM_SUBTYPE(mii->mii_media_active)) { in re_miibus_statchg()
638 sc->rl_flags |= RL_FLAG_LINK; in re_miibus_statchg()
641 if ((sc->rl_flags & RL_FLAG_FASTETHER) != 0) in re_miibus_statchg()
643 sc->rl_flags |= RL_FLAG_LINK; in re_miibus_statchg()
651 * MACs for resolved speed, duplex and flow-control parameters. in re_miibus_statchg()
656 re_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) in re_hash_maddr() argument
664 hashes[1] |= (1 << (h - 32)); in re_hash_maddr()
670 * Set the RX configuration and 64-bit multicast hash filter.
681 ifp = sc->rl_ifp; in re_set_rxmode()
684 if ((sc->rl_flags & RL_FLAG_EARLYOFF) != 0) in re_set_rxmode()
686 else if ((sc->rl_flags & RL_FLAG_8168G_PLUS) != 0) in re_set_rxmode()
712 if ((sc->rl_flags & RL_FLAG_PCIE) != 0) { in re_set_rxmode()
720 if (sc->rl_hwrev->rl_rev == RL_HWREV_8168F) { in re_set_rxmode()
747 device_printf(sc->rl_dev, "reset never completed!\n"); in re_reset()
749 if ((sc->rl_flags & RL_FLAG_MACRESET) != 0) in re_reset()
751 if (sc->rl_hwrev->rl_rev == RL_HWREV_8169S) in re_reset()
752 re_gmii_writereg(sc->rl_dev, 1, 0x0b, 0); in re_reset()
759 * 32-bit 8169 cards. Some of these NICs have the REQ64# and ACK64#
760 * lines connected to the bus, however for a 32-bit only card, they
762 * NIC will not work right if you plug it into a 64-bit slot: DMA
763 * operations will be done with 64-bit transfers, which will fail
764 * because the 64-bit data lines aren't connected.
772 * a defective NIC which has been mistakenly plugged into a 64-bit PCI
780 if_t ifp = sc->rl_ifp; in re_diag()
801 * - Puts receiver in promiscuous mode in re_diag()
802 * - Enables digital loopback mode in re_diag()
803 * - Leaves interrupts turned off in re_diag()
807 sc->rl_testmode = 1; in re_diag()
810 sc->rl_flags |= RL_FLAG_LINK; in re_diag()
811 if (sc->rl_type == RL_8169) in re_diag()
816 re_miibus_writereg(sc->rl_dev, phyaddr, MII_BMCR, BMCR_RESET); in re_diag()
818 status = re_miibus_readreg(sc->rl_dev, phyaddr, MII_BMCR); in re_diag()
823 re_miibus_writereg(sc->rl_dev, phyaddr, MII_BMCR, BMCR_LOOP); in re_diag()
831 bcopy ((char *)&dst, eh->ether_dhost, ETHER_ADDR_LEN); in re_diag()
832 bcopy ((char *)&src, eh->ether_shost, ETHER_ADDR_LEN); in re_diag()
833 eh->ether_type = htons(ETHERTYPE_IP); in re_diag()
834 m0->m_pkthdr.len = m0->m_len = ETHER_MIN_LEN - ETHER_CRC_LEN; in re_diag()
861 device_printf(sc->rl_dev, in re_diag()
870 * entry in the RX DMA ring. Grab it from there. in re_diag()
873 bus_dmamap_sync(sc->rl_ldata.rl_rx_list_tag, in re_diag()
874 sc->rl_ldata.rl_rx_list_map, in re_diag()
876 bus_dmamap_sync(sc->rl_ldata.rl_rx_mtag, in re_diag()
877 sc->rl_ldata.rl_rx_desc[0].rx_dmamap, in re_diag()
879 bus_dmamap_unload(sc->rl_ldata.rl_rx_mtag, in re_diag()
880 sc->rl_ldata.rl_rx_desc[0].rx_dmamap); in re_diag()
882 m0 = sc->rl_ldata.rl_rx_desc[0].rx_m; in re_diag()
883 sc->rl_ldata.rl_rx_desc[0].rx_m = NULL; in re_diag()
886 cur_rx = &sc->rl_ldata.rl_rx_list[0]; in re_diag()
888 rxstat = le32toh(cur_rx->rl_cmdstat); in re_diag()
891 device_printf(sc->rl_dev, in re_diag()
899 if (bcmp((char *)&eh->ether_dhost, (char *)&dst, ETHER_ADDR_LEN) || in re_diag()
900 bcmp((char *)&eh->ether_shost, (char *)&src, ETHER_ADDR_LEN) || in re_diag()
901 ntohs(eh->ether_type) != ETHERTYPE_IP) { in re_diag()
902 device_printf(sc->rl_dev, "WARNING, DMA FAILURE!\n"); in re_diag()
903 device_printf(sc->rl_dev, "expected TX data: %6D/%6D/0x%x\n", in re_diag()
905 device_printf(sc->rl_dev, "received RX data: %6D/%6D/0x%x\n", in re_diag()
906 eh->ether_dhost, ":", eh->ether_shost, ":", in re_diag()
907 ntohs(eh->ether_type)); in re_diag()
908 device_printf(sc->rl_dev, "You may have a defective 32-bit " in re_diag()
909 "NIC plugged into a 64-bit PCI slot.\n"); in re_diag()
910 device_printf(sc->rl_dev, "Please re-install the NIC in a " in re_diag()
911 "32-bit slot for proper operation.\n"); in re_diag()
912 device_printf(sc->rl_dev, "Read the re(4) man page for more " in re_diag()
920 sc->rl_testmode = 0; in re_diag()
921 sc->rl_flags &= ~RL_FLAG_LINK; in re_diag()
970 if (vendor == t->rl_vid && devid == t->rl_did) { in re_probe()
971 device_set_desc(dev, t->rl_name); in re_probe()
991 KASSERT(nseg == 1, ("too many DMA segments, %d should be 1", nseg)); in re_dma_map_addr()
993 *addr = segs->ds_addr; in re_dma_map_addr()
1004 rx_list_size = sc->rl_ldata.rl_rx_desc_cnt * sizeof(struct rl_desc); in re_allocmem()
1005 tx_list_size = sc->rl_ldata.rl_tx_desc_cnt * sizeof(struct rl_desc); in re_allocmem()
1008 * Allocate the parent bus DMA tag appropriate for PCI. in re_allocmem()
1012 * DMA address space to 32bit. PCIe variants of RealTek chips in re_allocmem()
1016 if ((sc->rl_flags & RL_FLAG_PCIE) == 0) in re_allocmem()
1021 NULL, NULL, &sc->rl_parent_tag); in re_allocmem()
1023 device_printf(dev, "could not allocate parent DMA tag\n"); in re_allocmem()
1030 error = bus_dma_tag_create(sc->rl_parent_tag, 1, 0, in re_allocmem()
1033 NULL, NULL, &sc->rl_ldata.rl_tx_mtag); in re_allocmem()
1035 device_printf(dev, "could not allocate TX DMA tag\n"); in re_allocmem()
1043 if ((sc->rl_flags & RL_FLAG_JUMBOV2) != 0) { in re_allocmem()
1044 error = bus_dma_tag_create(sc->rl_parent_tag, sizeof(uint64_t), in re_allocmem()
1047 &sc->rl_ldata.rl_jrx_mtag); in re_allocmem()
1050 "could not allocate jumbo RX DMA tag\n"); in re_allocmem()
1054 error = bus_dma_tag_create(sc->rl_parent_tag, sizeof(uint64_t), 0, in re_allocmem()
1056 MCLBYTES, 1, MCLBYTES, 0, NULL, NULL, &sc->rl_ldata.rl_rx_mtag); in re_allocmem()
1058 device_printf(dev, "could not allocate RX DMA tag\n"); in re_allocmem()
1065 error = bus_dma_tag_create(sc->rl_parent_tag, RL_RING_ALIGN, in re_allocmem()
1068 NULL, NULL, &sc->rl_ldata.rl_tx_list_tag); in re_allocmem()
1070 device_printf(dev, "could not allocate TX DMA ring tag\n"); in re_allocmem()
1074 /* Allocate DMA'able memory for the TX ring */ in re_allocmem()
1076 error = bus_dmamem_alloc(sc->rl_ldata.rl_tx_list_tag, in re_allocmem()
1077 (void **)&sc->rl_ldata.rl_tx_list, in re_allocmem()
1079 &sc->rl_ldata.rl_tx_list_map); in re_allocmem()
1081 device_printf(dev, "could not allocate TX DMA ring\n"); in re_allocmem()
1087 sc->rl_ldata.rl_tx_list_addr = 0; in re_allocmem()
1088 error = bus_dmamap_load(sc->rl_ldata.rl_tx_list_tag, in re_allocmem()
1089 sc->rl_ldata.rl_tx_list_map, sc->rl_ldata.rl_tx_list, in re_allocmem()
1091 &sc->rl_ldata.rl_tx_list_addr, BUS_DMA_NOWAIT); in re_allocmem()
1092 if (error != 0 || sc->rl_ldata.rl_tx_list_addr == 0) { in re_allocmem()
1093 device_printf(dev, "could not load TX DMA ring\n"); in re_allocmem()
1097 /* Create DMA maps for TX buffers */ in re_allocmem()
1099 for (i = 0; i < sc->rl_ldata.rl_tx_desc_cnt; i++) { in re_allocmem()
1100 error = bus_dmamap_create(sc->rl_ldata.rl_tx_mtag, 0, in re_allocmem()
1101 &sc->rl_ldata.rl_tx_desc[i].tx_dmamap); in re_allocmem()
1103 device_printf(dev, "could not create DMA map for TX\n"); in re_allocmem()
1111 error = bus_dma_tag_create(sc->rl_parent_tag, RL_RING_ALIGN, in re_allocmem()
1114 NULL, NULL, &sc->rl_ldata.rl_rx_list_tag); in re_allocmem()
1116 device_printf(dev, "could not create RX DMA ring tag\n"); in re_allocmem()
1120 /* Allocate DMA'able memory for the RX ring */ in re_allocmem()
1122 error = bus_dmamem_alloc(sc->rl_ldata.rl_rx_list_tag, in re_allocmem()
1123 (void **)&sc->rl_ldata.rl_rx_list, in re_allocmem()
1125 &sc->rl_ldata.rl_rx_list_map); in re_allocmem()
1127 device_printf(dev, "could not allocate RX DMA ring\n"); in re_allocmem()
1133 sc->rl_ldata.rl_rx_list_addr = 0; in re_allocmem()
1134 error = bus_dmamap_load(sc->rl_ldata.rl_rx_list_tag, in re_allocmem()
1135 sc->rl_ldata.rl_rx_list_map, sc->rl_ldata.rl_rx_list, in re_allocmem()
1137 &sc->rl_ldata.rl_rx_list_addr, BUS_DMA_NOWAIT); in re_allocmem()
1138 if (error != 0 || sc->rl_ldata.rl_rx_list_addr == 0) { in re_allocmem()
1139 device_printf(dev, "could not load RX DMA ring\n"); in re_allocmem()
1143 /* Create DMA maps for RX buffers */ in re_allocmem()
1145 if ((sc->rl_flags & RL_FLAG_JUMBOV2) != 0) { in re_allocmem()
1146 error = bus_dmamap_create(sc->rl_ldata.rl_jrx_mtag, 0, in re_allocmem()
1147 &sc->rl_ldata.rl_jrx_sparemap); in re_allocmem()
1150 "could not create spare DMA map for jumbo RX\n"); in re_allocmem()
1153 for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) { in re_allocmem()
1154 error = bus_dmamap_create(sc->rl_ldata.rl_jrx_mtag, 0, in re_allocmem()
1155 &sc->rl_ldata.rl_jrx_desc[i].rx_dmamap); in re_allocmem()
1158 "could not create DMA map for jumbo RX\n"); in re_allocmem()
1163 error = bus_dmamap_create(sc->rl_ldata.rl_rx_mtag, 0, in re_allocmem()
1164 &sc->rl_ldata.rl_rx_sparemap); in re_allocmem()
1166 device_printf(dev, "could not create spare DMA map for RX\n"); in re_allocmem()
1169 for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) { in re_allocmem()
1170 error = bus_dmamap_create(sc->rl_ldata.rl_rx_mtag, 0, in re_allocmem()
1171 &sc->rl_ldata.rl_rx_desc[i].rx_dmamap); in re_allocmem()
1173 device_printf(dev, "could not create DMA map for RX\n"); in re_allocmem()
1178 /* Create DMA map for statistics. */ in re_allocmem()
1179 error = bus_dma_tag_create(sc->rl_parent_tag, RL_DUMP_ALIGN, 0, in re_allocmem()
1182 &sc->rl_ldata.rl_stag); in re_allocmem()
1184 device_printf(dev, "could not create statistics DMA tag\n"); in re_allocmem()
1187 /* Allocate DMA'able memory for statistics. */ in re_allocmem()
1188 error = bus_dmamem_alloc(sc->rl_ldata.rl_stag, in re_allocmem()
1189 (void **)&sc->rl_ldata.rl_stats, in re_allocmem()
1191 &sc->rl_ldata.rl_smap); in re_allocmem()
1194 "could not allocate statistics DMA memory\n"); in re_allocmem()
1198 sc->rl_ldata.rl_stats_addr = 0; in re_allocmem()
1199 error = bus_dmamap_load(sc->rl_ldata.rl_stag, sc->rl_ldata.rl_smap, in re_allocmem()
1200 sc->rl_ldata.rl_stats, sizeof(struct rl_stats), re_dma_map_addr, in re_allocmem()
1201 &sc->rl_ldata.rl_stats_addr, BUS_DMA_NOWAIT); in re_allocmem()
1202 if (error != 0 || sc->rl_ldata.rl_stats_addr == 0) { in re_allocmem()
1203 device_printf(dev, "could not load statistics DMA memory\n"); in re_allocmem()
1229 sc->rl_dev = dev; in re_attach()
1231 mtx_init(&sc->rl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, in re_attach()
1233 callout_init_mtx(&sc->rl_stat_callout, &sc->rl_mtx, 0); in re_attach()
1249 sc->rl_res_id = PCIR_BAR(1); in re_attach()
1250 sc->rl_res_type = SYS_RES_MEMORY; in re_attach()
1253 sc->rl_res_id = PCIR_BAR(2); in re_attach()
1255 sc->rl_res_id = PCIR_BAR(0); in re_attach()
1256 sc->rl_res_type = SYS_RES_IOPORT; in re_attach()
1258 sc->rl_res = bus_alloc_resource_any(dev, sc->rl_res_type, in re_attach()
1259 &sc->rl_res_id, RF_ACTIVE); in re_attach()
1260 if (sc->rl_res == NULL && prefer_iomap == 0) { in re_attach()
1261 sc->rl_res_id = PCIR_BAR(0); in re_attach()
1262 sc->rl_res_type = SYS_RES_IOPORT; in re_attach()
1263 sc->rl_res = bus_alloc_resource_any(dev, sc->rl_res_type, in re_attach()
1264 &sc->rl_res_id, RF_ACTIVE); in re_attach()
1266 if (sc->rl_res == NULL) { in re_attach()
1272 sc->rl_btag = rman_get_bustag(sc->rl_res); in re_attach()
1273 sc->rl_bhandle = rman_get_bushandle(sc->rl_res); in re_attach()
1278 sc->rl_flags |= RL_FLAG_PCIE; in re_attach()
1279 sc->rl_expcap = reg; in re_attach()
1283 device_printf(dev, "MSI-X count : %d\n", msixc); in re_attach()
1289 /* Prefer MSI-X to MSI. */ in re_attach()
1293 sc->rl_res_pba = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in re_attach()
1295 if (sc->rl_res_pba == NULL) { in re_attach()
1296 device_printf(sc->rl_dev, in re_attach()
1297 "could not allocate MSI-X PBA resource\n"); in re_attach()
1299 if (sc->rl_res_pba != NULL && in re_attach()
1302 device_printf(dev, "Using %d MSI-X message\n", in re_attach()
1304 sc->rl_flags |= RL_FLAG_MSIX; in re_attach()
1308 if ((sc->rl_flags & RL_FLAG_MSIX) == 0) { in re_attach()
1309 if (sc->rl_res_pba != NULL) in re_attach()
1311 sc->rl_res_pba); in re_attach()
1312 sc->rl_res_pba = NULL; in re_attach()
1323 sc->rl_flags |= RL_FLAG_MSI; in re_attach()
1333 if ((sc->rl_flags & RL_FLAG_MSI) == 0) in re_attach()
1338 if ((sc->rl_flags & (RL_FLAG_MSI | RL_FLAG_MSIX)) == 0) { in re_attach()
1340 sc->rl_irq[0] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, in re_attach()
1342 if (sc->rl_irq[0] == NULL) { in re_attach()
1349 sc->rl_irq[i] = bus_alloc_resource_any(dev, in re_attach()
1351 if (sc->rl_irq[i] == NULL) { in re_attach()
1361 if ((sc->rl_flags & RL_FLAG_MSI) == 0) { in re_attach()
1373 if (sc->rl_expcap != 0) { in re_attach()
1374 cap = pci_read_config(dev, sc->rl_expcap + in re_attach()
1377 ctl = pci_read_config(dev, sc->rl_expcap + in re_attach()
1383 pci_write_config(dev, sc->rl_expcap + in re_attach()
1401 sc->rl_macrev = hwrev & 0x00700000; in re_attach()
1405 device_printf(dev, "MAC rev. 0x%08x\n", sc->rl_macrev); in re_attach()
1406 while (hw_rev->rl_desc != NULL) { in re_attach()
1407 if (hw_rev->rl_rev == hwrev) { in re_attach()
1408 sc->rl_type = hw_rev->rl_type; in re_attach()
1409 sc->rl_hwrev = hw_rev; in re_attach()
1414 if (hw_rev->rl_desc == NULL) { in re_attach()
1420 switch (hw_rev->rl_rev) { in re_attach()
1422 sc->rl_flags |= RL_FLAG_FASTETHER | RL_FLAG_AUTOPAD; in re_attach()
1426 sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_FASTETHER; in re_attach()
1431 sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | RL_FLAG_DESCV2 | in re_attach()
1436 sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | RL_FLAG_DESCV2 | in re_attach()
1444 sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PHYWAKE_PM | in re_attach()
1449 sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PHYWAKE_PM | in re_attach()
1456 sc->rl_flags |= RL_FLAG_WOLRXENB; in re_attach()
1459 sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_MACSTAT; in re_attach()
1462 sc->rl_flags |= RL_FLAG_MACSLEEP; in re_attach()
1465 if (sc->rl_macrev == 0x00200000) in re_attach()
1466 sc->rl_flags |= RL_FLAG_MACSLEEP; in re_attach()
1469 sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | in re_attach()
1474 sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PHYWAKE_PM | in re_attach()
1480 sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | in re_attach()
1485 sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PHYWAKE_PM | in re_attach()
1492 sc->rl_flags |= RL_FLAG_EARLYOFF; in re_attach()
1495 sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | in re_attach()
1504 sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | in re_attach()
1514 sc->rl_flags |= RL_FLAG_FASTETHER; in re_attach()
1516 sc->rl_flags |= RL_FLAG_JUMBOV2 | RL_FLAG_WOL_MANLINK; in re_attach()
1518 sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | in re_attach()
1527 sc->rl_flags |= RL_FLAG_PHYWAKE; in re_attach()
1532 sc->rl_flags |= RL_FLAG_MACRESET; in re_attach()
1538 if (sc->rl_hwrev->rl_rev == RL_HWREV_8139CPLUS) { in re_attach()
1539 sc->rl_cfg0 = RL_8139_CFG0; in re_attach()
1540 sc->rl_cfg1 = RL_8139_CFG1; in re_attach()
1541 sc->rl_cfg2 = 0; in re_attach()
1542 sc->rl_cfg3 = RL_8139_CFG3; in re_attach()
1543 sc->rl_cfg4 = RL_8139_CFG4; in re_attach()
1544 sc->rl_cfg5 = RL_8139_CFG5; in re_attach()
1546 sc->rl_cfg0 = RL_CFG0; in re_attach()
1547 sc->rl_cfg1 = RL_CFG1; in re_attach()
1548 sc->rl_cfg2 = RL_CFG2; in re_attach()
1549 sc->rl_cfg3 = RL_CFG3; in re_attach()
1550 sc->rl_cfg4 = RL_CFG4; in re_attach()
1551 sc->rl_cfg5 = RL_CFG5; in re_attach()
1561 cfg = CSR_READ_1(sc, sc->rl_cfg1); in re_attach()
1563 CSR_WRITE_1(sc, sc->rl_cfg1, cfg); in re_attach()
1564 cfg = CSR_READ_1(sc, sc->rl_cfg5); in re_attach()
1566 CSR_WRITE_1(sc, sc->rl_cfg5, cfg); in re_attach()
1569 if ((sc->rl_flags & RL_FLAG_PAR) != 0) { in re_attach()
1577 sc->rl_eewidth = RL_9356_ADDR_LEN; in re_attach()
1580 sc->rl_eewidth = RL_9346_ADDR_LEN; in re_attach()
1591 if (sc->rl_type == RL_8169) { in re_attach()
1593 sc->rl_rxlenmask = RL_RDESC_STAT_GFRAGLEN; in re_attach()
1594 sc->rl_txstart = RL_GTXSTART; in re_attach()
1595 sc->rl_ldata.rl_tx_desc_cnt = RL_8169_TX_DESC_CNT; in re_attach()
1596 sc->rl_ldata.rl_rx_desc_cnt = RL_8169_RX_DESC_CNT; in re_attach()
1599 sc->rl_rxlenmask = RL_RDESC_STAT_FRAGLEN; in re_attach()
1600 sc->rl_txstart = RL_TXSTART; in re_attach()
1601 sc->rl_ldata.rl_tx_desc_cnt = RL_8139_TX_DESC_CNT; in re_attach()
1602 sc->rl_ldata.rl_rx_desc_cnt = RL_8139_RX_DESC_CNT; in re_attach()
1610 ifp = sc->rl_ifp = if_alloc(IFT_ETHER); in re_attach()
1613 if ((sc->rl_flags & RL_FLAG_MACSLEEP) != 0) { in re_attach()
1623 if ((sc->rl_flags & RL_FLAG_PHYWAKE_PM) != 0) { in re_attach()
1625 if (hw_rev->rl_rev == RL_HWREV_8401E) in re_attach()
1628 if ((sc->rl_flags & RL_FLAG_PHYWAKE) != 0) { in re_attach()
1642 if (sc->rl_hwrev->rl_rev == RL_HWREV_8168C || in re_attach()
1643 sc->rl_hwrev->rl_rev == RL_HWREV_8168C_SPIN2 || in re_attach()
1644 sc->rl_hwrev->rl_rev == RL_HWREV_8168CP) { in re_attach()
1657 NET_TASK_INIT(&sc->rl_inttask, 0, re_int_task, sc); in re_attach()
1663 if (sc->rl_type == RL_8169) in re_attach()
1666 if ((sc->rl_flags & RL_FLAG_FASTETHER) != 0) in re_attach()
1668 error = mii_attach(dev, &sc->rl_miibus, ifp, re_ifmedia_upd, in re_attach()
1690 if (pci_has_pm(sc->rl_dev)) in re_attach()
1718 * Some 32-bit cards were incorrectly wired and would in re_attach()
1719 * malfunction if plugged into a 64-bit slot. in re_attach()
1736 if ((sc->rl_flags & (RL_FLAG_MSI | RL_FLAG_MSIX)) != 0 && in re_attach()
1738 error = bus_setup_intr(dev, sc->rl_irq[0], in re_attach()
1740 &sc->rl_intrhand[0]); in re_attach()
1742 error = bus_setup_intr(dev, sc->rl_irq[0], in re_attach()
1744 &sc->rl_intrhand[0]); in re_attach()
1776 ifp = sc->rl_ifp; in re_detach()
1777 KASSERT(mtx_initialized(&sc->rl_mtx), ("re mutex not initialized")); in re_detach()
1787 sc->suspended = 1; in re_detach()
1791 callout_drain(&sc->rl_stat_callout); in re_detach()
1792 taskqueue_drain(taskqueue_fast, &sc->rl_inttask); in re_detach()
1815 if (sc->rl_intrhand[0] != NULL) { in re_detach()
1816 bus_teardown_intr(dev, sc->rl_irq[0], sc->rl_intrhand[0]); in re_detach()
1817 sc->rl_intrhand[0] = NULL; in re_detach()
1825 if ((sc->rl_flags & (RL_FLAG_MSI | RL_FLAG_MSIX)) == 0) in re_detach()
1829 if (sc->rl_irq[0] != NULL) { in re_detach()
1830 bus_release_resource(dev, SYS_RES_IRQ, rid, sc->rl_irq[0]); in re_detach()
1831 sc->rl_irq[0] = NULL; in re_detach()
1833 if ((sc->rl_flags & (RL_FLAG_MSI | RL_FLAG_MSIX)) != 0) in re_detach()
1835 if (sc->rl_res_pba) { in re_detach()
1837 bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->rl_res_pba); in re_detach()
1839 if (sc->rl_res) in re_detach()
1840 bus_release_resource(dev, sc->rl_res_type, sc->rl_res_id, in re_detach()
1841 sc->rl_res); in re_detach()
1843 /* Unload and free the RX DMA ring memory and map */ in re_detach()
1845 if (sc->rl_ldata.rl_rx_list_tag) { in re_detach()
1846 if (sc->rl_ldata.rl_rx_list_addr) in re_detach()
1847 bus_dmamap_unload(sc->rl_ldata.rl_rx_list_tag, in re_detach()
1848 sc->rl_ldata.rl_rx_list_map); in re_detach()
1849 if (sc->rl_ldata.rl_rx_list) in re_detach()
1850 bus_dmamem_free(sc->rl_ldata.rl_rx_list_tag, in re_detach()
1851 sc->rl_ldata.rl_rx_list, in re_detach()
1852 sc->rl_ldata.rl_rx_list_map); in re_detach()
1853 bus_dma_tag_destroy(sc->rl_ldata.rl_rx_list_tag); in re_detach()
1856 /* Unload and free the TX DMA ring memory and map */ in re_detach()
1858 if (sc->rl_ldata.rl_tx_list_tag) { in re_detach()
1859 if (sc->rl_ldata.rl_tx_list_addr) in re_detach()
1860 bus_dmamap_unload(sc->rl_ldata.rl_tx_list_tag, in re_detach()
1861 sc->rl_ldata.rl_tx_list_map); in re_detach()
1862 if (sc->rl_ldata.rl_tx_list) in re_detach()
1863 bus_dmamem_free(sc->rl_ldata.rl_tx_list_tag, in re_detach()
1864 sc->rl_ldata.rl_tx_list, in re_detach()
1865 sc->rl_ldata.rl_tx_list_map); in re_detach()
1866 bus_dma_tag_destroy(sc->rl_ldata.rl_tx_list_tag); in re_detach()
1871 if (sc->rl_ldata.rl_tx_mtag) { in re_detach()
1872 for (i = 0; i < sc->rl_ldata.rl_tx_desc_cnt; i++) { in re_detach()
1873 if (sc->rl_ldata.rl_tx_desc[i].tx_dmamap) in re_detach()
1874 bus_dmamap_destroy(sc->rl_ldata.rl_tx_mtag, in re_detach()
1875 sc->rl_ldata.rl_tx_desc[i].tx_dmamap); in re_detach()
1877 bus_dma_tag_destroy(sc->rl_ldata.rl_tx_mtag); in re_detach()
1879 if (sc->rl_ldata.rl_rx_mtag) { in re_detach()
1880 for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) { in re_detach()
1881 if (sc->rl_ldata.rl_rx_desc[i].rx_dmamap) in re_detach()
1882 bus_dmamap_destroy(sc->rl_ldata.rl_rx_mtag, in re_detach()
1883 sc->rl_ldata.rl_rx_desc[i].rx_dmamap); in re_detach()
1885 if (sc->rl_ldata.rl_rx_sparemap) in re_detach()
1886 bus_dmamap_destroy(sc->rl_ldata.rl_rx_mtag, in re_detach()
1887 sc->rl_ldata.rl_rx_sparemap); in re_detach()
1888 bus_dma_tag_destroy(sc->rl_ldata.rl_rx_mtag); in re_detach()
1890 if (sc->rl_ldata.rl_jrx_mtag) { in re_detach()
1891 for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) { in re_detach()
1892 if (sc->rl_ldata.rl_jrx_desc[i].rx_dmamap) in re_detach()
1893 bus_dmamap_destroy(sc->rl_ldata.rl_jrx_mtag, in re_detach()
1894 sc->rl_ldata.rl_jrx_desc[i].rx_dmamap); in re_detach()
1896 if (sc->rl_ldata.rl_jrx_sparemap) in re_detach()
1897 bus_dmamap_destroy(sc->rl_ldata.rl_jrx_mtag, in re_detach()
1898 sc->rl_ldata.rl_jrx_sparemap); in re_detach()
1899 bus_dma_tag_destroy(sc->rl_ldata.rl_jrx_mtag); in re_detach()
1903 if (sc->rl_ldata.rl_stag) { in re_detach()
1904 if (sc->rl_ldata.rl_stats_addr) in re_detach()
1905 bus_dmamap_unload(sc->rl_ldata.rl_stag, in re_detach()
1906 sc->rl_ldata.rl_smap); in re_detach()
1907 if (sc->rl_ldata.rl_stats) in re_detach()
1908 bus_dmamem_free(sc->rl_ldata.rl_stag, in re_detach()
1909 sc->rl_ldata.rl_stats, sc->rl_ldata.rl_smap); in re_detach()
1910 bus_dma_tag_destroy(sc->rl_ldata.rl_stag); in re_detach()
1913 if (sc->rl_parent_tag) in re_detach()
1914 bus_dma_tag_destroy(sc->rl_parent_tag); in re_detach()
1916 mtx_destroy(&sc->rl_mtx); in re_detach()
1928 if (if_getmtu(sc->rl_ifp) > RL_MTU && in re_discard_rxbuf()
1929 (sc->rl_flags & RL_FLAG_JUMBOV2) != 0) in re_discard_rxbuf()
1930 rxd = &sc->rl_ldata.rl_jrx_desc[idx]; in re_discard_rxbuf()
1932 rxd = &sc->rl_ldata.rl_rx_desc[idx]; in re_discard_rxbuf()
1933 desc = &sc->rl_ldata.rl_rx_list[idx]; in re_discard_rxbuf()
1934 desc->rl_vlanctl = 0; in re_discard_rxbuf()
1935 cmdstat = rxd->rx_size; in re_discard_rxbuf()
1936 if (idx == sc->rl_ldata.rl_rx_desc_cnt - 1) in re_discard_rxbuf()
1938 desc->rl_cmdstat = htole32(cmdstat | RL_RDESC_CMD_OWN); in re_discard_rxbuf()
1956 m->m_len = m->m_pkthdr.len = MCLBYTES; in re_newbuf()
1959 * This is part of an evil trick to deal with non-x86 platforms. in re_newbuf()
1960 * The RealTek chip requires RX buffers to be aligned on 64-bit in re_newbuf()
1961 * boundaries, but that will hose non-x86 machines. To get around in re_newbuf()
1963 * and for non-x86 hosts, we copy the buffer back six bytes in re_newbuf()
1970 error = bus_dmamap_load_mbuf_sg(sc->rl_ldata.rl_rx_mtag, in re_newbuf()
1971 sc->rl_ldata.rl_rx_sparemap, m, segs, &nsegs, BUS_DMA_NOWAIT); in re_newbuf()
1978 rxd = &sc->rl_ldata.rl_rx_desc[idx]; in re_newbuf()
1979 if (rxd->rx_m != NULL) { in re_newbuf()
1980 bus_dmamap_sync(sc->rl_ldata.rl_rx_mtag, rxd->rx_dmamap, in re_newbuf()
1982 bus_dmamap_unload(sc->rl_ldata.rl_rx_mtag, rxd->rx_dmamap); in re_newbuf()
1985 rxd->rx_m = m; in re_newbuf()
1986 map = rxd->rx_dmamap; in re_newbuf()
1987 rxd->rx_dmamap = sc->rl_ldata.rl_rx_sparemap; in re_newbuf()
1988 rxd->rx_size = segs[0].ds_len; in re_newbuf()
1989 sc->rl_ldata.rl_rx_sparemap = map; in re_newbuf()
1990 bus_dmamap_sync(sc->rl_ldata.rl_rx_mtag, rxd->rx_dmamap, in re_newbuf()
1993 desc = &sc->rl_ldata.rl_rx_list[idx]; in re_newbuf()
1994 desc->rl_vlanctl = 0; in re_newbuf()
1995 desc->rl_bufaddr_lo = htole32(RL_ADDR_LO(segs[0].ds_addr)); in re_newbuf()
1996 desc->rl_bufaddr_hi = htole32(RL_ADDR_HI(segs[0].ds_addr)); in re_newbuf()
1998 if (idx == sc->rl_ldata.rl_rx_desc_cnt - 1) in re_newbuf()
2000 desc->rl_cmdstat = htole32(cmdstat | RL_RDESC_CMD_OWN); in re_newbuf()
2019 m->m_len = m->m_pkthdr.len = MJUM9BYTES; in re_jumbo_newbuf()
2023 error = bus_dmamap_load_mbuf_sg(sc->rl_ldata.rl_jrx_mtag, in re_jumbo_newbuf()
2024 sc->rl_ldata.rl_jrx_sparemap, m, segs, &nsegs, BUS_DMA_NOWAIT); in re_jumbo_newbuf()
2031 rxd = &sc->rl_ldata.rl_jrx_desc[idx]; in re_jumbo_newbuf()
2032 if (rxd->rx_m != NULL) { in re_jumbo_newbuf()
2033 bus_dmamap_sync(sc->rl_ldata.rl_jrx_mtag, rxd->rx_dmamap, in re_jumbo_newbuf()
2035 bus_dmamap_unload(sc->rl_ldata.rl_jrx_mtag, rxd->rx_dmamap); in re_jumbo_newbuf()
2038 rxd->rx_m = m; in re_jumbo_newbuf()
2039 map = rxd->rx_dmamap; in re_jumbo_newbuf()
2040 rxd->rx_dmamap = sc->rl_ldata.rl_jrx_sparemap; in re_jumbo_newbuf()
2041 rxd->rx_size = segs[0].ds_len; in re_jumbo_newbuf()
2042 sc->rl_ldata.rl_jrx_sparemap = map; in re_jumbo_newbuf()
2043 bus_dmamap_sync(sc->rl_ldata.rl_jrx_mtag, rxd->rx_dmamap, in re_jumbo_newbuf()
2046 desc = &sc->rl_ldata.rl_rx_list[idx]; in re_jumbo_newbuf()
2047 desc->rl_vlanctl = 0; in re_jumbo_newbuf()
2048 desc->rl_bufaddr_lo = htole32(RL_ADDR_LO(segs[0].ds_addr)); in re_jumbo_newbuf()
2049 desc->rl_bufaddr_hi = htole32(RL_ADDR_HI(segs[0].ds_addr)); in re_jumbo_newbuf()
2051 if (idx == sc->rl_ldata.rl_rx_desc_cnt - 1) in re_jumbo_newbuf()
2053 desc->rl_cmdstat = htole32(cmdstat | RL_RDESC_CMD_OWN); in re_jumbo_newbuf()
2066 dst = src - (RE_ETHER_ALIGN - ETHER_ALIGN) / sizeof *src; in re_fixup_rx()
2068 for (i = 0; i < (m->m_len / sizeof(uint16_t) + 1); i++) in re_fixup_rx()
2071 m->m_data -= RE_ETHER_ALIGN - ETHER_ALIGN; in re_fixup_rx()
2083 bzero(sc->rl_ldata.rl_tx_list, in re_tx_list_init()
2084 sc->rl_ldata.rl_tx_desc_cnt * sizeof(struct rl_desc)); in re_tx_list_init()
2085 for (i = 0; i < sc->rl_ldata.rl_tx_desc_cnt; i++) in re_tx_list_init()
2086 sc->rl_ldata.rl_tx_desc[i].tx_m = NULL; in re_tx_list_init()
2091 desc = &sc->rl_ldata.rl_tx_list[sc->rl_ldata.rl_tx_desc_cnt - 1]; in re_tx_list_init()
2092 desc->rl_cmdstat |= htole32(RL_TDESC_CMD_EOR); in re_tx_list_init()
2094 bus_dmamap_sync(sc->rl_ldata.rl_tx_list_tag, in re_tx_list_init()
2095 sc->rl_ldata.rl_tx_list_map, in re_tx_list_init()
2098 sc->rl_ldata.rl_tx_prodidx = 0; in re_tx_list_init()
2099 sc->rl_ldata.rl_tx_considx = 0; in re_tx_list_init()
2100 sc->rl_ldata.rl_tx_free = sc->rl_ldata.rl_tx_desc_cnt; in re_tx_list_init()
2110 bzero(sc->rl_ldata.rl_rx_list, in re_rx_list_init()
2111 sc->rl_ldata.rl_rx_desc_cnt * sizeof(struct rl_desc)); in re_rx_list_init()
2112 for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) { in re_rx_list_init()
2113 sc->rl_ldata.rl_rx_desc[i].rx_m = NULL; in re_rx_list_init()
2123 bus_dmamap_sync(sc->rl_ldata.rl_rx_list_tag, in re_rx_list_init()
2124 sc->rl_ldata.rl_rx_list_map, in re_rx_list_init()
2127 sc->rl_ldata.rl_rx_prodidx = 0; in re_rx_list_init()
2128 sc->rl_head = sc->rl_tail = NULL; in re_rx_list_init()
2129 sc->rl_int_rx_act = 0; in re_rx_list_init()
2139 bzero(sc->rl_ldata.rl_rx_list, in re_jrx_list_init()
2140 sc->rl_ldata.rl_rx_desc_cnt * sizeof(struct rl_desc)); in re_jrx_list_init()
2141 for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) { in re_jrx_list_init()
2142 sc->rl_ldata.rl_jrx_desc[i].rx_m = NULL; in re_jrx_list_init()
2147 bus_dmamap_sync(sc->rl_ldata.rl_rx_list_tag, in re_jrx_list_init()
2148 sc->rl_ldata.rl_rx_list_map, in re_jrx_list_init()
2151 sc->rl_ldata.rl_rx_prodidx = 0; in re_jrx_list_init()
2152 sc->rl_head = sc->rl_tail = NULL; in re_jrx_list_init()
2153 sc->rl_int_rx_act = 0; in re_jrx_list_init()
2175 ifp = sc->rl_ifp; in re_rxeof()
2180 if (if_getmtu(ifp) > RL_MTU && (sc->rl_flags & RL_FLAG_JUMBOV2) != 0) in re_rxeof()
2187 bus_dmamap_sync(sc->rl_ldata.rl_rx_list_tag, in re_rxeof()
2188 sc->rl_ldata.rl_rx_list_map, in re_rxeof()
2191 for (i = sc->rl_ldata.rl_rx_prodidx; maxpkt > 0; in re_rxeof()
2195 cur_rx = &sc->rl_ldata.rl_rx_list[i]; in re_rxeof()
2196 rxstat = le32toh(cur_rx->rl_cmdstat); in re_rxeof()
2199 total_len = rxstat & sc->rl_rxlenmask; in re_rxeof()
2200 rxvlan = le32toh(cur_rx->rl_vlanctl); in re_rxeof()
2202 m = sc->rl_ldata.rl_jrx_desc[i].rx_m; in re_rxeof()
2204 m = sc->rl_ldata.rl_rx_desc[i].rx_m; in re_rxeof()
2206 if ((sc->rl_flags & RL_FLAG_JUMBOV2) != 0 && in re_rxeof()
2211 * support multi-fragment packet. in re_rxeof()
2218 * If this is part of a multi-fragment packet, in re_rxeof()
2221 if (sc->rl_head != NULL) { in re_rxeof()
2222 m_freem(sc->rl_head); in re_rxeof()
2223 sc->rl_head = sc->rl_tail = NULL; in re_rxeof()
2228 m->m_len = RE_RX_DESC_BUFLEN; in re_rxeof()
2229 if (sc->rl_head == NULL) in re_rxeof()
2230 sc->rl_head = sc->rl_tail = m; in re_rxeof()
2232 m->m_flags &= ~M_PKTHDR; in re_rxeof()
2233 sc->rl_tail->m_next = m; in re_rxeof()
2234 sc->rl_tail = m; in re_rxeof()
2255 if (sc->rl_type == RL_8169) in re_rxeof()
2259 * if total_len > 2^13-1, both _RXERRSUM and _GIANT will be in re_rxeof()
2264 if ((sc->rl_flags & RL_FLAG_JUMBOV2) == 0 && in re_rxeof()
2271 * If this is part of a multi-fragment packet, in re_rxeof()
2274 if (sc->rl_head != NULL) { in re_rxeof()
2275 m_freem(sc->rl_head); in re_rxeof()
2276 sc->rl_head = sc->rl_tail = NULL; in re_rxeof()
2293 if (sc->rl_head != NULL) { in re_rxeof()
2294 m_freem(sc->rl_head); in re_rxeof()
2295 sc->rl_head = sc->rl_tail = NULL; in re_rxeof()
2301 if (sc->rl_head != NULL) { in re_rxeof()
2303 m->m_len = total_len; in re_rxeof()
2305 m->m_len = total_len % RE_RX_DESC_BUFLEN; in re_rxeof()
2306 if (m->m_len == 0) in re_rxeof()
2307 m->m_len = RE_RX_DESC_BUFLEN; in re_rxeof()
2315 if (m->m_len <= ETHER_CRC_LEN) { in re_rxeof()
2316 sc->rl_tail->m_len -= in re_rxeof()
2317 (ETHER_CRC_LEN - m->m_len); in re_rxeof()
2320 m->m_len -= ETHER_CRC_LEN; in re_rxeof()
2321 m->m_flags &= ~M_PKTHDR; in re_rxeof()
2322 sc->rl_tail->m_next = m; in re_rxeof()
2324 m = sc->rl_head; in re_rxeof()
2325 sc->rl_head = sc->rl_tail = NULL; in re_rxeof()
2326 m->m_pkthdr.len = total_len - ETHER_CRC_LEN; in re_rxeof()
2328 m->m_pkthdr.len = m->m_len = in re_rxeof()
2329 (total_len - ETHER_CRC_LEN); in re_rxeof()
2335 m->m_pkthdr.rcvif = ifp; in re_rxeof()
2340 if ((sc->rl_flags & RL_FLAG_DESCV2) == 0) { in re_rxeof()
2343 m->m_pkthdr.csum_flags |= in re_rxeof()
2346 m->m_pkthdr.csum_flags |= in re_rxeof()
2354 m->m_pkthdr.csum_flags |= in re_rxeof()
2356 m->m_pkthdr.csum_data = 0xffff; in re_rxeof()
2364 m->m_pkthdr.csum_flags |= in re_rxeof()
2368 m->m_pkthdr.csum_flags |= in re_rxeof()
2374 m->m_pkthdr.csum_flags |= in re_rxeof()
2376 m->m_pkthdr.csum_data = 0xffff; in re_rxeof()
2380 maxpkt--; in re_rxeof()
2382 m->m_pkthdr.ether_vtag = in re_rxeof()
2384 m->m_flags |= M_VLANTAG; in re_rxeof()
2392 /* Flush the RX DMA ring */ in re_rxeof()
2394 bus_dmamap_sync(sc->rl_ldata.rl_rx_list_tag, in re_rxeof()
2395 sc->rl_ldata.rl_rx_list_map, in re_rxeof()
2398 sc->rl_ldata.rl_rx_prodidx = i; in re_rxeof()
2416 cons = sc->rl_ldata.rl_tx_considx; in re_txeof()
2417 if (cons == sc->rl_ldata.rl_tx_prodidx) in re_txeof()
2420 ifp = sc->rl_ifp; in re_txeof()
2426 bus_dmamap_sync(sc->rl_ldata.rl_tx_list_tag, in re_txeof()
2427 sc->rl_ldata.rl_tx_list_map, in re_txeof()
2430 for (; cons != sc->rl_ldata.rl_tx_prodidx; in re_txeof()
2432 txstat = le32toh(sc->rl_ldata.rl_tx_list[cons].rl_cmdstat); in re_txeof()
2442 txd = &sc->rl_ldata.rl_tx_desc[cons]; in re_txeof()
2443 bus_dmamap_sync(sc->rl_ldata.rl_tx_mtag, in re_txeof()
2444 txd->tx_dmamap, BUS_DMASYNC_POSTWRITE); in re_txeof()
2445 bus_dmamap_unload(sc->rl_ldata.rl_tx_mtag, in re_txeof()
2446 txd->tx_dmamap); in re_txeof()
2447 KASSERT(txd->tx_m != NULL, in re_txeof()
2449 m_freem(txd->tx_m); in re_txeof()
2450 txd->tx_m = NULL; in re_txeof()
2459 sc->rl_ldata.rl_tx_free++; in re_txeof()
2462 sc->rl_ldata.rl_tx_considx = cons; in re_txeof()
2466 if (sc->rl_ldata.rl_tx_free != sc->rl_ldata.rl_tx_desc_cnt) { in re_txeof()
2471 * interrupt that will cause us to re-enter this routine. in re_txeof()
2477 sc->rl_watchdog_timer = 0; in re_txeof()
2490 mii = device_get_softc(sc->rl_miibus); in re_tick()
2492 if ((sc->rl_flags & RL_FLAG_LINK) == 0) in re_tick()
2493 re_miibus_statchg(sc->rl_dev); in re_tick()
2502 callout_reset(&sc->rl_stat_callout, hz, re_tick, sc); in re_tick()
2527 sc->rxcycles = count; in re_poll_locked()
2543 (sc->rl_flags & RL_FLAG_PCIE)) in re_poll_locked()
2544 CSR_WRITE_1(sc, sc->rl_txstart, RL_TXSTART_START); in re_poll_locked()
2572 taskqueue_enqueue(taskqueue_fast, &sc->rl_inttask); in re_intr()
2586 ifp = sc->rl_ifp; in re_int_task()
2593 if (sc->suspended || in re_int_task()
2618 (sc->rl_flags & RL_FLAG_PCIE)) in re_int_task()
2619 CSR_WRITE_1(sc, sc->rl_txstart, RL_TXSTART_START); in re_int_task()
2640 taskqueue_enqueue(taskqueue_fast, &sc->rl_inttask); in re_int_task()
2657 ifp = sc->rl_ifp; in re_intr_msi()
2674 if (sc->rl_int_rx_act > 0) { in re_intr_msi()
2685 if (sc->rl_int_rx_mod != 0 && in re_intr_msi()
2688 /* Rearm one-shot timer. */ in re_intr_msi()
2692 sc->rl_int_rx_act = 1; in re_intr_msi()
2696 sc->rl_int_rx_act = 0; in re_intr_msi()
2710 (sc->rl_flags & RL_FLAG_PCIE)) in re_intr_msi()
2711 CSR_WRITE_1(sc, sc->rl_txstart, RL_TXSTART_START); in re_intr_msi()
2755 if ((sc->rl_flags & RL_FLAG_AUTOPAD) == 0 && in re_encap()
2756 (*m_head)->m_pkthdr.len < RL_IP4CSUMTX_PADLEN && in re_encap()
2757 ((*m_head)->m_pkthdr.csum_flags & CSUM_IP) != 0) { in re_encap()
2758 padlen = RL_MIN_FRAMELEN - (*m_head)->m_pkthdr.len; in re_encap()
2769 if ((*m_head)->m_next != NULL || in re_encap()
2784 bzero(mtod(m_new, char *) + m_new->m_pkthdr.len, padlen); in re_encap()
2785 m_new->m_pkthdr.len += padlen; in re_encap()
2786 m_new->m_len = m_new->m_pkthdr.len; in re_encap()
2790 prod = sc->rl_ldata.rl_tx_prodidx; in re_encap()
2791 txd = &sc->rl_ldata.rl_tx_desc[prod]; in re_encap()
2792 error = bus_dmamap_load_mbuf_sg(sc->rl_ldata.rl_tx_mtag, txd->tx_dmamap, in re_encap()
2802 error = bus_dmamap_load_mbuf_sg(sc->rl_ldata.rl_tx_mtag, in re_encap()
2803 txd->tx_dmamap, *m_head, segs, &nsegs, BUS_DMA_NOWAIT); in re_encap()
2818 if (sc->rl_ldata.rl_tx_free - nsegs <= 1) { in re_encap()
2819 bus_dmamap_unload(sc->rl_ldata.rl_tx_mtag, txd->tx_dmamap); in re_encap()
2823 bus_dmamap_sync(sc->rl_ldata.rl_tx_mtag, txd->tx_dmamap, in re_encap()
2828 * appear in all descriptors of a multi-descriptor transmit in re_encap()
2834 if (((*m_head)->m_pkthdr.csum_flags & CSUM_TSO) != 0) { in re_encap()
2835 if ((sc->rl_flags & RL_FLAG_DESCV2) != 0) { in re_encap()
2837 vlanctl |= ((uint32_t)(*m_head)->m_pkthdr.tso_segsz << in re_encap()
2841 ((uint32_t)(*m_head)->m_pkthdr.tso_segsz << in re_encap()
2850 if (((*m_head)->m_pkthdr.csum_flags & RE_CSUM_FEATURES) != 0) { in re_encap()
2851 if ((sc->rl_flags & RL_FLAG_DESCV2) == 0) { in re_encap()
2853 if (((*m_head)->m_pkthdr.csum_flags & in re_encap()
2856 if (((*m_head)->m_pkthdr.csum_flags & in re_encap()
2861 if (((*m_head)->m_pkthdr.csum_flags & in re_encap()
2864 if (((*m_head)->m_pkthdr.csum_flags & in re_encap()
2873 * appear in all descriptors of a multi-descriptor in re_encap()
2876 if ((*m_head)->m_flags & M_VLANTAG) in re_encap()
2877 vlanctl |= bswap16((*m_head)->m_pkthdr.ether_vtag) | in re_encap()
2882 desc = &sc->rl_ldata.rl_tx_list[prod]; in re_encap()
2883 desc->rl_vlanctl = htole32(vlanctl); in re_encap()
2884 desc->rl_bufaddr_lo = htole32(RL_ADDR_LO(segs[i].ds_addr)); in re_encap()
2885 desc->rl_bufaddr_hi = htole32(RL_ADDR_HI(segs[i].ds_addr)); in re_encap()
2889 if (prod == sc->rl_ldata.rl_tx_desc_cnt - 1) in re_encap()
2891 desc->rl_cmdstat = htole32(cmdstat | csum_flags); in re_encap()
2892 sc->rl_ldata.rl_tx_free--; in re_encap()
2895 sc->rl_ldata.rl_tx_prodidx = prod; in re_encap()
2899 desc = &sc->rl_ldata.rl_tx_list[ei]; in re_encap()
2900 desc->rl_cmdstat |= htole32(RL_TDESC_CMD_EOF); in re_encap()
2902 desc = &sc->rl_ldata.rl_tx_list[si]; in re_encap()
2904 desc->rl_cmdstat |= htole32(RL_TDESC_CMD_OWN | RL_TDESC_CMD_SOF); in re_encap()
2911 txd_last = &sc->rl_ldata.rl_tx_desc[ei]; in re_encap()
2912 map = txd->tx_dmamap; in re_encap()
2913 txd->tx_dmamap = txd_last->tx_dmamap; in re_encap()
2914 txd_last->tx_dmamap = map; in re_encap()
2915 txd_last->tx_m = *m_head; in re_encap()
2946 struct netmap_kring *kring = NA(ifp)->tx_rings[0]; in re_start_locked()
2947 if (sc->rl_ldata.rl_tx_prodidx != kring->nr_hwcur) { in re_start_locked()
2949 CSR_WRITE_1(sc, sc->rl_txstart, RL_TXSTART_START); in re_start_locked()
2953 sc->rl_watchdog_timer = 5; in re_start_locked()
2960 IFF_DRV_RUNNING || (sc->rl_flags & RL_FLAG_LINK) == 0) in re_start_locked()
2964 sc->rl_ldata.rl_tx_free > 1;) { in re_start_locked()
2988 if (sc->rl_ldata.rl_tx_free != sc->rl_ldata.rl_tx_desc_cnt) in re_start_locked()
3002 bus_dmamap_sync(sc->rl_ldata.rl_tx_list_tag, in re_start_tx()
3003 sc->rl_ldata.rl_tx_list_map, in re_start_tx()
3006 CSR_WRITE_1(sc, sc->rl_txstart, RL_TXSTART_START); in re_start_tx()
3023 sc->rl_watchdog_timer = 5; in re_start_tx()
3030 if (sc->rl_hwrev->rl_rev == RL_HWREV_8168E_VL) { in re_set_jumbo()
3031 pci_set_max_read_req(sc->rl_dev, 4096); in re_set_jumbo()
3037 CSR_WRITE_1(sc, sc->rl_cfg3, CSR_READ_1(sc, sc->rl_cfg3) | in re_set_jumbo()
3039 switch (sc->rl_hwrev->rl_rev) { in re_set_jumbo()
3043 CSR_WRITE_1(sc, sc->rl_cfg4, in re_set_jumbo()
3044 CSR_READ_1(sc, sc->rl_cfg4) | 0x01); in re_set_jumbo()
3047 CSR_WRITE_1(sc, sc->rl_cfg4, in re_set_jumbo()
3048 CSR_READ_1(sc, sc->rl_cfg4) | RL_CFG4_JUMBO_EN1); in re_set_jumbo()
3051 CSR_WRITE_1(sc, sc->rl_cfg3, CSR_READ_1(sc, sc->rl_cfg3) & in re_set_jumbo()
3053 switch (sc->rl_hwrev->rl_rev) { in re_set_jumbo()
3057 CSR_WRITE_1(sc, sc->rl_cfg4, in re_set_jumbo()
3058 CSR_READ_1(sc, sc->rl_cfg4) & ~0x01); in re_set_jumbo()
3061 CSR_WRITE_1(sc, sc->rl_cfg4, in re_set_jumbo()
3062 CSR_READ_1(sc, sc->rl_cfg4) & ~RL_CFG4_JUMBO_EN1); in re_set_jumbo()
3067 switch (sc->rl_hwrev->rl_rev) { in re_set_jumbo()
3069 pci_set_max_read_req(sc->rl_dev, 4096); in re_set_jumbo()
3073 pci_set_max_read_req(sc->rl_dev, 512); in re_set_jumbo()
3075 pci_set_max_read_req(sc->rl_dev, 4096); in re_set_jumbo()
3092 if_t ifp = sc->rl_ifp; in re_init_locked()
3100 mii = device_get_softc(sc->rl_miibus); in re_init_locked()
3116 if ((sc->rl_flags & RL_FLAG_JUMBOV2) != 0) { in re_init_locked()
3119 device_printf(sc->rl_dev, in re_init_locked()
3129 device_printf(sc->rl_dev, in re_init_locked()
3138 device_printf(sc->rl_dev, "no memory for RX buffers\n"); in re_init_locked()
3142 if ((sc->rl_flags & RL_FLAG_PCIE) != 0 && in re_init_locked()
3143 pci_get_device(sc->rl_dev) != RT_DEVICEID_8101E) { in re_init_locked()
3145 pci_set_max_read_req(sc->rl_dev, 512); in re_init_locked()
3147 pci_set_max_read_req(sc->rl_dev, 4096); in re_init_locked()
3162 if ((sc->rl_flags & RL_FLAG_MACSTAT) != 0) { in re_init_locked()
3169 if (sc->rl_hwrev->rl_rev == RL_HWREV_8169_8110SC || in re_init_locked()
3170 sc->rl_hwrev->rl_rev == RL_HWREV_8169_8110SCE) { in re_init_locked()
3172 if ((CSR_READ_1(sc, sc->rl_cfg2) & RL_CFG2_PCI66MHZ) != 0) in re_init_locked()
3174 if (sc->rl_hwrev->rl_rev == RL_HWREV_8169_8110SCE) in re_init_locked()
3207 RL_ADDR_HI(sc->rl_ldata.rl_rx_list_addr)); in re_init_locked()
3209 RL_ADDR_LO(sc->rl_ldata.rl_rx_list_addr)); in re_init_locked()
3212 RL_ADDR_HI(sc->rl_ldata.rl_tx_list_addr)); in re_init_locked()
3214 RL_ADDR_LO(sc->rl_ldata.rl_tx_list_addr)); in re_init_locked()
3216 if ((sc->rl_flags & RL_FLAG_8168G_PLUS) != 0) { in re_init_locked()
3223 * Enable transmit and receive for pre-RTL8168G controllers. in re_init_locked()
3226 if ((sc->rl_flags & RL_FLAG_8168G_PLUS) == 0) in re_init_locked()
3232 if (sc->rl_testmode) { in re_init_locked()
3233 if (sc->rl_type == RL_8169) in re_init_locked()
3250 if (sc->rl_type == RL_8169) { in re_init_locked()
3259 if ((sc->rl_flags & RL_FLAG_8168G_PLUS) != 0) in re_init_locked()
3274 if (sc->rl_testmode) in re_init_locked()
3281 sc->rl_txthresh = RL_TX_THRESH_INIT; in re_init_locked()
3297 if (sc->rl_type == RL_8169) in re_init_locked()
3306 if ((sc->rl_flags & (RL_FLAG_MSI | RL_FLAG_MSIX)) != 0 && in re_init_locked()
3308 if (sc->rl_type == RL_8169) in re_init_locked()
3310 RL_USECS(sc->rl_int_rx_mod)); in re_init_locked()
3312 if (sc->rl_type == RL_8169) in re_init_locked()
3321 if (sc->rl_type == RL_8169) { in re_init_locked()
3322 if ((sc->rl_flags & RL_FLAG_JUMBOV2) != 0) { in re_init_locked()
3330 sc->rl_hwrev->rl_max_mtu + in re_init_locked()
3336 } else if ((sc->rl_flags & RL_FLAG_PCIE) != 0 && in re_init_locked()
3337 sc->rl_hwrev->rl_max_mtu == RL_MTU) { in re_init_locked()
3344 if (sc->rl_testmode) in re_init_locked()
3347 CSR_WRITE_1(sc, sc->rl_cfg1, CSR_READ_1(sc, sc->rl_cfg1) | in re_init_locked()
3353 sc->rl_flags &= ~RL_FLAG_LINK; in re_init_locked()
3356 sc->rl_watchdog_timer = 0; in re_init_locked()
3357 callout_reset(&sc->rl_stat_callout, hz, re_tick, sc); in re_init_locked()
3375 mii = device_get_softc(sc->rl_miibus); in re_ifmedia_upd()
3393 mii = device_get_softc(sc->rl_miibus); in re_ifmedia_sts()
3397 ifmr->ifm_active = mii->mii_media_active; in re_ifmedia_sts()
3398 ifmr->ifm_status = mii->mii_media_status; in re_ifmedia_sts()
3412 if (ifr->ifr_mtu < ETHERMIN || in re_ioctl()
3413 ifr->ifr_mtu > sc->rl_hwrev->rl_max_mtu || in re_ioctl()
3414 ((sc->rl_flags & RL_FLAG_FASTETHER) != 0 && in re_ioctl()
3415 ifr->ifr_mtu > RL_MTU)) { in re_ioctl()
3420 if (if_getmtu(ifp) != ifr->ifr_mtu) { in re_ioctl()
3421 if_setmtu(ifp, ifr->ifr_mtu); in re_ioctl()
3422 if ((sc->rl_flags & RL_FLAG_JUMBOV2) != 0 && in re_ioctl()
3441 if (((if_getflags(ifp) ^ sc->rl_if_flags) in re_ioctl()
3450 sc->rl_if_flags = if_getflags(ifp); in re_ioctl()
3462 mii = device_get_softc(sc->rl_miibus); in re_ioctl()
3463 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); in re_ioctl()
3469 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in re_ioctl()
3473 if (ifr->ifr_reqcap & IFCAP_POLLING) { in re_ioctl()
3531 if ((sc->rl_flags & RL_FLAG_JUMBOV2) != 0 && in re_ioctl()
3568 if (sc->rl_watchdog_timer == 0 || --sc->rl_watchdog_timer != 0) in re_watchdog()
3571 ifp = sc->rl_ifp; in re_watchdog()
3573 if (sc->rl_ldata.rl_tx_free == sc->rl_ldata.rl_tx_desc_cnt) { in re_watchdog()
3575 "-- recovering\n"); in re_watchdog()
3607 ifp = sc->rl_ifp; in re_stop()
3609 sc->rl_watchdog_timer = 0; in re_stop()
3610 callout_stop(&sc->rl_stat_callout); in re_stop()
3620 * execution is in progress and controller can DMA the frame in re_stop()
3627 if ((sc->rl_flags & RL_FLAG_8168G_PLUS) != 0) { in re_stop()
3633 if ((sc->rl_flags & RL_FLAG_WAIT_TXPOLL) != 0) { in re_stop()
3634 for (i = RL_TIMEOUT; i > 0; i--) { in re_stop()
3635 if ((CSR_READ_1(sc, sc->rl_txstart) & in re_stop()
3641 device_printf(sc->rl_dev, in re_stop()
3642 "stopping TX poll timed out!\n"); in re_stop()
3644 } else if ((sc->rl_flags & RL_FLAG_CMDSTOP) != 0) { in re_stop()
3647 if ((sc->rl_flags & RL_FLAG_CMDSTOP_WAIT_TXQ) != 0) { in re_stop()
3648 for (i = RL_TIMEOUT; i > 0; i--) { in re_stop()
3655 device_printf(sc->rl_dev, in re_stop()
3664 if (sc->rl_head != NULL) { in re_stop()
3665 m_freem(sc->rl_head); in re_stop()
3666 sc->rl_head = sc->rl_tail = NULL; in re_stop()
3670 for (i = 0; i < sc->rl_ldata.rl_tx_desc_cnt; i++) { in re_stop()
3671 txd = &sc->rl_ldata.rl_tx_desc[i]; in re_stop()
3672 if (txd->tx_m != NULL) { in re_stop()
3673 bus_dmamap_sync(sc->rl_ldata.rl_tx_mtag, in re_stop()
3674 txd->tx_dmamap, BUS_DMASYNC_POSTWRITE); in re_stop()
3675 bus_dmamap_unload(sc->rl_ldata.rl_tx_mtag, in re_stop()
3676 txd->tx_dmamap); in re_stop()
3677 m_freem(txd->tx_m); in re_stop()
3678 txd->tx_m = NULL; in re_stop()
3683 for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) { in re_stop()
3684 rxd = &sc->rl_ldata.rl_rx_desc[i]; in re_stop()
3685 if (rxd->rx_m != NULL) { in re_stop()
3686 bus_dmamap_sync(sc->rl_ldata.rl_rx_mtag, in re_stop()
3687 rxd->rx_dmamap, BUS_DMASYNC_POSTREAD); in re_stop()
3688 bus_dmamap_unload(sc->rl_ldata.rl_rx_mtag, in re_stop()
3689 rxd->rx_dmamap); in re_stop()
3690 m_freem(rxd->rx_m); in re_stop()
3691 rxd->rx_m = NULL; in re_stop()
3695 if ((sc->rl_flags & RL_FLAG_JUMBOV2) != 0) { in re_stop()
3696 for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) { in re_stop()
3697 rxd = &sc->rl_ldata.rl_jrx_desc[i]; in re_stop()
3698 if (rxd->rx_m != NULL) { in re_stop()
3699 bus_dmamap_sync(sc->rl_ldata.rl_jrx_mtag, in re_stop()
3700 rxd->rx_dmamap, BUS_DMASYNC_POSTREAD); in re_stop()
3701 bus_dmamap_unload(sc->rl_ldata.rl_jrx_mtag, in re_stop()
3702 rxd->rx_dmamap); in re_stop()
3703 m_freem(rxd->rx_m); in re_stop()
3704 rxd->rx_m = NULL; in re_stop()
3725 sc->suspended = 1; in re_suspend()
3733 * doesn't, re-enable busmastering, and restart the interface if
3746 ifp = sc->rl_ifp; in re_resume()
3748 if ((sc->rl_flags & RL_FLAG_MACSLEEP) != 0) { in re_resume()
3764 sc->suspended = 0; in re_resume()
3788 if_setflagbits(sc->rl_ifp, 0, IFF_UP); in re_shutdown()
3804 mii = device_get_softc(sc->rl_miibus); in re_set_linkspeed()
3807 if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == in re_set_linkspeed()
3809 switch IFM_SUBTYPE(mii->mii_media_active) { in re_set_linkspeed()
3820 miisc = LIST_FIRST(&mii->mii_phys); in re_set_linkspeed()
3821 phyno = miisc->mii_phy; in re_set_linkspeed()
3822 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) in re_set_linkspeed()
3824 re_miibus_writereg(sc->rl_dev, phyno, MII_100T2CR, 0); in re_set_linkspeed()
3825 re_miibus_writereg(sc->rl_dev, phyno, in re_set_linkspeed()
3827 re_miibus_writereg(sc->rl_dev, phyno, in re_set_linkspeed()
3832 * Poll link state until re(4) get a 10/100Mbps link. in re_set_linkspeed()
3836 if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) in re_set_linkspeed()
3838 switch (IFM_SUBTYPE(mii->mii_media_active)) { in re_set_linkspeed()
3851 device_printf(sc->rl_dev, in re_set_linkspeed()
3855 * No link, force MAC to have 100Mbps, full-duplex link. in re_set_linkspeed()
3859 mii->mii_media_status = IFM_AVALID | IFM_ACTIVE; in re_set_linkspeed()
3860 mii->mii_media_active = IFM_ETHER | IFM_100_TX | IFM_FDX; in re_set_linkspeed()
3871 if (!pci_has_pm(sc->rl_dev)) in re_setwol()
3874 ifp = sc->rl_ifp; in re_setwol()
3876 if ((sc->rl_flags & RL_FLAG_MACSLEEP) != 0) { in re_setwol()
3882 if ((sc->rl_flags & RL_FLAG_8168G_PLUS) != 0) { in re_setwol()
3888 if ((sc->rl_flags & RL_FLAG_WOL_MANLINK) != 0) in re_setwol()
3890 if ((sc->rl_flags & RL_FLAG_WOLRXENB) != 0) in re_setwol()
3897 v = CSR_READ_1(sc, sc->rl_cfg1); in re_setwol()
3901 CSR_WRITE_1(sc, sc->rl_cfg1, v); in re_setwol()
3903 v = CSR_READ_1(sc, sc->rl_cfg3); in re_setwol()
3907 CSR_WRITE_1(sc, sc->rl_cfg3, v); in re_setwol()
3909 v = CSR_READ_1(sc, sc->rl_cfg5); in re_setwol()
3918 CSR_WRITE_1(sc, sc->rl_cfg5, v); in re_setwol()
3924 (sc->rl_flags & RL_FLAG_PHYWAKE_PM) != 0) in re_setwol()
3934 pci_enable_pme(sc->rl_dev); in re_setwol()
3944 if (!pci_has_pm(sc->rl_dev)) in re_clrwol()
3950 v = CSR_READ_1(sc, sc->rl_cfg3); in re_clrwol()
3952 CSR_WRITE_1(sc, sc->rl_cfg3, v); in re_clrwol()
3957 v = CSR_READ_1(sc, sc->rl_cfg5); in re_clrwol()
3960 CSR_WRITE_1(sc, sc->rl_cfg5, v); in re_clrwol()
3970 ctx = device_get_sysctl_ctx(sc->rl_dev); in re_add_sysctls()
3971 children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->rl_dev)); in re_add_sysctls()
3976 if ((sc->rl_flags & (RL_FLAG_MSI | RL_FLAG_MSIX)) == 0) in re_add_sysctls()
3981 &sc->rl_int_rx_mod, 0, sysctl_hw_re_int_mod, "I", in re_add_sysctls()
3984 sc->rl_int_rx_mod = RL_TIMER_DEFAULT; in re_add_sysctls()
3985 error = resource_int_value(device_get_name(sc->rl_dev), in re_add_sysctls()
3986 device_get_unit(sc->rl_dev), "int_rx_mod", &sc->rl_int_rx_mod); in re_add_sysctls()
3988 if (sc->rl_int_rx_mod < RL_TIMER_MIN || in re_add_sysctls()
3989 sc->rl_int_rx_mod > RL_TIMER_MAX) { in re_add_sysctls()
3990 device_printf(sc->rl_dev, "int_rx_mod value out of " in re_add_sysctls()
3993 sc->rl_int_rx_mod = RL_TIMER_DEFAULT; in re_add_sysctls()
4005 result = -1; in re_sysctl_stats()
4007 if (error || req->newptr == NULL) in re_sysctl_stats()
4013 if ((if_getdrvflags(sc->rl_ifp) & IFF_DRV_RUNNING) == 0) { in re_sysctl_stats()
4017 bus_dmamap_sync(sc->rl_ldata.rl_stag, in re_sysctl_stats()
4018 sc->rl_ldata.rl_smap, BUS_DMASYNC_PREREAD); in re_sysctl_stats()
4020 RL_ADDR_HI(sc->rl_ldata.rl_stats_addr)); in re_sysctl_stats()
4022 RL_ADDR_LO(sc->rl_ldata.rl_stats_addr)); in re_sysctl_stats()
4024 RL_ADDR_LO(sc->rl_ldata.rl_stats_addr | in re_sysctl_stats()
4026 for (i = RL_TIMEOUT; i > 0; i--) { in re_sysctl_stats()
4032 bus_dmamap_sync(sc->rl_ldata.rl_stag, in re_sysctl_stats()
4033 sc->rl_ldata.rl_smap, BUS_DMASYNC_POSTREAD); in re_sysctl_stats()
4036 device_printf(sc->rl_dev, in re_sysctl_stats()
4041 stats = sc->rl_ldata.rl_stats; in re_sysctl_stats()
4042 printf("%s statistics:\n", device_get_nameunit(sc->rl_dev)); in re_sysctl_stats()
4044 (uintmax_t)le64toh(stats->rl_tx_pkts)); in re_sysctl_stats()
4046 (uintmax_t)le64toh(stats->rl_rx_pkts)); in re_sysctl_stats()
4048 (uintmax_t)le64toh(stats->rl_tx_errs)); in re_sysctl_stats()
4050 le32toh(stats->rl_rx_errs)); in re_sysctl_stats()
4052 (uint32_t)le16toh(stats->rl_missed_pkts)); in re_sysctl_stats()
4054 (uint32_t)le16toh(stats->rl_rx_framealign_errs)); in re_sysctl_stats()
4056 le32toh(stats->rl_tx_onecoll)); in re_sysctl_stats()
4058 le32toh(stats->rl_tx_multicolls)); in re_sysctl_stats()
4060 (uintmax_t)le64toh(stats->rl_rx_ucasts)); in re_sysctl_stats()
4062 (uintmax_t)le64toh(stats->rl_rx_bcasts)); in re_sysctl_stats()
4064 le32toh(stats->rl_rx_mcasts)); in re_sysctl_stats()
4066 (uint32_t)le16toh(stats->rl_tx_aborts)); in re_sysctl_stats()
4068 (uint32_t)le16toh(stats->rl_rx_underruns)); in re_sysctl_stats()
4083 if (error || req->newptr == NULL) in sysctl_int_range()
4108 *nrxr = sc->rl_ldata.rl_rx_desc_cnt; in re_debugnet_init()
4111 (sc->rl_flags & RL_FLAG_JUMBOV2) != 0) ? MJUM9BYTES : MCLBYTES; in re_debugnet_init()
4128 IFF_DRV_RUNNING || (sc->rl_flags & RL_FLAG_LINK) == 0) in re_debugnet_transmit()
4145 (sc->rl_flags & RL_FLAG_LINK) == 0) in re_debugnet_poll()