]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/et131x/et131x_debug.c
Merge branch 'master' of git://git.ipfire.org/ipfire-2.x
[people/pmueller/ipfire-2.x.git] / src / et131x / et131x_debug.c
1 /*
2 * Agere Systems Inc.
3 * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
4 *
5 * Copyright © 2005 Agere Systems Inc.
6 * All rights reserved.
7 * http://www.agere.com
8 *
9 *------------------------------------------------------------------------------
10 *
11 * et131x_debug.c - Routines used for debugging.
12 *
13 *------------------------------------------------------------------------------
14 *
15 * SOFTWARE LICENSE
16 *
17 * This software is provided subject to the following terms and conditions,
18 * which you should read carefully before using the software. Using this
19 * software indicates your acceptance of these terms and conditions. If you do
20 * not agree with these terms and conditions, do not use the software.
21 *
22 * Copyright © 2005 Agere Systems Inc.
23 * All rights reserved.
24 *
25 * Redistribution and use in source or binary forms, with or without
26 * modifications, are permitted provided that the following conditions are met:
27 *
28 * . Redistributions of source code must retain the above copyright notice, this
29 * list of conditions and the following Disclaimer as comments in the code as
30 * well as in the documentation and/or other materials provided with the
31 * distribution.
32 *
33 * . Redistributions in binary form must reproduce the above copyright notice,
34 * this list of conditions and the following Disclaimer in the documentation
35 * and/or other materials provided with the distribution.
36 *
37 * . Neither the name of Agere Systems Inc. nor the names of the contributors
38 * may be used to endorse or promote products derived from this software
39 * without specific prior written permission.
40 *
41 * Disclaimer
42 *
43 * THIS SOFTWARE IS PROVIDED \93AS IS\94 AND ANY EXPRESS OR IMPLIED WARRANTIES,
44 * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
45 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
46 * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
47 * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
48 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
49 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
51 * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
53 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
54 * DAMAGE.
55 *
56 */
57
58 #ifdef CONFIG_ET131X_DEBUG
59
60 #include "et131x_version.h"
61 #include "et131x_debug.h"
62 #include "et131x_defs.h"
63
64 #include <linux/pci.h>
65 #include <linux/init.h>
66 #include <linux/module.h>
67 #include <linux/types.h>
68 #include <linux/kernel.h>
69
70 #include <linux/sched.h>
71 #include <linux/ptrace.h>
72 #include <linux/slab.h>
73 #include <linux/ctype.h>
74 #include <linux/string.h>
75 #include <linux/timer.h>
76 #include <linux/interrupt.h>
77 #include <linux/in.h>
78 #include <linux/delay.h>
79 #include <asm/io.h>
80 #include <asm/system.h>
81 #include <asm/bitops.h>
82
83 #include <linux/netdevice.h>
84 #include <linux/etherdevice.h>
85 #include <linux/skbuff.h>
86 #include <linux/if_arp.h>
87 #include <linux/ioport.h>
88 #include <linux/random.h>
89
90 #include "et1310_phy.h"
91 #include "et1310_pm.h"
92 #include "et1310_jagcore.h"
93
94 #include "et131x_adapter.h"
95 #include "et131x_netdev.h"
96 #include "et131x_config.h"
97 #include "et131x_isr.h"
98
99 #include "et1310_address_map.h"
100 #include "et1310_jagcore.h"
101 #include "et1310_tx.h"
102 #include "et1310_rx.h"
103 #include "et1310_mac.h"
104
105 /* Data for debugging facilities */
106 extern dbg_info_t *et131x_dbginfo;
107
108 /**
109 * DumpTxQueueContents - Dump out the tx queue and the shadow pointers
110 * @pAdapter: pointer to our adapter structure
111 */
112 void DumpTxQueueContents(int dbgLvl, struct et131x_adapter *pAdapter)
113 {
114 MMC_t __iomem *mmc = &pAdapter->CSRAddress->mmc;
115 uint32_t TxQueueAddr;
116
117 if (DBG_FLAGS(et131x_dbginfo) & dbgLvl) {
118 for (TxQueueAddr = 0x200; TxQueueAddr < 0x3ff; TxQueueAddr++) {
119 MMC_SRAM_ACCESS_t sram_access;
120
121 sram_access.value = readl(&mmc->sram_access.value);
122 sram_access.bits.req_addr = TxQueueAddr;
123 sram_access.bits.req_access = 1;
124 writel(sram_access.value, &mmc->sram_access.value);
125
126 DBG_PRINT("Addr 0x%x, Access 0x%08x\t"
127 "Value 1 0x%08x, Value 2 0x%08x, "
128 "Value 3 0x%08x, Value 4 0x%08x, \n",
129 TxQueueAddr,
130 readl(&mmc->sram_access.value),
131 readl(&mmc->sram_word1),
132 readl(&mmc->sram_word2),
133 readl(&mmc->sram_word3),
134 readl(&mmc->sram_word4));
135 }
136
137 DBG_PRINT("Shadow Pointers 0x%08x\n",
138 readl(&pAdapter->CSRAddress->txmac.shadow_ptr.value));
139 }
140 }
141
142 /**
143 * DumpDeviceBlock
144 * @pAdapter: pointer to our adapter
145 *
146 * Dumps the first 64 regs of each block of the et-1310 (each block is
147 * mapped to a new page, each page is 4096 bytes).
148 */
149 #define NUM_BLOCKS 8
150 void DumpDeviceBlock(int dbgLvl, struct et131x_adapter *pAdapter,
151 uint32_t Block)
152 {
153 uint32_t Address1, Address2;
154 uint32_t __iomem *BigDevicePointer =
155 (uint32_t __iomem *) pAdapter->CSRAddress;
156 const char *BlockNames[NUM_BLOCKS] = {
157 "Global", "Tx DMA", "Rx DMA", "Tx MAC",
158 "Rx MAC", "MAC", "MAC Stat", "MMC"
159 };
160
161 /* Output the debug counters to the debug terminal */
162 if (DBG_FLAGS(et131x_dbginfo) & dbgLvl) {
163 DBG_PRINT("%s block\n", BlockNames[Block]);
164 BigDevicePointer += Block * 1024;
165 for (Address1 = 0; Address1 < 8; Address1++) {
166 for (Address2 = 0; Address2 < 8; Address2++) {
167 if (Block == 0 &&
168 (Address1 * 8 + Address2) == 6) {
169 DBG_PRINT(" ISR , ");
170 } else {
171 DBG_PRINT("0x%08x, ",
172 readl(BigDevicePointer++));
173 }
174 }
175 DBG_PRINT("\n");
176 }
177 DBG_PRINT("\n");
178 }
179 }
180
181 /**
182 * DumpDeviceReg
183 * @pAdapter: pointer to our adapter
184 *
185 * Dumps the first 64 regs of each block of the et-1310 (each block is
186 * mapped to a new page, each page is 4096 bytes).
187 */
188 void DumpDeviceReg(int dbgLvl, struct et131x_adapter *pAdapter)
189 {
190 uint32_t Address1, Address2;
191 uint32_t Block;
192 uint32_t __iomem *BigDevicePointer =
193 (uint32_t __iomem *) pAdapter->CSRAddress;
194 uint32_t __iomem *Pointer;
195 const char *BlockNames[NUM_BLOCKS] = {
196 "Global", "Tx DMA", "Rx DMA", "Tx MAC",
197 "Rx MAC", "MAC", "MAC Stat", "MMC"
198 };
199
200 /* Output the debug counters to the debug terminal */
201 if (DBG_FLAGS(et131x_dbginfo) & dbgLvl) {
202 for (Block = 0; Block < NUM_BLOCKS; Block++) {
203 DBG_PRINT("%s block\n", BlockNames[Block]);
204 Pointer = BigDevicePointer + (Block * 1024);
205
206 for (Address1 = 0; Address1 < 8; Address1++) {
207 for (Address2 = 0; Address2 < 8; Address2++) {
208 DBG_PRINT("0x%08x, ",
209 readl(Pointer++));
210 }
211 DBG_PRINT("\n");
212 }
213 DBG_PRINT("\n");
214 }
215 }
216 }
217
218 #endif // CONFIG_ET131X_DEBUG