1 /****************************************************************************
2 * Support for the Altera Triple Speed Ethernet 10/100/1000 Controller
3 *
4 * Copyright (C) 2014 Altera Corporation
5 *
6 * Author: Vince Bridgers <vbridgers2013@gmail.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation, incorporated herein by reference.
11 */
12
13 #include <stdio.h>
14 #include <string.h>
15 #include "internal.h"
16
17 #define ALTERA_VERSION_MASK 0xffff
18 #define ALTERA_ETHTOOL_V1 1
19
20 int
bitset(u32 val,int bit)21 bitset(u32 val, int bit)
22 {
23 if (val & (1 << bit))
24 return 1;
25 return 0;
26 }
27
altera_tse_dump_regs(struct ethtool_drvinfo * info maybe_unused,struct ethtool_regs * regs)28 int altera_tse_dump_regs(struct ethtool_drvinfo *info maybe_unused,
29 struct ethtool_regs *regs)
30 {
31 int i;
32 u32 *tsereg = (unsigned int *)regs->data;
33 u32 version = regs->version;
34
35 if ((version & ALTERA_VERSION_MASK) > ALTERA_ETHTOOL_V1)
36 return -1;
37
38 /*
39 * Version 1: Initial TSE driver release. No feature information
40 * available, 32-bits of version is equal to 1.
41 *
42 * Version 2: Lower 16-bits of version is 2, upper 16 bits are:
43 * Bit 16 - SGMDA or MSGDMA Registers
44 * Bit 17 - PCS Present
45 * Bit 18 - Supplementary MAC Address Filter Registers Present
46 * Bit 19 - Multicast Hash Filter Present
47 * Bit 20 - IEEE 1588 Feature Present
48 */
49 fprintf(stdout, "Altera TSE 10/100/1000 Registers, Version %d\n",
50 version);
51 fprintf(stdout, "---------------------------------------------\n");
52 fprintf(stdout, "Revision 0x%08X\n", tsereg[0]);
53 fprintf(stdout, " Core Version %d.%d\n",
54 (tsereg[0] & 0xffff) >> 8,
55 tsereg[0] & 0xff);
56 fprintf(stdout, " CustVersion 0x%08X\n", tsereg[0] >> 16);
57 fprintf(stdout, "Scratch 0x%08X\n", tsereg[1]);
58 fprintf(stdout, "Command/Config 0x%08X\n", tsereg[2]);
59 fprintf(stdout, " (0)TX_EN %d\n", bitset(tsereg[2], 0));
60 fprintf(stdout, " (1)RX_EN %d\n", bitset(tsereg[2], 1));
61 fprintf(stdout, " (2)XON_GEN %d\n", bitset(tsereg[2], 2));
62 fprintf(stdout, " (3)ETH_SPEED %d\n", bitset(tsereg[2], 3));
63 fprintf(stdout, " (4)PROMIS_EN %d\n", bitset(tsereg[2], 4));
64 fprintf(stdout, " (5)PAD_EN %d\n", bitset(tsereg[2], 5));
65 fprintf(stdout, " (6)CRC_FWD %d\n", bitset(tsereg[2], 6));
66 fprintf(stdout, " (7)PAUSE_FWD %d\n", bitset(tsereg[2], 7));
67 fprintf(stdout, " (8)PAUSE_IGN %d\n", bitset(tsereg[2], 8));
68 fprintf(stdout, " (9)TXADDR_INS %d\n", bitset(tsereg[2], 9));
69 fprintf(stdout, " (10)HD_EN %d\n", bitset(tsereg[2], 10));
70 fprintf(stdout, " (11)EXCESS_COL %d\n", bitset(tsereg[2], 11));
71 fprintf(stdout, " (12)LATE_COL %d\n", bitset(tsereg[2], 12));
72 fprintf(stdout, " (13)SW_RESET %d\n", bitset(tsereg[2], 13));
73 fprintf(stdout, " (14)MHASH_SEL %d\n", bitset(tsereg[2], 14));
74 fprintf(stdout, " (15)LOOP_EN %d\n", bitset(tsereg[2], 15));
75 fprintf(stdout, " (16-18)TX_ADDR_SEL %d\n",
76 (tsereg[2] & 0x30000) >> 16);
77 fprintf(stdout, " (19)MAGIC_EN %d\n", bitset(tsereg[2], 19));
78 fprintf(stdout, " (20)SLEEP %d\n", bitset(tsereg[2], 20));
79 fprintf(stdout, " (21)WAKEUP %d\n", bitset(tsereg[2], 21));
80 fprintf(stdout, " (22)XOFF_GEN %d\n", bitset(tsereg[2], 22));
81 fprintf(stdout, " (23)CTRL_FRAME_EN %d\n", bitset(tsereg[2], 23));
82 fprintf(stdout, " (24)NO_LEN_CHECK %d\n", bitset(tsereg[2], 24));
83 fprintf(stdout, " (25)ENA_10 %d\n", bitset(tsereg[2], 25));
84 fprintf(stdout, " (26)RX_ERR_DISC %d\n", bitset(tsereg[2], 26));
85 fprintf(stdout, " (31)CTRL_RESET %d\n", bitset(tsereg[2], 31));
86 fprintf(stdout, "mac_0 0x%08X\n", tsereg[3]);
87 fprintf(stdout, "mac_1 0x%08X\n", tsereg[4]);
88 fprintf(stdout, "frm_length 0x%08X\n", tsereg[5]);
89 fprintf(stdout, "pause_quant 0x%08X\n", tsereg[6]);
90 fprintf(stdout, "rx_section_empty 0x%08X\n", tsereg[7]);
91 fprintf(stdout, "rx_section_full 0x%08X\n", tsereg[8]);
92 fprintf(stdout, "tx_section_empty 0x%08X\n", tsereg[9]);
93 fprintf(stdout, "tx_section_full 0x%08X\n", tsereg[0xa]);
94 fprintf(stdout, "rx_almost_empty 0x%08X\n", tsereg[0xb]);
95 fprintf(stdout, "rx_almost_full 0x%08X\n", tsereg[0xc]);
96 fprintf(stdout, "tx_almost_empty 0x%08X\n", tsereg[0xd]);
97 fprintf(stdout, "tx_almost_full 0x%08X\n", tsereg[0xe]);
98 fprintf(stdout, "mdio_addr0 0x%08X\n", tsereg[0xf]);
99 fprintf(stdout, "mdio_addr1 0x%08X\n", tsereg[0x10]);
100 fprintf(stdout, "holdoff_quant 0x%08X\n", tsereg[0x11]);
101
102 fprintf(stdout, "tx_ipg_length 0x%08X\n", tsereg[0x17]);
103 fprintf(stdout, "Transmit Command 0x%08X\n", tsereg[0x3a]);
104 fprintf(stdout, "Receive Command 0x%08X\n", tsereg[0x3b]);
105
106 for (i = 0; i < 64; i++)
107 fprintf(stdout, "Multicast Hash[%02d] 0x%08X\n",
108 i,
109 tsereg[0x40 + i]);
110 return 0;
111 }
112
113