Module Name:    src
Committed By:   msaitoh
Date:           Thu Nov  4 12:25:05 UTC 2021

Modified Files:
        src/sys/dev/pci: if_wm.c

Log Message:
Add some sysctl info for debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.715 -r1.716 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.715 src/sys/dev/pci/if_wm.c:1.716
--- src/sys/dev/pci/if_wm.c:1.715	Wed Oct 20 08:10:26 2021
+++ src/sys/dev/pci/if_wm.c	Thu Nov  4 12:25:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.715 2021/10/20 08:10:26 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.716 2021/11/04 12:25:05 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.715 2021/10/20 08:10:26 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.716 2021/11/04 12:25:05 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1068,6 +1068,8 @@ static bool	wm_phy_need_linkdown_discard
 static void	wm_set_linkdown_discard(struct wm_softc *);
 static void	wm_clear_linkdown_discard(struct wm_softc *);
 
+static int	wm_sysctl_tdh_handler(SYSCTLFN_PROTO);
+static int	wm_sysctl_tdt_handler(SYSCTLFN_PROTO);
 #ifdef WM_DEBUG
 static int	wm_sysctl_debug(SYSCTLFN_PROTO);
 #endif
@@ -5991,6 +5993,7 @@ wm_init_sysctls(struct wm_softc *sc)
 		    sc->sc_queue[i].sysctlname, SYSCTL_DESCR("Queue Name"),
 		    NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL) != 0)
 			break;
+
 		if (sysctl_createv(log, 0, &qnode, &cnode,
 		    CTLFLAG_READONLY, CTLTYPE_INT,
 		    "txq_free", SYSCTL_DESCR("TX queue free"),
@@ -5999,10 +6002,58 @@ wm_init_sysctls(struct wm_softc *sc)
 			break;
 		if (sysctl_createv(log, 0, &qnode, &cnode,
 		    CTLFLAG_READONLY, CTLTYPE_INT,
+		    "txd_head", SYSCTL_DESCR("TX descriptor head"),
+		    wm_sysctl_tdh_handler, 0, (void *)txq,
+		    0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, &qnode, &cnode,
+		    CTLFLAG_READONLY, CTLTYPE_INT,
+		    "txd_tail", SYSCTL_DESCR("TX descriptor tail"),
+		    wm_sysctl_tdt_handler, 0, (void *)txq,
+		    0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, &qnode, &cnode,
+		    CTLFLAG_READONLY, CTLTYPE_INT,
 		    "txq_next", SYSCTL_DESCR("TX queue next"),
 		    NULL, 0, &txq->txq_next,
 		    0, CTL_CREATE, CTL_EOL) != 0)
 			break;
+		if (sysctl_createv(log, 0, &qnode, &cnode,
+		    CTLFLAG_READONLY, CTLTYPE_INT,
+		    "txq_sfree", SYSCTL_DESCR("TX queue sfree"),
+		    NULL, 0, &txq->txq_sfree,
+		    0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, &qnode, &cnode,
+		    CTLFLAG_READONLY, CTLTYPE_INT,
+		    "txq_snext", SYSCTL_DESCR("TX queue snext"),
+		    NULL, 0, &txq->txq_snext,
+		    0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, &qnode, &cnode,
+		    CTLFLAG_READONLY, CTLTYPE_INT,
+		    "txq_sdirty", SYSCTL_DESCR("TX queue sdirty"),
+		    NULL, 0, &txq->txq_sdirty,
+		    0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, &qnode, &cnode,
+		    CTLFLAG_READONLY, CTLTYPE_INT,
+		    "txq_flags", SYSCTL_DESCR("TX queue flags"),
+		    NULL, 0, &txq->txq_flags,
+		    0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, &qnode, &cnode,
+		    CTLFLAG_READONLY, CTLTYPE_BOOL,
+		    "txq_stopping", SYSCTL_DESCR("TX queue stopping"),
+		    NULL, 0, &txq->txq_stopping,
+		    0, CTL_CREATE, CTL_EOL) != 0)
+			break;
+		if (sysctl_createv(log, 0, &qnode, &cnode,
+		    CTLFLAG_READONLY, CTLTYPE_BOOL,
+		    "txq_sending", SYSCTL_DESCR("TX queue sending"),
+		    NULL, 0, &txq->txq_sending,
+		    0, CTL_CREATE, CTL_EOL) != 0)
+			break;
 
 		if (sysctl_createv(log, 0, &qnode, &cnode,
 		    CTLFLAG_READONLY, CTLTYPE_INT,
@@ -17084,7 +17135,35 @@ wm_legacy_irq_quirk_spt(struct wm_softc 
 	CSR_WRITE(sc, WMREG_FEXTNVM9, reg);
 }
 
-/* Sysctl function */
+/* Sysctl functions */
+static int
+wm_sysctl_tdh_handler(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node = *rnode;
+	struct wm_txqueue *txq = (struct wm_txqueue *)node.sysctl_data;
+	struct wm_queue *wmq = container_of(txq, struct wm_queue, wmq_txq);
+	struct wm_softc *sc = txq->txq_sc; 
+	uint32_t reg;
+
+	reg = CSR_READ(sc, WMREG_TDH(wmq->wmq_id));
+	node.sysctl_data = &reg;
+	return sysctl_lookup(SYSCTLFN_CALL(&node));
+}
+
+static int
+wm_sysctl_tdt_handler(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node = *rnode;
+	struct wm_txqueue *txq = (struct wm_txqueue *)node.sysctl_data;
+	struct wm_queue *wmq = container_of(txq, struct wm_queue, wmq_txq);
+	struct wm_softc *sc = txq->txq_sc; 
+	uint32_t reg;
+
+	reg = CSR_READ(sc, WMREG_TDT(wmq->wmq_id));
+	node.sysctl_data = &reg;
+	return sysctl_lookup(SYSCTLFN_CALL(&node));
+}
+
 #ifdef WM_DEBUG
 static int
 wm_sysctl_debug(SYSCTLFN_ARGS)
@@ -17102,6 +17181,8 @@ wm_sysctl_debug(SYSCTLFN_ARGS)
 		return error;
 
 	sc->sc_debug = dflags;
+	device_printf(sc->sc_dev, "TARC0: %08x\n", CSR_READ(sc, WMREG_TARC0));
+	device_printf(sc->sc_dev, "TDT0: %08x\n", CSR_READ(sc, WMREG_TDT(0)));
 
 	return 0;
 }

Reply via email to