• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <stdio.h>
2 #include <string.h>
3 #include "internal.h"
4 
5 #define TG3_MAGIC 0x669955aa
6 
tg3_dump_eeprom(struct ethtool_drvinfo * info maybe_unused,struct ethtool_eeprom * ee)7 int tg3_dump_eeprom(struct ethtool_drvinfo *info maybe_unused,
8 		    struct ethtool_eeprom *ee)
9 {
10 	int i;
11 
12 	if (ee->magic != TG3_MAGIC) {
13 		fprintf(stderr, "Magic number 0x%08x does not match 0x%08x\n",
14 			ee->magic, TG3_MAGIC);
15 		return -1;
16 	}
17 
18 	fprintf(stdout, "Address   \tData\n");
19 	fprintf(stdout, "----------\t----\n");
20 	for (i = 0; i < ee->len; i++)
21 		fprintf(stdout, "0x%08x\t0x%02x\n", i + ee->offset, ee->data[i]);
22 
23 	return 0;
24 }
25 
tg3_dump_regs(struct ethtool_drvinfo * info maybe_unused,struct ethtool_regs * regs)26 int tg3_dump_regs(struct ethtool_drvinfo *info maybe_unused,
27 		  struct ethtool_regs *regs)
28 {
29 	int i;
30 	u32 reg;
31 
32 	fprintf(stdout, "Offset\tValue\n");
33 	fprintf(stdout, "------\t----------\n");
34 	for (i = 0; i < regs->len; i += sizeof(reg)) {
35 		memcpy(&reg, &regs->data[i], sizeof(reg));
36 		if (reg)
37 			fprintf(stdout, "0x%04x\t0x%08x\n", i, reg);
38 
39 	}
40 	fprintf(stdout, "\n");
41 	return 0;
42 }
43