iwl-debugfs.c 80 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457
  1. /******************************************************************************
  2. *
  3. * GPL LICENSE SUMMARY
  4. *
  5. * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of version 2 of the GNU General Public License as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  19. * USA
  20. *
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called LICENSE.GPL.
  23. *
  24. * Contact Information:
  25. * Intel Linux Wireless <ilw@linux.intel.com>
  26. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  27. *****************************************************************************/
  28. #include <linux/slab.h>
  29. #include <linux/kernel.h>
  30. #include <linux/module.h>
  31. #include <linux/debugfs.h>
  32. #include <linux/ieee80211.h>
  33. #include <net/mac80211.h>
  34. #include "iwl-dev.h"
  35. #include "iwl-debug.h"
  36. #include "iwl-core.h"
  37. #include "iwl-io.h"
  38. #include "iwl-agn.h"
  39. /* create and remove of files */
  40. #define DEBUGFS_ADD_FILE(name, parent, mode) do { \
  41. if (!debugfs_create_file(#name, mode, parent, priv, \
  42. &iwl_dbgfs_##name##_ops)) \
  43. goto err; \
  44. } while (0)
  45. #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
  46. struct dentry *__tmp; \
  47. __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \
  48. parent, ptr); \
  49. if (IS_ERR(__tmp) || !__tmp) \
  50. goto err; \
  51. } while (0)
  52. #define DEBUGFS_ADD_X32(name, parent, ptr) do { \
  53. struct dentry *__tmp; \
  54. __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \
  55. parent, ptr); \
  56. if (IS_ERR(__tmp) || !__tmp) \
  57. goto err; \
  58. } while (0)
  59. /* file operation */
  60. #define DEBUGFS_READ_FUNC(name) \
  61. static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
  62. char __user *user_buf, \
  63. size_t count, loff_t *ppos);
  64. #define DEBUGFS_WRITE_FUNC(name) \
  65. static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
  66. const char __user *user_buf, \
  67. size_t count, loff_t *ppos);
  68. static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file)
  69. {
  70. file->private_data = inode->i_private;
  71. return 0;
  72. }
  73. #define DEBUGFS_READ_FILE_OPS(name) \
  74. DEBUGFS_READ_FUNC(name); \
  75. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  76. .read = iwl_dbgfs_##name##_read, \
  77. .open = iwl_dbgfs_open_file_generic, \
  78. .llseek = generic_file_llseek, \
  79. };
  80. #define DEBUGFS_WRITE_FILE_OPS(name) \
  81. DEBUGFS_WRITE_FUNC(name); \
  82. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  83. .write = iwl_dbgfs_##name##_write, \
  84. .open = iwl_dbgfs_open_file_generic, \
  85. .llseek = generic_file_llseek, \
  86. };
  87. #define DEBUGFS_READ_WRITE_FILE_OPS(name) \
  88. DEBUGFS_READ_FUNC(name); \
  89. DEBUGFS_WRITE_FUNC(name); \
  90. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  91. .write = iwl_dbgfs_##name##_write, \
  92. .read = iwl_dbgfs_##name##_read, \
  93. .open = iwl_dbgfs_open_file_generic, \
  94. .llseek = generic_file_llseek, \
  95. };
  96. static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
  97. char __user *user_buf,
  98. size_t count, loff_t *ppos) {
  99. struct iwl_priv *priv = file->private_data;
  100. char *buf;
  101. int pos = 0;
  102. int cnt;
  103. ssize_t ret;
  104. const size_t bufsz = 100 +
  105. sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
  106. buf = kzalloc(bufsz, GFP_KERNEL);
  107. if (!buf)
  108. return -ENOMEM;
  109. pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
  110. for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
  111. pos += scnprintf(buf + pos, bufsz - pos,
  112. "\t%25s\t\t: %u\n",
  113. get_mgmt_string(cnt),
  114. priv->tx_stats.mgmt[cnt]);
  115. }
  116. pos += scnprintf(buf + pos, bufsz - pos, "Control\n");
  117. for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
  118. pos += scnprintf(buf + pos, bufsz - pos,
  119. "\t%25s\t\t: %u\n",
  120. get_ctrl_string(cnt),
  121. priv->tx_stats.ctrl[cnt]);
  122. }
  123. pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
  124. pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
  125. priv->tx_stats.data_cnt);
  126. pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
  127. priv->tx_stats.data_bytes);
  128. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  129. kfree(buf);
  130. return ret;
  131. }
  132. static ssize_t iwl_dbgfs_clear_traffic_statistics_write(struct file *file,
  133. const char __user *user_buf,
  134. size_t count, loff_t *ppos)
  135. {
  136. struct iwl_priv *priv = file->private_data;
  137. u32 clear_flag;
  138. char buf[8];
  139. int buf_size;
  140. memset(buf, 0, sizeof(buf));
  141. buf_size = min(count, sizeof(buf) - 1);
  142. if (copy_from_user(buf, user_buf, buf_size))
  143. return -EFAULT;
  144. if (sscanf(buf, "%x", &clear_flag) != 1)
  145. return -EFAULT;
  146. iwl_clear_traffic_stats(priv);
  147. return count;
  148. }
  149. static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
  150. char __user *user_buf,
  151. size_t count, loff_t *ppos) {
  152. struct iwl_priv *priv = file->private_data;
  153. char *buf;
  154. int pos = 0;
  155. int cnt;
  156. ssize_t ret;
  157. const size_t bufsz = 100 +
  158. sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
  159. buf = kzalloc(bufsz, GFP_KERNEL);
  160. if (!buf)
  161. return -ENOMEM;
  162. pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
  163. for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
  164. pos += scnprintf(buf + pos, bufsz - pos,
  165. "\t%25s\t\t: %u\n",
  166. get_mgmt_string(cnt),
  167. priv->rx_stats.mgmt[cnt]);
  168. }
  169. pos += scnprintf(buf + pos, bufsz - pos, "Control:\n");
  170. for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
  171. pos += scnprintf(buf + pos, bufsz - pos,
  172. "\t%25s\t\t: %u\n",
  173. get_ctrl_string(cnt),
  174. priv->rx_stats.ctrl[cnt]);
  175. }
  176. pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
  177. pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
  178. priv->rx_stats.data_cnt);
  179. pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
  180. priv->rx_stats.data_bytes);
  181. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  182. kfree(buf);
  183. return ret;
  184. }
  185. static ssize_t iwl_dbgfs_sram_read(struct file *file,
  186. char __user *user_buf,
  187. size_t count, loff_t *ppos)
  188. {
  189. u32 val = 0;
  190. char *buf;
  191. ssize_t ret;
  192. int i = 0;
  193. bool device_format = false;
  194. int offset = 0;
  195. int len = 0;
  196. int pos = 0;
  197. int sram;
  198. struct iwl_priv *priv = file->private_data;
  199. size_t bufsz;
  200. /* default is to dump the entire data segment */
  201. if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) {
  202. priv->dbgfs_sram_offset = 0x800000;
  203. if (priv->ucode_type == IWL_UCODE_INIT)
  204. priv->dbgfs_sram_len = priv->ucode_init.data.len;
  205. else
  206. priv->dbgfs_sram_len = priv->ucode_rt.data.len;
  207. }
  208. len = priv->dbgfs_sram_len;
  209. if (len == -4) {
  210. device_format = true;
  211. len = 4;
  212. }
  213. bufsz = 50 + len * 4;
  214. buf = kmalloc(bufsz, GFP_KERNEL);
  215. if (!buf)
  216. return -ENOMEM;
  217. pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n",
  218. len);
  219. pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n",
  220. priv->dbgfs_sram_offset);
  221. /* adjust sram address since reads are only on even u32 boundaries */
  222. offset = priv->dbgfs_sram_offset & 0x3;
  223. sram = priv->dbgfs_sram_offset & ~0x3;
  224. /* read the first u32 from sram */
  225. val = iwl_read_targ_mem(bus(priv), sram);
  226. for (; len; len--) {
  227. /* put the address at the start of every line */
  228. if (i == 0)
  229. pos += scnprintf(buf + pos, bufsz - pos,
  230. "%08X: ", sram + offset);
  231. if (device_format)
  232. pos += scnprintf(buf + pos, bufsz - pos,
  233. "%02x", (val >> (8 * (3 - offset))) & 0xff);
  234. else
  235. pos += scnprintf(buf + pos, bufsz - pos,
  236. "%02x ", (val >> (8 * offset)) & 0xff);
  237. /* if all bytes processed, read the next u32 from sram */
  238. if (++offset == 4) {
  239. sram += 4;
  240. offset = 0;
  241. val = iwl_read_targ_mem(bus(priv), sram);
  242. }
  243. /* put in extra spaces and split lines for human readability */
  244. if (++i == 16) {
  245. i = 0;
  246. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  247. } else if (!(i & 7)) {
  248. pos += scnprintf(buf + pos, bufsz - pos, " ");
  249. } else if (!(i & 3)) {
  250. pos += scnprintf(buf + pos, bufsz - pos, " ");
  251. }
  252. }
  253. if (i)
  254. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  255. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  256. kfree(buf);
  257. return ret;
  258. }
  259. static ssize_t iwl_dbgfs_sram_write(struct file *file,
  260. const char __user *user_buf,
  261. size_t count, loff_t *ppos)
  262. {
  263. struct iwl_priv *priv = file->private_data;
  264. char buf[64];
  265. int buf_size;
  266. u32 offset, len;
  267. memset(buf, 0, sizeof(buf));
  268. buf_size = min(count, sizeof(buf) - 1);
  269. if (copy_from_user(buf, user_buf, buf_size))
  270. return -EFAULT;
  271. if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
  272. priv->dbgfs_sram_offset = offset;
  273. priv->dbgfs_sram_len = len;
  274. } else if (sscanf(buf, "%x", &offset) == 1) {
  275. priv->dbgfs_sram_offset = offset;
  276. priv->dbgfs_sram_len = -4;
  277. } else {
  278. priv->dbgfs_sram_offset = 0;
  279. priv->dbgfs_sram_len = 0;
  280. }
  281. return count;
  282. }
  283. static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file,
  284. char __user *user_buf,
  285. size_t count, loff_t *ppos)
  286. {
  287. struct iwl_priv *priv = file->private_data;
  288. if (!priv->wowlan_sram)
  289. return -ENODATA;
  290. return simple_read_from_buffer(user_buf, count, ppos,
  291. priv->wowlan_sram,
  292. priv->ucode_wowlan.data.len);
  293. }
  294. static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
  295. size_t count, loff_t *ppos)
  296. {
  297. struct iwl_priv *priv = file->private_data;
  298. struct iwl_station_entry *station;
  299. int max_sta = hw_params(priv).max_stations;
  300. char *buf;
  301. int i, j, pos = 0;
  302. ssize_t ret;
  303. /* Add 30 for initial string */
  304. const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
  305. buf = kmalloc(bufsz, GFP_KERNEL);
  306. if (!buf)
  307. return -ENOMEM;
  308. pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n",
  309. priv->num_stations);
  310. for (i = 0; i < max_sta; i++) {
  311. station = &priv->stations[i];
  312. if (!station->used)
  313. continue;
  314. pos += scnprintf(buf + pos, bufsz - pos,
  315. "station %d - addr: %pM, flags: %#x\n",
  316. i, station->sta.sta.addr,
  317. station->sta.station_flags_msk);
  318. pos += scnprintf(buf + pos, bufsz - pos,
  319. "TID\tseq_num\ttxq_id\tframes\ttfds\t");
  320. pos += scnprintf(buf + pos, bufsz - pos,
  321. "start_idx\tbitmap\t\t\trate_n_flags\n");
  322. for (j = 0; j < MAX_TID_COUNT; j++) {
  323. pos += scnprintf(buf + pos, bufsz - pos,
  324. "%d:\t%#x\t%#x\t%u\t%u\t%u\t\t%#.16llx\t%#x",
  325. j, station->tid[j].seq_number,
  326. station->tid[j].agg.txq_id,
  327. station->tid[j].agg.frame_count,
  328. station->tid[j].tfds_in_queue,
  329. station->tid[j].agg.start_idx,
  330. station->tid[j].agg.bitmap,
  331. station->tid[j].agg.rate_n_flags);
  332. if (station->tid[j].agg.wait_for_ba)
  333. pos += scnprintf(buf + pos, bufsz - pos,
  334. " - waitforba");
  335. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  336. }
  337. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  338. }
  339. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  340. kfree(buf);
  341. return ret;
  342. }
  343. static ssize_t iwl_dbgfs_nvm_read(struct file *file,
  344. char __user *user_buf,
  345. size_t count,
  346. loff_t *ppos)
  347. {
  348. ssize_t ret;
  349. struct iwl_priv *priv = file->private_data;
  350. int pos = 0, ofs = 0, buf_size = 0;
  351. const u8 *ptr;
  352. char *buf;
  353. u16 eeprom_ver;
  354. size_t eeprom_len = priv->cfg->base_params->eeprom_size;
  355. buf_size = 4 * eeprom_len + 256;
  356. if (eeprom_len % 16) {
  357. IWL_ERR(priv, "NVM size is not multiple of 16.\n");
  358. return -ENODATA;
  359. }
  360. ptr = priv->eeprom;
  361. if (!ptr) {
  362. IWL_ERR(priv, "Invalid EEPROM/OTP memory\n");
  363. return -ENOMEM;
  364. }
  365. /* 4 characters for byte 0xYY */
  366. buf = kzalloc(buf_size, GFP_KERNEL);
  367. if (!buf) {
  368. IWL_ERR(priv, "Can not allocate Buffer\n");
  369. return -ENOMEM;
  370. }
  371. eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
  372. pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, "
  373. "version: 0x%x\n",
  374. (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
  375. ? "OTP" : "EEPROM", eeprom_ver);
  376. for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
  377. pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
  378. hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
  379. buf_size - pos, 0);
  380. pos += strlen(buf + pos);
  381. if (buf_size - pos > 0)
  382. buf[pos++] = '\n';
  383. }
  384. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  385. kfree(buf);
  386. return ret;
  387. }
  388. static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
  389. size_t count, loff_t *ppos)
  390. {
  391. struct iwl_priv *priv = file->private_data;
  392. struct ieee80211_channel *channels = NULL;
  393. const struct ieee80211_supported_band *supp_band = NULL;
  394. int pos = 0, i, bufsz = PAGE_SIZE;
  395. char *buf;
  396. ssize_t ret;
  397. if (!test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status))
  398. return -EAGAIN;
  399. buf = kzalloc(bufsz, GFP_KERNEL);
  400. if (!buf) {
  401. IWL_ERR(priv, "Can not allocate Buffer\n");
  402. return -ENOMEM;
  403. }
  404. supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
  405. if (supp_band) {
  406. channels = supp_band->channels;
  407. pos += scnprintf(buf + pos, bufsz - pos,
  408. "Displaying %d channels in 2.4GHz band 802.11bg):\n",
  409. supp_band->n_channels);
  410. for (i = 0; i < supp_band->n_channels; i++)
  411. pos += scnprintf(buf + pos, bufsz - pos,
  412. "%d: %ddBm: BSS%s%s, %s.\n",
  413. channels[i].hw_value,
  414. channels[i].max_power,
  415. channels[i].flags & IEEE80211_CHAN_RADAR ?
  416. " (IEEE 802.11h required)" : "",
  417. ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
  418. || (channels[i].flags &
  419. IEEE80211_CHAN_RADAR)) ? "" :
  420. ", IBSS",
  421. channels[i].flags &
  422. IEEE80211_CHAN_PASSIVE_SCAN ?
  423. "passive only" : "active/passive");
  424. }
  425. supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
  426. if (supp_band) {
  427. channels = supp_band->channels;
  428. pos += scnprintf(buf + pos, bufsz - pos,
  429. "Displaying %d channels in 5.2GHz band (802.11a)\n",
  430. supp_band->n_channels);
  431. for (i = 0; i < supp_band->n_channels; i++)
  432. pos += scnprintf(buf + pos, bufsz - pos,
  433. "%d: %ddBm: BSS%s%s, %s.\n",
  434. channels[i].hw_value,
  435. channels[i].max_power,
  436. channels[i].flags & IEEE80211_CHAN_RADAR ?
  437. " (IEEE 802.11h required)" : "",
  438. ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
  439. || (channels[i].flags &
  440. IEEE80211_CHAN_RADAR)) ? "" :
  441. ", IBSS",
  442. channels[i].flags &
  443. IEEE80211_CHAN_PASSIVE_SCAN ?
  444. "passive only" : "active/passive");
  445. }
  446. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  447. kfree(buf);
  448. return ret;
  449. }
  450. static ssize_t iwl_dbgfs_status_read(struct file *file,
  451. char __user *user_buf,
  452. size_t count, loff_t *ppos) {
  453. struct iwl_priv *priv = file->private_data;
  454. char buf[512];
  455. int pos = 0;
  456. const size_t bufsz = sizeof(buf);
  457. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n",
  458. test_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status));
  459. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n",
  460. test_bit(STATUS_INT_ENABLED, &priv->shrd->status));
  461. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n",
  462. test_bit(STATUS_RF_KILL_HW, &priv->shrd->status));
  463. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n",
  464. test_bit(STATUS_CT_KILL, &priv->shrd->status));
  465. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n",
  466. test_bit(STATUS_INIT, &priv->shrd->status));
  467. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n",
  468. test_bit(STATUS_ALIVE, &priv->shrd->status));
  469. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n",
  470. test_bit(STATUS_READY, &priv->shrd->status));
  471. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n",
  472. test_bit(STATUS_TEMPERATURE, &priv->shrd->status));
  473. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n",
  474. test_bit(STATUS_GEO_CONFIGURED, &priv->shrd->status));
  475. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n",
  476. test_bit(STATUS_EXIT_PENDING, &priv->shrd->status));
  477. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n",
  478. test_bit(STATUS_STATISTICS, &priv->shrd->status));
  479. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n",
  480. test_bit(STATUS_SCANNING, &priv->shrd->status));
  481. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n",
  482. test_bit(STATUS_SCAN_ABORTING, &priv->shrd->status));
  483. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n",
  484. test_bit(STATUS_SCAN_HW, &priv->shrd->status));
  485. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n",
  486. test_bit(STATUS_POWER_PMI, &priv->shrd->status));
  487. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
  488. test_bit(STATUS_FW_ERROR, &priv->shrd->status));
  489. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  490. }
  491. static ssize_t iwl_dbgfs_rx_handlers_read(struct file *file,
  492. char __user *user_buf,
  493. size_t count, loff_t *ppos) {
  494. struct iwl_priv *priv = file->private_data;
  495. int pos = 0;
  496. int cnt = 0;
  497. char *buf;
  498. int bufsz = 24 * 64; /* 24 items * 64 char per item */
  499. ssize_t ret;
  500. buf = kzalloc(bufsz, GFP_KERNEL);
  501. if (!buf) {
  502. IWL_ERR(priv, "Can not allocate Buffer\n");
  503. return -ENOMEM;
  504. }
  505. for (cnt = 0; cnt < REPLY_MAX; cnt++) {
  506. if (priv->rx_handlers_stats[cnt] > 0)
  507. pos += scnprintf(buf + pos, bufsz - pos,
  508. "\tRx handler[%36s]:\t\t %u\n",
  509. get_cmd_string(cnt),
  510. priv->rx_handlers_stats[cnt]);
  511. }
  512. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  513. kfree(buf);
  514. return ret;
  515. }
  516. static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
  517. const char __user *user_buf,
  518. size_t count, loff_t *ppos)
  519. {
  520. struct iwl_priv *priv = file->private_data;
  521. char buf[8];
  522. int buf_size;
  523. u32 reset_flag;
  524. memset(buf, 0, sizeof(buf));
  525. buf_size = min(count, sizeof(buf) - 1);
  526. if (copy_from_user(buf, user_buf, buf_size))
  527. return -EFAULT;
  528. if (sscanf(buf, "%x", &reset_flag) != 1)
  529. return -EFAULT;
  530. if (reset_flag == 0)
  531. memset(&priv->rx_handlers_stats[0], 0,
  532. sizeof(priv->rx_handlers_stats));
  533. return count;
  534. }
  535. static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
  536. size_t count, loff_t *ppos)
  537. {
  538. struct iwl_priv *priv = file->private_data;
  539. struct iwl_rxon_context *ctx;
  540. int pos = 0, i;
  541. char buf[256 * NUM_IWL_RXON_CTX];
  542. const size_t bufsz = sizeof(buf);
  543. for_each_context(priv, ctx) {
  544. pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n",
  545. ctx->ctxid);
  546. for (i = 0; i < AC_NUM; i++) {
  547. pos += scnprintf(buf + pos, bufsz - pos,
  548. "\tcw_min\tcw_max\taifsn\ttxop\n");
  549. pos += scnprintf(buf + pos, bufsz - pos,
  550. "AC[%d]\t%u\t%u\t%u\t%u\n", i,
  551. ctx->qos_data.def_qos_parm.ac[i].cw_min,
  552. ctx->qos_data.def_qos_parm.ac[i].cw_max,
  553. ctx->qos_data.def_qos_parm.ac[i].aifsn,
  554. ctx->qos_data.def_qos_parm.ac[i].edca_txop);
  555. }
  556. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  557. }
  558. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  559. }
  560. static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
  561. char __user *user_buf,
  562. size_t count, loff_t *ppos)
  563. {
  564. struct iwl_priv *priv = file->private_data;
  565. struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
  566. struct iwl_tt_restriction *restriction;
  567. char buf[100];
  568. int pos = 0;
  569. const size_t bufsz = sizeof(buf);
  570. pos += scnprintf(buf + pos, bufsz - pos,
  571. "Thermal Throttling Mode: %s\n",
  572. tt->advanced_tt ? "Advance" : "Legacy");
  573. pos += scnprintf(buf + pos, bufsz - pos,
  574. "Thermal Throttling State: %d\n",
  575. tt->state);
  576. if (tt->advanced_tt) {
  577. restriction = tt->restriction + tt->state;
  578. pos += scnprintf(buf + pos, bufsz - pos,
  579. "Tx mode: %d\n",
  580. restriction->tx_stream);
  581. pos += scnprintf(buf + pos, bufsz - pos,
  582. "Rx mode: %d\n",
  583. restriction->rx_stream);
  584. pos += scnprintf(buf + pos, bufsz - pos,
  585. "HT mode: %d\n",
  586. restriction->is_ht);
  587. }
  588. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  589. }
  590. static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
  591. const char __user *user_buf,
  592. size_t count, loff_t *ppos)
  593. {
  594. struct iwl_priv *priv = file->private_data;
  595. char buf[8];
  596. int buf_size;
  597. int ht40;
  598. memset(buf, 0, sizeof(buf));
  599. buf_size = min(count, sizeof(buf) - 1);
  600. if (copy_from_user(buf, user_buf, buf_size))
  601. return -EFAULT;
  602. if (sscanf(buf, "%d", &ht40) != 1)
  603. return -EFAULT;
  604. if (!iwl_is_any_associated(priv))
  605. priv->disable_ht40 = ht40 ? true : false;
  606. else {
  607. IWL_ERR(priv, "Sta associated with AP - "
  608. "Change to 40MHz channel support is not allowed\n");
  609. return -EINVAL;
  610. }
  611. return count;
  612. }
  613. static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
  614. char __user *user_buf,
  615. size_t count, loff_t *ppos)
  616. {
  617. struct iwl_priv *priv = file->private_data;
  618. char buf[100];
  619. int pos = 0;
  620. const size_t bufsz = sizeof(buf);
  621. pos += scnprintf(buf + pos, bufsz - pos,
  622. "11n 40MHz Mode: %s\n",
  623. priv->disable_ht40 ? "Disabled" : "Enabled");
  624. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  625. }
  626. static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
  627. const char __user *user_buf,
  628. size_t count, loff_t *ppos)
  629. {
  630. struct iwl_priv *priv = file->private_data;
  631. char buf[8];
  632. int buf_size;
  633. int value;
  634. memset(buf, 0, sizeof(buf));
  635. buf_size = min(count, sizeof(buf) - 1);
  636. if (copy_from_user(buf, user_buf, buf_size))
  637. return -EFAULT;
  638. if (sscanf(buf, "%d", &value) != 1)
  639. return -EINVAL;
  640. /*
  641. * Our users expect 0 to be "CAM", but 0 isn't actually
  642. * valid here. However, let's not confuse them and present
  643. * IWL_POWER_INDEX_1 as "1", not "0".
  644. */
  645. if (value == 0)
  646. return -EINVAL;
  647. else if (value > 0)
  648. value -= 1;
  649. if (value != -1 && (value < 0 || value >= IWL_POWER_NUM))
  650. return -EINVAL;
  651. if (!iwl_is_ready_rf(priv->shrd))
  652. return -EAGAIN;
  653. priv->power_data.debug_sleep_level_override = value;
  654. mutex_lock(&priv->shrd->mutex);
  655. iwl_power_update_mode(priv, true);
  656. mutex_unlock(&priv->shrd->mutex);
  657. return count;
  658. }
  659. static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
  660. char __user *user_buf,
  661. size_t count, loff_t *ppos)
  662. {
  663. struct iwl_priv *priv = file->private_data;
  664. char buf[10];
  665. int pos, value;
  666. const size_t bufsz = sizeof(buf);
  667. /* see the write function */
  668. value = priv->power_data.debug_sleep_level_override;
  669. if (value >= 0)
  670. value += 1;
  671. pos = scnprintf(buf, bufsz, "%d\n", value);
  672. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  673. }
  674. static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
  675. char __user *user_buf,
  676. size_t count, loff_t *ppos)
  677. {
  678. struct iwl_priv *priv = file->private_data;
  679. char buf[200];
  680. int pos = 0, i;
  681. const size_t bufsz = sizeof(buf);
  682. struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd;
  683. pos += scnprintf(buf + pos, bufsz - pos,
  684. "flags: %#.2x\n", le16_to_cpu(cmd->flags));
  685. pos += scnprintf(buf + pos, bufsz - pos,
  686. "RX/TX timeout: %d/%d usec\n",
  687. le32_to_cpu(cmd->rx_data_timeout),
  688. le32_to_cpu(cmd->tx_data_timeout));
  689. for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
  690. pos += scnprintf(buf + pos, bufsz - pos,
  691. "sleep_interval[%d]: %d\n", i,
  692. le32_to_cpu(cmd->sleep_interval[i]));
  693. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  694. }
  695. DEBUGFS_READ_WRITE_FILE_OPS(sram);
  696. DEBUGFS_READ_FILE_OPS(wowlan_sram);
  697. DEBUGFS_READ_FILE_OPS(nvm);
  698. DEBUGFS_READ_FILE_OPS(stations);
  699. DEBUGFS_READ_FILE_OPS(channels);
  700. DEBUGFS_READ_FILE_OPS(status);
  701. DEBUGFS_READ_WRITE_FILE_OPS(rx_handlers);
  702. DEBUGFS_READ_FILE_OPS(qos);
  703. DEBUGFS_READ_FILE_OPS(thermal_throttling);
  704. DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
  705. DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
  706. DEBUGFS_READ_FILE_OPS(current_sleep_command);
  707. static const char *fmt_value = " %-30s %10u\n";
  708. static const char *fmt_hex = " %-30s 0x%02X\n";
  709. static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
  710. static const char *fmt_header =
  711. "%-32s current cumulative delta max\n";
  712. static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
  713. {
  714. int p = 0;
  715. u32 flag;
  716. flag = le32_to_cpu(priv->statistics.flag);
  717. p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag);
  718. if (flag & UCODE_STATISTICS_CLEAR_MSK)
  719. p += scnprintf(buf + p, bufsz - p,
  720. "\tStatistics have been cleared\n");
  721. p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
  722. (flag & UCODE_STATISTICS_FREQUENCY_MSK)
  723. ? "2.4 GHz" : "5.2 GHz");
  724. p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
  725. (flag & UCODE_STATISTICS_NARROW_BAND_MSK)
  726. ? "enabled" : "disabled");
  727. return p;
  728. }
  729. static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
  730. char __user *user_buf,
  731. size_t count, loff_t *ppos)
  732. {
  733. struct iwl_priv *priv = file->private_data;
  734. int pos = 0;
  735. char *buf;
  736. int bufsz = sizeof(struct statistics_rx_phy) * 40 +
  737. sizeof(struct statistics_rx_non_phy) * 40 +
  738. sizeof(struct statistics_rx_ht_phy) * 40 + 400;
  739. ssize_t ret;
  740. struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
  741. struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
  742. struct statistics_rx_non_phy *general, *accum_general;
  743. struct statistics_rx_non_phy *delta_general, *max_general;
  744. struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
  745. if (!iwl_is_alive(priv->shrd))
  746. return -EAGAIN;
  747. buf = kzalloc(bufsz, GFP_KERNEL);
  748. if (!buf) {
  749. IWL_ERR(priv, "Can not allocate Buffer\n");
  750. return -ENOMEM;
  751. }
  752. /*
  753. * the statistic information display here is based on
  754. * the last statistics notification from uCode
  755. * might not reflect the current uCode activity
  756. */
  757. ofdm = &priv->statistics.rx_ofdm;
  758. cck = &priv->statistics.rx_cck;
  759. general = &priv->statistics.rx_non_phy;
  760. ht = &priv->statistics.rx_ofdm_ht;
  761. accum_ofdm = &priv->accum_stats.rx_ofdm;
  762. accum_cck = &priv->accum_stats.rx_cck;
  763. accum_general = &priv->accum_stats.rx_non_phy;
  764. accum_ht = &priv->accum_stats.rx_ofdm_ht;
  765. delta_ofdm = &priv->delta_stats.rx_ofdm;
  766. delta_cck = &priv->delta_stats.rx_cck;
  767. delta_general = &priv->delta_stats.rx_non_phy;
  768. delta_ht = &priv->delta_stats.rx_ofdm_ht;
  769. max_ofdm = &priv->max_delta_stats.rx_ofdm;
  770. max_cck = &priv->max_delta_stats.rx_cck;
  771. max_general = &priv->max_delta_stats.rx_non_phy;
  772. max_ht = &priv->max_delta_stats.rx_ofdm_ht;
  773. pos += iwl_statistics_flag(priv, buf, bufsz);
  774. pos += scnprintf(buf + pos, bufsz - pos,
  775. fmt_header, "Statistics_Rx - OFDM:");
  776. pos += scnprintf(buf + pos, bufsz - pos,
  777. fmt_table, "ina_cnt:",
  778. le32_to_cpu(ofdm->ina_cnt),
  779. accum_ofdm->ina_cnt,
  780. delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
  781. pos += scnprintf(buf + pos, bufsz - pos,
  782. fmt_table, "fina_cnt:",
  783. le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
  784. delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
  785. pos += scnprintf(buf + pos, bufsz - pos,
  786. fmt_table, "plcp_err:",
  787. le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
  788. delta_ofdm->plcp_err, max_ofdm->plcp_err);
  789. pos += scnprintf(buf + pos, bufsz - pos,
  790. fmt_table, "crc32_err:",
  791. le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
  792. delta_ofdm->crc32_err, max_ofdm->crc32_err);
  793. pos += scnprintf(buf + pos, bufsz - pos,
  794. fmt_table, "overrun_err:",
  795. le32_to_cpu(ofdm->overrun_err),
  796. accum_ofdm->overrun_err, delta_ofdm->overrun_err,
  797. max_ofdm->overrun_err);
  798. pos += scnprintf(buf + pos, bufsz - pos,
  799. fmt_table, "early_overrun_err:",
  800. le32_to_cpu(ofdm->early_overrun_err),
  801. accum_ofdm->early_overrun_err,
  802. delta_ofdm->early_overrun_err,
  803. max_ofdm->early_overrun_err);
  804. pos += scnprintf(buf + pos, bufsz - pos,
  805. fmt_table, "crc32_good:",
  806. le32_to_cpu(ofdm->crc32_good),
  807. accum_ofdm->crc32_good, delta_ofdm->crc32_good,
  808. max_ofdm->crc32_good);
  809. pos += scnprintf(buf + pos, bufsz - pos,
  810. fmt_table, "false_alarm_cnt:",
  811. le32_to_cpu(ofdm->false_alarm_cnt),
  812. accum_ofdm->false_alarm_cnt,
  813. delta_ofdm->false_alarm_cnt,
  814. max_ofdm->false_alarm_cnt);
  815. pos += scnprintf(buf + pos, bufsz - pos,
  816. fmt_table, "fina_sync_err_cnt:",
  817. le32_to_cpu(ofdm->fina_sync_err_cnt),
  818. accum_ofdm->fina_sync_err_cnt,
  819. delta_ofdm->fina_sync_err_cnt,
  820. max_ofdm->fina_sync_err_cnt);
  821. pos += scnprintf(buf + pos, bufsz - pos,
  822. fmt_table, "sfd_timeout:",
  823. le32_to_cpu(ofdm->sfd_timeout),
  824. accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout,
  825. max_ofdm->sfd_timeout);
  826. pos += scnprintf(buf + pos, bufsz - pos,
  827. fmt_table, "fina_timeout:",
  828. le32_to_cpu(ofdm->fina_timeout),
  829. accum_ofdm->fina_timeout, delta_ofdm->fina_timeout,
  830. max_ofdm->fina_timeout);
  831. pos += scnprintf(buf + pos, bufsz - pos,
  832. fmt_table, "unresponded_rts:",
  833. le32_to_cpu(ofdm->unresponded_rts),
  834. accum_ofdm->unresponded_rts,
  835. delta_ofdm->unresponded_rts,
  836. max_ofdm->unresponded_rts);
  837. pos += scnprintf(buf + pos, bufsz - pos,
  838. fmt_table, "rxe_frame_lmt_ovrun:",
  839. le32_to_cpu(ofdm->rxe_frame_limit_overrun),
  840. accum_ofdm->rxe_frame_limit_overrun,
  841. delta_ofdm->rxe_frame_limit_overrun,
  842. max_ofdm->rxe_frame_limit_overrun);
  843. pos += scnprintf(buf + pos, bufsz - pos,
  844. fmt_table, "sent_ack_cnt:",
  845. le32_to_cpu(ofdm->sent_ack_cnt),
  846. accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt,
  847. max_ofdm->sent_ack_cnt);
  848. pos += scnprintf(buf + pos, bufsz - pos,
  849. fmt_table, "sent_cts_cnt:",
  850. le32_to_cpu(ofdm->sent_cts_cnt),
  851. accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt,
  852. max_ofdm->sent_cts_cnt);
  853. pos += scnprintf(buf + pos, bufsz - pos,
  854. fmt_table, "sent_ba_rsp_cnt:",
  855. le32_to_cpu(ofdm->sent_ba_rsp_cnt),
  856. accum_ofdm->sent_ba_rsp_cnt,
  857. delta_ofdm->sent_ba_rsp_cnt,
  858. max_ofdm->sent_ba_rsp_cnt);
  859. pos += scnprintf(buf + pos, bufsz - pos,
  860. fmt_table, "dsp_self_kill:",
  861. le32_to_cpu(ofdm->dsp_self_kill),
  862. accum_ofdm->dsp_self_kill,
  863. delta_ofdm->dsp_self_kill,
  864. max_ofdm->dsp_self_kill);
  865. pos += scnprintf(buf + pos, bufsz - pos,
  866. fmt_table, "mh_format_err:",
  867. le32_to_cpu(ofdm->mh_format_err),
  868. accum_ofdm->mh_format_err,
  869. delta_ofdm->mh_format_err,
  870. max_ofdm->mh_format_err);
  871. pos += scnprintf(buf + pos, bufsz - pos,
  872. fmt_table, "re_acq_main_rssi_sum:",
  873. le32_to_cpu(ofdm->re_acq_main_rssi_sum),
  874. accum_ofdm->re_acq_main_rssi_sum,
  875. delta_ofdm->re_acq_main_rssi_sum,
  876. max_ofdm->re_acq_main_rssi_sum);
  877. pos += scnprintf(buf + pos, bufsz - pos,
  878. fmt_header, "Statistics_Rx - CCK:");
  879. pos += scnprintf(buf + pos, bufsz - pos,
  880. fmt_table, "ina_cnt:",
  881. le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
  882. delta_cck->ina_cnt, max_cck->ina_cnt);
  883. pos += scnprintf(buf + pos, bufsz - pos,
  884. fmt_table, "fina_cnt:",
  885. le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
  886. delta_cck->fina_cnt, max_cck->fina_cnt);
  887. pos += scnprintf(buf + pos, bufsz - pos,
  888. fmt_table, "plcp_err:",
  889. le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
  890. delta_cck->plcp_err, max_cck->plcp_err);
  891. pos += scnprintf(buf + pos, bufsz - pos,
  892. fmt_table, "crc32_err:",
  893. le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
  894. delta_cck->crc32_err, max_cck->crc32_err);
  895. pos += scnprintf(buf + pos, bufsz - pos,
  896. fmt_table, "overrun_err:",
  897. le32_to_cpu(cck->overrun_err),
  898. accum_cck->overrun_err, delta_cck->overrun_err,
  899. max_cck->overrun_err);
  900. pos += scnprintf(buf + pos, bufsz - pos,
  901. fmt_table, "early_overrun_err:",
  902. le32_to_cpu(cck->early_overrun_err),
  903. accum_cck->early_overrun_err,
  904. delta_cck->early_overrun_err,
  905. max_cck->early_overrun_err);
  906. pos += scnprintf(buf + pos, bufsz - pos,
  907. fmt_table, "crc32_good:",
  908. le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
  909. delta_cck->crc32_good, max_cck->crc32_good);
  910. pos += scnprintf(buf + pos, bufsz - pos,
  911. fmt_table, "false_alarm_cnt:",
  912. le32_to_cpu(cck->false_alarm_cnt),
  913. accum_cck->false_alarm_cnt,
  914. delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
  915. pos += scnprintf(buf + pos, bufsz - pos,
  916. fmt_table, "fina_sync_err_cnt:",
  917. le32_to_cpu(cck->fina_sync_err_cnt),
  918. accum_cck->fina_sync_err_cnt,
  919. delta_cck->fina_sync_err_cnt,
  920. max_cck->fina_sync_err_cnt);
  921. pos += scnprintf(buf + pos, bufsz - pos,
  922. fmt_table, "sfd_timeout:",
  923. le32_to_cpu(cck->sfd_timeout),
  924. accum_cck->sfd_timeout, delta_cck->sfd_timeout,
  925. max_cck->sfd_timeout);
  926. pos += scnprintf(buf + pos, bufsz - pos,
  927. fmt_table, "fina_timeout:",
  928. le32_to_cpu(cck->fina_timeout),
  929. accum_cck->fina_timeout, delta_cck->fina_timeout,
  930. max_cck->fina_timeout);
  931. pos += scnprintf(buf + pos, bufsz - pos,
  932. fmt_table, "unresponded_rts:",
  933. le32_to_cpu(cck->unresponded_rts),
  934. accum_cck->unresponded_rts, delta_cck->unresponded_rts,
  935. max_cck->unresponded_rts);
  936. pos += scnprintf(buf + pos, bufsz - pos,
  937. fmt_table, "rxe_frame_lmt_ovrun:",
  938. le32_to_cpu(cck->rxe_frame_limit_overrun),
  939. accum_cck->rxe_frame_limit_overrun,
  940. delta_cck->rxe_frame_limit_overrun,
  941. max_cck->rxe_frame_limit_overrun);
  942. pos += scnprintf(buf + pos, bufsz - pos,
  943. fmt_table, "sent_ack_cnt:",
  944. le32_to_cpu(cck->sent_ack_cnt),
  945. accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt,
  946. max_cck->sent_ack_cnt);
  947. pos += scnprintf(buf + pos, bufsz - pos,
  948. fmt_table, "sent_cts_cnt:",
  949. le32_to_cpu(cck->sent_cts_cnt),
  950. accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt,
  951. max_cck->sent_cts_cnt);
  952. pos += scnprintf(buf + pos, bufsz - pos,
  953. fmt_table, "sent_ba_rsp_cnt:",
  954. le32_to_cpu(cck->sent_ba_rsp_cnt),
  955. accum_cck->sent_ba_rsp_cnt,
  956. delta_cck->sent_ba_rsp_cnt,
  957. max_cck->sent_ba_rsp_cnt);
  958. pos += scnprintf(buf + pos, bufsz - pos,
  959. fmt_table, "dsp_self_kill:",
  960. le32_to_cpu(cck->dsp_self_kill),
  961. accum_cck->dsp_self_kill, delta_cck->dsp_self_kill,
  962. max_cck->dsp_self_kill);
  963. pos += scnprintf(buf + pos, bufsz - pos,
  964. fmt_table, "mh_format_err:",
  965. le32_to_cpu(cck->mh_format_err),
  966. accum_cck->mh_format_err, delta_cck->mh_format_err,
  967. max_cck->mh_format_err);
  968. pos += scnprintf(buf + pos, bufsz - pos,
  969. fmt_table, "re_acq_main_rssi_sum:",
  970. le32_to_cpu(cck->re_acq_main_rssi_sum),
  971. accum_cck->re_acq_main_rssi_sum,
  972. delta_cck->re_acq_main_rssi_sum,
  973. max_cck->re_acq_main_rssi_sum);
  974. pos += scnprintf(buf + pos, bufsz - pos,
  975. fmt_header, "Statistics_Rx - GENERAL:");
  976. pos += scnprintf(buf + pos, bufsz - pos,
  977. fmt_table, "bogus_cts:",
  978. le32_to_cpu(general->bogus_cts),
  979. accum_general->bogus_cts, delta_general->bogus_cts,
  980. max_general->bogus_cts);
  981. pos += scnprintf(buf + pos, bufsz - pos,
  982. fmt_table, "bogus_ack:",
  983. le32_to_cpu(general->bogus_ack),
  984. accum_general->bogus_ack, delta_general->bogus_ack,
  985. max_general->bogus_ack);
  986. pos += scnprintf(buf + pos, bufsz - pos,
  987. fmt_table, "non_bssid_frames:",
  988. le32_to_cpu(general->non_bssid_frames),
  989. accum_general->non_bssid_frames,
  990. delta_general->non_bssid_frames,
  991. max_general->non_bssid_frames);
  992. pos += scnprintf(buf + pos, bufsz - pos,
  993. fmt_table, "filtered_frames:",
  994. le32_to_cpu(general->filtered_frames),
  995. accum_general->filtered_frames,
  996. delta_general->filtered_frames,
  997. max_general->filtered_frames);
  998. pos += scnprintf(buf + pos, bufsz - pos,
  999. fmt_table, "non_channel_beacons:",
  1000. le32_to_cpu(general->non_channel_beacons),
  1001. accum_general->non_channel_beacons,
  1002. delta_general->non_channel_beacons,
  1003. max_general->non_channel_beacons);
  1004. pos += scnprintf(buf + pos, bufsz - pos,
  1005. fmt_table, "channel_beacons:",
  1006. le32_to_cpu(general->channel_beacons),
  1007. accum_general->channel_beacons,
  1008. delta_general->channel_beacons,
  1009. max_general->channel_beacons);
  1010. pos += scnprintf(buf + pos, bufsz - pos,
  1011. fmt_table, "num_missed_bcon:",
  1012. le32_to_cpu(general->num_missed_bcon),
  1013. accum_general->num_missed_bcon,
  1014. delta_general->num_missed_bcon,
  1015. max_general->num_missed_bcon);
  1016. pos += scnprintf(buf + pos, bufsz - pos,
  1017. fmt_table, "adc_rx_saturation_time:",
  1018. le32_to_cpu(general->adc_rx_saturation_time),
  1019. accum_general->adc_rx_saturation_time,
  1020. delta_general->adc_rx_saturation_time,
  1021. max_general->adc_rx_saturation_time);
  1022. pos += scnprintf(buf + pos, bufsz - pos,
  1023. fmt_table, "ina_detect_search_tm:",
  1024. le32_to_cpu(general->ina_detection_search_time),
  1025. accum_general->ina_detection_search_time,
  1026. delta_general->ina_detection_search_time,
  1027. max_general->ina_detection_search_time);
  1028. pos += scnprintf(buf + pos, bufsz - pos,
  1029. fmt_table, "beacon_silence_rssi_a:",
  1030. le32_to_cpu(general->beacon_silence_rssi_a),
  1031. accum_general->beacon_silence_rssi_a,
  1032. delta_general->beacon_silence_rssi_a,
  1033. max_general->beacon_silence_rssi_a);
  1034. pos += scnprintf(buf + pos, bufsz - pos,
  1035. fmt_table, "beacon_silence_rssi_b:",
  1036. le32_to_cpu(general->beacon_silence_rssi_b),
  1037. accum_general->beacon_silence_rssi_b,
  1038. delta_general->beacon_silence_rssi_b,
  1039. max_general->beacon_silence_rssi_b);
  1040. pos += scnprintf(buf + pos, bufsz - pos,
  1041. fmt_table, "beacon_silence_rssi_c:",
  1042. le32_to_cpu(general->beacon_silence_rssi_c),
  1043. accum_general->beacon_silence_rssi_c,
  1044. delta_general->beacon_silence_rssi_c,
  1045. max_general->beacon_silence_rssi_c);
  1046. pos += scnprintf(buf + pos, bufsz - pos,
  1047. fmt_table, "interference_data_flag:",
  1048. le32_to_cpu(general->interference_data_flag),
  1049. accum_general->interference_data_flag,
  1050. delta_general->interference_data_flag,
  1051. max_general->interference_data_flag);
  1052. pos += scnprintf(buf + pos, bufsz - pos,
  1053. fmt_table, "channel_load:",
  1054. le32_to_cpu(general->channel_load),
  1055. accum_general->channel_load,
  1056. delta_general->channel_load,
  1057. max_general->channel_load);
  1058. pos += scnprintf(buf + pos, bufsz - pos,
  1059. fmt_table, "dsp_false_alarms:",
  1060. le32_to_cpu(general->dsp_false_alarms),
  1061. accum_general->dsp_false_alarms,
  1062. delta_general->dsp_false_alarms,
  1063. max_general->dsp_false_alarms);
  1064. pos += scnprintf(buf + pos, bufsz - pos,
  1065. fmt_table, "beacon_rssi_a:",
  1066. le32_to_cpu(general->beacon_rssi_a),
  1067. accum_general->beacon_rssi_a,
  1068. delta_general->beacon_rssi_a,
  1069. max_general->beacon_rssi_a);
  1070. pos += scnprintf(buf + pos, bufsz - pos,
  1071. fmt_table, "beacon_rssi_b:",
  1072. le32_to_cpu(general->beacon_rssi_b),
  1073. accum_general->beacon_rssi_b,
  1074. delta_general->beacon_rssi_b,
  1075. max_general->beacon_rssi_b);
  1076. pos += scnprintf(buf + pos, bufsz - pos,
  1077. fmt_table, "beacon_rssi_c:",
  1078. le32_to_cpu(general->beacon_rssi_c),
  1079. accum_general->beacon_rssi_c,
  1080. delta_general->beacon_rssi_c,
  1081. max_general->beacon_rssi_c);
  1082. pos += scnprintf(buf + pos, bufsz - pos,
  1083. fmt_table, "beacon_energy_a:",
  1084. le32_to_cpu(general->beacon_energy_a),
  1085. accum_general->beacon_energy_a,
  1086. delta_general->beacon_energy_a,
  1087. max_general->beacon_energy_a);
  1088. pos += scnprintf(buf + pos, bufsz - pos,
  1089. fmt_table, "beacon_energy_b:",
  1090. le32_to_cpu(general->beacon_energy_b),
  1091. accum_general->beacon_energy_b,
  1092. delta_general->beacon_energy_b,
  1093. max_general->beacon_energy_b);
  1094. pos += scnprintf(buf + pos, bufsz - pos,
  1095. fmt_table, "beacon_energy_c:",
  1096. le32_to_cpu(general->beacon_energy_c),
  1097. accum_general->beacon_energy_c,
  1098. delta_general->beacon_energy_c,
  1099. max_general->beacon_energy_c);
  1100. pos += scnprintf(buf + pos, bufsz - pos,
  1101. fmt_header, "Statistics_Rx - OFDM_HT:");
  1102. pos += scnprintf(buf + pos, bufsz - pos,
  1103. fmt_table, "plcp_err:",
  1104. le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
  1105. delta_ht->plcp_err, max_ht->plcp_err);
  1106. pos += scnprintf(buf + pos, bufsz - pos,
  1107. fmt_table, "overrun_err:",
  1108. le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
  1109. delta_ht->overrun_err, max_ht->overrun_err);
  1110. pos += scnprintf(buf + pos, bufsz - pos,
  1111. fmt_table, "early_overrun_err:",
  1112. le32_to_cpu(ht->early_overrun_err),
  1113. accum_ht->early_overrun_err,
  1114. delta_ht->early_overrun_err,
  1115. max_ht->early_overrun_err);
  1116. pos += scnprintf(buf + pos, bufsz - pos,
  1117. fmt_table, "crc32_good:",
  1118. le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
  1119. delta_ht->crc32_good, max_ht->crc32_good);
  1120. pos += scnprintf(buf + pos, bufsz - pos,
  1121. fmt_table, "crc32_err:",
  1122. le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
  1123. delta_ht->crc32_err, max_ht->crc32_err);
  1124. pos += scnprintf(buf + pos, bufsz - pos,
  1125. fmt_table, "mh_format_err:",
  1126. le32_to_cpu(ht->mh_format_err),
  1127. accum_ht->mh_format_err,
  1128. delta_ht->mh_format_err, max_ht->mh_format_err);
  1129. pos += scnprintf(buf + pos, bufsz - pos,
  1130. fmt_table, "agg_crc32_good:",
  1131. le32_to_cpu(ht->agg_crc32_good),
  1132. accum_ht->agg_crc32_good,
  1133. delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
  1134. pos += scnprintf(buf + pos, bufsz - pos,
  1135. fmt_table, "agg_mpdu_cnt:",
  1136. le32_to_cpu(ht->agg_mpdu_cnt),
  1137. accum_ht->agg_mpdu_cnt,
  1138. delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
  1139. pos += scnprintf(buf + pos, bufsz - pos,
  1140. fmt_table, "agg_cnt:",
  1141. le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
  1142. delta_ht->agg_cnt, max_ht->agg_cnt);
  1143. pos += scnprintf(buf + pos, bufsz - pos,
  1144. fmt_table, "unsupport_mcs:",
  1145. le32_to_cpu(ht->unsupport_mcs),
  1146. accum_ht->unsupport_mcs,
  1147. delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
  1148. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1149. kfree(buf);
  1150. return ret;
  1151. }
  1152. static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
  1153. char __user *user_buf,
  1154. size_t count, loff_t *ppos)
  1155. {
  1156. struct iwl_priv *priv = file->private_data;
  1157. int pos = 0;
  1158. char *buf;
  1159. int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
  1160. ssize_t ret;
  1161. struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
  1162. if (!iwl_is_alive(priv->shrd))
  1163. return -EAGAIN;
  1164. buf = kzalloc(bufsz, GFP_KERNEL);
  1165. if (!buf) {
  1166. IWL_ERR(priv, "Can not allocate Buffer\n");
  1167. return -ENOMEM;
  1168. }
  1169. /* the statistic information display here is based on
  1170. * the last statistics notification from uCode
  1171. * might not reflect the current uCode activity
  1172. */
  1173. tx = &priv->statistics.tx;
  1174. accum_tx = &priv->accum_stats.tx;
  1175. delta_tx = &priv->delta_stats.tx;
  1176. max_tx = &priv->max_delta_stats.tx;
  1177. pos += iwl_statistics_flag(priv, buf, bufsz);
  1178. pos += scnprintf(buf + pos, bufsz - pos,
  1179. fmt_header, "Statistics_Tx:");
  1180. pos += scnprintf(buf + pos, bufsz - pos,
  1181. fmt_table, "preamble:",
  1182. le32_to_cpu(tx->preamble_cnt),
  1183. accum_tx->preamble_cnt,
  1184. delta_tx->preamble_cnt, max_tx->preamble_cnt);
  1185. pos += scnprintf(buf + pos, bufsz - pos,
  1186. fmt_table, "rx_detected_cnt:",
  1187. le32_to_cpu(tx->rx_detected_cnt),
  1188. accum_tx->rx_detected_cnt,
  1189. delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
  1190. pos += scnprintf(buf + pos, bufsz - pos,
  1191. fmt_table, "bt_prio_defer_cnt:",
  1192. le32_to_cpu(tx->bt_prio_defer_cnt),
  1193. accum_tx->bt_prio_defer_cnt,
  1194. delta_tx->bt_prio_defer_cnt,
  1195. max_tx->bt_prio_defer_cnt);
  1196. pos += scnprintf(buf + pos, bufsz - pos,
  1197. fmt_table, "bt_prio_kill_cnt:",
  1198. le32_to_cpu(tx->bt_prio_kill_cnt),
  1199. accum_tx->bt_prio_kill_cnt,
  1200. delta_tx->bt_prio_kill_cnt,
  1201. max_tx->bt_prio_kill_cnt);
  1202. pos += scnprintf(buf + pos, bufsz - pos,
  1203. fmt_table, "few_bytes_cnt:",
  1204. le32_to_cpu(tx->few_bytes_cnt),
  1205. accum_tx->few_bytes_cnt,
  1206. delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
  1207. pos += scnprintf(buf + pos, bufsz - pos,
  1208. fmt_table, "cts_timeout:",
  1209. le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
  1210. delta_tx->cts_timeout, max_tx->cts_timeout);
  1211. pos += scnprintf(buf + pos, bufsz - pos,
  1212. fmt_table, "ack_timeout:",
  1213. le32_to_cpu(tx->ack_timeout),
  1214. accum_tx->ack_timeout,
  1215. delta_tx->ack_timeout, max_tx->ack_timeout);
  1216. pos += scnprintf(buf + pos, bufsz - pos,
  1217. fmt_table, "expected_ack_cnt:",
  1218. le32_to_cpu(tx->expected_ack_cnt),
  1219. accum_tx->expected_ack_cnt,
  1220. delta_tx->expected_ack_cnt,
  1221. max_tx->expected_ack_cnt);
  1222. pos += scnprintf(buf + pos, bufsz - pos,
  1223. fmt_table, "actual_ack_cnt:",
  1224. le32_to_cpu(tx->actual_ack_cnt),
  1225. accum_tx->actual_ack_cnt,
  1226. delta_tx->actual_ack_cnt,
  1227. max_tx->actual_ack_cnt);
  1228. pos += scnprintf(buf + pos, bufsz - pos,
  1229. fmt_table, "dump_msdu_cnt:",
  1230. le32_to_cpu(tx->dump_msdu_cnt),
  1231. accum_tx->dump_msdu_cnt,
  1232. delta_tx->dump_msdu_cnt,
  1233. max_tx->dump_msdu_cnt);
  1234. pos += scnprintf(buf + pos, bufsz - pos,
  1235. fmt_table, "abort_nxt_frame_mismatch:",
  1236. le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
  1237. accum_tx->burst_abort_next_frame_mismatch_cnt,
  1238. delta_tx->burst_abort_next_frame_mismatch_cnt,
  1239. max_tx->burst_abort_next_frame_mismatch_cnt);
  1240. pos += scnprintf(buf + pos, bufsz - pos,
  1241. fmt_table, "abort_missing_nxt_frame:",
  1242. le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
  1243. accum_tx->burst_abort_missing_next_frame_cnt,
  1244. delta_tx->burst_abort_missing_next_frame_cnt,
  1245. max_tx->burst_abort_missing_next_frame_cnt);
  1246. pos += scnprintf(buf + pos, bufsz - pos,
  1247. fmt_table, "cts_timeout_collision:",
  1248. le32_to_cpu(tx->cts_timeout_collision),
  1249. accum_tx->cts_timeout_collision,
  1250. delta_tx->cts_timeout_collision,
  1251. max_tx->cts_timeout_collision);
  1252. pos += scnprintf(buf + pos, bufsz - pos,
  1253. fmt_table, "ack_ba_timeout_collision:",
  1254. le32_to_cpu(tx->ack_or_ba_timeout_collision),
  1255. accum_tx->ack_or_ba_timeout_collision,
  1256. delta_tx->ack_or_ba_timeout_collision,
  1257. max_tx->ack_or_ba_timeout_collision);
  1258. pos += scnprintf(buf + pos, bufsz - pos,
  1259. fmt_table, "agg ba_timeout:",
  1260. le32_to_cpu(tx->agg.ba_timeout),
  1261. accum_tx->agg.ba_timeout,
  1262. delta_tx->agg.ba_timeout,
  1263. max_tx->agg.ba_timeout);
  1264. pos += scnprintf(buf + pos, bufsz - pos,
  1265. fmt_table, "agg ba_resched_frames:",
  1266. le32_to_cpu(tx->agg.ba_reschedule_frames),
  1267. accum_tx->agg.ba_reschedule_frames,
  1268. delta_tx->agg.ba_reschedule_frames,
  1269. max_tx->agg.ba_reschedule_frames);
  1270. pos += scnprintf(buf + pos, bufsz - pos,
  1271. fmt_table, "agg scd_query_agg_frame:",
  1272. le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
  1273. accum_tx->agg.scd_query_agg_frame_cnt,
  1274. delta_tx->agg.scd_query_agg_frame_cnt,
  1275. max_tx->agg.scd_query_agg_frame_cnt);
  1276. pos += scnprintf(buf + pos, bufsz - pos,
  1277. fmt_table, "agg scd_query_no_agg:",
  1278. le32_to_cpu(tx->agg.scd_query_no_agg),
  1279. accum_tx->agg.scd_query_no_agg,
  1280. delta_tx->agg.scd_query_no_agg,
  1281. max_tx->agg.scd_query_no_agg);
  1282. pos += scnprintf(buf + pos, bufsz - pos,
  1283. fmt_table, "agg scd_query_agg:",
  1284. le32_to_cpu(tx->agg.scd_query_agg),
  1285. accum_tx->agg.scd_query_agg,
  1286. delta_tx->agg.scd_query_agg,
  1287. max_tx->agg.scd_query_agg);
  1288. pos += scnprintf(buf + pos, bufsz - pos,
  1289. fmt_table, "agg scd_query_mismatch:",
  1290. le32_to_cpu(tx->agg.scd_query_mismatch),
  1291. accum_tx->agg.scd_query_mismatch,
  1292. delta_tx->agg.scd_query_mismatch,
  1293. max_tx->agg.scd_query_mismatch);
  1294. pos += scnprintf(buf + pos, bufsz - pos,
  1295. fmt_table, "agg frame_not_ready:",
  1296. le32_to_cpu(tx->agg.frame_not_ready),
  1297. accum_tx->agg.frame_not_ready,
  1298. delta_tx->agg.frame_not_ready,
  1299. max_tx->agg.frame_not_ready);
  1300. pos += scnprintf(buf + pos, bufsz - pos,
  1301. fmt_table, "agg underrun:",
  1302. le32_to_cpu(tx->agg.underrun),
  1303. accum_tx->agg.underrun,
  1304. delta_tx->agg.underrun, max_tx->agg.underrun);
  1305. pos += scnprintf(buf + pos, bufsz - pos,
  1306. fmt_table, "agg bt_prio_kill:",
  1307. le32_to_cpu(tx->agg.bt_prio_kill),
  1308. accum_tx->agg.bt_prio_kill,
  1309. delta_tx->agg.bt_prio_kill,
  1310. max_tx->agg.bt_prio_kill);
  1311. pos += scnprintf(buf + pos, bufsz - pos,
  1312. fmt_table, "agg rx_ba_rsp_cnt:",
  1313. le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
  1314. accum_tx->agg.rx_ba_rsp_cnt,
  1315. delta_tx->agg.rx_ba_rsp_cnt,
  1316. max_tx->agg.rx_ba_rsp_cnt);
  1317. if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) {
  1318. pos += scnprintf(buf + pos, bufsz - pos,
  1319. "tx power: (1/2 dB step)\n");
  1320. if ((priv->cfg->valid_tx_ant & ANT_A) && tx->tx_power.ant_a)
  1321. pos += scnprintf(buf + pos, bufsz - pos,
  1322. fmt_hex, "antenna A:",
  1323. tx->tx_power.ant_a);
  1324. if ((priv->cfg->valid_tx_ant & ANT_B) && tx->tx_power.ant_b)
  1325. pos += scnprintf(buf + pos, bufsz - pos,
  1326. fmt_hex, "antenna B:",
  1327. tx->tx_power.ant_b);
  1328. if ((priv->cfg->valid_tx_ant & ANT_C) && tx->tx_power.ant_c)
  1329. pos += scnprintf(buf + pos, bufsz - pos,
  1330. fmt_hex, "antenna C:",
  1331. tx->tx_power.ant_c);
  1332. }
  1333. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1334. kfree(buf);
  1335. return ret;
  1336. }
  1337. static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
  1338. char __user *user_buf,
  1339. size_t count, loff_t *ppos)
  1340. {
  1341. struct iwl_priv *priv = file->private_data;
  1342. int pos = 0;
  1343. char *buf;
  1344. int bufsz = sizeof(struct statistics_general) * 10 + 300;
  1345. ssize_t ret;
  1346. struct statistics_general_common *general, *accum_general;
  1347. struct statistics_general_common *delta_general, *max_general;
  1348. struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
  1349. struct statistics_div *div, *accum_div, *delta_div, *max_div;
  1350. if (!iwl_is_alive(priv->shrd))
  1351. return -EAGAIN;
  1352. buf = kzalloc(bufsz, GFP_KERNEL);
  1353. if (!buf) {
  1354. IWL_ERR(priv, "Can not allocate Buffer\n");
  1355. return -ENOMEM;
  1356. }
  1357. /* the statistic information display here is based on
  1358. * the last statistics notification from uCode
  1359. * might not reflect the current uCode activity
  1360. */
  1361. general = &priv->statistics.common;
  1362. dbg = &priv->statistics.common.dbg;
  1363. div = &priv->statistics.common.div;
  1364. accum_general = &priv->accum_stats.common;
  1365. accum_dbg = &priv->accum_stats.common.dbg;
  1366. accum_div = &priv->accum_stats.common.div;
  1367. delta_general = &priv->delta_stats.common;
  1368. max_general = &priv->max_delta_stats.common;
  1369. delta_dbg = &priv->delta_stats.common.dbg;
  1370. max_dbg = &priv->max_delta_stats.common.dbg;
  1371. delta_div = &priv->delta_stats.common.div;
  1372. max_div = &priv->max_delta_stats.common.div;
  1373. pos += iwl_statistics_flag(priv, buf, bufsz);
  1374. pos += scnprintf(buf + pos, bufsz - pos,
  1375. fmt_header, "Statistics_General:");
  1376. pos += scnprintf(buf + pos, bufsz - pos,
  1377. fmt_value, "temperature:",
  1378. le32_to_cpu(general->temperature));
  1379. pos += scnprintf(buf + pos, bufsz - pos,
  1380. fmt_value, "temperature_m:",
  1381. le32_to_cpu(general->temperature_m));
  1382. pos += scnprintf(buf + pos, bufsz - pos,
  1383. fmt_value, "ttl_timestamp:",
  1384. le32_to_cpu(general->ttl_timestamp));
  1385. pos += scnprintf(buf + pos, bufsz - pos,
  1386. fmt_table, "burst_check:",
  1387. le32_to_cpu(dbg->burst_check),
  1388. accum_dbg->burst_check,
  1389. delta_dbg->burst_check, max_dbg->burst_check);
  1390. pos += scnprintf(buf + pos, bufsz - pos,
  1391. fmt_table, "burst_count:",
  1392. le32_to_cpu(dbg->burst_count),
  1393. accum_dbg->burst_count,
  1394. delta_dbg->burst_count, max_dbg->burst_count);
  1395. pos += scnprintf(buf + pos, bufsz - pos,
  1396. fmt_table, "wait_for_silence_timeout_count:",
  1397. le32_to_cpu(dbg->wait_for_silence_timeout_cnt),
  1398. accum_dbg->wait_for_silence_timeout_cnt,
  1399. delta_dbg->wait_for_silence_timeout_cnt,
  1400. max_dbg->wait_for_silence_timeout_cnt);
  1401. pos += scnprintf(buf + pos, bufsz - pos,
  1402. fmt_table, "sleep_time:",
  1403. le32_to_cpu(general->sleep_time),
  1404. accum_general->sleep_time,
  1405. delta_general->sleep_time, max_general->sleep_time);
  1406. pos += scnprintf(buf + pos, bufsz - pos,
  1407. fmt_table, "slots_out:",
  1408. le32_to_cpu(general->slots_out),
  1409. accum_general->slots_out,
  1410. delta_general->slots_out, max_general->slots_out);
  1411. pos += scnprintf(buf + pos, bufsz - pos,
  1412. fmt_table, "slots_idle:",
  1413. le32_to_cpu(general->slots_idle),
  1414. accum_general->slots_idle,
  1415. delta_general->slots_idle, max_general->slots_idle);
  1416. pos += scnprintf(buf + pos, bufsz - pos,
  1417. fmt_table, "tx_on_a:",
  1418. le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
  1419. delta_div->tx_on_a, max_div->tx_on_a);
  1420. pos += scnprintf(buf + pos, bufsz - pos,
  1421. fmt_table, "tx_on_b:",
  1422. le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
  1423. delta_div->tx_on_b, max_div->tx_on_b);
  1424. pos += scnprintf(buf + pos, bufsz - pos,
  1425. fmt_table, "exec_time:",
  1426. le32_to_cpu(div->exec_time), accum_div->exec_time,
  1427. delta_div->exec_time, max_div->exec_time);
  1428. pos += scnprintf(buf + pos, bufsz - pos,
  1429. fmt_table, "probe_time:",
  1430. le32_to_cpu(div->probe_time), accum_div->probe_time,
  1431. delta_div->probe_time, max_div->probe_time);
  1432. pos += scnprintf(buf + pos, bufsz - pos,
  1433. fmt_table, "rx_enable_counter:",
  1434. le32_to_cpu(general->rx_enable_counter),
  1435. accum_general->rx_enable_counter,
  1436. delta_general->rx_enable_counter,
  1437. max_general->rx_enable_counter);
  1438. pos += scnprintf(buf + pos, bufsz - pos,
  1439. fmt_table, "num_of_sos_states:",
  1440. le32_to_cpu(general->num_of_sos_states),
  1441. accum_general->num_of_sos_states,
  1442. delta_general->num_of_sos_states,
  1443. max_general->num_of_sos_states);
  1444. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1445. kfree(buf);
  1446. return ret;
  1447. }
  1448. static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
  1449. char __user *user_buf,
  1450. size_t count, loff_t *ppos)
  1451. {
  1452. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  1453. int pos = 0;
  1454. char *buf;
  1455. int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200;
  1456. ssize_t ret;
  1457. struct statistics_bt_activity *bt, *accum_bt;
  1458. if (!iwl_is_alive(priv->shrd))
  1459. return -EAGAIN;
  1460. if (!priv->bt_enable_flag)
  1461. return -EINVAL;
  1462. /* make request to uCode to retrieve statistics information */
  1463. mutex_lock(&priv->shrd->mutex);
  1464. ret = iwl_send_statistics_request(priv, CMD_SYNC, false);
  1465. mutex_unlock(&priv->shrd->mutex);
  1466. if (ret) {
  1467. IWL_ERR(priv,
  1468. "Error sending statistics request: %zd\n", ret);
  1469. return -EAGAIN;
  1470. }
  1471. buf = kzalloc(bufsz, GFP_KERNEL);
  1472. if (!buf) {
  1473. IWL_ERR(priv, "Can not allocate Buffer\n");
  1474. return -ENOMEM;
  1475. }
  1476. /*
  1477. * the statistic information display here is based on
  1478. * the last statistics notification from uCode
  1479. * might not reflect the current uCode activity
  1480. */
  1481. bt = &priv->statistics.bt_activity;
  1482. accum_bt = &priv->accum_stats.bt_activity;
  1483. pos += iwl_statistics_flag(priv, buf, bufsz);
  1484. pos += scnprintf(buf + pos, bufsz - pos, "Statistics_BT:\n");
  1485. pos += scnprintf(buf + pos, bufsz - pos,
  1486. "\t\t\tcurrent\t\t\taccumulative\n");
  1487. pos += scnprintf(buf + pos, bufsz - pos,
  1488. "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
  1489. le32_to_cpu(bt->hi_priority_tx_req_cnt),
  1490. accum_bt->hi_priority_tx_req_cnt);
  1491. pos += scnprintf(buf + pos, bufsz - pos,
  1492. "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
  1493. le32_to_cpu(bt->hi_priority_tx_denied_cnt),
  1494. accum_bt->hi_priority_tx_denied_cnt);
  1495. pos += scnprintf(buf + pos, bufsz - pos,
  1496. "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
  1497. le32_to_cpu(bt->lo_priority_tx_req_cnt),
  1498. accum_bt->lo_priority_tx_req_cnt);
  1499. pos += scnprintf(buf + pos, bufsz - pos,
  1500. "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
  1501. le32_to_cpu(bt->lo_priority_tx_denied_cnt),
  1502. accum_bt->lo_priority_tx_denied_cnt);
  1503. pos += scnprintf(buf + pos, bufsz - pos,
  1504. "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
  1505. le32_to_cpu(bt->hi_priority_rx_req_cnt),
  1506. accum_bt->hi_priority_rx_req_cnt);
  1507. pos += scnprintf(buf + pos, bufsz - pos,
  1508. "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
  1509. le32_to_cpu(bt->hi_priority_rx_denied_cnt),
  1510. accum_bt->hi_priority_rx_denied_cnt);
  1511. pos += scnprintf(buf + pos, bufsz - pos,
  1512. "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
  1513. le32_to_cpu(bt->lo_priority_rx_req_cnt),
  1514. accum_bt->lo_priority_rx_req_cnt);
  1515. pos += scnprintf(buf + pos, bufsz - pos,
  1516. "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
  1517. le32_to_cpu(bt->lo_priority_rx_denied_cnt),
  1518. accum_bt->lo_priority_rx_denied_cnt);
  1519. pos += scnprintf(buf + pos, bufsz - pos,
  1520. "(rx)num_bt_kills:\t\t%u\t\t\t%u\n",
  1521. le32_to_cpu(priv->statistics.num_bt_kills),
  1522. priv->statistics.accum_num_bt_kills);
  1523. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1524. kfree(buf);
  1525. return ret;
  1526. }
  1527. static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file,
  1528. char __user *user_buf,
  1529. size_t count, loff_t *ppos)
  1530. {
  1531. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  1532. int pos = 0;
  1533. char *buf;
  1534. int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) +
  1535. (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200;
  1536. ssize_t ret;
  1537. if (!iwl_is_alive(priv->shrd))
  1538. return -EAGAIN;
  1539. buf = kzalloc(bufsz, GFP_KERNEL);
  1540. if (!buf) {
  1541. IWL_ERR(priv, "Can not allocate Buffer\n");
  1542. return -ENOMEM;
  1543. }
  1544. pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n");
  1545. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n",
  1546. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY),
  1547. priv->reply_tx_stats.pp_delay);
  1548. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1549. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES),
  1550. priv->reply_tx_stats.pp_few_bytes);
  1551. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1552. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO),
  1553. priv->reply_tx_stats.pp_bt_prio);
  1554. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1555. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD),
  1556. priv->reply_tx_stats.pp_quiet_period);
  1557. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1558. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK),
  1559. priv->reply_tx_stats.pp_calc_ttak);
  1560. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1561. iwl_get_tx_fail_reason(
  1562. TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY),
  1563. priv->reply_tx_stats.int_crossed_retry);
  1564. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1565. iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT),
  1566. priv->reply_tx_stats.short_limit);
  1567. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1568. iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT),
  1569. priv->reply_tx_stats.long_limit);
  1570. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1571. iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN),
  1572. priv->reply_tx_stats.fifo_underrun);
  1573. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1574. iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW),
  1575. priv->reply_tx_stats.drain_flow);
  1576. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1577. iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH),
  1578. priv->reply_tx_stats.rfkill_flush);
  1579. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1580. iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE),
  1581. priv->reply_tx_stats.life_expire);
  1582. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1583. iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS),
  1584. priv->reply_tx_stats.dest_ps);
  1585. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1586. iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED),
  1587. priv->reply_tx_stats.host_abort);
  1588. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1589. iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY),
  1590. priv->reply_tx_stats.pp_delay);
  1591. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1592. iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID),
  1593. priv->reply_tx_stats.sta_invalid);
  1594. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1595. iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED),
  1596. priv->reply_tx_stats.frag_drop);
  1597. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1598. iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE),
  1599. priv->reply_tx_stats.tid_disable);
  1600. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1601. iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED),
  1602. priv->reply_tx_stats.fifo_flush);
  1603. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1604. iwl_get_tx_fail_reason(
  1605. TX_STATUS_FAIL_INSUFFICIENT_CF_POLL),
  1606. priv->reply_tx_stats.insuff_cf_poll);
  1607. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1608. iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX),
  1609. priv->reply_tx_stats.fail_hw_drop);
  1610. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1611. iwl_get_tx_fail_reason(
  1612. TX_STATUS_FAIL_NO_BEACON_ON_RADAR),
  1613. priv->reply_tx_stats.sta_color_mismatch);
  1614. pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
  1615. priv->reply_tx_stats.unknown);
  1616. pos += scnprintf(buf + pos, bufsz - pos,
  1617. "\nStatistics_Agg_TX_Error:\n");
  1618. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1619. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK),
  1620. priv->reply_agg_tx_stats.underrun);
  1621. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1622. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK),
  1623. priv->reply_agg_tx_stats.bt_prio);
  1624. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1625. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK),
  1626. priv->reply_agg_tx_stats.few_bytes);
  1627. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1628. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK),
  1629. priv->reply_agg_tx_stats.abort);
  1630. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1631. iwl_get_agg_tx_fail_reason(
  1632. AGG_TX_STATE_LAST_SENT_TTL_MSK),
  1633. priv->reply_agg_tx_stats.last_sent_ttl);
  1634. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1635. iwl_get_agg_tx_fail_reason(
  1636. AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK),
  1637. priv->reply_agg_tx_stats.last_sent_try);
  1638. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1639. iwl_get_agg_tx_fail_reason(
  1640. AGG_TX_STATE_LAST_SENT_BT_KILL_MSK),
  1641. priv->reply_agg_tx_stats.last_sent_bt_kill);
  1642. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1643. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK),
  1644. priv->reply_agg_tx_stats.scd_query);
  1645. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1646. iwl_get_agg_tx_fail_reason(
  1647. AGG_TX_STATE_TEST_BAD_CRC32_MSK),
  1648. priv->reply_agg_tx_stats.bad_crc32);
  1649. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1650. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK),
  1651. priv->reply_agg_tx_stats.response);
  1652. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1653. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK),
  1654. priv->reply_agg_tx_stats.dump_tx);
  1655. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1656. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK),
  1657. priv->reply_agg_tx_stats.delay_tx);
  1658. pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
  1659. priv->reply_agg_tx_stats.unknown);
  1660. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1661. kfree(buf);
  1662. return ret;
  1663. }
  1664. static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
  1665. char __user *user_buf,
  1666. size_t count, loff_t *ppos) {
  1667. struct iwl_priv *priv = file->private_data;
  1668. int pos = 0;
  1669. int cnt = 0;
  1670. char *buf;
  1671. int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100;
  1672. ssize_t ret;
  1673. struct iwl_sensitivity_data *data;
  1674. data = &priv->sensitivity_data;
  1675. buf = kzalloc(bufsz, GFP_KERNEL);
  1676. if (!buf) {
  1677. IWL_ERR(priv, "Can not allocate Buffer\n");
  1678. return -ENOMEM;
  1679. }
  1680. pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
  1681. data->auto_corr_ofdm);
  1682. pos += scnprintf(buf + pos, bufsz - pos,
  1683. "auto_corr_ofdm_mrc:\t\t %u\n",
  1684. data->auto_corr_ofdm_mrc);
  1685. pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n",
  1686. data->auto_corr_ofdm_x1);
  1687. pos += scnprintf(buf + pos, bufsz - pos,
  1688. "auto_corr_ofdm_mrc_x1:\t\t %u\n",
  1689. data->auto_corr_ofdm_mrc_x1);
  1690. pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n",
  1691. data->auto_corr_cck);
  1692. pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n",
  1693. data->auto_corr_cck_mrc);
  1694. pos += scnprintf(buf + pos, bufsz - pos,
  1695. "last_bad_plcp_cnt_ofdm:\t\t %u\n",
  1696. data->last_bad_plcp_cnt_ofdm);
  1697. pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n",
  1698. data->last_fa_cnt_ofdm);
  1699. pos += scnprintf(buf + pos, bufsz - pos,
  1700. "last_bad_plcp_cnt_cck:\t\t %u\n",
  1701. data->last_bad_plcp_cnt_cck);
  1702. pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n",
  1703. data->last_fa_cnt_cck);
  1704. pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n",
  1705. data->nrg_curr_state);
  1706. pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n",
  1707. data->nrg_prev_state);
  1708. pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t");
  1709. for (cnt = 0; cnt < 10; cnt++) {
  1710. pos += scnprintf(buf + pos, bufsz - pos, " %u",
  1711. data->nrg_value[cnt]);
  1712. }
  1713. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  1714. pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t");
  1715. for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) {
  1716. pos += scnprintf(buf + pos, bufsz - pos, " %u",
  1717. data->nrg_silence_rssi[cnt]);
  1718. }
  1719. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  1720. pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n",
  1721. data->nrg_silence_ref);
  1722. pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n",
  1723. data->nrg_energy_idx);
  1724. pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n",
  1725. data->nrg_silence_idx);
  1726. pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n",
  1727. data->nrg_th_cck);
  1728. pos += scnprintf(buf + pos, bufsz - pos,
  1729. "nrg_auto_corr_silence_diff:\t %u\n",
  1730. data->nrg_auto_corr_silence_diff);
  1731. pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n",
  1732. data->num_in_cck_no_fa);
  1733. pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
  1734. data->nrg_th_ofdm);
  1735. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1736. kfree(buf);
  1737. return ret;
  1738. }
  1739. static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
  1740. char __user *user_buf,
  1741. size_t count, loff_t *ppos) {
  1742. struct iwl_priv *priv = file->private_data;
  1743. int pos = 0;
  1744. int cnt = 0;
  1745. char *buf;
  1746. int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100;
  1747. ssize_t ret;
  1748. struct iwl_chain_noise_data *data;
  1749. data = &priv->chain_noise_data;
  1750. buf = kzalloc(bufsz, GFP_KERNEL);
  1751. if (!buf) {
  1752. IWL_ERR(priv, "Can not allocate Buffer\n");
  1753. return -ENOMEM;
  1754. }
  1755. pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
  1756. data->active_chains);
  1757. pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n",
  1758. data->chain_noise_a);
  1759. pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n",
  1760. data->chain_noise_b);
  1761. pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n",
  1762. data->chain_noise_c);
  1763. pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n",
  1764. data->chain_signal_a);
  1765. pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n",
  1766. data->chain_signal_b);
  1767. pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n",
  1768. data->chain_signal_c);
  1769. pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n",
  1770. data->beacon_count);
  1771. pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t");
  1772. for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
  1773. pos += scnprintf(buf + pos, bufsz - pos, " %u",
  1774. data->disconn_array[cnt]);
  1775. }
  1776. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  1777. pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t");
  1778. for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
  1779. pos += scnprintf(buf + pos, bufsz - pos, " %u",
  1780. data->delta_gain_code[cnt]);
  1781. }
  1782. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  1783. pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n",
  1784. data->radio_write);
  1785. pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
  1786. data->state);
  1787. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1788. kfree(buf);
  1789. return ret;
  1790. }
  1791. static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
  1792. char __user *user_buf,
  1793. size_t count, loff_t *ppos)
  1794. {
  1795. struct iwl_priv *priv = file->private_data;
  1796. char buf[60];
  1797. int pos = 0;
  1798. const size_t bufsz = sizeof(buf);
  1799. u32 pwrsave_status;
  1800. pwrsave_status = iwl_read32(bus(priv), CSR_GP_CNTRL) &
  1801. CSR_GP_REG_POWER_SAVE_STATUS_MSK;
  1802. pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
  1803. pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
  1804. (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
  1805. (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
  1806. (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
  1807. "error");
  1808. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1809. }
  1810. static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
  1811. const char __user *user_buf,
  1812. size_t count, loff_t *ppos)
  1813. {
  1814. struct iwl_priv *priv = file->private_data;
  1815. char buf[8];
  1816. int buf_size;
  1817. int clear;
  1818. memset(buf, 0, sizeof(buf));
  1819. buf_size = min(count, sizeof(buf) - 1);
  1820. if (copy_from_user(buf, user_buf, buf_size))
  1821. return -EFAULT;
  1822. if (sscanf(buf, "%d", &clear) != 1)
  1823. return -EFAULT;
  1824. /* make request to uCode to retrieve statistics information */
  1825. mutex_lock(&priv->shrd->mutex);
  1826. iwl_send_statistics_request(priv, CMD_SYNC, true);
  1827. mutex_unlock(&priv->shrd->mutex);
  1828. return count;
  1829. }
  1830. static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
  1831. char __user *user_buf,
  1832. size_t count, loff_t *ppos) {
  1833. struct iwl_priv *priv = file->private_data;
  1834. int pos = 0;
  1835. char buf[128];
  1836. const size_t bufsz = sizeof(buf);
  1837. pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
  1838. priv->event_log.ucode_trace ? "On" : "Off");
  1839. pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
  1840. priv->event_log.non_wraps_count);
  1841. pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
  1842. priv->event_log.wraps_once_count);
  1843. pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
  1844. priv->event_log.wraps_more_count);
  1845. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1846. }
  1847. static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
  1848. const char __user *user_buf,
  1849. size_t count, loff_t *ppos)
  1850. {
  1851. struct iwl_priv *priv = file->private_data;
  1852. char buf[8];
  1853. int buf_size;
  1854. int trace;
  1855. memset(buf, 0, sizeof(buf));
  1856. buf_size = min(count, sizeof(buf) - 1);
  1857. if (copy_from_user(buf, user_buf, buf_size))
  1858. return -EFAULT;
  1859. if (sscanf(buf, "%d", &trace) != 1)
  1860. return -EFAULT;
  1861. if (trace) {
  1862. priv->event_log.ucode_trace = true;
  1863. /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */
  1864. mod_timer(&priv->ucode_trace,
  1865. jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD));
  1866. } else {
  1867. priv->event_log.ucode_trace = false;
  1868. del_timer_sync(&priv->ucode_trace);
  1869. }
  1870. return count;
  1871. }
  1872. static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
  1873. char __user *user_buf,
  1874. size_t count, loff_t *ppos) {
  1875. struct iwl_priv *priv = file->private_data;
  1876. int len = 0;
  1877. char buf[20];
  1878. len = sprintf(buf, "0x%04X\n",
  1879. le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags));
  1880. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1881. }
  1882. static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
  1883. char __user *user_buf,
  1884. size_t count, loff_t *ppos) {
  1885. struct iwl_priv *priv = file->private_data;
  1886. int len = 0;
  1887. char buf[20];
  1888. len = sprintf(buf, "0x%04X\n",
  1889. le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags));
  1890. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1891. }
  1892. static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
  1893. char __user *user_buf,
  1894. size_t count, loff_t *ppos) {
  1895. struct iwl_priv *priv = file->private_data;
  1896. int pos = 0;
  1897. char buf[12];
  1898. const size_t bufsz = sizeof(buf);
  1899. pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
  1900. priv->missed_beacon_threshold);
  1901. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1902. }
  1903. static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
  1904. const char __user *user_buf,
  1905. size_t count, loff_t *ppos)
  1906. {
  1907. struct iwl_priv *priv = file->private_data;
  1908. char buf[8];
  1909. int buf_size;
  1910. int missed;
  1911. memset(buf, 0, sizeof(buf));
  1912. buf_size = min(count, sizeof(buf) - 1);
  1913. if (copy_from_user(buf, user_buf, buf_size))
  1914. return -EFAULT;
  1915. if (sscanf(buf, "%d", &missed) != 1)
  1916. return -EINVAL;
  1917. if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN ||
  1918. missed > IWL_MISSED_BEACON_THRESHOLD_MAX)
  1919. priv->missed_beacon_threshold =
  1920. IWL_MISSED_BEACON_THRESHOLD_DEF;
  1921. else
  1922. priv->missed_beacon_threshold = missed;
  1923. return count;
  1924. }
  1925. static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
  1926. char __user *user_buf,
  1927. size_t count, loff_t *ppos) {
  1928. struct iwl_priv *priv = file->private_data;
  1929. int pos = 0;
  1930. char buf[12];
  1931. const size_t bufsz = sizeof(buf);
  1932. pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
  1933. priv->cfg->base_params->plcp_delta_threshold);
  1934. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1935. }
  1936. static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
  1937. const char __user *user_buf,
  1938. size_t count, loff_t *ppos) {
  1939. struct iwl_priv *priv = file->private_data;
  1940. char buf[8];
  1941. int buf_size;
  1942. int plcp;
  1943. memset(buf, 0, sizeof(buf));
  1944. buf_size = min(count, sizeof(buf) - 1);
  1945. if (copy_from_user(buf, user_buf, buf_size))
  1946. return -EFAULT;
  1947. if (sscanf(buf, "%d", &plcp) != 1)
  1948. return -EINVAL;
  1949. if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
  1950. (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
  1951. priv->cfg->base_params->plcp_delta_threshold =
  1952. IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE;
  1953. else
  1954. priv->cfg->base_params->plcp_delta_threshold = plcp;
  1955. return count;
  1956. }
  1957. static ssize_t iwl_dbgfs_force_reset_read(struct file *file,
  1958. char __user *user_buf,
  1959. size_t count, loff_t *ppos) {
  1960. struct iwl_priv *priv = file->private_data;
  1961. int i, pos = 0;
  1962. char buf[300];
  1963. const size_t bufsz = sizeof(buf);
  1964. struct iwl_force_reset *force_reset;
  1965. for (i = 0; i < IWL_MAX_FORCE_RESET; i++) {
  1966. force_reset = &priv->force_reset[i];
  1967. pos += scnprintf(buf + pos, bufsz - pos,
  1968. "Force reset method %d\n", i);
  1969. pos += scnprintf(buf + pos, bufsz - pos,
  1970. "\tnumber of reset request: %d\n",
  1971. force_reset->reset_request_count);
  1972. pos += scnprintf(buf + pos, bufsz - pos,
  1973. "\tnumber of reset request success: %d\n",
  1974. force_reset->reset_success_count);
  1975. pos += scnprintf(buf + pos, bufsz - pos,
  1976. "\tnumber of reset request reject: %d\n",
  1977. force_reset->reset_reject_count);
  1978. pos += scnprintf(buf + pos, bufsz - pos,
  1979. "\treset duration: %lu\n",
  1980. force_reset->reset_duration);
  1981. }
  1982. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1983. }
  1984. static ssize_t iwl_dbgfs_force_reset_write(struct file *file,
  1985. const char __user *user_buf,
  1986. size_t count, loff_t *ppos) {
  1987. struct iwl_priv *priv = file->private_data;
  1988. char buf[8];
  1989. int buf_size;
  1990. int reset, ret;
  1991. memset(buf, 0, sizeof(buf));
  1992. buf_size = min(count, sizeof(buf) - 1);
  1993. if (copy_from_user(buf, user_buf, buf_size))
  1994. return -EFAULT;
  1995. if (sscanf(buf, "%d", &reset) != 1)
  1996. return -EINVAL;
  1997. switch (reset) {
  1998. case IWL_RF_RESET:
  1999. case IWL_FW_RESET:
  2000. ret = iwl_force_reset(priv, reset, true);
  2001. break;
  2002. default:
  2003. return -EINVAL;
  2004. }
  2005. return ret ? ret : count;
  2006. }
  2007. static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
  2008. const char __user *user_buf,
  2009. size_t count, loff_t *ppos) {
  2010. struct iwl_priv *priv = file->private_data;
  2011. char buf[8];
  2012. int buf_size;
  2013. int flush;
  2014. memset(buf, 0, sizeof(buf));
  2015. buf_size = min(count, sizeof(buf) - 1);
  2016. if (copy_from_user(buf, user_buf, buf_size))
  2017. return -EFAULT;
  2018. if (sscanf(buf, "%d", &flush) != 1)
  2019. return -EINVAL;
  2020. if (iwl_is_rfkill(priv->shrd))
  2021. return -EFAULT;
  2022. iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL);
  2023. return count;
  2024. }
  2025. static ssize_t iwl_dbgfs_wd_timeout_write(struct file *file,
  2026. const char __user *user_buf,
  2027. size_t count, loff_t *ppos) {
  2028. struct iwl_priv *priv = file->private_data;
  2029. char buf[8];
  2030. int buf_size;
  2031. int timeout;
  2032. memset(buf, 0, sizeof(buf));
  2033. buf_size = min(count, sizeof(buf) - 1);
  2034. if (copy_from_user(buf, user_buf, buf_size))
  2035. return -EFAULT;
  2036. if (sscanf(buf, "%d", &timeout) != 1)
  2037. return -EINVAL;
  2038. if (timeout < 0 || timeout > IWL_MAX_WD_TIMEOUT)
  2039. timeout = IWL_DEF_WD_TIMEOUT;
  2040. priv->cfg->base_params->wd_timeout = timeout;
  2041. iwl_setup_watchdog(priv);
  2042. return count;
  2043. }
  2044. static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file,
  2045. char __user *user_buf,
  2046. size_t count, loff_t *ppos) {
  2047. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  2048. int pos = 0;
  2049. char buf[200];
  2050. const size_t bufsz = sizeof(buf);
  2051. if (!priv->bt_enable_flag) {
  2052. pos += scnprintf(buf + pos, bufsz - pos, "BT coex disabled\n");
  2053. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  2054. }
  2055. pos += scnprintf(buf + pos, bufsz - pos, "BT enable flag: 0x%x\n",
  2056. priv->bt_enable_flag);
  2057. pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n",
  2058. priv->bt_full_concurrent ? "full concurrency" : "3-wire");
  2059. pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, "
  2060. "last traffic notif: %d\n",
  2061. priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load);
  2062. pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, "
  2063. "kill_ack_mask: %x, kill_cts_mask: %x\n",
  2064. priv->bt_ch_announce, priv->kill_ack_mask,
  2065. priv->kill_cts_mask);
  2066. pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: ");
  2067. switch (priv->bt_traffic_load) {
  2068. case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
  2069. pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n");
  2070. break;
  2071. case IWL_BT_COEX_TRAFFIC_LOAD_HIGH:
  2072. pos += scnprintf(buf + pos, bufsz - pos, "High\n");
  2073. break;
  2074. case IWL_BT_COEX_TRAFFIC_LOAD_LOW:
  2075. pos += scnprintf(buf + pos, bufsz - pos, "Low\n");
  2076. break;
  2077. case IWL_BT_COEX_TRAFFIC_LOAD_NONE:
  2078. default:
  2079. pos += scnprintf(buf + pos, bufsz - pos, "None\n");
  2080. break;
  2081. }
  2082. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  2083. }
  2084. static ssize_t iwl_dbgfs_protection_mode_read(struct file *file,
  2085. char __user *user_buf,
  2086. size_t count, loff_t *ppos)
  2087. {
  2088. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  2089. int pos = 0;
  2090. char buf[40];
  2091. const size_t bufsz = sizeof(buf);
  2092. if (priv->cfg->ht_params)
  2093. pos += scnprintf(buf + pos, bufsz - pos,
  2094. "use %s for aggregation\n",
  2095. (priv->cfg->ht_params->use_rts_for_aggregation) ?
  2096. "rts/cts" : "cts-to-self");
  2097. else
  2098. pos += scnprintf(buf + pos, bufsz - pos, "N/A");
  2099. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  2100. }
  2101. static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
  2102. const char __user *user_buf,
  2103. size_t count, loff_t *ppos) {
  2104. struct iwl_priv *priv = file->private_data;
  2105. char buf[8];
  2106. int buf_size;
  2107. int rts;
  2108. if (!priv->cfg->ht_params)
  2109. return -EINVAL;
  2110. memset(buf, 0, sizeof(buf));
  2111. buf_size = min(count, sizeof(buf) - 1);
  2112. if (copy_from_user(buf, user_buf, buf_size))
  2113. return -EFAULT;
  2114. if (sscanf(buf, "%d", &rts) != 1)
  2115. return -EINVAL;
  2116. if (rts)
  2117. priv->cfg->ht_params->use_rts_for_aggregation = true;
  2118. else
  2119. priv->cfg->ht_params->use_rts_for_aggregation = false;
  2120. return count;
  2121. }
  2122. DEBUGFS_READ_FILE_OPS(rx_statistics);
  2123. DEBUGFS_READ_FILE_OPS(tx_statistics);
  2124. DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
  2125. DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
  2126. DEBUGFS_READ_FILE_OPS(ucode_general_stats);
  2127. DEBUGFS_READ_FILE_OPS(sensitivity);
  2128. DEBUGFS_READ_FILE_OPS(chain_noise);
  2129. DEBUGFS_READ_FILE_OPS(power_save_status);
  2130. DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
  2131. DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics);
  2132. DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
  2133. DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
  2134. DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
  2135. DEBUGFS_READ_WRITE_FILE_OPS(force_reset);
  2136. DEBUGFS_READ_FILE_OPS(rxon_flags);
  2137. DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
  2138. DEBUGFS_WRITE_FILE_OPS(txfifo_flush);
  2139. DEBUGFS_READ_FILE_OPS(ucode_bt_stats);
  2140. DEBUGFS_WRITE_FILE_OPS(wd_timeout);
  2141. DEBUGFS_READ_FILE_OPS(bt_traffic);
  2142. DEBUGFS_READ_WRITE_FILE_OPS(protection_mode);
  2143. DEBUGFS_READ_FILE_OPS(reply_tx_error);
  2144. /*
  2145. * Create the debugfs files and directories
  2146. *
  2147. */
  2148. int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
  2149. {
  2150. struct dentry *phyd = priv->hw->wiphy->debugfsdir;
  2151. struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug;
  2152. dir_drv = debugfs_create_dir(name, phyd);
  2153. if (!dir_drv)
  2154. return -ENOMEM;
  2155. priv->debugfs_dir = dir_drv;
  2156. dir_data = debugfs_create_dir("data", dir_drv);
  2157. if (!dir_data)
  2158. goto err;
  2159. dir_rf = debugfs_create_dir("rf", dir_drv);
  2160. if (!dir_rf)
  2161. goto err;
  2162. dir_debug = debugfs_create_dir("debug", dir_drv);
  2163. if (!dir_debug)
  2164. goto err;
  2165. DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
  2166. DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
  2167. DEBUGFS_ADD_FILE(wowlan_sram, dir_data, S_IRUSR);
  2168. DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
  2169. DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
  2170. DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
  2171. DEBUGFS_ADD_FILE(rx_handlers, dir_data, S_IWUSR | S_IRUSR);
  2172. DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
  2173. DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR);
  2174. DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
  2175. DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
  2176. DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
  2177. DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR);
  2178. DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR);
  2179. DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
  2180. DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
  2181. DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR);
  2182. DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
  2183. DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
  2184. DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR);
  2185. DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
  2186. DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
  2187. DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
  2188. DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR);
  2189. DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR);
  2190. DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
  2191. DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
  2192. DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
  2193. DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR);
  2194. DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR);
  2195. DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
  2196. DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
  2197. DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR);
  2198. if (iwl_advanced_bt_coexist(priv))
  2199. DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR);
  2200. DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf,
  2201. &priv->disable_sens_cal);
  2202. DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf,
  2203. &priv->disable_chain_noise_cal);
  2204. if (iwl_trans_dbgfs_register(trans(priv), dir_debug))
  2205. goto err;
  2206. return 0;
  2207. err:
  2208. IWL_ERR(priv, "Can't create the debugfs directory\n");
  2209. iwl_dbgfs_unregister(priv);
  2210. return -ENOMEM;
  2211. }
  2212. /**
  2213. * Remove the debugfs files and directories
  2214. *
  2215. */
  2216. void iwl_dbgfs_unregister(struct iwl_priv *priv)
  2217. {
  2218. if (!priv->debugfs_dir)
  2219. return;
  2220. debugfs_remove_recursive(priv->debugfs_dir);
  2221. priv->debugfs_dir = NULL;
  2222. }