moal_debug.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. /** @file moal_debug.c
  2. *
  3. * @brief This file contains functions for debug proc file.
  4. *
  5. * Copyright (C) 2008-2014, Marvell International Ltd.
  6. *
  7. * This software file (the "File") is distributed by Marvell International
  8. * Ltd. under the terms of the GNU General Public License Version 2, June 1991
  9. * (the "License"). You may use, redistribute and/or modify this File in
  10. * accordance with the terms and conditions of the License, a copy of which
  11. * is available by writing to the Free Software Foundation, Inc.,
  12. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
  13. * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
  14. *
  15. * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
  16. * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
  17. * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
  18. * this warranty disclaimer.
  19. *
  20. */
  21. /********************************************************
  22. Change log:
  23. 11/03/2008: initial version
  24. ********************************************************/
  25. #include "moal_main.h"
  26. /********************************************************
  27. Global Variables
  28. ********************************************************/
  29. /** MLAN debug info */
  30. extern mlan_debug_info info;
  31. /********************************************************
  32. Local Variables
  33. ********************************************************/
  34. #ifdef CONFIG_PROC_FS
  35. /** Get info item size */
  36. #define item_size(n) (sizeof(info.n))
  37. /** Get info item address */
  38. #define item_addr(n) ((t_ptr) &(info.n))
  39. /** Get moal_private member size */
  40. #define item_priv_size(n) (sizeof((moal_private *)0)->n)
  41. /** Get moal_private member address */
  42. #define item_priv_addr(n) ((t_ptr) &((moal_private *)0)->n)
  43. /** Get moal_handle member size */
  44. #define item_handle_size(n) (sizeof((moal_handle *)0)->n)
  45. /** Get moal_handle member address */
  46. #define item_handle_addr(n) ((t_ptr) &((moal_handle *)0)->n)
  47. #ifdef STA_SUPPORT
  48. static struct debug_data items[] = {
  49. #ifdef DEBUG_LEVEL1
  50. {"drvdbg", sizeof(drvdbg), (t_ptr) & drvdbg}
  51. ,
  52. #endif
  53. {"wmm_ac_vo", item_size(wmm_ac_vo), item_addr(wmm_ac_vo)}
  54. ,
  55. {"wmm_ac_vi", item_size(wmm_ac_vi), item_addr(wmm_ac_vi)}
  56. ,
  57. {"wmm_ac_be", item_size(wmm_ac_be), item_addr(wmm_ac_be)}
  58. ,
  59. {"wmm_ac_bk", item_size(wmm_ac_bk), item_addr(wmm_ac_bk)}
  60. ,
  61. {"max_tx_buf_size", item_size(max_tx_buf_size),
  62. item_addr(max_tx_buf_size)}
  63. ,
  64. {"tx_buf_size", item_size(tx_buf_size), item_addr(tx_buf_size)}
  65. ,
  66. {"curr_tx_buf_size", item_size(curr_tx_buf_size),
  67. item_addr(curr_tx_buf_size)}
  68. ,
  69. {"ps_mode", item_size(ps_mode), item_addr(ps_mode)}
  70. ,
  71. {"ps_state", item_size(ps_state), item_addr(ps_state)}
  72. ,
  73. {"is_deep_sleep", item_size(is_deep_sleep), item_addr(is_deep_sleep)}
  74. ,
  75. {"wakeup_dev_req", item_size(pm_wakeup_card_req),
  76. item_addr(pm_wakeup_card_req)}
  77. ,
  78. {"wakeup_tries", item_size(pm_wakeup_fw_try),
  79. item_addr(pm_wakeup_fw_try)}
  80. ,
  81. {"hs_configured", item_size(is_hs_configured),
  82. item_addr(is_hs_configured)}
  83. ,
  84. {"hs_activated", item_size(hs_activated), item_addr(hs_activated)}
  85. ,
  86. {"rx_pkts_queued", item_size(rx_pkts_queued), item_addr(rx_pkts_queued)}
  87. ,
  88. {"tx_pkts_queued", item_size(tx_pkts_queued), item_addr(tx_pkts_queued)}
  89. ,
  90. {"pps_uapsd_mode", item_size(pps_uapsd_mode), item_addr(pps_uapsd_mode)}
  91. ,
  92. {"sleep_pd", item_size(sleep_pd), item_addr(sleep_pd)}
  93. ,
  94. {"qos_cfg", item_size(qos_cfg), item_addr(qos_cfg)}
  95. ,
  96. {"tx_lock_flag", item_size(tx_lock_flag), item_addr(tx_lock_flag)}
  97. ,
  98. {"port_open", item_size(port_open), item_addr(port_open)}
  99. ,
  100. {"bypass_pkt_count", item_size(bypass_pkt_count),
  101. item_addr(bypass_pkt_count)}
  102. ,
  103. {"scan_processing", item_size(scan_processing),
  104. item_addr(scan_processing)}
  105. ,
  106. {"num_tx_timeout", item_size(num_tx_timeout), item_addr(num_tx_timeout)}
  107. ,
  108. {"num_cmd_timeout", item_size(num_cmd_timeout),
  109. item_addr(num_cmd_timeout)}
  110. ,
  111. {"timeout_cmd_id", item_size(timeout_cmd_id), item_addr(timeout_cmd_id)}
  112. ,
  113. {"timeout_cmd_act", item_size(timeout_cmd_act),
  114. item_addr(timeout_cmd_act)}
  115. ,
  116. {"last_cmd_id", item_size(last_cmd_id), item_addr(last_cmd_id)}
  117. ,
  118. {"last_cmd_act", item_size(last_cmd_act), item_addr(last_cmd_act)}
  119. ,
  120. {"last_cmd_index", item_size(last_cmd_index), item_addr(last_cmd_index)}
  121. ,
  122. {"last_cmd_resp_id", item_size(last_cmd_resp_id),
  123. item_addr(last_cmd_resp_id)}
  124. ,
  125. {"last_cmd_resp_index", item_size(last_cmd_resp_index),
  126. item_addr(last_cmd_resp_index)}
  127. ,
  128. {"last_event", item_size(last_event), item_addr(last_event)}
  129. ,
  130. {"last_event_index", item_size(last_event_index),
  131. item_addr(last_event_index)}
  132. ,
  133. {"num_no_cmd_node", item_size(num_no_cmd_node),
  134. item_addr(num_no_cmd_node)}
  135. ,
  136. {"num_cmd_h2c_fail", item_size(num_cmd_host_to_card_failure),
  137. item_addr(num_cmd_host_to_card_failure)}
  138. ,
  139. {"num_cmd_sleep_cfm_fail",
  140. item_size(num_cmd_sleep_cfm_host_to_card_failure),
  141. item_addr(num_cmd_sleep_cfm_host_to_card_failure)}
  142. ,
  143. {"num_tx_h2c_fail", item_size(num_tx_host_to_card_failure),
  144. item_addr(num_tx_host_to_card_failure)}
  145. ,
  146. {"num_cmdevt_c2h_fail", item_size(num_cmdevt_card_to_host_failure),
  147. item_addr(num_cmdevt_card_to_host_failure)}
  148. ,
  149. {"num_rx_c2h_fail", item_size(num_rx_card_to_host_failure),
  150. item_addr(num_rx_card_to_host_failure)}
  151. ,
  152. {"num_int_read_fail", item_size(num_int_read_failure),
  153. item_addr(num_int_read_failure)}
  154. ,
  155. {"last_int_status", item_size(last_int_status),
  156. item_addr(last_int_status)}
  157. ,
  158. #ifdef SDIO_MULTI_PORT_TX_AGGR
  159. {"mpa_sent_last_pkt", item_size(mpa_sent_last_pkt),
  160. item_addr(mpa_sent_last_pkt)}
  161. ,
  162. {"mpa_sent_no_ports", item_size(mpa_sent_no_ports),
  163. item_addr(mpa_sent_no_ports)}
  164. ,
  165. #endif
  166. {"num_evt_deauth", item_size(num_event_deauth),
  167. item_addr(num_event_deauth)}
  168. ,
  169. {"num_evt_disassoc", item_size(num_event_disassoc),
  170. item_addr(num_event_disassoc)}
  171. ,
  172. {"num_evt_link_lost", item_size(num_event_link_lost),
  173. item_addr(num_event_link_lost)}
  174. ,
  175. {"num_cmd_deauth", item_size(num_cmd_deauth), item_addr(num_cmd_deauth)}
  176. ,
  177. {"num_cmd_assoc_ok", item_size(num_cmd_assoc_success),
  178. item_addr(num_cmd_assoc_success)}
  179. ,
  180. {"num_cmd_assoc_fail", item_size(num_cmd_assoc_failure),
  181. item_addr(num_cmd_assoc_failure)}
  182. ,
  183. {"cmd_sent", item_size(cmd_sent), item_addr(cmd_sent)}
  184. ,
  185. {"data_sent", item_size(data_sent), item_addr(data_sent)}
  186. ,
  187. {"mp_rd_bitmap", item_size(mp_rd_bitmap), item_addr(mp_rd_bitmap)}
  188. ,
  189. {"curr_rd_port", item_size(curr_rd_port), item_addr(curr_rd_port)}
  190. ,
  191. {"mp_wr_bitmap", item_size(mp_wr_bitmap), item_addr(mp_wr_bitmap)}
  192. ,
  193. {"curr_wr_port", item_size(curr_wr_port), item_addr(curr_wr_port)}
  194. ,
  195. {"cmd_resp_received", item_size(cmd_resp_received),
  196. item_addr(cmd_resp_received)}
  197. ,
  198. {"event_received", item_size(event_received), item_addr(event_received)}
  199. ,
  200. {"ioctl_pending", item_handle_size(ioctl_pending),
  201. item_handle_addr(ioctl_pending)}
  202. ,
  203. {"tx_pending", item_handle_size(tx_pending),
  204. item_handle_addr(tx_pending)}
  205. ,
  206. {"rx_pending", item_handle_size(rx_pending),
  207. item_handle_addr(rx_pending)}
  208. ,
  209. {"lock_count", item_handle_size(lock_count),
  210. item_handle_addr(lock_count)}
  211. ,
  212. {"malloc_count", item_handle_size(malloc_count),
  213. item_handle_addr(malloc_count)}
  214. ,
  215. {"vmalloc_count", item_handle_size(vmalloc_count),
  216. item_handle_addr(vmalloc_count)}
  217. ,
  218. {"mbufalloc_count", item_handle_size(mbufalloc_count),
  219. item_handle_addr(mbufalloc_count)}
  220. ,
  221. {"main_state", item_handle_size(main_state),
  222. item_handle_addr(main_state)}
  223. ,
  224. {"driver_state", item_handle_size(driver_state),
  225. item_handle_addr(driver_state)}
  226. ,
  227. #ifdef SDIO_MMC_DEBUG
  228. {"sdiocmd53w", item_handle_size(cmd53w), item_handle_addr(cmd53w)}
  229. ,
  230. {"sdiocmd53r", item_handle_size(cmd53r), item_handle_addr(cmd53r)}
  231. ,
  232. #endif
  233. #if defined(SDIO_SUSPEND_RESUME)
  234. {"hs_skip_count", item_handle_size(hs_skip_count),
  235. item_handle_addr(hs_skip_count)}
  236. ,
  237. {"hs_force_count", item_handle_size(hs_force_count),
  238. item_handle_addr(hs_force_count)}
  239. ,
  240. #endif
  241. };
  242. #endif
  243. #ifdef UAP_SUPPORT
  244. static struct debug_data uap_items[] = {
  245. #ifdef DEBUG_LEVEL1
  246. {"drvdbg", sizeof(drvdbg), (t_ptr) & drvdbg}
  247. ,
  248. #endif
  249. {"wmm_ac_vo", item_size(wmm_ac_vo), item_addr(wmm_ac_vo)}
  250. ,
  251. {"wmm_ac_vi", item_size(wmm_ac_vi), item_addr(wmm_ac_vi)}
  252. ,
  253. {"wmm_ac_be", item_size(wmm_ac_be), item_addr(wmm_ac_be)}
  254. ,
  255. {"wmm_ac_bk", item_size(wmm_ac_bk), item_addr(wmm_ac_bk)}
  256. ,
  257. {"max_tx_buf_size", item_size(max_tx_buf_size),
  258. item_addr(max_tx_buf_size)}
  259. ,
  260. {"tx_buf_size", item_size(tx_buf_size), item_addr(tx_buf_size)}
  261. ,
  262. {"curr_tx_buf_size", item_size(curr_tx_buf_size),
  263. item_addr(curr_tx_buf_size)}
  264. ,
  265. {"ps_mode", item_size(ps_mode), item_addr(ps_mode)}
  266. ,
  267. {"ps_state", item_size(ps_state), item_addr(ps_state)}
  268. ,
  269. {"wakeup_dev_req", item_size(pm_wakeup_card_req),
  270. item_addr(pm_wakeup_card_req)}
  271. ,
  272. {"wakeup_tries", item_size(pm_wakeup_fw_try),
  273. item_addr(pm_wakeup_fw_try)}
  274. ,
  275. {"hs_configured", item_size(is_hs_configured),
  276. item_addr(is_hs_configured)}
  277. ,
  278. {"hs_activated", item_size(hs_activated), item_addr(hs_activated)}
  279. ,
  280. {"rx_pkts_queued", item_size(rx_pkts_queued), item_addr(rx_pkts_queued)}
  281. ,
  282. {"tx_pkts_queued", item_size(tx_pkts_queued), item_addr(tx_pkts_queued)}
  283. ,
  284. {"bypass_pkt_count", item_size(bypass_pkt_count),
  285. item_addr(bypass_pkt_count)}
  286. ,
  287. {"num_bridge_pkts", item_size(num_bridge_pkts),
  288. item_addr(num_bridge_pkts)}
  289. ,
  290. {"num_drop_pkts", item_size(num_drop_pkts), item_addr(num_drop_pkts)}
  291. ,
  292. {"num_tx_timeout", item_size(num_tx_timeout), item_addr(num_tx_timeout)}
  293. ,
  294. {"num_cmd_timeout", item_size(num_cmd_timeout),
  295. item_addr(num_cmd_timeout)}
  296. ,
  297. {"timeout_cmd_id", item_size(timeout_cmd_id), item_addr(timeout_cmd_id)}
  298. ,
  299. {"timeout_cmd_act", item_size(timeout_cmd_act),
  300. item_addr(timeout_cmd_act)}
  301. ,
  302. {"last_cmd_id", item_size(last_cmd_id), item_addr(last_cmd_id)}
  303. ,
  304. {"last_cmd_act", item_size(last_cmd_act), item_addr(last_cmd_act)}
  305. ,
  306. {"last_cmd_index", item_size(last_cmd_index), item_addr(last_cmd_index)}
  307. ,
  308. {"last_cmd_resp_id", item_size(last_cmd_resp_id),
  309. item_addr(last_cmd_resp_id)}
  310. ,
  311. {"last_cmd_resp_index", item_size(last_cmd_resp_index),
  312. item_addr(last_cmd_resp_index)}
  313. ,
  314. {"last_event", item_size(last_event), item_addr(last_event)}
  315. ,
  316. {"last_event_index", item_size(last_event_index),
  317. item_addr(last_event_index)}
  318. ,
  319. {"num_no_cmd_node", item_size(num_no_cmd_node),
  320. item_addr(num_no_cmd_node)}
  321. ,
  322. {"num_cmd_h2c_fail", item_size(num_cmd_host_to_card_failure),
  323. item_addr(num_cmd_host_to_card_failure)}
  324. ,
  325. {"num_cmd_sleep_cfm_fail",
  326. item_size(num_cmd_sleep_cfm_host_to_card_failure),
  327. item_addr(num_cmd_sleep_cfm_host_to_card_failure)}
  328. ,
  329. {"num_tx_h2c_fail", item_size(num_tx_host_to_card_failure),
  330. item_addr(num_tx_host_to_card_failure)}
  331. ,
  332. {"num_cmdevt_c2h_fail", item_size(num_cmdevt_card_to_host_failure),
  333. item_addr(num_cmdevt_card_to_host_failure)}
  334. ,
  335. {"num_rx_c2h_fail", item_size(num_rx_card_to_host_failure),
  336. item_addr(num_rx_card_to_host_failure)}
  337. ,
  338. {"num_int_read_fail", item_size(num_int_read_failure),
  339. item_addr(num_int_read_failure)}
  340. ,
  341. {"last_int_status", item_size(last_int_status),
  342. item_addr(last_int_status)}
  343. ,
  344. #ifdef SDIO_MULTI_PORT_TX_AGGR
  345. {"mpa_sent_last_pkt", item_size(mpa_sent_last_pkt),
  346. item_addr(mpa_sent_last_pkt)}
  347. ,
  348. {"mpa_sent_no_ports", item_size(mpa_sent_no_ports),
  349. item_addr(mpa_sent_no_ports)}
  350. ,
  351. #endif
  352. {"cmd_sent", item_size(cmd_sent), item_addr(cmd_sent)}
  353. ,
  354. {"data_sent", item_size(data_sent), item_addr(data_sent)}
  355. ,
  356. {"mp_rd_bitmap", item_size(mp_rd_bitmap), item_addr(mp_rd_bitmap)}
  357. ,
  358. {"curr_rd_port", item_size(curr_rd_port), item_addr(curr_rd_port)}
  359. ,
  360. {"mp_wr_bitmap", item_size(mp_wr_bitmap), item_addr(mp_wr_bitmap)}
  361. ,
  362. {"curr_wr_port", item_size(curr_wr_port), item_addr(curr_wr_port)}
  363. ,
  364. {"cmd_resp_received", item_size(cmd_resp_received),
  365. item_addr(cmd_resp_received)}
  366. ,
  367. {"event_received", item_size(event_received), item_addr(event_received)}
  368. ,
  369. {"ioctl_pending", item_handle_size(ioctl_pending),
  370. item_handle_addr(ioctl_pending)}
  371. ,
  372. {"tx_pending", item_handle_size(tx_pending),
  373. item_handle_addr(tx_pending)}
  374. ,
  375. {"rx_pending", item_handle_size(rx_pending),
  376. item_handle_addr(rx_pending)}
  377. ,
  378. {"lock_count", item_handle_size(lock_count),
  379. item_handle_addr(lock_count)}
  380. ,
  381. {"malloc_count", item_handle_size(malloc_count),
  382. item_handle_addr(malloc_count)}
  383. ,
  384. {"vmalloc_count", item_handle_size(vmalloc_count),
  385. item_handle_addr(vmalloc_count)}
  386. ,
  387. {"mbufalloc_count", item_handle_size(mbufalloc_count),
  388. item_handle_addr(mbufalloc_count)}
  389. ,
  390. {"main_state", item_handle_size(main_state),
  391. item_handle_addr(main_state)}
  392. ,
  393. {"driver_state", item_handle_size(driver_state),
  394. item_handle_addr(driver_state)}
  395. ,
  396. #ifdef SDIO_MMC_DEBUG
  397. {"sdiocmd53w", item_handle_size(cmd53w), item_handle_addr(cmd53w)}
  398. ,
  399. {"sdiocmd53r", item_handle_size(cmd53r), item_handle_addr(cmd53r)}
  400. ,
  401. #endif
  402. #if defined(SDIO_SUSPEND_RESUME)
  403. {"hs_skip_count", item_handle_size(hs_skip_count),
  404. item_handle_addr(hs_skip_count)}
  405. ,
  406. {"hs_force_count", item_handle_size(hs_force_count),
  407. item_handle_addr(hs_force_count)}
  408. ,
  409. #endif
  410. };
  411. #endif /* UAP_SUPPORT */
  412. /********************************************************
  413. Local Functions
  414. ********************************************************/
  415. /**
  416. * @brief Proc read function
  417. *
  418. * @param sfp pointer to seq_file structure
  419. * @param data
  420. *
  421. * @return Number of output data or MLAN_STATUS_FAILURE
  422. */
  423. static int
  424. woal_debug_read(struct seq_file *sfp, void *data)
  425. {
  426. int val = 0;
  427. unsigned int i;
  428. #ifdef SDIO_MULTI_PORT_TX_AGGR
  429. unsigned int j;
  430. #endif
  431. struct debug_data_priv *items_priv =
  432. (struct debug_data_priv *)sfp->private;
  433. struct debug_data *d = items_priv->items;
  434. moal_private *priv = items_priv->priv;
  435. ENTER();
  436. if (priv == NULL) {
  437. LEAVE();
  438. return -EFAULT;
  439. }
  440. if (MODULE_GET == 0) {
  441. LEAVE();
  442. return -EFAULT;
  443. }
  444. priv->phandle->driver_state = woal_check_driver_status(priv->phandle);
  445. /* Get debug information */
  446. if (woal_get_debug_info(priv, MOAL_PROC_WAIT, &info))
  447. goto exit;
  448. for (i = 0; i < (unsigned int)items_priv->num_of_items; i++) {
  449. if (d[i].size == 1)
  450. val = *((t_u8 *) d[i].addr);
  451. else if (d[i].size == 2)
  452. val = *((t_u16 *) d[i].addr);
  453. else if (d[i].size == 4)
  454. val = *((t_ptr *) d[i].addr);
  455. else {
  456. unsigned int j;
  457. seq_printf(sfp, "%s=", d[i].name);
  458. for (j = 0; j < d[i].size; j += 2) {
  459. val = *(t_u16 *) (d[i].addr + j);
  460. seq_printf(sfp, "0x%x ", val);
  461. }
  462. seq_printf(sfp, "\n");
  463. continue;
  464. }
  465. if (strstr(d[i].name, "id")
  466. || strstr(d[i].name, "bitmap")
  467. )
  468. seq_printf(sfp, "%s=0x%x\n", d[i].name, val);
  469. else
  470. seq_printf(sfp, "%s=%d\n", d[i].name, val);
  471. }
  472. #ifdef SDIO_MULTI_PORT_TX_AGGR
  473. seq_printf(sfp, "last_recv_wr_bitmap=0x%x last_mp_index=%d\n",
  474. info.last_recv_wr_bitmap, info.last_mp_index);
  475. for (i = 0; i < SDIO_MP_DBG_NUM; i++) {
  476. seq_printf(sfp,
  477. "mp_wr_bitmap: 0x%x mp_wr_ports=0x%x len=%d curr_wr_port=0x%x\n",
  478. info.last_mp_wr_bitmap[i], info.last_mp_wr_ports[i],
  479. info.last_mp_wr_len[i], info.last_curr_wr_port[i]);
  480. for (j = 0; j < SDIO_MP_AGGR_DEF_PKT_LIMIT; j++) {
  481. seq_printf(sfp, "0x%02x ",
  482. info.last_mp_wr_info[i *
  483. SDIO_MP_AGGR_DEF_PKT_LIMIT
  484. + j]);
  485. }
  486. seq_printf(sfp, "\n");
  487. }
  488. seq_printf(sfp, "SDIO MPA Tx: ");
  489. for (i = 0; i < SDIO_MP_AGGR_DEF_PKT_LIMIT; i++)
  490. seq_printf(sfp, "%d ", info.mpa_tx_count[i]);
  491. seq_printf(sfp, "\n");
  492. #endif
  493. #ifdef SDIO_MULTI_PORT_RX_AGGR
  494. seq_printf(sfp, "SDIO MPA Rx: ");
  495. for (i = 0; i < SDIO_MP_AGGR_DEF_PKT_LIMIT; i++)
  496. seq_printf(sfp, "%d ", info.mpa_rx_count[i]);
  497. seq_printf(sfp, "\n");
  498. #endif
  499. seq_printf(sfp, "tcp_ack_drop_cnt=%d\n", priv->tcp_ack_drop_cnt);
  500. seq_printf(sfp, "tcp_ack_cnt=%d\n", priv->tcp_ack_cnt);
  501. #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29)
  502. for (i = 0; i < 4; i++)
  503. seq_printf(sfp, "wmm_tx_pending[%d]:%d\n", i,
  504. atomic_read(&priv->wmm_tx_pending[i]));
  505. #endif
  506. if (info.tx_tbl_num) {
  507. seq_printf(sfp, "Tx BA stream table:\n");
  508. for (i = 0; i < info.tx_tbl_num; i++) {
  509. seq_printf(sfp,
  510. "tid = %d, ra = %02x:%02x:%02x:%02x:%02x:%02x amsdu=%d\n",
  511. (int)info.tx_tbl[i].tid,
  512. info.tx_tbl[i].ra[0], info.tx_tbl[i].ra[1],
  513. info.tx_tbl[i].ra[2], info.tx_tbl[i].ra[3],
  514. info.tx_tbl[i].ra[4], info.tx_tbl[i].ra[5],
  515. (int)info.tx_tbl[i].amsdu);
  516. }
  517. }
  518. if (info.rx_tbl_num) {
  519. seq_printf(sfp, "Rx reorder table:\n");
  520. for (i = 0; i < info.rx_tbl_num; i++) {
  521. unsigned int j;
  522. seq_printf(sfp,
  523. "tid = %d, ta = %02x:%02x:%02x:%02x:%02x:%02x, start_win = %d, "
  524. "win_size = %d, amsdu=%d\n",
  525. (int)info.rx_tbl[i].tid,
  526. info.rx_tbl[i].ta[0], info.rx_tbl[i].ta[1],
  527. info.rx_tbl[i].ta[2], info.rx_tbl[i].ta[3],
  528. info.rx_tbl[i].ta[4], info.rx_tbl[i].ta[5],
  529. (int)info.rx_tbl[i].start_win,
  530. (int)info.rx_tbl[i].win_size,
  531. (int)info.rx_tbl[i].amsdu);
  532. seq_printf(sfp, "buffer: ");
  533. for (j = 0; j < info.rx_tbl[i].win_size; j++) {
  534. if (info.rx_tbl[i].buffer[j] == MTRUE)
  535. seq_printf(sfp, "1 ");
  536. else
  537. seq_printf(sfp, "0 ");
  538. }
  539. seq_printf(sfp, "\n");
  540. }
  541. }
  542. for (i = 0; i < info.ralist_num; i++) {
  543. seq_printf(sfp,
  544. "ralist ra: %02x:%02x:%02x:%02x:%02x:%02x tid=%d pkts=%d pause=%d\n",
  545. info.ralist[i].ra[0], info.ralist[i].ra[1],
  546. info.ralist[i].ra[2], info.ralist[i].ra[3],
  547. info.ralist[i].ra[4], info.ralist[i].ra[5],
  548. info.ralist[i].tid, info.ralist[i].total_pkts,
  549. info.ralist[i].tx_pause);
  550. }
  551. exit:
  552. MODULE_PUT;
  553. LEAVE();
  554. return 0;
  555. }
  556. /**
  557. * @brief Proc write function
  558. *
  559. * @param f file pointer
  560. * @param buf pointer to data buffer
  561. * @param count data number to write
  562. * @param off Offset
  563. *
  564. * @return number of data
  565. */
  566. static ssize_t
  567. woal_debug_write(struct file *f, const char __user * buf, size_t count,
  568. loff_t * off)
  569. {
  570. int r, i;
  571. char *pdata;
  572. char *p;
  573. char *p0;
  574. char *p1;
  575. char *p2;
  576. struct seq_file *sfp = f->private_data;
  577. struct debug_data_priv *items_priv =
  578. (struct debug_data_priv *)sfp->private;
  579. struct debug_data *d = items_priv->items;
  580. moal_private *priv = items_priv->priv;
  581. #ifdef DEBUG_LEVEL1
  582. t_u32 last_drvdbg = drvdbg;
  583. #endif
  584. gfp_t flag;
  585. ENTER();
  586. if (MODULE_GET == 0) {
  587. LEAVE();
  588. return MLAN_STATUS_FAILURE;
  589. }
  590. flag = (in_atomic() || irqs_disabled())? GFP_ATOMIC : GFP_KERNEL;
  591. pdata = kzalloc(count + 1, flag);
  592. if (pdata == NULL) {
  593. MODULE_PUT;
  594. LEAVE();
  595. return 0;
  596. }
  597. if (copy_from_user(pdata, buf, count)) {
  598. PRINTM(MERROR, "Copy from user failed\n");
  599. kfree(pdata);
  600. MODULE_PUT;
  601. LEAVE();
  602. return 0;
  603. }
  604. if (woal_get_debug_info(priv, MOAL_PROC_WAIT, &info)) {
  605. kfree(pdata);
  606. MODULE_PUT;
  607. LEAVE();
  608. return 0;
  609. }
  610. p0 = pdata;
  611. for (i = 0; i < items_priv->num_of_items; i++) {
  612. do {
  613. p = strstr(p0, d[i].name);
  614. if (p == NULL)
  615. break;
  616. p1 = strchr(p, '\n');
  617. if (p1 == NULL)
  618. break;
  619. p0 = p1++;
  620. p2 = strchr(p, '=');
  621. if (!p2)
  622. break;
  623. p2++;
  624. r = woal_string_to_number(p2);
  625. if (d[i].size == 1)
  626. *((t_u8 *) d[i].addr) = (t_u8) r;
  627. else if (d[i].size == 2)
  628. *((t_u16 *) d[i].addr) = (t_u16) r;
  629. else if (d[i].size == 4)
  630. *((t_ptr *) d[i].addr) = (t_ptr) r;
  631. break;
  632. } while (MTRUE);
  633. }
  634. kfree(pdata);
  635. #ifdef DEBUG_LEVEL1
  636. if (last_drvdbg != drvdbg)
  637. woal_set_drvdbg(priv, drvdbg);
  638. #endif
  639. MODULE_PUT;
  640. LEAVE();
  641. return count;
  642. }
  643. static int
  644. woal_debug_proc_open(struct inode *inode, struct file *file)
  645. {
  646. #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
  647. return single_open(file, woal_debug_read, PDE_DATA(inode));
  648. #else
  649. return single_open(file, woal_debug_read, PDE(inode)->data);
  650. #endif
  651. }
  652. static const struct file_operations debug_proc_fops = {
  653. .owner = THIS_MODULE,
  654. .open = woal_debug_proc_open,
  655. .read = seq_read,
  656. .llseek = seq_lseek,
  657. .release = single_release,
  658. .write = woal_debug_write,
  659. };
  660. /********************************************************
  661. Global Functions
  662. ********************************************************/
  663. /**
  664. * @brief Create debug proc file
  665. *
  666. * @param priv A pointer to a moal_private structure
  667. *
  668. * @return N/A
  669. */
  670. void
  671. woal_debug_entry(moal_private * priv)
  672. {
  673. struct proc_dir_entry *r;
  674. int i;
  675. int handle_items;
  676. ENTER();
  677. if (priv->proc_entry == NULL) {
  678. LEAVE();
  679. return;
  680. }
  681. #ifdef STA_SUPPORT
  682. if (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA) {
  683. priv->items_priv.items = kmalloc(sizeof(items), GFP_KERNEL);
  684. if (!priv->items_priv.items) {
  685. PRINTM(MERROR,
  686. "Failed to allocate memory for debug data\n");
  687. LEAVE();
  688. return;
  689. }
  690. memcpy(priv->items_priv.items, items, sizeof(items));
  691. priv->items_priv.num_of_items = ARRAY_SIZE(items);
  692. }
  693. #endif
  694. #ifdef UAP_SUPPORT
  695. if (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_UAP) {
  696. priv->items_priv.items = kmalloc(sizeof(uap_items), GFP_KERNEL);
  697. if (!priv->items_priv.items) {
  698. PRINTM(MERROR,
  699. "Failed to allocate memory for debug data\n");
  700. LEAVE();
  701. return;
  702. }
  703. memcpy(priv->items_priv.items, uap_items, sizeof(uap_items));
  704. priv->items_priv.num_of_items = ARRAY_SIZE(uap_items);
  705. }
  706. #endif
  707. priv->items_priv.priv = priv;
  708. handle_items = 9;
  709. #ifdef SDIO_MMC_DEBUG
  710. handle_items += 2;
  711. #endif
  712. #if defined(SDIO_SUSPEND_RESUME)
  713. handle_items += 2;
  714. #endif
  715. for (i = 1; i <= handle_items; i++)
  716. priv->items_priv.items[priv->items_priv.num_of_items -
  717. i].addr += (t_ptr) (priv->phandle);
  718. /* Create proc entry */
  719. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
  720. r = proc_create_data("debug", 0644, priv->proc_entry, &debug_proc_fops,
  721. &priv->items_priv);
  722. if (r == NULL)
  723. #else
  724. r = create_proc_entry("debug", 0644, priv->proc_entry);
  725. if (r) {
  726. r->data = &priv->items_priv;
  727. r->proc_fops = &debug_proc_fops;
  728. } else
  729. #endif
  730. {
  731. PRINTM(MMSG, "Fail to create proc debug entry\n");
  732. LEAVE();
  733. return;
  734. }
  735. LEAVE();
  736. }
  737. /**
  738. * @brief Remove proc file
  739. *
  740. * @param priv A pointer to a moal_private structure
  741. *
  742. * @return N/A
  743. */
  744. void
  745. woal_debug_remove(moal_private * priv)
  746. {
  747. ENTER();
  748. kfree(priv->items_priv.items);
  749. /* Remove proc entry */
  750. remove_proc_entry("debug", priv->proc_entry);
  751. LEAVE();
  752. }
  753. #endif