debug.c 16 KB

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