2 * drivers/net/ibm_emac/ibm_emac_debug.c
4 * Driver for PowerPC 4xx on-chip ethernet controller, debug print routines.
6 * Copyright (c) 2004, 2005 Zultys Technologies
7 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
15 #include <linux/config.h>
16 #include <linux/init.h>
17 #include <linux/module.h>
18 #include <linux/kernel.h>
19 #include <linux/netdevice.h>
20 #include <linux/sysrq.h>
23 #include "ibm_emac_core.h"
25 static void emac_desc_dump(int idx
, struct ocp_enet_private
*p
)
28 printk("** EMAC%d TX BDs **\n"
29 " tx_cnt = %d tx_slot = %d ack_slot = %d\n",
30 idx
, p
->tx_cnt
, p
->tx_slot
, p
->ack_slot
);
31 for (i
= 0; i
< NUM_TX_BUFF
/ 2; ++i
)
33 ("bd[%2d] 0x%08x %c 0x%04x %4u - bd[%2d] 0x%08x %c 0x%04x %4u\n",
34 i
, p
->tx_desc
[i
].data_ptr
, p
->tx_skb
[i
] ? 'V' : ' ',
35 p
->tx_desc
[i
].ctrl
, p
->tx_desc
[i
].data_len
,
37 p
->tx_desc
[NUM_TX_BUFF
/ 2 + i
].data_ptr
,
38 p
->tx_skb
[NUM_TX_BUFF
/ 2 + i
] ? 'V' : ' ',
39 p
->tx_desc
[NUM_TX_BUFF
/ 2 + i
].ctrl
,
40 p
->tx_desc
[NUM_TX_BUFF
/ 2 + i
].data_len
);
42 printk("** EMAC%d RX BDs **\n"
43 " rx_slot = %d rx_stopped = %d rx_skb_size = %d rx_sync_size = %d\n"
44 " rx_sg_skb = 0x%p\n",
45 idx
, p
->rx_slot
, p
->commac
.rx_stopped
, p
->rx_skb_size
,
46 p
->rx_sync_size
, p
->rx_sg_skb
);
47 for (i
= 0; i
< NUM_RX_BUFF
/ 2; ++i
)
49 ("bd[%2d] 0x%08x %c 0x%04x %4u - bd[%2d] 0x%08x %c 0x%04x %4u\n",
50 i
, p
->rx_desc
[i
].data_ptr
, p
->rx_skb
[i
] ? 'V' : ' ',
51 p
->rx_desc
[i
].ctrl
, p
->rx_desc
[i
].data_len
,
53 p
->rx_desc
[NUM_RX_BUFF
/ 2 + i
].data_ptr
,
54 p
->rx_skb
[NUM_RX_BUFF
/ 2 + i
] ? 'V' : ' ',
55 p
->rx_desc
[NUM_RX_BUFF
/ 2 + i
].ctrl
,
56 p
->rx_desc
[NUM_RX_BUFF
/ 2 + i
].data_len
);
59 static void emac_mac_dump(int idx
, struct ocp_enet_private
*dev
)
61 struct emac_regs __iomem
*p
= dev
->emacp
;
63 printk("** EMAC%d registers **\n"
64 "MR0 = 0x%08x MR1 = 0x%08x TMR0 = 0x%08x TMR1 = 0x%08x\n"
65 "RMR = 0x%08x ISR = 0x%08x ISER = 0x%08x\n"
66 "IAR = %04x%08x VTPID = 0x%04x VTCI = 0x%04x\n"
67 "IAHT: 0x%04x 0x%04x 0x%04x 0x%04x "
68 "GAHT: 0x%04x 0x%04x 0x%04x 0x%04x\n"
69 "LSA = %04x%08x IPGVR = 0x%04x\n"
70 "STACR = 0x%08x TRTR = 0x%08x RWMR = 0x%08x\n"
71 "OCTX = 0x%08x OCRX = 0x%08x IPCR = 0x%08x\n",
72 idx
, in_be32(&p
->mr0
), in_be32(&p
->mr1
),
73 in_be32(&p
->tmr0
), in_be32(&p
->tmr1
),
74 in_be32(&p
->rmr
), in_be32(&p
->isr
), in_be32(&p
->iser
),
75 in_be32(&p
->iahr
), in_be32(&p
->ialr
), in_be32(&p
->vtpid
),
77 in_be32(&p
->iaht1
), in_be32(&p
->iaht2
), in_be32(&p
->iaht3
),
79 in_be32(&p
->gaht1
), in_be32(&p
->gaht2
), in_be32(&p
->gaht3
),
81 in_be32(&p
->lsah
), in_be32(&p
->lsal
), in_be32(&p
->ipgvr
),
82 in_be32(&p
->stacr
), in_be32(&p
->trtr
), in_be32(&p
->rwmr
),
83 in_be32(&p
->octx
), in_be32(&p
->ocrx
), in_be32(&p
->ipcr
)
86 emac_desc_dump(idx
, dev
);
89 static void emac_mal_dump(struct ibm_ocp_mal
*mal
)
91 struct ocp_func_mal_data
*maldata
= mal
->def
->additions
;
94 printk("** MAL%d Registers **\n"
95 "CFG = 0x%08x ESR = 0x%08x IER = 0x%08x\n"
96 "TX|CASR = 0x%08x CARR = 0x%08x EOBISR = 0x%08x DEIR = 0x%08x\n"
97 "RX|CASR = 0x%08x CARR = 0x%08x EOBISR = 0x%08x DEIR = 0x%08x\n",
99 get_mal_dcrn(mal
, MAL_CFG
), get_mal_dcrn(mal
, MAL_ESR
),
100 get_mal_dcrn(mal
, MAL_IER
),
101 get_mal_dcrn(mal
, MAL_TXCASR
), get_mal_dcrn(mal
, MAL_TXCARR
),
102 get_mal_dcrn(mal
, MAL_TXEOBISR
), get_mal_dcrn(mal
, MAL_TXDEIR
),
103 get_mal_dcrn(mal
, MAL_RXCASR
), get_mal_dcrn(mal
, MAL_RXCARR
),
104 get_mal_dcrn(mal
, MAL_RXEOBISR
), get_mal_dcrn(mal
, MAL_RXDEIR
)
108 for (i
= 0; i
< maldata
->num_tx_chans
; ++i
) {
111 printk("CTP%d = 0x%08x ", i
, get_mal_dcrn(mal
, MAL_TXCTPR(i
)));
114 for (i
= 0; i
< maldata
->num_rx_chans
; ++i
) {
117 printk("CTP%d = 0x%08x ", i
, get_mal_dcrn(mal
, MAL_RXCTPR(i
)));
120 for (i
= 0; i
< maldata
->num_rx_chans
; ++i
) {
121 u32 r
= get_mal_dcrn(mal
, MAL_RCBS(i
));
124 printk("RCBS%d = 0x%08x (%d) ", i
, r
, r
* 16);
129 static struct ocp_enet_private
*__emacs
[4];
130 static struct ibm_ocp_mal
*__mals
[1];
132 void emac_dbg_register(int idx
, struct ocp_enet_private
*dev
)
136 if (idx
>= sizeof(__emacs
) / sizeof(__emacs
[0])) {
138 "invalid index %d when registering EMAC for debugging\n",
143 local_irq_save(flags
);
145 local_irq_restore(flags
);
148 void mal_dbg_register(int idx
, struct ibm_ocp_mal
*mal
)
152 if (idx
>= sizeof(__mals
) / sizeof(__mals
[0])) {
154 "invalid index %d when registering MAL for debugging\n",
159 local_irq_save(flags
);
161 local_irq_restore(flags
);
164 void emac_dbg_dump_all(void)
169 local_irq_save(flags
);
171 for (i
= 0; i
< sizeof(__mals
) / sizeof(__mals
[0]); ++i
)
173 emac_mal_dump(__mals
[i
]);
175 for (i
= 0; i
< sizeof(__emacs
) / sizeof(__emacs
[0]); ++i
)
177 emac_mac_dump(i
, __emacs
[i
]);
179 local_irq_restore(flags
);
182 #if defined(CONFIG_MAGIC_SYSRQ)
183 static void emac_sysrq_handler(int key
, struct pt_regs
*pt_regs
,
184 struct tty_struct
*tty
)
189 static struct sysrq_key_op emac_sysrq_op
= {
190 .handler
= emac_sysrq_handler
,
192 .action_msg
= "Show EMAC(s) status",
195 int __init
emac_init_debug(void)
197 return register_sysrq_key('c', &emac_sysrq_op
);
200 void __exit
emac_fini_debug(void)
202 unregister_sysrq_key('c', &emac_sysrq_op
);
206 int __init
emac_init_debug(void)
210 void __exit
emac_fini_debug(void)
213 #endif /* CONFIG_MAGIC_SYSRQ */