Commit | Line | Data |
---|---|---|
635d2b00 GKH |
1 | /***************************************************************************** |
2 | ||
3 | (c) Cambridge Silicon Radio Limited 2011 | |
4 | All rights reserved and confidential information of CSR | |
5 | ||
6 | Refer to LICENSE.txt included with this source for details | |
7 | on the license terms. | |
8 | ||
9 | *****************************************************************************/ | |
10 | ||
11 | /* | |
12 | * --------------------------------------------------------------------------- | |
13 | * FILE: csr_wifi_hip_card_udi.c | |
14 | * | |
15 | * PURPOSE: | |
16 | * Maintain a list of callbacks to log UniFi exchanges to one or more | |
17 | * debug/monitoring client applications. | |
18 | * | |
19 | * NOTES: | |
20 | * Just call the UDI driver log fn directly for now. | |
21 | * When done properly, each open() on the UDI device will install | |
22 | * a log function. We will call all log fns whenever a signal is written | |
23 | * to or read form the UniFi. | |
24 | * | |
25 | * --------------------------------------------------------------------------- | |
26 | */ | |
294a08e4 | 27 | #include <linux/seq_file.h> |
635d2b00 GKH |
28 | #include "csr_wifi_hip_unifi.h" |
29 | #include "csr_wifi_hip_card.h" | |
30 | ||
31 | ||
294a08e4 DH |
32 | static void unifi_print_unsafe_sdio_status(card_t *card, struct seq_file *m) |
33 | { | |
34 | #ifdef CSR_UNSAFE_SDIO_ACCESS | |
35 | s32 iostate; | |
36 | CsrResult r; | |
37 | static const char *const states[] = { | |
38 | "AWAKE", "DROWSY", "TORPID" | |
39 | }; | |
40 | #define SHARED_READ_RETRY_LIMIT 10 | |
41 | u8 b; | |
42 | ||
43 | seq_printf(m, "Host State: %s\n", states[card->host_state]); | |
44 | ||
45 | r = unifi_check_io_status(card, &iostate); | |
46 | if (iostate == 1) { | |
47 | seq_puts(m, remaining, "I/O Check: F1 disabled\n"); | |
48 | } else { | |
49 | if (iostate == 1) { | |
50 | seq_puts(m, "I/O Check: pending interrupt\n"); | |
51 | ||
52 | seq_printf(m, "BH reason interrupt = %d\n", card->bh_reason_unifi); | |
53 | seq_printf(m, "BH reason host = %d\n", card->bh_reason_host); | |
54 | ||
55 | for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++) { | |
56 | r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 2, &b); | |
57 | if (r == CSR_RESULT_SUCCESS && !(b & 0x80)) { | |
58 | seq_printf(m, "fhsr: %u (driver thinks is %u)\n", | |
59 | b, card->from_host_signals_r); | |
60 | break; | |
61 | } | |
62 | } | |
63 | ||
64 | iostate = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4); | |
65 | seq_printf(m, "thsw: %u (driver thinks is %u)\n", | |
66 | iostate, card->to_host_signals_w); | |
67 | } | |
68 | #endif | |
69 | } | |
70 | ||
635d2b00 GKH |
71 | /* |
72 | * --------------------------------------------------------------------------- | |
73 | * unifi_print_status | |
74 | * | |
75 | * Print status info to given character buffer. | |
76 | * | |
77 | * Arguments: | |
78 | * None. | |
79 | * | |
80 | * Returns: | |
81 | * None. | |
82 | * --------------------------------------------------------------------------- | |
83 | */ | |
294a08e4 | 84 | s32 unifi_print_status(card_t *card, struct seq_file *m) |
635d2b00 | 85 | { |
294a08e4 DH |
86 | sdio_config_data_t *cfg; |
87 | u16 i, n; | |
88 | ||
89 | i = n = 0; | |
90 | seq_printf(m, "Chip ID %u\n", card->chip_id); | |
91 | seq_printf(m, "Chip Version %04X\n", card->chip_version); | |
92 | seq_printf(m, "HIP v%u.%u\n", | |
93 | (card->config_data.version >> 8) & 0xFF, | |
94 | card->config_data.version & 0xFF); | |
95 | seq_printf(m, "Build %u: %s\n", card->build_id, card->build_id_string); | |
96 | ||
97 | cfg = &card->config_data; | |
98 | ||
99 | seq_printf(m, "sdio ctrl offset %u\n", cfg->sdio_ctrl_offset); | |
100 | seq_printf(m, "fromhost sigbuf handle %u\n", cfg->fromhost_sigbuf_handle); | |
101 | seq_printf(m, "tohost_sigbuf_handle %u\n", cfg->tohost_sigbuf_handle); | |
102 | seq_printf(m, "num_fromhost_sig_frags %u\n", cfg->num_fromhost_sig_frags); | |
103 | seq_printf(m, "num_tohost_sig_frags %u\n", cfg->num_tohost_sig_frags); | |
104 | seq_printf(m, "num_fromhost_data_slots %u\n", cfg->num_fromhost_data_slots); | |
105 | seq_printf(m, "num_tohost_data_slots %u\n", cfg->num_tohost_data_slots); | |
106 | seq_printf(m, "data_slot_size %u\n", cfg->data_slot_size); | |
107 | ||
108 | /* Added by protocol version 0x0001 */ | |
109 | seq_printf(m, "overlay_size %u\n", cfg->overlay_size); | |
110 | ||
111 | /* Added by protocol version 0x0300 */ | |
112 | seq_printf(m, "data_slot_round %u\n", cfg->data_slot_round); | |
113 | seq_printf(m, "sig_frag_size %u\n", cfg->sig_frag_size); | |
114 | ||
115 | /* Added by protocol version 0x0300 */ | |
116 | seq_printf(m, "tohost_sig_pad %u\n", cfg->tohost_signal_padding); | |
117 | ||
118 | seq_puts(m, "\nInternal state:\n"); | |
119 | ||
120 | seq_printf(m, "Last PHY PANIC: %04x:%04x\n", | |
121 | card->last_phy_panic_code, card->last_phy_panic_arg); | |
122 | seq_printf(m, "Last MAC PANIC: %04x:%04x\n", | |
123 | card->last_mac_panic_code, card->last_mac_panic_arg); | |
124 | ||
125 | seq_printf(m, "fhsr: %hu\n", (u16)card->from_host_signals_r); | |
126 | seq_printf(m, "fhsw: %hu\n", (u16)card->from_host_signals_w); | |
127 | seq_printf(m, "thsr: %hu\n", (u16)card->to_host_signals_r); | |
128 | seq_printf(m, "thsw: %hu\n", (u16)card->to_host_signals_w); | |
129 | seq_printf(m, "fh buffer contains: %d signals, %td bytes\n", | |
130 | card->fh_buffer.count, | |
131 | card->fh_buffer.ptr - card->fh_buffer.buf); | |
132 | ||
133 | seq_puts(m, "paused: "); | |
134 | for (i = 0; i < ARRAY_SIZE(card->tx_q_paused_flag); i++) | |
135 | seq_printf(m, card->tx_q_paused_flag[i] ? "1" : "0"); | |
136 | seq_putc(m, '\n'); | |
137 | ||
138 | seq_printf(m, "fh command q: %u waiting, %u free of %u:\n", | |
139 | CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_command_queue), | |
140 | CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_command_queue), | |
141 | UNIFI_SOFT_COMMAND_Q_LENGTH); | |
142 | ||
143 | for (i = 0; i < UNIFI_NO_OF_TX_QS; i++) | |
144 | seq_printf(m, "fh traffic q[%u]: %u waiting, %u free of %u:\n", | |
145 | i, | |
146 | CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[i]), | |
147 | CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[i]), | |
148 | UNIFI_SOFT_TRAFFIC_Q_LENGTH); | |
149 | ||
150 | seq_printf(m, "fh data slots free: %u\n", | |
151 | card->from_host_data ? CardGetFreeFromHostDataSlots(card) : 0); | |
152 | ||
153 | seq_puts(m, "From host data slots:"); | |
154 | n = card->config_data.num_fromhost_data_slots; | |
155 | for (i = 0; i < n && card->from_host_data; i++) | |
156 | seq_printf(m, " %hu", (u16)card->from_host_data[i].bd.data_length); | |
157 | seq_putc(m, '\n'); | |
158 | ||
159 | seq_puts(m, "To host data slots:"); | |
160 | n = card->config_data.num_tohost_data_slots; | |
161 | for (i = 0; i < n && card->to_host_data; i++) | |
162 | seq_printf(m, " %hu", (u16)card->to_host_data[i].data_length); | |
163 | seq_putc(m, '\n'); | |
164 | ||
165 | unifi_print_unsafe_sdio_status(card, m); | |
166 | ||
167 | seq_puts(m, "\nStats:\n"); | |
168 | seq_printf(m, "Total SDIO bytes: R=%u W=%u\n", | |
169 | card->sdio_bytes_read, card->sdio_bytes_written); | |
170 | ||
171 | seq_printf(m, "Interrupts generated on card: %u\n", card->unifi_interrupt_seq); | |
172 | return 0; | |
173 | } |