igb: Dump registers.
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 7 May 2018 14:55:46 +0000 (22:55 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 7 May 2018 14:59:29 +0000 (22:59 +0800)
This helps debugging.

Obtained-from: dillon

sys/dev/netif/igb/if_igb.c

index c65955a..9ac16b1 100644 (file)
@@ -170,6 +170,8 @@ static void igb_update_link_status(struct igb_softc *);
 static void    igb_init_tx_unit(struct igb_softc *);
 static void    igb_init_rx_unit(struct igb_softc *, boolean_t);
 static void    igb_init_dmac(struct igb_softc *, uint32_t);
+static void    igb_reg_dump(struct igb_softc *);
+static int     igb_sysctl_reg_dump(SYSCTL_HANDLER_ARGS);
 
 static void    igb_set_vlan(struct igb_softc *);
 static void    igb_set_multi(struct igb_softc *);
@@ -1757,6 +1759,10 @@ do { \
                SYSCTL_ADD_ULONG(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, node,
                    CTLFLAG_RW, &txr->tx_gc, "# of TX desc GC");
        }
+
+       SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree),
+           OID_AUTO, "dumpreg", CTLTYPE_INT | CTLFLAG_RW,
+           sc, 0, igb_sysctl_reg_dump, "I", "dump registers");
 }
 
 static int
@@ -5052,3 +5058,291 @@ igb_init_dmac(struct igb_softc *sc, uint32_t pba)
                E1000_WRITE_REG(hw, E1000_DMACR, 0);
        }
 }
