Module Name: src Committed By: msaitoh Date: Fri Oct 30 06:23:39 UTC 2020
Modified Files: src/sys/dev/pci: if_wm.c Log Message: Add new sysctl hw.wmN.debug_flags. This sysctl can be used if WM_DEBUG is set. OK'd by knakahara. % sysctl -d hw.wm0.debug_flags hw.wm0.debug_flags: Debug flags: 0x01 LINK 0x02 TX 0x04 RX 0x08 GMII 0x10 MANAGE 0x20 NVM 0x40 INIT 0x80 LOCK To generate a diff of this commit: cvs rdiff -u -r1.692 -r1.693 src/sys/dev/pci/if_wm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.692 src/sys/dev/pci/if_wm.c:1.693 --- src/sys/dev/pci/if_wm.c:1.692 Wed Oct 28 07:08:08 2020 +++ src/sys/dev/pci/if_wm.c Fri Oct 30 06:23:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.692 2020/10/28 07:08:08 msaitoh Exp $ */ +/* $NetBSD: if_wm.c,v 1.693 2020/10/30 06:23:39 msaitoh Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -82,7 +82,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.692 2020/10/28 07:08:08 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.693 2020/10/30 06:23:39 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -157,11 +157,20 @@ __KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1. #define WM_DEBUG_NVM __BIT(5) #define WM_DEBUG_INIT __BIT(6) #define WM_DEBUG_LOCK __BIT(7) -int wm_debug = WM_DEBUG_TX | WM_DEBUG_RX | WM_DEBUG_LINK | WM_DEBUG_GMII - | WM_DEBUG_MANAGE | WM_DEBUG_NVM | WM_DEBUG_INIT | WM_DEBUG_LOCK; -#define DPRINTF(x, y) do { if (wm_debug & (x)) printf y; } while (0) + +#if 0 +#define WM_DEBUG_DEFAULT WM_DEBUG_TX | WM_DEBUG_RX | WM_DEBUG_LINK | \ + WM_DEBUG_GMII | WM_DEBUG_MANAGE | WM_DEBUG_NVM | WM_DEBUG_INIT | \ + WM_DEBUG_LOCK +#endif + +#define DPRINTF(sc, x, y) \ + do { \ + if ((sc)->sc_debug & (x)) \ + printf y; \ + } while (0) #else -#define DPRINTF(x, y) __nothing +#define DPRINTF(sc, x, y) __nothing #endif /* WM_DEBUG */ #ifdef NET_MPSAFE @@ -624,6 +633,9 @@ struct wm_softc { struct wm_phyop phy; struct wm_nvmop nvm; +#ifdef WM_DEBUG + uint32_t sc_debug; +#endif }; #define WM_CORE_LOCK(_sc) \ @@ -1033,6 +1045,10 @@ static int wm_platform_pm_pch_lpt(struct static int wm_pll_workaround_i210(struct wm_softc *); static void wm_legacy_irq_quirk_spt(struct wm_softc *); +#ifdef WM_DEBUG +static int wm_sysctl_debug(SYSCTLFN_PROTO); +#endif + CFATTACH_DECL3_NEW(wm, sizeof(struct wm_softc), wm_match, wm_attach, wm_detach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN); @@ -1844,6 +1860,9 @@ wm_attach(device_t parent, device_t self uint32_t link_mode; uint32_t reg; +#if defined(WM_DEBUG) && defined(WM_DEBUG_DEFAULT) + sc->sc_debug = WM_DEBUG_DEFAULT; +#endif sc->sc_dev = self; callout_init(&sc->sc_tick_ch, WM_CALLOUT_FLAGS); callout_setfunc(&sc->sc_tick_ch, wm_tick, sc); @@ -3422,7 +3441,7 @@ wm_ifflags_cb(struct ethercom *ec) bool needreset = false; int rc = 0; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); WM_CORE_LOCK(sc); @@ -3478,7 +3497,7 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, struct sockaddr_dl *sdl; int s, error; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); #ifndef WM_MPSAFE @@ -3807,7 +3826,7 @@ wm_set_filter(struct wm_softc *sc) uint32_t hash, reg, bit; int i, size, ralmax, rv; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->sc_type >= WM_T_82544) @@ -3951,7 +3970,7 @@ static void wm_set_vlan(struct wm_softc *sc) { - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); /* Deal with VLAN enables. */ @@ -4037,7 +4056,7 @@ wm_lan_init_done(struct wm_softc *sc) uint32_t reg = 0; int i; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); /* Wait for eeprom to reload */ @@ -4076,7 +4095,7 @@ wm_get_cfg_done(struct wm_softc *sc) uint32_t reg; int i; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); /* Wait for eeprom to reload */ @@ -4123,7 +4142,7 @@ wm_get_cfg_done(struct wm_softc *sc) delay(1000); } if (i >= WM_PHY_CFG_TIMEOUT) - DPRINTF(WM_DEBUG_GMII, ("%s: %s failed\n", + DPRINTF(sc, WM_DEBUG_GMII, ("%s: %s failed\n", device_xname(sc->sc_dev), __func__)); break; case WM_T_ICH8: @@ -4220,7 +4239,7 @@ wm_write_smbus_addr(struct wm_softc *sc) uint16_t phy_data; int rv; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); KASSERT(CSR_READ(sc, WMREG_EXTCNFCTR) & EXTCNFCTR_MDIO_SW_OWNERSHIP); @@ -4245,7 +4264,7 @@ wm_write_smbus_addr(struct wm_softc *sc) phy_data |= __SHIFTIN((freq & 0x02) != 0, HV_SMB_ADDR_FREQ_HIGH); } else - DPRINTF(WM_DEBUG_INIT, + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s Unsupported SMB frequency in PHY\n", device_xname(sc->sc_dev), __func__)); } @@ -4261,7 +4280,7 @@ wm_init_lcd_from_nvm(struct wm_softc *sc uint16_t phy_page = 0; int rv = 0; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); switch (sc->sc_type) { @@ -4303,7 +4322,7 @@ wm_init_lcd_from_nvm(struct wm_softc *sc && ((extcnfctr & EXTCNFCTR_PCIE_WRITE_ENABLE) != 0)) goto release; - DPRINTF(WM_DEBUG_INIT, ("%s: %s: Configure LCD by software\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s: Configure LCD by software\n", device_xname(sc->sc_dev), __func__)); /* word_addr is in DWORD */ word_addr = __SHIFTOUT(extcnfctr, EXTCNFCTR_EXT_CNF_POINTER) << 1; @@ -4321,7 +4340,7 @@ wm_init_lcd_from_nvm(struct wm_softc *sc * LCD Write Enable bits are set in the NVM. When both NVM bits * are cleared, SW will configure them instead. */ - DPRINTF(WM_DEBUG_INIT, ("%s: %s: Configure SMBus and LED\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s: Configure SMBus and LED\n", device_xname(sc->sc_dev), __func__)); if ((rv = wm_write_smbus_addr(sc)) != 0) goto release; @@ -4432,7 +4451,7 @@ wm_initialize_hardware_bits(struct wm_so { uint32_t tarc0, tarc1, reg; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); /* For 82571 variant, 80003 and ICHs */ @@ -4693,7 +4712,7 @@ wm_reset_phy(struct wm_softc *sc) { uint32_t reg; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (wm_phy_resetisblocked(sc)) return -1; @@ -4810,7 +4829,7 @@ wm_reset(struct wm_softc *sc) uint16_t kmreg; int rv; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); KASSERT(sc->sc_type != 0); @@ -5822,6 +5841,24 @@ wm_init_sysctls(struct wm_softc *sc) if (rv != 0) goto teardown; +#ifdef WM_DEBUG + rv = sysctl_createv(log, 0, &rnode, &cnode, CTLFLAG_READWRITE, + CTLTYPE_INT, "debug_flags", + SYSCTL_DESCR( + "Debug flags:\n" \ + "\t0x01 LINK\n" \ + "\t0x02 TX\n" \ + "\t0x04 RX\n" \ + "\t0x08 GMII\n" \ + "\t0x10 MANAGE\n" \ + "\t0x20 NVM\n" \ + "\t0x40 INIT\n" \ + "\t0x80 LOCK"), + wm_sysctl_debug, 0, (void *)sc, 0, CTL_CREATE, CTL_EOL); + if (rv != 0) + goto teardown; +#endif + return; teardown: @@ -5858,7 +5895,7 @@ wm_init_locked(struct ifnet *ifp) int i, j, trynum, error = 0; uint32_t reg, sfp_mask = 0; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); KASSERT(WM_CORE_LOCKED(sc)); @@ -6462,7 +6499,7 @@ wm_stop_locked(struct ifnet *ifp, bool d struct wm_txsoft *txs; int i, qidx; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); KASSERT(WM_CORE_LOCKED(sc)); @@ -7143,7 +7180,7 @@ wm_init_tx_regs(struct wm_softc *sc, str struct wm_txqueue *txq) { - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); KASSERT(mutex_owned(txq->txq_lock)); @@ -7352,7 +7389,7 @@ wm_init_txrx_queues(struct wm_softc *sc) { int i, error = 0; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); for (i = 0; i < sc->sc_nqueues; i++) { @@ -7745,7 +7782,7 @@ wm_send_common_locked(struct ifnet *ifp, if (txq->txq_sfree < WM_TXQUEUE_GC(txq)) { wm_txeof(txq, UINT_MAX); if (txq->txq_sfree == 0) { - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: no free job descriptors\n", device_xname(sc->sc_dev))); WM_Q_EVCNT_INCR(txq, txsstall); @@ -7761,7 +7798,7 @@ wm_send_common_locked(struct ifnet *ifp, if (m0 == NULL) break; - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: have packet to transmit: %p\n", device_xname(sc->sc_dev), m0)); @@ -7818,7 +7855,7 @@ retry: continue; } /* Short on resources, just stop for now. */ - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: dmamap load failed: %d\n", device_xname(sc->sc_dev), error)); break; @@ -7845,7 +7882,7 @@ retry: * pack on the queue, and punt. Notify the upper * layer that there are no more slots left. */ - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: need %d (%d) descriptors, have %d\n", device_xname(sc->sc_dev), dmamap->dm_nsegs, segs_needed, txq->txq_free - 1)); @@ -7862,7 +7899,7 @@ retry: */ if (sc->sc_type == WM_T_82547 && wm_82547_txfifo_bugchk(sc, m0)) { - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: 82547 Tx FIFO bug detected\n", device_xname(sc->sc_dev))); txq->txq_flags |= WM_TXQ_NO_SPACE; @@ -7873,7 +7910,7 @@ retry: /* WE ARE NOW COMMITTED TO TRANSMITTING THE PACKET. */ - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: packet has %d (%d) DMA segments\n", device_xname(sc->sc_dev), dmamap->dm_nsegs, segs_needed)); @@ -7942,7 +7979,7 @@ retry: txq->txq_descs[nexttx].wtx_fields.wtxu_vlan =0; lasttx = nexttx; - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: desc %d: low %#" PRIx64 ", " "len %#04zx\n", device_xname(sc->sc_dev), nexttx, @@ -7975,7 +8012,7 @@ retry: txs->txs_lastdesc = lasttx; - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: desc %d: cmdlen 0x%08x\n", device_xname(sc->sc_dev), lasttx, le32toh(txq->txq_descs[lasttx].wtx_cmdlen))); @@ -7987,10 +8024,10 @@ retry: /* Give the packet to the chip. */ CSR_WRITE(sc, txq->txq_tdt_reg, nexttx); - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: TDT -> %d\n", device_xname(sc->sc_dev), nexttx)); - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: finished transmitting packet, job %d\n", device_xname(sc->sc_dev), txq->txq_snext)); @@ -8008,7 +8045,7 @@ retry: if (m0 != NULL) { txq->txq_flags |= WM_TXQ_NO_SPACE; WM_Q_EVCNT_INCR(txq, descdrop); - DPRINTF(WM_DEBUG_TX, ("%s: TX: error after IFQ_DEQUEUE\n", + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: error after IFQ_DEQUEUE\n", __func__)); m_freem(m0); } @@ -8221,10 +8258,10 @@ wm_nq_tx_offload(struct wm_softc *sc, st txq->txq_nq_descs[txq->txq_next].nqrx_ctx.nqtxc_mssidx = htole32(mssidx); wm_cdtxsync(txq, txq->txq_next, 1, BUS_DMASYNC_PREWRITE); - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: context desc %d 0x%08x%08x\n", device_xname(sc->sc_dev), txq->txq_next, 0, vl_len)); - DPRINTF(WM_DEBUG_TX, ("\t0x%08x%08x\n", mssidx, cmdc)); + DPRINTF(sc, WM_DEBUG_TX, ("\t0x%08x%08x\n", mssidx, cmdc)); txq->txq_next = WM_NEXTTX(txq, txq->txq_next); txs->txs_ndesc++; } @@ -8344,7 +8381,7 @@ wm_nq_send_common_locked(struct ifnet *i if (txq->txq_sfree < WM_TXQUEUE_GC(txq)) { wm_txeof(txq, UINT_MAX); if (txq->txq_sfree == 0) { - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: no free job descriptors\n", device_xname(sc->sc_dev))); WM_Q_EVCNT_INCR(txq, txsstall); @@ -8360,7 +8397,7 @@ wm_nq_send_common_locked(struct ifnet *i if (m0 == NULL) break; - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: have packet to transmit: %p\n", device_xname(sc->sc_dev), m0)); @@ -8400,7 +8437,7 @@ retry: continue; } /* Short on resources, just stop for now. */ - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: dmamap load failed: %d\n", device_xname(sc->sc_dev), error)); break; @@ -8423,7 +8460,7 @@ retry: * pack on the queue, and punt. Notify the upper * layer that there are no more slots left. */ - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: need %d (%d) descriptors, have %d\n", device_xname(sc->sc_dev), dmamap->dm_nsegs, segs_needed, txq->txq_free - 1)); @@ -8435,7 +8472,7 @@ retry: /* WE ARE NOW COMMITTED TO TRANSMITTING THE PACKET. */ - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: packet has %d (%d) DMA segments\n", device_xname(sc->sc_dev), dmamap->dm_nsegs, segs_needed)); @@ -8500,11 +8537,11 @@ retry: htole32(dmamap->dm_segs[0].ds_len | cmdlen); txq->txq_nq_descs[nexttx].nqtx_data.nqtxd_fields = htole32(fields); - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: adv data desc %d 0x%" PRIx64 "\n", device_xname(sc->sc_dev), nexttx, (uint64_t)dmamap->dm_segs[0].ds_addr)); - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("\t 0x%08x%08x\n", fields, (uint32_t)dmamap->dm_segs[0].ds_len | cmdlen)); dcmdlen = NQTX_DTYP_D | NQTX_CMD_DEXT; @@ -8526,7 +8563,7 @@ retry: txq->txq_nq_descs[nexttx].nqtx_data.nqtxd_fields = 0; lasttx = nexttx; - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: desc %d: %#" PRIx64 ", len %#04zx\n", device_xname(sc->sc_dev), nexttx, (uint64_t)dmamap->dm_segs[seg].ds_addr, @@ -8547,7 +8584,7 @@ retry: txs->txs_lastdesc = lasttx; - DPRINTF(WM_DEBUG_TX, ("%s: TX: desc %d: cmdlen 0x%08x\n", + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: desc %d: cmdlen 0x%08x\n", device_xname(sc->sc_dev), lasttx, le32toh(txq->txq_descs[lasttx].wtx_cmdlen))); @@ -8559,10 +8596,10 @@ retry: CSR_WRITE(sc, txq->txq_tdt_reg, nexttx); sent = true; - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: TDT -> %d\n", device_xname(sc->sc_dev), nexttx)); - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: finished transmitting packet, job %d\n", device_xname(sc->sc_dev), txq->txq_snext)); @@ -8580,7 +8617,7 @@ retry: if (m0 != NULL) { txq->txq_flags |= WM_TXQ_NO_SPACE; WM_Q_EVCNT_INCR(txq, descdrop); - DPRINTF(WM_DEBUG_TX, ("%s: TX: error after IFQ_DEQUEUE\n", + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: error after IFQ_DEQUEUE\n", __func__)); m_freem(m0); } @@ -8658,7 +8695,7 @@ wm_txeof(struct wm_txqueue *txq, u_int l i = WM_NEXTTXS(txq, i), txq->txq_sfree++) { if (limit-- == 0) { more = true; - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: loop limited, job %d is not processed\n", device_xname(sc->sc_dev), i)); break; @@ -8666,7 +8703,7 @@ wm_txeof(struct wm_txqueue *txq, u_int l txs = &txq->txq_soft[i]; - DPRINTF(WM_DEBUG_TX, ("%s: TX: checking job %d\n", + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: checking job %d\n", device_xname(sc->sc_dev), i)); wm_cdtxsync(txq, txs->txs_firstdesc, txs->txs_ndesc, @@ -8681,7 +8718,7 @@ wm_txeof(struct wm_txqueue *txq, u_int l } count++; - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: job %d done: descs %d..%d\n", device_xname(sc->sc_dev), i, txs->txs_firstdesc, txs->txs_lastdesc)); @@ -8737,7 +8774,7 @@ wm_txeof(struct wm_txqueue *txq, u_int l /* Update the dirty transmit buffer pointer. */ txq->txq_sdirty = i; - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: txsdirty -> %d\n", device_xname(sc->sc_dev), i)); if (count != 0) @@ -8984,7 +9021,7 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l if (limit-- == 0) { rxq->rxq_ptr = i; more = true; - DPRINTF(WM_DEBUG_RX, + DPRINTF(sc, WM_DEBUG_RX, ("%s: RX: loop limited, descriptor %d is not processed\n", device_xname(sc->sc_dev), i)); break; @@ -8992,7 +9029,7 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l rxs = &rxq->rxq_soft[i]; - DPRINTF(WM_DEBUG_RX, + DPRINTF(sc, WM_DEBUG_RX, ("%s: RX: checking descriptor %d\n", device_xname(sc->sc_dev), i)); wm_cdrxsync(rxq, i, @@ -9018,13 +9055,13 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l count++; if (__predict_false(rxq->rxq_discard)) { - DPRINTF(WM_DEBUG_RX, + DPRINTF(sc, WM_DEBUG_RX, ("%s: RX: discarding contents of descriptor %d\n", device_xname(sc->sc_dev), i)); wm_init_rxdesc(rxq, i); if (wm_rxdesc_is_eop(rxq, status)) { /* Reset our state. */ - DPRINTF(WM_DEBUG_RX, + DPRINTF(sc, WM_DEBUG_RX, ("%s: RX: resetting rxdiscard -> 0\n", device_xname(sc->sc_dev))); rxq->rxq_discard = 0; @@ -9056,7 +9093,7 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l if (rxq->rxq_head != NULL) m_freem(rxq->rxq_head); WM_RXCHAIN_RESET(rxq); - DPRINTF(WM_DEBUG_RX, + DPRINTF(sc, WM_DEBUG_RX, ("%s: RX: Rx buffer allocation failed, " "dropping packet%s\n", device_xname(sc->sc_dev), rxq->rxq_discard ? " (discard)" : "")); @@ -9065,14 +9102,14 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l m->m_len = len; rxq->rxq_len += len; - DPRINTF(WM_DEBUG_RX, + DPRINTF(sc, WM_DEBUG_RX, ("%s: RX: buffer at %p len %d\n", device_xname(sc->sc_dev), m->m_data, len)); /* If this is not the end of the packet, keep looking. */ if (!wm_rxdesc_is_eop(rxq, status)) { WM_RXCHAIN_LINK(rxq, m); - DPRINTF(WM_DEBUG_RX, + DPRINTF(sc, WM_DEBUG_RX, ("%s: RX: not yet EOP, rxlen -> %d\n", device_xname(sc->sc_dev), rxq->rxq_len)); continue; @@ -9107,7 +9144,7 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l WM_RXCHAIN_RESET(rxq); - DPRINTF(WM_DEBUG_RX, + DPRINTF(sc, WM_DEBUG_RX, ("%s: RX: have entire packet, len -> %d\n", device_xname(sc->sc_dev), len)); @@ -9124,7 +9161,7 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l * TODO * should be save rsshash and rsstype to this mbuf. */ - DPRINTF(WM_DEBUG_RX, + DPRINTF(sc, WM_DEBUG_RX, ("%s: RX: RSS type=%" PRIu8 ", RSS hash=%" PRIu32 "\n", device_xname(sc->sc_dev), rsstype, rsshash)); @@ -9158,7 +9195,7 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l if (count != 0) rnd_add_uint32(&sc->rnd_source, count); - DPRINTF(WM_DEBUG_RX, + DPRINTF(sc, WM_DEBUG_RX, ("%s: RX: rxptr -> %d\n", device_xname(sc->sc_dev), i)); return more; @@ -9179,12 +9216,12 @@ wm_linkintr_gmii(struct wm_softc *sc, ui KASSERT(WM_CORE_LOCKED(sc)); - DPRINTF(WM_DEBUG_LINK, ("%s: %s:\n", device_xname(dev), + DPRINTF(sc, WM_DEBUG_LINK, ("%s: %s:\n", device_xname(dev), __func__)); if ((icr & ICR_LSC) == 0) { if (icr & ICR_RXSEQ) - DPRINTF(WM_DEBUG_LINK, + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK Receive sequence error\n", device_xname(dev))); return; @@ -9194,11 +9231,11 @@ wm_linkintr_gmii(struct wm_softc *sc, ui status = CSR_READ(sc, WMREG_STATUS); link = status & STATUS_LU; if (link) { - DPRINTF(WM_DEBUG_LINK, ("%s: LINK: LSC -> up %s\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: LSC -> up %s\n", device_xname(dev), (status & STATUS_FD) ? "FDX" : "HDX")); } else { - DPRINTF(WM_DEBUG_LINK, ("%s: LINK: LSC -> down\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: LSC -> down\n", device_xname(dev))); } if ((sc->sc_type == WM_T_ICH8) && (link == false)) @@ -9208,7 +9245,7 @@ wm_linkintr_gmii(struct wm_softc *sc, ui && (sc->sc_phytype == WMPHY_IGP_3)) { wm_kmrn_lock_loss_workaround_ich8lan(sc); } - DPRINTF(WM_DEBUG_LINK, ("%s: LINK: LSC -> mii_pollstat\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: LSC -> mii_pollstat\n", device_xname(dev))); mii_pollstat(&sc->sc_mii); if (sc->sc_type == WM_T_82543) { @@ -9436,14 +9473,14 @@ wm_linkintr_tbi(struct wm_softc *sc, uin struct ifnet *ifp = &sc->sc_ethercom.ec_if; uint32_t status; - DPRINTF(WM_DEBUG_LINK, ("%s: %s:\n", device_xname(sc->sc_dev), + DPRINTF(sc, WM_DEBUG_LINK, ("%s: %s:\n", device_xname(sc->sc_dev), __func__)); status = CSR_READ(sc, WMREG_STATUS); if (icr & ICR_LSC) { wm_check_for_link(sc); if (status & STATUS_LU) { - DPRINTF(WM_DEBUG_LINK, ("%s: LINK: LSC -> up %s\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: LSC -> up %s\n", device_xname(sc->sc_dev), (status & STATUS_FD) ? "FDX" : "HDX")); /* @@ -9468,7 +9505,7 @@ wm_linkintr_tbi(struct wm_softc *sc, uin sc->sc_tbi_linkup = 1; if_link_state_change(ifp, LINK_STATE_UP); } else { - DPRINTF(WM_DEBUG_LINK, ("%s: LINK: LSC -> down\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: LSC -> down\n", device_xname(sc->sc_dev))); sc->sc_tbi_linkup = 0; if_link_state_change(ifp, LINK_STATE_DOWN); @@ -9476,7 +9513,7 @@ wm_linkintr_tbi(struct wm_softc *sc, uin /* Update LED */ wm_tbi_serdes_set_linkled(sc); } else if (icr & ICR_RXSEQ) - DPRINTF(WM_DEBUG_LINK, ("%s: LINK: Receive sequence error\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: Receive sequence error\n", device_xname(sc->sc_dev))); } @@ -9493,20 +9530,20 @@ wm_linkintr_serdes(struct wm_softc *sc, struct ifmedia_entry *ife = mii->mii_media.ifm_cur; uint32_t pcs_adv, pcs_lpab, reg; - DPRINTF(WM_DEBUG_LINK, ("%s: %s:\n", device_xname(sc->sc_dev), + DPRINTF(sc, WM_DEBUG_LINK, ("%s: %s:\n", device_xname(sc->sc_dev), __func__)); if (icr & ICR_LSC) { /* Check PCS */ reg = CSR_READ(sc, WMREG_PCS_LSTS); if ((reg & PCS_LSTS_LINKOK) != 0) { - DPRINTF(WM_DEBUG_LINK, ("%s: LINK: LSC -> up\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: LSC -> up\n", device_xname(sc->sc_dev))); mii->mii_media_status |= IFM_ACTIVE; sc->sc_tbi_linkup = 1; if_link_state_change(ifp, LINK_STATE_UP); } else { - DPRINTF(WM_DEBUG_LINK, ("%s: LINK: LSC -> down\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: LSC -> down\n", device_xname(sc->sc_dev))); mii->mii_media_status |= IFM_NONE; sc->sc_tbi_linkup = 0; @@ -9523,13 +9560,13 @@ wm_linkintr_serdes(struct wm_softc *sc, /* Check flow */ reg = CSR_READ(sc, WMREG_PCS_LSTS); if ((reg & PCS_LSTS_AN_COMP) == 0) { - DPRINTF(WM_DEBUG_LINK, + DPRINTF(sc, WM_DEBUG_LINK, ("XXX LINKOK but not ACOMP\n")); return; } pcs_adv = CSR_READ(sc, WMREG_PCS_ANADV); pcs_lpab = CSR_READ(sc, WMREG_PCS_LPAB); - DPRINTF(WM_DEBUG_LINK, + DPRINTF(sc, WM_DEBUG_LINK, ("XXX AN result %08x, %08x\n", pcs_adv, pcs_lpab)); if ((pcs_adv & TXCW_SYM_PAUSE) && (pcs_lpab & TXCW_SYM_PAUSE)) { @@ -9551,7 +9588,7 @@ wm_linkintr_serdes(struct wm_softc *sc, /* Update LED */ wm_tbi_serdes_set_linkled(sc); } else - DPRINTF(WM_DEBUG_LINK, ("%s: LINK: Receive sequence error\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: Receive sequence error\n", device_xname(sc->sc_dev))); } @@ -9606,7 +9643,7 @@ wm_intr_legacy(void *arg) if ((icr & sc->sc_icr) == 0) break; if (handled == 0) - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: INTx: got intr\n",device_xname(sc->sc_dev))); if (rndval == 0) rndval = icr; @@ -9622,7 +9659,7 @@ wm_intr_legacy(void *arg) #if defined(WM_DEBUG) || defined(WM_EVENT_COUNTERS) if (icr & (ICR_RXDMT0 | ICR_RXT0)) { - DPRINTF(WM_DEBUG_RX, + DPRINTF(sc, WM_DEBUG_RX, ("%s: RX: got Rx intr 0x%08x\n", device_xname(sc->sc_dev), icr & (ICR_RXDMT0 | ICR_RXT0))); @@ -9646,7 +9683,7 @@ wm_intr_legacy(void *arg) #if defined(WM_DEBUG) || defined(WM_EVENT_COUNTERS) if (icr & ICR_TXDW) { - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: got TXDW interrupt\n", device_xname(sc->sc_dev))); WM_Q_EVCNT_INCR(txq, txdw); @@ -9742,7 +9779,7 @@ wm_txrxintr_msix(void *arg) KASSERT(wmq->wmq_intr_idx == wmq->wmq_id); - DPRINTF(WM_DEBUG_TX, + DPRINTF(sc, WM_DEBUG_TX, ("%s: TX: got Tx intr\n", device_xname(sc->sc_dev))); wm_txrxintr_disable(wmq); @@ -9759,7 +9796,7 @@ wm_txrxintr_msix(void *arg) /* wm_deferred start() is done in wm_handle_queue(). */ mutex_exit(txq->txq_lock); - DPRINTF(WM_DEBUG_RX, + DPRINTF(sc, WM_DEBUG_RX, ("%s: RX: got Rx intr\n", device_xname(sc->sc_dev))); mutex_enter(rxq->rxq_lock); @@ -9845,7 +9882,7 @@ wm_linkintr_msix(void *arg) reg = CSR_READ(sc, WMREG_ICR); WM_CORE_LOCK(sc); - DPRINTF(WM_DEBUG_LINK, + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: got link intr. ICR = %08x\n", device_xname(sc->sc_dev), reg)); @@ -9944,7 +9981,7 @@ wm_gmii_reset(struct wm_softc *sc) uint32_t reg; int rv; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); rv = sc->phy.acquire(sc); @@ -10131,7 +10168,7 @@ wm_gmii_setup_phytype(struct wm_softc *s mii_writereg_t new_writereg; bool dodiag = true; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); /* @@ -10426,7 +10463,7 @@ wm_gmii_mediainit(struct wm_softc *sc, p struct ifnet *ifp = &sc->sc_ethercom.ec_if; struct mii_data *mii = &sc->sc_mii; - DPRINTF(WM_DEBUG_GMII, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_GMII, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); /* We have GMII. */ @@ -10576,7 +10613,7 @@ wm_gmii_mediachange(struct ifnet *ifp) uint32_t reg; int rc; - DPRINTF(WM_DEBUG_GMII, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_GMII, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if ((ifp->if_flags & IFF_UP) == 0) return 0; @@ -10747,7 +10784,7 @@ wm_gmii_i82543_readreg(device_t dev, int (MII_COMMAND_READ << 10) | (MII_COMMAND_START << 12), 14); *val = wm_i82543_mii_recvbits(sc) & 0xffff; - DPRINTF(WM_DEBUG_GMII, ("%s: GMII: read phy %d reg %d -> 0x%04hx\n", + DPRINTF(sc, WM_DEBUG_GMII, ("%s: GMII: read phy %d reg %d -> 0x%04hx\n", device_xname(dev), phy, reg, *val)); return 0; @@ -10801,13 +10838,13 @@ wm_gmii_mdic_readreg(device_t dev, int p } if ((mdic & MDIC_READY) == 0) { - DPRINTF(WM_DEBUG_GMII, + DPRINTF(sc, WM_DEBUG_GMII, ("%s: MDIC read timed out: phy %d reg %d\n", device_xname(dev), phy, reg)); return ETIMEDOUT; } else if (mdic & MDIC_E) { /* This is normal if no PHY is present. */ - DPRINTF(WM_DEBUG_GMII, ("%s: MDIC read error: phy %d reg %d\n", + DPRINTF(sc, WM_DEBUG_GMII, ("%s: MDIC read error: phy %d reg %d\n", device_xname(sc->sc_dev), phy, reg)); return -1; } else @@ -10853,12 +10890,12 @@ wm_gmii_mdic_writereg(device_t dev, int } if ((mdic & MDIC_READY) == 0) { - DPRINTF(WM_DEBUG_GMII, + DPRINTF(sc, WM_DEBUG_GMII, ("%s: MDIC write timed out: phy %d reg %d\n", device_xname(dev), phy, reg)); return ETIMEDOUT; } else if (mdic & MDIC_E) { - DPRINTF(WM_DEBUG_GMII, + DPRINTF(sc, WM_DEBUG_GMII, ("%s: MDIC write error: phy %d reg %d\n", device_xname(dev), phy, reg)); return -1; @@ -11197,10 +11234,13 @@ release: static int wm_enable_phy_wakeup_reg_access_bm(device_t dev, uint16_t *phy_regp) { +#ifdef WM_DEBUG + struct wm_softc *sc = device_private(dev); +#endif uint16_t temp; int rv; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(dev), __func__)); if (!phy_regp) @@ -11250,8 +11290,11 @@ wm_enable_phy_wakeup_reg_access_bm(devic static int wm_disable_phy_wakeup_reg_access_bm(device_t dev, uint16_t *phy_regp) { +#ifdef WM_DEBUG + struct wm_softc *sc = device_private(dev); +#endif - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(dev), __func__)); if (!phy_regp) @@ -11302,7 +11345,7 @@ wm_access_phy_wakeup_reg_bm(device_t dev uint16_t wuce; int rv = 0; - DPRINTF(WM_DEBUG_GMII, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_GMII, ("%s: %s called\n", device_xname(dev), __func__)); /* XXX Gig must be disabled for MDIO accesses to page 800 */ if ((sc->sc_type == WM_T_PCH) @@ -11321,7 +11364,7 @@ wm_access_phy_wakeup_reg_bm(device_t dev return rv; } } - DPRINTF(WM_DEBUG_GMII, ("%s: %s: Accessing PHY page %d reg 0x%x\n", + DPRINTF(sc, WM_DEBUG_GMII, ("%s: %s: Accessing PHY page %d reg 0x%x\n", device_xname(sc->sc_dev), __func__, page, regnum)); /* @@ -11363,7 +11406,7 @@ wm_gmii_hv_readreg(device_t dev, int phy struct wm_softc *sc = device_private(dev); int rv; - DPRINTF(WM_DEBUG_GMII, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_GMII, ("%s: %s called\n", device_xname(dev), __func__)); if (sc->phy.acquire(sc)) { device_printf(dev, "%s: failed to get semaphore\n", __func__); @@ -11427,7 +11470,7 @@ wm_gmii_hv_writereg(device_t dev, int ph struct wm_softc *sc = device_private(dev); int rv; - DPRINTF(WM_DEBUG_GMII, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_GMII, ("%s: %s called\n", device_xname(dev), __func__)); if (sc->phy.acquire(sc)) { @@ -11665,11 +11708,11 @@ wm_gmii_statchg(struct ifnet *ifp) } if (mii->mii_media_active & IFM_FDX) { - DPRINTF(WM_DEBUG_LINK, + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: statchg: FDX\n", ifp->if_xname)); sc->sc_tctl |= TCTL_COLD(TX_COLLISION_DISTANCE_FDX); } else { - DPRINTF(WM_DEBUG_LINK, + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: statchg: HDX\n", ifp->if_xname)); sc->sc_tctl |= TCTL_COLD(TX_COLLISION_DISTANCE_HDX); } @@ -12165,7 +12208,7 @@ wm_tbi_mediachange(struct ifnet *ifp) if ((sc->sc_mii.mii_media.ifm_media & IFM_FLOW) != 0) sc->sc_txcw |= TXCW_SYM_PAUSE | TXCW_ASYM_PAUSE; - DPRINTF(WM_DEBUG_LINK,("%s: sc_txcw = 0x%x after autoneg check\n", + DPRINTF(sc, WM_DEBUG_LINK,("%s: sc_txcw = 0x%x after autoneg check\n", device_xname(sc->sc_dev), sc->sc_txcw)); CSR_WRITE(sc, WMREG_TXCW, sc->sc_txcw); CSR_WRITE(sc, WMREG_CTRL, sc->sc_ctrl); @@ -12175,7 +12218,7 @@ wm_tbi_mediachange(struct ifnet *ifp) ctrl = CSR_READ(sc, WMREG_CTRL); signal = wm_tbi_havesignal(sc, ctrl); - DPRINTF(WM_DEBUG_LINK, ("%s: signal = %d\n", device_xname(sc->sc_dev), + DPRINTF(sc, WM_DEBUG_LINK, ("%s: signal = %d\n", device_xname(sc->sc_dev), signal)); if (signal) { @@ -12186,16 +12229,16 @@ wm_tbi_mediachange(struct ifnet *ifp) break; } - DPRINTF(WM_DEBUG_LINK,("%s: i = %d after waiting for link\n", + DPRINTF(sc, WM_DEBUG_LINK,("%s: i = %d after waiting for link\n", device_xname(sc->sc_dev), i)); status = CSR_READ(sc, WMREG_STATUS); - DPRINTF(WM_DEBUG_LINK, + DPRINTF(sc, WM_DEBUG_LINK, ("%s: status after final read = 0x%x, STATUS_LU = 0x%x\n", device_xname(sc->sc_dev), status, STATUS_LU)); if (status & STATUS_LU) { /* Link is up. */ - DPRINTF(WM_DEBUG_LINK, + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: set media -> link up %s\n", device_xname(sc->sc_dev), (status & STATUS_FD) ? "FDX" : "HDX")); @@ -12223,13 +12266,13 @@ wm_tbi_mediachange(struct ifnet *ifp) if (i == WM_LINKUP_TIMEOUT) wm_check_for_link(sc); /* Link is down. */ - DPRINTF(WM_DEBUG_LINK, + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: set media -> link down\n", device_xname(sc->sc_dev))); sc->sc_tbi_linkup = 0; } } else { - DPRINTF(WM_DEBUG_LINK, ("%s: LINK: set media -> no signal\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: set media -> no signal\n", device_xname(sc->sc_dev))); sc->sc_tbi_linkup = 0; } @@ -12286,7 +12329,7 @@ wm_check_for_link(struct wm_softc *sc) uint32_t status; bool signal; - DPRINTF(WM_DEBUG_LINK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->sc_mediatype == WM_MEDIATYPE_SERDES) { @@ -12302,7 +12345,7 @@ wm_check_for_link(struct wm_softc *sc) status = CSR_READ(sc, WMREG_STATUS); signal = wm_tbi_havesignal(sc, ctrl); - DPRINTF(WM_DEBUG_LINK, + DPRINTF(sc, WM_DEBUG_LINK, ("%s: %s: signal = %d, status_lu = %d, rxcw_c = %d\n", device_xname(sc->sc_dev), __func__, signal, ((status & STATUS_LU) != 0), ((rxcw & RXCW_C) != 0))); @@ -12320,7 +12363,7 @@ wm_check_for_link(struct wm_softc *sc) * */ if (signal && ((status & STATUS_LU) == 0) && ((rxcw & RXCW_C) == 0)) { - DPRINTF(WM_DEBUG_LINK, + DPRINTF(sc, WM_DEBUG_LINK, ("%s: %s: force linkup and fullduplex\n", device_xname(sc->sc_dev), __func__)); sc->sc_tbi_linkup = 0; @@ -12339,16 +12382,16 @@ wm_check_for_link(struct wm_softc *sc) && ((rxcw & RXCW_C) != 0) && (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO)) { sc->sc_tbi_linkup = 1; - DPRINTF(WM_DEBUG_LINK, ("%s: %s: go back to autonego\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: %s: go back to autonego\n", device_xname(sc->sc_dev), __func__)); CSR_WRITE(sc, WMREG_TXCW, sc->sc_txcw); CSR_WRITE(sc, WMREG_CTRL, (ctrl & ~CTRL_SLU)); } else if (signal && ((rxcw & RXCW_C) != 0)) { - DPRINTF(WM_DEBUG_LINK, ("%s: %s: /C/", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: %s: /C/", device_xname(sc->sc_dev), __func__)); } else { - DPRINTF(WM_DEBUG_LINK, ("%s: %s: linkup %08x,%08x,%08x\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: %s: linkup %08x,%08x,%08x\n", device_xname(sc->sc_dev), __func__, rxcw, ctrl, status)); } @@ -12379,11 +12422,11 @@ wm_tbi_tick(struct wm_softc *sc) /* set link status */ if ((status & STATUS_LU) == 0) { - DPRINTF(WM_DEBUG_LINK, ("%s: LINK: checklink -> down\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: checklink -> down\n", device_xname(sc->sc_dev))); sc->sc_tbi_linkup = 0; } else if (sc->sc_tbi_linkup == 0) { - DPRINTF(WM_DEBUG_LINK, ("%s: LINK: checklink -> up %s\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: LINK: checklink -> up %s\n", device_xname(sc->sc_dev), (status & STATUS_FD) ? "FDX" : "HDX")); sc->sc_tbi_linkup = 1; @@ -12399,7 +12442,7 @@ wm_tbi_tick(struct wm_softc *sc) if ((IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) && (++sc->sc_tbi_serdes_ticks >= sc->sc_tbi_serdes_anegticks)) { - DPRINTF(WM_DEBUG_LINK, ("%s: %s: EXPIRE\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: %s: EXPIRE\n", device_xname(sc->sc_dev), __func__)); sc->sc_tbi_serdes_ticks = 0; /* @@ -12586,12 +12629,12 @@ wm_serdes_mediastatus(struct ifnet *ifp, /* Check flow */ reg = CSR_READ(sc, WMREG_PCS_LSTS); if ((reg & PCS_LSTS_AN_COMP) == 0) { - DPRINTF(WM_DEBUG_LINK, ("XXX LINKOK but not ACOMP\n")); + DPRINTF(sc, WM_DEBUG_LINK, ("XXX LINKOK but not ACOMP\n")); goto setled; } pcs_adv = CSR_READ(sc, WMREG_PCS_ANADV); pcs_lpab = CSR_READ(sc, WMREG_PCS_LPAB); - DPRINTF(WM_DEBUG_LINK, + DPRINTF(sc, WM_DEBUG_LINK, ("XXX AN result(2) %08x, %08x\n", pcs_adv, pcs_lpab)); if ((pcs_adv & TXCW_SYM_PAUSE) && (pcs_lpab & TXCW_SYM_PAUSE)) { @@ -12653,7 +12696,7 @@ wm_serdes_tick(struct wm_softc *sc) if ((IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) && (++sc->sc_tbi_serdes_ticks >= sc->sc_tbi_serdes_anegticks)) { - DPRINTF(WM_DEBUG_LINK, ("%s: %s: EXPIRE\n", + DPRINTF(sc, WM_DEBUG_LINK, ("%s: %s: EXPIRE\n", device_xname(sc->sc_dev), __func__)); sc->sc_tbi_serdes_ticks = 0; /* XXX */ @@ -12834,7 +12877,7 @@ wm_nvm_read_uwire(struct wm_softc *sc, i uint32_t reg, val; int i; - DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_NVM, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->nvm.acquire(sc) != 0) @@ -12969,7 +13012,7 @@ wm_nvm_ready_spi(struct wm_softc *sc) uint32_t val; int usec; - DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_NVM, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); for (usec = 0; usec < SPI_MAX_RETRIES; delay(5), usec += 5) { @@ -12998,7 +13041,7 @@ wm_nvm_read_spi(struct wm_softc *sc, int uint8_t opc; int rv = 0; - DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_NVM, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->nvm.acquire(sc) != 0) @@ -13072,7 +13115,7 @@ wm_nvm_read_eerd(struct wm_softc *sc, in int i, eerd = 0; int rv = 0; - DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_NVM, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->nvm.acquire(sc) != 0) @@ -13164,7 +13207,7 @@ wm_nvm_valid_bank_detect_ich8lan(struct } } - DPRINTF(WM_DEBUG_NVM, ("%s: No valid NVM bank present\n", + DPRINTF(sc, WM_DEBUG_NVM, ("%s: No valid NVM bank present\n", device_xname(sc->sc_dev))); return -1; } @@ -13484,7 +13527,7 @@ wm_nvm_read_ich8(struct wm_softc *sc, in uint16_t word = 0; uint16_t i = 0; - DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_NVM, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->nvm.acquire(sc) != 0) @@ -13498,7 +13541,7 @@ wm_nvm_read_ich8(struct wm_softc *sc, in */ rv = wm_nvm_valid_bank_detect_ich8lan(sc, &flash_bank); if (rv) { - DPRINTF(WM_DEBUG_NVM, ("%s: failed to detect NVM bank\n", + DPRINTF(sc, WM_DEBUG_NVM, ("%s: failed to detect NVM bank\n", device_xname(sc->sc_dev))); flash_bank = 0; } @@ -13544,7 +13587,7 @@ wm_nvm_read_spt(struct wm_softc *sc, int uint32_t dword = 0; uint16_t i = 0; - DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_NVM, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->nvm.acquire(sc) != 0) @@ -13558,7 +13601,7 @@ wm_nvm_read_spt(struct wm_softc *sc, int */ rv = wm_nvm_valid_bank_detect_ich8lan(sc, &flash_bank); if (rv) { - DPRINTF(WM_DEBUG_NVM, ("%s: failed to detect NVM bank\n", + DPRINTF(sc, WM_DEBUG_NVM, ("%s: failed to detect NVM bank\n", device_xname(sc->sc_dev))); flash_bank = 0; } @@ -13600,7 +13643,7 @@ wm_nvm_read_word_invm(struct wm_softc *s uint16_t i; uint8_t record_type, word_address; - DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_NVM, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); for (i = 0; i < INVM_SIZE; i++) { @@ -13632,7 +13675,7 @@ wm_nvm_read_invm(struct wm_softc *sc, in int rv = 0; int i; - DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_NVM, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->nvm.acquire(sc) != 0) @@ -13692,7 +13735,7 @@ wm_nvm_read_invm(struct wm_softc *sc, in } break; default: - DPRINTF(WM_DEBUG_NVM, + DPRINTF(sc, WM_DEBUG_NVM, ("NVM word 0x%02x is not mapped.\n", offset)); *data = NVM_RESERVED_WORD; break; @@ -13774,13 +13817,13 @@ wm_nvm_validate_checksum(struct wm_softc /* XXX PCH_SPT? */ wm_nvm_read(sc, csum_wordaddr, 1, &eeprom_data); if ((eeprom_data & valid_checksum) == 0) - DPRINTF(WM_DEBUG_NVM, + DPRINTF(sc, WM_DEBUG_NVM, ("%s: NVM need to be updated (%04x != %04x)\n", device_xname(sc->sc_dev), eeprom_data, valid_checksum)); } - if ((wm_debug & WM_DEBUG_NVM) != 0) { + if ((sc->sc_debug & WM_DEBUG_NVM) != 0) { printf("%s: NVM dump:\n", device_xname(sc->sc_dev)); for (i = 0; i < NVM_SIZE; i++) { if (wm_nvm_read(sc, i, 1, &eeprom_data)) @@ -13985,7 +14028,7 @@ wm_nvm_read(struct wm_softc *sc, int wor { int rv; - DPRINTF(WM_DEBUG_NVM, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_NVM, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->sc_flags & WM_F_EEPROM_INVALID) @@ -14005,7 +14048,7 @@ static int wm_get_null(struct wm_softc *sc) { - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); return 0; } @@ -14014,7 +14057,7 @@ static void wm_put_null(struct wm_softc *sc) { - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); return; } @@ -14025,7 +14068,7 @@ wm_get_eecd(struct wm_softc *sc) uint32_t reg; int x; - DPRINTF(WM_DEBUG_LOCK | WM_DEBUG_NVM, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK | WM_DEBUG_NVM, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); reg = CSR_READ(sc, WMREG_EECD); @@ -14083,7 +14126,7 @@ wm_put_eecd(struct wm_softc *sc) { uint32_t reg; - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); /* Stop nvm */ @@ -14117,7 +14160,7 @@ wm_get_swsm_semaphore(struct wm_softc *s int32_t timeout; uint32_t swsm; - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); KASSERT(sc->sc_nvm_wordsize > 0); @@ -14184,7 +14227,7 @@ wm_put_swsm_semaphore(struct wm_softc *s { uint32_t swsm; - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); swsm = CSR_READ(sc, WMREG_SWSM); @@ -14204,7 +14247,7 @@ wm_get_swfw_semaphore(struct wm_softc *s uint32_t fwmask = mask << SWFW_FIRM_SHIFT; int timeout; - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->sc_type == WM_T_80003) @@ -14241,7 +14284,7 @@ wm_put_swfw_semaphore(struct wm_softc *s { uint32_t swfw_sync; - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); while (wm_get_swsm_semaphore(sc) != 0) @@ -14259,7 +14302,7 @@ wm_get_nvm_80003(struct wm_softc *sc) { int rv; - DPRINTF(WM_DEBUG_LOCK | WM_DEBUG_NVM, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK | WM_DEBUG_NVM, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if ((rv = wm_get_swfw_semaphore(sc, SWFW_EEP_SM)) != 0) { @@ -14283,7 +14326,7 @@ static void wm_put_nvm_80003(struct wm_softc *sc) { - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if ((sc->sc_flags & WM_F_LOCK_EECD) != 0) @@ -14296,7 +14339,7 @@ wm_get_nvm_82571(struct wm_softc *sc) { int rv; - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if ((rv = wm_get_swsm_semaphore(sc)) != 0) @@ -14325,7 +14368,7 @@ static void wm_put_nvm_82571(struct wm_softc *sc) { - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); switch (sc->sc_type) { @@ -14344,7 +14387,7 @@ static int wm_get_phy_82575(struct wm_softc *sc) { - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); return wm_get_swfw_semaphore(sc, swfwphysem[sc->sc_funcid]); } @@ -14353,7 +14396,7 @@ static void wm_put_phy_82575(struct wm_softc *sc) { - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); return wm_put_swfw_semaphore(sc, swfwphysem[sc->sc_funcid]); } @@ -14364,7 +14407,7 @@ wm_get_swfwhw_semaphore(struct wm_softc uint32_t ext_ctrl; int timeout = 200; - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); mutex_enter(sc->sc_ich_phymtx); /* Use PHY mtx for both PHY and NVM */ @@ -14389,7 +14432,7 @@ wm_put_swfwhw_semaphore(struct wm_softc { uint32_t ext_ctrl; - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); ext_ctrl = CSR_READ(sc, WMREG_EXTCNFCTR); @@ -14405,7 +14448,7 @@ wm_get_swflag_ich8lan(struct wm_softc *s uint32_t ext_ctrl; int timeout; - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); mutex_enter(sc->sc_ich_phymtx); for (timeout = 0; timeout < WM_PHY_CFG_TIMEOUT; timeout++) { @@ -14446,7 +14489,7 @@ wm_put_swflag_ich8lan(struct wm_softc *s { uint32_t ext_ctrl; - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); ext_ctrl = CSR_READ(sc, WMREG_EXTCNFCTR); if (ext_ctrl & EXTCNFCTR_MDIO_SW_OWNERSHIP) { @@ -14463,7 +14506,7 @@ static int wm_get_nvm_ich8lan(struct wm_softc *sc) { - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); mutex_enter(sc->sc_ich_nvmmtx); @@ -14474,7 +14517,7 @@ static void wm_put_nvm_ich8lan(struct wm_softc *sc) { - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); mutex_exit(sc->sc_ich_nvmmtx); } @@ -14485,7 +14528,7 @@ wm_get_hw_semaphore_82573(struct wm_soft int i = 0; uint32_t reg; - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); reg = CSR_READ(sc, WMREG_EXTCNFCTR); @@ -14514,7 +14557,7 @@ wm_put_hw_semaphore_82573(struct wm_soft { uint32_t reg; - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); reg = CSR_READ(sc, WMREG_EXTCNFCTR); @@ -14614,7 +14657,7 @@ wm_enable_mng_pass_thru(struct wm_softc manc = CSR_READ(sc, WMREG_MANC); - DPRINTF(WM_DEBUG_MANAGE, ("%s: MANC (%08x)\n", + DPRINTF(sc, WM_DEBUG_MANAGE, ("%s: MANC (%08x)\n", device_xname(sc->sc_dev), manc)); if ((manc & MANC_RECV_TCO_EN) == 0) return 0; @@ -14630,7 +14673,7 @@ wm_enable_mng_pass_thru(struct wm_softc factps = CSR_READ(sc, WMREG_FACTPS); wm_nvm_read(sc, NVM_OFF_CFG2, 1, &data); - DPRINTF(WM_DEBUG_MANAGE, ("%s: FACTPS = %08x, CFG2=%04x\n", + DPRINTF(sc, WM_DEBUG_MANAGE, ("%s: FACTPS = %08x, CFG2=%04x\n", device_xname(sc->sc_dev), factps, data)); if (((factps & FACTPS_MNGCG) == 0) && ((data & NVM_CFG2_MNGM_MASK) @@ -14650,7 +14693,7 @@ wm_phy_resetisblocked(struct wm_softc *s uint32_t reg; int i = 0; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); switch (sc->sc_type) { @@ -14698,7 +14741,7 @@ wm_get_hw_control(struct wm_softc *sc) { uint32_t reg; - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->sc_type == WM_T_82573) { @@ -14715,7 +14758,7 @@ wm_release_hw_control(struct wm_softc *s { uint32_t reg; - DPRINTF(WM_DEBUG_LOCK, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_LOCK, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->sc_type == WM_T_82573) { @@ -14732,7 +14775,7 @@ wm_gate_hw_phy_config_ich8lan(struct wm_ { uint32_t reg; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->sc_type < WM_T_PCH2) @@ -14754,7 +14797,7 @@ wm_init_phy_workarounds_pchlan(struct wm uint32_t fwsm, reg; int rv = 0; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); /* Gate automatic PHY configuration by hardware on non-managed 82579 */ @@ -14766,7 +14809,7 @@ wm_init_phy_workarounds_pchlan(struct wm /* Acquire PHY semaphore */ rv = sc->phy.acquire(sc); if (rv != 0) { - DPRINTF(WM_DEBUG_INIT, ("%s: %s: failed\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s: failed\n", device_xname(sc->sc_dev), __func__)); return -1; } @@ -14878,7 +14921,7 @@ static void wm_init_manageability(struct wm_softc *sc) { - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->sc_flags & WM_F_HAS_MANAGE) { uint32_t manc2h = CSR_READ(sc, WMREG_MANC2H); @@ -14977,7 +15020,7 @@ wm_ulp_disable(struct wm_softc *sc) uint16_t phyreg; int i = 0, rv = 0; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); /* Exclude old devices */ if ((sc->sc_type < WM_T_PCH_LPT) @@ -15013,7 +15056,7 @@ wm_ulp_disable(struct wm_softc *sc) /* Acquire semaphore */ rv = sc->phy.acquire(sc); if (rv != 0) { - DPRINTF(WM_DEBUG_INIT, ("%s: %s: failed\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s: failed\n", device_xname(sc->sc_dev), __func__)); return -1; } @@ -15391,7 +15434,7 @@ wm_enable_wakeup(struct wm_softc *sc) pcireg_t pmode; int rv = 0; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (pci_get_capability(sc->sc_pc, sc->sc_pcitag, PCI_CAP_PWRMGMT, @@ -15523,7 +15566,7 @@ wm_lplu_d0_disable(struct wm_softc *sc) uint32_t reg; uint16_t phyval; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->sc_phytype == WMPHY_IFE) @@ -15726,7 +15769,7 @@ wm_kmrn_lock_loss_workaround_ich8lan(str int i, reg, rv; uint16_t phyreg; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); /* If the link is not up, do nothing */ @@ -15810,7 +15853,7 @@ wm_hv_phy_workarounds_ich8lan(struct wm_ int phytype = sc->sc_phytype; int rv; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(dev), __func__)); KASSERT(sc->sc_type == WM_T_PCH); @@ -15903,7 +15946,7 @@ static void wm_copy_rx_addrs_to_phy_ich8lan(struct wm_softc *sc) { - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->phy.acquire(sc) != 0) @@ -15922,7 +15965,7 @@ wm_copy_rx_addrs_to_phy_ich8lan_locked(s uint16_t i, wuce; int count; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(dev), __func__)); if (wm_enable_phy_wakeup_reg_access_bm(dev, &wuce) != 0) @@ -15963,7 +16006,7 @@ wm_lv_jumbo_workaround_ich8lan(struct wm uint16_t dft_ctrl, data; uint16_t i; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(dev), __func__)); if (sc->sc_type < WM_T_PCH2) @@ -16134,7 +16177,7 @@ wm_lv_phy_workarounds_ich8lan(struct wm_ device_t dev = sc->sc_dev; int rv; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(dev), __func__)); KASSERT(sc->sc_type == WM_T_PCH2); @@ -16244,7 +16287,7 @@ wm_k1_gig_workaround_hv(struct wm_softc { int k1_enable = sc->sc_nvm_k1_enabled; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (sc->phy.acquire(sc) != 0) @@ -16492,7 +16535,7 @@ wm_phy_is_accessible_pchlan(struct wm_so uint16_t id1, id2; int i, rv; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); KASSERT(CSR_READ(sc, WMREG_EXTCNFCTR) & EXTCNFCTR_MDIO_SW_OWNERSHIP); @@ -16596,7 +16639,7 @@ wm_platform_pm_pch_lpt(struct wm_softc * int32_t obff_hwm = 0; int64_t lat_ns, value; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); if (link) { @@ -16791,7 +16834,7 @@ wm_legacy_irq_quirk_spt(struct wm_softc { uint32_t reg; - DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n", + DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); KASSERT((sc->sc_type == WM_T_PCH_SPT) || (sc->sc_type == WM_T_PCH_CNP)); @@ -16804,3 +16847,26 @@ wm_legacy_irq_quirk_spt(struct wm_softc reg |= FEXTNVM9_IOSFSB_CLKGATE_DIS | FEXTNVM9_IOSFSB_CLKREQ_DIS; CSR_WRITE(sc, WMREG_FEXTNVM9, reg); } + +/* Sysctl function */ +#ifdef WM_DEBUG +static int +wm_sysctl_debug(SYSCTLFN_ARGS) +{ + struct sysctlnode node = *rnode; + struct wm_softc *sc = (struct wm_softc *)node.sysctl_data; + uint32_t dflags; + int error; + + dflags = sc->sc_debug; + node.sysctl_data = &dflags; + error = sysctl_lookup(SYSCTLFN_CALL(&node)); + + if (error || newp == NULL) + return error; + + sc->sc_debug = dflags; + + return 0; +} +#endif