Lines Matching +full:pme +full:- +full:active +full:- +full:high
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
195 { -1, 0, 0 }
200 { -1, 0, 0 }
205 { -1, 0, 0 }
221 if ((sc->jme_flags & JME_FLAG_FPGA) != 0 && phy == 0) in jme_miibus_readreg()
226 for (i = JME_PHY_TIMEOUT; i > 0; i--) { in jme_miibus_readreg()
233 device_printf(sc->jme_dev, "phy read timeout : %d\n", reg); in jme_miibus_readreg()
252 if ((sc->jme_flags & JME_FLAG_FPGA) != 0 && phy == 0) in jme_miibus_writereg()
258 for (i = JME_PHY_TIMEOUT; i > 0; i--) { in jme_miibus_writereg()
265 device_printf(sc->jme_dev, "phy write timeout : %d\n", reg); in jme_miibus_writereg()
279 taskqueue_enqueue(taskqueue_swi, &sc->jme_link_task); in jme_miibus_statchg()
297 mii = device_get_softc(sc->jme_miibus); in jme_mediastatus()
300 ifmr->ifm_status = mii->mii_media_status; in jme_mediastatus()
301 ifmr->ifm_active = mii->mii_media_active; in jme_mediastatus()
306 * Set hardware to newly-selected media.
318 mii = device_get_softc(sc->jme_miibus); in jme_mediachange()
319 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) in jme_mediachange()
338 if (vendor == sp->jme_vendorid && in jme_probe()
339 devid == sp->jme_deviceid) { in jme_probe()
340 device_set_desc(dev, sp->jme_name); in jme_probe()
355 for (i = JME_TIMEOUT; i > 0; i--) { in jme_eeprom_read_byte()
363 device_printf(sc->jme_dev, "EEPROM idle timeout!\n"); in jme_eeprom_read_byte()
369 for (i = JME_TIMEOUT; i > 0; i--) { in jme_eeprom_read_byte()
377 device_printf(sc->jme_dev, "EEPROM read timeout!\n"); in jme_eeprom_read_byte()
415 eaddr[reg - JME_PAR0] = val; in jme_eeprom_macaddr()
427 bcopy(eaddr, sc->jme_eaddr, ETHER_ADDR_LEN); in jme_eeprom_macaddr()
440 reg = pci_read_config(sc->jme_dev, JME_EFUSE_CTL1, 4); in jme_efuse_macaddr()
445 reg = pci_read_config(sc->jme_dev, JME_EFUSE_CTL2, 4); in jme_efuse_macaddr()
447 pci_write_config(sc->jme_dev, JME_EFUSE_CTL2, reg, 4); in jme_efuse_macaddr()
448 reg = pci_read_config(sc->jme_dev, JME_EFUSE_CTL2, 4); in jme_efuse_macaddr()
450 pci_write_config(sc->jme_dev, JME_EFUSE_CTL2, reg, 4); in jme_efuse_macaddr()
453 reg = pci_read_config(sc->jme_dev, JME_EFUSE_CTL1, 4); in jme_efuse_macaddr()
456 pci_write_config(sc->jme_dev, JME_EFUSE_CTL1, reg, 4); in jme_efuse_macaddr()
463 for (i = 10; i > 0; i--) { in jme_efuse_macaddr()
464 reg = pci_read_config(sc->jme_dev, JME_EFUSE_CTL1, 4); in jme_efuse_macaddr()
476 device_printf(sc->jme_dev, "eFuse autoload timed out.\n"); in jme_efuse_macaddr()
494 device_printf(sc->jme_dev, in jme_reg_macaddr()
504 sc->jme_eaddr[0] = (par0 >> 0) & 0xFF; in jme_reg_macaddr()
505 sc->jme_eaddr[1] = (par0 >> 8) & 0xFF; in jme_reg_macaddr()
506 sc->jme_eaddr[2] = (par0 >> 16) & 0xFF; in jme_reg_macaddr()
507 sc->jme_eaddr[3] = (par0 >> 24) & 0xFF; in jme_reg_macaddr()
508 sc->jme_eaddr[4] = (par1 >> 0) & 0xFF; in jme_reg_macaddr()
509 sc->jme_eaddr[5] = (par1 >> 8) & 0xFF; in jme_reg_macaddr()
519 if ((sc->jme_flags & JME_FLAG_EFUSE) != 0) { in jme_set_macaddr()
529 if (bcmp(eaddr, sc->jme_eaddr, ETHER_ADDR_LEN) != 0) { in jme_set_macaddr()
538 pci_write_config(sc->jme_dev, JME_EFUSE_EEPROM, in jme_set_macaddr()
632 sc->jme_dev = dev; in jme_attach()
634 mtx_init(&sc->jme_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, in jme_attach()
636 callout_init_mtx(&sc->jme_tick_ch, &sc->jme_mtx, 0); in jme_attach()
637 TASK_INIT(&sc->jme_int_task, 0, jme_int_task, sc); in jme_attach()
638 TASK_INIT(&sc->jme_link_task, 0, jme_link_task, sc); in jme_attach()
648 sc->jme_res_spec = jme_res_spec_mem; in jme_attach()
649 sc->jme_irq_spec = jme_irq_spec_legacy; in jme_attach()
650 error = bus_alloc_resources(dev, sc->jme_res_spec, sc->jme_res); in jme_attach()
664 /* Use 1 MSI/MSI-X. */ in jme_attach()
676 sc->jme_flags |= JME_FLAG_MSIX; in jme_attach()
677 sc->jme_irq_spec = jme_irq_spec_msi; in jme_attach()
681 if (msi_disable == 0 && (sc->jme_flags & JME_FLAG_MSIX) == 0 && in jme_attach()
686 sc->jme_flags |= JME_FLAG_MSI; in jme_attach()
687 sc->jme_irq_spec = jme_irq_spec_msi; in jme_attach()
692 if ((sc->jme_flags & JME_FLAG_MSI) != 0 || in jme_attach()
693 (sc->jme_flags & JME_FLAG_MSIX) != 0) in jme_attach()
697 error = bus_alloc_resources(dev, sc->jme_irq_spec, sc->jme_irq); in jme_attach()
703 sc->jme_rev = pci_get_device(dev); in jme_attach()
704 if ((sc->jme_rev & DEVICEID_JMC2XX_MASK) == DEVICEID_JMC260) { in jme_attach()
705 sc->jme_flags |= JME_FLAG_FASTETH; in jme_attach()
706 sc->jme_flags |= JME_FLAG_NOJUMBO; in jme_attach()
709 sc->jme_chip_rev = (reg & CHIPMODE_REV_MASK) >> CHIPMODE_REV_SHIFT; in jme_attach()
712 sc->jme_flags |= JME_FLAG_FPGA; in jme_attach()
715 sc->jme_rev); in jme_attach()
717 sc->jme_chip_rev); in jme_attach()
718 if ((sc->jme_flags & JME_FLAG_FPGA) != 0) in jme_attach()
723 if (sc->jme_chip_rev == 0xFF) { in jme_attach()
725 sc->jme_rev); in jme_attach()
731 if (CHIPMODE_REVFM(sc->jme_chip_rev) >= 2) { in jme_attach()
732 if ((sc->jme_rev & DEVICEID_JMC2XX_MASK) == DEVICEID_JMC260 && in jme_attach()
733 CHIPMODE_REVFM(sc->jme_chip_rev) == 2) in jme_attach()
734 sc->jme_flags |= JME_FLAG_DMA32BIT; in jme_attach()
735 if (CHIPMODE_REVFM(sc->jme_chip_rev) >= 5) in jme_attach()
736 sc->jme_flags |= JME_FLAG_EFUSE | JME_FLAG_PCCPCD; in jme_attach()
737 sc->jme_flags |= JME_FLAG_TXCLK | JME_FLAG_RXCLK; in jme_attach()
738 sc->jme_flags |= JME_FLAG_HWMIB; in jme_attach()
745 if ((sc->jme_flags & JME_FLAG_EFUSE) != 0) { in jme_attach()
755 device_printf(sc->jme_dev, in jme_attach()
766 if ((sc->jme_flags & JME_FLAG_FPGA) == 0) { in jme_attach()
767 sc->jme_phyaddr = CSR_READ_4(sc, JME_GPREG0) & in jme_attach()
771 sc->jme_phyaddr); in jme_attach()
773 sc->jme_phyaddr = 0; in jme_attach()
777 sc->jme_flags |= JME_FLAG_PCIE; in jme_attach()
787 sc->jme_tx_dma_size = TXCSR_DMA_SIZE_128; in jme_attach()
790 sc->jme_tx_dma_size = TXCSR_DMA_SIZE_256; in jme_attach()
793 sc->jme_tx_dma_size = TXCSR_DMA_SIZE_512; in jme_attach()
796 sc->jme_rx_dma_size = RXCSR_DMA_SIZE_128; in jme_attach()
798 sc->jme_tx_dma_size = TXCSR_DMA_SIZE_512; in jme_attach()
799 sc->jme_rx_dma_size = RXCSR_DMA_SIZE_128; in jme_attach()
806 ifp = sc->jme_ifp = if_alloc(IFT_ETHER); in jme_attach()
813 if_setsendqlen(ifp, JME_TX_RING_CNT - 1); in jme_attach()
819 sc->jme_flags |= JME_FLAG_PMCAP; in jme_attach()
828 if (CHIPMODE_REVFM(sc->jme_chip_rev) >= 5) in jme_attach()
831 error = mii_attach(dev, &sc->jme_miibus, ifp, jme_mediachange, in jme_attach()
833 sc->jme_flags & JME_FLAG_FPGA ? MII_PHY_ANY : sc->jme_phyaddr, in jme_attach()
843 if ((sc->jme_flags & JME_FLAG_FPGA) != 0) { in jme_attach()
844 mii = device_get_softc(sc->jme_miibus); in jme_attach()
845 if (mii->mii_instance != 0) { in jme_attach()
846 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) { in jme_attach()
847 if (miisc->mii_phy != 0) { in jme_attach()
848 sc->jme_phyaddr = miisc->mii_phy; in jme_attach()
852 if (sc->jme_phyaddr != 0) { in jme_attach()
853 device_printf(sc->jme_dev, in jme_attach()
854 "FPGA PHY is at %d\n", sc->jme_phyaddr); in jme_attach()
856 jme_miibus_writereg(dev, sc->jme_phyaddr, 27, in jme_attach()
862 ether_ifattach(ifp, sc->jme_eaddr); in jme_attach()
873 sc->jme_tq = taskqueue_create_fast("jme_taskq", M_WAITOK, in jme_attach()
874 taskqueue_thread_enqueue, &sc->jme_tq); in jme_attach()
875 taskqueue_start_threads(&sc->jme_tq, 1, PI_NET, "%s taskq", in jme_attach()
876 device_get_nameunit(sc->jme_dev)); in jme_attach()
879 error = bus_setup_intr(dev, sc->jme_irq[i], in jme_attach()
881 &sc->jme_intrhand[i]); in jme_attach()
888 taskqueue_free(sc->jme_tq); in jme_attach()
889 sc->jme_tq = NULL; in jme_attach()
910 ifp = sc->jme_ifp; in jme_detach()
913 sc->jme_flags |= JME_FLAG_DETACH; in jme_detach()
916 callout_drain(&sc->jme_tick_ch); in jme_detach()
917 taskqueue_drain(sc->jme_tq, &sc->jme_int_task); in jme_detach()
918 taskqueue_drain(taskqueue_swi, &sc->jme_link_task); in jme_detach()
920 if ((sc->jme_flags & JME_FLAG_EFUSE) != 0) in jme_detach()
921 jme_set_macaddr(sc, sc->jme_eaddr); in jme_detach()
925 if (sc->jme_tq != NULL) { in jme_detach()
926 taskqueue_drain(sc->jme_tq, &sc->jme_int_task); in jme_detach()
927 taskqueue_free(sc->jme_tq); in jme_detach()
928 sc->jme_tq = NULL; in jme_detach()
936 sc->jme_ifp = NULL; in jme_detach()
940 if (sc->jme_intrhand[i] != NULL) { in jme_detach()
941 bus_teardown_intr(dev, sc->jme_irq[i], in jme_detach()
942 sc->jme_intrhand[i]); in jme_detach()
943 sc->jme_intrhand[i] = NULL; in jme_detach()
947 if (sc->jme_irq[0] != NULL) in jme_detach()
948 bus_release_resources(dev, sc->jme_irq_spec, sc->jme_irq); in jme_detach()
949 if ((sc->jme_flags & (JME_FLAG_MSIX | JME_FLAG_MSI)) != 0) in jme_detach()
951 if (sc->jme_res[0] != NULL) in jme_detach()
952 bus_release_resources(dev, sc->jme_res_spec, sc->jme_res); in jme_detach()
953 mtx_destroy(&sc->jme_mtx); in jme_detach()
970 stats = &sc->jme_stats; in jme_sysctl_node()
971 ctx = device_get_sysctl_ctx(sc->jme_dev); in jme_sysctl_node()
972 child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->jme_dev)); in jme_sysctl_node()
975 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &sc->jme_tx_coal_to, in jme_sysctl_node()
979 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &sc->jme_tx_coal_pkt, in jme_sysctl_node()
983 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &sc->jme_rx_coal_to, in jme_sysctl_node()
987 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &sc->jme_rx_coal_pkt, in jme_sysctl_node()
992 &sc->jme_process_limit, 0, sysctl_hw_jme_proc_limit, "I", in jme_sysctl_node()
996 sc->jme_process_limit = JME_PROC_DEFAULT; in jme_sysctl_node()
997 error = resource_int_value(device_get_name(sc->jme_dev), in jme_sysctl_node()
998 device_get_unit(sc->jme_dev), "process_limit", in jme_sysctl_node()
999 &sc->jme_process_limit); in jme_sysctl_node()
1001 if (sc->jme_process_limit < JME_PROC_MIN || in jme_sysctl_node()
1002 sc->jme_process_limit > JME_PROC_MAX) { in jme_sysctl_node()
1003 device_printf(sc->jme_dev, in jme_sysctl_node()
1006 sc->jme_process_limit = JME_PROC_DEFAULT; in jme_sysctl_node()
1010 sc->jme_tx_coal_to = PCCTX_COAL_TO_DEFAULT; in jme_sysctl_node()
1011 error = resource_int_value(device_get_name(sc->jme_dev), in jme_sysctl_node()
1012 device_get_unit(sc->jme_dev), "tx_coal_to", &sc->jme_tx_coal_to); in jme_sysctl_node()
1014 if (sc->jme_tx_coal_to < PCCTX_COAL_TO_MIN || in jme_sysctl_node()
1015 sc->jme_tx_coal_to > PCCTX_COAL_TO_MAX) { in jme_sysctl_node()
1016 device_printf(sc->jme_dev, in jme_sysctl_node()
1019 sc->jme_tx_coal_to = PCCTX_COAL_TO_DEFAULT; in jme_sysctl_node()
1023 sc->jme_tx_coal_pkt = PCCTX_COAL_PKT_DEFAULT; in jme_sysctl_node()
1024 error = resource_int_value(device_get_name(sc->jme_dev), in jme_sysctl_node()
1025 device_get_unit(sc->jme_dev), "tx_coal_pkt", &sc->jme_tx_coal_to); in jme_sysctl_node()
1027 if (sc->jme_tx_coal_pkt < PCCTX_COAL_PKT_MIN || in jme_sysctl_node()
1028 sc->jme_tx_coal_pkt > PCCTX_COAL_PKT_MAX) { in jme_sysctl_node()
1029 device_printf(sc->jme_dev, in jme_sysctl_node()
1032 sc->jme_tx_coal_pkt = PCCTX_COAL_PKT_DEFAULT; in jme_sysctl_node()
1036 sc->jme_rx_coal_to = PCCRX_COAL_TO_DEFAULT; in jme_sysctl_node()
1037 error = resource_int_value(device_get_name(sc->jme_dev), in jme_sysctl_node()
1038 device_get_unit(sc->jme_dev), "rx_coal_to", &sc->jme_rx_coal_to); in jme_sysctl_node()
1040 if (sc->jme_rx_coal_to < PCCRX_COAL_TO_MIN || in jme_sysctl_node()
1041 sc->jme_rx_coal_to > PCCRX_COAL_TO_MAX) { in jme_sysctl_node()
1042 device_printf(sc->jme_dev, in jme_sysctl_node()
1045 sc->jme_rx_coal_to = PCCRX_COAL_TO_DEFAULT; in jme_sysctl_node()
1049 sc->jme_rx_coal_pkt = PCCRX_COAL_PKT_DEFAULT; in jme_sysctl_node()
1050 error = resource_int_value(device_get_name(sc->jme_dev), in jme_sysctl_node()
1051 device_get_unit(sc->jme_dev), "rx_coal_pkt", &sc->jme_rx_coal_to); in jme_sysctl_node()
1053 if (sc->jme_rx_coal_pkt < PCCRX_COAL_PKT_MIN || in jme_sysctl_node()
1054 sc->jme_rx_coal_pkt > PCCRX_COAL_PKT_MAX) { in jme_sysctl_node()
1055 device_printf(sc->jme_dev, in jme_sysctl_node()
1058 sc->jme_rx_coal_pkt = PCCRX_COAL_PKT_DEFAULT; in jme_sysctl_node()
1062 if ((sc->jme_flags & JME_FLAG_HWMIB) == 0) in jme_sysctl_node()
1074 &stats->rx_good_frames, "Good frames"); in jme_sysctl_node()
1076 &stats->rx_crc_errs, "CRC errors"); in jme_sysctl_node()
1078 &stats->rx_mii_errs, "MII errors"); in jme_sysctl_node()
1080 &stats->rx_fifo_oflows, "FIFO overflows"); in jme_sysctl_node()
1082 &stats->rx_desc_empty, "Descriptor empty"); in jme_sysctl_node()
1084 &stats->rx_bad_frames, "Bad frames"); in jme_sysctl_node()
1091 &stats->tx_good_frames, "Good frames"); in jme_sysctl_node()
1093 &stats->tx_bad_frames, "Bad frames"); in jme_sysctl_node()
1113 ctx->jme_busaddr = segs[0].ds_addr; in jme_dmamap_cb()
1126 if ((sc->jme_flags & JME_FLAG_DMA32BIT) != 0) in jme_dma_alloc()
1131 error = bus_dma_tag_create(bus_get_dma_tag(sc->jme_dev),/* parent */ in jme_dma_alloc()
1141 &sc->jme_cdata.jme_ring_tag); in jme_dma_alloc()
1143 device_printf(sc->jme_dev, in jme_dma_alloc()
1148 error = bus_dma_tag_create(sc->jme_cdata.jme_ring_tag,/* parent */ in jme_dma_alloc()
1158 &sc->jme_cdata.jme_tx_ring_tag); in jme_dma_alloc()
1160 device_printf(sc->jme_dev, in jme_dma_alloc()
1166 error = bus_dma_tag_create(sc->jme_cdata.jme_ring_tag,/* parent */ in jme_dma_alloc()
1176 &sc->jme_cdata.jme_rx_ring_tag); in jme_dma_alloc()
1178 device_printf(sc->jme_dev, in jme_dma_alloc()
1184 error = bus_dmamem_alloc(sc->jme_cdata.jme_tx_ring_tag, in jme_dma_alloc()
1185 (void **)&sc->jme_rdata.jme_tx_ring, in jme_dma_alloc()
1187 &sc->jme_cdata.jme_tx_ring_map); in jme_dma_alloc()
1189 device_printf(sc->jme_dev, in jme_dma_alloc()
1195 error = bus_dmamap_load(sc->jme_cdata.jme_tx_ring_tag, in jme_dma_alloc()
1196 sc->jme_cdata.jme_tx_ring_map, sc->jme_rdata.jme_tx_ring, in jme_dma_alloc()
1199 device_printf(sc->jme_dev, in jme_dma_alloc()
1203 sc->jme_rdata.jme_tx_ring_paddr = ctx.jme_busaddr; in jme_dma_alloc()
1206 error = bus_dmamem_alloc(sc->jme_cdata.jme_rx_ring_tag, in jme_dma_alloc()
1207 (void **)&sc->jme_rdata.jme_rx_ring, in jme_dma_alloc()
1209 &sc->jme_cdata.jme_rx_ring_map); in jme_dma_alloc()
1211 device_printf(sc->jme_dev, in jme_dma_alloc()
1217 error = bus_dmamap_load(sc->jme_cdata.jme_rx_ring_tag, in jme_dma_alloc()
1218 sc->jme_cdata.jme_rx_ring_map, sc->jme_rdata.jme_rx_ring, in jme_dma_alloc()
1221 device_printf(sc->jme_dev, in jme_dma_alloc()
1225 sc->jme_rdata.jme_rx_ring_paddr = ctx.jme_busaddr; in jme_dma_alloc()
1229 tx_ring_end = sc->jme_rdata.jme_tx_ring_paddr + in jme_dma_alloc()
1231 rx_ring_end = sc->jme_rdata.jme_rx_ring_paddr + in jme_dma_alloc()
1234 JME_ADDR_HI(sc->jme_rdata.jme_tx_ring_paddr)) || in jme_dma_alloc()
1236 JME_ADDR_HI(sc->jme_rdata.jme_rx_ring_paddr))) { in jme_dma_alloc()
1237 device_printf(sc->jme_dev, "4GB boundary crossed, " in jme_dma_alloc()
1247 if ((sc->jme_flags & JME_FLAG_DMA32BIT) != 0) in jme_dma_alloc()
1250 error = bus_dma_tag_create(bus_get_dma_tag(sc->jme_dev),/* parent */ in jme_dma_alloc()
1260 &sc->jme_cdata.jme_buffer_tag); in jme_dma_alloc()
1262 device_printf(sc->jme_dev, in jme_dma_alloc()
1268 error = bus_dma_tag_create(sc->jme_cdata.jme_buffer_tag,/* parent */ in jme_dma_alloc()
1278 &sc->jme_cdata.jme_ssb_tag); in jme_dma_alloc()
1280 device_printf(sc->jme_dev, in jme_dma_alloc()
1286 error = bus_dma_tag_create(sc->jme_cdata.jme_buffer_tag,/* parent */ in jme_dma_alloc()
1296 &sc->jme_cdata.jme_tx_tag); in jme_dma_alloc()
1298 device_printf(sc->jme_dev, "could not create Tx DMA tag.\n"); in jme_dma_alloc()
1303 error = bus_dma_tag_create(sc->jme_cdata.jme_buffer_tag,/* parent */ in jme_dma_alloc()
1313 &sc->jme_cdata.jme_rx_tag); in jme_dma_alloc()
1315 device_printf(sc->jme_dev, "could not create Rx DMA tag.\n"); in jme_dma_alloc()
1323 error = bus_dmamem_alloc(sc->jme_cdata.jme_ssb_tag, in jme_dma_alloc()
1324 (void **)&sc->jme_rdata.jme_ssb_block, in jme_dma_alloc()
1326 &sc->jme_cdata.jme_ssb_map); in jme_dma_alloc()
1328 device_printf(sc->jme_dev, "could not allocate DMA'able " in jme_dma_alloc()
1334 error = bus_dmamap_load(sc->jme_cdata.jme_ssb_tag, in jme_dma_alloc()
1335 sc->jme_cdata.jme_ssb_map, sc->jme_rdata.jme_ssb_block, in jme_dma_alloc()
1338 device_printf(sc->jme_dev, "could not load DMA'able memory " in jme_dma_alloc()
1342 sc->jme_rdata.jme_ssb_block_paddr = ctx.jme_busaddr; in jme_dma_alloc()
1346 txd = &sc->jme_cdata.jme_txdesc[i]; in jme_dma_alloc()
1347 txd->tx_m = NULL; in jme_dma_alloc()
1348 txd->tx_dmamap = NULL; in jme_dma_alloc()
1349 error = bus_dmamap_create(sc->jme_cdata.jme_tx_tag, 0, in jme_dma_alloc()
1350 &txd->tx_dmamap); in jme_dma_alloc()
1352 device_printf(sc->jme_dev, in jme_dma_alloc()
1358 if ((error = bus_dmamap_create(sc->jme_cdata.jme_rx_tag, 0, in jme_dma_alloc()
1359 &sc->jme_cdata.jme_rx_sparemap)) != 0) { in jme_dma_alloc()
1360 device_printf(sc->jme_dev, in jme_dma_alloc()
1365 rxd = &sc->jme_cdata.jme_rxdesc[i]; in jme_dma_alloc()
1366 rxd->rx_m = NULL; in jme_dma_alloc()
1367 rxd->rx_dmamap = NULL; in jme_dma_alloc()
1368 error = bus_dmamap_create(sc->jme_cdata.jme_rx_tag, 0, in jme_dma_alloc()
1369 &rxd->rx_dmamap); in jme_dma_alloc()
1371 device_printf(sc->jme_dev, in jme_dma_alloc()
1389 if (sc->jme_cdata.jme_tx_ring_tag != NULL) { in jme_dma_free()
1390 if (sc->jme_rdata.jme_tx_ring_paddr) in jme_dma_free()
1391 bus_dmamap_unload(sc->jme_cdata.jme_tx_ring_tag, in jme_dma_free()
1392 sc->jme_cdata.jme_tx_ring_map); in jme_dma_free()
1393 if (sc->jme_rdata.jme_tx_ring) in jme_dma_free()
1394 bus_dmamem_free(sc->jme_cdata.jme_tx_ring_tag, in jme_dma_free()
1395 sc->jme_rdata.jme_tx_ring, in jme_dma_free()
1396 sc->jme_cdata.jme_tx_ring_map); in jme_dma_free()
1397 sc->jme_rdata.jme_tx_ring = NULL; in jme_dma_free()
1398 sc->jme_rdata.jme_tx_ring_paddr = 0; in jme_dma_free()
1399 bus_dma_tag_destroy(sc->jme_cdata.jme_tx_ring_tag); in jme_dma_free()
1400 sc->jme_cdata.jme_tx_ring_tag = NULL; in jme_dma_free()
1403 if (sc->jme_cdata.jme_rx_ring_tag != NULL) { in jme_dma_free()
1404 if (sc->jme_rdata.jme_rx_ring_paddr) in jme_dma_free()
1405 bus_dmamap_unload(sc->jme_cdata.jme_rx_ring_tag, in jme_dma_free()
1406 sc->jme_cdata.jme_rx_ring_map); in jme_dma_free()
1407 if (sc->jme_rdata.jme_rx_ring) in jme_dma_free()
1408 bus_dmamem_free(sc->jme_cdata.jme_rx_ring_tag, in jme_dma_free()
1409 sc->jme_rdata.jme_rx_ring, in jme_dma_free()
1410 sc->jme_cdata.jme_rx_ring_map); in jme_dma_free()
1411 sc->jme_rdata.jme_rx_ring = NULL; in jme_dma_free()
1412 sc->jme_rdata.jme_rx_ring_paddr = 0; in jme_dma_free()
1413 bus_dma_tag_destroy(sc->jme_cdata.jme_rx_ring_tag); in jme_dma_free()
1414 sc->jme_cdata.jme_rx_ring_tag = NULL; in jme_dma_free()
1417 if (sc->jme_cdata.jme_tx_tag != NULL) { in jme_dma_free()
1419 txd = &sc->jme_cdata.jme_txdesc[i]; in jme_dma_free()
1420 if (txd->tx_dmamap != NULL) { in jme_dma_free()
1421 bus_dmamap_destroy(sc->jme_cdata.jme_tx_tag, in jme_dma_free()
1422 txd->tx_dmamap); in jme_dma_free()
1423 txd->tx_dmamap = NULL; in jme_dma_free()
1426 bus_dma_tag_destroy(sc->jme_cdata.jme_tx_tag); in jme_dma_free()
1427 sc->jme_cdata.jme_tx_tag = NULL; in jme_dma_free()
1430 if (sc->jme_cdata.jme_rx_tag != NULL) { in jme_dma_free()
1432 rxd = &sc->jme_cdata.jme_rxdesc[i]; in jme_dma_free()
1433 if (rxd->rx_dmamap != NULL) { in jme_dma_free()
1434 bus_dmamap_destroy(sc->jme_cdata.jme_rx_tag, in jme_dma_free()
1435 rxd->rx_dmamap); in jme_dma_free()
1436 rxd->rx_dmamap = NULL; in jme_dma_free()
1439 if (sc->jme_cdata.jme_rx_sparemap != NULL) { in jme_dma_free()
1440 bus_dmamap_destroy(sc->jme_cdata.jme_rx_tag, in jme_dma_free()
1441 sc->jme_cdata.jme_rx_sparemap); in jme_dma_free()
1442 sc->jme_cdata.jme_rx_sparemap = NULL; in jme_dma_free()
1444 bus_dma_tag_destroy(sc->jme_cdata.jme_rx_tag); in jme_dma_free()
1445 sc->jme_cdata.jme_rx_tag = NULL; in jme_dma_free()
1449 if (sc->jme_cdata.jme_ssb_tag != NULL) { in jme_dma_free()
1450 if (sc->jme_rdata.jme_ssb_block_paddr) in jme_dma_free()
1451 bus_dmamap_unload(sc->jme_cdata.jme_ssb_tag, in jme_dma_free()
1452 sc->jme_cdata.jme_ssb_map); in jme_dma_free()
1453 if (sc->jme_rdata.jme_ssb_block) in jme_dma_free()
1454 bus_dmamem_free(sc->jme_cdata.jme_ssb_tag, in jme_dma_free()
1455 sc->jme_rdata.jme_ssb_block, in jme_dma_free()
1456 sc->jme_cdata.jme_ssb_map); in jme_dma_free()
1457 sc->jme_rdata.jme_ssb_block = NULL; in jme_dma_free()
1458 sc->jme_rdata.jme_ssb_block_paddr = 0; in jme_dma_free()
1459 bus_dma_tag_destroy(sc->jme_cdata.jme_ssb_tag); in jme_dma_free()
1460 sc->jme_cdata.jme_ssb_tag = NULL; in jme_dma_free()
1463 if (sc->jme_cdata.jme_buffer_tag != NULL) { in jme_dma_free()
1464 bus_dma_tag_destroy(sc->jme_cdata.jme_buffer_tag); in jme_dma_free()
1465 sc->jme_cdata.jme_buffer_tag = NULL; in jme_dma_free()
1467 if (sc->jme_cdata.jme_ring_tag != NULL) { in jme_dma_free()
1468 bus_dma_tag_destroy(sc->jme_cdata.jme_ring_tag); in jme_dma_free()
1469 sc->jme_cdata.jme_ring_tag = NULL; in jme_dma_free()
1488 * auto-negotiation but we don't know whether that operation
1496 * Save current negotiated media speed/duplex/flow-control
1509 mii = device_get_softc(sc->jme_miibus); in jme_setlinkspeed()
1512 if ((mii->mii_media_status & IFM_AVALID) != 0) { in jme_setlinkspeed()
1513 switch IFM_SUBTYPE(mii->mii_media_active) { in jme_setlinkspeed()
1523 jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr, MII_100T2CR, 0); in jme_setlinkspeed()
1524 jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr, MII_ANAR, in jme_setlinkspeed()
1526 jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr, MII_BMCR, in jme_setlinkspeed()
1533 if ((mii->mii_media_status & IFM_AVALID) != 0) { in jme_setlinkspeed()
1534 switch (IFM_SUBTYPE(mii->mii_media_active)) { in jme_setlinkspeed()
1548 device_printf(sc->jme_dev, "establishing link failed, " in jme_setlinkspeed()
1552 * No link, force MAC to have 100Mbps, full-duplex link. in jme_setlinkspeed()
1555 mii->mii_media_status = IFM_AVALID | IFM_ACTIVE; in jme_setlinkspeed()
1556 mii->mii_media_active = IFM_ETHER | IFM_100_TX | IFM_FDX; in jme_setlinkspeed()
1570 if (pci_find_cap(sc->jme_dev, PCIY_PMG, &pmc) != 0) { in jme_setwol()
1572 if ((sc->jme_flags & JME_FLAG_TXCLK) != 0) in jme_setwol()
1576 if ((sc->jme_flags & JME_FLAG_RXCLK) != 0) in jme_setwol()
1579 /* No PME capability, PHY power down. */ in jme_setwol()
1584 ifp = sc->jme_ifp; in jme_setwol()
1590 /* Enable PME message. */ in jme_setwol()
1593 if ((sc->jme_flags & JME_FLAG_FASTETH) == 0) in jme_setwol()
1600 if ((sc->jme_flags & JME_FLAG_TXCLK) != 0) in jme_setwol()
1604 /* Request PME. */ in jme_setwol()
1605 pmstat = pci_read_config(sc->jme_dev, pmc + PCIR_POWER_STATUS, 2); in jme_setwol()
1609 pci_write_config(sc->jme_dev, pmc + PCIR_POWER_STATUS, pmstat, 2); in jme_setwol()
1642 if (pci_find_cap(sc->jme_dev, PCIY_PMG, &pmc) == 0) { in jme_resume()
1643 pmstat = pci_read_config(sc->jme_dev, in jme_resume()
1645 /* Disable PME clear PME status. */ in jme_resume()
1647 pci_write_config(sc->jme_dev, in jme_resume()
1652 ifp = sc->jme_ifp; in jme_resume()
1677 if (((*m_head)->m_pkthdr.csum_flags & CSUM_TSO) != 0) { in jme_encap()
1709 if (eh->ether_type == htons(ETHERTYPE_VLAN)) { in jme_encap()
1723 poff = ip_off + (ip->ip_hl << 2); in jme_encap()
1735 ip->ip_sum = 0; in jme_encap()
1736 if (poff + (tcp->th_off << 2) == m->m_pkthdr.len) { in jme_encap()
1737 tcp->th_sum = in_pseudo(ip->ip_src.s_addr, in jme_encap()
1738 ip->ip_dst.s_addr, in jme_encap()
1739 htons((tcp->th_off << 2) + IPPROTO_TCP)); in jme_encap()
1741 (*m_head)->m_pkthdr.csum_flags &= ~CSUM_TSO; in jme_encap()
1742 (*m_head)->m_pkthdr.csum_flags |= CSUM_IP; in jme_encap()
1744 tcp->th_sum = in_pseudo(ip->ip_src.s_addr, in jme_encap()
1745 ip->ip_dst.s_addr, htons(IPPROTO_TCP)); in jme_encap()
1749 prod = sc->jme_cdata.jme_tx_prod; in jme_encap()
1750 txd = &sc->jme_cdata.jme_txdesc[prod]; in jme_encap()
1752 error = bus_dmamap_load_mbuf_sg(sc->jme_cdata.jme_tx_tag, in jme_encap()
1753 txd->tx_dmamap, *m_head, txsegs, &nsegs, 0); in jme_encap()
1762 error = bus_dmamap_load_mbuf_sg(sc->jme_cdata.jme_tx_tag, in jme_encap()
1763 txd->tx_dmamap, *m_head, txsegs, &nsegs, 0); in jme_encap()
1782 if (sc->jme_cdata.jme_tx_cnt + nsegs + 1 > JME_TX_RING_CNT - 1) { in jme_encap()
1783 bus_dmamap_unload(sc->jme_cdata.jme_tx_tag, txd->tx_dmamap); in jme_encap()
1791 if ((m->m_pkthdr.csum_flags & CSUM_TSO) != 0) { in jme_encap()
1792 tsosegsz = (uint32_t)m->m_pkthdr.tso_segsz << in jme_encap()
1796 if ((m->m_pkthdr.csum_flags & CSUM_IP) != 0) in jme_encap()
1798 if ((m->m_pkthdr.csum_flags & CSUM_TCP) != 0) in jme_encap()
1800 if ((m->m_pkthdr.csum_flags & CSUM_UDP) != 0) in jme_encap()
1804 if ((m->m_flags & M_VLANTAG) != 0) { in jme_encap()
1805 cflags |= (m->m_pkthdr.ether_vtag & JME_TD_VLAN_MASK); in jme_encap()
1809 desc = &sc->jme_rdata.jme_tx_ring[prod]; in jme_encap()
1810 desc->flags = htole32(cflags); in jme_encap()
1811 desc->buflen = htole32(tsosegsz); in jme_encap()
1812 desc->addr_hi = htole32(m->m_pkthdr.len); in jme_encap()
1813 desc->addr_lo = 0; in jme_encap()
1814 sc->jme_cdata.jme_tx_cnt++; in jme_encap()
1817 desc = &sc->jme_rdata.jme_tx_ring[prod]; in jme_encap()
1818 desc->flags = htole32(JME_TD_OWN | JME_TD_64BIT); in jme_encap()
1819 desc->buflen = htole32(txsegs[i].ds_len); in jme_encap()
1820 desc->addr_hi = htole32(JME_ADDR_HI(txsegs[i].ds_addr)); in jme_encap()
1821 desc->addr_lo = htole32(JME_ADDR_LO(txsegs[i].ds_addr)); in jme_encap()
1822 sc->jme_cdata.jme_tx_cnt++; in jme_encap()
1827 sc->jme_cdata.jme_tx_prod = prod; in jme_encap()
1832 desc = txd->tx_desc; in jme_encap()
1833 desc->flags |= htole32(JME_TD_OWN | JME_TD_INTR); in jme_encap()
1835 txd->tx_m = m; in jme_encap()
1836 txd->tx_ndesc = nsegs + 1; in jme_encap()
1839 bus_dmamap_sync(sc->jme_cdata.jme_tx_tag, txd->tx_dmamap, in jme_encap()
1841 bus_dmamap_sync(sc->jme_cdata.jme_tx_ring_tag, in jme_encap()
1842 sc->jme_cdata.jme_tx_ring_map, in jme_encap()
1870 if (sc->jme_cdata.jme_tx_cnt >= JME_TX_DESC_HIWAT) in jme_start_locked()
1874 IFF_DRV_RUNNING || (sc->jme_flags & JME_FLAG_LINK) == 0) in jme_start_locked()
1909 CSR_WRITE_4(sc, JME_TXCSR, sc->jme_txcsr | TXCSR_TX_ENB | in jme_start_locked()
1912 sc->jme_watchdog_timer = JME_TX_TIMEOUT; in jme_start_locked()
1923 if (sc->jme_watchdog_timer == 0 || --sc->jme_watchdog_timer) in jme_watchdog()
1926 ifp = sc->jme_ifp; in jme_watchdog()
1927 if ((sc->jme_flags & JME_FLAG_LINK) == 0) { in jme_watchdog()
1928 if_printf(sc->jme_ifp, "watchdog timeout (missed link)\n"); in jme_watchdog()
1935 if (sc->jme_cdata.jme_tx_cnt == 0) { in jme_watchdog()
1936 if_printf(sc->jme_ifp, in jme_watchdog()
1937 "watchdog timeout (missed Tx interrupts) -- recovering\n"); in jme_watchdog()
1943 if_printf(sc->jme_ifp, "watchdog timeout\n"); in jme_watchdog()
1965 if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > JME_JUMBO_MTU || in jme_ioctl()
1966 ((sc->jme_flags & JME_FLAG_NOJUMBO) != 0 && in jme_ioctl()
1967 ifr->ifr_mtu > JME_MAX_MTU)) { in jme_ioctl()
1972 if (if_getmtu(ifp) != ifr->ifr_mtu) { in jme_ioctl()
1980 if (ifr->ifr_mtu >= JME_TX_FIFO_SIZE) { in jme_ioctl()
1987 if_setmtu(ifp, ifr->ifr_mtu); in jme_ioctl()
1999 if (((if_getflags(ifp) ^ sc->jme_if_flags) in jme_ioctl()
2003 if ((sc->jme_flags & JME_FLAG_DETACH) == 0) in jme_ioctl()
2010 sc->jme_if_flags = if_getflags(ifp); in jme_ioctl()
2022 mii = device_get_softc(sc->jme_miibus); in jme_ioctl()
2023 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, cmd); in jme_ioctl()
2027 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in jme_ioctl()
2091 mii = device_get_softc(sc->jme_miibus); in jme_mac_config()
2104 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) { in jme_mac_config()
2110 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_TXPAUSE) != 0) in jme_mac_config()
2112 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_RXPAUSE) != 0) in jme_mac_config()
2125 switch (IFM_SUBTYPE(mii->mii_media_active)) { in jme_mac_config()
2135 if ((sc->jme_flags & JME_FLAG_FASTETH) != 0) in jme_mac_config()
2139 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) == 0) in jme_mac_config()
2145 if (sc->jme_rev == DEVICEID_JMC250 && in jme_mac_config()
2146 sc->jme_chip_rev == DEVICEREVID_JMC250_A2) { in jme_mac_config()
2149 * when it runs on half-duplex media. in jme_mac_config()
2152 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) in jme_mac_config()
2158 if (IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX) { in jme_mac_config()
2160 jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr, in jme_mac_config()
2164 jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr, in jme_mac_config()
2168 if ((sc->jme_flags & JME_FLAG_TXCLK) != 0) in jme_mac_config()
2189 mii = device_get_softc(sc->jme_miibus); in jme_link_task()
2190 ifp = sc->jme_ifp; in jme_link_task()
2197 sc->jme_flags &= ~JME_FLAG_LINK; in jme_link_task()
2198 if ((mii->mii_media_status & IFM_AVALID) != 0) { in jme_link_task()
2199 switch (IFM_SUBTYPE(mii->mii_media_active)) { in jme_link_task()
2202 sc->jme_flags |= JME_FLAG_LINK; in jme_link_task()
2205 if ((sc->jme_flags & JME_FLAG_FASTETH) != 0) in jme_link_task()
2207 sc->jme_flags |= JME_FLAG_LINK; in jme_link_task()
2215 * Disabling Rx/Tx MACs have a side-effect of resetting in jme_link_task()
2228 taskqueue_block(sc->jme_tq); in jme_link_task()
2232 callout_stop(&sc->jme_tick_ch); in jme_link_task()
2233 sc->jme_watchdog_timer = 0; in jme_link_task()
2241 taskqueue_drain(sc->jme_tq, &sc->jme_int_task); in jme_link_task()
2244 if (sc->jme_cdata.jme_rxhead != NULL) in jme_link_task()
2245 m_freem(sc->jme_cdata.jme_rxhead); in jme_link_task()
2248 if (sc->jme_cdata.jme_tx_cnt != 0) { in jme_link_task()
2251 txd = &sc->jme_cdata.jme_txdesc[i]; in jme_link_task()
2252 if (txd->tx_m != NULL) { in jme_link_task()
2254 sc->jme_cdata.jme_tx_tag, in jme_link_task()
2255 txd->tx_dmamap, in jme_link_task()
2258 sc->jme_cdata.jme_tx_tag, in jme_link_task()
2259 txd->tx_dmamap); in jme_link_task()
2260 m_freem(txd->tx_m); in jme_link_task()
2261 txd->tx_m = NULL; in jme_link_task()
2262 txd->tx_ndesc = 0; in jme_link_task()
2272 sc->jme_cdata.jme_rx_cons = 0; in jme_link_task()
2273 sc->jme_morework = 0; in jme_link_task()
2278 /* Program MAC with resolved speed/duplex/flow-control. */ in jme_link_task()
2279 if ((sc->jme_flags & JME_FLAG_LINK) != 0) { in jme_link_task()
2283 CSR_WRITE_4(sc, JME_RXCSR, sc->jme_rxcsr); in jme_link_task()
2284 CSR_WRITE_4(sc, JME_TXCSR, sc->jme_txcsr); in jme_link_task()
2297 CSR_WRITE_4(sc, JME_RXCSR, sc->jme_rxcsr | RXCSR_RX_ENB | in jme_link_task()
2299 CSR_WRITE_4(sc, JME_TXCSR, sc->jme_txcsr | TXCSR_TX_ENB); in jme_link_task()
2301 if ((sc->jme_flags & JME_FLAG_TXCLK) != 0) in jme_link_task()
2304 if ((sc->jme_flags & JME_FLAG_RXCLK) != 0) in jme_link_task()
2311 callout_reset(&sc->jme_tick_ch, hz, jme_tick, sc); in jme_link_task()
2313 taskqueue_unblock(sc->jme_tq); in jme_link_task()
2333 taskqueue_enqueue(sc->jme_tq, &sc->jme_int_task); in jme_intr()
2347 ifp = sc->jme_ifp; in jme_int_task()
2351 if (sc->jme_morework != 0) { in jme_int_task()
2352 sc->jme_morework = 0; in jme_int_task()
2367 more = jme_rxintr(sc, sc->jme_process_limit); in jme_int_task()
2369 sc->jme_morework = 1; in jme_int_task()
2381 CSR_WRITE_4(sc, JME_RXCSR, sc->jme_rxcsr | in jme_int_task()
2389 taskqueue_enqueue(sc->jme_tq, &sc->jme_int_task); in jme_int_task()
2410 ifp = sc->jme_ifp; in jme_txeof()
2412 cons = sc->jme_cdata.jme_tx_cons; in jme_txeof()
2413 if (cons == sc->jme_cdata.jme_tx_prod) in jme_txeof()
2416 bus_dmamap_sync(sc->jme_cdata.jme_tx_ring_tag, in jme_txeof()
2417 sc->jme_cdata.jme_tx_ring_map, in jme_txeof()
2424 for (; cons != sc->jme_cdata.jme_tx_prod;) { in jme_txeof()
2425 txd = &sc->jme_cdata.jme_txdesc[cons]; in jme_txeof()
2426 status = le32toh(txd->tx_desc->flags); in jme_txeof()
2436 le32toh(txd->tx_desc->buflen) & in jme_txeof()
2440 * Only the first descriptor of multi-descriptor in jme_txeof()
2444 * descriptor of a multi-descriptor transmission. in jme_txeof()
2446 for (nsegs = 0; nsegs < txd->tx_ndesc; nsegs++) { in jme_txeof()
2447 sc->jme_rdata.jme_tx_ring[cons].flags = 0; in jme_txeof()
2452 bus_dmamap_sync(sc->jme_cdata.jme_tx_tag, txd->tx_dmamap, in jme_txeof()
2454 bus_dmamap_unload(sc->jme_cdata.jme_tx_tag, txd->tx_dmamap); in jme_txeof()
2456 KASSERT(txd->tx_m != NULL, in jme_txeof()
2458 m_freem(txd->tx_m); in jme_txeof()
2459 txd->tx_m = NULL; in jme_txeof()
2460 sc->jme_cdata.jme_tx_cnt -= txd->tx_ndesc; in jme_txeof()
2461 KASSERT(sc->jme_cdata.jme_tx_cnt >= 0, in jme_txeof()
2462 ("%s: Active Tx desc counter was garbled\n", __func__)); in jme_txeof()
2463 txd->tx_ndesc = 0; in jme_txeof()
2466 sc->jme_cdata.jme_tx_cons = cons; in jme_txeof()
2468 if (sc->jme_cdata.jme_tx_cnt == 0) in jme_txeof()
2469 sc->jme_watchdog_timer = 0; in jme_txeof()
2471 bus_dmamap_sync(sc->jme_cdata.jme_tx_ring_tag, in jme_txeof()
2472 sc->jme_cdata.jme_tx_ring_map, in jme_txeof()
2481 desc = &sc->jme_rdata.jme_rx_ring[cons]; in jme_discard_rxbuf()
2482 desc->flags = htole32(JME_RD_OWN | JME_RD_INTR | JME_RD_64BIT); in jme_discard_rxbuf()
2483 desc->buflen = htole32(MCLBYTES); in jme_discard_rxbuf()
2499 ifp = sc->jme_ifp; in jme_rxeof()
2501 cons = sc->jme_cdata.jme_rx_cons; in jme_rxeof()
2502 desc = &sc->jme_rdata.jme_rx_ring[cons]; in jme_rxeof()
2503 flags = le32toh(desc->flags); in jme_rxeof()
2504 status = le32toh(desc->buflen); in jme_rxeof()
2506 sc->jme_cdata.jme_rxlen = JME_RX_BYTES(status) - JME_RX_PAD_BYTES; in jme_rxeof()
2509 jme_discard_rxbuf(sc, sc->jme_cdata.jme_rx_cons); in jme_rxeof()
2511 device_printf(sc->jme_dev, "%s : receive error = 0x%b\n", in jme_rxeof()
2514 sc->jme_cdata.jme_rx_cons += nsegs; in jme_rxeof()
2515 sc->jme_cdata.jme_rx_cons %= JME_RX_RING_CNT; in jme_rxeof()
2521 rxd = &sc->jme_cdata.jme_rxdesc[cons]; in jme_rxeof()
2522 mp = rxd->rx_m; in jme_rxeof()
2531 if (sc->jme_cdata.jme_rxhead != NULL) { in jme_rxeof()
2532 m_freem(sc->jme_cdata.jme_rxhead); in jme_rxeof()
2541 * multi-segmented frame. in jme_rxeof()
2543 mp->m_len = MCLBYTES; in jme_rxeof()
2546 if (sc->jme_cdata.jme_rxhead == NULL) { in jme_rxeof()
2547 sc->jme_cdata.jme_rxhead = mp; in jme_rxeof()
2548 sc->jme_cdata.jme_rxtail = mp; in jme_rxeof()
2554 mp->m_flags &= ~M_PKTHDR; in jme_rxeof()
2555 sc->jme_cdata.jme_rxtail->m_next = mp; in jme_rxeof()
2556 sc->jme_cdata.jme_rxtail = mp; in jme_rxeof()
2559 if (count == nsegs - 1) { in jme_rxeof()
2561 m = sc->jme_cdata.jme_rxhead; in jme_rxeof()
2562 m->m_flags |= M_PKTHDR; in jme_rxeof()
2563 m->m_pkthdr.len = sc->jme_cdata.jme_rxlen; in jme_rxeof()
2566 m->m_len = MCLBYTES - JME_RX_PAD_BYTES; in jme_rxeof()
2568 mp->m_len = sc->jme_cdata.jme_rxlen - in jme_rxeof()
2569 ((MCLBYTES - JME_RX_PAD_BYTES) + in jme_rxeof()
2570 (MCLBYTES * (nsegs - 2))); in jme_rxeof()
2572 m->m_len = sc->jme_cdata.jme_rxlen; in jme_rxeof()
2573 m->m_pkthdr.rcvif = ifp; in jme_rxeof()
2581 m->m_data += JME_RX_PAD_BYTES; in jme_rxeof()
2586 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; in jme_rxeof()
2588 m->m_pkthdr.csum_flags |= CSUM_IP_VALID; in jme_rxeof()
2594 m->m_pkthdr.csum_flags |= in jme_rxeof()
2596 m->m_pkthdr.csum_data = 0xffff; in jme_rxeof()
2603 m->m_pkthdr.ether_vtag = in jme_rxeof()
2605 m->m_flags |= M_VLANTAG; in jme_rxeof()
2619 sc->jme_cdata.jme_rx_cons += nsegs; in jme_rxeof()
2620 sc->jme_cdata.jme_rx_cons %= JME_RX_RING_CNT; in jme_rxeof()
2629 bus_dmamap_sync(sc->jme_cdata.jme_rx_ring_tag, in jme_rxintr()
2630 sc->jme_cdata.jme_rx_ring_map, in jme_rxintr()
2634 desc = &sc->jme_rdata.jme_rx_ring[sc->jme_cdata.jme_rx_cons]; in jme_rxintr()
2635 if ((le32toh(desc->flags) & JME_RD_OWN) == JME_RD_OWN) in jme_rxintr()
2637 if ((le32toh(desc->buflen) & JME_RD_VALID) == 0) in jme_rxintr()
2639 nsegs = JME_RX_NSEGS(le32toh(desc->buflen)); in jme_rxintr()
2642 * Non-matching value would indicate that hardware in jme_rxintr()
2646 pktlen = JME_RX_BYTES(le32toh(desc->buflen)); in jme_rxintr()
2652 count -= nsegs; in jme_rxintr()
2656 bus_dmamap_sync(sc->jme_cdata.jme_rx_ring_tag, in jme_rxintr()
2657 sc->jme_cdata.jme_rx_ring_map, in jme_rxintr()
2673 mii = device_get_softc(sc->jme_miibus); in jme_tick()
2683 callout_reset(&sc->jme_tick_ch, hz, jme_tick, sc); in jme_tick()
2704 if ((sc->jme_flags & (JME_FLAG_TXCLK | JME_FLAG_RXCLK)) != 0) { in jme_reset()
2711 /* De-assert RESET but still disable TX clock. */ in jme_reset()
2752 ifp = sc->jme_ifp; in jme_init_locked()
2753 mii = device_get_softc(sc->jme_miibus); in jme_init_locked()
2770 device_printf(sc->jme_dev, in jme_init_locked()
2781 jme_set_macaddr(sc, if_getlladdr(sc->jme_ifp)); in jme_init_locked()
2790 sc->jme_txcsr = TXCSR_TXQ_N_SEL(TXCSR_TXQ0); in jme_init_locked()
2791 sc->jme_txcsr |= TXCSR_TXQ_WEIGHT(TXCSR_TXQ_WEIGHT_MIN); in jme_init_locked()
2792 sc->jme_txcsr |= TXCSR_FIFO_THRESH_16QW; in jme_init_locked()
2793 sc->jme_txcsr |= sc->jme_tx_dma_size; in jme_init_locked()
2794 sc->jme_txcsr |= TXCSR_DMA_BURST; in jme_init_locked()
2795 CSR_WRITE_4(sc, JME_TXCSR, sc->jme_txcsr); in jme_init_locked()
2821 sc->jme_rxcsr = RXCSR_FIFO_FTHRESH_128T; in jme_init_locked()
2832 if (CHIPMODE_REVFM(sc->jme_chip_rev) >= 2) in jme_init_locked()
2833 sc->jme_rxcsr |= RXCSR_FIFO_THRESH_16QW; in jme_init_locked()
2837 sc->jme_rxcsr |= RXCSR_FIFO_THRESH_16QW; in jme_init_locked()
2839 sc->jme_rxcsr |= RXCSR_FIFO_THRESH_128QW; in jme_init_locked()
2841 sc->jme_rxcsr |= sc->jme_rx_dma_size | RXCSR_RXQ_N_SEL(RXCSR_RXQ0); in jme_init_locked()
2842 sc->jme_rxcsr |= RXCSR_DESC_RT_CNT(RXCSR_DESC_RT_CNT_DEFAULT); in jme_init_locked()
2843 sc->jme_rxcsr |= RXCSR_DESC_RT_GAP_256 & RXCSR_DESC_RT_GAP_MASK; in jme_init_locked()
2844 CSR_WRITE_4(sc, JME_RXCSR, sc->jme_rxcsr); in jme_init_locked()
2871 * help Rx performance on strict-alignment architectures as in jme_init_locked()
2882 /* Set PCC timer resolution to micro-seconds unit. */ in jme_init_locked()
2897 /* Clear PME message. */ in jme_init_locked()
2901 reg |= sc->jme_phyaddr; in jme_init_locked()
2905 reg = (sc->jme_tx_coal_to << PCCTX_COAL_TO_SHIFT) & in jme_init_locked()
2907 reg |= (sc->jme_tx_coal_pkt << PCCTX_COAL_PKT_SHIFT) & in jme_init_locked()
2913 reg = (sc->jme_rx_coal_to << PCCRX_COAL_TO_SHIFT) & in jme_init_locked()
2915 reg |= (sc->jme_rx_coal_pkt << PCCRX_COAL_PKT_SHIFT) & in jme_init_locked()
2922 * back-to-back incoming/outgoing packet is long enough for in jme_init_locked()
2928 if ((sc->jme_flags & JME_FLAG_PCCPCD) != 0) { in jme_init_locked()
2929 sc->jme_rx_pcd_to = sc->jme_rx_coal_to; in jme_init_locked()
2930 if (sc->jme_rx_coal_to > PCDRX_TO_MAX) in jme_init_locked()
2931 sc->jme_rx_pcd_to = PCDRX_TO_MAX; in jme_init_locked()
2932 sc->jme_tx_pcd_to = sc->jme_tx_coal_to; in jme_init_locked()
2933 if (sc->jme_tx_coal_to > PCDTX_TO_MAX) in jme_init_locked()
2934 sc->jme_tx_pcd_to = PCDTX_TO_MAX; in jme_init_locked()
2935 reg = sc->jme_rx_pcd_to << PCDRX0_TO_THROTTLE_SHIFT; in jme_init_locked()
2936 reg |= sc->jme_rx_pcd_to << PCDRX0_TO_SHIFT; in jme_init_locked()
2938 reg = sc->jme_tx_pcd_to << PCDTX_TO_THROTTLE_SHIFT; in jme_init_locked()
2939 reg |= sc->jme_tx_pcd_to << PCDTX_TO_SHIFT; in jme_init_locked()
2944 paddr = sc->jme_rdata.jme_ssb_block_paddr; in jme_init_locked()
2971 sc->jme_flags &= ~JME_FLAG_LINK; in jme_init_locked()
2975 callout_reset(&sc->jme_tick_ch, hz, jme_tick, sc); in jme_init_locked()
2993 ifp = sc->jme_ifp; in jme_stop()
2995 sc->jme_flags &= ~JME_FLAG_LINK; in jme_stop()
2996 callout_stop(&sc->jme_tick_ch); in jme_stop()
2997 sc->jme_watchdog_timer = 0; in jme_stop()
3015 if (sc->jme_cdata.jme_rxhead != NULL) in jme_stop()
3016 m_freem(sc->jme_cdata.jme_rxhead); in jme_stop()
3023 rxd = &sc->jme_cdata.jme_rxdesc[i]; in jme_stop()
3024 if (rxd->rx_m != NULL) { in jme_stop()
3025 bus_dmamap_sync(sc->jme_cdata.jme_rx_tag, in jme_stop()
3026 rxd->rx_dmamap, BUS_DMASYNC_POSTREAD); in jme_stop()
3027 bus_dmamap_unload(sc->jme_cdata.jme_rx_tag, in jme_stop()
3028 rxd->rx_dmamap); in jme_stop()
3029 m_freem(rxd->rx_m); in jme_stop()
3030 rxd->rx_m = NULL; in jme_stop()
3034 txd = &sc->jme_cdata.jme_txdesc[i]; in jme_stop()
3035 if (txd->tx_m != NULL) { in jme_stop()
3036 bus_dmamap_sync(sc->jme_cdata.jme_tx_tag, in jme_stop()
3037 txd->tx_dmamap, BUS_DMASYNC_POSTWRITE); in jme_stop()
3038 bus_dmamap_unload(sc->jme_cdata.jme_tx_tag, in jme_stop()
3039 txd->tx_dmamap); in jme_stop()
3040 m_freem(txd->tx_m); in jme_stop()
3041 txd->tx_m = NULL; in jme_stop()
3042 txd->tx_ndesc = 0; in jme_stop()
3060 for (i = JME_TIMEOUT; i > 0; i--) { in jme_stop_tx()
3066 device_printf(sc->jme_dev, "stopping transmitter timeout!\n"); in jme_stop_tx()
3080 for (i = JME_TIMEOUT; i > 0; i--) { in jme_stop_rx()
3086 device_printf(sc->jme_dev, "stopping recevier timeout!\n"); in jme_stop_rx()
3096 sc->jme_cdata.jme_tx_prod = 0; in jme_init_tx_ring()
3097 sc->jme_cdata.jme_tx_cons = 0; in jme_init_tx_ring()
3098 sc->jme_cdata.jme_tx_cnt = 0; in jme_init_tx_ring()
3100 rd = &sc->jme_rdata; in jme_init_tx_ring()
3101 bzero(rd->jme_tx_ring, JME_TX_RING_SIZE); in jme_init_tx_ring()
3103 txd = &sc->jme_cdata.jme_txdesc[i]; in jme_init_tx_ring()
3104 txd->tx_m = NULL; in jme_init_tx_ring()
3105 txd->tx_desc = &rd->jme_tx_ring[i]; in jme_init_tx_ring()
3106 txd->tx_ndesc = 0; in jme_init_tx_ring()
3109 bus_dmamap_sync(sc->jme_cdata.jme_tx_ring_tag, in jme_init_tx_ring()
3110 sc->jme_cdata.jme_tx_ring_map, in jme_init_tx_ring()
3119 rd = &sc->jme_rdata; in jme_init_ssb()
3120 bzero(rd->jme_ssb_block, JME_SSB_SIZE); in jme_init_ssb()
3121 bus_dmamap_sync(sc->jme_cdata.jme_ssb_tag, sc->jme_cdata.jme_ssb_map, in jme_init_ssb()
3132 sc->jme_cdata.jme_rx_cons = 0; in jme_init_rx_ring()
3134 sc->jme_morework = 0; in jme_init_rx_ring()
3136 rd = &sc->jme_rdata; in jme_init_rx_ring()
3137 bzero(rd->jme_rx_ring, JME_RX_RING_SIZE); in jme_init_rx_ring()
3139 rxd = &sc->jme_cdata.jme_rxdesc[i]; in jme_init_rx_ring()
3140 rxd->rx_m = NULL; in jme_init_rx_ring()
3141 rxd->rx_desc = &rd->jme_rx_ring[i]; in jme_init_rx_ring()
3146 bus_dmamap_sync(sc->jme_cdata.jme_rx_ring_tag, in jme_init_rx_ring()
3147 sc->jme_cdata.jme_rx_ring_map, in jme_init_rx_ring()
3171 m->m_len = m->m_pkthdr.len = MCLBYTES; in jme_newbuf()
3173 if (bus_dmamap_load_mbuf_sg(sc->jme_cdata.jme_rx_tag, in jme_newbuf()
3174 sc->jme_cdata.jme_rx_sparemap, m, segs, &nsegs, 0) != 0) { in jme_newbuf()
3180 if (rxd->rx_m != NULL) { in jme_newbuf()
3181 bus_dmamap_sync(sc->jme_cdata.jme_rx_tag, rxd->rx_dmamap, in jme_newbuf()
3183 bus_dmamap_unload(sc->jme_cdata.jme_rx_tag, rxd->rx_dmamap); in jme_newbuf()
3185 map = rxd->rx_dmamap; in jme_newbuf()
3186 rxd->rx_dmamap = sc->jme_cdata.jme_rx_sparemap; in jme_newbuf()
3187 sc->jme_cdata.jme_rx_sparemap = map; in jme_newbuf()
3188 bus_dmamap_sync(sc->jme_cdata.jme_rx_tag, rxd->rx_dmamap, in jme_newbuf()
3190 rxd->rx_m = m; in jme_newbuf()
3192 desc = rxd->rx_desc; in jme_newbuf()
3193 desc->buflen = htole32(segs[0].ds_len); in jme_newbuf()
3194 desc->addr_lo = htole32(JME_ADDR_LO(segs[0].ds_addr)); in jme_newbuf()
3195 desc->addr_hi = htole32(JME_ADDR_HI(segs[0].ds_addr)); in jme_newbuf()
3196 desc->flags = htole32(JME_RD_OWN | JME_RD_INTR | JME_RD_64BIT); in jme_newbuf()
3209 ifp = sc->jme_ifp; in jme_set_vlan()
3242 ifp = sc->jme_ifp; in jme_set_filter()
3264 * addresses through a CRC generator, and then using the low-order in jme_set_filter()
3266 * high order bits select the register, while the rest of the bits in jme_set_filter()
3284 if ((sc->jme_flags & JME_FLAG_HWMIB) == 0) in jme_stats_clear()
3292 bzero(&sc->jme_stats, sizeof(struct jme_hw_stats)); in jme_stats_clear()
3301 if ((sc->jme_flags & JME_FLAG_HWMIB) == 0) in jme_stats_save()
3304 bcopy(&sc->jme_stats, &sc->jme_ostats, sizeof(struct jme_hw_stats)); in jme_stats_save()
3317 if ((sc->jme_flags & JME_FLAG_HWMIB) == 0) in jme_stats_update()
3319 stat = &sc->jme_stats; in jme_stats_update()
3320 ostat = &sc->jme_ostats; in jme_stats_update()
3321 stat->tx_good_frames = CSR_READ_4(sc, JME_STAT_TXGOOD); in jme_stats_update()
3322 stat->rx_good_frames = CSR_READ_4(sc, JME_STAT_RXGOOD); in jme_stats_update()
3324 stat->rx_crc_errs = (reg & STAT_RX_CRC_ERR_MASK) >> in jme_stats_update()
3326 stat->rx_mii_errs = (reg & STAT_RX_MII_ERR_MASK) >> in jme_stats_update()
3329 stat->rx_fifo_oflows = (reg & STAT_RXERR_OFLOW_MASK) >> in jme_stats_update()
3331 stat->rx_desc_empty = (reg & STAT_RXERR_MPTY_MASK) >> in jme_stats_update()
3334 stat->rx_bad_frames = (reg & STAT_FAIL_RX_MASK) >> STAT_FAIL_RX_SHIFT; in jme_stats_update()
3335 stat->tx_bad_frames = (reg & STAT_FAIL_TX_MASK) >> STAT_FAIL_TX_SHIFT; in jme_stats_update()
3338 stat->rx_good_frames += ostat->rx_good_frames; in jme_stats_update()
3339 stat->rx_crc_errs += ostat->rx_crc_errs; in jme_stats_update()
3340 stat->rx_mii_errs += ostat->rx_mii_errs; in jme_stats_update()
3341 stat->rx_fifo_oflows += ostat->rx_fifo_oflows; in jme_stats_update()
3342 stat->rx_desc_empty += ostat->rx_desc_empty; in jme_stats_update()
3343 stat->rx_bad_frames += ostat->rx_bad_frames; in jme_stats_update()
3344 stat->tx_good_frames += ostat->tx_good_frames; in jme_stats_update()
3345 stat->tx_bad_frames += ostat->tx_bad_frames; in jme_stats_update()
3353 jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr, MII_BMCR, BMCR_PDOWN); in jme_phy_down()
3354 if (CHIPMODE_REVFM(sc->jme_chip_rev) >= 5) { in jme_phy_down()
3358 reg = pci_read_config(sc->jme_dev, JME_PCI_PE1, 4); in jme_phy_down()
3361 pci_write_config(sc->jme_dev, JME_PCI_PE1, reg, 4); in jme_phy_down()
3371 bmcr = jme_miibus_readreg(sc->jme_dev, sc->jme_phyaddr, MII_BMCR); in jme_phy_up()
3373 jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr, MII_BMCR, bmcr); in jme_phy_up()
3374 if (CHIPMODE_REVFM(sc->jme_chip_rev) >= 5) { in jme_phy_up()
3378 reg = pci_read_config(sc->jme_dev, JME_PCI_PE1, 4); in jme_phy_up()
3381 pci_write_config(sc->jme_dev, JME_PCI_PE1, reg, 4); in jme_phy_up()
3386 sysctl_int_range(SYSCTL_HANDLER_ARGS, int low, int high) in sysctl_int_range() argument
3394 if (error || req->newptr == NULL) in sysctl_int_range()
3396 if (value < low || value > high) in sysctl_int_range()