Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 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 AS IS 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" |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 100 | #include "et1310_tx.h" |
| 101 | #include "et1310_rx.h" |
| 102 | #include "et1310_mac.h" |
| 103 | |
| 104 | /* Data for debugging facilities */ |
| 105 | extern dbg_info_t *et131x_dbginfo; |
| 106 | |
| 107 | /** |
| 108 | * DumpTxQueueContents - Dump out the tx queue and the shadow pointers |
| 109 | * @pAdapter: pointer to our adapter structure |
| 110 | */ |
| 111 | void DumpTxQueueContents(int dbgLvl, struct et131x_adapter *pAdapter) |
| 112 | { |
| 113 | MMC_t __iomem *mmc = &pAdapter->CSRAddress->mmc; |
| 114 | uint32_t TxQueueAddr; |
| 115 | |
| 116 | if (DBG_FLAGS(et131x_dbginfo) & dbgLvl) { |
| 117 | for (TxQueueAddr = 0x200; TxQueueAddr < 0x3ff; TxQueueAddr++) { |
| 118 | MMC_SRAM_ACCESS_t sram_access; |
| 119 | |
| 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); |
| 124 | |
| 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", |
| 128 | TxQueueAddr, |
| 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)); |
| 134 | } |
| 135 | |
| 136 | DBG_PRINT("Shadow Pointers 0x%08x\n", |
| 137 | readl(&pAdapter->CSRAddress->txmac.shadow_ptr.value)); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * DumpDeviceBlock |
| 143 | * @pAdapter: pointer to our adapter |
| 144 | * |
| 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). |
| 147 | */ |
| 148 | #define NUM_BLOCKS 8 |
| 149 | void DumpDeviceBlock(int dbgLvl, struct et131x_adapter *pAdapter, |
| 150 | uint32_t Block) |
| 151 | { |
| 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" |
| 158 | }; |
| 159 | |
| 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++) { |
| 166 | if (Block == 0 && |
| 167 | (Address1 * 8 + Address2) == 6) { |
| 168 | DBG_PRINT(" ISR , "); |
| 169 | } else { |
| 170 | DBG_PRINT("0x%08x, ", |
| 171 | readl(BigDevicePointer++)); |
| 172 | } |
| 173 | } |
| 174 | DBG_PRINT("\n"); |
| 175 | } |
| 176 | DBG_PRINT("\n"); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * DumpDeviceReg |
| 182 | * @pAdapter: pointer to our adapter |
| 183 | * |
| 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). |
| 186 | */ |
| 187 | void DumpDeviceReg(int dbgLvl, struct et131x_adapter *pAdapter) |
| 188 | { |
| 189 | uint32_t Address1, Address2; |
| 190 | uint32_t Block; |
| 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" |
| 197 | }; |
| 198 | |
| 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); |
| 204 | |
| 205 | for (Address1 = 0; Address1 < 8; Address1++) { |
| 206 | for (Address2 = 0; Address2 < 8; Address2++) { |
| 207 | DBG_PRINT("0x%08x, ", |
| 208 | readl(Pointer++)); |
| 209 | } |
| 210 | DBG_PRINT("\n"); |
| 211 | } |
| 212 | DBG_PRINT("\n"); |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | #endif // CONFIG_ET131X_DEBUG |