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_jagcore.h"
101 #include "et1310_tx.h"
102 #include "et1310_rx.h"
103 #include "et1310_mac.h"
105 /* Data for debugging facilities */
106 extern dbg_info_t
*et131x_dbginfo
;
109 * DumpTxQueueContents - Dump out the tx queue and the shadow pointers
110 * @pAdapter: pointer to our adapter structure
112 void DumpTxQueueContents(int dbgLvl
, struct et131x_adapter
*pAdapter
)
114 MMC_t __iomem
*mmc
= &pAdapter
->CSRAddress
->mmc
;
115 uint32_t TxQueueAddr
;
117 if (DBG_FLAGS(et131x_dbginfo
) & dbgLvl
) {
118 for (TxQueueAddr
= 0x200; TxQueueAddr
< 0x3ff; TxQueueAddr
++) {
119 MMC_SRAM_ACCESS_t sram_access
;
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
);
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",
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
));
137 DBG_PRINT("Shadow Pointers 0x%08x\n",
138 readl(&pAdapter
->CSRAddress
->txmac
.shadow_ptr
.value
));
144 * @pAdapter: pointer to our adapter
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).
150 void DumpDeviceBlock(int dbgLvl
, struct et131x_adapter
*pAdapter
,
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"
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
++) {
168 (Address1
* 8 + Address2
) == 6) {
169 DBG_PRINT(" ISR , ");
171 DBG_PRINT("0x%08x, ",
172 readl(BigDevicePointer
++));
183 * @pAdapter: pointer to our adapter
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).
188 void DumpDeviceReg(int dbgLvl
, struct et131x_adapter
*pAdapter
)
190 uint32_t Address1
, Address2
;
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"
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);
206 for (Address1
= 0; Address1
< 8; Address1
++) {
207 for (Address2
= 0; Address2
< 8; Address2
++) {
208 DBG_PRINT("0x%08x, ",
218 #endif // CONFIG_ET131X_DEBUG