Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2008 Atheros Communications Inc. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 17 | #include "ath9k.h" |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 18 | |
| 19 | static unsigned int ath9k_debug = DBG_DEFAULT; |
| 20 | module_param_named(debug, ath9k_debug, uint, 0); |
| 21 | |
| 22 | void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...) |
| 23 | { |
| 24 | if (!sc) |
| 25 | return; |
| 26 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 27 | if (sc->debug.debug_mask & dbg_mask) { |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 28 | va_list args; |
| 29 | |
| 30 | va_start(args, fmt); |
| 31 | printk(KERN_DEBUG "ath9k: "); |
| 32 | vprintk(fmt, args); |
| 33 | va_end(args); |
| 34 | } |
| 35 | } |
| 36 | |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 37 | static int ath9k_debugfs_open(struct inode *inode, struct file *file) |
| 38 | { |
| 39 | file->private_data = inode->i_private; |
| 40 | return 0; |
| 41 | } |
| 42 | |
| 43 | static ssize_t read_file_dma(struct file *file, char __user *user_buf, |
| 44 | size_t count, loff_t *ppos) |
| 45 | { |
| 46 | struct ath_softc *sc = file->private_data; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 47 | struct ath_hw *ah = sc->sc_ah; |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 48 | char buf[1024]; |
| 49 | unsigned int len = 0; |
| 50 | u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; |
| 51 | int i, qcuOffset = 0, dcuOffset = 0; |
| 52 | u32 *qcuBase = &val[0], *dcuBase = &val[4]; |
| 53 | |
| 54 | REG_WRITE(ah, AR_MACMISC, |
| 55 | ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) | |
| 56 | (AR_MACMISC_MISC_OBS_BUS_1 << |
| 57 | AR_MACMISC_MISC_OBS_BUS_MSB_S))); |
| 58 | |
| 59 | len += snprintf(buf + len, sizeof(buf) - len, |
| 60 | "Raw DMA Debug values:\n"); |
| 61 | |
| 62 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { |
| 63 | if (i % 4 == 0) |
| 64 | len += snprintf(buf + len, sizeof(buf) - len, "\n"); |
| 65 | |
| 66 | val[i] = REG_READ(ah, AR_DMADBG_0 + (i * sizeof(u32))); |
| 67 | len += snprintf(buf + len, sizeof(buf) - len, "%d: %08x ", |
| 68 | i, val[i]); |
| 69 | } |
| 70 | |
| 71 | len += snprintf(buf + len, sizeof(buf) - len, "\n\n"); |
| 72 | len += snprintf(buf + len, sizeof(buf) - len, |
| 73 | "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); |
| 74 | |
| 75 | for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { |
| 76 | if (i == 8) { |
| 77 | qcuOffset = 0; |
| 78 | qcuBase++; |
| 79 | } |
| 80 | |
| 81 | if (i == 6) { |
| 82 | dcuOffset = 0; |
| 83 | dcuBase++; |
| 84 | } |
| 85 | |
| 86 | len += snprintf(buf + len, sizeof(buf) - len, |
| 87 | "%2d %2x %1x %2x %2x\n", |
| 88 | i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, |
| 89 | (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), |
| 90 | val[2] & (0x7 << (i * 3)) >> (i * 3), |
| 91 | (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); |
| 92 | } |
| 93 | |
| 94 | len += snprintf(buf + len, sizeof(buf) - len, "\n"); |
| 95 | |
| 96 | len += snprintf(buf + len, sizeof(buf) - len, |
| 97 | "qcu_stitch state: %2x qcu_fetch state: %2x\n", |
| 98 | (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); |
| 99 | len += snprintf(buf + len, sizeof(buf) - len, |
| 100 | "qcu_complete state: %2x dcu_complete state: %2x\n", |
| 101 | (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); |
| 102 | len += snprintf(buf + len, sizeof(buf) - len, |
| 103 | "dcu_arb state: %2x dcu_fp state: %2x\n", |
| 104 | (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); |
| 105 | len += snprintf(buf + len, sizeof(buf) - len, |
| 106 | "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", |
| 107 | (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); |
| 108 | len += snprintf(buf + len, sizeof(buf) - len, |
| 109 | "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", |
| 110 | (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); |
| 111 | len += snprintf(buf + len, sizeof(buf) - len, |
| 112 | "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", |
| 113 | (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); |
| 114 | |
| 115 | len += snprintf(buf + len, sizeof(buf) - len, "pcu observe: 0x%x \n", |
| 116 | REG_READ(ah, AR_OBS_BUS_1)); |
| 117 | len += snprintf(buf + len, sizeof(buf) - len, |
| 118 | "AR_CR: 0x%x \n", REG_READ(ah, AR_CR)); |
| 119 | |
| 120 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 121 | } |
| 122 | |
| 123 | static const struct file_operations fops_dma = { |
| 124 | .read = read_file_dma, |
| 125 | .open = ath9k_debugfs_open, |
| 126 | .owner = THIS_MODULE |
| 127 | }; |
| 128 | |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 129 | |
| 130 | void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) |
| 131 | { |
| 132 | if (status) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 133 | sc->debug.stats.istats.total++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 134 | if (status & ATH9K_INT_RX) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 135 | sc->debug.stats.istats.rxok++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 136 | if (status & ATH9K_INT_RXEOL) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 137 | sc->debug.stats.istats.rxeol++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 138 | if (status & ATH9K_INT_RXORN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 139 | sc->debug.stats.istats.rxorn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 140 | if (status & ATH9K_INT_TX) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 141 | sc->debug.stats.istats.txok++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 142 | if (status & ATH9K_INT_TXURN) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 143 | sc->debug.stats.istats.txurn++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 144 | if (status & ATH9K_INT_MIB) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 145 | sc->debug.stats.istats.mib++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 146 | if (status & ATH9K_INT_RXPHY) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 147 | sc->debug.stats.istats.rxphyerr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 148 | if (status & ATH9K_INT_RXKCM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 149 | sc->debug.stats.istats.rx_keycache_miss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 150 | if (status & ATH9K_INT_SWBA) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 151 | sc->debug.stats.istats.swba++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 152 | if (status & ATH9K_INT_BMISS) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 153 | sc->debug.stats.istats.bmiss++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 154 | if (status & ATH9K_INT_BNR) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 155 | sc->debug.stats.istats.bnr++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 156 | if (status & ATH9K_INT_CST) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 157 | sc->debug.stats.istats.cst++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 158 | if (status & ATH9K_INT_GTT) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 159 | sc->debug.stats.istats.gtt++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 160 | if (status & ATH9K_INT_TIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 161 | sc->debug.stats.istats.tim++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 162 | if (status & ATH9K_INT_CABEND) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 163 | sc->debug.stats.istats.cabend++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 164 | if (status & ATH9K_INT_DTIMSYNC) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 165 | sc->debug.stats.istats.dtimsync++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 166 | if (status & ATH9K_INT_DTIM) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 167 | sc->debug.stats.istats.dtim++; |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, |
| 171 | size_t count, loff_t *ppos) |
| 172 | { |
| 173 | struct ath_softc *sc = file->private_data; |
| 174 | char buf[512]; |
| 175 | unsigned int len = 0; |
| 176 | |
| 177 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 178 | "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 179 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 180 | "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 181 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 182 | "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 183 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 184 | "%8s: %10u\n", "TX", sc->debug.stats.istats.txok); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 185 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 186 | "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 187 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 188 | "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 189 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 190 | "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 191 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 192 | "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 193 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 194 | "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 195 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 196 | "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 197 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 198 | "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 199 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 200 | "%8s: %10u\n", "CST", sc->debug.stats.istats.cst); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 201 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 202 | "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 203 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 204 | "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 205 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 206 | "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 207 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 208 | "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 209 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 210 | "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 211 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 212 | "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total); |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 213 | |
| 214 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 215 | } |
| 216 | |
| 217 | static const struct file_operations fops_interrupt = { |
| 218 | .read = read_file_interrupt, |
| 219 | .open = ath9k_debugfs_open, |
| 220 | .owner = THIS_MODULE |
| 221 | }; |
| 222 | |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 223 | static void ath_debug_stat_11n_rc(struct ath_softc *sc, struct sk_buff *skb) |
| 224 | { |
| 225 | struct ath_tx_info_priv *tx_info_priv = NULL; |
| 226 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
| 227 | struct ieee80211_tx_rate *rates = tx_info->status.rates; |
| 228 | int final_ts_idx, idx; |
| 229 | |
| 230 | tx_info_priv = ATH_TX_INFO_PRIV(tx_info); |
| 231 | final_ts_idx = tx_info_priv->tx.ts_rateindex; |
| 232 | idx = sc->cur_rate_table->info[rates[final_ts_idx].idx].dot11rate; |
| 233 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 234 | sc->debug.stats.n_rcstats[idx].success++; |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | static void ath_debug_stat_legacy_rc(struct ath_softc *sc, struct sk_buff *skb) |
| 238 | { |
| 239 | struct ath_tx_info_priv *tx_info_priv = NULL; |
| 240 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); |
| 241 | struct ieee80211_tx_rate *rates = tx_info->status.rates; |
| 242 | int final_ts_idx, idx; |
| 243 | |
| 244 | tx_info_priv = ATH_TX_INFO_PRIV(tx_info); |
| 245 | final_ts_idx = tx_info_priv->tx.ts_rateindex; |
| 246 | idx = rates[final_ts_idx].idx; |
| 247 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 248 | sc->debug.stats.legacy_rcstats[idx].success++; |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb) |
| 252 | { |
| 253 | if (conf_is_ht(&sc->hw->conf)) |
| 254 | ath_debug_stat_11n_rc(sc, skb); |
| 255 | else |
| 256 | ath_debug_stat_legacy_rc(sc, skb); |
| 257 | } |
| 258 | |
Sujith | 029bc43 | 2009-02-04 08:10:26 +0530 | [diff] [blame] | 259 | /* FIXME: legacy rates, later on .. */ |
| 260 | void ath_debug_stat_retries(struct ath_softc *sc, int rix, |
Sujith | 9e71279 | 2009-02-20 15:13:20 +0530 | [diff] [blame^] | 261 | int xretries, int retries, u8 per) |
Sujith | 029bc43 | 2009-02-04 08:10:26 +0530 | [diff] [blame] | 262 | { |
| 263 | if (conf_is_ht(&sc->hw->conf)) { |
| 264 | int idx = sc->cur_rate_table->info[rix].dot11rate; |
| 265 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 266 | sc->debug.stats.n_rcstats[idx].xretries += xretries; |
| 267 | sc->debug.stats.n_rcstats[idx].retries += retries; |
Sujith | 9e71279 | 2009-02-20 15:13:20 +0530 | [diff] [blame^] | 268 | sc->debug.stats.n_rcstats[idx].per = per; |
Sujith | 029bc43 | 2009-02-04 08:10:26 +0530 | [diff] [blame] | 269 | } |
| 270 | } |
| 271 | |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 272 | static ssize_t ath_read_file_stat_11n_rc(struct file *file, |
| 273 | char __user *user_buf, |
| 274 | size_t count, loff_t *ppos) |
| 275 | { |
| 276 | struct ath_softc *sc = file->private_data; |
Sujith | 029bc43 | 2009-02-04 08:10:26 +0530 | [diff] [blame] | 277 | char buf[1024]; |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 278 | unsigned int len = 0; |
| 279 | int i = 0; |
| 280 | |
Sujith | 9e71279 | 2009-02-20 15:13:20 +0530 | [diff] [blame^] | 281 | len += sprintf(buf, "%7s %13s %8s %8s %6s\n\n", "Rate", "Success", |
| 282 | "Retries", "XRetries", "PER"); |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 283 | |
| 284 | for (i = 0; i <= 15; i++) { |
| 285 | len += snprintf(buf + len, sizeof(buf) - len, |
Sujith | 9e71279 | 2009-02-20 15:13:20 +0530 | [diff] [blame^] | 286 | "%5s%3d: %8u %8u %8u %8u\n", "MCS", i, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 287 | sc->debug.stats.n_rcstats[i].success, |
| 288 | sc->debug.stats.n_rcstats[i].retries, |
Sujith | 9e71279 | 2009-02-20 15:13:20 +0530 | [diff] [blame^] | 289 | sc->debug.stats.n_rcstats[i].xretries, |
| 290 | sc->debug.stats.n_rcstats[i].per); |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 294 | } |
| 295 | |
| 296 | static ssize_t ath_read_file_stat_legacy_rc(struct file *file, |
| 297 | char __user *user_buf, |
| 298 | size_t count, loff_t *ppos) |
| 299 | { |
| 300 | struct ath_softc *sc = file->private_data; |
| 301 | char buf[512]; |
| 302 | unsigned int len = 0; |
| 303 | int i = 0; |
| 304 | |
| 305 | len += sprintf(buf, "%7s %13s\n\n", "Rate", "Success"); |
| 306 | |
| 307 | for (i = 0; i < sc->cur_rate_table->rate_cnt; i++) { |
| 308 | len += snprintf(buf + len, sizeof(buf) - len, "%5u: %12u\n", |
| 309 | sc->cur_rate_table->info[i].ratekbps / 1000, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 310 | sc->debug.stats.legacy_rcstats[i].success); |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 314 | } |
| 315 | |
| 316 | static ssize_t read_file_rcstat(struct file *file, char __user *user_buf, |
| 317 | size_t count, loff_t *ppos) |
| 318 | { |
| 319 | struct ath_softc *sc = file->private_data; |
| 320 | |
| 321 | if (conf_is_ht(&sc->hw->conf)) |
| 322 | return ath_read_file_stat_11n_rc(file, user_buf, count, ppos); |
| 323 | else |
| 324 | return ath_read_file_stat_legacy_rc(file, user_buf, count ,ppos); |
| 325 | } |
| 326 | |
| 327 | static const struct file_operations fops_rcstat = { |
| 328 | .read = read_file_rcstat, |
| 329 | .open = ath9k_debugfs_open, |
| 330 | .owner = THIS_MODULE |
| 331 | }; |
Alina Friedrichsen | 27abe06 | 2009-01-23 05:44:21 +0100 | [diff] [blame] | 332 | |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 333 | int ath9k_init_debug(struct ath_softc *sc) |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 334 | { |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 335 | sc->debug.debug_mask = ath9k_debug; |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 336 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 337 | sc->debug.debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL); |
| 338 | if (!sc->debug.debugfs_root) |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 339 | goto err; |
| 340 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 341 | sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy), |
| 342 | sc->debug.debugfs_root); |
| 343 | if (!sc->debug.debugfs_phy) |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 344 | goto err; |
| 345 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 346 | sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUGO, |
| 347 | sc->debug.debugfs_phy, sc, &fops_dma); |
| 348 | if (!sc->debug.debugfs_dma) |
Sujith | 2a163c6 | 2008-11-28 22:21:08 +0530 | [diff] [blame] | 349 | goto err; |
| 350 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 351 | sc->debug.debugfs_interrupt = debugfs_create_file("interrupt", |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 352 | S_IRUGO, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 353 | sc->debug.debugfs_phy, |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 354 | sc, &fops_interrupt); |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 355 | if (!sc->debug.debugfs_interrupt) |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 356 | goto err; |
| 357 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 358 | sc->debug.debugfs_rcstat = debugfs_create_file("rcstat", |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 359 | S_IRUGO, |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 360 | sc->debug.debugfs_phy, |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 361 | sc, &fops_rcstat); |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 362 | if (!sc->debug.debugfs_rcstat) |
Sujith | 7a7dec6 | 2009-01-30 14:32:09 +0530 | [diff] [blame] | 363 | goto err; |
| 364 | |
Sujith | 826d268 | 2008-11-28 22:20:23 +0530 | [diff] [blame] | 365 | return 0; |
| 366 | err: |
| 367 | ath9k_exit_debug(sc); |
| 368 | return -ENOMEM; |
| 369 | } |
| 370 | |
| 371 | void ath9k_exit_debug(struct ath_softc *sc) |
| 372 | { |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 373 | debugfs_remove(sc->debug.debugfs_rcstat); |
| 374 | debugfs_remove(sc->debug.debugfs_interrupt); |
| 375 | debugfs_remove(sc->debug.debugfs_dma); |
| 376 | debugfs_remove(sc->debug.debugfs_phy); |
| 377 | debugfs_remove(sc->debug.debugfs_root); |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 378 | } |