debug.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. /*
  2. * Copyright (c) 2008-2009 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. #include <asm/unaligned.h>
  17. #include "ath9k.h"
  18. static unsigned int ath9k_debug = DBG_DEFAULT;
  19. module_param_named(debug, ath9k_debug, uint, 0);
  20. static struct dentry *ath9k_debugfs_root;
  21. void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...)
  22. {
  23. if (!sc)
  24. return;
  25. if (sc->debug.debug_mask & dbg_mask) {
  26. va_list args;
  27. va_start(args, fmt);
  28. printk(KERN_DEBUG "ath9k: ");
  29. vprintk(fmt, args);
  30. va_end(args);
  31. }
  32. }
  33. static int ath9k_debugfs_open(struct inode *inode, struct file *file)
  34. {
  35. file->private_data = inode->i_private;
  36. return 0;
  37. }
  38. static ssize_t read_file_dma(struct file *file, char __user *user_buf,
  39. size_t count, loff_t *ppos)
  40. {
  41. struct ath_softc *sc = file->private_data;
  42. struct ath_hw *ah = sc->sc_ah;
  43. char buf[1024];
  44. unsigned int len = 0;
  45. u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
  46. int i, qcuOffset = 0, dcuOffset = 0;
  47. u32 *qcuBase = &val[0], *dcuBase = &val[4];
  48. REG_WRITE(ah, AR_MACMISC,
  49. ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
  50. (AR_MACMISC_MISC_OBS_BUS_1 <<
  51. AR_MACMISC_MISC_OBS_BUS_MSB_S)));
  52. len += snprintf(buf + len, sizeof(buf) - len,
  53. "Raw DMA Debug values:\n");
  54. for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
  55. if (i % 4 == 0)
  56. len += snprintf(buf + len, sizeof(buf) - len, "\n");
  57. val[i] = REG_READ(ah, AR_DMADBG_0 + (i * sizeof(u32)));
  58. len += snprintf(buf + len, sizeof(buf) - len, "%d: %08x ",
  59. i, val[i]);
  60. }
  61. len += snprintf(buf + len, sizeof(buf) - len, "\n\n");
  62. len += snprintf(buf + len, sizeof(buf) - len,
  63. "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
  64. for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
  65. if (i == 8) {
  66. qcuOffset = 0;
  67. qcuBase++;
  68. }
  69. if (i == 6) {
  70. dcuOffset = 0;
  71. dcuBase++;
  72. }
  73. len += snprintf(buf + len, sizeof(buf) - len,
  74. "%2d %2x %1x %2x %2x\n",
  75. i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
  76. (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
  77. val[2] & (0x7 << (i * 3)) >> (i * 3),
  78. (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
  79. }
  80. len += snprintf(buf + len, sizeof(buf) - len, "\n");
  81. len += snprintf(buf + len, sizeof(buf) - len,
  82. "qcu_stitch state: %2x qcu_fetch state: %2x\n",
  83. (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
  84. len += snprintf(buf + len, sizeof(buf) - len,
  85. "qcu_complete state: %2x dcu_complete state: %2x\n",
  86. (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
  87. len += snprintf(buf + len, sizeof(buf) - len,
  88. "dcu_arb state: %2x dcu_fp state: %2x\n",
  89. (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
  90. len += snprintf(buf + len, sizeof(buf) - len,
  91. "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
  92. (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
  93. len += snprintf(buf + len, sizeof(buf) - len,
  94. "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
  95. (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
  96. len += snprintf(buf + len, sizeof(buf) - len,
  97. "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
  98. (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
  99. len += snprintf(buf + len, sizeof(buf) - len, "pcu observe: 0x%x \n",
  100. REG_READ(ah, AR_OBS_BUS_1));
  101. len += snprintf(buf + len, sizeof(buf) - len,
  102. "AR_CR: 0x%x \n", REG_READ(ah, AR_CR));
  103. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  104. }
  105. static const struct file_operations fops_dma = {
  106. .read = read_file_dma,
  107. .open = ath9k_debugfs_open,
  108. .owner = THIS_MODULE
  109. };
  110. void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status)
  111. {
  112. if (status)
  113. sc->debug.stats.istats.total++;
  114. if (status & ATH9K_INT_RX)
  115. sc->debug.stats.istats.rxok++;
  116. if (status & ATH9K_INT_RXEOL)
  117. sc->debug.stats.istats.rxeol++;
  118. if (status & ATH9K_INT_RXORN)
  119. sc->debug.stats.istats.rxorn++;
  120. if (status & ATH9K_INT_TX)
  121. sc->debug.stats.istats.txok++;
  122. if (status & ATH9K_INT_TXURN)
  123. sc->debug.stats.istats.txurn++;
  124. if (status & ATH9K_INT_MIB)
  125. sc->debug.stats.istats.mib++;
  126. if (status & ATH9K_INT_RXPHY)
  127. sc->debug.stats.istats.rxphyerr++;
  128. if (status & ATH9K_INT_RXKCM)
  129. sc->debug.stats.istats.rx_keycache_miss++;
  130. if (status & ATH9K_INT_SWBA)
  131. sc->debug.stats.istats.swba++;
  132. if (status & ATH9K_INT_BMISS)
  133. sc->debug.stats.istats.bmiss++;
  134. if (status & ATH9K_INT_BNR)
  135. sc->debug.stats.istats.bnr++;
  136. if (status & ATH9K_INT_CST)
  137. sc->debug.stats.istats.cst++;
  138. if (status & ATH9K_INT_GTT)
  139. sc->debug.stats.istats.gtt++;
  140. if (status & ATH9K_INT_TIM)
  141. sc->debug.stats.istats.tim++;
  142. if (status & ATH9K_INT_CABEND)
  143. sc->debug.stats.istats.cabend++;
  144. if (status & ATH9K_INT_DTIMSYNC)
  145. sc->debug.stats.istats.dtimsync++;
  146. if (status & ATH9K_INT_DTIM)
  147. sc->debug.stats.istats.dtim++;
  148. }
  149. static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
  150. size_t count, loff_t *ppos)
  151. {
  152. struct ath_softc *sc = file->private_data;
  153. char buf[512];
  154. unsigned int len = 0;
  155. len += snprintf(buf + len, sizeof(buf) - len,
  156. "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok);
  157. len += snprintf(buf + len, sizeof(buf) - len,
  158. "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol);
  159. len += snprintf(buf + len, sizeof(buf) - len,
  160. "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn);
  161. len += snprintf(buf + len, sizeof(buf) - len,
  162. "%8s: %10u\n", "TX", sc->debug.stats.istats.txok);
  163. len += snprintf(buf + len, sizeof(buf) - len,
  164. "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn);
  165. len += snprintf(buf + len, sizeof(buf) - len,
  166. "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib);
  167. len += snprintf(buf + len, sizeof(buf) - len,
  168. "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr);
  169. len += snprintf(buf + len, sizeof(buf) - len,
  170. "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss);
  171. len += snprintf(buf + len, sizeof(buf) - len,
  172. "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba);
  173. len += snprintf(buf + len, sizeof(buf) - len,
  174. "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss);
  175. len += snprintf(buf + len, sizeof(buf) - len,
  176. "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr);
  177. len += snprintf(buf + len, sizeof(buf) - len,
  178. "%8s: %10u\n", "CST", sc->debug.stats.istats.cst);
  179. len += snprintf(buf + len, sizeof(buf) - len,
  180. "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt);
  181. len += snprintf(buf + len, sizeof(buf) - len,
  182. "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim);
  183. len += snprintf(buf + len, sizeof(buf) - len,
  184. "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend);
  185. len += snprintf(buf + len, sizeof(buf) - len,
  186. "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync);
  187. len += snprintf(buf + len, sizeof(buf) - len,
  188. "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim);
  189. len += snprintf(buf + len, sizeof(buf) - len,
  190. "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total);
  191. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  192. }
  193. static const struct file_operations fops_interrupt = {
  194. .read = read_file_interrupt,
  195. .open = ath9k_debugfs_open,
  196. .owner = THIS_MODULE
  197. };
  198. static void ath_debug_stat_11n_rc(struct ath_softc *sc, struct sk_buff *skb)
  199. {
  200. struct ath_tx_info_priv *tx_info_priv = NULL;
  201. struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
  202. struct ieee80211_tx_rate *rates = tx_info->status.rates;
  203. int final_ts_idx, idx;
  204. tx_info_priv = ATH_TX_INFO_PRIV(tx_info);
  205. final_ts_idx = tx_info_priv->tx.ts_rateindex;
  206. idx = sc->cur_rate_table->info[rates[final_ts_idx].idx].dot11rate;
  207. sc->debug.stats.n_rcstats[idx].success++;
  208. }
  209. static void ath_debug_stat_legacy_rc(struct ath_softc *sc, struct sk_buff *skb)
  210. {
  211. struct ath_tx_info_priv *tx_info_priv = NULL;
  212. struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
  213. struct ieee80211_tx_rate *rates = tx_info->status.rates;
  214. int final_ts_idx, idx;
  215. tx_info_priv = ATH_TX_INFO_PRIV(tx_info);
  216. final_ts_idx = tx_info_priv->tx.ts_rateindex;
  217. idx = rates[final_ts_idx].idx;
  218. sc->debug.stats.legacy_rcstats[idx].success++;
  219. }
  220. void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb)
  221. {
  222. if (conf_is_ht(&sc->hw->conf))
  223. ath_debug_stat_11n_rc(sc, skb);
  224. else
  225. ath_debug_stat_legacy_rc(sc, skb);
  226. }
  227. /* FIXME: legacy rates, later on .. */
  228. void ath_debug_stat_retries(struct ath_softc *sc, int rix,
  229. int xretries, int retries, u8 per)
  230. {
  231. if (conf_is_ht(&sc->hw->conf)) {
  232. int idx = sc->cur_rate_table->info[rix].dot11rate;
  233. sc->debug.stats.n_rcstats[idx].xretries += xretries;
  234. sc->debug.stats.n_rcstats[idx].retries += retries;
  235. sc->debug.stats.n_rcstats[idx].per = per;
  236. }
  237. }
  238. static ssize_t ath_read_file_stat_11n_rc(struct file *file,
  239. char __user *user_buf,
  240. size_t count, loff_t *ppos)
  241. {
  242. struct ath_softc *sc = file->private_data;
  243. char buf[1024];
  244. unsigned int len = 0;
  245. int i = 0;
  246. len += sprintf(buf, "%7s %13s %8s %8s %6s\n\n", "Rate", "Success",
  247. "Retries", "XRetries", "PER");
  248. for (i = 0; i <= 15; i++) {
  249. len += snprintf(buf + len, sizeof(buf) - len,
  250. "%5s%3d: %8u %8u %8u %8u\n", "MCS", i,
  251. sc->debug.stats.n_rcstats[i].success,
  252. sc->debug.stats.n_rcstats[i].retries,
  253. sc->debug.stats.n_rcstats[i].xretries,
  254. sc->debug.stats.n_rcstats[i].per);
  255. }
  256. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  257. }
  258. static ssize_t ath_read_file_stat_legacy_rc(struct file *file,
  259. char __user *user_buf,
  260. size_t count, loff_t *ppos)
  261. {
  262. struct ath_softc *sc = file->private_data;
  263. char buf[512];
  264. unsigned int len = 0;
  265. int i = 0;
  266. len += sprintf(buf, "%7s %13s\n\n", "Rate", "Success");
  267. for (i = 0; i < sc->cur_rate_table->rate_cnt; i++) {
  268. len += snprintf(buf + len, sizeof(buf) - len, "%5u: %12u\n",
  269. sc->cur_rate_table->info[i].ratekbps / 1000,
  270. sc->debug.stats.legacy_rcstats[i].success);
  271. }
  272. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  273. }
  274. static ssize_t read_file_rcstat(struct file *file, char __user *user_buf,
  275. size_t count, loff_t *ppos)
  276. {
  277. struct ath_softc *sc = file->private_data;
  278. if (sc->cur_rate_table == NULL)
  279. return 0;
  280. if (conf_is_ht(&sc->hw->conf))
  281. return ath_read_file_stat_11n_rc(file, user_buf, count, ppos);
  282. else
  283. return ath_read_file_stat_legacy_rc(file, user_buf, count ,ppos);
  284. }
  285. static const struct file_operations fops_rcstat = {
  286. .read = read_file_rcstat,
  287. .open = ath9k_debugfs_open,
  288. .owner = THIS_MODULE
  289. };
  290. static const char * ath_wiphy_state_str(enum ath_wiphy_state state)
  291. {
  292. switch (state) {
  293. case ATH_WIPHY_INACTIVE:
  294. return "INACTIVE";
  295. case ATH_WIPHY_ACTIVE:
  296. return "ACTIVE";
  297. case ATH_WIPHY_PAUSING:
  298. return "PAUSING";
  299. case ATH_WIPHY_PAUSED:
  300. return "PAUSED";
  301. case ATH_WIPHY_SCAN:
  302. return "SCAN";
  303. }
  304. return "?";
  305. }
  306. static ssize_t read_file_wiphy(struct file *file, char __user *user_buf,
  307. size_t count, loff_t *ppos)
  308. {
  309. struct ath_softc *sc = file->private_data;
  310. char buf[512];
  311. unsigned int len = 0;
  312. int i;
  313. u8 addr[ETH_ALEN];
  314. len += snprintf(buf + len, sizeof(buf) - len,
  315. "primary: %s (%s chan=%d ht=%d)\n",
  316. wiphy_name(sc->pri_wiphy->hw->wiphy),
  317. ath_wiphy_state_str(sc->pri_wiphy->state),
  318. sc->pri_wiphy->chan_idx, sc->pri_wiphy->chan_is_ht);
  319. for (i = 0; i < sc->num_sec_wiphy; i++) {
  320. struct ath_wiphy *aphy = sc->sec_wiphy[i];
  321. if (aphy == NULL)
  322. continue;
  323. len += snprintf(buf + len, sizeof(buf) - len,
  324. "secondary: %s (%s chan=%d ht=%d)\n",
  325. wiphy_name(aphy->hw->wiphy),
  326. ath_wiphy_state_str(aphy->state),
  327. aphy->chan_idx, aphy->chan_is_ht);
  328. }
  329. put_unaligned_le32(REG_READ(sc->sc_ah, AR_STA_ID0), addr);
  330. put_unaligned_le16(REG_READ(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4);
  331. len += snprintf(buf + len, sizeof(buf) - len,
  332. "addr: %pM\n", addr);
  333. put_unaligned_le32(REG_READ(sc->sc_ah, AR_BSSMSKL), addr);
  334. put_unaligned_le16(REG_READ(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4);
  335. len += snprintf(buf + len, sizeof(buf) - len,
  336. "addrmask: %pM\n", addr);
  337. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  338. }
  339. static struct ath_wiphy * get_wiphy(struct ath_softc *sc, const char *name)
  340. {
  341. int i;
  342. if (strcmp(name, wiphy_name(sc->pri_wiphy->hw->wiphy)) == 0)
  343. return sc->pri_wiphy;
  344. for (i = 0; i < sc->num_sec_wiphy; i++) {
  345. struct ath_wiphy *aphy = sc->sec_wiphy[i];
  346. if (aphy && strcmp(name, wiphy_name(aphy->hw->wiphy)) == 0)
  347. return aphy;
  348. }
  349. return NULL;
  350. }
  351. static int del_wiphy(struct ath_softc *sc, const char *name)
  352. {
  353. struct ath_wiphy *aphy = get_wiphy(sc, name);
  354. if (!aphy)
  355. return -ENOENT;
  356. return ath9k_wiphy_del(aphy);
  357. }
  358. static int pause_wiphy(struct ath_softc *sc, const char *name)
  359. {
  360. struct ath_wiphy *aphy = get_wiphy(sc, name);
  361. if (!aphy)
  362. return -ENOENT;
  363. return ath9k_wiphy_pause(aphy);
  364. }
  365. static int unpause_wiphy(struct ath_softc *sc, const char *name)
  366. {
  367. struct ath_wiphy *aphy = get_wiphy(sc, name);
  368. if (!aphy)
  369. return -ENOENT;
  370. return ath9k_wiphy_unpause(aphy);
  371. }
  372. static int select_wiphy(struct ath_softc *sc, const char *name)
  373. {
  374. struct ath_wiphy *aphy = get_wiphy(sc, name);
  375. if (!aphy)
  376. return -ENOENT;
  377. return ath9k_wiphy_select(aphy);
  378. }
  379. static int schedule_wiphy(struct ath_softc *sc, const char *msec)
  380. {
  381. ath9k_wiphy_set_scheduler(sc, simple_strtoul(msec, NULL, 0));
  382. return 0;
  383. }
  384. static ssize_t write_file_wiphy(struct file *file, const char __user *user_buf,
  385. size_t count, loff_t *ppos)
  386. {
  387. struct ath_softc *sc = file->private_data;
  388. char buf[50];
  389. size_t len;
  390. len = min(count, sizeof(buf) - 1);
  391. if (copy_from_user(buf, user_buf, len))
  392. return -EFAULT;
  393. buf[len] = '\0';
  394. if (len > 0 && buf[len - 1] == '\n')
  395. buf[len - 1] = '\0';
  396. if (strncmp(buf, "add", 3) == 0) {
  397. int res = ath9k_wiphy_add(sc);
  398. if (res < 0)
  399. return res;
  400. } else if (strncmp(buf, "del=", 4) == 0) {
  401. int res = del_wiphy(sc, buf + 4);
  402. if (res < 0)
  403. return res;
  404. } else if (strncmp(buf, "pause=", 6) == 0) {
  405. int res = pause_wiphy(sc, buf + 6);
  406. if (res < 0)
  407. return res;
  408. } else if (strncmp(buf, "unpause=", 8) == 0) {
  409. int res = unpause_wiphy(sc, buf + 8);
  410. if (res < 0)
  411. return res;
  412. } else if (strncmp(buf, "select=", 7) == 0) {
  413. int res = select_wiphy(sc, buf + 7);
  414. if (res < 0)
  415. return res;
  416. } else if (strncmp(buf, "schedule=", 9) == 0) {
  417. int res = schedule_wiphy(sc, buf + 9);
  418. if (res < 0)
  419. return res;
  420. } else
  421. return -EOPNOTSUPP;
  422. return count;
  423. }
  424. static const struct file_operations fops_wiphy = {
  425. .read = read_file_wiphy,
  426. .write = write_file_wiphy,
  427. .open = ath9k_debugfs_open,
  428. .owner = THIS_MODULE
  429. };
  430. int ath9k_init_debug(struct ath_softc *sc)
  431. {
  432. sc->debug.debug_mask = ath9k_debug;
  433. sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
  434. ath9k_debugfs_root);
  435. if (!sc->debug.debugfs_phy)
  436. goto err;
  437. sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUGO,
  438. sc->debug.debugfs_phy, sc, &fops_dma);
  439. if (!sc->debug.debugfs_dma)
  440. goto err;
  441. sc->debug.debugfs_interrupt = debugfs_create_file("interrupt",
  442. S_IRUGO,
  443. sc->debug.debugfs_phy,
  444. sc, &fops_interrupt);
  445. if (!sc->debug.debugfs_interrupt)
  446. goto err;
  447. sc->debug.debugfs_rcstat = debugfs_create_file("rcstat",
  448. S_IRUGO,
  449. sc->debug.debugfs_phy,
  450. sc, &fops_rcstat);
  451. if (!sc->debug.debugfs_rcstat)
  452. goto err;
  453. sc->debug.debugfs_wiphy = debugfs_create_file(
  454. "wiphy", S_IRUGO | S_IWUSR, sc->debug.debugfs_phy, sc,
  455. &fops_wiphy);
  456. if (!sc->debug.debugfs_wiphy)
  457. goto err;
  458. return 0;
  459. err:
  460. ath9k_exit_debug(sc);
  461. return -ENOMEM;
  462. }
  463. void ath9k_exit_debug(struct ath_softc *sc)
  464. {
  465. debugfs_remove(sc->debug.debugfs_wiphy);
  466. debugfs_remove(sc->debug.debugfs_rcstat);
  467. debugfs_remove(sc->debug.debugfs_interrupt);
  468. debugfs_remove(sc->debug.debugfs_dma);
  469. debugfs_remove(sc->debug.debugfs_phy);
  470. }
  471. int ath9k_debug_create_root(void)
  472. {
  473. ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
  474. if (!ath9k_debugfs_root)
  475. return -ENOENT;
  476. return 0;
  477. }
  478. void ath9k_debug_remove_root(void)
  479. {
  480. debugfs_remove(ath9k_debugfs_root);
  481. ath9k_debugfs_root = NULL;
  482. }