Lines Matching +full:disable +full:- +full:eop

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
5 * Copyright (c) 2001-2003 Thomas Moestl
42 #if 0 /* XXX: In case of emergency, re-enable this. */
128 static void gem_stop(if_t ifp, int disable);
151 device_printf(sc->sc_dev, "flags=0x%x\n", sc->sc_flags); in gem_attach()
154 ifp = sc->sc_ifp = if_alloc(IFT_ETHER); in gem_attach()
155 sc->sc_csum_features = GEM_CSUM_FEATURES; in gem_attach()
157 if_initname(ifp, device_get_name(sc->sc_dev), in gem_attach()
158 device_get_unit(sc->sc_dev)); in gem_attach()
166 callout_init_mtx(&sc->sc_tick_ch, &sc->sc_mtx, 0); in gem_attach()
168 callout_init_mtx(&sc->sc_rx_ch, &sc->sc_mtx, 0); in gem_attach()
174 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, in gem_attach()
177 NULL, &sc->sc_pdmatag); in gem_attach()
181 error = bus_dma_tag_create(sc->sc_pdmatag, 1, 0, in gem_attach()
183 1, MCLBYTES, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->sc_rdmatag); in gem_attach()
187 error = bus_dma_tag_create(sc->sc_pdmatag, 1, 0, in gem_attach()
190 BUS_DMA_ALLOCNOW, NULL, NULL, &sc->sc_tdmatag); in gem_attach()
194 error = bus_dma_tag_create(sc->sc_pdmatag, PAGE_SIZE, 0, in gem_attach()
198 NULL, NULL, &sc->sc_cdmatag); in gem_attach()
206 if ((error = bus_dmamem_alloc(sc->sc_cdmatag, in gem_attach()
207 (void **)&sc->sc_control_data, in gem_attach()
209 &sc->sc_cddmamap)) != 0) { in gem_attach()
210 device_printf(sc->sc_dev, in gem_attach()
215 sc->sc_cddma = 0; in gem_attach()
216 if ((error = bus_dmamap_load(sc->sc_cdmatag, sc->sc_cddmamap, in gem_attach()
217 sc->sc_control_data, sizeof(struct gem_control_data), in gem_attach()
218 gem_cddma_callback, sc, 0)) != 0 || sc->sc_cddma == 0) { in gem_attach()
219 device_printf(sc->sc_dev, in gem_attach()
228 STAILQ_INIT(&sc->sc_txfreeq); in gem_attach()
229 STAILQ_INIT(&sc->sc_txdirtyq); in gem_attach()
236 txs = &sc->sc_txsoft[i]; in gem_attach()
237 txs->txs_mbuf = NULL; in gem_attach()
238 txs->txs_ndescs = 0; in gem_attach()
239 if ((error = bus_dmamap_create(sc->sc_tdmatag, 0, in gem_attach()
240 &txs->txs_dmamap)) != 0) { in gem_attach()
241 device_printf(sc->sc_dev, in gem_attach()
246 STAILQ_INSERT_TAIL(&sc->sc_txfreeq, txs, txs_q); in gem_attach()
253 if ((error = bus_dmamap_create(sc->sc_rdmatag, 0, in gem_attach()
254 &sc->sc_rxsoft[i].rxs_dmamap)) != 0) { in gem_attach()
255 device_printf(sc->sc_dev, in gem_attach()
260 sc->sc_rxsoft[i].rxs_mbuf = NULL; in gem_attach()
264 if ((sc->sc_flags & GEM_SERDES) != 0) in gem_attach()
283 error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp, in gem_attach()
299 switch (sc->sc_variant) { in gem_attach()
310 error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp, in gem_attach()
318 if (error != 0 && sc->sc_variant == GEM_SUN_GEM) { in gem_attach()
331 sc->sc_flags |= GEM_SERDES; in gem_attach()
332 error = mii_attach(sc->sc_dev, &sc->sc_miibus, ifp, in gem_attach()
337 device_printf(sc->sc_dev, "attaching PHYs failed\n"); in gem_attach()
340 sc->sc_mii = device_get_softc(sc->sc_miibus); in gem_attach()
349 sc->sc_rxfifosize = 64 * in gem_attach()
354 device_printf(sc->sc_dev, "%ukB RX FIFO, %ukB TX FIFO\n", in gem_attach()
355 sc->sc_rxfifosize / 1024, v / 16); in gem_attach()
358 ether_ifattach(ifp, sc->sc_enaddr); in gem_attach()
365 if_sethwassistbits(ifp, sc->sc_csum_features, 0); in gem_attach()
376 if (sc->sc_rxsoft[i].rxs_dmamap != NULL) in gem_attach()
377 bus_dmamap_destroy(sc->sc_rdmatag, in gem_attach()
378 sc->sc_rxsoft[i].rxs_dmamap); in gem_attach()
381 if (sc->sc_txsoft[i].txs_dmamap != NULL) in gem_attach()
382 bus_dmamap_destroy(sc->sc_tdmatag, in gem_attach()
383 sc->sc_txsoft[i].txs_dmamap); in gem_attach()
384 bus_dmamap_unload(sc->sc_cdmatag, sc->sc_cddmamap); in gem_attach()
386 bus_dmamem_free(sc->sc_cdmatag, sc->sc_control_data, in gem_attach()
387 sc->sc_cddmamap); in gem_attach()
389 bus_dma_tag_destroy(sc->sc_cdmatag); in gem_attach()
391 bus_dma_tag_destroy(sc->sc_tdmatag); in gem_attach()
393 bus_dma_tag_destroy(sc->sc_rdmatag); in gem_attach()
395 bus_dma_tag_destroy(sc->sc_pdmatag); in gem_attach()
404 if_t ifp = sc->sc_ifp; in gem_detach()
411 callout_drain(&sc->sc_tick_ch); in gem_detach()
413 callout_drain(&sc->sc_rx_ch); in gem_detach()
416 bus_generic_detach(sc->sc_dev); in gem_detach()
419 if (sc->sc_rxsoft[i].rxs_dmamap != NULL) in gem_detach()
420 bus_dmamap_destroy(sc->sc_rdmatag, in gem_detach()
421 sc->sc_rxsoft[i].rxs_dmamap); in gem_detach()
423 if (sc->sc_txsoft[i].txs_dmamap != NULL) in gem_detach()
424 bus_dmamap_destroy(sc->sc_tdmatag, in gem_detach()
425 sc->sc_txsoft[i].txs_dmamap); in gem_detach()
427 bus_dmamap_unload(sc->sc_cdmatag, sc->sc_cddmamap); in gem_detach()
428 bus_dmamem_free(sc->sc_cdmatag, sc->sc_control_data, in gem_detach()
429 sc->sc_cddmamap); in gem_detach()
430 bus_dma_tag_destroy(sc->sc_cdmatag); in gem_detach()
431 bus_dma_tag_destroy(sc->sc_tdmatag); in gem_detach()
432 bus_dma_tag_destroy(sc->sc_rdmatag); in gem_detach()
433 bus_dma_tag_destroy(sc->sc_pdmatag); in gem_detach()
439 if_t ifp = sc->sc_ifp; in gem_suspend()
449 if_t ifp = sc->sc_ifp; in gem_resume()
454 * after power-on. in gem_resume()
456 sc->sc_flags &= ~GEM_INITED; in gem_resume()
473 pktlen = m->m_pkthdr.len; in gem_rxcksum()
477 if (eh->ether_type != htons(ETHERTYPE_IP)) in gem_rxcksum()
480 if (ip->ip_v != IPVERSION) in gem_rxcksum()
483 hlen = ip->ip_hl << 2; in gem_rxcksum()
484 pktlen -= sizeof(struct ether_header); in gem_rxcksum()
487 if (ntohs(ip->ip_len) < hlen) in gem_rxcksum()
489 if (ntohs(ip->ip_len) != pktlen) in gem_rxcksum()
491 if (ip->ip_off & htons(IP_MF | IP_OFFMASK)) in gem_rxcksum()
494 switch (ip->ip_p) { in gem_rxcksum()
503 if (uh->uh_sum == 0) in gem_rxcksum()
512 len = hlen - sizeof(struct ip); in gem_rxcksum()
515 for (; len > 0; len -= sizeof(uint16_t), opts++) { in gem_rxcksum()
516 temp32 = cksum - *opts; in gem_rxcksum()
521 m->m_pkthdr.csum_flags |= CSUM_DATA_VALID; in gem_rxcksum()
522 m->m_pkthdr.csum_data = cksum; in gem_rxcksum()
534 sc->sc_cddma = segs[0].ds_addr; in gem_cddma_callback()
541 if_t ifp = sc->sc_ifp; in gem_tick()
574 mii_tick(sc->sc_mii); in gem_tick()
579 callout_reset(&sc->sc_tick_ch, hz, gem_tick, sc); in gem_tick()
588 for (i = GEM_TRIES; i--; DELAY(100)) { in gem_bitwait()
601 CTR2(KTR_GEM, "%s: %s", device_get_name(sc->sc_dev), __func__); in gem_reset()
611 device_printf(sc->sc_dev, "cannot reset device\n"); in gem_reset()
621 rxs = &sc->sc_rxsoft[i]; in gem_rxdrain()
622 if (rxs->rxs_mbuf != NULL) { in gem_rxdrain()
623 bus_dmamap_sync(sc->sc_rdmatag, rxs->rxs_dmamap, in gem_rxdrain()
625 bus_dmamap_unload(sc->sc_rdmatag, rxs->rxs_dmamap); in gem_rxdrain()
626 m_freem(rxs->rxs_mbuf); in gem_rxdrain()
627 rxs->rxs_mbuf = NULL; in gem_rxdrain()
633 gem_stop(if_t ifp, int disable) in gem_stop() argument
639 CTR2(KTR_GEM, "%s: %s", device_get_name(sc->sc_dev), __func__); in gem_stop()
642 callout_stop(&sc->sc_tick_ch); in gem_stop()
644 callout_stop(&sc->sc_rx_ch); in gem_stop()
653 while ((txs = STAILQ_FIRST(&sc->sc_txdirtyq)) != NULL) { in gem_stop()
654 STAILQ_REMOVE_HEAD(&sc->sc_txdirtyq, txs_q); in gem_stop()
655 if (txs->txs_ndescs != 0) { in gem_stop()
656 bus_dmamap_sync(sc->sc_tdmatag, txs->txs_dmamap, in gem_stop()
658 bus_dmamap_unload(sc->sc_tdmatag, txs->txs_dmamap); in gem_stop()
659 if (txs->txs_mbuf != NULL) { in gem_stop()
660 m_freem(txs->txs_mbuf); in gem_stop()
661 txs->txs_mbuf = NULL; in gem_stop()
664 STAILQ_INSERT_TAIL(&sc->sc_txfreeq, txs, txs_q); in gem_stop()
667 if (disable) in gem_stop()
674 sc->sc_flags &= ~GEM_LINK; in gem_stop()
675 sc->sc_wdog_timer = 0; in gem_stop()
684 * disable DMA first. in gem_reset_rx()
691 device_printf(sc->sc_dev, "cannot disable RX DMA\n"); in gem_reset_rx()
701 device_printf(sc->sc_dev, "cannot reset receiver\n"); in gem_reset_rx()
710 device_printf(sc->sc_dev, "cannot reset RX MAC\n"); in gem_reset_rx()
730 if_setdrvflagbits(sc->sc_ifp, 0, IFF_DRV_RUNNING); in gem_reset_rxdma()
734 if (sc->sc_rxsoft[i].rxs_mbuf != NULL) in gem_reset_rxdma()
736 sc->sc_rxptr = 0; in gem_reset_rxdma()
739 /* NOTE: we use only 32-bit DMA addresses here. */ in gem_reset_rxdma()
742 GEM_WRITE_4(sc, GEM_RX_KICK, GEM_NRXDESC - 4); in gem_reset_rxdma()
750 ((6 * (sc->sc_flags & GEM_PCI66) != 0 ? 2 : 1) << in gem_reset_rxdma()
753 (3 * sc->sc_rxfifosize / 256) | in gem_reset_rxdma()
754 ((sc->sc_rxfifosize / 256) << 12)); in gem_reset_rxdma()
772 * disable DMA first. in gem_reset_tx()
779 device_printf(sc->sc_dev, "cannot disable TX DMA\n"); in gem_reset_tx()
789 device_printf(sc->sc_dev, "cannot reset transmitter\n"); in gem_reset_tx()
805 device_printf(sc->sc_dev, "cannot disable RX MAC\n"); in gem_disable_rx()
819 device_printf(sc->sc_dev, "cannot disable TX MAC\n"); in gem_disable_tx()
835 sc->sc_txdescs[i].gd_flags = 0; in gem_meminit()
836 sc->sc_txdescs[i].gd_addr = 0; in gem_meminit()
838 sc->sc_txfree = GEM_MAXTXFREE; in gem_meminit()
839 sc->sc_txnext = 0; in gem_meminit()
840 sc->sc_txwin = 0; in gem_meminit()
847 rxs = &sc->sc_rxsoft[i]; in gem_meminit()
848 if (rxs->rxs_mbuf == NULL) { in gem_meminit()
850 device_printf(sc->sc_dev, in gem_meminit()
863 sc->sc_rxptr = 0; in gem_meminit()
916 if_t ifp = sc->sc_ifp; in gem_init_locked()
925 CTR2(KTR_GEM, "%s: %s: calling stop", device_get_name(sc->sc_dev), in gem_init_locked()
932 * See also the STP2002-STQ document from Sun Microsystems. in gem_init_locked()
939 CTR2(KTR_GEM, "%s: %s: restarting", device_get_name(sc->sc_dev), in gem_init_locked()
943 if ((sc->sc_flags & GEM_SERDES) == 0) in gem_init_locked()
944 /* Re-initialize the MIF. */ in gem_init_locked()
957 /* NOTE: we use only 32-bit DMA addresses here. */ in gem_init_locked()
965 GEM_CDRXADDR(sc, 0), GEM_CDTXADDR(sc, 0), sc->sc_cddma); in gem_init_locked()
1025 ((6 * (sc->sc_flags & GEM_PCI66) != 0 ? 2 : 1) << in gem_init_locked()
1033 (3 * sc->sc_rxfifosize / 256) | in gem_init_locked()
1034 ((sc->sc_rxfifosize / 256) << 12)); in gem_init_locked()
1042 sc->sc_mac_rxcfg = v; in gem_init_locked()
1058 GEM_WRITE_4(sc, GEM_RX_KICK, GEM_NRXDESC - 4); in gem_init_locked()
1063 mii_mediachg(sc->sc_mii); in gem_init_locked()
1066 sc->sc_wdog_timer = 0; in gem_init_locked()
1067 callout_reset(&sc->sc_tick_ch, hz, gem_tick, sc); in gem_init_locked()
1083 if ((txs = STAILQ_FIRST(&sc->sc_txfreeq)) == NULL) { in gem_load_txmbuf()
1089 if (((*m_head)->m_pkthdr.csum_flags & sc->sc_csum_features) != 0) { in gem_load_txmbuf()
1104 offset += (ip->ip_hl << 2); in gem_load_txmbuf()
1106 ((offset + m->m_pkthdr.csum_data) << in gem_load_txmbuf()
1111 error = bus_dmamap_load_mbuf_sg(sc->sc_tdmatag, txs->txs_dmamap, in gem_load_txmbuf()
1121 error = bus_dmamap_load_mbuf_sg(sc->sc_tdmatag, in gem_load_txmbuf()
1122 txs->txs_dmamap, *m_head, txsegs, &nsegs, in gem_load_txmbuf()
1144 * order to prevent wrap-around. in gem_load_txmbuf()
1146 if (nsegs > sc->sc_txfree - 1) { in gem_load_txmbuf()
1147 txs->txs_ndescs = 0; in gem_load_txmbuf()
1148 bus_dmamap_unload(sc->sc_tdmatag, txs->txs_dmamap); in gem_load_txmbuf()
1152 txs->txs_ndescs = nsegs; in gem_load_txmbuf()
1153 txs->txs_firstdesc = sc->sc_txnext; in gem_load_txmbuf()
1154 nexttx = txs->txs_firstdesc; in gem_load_txmbuf()
1162 sc->sc_txdescs[nexttx].gd_addr = htole64(txsegs[seg].ds_addr); in gem_load_txmbuf()
1166 sc->sc_txdescs[nexttx].gd_flags = htole64(flags | cflags); in gem_load_txmbuf()
1167 txs->txs_lastdesc = nexttx; in gem_load_txmbuf()
1170 /* Set EOP on the last descriptor. */ in gem_load_txmbuf()
1175 sc->sc_txdescs[txs->txs_lastdesc].gd_flags |= in gem_load_txmbuf()
1183 if (++sc->sc_txwin > GEM_NTXSEGS * 2 / 3) { in gem_load_txmbuf()
1184 sc->sc_txwin = 0; in gem_load_txmbuf()
1185 sc->sc_txdescs[txs->txs_firstdesc].gd_flags |= in gem_load_txmbuf()
1188 sc->sc_txdescs[txs->txs_firstdesc].gd_flags |= in gem_load_txmbuf()
1192 bus_dmamap_sync(sc->sc_tdmatag, txs->txs_dmamap, in gem_load_txmbuf()
1197 __func__, txs->txs_firstdesc, txs->txs_lastdesc, in gem_load_txmbuf()
1198 txs->txs_ndescs); in gem_load_txmbuf()
1200 STAILQ_REMOVE_HEAD(&sc->sc_txfreeq, txs_q); in gem_load_txmbuf()
1201 STAILQ_INSERT_TAIL(&sc->sc_txdirtyq, txs, txs_q); in gem_load_txmbuf()
1202 txs->txs_mbuf = *m_head; in gem_load_txmbuf()
1204 sc->sc_txnext = GEM_NEXTTX(txs->txs_lastdesc); in gem_load_txmbuf()
1205 sc->sc_txfree -= txs->txs_ndescs; in gem_load_txmbuf()
1213 const u_char *laddr = if_getlladdr(sc->sc_ifp); in gem_init_regs()
1218 if ((sc->sc_flags & GEM_INITED) == 0) { in gem_init_regs()
1257 sc->sc_flags |= GEM_INITED; in gem_init_regs()
1307 device_get_name(sc->sc_dev), __func__, sc->sc_txnext); in gem_txkick()
1310 GEM_WRITE_4(sc, GEM_TX_KICK, sc->sc_txnext); in gem_txkick()
1323 IFF_DRV_RUNNING || (sc->sc_flags & GEM_LINK) == 0) in gem_start_locked()
1328 device_get_name(sc->sc_dev), __func__, sc->sc_txfree, in gem_start_locked()
1329 sc->sc_txnext); in gem_start_locked()
1333 for (; !if_sendq_empty(ifp) && sc->sc_txfree > 1;) { in gem_start_locked()
1344 if ((sc->sc_txnext % 4) == 0) { in gem_start_locked()
1358 device_get_name(sc->sc_dev), sc->sc_txnext); in gem_start_locked()
1362 sc->sc_wdog_timer = 5; in gem_start_locked()
1365 device_get_name(sc->sc_dev), __func__, in gem_start_locked()
1366 sc->sc_wdog_timer); in gem_start_locked()
1374 if_t ifp = sc->sc_ifp; in gem_tint()
1383 CTR2(KTR_GEM, "%s: %s", device_get_name(sc->sc_dev), __func__); in gem_tint()
1392 while ((txs = STAILQ_FIRST(&sc->sc_txdirtyq)) != NULL) { in gem_tint()
1396 for (i = txs->txs_firstdesc;; i = GEM_NEXTTX(i)) { in gem_tint()
1400 sc->sc_txdescs[i].gd_flags)); in gem_tint()
1403 sc->sc_txdescs[i].gd_addr)); in gem_tint()
1404 if (i == txs->txs_lastdesc) in gem_tint()
1419 CTR4(KTR_GEM, "%s: txs->txs_firstdesc = %d, " in gem_tint()
1420 "txs->txs_lastdesc = %d, txlast = %d", in gem_tint()
1421 __func__, txs->txs_firstdesc, txs->txs_lastdesc, txlast); in gem_tint()
1423 if (txs->txs_firstdesc <= txs->txs_lastdesc) { in gem_tint()
1424 if ((txlast >= txs->txs_firstdesc) && in gem_tint()
1425 (txlast <= txs->txs_lastdesc)) in gem_tint()
1428 /* Ick -- this command wraps. */ in gem_tint()
1429 if ((txlast >= txs->txs_firstdesc) || in gem_tint()
1430 (txlast <= txs->txs_lastdesc)) in gem_tint()
1437 STAILQ_REMOVE_HEAD(&sc->sc_txdirtyq, txs_q); in gem_tint()
1439 sc->sc_txfree += txs->txs_ndescs; in gem_tint()
1441 bus_dmamap_sync(sc->sc_tdmatag, txs->txs_dmamap, in gem_tint()
1443 bus_dmamap_unload(sc->sc_tdmatag, txs->txs_dmamap); in gem_tint()
1444 if (txs->txs_mbuf != NULL) { in gem_tint()
1445 m_freem(txs->txs_mbuf); in gem_tint()
1446 txs->txs_mbuf = NULL; in gem_tint()
1449 STAILQ_INSERT_TAIL(&sc->sc_txfreeq, txs, txs_q); in gem_tint()
1465 if (sc->sc_txfree == GEM_NTXDESC - 1) in gem_tint()
1466 sc->sc_txwin = 0; in gem_tint()
1473 if (STAILQ_EMPTY(&sc->sc_txdirtyq)) in gem_tint()
1474 sc->sc_wdog_timer = 0; in gem_tint()
1480 device_get_name(sc->sc_dev), __func__, sc->sc_wdog_timer); in gem_tint()
1499 if_t ifp = sc->sc_ifp; in gem_rint()
1507 callout_stop(&sc->sc_rx_ch); in gem_rint()
1510 CTR2(KTR_GEM, "%s: %s", device_get_name(sc->sc_dev), __func__); in gem_rint()
1519 CTR3(KTR_GEM, "%s: sc->sc_rxptr %d, complete %d", in gem_rint()
1520 __func__, sc->sc_rxptr, rxcomp); in gem_rint()
1523 for (; sc->sc_rxptr != rxcomp;) { in gem_rint()
1524 m = sc->sc_rxsoft[sc->sc_rxptr].rxs_mbuf; in gem_rint()
1525 rxstat = le64toh(sc->sc_rxdescs[sc->sc_rxptr].gd_flags); in gem_rint()
1537 callout_reset(&sc->sc_rx_ch, GEM_RXOWN_TICKS, in gem_rint()
1546 device_printf(sc->sc_dev, "receive error: CRC error\n"); in gem_rint()
1547 GEM_INIT_RXDESC(sc, sc->sc_rxptr); in gem_rint()
1555 &sc->sc_rxsoft[sc->sc_rxptr], sc->sc_rxptr); in gem_rint()
1558 sc->sc_rxdescs[sc->sc_rxptr].gd_flags)); in gem_rint()
1561 sc->sc_rxdescs[sc->sc_rxptr].gd_addr)); in gem_rint()
1570 if (gem_add_rxbuf(sc, sc->sc_rxptr) != 0) { in gem_rint()
1572 GEM_INIT_RXDESC(sc, sc->sc_rxptr); in gem_rint()
1584 sc->sc_rxptr = GEM_NEXTRX(sc->sc_rxptr); in gem_rint()
1585 if ((sc->sc_rxptr % 4) == 0) { in gem_rint()
1589 (sc->sc_rxptr + GEM_NRXDESC - 4) & in gem_rint()
1600 m->m_data += ETHER_ALIGN; /* first byte offset */ in gem_rint()
1601 m->m_pkthdr.rcvif = ifp; in gem_rint()
1602 m->m_pkthdr.len = m->m_len = GEM_RD_BUFLEN(rxstat); in gem_rint()
1614 CTR3(KTR_GEM, "%s: done sc->sc_rxptr %d, complete %d", __func__, in gem_rint()
1615 sc->sc_rxptr, GEM_READ_4(sc, GEM_RX_COMPLETION)); in gem_rint()
1622 struct gem_rxsoft *rxs = &sc->sc_rxsoft[idx]; in gem_add_rxbuf()
1632 m->m_len = m->m_pkthdr.len = m->m_ext.ext_size; in gem_add_rxbuf()
1636 memset(m->m_ext.ext_buf, 0, m->m_ext.ext_size); in gem_add_rxbuf()
1639 if (rxs->rxs_mbuf != NULL) { in gem_add_rxbuf()
1640 bus_dmamap_sync(sc->sc_rdmatag, rxs->rxs_dmamap, in gem_add_rxbuf()
1642 bus_dmamap_unload(sc->sc_rdmatag, rxs->rxs_dmamap); in gem_add_rxbuf()
1645 error = bus_dmamap_load_mbuf_sg(sc->sc_rdmatag, rxs->rxs_dmamap, in gem_add_rxbuf()
1648 device_printf(sc->sc_dev, in gem_add_rxbuf()
1656 rxs->rxs_mbuf = m; in gem_add_rxbuf()
1657 rxs->rxs_paddr = segs[0].ds_addr; in gem_add_rxbuf()
1659 bus_dmamap_sync(sc->sc_rdmatag, rxs->rxs_dmamap, in gem_add_rxbuf()
1671 if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1); in gem_eint()
1677 device_printf(sc->sc_dev, "%s: status 0x%x", __func__, status); in gem_eint()
1696 device_get_name(sc->sc_dev), __func__, in gem_intr()
1707 device_printf(sc->sc_dev, in gem_intr()
1713 device_printf(sc->sc_dev, in gem_intr()
1717 device_printf(sc->sc_dev, in gem_intr()
1720 device_printf(sc->sc_dev, in gem_intr()
1721 "%s: transited to non-PAUSE state\n", __func__); in gem_intr()
1724 device_printf(sc->sc_dev, "%s: MIF interrupt\n", __func__); in gem_intr()
1742 device_printf(sc->sc_dev, in gem_intr()
1746 if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); in gem_intr()
1747 if_setdrvflagbits(sc->sc_ifp, 0, IFF_DRV_RUNNING); in gem_intr()
1760 if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1); in gem_intr()
1764 device_printf(sc->sc_dev, in gem_intr()
1773 if_t ifp = sc->sc_ifp; in gem_watchdog()
1790 if (sc->sc_wdog_timer == 0 || --sc->sc_wdog_timer != 0) in gem_watchdog()
1793 if ((sc->sc_flags & GEM_LINK) != 0) in gem_watchdog()
1794 device_printf(sc->sc_dev, "device timeout\n"); in gem_watchdog()
1796 device_printf(sc->sc_dev, "device timeout (no link)\n"); in gem_watchdog()
1843 if ((sc->sc_flags & GEM_SERDES) != 0) { in gem_mii_readreg()
1863 device_printf(sc->sc_dev, in gem_mii_readreg()
1885 device_printf(sc->sc_dev, "%s: timed out\n", __func__); in gem_mii_readreg()
1901 if ((sc->sc_flags & GEM_SERDES) != 0) { in gem_mii_writereg()
1915 device_printf(sc->sc_dev, in gem_mii_writereg()
1938 device_printf(sc->sc_dev, in gem_mii_writereg()
1964 device_printf(sc->sc_dev, "%s: timed out\n", __func__); in gem_mii_writereg()
1980 if ((sc->sc_if_getflags(ifp) & IFF_DEBUG) != 0) in gem_mii_statchg()
1981 device_printf(sc->sc_dev, "%s: status change\n", __func__); in gem_mii_statchg()
1984 if ((sc->sc_mii->mii_media_status & IFM_ACTIVE) != 0 && in gem_mii_statchg()
1985 IFM_SUBTYPE(sc->sc_mii->mii_media_active) != IFM_NONE) in gem_mii_statchg()
1986 sc->sc_flags |= GEM_LINK; in gem_mii_statchg()
1988 sc->sc_flags &= ~GEM_LINK; in gem_mii_statchg()
1990 switch (IFM_SUBTYPE(sc->sc_mii->mii_media_active)) { in gem_mii_statchg()
2008 rxcfg = sc->sc_mac_rxcfg; in gem_mii_statchg()
2011 if ((IFM_OPTIONS(sc->sc_mii->mii_media_active) & IFM_FDX) != 0) in gem_mii_statchg()
2024 if ((IFM_OPTIONS(sc->sc_mii->mii_media_active) & in gem_mii_statchg()
2027 if ((IFM_OPTIONS(sc->sc_mii->mii_media_active) & in gem_mii_statchg()
2032 if ((IFM_OPTIONS(sc->sc_mii->mii_media_active) & IFM_FDX) == 0 && in gem_mii_statchg()
2043 if ((sc->sc_flags & GEM_SERDES) == 0) { in gem_mii_statchg()
2046 /* External MII needs echo disable if half duplex. */ in gem_mii_statchg()
2047 if ((IFM_OPTIONS(sc->sc_mii->mii_media_active) & in gem_mii_statchg()
2060 if ((IFM_OPTIONS(sc->sc_mii->mii_media_active) & IFM_FDX) != 0) in gem_mii_statchg()
2064 sc->sc_mac_rxcfg = rxcfg; in gem_mii_statchg()
2065 if ((if_getdrvflags(sc->sc_ifp) & IFF_DRV_RUNNING) != 0 && in gem_mii_statchg()
2066 (sc->sc_flags & GEM_LINK) != 0) { in gem_mii_statchg()
2083 error = mii_mediachg(sc->sc_mii); in gem_mediachange()
2099 mii_pollstat(sc->sc_mii); in gem_mediastatus()
2100 ifmr->ifm_active = sc->sc_mii->mii_media_active; in gem_mediastatus()
2101 ifmr->ifm_status = sc->sc_mii->mii_media_status; in gem_mediastatus()
2118 ((if_getflags(ifp) ^ sc->sc_ifflags) & in gem_ioctl()
2126 sc->sc_csum_features |= CSUM_UDP; in gem_ioctl()
2128 sc->sc_csum_features &= ~CSUM_UDP; in gem_ioctl()
2130 if_sethwassist(ifp, sc->sc_csum_features); in gem_ioctl()
2131 sc->sc_ifflags = if_getflags(ifp); in gem_ioctl()
2143 error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii->mii_media, cmd); in gem_ioctl()
2147 if_setcapenable(ifp, ifr->ifr_reqcap); in gem_ioctl()
2149 if_sethwassist(ifp, sc->sc_csum_features); in gem_ioctl()
2171 hash[crc >> 4] |= 1 << (15 - (crc & 15)); in gem_hash_maddr()
2179 if_t ifp = sc->sc_ifp; in gem_setladrf()
2190 v = sc->sc_mac_rxcfg & ~GEM_MAC_RX_HASH_FILTER; in gem_setladrf()
2196 device_printf(sc->sc_dev, in gem_setladrf()
2197 "cannot disable RX MAC or hash filter\n"); in gem_setladrf()
2226 GEM_MAC_HASH0 + i * (GEM_MAC_HASH1 - GEM_MAC_HASH0), in gem_setladrf()
2230 sc->sc_mac_rxcfg = v; in gem_setladrf()