4965-debug.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. /******************************************************************************
  2. *
  3. * GPL LICENSE SUMMARY
  4. *
  5. * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of version 2 of the GNU General Public License as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  19. * USA
  20. *
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called LICENSE.GPL.
  23. *
  24. * Contact Information:
  25. * Intel Linux Wireless <ilw@linux.intel.com>
  26. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  27. *****************************************************************************/
  28. #include "common.h"
  29. #include "4965.h"
  30. static const char *fmt_value = " %-30s %10u\n";
  31. static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
  32. static const char *fmt_header =
  33. "%-32s current cumulative delta max\n";
  34. static int
  35. il4965_stats_flag(struct il_priv *il, char *buf, int bufsz)
  36. {
  37. int p = 0;
  38. u32 flag;
  39. flag = le32_to_cpu(il->_4965.stats.flag);
  40. p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag);
  41. if (flag & UCODE_STATS_CLEAR_MSK)
  42. p += scnprintf(buf + p, bufsz - p,
  43. "\tStatistics have been cleared\n");
  44. p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
  45. (flag & UCODE_STATS_FREQUENCY_MSK) ? "2.4 GHz" :
  46. "5.2 GHz");
  47. p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
  48. (flag & UCODE_STATS_NARROW_BAND_MSK) ? "enabled" :
  49. "disabled");
  50. return p;
  51. }
  52. static ssize_t
  53. il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf,
  54. size_t count, loff_t *ppos)
  55. {
  56. struct il_priv *il = file->private_data;
  57. int pos = 0;
  58. char *buf;
  59. int bufsz =
  60. sizeof(struct stats_rx_phy) * 40 +
  61. sizeof(struct stats_rx_non_phy) * 40 +
  62. sizeof(struct stats_rx_ht_phy) * 40 + 400;
  63. ssize_t ret;
  64. struct stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
  65. struct stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
  66. struct stats_rx_non_phy *general, *accum_general;
  67. struct stats_rx_non_phy *delta_general, *max_general;
  68. struct stats_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
  69. if (!il_is_alive(il))
  70. return -EAGAIN;
  71. buf = kzalloc(bufsz, GFP_KERNEL);
  72. if (!buf) {
  73. IL_ERR("Can not allocate Buffer\n");
  74. return -ENOMEM;
  75. }
  76. /*
  77. * the statistic information display here is based on
  78. * the last stats notification from uCode
  79. * might not reflect the current uCode activity
  80. */
  81. ofdm = &il->_4965.stats.rx.ofdm;
  82. cck = &il->_4965.stats.rx.cck;
  83. general = &il->_4965.stats.rx.general;
  84. ht = &il->_4965.stats.rx.ofdm_ht;
  85. accum_ofdm = &il->_4965.accum_stats.rx.ofdm;
  86. accum_cck = &il->_4965.accum_stats.rx.cck;
  87. accum_general = &il->_4965.accum_stats.rx.general;
  88. accum_ht = &il->_4965.accum_stats.rx.ofdm_ht;
  89. delta_ofdm = &il->_4965.delta_stats.rx.ofdm;
  90. delta_cck = &il->_4965.delta_stats.rx.cck;
  91. delta_general = &il->_4965.delta_stats.rx.general;
  92. delta_ht = &il->_4965.delta_stats.rx.ofdm_ht;
  93. max_ofdm = &il->_4965.max_delta.rx.ofdm;
  94. max_cck = &il->_4965.max_delta.rx.cck;
  95. max_general = &il->_4965.max_delta.rx.general;
  96. max_ht = &il->_4965.max_delta.rx.ofdm_ht;
  97. pos += il4965_stats_flag(il, buf, bufsz);
  98. pos +=
  99. scnprintf(buf + pos, bufsz - pos, fmt_header,
  100. "Statistics_Rx - OFDM:");
  101. pos +=
  102. scnprintf(buf + pos, bufsz - pos, fmt_table, "ina_cnt:",
  103. le32_to_cpu(ofdm->ina_cnt), accum_ofdm->ina_cnt,
  104. delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
  105. pos +=
  106. scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_cnt:",
  107. le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
  108. delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
  109. pos +=
  110. scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:",
  111. le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
  112. delta_ofdm->plcp_err, max_ofdm->plcp_err);
  113. pos +=
  114. scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:",
  115. le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
  116. delta_ofdm->crc32_err, max_ofdm->crc32_err);
  117. pos +=
  118. scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:",
  119. le32_to_cpu(ofdm->overrun_err), accum_ofdm->overrun_err,
  120. delta_ofdm->overrun_err, max_ofdm->overrun_err);
  121. pos +=
  122. scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:",
  123. le32_to_cpu(ofdm->early_overrun_err),
  124. accum_ofdm->early_overrun_err,
  125. delta_ofdm->early_overrun_err,
  126. max_ofdm->early_overrun_err);
  127. pos +=
  128. scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:",
  129. le32_to_cpu(ofdm->crc32_good), accum_ofdm->crc32_good,
  130. delta_ofdm->crc32_good, max_ofdm->crc32_good);
  131. pos +=
  132. scnprintf(buf + pos, bufsz - pos, fmt_table, "false_alarm_cnt:",
  133. le32_to_cpu(ofdm->false_alarm_cnt),
  134. accum_ofdm->false_alarm_cnt, delta_ofdm->false_alarm_cnt,
  135. max_ofdm->false_alarm_cnt);
  136. pos +=
  137. scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_sync_err_cnt:",
  138. le32_to_cpu(ofdm->fina_sync_err_cnt),
  139. accum_ofdm->fina_sync_err_cnt,
  140. delta_ofdm->fina_sync_err_cnt,
  141. max_ofdm->fina_sync_err_cnt);
  142. pos +=
  143. scnprintf(buf + pos, bufsz - pos, fmt_table, "sfd_timeout:",
  144. le32_to_cpu(ofdm->sfd_timeout), accum_ofdm->sfd_timeout,
  145. delta_ofdm->sfd_timeout, max_ofdm->sfd_timeout);
  146. pos +=
  147. scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_timeout:",
  148. le32_to_cpu(ofdm->fina_timeout), accum_ofdm->fina_timeout,
  149. delta_ofdm->fina_timeout, max_ofdm->fina_timeout);
  150. pos +=
  151. scnprintf(buf + pos, bufsz - pos, fmt_table, "unresponded_rts:",
  152. le32_to_cpu(ofdm->unresponded_rts),
  153. accum_ofdm->unresponded_rts, delta_ofdm->unresponded_rts,
  154. max_ofdm->unresponded_rts);
  155. pos +=
  156. scnprintf(buf + pos, bufsz - pos, fmt_table, "rxe_frame_lmt_ovrun:",
  157. le32_to_cpu(ofdm->rxe_frame_limit_overrun),
  158. accum_ofdm->rxe_frame_limit_overrun,
  159. delta_ofdm->rxe_frame_limit_overrun,
  160. max_ofdm->rxe_frame_limit_overrun);
  161. pos +=
  162. scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ack_cnt:",
  163. le32_to_cpu(ofdm->sent_ack_cnt), accum_ofdm->sent_ack_cnt,
  164. delta_ofdm->sent_ack_cnt, max_ofdm->sent_ack_cnt);
  165. pos +=
  166. scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_cts_cnt:",
  167. le32_to_cpu(ofdm->sent_cts_cnt), accum_ofdm->sent_cts_cnt,
  168. delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt);
  169. pos +=
  170. scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ba_rsp_cnt:",
  171. le32_to_cpu(ofdm->sent_ba_rsp_cnt),
  172. accum_ofdm->sent_ba_rsp_cnt, delta_ofdm->sent_ba_rsp_cnt,
  173. max_ofdm->sent_ba_rsp_cnt);
  174. pos +=
  175. scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_self_kill:",
  176. le32_to_cpu(ofdm->dsp_self_kill),
  177. accum_ofdm->dsp_self_kill, delta_ofdm->dsp_self_kill,
  178. max_ofdm->dsp_self_kill);
  179. pos +=
  180. scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:",
  181. le32_to_cpu(ofdm->mh_format_err),
  182. accum_ofdm->mh_format_err, delta_ofdm->mh_format_err,
  183. max_ofdm->mh_format_err);
  184. pos +=
  185. scnprintf(buf + pos, bufsz - pos, fmt_table,
  186. "re_acq_main_rssi_sum:",
  187. le32_to_cpu(ofdm->re_acq_main_rssi_sum),
  188. accum_ofdm->re_acq_main_rssi_sum,
  189. delta_ofdm->re_acq_main_rssi_sum,
  190. max_ofdm->re_acq_main_rssi_sum);
  191. pos +=
  192. scnprintf(buf + pos, bufsz - pos, fmt_header,
  193. "Statistics_Rx - CCK:");
  194. pos +=
  195. scnprintf(buf + pos, bufsz - pos, fmt_table, "ina_cnt:",
  196. le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
  197. delta_cck->ina_cnt, max_cck->ina_cnt);
  198. pos +=
  199. scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_cnt:",
  200. le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
  201. delta_cck->fina_cnt, max_cck->fina_cnt);
  202. pos +=
  203. scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:",
  204. le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
  205. delta_cck->plcp_err, max_cck->plcp_err);
  206. pos +=
  207. scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:",
  208. le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
  209. delta_cck->crc32_err, max_cck->crc32_err);
  210. pos +=
  211. scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:",
  212. le32_to_cpu(cck->overrun_err), accum_cck->overrun_err,
  213. delta_cck->overrun_err, max_cck->overrun_err);
  214. pos +=
  215. scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:",
  216. le32_to_cpu(cck->early_overrun_err),
  217. accum_cck->early_overrun_err,
  218. delta_cck->early_overrun_err, max_cck->early_overrun_err);
  219. pos +=
  220. scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:",
  221. le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
  222. delta_cck->crc32_good, max_cck->crc32_good);
  223. pos +=
  224. scnprintf(buf + pos, bufsz - pos, fmt_table, "false_alarm_cnt:",
  225. le32_to_cpu(cck->false_alarm_cnt),
  226. accum_cck->false_alarm_cnt, delta_cck->false_alarm_cnt,
  227. max_cck->false_alarm_cnt);
  228. pos +=
  229. scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_sync_err_cnt:",
  230. le32_to_cpu(cck->fina_sync_err_cnt),
  231. accum_cck->fina_sync_err_cnt,
  232. delta_cck->fina_sync_err_cnt, max_cck->fina_sync_err_cnt);
  233. pos +=
  234. scnprintf(buf + pos, bufsz - pos, fmt_table, "sfd_timeout:",
  235. le32_to_cpu(cck->sfd_timeout), accum_cck->sfd_timeout,
  236. delta_cck->sfd_timeout, max_cck->sfd_timeout);
  237. pos +=
  238. scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_timeout:",
  239. le32_to_cpu(cck->fina_timeout), accum_cck->fina_timeout,
  240. delta_cck->fina_timeout, max_cck->fina_timeout);
  241. pos +=
  242. scnprintf(buf + pos, bufsz - pos, fmt_table, "unresponded_rts:",
  243. le32_to_cpu(cck->unresponded_rts),
  244. accum_cck->unresponded_rts, delta_cck->unresponded_rts,
  245. max_cck->unresponded_rts);
  246. pos +=
  247. scnprintf(buf + pos, bufsz - pos, fmt_table, "rxe_frame_lmt_ovrun:",
  248. le32_to_cpu(cck->rxe_frame_limit_overrun),
  249. accum_cck->rxe_frame_limit_overrun,
  250. delta_cck->rxe_frame_limit_overrun,
  251. max_cck->rxe_frame_limit_overrun);
  252. pos +=
  253. scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ack_cnt:",
  254. le32_to_cpu(cck->sent_ack_cnt), accum_cck->sent_ack_cnt,
  255. delta_cck->sent_ack_cnt, max_cck->sent_ack_cnt);
  256. pos +=
  257. scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_cts_cnt:",
  258. le32_to_cpu(cck->sent_cts_cnt), accum_cck->sent_cts_cnt,
  259. delta_cck->sent_cts_cnt, max_cck->sent_cts_cnt);
  260. pos +=
  261. scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ba_rsp_cnt:",
  262. le32_to_cpu(cck->sent_ba_rsp_cnt),
  263. accum_cck->sent_ba_rsp_cnt, delta_cck->sent_ba_rsp_cnt,
  264. max_cck->sent_ba_rsp_cnt);
  265. pos +=
  266. scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_self_kill:",
  267. le32_to_cpu(cck->dsp_self_kill), accum_cck->dsp_self_kill,
  268. delta_cck->dsp_self_kill, max_cck->dsp_self_kill);
  269. pos +=
  270. scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:",
  271. le32_to_cpu(cck->mh_format_err), accum_cck->mh_format_err,
  272. delta_cck->mh_format_err, max_cck->mh_format_err);
  273. pos +=
  274. scnprintf(buf + pos, bufsz - pos, fmt_table,
  275. "re_acq_main_rssi_sum:",
  276. le32_to_cpu(cck->re_acq_main_rssi_sum),
  277. accum_cck->re_acq_main_rssi_sum,
  278. delta_cck->re_acq_main_rssi_sum,
  279. max_cck->re_acq_main_rssi_sum);
  280. pos +=
  281. scnprintf(buf + pos, bufsz - pos, fmt_header,
  282. "Statistics_Rx - GENERAL:");
  283. pos +=
  284. scnprintf(buf + pos, bufsz - pos, fmt_table, "bogus_cts:",
  285. le32_to_cpu(general->bogus_cts), accum_general->bogus_cts,
  286. delta_general->bogus_cts, max_general->bogus_cts);
  287. pos +=
  288. scnprintf(buf + pos, bufsz - pos, fmt_table, "bogus_ack:",
  289. le32_to_cpu(general->bogus_ack), accum_general->bogus_ack,
  290. delta_general->bogus_ack, max_general->bogus_ack);
  291. pos +=
  292. scnprintf(buf + pos, bufsz - pos, fmt_table, "non_bssid_frames:",
  293. le32_to_cpu(general->non_bssid_frames),
  294. accum_general->non_bssid_frames,
  295. delta_general->non_bssid_frames,
  296. max_general->non_bssid_frames);
  297. pos +=
  298. scnprintf(buf + pos, bufsz - pos, fmt_table, "filtered_frames:",
  299. le32_to_cpu(general->filtered_frames),
  300. accum_general->filtered_frames,
  301. delta_general->filtered_frames,
  302. max_general->filtered_frames);
  303. pos +=
  304. scnprintf(buf + pos, bufsz - pos, fmt_table, "non_channel_beacons:",
  305. le32_to_cpu(general->non_channel_beacons),
  306. accum_general->non_channel_beacons,
  307. delta_general->non_channel_beacons,
  308. max_general->non_channel_beacons);
  309. pos +=
  310. scnprintf(buf + pos, bufsz - pos, fmt_table, "channel_beacons:",
  311. le32_to_cpu(general->channel_beacons),
  312. accum_general->channel_beacons,
  313. delta_general->channel_beacons,
  314. max_general->channel_beacons);
  315. pos +=
  316. scnprintf(buf + pos, bufsz - pos, fmt_table, "num_missed_bcon:",
  317. le32_to_cpu(general->num_missed_bcon),
  318. accum_general->num_missed_bcon,
  319. delta_general->num_missed_bcon,
  320. max_general->num_missed_bcon);
  321. pos +=
  322. scnprintf(buf + pos, bufsz - pos, fmt_table,
  323. "adc_rx_saturation_time:",
  324. le32_to_cpu(general->adc_rx_saturation_time),
  325. accum_general->adc_rx_saturation_time,
  326. delta_general->adc_rx_saturation_time,
  327. max_general->adc_rx_saturation_time);
  328. pos +=
  329. scnprintf(buf + pos, bufsz - pos, fmt_table,
  330. "ina_detect_search_tm:",
  331. le32_to_cpu(general->ina_detection_search_time),
  332. accum_general->ina_detection_search_time,
  333. delta_general->ina_detection_search_time,
  334. max_general->ina_detection_search_time);
  335. pos +=
  336. scnprintf(buf + pos, bufsz - pos, fmt_table,
  337. "beacon_silence_rssi_a:",
  338. le32_to_cpu(general->beacon_silence_rssi_a),
  339. accum_general->beacon_silence_rssi_a,
  340. delta_general->beacon_silence_rssi_a,
  341. max_general->beacon_silence_rssi_a);
  342. pos +=
  343. scnprintf(buf + pos, bufsz - pos, fmt_table,
  344. "beacon_silence_rssi_b:",
  345. le32_to_cpu(general->beacon_silence_rssi_b),
  346. accum_general->beacon_silence_rssi_b,
  347. delta_general->beacon_silence_rssi_b,
  348. max_general->beacon_silence_rssi_b);
  349. pos +=
  350. scnprintf(buf + pos, bufsz - pos, fmt_table,
  351. "beacon_silence_rssi_c:",
  352. le32_to_cpu(general->beacon_silence_rssi_c),
  353. accum_general->beacon_silence_rssi_c,
  354. delta_general->beacon_silence_rssi_c,
  355. max_general->beacon_silence_rssi_c);
  356. pos +=
  357. scnprintf(buf + pos, bufsz - pos, fmt_table,
  358. "interference_data_flag:",
  359. le32_to_cpu(general->interference_data_flag),
  360. accum_general->interference_data_flag,
  361. delta_general->interference_data_flag,
  362. max_general->interference_data_flag);
  363. pos +=
  364. scnprintf(buf + pos, bufsz - pos, fmt_table, "channel_load:",
  365. le32_to_cpu(general->channel_load),
  366. accum_general->channel_load, delta_general->channel_load,
  367. max_general->channel_load);
  368. pos +=
  369. scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_false_alarms:",
  370. le32_to_cpu(general->dsp_false_alarms),
  371. accum_general->dsp_false_alarms,
  372. delta_general->dsp_false_alarms,
  373. max_general->dsp_false_alarms);
  374. pos +=
  375. scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_a:",
  376. le32_to_cpu(general->beacon_rssi_a),
  377. accum_general->beacon_rssi_a,
  378. delta_general->beacon_rssi_a, max_general->beacon_rssi_a);
  379. pos +=
  380. scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_b:",
  381. le32_to_cpu(general->beacon_rssi_b),
  382. accum_general->beacon_rssi_b,
  383. delta_general->beacon_rssi_b, max_general->beacon_rssi_b);
  384. pos +=
  385. scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_c:",
  386. le32_to_cpu(general->beacon_rssi_c),
  387. accum_general->beacon_rssi_c,
  388. delta_general->beacon_rssi_c, max_general->beacon_rssi_c);
  389. pos +=
  390. scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_a:",
  391. le32_to_cpu(general->beacon_energy_a),
  392. accum_general->beacon_energy_a,
  393. delta_general->beacon_energy_a,
  394. max_general->beacon_energy_a);
  395. pos +=
  396. scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_b:",
  397. le32_to_cpu(general->beacon_energy_b),
  398. accum_general->beacon_energy_b,
  399. delta_general->beacon_energy_b,
  400. max_general->beacon_energy_b);
  401. pos +=
  402. scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_c:",
  403. le32_to_cpu(general->beacon_energy_c),
  404. accum_general->beacon_energy_c,
  405. delta_general->beacon_energy_c,
  406. max_general->beacon_energy_c);
  407. pos +=
  408. scnprintf(buf + pos, bufsz - pos, fmt_header,
  409. "Statistics_Rx - OFDM_HT:");
  410. pos +=
  411. scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:",
  412. le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
  413. delta_ht->plcp_err, max_ht->plcp_err);
  414. pos +=
  415. scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:",
  416. le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
  417. delta_ht->overrun_err, max_ht->overrun_err);
  418. pos +=
  419. scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:",
  420. le32_to_cpu(ht->early_overrun_err),
  421. accum_ht->early_overrun_err, delta_ht->early_overrun_err,
  422. max_ht->early_overrun_err);
  423. pos +=
  424. scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:",
  425. le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
  426. delta_ht->crc32_good, max_ht->crc32_good);
  427. pos +=
  428. scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:",
  429. le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
  430. delta_ht->crc32_err, max_ht->crc32_err);
  431. pos +=
  432. scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:",
  433. le32_to_cpu(ht->mh_format_err), accum_ht->mh_format_err,
  434. delta_ht->mh_format_err, max_ht->mh_format_err);
  435. pos +=
  436. scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_crc32_good:",
  437. le32_to_cpu(ht->agg_crc32_good), accum_ht->agg_crc32_good,
  438. delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
  439. pos +=
  440. scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_mpdu_cnt:",
  441. le32_to_cpu(ht->agg_mpdu_cnt), accum_ht->agg_mpdu_cnt,
  442. delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
  443. pos +=
  444. scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_cnt:",
  445. le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
  446. delta_ht->agg_cnt, max_ht->agg_cnt);
  447. pos +=
  448. scnprintf(buf + pos, bufsz - pos, fmt_table, "unsupport_mcs:",
  449. le32_to_cpu(ht->unsupport_mcs), accum_ht->unsupport_mcs,
  450. delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
  451. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  452. kfree(buf);
  453. return ret;
  454. }
  455. static ssize_t
  456. il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf,
  457. size_t count, loff_t *ppos)
  458. {
  459. struct il_priv *il = file->private_data;
  460. int pos = 0;
  461. char *buf;
  462. int bufsz = (sizeof(struct stats_tx) * 48) + 250;
  463. ssize_t ret;
  464. struct stats_tx *tx, *accum_tx, *delta_tx, *max_tx;
  465. if (!il_is_alive(il))
  466. return -EAGAIN;
  467. buf = kzalloc(bufsz, GFP_KERNEL);
  468. if (!buf) {
  469. IL_ERR("Can not allocate Buffer\n");
  470. return -ENOMEM;
  471. }
  472. /* the statistic information display here is based on
  473. * the last stats notification from uCode
  474. * might not reflect the current uCode activity
  475. */
  476. tx = &il->_4965.stats.tx;
  477. accum_tx = &il->_4965.accum_stats.tx;
  478. delta_tx = &il->_4965.delta_stats.tx;
  479. max_tx = &il->_4965.max_delta.tx;
  480. pos += il4965_stats_flag(il, buf, bufsz);
  481. pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Tx:");
  482. pos +=
  483. scnprintf(buf + pos, bufsz - pos, fmt_table, "preamble:",
  484. le32_to_cpu(tx->preamble_cnt), accum_tx->preamble_cnt,
  485. delta_tx->preamble_cnt, max_tx->preamble_cnt);
  486. pos +=
  487. scnprintf(buf + pos, bufsz - pos, fmt_table, "rx_detected_cnt:",
  488. le32_to_cpu(tx->rx_detected_cnt),
  489. accum_tx->rx_detected_cnt, delta_tx->rx_detected_cnt,
  490. max_tx->rx_detected_cnt);
  491. pos +=
  492. scnprintf(buf + pos, bufsz - pos, fmt_table, "bt_prio_defer_cnt:",
  493. le32_to_cpu(tx->bt_prio_defer_cnt),
  494. accum_tx->bt_prio_defer_cnt, delta_tx->bt_prio_defer_cnt,
  495. max_tx->bt_prio_defer_cnt);
  496. pos +=
  497. scnprintf(buf + pos, bufsz - pos, fmt_table, "bt_prio_kill_cnt:",
  498. le32_to_cpu(tx->bt_prio_kill_cnt),
  499. accum_tx->bt_prio_kill_cnt, delta_tx->bt_prio_kill_cnt,
  500. max_tx->bt_prio_kill_cnt);
  501. pos +=
  502. scnprintf(buf + pos, bufsz - pos, fmt_table, "few_bytes_cnt:",
  503. le32_to_cpu(tx->few_bytes_cnt), accum_tx->few_bytes_cnt,
  504. delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
  505. pos +=
  506. scnprintf(buf + pos, bufsz - pos, fmt_table, "cts_timeout:",
  507. le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
  508. delta_tx->cts_timeout, max_tx->cts_timeout);
  509. pos +=
  510. scnprintf(buf + pos, bufsz - pos, fmt_table, "ack_timeout:",
  511. le32_to_cpu(tx->ack_timeout), accum_tx->ack_timeout,
  512. delta_tx->ack_timeout, max_tx->ack_timeout);
  513. pos +=
  514. scnprintf(buf + pos, bufsz - pos, fmt_table, "expected_ack_cnt:",
  515. le32_to_cpu(tx->expected_ack_cnt),
  516. accum_tx->expected_ack_cnt, delta_tx->expected_ack_cnt,
  517. max_tx->expected_ack_cnt);
  518. pos +=
  519. scnprintf(buf + pos, bufsz - pos, fmt_table, "actual_ack_cnt:",
  520. le32_to_cpu(tx->actual_ack_cnt), accum_tx->actual_ack_cnt,
  521. delta_tx->actual_ack_cnt, max_tx->actual_ack_cnt);
  522. pos +=
  523. scnprintf(buf + pos, bufsz - pos, fmt_table, "dump_msdu_cnt:",
  524. le32_to_cpu(tx->dump_msdu_cnt), accum_tx->dump_msdu_cnt,
  525. delta_tx->dump_msdu_cnt, max_tx->dump_msdu_cnt);
  526. pos +=
  527. scnprintf(buf + pos, bufsz - pos, fmt_table,
  528. "abort_nxt_frame_mismatch:",
  529. le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
  530. accum_tx->burst_abort_next_frame_mismatch_cnt,
  531. delta_tx->burst_abort_next_frame_mismatch_cnt,
  532. max_tx->burst_abort_next_frame_mismatch_cnt);
  533. pos +=
  534. scnprintf(buf + pos, bufsz - pos, fmt_table,
  535. "abort_missing_nxt_frame:",
  536. le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
  537. accum_tx->burst_abort_missing_next_frame_cnt,
  538. delta_tx->burst_abort_missing_next_frame_cnt,
  539. max_tx->burst_abort_missing_next_frame_cnt);
  540. pos +=
  541. scnprintf(buf + pos, bufsz - pos, fmt_table,
  542. "cts_timeout_collision:",
  543. le32_to_cpu(tx->cts_timeout_collision),
  544. accum_tx->cts_timeout_collision,
  545. delta_tx->cts_timeout_collision,
  546. max_tx->cts_timeout_collision);
  547. pos +=
  548. scnprintf(buf + pos, bufsz - pos, fmt_table,
  549. "ack_ba_timeout_collision:",
  550. le32_to_cpu(tx->ack_or_ba_timeout_collision),
  551. accum_tx->ack_or_ba_timeout_collision,
  552. delta_tx->ack_or_ba_timeout_collision,
  553. max_tx->ack_or_ba_timeout_collision);
  554. pos +=
  555. scnprintf(buf + pos, bufsz - pos, fmt_table, "agg ba_timeout:",
  556. le32_to_cpu(tx->agg.ba_timeout), accum_tx->agg.ba_timeout,
  557. delta_tx->agg.ba_timeout, max_tx->agg.ba_timeout);
  558. pos +=
  559. scnprintf(buf + pos, bufsz - pos, fmt_table,
  560. "agg ba_resched_frames:",
  561. le32_to_cpu(tx->agg.ba_reschedule_frames),
  562. accum_tx->agg.ba_reschedule_frames,
  563. delta_tx->agg.ba_reschedule_frames,
  564. max_tx->agg.ba_reschedule_frames);
  565. pos +=
  566. scnprintf(buf + pos, bufsz - pos, fmt_table,
  567. "agg scd_query_agg_frame:",
  568. le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
  569. accum_tx->agg.scd_query_agg_frame_cnt,
  570. delta_tx->agg.scd_query_agg_frame_cnt,
  571. max_tx->agg.scd_query_agg_frame_cnt);
  572. pos +=
  573. scnprintf(buf + pos, bufsz - pos, fmt_table,
  574. "agg scd_query_no_agg:",
  575. le32_to_cpu(tx->agg.scd_query_no_agg),
  576. accum_tx->agg.scd_query_no_agg,
  577. delta_tx->agg.scd_query_no_agg,
  578. max_tx->agg.scd_query_no_agg);
  579. pos +=
  580. scnprintf(buf + pos, bufsz - pos, fmt_table, "agg scd_query_agg:",
  581. le32_to_cpu(tx->agg.scd_query_agg),
  582. accum_tx->agg.scd_query_agg, delta_tx->agg.scd_query_agg,
  583. max_tx->agg.scd_query_agg);
  584. pos +=
  585. scnprintf(buf + pos, bufsz - pos, fmt_table,
  586. "agg scd_query_mismatch:",
  587. le32_to_cpu(tx->agg.scd_query_mismatch),
  588. accum_tx->agg.scd_query_mismatch,
  589. delta_tx->agg.scd_query_mismatch,
  590. max_tx->agg.scd_query_mismatch);
  591. pos +=
  592. scnprintf(buf + pos, bufsz - pos, fmt_table, "agg frame_not_ready:",
  593. le32_to_cpu(tx->agg.frame_not_ready),
  594. accum_tx->agg.frame_not_ready,
  595. delta_tx->agg.frame_not_ready,
  596. max_tx->agg.frame_not_ready);
  597. pos +=
  598. scnprintf(buf + pos, bufsz - pos, fmt_table, "agg underrun:",
  599. le32_to_cpu(tx->agg.underrun), accum_tx->agg.underrun,
  600. delta_tx->agg.underrun, max_tx->agg.underrun);
  601. pos +=
  602. scnprintf(buf + pos, bufsz - pos, fmt_table, "agg bt_prio_kill:",
  603. le32_to_cpu(tx->agg.bt_prio_kill),
  604. accum_tx->agg.bt_prio_kill, delta_tx->agg.bt_prio_kill,
  605. max_tx->agg.bt_prio_kill);
  606. pos +=
  607. scnprintf(buf + pos, bufsz - pos, fmt_table, "agg rx_ba_rsp_cnt:",
  608. le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
  609. accum_tx->agg.rx_ba_rsp_cnt, delta_tx->agg.rx_ba_rsp_cnt,
  610. max_tx->agg.rx_ba_rsp_cnt);
  611. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  612. kfree(buf);
  613. return ret;
  614. }
  615. static ssize_t
  616. il4965_ucode_general_stats_read(struct file *file, char __user *user_buf,
  617. size_t count, loff_t *ppos)
  618. {
  619. struct il_priv *il = file->private_data;
  620. int pos = 0;
  621. char *buf;
  622. int bufsz = sizeof(struct stats_general) * 10 + 300;
  623. ssize_t ret;
  624. struct stats_general_common *general, *accum_general;
  625. struct stats_general_common *delta_general, *max_general;
  626. struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
  627. struct stats_div *div, *accum_div, *delta_div, *max_div;
  628. if (!il_is_alive(il))
  629. return -EAGAIN;
  630. buf = kzalloc(bufsz, GFP_KERNEL);
  631. if (!buf) {
  632. IL_ERR("Can not allocate Buffer\n");
  633. return -ENOMEM;
  634. }
  635. /* the statistic information display here is based on
  636. * the last stats notification from uCode
  637. * might not reflect the current uCode activity
  638. */
  639. general = &il->_4965.stats.general.common;
  640. dbg = &il->_4965.stats.general.common.dbg;
  641. div = &il->_4965.stats.general.common.div;
  642. accum_general = &il->_4965.accum_stats.general.common;
  643. accum_dbg = &il->_4965.accum_stats.general.common.dbg;
  644. accum_div = &il->_4965.accum_stats.general.common.div;
  645. delta_general = &il->_4965.delta_stats.general.common;
  646. max_general = &il->_4965.max_delta.general.common;
  647. delta_dbg = &il->_4965.delta_stats.general.common.dbg;
  648. max_dbg = &il->_4965.max_delta.general.common.dbg;
  649. delta_div = &il->_4965.delta_stats.general.common.div;
  650. max_div = &il->_4965.max_delta.general.common.div;
  651. pos += il4965_stats_flag(il, buf, bufsz);
  652. pos +=
  653. scnprintf(buf + pos, bufsz - pos, fmt_header,
  654. "Statistics_General:");
  655. pos +=
  656. scnprintf(buf + pos, bufsz - pos, fmt_value, "temperature:",
  657. le32_to_cpu(general->temperature));
  658. pos +=
  659. scnprintf(buf + pos, bufsz - pos, fmt_value, "ttl_timestamp:",
  660. le32_to_cpu(general->ttl_timestamp));
  661. pos +=
  662. scnprintf(buf + pos, bufsz - pos, fmt_table, "burst_check:",
  663. le32_to_cpu(dbg->burst_check), accum_dbg->burst_check,
  664. delta_dbg->burst_check, max_dbg->burst_check);
  665. pos +=
  666. scnprintf(buf + pos, bufsz - pos, fmt_table, "burst_count:",
  667. le32_to_cpu(dbg->burst_count), accum_dbg->burst_count,
  668. delta_dbg->burst_count, max_dbg->burst_count);
  669. pos +=
  670. scnprintf(buf + pos, bufsz - pos, fmt_table,
  671. "wait_for_silence_timeout_count:",
  672. le32_to_cpu(dbg->wait_for_silence_timeout_cnt),
  673. accum_dbg->wait_for_silence_timeout_cnt,
  674. delta_dbg->wait_for_silence_timeout_cnt,
  675. max_dbg->wait_for_silence_timeout_cnt);
  676. pos +=
  677. scnprintf(buf + pos, bufsz - pos, fmt_table, "sleep_time:",
  678. le32_to_cpu(general->sleep_time),
  679. accum_general->sleep_time, delta_general->sleep_time,
  680. max_general->sleep_time);
  681. pos +=
  682. scnprintf(buf + pos, bufsz - pos, fmt_table, "slots_out:",
  683. le32_to_cpu(general->slots_out), accum_general->slots_out,
  684. delta_general->slots_out, max_general->slots_out);
  685. pos +=
  686. scnprintf(buf + pos, bufsz - pos, fmt_table, "slots_idle:",
  687. le32_to_cpu(general->slots_idle),
  688. accum_general->slots_idle, delta_general->slots_idle,
  689. max_general->slots_idle);
  690. pos +=
  691. scnprintf(buf + pos, bufsz - pos, fmt_table, "tx_on_a:",
  692. le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
  693. delta_div->tx_on_a, max_div->tx_on_a);
  694. pos +=
  695. scnprintf(buf + pos, bufsz - pos, fmt_table, "tx_on_b:",
  696. le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
  697. delta_div->tx_on_b, max_div->tx_on_b);
  698. pos +=
  699. scnprintf(buf + pos, bufsz - pos, fmt_table, "exec_time:",
  700. le32_to_cpu(div->exec_time), accum_div->exec_time,
  701. delta_div->exec_time, max_div->exec_time);
  702. pos +=
  703. scnprintf(buf + pos, bufsz - pos, fmt_table, "probe_time:",
  704. le32_to_cpu(div->probe_time), accum_div->probe_time,
  705. delta_div->probe_time, max_div->probe_time);
  706. pos +=
  707. scnprintf(buf + pos, bufsz - pos, fmt_table, "rx_enable_counter:",
  708. le32_to_cpu(general->rx_enable_counter),
  709. accum_general->rx_enable_counter,
  710. delta_general->rx_enable_counter,
  711. max_general->rx_enable_counter);
  712. pos +=
  713. scnprintf(buf + pos, bufsz - pos, fmt_table, "num_of_sos_states:",
  714. le32_to_cpu(general->num_of_sos_states),
  715. accum_general->num_of_sos_states,
  716. delta_general->num_of_sos_states,
  717. max_general->num_of_sos_states);
  718. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  719. kfree(buf);
  720. return ret;
  721. }
  722. const struct il_debugfs_ops il4965_debugfs_ops = {
  723. .rx_stats_read = il4965_ucode_rx_stats_read,
  724. .tx_stats_read = il4965_ucode_tx_stats_read,
  725. .general_stats_read = il4965_ucode_general_stats_read,
  726. };