debug.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041
  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. count = min_t(size_t, count, sizeof(buf) - 1);
  218. if (copy_from_user(buf, userbuf, count))
  219. return -EFAULT;
  220. buf[count] = '\0';
  221. if (strncmp(buf, "disable", 7) == 0) {
  222. AR5K_REG_DISABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
  223. pr_info("debugfs disable beacons\n");
  224. } else if (strncmp(buf, "enable", 6) == 0) {
  225. AR5K_REG_ENABLE_BITS(ah, AR5K_BEACON, AR5K_BEACON_ENABLE);
  226. pr_info("debugfs enable beacons\n");
  227. }
  228. return count;
  229. }
  230. static const struct file_operations fops_beacon = {
  231. .read = read_file_beacon,
  232. .write = write_file_beacon,
  233. .open = simple_open,
  234. .owner = THIS_MODULE,
  235. .llseek = default_llseek,
  236. };
  237. /* debugfs: reset */
  238. static ssize_t write_file_reset(struct file *file,
  239. const char __user *userbuf,
  240. size_t count, loff_t *ppos)
  241. {
  242. struct ath5k_hw *ah = file->private_data;
  243. ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "debug file triggered reset\n");
  244. ieee80211_queue_work(ah->hw, &ah->reset_work);
  245. return count;
  246. }
  247. static const struct file_operations fops_reset = {
  248. .write = write_file_reset,
  249. .open = simple_open,
  250. .owner = THIS_MODULE,
  251. .llseek = noop_llseek,
  252. };
  253. /* debugfs: debug level */
  254. static const struct {
  255. enum ath5k_debug_level level;
  256. const char *name;
  257. const char *desc;
  258. } dbg_info[] = {
  259. { ATH5K_DEBUG_RESET, "reset", "reset and initialization" },
  260. { ATH5K_DEBUG_INTR, "intr", "interrupt handling" },
  261. { ATH5K_DEBUG_MODE, "mode", "mode init/setup" },
  262. { ATH5K_DEBUG_XMIT, "xmit", "basic xmit operation" },
  263. { ATH5K_DEBUG_BEACON, "beacon", "beacon handling" },
  264. { ATH5K_DEBUG_CALIBRATE, "calib", "periodic calibration" },
  265. { ATH5K_DEBUG_TXPOWER, "txpower", "transmit power setting" },
  266. { ATH5K_DEBUG_LED, "led", "LED management" },
  267. { ATH5K_DEBUG_DUMPBANDS, "dumpbands", "dump bands" },
  268. { ATH5K_DEBUG_DMA, "dma", "dma start/stop" },
  269. { ATH5K_DEBUG_ANI, "ani", "adaptive noise immunity" },
  270. { ATH5K_DEBUG_DESC, "desc", "descriptor chains" },
  271. { ATH5K_DEBUG_ANY, "all", "show all debug levels" },
  272. };
  273. static ssize_t read_file_debug(struct file *file, char __user *user_buf,
  274. size_t count, loff_t *ppos)
  275. {
  276. struct ath5k_hw *ah = file->private_data;
  277. char buf[700];
  278. unsigned int len = 0;
  279. unsigned int i;
  280. len += snprintf(buf + len, sizeof(buf) - len,
  281. "DEBUG LEVEL: 0x%08x\n\n", ah->debug.level);
  282. for (i = 0; i < ARRAY_SIZE(dbg_info) - 1; i++) {
  283. len += snprintf(buf + len, sizeof(buf) - len,
  284. "%10s %c 0x%08x - %s\n", dbg_info[i].name,
  285. ah->debug.level & dbg_info[i].level ? '+' : ' ',
  286. dbg_info[i].level, dbg_info[i].desc);
  287. }
  288. len += snprintf(buf + len, sizeof(buf) - len,
  289. "%10s %c 0x%08x - %s\n", dbg_info[i].name,
  290. ah->debug.level == dbg_info[i].level ? '+' : ' ',
  291. dbg_info[i].level, dbg_info[i].desc);
  292. if (len > sizeof(buf))
  293. len = sizeof(buf);
  294. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  295. }
  296. static ssize_t write_file_debug(struct file *file,
  297. const char __user *userbuf,
  298. size_t count, loff_t *ppos)
  299. {
  300. struct ath5k_hw *ah = file->private_data;
  301. unsigned int i;
  302. char buf[20];
  303. count = min_t(size_t, count, sizeof(buf) - 1);
  304. if (copy_from_user(buf, userbuf, count))
  305. return -EFAULT;
  306. buf[count] = '\0';
  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. ah->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 = simple_open,
  320. .owner = THIS_MODULE,
  321. .llseek = default_llseek,
  322. };
  323. /* debugfs: antenna */
  324. static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
  325. size_t count, loff_t *ppos)
  326. {
  327. struct ath5k_hw *ah = file->private_data;
  328. char buf[700];
  329. unsigned int len = 0;
  330. unsigned int i;
  331. unsigned int v;
  332. len += snprintf(buf + len, sizeof(buf) - len, "antenna mode\t%d\n",
  333. ah->ah_ant_mode);
  334. len += snprintf(buf + len, sizeof(buf) - len, "default antenna\t%d\n",
  335. ah->ah_def_ant);
  336. len += snprintf(buf + len, sizeof(buf) - len, "tx antenna\t%d\n",
  337. ah->ah_tx_ant);
  338. len += snprintf(buf + len, sizeof(buf) - len, "\nANTENNA\t\tRX\tTX\n");
  339. for (i = 1; i < ARRAY_SIZE(ah->stats.antenna_rx); i++) {
  340. len += snprintf(buf + len, sizeof(buf) - len,
  341. "[antenna %d]\t%d\t%d\n",
  342. i, ah->stats.antenna_rx[i], ah->stats.antenna_tx[i]);
  343. }
  344. len += snprintf(buf + len, sizeof(buf) - len, "[invalid]\t%d\t%d\n",
  345. ah->stats.antenna_rx[0], ah->stats.antenna_tx[0]);
  346. v = ath5k_hw_reg_read(ah, AR5K_DEFAULT_ANTENNA);
  347. len += snprintf(buf + len, sizeof(buf) - len,
  348. "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v);
  349. v = ath5k_hw_reg_read(ah, AR5K_STA_ID1);
  350. len += snprintf(buf + len, sizeof(buf) - len,
  351. "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n",
  352. (v & AR5K_STA_ID1_DEFAULT_ANTENNA) != 0);
  353. len += snprintf(buf + len, sizeof(buf) - len,
  354. "AR5K_STA_ID1_DESC_ANTENNA\t%d\n",
  355. (v & AR5K_STA_ID1_DESC_ANTENNA) != 0);
  356. len += snprintf(buf + len, sizeof(buf) - len,
  357. "AR5K_STA_ID1_RTS_DEF_ANTENNA\t%d\n",
  358. (v & AR5K_STA_ID1_RTS_DEF_ANTENNA) != 0);
  359. len += snprintf(buf + len, sizeof(buf) - len,
  360. "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n",
  361. (v & AR5K_STA_ID1_SELFGEN_DEF_ANT) != 0);
  362. v = ath5k_hw_reg_read(ah, AR5K_PHY_AGCCTL);
  363. len += snprintf(buf + len, sizeof(buf) - len,
  364. "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n",
  365. (v & AR5K_PHY_AGCCTL_OFDM_DIV_DIS) != 0);
  366. v = ath5k_hw_reg_read(ah, AR5K_PHY_RESTART);
  367. len += snprintf(buf + len, sizeof(buf) - len,
  368. "AR5K_PHY_RESTART_DIV_GC\t\t%x\n",
  369. (v & AR5K_PHY_RESTART_DIV_GC) >> AR5K_PHY_RESTART_DIV_GC_S);
  370. v = ath5k_hw_reg_read(ah, AR5K_PHY_FAST_ANT_DIV);
  371. len += snprintf(buf + len, sizeof(buf) - len,
  372. "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n",
  373. (v & AR5K_PHY_FAST_ANT_DIV_EN) != 0);
  374. v = ath5k_hw_reg_read(ah, AR5K_PHY_ANT_SWITCH_TABLE_0);
  375. len += snprintf(buf + len, sizeof(buf) - len,
  376. "\nAR5K_PHY_ANT_SWITCH_TABLE_0\t0x%08x\n", v);
  377. v = ath5k_hw_reg_read(ah, AR5K_PHY_ANT_SWITCH_TABLE_1);
  378. len += snprintf(buf + len, sizeof(buf) - len,
  379. "AR5K_PHY_ANT_SWITCH_TABLE_1\t0x%08x\n", v);
  380. if (len > sizeof(buf))
  381. len = sizeof(buf);
  382. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  383. }
  384. static ssize_t write_file_antenna(struct file *file,
  385. const char __user *userbuf,
  386. size_t count, loff_t *ppos)
  387. {
  388. struct ath5k_hw *ah = file->private_data;
  389. unsigned int i;
  390. char buf[20];
  391. count = min_t(size_t, count, sizeof(buf) - 1);
  392. if (copy_from_user(buf, userbuf, count))
  393. return -EFAULT;
  394. buf[count] = '\0';
  395. if (strncmp(buf, "diversity", 9) == 0) {
  396. ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_DEFAULT);
  397. pr_info("debug: enable diversity\n");
  398. } else if (strncmp(buf, "fixed-a", 7) == 0) {
  399. ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_FIXED_A);
  400. pr_info("debug: fixed antenna A\n");
  401. } else if (strncmp(buf, "fixed-b", 7) == 0) {
  402. ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_FIXED_B);
  403. pr_info("debug: fixed antenna B\n");
  404. } else if (strncmp(buf, "clear", 5) == 0) {
  405. for (i = 0; i < ARRAY_SIZE(ah->stats.antenna_rx); i++) {
  406. ah->stats.antenna_rx[i] = 0;
  407. ah->stats.antenna_tx[i] = 0;
  408. }
  409. pr_info("debug: cleared antenna stats\n");
  410. }
  411. return count;
  412. }
  413. static const struct file_operations fops_antenna = {
  414. .read = read_file_antenna,
  415. .write = write_file_antenna,
  416. .open = simple_open,
  417. .owner = THIS_MODULE,
  418. .llseek = default_llseek,
  419. };
  420. /* debugfs: misc */
  421. static ssize_t read_file_misc(struct file *file, char __user *user_buf,
  422. size_t count, loff_t *ppos)
  423. {
  424. struct ath5k_hw *ah = file->private_data;
  425. char buf[700];
  426. unsigned int len = 0;
  427. u32 filt = ath5k_hw_get_rx_filter(ah);
  428. len += snprintf(buf + len, sizeof(buf) - len, "bssid-mask: %pM\n",
  429. ah->bssidmask);
  430. len += snprintf(buf + len, sizeof(buf) - len, "filter-flags: 0x%x ",
  431. filt);
  432. if (filt & AR5K_RX_FILTER_UCAST)
  433. len += snprintf(buf + len, sizeof(buf) - len, " UCAST");
  434. if (filt & AR5K_RX_FILTER_MCAST)
  435. len += snprintf(buf + len, sizeof(buf) - len, " MCAST");
  436. if (filt & AR5K_RX_FILTER_BCAST)
  437. len += snprintf(buf + len, sizeof(buf) - len, " BCAST");
  438. if (filt & AR5K_RX_FILTER_CONTROL)
  439. len += snprintf(buf + len, sizeof(buf) - len, " CONTROL");
  440. if (filt & AR5K_RX_FILTER_BEACON)
  441. len += snprintf(buf + len, sizeof(buf) - len, " BEACON");
  442. if (filt & AR5K_RX_FILTER_PROM)
  443. len += snprintf(buf + len, sizeof(buf) - len, " PROM");
  444. if (filt & AR5K_RX_FILTER_XRPOLL)
  445. len += snprintf(buf + len, sizeof(buf) - len, " XRPOLL");
  446. if (filt & AR5K_RX_FILTER_PROBEREQ)
  447. len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ");
  448. if (filt & AR5K_RX_FILTER_PHYERR_5212)
  449. len += snprintf(buf + len, sizeof(buf) - len, " PHYERR-5212");
  450. if (filt & AR5K_RX_FILTER_RADARERR_5212)
  451. len += snprintf(buf + len, sizeof(buf) - len, " RADARERR-5212");
  452. if (filt & AR5K_RX_FILTER_PHYERR_5211)
  453. snprintf(buf + len, sizeof(buf) - len, " PHYERR-5211");
  454. if (filt & AR5K_RX_FILTER_RADARERR_5211)
  455. len += snprintf(buf + len, sizeof(buf) - len, " RADARERR-5211");
  456. len += snprintf(buf + len, sizeof(buf) - len, "\nopmode: %s (%d)\n",
  457. ath_opmode_to_string(ah->opmode), ah->opmode);
  458. if (len > sizeof(buf))
  459. len = sizeof(buf);
  460. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  461. }
  462. static const struct file_operations fops_misc = {
  463. .read = read_file_misc,
  464. .open = simple_open,
  465. .owner = THIS_MODULE,
  466. };
  467. /* debugfs: frameerrors */
  468. static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf,
  469. size_t count, loff_t *ppos)
  470. {
  471. struct ath5k_hw *ah = file->private_data;
  472. struct ath5k_statistics *st = &ah->stats;
  473. char buf[700];
  474. unsigned int len = 0;
  475. int i;
  476. len += snprintf(buf + len, sizeof(buf) - len,
  477. "RX\n---------------------\n");
  478. len += snprintf(buf + len, sizeof(buf) - len, "CRC\t%u\t(%u%%)\n",
  479. st->rxerr_crc,
  480. st->rx_all_count > 0 ?
  481. st->rxerr_crc * 100 / st->rx_all_count : 0);
  482. len += snprintf(buf + len, sizeof(buf) - len, "PHY\t%u\t(%u%%)\n",
  483. st->rxerr_phy,
  484. st->rx_all_count > 0 ?
  485. st->rxerr_phy * 100 / st->rx_all_count : 0);
  486. for (i = 0; i < 32; i++) {
  487. if (st->rxerr_phy_code[i])
  488. len += snprintf(buf + len, sizeof(buf) - len,
  489. " phy_err[%u]\t%u\n",
  490. i, st->rxerr_phy_code[i]);
  491. }
  492. len += snprintf(buf + len, sizeof(buf) - len, "FIFO\t%u\t(%u%%)\n",
  493. st->rxerr_fifo,
  494. st->rx_all_count > 0 ?
  495. st->rxerr_fifo * 100 / st->rx_all_count : 0);
  496. len += snprintf(buf + len, sizeof(buf) - len, "decrypt\t%u\t(%u%%)\n",
  497. st->rxerr_decrypt,
  498. st->rx_all_count > 0 ?
  499. st->rxerr_decrypt * 100 / st->rx_all_count : 0);
  500. len += snprintf(buf + len, sizeof(buf) - len, "MIC\t%u\t(%u%%)\n",
  501. st->rxerr_mic,
  502. st->rx_all_count > 0 ?
  503. st->rxerr_mic * 100 / st->rx_all_count : 0);
  504. len += snprintf(buf + len, sizeof(buf) - len, "process\t%u\t(%u%%)\n",
  505. st->rxerr_proc,
  506. st->rx_all_count > 0 ?
  507. st->rxerr_proc * 100 / st->rx_all_count : 0);
  508. len += snprintf(buf + len, sizeof(buf) - len, "jumbo\t%u\t(%u%%)\n",
  509. st->rxerr_jumbo,
  510. st->rx_all_count > 0 ?
  511. st->rxerr_jumbo * 100 / st->rx_all_count : 0);
  512. len += snprintf(buf + len, sizeof(buf) - len, "[RX all\t%u]\n",
  513. st->rx_all_count);
  514. len += snprintf(buf + len, sizeof(buf) - len, "RX-all-bytes\t%u\n",
  515. st->rx_bytes_count);
  516. len += snprintf(buf + len, sizeof(buf) - len,
  517. "\nTX\n---------------------\n");
  518. len += snprintf(buf + len, sizeof(buf) - len, "retry\t%u\t(%u%%)\n",
  519. st->txerr_retry,
  520. st->tx_all_count > 0 ?
  521. st->txerr_retry * 100 / st->tx_all_count : 0);
  522. len += snprintf(buf + len, sizeof(buf) - len, "FIFO\t%u\t(%u%%)\n",
  523. st->txerr_fifo,
  524. st->tx_all_count > 0 ?
  525. st->txerr_fifo * 100 / st->tx_all_count : 0);
  526. len += snprintf(buf + len, sizeof(buf) - len, "filter\t%u\t(%u%%)\n",
  527. st->txerr_filt,
  528. st->tx_all_count > 0 ?
  529. st->txerr_filt * 100 / st->tx_all_count : 0);
  530. len += snprintf(buf + len, sizeof(buf) - len, "[TX all\t%u]\n",
  531. st->tx_all_count);
  532. len += snprintf(buf + len, sizeof(buf) - len, "TX-all-bytes\t%u\n",
  533. st->tx_bytes_count);
  534. if (len > sizeof(buf))
  535. len = sizeof(buf);
  536. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  537. }
  538. static ssize_t write_file_frameerrors(struct file *file,
  539. const char __user *userbuf,
  540. size_t count, loff_t *ppos)
  541. {
  542. struct ath5k_hw *ah = file->private_data;
  543. struct ath5k_statistics *st = &ah->stats;
  544. char buf[20];
  545. count = min_t(size_t, count, sizeof(buf) - 1);
  546. if (copy_from_user(buf, userbuf, count))
  547. return -EFAULT;
  548. buf[count] = '\0';
  549. if (strncmp(buf, "clear", 5) == 0) {
  550. st->rxerr_crc = 0;
  551. st->rxerr_phy = 0;
  552. st->rxerr_fifo = 0;
  553. st->rxerr_decrypt = 0;
  554. st->rxerr_mic = 0;
  555. st->rxerr_proc = 0;
  556. st->rxerr_jumbo = 0;
  557. st->rx_all_count = 0;
  558. st->txerr_retry = 0;
  559. st->txerr_fifo = 0;
  560. st->txerr_filt = 0;
  561. st->tx_all_count = 0;
  562. pr_info("debug: cleared frameerrors stats\n");
  563. }
  564. return count;
  565. }
  566. static const struct file_operations fops_frameerrors = {
  567. .read = read_file_frameerrors,
  568. .write = write_file_frameerrors,
  569. .open = simple_open,
  570. .owner = THIS_MODULE,
  571. .llseek = default_llseek,
  572. };
  573. /* debugfs: ani */
  574. static ssize_t read_file_ani(struct file *file, char __user *user_buf,
  575. size_t count, loff_t *ppos)
  576. {
  577. struct ath5k_hw *ah = file->private_data;
  578. struct ath5k_statistics *st = &ah->stats;
  579. struct ath5k_ani_state *as = &ah->ani_state;
  580. char buf[700];
  581. unsigned int len = 0;
  582. len += snprintf(buf + len, sizeof(buf) - len,
  583. "HW has PHY error counters:\t%s\n",
  584. ah->ah_capabilities.cap_has_phyerr_counters ?
  585. "yes" : "no");
  586. len += snprintf(buf + len, sizeof(buf) - len,
  587. "HW max spur immunity level:\t%d\n",
  588. as->max_spur_level);
  589. len += snprintf(buf + len, sizeof(buf) - len,
  590. "\nANI state\n--------------------------------------------\n");
  591. len += snprintf(buf + len, sizeof(buf) - len, "operating mode:\t\t\t");
  592. switch (as->ani_mode) {
  593. case ATH5K_ANI_MODE_OFF:
  594. len += snprintf(buf + len, sizeof(buf) - len, "OFF\n");
  595. break;
  596. case ATH5K_ANI_MODE_MANUAL_LOW:
  597. len += snprintf(buf + len, sizeof(buf) - len,
  598. "MANUAL LOW\n");
  599. break;
  600. case ATH5K_ANI_MODE_MANUAL_HIGH:
  601. len += snprintf(buf + len, sizeof(buf) - len,
  602. "MANUAL HIGH\n");
  603. break;
  604. case ATH5K_ANI_MODE_AUTO:
  605. len += snprintf(buf + len, sizeof(buf) - len, "AUTO\n");
  606. break;
  607. default:
  608. len += snprintf(buf + len, sizeof(buf) - len,
  609. "??? (not good)\n");
  610. break;
  611. }
  612. len += snprintf(buf + len, sizeof(buf) - len,
  613. "noise immunity level:\t\t%d\n",
  614. as->noise_imm_level);
  615. len += snprintf(buf + len, sizeof(buf) - len,
  616. "spur immunity level:\t\t%d\n",
  617. as->spur_level);
  618. len += snprintf(buf + len, sizeof(buf) - len,
  619. "firstep level:\t\t\t%d\n",
  620. as->firstep_level);
  621. len += snprintf(buf + len, sizeof(buf) - len,
  622. "OFDM weak signal detection:\t%s\n",
  623. as->ofdm_weak_sig ? "on" : "off");
  624. len += snprintf(buf + len, sizeof(buf) - len,
  625. "CCK weak signal detection:\t%s\n",
  626. as->cck_weak_sig ? "on" : "off");
  627. len += snprintf(buf + len, sizeof(buf) - len,
  628. "\nMIB INTERRUPTS:\t\t%u\n",
  629. st->mib_intr);
  630. len += snprintf(buf + len, sizeof(buf) - len,
  631. "beacon RSSI average:\t%d\n",
  632. (int)ewma_read(&ah->ah_beacon_rssi_avg));
  633. #define CC_PRINT(_struct, _field) \
  634. _struct._field, \
  635. _struct.cycles > 0 ? \
  636. _struct._field * 100 / _struct.cycles : 0
  637. len += snprintf(buf + len, sizeof(buf) - len,
  638. "profcnt tx\t\t%u\t(%d%%)\n",
  639. CC_PRINT(as->last_cc, tx_frame));
  640. len += snprintf(buf + len, sizeof(buf) - len,
  641. "profcnt rx\t\t%u\t(%d%%)\n",
  642. CC_PRINT(as->last_cc, rx_frame));
  643. len += snprintf(buf + len, sizeof(buf) - len,
  644. "profcnt busy\t\t%u\t(%d%%)\n",
  645. CC_PRINT(as->last_cc, rx_busy));
  646. #undef CC_PRINT
  647. len += snprintf(buf + len, sizeof(buf) - len, "profcnt cycles\t\t%u\n",
  648. as->last_cc.cycles);
  649. len += snprintf(buf + len, sizeof(buf) - len,
  650. "listen time\t\t%d\tlast: %d\n",
  651. as->listen_time, as->last_listen);
  652. len += snprintf(buf + len, sizeof(buf) - len,
  653. "OFDM errors\t\t%u\tlast: %u\tsum: %u\n",
  654. as->ofdm_errors, as->last_ofdm_errors,
  655. as->sum_ofdm_errors);
  656. len += snprintf(buf + len, sizeof(buf) - len,
  657. "CCK errors\t\t%u\tlast: %u\tsum: %u\n",
  658. as->cck_errors, as->last_cck_errors,
  659. as->sum_cck_errors);
  660. len += snprintf(buf + len, sizeof(buf) - len,
  661. "AR5K_PHYERR_CNT1\t%x\t(=%d)\n",
  662. ath5k_hw_reg_read(ah, AR5K_PHYERR_CNT1),
  663. ATH5K_ANI_OFDM_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
  664. ath5k_hw_reg_read(ah, AR5K_PHYERR_CNT1)));
  665. len += snprintf(buf + len, sizeof(buf) - len,
  666. "AR5K_PHYERR_CNT2\t%x\t(=%d)\n",
  667. ath5k_hw_reg_read(ah, AR5K_PHYERR_CNT2),
  668. ATH5K_ANI_CCK_TRIG_HIGH - (ATH5K_PHYERR_CNT_MAX -
  669. ath5k_hw_reg_read(ah, AR5K_PHYERR_CNT2)));
  670. if (len > sizeof(buf))
  671. len = sizeof(buf);
  672. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  673. }
  674. static ssize_t write_file_ani(struct file *file,
  675. const char __user *userbuf,
  676. size_t count, loff_t *ppos)
  677. {
  678. struct ath5k_hw *ah = file->private_data;
  679. char buf[20];
  680. count = min_t(size_t, count, sizeof(buf) - 1);
  681. if (copy_from_user(buf, userbuf, count))
  682. return -EFAULT;
  683. buf[count] = '\0';
  684. if (strncmp(buf, "sens-low", 8) == 0) {
  685. ath5k_ani_init(ah, ATH5K_ANI_MODE_MANUAL_HIGH);
  686. } else if (strncmp(buf, "sens-high", 9) == 0) {
  687. ath5k_ani_init(ah, ATH5K_ANI_MODE_MANUAL_LOW);
  688. } else if (strncmp(buf, "ani-off", 7) == 0) {
  689. ath5k_ani_init(ah, ATH5K_ANI_MODE_OFF);
  690. } else if (strncmp(buf, "ani-on", 6) == 0) {
  691. ath5k_ani_init(ah, ATH5K_ANI_MODE_AUTO);
  692. } else if (strncmp(buf, "noise-low", 9) == 0) {
  693. ath5k_ani_set_noise_immunity_level(ah, 0);
  694. } else if (strncmp(buf, "noise-high", 10) == 0) {
  695. ath5k_ani_set_noise_immunity_level(ah,
  696. ATH5K_ANI_MAX_NOISE_IMM_LVL);
  697. } else if (strncmp(buf, "spur-low", 8) == 0) {
  698. ath5k_ani_set_spur_immunity_level(ah, 0);
  699. } else if (strncmp(buf, "spur-high", 9) == 0) {
  700. ath5k_ani_set_spur_immunity_level(ah,
  701. ah->ani_state.max_spur_level);
  702. } else if (strncmp(buf, "fir-low", 7) == 0) {
  703. ath5k_ani_set_firstep_level(ah, 0);
  704. } else if (strncmp(buf, "fir-high", 8) == 0) {
  705. ath5k_ani_set_firstep_level(ah, ATH5K_ANI_MAX_FIRSTEP_LVL);
  706. } else if (strncmp(buf, "ofdm-off", 8) == 0) {
  707. ath5k_ani_set_ofdm_weak_signal_detection(ah, false);
  708. } else if (strncmp(buf, "ofdm-on", 7) == 0) {
  709. ath5k_ani_set_ofdm_weak_signal_detection(ah, true);
  710. } else if (strncmp(buf, "cck-off", 7) == 0) {
  711. ath5k_ani_set_cck_weak_signal_detection(ah, false);
  712. } else if (strncmp(buf, "cck-on", 6) == 0) {
  713. ath5k_ani_set_cck_weak_signal_detection(ah, true);
  714. }
  715. return count;
  716. }
  717. static const struct file_operations fops_ani = {
  718. .read = read_file_ani,
  719. .write = write_file_ani,
  720. .open = simple_open,
  721. .owner = THIS_MODULE,
  722. .llseek = default_llseek,
  723. };
  724. /* debugfs: queues etc */
  725. static ssize_t read_file_queue(struct file *file, char __user *user_buf,
  726. size_t count, loff_t *ppos)
  727. {
  728. struct ath5k_hw *ah = file->private_data;
  729. char buf[700];
  730. unsigned int len = 0;
  731. struct ath5k_txq *txq;
  732. struct ath5k_buf *bf, *bf0;
  733. int i, n;
  734. len += snprintf(buf + len, sizeof(buf) - len,
  735. "available txbuffers: %d\n", ah->txbuf_len);
  736. for (i = 0; i < ARRAY_SIZE(ah->txqs); i++) {
  737. txq = &ah->txqs[i];
  738. len += snprintf(buf + len, sizeof(buf) - len,
  739. "%02d: %ssetup\n", i, txq->setup ? "" : "not ");
  740. if (!txq->setup)
  741. continue;
  742. n = 0;
  743. spin_lock_bh(&txq->lock);
  744. list_for_each_entry_safe(bf, bf0, &txq->q, list)
  745. n++;
  746. spin_unlock_bh(&txq->lock);
  747. len += snprintf(buf + len, sizeof(buf) - len,
  748. " len: %d bufs: %d\n", txq->txq_len, n);
  749. len += snprintf(buf + len, sizeof(buf) - len,
  750. " stuck: %d\n", txq->txq_stuck);
  751. }
  752. if (len > sizeof(buf))
  753. len = sizeof(buf);
  754. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  755. }
  756. static ssize_t write_file_queue(struct file *file,
  757. const char __user *userbuf,
  758. size_t count, loff_t *ppos)
  759. {
  760. struct ath5k_hw *ah = file->private_data;
  761. char buf[20];
  762. count = min_t(size_t, count, sizeof(buf) - 1);
  763. if (copy_from_user(buf, userbuf, count))
  764. return -EFAULT;
  765. buf[count] = '\0';
  766. if (strncmp(buf, "start", 5) == 0)
  767. ieee80211_wake_queues(ah->hw);
  768. else if (strncmp(buf, "stop", 4) == 0)
  769. ieee80211_stop_queues(ah->hw);
  770. return count;
  771. }
  772. static const struct file_operations fops_queue = {
  773. .read = read_file_queue,
  774. .write = write_file_queue,
  775. .open = simple_open,
  776. .owner = THIS_MODULE,
  777. .llseek = default_llseek,
  778. };
  779. void
  780. ath5k_debug_init_device(struct ath5k_hw *ah)
  781. {
  782. struct dentry *phydir;
  783. ah->debug.level = ath5k_debug;
  784. phydir = debugfs_create_dir("ath5k", ah->hw->wiphy->debugfsdir);
  785. if (!phydir)
  786. return;
  787. debugfs_create_file("debug", S_IWUSR | S_IRUSR, phydir, ah,
  788. &fops_debug);
  789. debugfs_create_file("registers", S_IRUSR, phydir, ah, &fops_registers);
  790. debugfs_create_file("beacon", S_IWUSR | S_IRUSR, phydir, ah,
  791. &fops_beacon);
  792. debugfs_create_file("reset", S_IWUSR, phydir, ah, &fops_reset);
  793. debugfs_create_file("antenna", S_IWUSR | S_IRUSR, phydir, ah,
  794. &fops_antenna);
  795. debugfs_create_file("misc", S_IRUSR, phydir, ah, &fops_misc);
  796. debugfs_create_file("frameerrors", S_IWUSR | S_IRUSR, phydir, ah,
  797. &fops_frameerrors);
  798. debugfs_create_file("ani", S_IWUSR | S_IRUSR, phydir, ah, &fops_ani);
  799. debugfs_create_file("queue", S_IWUSR | S_IRUSR, phydir, ah,
  800. &fops_queue);
  801. debugfs_create_bool("32khz_clock", S_IWUSR | S_IRUSR, phydir,
  802. &ah->ah_use_32khz_clock);
  803. }
  804. /* functions used in other places */
  805. void
  806. ath5k_debug_dump_bands(struct ath5k_hw *ah)
  807. {
  808. unsigned int b, i;
  809. if (likely(!(ah->debug.level & ATH5K_DEBUG_DUMPBANDS)))
  810. return;
  811. BUG_ON(!ah->sbands);
  812. for (b = 0; b < IEEE80211_NUM_BANDS; b++) {
  813. struct ieee80211_supported_band *band = &ah->sbands[b];
  814. char bname[6];
  815. switch (band->band) {
  816. case IEEE80211_BAND_2GHZ:
  817. strcpy(bname, "2 GHz");
  818. break;
  819. case IEEE80211_BAND_5GHZ:
  820. strcpy(bname, "5 GHz");
  821. break;
  822. default:
  823. printk(KERN_DEBUG "Band not supported: %d\n",
  824. band->band);
  825. return;
  826. }
  827. printk(KERN_DEBUG "Band %s: channels %d, rates %d\n", bname,
  828. band->n_channels, band->n_bitrates);
  829. printk(KERN_DEBUG " channels:\n");
  830. for (i = 0; i < band->n_channels; i++)
  831. printk(KERN_DEBUG " %3d %d %.4x %.4x\n",
  832. ieee80211_frequency_to_channel(
  833. band->channels[i].center_freq),
  834. band->channels[i].center_freq,
  835. band->channels[i].hw_value,
  836. band->channels[i].flags);
  837. printk(KERN_DEBUG " rates:\n");
  838. for (i = 0; i < band->n_bitrates; i++)
  839. printk(KERN_DEBUG " %4d %.4x %.4x %.4x\n",
  840. band->bitrates[i].bitrate,
  841. band->bitrates[i].hw_value,
  842. band->bitrates[i].flags,
  843. band->bitrates[i].hw_value_short);
  844. }
  845. }
  846. static inline void
  847. ath5k_debug_printrxbuf(struct ath5k_buf *bf, int done,
  848. struct ath5k_rx_status *rs)
  849. {
  850. struct ath5k_desc *ds = bf->desc;
  851. struct ath5k_hw_all_rx_desc *rd = &ds->ud.ds_rx;
  852. printk(KERN_DEBUG "R (%p %llx) %08x %08x %08x %08x %08x %08x %c\n",
  853. ds, (unsigned long long)bf->daddr,
  854. ds->ds_link, ds->ds_data,
  855. rd->rx_ctl.rx_control_0, rd->rx_ctl.rx_control_1,
  856. rd->rx_stat.rx_status_0, rd->rx_stat.rx_status_1,
  857. !done ? ' ' : (rs->rs_status == 0) ? '*' : '!');
  858. }
  859. void
  860. ath5k_debug_printrxbuffs(struct ath5k_hw *ah)
  861. {
  862. struct ath5k_desc *ds;
  863. struct ath5k_buf *bf;
  864. struct ath5k_rx_status rs = {};
  865. int status;
  866. if (likely(!(ah->debug.level & ATH5K_DEBUG_DESC)))
  867. return;
  868. printk(KERN_DEBUG "rxdp %x, rxlink %p\n",
  869. ath5k_hw_get_rxdp(ah), ah->rxlink);
  870. spin_lock_bh(&ah->rxbuflock);
  871. list_for_each_entry(bf, &ah->rxbuf, list) {
  872. ds = bf->desc;
  873. status = ah->ah_proc_rx_desc(ah, ds, &rs);
  874. if (!status)
  875. ath5k_debug_printrxbuf(bf, status == 0, &rs);
  876. }
  877. spin_unlock_bh(&ah->rxbuflock);
  878. }
  879. void
  880. ath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf)
  881. {
  882. struct ath5k_desc *ds = bf->desc;
  883. struct ath5k_hw_5212_tx_desc *td = &ds->ud.ds_tx5212;
  884. struct ath5k_tx_status ts = {};
  885. int done;
  886. if (likely(!(ah->debug.level & ATH5K_DEBUG_DESC)))
  887. return;
  888. done = ah->ah_proc_tx_desc(ah, bf->desc, &ts);
  889. printk(KERN_DEBUG "T (%p %llx) %08x %08x %08x %08x %08x %08x %08x "
  890. "%08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link,
  891. ds->ds_data, td->tx_ctl.tx_control_0, td->tx_ctl.tx_control_1,
  892. td->tx_ctl.tx_control_2, td->tx_ctl.tx_control_3,
  893. td->tx_stat.tx_status_0, td->tx_stat.tx_status_1,
  894. done ? ' ' : (ts.ts_status == 0) ? '*' : '!');
  895. }