Lines Matching +full:report +full:- +full:speed +full:- +full:hz
1 /*-
2 * SPDX-License-Identifier: BSD-4-Clause
4 * Copyright (c) 2008-2010 Nikolay Denev <ndenev@gmail.com>
5 * Copyright (c) 2007-2008 Alexander Pohoyda <alexander.pohoyda@gmx.net>
20 * 4. Neither the name of the author nor the names of any co-contributors
180 #define CSR_WRITE_4(sc, reg, val) bus_write_4(sc->sge_res, reg, val)
181 #define CSR_WRITE_2(sc, reg, val) bus_write_2(sc->sge_res, reg, val)
182 #define CSR_WRITE_1(cs, reg, val) bus_write_1(sc->sge_res, reg, val)
184 #define CSR_READ_4(sc, reg) bus_read_4(sc->sge_res, reg)
185 #define CSR_READ_2(sc, reg) bus_read_2(sc->sge_res, reg)
186 #define CSR_READ_1(sc, reg) bus_read_1(sc->sge_res, reg)
202 *p = segs->ds_addr; in sge_dma_map_addr()
225 device_printf(sc->sge_dev, in sge_read_eeprom()
241 device_printf(sc->sge_dev, in sge_get_mac_addr_eeprom()
253 sc->sge_flags |= SGE_FLAG_RGMII; in sge_get_mac_addr_eeprom()
292 if (pci_get_vendor(dev) == tp->vid && in sge_get_mac_addr_apc()
293 pci_get_device(dev) == tp->did) { in sge_get_mac_addr_apc()
303 device_printf(sc->sge_dev, "couldn't find PCI-ISA bridge\n"); in sge_get_mac_addr_apc()
318 sc->sge_flags |= SGE_FLAG_RGMII; in sge_get_mac_addr_apc()
346 device_printf(sc->sge_dev, "PHY read timeout : %d\n", reg); in sge_miibus_readreg()
371 device_printf(sc->sge_dev, "PHY write timeout : %d\n", reg); in sge_miibus_writereg()
381 uint32_t ctl, speed; in sge_miibus_statchg() local
384 mii = device_get_softc(sc->sge_miibus); in sge_miibus_statchg()
385 ifp = sc->sge_ifp; in sge_miibus_statchg()
389 speed = 0; in sge_miibus_statchg()
390 sc->sge_flags &= ~SGE_FLAG_LINK; in sge_miibus_statchg()
391 if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == in sge_miibus_statchg()
393 switch (IFM_SUBTYPE(mii->mii_media_active)) { in sge_miibus_statchg()
395 sc->sge_flags |= SGE_FLAG_LINK; in sge_miibus_statchg()
396 speed = SC_SPEED_10; in sge_miibus_statchg()
399 sc->sge_flags |= SGE_FLAG_LINK; in sge_miibus_statchg()
400 speed = SC_SPEED_100; in sge_miibus_statchg()
403 if ((sc->sge_flags & SGE_FLAG_FASTETHER) == 0) { in sge_miibus_statchg()
404 sc->sge_flags |= SGE_FLAG_LINK; in sge_miibus_statchg()
405 speed = SC_SPEED_1000; in sge_miibus_statchg()
412 if ((sc->sge_flags & SGE_FLAG_LINK) == 0) in sge_miibus_statchg()
414 /* Reprogram MAC to resolved speed/duplex/flow-control parameters. */ in sge_miibus_statchg()
417 if (speed == SC_SPEED_1000) { in sge_miibus_statchg()
419 sc->sge_flags |= SGE_FLAG_SPEED_1000; in sge_miibus_statchg()
422 sc->sge_flags &= ~SGE_FLAG_SPEED_1000; in sge_miibus_statchg()
425 if ((sc->sge_flags & SGE_FLAG_GMII) != 0) in sge_miibus_statchg()
428 ctl |= speed; in sge_miibus_statchg()
429 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) { in sge_miibus_statchg()
431 sc->sge_flags |= SGE_FLAG_FDX; in sge_miibus_statchg()
433 sc->sge_flags &= ~SGE_FLAG_FDX; in sge_miibus_statchg()
435 if ((sc->sge_flags & SGE_FLAG_RGMII) != 0) { in sge_miibus_statchg()
461 ifp = sc->sge_ifp; in sge_rxfilter()
492 ifp = sc->sge_ifp; in sge_setvlan()
535 while (t->sge_name != NULL) { in sge_probe()
536 if ((pci_get_vendor(dev) == t->sge_vid) && in sge_probe()
537 (pci_get_device(dev) == t->sge_did)) { in sge_probe()
538 device_set_desc(dev, t->sge_name); in sge_probe()
560 sc->sge_dev = dev; in sge_attach()
562 mtx_init(&sc->sge_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, in sge_attach()
564 callout_init_mtx(&sc->sge_stat_ch, &sc->sge_mtx, 0); in sge_attach()
572 sc->sge_res_id = PCIR_BAR(0); in sge_attach()
573 sc->sge_res_type = SYS_RES_MEMORY; in sge_attach()
574 sc->sge_res = bus_alloc_resource_any(dev, sc->sge_res_type, in sge_attach()
575 &sc->sge_res_id, RF_ACTIVE); in sge_attach()
576 if (sc->sge_res == NULL) { in sge_attach()
583 sc->sge_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, in sge_attach()
585 if (sc->sge_irq == NULL) { in sge_attach()
590 sc->sge_rev = pci_get_revid(dev); in sge_attach()
592 sc->sge_flags |= SGE_FLAG_FASTETHER | SGE_FLAG_SIS190; in sge_attach()
605 ifp = sc->sge_ifp = if_alloc(IFT_ETHER); in sge_attach()
612 if_setsendqlen(ifp, SGE_TX_RING_CNT - 1); in sge_attach()
620 error = mii_attach(dev, &sc->sge_miibus, ifp, sge_ifmedia_upd, in sge_attach()
640 error = bus_setup_intr(dev, sc->sge_irq, INTR_TYPE_NET | INTR_MPSAFE, in sge_attach()
641 NULL, sge_intr, sc, &sc->sge_intrhand); in sge_attach()
669 ifp = sc->sge_ifp; in sge_detach()
676 callout_drain(&sc->sge_stat_ch); in sge_detach()
678 if (sc->sge_miibus) in sge_detach()
679 device_delete_child(dev, sc->sge_miibus); in sge_detach()
682 if (sc->sge_intrhand) in sge_detach()
683 bus_teardown_intr(dev, sc->sge_irq, sc->sge_intrhand); in sge_detach()
684 if (sc->sge_irq) in sge_detach()
685 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sge_irq); in sge_detach()
686 if (sc->sge_res) in sge_detach()
687 bus_release_resource(dev, sc->sge_res_type, sc->sge_res_id, in sge_detach()
688 sc->sge_res); in sge_detach()
692 mtx_destroy(&sc->sge_mtx); in sge_detach()
721 ifp = sc->sge_ifp; in sge_suspend()
736 ifp = sc->sge_ifp; in sge_resume()
752 cd = &sc->sge_cdata; in sge_dma_alloc()
753 ld = &sc->sge_ldata; in sge_dma_alloc()
754 error = bus_dma_tag_create(bus_get_dma_tag(sc->sge_dev), in sge_dma_alloc()
765 &cd->sge_tag); in sge_dma_alloc()
767 device_printf(sc->sge_dev, in sge_dma_alloc()
773 error = bus_dma_tag_create(cd->sge_tag, in sge_dma_alloc()
783 &cd->sge_rx_tag); in sge_dma_alloc()
785 device_printf(sc->sge_dev, in sge_dma_alloc()
790 error = bus_dmamem_alloc(cd->sge_rx_tag, (void **)&ld->sge_rx_ring, in sge_dma_alloc()
792 &cd->sge_rx_dmamap); in sge_dma_alloc()
794 device_printf(sc->sge_dev, in sge_dma_alloc()
798 error = bus_dmamap_load(cd->sge_rx_tag, cd->sge_rx_dmamap, in sge_dma_alloc()
799 ld->sge_rx_ring, SGE_RX_RING_SZ, sge_dma_map_addr, in sge_dma_alloc()
800 &ld->sge_rx_paddr, BUS_DMA_NOWAIT); in sge_dma_alloc()
802 device_printf(sc->sge_dev, in sge_dma_alloc()
807 error = bus_dma_tag_create(cd->sge_tag, in sge_dma_alloc()
817 &cd->sge_tx_tag); in sge_dma_alloc()
819 device_printf(sc->sge_dev, in sge_dma_alloc()
824 error = bus_dmamem_alloc(cd->sge_tx_tag, (void **)&ld->sge_tx_ring, in sge_dma_alloc()
826 &cd->sge_tx_dmamap); in sge_dma_alloc()
828 device_printf(sc->sge_dev, in sge_dma_alloc()
832 error = bus_dmamap_load(cd->sge_tx_tag, cd->sge_tx_dmamap, in sge_dma_alloc()
833 ld->sge_tx_ring, SGE_TX_RING_SZ, sge_dma_map_addr, in sge_dma_alloc()
834 &ld->sge_tx_paddr, BUS_DMA_NOWAIT); in sge_dma_alloc()
836 device_printf(sc->sge_dev, in sge_dma_alloc()
842 error = bus_dma_tag_create(cd->sge_tag, 1, 0, BUS_SPACE_MAXADDR, in sge_dma_alloc()
844 SGE_TSO_MAXSEGSIZE, 0, NULL, NULL, &cd->sge_txmbuf_tag); in sge_dma_alloc()
846 device_printf(sc->sge_dev, in sge_dma_alloc()
852 error = bus_dma_tag_create(cd->sge_tag, SGE_RX_BUF_ALIGN, 0, in sge_dma_alloc()
854 MCLBYTES, 0, NULL, NULL, &cd->sge_rxmbuf_tag); in sge_dma_alloc()
856 device_printf(sc->sge_dev, in sge_dma_alloc()
863 txd = &cd->sge_txdesc[i]; in sge_dma_alloc()
864 txd->tx_m = NULL; in sge_dma_alloc()
865 txd->tx_dmamap = NULL; in sge_dma_alloc()
866 txd->tx_ndesc = 0; in sge_dma_alloc()
867 error = bus_dmamap_create(cd->sge_txmbuf_tag, 0, in sge_dma_alloc()
868 &txd->tx_dmamap); in sge_dma_alloc()
870 device_printf(sc->sge_dev, in sge_dma_alloc()
876 error = bus_dmamap_create(cd->sge_rxmbuf_tag, 0, &cd->sge_rx_spare_map); in sge_dma_alloc()
878 device_printf(sc->sge_dev, in sge_dma_alloc()
884 rxd = &cd->sge_rxdesc[i]; in sge_dma_alloc()
885 rxd->rx_m = NULL; in sge_dma_alloc()
886 rxd->rx_dmamap = NULL; in sge_dma_alloc()
887 error = bus_dmamap_create(cd->sge_rxmbuf_tag, 0, in sge_dma_alloc()
888 &rxd->rx_dmamap); in sge_dma_alloc()
890 device_printf(sc->sge_dev, in sge_dma_alloc()
908 cd = &sc->sge_cdata; in sge_dma_free()
909 ld = &sc->sge_ldata; in sge_dma_free()
911 if (cd->sge_rx_tag != NULL) { in sge_dma_free()
912 if (ld->sge_rx_paddr != 0) in sge_dma_free()
913 bus_dmamap_unload(cd->sge_rx_tag, cd->sge_rx_dmamap); in sge_dma_free()
914 if (ld->sge_rx_ring != NULL) in sge_dma_free()
915 bus_dmamem_free(cd->sge_rx_tag, ld->sge_rx_ring, in sge_dma_free()
916 cd->sge_rx_dmamap); in sge_dma_free()
917 ld->sge_rx_ring = NULL; in sge_dma_free()
918 ld->sge_rx_paddr = 0; in sge_dma_free()
919 bus_dma_tag_destroy(cd->sge_rx_tag); in sge_dma_free()
920 cd->sge_rx_tag = NULL; in sge_dma_free()
923 if (cd->sge_tx_tag != NULL) { in sge_dma_free()
924 if (ld->sge_tx_paddr != 0) in sge_dma_free()
925 bus_dmamap_unload(cd->sge_tx_tag, cd->sge_tx_dmamap); in sge_dma_free()
926 if (ld->sge_tx_ring != NULL) in sge_dma_free()
927 bus_dmamem_free(cd->sge_tx_tag, ld->sge_tx_ring, in sge_dma_free()
928 cd->sge_tx_dmamap); in sge_dma_free()
929 ld->sge_tx_ring = NULL; in sge_dma_free()
930 ld->sge_tx_paddr = 0; in sge_dma_free()
931 bus_dma_tag_destroy(cd->sge_tx_tag); in sge_dma_free()
932 cd->sge_tx_tag = NULL; in sge_dma_free()
935 if (cd->sge_rxmbuf_tag != NULL) { in sge_dma_free()
937 rxd = &cd->sge_rxdesc[i]; in sge_dma_free()
938 if (rxd->rx_dmamap != NULL) { in sge_dma_free()
939 bus_dmamap_destroy(cd->sge_rxmbuf_tag, in sge_dma_free()
940 rxd->rx_dmamap); in sge_dma_free()
941 rxd->rx_dmamap = NULL; in sge_dma_free()
944 if (cd->sge_rx_spare_map != NULL) { in sge_dma_free()
945 bus_dmamap_destroy(cd->sge_rxmbuf_tag, in sge_dma_free()
946 cd->sge_rx_spare_map); in sge_dma_free()
947 cd->sge_rx_spare_map = NULL; in sge_dma_free()
949 bus_dma_tag_destroy(cd->sge_rxmbuf_tag); in sge_dma_free()
950 cd->sge_rxmbuf_tag = NULL; in sge_dma_free()
953 if (cd->sge_txmbuf_tag != NULL) { in sge_dma_free()
955 txd = &cd->sge_txdesc[i]; in sge_dma_free()
956 if (txd->tx_dmamap != NULL) { in sge_dma_free()
957 bus_dmamap_destroy(cd->sge_txmbuf_tag, in sge_dma_free()
958 txd->tx_dmamap); in sge_dma_free()
959 txd->tx_dmamap = NULL; in sge_dma_free()
962 bus_dma_tag_destroy(cd->sge_txmbuf_tag); in sge_dma_free()
963 cd->sge_txmbuf_tag = NULL; in sge_dma_free()
965 if (cd->sge_tag != NULL) in sge_dma_free()
966 bus_dma_tag_destroy(cd->sge_tag); in sge_dma_free()
967 cd->sge_tag = NULL; in sge_dma_free()
980 ld = &sc->sge_ldata; in sge_list_tx_init()
981 cd = &sc->sge_cdata; in sge_list_tx_init()
982 bzero(ld->sge_tx_ring, SGE_TX_RING_SZ); in sge_list_tx_init()
983 ld->sge_tx_ring[SGE_TX_RING_CNT - 1].sge_flags = htole32(RING_END); in sge_list_tx_init()
984 bus_dmamap_sync(cd->sge_tx_tag, cd->sge_tx_dmamap, in sge_list_tx_init()
986 cd->sge_tx_prod = 0; in sge_list_tx_init()
987 cd->sge_tx_cons = 0; in sge_list_tx_init()
988 cd->sge_tx_cnt = 0; in sge_list_tx_init()
1000 cd = &sc->sge_cdata; in sge_list_tx_free()
1002 txd = &cd->sge_txdesc[i]; in sge_list_tx_free()
1003 if (txd->tx_m != NULL) { in sge_list_tx_free()
1004 bus_dmamap_sync(cd->sge_txmbuf_tag, txd->tx_dmamap, in sge_list_tx_free()
1006 bus_dmamap_unload(cd->sge_txmbuf_tag, txd->tx_dmamap); in sge_list_tx_free()
1007 m_freem(txd->tx_m); in sge_list_tx_free()
1008 txd->tx_m = NULL; in sge_list_tx_free()
1009 txd->tx_ndesc = 0; in sge_list_tx_free()
1028 cd = &sc->sge_cdata; in sge_list_rx_init()
1029 cd->sge_rx_cons = 0; in sge_list_rx_init()
1030 bzero(sc->sge_ldata.sge_rx_ring, SGE_RX_RING_SZ); in sge_list_rx_init()
1035 bus_dmamap_sync(cd->sge_rx_tag, cd->sge_rx_dmamap, in sge_list_rx_init()
1048 cd = &sc->sge_cdata; in sge_list_rx_free()
1050 rxd = &cd->sge_rxdesc[i]; in sge_list_rx_free()
1051 if (rxd->rx_m != NULL) { in sge_list_rx_free()
1052 bus_dmamap_sync(cd->sge_rxmbuf_tag, rxd->rx_dmamap, in sge_list_rx_free()
1054 bus_dmamap_unload(cd->sge_rxmbuf_tag, in sge_list_rx_free()
1055 rxd->rx_dmamap); in sge_list_rx_free()
1056 m_freem(rxd->rx_m); in sge_list_rx_free()
1057 rxd->rx_m = NULL; in sge_list_rx_free()
1079 cd = &sc->sge_cdata; in sge_newbuf()
1083 m->m_len = m->m_pkthdr.len = MCLBYTES; in sge_newbuf()
1085 error = bus_dmamap_load_mbuf_sg(cd->sge_rxmbuf_tag, in sge_newbuf()
1086 cd->sge_rx_spare_map, m, segs, &nsegs, 0); in sge_newbuf()
1092 rxd = &cd->sge_rxdesc[prod]; in sge_newbuf()
1093 if (rxd->rx_m != NULL) { in sge_newbuf()
1094 bus_dmamap_sync(cd->sge_rxmbuf_tag, rxd->rx_dmamap, in sge_newbuf()
1096 bus_dmamap_unload(cd->sge_rxmbuf_tag, rxd->rx_dmamap); in sge_newbuf()
1098 map = rxd->rx_dmamap; in sge_newbuf()
1099 rxd->rx_dmamap = cd->sge_rx_spare_map; in sge_newbuf()
1100 cd->sge_rx_spare_map = map; in sge_newbuf()
1101 bus_dmamap_sync(cd->sge_rxmbuf_tag, rxd->rx_dmamap, in sge_newbuf()
1103 rxd->rx_m = m; in sge_newbuf()
1105 desc = &sc->sge_ldata.sge_rx_ring[prod]; in sge_newbuf()
1106 desc->sge_sts_size = 0; in sge_newbuf()
1107 desc->sge_ptr = htole32(SGE_ADDR_LO(segs[0].ds_addr)); in sge_newbuf()
1108 desc->sge_flags = htole32(segs[0].ds_len); in sge_newbuf()
1109 if (prod == SGE_RX_RING_CNT - 1) in sge_newbuf()
1110 desc->sge_flags |= htole32(RING_END); in sge_newbuf()
1111 desc->sge_cmdsts = htole32(RDC_OWN | RDC_INTR); in sge_newbuf()
1120 desc = &sc->sge_ldata.sge_rx_ring[index]; in sge_discard_rxbuf()
1121 desc->sge_sts_size = 0; in sge_discard_rxbuf()
1122 desc->sge_flags = htole32(MCLBYTES - SGE_RX_BUF_ALIGN); in sge_discard_rxbuf()
1123 if (index == SGE_RX_RING_CNT - 1) in sge_discard_rxbuf()
1124 desc->sge_flags |= htole32(RING_END); in sge_discard_rxbuf()
1125 desc->sge_cmdsts = htole32(RDC_OWN | RDC_INTR); in sge_discard_rxbuf()
1144 ifp = sc->sge_ifp; in sge_rxeof()
1145 cd = &sc->sge_cdata; in sge_rxeof()
1147 bus_dmamap_sync(cd->sge_rx_tag, cd->sge_rx_dmamap, in sge_rxeof()
1149 cons = cd->sge_rx_cons; in sge_rxeof()
1154 cur_rx = &sc->sge_ldata.sge_rx_ring[cons]; in sge_rxeof()
1155 rxinfo = le32toh(cur_rx->sge_cmdsts); in sge_rxeof()
1158 rxstat = le32toh(cur_rx->sge_sts_size); in sge_rxeof()
1161 /* XXX We don't support multi-segment frames yet. */ in sge_rxeof()
1163 device_printf(sc->sge_dev, "Rx error : 0x%b\n", rxstat, in sge_rxeof()
1170 m = cd->sge_rxdesc[cons].rx_m; in sge_rxeof()
1179 m->m_pkthdr.csum_flags |= in sge_rxeof()
1185 m->m_pkthdr.csum_flags |= in sge_rxeof()
1187 m->m_pkthdr.csum_data = 0xffff; in sge_rxeof()
1193 m->m_pkthdr.ether_vtag = rxinfo & RDC_VLAN_MASK; in sge_rxeof()
1194 m->m_flags |= M_VLANTAG; in sge_rxeof()
1202 m->m_data += SGE_RX_PAD_BYTES; in sge_rxeof()
1203 m->m_pkthdr.len = m->m_len = SGE_RX_BYTES(rxstat) - in sge_rxeof()
1205 m->m_pkthdr.rcvif = ifp; in sge_rxeof()
1213 bus_dmamap_sync(cd->sge_rx_tag, cd->sge_rx_dmamap, in sge_rxeof()
1215 cd->sge_rx_cons = cons; in sge_rxeof()
1235 ifp = sc->sge_ifp; in sge_txeof()
1236 ld = &sc->sge_ldata; in sge_txeof()
1237 cd = &sc->sge_cdata; in sge_txeof()
1239 if (cd->sge_tx_cnt == 0) in sge_txeof()
1241 bus_dmamap_sync(cd->sge_tx_tag, cd->sge_tx_dmamap, in sge_txeof()
1243 cons = cd->sge_tx_cons; in sge_txeof()
1244 prod = cd->sge_tx_prod; in sge_txeof()
1246 txstat = le32toh(ld->sge_tx_ring[cons].sge_cmdsts); in sge_txeof()
1250 * Only the first descriptor of multi-descriptor transmission in sge_txeof()
1254 * multi-descriptor transmission. in sge_txeof()
1258 device_printf(sc->sge_dev, "Tx error : 0x%b\n", in sge_txeof()
1264 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, (txstat & 0xFFFF) - 1); in sge_txeof()
1268 txd = &cd->sge_txdesc[cons]; in sge_txeof()
1269 for (nsegs = 0; nsegs < txd->tx_ndesc; nsegs++) { in sge_txeof()
1270 ld->sge_tx_ring[cons].sge_cmdsts = 0; in sge_txeof()
1274 KASSERT(txd->tx_m != NULL, in sge_txeof()
1276 bus_dmamap_sync(cd->sge_txmbuf_tag, txd->tx_dmamap, in sge_txeof()
1278 bus_dmamap_unload(cd->sge_txmbuf_tag, txd->tx_dmamap); in sge_txeof()
1279 m_freem(txd->tx_m); in sge_txeof()
1280 txd->tx_m = NULL; in sge_txeof()
1281 cd->sge_tx_cnt -= txd->tx_ndesc; in sge_txeof()
1282 KASSERT(cd->sge_tx_cnt >= 0, in sge_txeof()
1284 txd->tx_ndesc = 0; in sge_txeof()
1287 cd->sge_tx_cons = cons; in sge_txeof()
1288 if (cd->sge_tx_cnt == 0) in sge_txeof()
1289 sc->sge_timer = 0; in sge_txeof()
1302 ifp = sc->sge_ifp; in sge_tick()
1303 mii = device_get_softc(sc->sge_miibus); in sge_tick()
1305 if ((sc->sge_flags & SGE_FLAG_LINK) == 0) { in sge_tick()
1306 sge_miibus_statchg(sc->sge_dev); in sge_tick()
1307 if ((sc->sge_flags & SGE_FLAG_LINK) != 0 && in sge_tick()
1318 callout_reset(&sc->sge_stat_ch, hz, sge_tick, sc); in sge_tick()
1330 ifp = sc->sge_ifp; in sge_intr()
1370 /* Re-enable interrupts */ in sge_intr()
1394 si = prod = sc->sge_cdata.sge_tx_prod; in sge_encap()
1395 txd = &sc->sge_cdata.sge_txdesc[prod]; in sge_encap()
1396 if (((*m_head)->m_pkthdr.csum_flags & CSUM_TSO) != 0) { in sge_encap()
1420 if (eh->ether_type == htons(ETHERTYPE_VLAN)) { in sge_encap()
1434 poff = ip_off + (ip->ip_hl << 2); in sge_encap()
1441 m = m_pullup(m, poff + (tcp->th_off << 2)); in sge_encap()
1451 ip->ip_sum = 0; in sge_encap()
1453 tcp->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, in sge_encap()
1458 error = bus_dmamap_load_mbuf_sg(sc->sge_cdata.sge_txmbuf_tag, in sge_encap()
1459 txd->tx_dmamap, *m_head, txsegs, &nsegs, 0); in sge_encap()
1468 error = bus_dmamap_load_mbuf_sg(sc->sge_cdata.sge_txmbuf_tag, in sge_encap()
1469 txd->tx_dmamap, *m_head, txsegs, &nsegs, 0); in sge_encap()
1480 if (sc->sge_cdata.sge_tx_cnt + nsegs >= SGE_TX_RING_CNT) { in sge_encap()
1481 bus_dmamap_unload(sc->sge_cdata.sge_txmbuf_tag, txd->tx_dmamap); in sge_encap()
1484 bus_dmamap_sync(sc->sge_cdata.sge_txmbuf_tag, txd->tx_dmamap, in sge_encap()
1490 if ((m->m_pkthdr.csum_flags & CSUM_TSO) != 0) { in sge_encap()
1492 mss = (uint32_t)m->m_pkthdr.tso_segsz; in sge_encap()
1495 if (m->m_pkthdr.csum_flags & CSUM_IP) in sge_encap()
1497 if (m->m_pkthdr.csum_flags & CSUM_TCP) in sge_encap()
1499 if (m->m_pkthdr.csum_flags & CSUM_UDP) in sge_encap()
1503 desc = &sc->sge_ldata.sge_tx_ring[prod]; in sge_encap()
1505 desc->sge_sts_size = htole32(m->m_pkthdr.len | mss); in sge_encap()
1506 desc->sge_cmdsts = 0; in sge_encap()
1508 desc->sge_sts_size = 0; in sge_encap()
1509 desc->sge_cmdsts = htole32(TDC_OWN); in sge_encap()
1511 desc->sge_ptr = htole32(SGE_ADDR_LO(txsegs[i].ds_addr)); in sge_encap()
1512 desc->sge_flags = htole32(txsegs[i].ds_len); in sge_encap()
1513 if (prod == SGE_TX_RING_CNT - 1) in sge_encap()
1514 desc->sge_flags |= htole32(RING_END); in sge_encap()
1515 sc->sge_cdata.sge_tx_cnt++; in sge_encap()
1519 sc->sge_cdata.sge_tx_prod = prod; in sge_encap()
1521 desc = &sc->sge_ldata.sge_tx_ring[si]; in sge_encap()
1523 if((m->m_flags & M_VLANTAG) != 0) { in sge_encap()
1524 cflags |= m->m_pkthdr.ether_vtag; in sge_encap()
1525 desc->sge_sts_size |= htole32(TDS_INS_VLAN); in sge_encap()
1527 desc->sge_cmdsts |= htole32(TDC_DEF | TDC_CRC | TDC_PAD | cflags); in sge_encap()
1529 if ((sc->sge_flags & SGE_FLAG_SPEED_1000) != 0) in sge_encap()
1530 desc->sge_cmdsts |= htole32(TDC_BST); in sge_encap()
1532 if ((sc->sge_flags & SGE_FLAG_FDX) == 0) { in sge_encap()
1533 desc->sge_cmdsts |= htole32(TDC_COL | TDC_CRS | TDC_BKF); in sge_encap()
1534 if ((sc->sge_flags & SGE_FLAG_SPEED_1000) != 0) in sge_encap()
1535 desc->sge_cmdsts |= htole32(TDC_EXT | TDC_BST); in sge_encap()
1539 desc->sge_cmdsts |= htole32(TDC_OWN | TDC_INTR); in sge_encap()
1540 txd->tx_m = m; in sge_encap()
1541 txd->tx_ndesc = nsegs; in sge_encap()
1566 if ((sc->sge_flags & SGE_FLAG_LINK) == 0 || in sge_start_locked()
1572 if (sc->sge_cdata.sge_tx_cnt > (SGE_TX_RING_CNT - in sge_start_locked()
1596 bus_dmamap_sync(sc->sge_cdata.sge_tx_tag, in sge_start_locked()
1597 sc->sge_cdata.sge_tx_dmamap, in sge_start_locked()
1600 sc->sge_timer = 5; in sge_start_locked()
1624 ifp = sc->sge_ifp; in sge_init_locked()
1625 mii = device_get_softc(sc->sge_miibus); in sge_init_locked()
1636 device_printf(sc->sge_dev, "no memory for Rx buffers\n"); in sge_init_locked()
1645 CSR_WRITE_4(sc, TX_DESC, SGE_ADDR_LO(sc->sge_ldata.sge_tx_paddr)); in sge_init_locked()
1646 CSR_WRITE_4(sc, RX_DESC, SGE_ADDR_LO(sc->sge_ldata.sge_rx_paddr)); in sge_init_locked()
1663 /* Initialize default speed/duplex information. */ in sge_init_locked()
1664 if ((sc->sge_flags & SGE_FLAG_FASTETHER) == 0) in sge_init_locked()
1665 sc->sge_flags |= SGE_FLAG_SPEED_1000; in sge_init_locked()
1666 sc->sge_flags |= SGE_FLAG_FDX; in sge_init_locked()
1667 if ((sc->sge_flags & SGE_FLAG_RGMII) != 0) in sge_init_locked()
1676 if (sc->sge_intrcontrol != 0) in sge_init_locked()
1677 CSR_WRITE_4(sc, IntrControl, sc->sge_intrcontrol); in sge_init_locked()
1678 if (sc->sge_intrtimer != 0) in sge_init_locked()
1679 CSR_WRITE_4(sc, IntrTimer, sc->sge_intrtimer); in sge_init_locked()
1695 sc->sge_flags &= ~SGE_FLAG_LINK; in sge_init_locked()
1697 callout_reset(&sc->sge_stat_ch, hz, sge_tick, sc); in sge_init_locked()
1713 mii = device_get_softc(sc->sge_miibus); in sge_ifmedia_upd()
1714 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) in sge_ifmedia_upd()
1723 * Report current media status.
1733 mii = device_get_softc(sc->sge_miibus); in sge_ifmedia_sts()
1739 ifmr->ifm_active = mii->mii_media_active; in sge_ifmedia_sts()
1740 ifmr->ifm_status = mii->mii_media_status; in sge_ifmedia_sts()
1760 ((if_getflags(ifp) ^ sc->sge_if_flags) & in sge_ioctl()
1767 sc->sge_if_flags = if_getflags(ifp); in sge_ioctl()
1773 mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); in sge_ioctl()
1827 mii = device_get_softc(sc->sge_miibus); in sge_ioctl()
1828 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); in sge_ioctl()
1844 if (sc->sge_timer == 0 || --sc->sge_timer > 0) in sge_watchdog()
1847 ifp = sc->sge_ifp; in sge_watchdog()
1848 if ((sc->sge_flags & SGE_FLAG_LINK) == 0) { in sge_watchdog()
1850 device_printf(sc->sge_dev, in sge_watchdog()
1857 device_printf(sc->sge_dev, "watchdog timeout\n"); in sge_watchdog()
1862 if (!if_sendq_empty(sc->sge_ifp)) in sge_watchdog()
1875 ifp = sc->sge_ifp; in sge_stop()
1879 sc->sge_timer = 0; in sge_stop()
1880 callout_stop(&sc->sge_stat_ch); in sge_stop()
1894 sc->sge_flags &= ~SGE_FLAG_LINK; in sge_stop()