debug.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  1. /*
  2. * Copyright (c) 2007-2008 Bruno Randolf <bruno@thinktube.com>
  3. *
  4. * This file is free software: you may copy, redistribute and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation, either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * This file is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. *
  18. * This file incorporates work covered by the following copyright and
  19. * permission notice:
  20. *
  21. * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
  22. * Copyright (c) 2004-2005 Atheros Communications, Inc.
  23. * Copyright (c) 2006 Devicescape Software, Inc.
  24. * Copyright (c) 2007 Jiri Slaby <jirislaby@gmail.com>
  25. * Copyright (c) 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
  26. *
  27. * All rights reserved.
  28. *
  29. * Redistribution and use in source and binary forms, with or without
  30. * modification, are permitted provided that the following conditions
  31. * are met:
  32. * 1. Redistributions of source code must retain the above copyright
  33. * notice, this list of conditions and the following disclaimer,
  34. * without modification.
  35. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  36. * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
  37. * redistribution must be conditioned upon including a substantially
  38. * similar Disclaimer requirement for further binary redistribution.
  39. * 3. Neither the names of the above-listed copyright holders nor the names
  40. * of any contributors may be used to endorse or promote products derived
  41. * from this software without specific prior written permission.
  42. *
  43. * Alternatively, this software may be distributed under the terms of the
  44. * GNU General Public License ("GPL") version 2 as published by the Free
  45. * Software Foundation.
  46. *
  47. * NO WARRANTY
  48. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  49. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  50. * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
  51. * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  52. * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
  53. * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  54. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  55. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  56. * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  57. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  58. * THE POSSIBILITY OF SUCH DAMAGES.
  59. */
  60. #include "base.h"
  61. #include "debug.h"
  62. static unsigned int ath5k_debug;
  63. module_param_named(debug, ath5k_debug, uint, 0);
  64. #ifdef CONFIG_ATH5K_DEBUG
  65. #include <linux/seq_file.h>
  66. #include "reg.h"
  67. #include "ani.h"
  68. static int ath5k_debugfs_open(struct inode *inode, struct file *file)
  69. {
  70. file->private_data = inode->i_private;
  71. return 0;
  72. }
  73. /* debugfs: registers */
  74. struct reg {
  75. const char *name;
  76. int addr;
  77. };
  78. #define REG_STRUCT_INIT(r) { #r, r }
  79. /* just a few random registers, might want to add more */
  80. static const struct reg regs[] = {
  81. REG_STRUCT_INIT(AR5K_CR),
  82. REG_STRUCT_INIT(AR5K_RXDP),
  83. REG_STRUCT_INIT(AR5K_CFG),
  84. REG_STRUCT_INIT(AR5K_IER),
  85. REG_STRUCT_INIT(AR5K_BCR),
  86. REG_STRUCT_INIT(AR5K_RTSD0),
  87. REG_STRUCT_INIT(AR5K_RTSD1),
  88. REG_STRUCT_INIT(AR5K_TXCFG),
  89. REG_STRUCT_INIT(AR5K_RXCFG),
  90. REG_STRUCT_INIT(AR5K_RXJLA),
  91. REG_STRUCT_INIT(AR5K_MIBC),
  92. REG_STRUCT_INIT(AR5K_TOPS),
  93. REG_STRUCT_INIT(AR5K_RXNOFRM),
  94. REG_STRUCT_INIT(AR5K_TXNOFRM),
  95. REG_STRUCT_INIT(AR5K_RPGTO),
  96. REG_STRUCT_INIT(AR5K_RFCNT),
  97. REG_STRUCT_INIT(AR5K_MISC),
  98. REG_STRUCT_INIT(AR5K_QCUDCU_CLKGT),
  99. REG_STRUCT_INIT(AR5K_ISR),
  100. REG_STRUCT_INIT(AR5K_PISR),
  101. REG_STRUCT_INIT(AR5K_SISR0),
  102. REG_STRUCT_INIT(AR5K_SISR1),
  103. REG_STRUCT_INIT(AR5K_SISR2),
  104. REG_STRUCT_INIT(AR5K_SISR3),
  105. REG_STRUCT_INIT(AR5K_SISR4),
  106. REG_STRUCT_INIT(AR5K_IMR),
  107. REG_STRUCT_INIT(AR5K_PIMR),
  108. REG_STRUCT_INIT(AR5K_SIMR0),
  109. REG_STRUCT_INIT(AR5K_SIMR1),
  110. REG_STRUCT_INIT(AR5K_SIMR2),
  111. REG_STRUCT_INIT(AR5K_SIMR3),
  112. REG_STRUCT_INIT(AR5K_SIMR4),
  113. REG_STRUCT_INIT(AR5K_DCM_ADDR),
  114. REG_STRUCT_INIT(AR5K_DCCFG),
  115. REG_STRUCT_INIT(AR5K_CCFG),
  116. REG_STRUCT_INIT(AR5K_CPC0),
  117. REG_STRUCT_INIT(AR5K_CPC1),
  118. REG_STRUCT_INIT(AR5K_CPC2),
  119. REG_STRUCT_INIT(AR5K_CPC3),
  120. REG_STRUCT_INIT(AR5K_CPCOVF),
  121. REG_STRUCT_INIT(AR5K_RESET_CTL),
  122. REG_STRUCT_INIT(AR5K_SLEEP_CTL),
  123. REG_STRUCT_INIT(AR5K_INTPEND),
  124. REG_STRUCT_INIT(AR5K_SFR),
  125. REG_STRUCT_INIT(AR5K_PCICFG),
  126. REG_STRUCT_INIT(AR5K_GPIOCR),
  127. REG_STRUCT_INIT(AR5K_GPIODO),
  128. REG_STRUCT_INIT(AR5K_SREV),
  129. };
  130. static void *reg_start(struct seq_file *seq, loff_t *pos)
  131. {
  132. return *pos < ARRAY_SIZE(regs) ? (void *)&regs[*pos] : NULL;
  133. }
  134. static void reg_stop(struct seq_file *seq, void *p)
  135. {
  136. /* nothing to do */
  137. }
  138. static void *reg_next(struct seq_file *seq, void *p, loff_t *pos)
  139. {
  140. ++*pos;
  141. return *pos < ARRAY_SIZE(regs) ? (void *)&regs[*pos] : NULL;
  142. }
  143. static int reg_show(struct seq_file *seq, void *p)
  144. {
  145. struct ath5k_softc *sc = seq->private;
  146. struct reg *r = p;
  147. seq_printf(seq, "%-25s0x%08x\n", r->name,
  148. ath5k_hw_reg_read(sc->ah, r->addr));
  149. return 0;
  150. }
  151. static const struct seq_operations register_seq_ops = {
  152. .start = reg_start,
  153. .next = reg_next,
  154. .stop = reg_stop,
  155. .show = reg_show
  156. };
  157. static int open_file_registers(struct inode *inode, struct file *file)
  158. {
  159. struct seq_file *s;
  160. int res;
  161. res = seq_open(file, &register_seq_ops);
  162. if (res == 0) {
  163. s = file->private_data;
  164. s->private = inode->i_private;
  165. }
  166. return res;
  167. }
  168. static const struct file_operations fops_registers = {
  169. .open = open_file_registers,
  170. .read = seq_read,
  171. .llseek = seq_lseek,
  172. .release = seq_release,
  173. .owner = THIS_MODULE,
  174. };
  175. /* debugfs: beacons */
  176. static ssize_t read_file_beacon(struct file *file, char __user *user_buf,
  177. size_t count, loff_t *ppos)
  178. {
  179. struct ath5k_softc *sc = file->private_data;
  180. struct ath5k_hw *ah = sc->ah;
  181. char buf[500];
  182. unsigned int len = 0;
  183. unsigned int v;
  184. u64 tsf;
  185. v = ath5k_hw_reg_read(sc->ah, AR5K_BEACON);
  186. len += snprintf(buf+len, sizeof(buf)-len,
  187. "%-24s0x%08x\tintval: %d\tTIM: 0x%x\n",
  188. "AR5K_BEACON", v, v & AR5K_BEACON_PERIOD,
  189. (v & AR5K_BEACON_TIM) >> AR5K_BEACON_TIM_S);
  190. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n",
  191. "AR5K_LAST_TSTP", ath5k_hw_reg_read(sc->ah, AR5K_LAST_TSTP));
  192. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n\n",
  193. "AR5K_BEACON_CNT", ath5k_hw_reg_read(sc->ah, AR5K_BEACON_CNT));
  194. v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER0);
  195. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
  196. "AR5K_TIMER0 (TBTT)", v, v);
  197. v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER1);
  198. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
  199. "AR5K_TIMER1 (DMA)", v, v >> 3);
  200. v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER2);
  201. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
  202. "AR5K_TIMER2 (SWBA)", v, v >> 3);
  203. v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER3);
  204. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
  205. "AR5K_TIMER3 (ATIM)", v, v);
  206. tsf = ath5k_hw_get_tsf64(sc->ah);
  207. len += snprintf(buf+len, sizeof(buf)-len,
  208. "TSF\t\t0x%016llx\tTU: %08x\n",
  209. (unsigned long long)tsf, TSF_TO_TU(tsf));
  210. if (len > sizeof(buf))
  211. len = sizeof(buf);
  212. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  213. }
  214. static ssize_t write_file_beacon(struct file *file,
  215. const char __user *userbuf,
  216. size_t count, loff_t *ppos)
  217. {
  218. struct ath5k_softc *sc = file->private_data;
  219. struct ath5k_hw *ah = sc->ah;
  220. char buf[20];
  221. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  222. return -EFAULT;
  223. if (strncmp(buf, "disable", 7) == 0) {
  224. AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
  225. printk(KERN_INFO "debugfs disable beacons\n");
  226. } else if (strncmp(buf, "enable", 6) == 0) {
  227. AR5K_REG_ENABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
  228. printk(KERN_INFO "debugfs enable beacons\n");
  229. }
  230. return count;
  231. }
  232. static const struct file_operations fops_beacon = {
  233. .read = read_file_beacon,
  234. .write = write_file_beacon,
  235. .open = ath5k_debugfs_open,
  236. .owner = THIS_MODULE,
  237. .llseek = default_llseek,
  238. };
  239. /* debugfs: reset */
  240. static ssize_t write_file_reset(struct file *file,
  241. const char __user *userbuf,
  242. size_t count, loff_t *ppos)
  243. {
  244. struct ath5k_softc *sc = file->private_data;
  245. ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "debug file triggered reset\n");
  246. ieee80211_queue_work(sc->hw, &sc->reset_work);
  247. return count;
  248. }
  249. static const struct file_operations fops_reset = {
  250. .write = write_file_reset,
  251. .open = ath5k_debugfs_open,
  252. .owner = THIS_MODULE,
  253. .llseek = noop_llseek,
  254. };
  255. /* debugfs: debug level */
  256. static const struct {
  257. enum ath5k_debug_level level;
  258. const char *name;
  259. const char *desc;
  260. } dbg_info[] = {
  261. { ATH5K_DEBUG_RESET, "reset", "reset and initialization" },
  262. { ATH5K_DEBUG_INTR, "intr", "interrupt handling" },
  263. { ATH5K_DEBUG_MODE, "mode", "mode init/setup" },
  264. { ATH5K_DEBUG_XMIT, "xmit", "basic xmit operation" },
  265. { ATH5K_DEBUG_BEACON, "beacon", "beacon handling" },
  266. { ATH5K_DEBUG_CALIBRATE, "calib", "periodic calibration" },
  267. { ATH5K_DEBUG_TXPOWER, "txpower", "transmit power setting" },
  268. { ATH5K_DEBUG_LED, "led", "LED management" },
  269. { ATH5K_DEBUG_DUMPBANDS, "dumpbands", "dump bands" },
  270. { ATH5K_DEBUG_DMA, "dma", "dma start/stop" },
  271. { ATH5K_DEBUG_ANI, "ani", "adaptive noise immunity" },
  272. { ATH5K_DEBUG_DESC, "desc", "descriptor chains" },
  273. { ATH5K_DEBUG_ANY, "all", "show all debug levels" },
  274. };
  275. static ssize_t read_file_debug(struct file *file, char __user *user_buf,
  276. size_t count, loff_t *ppos)
  277. {
  278. struct ath5k_softc *sc = file->private_data;
  279. char buf[700];
  280. unsigned int len = 0;
  281. unsigned int i;
  282. len += snprintf(buf+len, sizeof(buf)-len,
  283. "DEBUG LEVEL: 0x%08x\n\n", sc->debug.level);
  284. for (i = 0; i < ARRAY_SIZE(dbg_info) - 1; i++) {
  285. len += snprintf(buf+len, sizeof(buf)-len,
  286. "%10s %c 0x%08x - %s\n", dbg_info[i].name,
  287. sc->debug.level & dbg_info[i].level ? '+' : ' ',
  288. dbg_info[i].level, dbg_info[i].desc);
  289. }
  290. len += snprintf(buf+len, sizeof(buf)-len,
  291. "%10s %c 0x%08x - %s\n", dbg_info[i].name,
  292. sc->debug.level == dbg_info[i].level ? '+' : ' ',
  293. dbg_info[i].level, dbg_info[i].desc);
  294. if (len > sizeof(buf))
  295. len = sizeof(buf);
  296. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  297. }
  298. static ssize_t write_file_debug(struct file *file,
  299. const char __user *userbuf,
  300. size_t count, loff_t *ppos)
  301. {
  302. struct ath5k_softc *sc = file->private_data;
  303. unsigned int i;
  304. char buf[20];
  305. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  306. return -EFAULT;
  307. for (i = 0; i < ARRAY_SIZE(dbg_info); i++) {
  308. if (strncmp(buf, dbg_info[i].name,
  309. strlen(dbg_info[i].name)) == 0) {
  310. sc->debug.level ^= dbg_info[i].level; /* toggle bit */
  311. break;
  312. }
  313. }
  314. return count;
  315. }
  316. static const struct file_operations fops_debug = {
  317. .read = read_file_debug,
  318. .write = write_file_debug,
  319. .open = ath5k_debugfs_open,
  320. .owner = THIS_MODULE,
  321. .llseek = default_llseek,
  322. };
  323. /* debugfs: antenna */
  324. static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
  325. size_t count, loff_t *ppos)
  326. {
  327. struct ath5k_softc *sc = file->private_data;
  328. char buf[700];
  329. unsigned int len = 0;
  330. unsigned int i;
  331. unsigned int v;
  332. len += snprintf(buf+len, sizeof(buf)-len, "antenna mode\t%d\n",
  333. sc->ah->ah_ant_mode);
  334. len += snprintf(buf+len, sizeof(buf)-len, "default antenna\t%d\n",
  335. sc->ah->ah_def_ant);
  336. len += snprintf(buf+len, sizeof(buf)-len, "tx antenna\t%d\n",
  337. sc->ah->ah_tx_ant);
  338. len += snprintf(buf+len, sizeof(buf)-len, "\nANTENNA\t\tRX\tTX\n");
  339. for (i = 1; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) {
  340. len += snprintf(buf+len, sizeof(buf)-len,
  341. "[antenna %d]\t%d\t%d\n",
  342. i, sc->stats.antenna_rx[i], sc->stats.antenna_tx[i]);
  343. }
  344. len += snprintf(buf+len, sizeof(buf)-len, "[invalid]\t%d\t%d\n",
  345. sc->stats.antenna_rx[0], sc->stats.antenna_tx[0]);
  346. v = ath5k_hw_reg_read(sc->ah, AR5K_DEFAULT_ANTENNA);
  347. len += snprintf(buf+len, sizeof(buf)-len,
  348. "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v);
  349. v = ath5k_hw_reg_read(sc->ah, AR5K_STA_ID1);
  350. len += snprintf(buf+len, sizeof(buf)-len,
  351. "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n",
  352. (v & AR5K_STA_ID1_DEFAULT_ANTENNA) != 0);
  353. len += snprintf(buf+len, sizeof(buf)-len,
  354. "AR5K_STA_ID1_DESC_ANTENNA\t%d\n",
  355. (v & AR5K_STA_ID1_DESC_ANTENNA) != 0);
  356. len += snprintf(buf+len, sizeof(buf)-len,
  357. "AR5K_STA_ID1_RTS_DEF_ANTENNA\t%d\n",
  358. (v & AR5K_STA_ID1_RTS_DEF_ANTENNA) != 0);
  359. len += snprintf(buf+len, sizeof(buf)-len,
  360. "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n",
  361. (v & AR5K_STA_ID1_SELFGEN_DEF_ANT) != 0);
  362. v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_AGCCTL);
  363. len += snprintf(buf+len, sizeof(buf)-len,
  364. "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n",
  365. (v & AR5K_PHY_AGCCTL_OFDM_DIV_DIS) != 0);
  366. v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_RESTART);
  367. len += snprintf(buf+len, sizeof(buf)-len,
  368. "AR5K_PHY_RESTART_DIV_GC\t\t%x\n",
  369. (v & AR5K_PHY_RESTART_DIV_GC) >> AR5K_PHY_RESTART_DIV_GC_S);
  370. v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_FAST_ANT_DIV);
  371. len += snprintf(buf+len, sizeof(buf)-len,
  372. "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n",
  373. (v & AR5K_PHY_FAST_ANT_DIV_EN) != 0);
  374. v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_ANT_SWITCH_TABLE_0);
  375. len += snprintf(buf+len, sizeof(buf)-len,
  376. "\nAR5K_PHY_ANT_SWITCH_TABLE_0\t0x%08x\n", v);
  377. v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_ANT_SWITCH_TABLE_1);
  378. len += snprintf(buf+len, sizeof(buf)-len,
  379. "AR5K_PHY_ANT_SWITCH_TABLE_1\t0x%08x\n", v);
  380. if (len > sizeof(buf))
  381. len = sizeof(buf);
  382. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  383. }
  384. static ssize_t write_file_antenna(struct file *file,
  385. const char __user *userbuf,
  386. size_t count, loff_t *ppos)
  387. {
  388. struct ath5k_softc *sc = file->private_data;
  389. unsigned int i;
  390. char buf[20];
  391. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  392. return -EFAULT;
  393. if (strncmp(buf, "diversity", 9) == 0) {
  394. ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_DEFAULT);
  395. printk(KERN_INFO "ath5k debug: enable diversity\n");
  396. } else if (strncmp(buf, "fixed-a", 7) == 0) {
  397. ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_A);
  398. printk(KERN_INFO "ath5k debugfs: fixed antenna A\n");
  399. } else if (strncmp(buf, "fixed-b", 7) == 0) {
  400. ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_B);
  401. printk(KERN_INFO "ath5k debug: fixed antenna B\n");
  402. } else if (strncmp(buf, "clear", 5) == 0) {
  403. for (i = 0; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) {
  404. sc->stats.antenna_rx[i] = 0;
  405. sc->stats.antenna_tx[i] = 0;
  406. }
  407. printk(KERN_INFO "ath5k debug: cleared antenna stats\n");
  408. }
  409. return count;
  410. }
  411. static const struct file_operations fops_antenna = {
  412. .read = read_file_antenna,
  413. .write = write_file_antenna,
  414. .open = ath5k_debugfs_open,
  415. .owner = THIS_MODULE,
  416. .llseek = default_llseek,
  417. };
  418. /* debugfs: misc */
  419. static ssize_t read_file_misc(struct file *file, char __user *user_buf,
  420. size_t count, loff_t *ppos)
  421. {
  422. struct ath5k_softc *sc = file->private_data;
  423. char buf[700];
  424. unsigned int len = 0;
  425. u32 filt = ath5k_hw_get_rx_filter(sc->ah);
  426. len += snprintf(buf+len, sizeof(buf)-len, "bssid-mask: %pM\n",
  427. sc->bssidmask);
  428. len += snprintf(buf+len, sizeof(buf)-len, "filter-flags: 0x%x ",
  429. filt);
  430. if (filt & AR5K_RX_FILTER_UCAST)
  431. len += snprintf(buf+len, sizeof(buf)-len, " UCAST");
  432. if (filt & AR5K_RX_FILTER_MCAST)
  433. len += snprintf(buf+len, sizeof(buf)-len, " MCAST");
  434. if (filt & AR5K_RX_FILTER_BCAST)
  435. len += snprintf(buf+len, sizeof(buf)-len, " BCAST");
  436. if (filt & AR5K_RX_FILTER_CONTROL)
  437. len += snprintf(buf+len, sizeof(buf)-len, " CONTROL");
  438. if (filt & AR5K_RX_FILTER_BEACON)
  439. len += snprintf(buf+len, sizeof(buf)-len, " BEACON");
  440. if (filt & AR5K_RX_FILTER_PROM)
  441. len += snprintf(buf+len, sizeof(buf)-len, " PROM");
  442. if (filt & AR5K_RX_FILTER_XRPOLL)
  443. len += snprintf(buf+len, sizeof(buf)-len, " XRPOLL");
  444. if (filt & AR5K_RX_FILTER_PROBEREQ)
  445. len += snprintf(buf+len, sizeof(buf)-len, " PROBEREQ");
  446. if (filt & AR5K_RX_FILTER_PHYERR_5212)
  447. len += snprintf(buf+len, sizeof(buf)-len, " PHYERR-5212");
  448. if (filt & AR5K_RX_FILTER_RADARERR_5212)
  449. len += snprintf(buf+len, sizeof(buf)-len, " RADARERR-5212");
  450. if (filt & AR5K_RX_FILTER_PHYERR_5211)
  451. snprintf(buf+len, sizeof(buf)-len, " PHYERR-5211");
  452. if (filt & AR5K_RX_FILTER_RADARERR_5211)
  453. len += snprintf(buf+len, sizeof(buf)-len, " RADARERR-5211");
  454. len += snprintf(buf+len, sizeof(buf)-len, "\nopmode: %s (%d)\n",
  455. ath_opmode_to_string(sc->opmode), sc->opmode);
  456. if (len > sizeof(buf))
  457. len = sizeof(buf);
  458. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  459. }
  460. static const struct file_operations fops_misc = {
  461. .read = read_file_misc,
  462. .open = ath5k_debugfs_open,
  463. .owner = THIS_MODULE,
  464. };
  465. /* debugfs: frameerrors */
  466. static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf,
  467. size_t count, loff_t *ppos)
  468. {
  469. struct ath5k_softc *sc = file->private_data;
  470. struct ath5k_statistics *st = &sc->stats;
  471. char buf[700];
  472. unsigned int len = 0;
  473. int i;
  474. len += snprintf(buf+len, sizeof(buf)-len,
  475. "RX\n---------------------\n");
  476. len += snprintf(buf+len, sizeof(buf)-len, "CRC\t%u\t(%u%%)\n",
  477. st->rxerr_crc,
  478. st->rx_all_count > 0 ?
  479. st->rxerr_crc*100/st->rx_all_count : 0);
  480. len += snprintf(buf+len, sizeof(buf)-len, "PHY\t%u\t(%u%%)\n",
  481. st->rxerr_phy,
  482. st->rx_all_count > 0 ?
  483. st->rxerr_phy*100/st->rx_all_count : 0);
  484. for (i = 0; i < 32; i++) {
  485. if (st->rxerr_phy_code[i])
  486. len += snprintf(buf+len, sizeof(buf)-len,
  487. " phy_err[%u]\t%u\n",
  488. i, st->rxerr_phy_code[i]);
  489. }
  490. len += snprintf(buf+len, sizeof(buf)-len, "FIFO\t%u\t(%u%%)\n",
  491. st->rxerr_fifo,
  492. st->rx_all_count > 0 ?
  493. st->rxerr_fifo*100/st->rx_all_count : 0);
  494. len += snprintf(buf+len, sizeof(buf)-len, "decrypt\t%u\t(%u%%)\n",
  495. st->rxerr_decrypt,
  496. st->rx_all_count > 0 ?
  497. st->rxerr_decrypt*100/st->rx_all_count : 0);
  498. len += snprintf(buf+len, sizeof(buf)-len, "MIC\t%u\t(%u%%)\n",
  499. st->rxerr_mic,
  500. st->rx_all_count > 0 ?
  501. st->rxerr_mic*100/st->rx_all_count : 0);
  502. len += snprintf(buf+len, sizeof(buf)-len, "process\t%u\t(%u%%)\n",
  503. st->rxerr_proc,
  504. st->rx_all_count > 0 ?
  505. st->rxerr_proc*100/st->rx_all_count : 0);
  506. len += snprintf(buf+len, sizeof(buf)-len, "jumbo\t%u\t(%u%%)\n",
  507. st->rxerr_jumbo,
  508. st->rx_all_count > 0 ?
  509. st->rxerr_jumbo*100/st->rx_all_count : 0);
  510. len += snprintf(buf+len, sizeof(buf)-len, "[RX all\t%u]\n",
  511. st->rx_all_count);
  512. len += snprintf(buf+len, sizeof(buf)-len, "RX-all-bytes\t%u\n",
  513. st->rx_bytes_count);
  514. len += snprintf(buf+len, sizeof(buf)-len,
  515. "\nTX\n---------------------\n");
  516. len += snprintf(buf+len, sizeof(buf)-len, "retry\t%u\t(%u%%)\n",
  517. st->txerr_retry,
  518. st->tx_all_count > 0 ?
  519. st->txerr_retry*100/st->tx_all_count : 0);
  520. len += snprintf(buf+len, sizeof(buf)-len, "FIFO\t%u\t(%u%%)\n",
  521. st->txerr_fifo,
  522. st->tx_all_count > 0 ?
  523. st->txerr_fifo*100/st->tx_all_count : 0);
  524. len += snprintf(buf+len, sizeof(buf)-len, "filter\t%u\t(%u%%)\n",
  525. st->txerr_filt,
  526. st->tx_all_count > 0 ?
  527. st->txerr_filt*100/st->tx_all_count : 0);
  528. len += snprintf(buf+len, sizeof(buf)-len, "[TX all\t%u]\n",
  529. st->tx_all_count);
  530. len += snprintf(buf+len, sizeof(buf)-len, "TX-all-bytes\t%u\n",
  531. st->tx_bytes_count);
  532. if (len > sizeof(buf))
  533. len = sizeof(buf);
  534. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  535. }
  536. static ssize_t write_file_frameerrors(struct file *file,
  537. const char __user *userbuf,
  538. size_t count, loff_t *ppos)
  539. {
  540. struct ath5k_softc *sc = file->private_data;
  541. struct ath5k_statistics *st = &sc->stats;
  542. char buf[20];
  543. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  544. return -EFAULT;
  545. if (strncmp(buf, "clear", 5) == 0) {
  546. st->rxerr_crc = 0;
  547. st->rxerr_phy = 0;
  548. st->rxerr_fifo = 0;
  549. st->rxerr_decrypt = 0;
  550. st->rxerr_mic = 0;
  551. st->rxerr_proc = 0;
  552. st->rxerr_jumbo = 0;
  553. st->rx_all_count = 0;
  554. st->txerr_retry = 0;
  555. st->txerr_fifo = 0;
  556. st->txerr_filt = 0;
  557. st->tx_all_count = 0;
  558. printk(KERN_INFO "ath5k debug: cleared frameerrors stats\n");
  559. }
  560. return count;
  561. }
  562. static const struct file_operations fops_frameerrors = {
  563. .read = read_file_frameerrors,
  564. .write = write_file_frameerrors,
  565. .open = ath5k_debugfs_open,
  566. .owner = THIS_MODULE,
  567. .llseek = default_llseek,
  568. };
  569. /* debugfs: ani */
  570. static ssize_t read_file_ani(struct file *file, char __user *user_buf,
  571. size_t count, loff_t *ppos)
  572. {
  573. struct ath5k_softc *sc = file->private_data;
  574. struct ath5k_statistics *st = &sc->stats;
  575. struct ath5k_ani_state *as = &sc->ani_state;
  576. char buf[700];
  577. unsigned int len = 0;
  578. len += snprintf(buf+len, sizeof(buf)-len,
  579. "HW has PHY error counters:\t%s\n",
  580. sc->ah->ah_capabilities.cap_has_phyerr_counters ?
  581. "yes" : "no");
  582. len += snprintf(buf+len, sizeof(buf)-len,
  583. "HW max spur immunity level:\t%d\n",
  584. as->max_spur_level);
  585. len += snprintf(buf+len, sizeof(buf)-len,
  586. "\nANI state\n--------------------------------------------\n");
  587. len += snprintf(buf+len, sizeof(buf)-len, "operating mode:\t\t\t");
  588. switch (as->ani_mode) {
  589. case ATH5K_ANI_MODE_OFF:
  590. len += snprintf(buf+len, sizeof(buf)-len, "OFF\n");
  591. break;
  592. case ATH5K_ANI_MODE_MANUAL_LOW:
  593. len += snprintf(buf+len, sizeof(buf)-len,
  594. "MANUAL LOW\n");
  595. break;
  596. case ATH5K_ANI_MODE_MANUAL_HIGH:
  597. len += snprintf(buf+len, sizeof(buf)-len,
  598. "MANUAL HIGH\n");
  599. break;
  600. case ATH5K_ANI_MODE_AUTO:
  601. len += snprintf(buf+len, sizeof(buf)-len, "AUTO\n");
  602. break;
  603. default:
  604. len += snprintf(buf+len, sizeof(buf)-len,
  605. "??? (not good)\n");
  606. break;
  607. }
  608. len += snprintf(buf+len, sizeof(buf)-len,
  609. "noise immunity level:\t\t%d\n",
  610. as->noise_imm_level);
  611. len += snprintf(buf+len, sizeof(buf)-len,
  612. "spur immunity level:\t\t%d\n",
  613. as->spur_level);
  614. len += snprintf(buf+len, sizeof(buf)-len, "firstep level:\t\t\t%d\n",
  615. as->firstep_level);
  616. len += snprintf(buf+len, sizeof(buf)-len,
  617. "OFDM weak signal detection:\t%s\n",
  618. as->ofdm_weak_sig ? "on" : "off");
  619. len += snprintf(buf+len, sizeof(buf)-len,
  620. "CCK weak signal detection:\t%s\n",
  621. as->cck_weak_sig ? "on" : "off");
  622. len += snprintf(buf+len, sizeof(buf)-len,
  623. "\nMIB INTERRUPTS:\t\t%u\n",
  624. st->mib_intr);
  625. len += snprintf(buf+len, sizeof(buf)-len,
  626. "beacon RSSI average:\t%d\n",
  627. (int)ewma_read(&sc->ah->ah_beacon_rssi_avg));
  628. #define CC_PRINT(_struct, _field) \
  629. _struct._field, \
  630. _struct.cycles > 0 ? \
  631. _struct._field*100/_struct.cycles : 0
  632. len += snprintf(buf+len, sizeof(buf)-len, "profcnt tx\t\t%u\t(%d%%)\n",
  633. CC_PRINT(as->last_cc, tx_frame));
  634. len += snprintf(buf+len, sizeof(buf)-len, "profcnt rx\t\t%u\t(%d%%)\n",
  635. CC_PRINT(as->last_cc, rx_frame));
  636. len += snprintf(buf+len, sizeof(buf)-len, "profcnt busy\t\t%u\t(%d%%)\n",
  637. CC_PRINT(as->last_cc, rx_busy));
  638. #undef CC_PRINT
  639. len += snprintf(buf+len, sizeof(buf)-len, "profcnt cycles\t\t%u\n",
  640. as->last_cc.cycles);
  641. len += snprintf(buf+len, sizeof(buf)-len,
  642. "listen time\t\t%d\tlast: %d\n",
  643. as->listen_time, as->last_listen);
  644. len += snprintf(buf+len, sizeof(buf)-len,
  645. "OFDM errors\t\t%u\tlast: %u\tsum: %u\n",
  646. as->ofdm_errors, as->last_ofdm_errors,
  647. as->sum_ofdm_errors);
  648. len += snprintf(buf+len, sizeof(buf)-len,
  649. "CCK errors\t\t%u\tlast: %u\tsum: %u\n",
  650. as->cck_errors, as->last_cck_errors,
  651. as->sum_cck_errors);
  652. len += snprintf(buf+len, sizeof(buf)-len,
  653. "AR5K_PHYERR_CNT1\t%x\t(=%d)\n",
  654. ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1),
  655. ATH5K_ANI_OFDM_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
  656. ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1)));
  657. len += snprintf(buf+len, sizeof(buf)-len,
  658. "AR5K_PHYERR_CNT2\t%x\t(=%d)\n",
  659. ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2),
  660. ATH5K_ANI_CCK_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
  661. ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2)));
  662. if (len > sizeof(buf))
  663. len = sizeof(buf);
  664. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  665. }
  666. static ssize_t write_file_ani(struct file *file,
  667. const char __user *userbuf,
  668. size_t count, loff_t *ppos)
  669. {
  670. struct ath5k_softc *sc = file->private_data;
  671. char buf[20];
  672. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  673. return -EFAULT;
  674. if (strncmp(buf, "sens-low", 8) == 0) {
  675. ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_MANUAL_HIGH);
  676. } else if (strncmp(buf, "sens-high", 9) == 0) {
  677. ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_MANUAL_LOW);
  678. } else if (strncmp(buf, "ani-off", 7) == 0) {
  679. ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_OFF);
  680. } else if (strncmp(buf, "ani-on", 6) == 0) {
  681. ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_AUTO);
  682. } else if (strncmp(buf, "noise-low", 9) == 0) {
  683. ath5k_ani_set_noise_immunity_level(sc->ah, 0);
  684. } else if (strncmp(buf, "noise-high", 10) == 0) {
  685. ath5k_ani_set_noise_immunity_level(sc->ah,
  686. ATH5K_ANI_MAX_NOISE_IMM_LVL);
  687. } else if (strncmp(buf, "spur-low", 8) == 0) {
  688. ath5k_ani_set_spur_immunity_level(sc->ah, 0);
  689. } else if (strncmp(buf, "spur-high", 9) == 0) {
  690. ath5k_ani_set_spur_immunity_level(sc->ah,
  691. sc->ani_state.max_spur_level);
  692. } else if (strncmp(buf, "fir-low", 7) == 0) {
  693. ath5k_ani_set_firstep_level(sc->ah, 0);
  694. } else if (strncmp(buf, "fir-high", 8) == 0) {
  695. ath5k_ani_set_firstep_level(sc->ah, ATH5K_ANI_MAX_FIRSTEP_LVL);
  696. } else if (strncmp(buf, "ofdm-off", 8) == 0) {
  697. ath5k_ani_set_ofdm_weak_signal_detection(sc->ah, false);
  698. } else if (strncmp(buf, "ofdm-on", 7) == 0) {
  699. ath5k_ani_set_ofdm_weak_signal_detection(sc->ah, true);
  700. } else if (strncmp(buf, "cck-off", 7) == 0) {
  701. ath5k_ani_set_cck_weak_signal_detection(sc->ah, false);
  702. } else if (strncmp(buf, "cck-on", 6) == 0) {
  703. ath5k_ani_set_cck_weak_signal_detection(sc->ah, true);
  704. }
  705. return count;
  706. }
  707. static const struct file_operations fops_ani = {
  708. .read = read_file_ani,
  709. .write = write_file_ani,
  710. .open = ath5k_debugfs_open,
  711. .owner = THIS_MODULE,
  712. .llseek = default_llseek,
  713. };
  714. /* debugfs: queues etc */
  715. static ssize_t read_file_queue(struct file *file, char __user *user_buf,
  716. size_t count, loff_t *ppos)
  717. {
  718. struct ath5k_softc *sc = file->private_data;
  719. char buf[700];
  720. unsigned int len = 0;
  721. struct ath5k_txq *txq;
  722. struct ath5k_buf *bf, *bf0;
  723. int i, n;
  724. len += snprintf(buf+len, sizeof(buf)-len,
  725. "available txbuffers: %d\n", sc->txbuf_len);
  726. for (i = 0; i < ARRAY_SIZE(sc->txqs); i++) {
  727. txq = &sc->txqs[i];
  728. len += snprintf(buf+len, sizeof(buf)-len,
  729. "%02d: %ssetup\n", i, txq->setup ? "" : "not ");
  730. if (!txq->setup)
  731. continue;
  732. n = 0;
  733. spin_lock_bh(&txq->lock);
  734. list_for_each_entry_safe(bf, bf0, &txq->q, list)
  735. n++;
  736. spin_unlock_bh(&txq->lock);
  737. len += snprintf(buf+len, sizeof(buf)-len,
  738. " len: %d bufs: %d\n", txq->txq_len, n);
  739. len += snprintf(buf+len, sizeof(buf)-len,
  740. " stuck: %d\n", txq->txq_stuck);
  741. }
  742. if (len > sizeof(buf))
  743. len = sizeof(buf);
  744. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  745. }
  746. static ssize_t write_file_queue(struct file *file,
  747. const char __user *userbuf,
  748. size_t count, loff_t *ppos)
  749. {
  750. struct ath5k_softc *sc = file->private_data;
  751. char buf[20];
  752. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  753. return -EFAULT;
  754. if (strncmp(buf, "start", 5) == 0)
  755. ieee80211_wake_queues(sc->hw);
  756. else if (strncmp(buf, "stop", 4) == 0)
  757. ieee80211_stop_queues(sc->hw);
  758. return count;
  759. }
  760. static const struct file_operations fops_queue = {
  761. .read = read_file_queue,
  762. .write = write_file_queue,
  763. .open = ath5k_debugfs_open,
  764. .owner = THIS_MODULE,
  765. .llseek = default_llseek,
  766. };
  767. void
  768. ath5k_debug_init_device(struct ath5k_softc *sc)
  769. {
  770. struct dentry *phydir;
  771. sc->debug.level = ath5k_debug;
  772. phydir = debugfs_create_dir("ath5k", sc->hw->wiphy->debugfsdir);
  773. if (!phydir)
  774. return;
  775. debugfs_create_file("debug", S_IWUSR | S_IRUSR, phydir, sc,
  776. &fops_debug);
  777. debugfs_create_file("registers", S_IRUSR, phydir, sc, &fops_registers);
  778. debugfs_create_file("beacon", S_IWUSR | S_IRUSR, phydir, sc,
  779. &fops_beacon);
  780. debugfs_create_file("reset", S_IWUSR, phydir, sc, &fops_reset);
  781. debugfs_create_file("antenna", S_IWUSR | S_IRUSR, phydir, sc,
  782. &fops_antenna);
  783. debugfs_create_file("misc", S_IRUSR, phydir, sc, &fops_misc);
  784. debugfs_create_file("frameerrors", S_IWUSR | S_IRUSR, phydir, sc,
  785. &fops_frameerrors);
  786. debugfs_create_file("ani", S_IWUSR | S_IRUSR, phydir, sc, &fops_ani);
  787. debugfs_create_file("queue", S_IWUSR | S_IRUSR, phydir, sc,
  788. &fops_queue);
  789. }
  790. /* functions used in other places */
  791. void
  792. ath5k_debug_dump_bands(struct ath5k_softc *sc)
  793. {
  794. unsigned int b, i;
  795. if (likely(!(sc->debug.level & ATH5K_DEBUG_DUMPBANDS)))
  796. return;
  797. BUG_ON(!sc->sbands);
  798. for (b = 0; b < IEEE80211_NUM_BANDS; b++) {
  799. struct ieee80211_supported_band *band = &sc->sbands[b];
  800. char bname[6];
  801. switch (band->band) {
  802. case IEEE80211_BAND_2GHZ:
  803. strcpy(bname, "2 GHz");
  804. break;
  805. case IEEE80211_BAND_5GHZ:
  806. strcpy(bname, "5 GHz");
  807. break;
  808. default:
  809. printk(KERN_DEBUG "Band not supported: %d\n",
  810. band->band);
  811. return;
  812. }
  813. printk(KERN_DEBUG "Band %s: channels %d, rates %d\n", bname,
  814. band->n_channels, band->n_bitrates);
  815. printk(KERN_DEBUG " channels:\n");
  816. for (i = 0; i < band->n_channels; i++)
  817. printk(KERN_DEBUG " %3d %d %.4x %.4x\n",
  818. ieee80211_frequency_to_channel(
  819. band->channels[i].center_freq),
  820. band->channels[i].center_freq,
  821. band->channels[i].hw_value,
  822. band->channels[i].flags);
  823. printk(KERN_DEBUG " rates:\n");
  824. for (i = 0; i < band->n_bitrates; i++)
  825. printk(KERN_DEBUG " %4d %.4x %.4x %.4x\n",
  826. band->bitrates[i].bitrate,
  827. band->bitrates[i].hw_value,
  828. band->bitrates[i].flags,
  829. band->bitrates[i].hw_value_short);
  830. }
  831. }
  832. static inline void
  833. ath5k_debug_printrxbuf(struct ath5k_buf *bf, int done,
  834. struct ath5k_rx_status *rs)
  835. {
  836. struct ath5k_desc *ds = bf->desc;
  837. struct ath5k_hw_all_rx_desc *rd = &ds->ud.ds_rx;
  838. printk(KERN_DEBUG "R (%p %llx) %08x %08x %08x %08x %08x %08x %c\n",
  839. ds, (unsigned long long)bf->daddr,
  840. ds->ds_link, ds->ds_data,
  841. rd->rx_ctl.rx_control_0, rd->rx_ctl.rx_control_1,
  842. rd->rx_stat.rx_status_0, rd->rx_stat.rx_status_1,
  843. !done ? ' ' : (rs->rs_status == 0) ? '*' : '!');
  844. }
  845. void
  846. ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah)
  847. {
  848. struct ath5k_desc *ds;
  849. struct ath5k_buf *bf;
  850. struct ath5k_rx_status rs = {};
  851. int status;
  852. if (likely(!(sc->debug.level & ATH5K_DEBUG_DESC)))
  853. return;
  854. printk(KERN_DEBUG "rxdp %x, rxlink %p\n",
  855. ath5k_hw_get_rxdp(ah), sc->rxlink);
  856. spin_lock_bh(&sc->rxbuflock);
  857. list_for_each_entry(bf, &sc->rxbuf, list) {
  858. ds = bf->desc;
  859. status = ah->ah_proc_rx_desc(ah, ds, &rs);
  860. if (!status)
  861. ath5k_debug_printrxbuf(bf, status == 0, &rs);
  862. }
  863. spin_unlock_bh(&sc->rxbuflock);
  864. }
  865. void
  866. ath5k_debug_printtxbuf(struct ath5k_softc *sc, struct ath5k_buf *bf)
  867. {
  868. struct ath5k_desc *ds = bf->desc;
  869. struct ath5k_hw_5212_tx_desc *td = &ds->ud.ds_tx5212;
  870. struct ath5k_tx_status ts = {};
  871. int done;
  872. if (likely(!(sc->debug.level & ATH5K_DEBUG_DESC)))
  873. return;
  874. done = sc->ah->ah_proc_tx_desc(sc->ah, bf->desc, &ts);
  875. printk(KERN_DEBUG "T (%p %llx) %08x %08x %08x %08x %08x %08x %08x "
  876. "%08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link,
  877. ds->ds_data, td->tx_ctl.tx_control_0, td->tx_ctl.tx_control_1,
  878. td->tx_ctl.tx_control_2, td->tx_ctl.tx_control_3,
  879. td->tx_stat.tx_status_0, td->tx_stat.tx_status_1,
  880. done ? ' ' : (ts.ts_status == 0) ? '*' : '!');
  881. }
  882. #endif /* ifdef CONFIG_ATH5K_DEBUG */