3 * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
5 * Copyright © 2005 Agere Systems Inc.
9 *------------------------------------------------------------------------------
11 * et131x_debug.c - Routines used for debugging.
13 *------------------------------------------------------------------------------
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.
22 * Copyright © 2005 Agere Systems Inc.
23 * All rights reserved.
25 * Redistribution and use in source or binary forms, with or without
26 * modifications, are permitted provided that the following conditions are met:
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
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.
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.
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
58 #ifdef CONFIG_ET131X_DEBUG
60 #include "et131x_version.h"
61 #include "et131x_debug.h"
62 #include "et131x_defs.h"
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>
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>
78 #include <linux/delay.h>
80 #include <asm/system.h>
81 #include <asm/bitops.h>
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>
90 #include "et1310_phy.h"
91 #include "et1310_pm.h"
92 #include "et1310_jagcore.h"
94 #include "et131x_adapter.h"
95 #include "et131x_netdev.h"
96 #include "et131x_config.h"
97 #include "et131x_isr.h"
99 #include "et1310_address_map.h"
100 #include "et1310_tx.h"
101 #include "et1310_rx.h"
102 #include "et1310_mac.h"
104 /* Data for debugging facilities */
105 extern dbg_info_t *et131x_dbginfo;
108 * DumpTxQueueContents - Dump out the tx queue and the shadow pointers
109 * @pAdapter: pointer to our adapter structure
111 void DumpTxQueueContents(int dbgLvl, struct et131x_adapter *pAdapter)
113 MMC_t __iomem *mmc = &pAdapter->CSRAddress->mmc;
114 uint32_t TxQueueAddr;
116 if (DBG_FLAGS(et131x_dbginfo) & dbgLvl) {
117 for (TxQueueAddr = 0x200; TxQueueAddr < 0x3ff; TxQueueAddr++) {
118 MMC_SRAM_ACCESS_t sram_access;
120 sram_access.value = readl(&mmc->sram_access.value);
121 sram_access.bits.req_addr = TxQueueAddr;
122 sram_access.bits.req_access = 1;
123 writel(sram_access.value, &mmc->sram_access.value);
125 DBG_PRINT("Addr 0x%x, Access 0x%08x\t"
126 "Value 1 0x%08x, Value 2 0x%08x, "
127 "Value 3 0x%08x, Value 4 0x%08x, \n",
129 readl(&mmc->sram_access.value),
130 readl(&mmc->sram_word1),
131 readl(&mmc->sram_word2),
132 readl(&mmc->sram_word3),
133 readl(&mmc->sram_word4));
136 DBG_PRINT("Shadow Pointers 0x%08x\n",
137 readl(&pAdapter->CSRAddress->txmac.shadow_ptr.value));
143 * @pAdapter: pointer to our adapter
145 * Dumps the first 64 regs of each block of the et-1310 (each block is
146 * mapped to a new page, each page is 4096 bytes).
149 void DumpDeviceBlock(int dbgLvl, struct et131x_adapter *pAdapter,
152 uint32_t Address1, Address2;
153 uint32_t __iomem *BigDevicePointer =
154 (uint32_t __iomem *) pAdapter->CSRAddress;
155 const char *BlockNames[NUM_BLOCKS] = {
156 "Global", "Tx DMA", "Rx DMA", "Tx MAC",
157 "Rx MAC", "MAC", "MAC Stat", "MMC"
160 /* Output the debug counters to the debug terminal */
161 if (DBG_FLAGS(et131x_dbginfo) & dbgLvl) {
162 DBG_PRINT("%s block\n", BlockNames[Block]);
163 BigDevicePointer += Block * 1024;
164 for (Address1 = 0; Address1 < 8; Address1++) {
165 for (Address2 = 0; Address2 < 8; Address2++) {
167 (Address1 * 8 + Address2) == 6) {
168 DBG_PRINT(" ISR , ");
170 DBG_PRINT("0x%08x, ",
171 readl(BigDevicePointer++));
182 * @pAdapter: pointer to our adapter
184 * Dumps the first 64 regs of each block of the et-1310 (each block is
185 * mapped to a new page, each page is 4096 bytes).
187 void DumpDeviceReg(int dbgLvl, struct et131x_adapter *pAdapter)
189 uint32_t Address1, Address2;
191 uint32_t __iomem *BigDevicePointer =
192 (uint32_t __iomem *) pAdapter->CSRAddress;
193 uint32_t __iomem *Pointer;
194 const char *BlockNames[NUM_BLOCKS] = {
195 "Global", "Tx DMA", "Rx DMA", "Tx MAC",
196 "Rx MAC", "MAC", "MAC Stat", "MMC"
199 /* Output the debug counters to the debug terminal */
200 if (DBG_FLAGS(et131x_dbginfo) & dbgLvl) {
201 for (Block = 0; Block < NUM_BLOCKS; Block++) {
202 DBG_PRINT("%s block\n", BlockNames[Block]);
203 Pointer = BigDevicePointer + (Block * 1024);
205 for (Address1 = 0; Address1 < 8; Address1++) {
206 for (Address2 = 0; Address2 < 8; Address2++) {
207 DBG_PRINT("0x%08x, ",
217 #endif // CONFIG_ET131X_DEBUG