debug.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  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. static struct dentry *ath5k_global_debugfs;
  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. 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 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) ? &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) ? &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 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: TSF */
  176. static ssize_t read_file_tsf(struct file *file, char __user *user_buf,
  177. size_t count, loff_t *ppos)
  178. {
  179. struct ath5k_softc *sc = file->private_data;
  180. char buf[100];
  181. snprintf(buf, sizeof(buf), "0x%016llx\n",
  182. (unsigned long long)ath5k_hw_get_tsf64(sc->ah));
  183. return simple_read_from_buffer(user_buf, count, ppos, buf, 19);
  184. }
  185. static ssize_t write_file_tsf(struct file *file,
  186. const char __user *userbuf,
  187. size_t count, loff_t *ppos)
  188. {
  189. struct ath5k_softc *sc = file->private_data;
  190. char buf[20];
  191. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  192. return -EFAULT;
  193. if (strncmp(buf, "reset", 5) == 0) {
  194. ath5k_hw_reset_tsf(sc->ah);
  195. printk(KERN_INFO "debugfs reset TSF\n");
  196. }
  197. return count;
  198. }
  199. static const struct file_operations fops_tsf = {
  200. .read = read_file_tsf,
  201. .write = write_file_tsf,
  202. .open = ath5k_debugfs_open,
  203. .owner = THIS_MODULE,
  204. };
  205. /* debugfs: beacons */
  206. static ssize_t read_file_beacon(struct file *file, char __user *user_buf,
  207. size_t count, loff_t *ppos)
  208. {
  209. struct ath5k_softc *sc = file->private_data;
  210. struct ath5k_hw *ah = sc->ah;
  211. char buf[500];
  212. unsigned int len = 0;
  213. unsigned int v;
  214. u64 tsf;
  215. v = ath5k_hw_reg_read(sc->ah, AR5K_BEACON);
  216. len += snprintf(buf+len, sizeof(buf)-len,
  217. "%-24s0x%08x\tintval: %d\tTIM: 0x%x\n",
  218. "AR5K_BEACON", v, v & AR5K_BEACON_PERIOD,
  219. (v & AR5K_BEACON_TIM) >> AR5K_BEACON_TIM_S);
  220. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n",
  221. "AR5K_LAST_TSTP", ath5k_hw_reg_read(sc->ah, AR5K_LAST_TSTP));
  222. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\n\n",
  223. "AR5K_BEACON_CNT", ath5k_hw_reg_read(sc->ah, AR5K_BEACON_CNT));
  224. v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER0);
  225. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
  226. "AR5K_TIMER0 (TBTT)", v, v);
  227. v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER1);
  228. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
  229. "AR5K_TIMER1 (DMA)", v, v >> 3);
  230. v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER2);
  231. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
  232. "AR5K_TIMER2 (SWBA)", v, v >> 3);
  233. v = ath5k_hw_reg_read(sc->ah, AR5K_TIMER3);
  234. len += snprintf(buf+len, sizeof(buf)-len, "%-24s0x%08x\tTU: %08x\n",
  235. "AR5K_TIMER3 (ATIM)", v, v);
  236. tsf = ath5k_hw_get_tsf64(sc->ah);
  237. len += snprintf(buf+len, sizeof(buf)-len,
  238. "TSF\t\t0x%016llx\tTU: %08x\n",
  239. (unsigned long long)tsf, TSF_TO_TU(tsf));
  240. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  241. }
  242. static ssize_t write_file_beacon(struct file *file,
  243. const char __user *userbuf,
  244. size_t count, loff_t *ppos)
  245. {
  246. struct ath5k_softc *sc = file->private_data;
  247. struct ath5k_hw *ah = sc->ah;
  248. char buf[20];
  249. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  250. return -EFAULT;
  251. if (strncmp(buf, "disable", 7) == 0) {
  252. AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
  253. printk(KERN_INFO "debugfs disable beacons\n");
  254. } else if (strncmp(buf, "enable", 6) == 0) {
  255. AR5K_REG_ENABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
  256. printk(KERN_INFO "debugfs enable beacons\n");
  257. }
  258. return count;
  259. }
  260. static const struct file_operations fops_beacon = {
  261. .read = read_file_beacon,
  262. .write = write_file_beacon,
  263. .open = ath5k_debugfs_open,
  264. .owner = THIS_MODULE,
  265. };
  266. /* debugfs: reset */
  267. static ssize_t write_file_reset(struct file *file,
  268. const char __user *userbuf,
  269. size_t count, loff_t *ppos)
  270. {
  271. struct ath5k_softc *sc = file->private_data;
  272. tasklet_schedule(&sc->restq);
  273. return count;
  274. }
  275. static const struct file_operations fops_reset = {
  276. .write = write_file_reset,
  277. .open = ath5k_debugfs_open,
  278. .owner = THIS_MODULE,
  279. };
  280. /* debugfs: debug level */
  281. static struct {
  282. enum ath5k_debug_level level;
  283. const char *name;
  284. const char *desc;
  285. } dbg_info[] = {
  286. { ATH5K_DEBUG_RESET, "reset", "reset and initialization" },
  287. { ATH5K_DEBUG_INTR, "intr", "interrupt handling" },
  288. { ATH5K_DEBUG_MODE, "mode", "mode init/setup" },
  289. { ATH5K_DEBUG_XMIT, "xmit", "basic xmit operation" },
  290. { ATH5K_DEBUG_BEACON, "beacon", "beacon handling" },
  291. { ATH5K_DEBUG_CALIBRATE, "calib", "periodic calibration" },
  292. { ATH5K_DEBUG_TXPOWER, "txpower", "transmit power setting" },
  293. { ATH5K_DEBUG_LED, "led", "LED management" },
  294. { ATH5K_DEBUG_DUMP_RX, "dumprx", "print received skb content" },
  295. { ATH5K_DEBUG_DUMP_TX, "dumptx", "print transmit skb content" },
  296. { ATH5K_DEBUG_DUMPBANDS, "dumpbands", "dump bands" },
  297. { ATH5K_DEBUG_TRACE, "trace", "trace function calls" },
  298. { ATH5K_DEBUG_ANY, "all", "show all debug levels" },
  299. };
  300. static ssize_t read_file_debug(struct file *file, char __user *user_buf,
  301. size_t count, loff_t *ppos)
  302. {
  303. struct ath5k_softc *sc = file->private_data;
  304. char buf[700];
  305. unsigned int len = 0;
  306. unsigned int i;
  307. len += snprintf(buf+len, sizeof(buf)-len,
  308. "DEBUG LEVEL: 0x%08x\n\n", sc->debug.level);
  309. for (i = 0; i < ARRAY_SIZE(dbg_info) - 1; i++) {
  310. len += snprintf(buf+len, sizeof(buf)-len,
  311. "%10s %c 0x%08x - %s\n", dbg_info[i].name,
  312. sc->debug.level & dbg_info[i].level ? '+' : ' ',
  313. dbg_info[i].level, dbg_info[i].desc);
  314. }
  315. len += snprintf(buf+len, sizeof(buf)-len,
  316. "%10s %c 0x%08x - %s\n", dbg_info[i].name,
  317. sc->debug.level == dbg_info[i].level ? '+' : ' ',
  318. dbg_info[i].level, dbg_info[i].desc);
  319. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  320. }
  321. static ssize_t write_file_debug(struct file *file,
  322. const char __user *userbuf,
  323. size_t count, loff_t *ppos)
  324. {
  325. struct ath5k_softc *sc = file->private_data;
  326. unsigned int i;
  327. char buf[20];
  328. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  329. return -EFAULT;
  330. for (i = 0; i < ARRAY_SIZE(dbg_info); i++) {
  331. if (strncmp(buf, dbg_info[i].name,
  332. strlen(dbg_info[i].name)) == 0) {
  333. sc->debug.level ^= dbg_info[i].level; /* toggle bit */
  334. break;
  335. }
  336. }
  337. return count;
  338. }
  339. static const struct file_operations fops_debug = {
  340. .read = read_file_debug,
  341. .write = write_file_debug,
  342. .open = ath5k_debugfs_open,
  343. .owner = THIS_MODULE,
  344. };
  345. /* init */
  346. void
  347. ath5k_debug_init(void)
  348. {
  349. ath5k_global_debugfs = debugfs_create_dir("ath5k", NULL);
  350. }
  351. void
  352. ath5k_debug_init_device(struct ath5k_softc *sc)
  353. {
  354. sc->debug.level = ath5k_debug;
  355. sc->debug.debugfs_phydir = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
  356. ath5k_global_debugfs);
  357. sc->debug.debugfs_debug = debugfs_create_file("debug", S_IWUSR | S_IRUGO,
  358. sc->debug.debugfs_phydir, sc, &fops_debug);
  359. sc->debug.debugfs_registers = debugfs_create_file("registers", S_IRUGO,
  360. sc->debug.debugfs_phydir, sc, &fops_registers);
  361. sc->debug.debugfs_tsf = debugfs_create_file("tsf", S_IWUSR | S_IRUGO,
  362. sc->debug.debugfs_phydir, sc, &fops_tsf);
  363. sc->debug.debugfs_beacon = debugfs_create_file("beacon", S_IWUSR | S_IRUGO,
  364. sc->debug.debugfs_phydir, sc, &fops_beacon);
  365. sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR,
  366. sc->debug.debugfs_phydir, sc, &fops_reset);
  367. }
  368. void
  369. ath5k_debug_finish(void)
  370. {
  371. debugfs_remove(ath5k_global_debugfs);
  372. }
  373. void
  374. ath5k_debug_finish_device(struct ath5k_softc *sc)
  375. {
  376. debugfs_remove(sc->debug.debugfs_debug);
  377. debugfs_remove(sc->debug.debugfs_registers);
  378. debugfs_remove(sc->debug.debugfs_tsf);
  379. debugfs_remove(sc->debug.debugfs_beacon);
  380. debugfs_remove(sc->debug.debugfs_reset);
  381. debugfs_remove(sc->debug.debugfs_phydir);
  382. }
  383. /* functions used in other places */
  384. void
  385. ath5k_debug_dump_bands(struct ath5k_softc *sc)
  386. {
  387. unsigned int b, i;
  388. if (likely(!(sc->debug.level & ATH5K_DEBUG_DUMPBANDS)))
  389. return;
  390. BUG_ON(!sc->sbands);
  391. for (b = 0; b < IEEE80211_NUM_BANDS; b++) {
  392. struct ieee80211_supported_band *band = &sc->sbands[b];
  393. char bname[5];
  394. switch (band->band) {
  395. case IEEE80211_BAND_2GHZ:
  396. strcpy(bname, "2 GHz");
  397. break;
  398. case IEEE80211_BAND_5GHZ:
  399. strcpy(bname, "5 GHz");
  400. break;
  401. default:
  402. printk(KERN_DEBUG "Band not supported: %d\n",
  403. band->band);
  404. return;
  405. }
  406. printk(KERN_DEBUG "Band %s: channels %d, rates %d\n", bname,
  407. band->n_channels, band->n_bitrates);
  408. printk(KERN_DEBUG " channels:\n");
  409. for (i = 0; i < band->n_channels; i++)
  410. printk(KERN_DEBUG " %3d %d %.4x %.4x\n",
  411. ieee80211_frequency_to_channel(
  412. band->channels[i].center_freq),
  413. band->channels[i].center_freq,
  414. band->channels[i].hw_value,
  415. band->channels[i].flags);
  416. printk(KERN_DEBUG " rates:\n");
  417. for (i = 0; i < band->n_bitrates; i++)
  418. printk(KERN_DEBUG " %4d %.4x %.4x %.4x\n",
  419. band->bitrates[i].bitrate,
  420. band->bitrates[i].hw_value,
  421. band->bitrates[i].flags,
  422. band->bitrates[i].hw_value_short);
  423. }
  424. }
  425. static inline void
  426. ath5k_debug_printrxbuf(struct ath5k_buf *bf, int done,
  427. struct ath5k_rx_status *rs)
  428. {
  429. struct ath5k_desc *ds = bf->desc;
  430. struct ath5k_hw_all_rx_desc *rd = &ds->ud.ds_rx;
  431. printk(KERN_DEBUG "R (%p %llx) %08x %08x %08x %08x %08x %08x %c\n",
  432. ds, (unsigned long long)bf->daddr,
  433. ds->ds_link, ds->ds_data,
  434. rd->rx_ctl.rx_control_0, rd->rx_ctl.rx_control_1,
  435. rd->u.rx_stat.rx_status_0, rd->u.rx_stat.rx_status_0,
  436. !done ? ' ' : (rs->rs_status == 0) ? '*' : '!');
  437. }
  438. void
  439. ath5k_debug_printrxbuffs(struct ath5k_softc *sc, struct ath5k_hw *ah)
  440. {
  441. struct ath5k_desc *ds;
  442. struct ath5k_buf *bf;
  443. struct ath5k_rx_status rs = {};
  444. int status;
  445. if (likely(!(sc->debug.level & ATH5K_DEBUG_RESET)))
  446. return;
  447. printk(KERN_DEBUG "rx queue %x, link %p\n",
  448. ath5k_hw_get_rxdp(ah), sc->rxlink);
  449. spin_lock_bh(&sc->rxbuflock);
  450. list_for_each_entry(bf, &sc->rxbuf, list) {
  451. ds = bf->desc;
  452. status = ah->ah_proc_rx_desc(ah, ds, &rs);
  453. if (!status)
  454. ath5k_debug_printrxbuf(bf, status == 0, &rs);
  455. }
  456. spin_unlock_bh(&sc->rxbuflock);
  457. }
  458. void
  459. ath5k_debug_dump_skb(struct ath5k_softc *sc,
  460. struct sk_buff *skb, const char *prefix, int tx)
  461. {
  462. char buf[16];
  463. if (likely(!((tx && (sc->debug.level & ATH5K_DEBUG_DUMP_TX)) ||
  464. (!tx && (sc->debug.level & ATH5K_DEBUG_DUMP_RX)))))
  465. return;
  466. snprintf(buf, sizeof(buf), "%s %s", wiphy_name(sc->hw->wiphy), prefix);
  467. print_hex_dump_bytes(buf, DUMP_PREFIX_NONE, skb->data,
  468. min(200U, skb->len));
  469. printk(KERN_DEBUG "\n");
  470. }
  471. void
  472. ath5k_debug_printtxbuf(struct ath5k_softc *sc, struct ath5k_buf *bf)
  473. {
  474. struct ath5k_desc *ds = bf->desc;
  475. struct ath5k_hw_5212_tx_desc *td = &ds->ud.ds_tx5212;
  476. struct ath5k_tx_status ts = {};
  477. int done;
  478. if (likely(!(sc->debug.level & ATH5K_DEBUG_RESET)))
  479. return;
  480. done = sc->ah->ah_proc_tx_desc(sc->ah, bf->desc, &ts);
  481. printk(KERN_DEBUG "T (%p %llx) %08x %08x %08x %08x %08x %08x %08x "
  482. "%08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link,
  483. ds->ds_data, td->tx_ctl.tx_control_0, td->tx_ctl.tx_control_1,
  484. td->tx_ctl.tx_control_2, td->tx_ctl.tx_control_3,
  485. td->tx_stat.tx_status_0, td->tx_stat.tx_status_1,
  486. done ? ' ' : (ts.ts_status == 0) ? '*' : '!');
  487. }
  488. #endif /* ifdef CONFIG_ATH5K_DEBUG */