iwl-agn-debugfs.c 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. /******************************************************************************
  2. *
  3. * GPL LICENSE SUMMARY
  4. *
  5. * Copyright(c) 2008 - 2010 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 "iwl-agn.h"
  29. #include "iwl-agn-debugfs.h"
  30. static const char *fmt_value = " %-30s %10u\n";
  31. static const char *fmt_hex = " %-30s 0x%02X\n";
  32. static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
  33. static const char *fmt_header =
  34. "%-32s current cumulative delta max\n";
  35. static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
  36. {
  37. int p = 0;
  38. u32 flag;
  39. if (priv->cfg->bt_params &&
  40. priv->cfg->bt_params->bt_statistics)
  41. flag = le32_to_cpu(priv->_agn.statistics_bt.flag);
  42. else
  43. flag = le32_to_cpu(priv->_agn.statistics.flag);
  44. p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag);
  45. if (flag & UCODE_STATISTICS_CLEAR_MSK)
  46. p += scnprintf(buf + p, bufsz - p,
  47. "\tStatistics have been cleared\n");
  48. p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
  49. (flag & UCODE_STATISTICS_FREQUENCY_MSK)
  50. ? "2.4 GHz" : "5.2 GHz");
  51. p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
  52. (flag & UCODE_STATISTICS_NARROW_BAND_MSK)
  53. ? "enabled" : "disabled");
  54. return p;
  55. }
  56. ssize_t iwl_ucode_rx_stats_read(struct file *file, char __user *user_buf,
  57. size_t count, loff_t *ppos)
  58. {
  59. struct iwl_priv *priv = file->private_data;
  60. int pos = 0;
  61. char *buf;
  62. int bufsz = sizeof(struct statistics_rx_phy) * 40 +
  63. sizeof(struct statistics_rx_non_phy) * 40 +
  64. sizeof(struct statistics_rx_ht_phy) * 40 + 400;
  65. ssize_t ret;
  66. struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
  67. struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
  68. struct statistics_rx_non_phy *general, *accum_general;
  69. struct statistics_rx_non_phy *delta_general, *max_general;
  70. struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
  71. if (!iwl_is_alive(priv))
  72. return -EAGAIN;
  73. buf = kzalloc(bufsz, GFP_KERNEL);
  74. if (!buf) {
  75. IWL_ERR(priv, "Can not allocate Buffer\n");
  76. return -ENOMEM;
  77. }
  78. /*
  79. * the statistic information display here is based on
  80. * the last statistics notification from uCode
  81. * might not reflect the current uCode activity
  82. */
  83. if (priv->cfg->bt_params &&
  84. priv->cfg->bt_params->bt_statistics) {
  85. ofdm = &priv->_agn.statistics_bt.rx.ofdm;
  86. cck = &priv->_agn.statistics_bt.rx.cck;
  87. general = &priv->_agn.statistics_bt.rx.general.common;
  88. ht = &priv->_agn.statistics_bt.rx.ofdm_ht;
  89. accum_ofdm = &priv->_agn.accum_statistics_bt.rx.ofdm;
  90. accum_cck = &priv->_agn.accum_statistics_bt.rx.cck;
  91. accum_general =
  92. &priv->_agn.accum_statistics_bt.rx.general.common;
  93. accum_ht = &priv->_agn.accum_statistics_bt.rx.ofdm_ht;
  94. delta_ofdm = &priv->_agn.delta_statistics_bt.rx.ofdm;
  95. delta_cck = &priv->_agn.delta_statistics_bt.rx.cck;
  96. delta_general =
  97. &priv->_agn.delta_statistics_bt.rx.general.common;
  98. delta_ht = &priv->_agn.delta_statistics_bt.rx.ofdm_ht;
  99. max_ofdm = &priv->_agn.max_delta_bt.rx.ofdm;
  100. max_cck = &priv->_agn.max_delta_bt.rx.cck;
  101. max_general = &priv->_agn.max_delta_bt.rx.general.common;
  102. max_ht = &priv->_agn.max_delta_bt.rx.ofdm_ht;
  103. } else {
  104. ofdm = &priv->_agn.statistics.rx.ofdm;
  105. cck = &priv->_agn.statistics.rx.cck;
  106. general = &priv->_agn.statistics.rx.general;
  107. ht = &priv->_agn.statistics.rx.ofdm_ht;
  108. accum_ofdm = &priv->_agn.accum_statistics.rx.ofdm;
  109. accum_cck = &priv->_agn.accum_statistics.rx.cck;
  110. accum_general = &priv->_agn.accum_statistics.rx.general;
  111. accum_ht = &priv->_agn.accum_statistics.rx.ofdm_ht;
  112. delta_ofdm = &priv->_agn.delta_statistics.rx.ofdm;
  113. delta_cck = &priv->_agn.delta_statistics.rx.cck;
  114. delta_general = &priv->_agn.delta_statistics.rx.general;
  115. delta_ht = &priv->_agn.delta_statistics.rx.ofdm_ht;
  116. max_ofdm = &priv->_agn.max_delta.rx.ofdm;
  117. max_cck = &priv->_agn.max_delta.rx.cck;
  118. max_general = &priv->_agn.max_delta.rx.general;
  119. max_ht = &priv->_agn.max_delta.rx.ofdm_ht;
  120. }
  121. pos += iwl_statistics_flag(priv, buf, bufsz);
  122. pos += scnprintf(buf + pos, bufsz - pos,
  123. fmt_header, "Statistics_Rx - OFDM:");
  124. pos += scnprintf(buf + pos, bufsz - pos,
  125. fmt_table, "ina_cnt:",
  126. le32_to_cpu(ofdm->ina_cnt),
  127. accum_ofdm->ina_cnt,
  128. delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
  129. pos += scnprintf(buf + pos, bufsz - pos,
  130. fmt_table, "fina_cnt:",
  131. le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
  132. delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
  133. pos += scnprintf(buf + pos, bufsz - pos,
  134. fmt_table, "plcp_err:",
  135. le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
  136. delta_ofdm->plcp_err, max_ofdm->plcp_err);
  137. pos += scnprintf(buf + pos, bufsz - pos,
  138. fmt_table, "crc32_err:",
  139. le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
  140. delta_ofdm->crc32_err, max_ofdm->crc32_err);
  141. pos += scnprintf(buf + pos, bufsz - pos,
  142. fmt_table, "overrun_err:",
  143. le32_to_cpu(ofdm->overrun_err),
  144. accum_ofdm->overrun_err, delta_ofdm->overrun_err,
  145. max_ofdm->overrun_err);
  146. pos += scnprintf(buf + pos, bufsz - pos,
  147. fmt_table, "early_overrun_err:",
  148. le32_to_cpu(ofdm->early_overrun_err),
  149. accum_ofdm->early_overrun_err,
  150. delta_ofdm->early_overrun_err,
  151. max_ofdm->early_overrun_err);
  152. pos += scnprintf(buf + pos, bufsz - pos,
  153. fmt_table, "crc32_good:",
  154. le32_to_cpu(ofdm->crc32_good),
  155. accum_ofdm->crc32_good, delta_ofdm->crc32_good,
  156. max_ofdm->crc32_good);
  157. pos += scnprintf(buf + pos, bufsz - pos,
  158. fmt_table, "false_alarm_cnt:",
  159. le32_to_cpu(ofdm->false_alarm_cnt),
  160. accum_ofdm->false_alarm_cnt,
  161. delta_ofdm->false_alarm_cnt,
  162. max_ofdm->false_alarm_cnt);
  163. pos += scnprintf(buf + pos, bufsz - pos,
  164. fmt_table, "fina_sync_err_cnt:",
  165. le32_to_cpu(ofdm->fina_sync_err_cnt),
  166. accum_ofdm->fina_sync_err_cnt,
  167. delta_ofdm->fina_sync_err_cnt,
  168. max_ofdm->fina_sync_err_cnt);
  169. pos += scnprintf(buf + pos, bufsz - pos,
  170. fmt_table, "sfd_timeout:",
  171. le32_to_cpu(ofdm->sfd_timeout),
  172. accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout,
  173. max_ofdm->sfd_timeout);
  174. pos += scnprintf(buf + pos, bufsz - pos,
  175. fmt_table, "fina_timeout:",
  176. le32_to_cpu(ofdm->fina_timeout),
  177. accum_ofdm->fina_timeout, delta_ofdm->fina_timeout,
  178. max_ofdm->fina_timeout);
  179. pos += scnprintf(buf + pos, bufsz - pos,
  180. fmt_table, "unresponded_rts:",
  181. le32_to_cpu(ofdm->unresponded_rts),
  182. accum_ofdm->unresponded_rts,
  183. delta_ofdm->unresponded_rts,
  184. max_ofdm->unresponded_rts);
  185. pos += scnprintf(buf + pos, bufsz - pos,
  186. fmt_table, "rxe_frame_lmt_ovrun:",
  187. le32_to_cpu(ofdm->rxe_frame_limit_overrun),
  188. accum_ofdm->rxe_frame_limit_overrun,
  189. delta_ofdm->rxe_frame_limit_overrun,
  190. max_ofdm->rxe_frame_limit_overrun);
  191. pos += scnprintf(buf + pos, bufsz - pos,
  192. fmt_table, "sent_ack_cnt:",
  193. le32_to_cpu(ofdm->sent_ack_cnt),
  194. accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt,
  195. max_ofdm->sent_ack_cnt);
  196. pos += scnprintf(buf + pos, bufsz - pos,
  197. fmt_table, "sent_cts_cnt:",
  198. le32_to_cpu(ofdm->sent_cts_cnt),
  199. accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt,
  200. max_ofdm->sent_cts_cnt);
  201. pos += scnprintf(buf + pos, bufsz - pos,
  202. fmt_table, "sent_ba_rsp_cnt:",
  203. le32_to_cpu(ofdm->sent_ba_rsp_cnt),
  204. accum_ofdm->sent_ba_rsp_cnt,
  205. delta_ofdm->sent_ba_rsp_cnt,
  206. max_ofdm->sent_ba_rsp_cnt);
  207. pos += scnprintf(buf + pos, bufsz - pos,
  208. fmt_table, "dsp_self_kill:",
  209. le32_to_cpu(ofdm->dsp_self_kill),
  210. accum_ofdm->dsp_self_kill,
  211. delta_ofdm->dsp_self_kill,
  212. max_ofdm->dsp_self_kill);
  213. pos += scnprintf(buf + pos, bufsz - pos,
  214. fmt_table, "mh_format_err:",
  215. le32_to_cpu(ofdm->mh_format_err),
  216. accum_ofdm->mh_format_err,
  217. delta_ofdm->mh_format_err,
  218. max_ofdm->mh_format_err);
  219. pos += scnprintf(buf + pos, bufsz - pos,
  220. fmt_table, "re_acq_main_rssi_sum:",
  221. le32_to_cpu(ofdm->re_acq_main_rssi_sum),
  222. accum_ofdm->re_acq_main_rssi_sum,
  223. delta_ofdm->re_acq_main_rssi_sum,
  224. max_ofdm->re_acq_main_rssi_sum);
  225. pos += scnprintf(buf + pos, bufsz - pos,
  226. fmt_header, "Statistics_Rx - CCK:");
  227. pos += scnprintf(buf + pos, bufsz - pos,
  228. fmt_table, "ina_cnt:",
  229. le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
  230. delta_cck->ina_cnt, max_cck->ina_cnt);
  231. pos += scnprintf(buf + pos, bufsz - pos,
  232. fmt_table, "fina_cnt:",
  233. le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
  234. delta_cck->fina_cnt, max_cck->fina_cnt);
  235. pos += scnprintf(buf + pos, bufsz - pos,
  236. fmt_table, "plcp_err:",
  237. le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
  238. delta_cck->plcp_err, max_cck->plcp_err);
  239. pos += scnprintf(buf + pos, bufsz - pos,
  240. fmt_table, "crc32_err:",
  241. le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
  242. delta_cck->crc32_err, max_cck->crc32_err);
  243. pos += scnprintf(buf + pos, bufsz - pos,
  244. fmt_table, "overrun_err:",
  245. le32_to_cpu(cck->overrun_err),
  246. accum_cck->overrun_err, delta_cck->overrun_err,
  247. max_cck->overrun_err);
  248. pos += scnprintf(buf + pos, bufsz - pos,
  249. fmt_table, "early_overrun_err:",
  250. le32_to_cpu(cck->early_overrun_err),
  251. accum_cck->early_overrun_err,
  252. delta_cck->early_overrun_err,
  253. max_cck->early_overrun_err);
  254. pos += scnprintf(buf + pos, bufsz - pos,
  255. fmt_table, "crc32_good:",
  256. le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
  257. delta_cck->crc32_good, max_cck->crc32_good);
  258. pos += scnprintf(buf + pos, bufsz - pos,
  259. fmt_table, "false_alarm_cnt:",
  260. le32_to_cpu(cck->false_alarm_cnt),
  261. accum_cck->false_alarm_cnt,
  262. delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
  263. pos += scnprintf(buf + pos, bufsz - pos,
  264. fmt_table, "fina_sync_err_cnt:",
  265. le32_to_cpu(cck->fina_sync_err_cnt),
  266. accum_cck->fina_sync_err_cnt,
  267. delta_cck->fina_sync_err_cnt,
  268. max_cck->fina_sync_err_cnt);
  269. pos += scnprintf(buf + pos, bufsz - pos,
  270. fmt_table, "sfd_timeout:",
  271. le32_to_cpu(cck->sfd_timeout),
  272. accum_cck->sfd_timeout, delta_cck->sfd_timeout,
  273. max_cck->sfd_timeout);
  274. pos += scnprintf(buf + pos, bufsz - pos,
  275. fmt_table, "fina_timeout:",
  276. le32_to_cpu(cck->fina_timeout),
  277. accum_cck->fina_timeout, delta_cck->fina_timeout,
  278. max_cck->fina_timeout);
  279. pos += scnprintf(buf + pos, bufsz - pos,
  280. fmt_table, "unresponded_rts:",
  281. le32_to_cpu(cck->unresponded_rts),
  282. accum_cck->unresponded_rts, delta_cck->unresponded_rts,
  283. max_cck->unresponded_rts);
  284. pos += scnprintf(buf + pos, bufsz - pos,
  285. fmt_table, "rxe_frame_lmt_ovrun:",
  286. le32_to_cpu(cck->rxe_frame_limit_overrun),
  287. accum_cck->rxe_frame_limit_overrun,
  288. delta_cck->rxe_frame_limit_overrun,
  289. max_cck->rxe_frame_limit_overrun);
  290. pos += scnprintf(buf + pos, bufsz - pos,
  291. fmt_table, "sent_ack_cnt:",
  292. le32_to_cpu(cck->sent_ack_cnt),
  293. accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt,
  294. max_cck->sent_ack_cnt);
  295. pos += scnprintf(buf + pos, bufsz - pos,
  296. fmt_table, "sent_cts_cnt:",
  297. le32_to_cpu(cck->sent_cts_cnt),
  298. accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt,
  299. max_cck->sent_cts_cnt);
  300. pos += scnprintf(buf + pos, bufsz - pos,
  301. fmt_table, "sent_ba_rsp_cnt:",
  302. le32_to_cpu(cck->sent_ba_rsp_cnt),
  303. accum_cck->sent_ba_rsp_cnt,
  304. delta_cck->sent_ba_rsp_cnt,
  305. max_cck->sent_ba_rsp_cnt);
  306. pos += scnprintf(buf + pos, bufsz - pos,
  307. fmt_table, "dsp_self_kill:",
  308. le32_to_cpu(cck->dsp_self_kill),
  309. accum_cck->dsp_self_kill, delta_cck->dsp_self_kill,
  310. max_cck->dsp_self_kill);
  311. pos += scnprintf(buf + pos, bufsz - pos,
  312. fmt_table, "mh_format_err:",
  313. le32_to_cpu(cck->mh_format_err),
  314. accum_cck->mh_format_err, delta_cck->mh_format_err,
  315. max_cck->mh_format_err);
  316. pos += scnprintf(buf + pos, bufsz - pos,
  317. fmt_table, "re_acq_main_rssi_sum:",
  318. le32_to_cpu(cck->re_acq_main_rssi_sum),
  319. accum_cck->re_acq_main_rssi_sum,
  320. delta_cck->re_acq_main_rssi_sum,
  321. max_cck->re_acq_main_rssi_sum);
  322. pos += scnprintf(buf + pos, bufsz - pos,
  323. fmt_header, "Statistics_Rx - GENERAL:");
  324. pos += scnprintf(buf + pos, bufsz - pos,
  325. fmt_table, "bogus_cts:",
  326. le32_to_cpu(general->bogus_cts),
  327. accum_general->bogus_cts, delta_general->bogus_cts,
  328. max_general->bogus_cts);
  329. pos += scnprintf(buf + pos, bufsz - pos,
  330. fmt_table, "bogus_ack:",
  331. le32_to_cpu(general->bogus_ack),
  332. accum_general->bogus_ack, delta_general->bogus_ack,
  333. max_general->bogus_ack);
  334. pos += scnprintf(buf + pos, bufsz - pos,
  335. fmt_table, "non_bssid_frames:",
  336. le32_to_cpu(general->non_bssid_frames),
  337. accum_general->non_bssid_frames,
  338. delta_general->non_bssid_frames,
  339. max_general->non_bssid_frames);
  340. pos += scnprintf(buf + pos, bufsz - pos,
  341. fmt_table, "filtered_frames:",
  342. le32_to_cpu(general->filtered_frames),
  343. accum_general->filtered_frames,
  344. delta_general->filtered_frames,
  345. max_general->filtered_frames);
  346. pos += scnprintf(buf + pos, bufsz - pos,
  347. fmt_table, "non_channel_beacons:",
  348. le32_to_cpu(general->non_channel_beacons),
  349. accum_general->non_channel_beacons,
  350. delta_general->non_channel_beacons,
  351. max_general->non_channel_beacons);
  352. pos += scnprintf(buf + pos, bufsz - pos,
  353. fmt_table, "channel_beacons:",
  354. le32_to_cpu(general->channel_beacons),
  355. accum_general->channel_beacons,
  356. delta_general->channel_beacons,
  357. max_general->channel_beacons);
  358. pos += scnprintf(buf + pos, bufsz - pos,
  359. fmt_table, "num_missed_bcon:",
  360. le32_to_cpu(general->num_missed_bcon),
  361. accum_general->num_missed_bcon,
  362. delta_general->num_missed_bcon,
  363. max_general->num_missed_bcon);
  364. pos += scnprintf(buf + pos, bufsz - pos,
  365. fmt_table, "adc_rx_saturation_time:",
  366. le32_to_cpu(general->adc_rx_saturation_time),
  367. accum_general->adc_rx_saturation_time,
  368. delta_general->adc_rx_saturation_time,
  369. max_general->adc_rx_saturation_time);
  370. pos += scnprintf(buf + pos, bufsz - pos,
  371. fmt_table, "ina_detect_search_tm:",
  372. le32_to_cpu(general->ina_detection_search_time),
  373. accum_general->ina_detection_search_time,
  374. delta_general->ina_detection_search_time,
  375. max_general->ina_detection_search_time);
  376. pos += scnprintf(buf + pos, bufsz - pos,
  377. fmt_table, "beacon_silence_rssi_a:",
  378. le32_to_cpu(general->beacon_silence_rssi_a),
  379. accum_general->beacon_silence_rssi_a,
  380. delta_general->beacon_silence_rssi_a,
  381. max_general->beacon_silence_rssi_a);
  382. pos += scnprintf(buf + pos, bufsz - pos,
  383. fmt_table, "beacon_silence_rssi_b:",
  384. le32_to_cpu(general->beacon_silence_rssi_b),
  385. accum_general->beacon_silence_rssi_b,
  386. delta_general->beacon_silence_rssi_b,
  387. max_general->beacon_silence_rssi_b);
  388. pos += scnprintf(buf + pos, bufsz - pos,
  389. fmt_table, "beacon_silence_rssi_c:",
  390. le32_to_cpu(general->beacon_silence_rssi_c),
  391. accum_general->beacon_silence_rssi_c,
  392. delta_general->beacon_silence_rssi_c,
  393. max_general->beacon_silence_rssi_c);
  394. pos += scnprintf(buf + pos, bufsz - pos,
  395. fmt_table, "interference_data_flag:",
  396. le32_to_cpu(general->interference_data_flag),
  397. accum_general->interference_data_flag,
  398. delta_general->interference_data_flag,
  399. max_general->interference_data_flag);
  400. pos += scnprintf(buf + pos, bufsz - pos,
  401. fmt_table, "channel_load:",
  402. le32_to_cpu(general->channel_load),
  403. accum_general->channel_load,
  404. delta_general->channel_load,
  405. max_general->channel_load);
  406. pos += scnprintf(buf + pos, bufsz - pos,
  407. fmt_table, "dsp_false_alarms:",
  408. le32_to_cpu(general->dsp_false_alarms),
  409. accum_general->dsp_false_alarms,
  410. delta_general->dsp_false_alarms,
  411. max_general->dsp_false_alarms);
  412. pos += scnprintf(buf + pos, bufsz - pos,
  413. fmt_table, "beacon_rssi_a:",
  414. le32_to_cpu(general->beacon_rssi_a),
  415. accum_general->beacon_rssi_a,
  416. delta_general->beacon_rssi_a,
  417. max_general->beacon_rssi_a);
  418. pos += scnprintf(buf + pos, bufsz - pos,
  419. fmt_table, "beacon_rssi_b:",
  420. le32_to_cpu(general->beacon_rssi_b),
  421. accum_general->beacon_rssi_b,
  422. delta_general->beacon_rssi_b,
  423. max_general->beacon_rssi_b);
  424. pos += scnprintf(buf + pos, bufsz - pos,
  425. fmt_table, "beacon_rssi_c:",
  426. le32_to_cpu(general->beacon_rssi_c),
  427. accum_general->beacon_rssi_c,
  428. delta_general->beacon_rssi_c,
  429. max_general->beacon_rssi_c);
  430. pos += scnprintf(buf + pos, bufsz - pos,
  431. fmt_table, "beacon_energy_a:",
  432. le32_to_cpu(general->beacon_energy_a),
  433. accum_general->beacon_energy_a,
  434. delta_general->beacon_energy_a,
  435. max_general->beacon_energy_a);
  436. pos += scnprintf(buf + pos, bufsz - pos,
  437. fmt_table, "beacon_energy_b:",
  438. le32_to_cpu(general->beacon_energy_b),
  439. accum_general->beacon_energy_b,
  440. delta_general->beacon_energy_b,
  441. max_general->beacon_energy_b);
  442. pos += scnprintf(buf + pos, bufsz - pos,
  443. fmt_table, "beacon_energy_c:",
  444. le32_to_cpu(general->beacon_energy_c),
  445. accum_general->beacon_energy_c,
  446. delta_general->beacon_energy_c,
  447. max_general->beacon_energy_c);
  448. pos += scnprintf(buf + pos, bufsz - pos,
  449. fmt_header, "Statistics_Rx - OFDM_HT:");
  450. pos += scnprintf(buf + pos, bufsz - pos,
  451. fmt_table, "plcp_err:",
  452. le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
  453. delta_ht->plcp_err, max_ht->plcp_err);
  454. pos += scnprintf(buf + pos, bufsz - pos,
  455. fmt_table, "overrun_err:",
  456. le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
  457. delta_ht->overrun_err, max_ht->overrun_err);
  458. pos += scnprintf(buf + pos, bufsz - pos,
  459. fmt_table, "early_overrun_err:",
  460. le32_to_cpu(ht->early_overrun_err),
  461. accum_ht->early_overrun_err,
  462. delta_ht->early_overrun_err,
  463. max_ht->early_overrun_err);
  464. pos += scnprintf(buf + pos, bufsz - pos,
  465. fmt_table, "crc32_good:",
  466. le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
  467. delta_ht->crc32_good, max_ht->crc32_good);
  468. pos += scnprintf(buf + pos, bufsz - pos,
  469. fmt_table, "crc32_err:",
  470. le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
  471. delta_ht->crc32_err, max_ht->crc32_err);
  472. pos += scnprintf(buf + pos, bufsz - pos,
  473. fmt_table, "mh_format_err:",
  474. le32_to_cpu(ht->mh_format_err),
  475. accum_ht->mh_format_err,
  476. delta_ht->mh_format_err, max_ht->mh_format_err);
  477. pos += scnprintf(buf + pos, bufsz - pos,
  478. fmt_table, "agg_crc32_good:",
  479. le32_to_cpu(ht->agg_crc32_good),
  480. accum_ht->agg_crc32_good,
  481. delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
  482. pos += scnprintf(buf + pos, bufsz - pos,
  483. fmt_table, "agg_mpdu_cnt:",
  484. le32_to_cpu(ht->agg_mpdu_cnt),
  485. accum_ht->agg_mpdu_cnt,
  486. delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
  487. pos += scnprintf(buf + pos, bufsz - pos,
  488. fmt_table, "agg_cnt:",
  489. le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
  490. delta_ht->agg_cnt, max_ht->agg_cnt);
  491. pos += scnprintf(buf + pos, bufsz - pos,
  492. fmt_table, "unsupport_mcs:",
  493. le32_to_cpu(ht->unsupport_mcs),
  494. accum_ht->unsupport_mcs,
  495. delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
  496. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  497. kfree(buf);
  498. return ret;
  499. }
  500. ssize_t iwl_ucode_tx_stats_read(struct file *file,
  501. char __user *user_buf,
  502. size_t count, loff_t *ppos)
  503. {
  504. struct iwl_priv *priv = file->private_data;
  505. int pos = 0;
  506. char *buf;
  507. int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
  508. ssize_t ret;
  509. struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
  510. if (!iwl_is_alive(priv))
  511. return -EAGAIN;
  512. buf = kzalloc(bufsz, GFP_KERNEL);
  513. if (!buf) {
  514. IWL_ERR(priv, "Can not allocate Buffer\n");
  515. return -ENOMEM;
  516. }
  517. /* the statistic information display here is based on
  518. * the last statistics notification from uCode
  519. * might not reflect the current uCode activity
  520. */
  521. if (priv->cfg->bt_params &&
  522. priv->cfg->bt_params->bt_statistics) {
  523. tx = &priv->_agn.statistics_bt.tx;
  524. accum_tx = &priv->_agn.accum_statistics_bt.tx;
  525. delta_tx = &priv->_agn.delta_statistics_bt.tx;
  526. max_tx = &priv->_agn.max_delta_bt.tx;
  527. } else {
  528. tx = &priv->_agn.statistics.tx;
  529. accum_tx = &priv->_agn.accum_statistics.tx;
  530. delta_tx = &priv->_agn.delta_statistics.tx;
  531. max_tx = &priv->_agn.max_delta.tx;
  532. }
  533. pos += iwl_statistics_flag(priv, buf, bufsz);
  534. pos += scnprintf(buf + pos, bufsz - pos,
  535. fmt_header, "Statistics_Tx:");
  536. pos += scnprintf(buf + pos, bufsz - pos,
  537. fmt_table, "preamble:",
  538. le32_to_cpu(tx->preamble_cnt),
  539. accum_tx->preamble_cnt,
  540. delta_tx->preamble_cnt, max_tx->preamble_cnt);
  541. pos += scnprintf(buf + pos, bufsz - pos,
  542. fmt_table, "rx_detected_cnt:",
  543. le32_to_cpu(tx->rx_detected_cnt),
  544. accum_tx->rx_detected_cnt,
  545. delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
  546. pos += scnprintf(buf + pos, bufsz - pos,
  547. fmt_table, "bt_prio_defer_cnt:",
  548. le32_to_cpu(tx->bt_prio_defer_cnt),
  549. accum_tx->bt_prio_defer_cnt,
  550. delta_tx->bt_prio_defer_cnt,
  551. max_tx->bt_prio_defer_cnt);
  552. pos += scnprintf(buf + pos, bufsz - pos,
  553. fmt_table, "bt_prio_kill_cnt:",
  554. le32_to_cpu(tx->bt_prio_kill_cnt),
  555. accum_tx->bt_prio_kill_cnt,
  556. delta_tx->bt_prio_kill_cnt,
  557. max_tx->bt_prio_kill_cnt);
  558. pos += scnprintf(buf + pos, bufsz - pos,
  559. fmt_table, "few_bytes_cnt:",
  560. le32_to_cpu(tx->few_bytes_cnt),
  561. accum_tx->few_bytes_cnt,
  562. delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
  563. pos += scnprintf(buf + pos, bufsz - pos,
  564. fmt_table, "cts_timeout:",
  565. le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
  566. delta_tx->cts_timeout, max_tx->cts_timeout);
  567. pos += scnprintf(buf + pos, bufsz - pos,
  568. fmt_table, "ack_timeout:",
  569. le32_to_cpu(tx->ack_timeout),
  570. accum_tx->ack_timeout,
  571. delta_tx->ack_timeout, max_tx->ack_timeout);
  572. pos += scnprintf(buf + pos, bufsz - pos,
  573. fmt_table, "expected_ack_cnt:",
  574. le32_to_cpu(tx->expected_ack_cnt),
  575. accum_tx->expected_ack_cnt,
  576. delta_tx->expected_ack_cnt,
  577. max_tx->expected_ack_cnt);
  578. pos += scnprintf(buf + pos, bufsz - pos,
  579. fmt_table, "actual_ack_cnt:",
  580. le32_to_cpu(tx->actual_ack_cnt),
  581. accum_tx->actual_ack_cnt,
  582. delta_tx->actual_ack_cnt,
  583. max_tx->actual_ack_cnt);
  584. pos += scnprintf(buf + pos, bufsz - pos,
  585. fmt_table, "dump_msdu_cnt:",
  586. le32_to_cpu(tx->dump_msdu_cnt),
  587. accum_tx->dump_msdu_cnt,
  588. delta_tx->dump_msdu_cnt,
  589. max_tx->dump_msdu_cnt);
  590. pos += scnprintf(buf + pos, bufsz - pos,
  591. fmt_table, "abort_nxt_frame_mismatch:",
  592. le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
  593. accum_tx->burst_abort_next_frame_mismatch_cnt,
  594. delta_tx->burst_abort_next_frame_mismatch_cnt,
  595. max_tx->burst_abort_next_frame_mismatch_cnt);
  596. pos += scnprintf(buf + pos, bufsz - pos,
  597. fmt_table, "abort_missing_nxt_frame:",
  598. le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
  599. accum_tx->burst_abort_missing_next_frame_cnt,
  600. delta_tx->burst_abort_missing_next_frame_cnt,
  601. max_tx->burst_abort_missing_next_frame_cnt);
  602. pos += scnprintf(buf + pos, bufsz - pos,
  603. fmt_table, "cts_timeout_collision:",
  604. le32_to_cpu(tx->cts_timeout_collision),
  605. accum_tx->cts_timeout_collision,
  606. delta_tx->cts_timeout_collision,
  607. max_tx->cts_timeout_collision);
  608. pos += scnprintf(buf + pos, bufsz - pos,
  609. fmt_table, "ack_ba_timeout_collision:",
  610. le32_to_cpu(tx->ack_or_ba_timeout_collision),
  611. accum_tx->ack_or_ba_timeout_collision,
  612. delta_tx->ack_or_ba_timeout_collision,
  613. max_tx->ack_or_ba_timeout_collision);
  614. pos += scnprintf(buf + pos, bufsz - pos,
  615. fmt_table, "agg ba_timeout:",
  616. le32_to_cpu(tx->agg.ba_timeout),
  617. accum_tx->agg.ba_timeout,
  618. delta_tx->agg.ba_timeout,
  619. max_tx->agg.ba_timeout);
  620. pos += scnprintf(buf + pos, bufsz - pos,
  621. fmt_table, "agg ba_resched_frames:",
  622. le32_to_cpu(tx->agg.ba_reschedule_frames),
  623. accum_tx->agg.ba_reschedule_frames,
  624. delta_tx->agg.ba_reschedule_frames,
  625. max_tx->agg.ba_reschedule_frames);
  626. pos += scnprintf(buf + pos, bufsz - pos,
  627. fmt_table, "agg scd_query_agg_frame:",
  628. le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
  629. accum_tx->agg.scd_query_agg_frame_cnt,
  630. delta_tx->agg.scd_query_agg_frame_cnt,
  631. max_tx->agg.scd_query_agg_frame_cnt);
  632. pos += scnprintf(buf + pos, bufsz - pos,
  633. fmt_table, "agg scd_query_no_agg:",
  634. le32_to_cpu(tx->agg.scd_query_no_agg),
  635. accum_tx->agg.scd_query_no_agg,
  636. delta_tx->agg.scd_query_no_agg,
  637. max_tx->agg.scd_query_no_agg);
  638. pos += scnprintf(buf + pos, bufsz - pos,
  639. fmt_table, "agg scd_query_agg:",
  640. le32_to_cpu(tx->agg.scd_query_agg),
  641. accum_tx->agg.scd_query_agg,
  642. delta_tx->agg.scd_query_agg,
  643. max_tx->agg.scd_query_agg);
  644. pos += scnprintf(buf + pos, bufsz - pos,
  645. fmt_table, "agg scd_query_mismatch:",
  646. le32_to_cpu(tx->agg.scd_query_mismatch),
  647. accum_tx->agg.scd_query_mismatch,
  648. delta_tx->agg.scd_query_mismatch,
  649. max_tx->agg.scd_query_mismatch);
  650. pos += scnprintf(buf + pos, bufsz - pos,
  651. fmt_table, "agg frame_not_ready:",
  652. le32_to_cpu(tx->agg.frame_not_ready),
  653. accum_tx->agg.frame_not_ready,
  654. delta_tx->agg.frame_not_ready,
  655. max_tx->agg.frame_not_ready);
  656. pos += scnprintf(buf + pos, bufsz - pos,
  657. fmt_table, "agg underrun:",
  658. le32_to_cpu(tx->agg.underrun),
  659. accum_tx->agg.underrun,
  660. delta_tx->agg.underrun, max_tx->agg.underrun);
  661. pos += scnprintf(buf + pos, bufsz - pos,
  662. fmt_table, "agg bt_prio_kill:",
  663. le32_to_cpu(tx->agg.bt_prio_kill),
  664. accum_tx->agg.bt_prio_kill,
  665. delta_tx->agg.bt_prio_kill,
  666. max_tx->agg.bt_prio_kill);
  667. pos += scnprintf(buf + pos, bufsz - pos,
  668. fmt_table, "agg rx_ba_rsp_cnt:",
  669. le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
  670. accum_tx->agg.rx_ba_rsp_cnt,
  671. delta_tx->agg.rx_ba_rsp_cnt,
  672. max_tx->agg.rx_ba_rsp_cnt);
  673. if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) {
  674. pos += scnprintf(buf + pos, bufsz - pos,
  675. "tx power: (1/2 dB step)\n");
  676. if ((priv->cfg->valid_tx_ant & ANT_A) && tx->tx_power.ant_a)
  677. pos += scnprintf(buf + pos, bufsz - pos,
  678. fmt_hex, "antenna A:",
  679. tx->tx_power.ant_a);
  680. if ((priv->cfg->valid_tx_ant & ANT_B) && tx->tx_power.ant_b)
  681. pos += scnprintf(buf + pos, bufsz - pos,
  682. fmt_hex, "antenna B:",
  683. tx->tx_power.ant_b);
  684. if ((priv->cfg->valid_tx_ant & ANT_C) && tx->tx_power.ant_c)
  685. pos += scnprintf(buf + pos, bufsz - pos,
  686. fmt_hex, "antenna C:",
  687. tx->tx_power.ant_c);
  688. }
  689. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  690. kfree(buf);
  691. return ret;
  692. }
  693. ssize_t iwl_ucode_general_stats_read(struct file *file, char __user *user_buf,
  694. size_t count, loff_t *ppos)
  695. {
  696. struct iwl_priv *priv = file->private_data;
  697. int pos = 0;
  698. char *buf;
  699. int bufsz = sizeof(struct statistics_general) * 10 + 300;
  700. ssize_t ret;
  701. struct statistics_general_common *general, *accum_general;
  702. struct statistics_general_common *delta_general, *max_general;
  703. struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
  704. struct statistics_div *div, *accum_div, *delta_div, *max_div;
  705. if (!iwl_is_alive(priv))
  706. return -EAGAIN;
  707. buf = kzalloc(bufsz, GFP_KERNEL);
  708. if (!buf) {
  709. IWL_ERR(priv, "Can not allocate Buffer\n");
  710. return -ENOMEM;
  711. }
  712. /* the statistic information display here is based on
  713. * the last statistics notification from uCode
  714. * might not reflect the current uCode activity
  715. */
  716. if (priv->cfg->bt_params &&
  717. priv->cfg->bt_params->bt_statistics) {
  718. general = &priv->_agn.statistics_bt.general.common;
  719. dbg = &priv->_agn.statistics_bt.general.common.dbg;
  720. div = &priv->_agn.statistics_bt.general.common.div;
  721. accum_general = &priv->_agn.accum_statistics_bt.general.common;
  722. accum_dbg = &priv->_agn.accum_statistics_bt.general.common.dbg;
  723. accum_div = &priv->_agn.accum_statistics_bt.general.common.div;
  724. delta_general = &priv->_agn.delta_statistics_bt.general.common;
  725. max_general = &priv->_agn.max_delta_bt.general.common;
  726. delta_dbg = &priv->_agn.delta_statistics_bt.general.common.dbg;
  727. max_dbg = &priv->_agn.max_delta_bt.general.common.dbg;
  728. delta_div = &priv->_agn.delta_statistics_bt.general.common.div;
  729. max_div = &priv->_agn.max_delta_bt.general.common.div;
  730. } else {
  731. general = &priv->_agn.statistics.general.common;
  732. dbg = &priv->_agn.statistics.general.common.dbg;
  733. div = &priv->_agn.statistics.general.common.div;
  734. accum_general = &priv->_agn.accum_statistics.general.common;
  735. accum_dbg = &priv->_agn.accum_statistics.general.common.dbg;
  736. accum_div = &priv->_agn.accum_statistics.general.common.div;
  737. delta_general = &priv->_agn.delta_statistics.general.common;
  738. max_general = &priv->_agn.max_delta.general.common;
  739. delta_dbg = &priv->_agn.delta_statistics.general.common.dbg;
  740. max_dbg = &priv->_agn.max_delta.general.common.dbg;
  741. delta_div = &priv->_agn.delta_statistics.general.common.div;
  742. max_div = &priv->_agn.max_delta.general.common.div;
  743. }
  744. pos += iwl_statistics_flag(priv, buf, bufsz);
  745. pos += scnprintf(buf + pos, bufsz - pos,
  746. fmt_header, "Statistics_General:");
  747. pos += scnprintf(buf + pos, bufsz - pos,
  748. fmt_value, "temperature:",
  749. le32_to_cpu(general->temperature));
  750. pos += scnprintf(buf + pos, bufsz - pos,
  751. fmt_value, "temperature_m:",
  752. le32_to_cpu(general->temperature_m));
  753. pos += scnprintf(buf + pos, bufsz - pos,
  754. fmt_value, "ttl_timestamp:",
  755. le32_to_cpu(general->ttl_timestamp));
  756. pos += scnprintf(buf + pos, bufsz - pos,
  757. fmt_table, "burst_check:",
  758. le32_to_cpu(dbg->burst_check),
  759. accum_dbg->burst_check,
  760. delta_dbg->burst_check, max_dbg->burst_check);
  761. pos += scnprintf(buf + pos, bufsz - pos,
  762. fmt_table, "burst_count:",
  763. le32_to_cpu(dbg->burst_count),
  764. accum_dbg->burst_count,
  765. delta_dbg->burst_count, max_dbg->burst_count);
  766. pos += scnprintf(buf + pos, bufsz - pos,
  767. fmt_table, "wait_for_silence_timeout_count:",
  768. le32_to_cpu(dbg->wait_for_silence_timeout_cnt),
  769. accum_dbg->wait_for_silence_timeout_cnt,
  770. delta_dbg->wait_for_silence_timeout_cnt,
  771. max_dbg->wait_for_silence_timeout_cnt);
  772. pos += scnprintf(buf + pos, bufsz - pos,
  773. fmt_table, "sleep_time:",
  774. le32_to_cpu(general->sleep_time),
  775. accum_general->sleep_time,
  776. delta_general->sleep_time, max_general->sleep_time);
  777. pos += scnprintf(buf + pos, bufsz - pos,
  778. fmt_table, "slots_out:",
  779. le32_to_cpu(general->slots_out),
  780. accum_general->slots_out,
  781. delta_general->slots_out, max_general->slots_out);
  782. pos += scnprintf(buf + pos, bufsz - pos,
  783. fmt_table, "slots_idle:",
  784. le32_to_cpu(general->slots_idle),
  785. accum_general->slots_idle,
  786. delta_general->slots_idle, max_general->slots_idle);
  787. pos += scnprintf(buf + pos, bufsz - pos,
  788. fmt_table, "tx_on_a:",
  789. le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
  790. delta_div->tx_on_a, max_div->tx_on_a);
  791. pos += scnprintf(buf + pos, bufsz - pos,
  792. fmt_table, "tx_on_b:",
  793. le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
  794. delta_div->tx_on_b, max_div->tx_on_b);
  795. pos += scnprintf(buf + pos, bufsz - pos,
  796. fmt_table, "exec_time:",
  797. le32_to_cpu(div->exec_time), accum_div->exec_time,
  798. delta_div->exec_time, max_div->exec_time);
  799. pos += scnprintf(buf + pos, bufsz - pos,
  800. fmt_table, "probe_time:",
  801. le32_to_cpu(div->probe_time), accum_div->probe_time,
  802. delta_div->probe_time, max_div->probe_time);
  803. pos += scnprintf(buf + pos, bufsz - pos,
  804. fmt_table, "rx_enable_counter:",
  805. le32_to_cpu(general->rx_enable_counter),
  806. accum_general->rx_enable_counter,
  807. delta_general->rx_enable_counter,
  808. max_general->rx_enable_counter);
  809. pos += scnprintf(buf + pos, bufsz - pos,
  810. fmt_table, "num_of_sos_states:",
  811. le32_to_cpu(general->num_of_sos_states),
  812. accum_general->num_of_sos_states,
  813. delta_general->num_of_sos_states,
  814. max_general->num_of_sos_states);
  815. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  816. kfree(buf);
  817. return ret;
  818. }
  819. ssize_t iwl_ucode_bt_stats_read(struct file *file,
  820. char __user *user_buf,
  821. size_t count, loff_t *ppos)
  822. {
  823. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  824. int pos = 0;
  825. char *buf;
  826. int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200;
  827. ssize_t ret;
  828. struct statistics_bt_activity *bt, *accum_bt;
  829. if (!iwl_is_alive(priv))
  830. return -EAGAIN;
  831. /* make request to uCode to retrieve statistics information */
  832. mutex_lock(&priv->mutex);
  833. ret = iwl_send_statistics_request(priv, CMD_SYNC, false);
  834. mutex_unlock(&priv->mutex);
  835. if (ret) {
  836. IWL_ERR(priv,
  837. "Error sending statistics request: %zd\n", ret);
  838. return -EAGAIN;
  839. }
  840. buf = kzalloc(bufsz, GFP_KERNEL);
  841. if (!buf) {
  842. IWL_ERR(priv, "Can not allocate Buffer\n");
  843. return -ENOMEM;
  844. }
  845. /*
  846. * the statistic information display here is based on
  847. * the last statistics notification from uCode
  848. * might not reflect the current uCode activity
  849. */
  850. bt = &priv->_agn.statistics_bt.general.activity;
  851. accum_bt = &priv->_agn.accum_statistics_bt.general.activity;
  852. pos += iwl_statistics_flag(priv, buf, bufsz);
  853. pos += scnprintf(buf + pos, bufsz - pos, "Statistics_BT:\n");
  854. pos += scnprintf(buf + pos, bufsz - pos,
  855. "\t\t\tcurrent\t\t\taccumulative\n");
  856. pos += scnprintf(buf + pos, bufsz - pos,
  857. "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
  858. le32_to_cpu(bt->hi_priority_tx_req_cnt),
  859. accum_bt->hi_priority_tx_req_cnt);
  860. pos += scnprintf(buf + pos, bufsz - pos,
  861. "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
  862. le32_to_cpu(bt->hi_priority_tx_denied_cnt),
  863. accum_bt->hi_priority_tx_denied_cnt);
  864. pos += scnprintf(buf + pos, bufsz - pos,
  865. "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
  866. le32_to_cpu(bt->lo_priority_tx_req_cnt),
  867. accum_bt->lo_priority_tx_req_cnt);
  868. pos += scnprintf(buf + pos, bufsz - pos,
  869. "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
  870. le32_to_cpu(bt->lo_priority_tx_denied_cnt),
  871. accum_bt->lo_priority_tx_denied_cnt);
  872. pos += scnprintf(buf + pos, bufsz - pos,
  873. "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
  874. le32_to_cpu(bt->hi_priority_rx_req_cnt),
  875. accum_bt->hi_priority_rx_req_cnt);
  876. pos += scnprintf(buf + pos, bufsz - pos,
  877. "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
  878. le32_to_cpu(bt->hi_priority_rx_denied_cnt),
  879. accum_bt->hi_priority_rx_denied_cnt);
  880. pos += scnprintf(buf + pos, bufsz - pos,
  881. "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
  882. le32_to_cpu(bt->lo_priority_rx_req_cnt),
  883. accum_bt->lo_priority_rx_req_cnt);
  884. pos += scnprintf(buf + pos, bufsz - pos,
  885. "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
  886. le32_to_cpu(bt->lo_priority_rx_denied_cnt),
  887. accum_bt->lo_priority_rx_denied_cnt);
  888. pos += scnprintf(buf + pos, bufsz - pos,
  889. "(rx)num_bt_kills:\t\t%u\t\t\t%u\n",
  890. le32_to_cpu(priv->_agn.statistics_bt.rx.
  891. general.num_bt_kills),
  892. priv->_agn.accum_statistics_bt.rx.
  893. general.num_bt_kills);
  894. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  895. kfree(buf);
  896. return ret;
  897. }
  898. ssize_t iwl_reply_tx_error_read(struct file *file,
  899. char __user *user_buf,
  900. size_t count, loff_t *ppos)
  901. {
  902. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  903. int pos = 0;
  904. char *buf;
  905. int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) +
  906. (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200;
  907. ssize_t ret;
  908. if (!iwl_is_alive(priv))
  909. return -EAGAIN;
  910. buf = kzalloc(bufsz, GFP_KERNEL);
  911. if (!buf) {
  912. IWL_ERR(priv, "Can not allocate Buffer\n");
  913. return -ENOMEM;
  914. }
  915. pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n");
  916. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n",
  917. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY),
  918. priv->_agn.reply_tx_stats.pp_delay);
  919. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  920. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES),
  921. priv->_agn.reply_tx_stats.pp_few_bytes);
  922. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  923. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO),
  924. priv->_agn.reply_tx_stats.pp_bt_prio);
  925. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  926. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD),
  927. priv->_agn.reply_tx_stats.pp_quiet_period);
  928. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  929. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK),
  930. priv->_agn.reply_tx_stats.pp_calc_ttak);
  931. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  932. iwl_get_tx_fail_reason(
  933. TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY),
  934. priv->_agn.reply_tx_stats.int_crossed_retry);
  935. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  936. iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT),
  937. priv->_agn.reply_tx_stats.short_limit);
  938. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  939. iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT),
  940. priv->_agn.reply_tx_stats.long_limit);
  941. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  942. iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN),
  943. priv->_agn.reply_tx_stats.fifo_underrun);
  944. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  945. iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW),
  946. priv->_agn.reply_tx_stats.drain_flow);
  947. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  948. iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH),
  949. priv->_agn.reply_tx_stats.rfkill_flush);
  950. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  951. iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE),
  952. priv->_agn.reply_tx_stats.life_expire);
  953. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  954. iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS),
  955. priv->_agn.reply_tx_stats.dest_ps);
  956. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  957. iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED),
  958. priv->_agn.reply_tx_stats.host_abort);
  959. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  960. iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY),
  961. priv->_agn.reply_tx_stats.pp_delay);
  962. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  963. iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID),
  964. priv->_agn.reply_tx_stats.sta_invalid);
  965. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  966. iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED),
  967. priv->_agn.reply_tx_stats.frag_drop);
  968. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  969. iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE),
  970. priv->_agn.reply_tx_stats.tid_disable);
  971. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  972. iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED),
  973. priv->_agn.reply_tx_stats.fifo_flush);
  974. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  975. iwl_get_tx_fail_reason(
  976. TX_STATUS_FAIL_INSUFFICIENT_CF_POLL),
  977. priv->_agn.reply_tx_stats.insuff_cf_poll);
  978. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  979. iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX),
  980. priv->_agn.reply_tx_stats.fail_hw_drop);
  981. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  982. iwl_get_tx_fail_reason(
  983. TX_STATUS_FAIL_NO_BEACON_ON_RADAR),
  984. priv->_agn.reply_tx_stats.sta_color_mismatch);
  985. pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
  986. priv->_agn.reply_tx_stats.unknown);
  987. pos += scnprintf(buf + pos, bufsz - pos,
  988. "\nStatistics_Agg_TX_Error:\n");
  989. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  990. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK),
  991. priv->_agn.reply_agg_tx_stats.underrun);
  992. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  993. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK),
  994. priv->_agn.reply_agg_tx_stats.bt_prio);
  995. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  996. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK),
  997. priv->_agn.reply_agg_tx_stats.few_bytes);
  998. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  999. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK),
  1000. priv->_agn.reply_agg_tx_stats.abort);
  1001. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1002. iwl_get_agg_tx_fail_reason(
  1003. AGG_TX_STATE_LAST_SENT_TTL_MSK),
  1004. priv->_agn.reply_agg_tx_stats.last_sent_ttl);
  1005. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1006. iwl_get_agg_tx_fail_reason(
  1007. AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK),
  1008. priv->_agn.reply_agg_tx_stats.last_sent_try);
  1009. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1010. iwl_get_agg_tx_fail_reason(
  1011. AGG_TX_STATE_LAST_SENT_BT_KILL_MSK),
  1012. priv->_agn.reply_agg_tx_stats.last_sent_bt_kill);
  1013. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1014. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK),
  1015. priv->_agn.reply_agg_tx_stats.scd_query);
  1016. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1017. iwl_get_agg_tx_fail_reason(
  1018. AGG_TX_STATE_TEST_BAD_CRC32_MSK),
  1019. priv->_agn.reply_agg_tx_stats.bad_crc32);
  1020. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1021. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK),
  1022. priv->_agn.reply_agg_tx_stats.response);
  1023. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1024. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK),
  1025. priv->_agn.reply_agg_tx_stats.dump_tx);
  1026. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1027. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK),
  1028. priv->_agn.reply_agg_tx_stats.delay_tx);
  1029. pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
  1030. priv->_agn.reply_agg_tx_stats.unknown);
  1031. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1032. kfree(buf);
  1033. return ret;
  1034. }