Lines Matching +full:micro +full:- +full:frames
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()
869 /* Tell the upper layer(s) we support long frames. */ 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()
931 if (sc->jme_miibus != NULL) { in jme_detach()
932 device_delete_child(dev, sc->jme_miibus); in jme_detach()
933 sc->jme_miibus = NULL; in jme_detach()
940 sc->jme_ifp = NULL; in jme_detach()
944 if (sc->jme_intrhand[i] != NULL) { in jme_detach()
945 bus_teardown_intr(dev, sc->jme_irq[i], in jme_detach()
946 sc->jme_intrhand[i]); in jme_detach()
947 sc->jme_intrhand[i] = NULL; in jme_detach()
951 if (sc->jme_irq[0] != NULL) in jme_detach()
952 bus_release_resources(dev, sc->jme_irq_spec, sc->jme_irq); in jme_detach()
953 if ((sc->jme_flags & (JME_FLAG_MSIX | JME_FLAG_MSI)) != 0) in jme_detach()
955 if (sc->jme_res[0] != NULL) in jme_detach()
956 bus_release_resources(dev, sc->jme_res_spec, sc->jme_res); in jme_detach()
957 mtx_destroy(&sc->jme_mtx); in jme_detach()
974 stats = &sc->jme_stats; in jme_sysctl_node()
975 ctx = device_get_sysctl_ctx(sc->jme_dev); in jme_sysctl_node()
976 child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->jme_dev)); in jme_sysctl_node()
979 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &sc->jme_tx_coal_to, in jme_sysctl_node()
983 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &sc->jme_tx_coal_pkt, in jme_sysctl_node()
987 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &sc->jme_rx_coal_to, in jme_sysctl_node()
991 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, &sc->jme_rx_coal_pkt, in jme_sysctl_node()
996 &sc->jme_process_limit, 0, sysctl_hw_jme_proc_limit, "I", in jme_sysctl_node()
1000 sc->jme_process_limit = JME_PROC_DEFAULT; in jme_sysctl_node()
1001 error = resource_int_value(device_get_name(sc->jme_dev), in jme_sysctl_node()
1002 device_get_unit(sc->jme_dev), "process_limit", in jme_sysctl_node()
1003 &sc->jme_process_limit); in jme_sysctl_node()
1005 if (sc->jme_process_limit < JME_PROC_MIN || in jme_sysctl_node()
1006 sc->jme_process_limit > JME_PROC_MAX) { in jme_sysctl_node()
1007 device_printf(sc->jme_dev, in jme_sysctl_node()
1010 sc->jme_process_limit = JME_PROC_DEFAULT; in jme_sysctl_node()
1014 sc->jme_tx_coal_to = PCCTX_COAL_TO_DEFAULT; in jme_sysctl_node()
1015 error = resource_int_value(device_get_name(sc->jme_dev), in jme_sysctl_node()
1016 device_get_unit(sc->jme_dev), "tx_coal_to", &sc->jme_tx_coal_to); in jme_sysctl_node()
1018 if (sc->jme_tx_coal_to < PCCTX_COAL_TO_MIN || in jme_sysctl_node()
1019 sc->jme_tx_coal_to > PCCTX_COAL_TO_MAX) { in jme_sysctl_node()
1020 device_printf(sc->jme_dev, in jme_sysctl_node()
1023 sc->jme_tx_coal_to = PCCTX_COAL_TO_DEFAULT; in jme_sysctl_node()
1027 sc->jme_tx_coal_pkt = PCCTX_COAL_PKT_DEFAULT; in jme_sysctl_node()
1028 error = resource_int_value(device_get_name(sc->jme_dev), in jme_sysctl_node()
1029 device_get_unit(sc->jme_dev), "tx_coal_pkt", &sc->jme_tx_coal_to); in jme_sysctl_node()
1031 if (sc->jme_tx_coal_pkt < PCCTX_COAL_PKT_MIN || in jme_sysctl_node()
1032 sc->jme_tx_coal_pkt > PCCTX_COAL_PKT_MAX) { in jme_sysctl_node()
1033 device_printf(sc->jme_dev, in jme_sysctl_node()
1036 sc->jme_tx_coal_pkt = PCCTX_COAL_PKT_DEFAULT; in jme_sysctl_node()
1040 sc->jme_rx_coal_to = PCCRX_COAL_TO_DEFAULT; in jme_sysctl_node()
1041 error = resource_int_value(device_get_name(sc->jme_dev), in jme_sysctl_node()
1042 device_get_unit(sc->jme_dev), "rx_coal_to", &sc->jme_rx_coal_to); in jme_sysctl_node()
1044 if (sc->jme_rx_coal_to < PCCRX_COAL_TO_MIN || in jme_sysctl_node()
1045 sc->jme_rx_coal_to > PCCRX_COAL_TO_MAX) { in jme_sysctl_node()
1046 device_printf(sc->jme_dev, in jme_sysctl_node()
1049 sc->jme_rx_coal_to = PCCRX_COAL_TO_DEFAULT; in jme_sysctl_node()
1053 sc->jme_rx_coal_pkt = PCCRX_COAL_PKT_DEFAULT; in jme_sysctl_node()
1054 error = resource_int_value(device_get_name(sc->jme_dev), in jme_sysctl_node()
1055 device_get_unit(sc->jme_dev), "rx_coal_pkt", &sc->jme_rx_coal_to); in jme_sysctl_node()
1057 if (sc->jme_rx_coal_pkt < PCCRX_COAL_PKT_MIN || in jme_sysctl_node()
1058 sc->jme_rx_coal_pkt > PCCRX_COAL_PKT_MAX) { in jme_sysctl_node()
1059 device_printf(sc->jme_dev, in jme_sysctl_node()
1062 sc->jme_rx_coal_pkt = PCCRX_COAL_PKT_DEFAULT; in jme_sysctl_node()
1066 if ((sc->jme_flags & JME_FLAG_HWMIB) == 0) in jme_sysctl_node()
1078 &stats->rx_good_frames, "Good frames"); in jme_sysctl_node()
1080 &stats->rx_crc_errs, "CRC errors"); in jme_sysctl_node()
1082 &stats->rx_mii_errs, "MII errors"); in jme_sysctl_node()
1084 &stats->rx_fifo_oflows, "FIFO overflows"); in jme_sysctl_node()
1086 &stats->rx_desc_empty, "Descriptor empty"); in jme_sysctl_node()
1088 &stats->rx_bad_frames, "Bad frames"); in jme_sysctl_node()
1095 &stats->tx_good_frames, "Good frames"); in jme_sysctl_node()
1097 &stats->tx_bad_frames, "Bad frames"); in jme_sysctl_node()
1117 ctx->jme_busaddr = segs[0].ds_addr; in jme_dmamap_cb()
1130 if ((sc->jme_flags & JME_FLAG_DMA32BIT) != 0) in jme_dma_alloc()
1135 error = bus_dma_tag_create(bus_get_dma_tag(sc->jme_dev),/* parent */ in jme_dma_alloc()
1145 &sc->jme_cdata.jme_ring_tag); in jme_dma_alloc()
1147 device_printf(sc->jme_dev, in jme_dma_alloc()
1152 error = bus_dma_tag_create(sc->jme_cdata.jme_ring_tag,/* parent */ in jme_dma_alloc()
1162 &sc->jme_cdata.jme_tx_ring_tag); in jme_dma_alloc()
1164 device_printf(sc->jme_dev, in jme_dma_alloc()
1170 error = bus_dma_tag_create(sc->jme_cdata.jme_ring_tag,/* parent */ in jme_dma_alloc()
1180 &sc->jme_cdata.jme_rx_ring_tag); in jme_dma_alloc()
1182 device_printf(sc->jme_dev, in jme_dma_alloc()
1188 error = bus_dmamem_alloc(sc->jme_cdata.jme_tx_ring_tag, in jme_dma_alloc()
1189 (void **)&sc->jme_rdata.jme_tx_ring, in jme_dma_alloc()
1191 &sc->jme_cdata.jme_tx_ring_map); in jme_dma_alloc()
1193 device_printf(sc->jme_dev, in jme_dma_alloc()
1199 error = bus_dmamap_load(sc->jme_cdata.jme_tx_ring_tag, in jme_dma_alloc()
1200 sc->jme_cdata.jme_tx_ring_map, sc->jme_rdata.jme_tx_ring, in jme_dma_alloc()
1203 device_printf(sc->jme_dev, in jme_dma_alloc()
1207 sc->jme_rdata.jme_tx_ring_paddr = ctx.jme_busaddr; in jme_dma_alloc()
1210 error = bus_dmamem_alloc(sc->jme_cdata.jme_rx_ring_tag, in jme_dma_alloc()
1211 (void **)&sc->jme_rdata.jme_rx_ring, in jme_dma_alloc()
1213 &sc->jme_cdata.jme_rx_ring_map); in jme_dma_alloc()
1215 device_printf(sc->jme_dev, in jme_dma_alloc()
1221 error = bus_dmamap_load(sc->jme_cdata.jme_rx_ring_tag, in jme_dma_alloc()
1222 sc->jme_cdata.jme_rx_ring_map, sc->jme_rdata.jme_rx_ring, in jme_dma_alloc()
1225 device_printf(sc->jme_dev, in jme_dma_alloc()
1229 sc->jme_rdata.jme_rx_ring_paddr = ctx.jme_busaddr; in jme_dma_alloc()
1233 tx_ring_end = sc->jme_rdata.jme_tx_ring_paddr + in jme_dma_alloc()
1235 rx_ring_end = sc->jme_rdata.jme_rx_ring_paddr + in jme_dma_alloc()
1238 JME_ADDR_HI(sc->jme_rdata.jme_tx_ring_paddr)) || in jme_dma_alloc()
1240 JME_ADDR_HI(sc->jme_rdata.jme_rx_ring_paddr))) { in jme_dma_alloc()
1241 device_printf(sc->jme_dev, "4GB boundary crossed, " in jme_dma_alloc()
1251 if ((sc->jme_flags & JME_FLAG_DMA32BIT) != 0) in jme_dma_alloc()
1254 error = bus_dma_tag_create(bus_get_dma_tag(sc->jme_dev),/* parent */ in jme_dma_alloc()
1264 &sc->jme_cdata.jme_buffer_tag); in jme_dma_alloc()
1266 device_printf(sc->jme_dev, in jme_dma_alloc()
1272 error = bus_dma_tag_create(sc->jme_cdata.jme_buffer_tag,/* parent */ in jme_dma_alloc()
1282 &sc->jme_cdata.jme_ssb_tag); in jme_dma_alloc()
1284 device_printf(sc->jme_dev, in jme_dma_alloc()
1290 error = bus_dma_tag_create(sc->jme_cdata.jme_buffer_tag,/* parent */ in jme_dma_alloc()
1300 &sc->jme_cdata.jme_tx_tag); in jme_dma_alloc()
1302 device_printf(sc->jme_dev, "could not create Tx DMA tag.\n"); in jme_dma_alloc()
1307 error = bus_dma_tag_create(sc->jme_cdata.jme_buffer_tag,/* parent */ in jme_dma_alloc()
1317 &sc->jme_cdata.jme_rx_tag); in jme_dma_alloc()
1319 device_printf(sc->jme_dev, "could not create Rx DMA tag.\n"); in jme_dma_alloc()
1327 error = bus_dmamem_alloc(sc->jme_cdata.jme_ssb_tag, in jme_dma_alloc()
1328 (void **)&sc->jme_rdata.jme_ssb_block, in jme_dma_alloc()
1330 &sc->jme_cdata.jme_ssb_map); in jme_dma_alloc()
1332 device_printf(sc->jme_dev, "could not allocate DMA'able " in jme_dma_alloc()
1338 error = bus_dmamap_load(sc->jme_cdata.jme_ssb_tag, in jme_dma_alloc()
1339 sc->jme_cdata.jme_ssb_map, sc->jme_rdata.jme_ssb_block, in jme_dma_alloc()
1342 device_printf(sc->jme_dev, "could not load DMA'able memory " in jme_dma_alloc()
1346 sc->jme_rdata.jme_ssb_block_paddr = ctx.jme_busaddr; in jme_dma_alloc()
1350 txd = &sc->jme_cdata.jme_txdesc[i]; in jme_dma_alloc()
1351 txd->tx_m = NULL; in jme_dma_alloc()
1352 txd->tx_dmamap = NULL; in jme_dma_alloc()
1353 error = bus_dmamap_create(sc->jme_cdata.jme_tx_tag, 0, in jme_dma_alloc()
1354 &txd->tx_dmamap); in jme_dma_alloc()
1356 device_printf(sc->jme_dev, in jme_dma_alloc()
1362 if ((error = bus_dmamap_create(sc->jme_cdata.jme_rx_tag, 0, in jme_dma_alloc()
1363 &sc->jme_cdata.jme_rx_sparemap)) != 0) { in jme_dma_alloc()
1364 device_printf(sc->jme_dev, in jme_dma_alloc()
1369 rxd = &sc->jme_cdata.jme_rxdesc[i]; in jme_dma_alloc()
1370 rxd->rx_m = NULL; in jme_dma_alloc()
1371 rxd->rx_dmamap = NULL; in jme_dma_alloc()
1372 error = bus_dmamap_create(sc->jme_cdata.jme_rx_tag, 0, in jme_dma_alloc()
1373 &rxd->rx_dmamap); in jme_dma_alloc()
1375 device_printf(sc->jme_dev, in jme_dma_alloc()
1393 if (sc->jme_cdata.jme_tx_ring_tag != NULL) { in jme_dma_free()
1394 if (sc->jme_rdata.jme_tx_ring_paddr) in jme_dma_free()
1395 bus_dmamap_unload(sc->jme_cdata.jme_tx_ring_tag, in jme_dma_free()
1396 sc->jme_cdata.jme_tx_ring_map); in jme_dma_free()
1397 if (sc->jme_rdata.jme_tx_ring) in jme_dma_free()
1398 bus_dmamem_free(sc->jme_cdata.jme_tx_ring_tag, in jme_dma_free()
1399 sc->jme_rdata.jme_tx_ring, in jme_dma_free()
1400 sc->jme_cdata.jme_tx_ring_map); in jme_dma_free()
1401 sc->jme_rdata.jme_tx_ring = NULL; in jme_dma_free()
1402 sc->jme_rdata.jme_tx_ring_paddr = 0; in jme_dma_free()
1403 bus_dma_tag_destroy(sc->jme_cdata.jme_tx_ring_tag); in jme_dma_free()
1404 sc->jme_cdata.jme_tx_ring_tag = NULL; in jme_dma_free()
1407 if (sc->jme_cdata.jme_rx_ring_tag != NULL) { in jme_dma_free()
1408 if (sc->jme_rdata.jme_rx_ring_paddr) in jme_dma_free()
1409 bus_dmamap_unload(sc->jme_cdata.jme_rx_ring_tag, in jme_dma_free()
1410 sc->jme_cdata.jme_rx_ring_map); in jme_dma_free()
1411 if (sc->jme_rdata.jme_rx_ring) in jme_dma_free()
1412 bus_dmamem_free(sc->jme_cdata.jme_rx_ring_tag, in jme_dma_free()
1413 sc->jme_rdata.jme_rx_ring, in jme_dma_free()
1414 sc->jme_cdata.jme_rx_ring_map); in jme_dma_free()
1415 sc->jme_rdata.jme_rx_ring = NULL; in jme_dma_free()
1416 sc->jme_rdata.jme_rx_ring_paddr = 0; in jme_dma_free()
1417 bus_dma_tag_destroy(sc->jme_cdata.jme_rx_ring_tag); in jme_dma_free()
1418 sc->jme_cdata.jme_rx_ring_tag = NULL; in jme_dma_free()
1421 if (sc->jme_cdata.jme_tx_tag != NULL) { in jme_dma_free()
1423 txd = &sc->jme_cdata.jme_txdesc[i]; in jme_dma_free()
1424 if (txd->tx_dmamap != NULL) { in jme_dma_free()
1425 bus_dmamap_destroy(sc->jme_cdata.jme_tx_tag, in jme_dma_free()
1426 txd->tx_dmamap); in jme_dma_free()
1427 txd->tx_dmamap = NULL; in jme_dma_free()
1430 bus_dma_tag_destroy(sc->jme_cdata.jme_tx_tag); in jme_dma_free()
1431 sc->jme_cdata.jme_tx_tag = NULL; in jme_dma_free()
1434 if (sc->jme_cdata.jme_rx_tag != NULL) { in jme_dma_free()
1436 rxd = &sc->jme_cdata.jme_rxdesc[i]; in jme_dma_free()
1437 if (rxd->rx_dmamap != NULL) { in jme_dma_free()
1438 bus_dmamap_destroy(sc->jme_cdata.jme_rx_tag, in jme_dma_free()
1439 rxd->rx_dmamap); in jme_dma_free()
1440 rxd->rx_dmamap = NULL; in jme_dma_free()
1443 if (sc->jme_cdata.jme_rx_sparemap != NULL) { in jme_dma_free()
1444 bus_dmamap_destroy(sc->jme_cdata.jme_rx_tag, in jme_dma_free()
1445 sc->jme_cdata.jme_rx_sparemap); in jme_dma_free()
1446 sc->jme_cdata.jme_rx_sparemap = NULL; in jme_dma_free()
1448 bus_dma_tag_destroy(sc->jme_cdata.jme_rx_tag); in jme_dma_free()
1449 sc->jme_cdata.jme_rx_tag = NULL; in jme_dma_free()
1453 if (sc->jme_cdata.jme_ssb_tag != NULL) { in jme_dma_free()
1454 if (sc->jme_rdata.jme_ssb_block_paddr) in jme_dma_free()
1455 bus_dmamap_unload(sc->jme_cdata.jme_ssb_tag, in jme_dma_free()
1456 sc->jme_cdata.jme_ssb_map); in jme_dma_free()
1457 if (sc->jme_rdata.jme_ssb_block) in jme_dma_free()
1458 bus_dmamem_free(sc->jme_cdata.jme_ssb_tag, in jme_dma_free()
1459 sc->jme_rdata.jme_ssb_block, in jme_dma_free()
1460 sc->jme_cdata.jme_ssb_map); in jme_dma_free()
1461 sc->jme_rdata.jme_ssb_block = NULL; in jme_dma_free()
1462 sc->jme_rdata.jme_ssb_block_paddr = 0; in jme_dma_free()
1463 bus_dma_tag_destroy(sc->jme_cdata.jme_ssb_tag); in jme_dma_free()
1464 sc->jme_cdata.jme_ssb_tag = NULL; in jme_dma_free()
1467 if (sc->jme_cdata.jme_buffer_tag != NULL) { in jme_dma_free()
1468 bus_dma_tag_destroy(sc->jme_cdata.jme_buffer_tag); in jme_dma_free()
1469 sc->jme_cdata.jme_buffer_tag = NULL; in jme_dma_free()
1471 if (sc->jme_cdata.jme_ring_tag != NULL) { in jme_dma_free()
1472 bus_dma_tag_destroy(sc->jme_cdata.jme_ring_tag); in jme_dma_free()
1473 sc->jme_cdata.jme_ring_tag = NULL; in jme_dma_free()
1492 * auto-negotiation but we don't know whether that operation
1500 * Save current negotiated media speed/duplex/flow-control
1513 mii = device_get_softc(sc->jme_miibus); in jme_setlinkspeed()
1516 if ((mii->mii_media_status & IFM_AVALID) != 0) { in jme_setlinkspeed()
1517 switch IFM_SUBTYPE(mii->mii_media_active) { in jme_setlinkspeed()
1527 jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr, MII_100T2CR, 0); in jme_setlinkspeed()
1528 jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr, MII_ANAR, in jme_setlinkspeed()
1530 jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr, MII_BMCR, in jme_setlinkspeed()
1537 if ((mii->mii_media_status & IFM_AVALID) != 0) { in jme_setlinkspeed()
1538 switch (IFM_SUBTYPE(mii->mii_media_active)) { in jme_setlinkspeed()
1552 device_printf(sc->jme_dev, "establishing link failed, " in jme_setlinkspeed()
1556 * No link, force MAC to have 100Mbps, full-duplex link. in jme_setlinkspeed()
1559 mii->mii_media_status = IFM_AVALID | IFM_ACTIVE; in jme_setlinkspeed()
1560 mii->mii_media_active = IFM_ETHER | IFM_100_TX | IFM_FDX; in jme_setlinkspeed()
1574 if (pci_find_cap(sc->jme_dev, PCIY_PMG, &pmc) != 0) { in jme_setwol()
1576 if ((sc->jme_flags & JME_FLAG_TXCLK) != 0) in jme_setwol()
1580 if ((sc->jme_flags & JME_FLAG_RXCLK) != 0) in jme_setwol()
1588 ifp = sc->jme_ifp; in jme_setwol()
1597 if ((sc->jme_flags & JME_FLAG_FASTETH) == 0) in jme_setwol()
1604 if ((sc->jme_flags & JME_FLAG_TXCLK) != 0) in jme_setwol()
1609 pmstat = pci_read_config(sc->jme_dev, pmc + PCIR_POWER_STATUS, 2); in jme_setwol()
1613 pci_write_config(sc->jme_dev, pmc + PCIR_POWER_STATUS, pmstat, 2); in jme_setwol()
1646 if (pci_find_cap(sc->jme_dev, PCIY_PMG, &pmc) == 0) { in jme_resume()
1647 pmstat = pci_read_config(sc->jme_dev, in jme_resume()
1651 pci_write_config(sc->jme_dev, in jme_resume()
1656 ifp = sc->jme_ifp; in jme_resume()
1681 if (((*m_head)->m_pkthdr.csum_flags & CSUM_TSO) != 0) { in jme_encap()
1713 if (eh->ether_type == htons(ETHERTYPE_VLAN)) { in jme_encap()
1727 poff = ip_off + (ip->ip_hl << 2); in jme_encap()
1739 ip->ip_sum = 0; in jme_encap()
1740 if (poff + (tcp->th_off << 2) == m->m_pkthdr.len) { in jme_encap()
1741 tcp->th_sum = in_pseudo(ip->ip_src.s_addr, in jme_encap()
1742 ip->ip_dst.s_addr, in jme_encap()
1743 htons((tcp->th_off << 2) + IPPROTO_TCP)); in jme_encap()
1745 (*m_head)->m_pkthdr.csum_flags &= ~CSUM_TSO; in jme_encap()
1746 (*m_head)->m_pkthdr.csum_flags |= CSUM_IP; in jme_encap()
1748 tcp->th_sum = in_pseudo(ip->ip_src.s_addr, in jme_encap()
1749 ip->ip_dst.s_addr, htons(IPPROTO_TCP)); in jme_encap()
1753 prod = sc->jme_cdata.jme_tx_prod; in jme_encap()
1754 txd = &sc->jme_cdata.jme_txdesc[prod]; in jme_encap()
1756 error = bus_dmamap_load_mbuf_sg(sc->jme_cdata.jme_tx_tag, in jme_encap()
1757 txd->tx_dmamap, *m_head, txsegs, &nsegs, 0); in jme_encap()
1766 error = bus_dmamap_load_mbuf_sg(sc->jme_cdata.jme_tx_tag, in jme_encap()
1767 txd->tx_dmamap, *m_head, txsegs, &nsegs, 0); in jme_encap()
1786 if (sc->jme_cdata.jme_tx_cnt + nsegs + 1 > JME_TX_RING_CNT - 1) { in jme_encap()
1787 bus_dmamap_unload(sc->jme_cdata.jme_tx_tag, txd->tx_dmamap); in jme_encap()
1795 if ((m->m_pkthdr.csum_flags & CSUM_TSO) != 0) { in jme_encap()
1796 tsosegsz = (uint32_t)m->m_pkthdr.tso_segsz << in jme_encap()
1800 if ((m->m_pkthdr.csum_flags & CSUM_IP) != 0) in jme_encap()
1802 if ((m->m_pkthdr.csum_flags & CSUM_TCP) != 0) in jme_encap()
1804 if ((m->m_pkthdr.csum_flags & CSUM_UDP) != 0) in jme_encap()
1808 if ((m->m_flags & M_VLANTAG) != 0) { in jme_encap()
1809 cflags |= (m->m_pkthdr.ether_vtag & JME_TD_VLAN_MASK); in jme_encap()
1813 desc = &sc->jme_rdata.jme_tx_ring[prod]; in jme_encap()
1814 desc->flags = htole32(cflags); in jme_encap()
1815 desc->buflen = htole32(tsosegsz); in jme_encap()
1816 desc->addr_hi = htole32(m->m_pkthdr.len); in jme_encap()
1817 desc->addr_lo = 0; in jme_encap()
1818 sc->jme_cdata.jme_tx_cnt++; in jme_encap()
1821 desc = &sc->jme_rdata.jme_tx_ring[prod]; in jme_encap()
1822 desc->flags = htole32(JME_TD_OWN | JME_TD_64BIT); in jme_encap()
1823 desc->buflen = htole32(txsegs[i].ds_len); in jme_encap()
1824 desc->addr_hi = htole32(JME_ADDR_HI(txsegs[i].ds_addr)); in jme_encap()
1825 desc->addr_lo = htole32(JME_ADDR_LO(txsegs[i].ds_addr)); in jme_encap()
1826 sc->jme_cdata.jme_tx_cnt++; in jme_encap()
1831 sc->jme_cdata.jme_tx_prod = prod; in jme_encap()
1836 desc = txd->tx_desc; in jme_encap()
1837 desc->flags |= htole32(JME_TD_OWN | JME_TD_INTR); in jme_encap()
1839 txd->tx_m = m; in jme_encap()
1840 txd->tx_ndesc = nsegs + 1; in jme_encap()
1843 bus_dmamap_sync(sc->jme_cdata.jme_tx_tag, txd->tx_dmamap, in jme_encap()
1845 bus_dmamap_sync(sc->jme_cdata.jme_tx_ring_tag, in jme_encap()
1846 sc->jme_cdata.jme_tx_ring_map, in jme_encap()
1874 if (sc->jme_cdata.jme_tx_cnt >= JME_TX_DESC_HIWAT) in jme_start_locked()
1878 IFF_DRV_RUNNING || (sc->jme_flags & JME_FLAG_LINK) == 0) in jme_start_locked()
1913 CSR_WRITE_4(sc, JME_TXCSR, sc->jme_txcsr | TXCSR_TX_ENB | in jme_start_locked()
1916 sc->jme_watchdog_timer = JME_TX_TIMEOUT; in jme_start_locked()
1927 if (sc->jme_watchdog_timer == 0 || --sc->jme_watchdog_timer) in jme_watchdog()
1930 ifp = sc->jme_ifp; in jme_watchdog()
1931 if ((sc->jme_flags & JME_FLAG_LINK) == 0) { in jme_watchdog()
1932 if_printf(sc->jme_ifp, "watchdog timeout (missed link)\n"); in jme_watchdog()
1939 if (sc->jme_cdata.jme_tx_cnt == 0) { in jme_watchdog()
1940 if_printf(sc->jme_ifp, in jme_watchdog()
1941 "watchdog timeout (missed Tx interrupts) -- recovering\n"); in jme_watchdog()
1947 if_printf(sc->jme_ifp, "watchdog timeout\n"); in jme_watchdog()
1969 if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > JME_JUMBO_MTU || in jme_ioctl()
1970 ((sc->jme_flags & JME_FLAG_NOJUMBO) != 0 && in jme_ioctl()
1971 ifr->ifr_mtu > JME_MAX_MTU)) { in jme_ioctl()
1976 if (if_getmtu(ifp) != ifr->ifr_mtu) { in jme_ioctl()
1984 if (ifr->ifr_mtu >= JME_TX_FIFO_SIZE) { in jme_ioctl()
1991 if_setmtu(ifp, ifr->ifr_mtu); in jme_ioctl()
2003 if (((if_getflags(ifp) ^ sc->jme_if_flags) in jme_ioctl()
2007 if ((sc->jme_flags & JME_FLAG_DETACH) == 0) in jme_ioctl()
2014 sc->jme_if_flags = if_getflags(ifp); in jme_ioctl()
2026 mii = device_get_softc(sc->jme_miibus); in jme_ioctl()
2027 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, cmd); in jme_ioctl()
2031 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in jme_ioctl()
2095 mii = device_get_softc(sc->jme_miibus); in jme_mac_config()
2108 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) { in jme_mac_config()
2114 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_TXPAUSE) != 0) in jme_mac_config()
2116 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_RXPAUSE) != 0) in jme_mac_config()
2129 switch (IFM_SUBTYPE(mii->mii_media_active)) { in jme_mac_config()
2139 if ((sc->jme_flags & JME_FLAG_FASTETH) != 0) in jme_mac_config()
2143 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) == 0) in jme_mac_config()
2149 if (sc->jme_rev == DEVICEID_JMC250 && in jme_mac_config()
2150 sc->jme_chip_rev == DEVICEREVID_JMC250_A2) { in jme_mac_config()
2153 * when it runs on half-duplex media. in jme_mac_config()
2156 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) in jme_mac_config()
2162 if (IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX) { in jme_mac_config()
2164 jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr, in jme_mac_config()
2168 jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr, in jme_mac_config()
2172 if ((sc->jme_flags & JME_FLAG_TXCLK) != 0) in jme_mac_config()
2193 mii = device_get_softc(sc->jme_miibus); in jme_link_task()
2194 ifp = sc->jme_ifp; in jme_link_task()
2201 sc->jme_flags &= ~JME_FLAG_LINK; in jme_link_task()
2202 if ((mii->mii_media_status & IFM_AVALID) != 0) { in jme_link_task()
2203 switch (IFM_SUBTYPE(mii->mii_media_active)) { in jme_link_task()
2206 sc->jme_flags |= JME_FLAG_LINK; in jme_link_task()
2209 if ((sc->jme_flags & JME_FLAG_FASTETH) != 0) in jme_link_task()
2211 sc->jme_flags |= JME_FLAG_LINK; in jme_link_task()
2219 * Disabling Rx/Tx MACs have a side-effect of resetting in jme_link_task()
2232 taskqueue_block(sc->jme_tq); in jme_link_task()
2236 callout_stop(&sc->jme_tick_ch); in jme_link_task()
2237 sc->jme_watchdog_timer = 0; in jme_link_task()
2245 taskqueue_drain(sc->jme_tq, &sc->jme_int_task); in jme_link_task()
2248 if (sc->jme_cdata.jme_rxhead != NULL) in jme_link_task()
2249 m_freem(sc->jme_cdata.jme_rxhead); in jme_link_task()
2252 if (sc->jme_cdata.jme_tx_cnt != 0) { in jme_link_task()
2255 txd = &sc->jme_cdata.jme_txdesc[i]; in jme_link_task()
2256 if (txd->tx_m != NULL) { in jme_link_task()
2258 sc->jme_cdata.jme_tx_tag, in jme_link_task()
2259 txd->tx_dmamap, in jme_link_task()
2262 sc->jme_cdata.jme_tx_tag, in jme_link_task()
2263 txd->tx_dmamap); in jme_link_task()
2264 m_freem(txd->tx_m); in jme_link_task()
2265 txd->tx_m = NULL; in jme_link_task()
2266 txd->tx_ndesc = 0; in jme_link_task()
2276 sc->jme_cdata.jme_rx_cons = 0; in jme_link_task()
2277 sc->jme_morework = 0; in jme_link_task()
2282 /* Program MAC with resolved speed/duplex/flow-control. */ in jme_link_task()
2283 if ((sc->jme_flags & JME_FLAG_LINK) != 0) { in jme_link_task()
2287 CSR_WRITE_4(sc, JME_RXCSR, sc->jme_rxcsr); in jme_link_task()
2288 CSR_WRITE_4(sc, JME_TXCSR, sc->jme_txcsr); in jme_link_task()
2301 CSR_WRITE_4(sc, JME_RXCSR, sc->jme_rxcsr | RXCSR_RX_ENB | in jme_link_task()
2303 CSR_WRITE_4(sc, JME_TXCSR, sc->jme_txcsr | TXCSR_TX_ENB); in jme_link_task()
2305 if ((sc->jme_flags & JME_FLAG_TXCLK) != 0) in jme_link_task()
2308 if ((sc->jme_flags & JME_FLAG_RXCLK) != 0) in jme_link_task()
2315 callout_reset(&sc->jme_tick_ch, hz, jme_tick, sc); in jme_link_task()
2317 taskqueue_unblock(sc->jme_tq); in jme_link_task()
2337 taskqueue_enqueue(sc->jme_tq, &sc->jme_int_task); in jme_intr()
2351 ifp = sc->jme_ifp; in jme_int_task()
2355 if (sc->jme_morework != 0) { in jme_int_task()
2356 sc->jme_morework = 0; in jme_int_task()
2371 more = jme_rxintr(sc, sc->jme_process_limit); in jme_int_task()
2373 sc->jme_morework = 1; in jme_int_task()
2385 CSR_WRITE_4(sc, JME_RXCSR, sc->jme_rxcsr | in jme_int_task()
2393 taskqueue_enqueue(sc->jme_tq, &sc->jme_int_task); in jme_int_task()
2414 ifp = sc->jme_ifp; in jme_txeof()
2416 cons = sc->jme_cdata.jme_tx_cons; in jme_txeof()
2417 if (cons == sc->jme_cdata.jme_tx_prod) in jme_txeof()
2420 bus_dmamap_sync(sc->jme_cdata.jme_tx_ring_tag, in jme_txeof()
2421 sc->jme_cdata.jme_tx_ring_map, in jme_txeof()
2426 * frames which have been transmitted. in jme_txeof()
2428 for (; cons != sc->jme_cdata.jme_tx_prod;) { in jme_txeof()
2429 txd = &sc->jme_cdata.jme_txdesc[cons]; in jme_txeof()
2430 status = le32toh(txd->tx_desc->flags); in jme_txeof()
2440 le32toh(txd->tx_desc->buflen) & in jme_txeof()
2444 * Only the first descriptor of multi-descriptor in jme_txeof()
2448 * descriptor of a multi-descriptor transmission. in jme_txeof()
2450 for (nsegs = 0; nsegs < txd->tx_ndesc; nsegs++) { in jme_txeof()
2451 sc->jme_rdata.jme_tx_ring[cons].flags = 0; in jme_txeof()
2456 bus_dmamap_sync(sc->jme_cdata.jme_tx_tag, txd->tx_dmamap, in jme_txeof()
2458 bus_dmamap_unload(sc->jme_cdata.jme_tx_tag, txd->tx_dmamap); in jme_txeof()
2460 KASSERT(txd->tx_m != NULL, in jme_txeof()
2462 m_freem(txd->tx_m); in jme_txeof()
2463 txd->tx_m = NULL; in jme_txeof()
2464 sc->jme_cdata.jme_tx_cnt -= txd->tx_ndesc; in jme_txeof()
2465 KASSERT(sc->jme_cdata.jme_tx_cnt >= 0, in jme_txeof()
2467 txd->tx_ndesc = 0; in jme_txeof()
2470 sc->jme_cdata.jme_tx_cons = cons; in jme_txeof()
2472 if (sc->jme_cdata.jme_tx_cnt == 0) in jme_txeof()
2473 sc->jme_watchdog_timer = 0; in jme_txeof()
2475 bus_dmamap_sync(sc->jme_cdata.jme_tx_ring_tag, in jme_txeof()
2476 sc->jme_cdata.jme_tx_ring_map, in jme_txeof()
2485 desc = &sc->jme_rdata.jme_rx_ring[cons]; in jme_discard_rxbuf()
2486 desc->flags = htole32(JME_RD_OWN | JME_RD_INTR | JME_RD_64BIT); in jme_discard_rxbuf()
2487 desc->buflen = htole32(MCLBYTES); in jme_discard_rxbuf()
2503 ifp = sc->jme_ifp; in jme_rxeof()
2505 cons = sc->jme_cdata.jme_rx_cons; in jme_rxeof()
2506 desc = &sc->jme_rdata.jme_rx_ring[cons]; in jme_rxeof()
2507 flags = le32toh(desc->flags); in jme_rxeof()
2508 status = le32toh(desc->buflen); in jme_rxeof()
2510 sc->jme_cdata.jme_rxlen = JME_RX_BYTES(status) - JME_RX_PAD_BYTES; in jme_rxeof()
2513 jme_discard_rxbuf(sc, sc->jme_cdata.jme_rx_cons); in jme_rxeof()
2515 device_printf(sc->jme_dev, "%s : receive error = 0x%b\n", in jme_rxeof()
2518 sc->jme_cdata.jme_rx_cons += nsegs; in jme_rxeof()
2519 sc->jme_cdata.jme_rx_cons %= JME_RX_RING_CNT; in jme_rxeof()
2525 rxd = &sc->jme_cdata.jme_rxdesc[cons]; in jme_rxeof()
2526 mp = rxd->rx_m; in jme_rxeof()
2535 if (sc->jme_cdata.jme_rxhead != NULL) { in jme_rxeof()
2536 m_freem(sc->jme_cdata.jme_rxhead); in jme_rxeof()
2545 * multi-segmented frame. in jme_rxeof()
2547 mp->m_len = MCLBYTES; in jme_rxeof()
2550 if (sc->jme_cdata.jme_rxhead == NULL) { in jme_rxeof()
2551 sc->jme_cdata.jme_rxhead = mp; in jme_rxeof()
2552 sc->jme_cdata.jme_rxtail = mp; in jme_rxeof()
2558 mp->m_flags &= ~M_PKTHDR; in jme_rxeof()
2559 sc->jme_cdata.jme_rxtail->m_next = mp; in jme_rxeof()
2560 sc->jme_cdata.jme_rxtail = mp; in jme_rxeof()
2563 if (count == nsegs - 1) { in jme_rxeof()
2565 m = sc->jme_cdata.jme_rxhead; in jme_rxeof()
2566 m->m_flags |= M_PKTHDR; in jme_rxeof()
2567 m->m_pkthdr.len = sc->jme_cdata.jme_rxlen; in jme_rxeof()
2570 m->m_len = MCLBYTES - JME_RX_PAD_BYTES; in jme_rxeof()
2572 mp->m_len = sc->jme_cdata.jme_rxlen - in jme_rxeof()
2573 ((MCLBYTES - JME_RX_PAD_BYTES) + in jme_rxeof()
2574 (MCLBYTES * (nsegs - 2))); in jme_rxeof()
2576 m->m_len = sc->jme_cdata.jme_rxlen; in jme_rxeof()
2577 m->m_pkthdr.rcvif = ifp; in jme_rxeof()
2585 m->m_data += JME_RX_PAD_BYTES; in jme_rxeof()
2590 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; in jme_rxeof()
2592 m->m_pkthdr.csum_flags |= CSUM_IP_VALID; in jme_rxeof()
2598 m->m_pkthdr.csum_flags |= in jme_rxeof()
2600 m->m_pkthdr.csum_data = 0xffff; in jme_rxeof()
2607 m->m_pkthdr.ether_vtag = in jme_rxeof()
2609 m->m_flags |= M_VLANTAG; in jme_rxeof()
2623 sc->jme_cdata.jme_rx_cons += nsegs; in jme_rxeof()
2624 sc->jme_cdata.jme_rx_cons %= JME_RX_RING_CNT; in jme_rxeof()
2633 bus_dmamap_sync(sc->jme_cdata.jme_rx_ring_tag, in jme_rxintr()
2634 sc->jme_cdata.jme_rx_ring_map, in jme_rxintr()
2638 desc = &sc->jme_rdata.jme_rx_ring[sc->jme_cdata.jme_rx_cons]; in jme_rxintr()
2639 if ((le32toh(desc->flags) & JME_RD_OWN) == JME_RD_OWN) in jme_rxintr()
2641 if ((le32toh(desc->buflen) & JME_RD_VALID) == 0) in jme_rxintr()
2643 nsegs = JME_RX_NSEGS(le32toh(desc->buflen)); in jme_rxintr()
2646 * Non-matching value would indicate that hardware in jme_rxintr()
2650 pktlen = JME_RX_BYTES(le32toh(desc->buflen)); in jme_rxintr()
2656 count -= nsegs; in jme_rxintr()
2660 bus_dmamap_sync(sc->jme_cdata.jme_rx_ring_tag, in jme_rxintr()
2661 sc->jme_cdata.jme_rx_ring_map, in jme_rxintr()
2677 mii = device_get_softc(sc->jme_miibus); in jme_tick()
2687 callout_reset(&sc->jme_tick_ch, hz, jme_tick, sc); in jme_tick()
2708 if ((sc->jme_flags & (JME_FLAG_TXCLK | JME_FLAG_RXCLK)) != 0) { in jme_reset()
2715 /* De-assert RESET but still disable TX clock. */ in jme_reset()
2756 ifp = sc->jme_ifp; in jme_init_locked()
2757 mii = device_get_softc(sc->jme_miibus); in jme_init_locked()
2774 device_printf(sc->jme_dev, in jme_init_locked()
2785 jme_set_macaddr(sc, if_getlladdr(sc->jme_ifp)); in jme_init_locked()
2794 sc->jme_txcsr = TXCSR_TXQ_N_SEL(TXCSR_TXQ0); in jme_init_locked()
2795 sc->jme_txcsr |= TXCSR_TXQ_WEIGHT(TXCSR_TXQ_WEIGHT_MIN); in jme_init_locked()
2796 sc->jme_txcsr |= TXCSR_FIFO_THRESH_16QW; in jme_init_locked()
2797 sc->jme_txcsr |= sc->jme_tx_dma_size; in jme_init_locked()
2798 sc->jme_txcsr |= TXCSR_DMA_BURST; in jme_init_locked()
2799 CSR_WRITE_4(sc, JME_TXCSR, sc->jme_txcsr); in jme_init_locked()
2825 sc->jme_rxcsr = RXCSR_FIFO_FTHRESH_128T; in jme_init_locked()
2827 * Since Rx FIFO size is 4K bytes, receiving frames larger in jme_init_locked()
2830 * frames larger than 4000 bytes. in jme_init_locked()
2831 * For best performance of standard MTU sized frames use in jme_init_locked()
2836 if (CHIPMODE_REVFM(sc->jme_chip_rev) >= 2) in jme_init_locked()
2837 sc->jme_rxcsr |= RXCSR_FIFO_THRESH_16QW; in jme_init_locked()
2841 sc->jme_rxcsr |= RXCSR_FIFO_THRESH_16QW; in jme_init_locked()
2843 sc->jme_rxcsr |= RXCSR_FIFO_THRESH_128QW; in jme_init_locked()
2845 sc->jme_rxcsr |= sc->jme_rx_dma_size | RXCSR_RXQ_N_SEL(RXCSR_RXQ0); in jme_init_locked()
2846 sc->jme_rxcsr |= RXCSR_DESC_RT_CNT(RXCSR_DESC_RT_CNT_DEFAULT); in jme_init_locked()
2847 sc->jme_rxcsr |= RXCSR_DESC_RT_GAP_256 & RXCSR_DESC_RT_GAP_MASK; in jme_init_locked()
2848 CSR_WRITE_4(sc, JME_RXCSR, sc->jme_rxcsr); in jme_init_locked()
2875 * help Rx performance on strict-alignment architectures as in jme_init_locked()
2886 /* Set PCC timer resolution to micro-seconds unit. */ in jme_init_locked()
2905 reg |= sc->jme_phyaddr; in jme_init_locked()
2909 reg = (sc->jme_tx_coal_to << PCCTX_COAL_TO_SHIFT) & in jme_init_locked()
2911 reg |= (sc->jme_tx_coal_pkt << PCCTX_COAL_PKT_SHIFT) & in jme_init_locked()
2917 reg = (sc->jme_rx_coal_to << PCCRX_COAL_TO_SHIFT) & in jme_init_locked()
2919 reg |= (sc->jme_rx_coal_pkt << PCCRX_COAL_PKT_SHIFT) & in jme_init_locked()
2926 * back-to-back incoming/outgoing packet is long enough for in jme_init_locked()
2932 if ((sc->jme_flags & JME_FLAG_PCCPCD) != 0) { in jme_init_locked()
2933 sc->jme_rx_pcd_to = sc->jme_rx_coal_to; in jme_init_locked()
2934 if (sc->jme_rx_coal_to > PCDRX_TO_MAX) in jme_init_locked()
2935 sc->jme_rx_pcd_to = PCDRX_TO_MAX; in jme_init_locked()
2936 sc->jme_tx_pcd_to = sc->jme_tx_coal_to; in jme_init_locked()
2937 if (sc->jme_tx_coal_to > PCDTX_TO_MAX) in jme_init_locked()
2938 sc->jme_tx_pcd_to = PCDTX_TO_MAX; in jme_init_locked()
2939 reg = sc->jme_rx_pcd_to << PCDRX0_TO_THROTTLE_SHIFT; in jme_init_locked()
2940 reg |= sc->jme_rx_pcd_to << PCDRX0_TO_SHIFT; in jme_init_locked()
2942 reg = sc->jme_tx_pcd_to << PCDTX_TO_THROTTLE_SHIFT; in jme_init_locked()
2943 reg |= sc->jme_tx_pcd_to << PCDTX_TO_SHIFT; in jme_init_locked()
2948 paddr = sc->jme_rdata.jme_ssb_block_paddr; in jme_init_locked()
2975 sc->jme_flags &= ~JME_FLAG_LINK; in jme_init_locked()
2979 callout_reset(&sc->jme_tick_ch, hz, jme_tick, sc); in jme_init_locked()
2997 ifp = sc->jme_ifp; in jme_stop()
2999 sc->jme_flags &= ~JME_FLAG_LINK; in jme_stop()
3000 callout_stop(&sc->jme_tick_ch); in jme_stop()
3001 sc->jme_watchdog_timer = 0; in jme_stop()
3019 if (sc->jme_cdata.jme_rxhead != NULL) in jme_stop()
3020 m_freem(sc->jme_cdata.jme_rxhead); in jme_stop()
3027 rxd = &sc->jme_cdata.jme_rxdesc[i]; in jme_stop()
3028 if (rxd->rx_m != NULL) { in jme_stop()
3029 bus_dmamap_sync(sc->jme_cdata.jme_rx_tag, in jme_stop()
3030 rxd->rx_dmamap, BUS_DMASYNC_POSTREAD); in jme_stop()
3031 bus_dmamap_unload(sc->jme_cdata.jme_rx_tag, in jme_stop()
3032 rxd->rx_dmamap); in jme_stop()
3033 m_freem(rxd->rx_m); in jme_stop()
3034 rxd->rx_m = NULL; in jme_stop()
3038 txd = &sc->jme_cdata.jme_txdesc[i]; in jme_stop()
3039 if (txd->tx_m != NULL) { in jme_stop()
3040 bus_dmamap_sync(sc->jme_cdata.jme_tx_tag, in jme_stop()
3041 txd->tx_dmamap, BUS_DMASYNC_POSTWRITE); in jme_stop()
3042 bus_dmamap_unload(sc->jme_cdata.jme_tx_tag, in jme_stop()
3043 txd->tx_dmamap); in jme_stop()
3044 m_freem(txd->tx_m); in jme_stop()
3045 txd->tx_m = NULL; in jme_stop()
3046 txd->tx_ndesc = 0; in jme_stop()
3064 for (i = JME_TIMEOUT; i > 0; i--) { in jme_stop_tx()
3070 device_printf(sc->jme_dev, "stopping transmitter timeout!\n"); in jme_stop_tx()
3084 for (i = JME_TIMEOUT; i > 0; i--) { in jme_stop_rx()
3090 device_printf(sc->jme_dev, "stopping recevier timeout!\n"); in jme_stop_rx()
3100 sc->jme_cdata.jme_tx_prod = 0; in jme_init_tx_ring()
3101 sc->jme_cdata.jme_tx_cons = 0; in jme_init_tx_ring()
3102 sc->jme_cdata.jme_tx_cnt = 0; in jme_init_tx_ring()
3104 rd = &sc->jme_rdata; in jme_init_tx_ring()
3105 bzero(rd->jme_tx_ring, JME_TX_RING_SIZE); in jme_init_tx_ring()
3107 txd = &sc->jme_cdata.jme_txdesc[i]; in jme_init_tx_ring()
3108 txd->tx_m = NULL; in jme_init_tx_ring()
3109 txd->tx_desc = &rd->jme_tx_ring[i]; in jme_init_tx_ring()
3110 txd->tx_ndesc = 0; in jme_init_tx_ring()
3113 bus_dmamap_sync(sc->jme_cdata.jme_tx_ring_tag, in jme_init_tx_ring()
3114 sc->jme_cdata.jme_tx_ring_map, in jme_init_tx_ring()
3123 rd = &sc->jme_rdata; in jme_init_ssb()
3124 bzero(rd->jme_ssb_block, JME_SSB_SIZE); in jme_init_ssb()
3125 bus_dmamap_sync(sc->jme_cdata.jme_ssb_tag, sc->jme_cdata.jme_ssb_map, in jme_init_ssb()
3136 sc->jme_cdata.jme_rx_cons = 0; in jme_init_rx_ring()
3138 sc->jme_morework = 0; in jme_init_rx_ring()
3140 rd = &sc->jme_rdata; in jme_init_rx_ring()
3141 bzero(rd->jme_rx_ring, JME_RX_RING_SIZE); in jme_init_rx_ring()
3143 rxd = &sc->jme_cdata.jme_rxdesc[i]; in jme_init_rx_ring()
3144 rxd->rx_m = NULL; in jme_init_rx_ring()
3145 rxd->rx_desc = &rd->jme_rx_ring[i]; in jme_init_rx_ring()
3150 bus_dmamap_sync(sc->jme_cdata.jme_rx_ring_tag, in jme_init_rx_ring()
3151 sc->jme_cdata.jme_rx_ring_map, in jme_init_rx_ring()
3175 m->m_len = m->m_pkthdr.len = MCLBYTES; in jme_newbuf()
3177 if (bus_dmamap_load_mbuf_sg(sc->jme_cdata.jme_rx_tag, in jme_newbuf()
3178 sc->jme_cdata.jme_rx_sparemap, m, segs, &nsegs, 0) != 0) { in jme_newbuf()
3184 if (rxd->rx_m != NULL) { in jme_newbuf()
3185 bus_dmamap_sync(sc->jme_cdata.jme_rx_tag, rxd->rx_dmamap, in jme_newbuf()
3187 bus_dmamap_unload(sc->jme_cdata.jme_rx_tag, rxd->rx_dmamap); in jme_newbuf()
3189 map = rxd->rx_dmamap; in jme_newbuf()
3190 rxd->rx_dmamap = sc->jme_cdata.jme_rx_sparemap; in jme_newbuf()
3191 sc->jme_cdata.jme_rx_sparemap = map; in jme_newbuf()
3192 bus_dmamap_sync(sc->jme_cdata.jme_rx_tag, rxd->rx_dmamap, in jme_newbuf()
3194 rxd->rx_m = m; in jme_newbuf()
3196 desc = rxd->rx_desc; in jme_newbuf()
3197 desc->buflen = htole32(segs[0].ds_len); in jme_newbuf()
3198 desc->addr_lo = htole32(JME_ADDR_LO(segs[0].ds_addr)); in jme_newbuf()
3199 desc->addr_hi = htole32(JME_ADDR_HI(segs[0].ds_addr)); in jme_newbuf()
3200 desc->flags = htole32(JME_RD_OWN | JME_RD_INTR | JME_RD_64BIT); in jme_newbuf()
3213 ifp = sc->jme_ifp; in jme_set_vlan()
3246 ifp = sc->jme_ifp; in jme_set_filter()
3251 /* Always accept frames destined to our station address. */ in jme_set_filter()
3268 * addresses through a CRC generator, and then using the low-order in jme_set_filter()
3288 if ((sc->jme_flags & JME_FLAG_HWMIB) == 0) in jme_stats_clear()
3296 bzero(&sc->jme_stats, sizeof(struct jme_hw_stats)); in jme_stats_clear()
3305 if ((sc->jme_flags & JME_FLAG_HWMIB) == 0) in jme_stats_save()
3308 bcopy(&sc->jme_stats, &sc->jme_ostats, sizeof(struct jme_hw_stats)); in jme_stats_save()
3321 if ((sc->jme_flags & JME_FLAG_HWMIB) == 0) in jme_stats_update()
3323 stat = &sc->jme_stats; in jme_stats_update()
3324 ostat = &sc->jme_ostats; in jme_stats_update()
3325 stat->tx_good_frames = CSR_READ_4(sc, JME_STAT_TXGOOD); in jme_stats_update()
3326 stat->rx_good_frames = CSR_READ_4(sc, JME_STAT_RXGOOD); in jme_stats_update()
3328 stat->rx_crc_errs = (reg & STAT_RX_CRC_ERR_MASK) >> in jme_stats_update()
3330 stat->rx_mii_errs = (reg & STAT_RX_MII_ERR_MASK) >> in jme_stats_update()
3333 stat->rx_fifo_oflows = (reg & STAT_RXERR_OFLOW_MASK) >> in jme_stats_update()
3335 stat->rx_desc_empty = (reg & STAT_RXERR_MPTY_MASK) >> in jme_stats_update()
3338 stat->rx_bad_frames = (reg & STAT_FAIL_RX_MASK) >> STAT_FAIL_RX_SHIFT; in jme_stats_update()
3339 stat->tx_bad_frames = (reg & STAT_FAIL_TX_MASK) >> STAT_FAIL_TX_SHIFT; in jme_stats_update()
3342 stat->rx_good_frames += ostat->rx_good_frames; in jme_stats_update()
3343 stat->rx_crc_errs += ostat->rx_crc_errs; in jme_stats_update()
3344 stat->rx_mii_errs += ostat->rx_mii_errs; in jme_stats_update()
3345 stat->rx_fifo_oflows += ostat->rx_fifo_oflows; in jme_stats_update()
3346 stat->rx_desc_empty += ostat->rx_desc_empty; in jme_stats_update()
3347 stat->rx_bad_frames += ostat->rx_bad_frames; in jme_stats_update()
3348 stat->tx_good_frames += ostat->tx_good_frames; in jme_stats_update()
3349 stat->tx_bad_frames += ostat->tx_bad_frames; in jme_stats_update()
3357 jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr, MII_BMCR, BMCR_PDOWN); in jme_phy_down()
3358 if (CHIPMODE_REVFM(sc->jme_chip_rev) >= 5) { in jme_phy_down()
3362 reg = pci_read_config(sc->jme_dev, JME_PCI_PE1, 4); in jme_phy_down()
3365 pci_write_config(sc->jme_dev, JME_PCI_PE1, reg, 4); in jme_phy_down()
3375 bmcr = jme_miibus_readreg(sc->jme_dev, sc->jme_phyaddr, MII_BMCR); in jme_phy_up()
3377 jme_miibus_writereg(sc->jme_dev, sc->jme_phyaddr, MII_BMCR, bmcr); in jme_phy_up()
3378 if (CHIPMODE_REVFM(sc->jme_chip_rev) >= 5) { in jme_phy_up()
3382 reg = pci_read_config(sc->jme_dev, JME_PCI_PE1, 4); in jme_phy_up()
3385 pci_write_config(sc->jme_dev, JME_PCI_PE1, reg, 4); in jme_phy_up()
3398 if (error || req->newptr == NULL) in sysctl_int_range()