debug.c 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769
  1. /*
  2. * Copyright (c) 2008-2011 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 <linux/slab.h>
  17. #include <linux/vmalloc.h>
  18. #include <linux/export.h>
  19. #include <linux/relay.h>
  20. #include <asm/unaligned.h>
  21. #include "ath9k.h"
  22. #define REG_WRITE_D(_ah, _reg, _val) \
  23. ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
  24. #define REG_READ_D(_ah, _reg) \
  25. ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
  26. static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf,
  27. size_t count, loff_t *ppos)
  28. {
  29. u8 *buf = file->private_data;
  30. return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
  31. }
  32. static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file)
  33. {
  34. vfree(file->private_data);
  35. return 0;
  36. }
  37. #ifdef CONFIG_ATH_DEBUG
  38. static ssize_t read_file_debug(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_common *common = ath9k_hw_common(sc->sc_ah);
  43. char buf[32];
  44. unsigned int len;
  45. len = sprintf(buf, "0x%08x\n", common->debug_mask);
  46. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  47. }
  48. static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
  49. size_t count, loff_t *ppos)
  50. {
  51. struct ath_softc *sc = file->private_data;
  52. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  53. unsigned long mask;
  54. char buf[32];
  55. ssize_t len;
  56. len = min(count, sizeof(buf) - 1);
  57. if (copy_from_user(buf, user_buf, len))
  58. return -EFAULT;
  59. buf[len] = '\0';
  60. if (strict_strtoul(buf, 0, &mask))
  61. return -EINVAL;
  62. common->debug_mask = mask;
  63. return count;
  64. }
  65. static const struct file_operations fops_debug = {
  66. .read = read_file_debug,
  67. .write = write_file_debug,
  68. .open = simple_open,
  69. .owner = THIS_MODULE,
  70. .llseek = default_llseek,
  71. };
  72. #endif
  73. #define DMA_BUF_LEN 1024
  74. static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf,
  75. size_t count, loff_t *ppos)
  76. {
  77. struct ath_softc *sc = file->private_data;
  78. struct ath_hw *ah = sc->sc_ah;
  79. char buf[32];
  80. unsigned int len;
  81. len = sprintf(buf, "0x%08x\n", ah->txchainmask);
  82. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  83. }
  84. static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf,
  85. size_t count, loff_t *ppos)
  86. {
  87. struct ath_softc *sc = file->private_data;
  88. struct ath_hw *ah = sc->sc_ah;
  89. unsigned long mask;
  90. char buf[32];
  91. ssize_t len;
  92. len = min(count, sizeof(buf) - 1);
  93. if (copy_from_user(buf, user_buf, len))
  94. return -EFAULT;
  95. buf[len] = '\0';
  96. if (strict_strtoul(buf, 0, &mask))
  97. return -EINVAL;
  98. ah->txchainmask = mask;
  99. ah->caps.tx_chainmask = mask;
  100. return count;
  101. }
  102. static const struct file_operations fops_tx_chainmask = {
  103. .read = read_file_tx_chainmask,
  104. .write = write_file_tx_chainmask,
  105. .open = simple_open,
  106. .owner = THIS_MODULE,
  107. .llseek = default_llseek,
  108. };
  109. static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf,
  110. size_t count, loff_t *ppos)
  111. {
  112. struct ath_softc *sc = file->private_data;
  113. struct ath_hw *ah = sc->sc_ah;
  114. char buf[32];
  115. unsigned int len;
  116. len = sprintf(buf, "0x%08x\n", ah->rxchainmask);
  117. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  118. }
  119. static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf,
  120. size_t count, loff_t *ppos)
  121. {
  122. struct ath_softc *sc = file->private_data;
  123. struct ath_hw *ah = sc->sc_ah;
  124. unsigned long mask;
  125. char buf[32];
  126. ssize_t len;
  127. len = min(count, sizeof(buf) - 1);
  128. if (copy_from_user(buf, user_buf, len))
  129. return -EFAULT;
  130. buf[len] = '\0';
  131. if (strict_strtoul(buf, 0, &mask))
  132. return -EINVAL;
  133. ah->rxchainmask = mask;
  134. ah->caps.rx_chainmask = mask;
  135. return count;
  136. }
  137. static const struct file_operations fops_rx_chainmask = {
  138. .read = read_file_rx_chainmask,
  139. .write = write_file_rx_chainmask,
  140. .open = simple_open,
  141. .owner = THIS_MODULE,
  142. .llseek = default_llseek,
  143. };
  144. static ssize_t read_file_disable_ani(struct file *file, char __user *user_buf,
  145. size_t count, loff_t *ppos)
  146. {
  147. struct ath_softc *sc = file->private_data;
  148. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  149. char buf[32];
  150. unsigned int len;
  151. len = sprintf(buf, "%d\n", common->disable_ani);
  152. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  153. }
  154. static ssize_t write_file_disable_ani(struct file *file,
  155. const char __user *user_buf,
  156. size_t count, loff_t *ppos)
  157. {
  158. struct ath_softc *sc = file->private_data;
  159. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  160. unsigned long disable_ani;
  161. char buf[32];
  162. ssize_t len;
  163. len = min(count, sizeof(buf) - 1);
  164. if (copy_from_user(buf, user_buf, len))
  165. return -EFAULT;
  166. buf[len] = '\0';
  167. if (strict_strtoul(buf, 0, &disable_ani))
  168. return -EINVAL;
  169. common->disable_ani = !!disable_ani;
  170. if (disable_ani) {
  171. clear_bit(SC_OP_ANI_RUN, &sc->sc_flags);
  172. ath_stop_ani(sc);
  173. } else {
  174. ath_check_ani(sc);
  175. }
  176. return count;
  177. }
  178. static const struct file_operations fops_disable_ani = {
  179. .read = read_file_disable_ani,
  180. .write = write_file_disable_ani,
  181. .open = simple_open,
  182. .owner = THIS_MODULE,
  183. .llseek = default_llseek,
  184. };
  185. static ssize_t read_file_ant_diversity(struct file *file, char __user *user_buf,
  186. size_t count, loff_t *ppos)
  187. {
  188. struct ath_softc *sc = file->private_data;
  189. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  190. char buf[32];
  191. unsigned int len;
  192. len = sprintf(buf, "%d\n", common->antenna_diversity);
  193. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  194. }
  195. static ssize_t write_file_ant_diversity(struct file *file,
  196. const char __user *user_buf,
  197. size_t count, loff_t *ppos)
  198. {
  199. struct ath_softc *sc = file->private_data;
  200. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  201. unsigned long antenna_diversity;
  202. char buf[32];
  203. ssize_t len;
  204. len = min(count, sizeof(buf) - 1);
  205. if (copy_from_user(buf, user_buf, len))
  206. return -EFAULT;
  207. if (!AR_SREV_9565(sc->sc_ah))
  208. goto exit;
  209. buf[len] = '\0';
  210. if (strict_strtoul(buf, 0, &antenna_diversity))
  211. return -EINVAL;
  212. common->antenna_diversity = !!antenna_diversity;
  213. ath9k_ps_wakeup(sc);
  214. ath_ant_comb_update(sc);
  215. ath_dbg(common, CONFIG, "Antenna diversity: %d\n",
  216. common->antenna_diversity);
  217. ath9k_ps_restore(sc);
  218. exit:
  219. return count;
  220. }
  221. static const struct file_operations fops_ant_diversity = {
  222. .read = read_file_ant_diversity,
  223. .write = write_file_ant_diversity,
  224. .open = simple_open,
  225. .owner = THIS_MODULE,
  226. .llseek = default_llseek,
  227. };
  228. static ssize_t read_file_dma(struct file *file, char __user *user_buf,
  229. size_t count, loff_t *ppos)
  230. {
  231. struct ath_softc *sc = file->private_data;
  232. struct ath_hw *ah = sc->sc_ah;
  233. char *buf;
  234. int retval;
  235. unsigned int len = 0;
  236. u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
  237. int i, qcuOffset = 0, dcuOffset = 0;
  238. u32 *qcuBase = &val[0], *dcuBase = &val[4];
  239. buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL);
  240. if (!buf)
  241. return -ENOMEM;
  242. ath9k_ps_wakeup(sc);
  243. REG_WRITE_D(ah, AR_MACMISC,
  244. ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
  245. (AR_MACMISC_MISC_OBS_BUS_1 <<
  246. AR_MACMISC_MISC_OBS_BUS_MSB_S)));
  247. len += snprintf(buf + len, DMA_BUF_LEN - len,
  248. "Raw DMA Debug values:\n");
  249. for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
  250. if (i % 4 == 0)
  251. len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
  252. val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
  253. len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ",
  254. i, val[i]);
  255. }
  256. len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n");
  257. len += snprintf(buf + len, DMA_BUF_LEN - len,
  258. "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
  259. for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
  260. if (i == 8) {
  261. qcuOffset = 0;
  262. qcuBase++;
  263. }
  264. if (i == 6) {
  265. dcuOffset = 0;
  266. dcuBase++;
  267. }
  268. len += snprintf(buf + len, DMA_BUF_LEN - len,
  269. "%2d %2x %1x %2x %2x\n",
  270. i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
  271. (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
  272. val[2] & (0x7 << (i * 3)) >> (i * 3),
  273. (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
  274. }
  275. len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
  276. len += snprintf(buf + len, DMA_BUF_LEN - len,
  277. "qcu_stitch state: %2x qcu_fetch state: %2x\n",
  278. (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
  279. len += snprintf(buf + len, DMA_BUF_LEN - len,
  280. "qcu_complete state: %2x dcu_complete state: %2x\n",
  281. (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
  282. len += snprintf(buf + len, DMA_BUF_LEN - len,
  283. "dcu_arb state: %2x dcu_fp state: %2x\n",
  284. (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
  285. len += snprintf(buf + len, DMA_BUF_LEN - len,
  286. "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
  287. (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
  288. len += snprintf(buf + len, DMA_BUF_LEN - len,
  289. "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
  290. (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
  291. len += snprintf(buf + len, DMA_BUF_LEN - len,
  292. "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
  293. (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
  294. len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n",
  295. REG_READ_D(ah, AR_OBS_BUS_1));
  296. len += snprintf(buf + len, DMA_BUF_LEN - len,
  297. "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR));
  298. ath9k_ps_restore(sc);
  299. if (len > DMA_BUF_LEN)
  300. len = DMA_BUF_LEN;
  301. retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  302. kfree(buf);
  303. return retval;
  304. }
  305. static const struct file_operations fops_dma = {
  306. .read = read_file_dma,
  307. .open = simple_open,
  308. .owner = THIS_MODULE,
  309. .llseek = default_llseek,
  310. };
  311. void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status)
  312. {
  313. if (status)
  314. sc->debug.stats.istats.total++;
  315. if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
  316. if (status & ATH9K_INT_RXLP)
  317. sc->debug.stats.istats.rxlp++;
  318. if (status & ATH9K_INT_RXHP)
  319. sc->debug.stats.istats.rxhp++;
  320. if (status & ATH9K_INT_BB_WATCHDOG)
  321. sc->debug.stats.istats.bb_watchdog++;
  322. } else {
  323. if (status & ATH9K_INT_RX)
  324. sc->debug.stats.istats.rxok++;
  325. }
  326. if (status & ATH9K_INT_RXEOL)
  327. sc->debug.stats.istats.rxeol++;
  328. if (status & ATH9K_INT_RXORN)
  329. sc->debug.stats.istats.rxorn++;
  330. if (status & ATH9K_INT_TX)
  331. sc->debug.stats.istats.txok++;
  332. if (status & ATH9K_INT_TXURN)
  333. sc->debug.stats.istats.txurn++;
  334. if (status & ATH9K_INT_RXPHY)
  335. sc->debug.stats.istats.rxphyerr++;
  336. if (status & ATH9K_INT_RXKCM)
  337. sc->debug.stats.istats.rx_keycache_miss++;
  338. if (status & ATH9K_INT_SWBA)
  339. sc->debug.stats.istats.swba++;
  340. if (status & ATH9K_INT_BMISS)
  341. sc->debug.stats.istats.bmiss++;
  342. if (status & ATH9K_INT_BNR)
  343. sc->debug.stats.istats.bnr++;
  344. if (status & ATH9K_INT_CST)
  345. sc->debug.stats.istats.cst++;
  346. if (status & ATH9K_INT_GTT)
  347. sc->debug.stats.istats.gtt++;
  348. if (status & ATH9K_INT_TIM)
  349. sc->debug.stats.istats.tim++;
  350. if (status & ATH9K_INT_CABEND)
  351. sc->debug.stats.istats.cabend++;
  352. if (status & ATH9K_INT_DTIMSYNC)
  353. sc->debug.stats.istats.dtimsync++;
  354. if (status & ATH9K_INT_DTIM)
  355. sc->debug.stats.istats.dtim++;
  356. if (status & ATH9K_INT_TSFOOR)
  357. sc->debug.stats.istats.tsfoor++;
  358. if (status & ATH9K_INT_MCI)
  359. sc->debug.stats.istats.mci++;
  360. if (status & ATH9K_INT_GENTIMER)
  361. sc->debug.stats.istats.gen_timer++;
  362. }
  363. static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
  364. size_t count, loff_t *ppos)
  365. {
  366. struct ath_softc *sc = file->private_data;
  367. unsigned int len = 0;
  368. int rv;
  369. int mxlen = 4000;
  370. char *buf = kmalloc(mxlen, GFP_KERNEL);
  371. if (!buf)
  372. return -ENOMEM;
  373. #define PR_IS(a, s) \
  374. do { \
  375. len += snprintf(buf + len, mxlen - len, \
  376. "%21s: %10u\n", a, \
  377. sc->debug.stats.istats.s); \
  378. } while (0)
  379. if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
  380. PR_IS("RXLP", rxlp);
  381. PR_IS("RXHP", rxhp);
  382. PR_IS("WATHDOG", bb_watchdog);
  383. } else {
  384. PR_IS("RX", rxok);
  385. }
  386. PR_IS("RXEOL", rxeol);
  387. PR_IS("RXORN", rxorn);
  388. PR_IS("TX", txok);
  389. PR_IS("TXURN", txurn);
  390. PR_IS("MIB", mib);
  391. PR_IS("RXPHY", rxphyerr);
  392. PR_IS("RXKCM", rx_keycache_miss);
  393. PR_IS("SWBA", swba);
  394. PR_IS("BMISS", bmiss);
  395. PR_IS("BNR", bnr);
  396. PR_IS("CST", cst);
  397. PR_IS("GTT", gtt);
  398. PR_IS("TIM", tim);
  399. PR_IS("CABEND", cabend);
  400. PR_IS("DTIMSYNC", dtimsync);
  401. PR_IS("DTIM", dtim);
  402. PR_IS("TSFOOR", tsfoor);
  403. PR_IS("MCI", mci);
  404. PR_IS("GENTIMER", gen_timer);
  405. PR_IS("TOTAL", total);
  406. len += snprintf(buf + len, mxlen - len,
  407. "SYNC_CAUSE stats:\n");
  408. PR_IS("Sync-All", sync_cause_all);
  409. PR_IS("RTC-IRQ", sync_rtc_irq);
  410. PR_IS("MAC-IRQ", sync_mac_irq);
  411. PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access);
  412. PR_IS("APB-Timeout", apb_timeout);
  413. PR_IS("PCI-Mode-Conflict", pci_mode_conflict);
  414. PR_IS("HOST1-Fatal", host1_fatal);
  415. PR_IS("HOST1-Perr", host1_perr);
  416. PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr);
  417. PR_IS("RADM-CPL-EP", radm_cpl_ep);
  418. PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort);
  419. PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort);
  420. PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err);
  421. PR_IS("RADM-CPL-Timeout", radm_cpl_timeout);
  422. PR_IS("Local-Bus-Timeout", local_timeout);
  423. PR_IS("PM-Access", pm_access);
  424. PR_IS("MAC-Awake", mac_awake);
  425. PR_IS("MAC-Asleep", mac_asleep);
  426. PR_IS("MAC-Sleep-Access", mac_sleep_access);
  427. if (len > mxlen)
  428. len = mxlen;
  429. rv = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  430. kfree(buf);
  431. return rv;
  432. }
  433. static const struct file_operations fops_interrupt = {
  434. .read = read_file_interrupt,
  435. .open = simple_open,
  436. .owner = THIS_MODULE,
  437. .llseek = default_llseek,
  438. };
  439. static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
  440. size_t count, loff_t *ppos)
  441. {
  442. struct ath_softc *sc = file->private_data;
  443. char *buf;
  444. unsigned int len = 0, size = 2048;
  445. ssize_t retval = 0;
  446. buf = kzalloc(size, GFP_KERNEL);
  447. if (buf == NULL)
  448. return -ENOMEM;
  449. len += sprintf(buf, "%30s %10s%10s%10s\n\n",
  450. "BE", "BK", "VI", "VO");
  451. PR("MPDUs Queued: ", queued);
  452. PR("MPDUs Completed: ", completed);
  453. PR("MPDUs XRetried: ", xretries);
  454. PR("Aggregates: ", a_aggr);
  455. PR("AMPDUs Queued HW:", a_queued_hw);
  456. PR("AMPDUs Queued SW:", a_queued_sw);
  457. PR("AMPDUs Completed:", a_completed);
  458. PR("AMPDUs Retried: ", a_retries);
  459. PR("AMPDUs XRetried: ", a_xretries);
  460. PR("TXERR Filtered: ", txerr_filtered);
  461. PR("FIFO Underrun: ", fifo_underrun);
  462. PR("TXOP Exceeded: ", xtxop);
  463. PR("TXTIMER Expiry: ", timer_exp);
  464. PR("DESC CFG Error: ", desc_cfg_err);
  465. PR("DATA Underrun: ", data_underrun);
  466. PR("DELIM Underrun: ", delim_underrun);
  467. PR("TX-Pkts-All: ", tx_pkts_all);
  468. PR("TX-Bytes-All: ", tx_bytes_all);
  469. PR("HW-put-tx-buf: ", puttxbuf);
  470. PR("HW-tx-start: ", txstart);
  471. PR("HW-tx-proc-desc: ", txprocdesc);
  472. PR("TX-Failed: ", txfailed);
  473. if (len > size)
  474. len = size;
  475. retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  476. kfree(buf);
  477. return retval;
  478. }
  479. static ssize_t read_file_queues(struct file *file, char __user *user_buf,
  480. size_t count, loff_t *ppos)
  481. {
  482. struct ath_softc *sc = file->private_data;
  483. struct ath_txq *txq;
  484. char *buf;
  485. unsigned int len = 0, size = 1024;
  486. ssize_t retval = 0;
  487. int i;
  488. char *qname[4] = {"VO", "VI", "BE", "BK"};
  489. buf = kzalloc(size, GFP_KERNEL);
  490. if (buf == NULL)
  491. return -ENOMEM;
  492. for (i = 0; i < IEEE80211_NUM_ACS; i++) {
  493. txq = sc->tx.txq_map[i];
  494. len += snprintf(buf + len, size - len, "(%s): ", qname[i]);
  495. ath_txq_lock(sc, txq);
  496. len += snprintf(buf + len, size - len, "%s: %d ",
  497. "qnum", txq->axq_qnum);
  498. len += snprintf(buf + len, size - len, "%s: %2d ",
  499. "qdepth", txq->axq_depth);
  500. len += snprintf(buf + len, size - len, "%s: %2d ",
  501. "ampdu-depth", txq->axq_ampdu_depth);
  502. len += snprintf(buf + len, size - len, "%s: %3d ",
  503. "pending", txq->pending_frames);
  504. len += snprintf(buf + len, size - len, "%s: %d\n",
  505. "stopped", txq->stopped);
  506. ath_txq_unlock(sc, txq);
  507. }
  508. if (len > size)
  509. len = size;
  510. retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  511. kfree(buf);
  512. return retval;
  513. }
  514. static ssize_t read_file_misc(struct file *file, char __user *user_buf,
  515. size_t count, loff_t *ppos)
  516. {
  517. struct ath_softc *sc = file->private_data;
  518. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  519. struct ieee80211_hw *hw = sc->hw;
  520. struct ath9k_vif_iter_data iter_data;
  521. char buf[512];
  522. unsigned int len = 0;
  523. ssize_t retval = 0;
  524. unsigned int reg;
  525. u32 rxfilter;
  526. len += snprintf(buf + len, sizeof(buf) - len,
  527. "BSSID: %pM\n", common->curbssid);
  528. len += snprintf(buf + len, sizeof(buf) - len,
  529. "BSSID-MASK: %pM\n", common->bssidmask);
  530. len += snprintf(buf + len, sizeof(buf) - len,
  531. "OPMODE: %s\n", ath_opmode_to_string(sc->sc_ah->opmode));
  532. ath9k_ps_wakeup(sc);
  533. rxfilter = ath9k_hw_getrxfilter(sc->sc_ah);
  534. ath9k_ps_restore(sc);
  535. len += snprintf(buf + len, sizeof(buf) - len,
  536. "RXFILTER: 0x%x", rxfilter);
  537. if (rxfilter & ATH9K_RX_FILTER_UCAST)
  538. len += snprintf(buf + len, sizeof(buf) - len, " UCAST");
  539. if (rxfilter & ATH9K_RX_FILTER_MCAST)
  540. len += snprintf(buf + len, sizeof(buf) - len, " MCAST");
  541. if (rxfilter & ATH9K_RX_FILTER_BCAST)
  542. len += snprintf(buf + len, sizeof(buf) - len, " BCAST");
  543. if (rxfilter & ATH9K_RX_FILTER_CONTROL)
  544. len += snprintf(buf + len, sizeof(buf) - len, " CONTROL");
  545. if (rxfilter & ATH9K_RX_FILTER_BEACON)
  546. len += snprintf(buf + len, sizeof(buf) - len, " BEACON");
  547. if (rxfilter & ATH9K_RX_FILTER_PROM)
  548. len += snprintf(buf + len, sizeof(buf) - len, " PROM");
  549. if (rxfilter & ATH9K_RX_FILTER_PROBEREQ)
  550. len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ");
  551. if (rxfilter & ATH9K_RX_FILTER_PHYERR)
  552. len += snprintf(buf + len, sizeof(buf) - len, " PHYERR");
  553. if (rxfilter & ATH9K_RX_FILTER_MYBEACON)
  554. len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON");
  555. if (rxfilter & ATH9K_RX_FILTER_COMP_BAR)
  556. len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR");
  557. if (rxfilter & ATH9K_RX_FILTER_PSPOLL)
  558. len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL");
  559. if (rxfilter & ATH9K_RX_FILTER_PHYRADAR)
  560. len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR");
  561. if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL)
  562. len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL");
  563. if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER)
  564. len += snprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER");
  565. len += snprintf(buf + len, sizeof(buf) - len, "\n");
  566. reg = sc->sc_ah->imask;
  567. len += snprintf(buf + len, sizeof(buf) - len, "INTERRUPT-MASK: 0x%x", reg);
  568. if (reg & ATH9K_INT_SWBA)
  569. len += snprintf(buf + len, sizeof(buf) - len, " SWBA");
  570. if (reg & ATH9K_INT_BMISS)
  571. len += snprintf(buf + len, sizeof(buf) - len, " BMISS");
  572. if (reg & ATH9K_INT_CST)
  573. len += snprintf(buf + len, sizeof(buf) - len, " CST");
  574. if (reg & ATH9K_INT_RX)
  575. len += snprintf(buf + len, sizeof(buf) - len, " RX");
  576. if (reg & ATH9K_INT_RXHP)
  577. len += snprintf(buf + len, sizeof(buf) - len, " RXHP");
  578. if (reg & ATH9K_INT_RXLP)
  579. len += snprintf(buf + len, sizeof(buf) - len, " RXLP");
  580. if (reg & ATH9K_INT_BB_WATCHDOG)
  581. len += snprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG");
  582. len += snprintf(buf + len, sizeof(buf) - len, "\n");
  583. ath9k_calculate_iter_data(hw, NULL, &iter_data);
  584. len += snprintf(buf + len, sizeof(buf) - len,
  585. "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i"
  586. " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n",
  587. iter_data.naps, iter_data.nstations, iter_data.nmeshes,
  588. iter_data.nwds, iter_data.nadhocs,
  589. sc->nvifs, sc->nbcnvifs);
  590. if (len > sizeof(buf))
  591. len = sizeof(buf);
  592. retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  593. return retval;
  594. }
  595. static ssize_t read_file_reset(struct file *file, char __user *user_buf,
  596. size_t count, loff_t *ppos)
  597. {
  598. struct ath_softc *sc = file->private_data;
  599. char buf[512];
  600. unsigned int len = 0;
  601. len += snprintf(buf + len, sizeof(buf) - len,
  602. "%17s: %2d\n", "Baseband Hang",
  603. sc->debug.stats.reset[RESET_TYPE_BB_HANG]);
  604. len += snprintf(buf + len, sizeof(buf) - len,
  605. "%17s: %2d\n", "Baseband Watchdog",
  606. sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]);
  607. len += snprintf(buf + len, sizeof(buf) - len,
  608. "%17s: %2d\n", "Fatal HW Error",
  609. sc->debug.stats.reset[RESET_TYPE_FATAL_INT]);
  610. len += snprintf(buf + len, sizeof(buf) - len,
  611. "%17s: %2d\n", "TX HW error",
  612. sc->debug.stats.reset[RESET_TYPE_TX_ERROR]);
  613. len += snprintf(buf + len, sizeof(buf) - len,
  614. "%17s: %2d\n", "TX Path Hang",
  615. sc->debug.stats.reset[RESET_TYPE_TX_HANG]);
  616. len += snprintf(buf + len, sizeof(buf) - len,
  617. "%17s: %2d\n", "PLL RX Hang",
  618. sc->debug.stats.reset[RESET_TYPE_PLL_HANG]);
  619. len += snprintf(buf + len, sizeof(buf) - len,
  620. "%17s: %2d\n", "MCI Reset",
  621. sc->debug.stats.reset[RESET_TYPE_MCI]);
  622. if (len > sizeof(buf))
  623. len = sizeof(buf);
  624. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  625. }
  626. void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
  627. struct ath_tx_status *ts, struct ath_txq *txq,
  628. unsigned int flags)
  629. {
  630. int qnum = txq->axq_qnum;
  631. TX_STAT_INC(qnum, tx_pkts_all);
  632. sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len;
  633. if (bf_isampdu(bf)) {
  634. if (flags & ATH_TX_ERROR)
  635. TX_STAT_INC(qnum, a_xretries);
  636. else
  637. TX_STAT_INC(qnum, a_completed);
  638. } else {
  639. if (ts->ts_status & ATH9K_TXERR_XRETRY)
  640. TX_STAT_INC(qnum, xretries);
  641. else
  642. TX_STAT_INC(qnum, completed);
  643. }
  644. if (ts->ts_status & ATH9K_TXERR_FILT)
  645. TX_STAT_INC(qnum, txerr_filtered);
  646. if (ts->ts_status & ATH9K_TXERR_FIFO)
  647. TX_STAT_INC(qnum, fifo_underrun);
  648. if (ts->ts_status & ATH9K_TXERR_XTXOP)
  649. TX_STAT_INC(qnum, xtxop);
  650. if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED)
  651. TX_STAT_INC(qnum, timer_exp);
  652. if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR)
  653. TX_STAT_INC(qnum, desc_cfg_err);
  654. if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN)
  655. TX_STAT_INC(qnum, data_underrun);
  656. if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
  657. TX_STAT_INC(qnum, delim_underrun);
  658. }
  659. static const struct file_operations fops_xmit = {
  660. .read = read_file_xmit,
  661. .open = simple_open,
  662. .owner = THIS_MODULE,
  663. .llseek = default_llseek,
  664. };
  665. static const struct file_operations fops_queues = {
  666. .read = read_file_queues,
  667. .open = simple_open,
  668. .owner = THIS_MODULE,
  669. .llseek = default_llseek,
  670. };
  671. static const struct file_operations fops_misc = {
  672. .read = read_file_misc,
  673. .open = simple_open,
  674. .owner = THIS_MODULE,
  675. .llseek = default_llseek,
  676. };
  677. static const struct file_operations fops_reset = {
  678. .read = read_file_reset,
  679. .open = simple_open,
  680. .owner = THIS_MODULE,
  681. .llseek = default_llseek,
  682. };
  683. static ssize_t read_file_recv(struct file *file, char __user *user_buf,
  684. size_t count, loff_t *ppos)
  685. {
  686. #define PHY_ERR(s, p) \
  687. len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \
  688. sc->debug.stats.rxstats.phy_err_stats[p]);
  689. #define RXS_ERR(s, e) \
  690. do { \
  691. len += snprintf(buf + len, size - len, \
  692. "%22s : %10u\n", s, \
  693. sc->debug.stats.rxstats.e); \
  694. } while (0)
  695. struct ath_softc *sc = file->private_data;
  696. char *buf;
  697. unsigned int len = 0, size = 1600;
  698. ssize_t retval = 0;
  699. buf = kzalloc(size, GFP_KERNEL);
  700. if (buf == NULL)
  701. return -ENOMEM;
  702. RXS_ERR("CRC ERR", crc_err);
  703. RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err);
  704. RXS_ERR("PHY ERR", phy_err);
  705. RXS_ERR("MIC ERR", mic_err);
  706. RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err);
  707. RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err);
  708. RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err);
  709. RXS_ERR("RX-LENGTH-ERR", rx_len_err);
  710. RXS_ERR("RX-OOM-ERR", rx_oom_err);
  711. RXS_ERR("RX-RATE-ERR", rx_rate_err);
  712. RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err);
  713. PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN);
  714. PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING);
  715. PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY);
  716. PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE);
  717. PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH);
  718. PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR);
  719. PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE);
  720. PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR);
  721. PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING);
  722. PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY);
  723. PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL);
  724. PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL);
  725. PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP);
  726. PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE);
  727. PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART);
  728. PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT);
  729. PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING);
  730. PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC);
  731. PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL);
  732. PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE);
  733. PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART);
  734. PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL);
  735. PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP);
  736. PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR);
  737. PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
  738. PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL);
  739. RXS_ERR("RX-Pkts-All", rx_pkts_all);
  740. RXS_ERR("RX-Bytes-All", rx_bytes_all);
  741. RXS_ERR("RX-Beacons", rx_beacons);
  742. RXS_ERR("RX-Frags", rx_frags);
  743. RXS_ERR("RX-Spectral", rx_spectral);
  744. if (len > size)
  745. len = size;
  746. retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  747. kfree(buf);
  748. return retval;
  749. #undef RXS_ERR
  750. #undef PHY_ERR
  751. }
  752. void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
  753. {
  754. #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
  755. RX_STAT_INC(rx_pkts_all);
  756. sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen;
  757. if (rs->rs_status & ATH9K_RXERR_CRC)
  758. RX_STAT_INC(crc_err);
  759. if (rs->rs_status & ATH9K_RXERR_DECRYPT)
  760. RX_STAT_INC(decrypt_crc_err);
  761. if (rs->rs_status & ATH9K_RXERR_MIC)
  762. RX_STAT_INC(mic_err);
  763. if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE)
  764. RX_STAT_INC(pre_delim_crc_err);
  765. if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST)
  766. RX_STAT_INC(post_delim_crc_err);
  767. if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY)
  768. RX_STAT_INC(decrypt_busy_err);
  769. if (rs->rs_status & ATH9K_RXERR_PHY) {
  770. RX_STAT_INC(phy_err);
  771. if (rs->rs_phyerr < ATH9K_PHYERR_MAX)
  772. RX_PHY_ERR_INC(rs->rs_phyerr);
  773. }
  774. #undef RX_PHY_ERR_INC
  775. }
  776. static const struct file_operations fops_recv = {
  777. .read = read_file_recv,
  778. .open = simple_open,
  779. .owner = THIS_MODULE,
  780. .llseek = default_llseek,
  781. };
  782. static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf,
  783. size_t count, loff_t *ppos)
  784. {
  785. struct ath_softc *sc = file->private_data;
  786. char *mode = "";
  787. unsigned int len;
  788. switch (sc->spectral_mode) {
  789. case SPECTRAL_DISABLED:
  790. mode = "disable";
  791. break;
  792. case SPECTRAL_BACKGROUND:
  793. mode = "background";
  794. break;
  795. case SPECTRAL_CHANSCAN:
  796. mode = "chanscan";
  797. break;
  798. case SPECTRAL_MANUAL:
  799. mode = "manual";
  800. break;
  801. }
  802. len = strlen(mode);
  803. return simple_read_from_buffer(user_buf, count, ppos, mode, len);
  804. }
  805. static ssize_t write_file_spec_scan_ctl(struct file *file,
  806. const char __user *user_buf,
  807. size_t count, loff_t *ppos)
  808. {
  809. struct ath_softc *sc = file->private_data;
  810. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  811. char buf[32];
  812. ssize_t len;
  813. len = min(count, sizeof(buf) - 1);
  814. if (copy_from_user(buf, user_buf, len))
  815. return -EFAULT;
  816. buf[len] = '\0';
  817. if (strncmp("trigger", buf, 7) == 0) {
  818. ath9k_spectral_scan_trigger(sc->hw);
  819. } else if (strncmp("background", buf, 9) == 0) {
  820. ath9k_spectral_scan_config(sc->hw, SPECTRAL_BACKGROUND);
  821. ath_dbg(common, CONFIG, "spectral scan: background mode enabled\n");
  822. } else if (strncmp("chanscan", buf, 8) == 0) {
  823. ath9k_spectral_scan_config(sc->hw, SPECTRAL_CHANSCAN);
  824. ath_dbg(common, CONFIG, "spectral scan: channel scan mode enabled\n");
  825. } else if (strncmp("manual", buf, 6) == 0) {
  826. ath9k_spectral_scan_config(sc->hw, SPECTRAL_MANUAL);
  827. ath_dbg(common, CONFIG, "spectral scan: manual mode enabled\n");
  828. } else if (strncmp("disable", buf, 7) == 0) {
  829. ath9k_spectral_scan_config(sc->hw, SPECTRAL_DISABLED);
  830. ath_dbg(common, CONFIG, "spectral scan: disabled\n");
  831. } else {
  832. return -EINVAL;
  833. }
  834. return count;
  835. }
  836. static const struct file_operations fops_spec_scan_ctl = {
  837. .read = read_file_spec_scan_ctl,
  838. .write = write_file_spec_scan_ctl,
  839. .open = simple_open,
  840. .owner = THIS_MODULE,
  841. .llseek = default_llseek,
  842. };
  843. static ssize_t read_file_spectral_short_repeat(struct file *file,
  844. char __user *user_buf,
  845. size_t count, loff_t *ppos)
  846. {
  847. struct ath_softc *sc = file->private_data;
  848. char buf[32];
  849. unsigned int len;
  850. len = sprintf(buf, "%d\n", sc->spec_config.short_repeat);
  851. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  852. }
  853. static ssize_t write_file_spectral_short_repeat(struct file *file,
  854. const char __user *user_buf,
  855. size_t count, loff_t *ppos)
  856. {
  857. struct ath_softc *sc = file->private_data;
  858. unsigned long val;
  859. char buf[32];
  860. ssize_t len;
  861. len = min(count, sizeof(buf) - 1);
  862. if (copy_from_user(buf, user_buf, len))
  863. return -EFAULT;
  864. buf[len] = '\0';
  865. if (kstrtoul(buf, 0, &val))
  866. return -EINVAL;
  867. if (val < 0 || val > 1)
  868. return -EINVAL;
  869. sc->spec_config.short_repeat = val;
  870. return count;
  871. }
  872. static const struct file_operations fops_spectral_short_repeat = {
  873. .read = read_file_spectral_short_repeat,
  874. .write = write_file_spectral_short_repeat,
  875. .open = simple_open,
  876. .owner = THIS_MODULE,
  877. .llseek = default_llseek,
  878. };
  879. static ssize_t read_file_spectral_count(struct file *file,
  880. char __user *user_buf,
  881. size_t count, loff_t *ppos)
  882. {
  883. struct ath_softc *sc = file->private_data;
  884. char buf[32];
  885. unsigned int len;
  886. len = sprintf(buf, "%d\n", sc->spec_config.count);
  887. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  888. }
  889. static ssize_t write_file_spectral_count(struct file *file,
  890. const char __user *user_buf,
  891. size_t count, loff_t *ppos)
  892. {
  893. struct ath_softc *sc = file->private_data;
  894. unsigned long val;
  895. char buf[32];
  896. ssize_t len;
  897. len = min(count, sizeof(buf) - 1);
  898. if (copy_from_user(buf, user_buf, len))
  899. return -EFAULT;
  900. buf[len] = '\0';
  901. if (kstrtoul(buf, 0, &val))
  902. return -EINVAL;
  903. if (val < 0 || val > 255)
  904. return -EINVAL;
  905. sc->spec_config.count = val;
  906. return count;
  907. }
  908. static const struct file_operations fops_spectral_count = {
  909. .read = read_file_spectral_count,
  910. .write = write_file_spectral_count,
  911. .open = simple_open,
  912. .owner = THIS_MODULE,
  913. .llseek = default_llseek,
  914. };
  915. static ssize_t read_file_spectral_period(struct file *file,
  916. char __user *user_buf,
  917. size_t count, loff_t *ppos)
  918. {
  919. struct ath_softc *sc = file->private_data;
  920. char buf[32];
  921. unsigned int len;
  922. len = sprintf(buf, "%d\n", sc->spec_config.period);
  923. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  924. }
  925. static ssize_t write_file_spectral_period(struct file *file,
  926. const char __user *user_buf,
  927. size_t count, loff_t *ppos)
  928. {
  929. struct ath_softc *sc = file->private_data;
  930. unsigned long val;
  931. char buf[32];
  932. ssize_t len;
  933. len = min(count, sizeof(buf) - 1);
  934. if (copy_from_user(buf, user_buf, len))
  935. return -EFAULT;
  936. buf[len] = '\0';
  937. if (kstrtoul(buf, 0, &val))
  938. return -EINVAL;
  939. if (val < 0 || val > 255)
  940. return -EINVAL;
  941. sc->spec_config.period = val;
  942. return count;
  943. }
  944. static const struct file_operations fops_spectral_period = {
  945. .read = read_file_spectral_period,
  946. .write = write_file_spectral_period,
  947. .open = simple_open,
  948. .owner = THIS_MODULE,
  949. .llseek = default_llseek,
  950. };
  951. static ssize_t read_file_spectral_fft_period(struct file *file,
  952. char __user *user_buf,
  953. size_t count, loff_t *ppos)
  954. {
  955. struct ath_softc *sc = file->private_data;
  956. char buf[32];
  957. unsigned int len;
  958. len = sprintf(buf, "%d\n", sc->spec_config.fft_period);
  959. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  960. }
  961. static ssize_t write_file_spectral_fft_period(struct file *file,
  962. const char __user *user_buf,
  963. size_t count, loff_t *ppos)
  964. {
  965. struct ath_softc *sc = file->private_data;
  966. unsigned long val;
  967. char buf[32];
  968. ssize_t len;
  969. len = min(count, sizeof(buf) - 1);
  970. if (copy_from_user(buf, user_buf, len))
  971. return -EFAULT;
  972. buf[len] = '\0';
  973. if (kstrtoul(buf, 0, &val))
  974. return -EINVAL;
  975. if (val < 0 || val > 15)
  976. return -EINVAL;
  977. sc->spec_config.fft_period = val;
  978. return count;
  979. }
  980. static const struct file_operations fops_spectral_fft_period = {
  981. .read = read_file_spectral_fft_period,
  982. .write = write_file_spectral_fft_period,
  983. .open = simple_open,
  984. .owner = THIS_MODULE,
  985. .llseek = default_llseek,
  986. };
  987. static struct dentry *create_buf_file_handler(const char *filename,
  988. struct dentry *parent,
  989. umode_t mode,
  990. struct rchan_buf *buf,
  991. int *is_global)
  992. {
  993. struct dentry *buf_file;
  994. buf_file = debugfs_create_file(filename, mode, parent, buf,
  995. &relay_file_operations);
  996. *is_global = 1;
  997. return buf_file;
  998. }
  999. static int remove_buf_file_handler(struct dentry *dentry)
  1000. {
  1001. debugfs_remove(dentry);
  1002. return 0;
  1003. }
  1004. void ath_debug_send_fft_sample(struct ath_softc *sc,
  1005. struct fft_sample_tlv *fft_sample_tlv)
  1006. {
  1007. int length;
  1008. if (!sc->rfs_chan_spec_scan)
  1009. return;
  1010. length = __be16_to_cpu(fft_sample_tlv->length) +
  1011. sizeof(*fft_sample_tlv);
  1012. relay_write(sc->rfs_chan_spec_scan, fft_sample_tlv, length);
  1013. }
  1014. static struct rchan_callbacks rfs_spec_scan_cb = {
  1015. .create_buf_file = create_buf_file_handler,
  1016. .remove_buf_file = remove_buf_file_handler,
  1017. };
  1018. static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
  1019. size_t count, loff_t *ppos)
  1020. {
  1021. struct ath_softc *sc = file->private_data;
  1022. char buf[32];
  1023. unsigned int len;
  1024. len = sprintf(buf, "0x%08x\n", sc->debug.regidx);
  1025. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1026. }
  1027. static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
  1028. size_t count, loff_t *ppos)
  1029. {
  1030. struct ath_softc *sc = file->private_data;
  1031. unsigned long regidx;
  1032. char buf[32];
  1033. ssize_t len;
  1034. len = min(count, sizeof(buf) - 1);
  1035. if (copy_from_user(buf, user_buf, len))
  1036. return -EFAULT;
  1037. buf[len] = '\0';
  1038. if (strict_strtoul(buf, 0, &regidx))
  1039. return -EINVAL;
  1040. sc->debug.regidx = regidx;
  1041. return count;
  1042. }
  1043. static const struct file_operations fops_regidx = {
  1044. .read = read_file_regidx,
  1045. .write = write_file_regidx,
  1046. .open = simple_open,
  1047. .owner = THIS_MODULE,
  1048. .llseek = default_llseek,
  1049. };
  1050. static ssize_t read_file_regval(struct file *file, char __user *user_buf,
  1051. size_t count, loff_t *ppos)
  1052. {
  1053. struct ath_softc *sc = file->private_data;
  1054. struct ath_hw *ah = sc->sc_ah;
  1055. char buf[32];
  1056. unsigned int len;
  1057. u32 regval;
  1058. ath9k_ps_wakeup(sc);
  1059. regval = REG_READ_D(ah, sc->debug.regidx);
  1060. ath9k_ps_restore(sc);
  1061. len = sprintf(buf, "0x%08x\n", regval);
  1062. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1063. }
  1064. static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
  1065. size_t count, loff_t *ppos)
  1066. {
  1067. struct ath_softc *sc = file->private_data;
  1068. struct ath_hw *ah = sc->sc_ah;
  1069. unsigned long regval;
  1070. char buf[32];
  1071. ssize_t len;
  1072. len = min(count, sizeof(buf) - 1);
  1073. if (copy_from_user(buf, user_buf, len))
  1074. return -EFAULT;
  1075. buf[len] = '\0';
  1076. if (strict_strtoul(buf, 0, &regval))
  1077. return -EINVAL;
  1078. ath9k_ps_wakeup(sc);
  1079. REG_WRITE_D(ah, sc->debug.regidx, regval);
  1080. ath9k_ps_restore(sc);
  1081. return count;
  1082. }
  1083. static const struct file_operations fops_regval = {
  1084. .read = read_file_regval,
  1085. .write = write_file_regval,
  1086. .open = simple_open,
  1087. .owner = THIS_MODULE,
  1088. .llseek = default_llseek,
  1089. };
  1090. #define REGDUMP_LINE_SIZE 20
  1091. static int open_file_regdump(struct inode *inode, struct file *file)
  1092. {
  1093. struct ath_softc *sc = inode->i_private;
  1094. unsigned int len = 0;
  1095. u8 *buf;
  1096. int i;
  1097. unsigned long num_regs, regdump_len, max_reg_offset;
  1098. max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500;
  1099. num_regs = max_reg_offset / 4 + 1;
  1100. regdump_len = num_regs * REGDUMP_LINE_SIZE + 1;
  1101. buf = vmalloc(regdump_len);
  1102. if (!buf)
  1103. return -ENOMEM;
  1104. ath9k_ps_wakeup(sc);
  1105. for (i = 0; i < num_regs; i++)
  1106. len += scnprintf(buf + len, regdump_len - len,
  1107. "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2));
  1108. ath9k_ps_restore(sc);
  1109. file->private_data = buf;
  1110. return 0;
  1111. }
  1112. static const struct file_operations fops_regdump = {
  1113. .open = open_file_regdump,
  1114. .read = ath9k_debugfs_read_buf,
  1115. .release = ath9k_debugfs_release_buf,
  1116. .owner = THIS_MODULE,
  1117. .llseek = default_llseek,/* read accesses f_pos */
  1118. };
  1119. static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf,
  1120. size_t count, loff_t *ppos)
  1121. {
  1122. struct ath_softc *sc = file->private_data;
  1123. struct ath_hw *ah = sc->sc_ah;
  1124. struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist;
  1125. struct ath_common *common = ath9k_hw_common(ah);
  1126. struct ieee80211_conf *conf = &common->hw->conf;
  1127. u32 len = 0, size = 1500;
  1128. u32 i, j;
  1129. ssize_t retval = 0;
  1130. char *buf;
  1131. u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
  1132. u8 nread;
  1133. buf = kzalloc(size, GFP_KERNEL);
  1134. if (!buf)
  1135. return -ENOMEM;
  1136. len += snprintf(buf + len, size - len,
  1137. "Channel Noise Floor : %d\n", ah->noise);
  1138. len += snprintf(buf + len, size - len,
  1139. "Chain | privNF | # Readings | NF Readings\n");
  1140. for (i = 0; i < NUM_NF_READINGS; i++) {
  1141. if (!(chainmask & (1 << i)) ||
  1142. ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
  1143. continue;
  1144. nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount;
  1145. len += snprintf(buf + len, size - len, " %d\t %d\t %d\t\t",
  1146. i, h[i].privNF, nread);
  1147. for (j = 0; j < nread; j++)
  1148. len += snprintf(buf + len, size - len,
  1149. " %d", h[i].nfCalBuffer[j]);
  1150. len += snprintf(buf + len, size - len, "\n");
  1151. }
  1152. if (len > size)
  1153. len = size;
  1154. retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1155. kfree(buf);
  1156. return retval;
  1157. }
  1158. static const struct file_operations fops_dump_nfcal = {
  1159. .read = read_file_dump_nfcal,
  1160. .open = simple_open,
  1161. .owner = THIS_MODULE,
  1162. .llseek = default_llseek,
  1163. };
  1164. static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
  1165. size_t count, loff_t *ppos)
  1166. {
  1167. struct ath_softc *sc = file->private_data;
  1168. struct ath_hw *ah = sc->sc_ah;
  1169. u32 len = 0, size = 1500;
  1170. ssize_t retval = 0;
  1171. char *buf;
  1172. buf = kzalloc(size, GFP_KERNEL);
  1173. if (!buf)
  1174. return -ENOMEM;
  1175. len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size);
  1176. retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1177. kfree(buf);
  1178. return retval;
  1179. }
  1180. static const struct file_operations fops_base_eeprom = {
  1181. .read = read_file_base_eeprom,
  1182. .open = simple_open,
  1183. .owner = THIS_MODULE,
  1184. .llseek = default_llseek,
  1185. };
  1186. static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf,
  1187. size_t count, loff_t *ppos)
  1188. {
  1189. struct ath_softc *sc = file->private_data;
  1190. struct ath_hw *ah = sc->sc_ah;
  1191. u32 len = 0, size = 6000;
  1192. char *buf;
  1193. size_t retval;
  1194. buf = kzalloc(size, GFP_KERNEL);
  1195. if (buf == NULL)
  1196. return -ENOMEM;
  1197. len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size);
  1198. retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1199. kfree(buf);
  1200. return retval;
  1201. }
  1202. static const struct file_operations fops_modal_eeprom = {
  1203. .read = read_file_modal_eeprom,
  1204. .open = simple_open,
  1205. .owner = THIS_MODULE,
  1206. .llseek = default_llseek,
  1207. };
  1208. #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
  1209. static ssize_t read_file_btcoex(struct file *file, char __user *user_buf,
  1210. size_t count, loff_t *ppos)
  1211. {
  1212. struct ath_softc *sc = file->private_data;
  1213. u32 len = 0, size = 1500;
  1214. char *buf;
  1215. size_t retval;
  1216. buf = kzalloc(size, GFP_KERNEL);
  1217. if (buf == NULL)
  1218. return -ENOMEM;
  1219. if (!sc->sc_ah->common.btcoex_enabled) {
  1220. len = snprintf(buf, size, "%s\n",
  1221. "BTCOEX is disabled");
  1222. goto exit;
  1223. }
  1224. len = ath9k_dump_btcoex(sc, buf, size);
  1225. exit:
  1226. retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1227. kfree(buf);
  1228. return retval;
  1229. }
  1230. static const struct file_operations fops_btcoex = {
  1231. .read = read_file_btcoex,
  1232. .open = simple_open,
  1233. .owner = THIS_MODULE,
  1234. .llseek = default_llseek,
  1235. };
  1236. #endif
  1237. static ssize_t read_file_node_stat(struct file *file, char __user *user_buf,
  1238. size_t count, loff_t *ppos)
  1239. {
  1240. struct ath_node *an = file->private_data;
  1241. struct ath_softc *sc = an->sc;
  1242. struct ath_atx_tid *tid;
  1243. struct ath_atx_ac *ac;
  1244. struct ath_txq *txq;
  1245. u32 len = 0, size = 4096;
  1246. char *buf;
  1247. size_t retval;
  1248. int tidno, acno;
  1249. buf = kzalloc(size, GFP_KERNEL);
  1250. if (buf == NULL)
  1251. return -ENOMEM;
  1252. if (!an->sta->ht_cap.ht_supported) {
  1253. len = snprintf(buf, size, "%s\n",
  1254. "HT not supported");
  1255. goto exit;
  1256. }
  1257. len = snprintf(buf, size, "Max-AMPDU: %d\n",
  1258. an->maxampdu);
  1259. len += snprintf(buf + len, size - len, "MPDU Density: %d\n\n",
  1260. an->mpdudensity);
  1261. len += snprintf(buf + len, size - len,
  1262. "%2s%7s\n", "AC", "SCHED");
  1263. for (acno = 0, ac = &an->ac[acno];
  1264. acno < IEEE80211_NUM_ACS; acno++, ac++) {
  1265. txq = ac->txq;
  1266. ath_txq_lock(sc, txq);
  1267. len += snprintf(buf + len, size - len,
  1268. "%2d%7d\n",
  1269. acno, ac->sched);
  1270. ath_txq_unlock(sc, txq);
  1271. }
  1272. len += snprintf(buf + len, size - len,
  1273. "\n%3s%11s%10s%10s%10s%10s%9s%6s%8s\n",
  1274. "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE",
  1275. "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED");
  1276. for (tidno = 0, tid = &an->tid[tidno];
  1277. tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
  1278. txq = tid->ac->txq;
  1279. ath_txq_lock(sc, txq);
  1280. len += snprintf(buf + len, size - len,
  1281. "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n",
  1282. tid->tidno, tid->seq_start, tid->seq_next,
  1283. tid->baw_size, tid->baw_head, tid->baw_tail,
  1284. tid->bar_index, tid->sched, tid->paused);
  1285. ath_txq_unlock(sc, txq);
  1286. }
  1287. exit:
  1288. retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1289. kfree(buf);
  1290. return retval;
  1291. }
  1292. static const struct file_operations fops_node_stat = {
  1293. .read = read_file_node_stat,
  1294. .open = simple_open,
  1295. .owner = THIS_MODULE,
  1296. .llseek = default_llseek,
  1297. };
  1298. void ath9k_sta_add_debugfs(struct ieee80211_hw *hw,
  1299. struct ieee80211_vif *vif,
  1300. struct ieee80211_sta *sta,
  1301. struct dentry *dir)
  1302. {
  1303. struct ath_node *an = (struct ath_node *)sta->drv_priv;
  1304. an->node_stat = debugfs_create_file("node_stat", S_IRUGO,
  1305. dir, an, &fops_node_stat);
  1306. }
  1307. void ath9k_sta_remove_debugfs(struct ieee80211_hw *hw,
  1308. struct ieee80211_vif *vif,
  1309. struct ieee80211_sta *sta,
  1310. struct dentry *dir)
  1311. {
  1312. struct ath_node *an = (struct ath_node *)sta->drv_priv;
  1313. debugfs_remove(an->node_stat);
  1314. }
  1315. /* Ethtool support for get-stats */
  1316. #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
  1317. static const char ath9k_gstrings_stats[][ETH_GSTRING_LEN] = {
  1318. "tx_pkts_nic",
  1319. "tx_bytes_nic",
  1320. "rx_pkts_nic",
  1321. "rx_bytes_nic",
  1322. AMKSTR(d_tx_pkts),
  1323. AMKSTR(d_tx_bytes),
  1324. AMKSTR(d_tx_mpdus_queued),
  1325. AMKSTR(d_tx_mpdus_completed),
  1326. AMKSTR(d_tx_mpdu_xretries),
  1327. AMKSTR(d_tx_aggregates),
  1328. AMKSTR(d_tx_ampdus_queued_hw),
  1329. AMKSTR(d_tx_ampdus_queued_sw),
  1330. AMKSTR(d_tx_ampdus_completed),
  1331. AMKSTR(d_tx_ampdu_retries),
  1332. AMKSTR(d_tx_ampdu_xretries),
  1333. AMKSTR(d_tx_fifo_underrun),
  1334. AMKSTR(d_tx_op_exceeded),
  1335. AMKSTR(d_tx_timer_expiry),
  1336. AMKSTR(d_tx_desc_cfg_err),
  1337. AMKSTR(d_tx_data_underrun),
  1338. AMKSTR(d_tx_delim_underrun),
  1339. "d_rx_crc_err",
  1340. "d_rx_decrypt_crc_err",
  1341. "d_rx_phy_err",
  1342. "d_rx_mic_err",
  1343. "d_rx_pre_delim_crc_err",
  1344. "d_rx_post_delim_crc_err",
  1345. "d_rx_decrypt_busy_err",
  1346. "d_rx_phyerr_radar",
  1347. "d_rx_phyerr_ofdm_timing",
  1348. "d_rx_phyerr_cck_timing",
  1349. };
  1350. #define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats)
  1351. void ath9k_get_et_strings(struct ieee80211_hw *hw,
  1352. struct ieee80211_vif *vif,
  1353. u32 sset, u8 *data)
  1354. {
  1355. if (sset == ETH_SS_STATS)
  1356. memcpy(data, *ath9k_gstrings_stats,
  1357. sizeof(ath9k_gstrings_stats));
  1358. }
  1359. int ath9k_get_et_sset_count(struct ieee80211_hw *hw,
  1360. struct ieee80211_vif *vif, int sset)
  1361. {
  1362. if (sset == ETH_SS_STATS)
  1363. return ATH9K_SSTATS_LEN;
  1364. return 0;
  1365. }
  1366. #define AWDATA(elem) \
  1367. do { \
  1368. data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].elem; \
  1369. data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].elem; \
  1370. data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].elem; \
  1371. data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].elem; \
  1372. } while (0)
  1373. #define AWDATA_RX(elem) \
  1374. do { \
  1375. data[i++] = sc->debug.stats.rxstats.elem; \
  1376. } while (0)
  1377. void ath9k_get_et_stats(struct ieee80211_hw *hw,
  1378. struct ieee80211_vif *vif,
  1379. struct ethtool_stats *stats, u64 *data)
  1380. {
  1381. struct ath_softc *sc = hw->priv;
  1382. int i = 0;
  1383. data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_pkts_all +
  1384. sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_pkts_all +
  1385. sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_pkts_all +
  1386. sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_pkts_all);
  1387. data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_bytes_all +
  1388. sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_bytes_all +
  1389. sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_bytes_all +
  1390. sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_bytes_all);
  1391. AWDATA_RX(rx_pkts_all);
  1392. AWDATA_RX(rx_bytes_all);
  1393. AWDATA(tx_pkts_all);
  1394. AWDATA(tx_bytes_all);
  1395. AWDATA(queued);
  1396. AWDATA(completed);
  1397. AWDATA(xretries);
  1398. AWDATA(a_aggr);
  1399. AWDATA(a_queued_hw);
  1400. AWDATA(a_queued_sw);
  1401. AWDATA(a_completed);
  1402. AWDATA(a_retries);
  1403. AWDATA(a_xretries);
  1404. AWDATA(fifo_underrun);
  1405. AWDATA(xtxop);
  1406. AWDATA(timer_exp);
  1407. AWDATA(desc_cfg_err);
  1408. AWDATA(data_underrun);
  1409. AWDATA(delim_underrun);
  1410. AWDATA_RX(crc_err);
  1411. AWDATA_RX(decrypt_crc_err);
  1412. AWDATA_RX(phy_err);
  1413. AWDATA_RX(mic_err);
  1414. AWDATA_RX(pre_delim_crc_err);
  1415. AWDATA_RX(post_delim_crc_err);
  1416. AWDATA_RX(decrypt_busy_err);
  1417. AWDATA_RX(phy_err_stats[ATH9K_PHYERR_RADAR]);
  1418. AWDATA_RX(phy_err_stats[ATH9K_PHYERR_OFDM_TIMING]);
  1419. AWDATA_RX(phy_err_stats[ATH9K_PHYERR_CCK_TIMING]);
  1420. WARN_ON(i != ATH9K_SSTATS_LEN);
  1421. }
  1422. int ath9k_init_debug(struct ath_hw *ah)
  1423. {
  1424. struct ath_common *common = ath9k_hw_common(ah);
  1425. struct ath_softc *sc = (struct ath_softc *) common->priv;
  1426. sc->debug.debugfs_phy = debugfs_create_dir("ath9k",
  1427. sc->hw->wiphy->debugfsdir);
  1428. if (!sc->debug.debugfs_phy)
  1429. return -ENOMEM;
  1430. #ifdef CONFIG_ATH_DEBUG
  1431. debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  1432. sc, &fops_debug);
  1433. #endif
  1434. ath9k_dfs_init_debug(sc);
  1435. debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
  1436. &fops_dma);
  1437. debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
  1438. &fops_interrupt);
  1439. debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc,
  1440. &fops_xmit);
  1441. debugfs_create_file("queues", S_IRUSR, sc->debug.debugfs_phy, sc,
  1442. &fops_queues);
  1443. debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  1444. &sc->tx.txq_max_pending[IEEE80211_AC_BK]);
  1445. debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  1446. &sc->tx.txq_max_pending[IEEE80211_AC_BE]);
  1447. debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  1448. &sc->tx.txq_max_pending[IEEE80211_AC_VI]);
  1449. debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  1450. &sc->tx.txq_max_pending[IEEE80211_AC_VO]);
  1451. debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc,
  1452. &fops_misc);
  1453. debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc,
  1454. &fops_reset);
  1455. debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc,
  1456. &fops_recv);
  1457. debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR,
  1458. sc->debug.debugfs_phy, sc, &fops_rx_chainmask);
  1459. debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR,
  1460. sc->debug.debugfs_phy, sc, &fops_tx_chainmask);
  1461. debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR,
  1462. sc->debug.debugfs_phy, sc, &fops_disable_ani);
  1463. debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  1464. &sc->sc_ah->config.enable_paprd);
  1465. debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  1466. sc, &fops_regidx);
  1467. debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  1468. sc, &fops_regval);
  1469. debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR,
  1470. sc->debug.debugfs_phy,
  1471. &ah->config.cwm_ignore_extcca);
  1472. debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc,
  1473. &fops_regdump);
  1474. debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc,
  1475. &fops_dump_nfcal);
  1476. debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
  1477. &fops_base_eeprom);
  1478. debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
  1479. &fops_modal_eeprom);
  1480. sc->rfs_chan_spec_scan = relay_open("spectral_scan",
  1481. sc->debug.debugfs_phy,
  1482. 1024, 256, &rfs_spec_scan_cb,
  1483. NULL);
  1484. debugfs_create_file("spectral_scan_ctl", S_IRUSR | S_IWUSR,
  1485. sc->debug.debugfs_phy, sc,
  1486. &fops_spec_scan_ctl);
  1487. debugfs_create_file("spectral_short_repeat", S_IRUSR | S_IWUSR,
  1488. sc->debug.debugfs_phy, sc,
  1489. &fops_spectral_short_repeat);
  1490. debugfs_create_file("spectral_count", S_IRUSR | S_IWUSR,
  1491. sc->debug.debugfs_phy, sc, &fops_spectral_count);
  1492. debugfs_create_file("spectral_period", S_IRUSR | S_IWUSR,
  1493. sc->debug.debugfs_phy, sc, &fops_spectral_period);
  1494. debugfs_create_file("spectral_fft_period", S_IRUSR | S_IWUSR,
  1495. sc->debug.debugfs_phy, sc,
  1496. &fops_spectral_fft_period);
  1497. debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
  1498. sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
  1499. debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
  1500. sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
  1501. debugfs_create_file("diversity", S_IRUSR | S_IWUSR,
  1502. sc->debug.debugfs_phy, sc, &fops_ant_diversity);
  1503. #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
  1504. debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc,
  1505. &fops_btcoex);
  1506. #endif
  1507. return 0;
  1508. }