iwl-agn-debugfs.c 41 KB

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