debug.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021
  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 struct dentry *ath5k_global_debugfs;
  69. static int ath5k_debugfs_open(struct inode *inode, struct file *file)
  70. {
  71. file->private_data = inode->i_private;
  72. return 0;
  73. }
  74. /* debugfs: registers */
  75. struct reg {
  76. const char *name;
  77. int addr;
  78. };
  79. #define REG_STRUCT_INIT(r) { #r, r }
  80. /* just a few random registers, might want to add more */
  81. static const struct reg regs[] = {
  82. REG_STRUCT_INIT(AR5K_CR),
  83. REG_STRUCT_INIT(AR5K_RXDP),
  84. REG_STRUCT_INIT(AR5K_CFG),
  85. REG_STRUCT_INIT(AR5K_IER),
  86. REG_STRUCT_INIT(AR5K_BCR),
  87. REG_STRUCT_INIT(AR5K_RTSD0),
  88. REG_STRUCT_INIT(AR5K_RTSD1),
  89. REG_STRUCT_INIT(AR5K_TXCFG),
  90. REG_STRUCT_INIT(AR5K_RXCFG),
  91. REG_STRUCT_INIT(AR5K_RXJLA),
  92. REG_STRUCT_INIT(AR5K_MIBC),
  93. REG_STRUCT_INIT(AR5K_TOPS),
  94. REG_STRUCT_INIT(AR5K_RXNOFRM),
  95. REG_STRUCT_INIT(AR5K_TXNOFRM),
  96. REG_STRUCT_INIT(AR5K_RPGTO),
  97. REG_STRUCT_INIT(AR5K_RFCNT),
  98. REG_STRUCT_INIT(AR5K_MISC),
  99. REG_STRUCT_INIT(AR5K_QCUDCU_CLKGT),
  100. REG_STRUCT_INIT(AR5K_ISR),
  101. REG_STRUCT_INIT(AR5K_PISR),
  102. REG_STRUCT_INIT(AR5K_SISR0),
  103. REG_STRUCT_INIT(AR5K_SISR1),
  104. REG_STRUCT_INIT(AR5K_SISR2),
  105. REG_STRUCT_INIT(AR5K_SISR3),
  106. REG_STRUCT_INIT(AR5K_SISR4),
  107. REG_STRUCT_INIT(AR5K_IMR),
  108. REG_STRUCT_INIT(AR5K_PIMR),
  109. REG_STRUCT_INIT(AR5K_SIMR0),
  110. REG_STRUCT_INIT(AR5K_SIMR1),
  111. REG_STRUCT_INIT(AR5K_SIMR2),
  112. REG_STRUCT_INIT(AR5K_SIMR3),
  113. REG_STRUCT_INIT(AR5K_SIMR4),
  114. REG_STRUCT_INIT(AR5K_DCM_ADDR),
  115. REG_STRUCT_INIT(AR5K_DCCFG),
  116. REG_STRUCT_INIT(AR5K_CCFG),
  117. REG_STRUCT_INIT(AR5K_CPC0),
  118. REG_STRUCT_INIT(AR5K_CPC1),
  119. REG_STRUCT_INIT(AR5K_CPC2),
  120. REG_STRUCT_INIT(AR5K_CPC3),
  121. REG_STRUCT_INIT(AR5K_CPCOVF),
  122. REG_STRUCT_INIT(AR5K_RESET_CTL),
  123. REG_STRUCT_INIT(AR5K_SLEEP_CTL),
  124. REG_STRUCT_INIT(AR5K_INTPEND),
  125. REG_STRUCT_INIT(AR5K_SFR),
  126. REG_STRUCT_INIT(AR5K_PCICFG),
  127. REG_STRUCT_INIT(AR5K_GPIOCR),
  128. REG_STRUCT_INIT(AR5K_GPIODO),
  129. REG_STRUCT_INIT(AR5K_SREV),
  130. };
  131. static void *reg_start(struct seq_file *seq, loff_t *pos)
  132. {
  133. return *pos < ARRAY_SIZE(regs) ? (void *)&regs[*pos] : NULL;
  134. }
  135. static void reg_stop(struct seq_file *seq, void *p)
  136. {
  137. /* nothing to do */
  138. }
  139. static void *reg_next(struct seq_file *seq, void *p, loff_t *pos)
  140. {
  141. ++*pos;
  142. return *pos < ARRAY_SIZE(regs) ? (void *)&regs[*pos] : NULL;
  143. }
  144. static int reg_show(struct seq_file *seq, void *p)
  145. {
  146. struct ath5k_softc *sc = seq->private;
  147. struct reg *r = p;
  148. seq_printf(seq, "%-25s0x%08x\n", r->name,
  149. ath5k_hw_reg_read(sc->ah, r->addr));
  150. return 0;
  151. }
  152. static const struct seq_operations register_seq_ops = {
  153. .start = reg_start,
  154. .next = reg_next,
  155. .stop = reg_stop,
  156. .show = reg_show
  157. };
  158. static int open_file_registers(struct inode *inode, struct file *file)
  159. {
  160. struct seq_file *s;
  161. int res;
  162. res = seq_open(file, &register_seq_ops);
  163. if (res == 0) {
  164. s = file->private_data;
  165. s->private = inode->i_private;
  166. }
  167. return res;
  168. }
  169. static const struct file_operations fops_registers = {
  170. .open = open_file_registers,
  171. .read = seq_read,
  172. .llseek = seq_lseek,
  173. .release = seq_release,
  174. .owner = THIS_MODULE,
  175. };
  176. /* debugfs: beacons */
  177. static ssize_t read_file_beacon(struct file *file, char __user *user_buf,
  178. size_t count, loff_t *ppos)
  179. {
  180. struct ath5k_softc *sc = file->private_data;
  181. struct ath5k_hw *ah = sc->ah;
  182. char buf[500];
  183. unsigned int len = 0;
  184. unsigned int v;
  185. u64 tsf;
  186. v = ath5k_hw_reg_read(sc->ah, AR5K_BEACON);
  187. len += snprintf(buf+len, sizeof(buf)-len,
  188. "%-24s0x%08x\tintval: %d\tTIM: 0x%x\n",
  189. "AR5K_BEACON", v, v & AR5K_BEACON_PERIOD,
  190. (v & AR5K_BEACON_TIM) >> AR5K_BEACON_TIM_S);
  191. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n",
  192. "AR5K_LAST_TSTP", ath5k_hw_reg_read(sc->ah, AR5K_LAST_TSTP));
  193. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n\n",
  194. "AR5K_BEACON_CNT", ath5k_hw_reg_read(sc->ah, AR5K_BEACON_CNT));
  195. v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER0);
  196. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
  197. "AR5K_TIMER0 (TBTT)", v, v);
  198. v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER1);
  199. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
  200. "AR5K_TIMER1 (DMA)", v, v >> 3);
  201. v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER2);
  202. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
  203. "AR5K_TIMER2 (SWBA)", v, v >> 3);
  204. v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER3);
  205. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
  206. "AR5K_TIMER3 (ATIM)", v, v);
  207. tsf = ath5k_hw_get_tsf64(sc->ah);
  208. len += snprintf(buf+len, sizeof(buf)-len,
  209. "TSF\t\t0x%016llx\tTU: %08x\n",
  210. (unsigned long long)tsf, TSF_TO_TU(tsf));
  211. if (len > sizeof(buf))
  212. len = sizeof(buf);
  213. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  214. }
  215. static ssize_t write_file_beacon(struct file *file,
  216. const char __user *userbuf,
  217. size_t count, loff_t *ppos)
  218. {
  219. struct ath5k_softc *sc = file->private_data;
  220. struct ath5k_hw *ah = sc->ah;
  221. char buf[20];
  222. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  223. return -EFAULT;
  224. if (strncmp(buf, "disable", 7) == 0) {
  225. AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
  226. printk(KERN_INFO "debugfs disable beacons\n");
  227. } else if (strncmp(buf, "enable", 6) == 0) {
  228. AR5K_REG_ENABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
  229. printk(KERN_INFO "debugfs enable beacons\n");
  230. }
  231. return count;
  232. }
  233. static const struct file_operations fops_beacon = {
  234. .read = read_file_beacon,
  235. .write = write_file_beacon,
  236. .open = ath5k_debugfs_open,
  237. .owner = THIS_MODULE,
  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. };
  254. /* debugfs: debug level */
  255. static const struct {
  256. enum ath5k_debug_level level;
  257. const char *name;
  258. const char *desc;
  259. } dbg_info[] = {
  260. { ATH5K_DEBUG_RESET, "reset", "reset and initialization" },
  261. { ATH5K_DEBUG_INTR, "intr", "interrupt handling" },
  262. { ATH5K_DEBUG_MODE, "mode", "mode init/setup" },
  263. { ATH5K_DEBUG_XMIT, "xmit", "basic xmit operation" },
  264. { ATH5K_DEBUG_BEACON, "beacon", "beacon handling" },
  265. { ATH5K_DEBUG_CALIBRATE, "calib", "periodic calibration" },
  266. { ATH5K_DEBUG_TXPOWER, "txpower", "transmit power setting" },
  267. { ATH5K_DEBUG_LED, "led", "LED management" },
  268. { ATH5K_DEBUG_DUMP_RX, "dumprx", "print received skb content" },
  269. { ATH5K_DEBUG_DUMP_TX, "dumptx", "print transmit skb content" },
  270. { ATH5K_DEBUG_DUMPBANDS, "dumpbands", "dump bands" },
  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. };
  322. /* debugfs: antenna */
  323. static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
  324. size_t count, loff_t *ppos)
  325. {
  326. struct ath5k_softc *sc = file->private_data;
  327. char buf[700];
  328. unsigned int len = 0;
  329. unsigned int i;
  330. unsigned int v;
  331. len += snprintf(buf+len, sizeof(buf)-len, "antenna mode\t%d\n",
  332. sc->ah->ah_ant_mode);
  333. len += snprintf(buf+len, sizeof(buf)-len, "default antenna\t%d\n",
  334. sc->ah->ah_def_ant);
  335. len += snprintf(buf+len, sizeof(buf)-len, "tx antenna\t%d\n",
  336. sc->ah->ah_tx_ant);
  337. len += snprintf(buf+len, sizeof(buf)-len, "\nANTENNA\t\tRX\tTX\n");
  338. for (i = 1; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) {
  339. len += snprintf(buf+len, sizeof(buf)-len,
  340. "[antenna %d]\t%d\t%d\n",
  341. i, sc->stats.antenna_rx[i], sc->stats.antenna_tx[i]);
  342. }
  343. len += snprintf(buf+len, sizeof(buf)-len, "[invalid]\t%d\t%d\n",
  344. sc->stats.antenna_rx[0], sc->stats.antenna_tx[0]);
  345. v = ath5k_hw_reg_read(sc->ah, AR5K_DEFAULT_ANTENNA);
  346. len += snprintf(buf+len, sizeof(buf)-len,
  347. "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v);
  348. v = ath5k_hw_reg_read(sc->ah, AR5K_STA_ID1);
  349. len += snprintf(buf+len, sizeof(buf)-len,
  350. "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n",
  351. (v & AR5K_STA_ID1_DEFAULT_ANTENNA) != 0);
  352. len += snprintf(buf+len, sizeof(buf)-len,
  353. "AR5K_STA_ID1_DESC_ANTENNA\t%d\n",
  354. (v & AR5K_STA_ID1_DESC_ANTENNA) != 0);
  355. len += snprintf(buf+len, sizeof(buf)-len,
  356. "AR5K_STA_ID1_RTS_DEF_ANTENNA\t%d\n",
  357. (v & AR5K_STA_ID1_RTS_DEF_ANTENNA) != 0);
  358. len += snprintf(buf+len, sizeof(buf)-len,
  359. "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n",
  360. (v & AR5K_STA_ID1_SELFGEN_DEF_ANT) != 0);
  361. v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_AGCCTL);
  362. len += snprintf(buf+len, sizeof(buf)-len,
  363. "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n",
  364. (v & AR5K_PHY_AGCCTL_OFDM_DIV_DIS) != 0);
  365. v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_RESTART);
  366. len += snprintf(buf+len, sizeof(buf)-len,
  367. "AR5K_PHY_RESTART_DIV_GC\t\t%x\n",
  368. (v & AR5K_PHY_RESTART_DIV_GC) >> AR5K_PHY_RESTART_DIV_GC_S);
  369. v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_FAST_ANT_DIV);
  370. len += snprintf(buf+len, sizeof(buf)-len,
  371. "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n",
  372. (v & AR5K_PHY_FAST_ANT_DIV_EN) != 0);
  373. v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_ANT_SWITCH_TABLE_0);
  374. len += snprintf(buf+len, sizeof(buf)-len,
  375. "\nAR5K_PHY_ANT_SWITCH_TABLE_0\t0x%08x\n", v);
  376. v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_ANT_SWITCH_TABLE_1);
  377. len += snprintf(buf+len, sizeof(buf)-len,
  378. "AR5K_PHY_ANT_SWITCH_TABLE_1\t0x%08x\n", v);
  379. if (len > sizeof(buf))
  380. len = sizeof(buf);
  381. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  382. }
  383. static ssize_t write_file_antenna(struct file *file,
  384. const char __user *userbuf,
  385. size_t count, loff_t *ppos)
  386. {
  387. struct ath5k_softc *sc = file->private_data;
  388. unsigned int i;
  389. char buf[20];
  390. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  391. return -EFAULT;
  392. if (strncmp(buf, "diversity", 9) == 0) {
  393. ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_DEFAULT);
  394. printk(KERN_INFO "ath5k debug: enable diversity\n");
  395. } else if (strncmp(buf, "fixed-a", 7) == 0) {
  396. ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_A);
  397. printk(KERN_INFO "ath5k debugfs: fixed antenna A\n");
  398. } else if (strncmp(buf, "fixed-b", 7) == 0) {
  399. ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_B);
  400. printk(KERN_INFO "ath5k debug: fixed antenna B\n");
  401. } else if (strncmp(buf, "clear", 5) == 0) {
  402. for (i = 0; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) {
  403. sc->stats.antenna_rx[i] = 0;
  404. sc->stats.antenna_tx[i] = 0;
  405. }
  406. printk(KERN_INFO "ath5k debug: cleared antenna stats\n");
  407. }
  408. return count;
  409. }
  410. static const struct file_operations fops_antenna = {
  411. .read = read_file_antenna,
  412. .write = write_file_antenna,
  413. .open = ath5k_debugfs_open,
  414. .owner = THIS_MODULE,
  415. };
  416. /* debugfs: frameerrors */
  417. static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf,
  418. size_t count, loff_t *ppos)
  419. {
  420. struct ath5k_softc *sc = file->private_data;
  421. struct ath5k_statistics *st = &sc->stats;
  422. char buf[700];
  423. unsigned int len = 0;
  424. int i;
  425. len += snprintf(buf+len, sizeof(buf)-len,
  426. "RX\n---------------------\n");
  427. len += snprintf(buf+len, sizeof(buf)-len, "CRC\t%d\t(%d%%)\n",
  428. st->rxerr_crc,
  429. st->rx_all_count > 0 ?
  430. st->rxerr_crc*100/st->rx_all_count : 0);
  431. len += snprintf(buf+len, sizeof(buf)-len, "PHY\t%d\t(%d%%)\n",
  432. st->rxerr_phy,
  433. st->rx_all_count > 0 ?
  434. st->rxerr_phy*100/st->rx_all_count : 0);
  435. for (i = 0; i < 32; i++) {
  436. if (st->rxerr_phy_code[i])
  437. len += snprintf(buf+len, sizeof(buf)-len,
  438. " phy_err[%d]\t%d\n",
  439. i, st->rxerr_phy_code[i]);
  440. }
  441. len += snprintf(buf+len, sizeof(buf)-len, "FIFO\t%d\t(%d%%)\n",
  442. st->rxerr_fifo,
  443. st->rx_all_count > 0 ?
  444. st->rxerr_fifo*100/st->rx_all_count : 0);
  445. len += snprintf(buf+len, sizeof(buf)-len, "decrypt\t%d\t(%d%%)\n",
  446. st->rxerr_decrypt,
  447. st->rx_all_count > 0 ?
  448. st->rxerr_decrypt*100/st->rx_all_count : 0);
  449. len += snprintf(buf+len, sizeof(buf)-len, "MIC\t%d\t(%d%%)\n",
  450. st->rxerr_mic,
  451. st->rx_all_count > 0 ?
  452. st->rxerr_mic*100/st->rx_all_count : 0);
  453. len += snprintf(buf+len, sizeof(buf)-len, "process\t%d\t(%d%%)\n",
  454. st->rxerr_proc,
  455. st->rx_all_count > 0 ?
  456. st->rxerr_proc*100/st->rx_all_count : 0);
  457. len += snprintf(buf+len, sizeof(buf)-len, "jumbo\t%d\t(%d%%)\n",
  458. st->rxerr_jumbo,
  459. st->rx_all_count > 0 ?
  460. st->rxerr_jumbo*100/st->rx_all_count : 0);
  461. len += snprintf(buf+len, sizeof(buf)-len, "[RX all\t%d]\n",
  462. st->rx_all_count);
  463. len += snprintf(buf+len, sizeof(buf)-len,
  464. "\nTX\n---------------------\n");
  465. len += snprintf(buf+len, sizeof(buf)-len, "retry\t%d\t(%d%%)\n",
  466. st->txerr_retry,
  467. st->tx_all_count > 0 ?
  468. st->txerr_retry*100/st->tx_all_count : 0);
  469. len += snprintf(buf+len, sizeof(buf)-len, "FIFO\t%d\t(%d%%)\n",
  470. st->txerr_fifo,
  471. st->tx_all_count > 0 ?
  472. st->txerr_fifo*100/st->tx_all_count : 0);
  473. len += snprintf(buf+len, sizeof(buf)-len, "filter\t%d\t(%d%%)\n",
  474. st->txerr_filt,
  475. st->tx_all_count > 0 ?
  476. st->txerr_filt*100/st->tx_all_count : 0);
  477. len += snprintf(buf+len, sizeof(buf)-len, "[TX all\t%d]\n",
  478. st->tx_all_count);
  479. if (len > sizeof(buf))
  480. len = sizeof(buf);
  481. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  482. }
  483. static ssize_t write_file_frameerrors(struct file *file,
  484. const char __user *userbuf,
  485. size_t count, loff_t *ppos)
  486. {
  487. struct ath5k_softc *sc = file->private_data;
  488. struct ath5k_statistics *st = &sc->stats;
  489. char buf[20];
  490. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  491. return -EFAULT;
  492. if (strncmp(buf, "clear", 5) == 0) {
  493. st->rxerr_crc = 0;
  494. st->rxerr_phy = 0;
  495. st->rxerr_fifo = 0;
  496. st->rxerr_decrypt = 0;
  497. st->rxerr_mic = 0;
  498. st->rxerr_proc = 0;
  499. st->rxerr_jumbo = 0;
  500. st->rx_all_count = 0;
  501. st->txerr_retry = 0;
  502. st->txerr_fifo = 0;
  503. st->txerr_filt = 0;
  504. st->tx_all_count = 0;
  505. printk(KERN_INFO "ath5k debug: cleared frameerrors stats\n");
  506. }
  507. return count;
  508. }
  509. static const struct file_operations fops_frameerrors = {
  510. .read = read_file_frameerrors,
  511. .write = write_file_frameerrors,
  512. .open = ath5k_debugfs_open,
  513. .owner = THIS_MODULE,
  514. };
  515. /* debugfs: ani */
  516. static ssize_t read_file_ani(struct file *file, char __user *user_buf,
  517. size_t count, loff_t *ppos)
  518. {
  519. struct ath5k_softc *sc = file->private_data;
  520. struct ath5k_statistics *st = &sc->stats;
  521. struct ath5k_ani_state *as = &sc->ani_state;
  522. char buf[700];
  523. unsigned int len = 0;
  524. len += snprintf(buf+len, sizeof(buf)-len,
  525. "HW has PHY error counters:\t%s\n",
  526. sc->ah->ah_capabilities.cap_has_phyerr_counters ?
  527. "yes" : "no");
  528. len += snprintf(buf+len, sizeof(buf)-len,
  529. "HW max spur immunity level:\t%d\n",
  530. as->max_spur_level);
  531. len += snprintf(buf+len, sizeof(buf)-len,
  532. "\nANI state\n--------------------------------------------\n");
  533. len += snprintf(buf+len, sizeof(buf)-len, "operating mode:\t\t\t");
  534. switch (as->ani_mode) {
  535. case ATH5K_ANI_MODE_OFF:
  536. len += snprintf(buf+len, sizeof(buf)-len, "OFF\n");
  537. break;
  538. case ATH5K_ANI_MODE_MANUAL_LOW:
  539. len += snprintf(buf+len, sizeof(buf)-len,
  540. "MANUAL LOW\n");
  541. break;
  542. case ATH5K_ANI_MODE_MANUAL_HIGH:
  543. len += snprintf(buf+len, sizeof(buf)-len,
  544. "MANUAL HIGH\n");
  545. break;
  546. case ATH5K_ANI_MODE_AUTO:
  547. len += snprintf(buf+len, sizeof(buf)-len, "AUTO\n");
  548. break;
  549. default:
  550. len += snprintf(buf+len, sizeof(buf)-len,
  551. "??? (not good)\n");
  552. break;
  553. }
  554. len += snprintf(buf+len, sizeof(buf)-len,
  555. "noise immunity level:\t\t%d\n",
  556. as->noise_imm_level);
  557. len += snprintf(buf+len, sizeof(buf)-len,
  558. "spur immunity level:\t\t%d\n",
  559. as->spur_level);
  560. len += snprintf(buf+len, sizeof(buf)-len, "firstep level:\t\t\t%d\n",
  561. as->firstep_level);
  562. len += snprintf(buf+len, sizeof(buf)-len,
  563. "OFDM weak signal detection:\t%s\n",
  564. as->ofdm_weak_sig ? "on" : "off");
  565. len += snprintf(buf+len, sizeof(buf)-len,
  566. "CCK weak signal detection:\t%s\n",
  567. as->cck_weak_sig ? "on" : "off");
  568. len += snprintf(buf+len, sizeof(buf)-len,
  569. "\nMIB INTERRUPTS:\t\t%u\n",
  570. st->mib_intr);
  571. len += snprintf(buf+len, sizeof(buf)-len,
  572. "beacon RSSI average:\t%d\n",
  573. sc->ah->ah_beacon_rssi_avg.avg);
  574. len += snprintf(buf+len, sizeof(buf)-len, "profcnt tx\t\t%u\t(%d%%)\n",
  575. as->pfc_tx,
  576. as->pfc_cycles > 0 ?
  577. as->pfc_tx*100/as->pfc_cycles : 0);
  578. len += snprintf(buf+len, sizeof(buf)-len, "profcnt rx\t\t%u\t(%d%%)\n",
  579. as->pfc_rx,
  580. as->pfc_cycles > 0 ?
  581. as->pfc_rx*100/as->pfc_cycles : 0);
  582. len += snprintf(buf+len, sizeof(buf)-len, "profcnt busy\t\t%u\t(%d%%)\n",
  583. as->pfc_busy,
  584. as->pfc_cycles > 0 ?
  585. as->pfc_busy*100/as->pfc_cycles : 0);
  586. len += snprintf(buf+len, sizeof(buf)-len, "profcnt cycles\t\t%u\n",
  587. as->pfc_cycles);
  588. len += snprintf(buf+len, sizeof(buf)-len,
  589. "listen time\t\t%d\tlast: %d\n",
  590. as->listen_time, as->last_listen);
  591. len += snprintf(buf+len, sizeof(buf)-len,
  592. "OFDM errors\t\t%u\tlast: %u\tsum: %u\n",
  593. as->ofdm_errors, as->last_ofdm_errors,
  594. as->sum_ofdm_errors);
  595. len += snprintf(buf+len, sizeof(buf)-len,
  596. "CCK errors\t\t%u\tlast: %u\tsum: %u\n",
  597. as->cck_errors, as->last_cck_errors,
  598. as->sum_cck_errors);
  599. len += snprintf(buf+len, sizeof(buf)-len,
  600. "AR5K_PHYERR_CNT1\t%x\t(=%d)\n",
  601. ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1),
  602. ATH5K_ANI_OFDM_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
  603. ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT1)));
  604. len += snprintf(buf+len, sizeof(buf)-len,
  605. "AR5K_PHYERR_CNT2\t%x\t(=%d)\n",
  606. ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2),
  607. ATH5K_ANI_CCK_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
  608. ath5k_hw_reg_read(sc->ah, AR5K_PHYERR_CNT2)));
  609. if (len > sizeof(buf))
  610. len = sizeof(buf);
  611. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  612. }
  613. static ssize_t write_file_ani(struct file *file,
  614. const char __user *userbuf,
  615. size_t count, loff_t *ppos)
  616. {
  617. struct ath5k_softc *sc = file->private_data;
  618. char buf[20];
  619. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  620. return -EFAULT;
  621. if (strncmp(buf, "sens-low", 8) == 0) {
  622. ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_MANUAL_HIGH);
  623. } else if (strncmp(buf, "sens-high", 9) == 0) {
  624. ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_MANUAL_LOW);
  625. } else if (strncmp(buf, "ani-off", 7) == 0) {
  626. ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_OFF);
  627. } else if (strncmp(buf, "ani-on", 6) == 0) {
  628. ath5k_ani_init(sc->ah, ATH5K_ANI_MODE_AUTO);
  629. } else if (strncmp(buf, "noise-low", 9) == 0) {
  630. ath5k_ani_set_noise_immunity_level(sc->ah, 0);
  631. } else if (strncmp(buf, "noise-high", 10) == 0) {
  632. ath5k_ani_set_noise_immunity_level(sc->ah,
  633. ATH5K_ANI_MAX_NOISE_IMM_LVL);
  634. } else if (strncmp(buf, "spur-low", 8) == 0) {
  635. ath5k_ani_set_spur_immunity_level(sc->ah, 0);
  636. } else if (strncmp(buf, "spur-high", 9) == 0) {
  637. ath5k_ani_set_spur_immunity_level(sc->ah,
  638. sc->ani_state.max_spur_level);
  639. } else if (strncmp(buf, "fir-low", 7) == 0) {
  640. ath5k_ani_set_firstep_level(sc->ah, 0);
  641. } else if (strncmp(buf, "fir-high", 8) == 0) {
  642. ath5k_ani_set_firstep_level(sc->ah, ATH5K_ANI_MAX_FIRSTEP_LVL);
  643. } else if (strncmp(buf, "ofdm-off", 8) == 0) {
  644. ath5k_ani_set_ofdm_weak_signal_detection(sc->ah, false);
  645. } else if (strncmp(buf, "ofdm-on", 7) == 0) {
  646. ath5k_ani_set_ofdm_weak_signal_detection(sc->ah, true);
  647. } else if (strncmp(buf, "cck-off", 7) == 0) {
  648. ath5k_ani_set_cck_weak_signal_detection(sc->ah, false);
  649. } else if (strncmp(buf, "cck-on", 6) == 0) {
  650. ath5k_ani_set_cck_weak_signal_detection(sc->ah, true);
  651. }
  652. return count;
  653. }
  654. static const struct file_operations fops_ani = {
  655. .read = read_file_ani,
  656. .write = write_file_ani,
  657. .open = ath5k_debugfs_open,
  658. .owner = THIS_MODULE,
  659. };
  660. /* debugfs: queues etc */
  661. static ssize_t read_file_queue(struct file *file, char __user *user_buf,
  662. size_t count, loff_t *ppos)
  663. {
  664. struct ath5k_softc *sc = file->private_data;
  665. char buf[700];
  666. unsigned int len = 0;
  667. struct ath5k_txq *txq;
  668. struct ath5k_buf *bf, *bf0;
  669. int i, n;
  670. len += snprintf(buf+len, sizeof(buf)-len,
  671. "available txbuffers: %d\n", sc->txbuf_len);
  672. for (i = 0; i < ARRAY_SIZE(sc->txqs); i++) {
  673. txq = &sc->txqs[i];
  674. len += snprintf(buf+len, sizeof(buf)-len,
  675. "%02d: %ssetup\n", i, txq->setup ? "" : "not ");
  676. if (!txq->setup)
  677. continue;
  678. n = 0;
  679. spin_lock_bh(&txq->lock);
  680. list_for_each_entry_safe(bf, bf0, &txq->q, list)
  681. n++;
  682. spin_unlock_bh(&txq->lock);
  683. len += snprintf(buf+len, sizeof(buf)-len,
  684. " len: %d bufs: %d\n", txq->txq_len, n);
  685. len += snprintf(buf+len, sizeof(buf)-len,
  686. " stuck: %d\n", txq->txq_stuck);
  687. }
  688. if (len > sizeof(buf))
  689. len = sizeof(buf);
  690. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  691. }
  692. static ssize_t write_file_queue(struct file *file,
  693. const char __user *userbuf,
  694. size_t count, loff_t *ppos)
  695. {
  696. struct ath5k_softc *sc = file->private_data;
  697. char buf[20];
  698. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  699. return -EFAULT;
  700. if (strncmp(buf, "start", 5) == 0)
  701. ieee80211_wake_queues(sc->hw);
  702. else if (strncmp(buf, "stop", 4) == 0)
  703. ieee80211_stop_queues(sc->hw);
  704. return count;
  705. }
  706. static const struct file_operations fops_queue = {
  707. .read = read_file_queue,
  708. .write = write_file_queue,
  709. .open = ath5k_debugfs_open,
  710. .owner = THIS_MODULE,
  711. };
  712. /* init */
  713. void
  714. ath5k_debug_init(void)
  715. {
  716. ath5k_global_debugfs = debugfs_create_dir("ath5k", NULL);
  717. }
  718. void
  719. ath5k_debug_init_device(struct ath5k_softc *sc)
  720. {
  721. sc->debug.level = ath5k_debug;
  722. sc->debug.debugfs_phydir = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
  723. ath5k_global_debugfs);
  724. sc->debug.debugfs_debug = debugfs_create_file("debug",
  725. S_IWUSR | S_IRUSR,
  726. sc->debug.debugfs_phydir, sc, &fops_debug);
  727. sc->debug.debugfs_registers = debugfs_create_file("registers", S_IRUSR,
  728. sc->debug.debugfs_phydir, sc, &fops_registers);
  729. sc->debug.debugfs_beacon = debugfs_create_file("beacon",
  730. S_IWUSR | S_IRUSR,
  731. sc->debug.debugfs_phydir, sc, &fops_beacon);
  732. sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR,
  733. sc->debug.debugfs_phydir, sc, &fops_reset);
  734. sc->debug.debugfs_antenna = debugfs_create_file("antenna",
  735. S_IWUSR | S_IRUSR,
  736. sc->debug.debugfs_phydir, sc, &fops_antenna);
  737. sc->debug.debugfs_frameerrors = debugfs_create_file("frameerrors",
  738. S_IWUSR | S_IRUSR,
  739. sc->debug.debugfs_phydir, sc,
  740. &fops_frameerrors);
  741. sc->debug.debugfs_ani = debugfs_create_file("ani",
  742. S_IWUSR | S_IRUSR,
  743. sc->debug.debugfs_phydir, sc,
  744. &fops_ani);
  745. sc->debug.debugfs_queue = debugfs_create_file("queue",
  746. S_IWUSR | S_IRUSR,
  747. sc->debug.debugfs_phydir, sc,
  748. &fops_queue);
  749. }
  750. void
  751. ath5k_debug_finish(void)
  752. {
  753. debugfs_remove(ath5k_global_debugfs);
  754. }
  755. void
  756. ath5k_debug_finish_device(struct ath5k_softc *sc)
  757. {
  758. debugfs_remove(sc->debug.debugfs_debug);
  759. debugfs_remove(sc->debug.debugfs_registers);
  760. debugfs_remove(sc->debug.debugfs_beacon);
  761. debugfs_remove(sc->debug.debugfs_reset);
  762. debugfs_remove(sc->debug.debugfs_antenna);
  763. debugfs_remove(sc->debug.debugfs_frameerrors);
  764. debugfs_remove(sc->debug.debugfs_ani);
  765. debugfs_remove(sc->debug.debugfs_queue);
  766. debugfs_remove(sc->debug.debugfs_phydir);
  767. }
  768. /* functions used in other places */
  769. void
  770. ath5k_debug_dump_bands(struct ath5k_softc *sc)
  771. {
  772. unsigned int b, i;
  773. if (likely(!(sc->debug.level & ATH5K_DEBUG_DUMPBANDS)))
  774. return;
  775. BUG_ON(!sc->sbands);
  776. for (b = 0; b < IEEE80211_NUM_BANDS; b++) {
  777. struct ieee80211_supported_band *band = &sc->sbands[b];
  778. char bname[6];
  779. switch (band->band) {
  780. case IEEE80211_BAND_2GHZ:
  781. strcpy(bname, "2 GHz");
  782. break;
  783. case IEEE80211_BAND_5GHZ:
  784. strcpy(bname, "5 GHz");
  785. break;
  786. default:
  787. printk(KERN_DEBUG "Band not supported: %d\n",
  788. band->band);
  789. return;
  790. }
  791. printk(KERN_DEBUG "Band %s: channels %d, rates %d\n", bname,
  792. band->n_channels, band->n_bitrates);
  793. printk(KERN_DEBUG " channels:\n");
  794. for (i = 0; i < band->n_channels; i++)
  795. printk(KERN_DEBUG " %3d %d %.4x %.4x\n",
  796. ieee80211_frequency_to_channel(
  797. band->channels[i].center_freq),
  798. band->channels[i].center_freq,
  799. band->channels[i].hw_value,
  800. band->channels[i].flags);
  801. printk(KERN_DEBUG " rates:\n");
  802. for (i = 0; i < band->n_bitrates; i++)
  803. printk(KERN_DEBUG " %4d %.4x %.4x %.4x\n",
  804. band->bitrates[i].bitrate,
  805. band->bitrates[i].hw_value,
  806. band->bitrates[i].flags,
  807. band->bitrates[i].hw_value_short);
  808. }
  809. }
  810. static inline void
  811. ath5k_debug_printrxbuf(struct ath5k_buf *bf, int done,
  812. struct ath5k_rx_status *rs)
  813. {
  814. struct ath5k_desc *ds = bf->desc;
  815. struct ath5k_hw_all_rx_desc *rd = &ds->ud.ds_rx;
  816. printk(KERN_DEBUG "R (%p %llx) %08x %08x %08x %08x %08x %08x %c\n",
  817. ds, (unsigned long long)bf->daddr,
  818. ds->ds_link, ds->ds_data,
  819. rd->rx_ctl.rx_control_0, rd->rx_ctl.rx_control_1,
  820. rd->rx_stat.rx_status_0, rd->rx_stat.rx_status_1,
  821. !done ? ' ' : (rs->rs_status == 0) ? '*' : '!');
  822. }
  823. void
  824. ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah)
  825. {
  826. struct ath5k_desc *ds;
  827. struct ath5k_buf *bf;
  828. struct ath5k_rx_status rs = {};
  829. int status;
  830. if (likely(!(sc->debug.level & ATH5K_DEBUG_DESC)))
  831. return;
  832. printk(KERN_DEBUG "rxdp %x, rxlink %p\n",
  833. ath5k_hw_get_rxdp(ah), sc->rxlink);
  834. spin_lock_bh(&sc->rxbuflock);
  835. list_for_each_entry(bf, &sc->rxbuf, list) {
  836. ds = bf->desc;
  837. status = ah->ah_proc_rx_desc(ah, ds, &rs);
  838. if (!status)
  839. ath5k_debug_printrxbuf(bf, status == 0, &rs);
  840. }
  841. spin_unlock_bh(&sc->rxbuflock);
  842. }
  843. void
  844. ath5k_debug_dump_skb(struct ath5k_softc *sc,
  845. struct sk_buff *skb, const char *prefix, int tx)
  846. {
  847. char buf[16];
  848. if (likely(!((tx && (sc->debug.level & ATH5K_DEBUG_DUMP_TX)) ||
  849. (!tx && (sc->debug.level & ATH5K_DEBUG_DUMP_RX)))))
  850. return;
  851. snprintf(buf, sizeof(buf), "%s %s", wiphy_name(sc->hw->wiphy), prefix);
  852. print_hex_dump_bytes(buf, DUMP_PREFIX_NONE, skb->data,
  853. min(200U, skb->len));
  854. printk(KERN_DEBUG "\n");
  855. }
  856. void
  857. ath5k_debug_printtxbuf(struct ath5k_softc *sc, struct ath5k_buf *bf)
  858. {
  859. struct ath5k_desc *ds = bf->desc;
  860. struct ath5k_hw_5212_tx_desc *td = &ds->ud.ds_tx5212;
  861. struct ath5k_tx_status ts = {};
  862. int done;
  863. if (likely(!(sc->debug.level & ATH5K_DEBUG_DESC)))
  864. return;
  865. done = sc->ah->ah_proc_tx_desc(sc->ah, bf->desc, &ts);
  866. printk(KERN_DEBUG "T (%p %llx) %08x %08x %08x %08x %08x %08x %08x "
  867. "%08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link,
  868. ds->ds_data, td->tx_ctl.tx_control_0, td->tx_ctl.tx_control_1,
  869. td->tx_ctl.tx_control_2, td->tx_ctl.tx_control_3,
  870. td->tx_stat.tx_status_0, td->tx_stat.tx_status_1,
  871. done ? ' ' : (ts.ts_status == 0) ? '*' : '!');
  872. }
  873. #endif /* ifdef CONFIG_ATH5K_DEBUG */