+
+static void
+igb_reg_dump(struct igb_softc *sc)
+{
+       device_t dev = sc->dev;
+       int col = 0;
+
+#define DUMPREG(regno) \
+       kprintf(" %13s=%08x", #regno + 6, E1000_READ_REG(&sc->hw, regno));\
+       if (++col == 3) {               \
+               kprintf("\n");          \
+               col = 0;                \
+       }                               \
+
+       device_printf(dev, "REGISTER DUMP\n");
+       DUMPREG(E1000_CTRL);
+       DUMPREG(E1000_STATUS);
+       DUMPREG(E1000_EECD);
+       DUMPREG(E1000_EERD);
+       DUMPREG(E1000_CTRL_EXT);
+       DUMPREG(E1000_FLA);
+       DUMPREG(E1000_MDIC);
+       DUMPREG(E1000_SCTL);
+       DUMPREG(E1000_FCAL);
+       DUMPREG(E1000_FCAH);
+       DUMPREG(E1000_FCT);
+       DUMPREG(E1000_CONNSW);
+       DUMPREG(E1000_VET);
+       DUMPREG(E1000_ICR);
+       DUMPREG(E1000_ITR);
+       DUMPREG(E1000_IMS);
+       DUMPREG(E1000_IVAR);
+       DUMPREG(E1000_SVCR);
+       DUMPREG(E1000_SVT);
+       DUMPREG(E1000_LPIC);
+       DUMPREG(E1000_RCTL);
+       DUMPREG(E1000_FCTTV);
+       DUMPREG(E1000_TXCW);
+       DUMPREG(E1000_RXCW);
+       DUMPREG(E1000_EIMS);
+       DUMPREG(E1000_EIAC);
+       DUMPREG(E1000_EIAM);
+       DUMPREG(E1000_GPIE);
+       DUMPREG(E1000_IVAR0);
+       DUMPREG(E1000_IVAR_MISC);
+       DUMPREG(E1000_TCTL);
+       DUMPREG(E1000_TCTL_EXT);
+       DUMPREG(E1000_TIPG);
+       DUMPREG(E1000_TBT);
+       DUMPREG(E1000_AIT);
+       DUMPREG(E1000_LEDCTL);
+       DUMPREG(E1000_EXTCNF_CTRL);
+       DUMPREG(E1000_EXTCNF_SIZE);
+       DUMPREG(E1000_PHY_CTRL);
+       DUMPREG(E1000_PBA);
+       DUMPREG(E1000_PBS);
+       DUMPREG(E1000_PBECCSTS);
+       DUMPREG(E1000_EEMNGCTL);
+       DUMPREG(E1000_EEARBC);
+       DUMPREG(E1000_FLASHT);
+       DUMPREG(E1000_EEARBC_I210);
+       DUMPREG(E1000_EEWR);
+       DUMPREG(E1000_FLSWCTL);
+       DUMPREG(E1000_FLSWDATA);
+       DUMPREG(E1000_FLSWCNT);
+       DUMPREG(E1000_FLOP);
+       DUMPREG(E1000_I2CCMD);
+       DUMPREG(E1000_I2CPARAMS);
+       DUMPREG(E1000_WDSTP);
+       DUMPREG(E1000_SWDSTS);
+       DUMPREG(E1000_FRTIMER);
+       DUMPREG(E1000_TCPTIMER);
+       DUMPREG(E1000_VPDDIAG);
+       DUMPREG(E1000_IMS_V2);
+       DUMPREG(E1000_IAM_V2);
+       DUMPREG(E1000_ERT);
+       DUMPREG(E1000_FCRTL);
+       DUMPREG(E1000_FCRTH);
+       DUMPREG(E1000_PSRCTL);
+       DUMPREG(E1000_RDFH);
+       DUMPREG(E1000_RDFT);
+       DUMPREG(E1000_RDFHS);
+       DUMPREG(E1000_RDFTS);
+       DUMPREG(E1000_RDFPC);
+       DUMPREG(E1000_PBRTH);
+       DUMPREG(E1000_FCRTV);
+       DUMPREG(E1000_RDPUMB);
+       DUMPREG(E1000_RDPUAD);
+       DUMPREG(E1000_RDPUWD);
+       DUMPREG(E1000_RDPURD);
+       DUMPREG(E1000_RDPUCTL);
+       DUMPREG(E1000_PBDIAG);
+       DUMPREG(E1000_RXPBS);
+       DUMPREG(E1000_IRPBS);
+       DUMPREG(E1000_PBRWAC);
+       DUMPREG(E1000_RDTR);
+       DUMPREG(E1000_RADV);
+       DUMPREG(E1000_SRWR);
+       DUMPREG(E1000_I210_FLMNGCTL);
+       DUMPREG(E1000_I210_FLMNGDATA);
+       DUMPREG(E1000_I210_FLMNGCNT);
+       DUMPREG(E1000_I210_FLSWCTL);
+       DUMPREG(E1000_I210_FLSWDATA);
+       DUMPREG(E1000_I210_FLSWCNT);
+       DUMPREG(E1000_I210_FLA);
+       DUMPREG(E1000_INVM_SIZE);
+       DUMPREG(E1000_I210_TQAVCTRL);
+       DUMPREG(E1000_RSRPD);
+       DUMPREG(E1000_RAID);
+       DUMPREG(E1000_TXDMAC);
+       DUMPREG(E1000_KABGTXD);
+       DUMPREG(E1000_PBSLAC);
+       DUMPREG(E1000_TXPBS);
+       DUMPREG(E1000_ITPBS);
+       DUMPREG(E1000_TDFH);
+       DUMPREG(E1000_TDFT);
+       DUMPREG(E1000_TDFHS);
+       DUMPREG(E1000_TDFTS);
+       DUMPREG(E1000_TDFPC);
+       DUMPREG(E1000_TDPUMB);
+       DUMPREG(E1000_TDPUAD);
+       DUMPREG(E1000_TDPUWD);
+       DUMPREG(E1000_TDPURD);
+       DUMPREG(E1000_TDPUCTL);
+       DUMPREG(E1000_DTXCTL);
+       DUMPREG(E1000_DTXTCPFLGL);
+       DUMPREG(E1000_DTXTCPFLGH);
+       DUMPREG(E1000_DTXMXSZRQ);
+       DUMPREG(E1000_TIDV);
+       DUMPREG(E1000_TADV);
+       DUMPREG(E1000_TSPMT);
+       DUMPREG(E1000_VFGPRC);
+       DUMPREG(E1000_VFGORC);
+       DUMPREG(E1000_VFMPRC);
+       DUMPREG(E1000_VFGPTC);
+       DUMPREG(E1000_VFGOTC);
+       DUMPREG(E1000_VFGOTLBC);
+       DUMPREG(E1000_VFGPTLBC);
+       DUMPREG(E1000_VFGORLBC);
+       DUMPREG(E1000_VFGPRLBC);
+       DUMPREG(E1000_LSECTXCAP);
+       DUMPREG(E1000_LSECRXCAP);
+       DUMPREG(E1000_LSECTXCTRL);
+       DUMPREG(E1000_LSECRXCTRL);
+       DUMPREG(E1000_LSECTXSCL);
+       DUMPREG(E1000_LSECTXSCH);
+       DUMPREG(E1000_LSECTXSA);
+       DUMPREG(E1000_LSECTXPN0);
+       DUMPREG(E1000_LSECTXPN1);
+       DUMPREG(E1000_LSECRXSCL);
+       DUMPREG(E1000_LSECRXSCH);
+       DUMPREG(E1000_IPSCTRL);
+       DUMPREG(E1000_IPSRXCMD);
+       DUMPREG(E1000_IPSRXIDX);
+       DUMPREG(E1000_IPSRXSALT);
+       DUMPREG(E1000_IPSRXSPI);
+       DUMPREG(E1000_IPSTXSALT);
+       DUMPREG(E1000_IPSTXIDX);
+       DUMPREG(E1000_PCS_CFG0);
+       DUMPREG(E1000_PCS_LCTL);
+       DUMPREG(E1000_PCS_LSTAT);
+       DUMPREG(E1000_PCS_ANADV);
+       DUMPREG(E1000_PCS_LPAB);
+       DUMPREG(E1000_PCS_NPTX);
+       DUMPREG(E1000_PCS_LPABNP);
+       DUMPREG(E1000_RXCSUM);
+       DUMPREG(E1000_RLPML);
+       DUMPREG(E1000_RFCTL);
+       DUMPREG(E1000_MTA);
+       DUMPREG(E1000_RA);
+       DUMPREG(E1000_RA2);
+       DUMPREG(E1000_VFTA);
+       DUMPREG(E1000_VT_CTL);
+       DUMPREG(E1000_CIAA);
+       DUMPREG(E1000_CIAD);
+       DUMPREG(E1000_VFQA0);
+       DUMPREG(E1000_VFQA1);
+       DUMPREG(E1000_WUC);
+       DUMPREG(E1000_WUFC);
+       DUMPREG(E1000_WUS);
+       DUMPREG(E1000_MANC);
+       DUMPREG(E1000_IPAV);
+       DUMPREG(E1000_IP4AT);
+       DUMPREG(E1000_IP6AT);
+       DUMPREG(E1000_WUPL);
+       DUMPREG(E1000_WUPM);
+       DUMPREG(E1000_PBACL);
+       DUMPREG(E1000_FFLT);
+       DUMPREG(E1000_HOST_IF);
+       DUMPREG(E1000_HIBBA);
+       DUMPREG(E1000_KMRNCTRLSTA);
+       DUMPREG(E1000_MANC2H);
+       DUMPREG(E1000_CCMCTL);
+       DUMPREG(E1000_GIOCTL);
+       DUMPREG(E1000_SCCTL);
+
+#define E1000_WCS      0x558C
+       DUMPREG(E1000_WCS);
+#define E1000_GCR_EXT  0x586C
+       DUMPREG(E1000_GCR_EXT);
+       DUMPREG(E1000_GCR);
+       DUMPREG(E1000_GCR2);
+       DUMPREG(E1000_FACTPS);
+       DUMPREG(E1000_DCA_ID);
+       DUMPREG(E1000_DCA_CTRL);
+       DUMPREG(E1000_UFUSE);
+       DUMPREG(E1000_FFLT_DBG);
+       DUMPREG(E1000_HICR);
+       DUMPREG(E1000_FWSTS);
+       DUMPREG(E1000_CPUVEC);
+       DUMPREG(E1000_MRQC);
+       DUMPREG(E1000_SWPBS);
+       DUMPREG(E1000_MBVFICR);
+       DUMPREG(E1000_MBVFIMR);
+       DUMPREG(E1000_VFLRE);
+       DUMPREG(E1000_VFRE);
+       DUMPREG(E1000_VFTE);
+       DUMPREG(E1000_QDE);
+       DUMPREG(E1000_DTXSWC);
+       DUMPREG(E1000_WVBR);
+       DUMPREG(E1000_RPLOLR);
+       DUMPREG(E1000_UTA);
+       DUMPREG(E1000_IOVTCL);
+       DUMPREG(E1000_VMRCTL);
+       DUMPREG(E1000_VMRVLAN);
+       DUMPREG(E1000_VMRVM);
+       DUMPREG(E1000_LVMMC);
+       DUMPREG(E1000_TXSWC);
+       DUMPREG(E1000_SCCRL);
+       DUMPREG(E1000_BSCTRH);
+       DUMPREG(E1000_MSCTRH);
+       DUMPREG(E1000_RXSTMPL);
+       DUMPREG(E1000_RXSTMPH);
+       DUMPREG(E1000_RXSATRL);
+       DUMPREG(E1000_RXSATRH);
+       DUMPREG(E1000_TXSTMPL);
+       DUMPREG(E1000_TXSTMPH);
+       DUMPREG(E1000_TIMINCA);
+       DUMPREG(E1000_TIMADJL);
+       DUMPREG(E1000_TIMADJH);
+       DUMPREG(E1000_TSAUXC);
+       DUMPREG(E1000_SYSSTMPL);
+       DUMPREG(E1000_SYSSTMPH);
+       DUMPREG(E1000_PLTSTMPL);
+       DUMPREG(E1000_PLTSTMPH);
+       DUMPREG(E1000_RXMTRL);
+       DUMPREG(E1000_RXUDP);
+       DUMPREG(E1000_SYSTIMR);
+       DUMPREG(E1000_TSICR);
+       DUMPREG(E1000_TSIM);
+       DUMPREG(E1000_DMACR);
+       DUMPREG(E1000_DMCTXTH);
+       DUMPREG(E1000_DMCTLX);
+       DUMPREG(E1000_DMCRTRH);
+       DUMPREG(E1000_DMCCNT);
+       DUMPREG(E1000_FCRTC);
+       DUMPREG(E1000_PCIEMISC);
+       DUMPREG(E1000_PCIEERRSTS);
+       DUMPREG(E1000_IPCNFG);
+       DUMPREG(E1000_LTRC);
+       DUMPREG(E1000_EEER);
+       DUMPREG(E1000_EEE_SU);
+       DUMPREG(E1000_TLPIC);
+       DUMPREG(E1000_RLPIC);
+       if (++col != 1)
+               kprintf("\n");
+       kprintf("\n");
+}
+
+static int
+igb_sysctl_reg_dump(SYSCTL_HANDLER_ARGS)
+{
+       struct igb_softc *sc = (void *)arg1;
+       struct ifnet *ifp = &sc->arpcom.ac_if;
+       int error, dump = 0;
+
+       error = sysctl_handle_int(oidp, &dump, 0, req);
+       if (error || req->newptr == NULL)
+               return error;
+       if (dump <= 0)
+               return EINVAL;
+
+       ifnet_serialize_all(ifp);
+       igb_reg_dump(sc);
+       ifnet_deserialize_all(ifp);
+
+       return error;
+}