debug.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  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. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  61. #include <linux/export.h>
  62. #include <linux/moduleparam.h>
  63. #include <linux/seq_file.h>
  64. #include <linux/list.h>
  65. #include "debug.h"
  66. #include "ath5k.h"
  67. #include "reg.h"
  68. #include "base.h"
  69. static unsigned int ath5k_debug;
  70. module_param_named(debug, ath5k_debug, uint, 0);
  71. /* debugfs: registers */
  72. struct reg {
  73. const char *name;
  74. int addr;
  75. };
  76. #define REG_STRUCT_INIT(r) { #r, r }
  77. /* just a few random registers, might want to add more */
  78. static const struct reg regs[] = {
  79. REG_STRUCT_INIT(AR5K_CR),
  80. REG_STRUCT_INIT(AR5K_RXDP),
  81. REG_STRUCT_INIT(AR5K_CFG),
  82. REG_STRUCT_INIT(AR5K_IER),
  83. REG_STRUCT_INIT(AR5K_BCR),
  84. REG_STRUCT_INIT(AR5K_RTSD0),
  85. REG_STRUCT_INIT(AR5K_RTSD1),
  86. REG_STRUCT_INIT(AR5K_TXCFG),
  87. REG_STRUCT_INIT(AR5K_RXCFG),
  88. REG_STRUCT_INIT(AR5K_RXJLA),
  89. REG_STRUCT_INIT(AR5K_MIBC),
  90. REG_STRUCT_INIT(AR5K_TOPS),
  91. REG_STRUCT_INIT(AR5K_RXNOFRM),
  92. REG_STRUCT_INIT(AR5K_TXNOFRM),
  93. REG_STRUCT_INIT(AR5K_RPGTO),
  94. REG_STRUCT_INIT(AR5K_RFCNT),
  95. REG_STRUCT_INIT(AR5K_MISC),
  96. REG_STRUCT_INIT(AR5K_QCUDCU_CLKGT),
  97. REG_STRUCT_INIT(AR5K_ISR),
  98. REG_STRUCT_INIT(AR5K_PISR),
  99. REG_STRUCT_INIT(AR5K_SISR0),
  100. REG_STRUCT_INIT(AR5K_SISR1),
  101. REG_STRUCT_INIT(AR5K_SISR2),
  102. REG_STRUCT_INIT(AR5K_SISR3),
  103. REG_STRUCT_INIT(AR5K_SISR4),
  104. REG_STRUCT_INIT(AR5K_IMR),
  105. REG_STRUCT_INIT(AR5K_PIMR),
  106. REG_STRUCT_INIT(AR5K_SIMR0),
  107. REG_STRUCT_INIT(AR5K_SIMR1),
  108. REG_STRUCT_INIT(AR5K_SIMR2),
  109. REG_STRUCT_INIT(AR5K_SIMR3),
  110. REG_STRUCT_INIT(AR5K_SIMR4),
  111. REG_STRUCT_INIT(AR5K_DCM_ADDR),
  112. REG_STRUCT_INIT(AR5K_DCCFG),
  113. REG_STRUCT_INIT(AR5K_CCFG),
  114. REG_STRUCT_INIT(AR5K_CPC0),
  115. REG_STRUCT_INIT(AR5K_CPC1),
  116. REG_STRUCT_INIT(AR5K_CPC2),
  117. REG_STRUCT_INIT(AR5K_CPC3),
  118. REG_STRUCT_INIT(AR5K_CPCOVF),
  119. REG_STRUCT_INIT(AR5K_RESET_CTL),
  120. REG_STRUCT_INIT(AR5K_SLEEP_CTL),
  121. REG_STRUCT_INIT(AR5K_INTPEND),
  122. REG_STRUCT_INIT(AR5K_SFR),
  123. REG_STRUCT_INIT(AR5K_PCICFG),
  124. REG_STRUCT_INIT(AR5K_GPIOCR),
  125. REG_STRUCT_INIT(AR5K_GPIODO),
  126. REG_STRUCT_INIT(AR5K_SREV),
  127. };
  128. static void *reg_start(struct seq_file *seq, loff_t *pos)
  129. {
  130. return *pos < ARRAY_SIZE(regs) ? (void *)&regs[*pos] : NULL;
  131. }
  132. static void reg_stop(struct seq_file *seq, void *p)
  133. {
  134. /* nothing to do */
  135. }
  136. static void *reg_next(struct seq_file *seq, void *p, loff_t *pos)
  137. {
  138. ++*pos;
  139. return *pos < ARRAY_SIZE(regs) ? (void *)&regs[*pos] : NULL;
  140. }
  141. static int reg_show(struct seq_file *seq, void *p)
  142. {
  143. struct ath5k_hw *ah = seq->private;
  144. struct reg *r = p;
  145. seq_printf(seq, "%-25s0x%08x\n", r->name,
  146. ath5k_hw_reg_read(ah, r->addr));
  147. return 0;
  148. }
  149. static const struct seq_operations register_seq_ops = {
  150. .start = reg_start,
  151. .next = reg_next,
  152. .stop = reg_stop,
  153. .show = reg_show
  154. };
  155. static int open_file_registers(struct inode *inode, struct file *file)
  156. {
  157. struct seq_file *s;
  158. int res;
  159. res = seq_open(file, &register_seq_ops);
  160. if (res == 0) {
  161. s = file->private_data;
  162. s->private = inode->i_private;
  163. }
  164. return res;
  165. }
  166. static const struct file_operations fops_registers = {
  167. .open = open_file_registers,
  168. .read = seq_read,
  169. .llseek = seq_lseek,
  170. .release = seq_release,
  171. .owner = THIS_MODULE,
  172. };
  173. /* debugfs: beacons */
  174. static ssize_t read_file_beacon(struct file *file, char __user *user_buf,
  175. size_t count, loff_t *ppos)
  176. {
  177. struct ath5k_hw *ah = file->private_data;
  178. char buf[500];
  179. unsigned int len = 0;
  180. unsigned int v;
  181. u64 tsf;
  182. v = ath5k_hw_reg_read(ah, AR5K_BEACON);
  183. len += snprintf(buf + len, sizeof(buf) - len,
  184. "%-24s0x%08x\tintval: %d\tTIM: 0x%x\n",
  185. "AR5K_BEACON", v, v & AR5K_BEACON_PERIOD,
  186. (v & AR5K_BEACON_TIM) >> AR5K_BEACON_TIM_S);
  187. len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\n",
  188. "AR5K_LAST_TSTP", ath5k_hw_reg_read(ah, AR5K_LAST_TSTP));
  189. len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\n\n",
  190. "AR5K_BEACON_CNT", ath5k_hw_reg_read(ah, AR5K_BEACON_CNT));
  191. v = ath5k_hw_reg_read(ah, AR5K_TIMER0);
  192. len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
  193. "AR5K_TIMER0 (TBTT)", v, v);
  194. v = ath5k_hw_reg_read(ah, AR5K_TIMER1);
  195. len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
  196. "AR5K_TIMER1 (DMA)", v, v >> 3);
  197. v = ath5k_hw_reg_read(ah, AR5K_TIMER2);
  198. len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
  199. "AR5K_TIMER2 (SWBA)", v, v >> 3);
  200. v = ath5k_hw_reg_read(ah, AR5K_TIMER3);
  201. len += snprintf(buf + len, sizeof(buf) - len, "%-24s0x%08x\tTU: %08x\n",
  202. "AR5K_TIMER3 (ATIM)", v, v);
  203. tsf = ath5k_hw_get_tsf64(ah);
  204. len += snprintf(buf + len, sizeof(buf) - len,
  205. "TSF\t\t0x%016llx\tTU: %08x\n",
  206. (unsigned long long)tsf, TSF_TO_TU(tsf));
  207. if (len > sizeof(buf))
  208. len = sizeof(buf);
  209. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  210. }
  211. static ssize_t write_file_beacon(struct file *file,
  212. const char __user *userbuf,
  213. size_t count, loff_t *ppos)
  214. {
  215. struct ath5k_hw *ah = file->private_data;
  216. char buf[20];
  217. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  218. return -EFAULT;
  219. if (strncmp(buf, "disable", 7) == 0) {
  220. AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
  221. pr_info("debugfs disable beacons\n");
  222. } else if (strncmp(buf, "enable", 6) == 0) {
  223. AR5K_REG_ENABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
  224. pr_info("debugfs enable beacons\n");
  225. }
  226. return count;
  227. }
  228. static const struct file_operations fops_beacon = {
  229. .read = read_file_beacon,
  230. .write = write_file_beacon,
  231. .open = simple_open,
  232. .owner = THIS_MODULE,
  233. .llseek = default_llseek,
  234. };
  235. /* debugfs: reset */
  236. static ssize_t write_file_reset(struct file *file,
  237. const char __user *userbuf,
  238. size_t count, loff_t *ppos)
  239. {
  240. struct ath5k_hw *ah = file->private_data;
  241. ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "debug file triggered reset\n");
  242. ieee80211_queue_work(ah->hw, &ah->reset_work);
  243. return count;
  244. }
  245. static const struct file_operations fops_reset = {
  246. .write = write_file_reset,
  247. .open = simple_open,
  248. .owner = THIS_MODULE,
  249. .llseek = noop_llseek,
  250. };
  251. /* debugfs: debug level */
  252. static const struct {
  253. enum ath5k_debug_level level;
  254. const char *name;
  255. const char *desc;
  256. } dbg_info[] = {
  257. { ATH5K_DEBUG_RESET, "reset", "reset and initialization" },
  258. { ATH5K_DEBUG_INTR, "intr", "interrupt handling" },
  259. { ATH5K_DEBUG_MODE, "mode", "mode init/setup" },
  260. { ATH5K_DEBUG_XMIT, "xmit", "basic xmit operation" },
  261. { ATH5K_DEBUG_BEACON, "beacon", "beacon handling" },
  262. { ATH5K_DEBUG_CALIBRATE, "calib", "periodic calibration" },
  263. { ATH5K_DEBUG_TXPOWER, "txpower", "transmit power setting" },
  264. { ATH5K_DEBUG_LED, "led", "LED management" },
  265. { ATH5K_DEBUG_DUMPBANDS, "dumpbands", "dump bands" },
  266. { ATH5K_DEBUG_DMA, "dma", "dma start/stop" },
  267. { ATH5K_DEBUG_ANI, "ani", "adaptive noise immunity" },
  268. { ATH5K_DEBUG_DESC, "desc", "descriptor chains" },
  269. { ATH5K_DEBUG_ANY, "all", "show all debug levels" },
  270. };
  271. static ssize_t read_file_debug(struct file *file, char __user *user_buf,
  272. size_t count, loff_t *ppos)
  273. {
  274. struct ath5k_hw *ah = file->private_data;
  275. char buf[700];
  276. unsigned int len = 0;
  277. unsigned int i;
  278. len += snprintf(buf + len, sizeof(buf) - len,
  279. "DEBUG LEVEL: 0x%08x\n\n", ah->debug.level);
  280. for (i = 0; i < ARRAY_SIZE(dbg_info) - 1; i++) {
  281. len += snprintf(buf + len, sizeof(buf) - len,
  282. "%10s %c 0x%08x - %s\n", dbg_info[i].name,
  283. ah->debug.level & dbg_info[i].level ? '+' : ' ',
  284. dbg_info[i].level, dbg_info[i].desc);
  285. }
  286. len += snprintf(buf + len, sizeof(buf) - len,
  287. "%10s %c 0x%08x - %s\n", dbg_info[i].name,
  288. ah->debug.level == dbg_info[i].level ? '+' : ' ',
  289. dbg_info[i].level, dbg_info[i].desc);
  290. if (len > sizeof(buf))
  291. len = sizeof(buf);
  292. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  293. }
  294. static ssize_t write_file_debug(struct file *file,
  295. const char __user *userbuf,
  296. size_t count, loff_t *ppos)
  297. {
  298. struct ath5k_hw *ah = file->private_data;
  299. unsigned int i;
  300. char buf[20];
  301. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  302. return -EFAULT;
  303. for (i = 0; i < ARRAY_SIZE(dbg_info); i++) {
  304. if (strncmp(buf, dbg_info[i].name,
  305. strlen(dbg_info[i].name)) == 0) {
  306. ah->debug.level ^= dbg_info[i].level; /* toggle bit */
  307. break;
  308. }
  309. }
  310. return count;
  311. }
  312. static const struct file_operations fops_debug = {
  313. .read = read_file_debug,
  314. .write = write_file_debug,
  315. .open = simple_open,
  316. .owner = THIS_MODULE,
  317. .llseek = default_llseek,
  318. };
  319. /* debugfs: antenna */
  320. static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
  321. size_t count, loff_t *ppos)
  322. {
  323. struct ath5k_hw *ah = file->private_data;
  324. char buf[700];
  325. unsigned int len = 0;
  326. unsigned int i;
  327. unsigned int v;
  328. len += snprintf(buf + len, sizeof(buf) - len, "antenna mode\t%d\n",
  329. ah->ah_ant_mode);
  330. len += snprintf(buf + len, sizeof(buf) - len, "default antenna\t%d\n",
  331. ah->ah_def_ant);
  332. len += snprintf(buf + len, sizeof(buf) - len, "tx antenna\t%d\n",
  333. ah->ah_tx_ant);
  334. len += snprintf(buf + len, sizeof(buf) - len, "\nANTENNA\t\tRX\tTX\n");
  335. for (i = 1; i < ARRAY_SIZE(ah->stats.antenna_rx); i++) {
  336. len += snprintf(buf + len, sizeof(buf) - len,
  337. "[antenna %d]\t%d\t%d\n",
  338. i, ah->stats.antenna_rx[i], ah->stats.antenna_tx[i]);
  339. }
  340. len += snprintf(buf + len, sizeof(buf) - len, "[invalid]\t%d\t%d\n",
  341. ah->stats.antenna_rx[0], ah->stats.antenna_tx[0]);
  342. v = ath5k_hw_reg_read(ah, AR5K_DEFAULT_ANTENNA);
  343. len += snprintf(buf + len, sizeof(buf) - len,
  344. "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v);
  345. v = ath5k_hw_reg_read(ah, AR5K_STA_ID1);
  346. len += snprintf(buf + len, sizeof(buf) - len,
  347. "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n",
  348. (v & AR5K_STA_ID1_DEFAULT_ANTENNA) != 0);
  349. len += snprintf(buf + len, sizeof(buf) - len,
  350. "AR5K_STA_ID1_DESC_ANTENNA\t%d\n",
  351. (v & AR5K_STA_ID1_DESC_ANTENNA) != 0);
  352. len += snprintf(buf + len, sizeof(buf) - len,
  353. "AR5K_STA_ID1_RTS_DEF_ANTENNA\t%d\n",
  354. (v & AR5K_STA_ID1_RTS_DEF_ANTENNA) != 0);
  355. len += snprintf(buf + len, sizeof(buf) - len,
  356. "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n",
  357. (v & AR5K_STA_ID1_SELFGEN_DEF_ANT) != 0);
  358. v = ath5k_hw_reg_read(ah, AR5K_PHY_AGCCTL);
  359. len += snprintf(buf + len, sizeof(buf) - len,
  360. "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n",
  361. (v & AR5K_PHY_AGCCTL_OFDM_DIV_DIS) != 0);
  362. v = ath5k_hw_reg_read(ah, AR5K_PHY_RESTART);
  363. len += snprintf(buf + len, sizeof(buf) - len,
  364. "AR5K_PHY_RESTART_DIV_GC\t\t%x\n",
  365. (v & AR5K_PHY_RESTART_DIV_GC) >> AR5K_PHY_RESTART_DIV_GC_S);
  366. v = ath5k_hw_reg_read(ah, AR5K_PHY_FAST_ANT_DIV);
  367. len += snprintf(buf + len, sizeof(buf) - len,
  368. "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n",
  369. (v & AR5K_PHY_FAST_ANT_DIV_EN) != 0);
  370. v = ath5k_hw_reg_read(ah, AR5K_PHY_ANT_SWITCH_TABLE_0);
  371. len += snprintf(buf + len, sizeof(buf) - len,
  372. "\nAR5K_PHY_ANT_SWITCH_TABLE_0\t0x%08x\n", v);
  373. v = ath5k_hw_reg_read(ah, AR5K_PHY_ANT_SWITCH_TABLE_1);
  374. len += snprintf(buf + len, sizeof(buf) - len,
  375. "AR5K_PHY_ANT_SWITCH_TABLE_1\t0x%08x\n", v);
  376. if (len > sizeof(buf))
  377. len = sizeof(buf);
  378. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  379. }
  380. static ssize_t write_file_antenna(struct file *file,
  381. const char __user *userbuf,
  382. size_t count, loff_t *ppos)
  383. {
  384. struct ath5k_hw *ah = file->private_data;
  385. unsigned int i;
  386. char buf[20];
  387. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  388. return -EFAULT;
  389. if (strncmp(buf, "diversity", 9) == 0) {
  390. ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_DEFAULT);
  391. pr_info("debug: enable diversity\n");
  392. } else if (strncmp(buf, "fixed-a", 7) == 0) {
  393. ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_FIXED_A);
  394. pr_info("debug: fixed antenna A\n");
  395. } else if (strncmp(buf, "fixed-b", 7) == 0) {
  396. ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_FIXED_B);
  397. pr_info("debug: fixed antenna B\n");
  398. } else if (strncmp(buf, "clear", 5) == 0) {
  399. for (i = 0; i < ARRAY_SIZE(ah->stats.antenna_rx); i++) {
  400. ah->stats.antenna_rx[i] = 0;
  401. ah->stats.antenna_tx[i] = 0;
  402. }
  403. pr_info("debug: cleared antenna stats\n");
  404. }
  405. return count;
  406. }
  407. static const struct file_operations fops_antenna = {
  408. .read = read_file_antenna,
  409. .write = write_file_antenna,
  410. .open = simple_open,
  411. .owner = THIS_MODULE,
  412. .llseek = default_llseek,
  413. };
  414. /* debugfs: misc */
  415. static ssize_t read_file_misc(struct file *file, char __user *user_buf,
  416. size_t count, loff_t *ppos)
  417. {
  418. struct ath5k_hw *ah = file->private_data;
  419. char buf[700];
  420. unsigned int len = 0;
  421. u32 filt = ath5k_hw_get_rx_filter(ah);
  422. len += snprintf(buf + len, sizeof(buf) - len, "bssid-mask: %pM\n",
  423. ah->bssidmask);
  424. len += snprintf(buf + len, sizeof(buf) - len, "filter-flags: 0x%x ",
  425. filt);
  426. if (filt & AR5K_RX_FILTER_UCAST)
  427. len += snprintf(buf + len, sizeof(buf) - len, " UCAST");
  428. if (filt & AR5K_RX_FILTER_MCAST)
  429. len += snprintf(buf + len, sizeof(buf) - len, " MCAST");
  430. if (filt & AR5K_RX_FILTER_BCAST)
  431. len += snprintf(buf + len, sizeof(buf) - len, " BCAST");
  432. if (filt & AR5K_RX_FILTER_CONTROL)
  433. len += snprintf(buf + len, sizeof(buf) - len, " CONTROL");
  434. if (filt & AR5K_RX_FILTER_BEACON)
  435. len += snprintf(buf + len, sizeof(buf) - len, " BEACON");
  436. if (filt & AR5K_RX_FILTER_PROM)
  437. len += snprintf(buf + len, sizeof(buf) - len, " PROM");
  438. if (filt & AR5K_RX_FILTER_XRPOLL)
  439. len += snprintf(buf + len, sizeof(buf) - len, " XRPOLL");
  440. if (filt & AR5K_RX_FILTER_PROBEREQ)
  441. len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ");
  442. if (filt & AR5K_RX_FILTER_PHYERR_5212)
  443. len += snprintf(buf + len, sizeof(buf) - len, " PHYERR-5212");
  444. if (filt & AR5K_RX_FILTER_RADARERR_5212)
  445. len += snprintf(buf + len, sizeof(buf) - len, " RADARERR-5212");
  446. if (filt & AR5K_RX_FILTER_PHYERR_5211)
  447. snprintf(buf + len, sizeof(buf) - len, " PHYERR-5211");
  448. if (filt & AR5K_RX_FILTER_RADARERR_5211)
  449. len += snprintf(buf + len, sizeof(buf) - len, " RADARERR-5211");
  450. len += snprintf(buf + len, sizeof(buf) - len, "\nopmode: %s (%d)\n",
  451. ath_opmode_to_string(ah->opmode), ah->opmode);
  452. if (len > sizeof(buf))
  453. len = sizeof(buf);
  454. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  455. }
  456. static const struct file_operations fops_misc = {
  457. .read = read_file_misc,
  458. .open = simple_open,
  459. .owner = THIS_MODULE,
  460. };
  461. /* debugfs: frameerrors */
  462. static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf,
  463. size_t count, loff_t *ppos)
  464. {
  465. struct ath5k_hw *ah = file->private_data;
  466. struct ath5k_statistics *st = &ah->stats;
  467. char buf[700];
  468. unsigned int len = 0;
  469. int i;
  470. len += snprintf(buf + len, sizeof(buf) - len,
  471. "RX\n---------------------\n");
  472. len += snprintf(buf + len, sizeof(buf) - len, "CRC\t%u\t(%u%%)\n",
  473. st->rxerr_crc,
  474. st->rx_all_count > 0 ?
  475. st->rxerr_crc * 100 / st->rx_all_count : 0);
  476. len += snprintf(buf + len, sizeof(buf) - len, "PHY\t%u\t(%u%%)\n",
  477. st->rxerr_phy,
  478. st->rx_all_count > 0 ?
  479. st->rxerr_phy * 100 / st->rx_all_count : 0);
  480. for (i = 0; i < 32; i++) {
  481. if (st->rxerr_phy_code[i])
  482. len += snprintf(buf + len, sizeof(buf) - len,
  483. " phy_err[%u]\t%u\n",
  484. i, st->rxerr_phy_code[i]);
  485. }
  486. len += snprintf(buf + len, sizeof(buf) - len, "FIFO\t%u\t(%u%%)\n",
  487. st->rxerr_fifo,
  488. st->rx_all_count > 0 ?
  489. st->rxerr_fifo * 100 / st->rx_all_count : 0);
  490. len += snprintf(buf + len, sizeof(buf) - len, "decrypt\t%u\t(%u%%)\n",
  491. st->rxerr_decrypt,
  492. st->rx_all_count > 0 ?
  493. st->rxerr_decrypt * 100 / st->rx_all_count : 0);
  494. len += snprintf(buf + len, sizeof(buf) - len, "MIC\t%u\t(%u%%)\n",
  495. st->rxerr_mic,
  496. st->rx_all_count > 0 ?
  497. st->rxerr_mic * 100 / st->rx_all_count : 0);
  498. len += snprintf(buf + len, sizeof(buf) - len, "process\t%u\t(%u%%)\n",
  499. st->rxerr_proc,
  500. st->rx_all_count > 0 ?
  501. st->rxerr_proc * 100 / st->rx_all_count : 0);
  502. len += snprintf(buf + len, sizeof(buf) - len, "jumbo\t%u\t(%u%%)\n",
  503. st->rxerr_jumbo,
  504. st->rx_all_count > 0 ?
  505. st->rxerr_jumbo * 100 / st->rx_all_count : 0);
  506. len += snprintf(buf + len, sizeof(buf) - len, "[RX all\t%u]\n",
  507. st->rx_all_count);
  508. len += snprintf(buf + len, sizeof(buf) - len, "RX-all-bytes\t%u\n",
  509. st->rx_bytes_count);
  510. len += snprintf(buf + len, sizeof(buf) - len,
  511. "\nTX\n---------------------\n");
  512. len += snprintf(buf + len, sizeof(buf) - len, "retry\t%u\t(%u%%)\n",
  513. st->txerr_retry,
  514. st->tx_all_count > 0 ?
  515. st->txerr_retry * 100 / st->tx_all_count : 0);
  516. len += snprintf(buf + len, sizeof(buf) - len, "FIFO\t%u\t(%u%%)\n",
  517. st->txerr_fifo,
  518. st->tx_all_count > 0 ?
  519. st->txerr_fifo * 100 / st->tx_all_count : 0);
  520. len += snprintf(buf + len, sizeof(buf) - len, "filter\t%u\t(%u%%)\n",
  521. st->txerr_filt,
  522. st->tx_all_count > 0 ?
  523. st->txerr_filt * 100 / st->tx_all_count : 0);
  524. len += snprintf(buf + len, sizeof(buf) - len, "[TX all\t%u]\n",
  525. st->tx_all_count);
  526. len += snprintf(buf + len, sizeof(buf) - len, "TX-all-bytes\t%u\n",
  527. st->tx_bytes_count);
  528. if (len > sizeof(buf))
  529. len = sizeof(buf);
  530. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  531. }
  532. static ssize_t write_file_frameerrors(struct file *file,
  533. const char __user *userbuf,
  534. size_t count, loff_t *ppos)
  535. {
  536. struct ath5k_hw *ah = file->private_data;
  537. struct ath5k_statistics *st = &ah->stats;
  538. char buf[20];
  539. if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
  540. return -EFAULT;
  541. if (strncmp(buf, "clear", 5) == 0) {
  542. st->rxerr_crc = 0;
  543. st->rxerr_phy = 0;
  544. st->rxerr_fifo = 0;
  545. st->rxerr_decrypt = 0;
  546. st->rxerr_mic = 0;
  547. st->rxerr_proc = 0;
  548. st->rxerr_jumbo = 0;
  549. st->rx_all_count = 0;
  550. st->txerr_retry = 0;
  551. st->txerr_fifo = 0;
  552. st->txerr_filt = 0;
  553. st->tx_all_count = 0;
  554. pr_info("debug: cleared frameerrors stats\n");
  555. }
  556. return count;
  557. }
  558. static const struct file_operations fops_frameerrors = {
  559. .read = read_file_frameerrors,
  560. .write = write_file_frameerrors,
  561. .open = simple_open,
  562. .owner = THIS_MODULE,
  563. .llseek = default_llseek,
  564. };
  565. /* debugfs: ani */
  566. static ssize_t read_file_ani(struct file *file, char __user *user_buf,
  567. size_t count, loff_t *ppos)
  568. {
  569. struct ath5k_hw *ah = file->private_data;
  570. struct ath5k_statistics *st = &ah->stats;
  571. struct ath5k_ani_state *as = &ah->ani_state;
  572. char buf[700];
  573. unsigned int len = 0;
  574. len += snprintf(buf + len, sizeof(buf) - len,
  575. "HW has PHY error counters:\t%s\n",
  576. ah->ah_capabilities.cap_has_phyerr_counters ?
  577. "yes" : "no");
  578. len += snprintf(buf + len, sizeof(buf) - len,
  579. "HW max spur immunity level:\t%d\n",
  580. as->max_spur_level);
  581. len += snprintf(buf + len, sizeof(buf) - len,
  582. "\nANI state\n--------------------------------------------\n");
  583. len += snprintf(buf + len, sizeof(buf) - len, "operating mode:\t\t\t");
  584. switch (as->ani_mode) {
  585. case ATH5K_ANI_MODE_OFF:
  586. len += snprintf(buf + len, sizeof(buf) - len, "OFF\n");
  587. break;
  588. case ATH5K_ANI_MODE_MANUAL_LOW:
  589. len += snprintf(buf + len, sizeof(buf) - len,
  590. "MANUAL LOW\n");
  591. break;
  592. case ATH5K_ANI_MODE_MANUAL_HIGH:
  593. len += snprintf(buf + len, sizeof(buf) - len,
  594. "MANUAL HIGH\n");
  595. break;
  596. case ATH5K_ANI_MODE_AUTO:
  597. len += snprintf(buf + len, sizeof(buf) - len, "AUTO\n");
  598. break;
  599. default:
  600. len += snprintf(buf + len, sizeof(buf) - len,
  601. "??? (not good)\n");
  602. break;
  603. }
  604. len += snprintf(buf + len, sizeof(buf) - len,
  605. "noise immunity level:\t\t%d\n",
  606. as->noise_imm_level);
  607. len += snprintf(buf + len, sizeof(buf) - len,
  608. "spur immunity level:\t\t%d\n",
  609. as->spur_level);
  610. len += snprintf(buf + len, sizeof(buf) - len,
  611. "firstep level:\t\t\t%d\n",
  612. as->firstep_level);
  613. len += snprintf(buf + len, sizeof(buf) - len,
  614. "OFDM weak signal detection:\t%s\n",
  615. as->ofdm_weak_sig ? "on" : "off");
  616. len += snprintf(buf + len, sizeof(buf) - len,
  617. "CCK weak signal detection:\t%s\n",
  618. as->cck_weak_sig ? "on" : "off");
  619. len += snprintf(buf + len, sizeof(buf) - len,
  620. "\nMIB INTERRUPTS:\t\t%u\n",
  621. st->mib_intr);
  622. len += snprintf(buf + len, sizeof(buf) - len,
  623. "beacon RSSI average:\t%d\n",
  624. (int)ewma_read(&ah->ah_beacon_rssi_avg));
  625. #define CC_PRINT(_struct, _field) \
  626. _struct._field, \
  627. _struct.cycles > 0 ? \
  628. _struct._field * 100 / _struct.cycles : 0
  629. len += snprintf(buf + len, sizeof(buf) - len,
  630. "profcnt tx\t\t%u\t(%d%%)\n",
  631. CC_PRINT(as->last_cc, tx_frame));
  632. len += snprintf(buf + len, sizeof(buf) - len,
  633. "profcnt rx\t\t%u\t(%d%%)\n",
  634. CC_PRINT(as->last_cc, rx_frame));
  635. len += snprintf(buf + len, sizeof(buf) - len,
  636. "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(ah, AR5K_PHYERR_CNT1),
  655. ATH5K_ANI_OFDM_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
  656. ath5k_hw_reg_read(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(ah, AR5K_PHYERR_CNT2),
  660. ATH5K_ANI_CCK_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
  661. ath5k_hw_reg_read(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_hw *ah = 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(ah, ATH5K_ANI_MODE_MANUAL_HIGH);
  676. } else if (strncmp(buf, "sens-high", 9) == 0) {
  677. ath5k_ani_init(ah, ATH5K_ANI_MODE_MANUAL_LOW);
  678. } else if (strncmp(buf, "ani-off", 7) == 0) {
  679. ath5k_ani_init(ah, ATH5K_ANI_MODE_OFF);
  680. } else if (strncmp(buf, "ani-on", 6) == 0) {
  681. ath5k_ani_init(ah, ATH5K_ANI_MODE_AUTO);
  682. } else if (strncmp(buf, "noise-low", 9) == 0) {
  683. ath5k_ani_set_noise_immunity_level(ah, 0);
  684. } else if (strncmp(buf, "noise-high", 10) == 0) {
  685. ath5k_ani_set_noise_immunity_level(ah,
  686. ATH5K_ANI_MAX_NOISE_IMM_LVL);
  687. } else if (strncmp(buf, "spur-low", 8) == 0) {
  688. ath5k_ani_set_spur_immunity_level(ah, 0);
  689. } else if (strncmp(buf, "spur-high", 9) == 0) {
  690. ath5k_ani_set_spur_immunity_level(ah,
  691. ah->ani_state.max_spur_level);
  692. } else if (strncmp(buf, "fir-low", 7) == 0) {
  693. ath5k_ani_set_firstep_level(ah, 0);
  694. } else if (strncmp(buf, "fir-high", 8) == 0) {
  695. ath5k_ani_set_firstep_level(ah, ATH5K_ANI_MAX_FIRSTEP_LVL);
  696. } else if (strncmp(buf, "ofdm-off", 8) == 0) {
  697. ath5k_ani_set_ofdm_weak_signal_detection(ah, false);
  698. } else if (strncmp(buf, "ofdm-on", 7) == 0) {
  699. ath5k_ani_set_ofdm_weak_signal_detection(ah, true);
  700. } else if (strncmp(buf, "cck-off", 7) == 0) {
  701. ath5k_ani_set_cck_weak_signal_detection(ah, false);
  702. } else if (strncmp(buf, "cck-on", 6) == 0) {
  703. ath5k_ani_set_cck_weak_signal_detection(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 = simple_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_hw *ah = 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", ah->txbuf_len);
  726. for (i = 0; i < ARRAY_SIZE(ah->txqs); i++) {
  727. txq = &ah->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_hw *ah = 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(ah->hw);
  756. else if (strncmp(buf, "stop", 4) == 0)
  757. ieee80211_stop_queues(ah->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 = simple_open,
  764. .owner = THIS_MODULE,
  765. .llseek = default_llseek,
  766. };
  767. void
  768. ath5k_debug_init_device(struct ath5k_hw *ah)
  769. {
  770. struct dentry *phydir;
  771. ah->debug.level = ath5k_debug;
  772. phydir = debugfs_create_dir("ath5k", ah->hw->wiphy->debugfsdir);
  773. if (!phydir)
  774. return;
  775. debugfs_create_file("debug", S_IWUSR | S_IRUSR, phydir, ah,
  776. &fops_debug);
  777. debugfs_create_file("registers", S_IRUSR, phydir, ah, &fops_registers);
  778. debugfs_create_file("beacon", S_IWUSR | S_IRUSR, phydir, ah,
  779. &fops_beacon);
  780. debugfs_create_file("reset", S_IWUSR, phydir, ah, &fops_reset);
  781. debugfs_create_file("antenna", S_IWUSR | S_IRUSR, phydir, ah,
  782. &fops_antenna);
  783. debugfs_create_file("misc", S_IRUSR, phydir, ah, &fops_misc);
  784. debugfs_create_file("frameerrors", S_IWUSR | S_IRUSR, phydir, ah,
  785. &fops_frameerrors);
  786. debugfs_create_file("ani", S_IWUSR | S_IRUSR, phydir, ah, &fops_ani);
  787. debugfs_create_file("queue", S_IWUSR | S_IRUSR, phydir, ah,
  788. &fops_queue);
  789. debugfs_create_bool("32khz_clock", S_IWUSR | S_IRUSR, phydir,
  790. &ah->ah_use_32khz_clock);
  791. }
  792. /* functions used in other places */
  793. void
  794. ath5k_debug_dump_bands(struct ath5k_hw *ah)
  795. {
  796. unsigned int b, i;
  797. if (likely(!(ah->debug.level & ATH5K_DEBUG_DUMPBANDS)))
  798. return;
  799. BUG_ON(!ah->sbands);
  800. for (b = 0; b < IEEE80211_NUM_BANDS; b++) {
  801. struct ieee80211_supported_band *band = &ah->sbands[b];
  802. char bname[6];
  803. switch (band->band) {
  804. case IEEE80211_BAND_2GHZ:
  805. strcpy(bname, "2 GHz");
  806. break;
  807. case IEEE80211_BAND_5GHZ:
  808. strcpy(bname, "5 GHz");
  809. break;
  810. default:
  811. printk(KERN_DEBUG "Band not supported: %d\n",
  812. band->band);
  813. return;
  814. }
  815. printk(KERN_DEBUG "Band %s: channels %d, rates %d\n", bname,
  816. band->n_channels, band->n_bitrates);
  817. printk(KERN_DEBUG " channels:\n");
  818. for (i = 0; i < band->n_channels; i++)
  819. printk(KERN_DEBUG " %3d %d %.4x %.4x\n",
  820. ieee80211_frequency_to_channel(
  821. band->channels[i].center_freq),
  822. band->channels[i].center_freq,
  823. band->channels[i].hw_value,
  824. band->channels[i].flags);
  825. printk(KERN_DEBUG " rates:\n");
  826. for (i = 0; i < band->n_bitrates; i++)
  827. printk(KERN_DEBUG " %4d %.4x %.4x %.4x\n",
  828. band->bitrates[i].bitrate,
  829. band->bitrates[i].hw_value,
  830. band->bitrates[i].flags,
  831. band->bitrates[i].hw_value_short);
  832. }
  833. }
  834. static inline void
  835. ath5k_debug_printrxbuf(struct ath5k_buf *bf, int done,
  836. struct ath5k_rx_status *rs)
  837. {
  838. struct ath5k_desc *ds = bf->desc;
  839. struct ath5k_hw_all_rx_desc *rd = &ds->ud.ds_rx;
  840. printk(KERN_DEBUG "R (%p %llx) %08x %08x %08x %08x %08x %08x %c\n",
  841. ds, (unsigned long long)bf->daddr,
  842. ds->ds_link, ds->ds_data,
  843. rd->rx_ctl.rx_control_0, rd->rx_ctl.rx_control_1,
  844. rd->rx_stat.rx_status_0, rd->rx_stat.rx_status_1,
  845. !done ? ' ' : (rs->rs_status == 0) ? '*' : '!');
  846. }
  847. void
  848. ath5k_debug_printrxbuffs(struct ath5k_hw *ah)
  849. {
  850. struct ath5k_desc *ds;
  851. struct ath5k_buf *bf;
  852. struct ath5k_rx_status rs = {};
  853. int status;
  854. if (likely(!(ah->debug.level & ATH5K_DEBUG_DESC)))
  855. return;
  856. printk(KERN_DEBUG "rxdp %x, rxlink %p\n",
  857. ath5k_hw_get_rxdp(ah), ah->rxlink);
  858. spin_lock_bh(&ah->rxbuflock);
  859. list_for_each_entry(bf, &ah->rxbuf, list) {
  860. ds = bf->desc;
  861. status = ah->ah_proc_rx_desc(ah, ds, &rs);
  862. if (!status)
  863. ath5k_debug_printrxbuf(bf, status == 0, &rs);
  864. }
  865. spin_unlock_bh(&ah->rxbuflock);
  866. }
  867. void
  868. ath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf)
  869. {
  870. struct ath5k_desc *ds = bf->desc;
  871. struct ath5k_hw_5212_tx_desc *td = &ds->ud.ds_tx5212;
  872. struct ath5k_tx_status ts = {};
  873. int done;
  874. if (likely(!(ah->debug.level & ATH5K_DEBUG_DESC)))
  875. return;
  876. done = ah->ah_proc_tx_desc(ah, bf->desc, &ts);
  877. printk(KERN_DEBUG "T (%p %llx) %08x %08x %08x %08x %08x %08x %08x "
  878. "%08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link,
  879. ds->ds_data, td->tx_ctl.tx_control_0, td->tx_ctl.tx_control_1,
  880. td->tx_ctl.tx_control_2, td->tx_ctl.tx_control_3,
  881. td->tx_stat.tx_status_0, td->tx_stat.tx_status_1,
  882. done ? ' ' : (ts.ts_status == 0) ? '*' : '!');
  883. }