Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Oct 2007 16:03:17 -0700
From:      "Jack Vogel" <jfvogel@gmail.com>
To:        "Mike Tancsa" <mike@sentex.net>,  "freebsd-net@freebsd.org" <freebsd-net@freebsd.org>,  "FreeBSD Current" <freebsd-current@freebsd.org>
Subject:   Patch to add EEPROM dump
Message-ID:  <2a41acea0710091603u7b87d6fdsdaaadf4cafbea2d9@mail.gmail.com>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Mike,

      This is a patch against my 6.6.6 driver that adds a new value to the
debug sysctl, you would give the command 'sysctl dev.em.0.debug=2'
and it will dump out the first 32 16-bit words of the prom.

Mike, go to e1000.sourceforge.net/wiki and look under issues, you
will find one talking about 82573, that will show you the word that
gets patched, and you can look at your own with this patch.

I was wondering what the general reaction to this is, it may be useful
at some points in helping debug things.

Comments?

Jack

[-- Attachment #2 --]
--- if_em.c	Fri Oct  5 09:23:50 2007
+++ /tmp/if_em.eeprom.c	Tue Oct  9 15:53:40 2007
@@ -279,6 +279,7 @@
 		    struct em_dma_alloc *, int);
 static void	em_dma_free(struct adapter *, struct em_dma_alloc *);
 static void	em_print_debug_info(struct adapter *);
+static void	em_print_nvm_info(struct adapter *);
 static int 	em_is_valid_ether_addr(uint8_t *);
 static int	em_sysctl_stats(SYSCTL_HANDLER_ARGS);
 static int	em_sysctl_debug_info(SYSCTL_HANDLER_ARGS);
@@ -447,7 +448,7 @@
 	/* SYSCTL stuff */
 	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
 	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-	    OID_AUTO, "debug_info", CTLTYPE_INT|CTLFLAG_RW, adapter, 0,
+	    OID_AUTO, "debug", CTLTYPE_INT|CTLFLAG_RW, adapter, 0,
 	    em_sysctl_debug_info, "I", "Debug Information");
 
 	SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
@@ -5099,6 +5100,33 @@
 	    (long long)adapter->stats.tsctfc);
 }
 
+/**********************************************************************
+ *
+ *  This routine provides a way to dump out the adapter eeprom,
+ *  often a useful debug/service tool. This only dumps the first
+ *  32 words, stuff that matters is in that extent.
+ *
+ **********************************************************************/
+static void
+em_print_nvm_info(struct adapter *adapter)
+{
+	u16	eeprom_data;
+	int	i, j, row = 0;
+
+	/* Its a bit crude, but it gets the job done */
+	printf("\nInterface EEPROM Dump:\n");
+	printf("Offset\n0x0000  ");
+	for (i = 0, j = 0; i < 32; i++, j++) {
+		if (j == 8) { /* Make the offset block */
+			j = 0; ++row;
+			printf("\n0x00%x0  ",row);
+		}
+		e1000_read_nvm(&adapter->hw, i, 1, &eeprom_data);
+		printf("%04x ", eeprom_data);
+	}
+	printf("\n");
+}
+
 static int
 em_sysctl_debug_info(SYSCTL_HANDLER_ARGS)
 {
@@ -5115,6 +5143,15 @@
 	if (result == 1) {
 		adapter = (struct adapter *)arg1;
 		em_print_debug_info(adapter);
+	}
+	/*
+	 * This value will cause a hex dump of the
+	 * first 32 16-bit words of the EEPROM to
+	 * the screen.
+	 */
+	if (result == 2) {
+		adapter = (struct adapter *)arg1;
+		em_print_nvm_info(adapter);
 	}
 
 	return (error);

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2a41acea0710091603u7b87d6fdsdaaadf4cafbea2d9>