iwl-debugfs.c 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301
  1. /******************************************************************************
  2. *
  3. * GPL LICENSE SUMMARY
  4. *
  5. * Copyright(c) 2008 - 2009 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/kernel.h>
  29. #include <linux/module.h>
  30. #include <linux/debugfs.h>
  31. #include <linux/ieee80211.h>
  32. #include <net/mac80211.h>
  33. #include "iwl-dev.h"
  34. #include "iwl-debug.h"
  35. #include "iwl-core.h"
  36. #include "iwl-io.h"
  37. #include "iwl-calib.h"
  38. /* create and remove of files */
  39. #define DEBUGFS_ADD_DIR(name, parent) do { \
  40. dbgfs->dir_##name = debugfs_create_dir(#name, parent); \
  41. if (!(dbgfs->dir_##name)) \
  42. goto err; \
  43. } while (0)
  44. #define DEBUGFS_ADD_FILE(name, parent, mode) do { \
  45. dbgfs->dbgfs_##parent##_files.file_##name = \
  46. debugfs_create_file(#name, mode, \
  47. dbgfs->dir_##parent, priv, \
  48. &iwl_dbgfs_##name##_ops); \
  49. if (!(dbgfs->dbgfs_##parent##_files.file_##name)) \
  50. goto err; \
  51. } while (0)
  52. #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
  53. dbgfs->dbgfs_##parent##_files.file_##name = \
  54. debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \
  55. dbgfs->dir_##parent, ptr); \
  56. if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \
  57. || !dbgfs->dbgfs_##parent##_files.file_##name) \
  58. goto err; \
  59. } while (0)
  60. #define DEBUGFS_ADD_X32(name, parent, ptr) do { \
  61. dbgfs->dbgfs_##parent##_files.file_##name = \
  62. debugfs_create_x32(#name, S_IRUSR, dbgfs->dir_##parent, ptr); \
  63. if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \
  64. || !dbgfs->dbgfs_##parent##_files.file_##name) \
  65. goto err; \
  66. } while (0)
  67. #define DEBUGFS_REMOVE(name) do { \
  68. debugfs_remove(name); \
  69. name = NULL; \
  70. } while (0);
  71. /* file operation */
  72. #define DEBUGFS_READ_FUNC(name) \
  73. static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
  74. char __user *user_buf, \
  75. size_t count, loff_t *ppos);
  76. #define DEBUGFS_WRITE_FUNC(name) \
  77. static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
  78. const char __user *user_buf, \
  79. size_t count, loff_t *ppos);
  80. static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file)
  81. {
  82. file->private_data = inode->i_private;
  83. return 0;
  84. }
  85. #define DEBUGFS_READ_FILE_OPS(name) \
  86. DEBUGFS_READ_FUNC(name); \
  87. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  88. .read = iwl_dbgfs_##name##_read, \
  89. .open = iwl_dbgfs_open_file_generic, \
  90. };
  91. #define DEBUGFS_WRITE_FILE_OPS(name) \
  92. DEBUGFS_WRITE_FUNC(name); \
  93. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  94. .write = iwl_dbgfs_##name##_write, \
  95. .open = iwl_dbgfs_open_file_generic, \
  96. };
  97. #define DEBUGFS_READ_WRITE_FILE_OPS(name) \
  98. DEBUGFS_READ_FUNC(name); \
  99. DEBUGFS_WRITE_FUNC(name); \
  100. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  101. .write = iwl_dbgfs_##name##_write, \
  102. .read = iwl_dbgfs_##name##_read, \
  103. .open = iwl_dbgfs_open_file_generic, \
  104. };
  105. static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
  106. char __user *user_buf,
  107. size_t count, loff_t *ppos) {
  108. struct iwl_priv *priv = file->private_data;
  109. char *buf;
  110. int pos = 0;
  111. int cnt;
  112. ssize_t ret;
  113. const size_t bufsz = 100 +
  114. sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
  115. buf = kzalloc(bufsz, GFP_KERNEL);
  116. if (!buf)
  117. return -ENOMEM;
  118. pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
  119. for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
  120. pos += scnprintf(buf + pos, bufsz - pos,
  121. "\t%25s\t\t: %u\n",
  122. get_mgmt_string(cnt),
  123. priv->tx_stats.mgmt[cnt]);
  124. }
  125. pos += scnprintf(buf + pos, bufsz - pos, "Control\n");
  126. for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
  127. pos += scnprintf(buf + pos, bufsz - pos,
  128. "\t%25s\t\t: %u\n",
  129. get_ctrl_string(cnt),
  130. priv->tx_stats.ctrl[cnt]);
  131. }
  132. pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
  133. pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
  134. priv->tx_stats.data_cnt);
  135. pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
  136. priv->tx_stats.data_bytes);
  137. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  138. kfree(buf);
  139. return ret;
  140. }
  141. static ssize_t iwl_dbgfs_clear_traffic_statistics_write(struct file *file,
  142. const char __user *user_buf,
  143. size_t count, loff_t *ppos)
  144. {
  145. struct iwl_priv *priv = file->private_data;
  146. u32 clear_flag;
  147. char buf[8];
  148. int buf_size;
  149. memset(buf, 0, sizeof(buf));
  150. buf_size = min(count, sizeof(buf) - 1);
  151. if (copy_from_user(buf, user_buf, buf_size))
  152. return -EFAULT;
  153. if (sscanf(buf, "%x", &clear_flag) != 1)
  154. return -EFAULT;
  155. iwl_clear_traffic_stats(priv);
  156. return count;
  157. }
  158. static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
  159. char __user *user_buf,
  160. size_t count, loff_t *ppos) {
  161. struct iwl_priv *priv = file->private_data;
  162. char *buf;
  163. int pos = 0;
  164. int cnt;
  165. ssize_t ret;
  166. const size_t bufsz = 100 +
  167. sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX);
  168. buf = kzalloc(bufsz, GFP_KERNEL);
  169. if (!buf)
  170. return -ENOMEM;
  171. pos += scnprintf(buf + pos, bufsz - pos, "Management:\n");
  172. for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) {
  173. pos += scnprintf(buf + pos, bufsz - pos,
  174. "\t%25s\t\t: %u\n",
  175. get_mgmt_string(cnt),
  176. priv->rx_stats.mgmt[cnt]);
  177. }
  178. pos += scnprintf(buf + pos, bufsz - pos, "Control:\n");
  179. for (cnt = 0; cnt < CONTROL_MAX; cnt++) {
  180. pos += scnprintf(buf + pos, bufsz - pos,
  181. "\t%25s\t\t: %u\n",
  182. get_ctrl_string(cnt),
  183. priv->rx_stats.ctrl[cnt]);
  184. }
  185. pos += scnprintf(buf + pos, bufsz - pos, "Data:\n");
  186. pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n",
  187. priv->rx_stats.data_cnt);
  188. pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
  189. priv->rx_stats.data_bytes);
  190. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  191. kfree(buf);
  192. return ret;
  193. }
  194. #define BYTE1_MASK 0x000000ff;
  195. #define BYTE2_MASK 0x0000ffff;
  196. #define BYTE3_MASK 0x00ffffff;
  197. static ssize_t iwl_dbgfs_sram_read(struct file *file,
  198. char __user *user_buf,
  199. size_t count, loff_t *ppos)
  200. {
  201. u32 val;
  202. char *buf;
  203. ssize_t ret;
  204. int i;
  205. int pos = 0;
  206. struct iwl_priv *priv = file->private_data;
  207. size_t bufsz;
  208. /* default is to dump the entire data segment */
  209. if (!priv->dbgfs->sram_offset && !priv->dbgfs->sram_len) {
  210. priv->dbgfs->sram_offset = 0x800000;
  211. if (priv->ucode_type == UCODE_INIT)
  212. priv->dbgfs->sram_len = priv->ucode_init_data.len;
  213. else
  214. priv->dbgfs->sram_len = priv->ucode_data.len;
  215. }
  216. bufsz = 30 + priv->dbgfs->sram_len * sizeof(char) * 10;
  217. buf = kmalloc(bufsz, GFP_KERNEL);
  218. if (!buf)
  219. return -ENOMEM;
  220. pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n",
  221. priv->dbgfs->sram_len);
  222. pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n",
  223. priv->dbgfs->sram_offset);
  224. for (i = priv->dbgfs->sram_len; i > 0; i -= 4) {
  225. val = iwl_read_targ_mem(priv, priv->dbgfs->sram_offset + \
  226. priv->dbgfs->sram_len - i);
  227. if (i < 4) {
  228. switch (i) {
  229. case 1:
  230. val &= BYTE1_MASK;
  231. break;
  232. case 2:
  233. val &= BYTE2_MASK;
  234. break;
  235. case 3:
  236. val &= BYTE3_MASK;
  237. break;
  238. }
  239. }
  240. if (!(i % 16))
  241. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  242. pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val);
  243. }
  244. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  245. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  246. kfree(buf);
  247. return ret;
  248. }
  249. static ssize_t iwl_dbgfs_sram_write(struct file *file,
  250. const char __user *user_buf,
  251. size_t count, loff_t *ppos)
  252. {
  253. struct iwl_priv *priv = file->private_data;
  254. char buf[64];
  255. int buf_size;
  256. u32 offset, len;
  257. memset(buf, 0, sizeof(buf));
  258. buf_size = min(count, sizeof(buf) - 1);
  259. if (copy_from_user(buf, user_buf, buf_size))
  260. return -EFAULT;
  261. if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
  262. priv->dbgfs->sram_offset = offset;
  263. priv->dbgfs->sram_len = len;
  264. } else {
  265. priv->dbgfs->sram_offset = 0;
  266. priv->dbgfs->sram_len = 0;
  267. }
  268. return count;
  269. }
  270. static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
  271. size_t count, loff_t *ppos)
  272. {
  273. struct iwl_priv *priv = file->private_data;
  274. struct iwl_station_entry *station;
  275. int max_sta = priv->hw_params.max_stations;
  276. char *buf;
  277. int i, j, pos = 0;
  278. ssize_t ret;
  279. /* Add 30 for initial string */
  280. const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
  281. buf = kmalloc(bufsz, GFP_KERNEL);
  282. if (!buf)
  283. return -ENOMEM;
  284. pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n",
  285. priv->num_stations);
  286. for (i = 0; i < max_sta; i++) {
  287. station = &priv->stations[i];
  288. if (station->used) {
  289. pos += scnprintf(buf + pos, bufsz - pos,
  290. "station %d:\ngeneral data:\n", i+1);
  291. pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n",
  292. station->sta.sta.sta_id);
  293. pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n",
  294. station->sta.mode);
  295. pos += scnprintf(buf + pos, bufsz - pos,
  296. "flags: 0x%x\n",
  297. station->sta.station_flags_msk);
  298. pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n");
  299. pos += scnprintf(buf + pos, bufsz - pos,
  300. "seq_num\t\ttxq_id");
  301. pos += scnprintf(buf + pos, bufsz - pos,
  302. "\tframe_count\twait_for_ba\t");
  303. pos += scnprintf(buf + pos, bufsz - pos,
  304. "start_idx\tbitmap0\t");
  305. pos += scnprintf(buf + pos, bufsz - pos,
  306. "bitmap1\trate_n_flags");
  307. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  308. for (j = 0; j < MAX_TID_COUNT; j++) {
  309. pos += scnprintf(buf + pos, bufsz - pos,
  310. "[%d]:\t\t%u", j,
  311. station->tid[j].seq_number);
  312. pos += scnprintf(buf + pos, bufsz - pos,
  313. "\t%u\t\t%u\t\t%u\t\t",
  314. station->tid[j].agg.txq_id,
  315. station->tid[j].agg.frame_count,
  316. station->tid[j].agg.wait_for_ba);
  317. pos += scnprintf(buf + pos, bufsz - pos,
  318. "%u\t%llu\t%u",
  319. station->tid[j].agg.start_idx,
  320. (unsigned long long)station->tid[j].agg.bitmap,
  321. station->tid[j].agg.rate_n_flags);
  322. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  323. }
  324. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  325. }
  326. }
  327. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  328. kfree(buf);
  329. return ret;
  330. }
  331. static ssize_t iwl_dbgfs_nvm_read(struct file *file,
  332. char __user *user_buf,
  333. size_t count,
  334. loff_t *ppos)
  335. {
  336. ssize_t ret;
  337. struct iwl_priv *priv = file->private_data;
  338. int pos = 0, ofs = 0, buf_size = 0;
  339. const u8 *ptr;
  340. char *buf;
  341. u16 eeprom_ver;
  342. size_t eeprom_len = priv->cfg->eeprom_size;
  343. buf_size = 4 * eeprom_len + 256;
  344. if (eeprom_len % 16) {
  345. IWL_ERR(priv, "NVM size is not multiple of 16.\n");
  346. return -ENODATA;
  347. }
  348. ptr = priv->eeprom;
  349. if (!ptr) {
  350. IWL_ERR(priv, "Invalid EEPROM/OTP memory\n");
  351. return -ENOMEM;
  352. }
  353. /* 4 characters for byte 0xYY */
  354. buf = kzalloc(buf_size, GFP_KERNEL);
  355. if (!buf) {
  356. IWL_ERR(priv, "Can not allocate Buffer\n");
  357. return -ENOMEM;
  358. }
  359. eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
  360. pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, "
  361. "version: 0x%x\n",
  362. (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
  363. ? "OTP" : "EEPROM", eeprom_ver);
  364. for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
  365. pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
  366. hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
  367. buf_size - pos, 0);
  368. pos += strlen(buf + pos);
  369. if (buf_size - pos > 0)
  370. buf[pos++] = '\n';
  371. }
  372. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  373. kfree(buf);
  374. return ret;
  375. }
  376. static ssize_t iwl_dbgfs_log_event_read(struct file *file,
  377. char __user *user_buf,
  378. size_t count, loff_t *ppos)
  379. {
  380. struct iwl_priv *priv = file->private_data;
  381. char *buf;
  382. int pos = 0;
  383. ssize_t ret = -ENOMEM;
  384. pos = priv->cfg->ops->lib->dump_nic_event_log(priv, true, &buf, true);
  385. if (pos && buf) {
  386. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  387. kfree(buf);
  388. }
  389. return ret;
  390. }
  391. static ssize_t iwl_dbgfs_log_event_write(struct file *file,
  392. const char __user *user_buf,
  393. size_t count, loff_t *ppos)
  394. {
  395. struct iwl_priv *priv = file->private_data;
  396. u32 event_log_flag;
  397. char buf[8];
  398. int buf_size;
  399. memset(buf, 0, sizeof(buf));
  400. buf_size = min(count, sizeof(buf) - 1);
  401. if (copy_from_user(buf, user_buf, buf_size))
  402. return -EFAULT;
  403. if (sscanf(buf, "%d", &event_log_flag) != 1)
  404. return -EFAULT;
  405. if (event_log_flag == 1)
  406. priv->cfg->ops->lib->dump_nic_event_log(priv, true,
  407. NULL, false);
  408. return count;
  409. }
  410. static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
  411. size_t count, loff_t *ppos)
  412. {
  413. struct iwl_priv *priv = file->private_data;
  414. struct ieee80211_channel *channels = NULL;
  415. const struct ieee80211_supported_band *supp_band = NULL;
  416. int pos = 0, i, bufsz = PAGE_SIZE;
  417. char *buf;
  418. ssize_t ret;
  419. if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status))
  420. return -EAGAIN;
  421. buf = kzalloc(bufsz, GFP_KERNEL);
  422. if (!buf) {
  423. IWL_ERR(priv, "Can not allocate Buffer\n");
  424. return -ENOMEM;
  425. }
  426. supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
  427. if (supp_band) {
  428. channels = supp_band->channels;
  429. pos += scnprintf(buf + pos, bufsz - pos,
  430. "Displaying %d channels in 2.4GHz band 802.11bg):\n",
  431. supp_band->n_channels);
  432. for (i = 0; i < supp_band->n_channels; i++)
  433. pos += scnprintf(buf + pos, bufsz - pos,
  434. "%d: %ddBm: BSS%s%s, %s.\n",
  435. ieee80211_frequency_to_channel(
  436. channels[i].center_freq),
  437. channels[i].max_power,
  438. channels[i].flags & IEEE80211_CHAN_RADAR ?
  439. " (IEEE 802.11h required)" : "",
  440. ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
  441. || (channels[i].flags &
  442. IEEE80211_CHAN_RADAR)) ? "" :
  443. ", IBSS",
  444. channels[i].flags &
  445. IEEE80211_CHAN_PASSIVE_SCAN ?
  446. "passive only" : "active/passive");
  447. }
  448. supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
  449. if (supp_band) {
  450. channels = supp_band->channels;
  451. pos += scnprintf(buf + pos, bufsz - pos,
  452. "Displaying %d channels in 5.2GHz band (802.11a)\n",
  453. supp_band->n_channels);
  454. for (i = 0; i < supp_band->n_channels; i++)
  455. pos += scnprintf(buf + pos, bufsz - pos,
  456. "%d: %ddBm: BSS%s%s, %s.\n",
  457. ieee80211_frequency_to_channel(
  458. channels[i].center_freq),
  459. channels[i].max_power,
  460. channels[i].flags & IEEE80211_CHAN_RADAR ?
  461. " (IEEE 802.11h required)" : "",
  462. ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
  463. || (channels[i].flags &
  464. IEEE80211_CHAN_RADAR)) ? "" :
  465. ", IBSS",
  466. channels[i].flags &
  467. IEEE80211_CHAN_PASSIVE_SCAN ?
  468. "passive only" : "active/passive");
  469. }
  470. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  471. kfree(buf);
  472. return ret;
  473. }
  474. static ssize_t iwl_dbgfs_status_read(struct file *file,
  475. char __user *user_buf,
  476. size_t count, loff_t *ppos) {
  477. struct iwl_priv *priv = file->private_data;
  478. char buf[512];
  479. int pos = 0;
  480. const size_t bufsz = sizeof(buf);
  481. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n",
  482. test_bit(STATUS_HCMD_ACTIVE, &priv->status));
  483. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_SYNC_ACTIVE: %d\n",
  484. test_bit(STATUS_HCMD_SYNC_ACTIVE, &priv->status));
  485. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n",
  486. test_bit(STATUS_INT_ENABLED, &priv->status));
  487. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n",
  488. test_bit(STATUS_RF_KILL_HW, &priv->status));
  489. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n",
  490. test_bit(STATUS_CT_KILL, &priv->status));
  491. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n",
  492. test_bit(STATUS_INIT, &priv->status));
  493. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n",
  494. test_bit(STATUS_ALIVE, &priv->status));
  495. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n",
  496. test_bit(STATUS_READY, &priv->status));
  497. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n",
  498. test_bit(STATUS_TEMPERATURE, &priv->status));
  499. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n",
  500. test_bit(STATUS_GEO_CONFIGURED, &priv->status));
  501. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n",
  502. test_bit(STATUS_EXIT_PENDING, &priv->status));
  503. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n",
  504. test_bit(STATUS_STATISTICS, &priv->status));
  505. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n",
  506. test_bit(STATUS_SCANNING, &priv->status));
  507. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n",
  508. test_bit(STATUS_SCAN_ABORTING, &priv->status));
  509. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n",
  510. test_bit(STATUS_SCAN_HW, &priv->status));
  511. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n",
  512. test_bit(STATUS_POWER_PMI, &priv->status));
  513. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
  514. test_bit(STATUS_FW_ERROR, &priv->status));
  515. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_MODE_PENDING:\t %d\n",
  516. test_bit(STATUS_MODE_PENDING, &priv->status));
  517. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  518. }
  519. static ssize_t iwl_dbgfs_interrupt_read(struct file *file,
  520. char __user *user_buf,
  521. size_t count, loff_t *ppos) {
  522. struct iwl_priv *priv = file->private_data;
  523. int pos = 0;
  524. int cnt = 0;
  525. char *buf;
  526. int bufsz = 24 * 64; /* 24 items * 64 char per item */
  527. ssize_t ret;
  528. buf = kzalloc(bufsz, GFP_KERNEL);
  529. if (!buf) {
  530. IWL_ERR(priv, "Can not allocate Buffer\n");
  531. return -ENOMEM;
  532. }
  533. pos += scnprintf(buf + pos, bufsz - pos,
  534. "Interrupt Statistics Report:\n");
  535. pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n",
  536. priv->isr_stats.hw);
  537. pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n",
  538. priv->isr_stats.sw);
  539. if (priv->isr_stats.sw > 0) {
  540. pos += scnprintf(buf + pos, bufsz - pos,
  541. "\tLast Restarting Code: 0x%X\n",
  542. priv->isr_stats.sw_err);
  543. }
  544. #ifdef CONFIG_IWLWIFI_DEBUG
  545. pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n",
  546. priv->isr_stats.sch);
  547. pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n",
  548. priv->isr_stats.alive);
  549. #endif
  550. pos += scnprintf(buf + pos, bufsz - pos,
  551. "HW RF KILL switch toggled:\t %u\n",
  552. priv->isr_stats.rfkill);
  553. pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n",
  554. priv->isr_stats.ctkill);
  555. pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n",
  556. priv->isr_stats.wakeup);
  557. pos += scnprintf(buf + pos, bufsz - pos,
  558. "Rx command responses:\t\t %u\n",
  559. priv->isr_stats.rx);
  560. for (cnt = 0; cnt < REPLY_MAX; cnt++) {
  561. if (priv->isr_stats.rx_handlers[cnt] > 0)
  562. pos += scnprintf(buf + pos, bufsz - pos,
  563. "\tRx handler[%36s]:\t\t %u\n",
  564. get_cmd_string(cnt),
  565. priv->isr_stats.rx_handlers[cnt]);
  566. }
  567. pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n",
  568. priv->isr_stats.tx);
  569. pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n",
  570. priv->isr_stats.unhandled);
  571. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  572. kfree(buf);
  573. return ret;
  574. }
  575. static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
  576. const char __user *user_buf,
  577. size_t count, loff_t *ppos)
  578. {
  579. struct iwl_priv *priv = file->private_data;
  580. char buf[8];
  581. int buf_size;
  582. u32 reset_flag;
  583. memset(buf, 0, sizeof(buf));
  584. buf_size = min(count, sizeof(buf) - 1);
  585. if (copy_from_user(buf, user_buf, buf_size))
  586. return -EFAULT;
  587. if (sscanf(buf, "%x", &reset_flag) != 1)
  588. return -EFAULT;
  589. if (reset_flag == 0)
  590. iwl_clear_isr_stats(priv);
  591. return count;
  592. }
  593. static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
  594. size_t count, loff_t *ppos)
  595. {
  596. struct iwl_priv *priv = file->private_data;
  597. int pos = 0, i;
  598. char buf[256];
  599. const size_t bufsz = sizeof(buf);
  600. ssize_t ret;
  601. for (i = 0; i < AC_NUM; i++) {
  602. pos += scnprintf(buf + pos, bufsz - pos,
  603. "\tcw_min\tcw_max\taifsn\ttxop\n");
  604. pos += scnprintf(buf + pos, bufsz - pos,
  605. "AC[%d]\t%u\t%u\t%u\t%u\n", i,
  606. priv->qos_data.def_qos_parm.ac[i].cw_min,
  607. priv->qos_data.def_qos_parm.ac[i].cw_max,
  608. priv->qos_data.def_qos_parm.ac[i].aifsn,
  609. priv->qos_data.def_qos_parm.ac[i].edca_txop);
  610. }
  611. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  612. return ret;
  613. }
  614. static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf,
  615. size_t count, loff_t *ppos)
  616. {
  617. struct iwl_priv *priv = file->private_data;
  618. int pos = 0;
  619. char buf[256];
  620. const size_t bufsz = sizeof(buf);
  621. ssize_t ret;
  622. pos += scnprintf(buf + pos, bufsz - pos,
  623. "allow blinking: %s\n",
  624. (priv->allow_blinking) ? "True" : "False");
  625. if (priv->allow_blinking) {
  626. pos += scnprintf(buf + pos, bufsz - pos,
  627. "Led blinking rate: %u\n",
  628. priv->last_blink_rate);
  629. pos += scnprintf(buf + pos, bufsz - pos,
  630. "Last blink time: %lu\n",
  631. priv->last_blink_time);
  632. }
  633. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  634. return ret;
  635. }
  636. static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
  637. char __user *user_buf,
  638. size_t count, loff_t *ppos)
  639. {
  640. struct iwl_priv *priv = file->private_data;
  641. struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
  642. struct iwl_tt_restriction *restriction;
  643. char buf[100];
  644. int pos = 0;
  645. const size_t bufsz = sizeof(buf);
  646. ssize_t ret;
  647. pos += scnprintf(buf + pos, bufsz - pos,
  648. "Thermal Throttling Mode: %s\n",
  649. tt->advanced_tt ? "Advance" : "Legacy");
  650. pos += scnprintf(buf + pos, bufsz - pos,
  651. "Thermal Throttling State: %d\n",
  652. tt->state);
  653. if (tt->advanced_tt) {
  654. restriction = tt->restriction + tt->state;
  655. pos += scnprintf(buf + pos, bufsz - pos,
  656. "Tx mode: %d\n",
  657. restriction->tx_stream);
  658. pos += scnprintf(buf + pos, bufsz - pos,
  659. "Rx mode: %d\n",
  660. restriction->rx_stream);
  661. pos += scnprintf(buf + pos, bufsz - pos,
  662. "HT mode: %d\n",
  663. restriction->is_ht);
  664. }
  665. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  666. return ret;
  667. }
  668. static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
  669. const char __user *user_buf,
  670. size_t count, loff_t *ppos)
  671. {
  672. struct iwl_priv *priv = file->private_data;
  673. char buf[8];
  674. int buf_size;
  675. int ht40;
  676. memset(buf, 0, sizeof(buf));
  677. buf_size = min(count, sizeof(buf) - 1);
  678. if (copy_from_user(buf, user_buf, buf_size))
  679. return -EFAULT;
  680. if (sscanf(buf, "%d", &ht40) != 1)
  681. return -EFAULT;
  682. if (!iwl_is_associated(priv))
  683. priv->disable_ht40 = ht40 ? true : false;
  684. else {
  685. IWL_ERR(priv, "Sta associated with AP - "
  686. "Change to 40MHz channel support is not allowed\n");
  687. return -EINVAL;
  688. }
  689. return count;
  690. }
  691. static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
  692. char __user *user_buf,
  693. size_t count, loff_t *ppos)
  694. {
  695. struct iwl_priv *priv = file->private_data;
  696. char buf[100];
  697. int pos = 0;
  698. const size_t bufsz = sizeof(buf);
  699. ssize_t ret;
  700. pos += scnprintf(buf + pos, bufsz - pos,
  701. "11n 40MHz Mode: %s\n",
  702. priv->disable_ht40 ? "Disabled" : "Enabled");
  703. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  704. return ret;
  705. }
  706. static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
  707. const char __user *user_buf,
  708. size_t count, loff_t *ppos)
  709. {
  710. struct iwl_priv *priv = file->private_data;
  711. char buf[8];
  712. int buf_size;
  713. int value;
  714. memset(buf, 0, sizeof(buf));
  715. buf_size = min(count, sizeof(buf) - 1);
  716. if (copy_from_user(buf, user_buf, buf_size))
  717. return -EFAULT;
  718. if (sscanf(buf, "%d", &value) != 1)
  719. return -EINVAL;
  720. /*
  721. * Our users expect 0 to be "CAM", but 0 isn't actually
  722. * valid here. However, let's not confuse them and present
  723. * IWL_POWER_INDEX_1 as "1", not "0".
  724. */
  725. if (value == 0)
  726. return -EINVAL;
  727. else if (value > 0)
  728. value -= 1;
  729. if (value != -1 && (value < 0 || value >= IWL_POWER_NUM))
  730. return -EINVAL;
  731. if (!iwl_is_ready_rf(priv))
  732. return -EAGAIN;
  733. priv->power_data.debug_sleep_level_override = value;
  734. iwl_power_update_mode(priv, true);
  735. return count;
  736. }
  737. static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
  738. char __user *user_buf,
  739. size_t count, loff_t *ppos)
  740. {
  741. struct iwl_priv *priv = file->private_data;
  742. char buf[10];
  743. int pos, value;
  744. const size_t bufsz = sizeof(buf);
  745. /* see the write function */
  746. value = priv->power_data.debug_sleep_level_override;
  747. if (value >= 0)
  748. value += 1;
  749. pos = scnprintf(buf, bufsz, "%d\n", value);
  750. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  751. }
  752. static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
  753. char __user *user_buf,
  754. size_t count, loff_t *ppos)
  755. {
  756. struct iwl_priv *priv = file->private_data;
  757. char buf[200];
  758. int pos = 0, i;
  759. const size_t bufsz = sizeof(buf);
  760. struct iwl_powertable_cmd *cmd = &priv->power_data.sleep_cmd;
  761. pos += scnprintf(buf + pos, bufsz - pos,
  762. "flags: %#.2x\n", le16_to_cpu(cmd->flags));
  763. pos += scnprintf(buf + pos, bufsz - pos,
  764. "RX/TX timeout: %d/%d usec\n",
  765. le32_to_cpu(cmd->rx_data_timeout),
  766. le32_to_cpu(cmd->tx_data_timeout));
  767. for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
  768. pos += scnprintf(buf + pos, bufsz - pos,
  769. "sleep_interval[%d]: %d\n", i,
  770. le32_to_cpu(cmd->sleep_interval[i]));
  771. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  772. }
  773. DEBUGFS_READ_WRITE_FILE_OPS(sram);
  774. DEBUGFS_READ_WRITE_FILE_OPS(log_event);
  775. DEBUGFS_READ_FILE_OPS(nvm);
  776. DEBUGFS_READ_FILE_OPS(stations);
  777. DEBUGFS_READ_FILE_OPS(channels);
  778. DEBUGFS_READ_FILE_OPS(status);
  779. DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
  780. DEBUGFS_READ_FILE_OPS(qos);
  781. DEBUGFS_READ_FILE_OPS(led);
  782. DEBUGFS_READ_FILE_OPS(thermal_throttling);
  783. DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
  784. DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
  785. DEBUGFS_READ_FILE_OPS(current_sleep_command);
  786. static ssize_t iwl_dbgfs_traffic_log_read(struct file *file,
  787. char __user *user_buf,
  788. size_t count, loff_t *ppos)
  789. {
  790. struct iwl_priv *priv = file->private_data;
  791. int pos = 0, ofs = 0;
  792. int cnt = 0, entry;
  793. struct iwl_tx_queue *txq;
  794. struct iwl_queue *q;
  795. struct iwl_rx_queue *rxq = &priv->rxq;
  796. char *buf;
  797. int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) +
  798. (priv->cfg->num_of_queues * 32 * 8) + 400;
  799. const u8 *ptr;
  800. ssize_t ret;
  801. if (!priv->txq) {
  802. IWL_ERR(priv, "txq not ready\n");
  803. return -EAGAIN;
  804. }
  805. buf = kzalloc(bufsz, GFP_KERNEL);
  806. if (!buf) {
  807. IWL_ERR(priv, "Can not allocate buffer\n");
  808. return -ENOMEM;
  809. }
  810. pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n");
  811. for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
  812. txq = &priv->txq[cnt];
  813. q = &txq->q;
  814. pos += scnprintf(buf + pos, bufsz - pos,
  815. "q[%d]: read_ptr: %u, write_ptr: %u\n",
  816. cnt, q->read_ptr, q->write_ptr);
  817. }
  818. if (priv->tx_traffic && (iwl_debug_level & IWL_DL_TX)) {
  819. ptr = priv->tx_traffic;
  820. pos += scnprintf(buf + pos, bufsz - pos,
  821. "Tx Traffic idx: %u\n", priv->tx_traffic_idx);
  822. for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) {
  823. for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16;
  824. entry++, ofs += 16) {
  825. pos += scnprintf(buf + pos, bufsz - pos,
  826. "0x%.4x ", ofs);
  827. hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
  828. buf + pos, bufsz - pos, 0);
  829. pos += strlen(buf + pos);
  830. if (bufsz - pos > 0)
  831. buf[pos++] = '\n';
  832. }
  833. }
  834. }
  835. pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n");
  836. pos += scnprintf(buf + pos, bufsz - pos,
  837. "read: %u, write: %u\n",
  838. rxq->read, rxq->write);
  839. if (priv->rx_traffic && (iwl_debug_level & IWL_DL_RX)) {
  840. ptr = priv->rx_traffic;
  841. pos += scnprintf(buf + pos, bufsz - pos,
  842. "Rx Traffic idx: %u\n", priv->rx_traffic_idx);
  843. for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) {
  844. for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16;
  845. entry++, ofs += 16) {
  846. pos += scnprintf(buf + pos, bufsz - pos,
  847. "0x%.4x ", ofs);
  848. hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
  849. buf + pos, bufsz - pos, 0);
  850. pos += strlen(buf + pos);
  851. if (bufsz - pos > 0)
  852. buf[pos++] = '\n';
  853. }
  854. }
  855. }
  856. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  857. kfree(buf);
  858. return ret;
  859. }
  860. static ssize_t iwl_dbgfs_traffic_log_write(struct file *file,
  861. const char __user *user_buf,
  862. size_t count, loff_t *ppos)
  863. {
  864. struct iwl_priv *priv = file->private_data;
  865. char buf[8];
  866. int buf_size;
  867. int traffic_log;
  868. memset(buf, 0, sizeof(buf));
  869. buf_size = min(count, sizeof(buf) - 1);
  870. if (copy_from_user(buf, user_buf, buf_size))
  871. return -EFAULT;
  872. if (sscanf(buf, "%d", &traffic_log) != 1)
  873. return -EFAULT;
  874. if (traffic_log == 0)
  875. iwl_reset_traffic_log(priv);
  876. return count;
  877. }
  878. static ssize_t iwl_dbgfs_tx_queue_read(struct file *file,
  879. char __user *user_buf,
  880. size_t count, loff_t *ppos) {
  881. struct iwl_priv *priv = file->private_data;
  882. struct iwl_tx_queue *txq;
  883. struct iwl_queue *q;
  884. char *buf;
  885. int pos = 0;
  886. int cnt;
  887. int ret;
  888. const size_t bufsz = sizeof(char) * 64 * priv->cfg->num_of_queues;
  889. if (!priv->txq) {
  890. IWL_ERR(priv, "txq not ready\n");
  891. return -EAGAIN;
  892. }
  893. buf = kzalloc(bufsz, GFP_KERNEL);
  894. if (!buf)
  895. return -ENOMEM;
  896. for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
  897. txq = &priv->txq[cnt];
  898. q = &txq->q;
  899. pos += scnprintf(buf + pos, bufsz - pos,
  900. "hwq %.2d: read=%u write=%u stop=%d"
  901. " swq_id=%#.2x (ac %d/hwq %d)\n",
  902. cnt, q->read_ptr, q->write_ptr,
  903. !!test_bit(cnt, priv->queue_stopped),
  904. txq->swq_id,
  905. txq->swq_id & 0x80 ? txq->swq_id & 3 :
  906. txq->swq_id,
  907. txq->swq_id & 0x80 ? (txq->swq_id >> 2) &
  908. 0x1f : txq->swq_id);
  909. if (cnt >= 4)
  910. continue;
  911. /* for the ACs, display the stop count too */
  912. pos += scnprintf(buf + pos, bufsz - pos,
  913. " stop-count: %d\n",
  914. atomic_read(&priv->queue_stop_count[cnt]));
  915. }
  916. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  917. kfree(buf);
  918. return ret;
  919. }
  920. static ssize_t iwl_dbgfs_rx_queue_read(struct file *file,
  921. char __user *user_buf,
  922. size_t count, loff_t *ppos) {
  923. struct iwl_priv *priv = file->private_data;
  924. struct iwl_rx_queue *rxq = &priv->rxq;
  925. char buf[256];
  926. int pos = 0;
  927. const size_t bufsz = sizeof(buf);
  928. pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n",
  929. rxq->read);
  930. pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n",
  931. rxq->write);
  932. pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n",
  933. rxq->free_count);
  934. pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n",
  935. le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF);
  936. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  937. }
  938. static int iwl_dbgfs_statistics_flag(struct iwl_priv *priv, char *buf,
  939. int bufsz)
  940. {
  941. int p = 0;
  942. p += scnprintf(buf + p, bufsz - p,
  943. "Statistics Flag(0x%X):\n",
  944. le32_to_cpu(priv->statistics.flag));
  945. if (le32_to_cpu(priv->statistics.flag) & UCODE_STATISTICS_CLEAR_MSK)
  946. p += scnprintf(buf + p, bufsz - p,
  947. "\tStatistics have been cleared\n");
  948. p += scnprintf(buf + p, bufsz - p,
  949. "\tOperational Frequency: %s\n",
  950. (le32_to_cpu(priv->statistics.flag) &
  951. UCODE_STATISTICS_FREQUENCY_MSK)
  952. ? "2.4 GHz" : "5.2 GHz");
  953. p += scnprintf(buf + p, bufsz - p,
  954. "\tTGj Narrow Band: %s\n",
  955. (le32_to_cpu(priv->statistics.flag) &
  956. UCODE_STATISTICS_NARROW_BAND_MSK)
  957. ? "enabled" : "disabled");
  958. return p;
  959. }
  960. static const char ucode_stats_header[] =
  961. "%-32s current acumulative delta max\n";
  962. static const char ucode_stats_short_format[] =
  963. " %-30s %10u\n";
  964. static const char ucode_stats_format[] =
  965. " %-30s %10u %10u %10u %10u\n";
  966. static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
  967. char __user *user_buf,
  968. size_t count, loff_t *ppos)
  969. {
  970. struct iwl_priv *priv = file->private_data;
  971. int pos = 0;
  972. char *buf;
  973. int bufsz = sizeof(struct statistics_rx_phy) * 40 +
  974. sizeof(struct statistics_rx_non_phy) * 40 +
  975. sizeof(struct statistics_rx_ht_phy) * 40 + 400;
  976. ssize_t ret;
  977. struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
  978. struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
  979. struct statistics_rx_non_phy *general, *accum_general;
  980. struct statistics_rx_non_phy *delta_general, *max_general;
  981. struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
  982. if (!iwl_is_alive(priv))
  983. return -EAGAIN;
  984. /* make request to uCode to retrieve statistics information */
  985. mutex_lock(&priv->mutex);
  986. ret = iwl_send_statistics_request(priv, CMD_SYNC, false);
  987. mutex_unlock(&priv->mutex);
  988. if (ret) {
  989. IWL_ERR(priv,
  990. "Error sending statistics request: %zd\n", ret);
  991. return -EAGAIN;
  992. }
  993. buf = kzalloc(bufsz, GFP_KERNEL);
  994. if (!buf) {
  995. IWL_ERR(priv, "Can not allocate Buffer\n");
  996. return -ENOMEM;
  997. }
  998. /* the statistic information display here is based on
  999. * the last statistics notification from uCode
  1000. * might not reflect the current uCode activity
  1001. */
  1002. ofdm = &priv->statistics.rx.ofdm;
  1003. cck = &priv->statistics.rx.cck;
  1004. general = &priv->statistics.rx.general;
  1005. ht = &priv->statistics.rx.ofdm_ht;
  1006. accum_ofdm = &priv->accum_statistics.rx.ofdm;
  1007. accum_cck = &priv->accum_statistics.rx.cck;
  1008. accum_general = &priv->accum_statistics.rx.general;
  1009. accum_ht = &priv->accum_statistics.rx.ofdm_ht;
  1010. delta_ofdm = &priv->delta_statistics.rx.ofdm;
  1011. delta_cck = &priv->delta_statistics.rx.cck;
  1012. delta_general = &priv->delta_statistics.rx.general;
  1013. delta_ht = &priv->delta_statistics.rx.ofdm_ht;
  1014. max_ofdm = &priv->max_delta.rx.ofdm;
  1015. max_cck = &priv->max_delta.rx.cck;
  1016. max_general = &priv->max_delta.rx.general;
  1017. max_ht = &priv->max_delta.rx.ofdm_ht;
  1018. pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
  1019. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
  1020. "Statistics_Rx - OFDM:");
  1021. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1022. "ina_cnt:", le32_to_cpu(ofdm->ina_cnt),
  1023. accum_ofdm->ina_cnt,
  1024. delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
  1025. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1026. "fina_cnt:",
  1027. le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
  1028. delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
  1029. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1030. "plcp_err:",
  1031. le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
  1032. delta_ofdm->plcp_err, max_ofdm->plcp_err);
  1033. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1034. "crc32_err:",
  1035. le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
  1036. delta_ofdm->crc32_err, max_ofdm->crc32_err);
  1037. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1038. "overrun_err:",
  1039. le32_to_cpu(ofdm->overrun_err),
  1040. accum_ofdm->overrun_err,
  1041. delta_ofdm->overrun_err, max_ofdm->overrun_err);
  1042. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1043. "early_overrun_err:",
  1044. le32_to_cpu(ofdm->early_overrun_err),
  1045. accum_ofdm->early_overrun_err,
  1046. delta_ofdm->early_overrun_err,
  1047. max_ofdm->early_overrun_err);
  1048. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1049. "crc32_good:",
  1050. le32_to_cpu(ofdm->crc32_good),
  1051. accum_ofdm->crc32_good,
  1052. delta_ofdm->crc32_good, max_ofdm->crc32_good);
  1053. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1054. "false_alarm_cnt:",
  1055. le32_to_cpu(ofdm->false_alarm_cnt),
  1056. accum_ofdm->false_alarm_cnt,
  1057. delta_ofdm->false_alarm_cnt,
  1058. max_ofdm->false_alarm_cnt);
  1059. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1060. "fina_sync_err_cnt:",
  1061. le32_to_cpu(ofdm->fina_sync_err_cnt),
  1062. accum_ofdm->fina_sync_err_cnt,
  1063. delta_ofdm->fina_sync_err_cnt,
  1064. max_ofdm->fina_sync_err_cnt);
  1065. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1066. "sfd_timeout:",
  1067. le32_to_cpu(ofdm->sfd_timeout),
  1068. accum_ofdm->sfd_timeout,
  1069. delta_ofdm->sfd_timeout,
  1070. max_ofdm->sfd_timeout);
  1071. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1072. "fina_timeout:",
  1073. le32_to_cpu(ofdm->fina_timeout),
  1074. accum_ofdm->fina_timeout,
  1075. delta_ofdm->fina_timeout,
  1076. max_ofdm->fina_timeout);
  1077. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1078. "unresponded_rts:",
  1079. le32_to_cpu(ofdm->unresponded_rts),
  1080. accum_ofdm->unresponded_rts,
  1081. delta_ofdm->unresponded_rts,
  1082. max_ofdm->unresponded_rts);
  1083. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1084. "rxe_frame_lmt_ovrun:",
  1085. le32_to_cpu(ofdm->rxe_frame_limit_overrun),
  1086. accum_ofdm->rxe_frame_limit_overrun,
  1087. delta_ofdm->rxe_frame_limit_overrun,
  1088. max_ofdm->rxe_frame_limit_overrun);
  1089. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1090. "sent_ack_cnt:",
  1091. le32_to_cpu(ofdm->sent_ack_cnt),
  1092. accum_ofdm->sent_ack_cnt,
  1093. delta_ofdm->sent_ack_cnt,
  1094. max_ofdm->sent_ack_cnt);
  1095. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1096. "sent_cts_cnt:",
  1097. le32_to_cpu(ofdm->sent_cts_cnt),
  1098. accum_ofdm->sent_cts_cnt,
  1099. delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt);
  1100. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1101. "sent_ba_rsp_cnt:",
  1102. le32_to_cpu(ofdm->sent_ba_rsp_cnt),
  1103. accum_ofdm->sent_ba_rsp_cnt,
  1104. delta_ofdm->sent_ba_rsp_cnt,
  1105. max_ofdm->sent_ba_rsp_cnt);
  1106. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1107. "dsp_self_kill:",
  1108. le32_to_cpu(ofdm->dsp_self_kill),
  1109. accum_ofdm->dsp_self_kill,
  1110. delta_ofdm->dsp_self_kill,
  1111. max_ofdm->dsp_self_kill);
  1112. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1113. "mh_format_err:",
  1114. le32_to_cpu(ofdm->mh_format_err),
  1115. accum_ofdm->mh_format_err,
  1116. delta_ofdm->mh_format_err,
  1117. max_ofdm->mh_format_err);
  1118. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1119. "re_acq_main_rssi_sum:",
  1120. le32_to_cpu(ofdm->re_acq_main_rssi_sum),
  1121. accum_ofdm->re_acq_main_rssi_sum,
  1122. delta_ofdm->re_acq_main_rssi_sum,
  1123. max_ofdm->re_acq_main_rssi_sum);
  1124. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
  1125. "Statistics_Rx - CCK:");
  1126. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1127. "ina_cnt:",
  1128. le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
  1129. delta_cck->ina_cnt, max_cck->ina_cnt);
  1130. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1131. "fina_cnt:",
  1132. le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
  1133. delta_cck->fina_cnt, max_cck->fina_cnt);
  1134. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1135. "plcp_err:",
  1136. le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
  1137. delta_cck->plcp_err, max_cck->plcp_err);
  1138. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1139. "crc32_err:",
  1140. le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
  1141. delta_cck->crc32_err, max_cck->crc32_err);
  1142. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1143. "overrun_err:",
  1144. le32_to_cpu(cck->overrun_err),
  1145. accum_cck->overrun_err,
  1146. delta_cck->overrun_err, max_cck->overrun_err);
  1147. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1148. "early_overrun_err:",
  1149. le32_to_cpu(cck->early_overrun_err),
  1150. accum_cck->early_overrun_err,
  1151. delta_cck->early_overrun_err,
  1152. max_cck->early_overrun_err);
  1153. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1154. "crc32_good:",
  1155. le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
  1156. delta_cck->crc32_good,
  1157. max_cck->crc32_good);
  1158. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1159. "false_alarm_cnt:",
  1160. le32_to_cpu(cck->false_alarm_cnt),
  1161. accum_cck->false_alarm_cnt,
  1162. delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
  1163. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1164. "fina_sync_err_cnt:",
  1165. le32_to_cpu(cck->fina_sync_err_cnt),
  1166. accum_cck->fina_sync_err_cnt,
  1167. delta_cck->fina_sync_err_cnt,
  1168. max_cck->fina_sync_err_cnt);
  1169. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1170. "sfd_timeout:",
  1171. le32_to_cpu(cck->sfd_timeout),
  1172. accum_cck->sfd_timeout,
  1173. delta_cck->sfd_timeout, max_cck->sfd_timeout);
  1174. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1175. "fina_timeout:",
  1176. le32_to_cpu(cck->fina_timeout),
  1177. accum_cck->fina_timeout,
  1178. delta_cck->fina_timeout, max_cck->fina_timeout);
  1179. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1180. "unresponded_rts:",
  1181. le32_to_cpu(cck->unresponded_rts),
  1182. accum_cck->unresponded_rts,
  1183. delta_cck->unresponded_rts,
  1184. max_cck->unresponded_rts);
  1185. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1186. "rxe_frame_lmt_ovrun:",
  1187. le32_to_cpu(cck->rxe_frame_limit_overrun),
  1188. accum_cck->rxe_frame_limit_overrun,
  1189. delta_cck->rxe_frame_limit_overrun,
  1190. max_cck->rxe_frame_limit_overrun);
  1191. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1192. "sent_ack_cnt:",
  1193. le32_to_cpu(cck->sent_ack_cnt),
  1194. accum_cck->sent_ack_cnt,
  1195. delta_cck->sent_ack_cnt,
  1196. max_cck->sent_ack_cnt);
  1197. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1198. "sent_cts_cnt:",
  1199. le32_to_cpu(cck->sent_cts_cnt),
  1200. accum_cck->sent_cts_cnt,
  1201. delta_cck->sent_cts_cnt,
  1202. max_cck->sent_cts_cnt);
  1203. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1204. "sent_ba_rsp_cnt:",
  1205. le32_to_cpu(cck->sent_ba_rsp_cnt),
  1206. accum_cck->sent_ba_rsp_cnt,
  1207. delta_cck->sent_ba_rsp_cnt,
  1208. max_cck->sent_ba_rsp_cnt);
  1209. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1210. "dsp_self_kill:",
  1211. le32_to_cpu(cck->dsp_self_kill),
  1212. accum_cck->dsp_self_kill,
  1213. delta_cck->dsp_self_kill,
  1214. max_cck->dsp_self_kill);
  1215. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1216. "mh_format_err:",
  1217. le32_to_cpu(cck->mh_format_err),
  1218. accum_cck->mh_format_err,
  1219. delta_cck->mh_format_err, max_cck->mh_format_err);
  1220. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1221. "re_acq_main_rssi_sum:",
  1222. le32_to_cpu(cck->re_acq_main_rssi_sum),
  1223. accum_cck->re_acq_main_rssi_sum,
  1224. delta_cck->re_acq_main_rssi_sum,
  1225. max_cck->re_acq_main_rssi_sum);
  1226. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
  1227. "Statistics_Rx - GENERAL:");
  1228. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1229. "bogus_cts:",
  1230. le32_to_cpu(general->bogus_cts),
  1231. accum_general->bogus_cts,
  1232. delta_general->bogus_cts, max_general->bogus_cts);
  1233. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1234. "bogus_ack:",
  1235. le32_to_cpu(general->bogus_ack),
  1236. accum_general->bogus_ack,
  1237. delta_general->bogus_ack, max_general->bogus_ack);
  1238. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1239. "non_bssid_frames:",
  1240. le32_to_cpu(general->non_bssid_frames),
  1241. accum_general->non_bssid_frames,
  1242. delta_general->non_bssid_frames,
  1243. max_general->non_bssid_frames);
  1244. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1245. "filtered_frames:",
  1246. le32_to_cpu(general->filtered_frames),
  1247. accum_general->filtered_frames,
  1248. delta_general->filtered_frames,
  1249. max_general->filtered_frames);
  1250. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1251. "non_channel_beacons:",
  1252. le32_to_cpu(general->non_channel_beacons),
  1253. accum_general->non_channel_beacons,
  1254. delta_general->non_channel_beacons,
  1255. max_general->non_channel_beacons);
  1256. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1257. "channel_beacons:",
  1258. le32_to_cpu(general->channel_beacons),
  1259. accum_general->channel_beacons,
  1260. delta_general->channel_beacons,
  1261. max_general->channel_beacons);
  1262. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1263. "num_missed_bcon:",
  1264. le32_to_cpu(general->num_missed_bcon),
  1265. accum_general->num_missed_bcon,
  1266. delta_general->num_missed_bcon,
  1267. max_general->num_missed_bcon);
  1268. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1269. "adc_rx_saturation_time:",
  1270. le32_to_cpu(general->adc_rx_saturation_time),
  1271. accum_general->adc_rx_saturation_time,
  1272. delta_general->adc_rx_saturation_time,
  1273. max_general->adc_rx_saturation_time);
  1274. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1275. "ina_detect_search_tm:",
  1276. le32_to_cpu(general->ina_detection_search_time),
  1277. accum_general->ina_detection_search_time,
  1278. delta_general->ina_detection_search_time,
  1279. max_general->ina_detection_search_time);
  1280. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1281. "beacon_silence_rssi_a:",
  1282. le32_to_cpu(general->beacon_silence_rssi_a),
  1283. accum_general->beacon_silence_rssi_a,
  1284. delta_general->beacon_silence_rssi_a,
  1285. max_general->beacon_silence_rssi_a);
  1286. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1287. "beacon_silence_rssi_b:",
  1288. le32_to_cpu(general->beacon_silence_rssi_b),
  1289. accum_general->beacon_silence_rssi_b,
  1290. delta_general->beacon_silence_rssi_b,
  1291. max_general->beacon_silence_rssi_b);
  1292. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1293. "beacon_silence_rssi_c:",
  1294. le32_to_cpu(general->beacon_silence_rssi_c),
  1295. accum_general->beacon_silence_rssi_c,
  1296. delta_general->beacon_silence_rssi_c,
  1297. max_general->beacon_silence_rssi_c);
  1298. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1299. "interference_data_flag:",
  1300. le32_to_cpu(general->interference_data_flag),
  1301. accum_general->interference_data_flag,
  1302. delta_general->interference_data_flag,
  1303. max_general->interference_data_flag);
  1304. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1305. "channel_load:",
  1306. le32_to_cpu(general->channel_load),
  1307. accum_general->channel_load,
  1308. delta_general->channel_load,
  1309. max_general->channel_load);
  1310. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1311. "dsp_false_alarms:",
  1312. le32_to_cpu(general->dsp_false_alarms),
  1313. accum_general->dsp_false_alarms,
  1314. delta_general->dsp_false_alarms,
  1315. max_general->dsp_false_alarms);
  1316. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1317. "beacon_rssi_a:",
  1318. le32_to_cpu(general->beacon_rssi_a),
  1319. accum_general->beacon_rssi_a,
  1320. delta_general->beacon_rssi_a,
  1321. max_general->beacon_rssi_a);
  1322. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1323. "beacon_rssi_b:",
  1324. le32_to_cpu(general->beacon_rssi_b),
  1325. accum_general->beacon_rssi_b,
  1326. delta_general->beacon_rssi_b,
  1327. max_general->beacon_rssi_b);
  1328. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1329. "beacon_rssi_c:",
  1330. le32_to_cpu(general->beacon_rssi_c),
  1331. accum_general->beacon_rssi_c,
  1332. delta_general->beacon_rssi_c,
  1333. max_general->beacon_rssi_c);
  1334. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1335. "beacon_energy_a:",
  1336. le32_to_cpu(general->beacon_energy_a),
  1337. accum_general->beacon_energy_a,
  1338. delta_general->beacon_energy_a,
  1339. max_general->beacon_energy_a);
  1340. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1341. "beacon_energy_b:",
  1342. le32_to_cpu(general->beacon_energy_b),
  1343. accum_general->beacon_energy_b,
  1344. delta_general->beacon_energy_b,
  1345. max_general->beacon_energy_b);
  1346. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1347. "beacon_energy_c:",
  1348. le32_to_cpu(general->beacon_energy_c),
  1349. accum_general->beacon_energy_c,
  1350. delta_general->beacon_energy_c,
  1351. max_general->beacon_energy_c);
  1352. pos += scnprintf(buf + pos, bufsz - pos, "Statistics_Rx - OFDM_HT:\n");
  1353. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
  1354. "Statistics_Rx - OFDM_HT:");
  1355. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1356. "plcp_err:",
  1357. le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
  1358. delta_ht->plcp_err, max_ht->plcp_err);
  1359. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1360. "overrun_err:",
  1361. le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
  1362. delta_ht->overrun_err, max_ht->overrun_err);
  1363. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1364. "early_overrun_err:",
  1365. le32_to_cpu(ht->early_overrun_err),
  1366. accum_ht->early_overrun_err,
  1367. delta_ht->early_overrun_err,
  1368. max_ht->early_overrun_err);
  1369. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1370. "crc32_good:",
  1371. le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
  1372. delta_ht->crc32_good, max_ht->crc32_good);
  1373. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1374. "crc32_err:",
  1375. le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
  1376. delta_ht->crc32_err, max_ht->crc32_err);
  1377. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1378. "mh_format_err:",
  1379. le32_to_cpu(ht->mh_format_err),
  1380. accum_ht->mh_format_err,
  1381. delta_ht->mh_format_err, max_ht->mh_format_err);
  1382. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1383. "agg_crc32_good:",
  1384. le32_to_cpu(ht->agg_crc32_good),
  1385. accum_ht->agg_crc32_good,
  1386. delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
  1387. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1388. "agg_mpdu_cnt:",
  1389. le32_to_cpu(ht->agg_mpdu_cnt),
  1390. accum_ht->agg_mpdu_cnt,
  1391. delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
  1392. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1393. "agg_cnt:",
  1394. le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
  1395. delta_ht->agg_cnt, max_ht->agg_cnt);
  1396. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1397. "unsupport_mcs:",
  1398. le32_to_cpu(ht->unsupport_mcs),
  1399. accum_ht->unsupport_mcs,
  1400. delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
  1401. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1402. kfree(buf);
  1403. return ret;
  1404. }
  1405. static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
  1406. char __user *user_buf,
  1407. size_t count, loff_t *ppos)
  1408. {
  1409. struct iwl_priv *priv = file->private_data;
  1410. int pos = 0;
  1411. char *buf;
  1412. int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
  1413. ssize_t ret;
  1414. struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
  1415. if (!iwl_is_alive(priv))
  1416. return -EAGAIN;
  1417. /* make request to uCode to retrieve statistics information */
  1418. mutex_lock(&priv->mutex);
  1419. ret = iwl_send_statistics_request(priv, CMD_SYNC, false);
  1420. mutex_unlock(&priv->mutex);
  1421. if (ret) {
  1422. IWL_ERR(priv,
  1423. "Error sending statistics request: %zd\n", ret);
  1424. return -EAGAIN;
  1425. }
  1426. buf = kzalloc(bufsz, GFP_KERNEL);
  1427. if (!buf) {
  1428. IWL_ERR(priv, "Can not allocate Buffer\n");
  1429. return -ENOMEM;
  1430. }
  1431. /* the statistic information display here is based on
  1432. * the last statistics notification from uCode
  1433. * might not reflect the current uCode activity
  1434. */
  1435. tx = &priv->statistics.tx;
  1436. accum_tx = &priv->accum_statistics.tx;
  1437. delta_tx = &priv->delta_statistics.tx;
  1438. max_tx = &priv->max_delta.tx;
  1439. pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
  1440. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
  1441. "Statistics_Tx:");
  1442. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1443. "preamble:",
  1444. le32_to_cpu(tx->preamble_cnt),
  1445. accum_tx->preamble_cnt,
  1446. delta_tx->preamble_cnt, max_tx->preamble_cnt);
  1447. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1448. "rx_detected_cnt:",
  1449. le32_to_cpu(tx->rx_detected_cnt),
  1450. accum_tx->rx_detected_cnt,
  1451. delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
  1452. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1453. "bt_prio_defer_cnt:",
  1454. le32_to_cpu(tx->bt_prio_defer_cnt),
  1455. accum_tx->bt_prio_defer_cnt,
  1456. delta_tx->bt_prio_defer_cnt,
  1457. max_tx->bt_prio_defer_cnt);
  1458. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1459. "bt_prio_kill_cnt:",
  1460. le32_to_cpu(tx->bt_prio_kill_cnt),
  1461. accum_tx->bt_prio_kill_cnt,
  1462. delta_tx->bt_prio_kill_cnt,
  1463. max_tx->bt_prio_kill_cnt);
  1464. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1465. "few_bytes_cnt:",
  1466. le32_to_cpu(tx->few_bytes_cnt),
  1467. accum_tx->few_bytes_cnt,
  1468. delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
  1469. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1470. "cts_timeout:",
  1471. le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
  1472. delta_tx->cts_timeout, max_tx->cts_timeout);
  1473. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1474. "ack_timeout:",
  1475. le32_to_cpu(tx->ack_timeout),
  1476. accum_tx->ack_timeout,
  1477. delta_tx->ack_timeout, max_tx->ack_timeout);
  1478. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1479. "expected_ack_cnt:",
  1480. le32_to_cpu(tx->expected_ack_cnt),
  1481. accum_tx->expected_ack_cnt,
  1482. delta_tx->expected_ack_cnt,
  1483. max_tx->expected_ack_cnt);
  1484. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1485. "actual_ack_cnt:",
  1486. le32_to_cpu(tx->actual_ack_cnt),
  1487. accum_tx->actual_ack_cnt,
  1488. delta_tx->actual_ack_cnt,
  1489. max_tx->actual_ack_cnt);
  1490. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1491. "dump_msdu_cnt:",
  1492. le32_to_cpu(tx->dump_msdu_cnt),
  1493. accum_tx->dump_msdu_cnt,
  1494. delta_tx->dump_msdu_cnt,
  1495. max_tx->dump_msdu_cnt);
  1496. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1497. "abort_nxt_frame_mismatch:",
  1498. le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
  1499. accum_tx->burst_abort_next_frame_mismatch_cnt,
  1500. delta_tx->burst_abort_next_frame_mismatch_cnt,
  1501. max_tx->burst_abort_next_frame_mismatch_cnt);
  1502. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1503. "abort_missing_nxt_frame:",
  1504. le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
  1505. accum_tx->burst_abort_missing_next_frame_cnt,
  1506. delta_tx->burst_abort_missing_next_frame_cnt,
  1507. max_tx->burst_abort_missing_next_frame_cnt);
  1508. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1509. "cts_timeout_collision:",
  1510. le32_to_cpu(tx->cts_timeout_collision),
  1511. accum_tx->cts_timeout_collision,
  1512. delta_tx->cts_timeout_collision,
  1513. max_tx->cts_timeout_collision);
  1514. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1515. "ack_ba_timeout_collision:",
  1516. le32_to_cpu(tx->ack_or_ba_timeout_collision),
  1517. accum_tx->ack_or_ba_timeout_collision,
  1518. delta_tx->ack_or_ba_timeout_collision,
  1519. max_tx->ack_or_ba_timeout_collision);
  1520. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1521. "agg ba_timeout:",
  1522. le32_to_cpu(tx->agg.ba_timeout),
  1523. accum_tx->agg.ba_timeout,
  1524. delta_tx->agg.ba_timeout,
  1525. max_tx->agg.ba_timeout);
  1526. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1527. "agg ba_resched_frames:",
  1528. le32_to_cpu(tx->agg.ba_reschedule_frames),
  1529. accum_tx->agg.ba_reschedule_frames,
  1530. delta_tx->agg.ba_reschedule_frames,
  1531. max_tx->agg.ba_reschedule_frames);
  1532. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1533. "agg scd_query_agg_frame:",
  1534. le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
  1535. accum_tx->agg.scd_query_agg_frame_cnt,
  1536. delta_tx->agg.scd_query_agg_frame_cnt,
  1537. max_tx->agg.scd_query_agg_frame_cnt);
  1538. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1539. "agg scd_query_no_agg:",
  1540. le32_to_cpu(tx->agg.scd_query_no_agg),
  1541. accum_tx->agg.scd_query_no_agg,
  1542. delta_tx->agg.scd_query_no_agg,
  1543. max_tx->agg.scd_query_no_agg);
  1544. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1545. "agg scd_query_agg:",
  1546. le32_to_cpu(tx->agg.scd_query_agg),
  1547. accum_tx->agg.scd_query_agg,
  1548. delta_tx->agg.scd_query_agg,
  1549. max_tx->agg.scd_query_agg);
  1550. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1551. "agg scd_query_mismatch:",
  1552. le32_to_cpu(tx->agg.scd_query_mismatch),
  1553. accum_tx->agg.scd_query_mismatch,
  1554. delta_tx->agg.scd_query_mismatch,
  1555. max_tx->agg.scd_query_mismatch);
  1556. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1557. "agg frame_not_ready:",
  1558. le32_to_cpu(tx->agg.frame_not_ready),
  1559. accum_tx->agg.frame_not_ready,
  1560. delta_tx->agg.frame_not_ready,
  1561. max_tx->agg.frame_not_ready);
  1562. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1563. "agg underrun:",
  1564. le32_to_cpu(tx->agg.underrun),
  1565. accum_tx->agg.underrun,
  1566. delta_tx->agg.underrun, max_tx->agg.underrun);
  1567. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1568. "agg bt_prio_kill:",
  1569. le32_to_cpu(tx->agg.bt_prio_kill),
  1570. accum_tx->agg.bt_prio_kill,
  1571. delta_tx->agg.bt_prio_kill,
  1572. max_tx->agg.bt_prio_kill);
  1573. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1574. "agg rx_ba_rsp_cnt:",
  1575. le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
  1576. accum_tx->agg.rx_ba_rsp_cnt,
  1577. delta_tx->agg.rx_ba_rsp_cnt,
  1578. max_tx->agg.rx_ba_rsp_cnt);
  1579. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1580. kfree(buf);
  1581. return ret;
  1582. }
  1583. static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
  1584. char __user *user_buf,
  1585. size_t count, loff_t *ppos)
  1586. {
  1587. struct iwl_priv *priv = file->private_data;
  1588. int pos = 0;
  1589. char *buf;
  1590. int bufsz = sizeof(struct statistics_general) * 8 + 250;
  1591. ssize_t ret;
  1592. struct statistics_general *general, *accum_general;
  1593. struct statistics_general *delta_general, *max_general;
  1594. struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
  1595. struct statistics_div *div, *accum_div, *delta_div, *max_div;
  1596. if (!iwl_is_alive(priv))
  1597. return -EAGAIN;
  1598. /* make request to uCode to retrieve statistics information */
  1599. mutex_lock(&priv->mutex);
  1600. ret = iwl_send_statistics_request(priv, CMD_SYNC, false);
  1601. mutex_unlock(&priv->mutex);
  1602. if (ret) {
  1603. IWL_ERR(priv,
  1604. "Error sending statistics request: %zd\n", ret);
  1605. return -EAGAIN;
  1606. }
  1607. buf = kzalloc(bufsz, GFP_KERNEL);
  1608. if (!buf) {
  1609. IWL_ERR(priv, "Can not allocate Buffer\n");
  1610. return -ENOMEM;
  1611. }
  1612. /* the statistic information display here is based on
  1613. * the last statistics notification from uCode
  1614. * might not reflect the current uCode activity
  1615. */
  1616. general = &priv->statistics.general;
  1617. dbg = &priv->statistics.general.dbg;
  1618. div = &priv->statistics.general.div;
  1619. accum_general = &priv->accum_statistics.general;
  1620. delta_general = &priv->delta_statistics.general;
  1621. max_general = &priv->max_delta.general;
  1622. accum_dbg = &priv->accum_statistics.general.dbg;
  1623. delta_dbg = &priv->delta_statistics.general.dbg;
  1624. max_dbg = &priv->max_delta.general.dbg;
  1625. accum_div = &priv->accum_statistics.general.div;
  1626. delta_div = &priv->delta_statistics.general.div;
  1627. max_div = &priv->max_delta.general.div;
  1628. pos += iwl_dbgfs_statistics_flag(priv, buf, bufsz);
  1629. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_header,
  1630. "Statistics_General:");
  1631. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_short_format,
  1632. "temperature:",
  1633. le32_to_cpu(general->temperature));
  1634. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_short_format,
  1635. "temperature_m:",
  1636. le32_to_cpu(general->temperature_m));
  1637. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1638. "burst_check:",
  1639. le32_to_cpu(dbg->burst_check),
  1640. accum_dbg->burst_check,
  1641. delta_dbg->burst_check, max_dbg->burst_check);
  1642. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1643. "burst_count:",
  1644. le32_to_cpu(dbg->burst_count),
  1645. accum_dbg->burst_count,
  1646. delta_dbg->burst_count, max_dbg->burst_count);
  1647. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1648. "sleep_time:",
  1649. le32_to_cpu(general->sleep_time),
  1650. accum_general->sleep_time,
  1651. delta_general->sleep_time, max_general->sleep_time);
  1652. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1653. "slots_out:",
  1654. le32_to_cpu(general->slots_out),
  1655. accum_general->slots_out,
  1656. delta_general->slots_out, max_general->slots_out);
  1657. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1658. "slots_idle:",
  1659. le32_to_cpu(general->slots_idle),
  1660. accum_general->slots_idle,
  1661. delta_general->slots_idle, max_general->slots_idle);
  1662. pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n",
  1663. le32_to_cpu(general->ttl_timestamp));
  1664. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1665. "tx_on_a:",
  1666. le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
  1667. delta_div->tx_on_a, max_div->tx_on_a);
  1668. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1669. "tx_on_b:",
  1670. le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
  1671. delta_div->tx_on_b, max_div->tx_on_b);
  1672. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1673. "exec_time:",
  1674. le32_to_cpu(div->exec_time), accum_div->exec_time,
  1675. delta_div->exec_time, max_div->exec_time);
  1676. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1677. "probe_time:",
  1678. le32_to_cpu(div->probe_time), accum_div->probe_time,
  1679. delta_div->probe_time, max_div->probe_time);
  1680. pos += scnprintf(buf + pos, bufsz - pos, ucode_stats_format,
  1681. "rx_enable_counter:",
  1682. le32_to_cpu(general->rx_enable_counter),
  1683. accum_general->rx_enable_counter,
  1684. delta_general->rx_enable_counter,
  1685. max_general->rx_enable_counter);
  1686. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1687. kfree(buf);
  1688. return ret;
  1689. }
  1690. static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
  1691. char __user *user_buf,
  1692. size_t count, loff_t *ppos) {
  1693. struct iwl_priv *priv = file->private_data;
  1694. int pos = 0;
  1695. int cnt = 0;
  1696. char *buf;
  1697. int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100;
  1698. ssize_t ret;
  1699. struct iwl_sensitivity_data *data;
  1700. data = &priv->sensitivity_data;
  1701. buf = kzalloc(bufsz, GFP_KERNEL);
  1702. if (!buf) {
  1703. IWL_ERR(priv, "Can not allocate Buffer\n");
  1704. return -ENOMEM;
  1705. }
  1706. pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
  1707. data->auto_corr_ofdm);
  1708. pos += scnprintf(buf + pos, bufsz - pos,
  1709. "auto_corr_ofdm_mrc:\t\t %u\n",
  1710. data->auto_corr_ofdm_mrc);
  1711. pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n",
  1712. data->auto_corr_ofdm_x1);
  1713. pos += scnprintf(buf + pos, bufsz - pos,
  1714. "auto_corr_ofdm_mrc_x1:\t\t %u\n",
  1715. data->auto_corr_ofdm_mrc_x1);
  1716. pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n",
  1717. data->auto_corr_cck);
  1718. pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n",
  1719. data->auto_corr_cck_mrc);
  1720. pos += scnprintf(buf + pos, bufsz - pos,
  1721. "last_bad_plcp_cnt_ofdm:\t\t %u\n",
  1722. data->last_bad_plcp_cnt_ofdm);
  1723. pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n",
  1724. data->last_fa_cnt_ofdm);
  1725. pos += scnprintf(buf + pos, bufsz - pos,
  1726. "last_bad_plcp_cnt_cck:\t\t %u\n",
  1727. data->last_bad_plcp_cnt_cck);
  1728. pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n",
  1729. data->last_fa_cnt_cck);
  1730. pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n",
  1731. data->nrg_curr_state);
  1732. pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n",
  1733. data->nrg_prev_state);
  1734. pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t");
  1735. for (cnt = 0; cnt < 10; cnt++) {
  1736. pos += scnprintf(buf + pos, bufsz - pos, " %u",
  1737. data->nrg_value[cnt]);
  1738. }
  1739. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  1740. pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t");
  1741. for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) {
  1742. pos += scnprintf(buf + pos, bufsz - pos, " %u",
  1743. data->nrg_silence_rssi[cnt]);
  1744. }
  1745. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  1746. pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n",
  1747. data->nrg_silence_ref);
  1748. pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n",
  1749. data->nrg_energy_idx);
  1750. pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n",
  1751. data->nrg_silence_idx);
  1752. pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n",
  1753. data->nrg_th_cck);
  1754. pos += scnprintf(buf + pos, bufsz - pos,
  1755. "nrg_auto_corr_silence_diff:\t %u\n",
  1756. data->nrg_auto_corr_silence_diff);
  1757. pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n",
  1758. data->num_in_cck_no_fa);
  1759. pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
  1760. data->nrg_th_ofdm);
  1761. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1762. kfree(buf);
  1763. return ret;
  1764. }
  1765. static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
  1766. char __user *user_buf,
  1767. size_t count, loff_t *ppos) {
  1768. struct iwl_priv *priv = file->private_data;
  1769. int pos = 0;
  1770. int cnt = 0;
  1771. char *buf;
  1772. int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100;
  1773. ssize_t ret;
  1774. struct iwl_chain_noise_data *data;
  1775. data = &priv->chain_noise_data;
  1776. buf = kzalloc(bufsz, GFP_KERNEL);
  1777. if (!buf) {
  1778. IWL_ERR(priv, "Can not allocate Buffer\n");
  1779. return -ENOMEM;
  1780. }
  1781. pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
  1782. data->active_chains);
  1783. pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n",
  1784. data->chain_noise_a);
  1785. pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n",
  1786. data->chain_noise_b);
  1787. pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n",
  1788. data->chain_noise_c);
  1789. pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n",
  1790. data->chain_signal_a);
  1791. pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n",
  1792. data->chain_signal_b);
  1793. pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n",
  1794. data->chain_signal_c);
  1795. pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n",
  1796. data->beacon_count);
  1797. pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t");
  1798. for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
  1799. pos += scnprintf(buf + pos, bufsz - pos, " %u",
  1800. data->disconn_array[cnt]);
  1801. }
  1802. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  1803. pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t");
  1804. for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
  1805. pos += scnprintf(buf + pos, bufsz - pos, " %u",
  1806. data->delta_gain_code[cnt]);
  1807. }
  1808. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  1809. pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n",
  1810. data->radio_write);
  1811. pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
  1812. data->state);
  1813. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1814. kfree(buf);
  1815. return ret;
  1816. }
  1817. static ssize_t iwl_dbgfs_tx_power_read(struct file *file,
  1818. char __user *user_buf,
  1819. size_t count, loff_t *ppos) {
  1820. struct iwl_priv *priv = file->private_data;
  1821. char buf[128];
  1822. int pos = 0;
  1823. ssize_t ret;
  1824. const size_t bufsz = sizeof(buf);
  1825. struct statistics_tx *tx;
  1826. if (!iwl_is_alive(priv))
  1827. pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
  1828. else {
  1829. /* make request to uCode to retrieve statistics information */
  1830. mutex_lock(&priv->mutex);
  1831. ret = iwl_send_statistics_request(priv, CMD_SYNC, false);
  1832. mutex_unlock(&priv->mutex);
  1833. if (ret) {
  1834. IWL_ERR(priv, "Error sending statistics request: %zd\n",
  1835. ret);
  1836. return -EAGAIN;
  1837. }
  1838. tx = &priv->statistics.tx;
  1839. if (tx->tx_power.ant_a ||
  1840. tx->tx_power.ant_b ||
  1841. tx->tx_power.ant_c) {
  1842. pos += scnprintf(buf + pos, bufsz - pos,
  1843. "tx power: (1/2 dB step)\n");
  1844. if ((priv->cfg->valid_tx_ant & ANT_A) &&
  1845. tx->tx_power.ant_a)
  1846. pos += scnprintf(buf + pos, bufsz - pos,
  1847. "\tantenna A: 0x%X\n",
  1848. tx->tx_power.ant_a);
  1849. if ((priv->cfg->valid_tx_ant & ANT_B) &&
  1850. tx->tx_power.ant_b)
  1851. pos += scnprintf(buf + pos, bufsz - pos,
  1852. "\tantenna B: 0x%X\n",
  1853. tx->tx_power.ant_b);
  1854. if ((priv->cfg->valid_tx_ant & ANT_C) &&
  1855. tx->tx_power.ant_c)
  1856. pos += scnprintf(buf + pos, bufsz - pos,
  1857. "\tantenna C: 0x%X\n",
  1858. tx->tx_power.ant_c);
  1859. } else
  1860. pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
  1861. }
  1862. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1863. }
  1864. static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
  1865. char __user *user_buf,
  1866. size_t count, loff_t *ppos)
  1867. {
  1868. struct iwl_priv *priv = file->private_data;
  1869. char buf[60];
  1870. int pos = 0;
  1871. const size_t bufsz = sizeof(buf);
  1872. u32 pwrsave_status;
  1873. pwrsave_status = iwl_read32(priv, CSR_GP_CNTRL) &
  1874. CSR_GP_REG_POWER_SAVE_STATUS_MSK;
  1875. pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
  1876. pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
  1877. (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
  1878. (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
  1879. (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
  1880. "error");
  1881. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1882. }
  1883. static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
  1884. const char __user *user_buf,
  1885. size_t count, loff_t *ppos)
  1886. {
  1887. struct iwl_priv *priv = file->private_data;
  1888. char buf[8];
  1889. int buf_size;
  1890. int clear;
  1891. memset(buf, 0, sizeof(buf));
  1892. buf_size = min(count, sizeof(buf) - 1);
  1893. if (copy_from_user(buf, user_buf, buf_size))
  1894. return -EFAULT;
  1895. if (sscanf(buf, "%d", &clear) != 1)
  1896. return -EFAULT;
  1897. /* make request to uCode to retrieve statistics information */
  1898. mutex_lock(&priv->mutex);
  1899. iwl_send_statistics_request(priv, CMD_SYNC, true);
  1900. mutex_unlock(&priv->mutex);
  1901. return count;
  1902. }
  1903. static ssize_t iwl_dbgfs_csr_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 csr;
  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", &csr) != 1)
  1916. return -EFAULT;
  1917. if (priv->cfg->ops->lib->dump_csr)
  1918. priv->cfg->ops->lib->dump_csr(priv);
  1919. return count;
  1920. }
  1921. static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
  1922. char __user *user_buf,
  1923. size_t count, loff_t *ppos) {
  1924. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  1925. int pos = 0;
  1926. char buf[128];
  1927. const size_t bufsz = sizeof(buf);
  1928. ssize_t ret;
  1929. pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
  1930. priv->event_log.ucode_trace ? "On" : "Off");
  1931. pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
  1932. priv->event_log.non_wraps_count);
  1933. pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
  1934. priv->event_log.wraps_once_count);
  1935. pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
  1936. priv->event_log.wraps_more_count);
  1937. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1938. return ret;
  1939. }
  1940. static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
  1941. const char __user *user_buf,
  1942. size_t count, loff_t *ppos)
  1943. {
  1944. struct iwl_priv *priv = file->private_data;
  1945. char buf[8];
  1946. int buf_size;
  1947. int trace;
  1948. memset(buf, 0, sizeof(buf));
  1949. buf_size = min(count, sizeof(buf) - 1);
  1950. if (copy_from_user(buf, user_buf, buf_size))
  1951. return -EFAULT;
  1952. if (sscanf(buf, "%d", &trace) != 1)
  1953. return -EFAULT;
  1954. if (trace) {
  1955. priv->event_log.ucode_trace = true;
  1956. /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */
  1957. mod_timer(&priv->ucode_trace,
  1958. jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD));
  1959. } else {
  1960. priv->event_log.ucode_trace = false;
  1961. del_timer_sync(&priv->ucode_trace);
  1962. }
  1963. return count;
  1964. }
  1965. DEBUGFS_READ_FILE_OPS(rx_statistics);
  1966. DEBUGFS_READ_FILE_OPS(tx_statistics);
  1967. DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
  1968. DEBUGFS_READ_FILE_OPS(rx_queue);
  1969. DEBUGFS_READ_FILE_OPS(tx_queue);
  1970. DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
  1971. DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
  1972. DEBUGFS_READ_FILE_OPS(ucode_general_stats);
  1973. DEBUGFS_READ_FILE_OPS(sensitivity);
  1974. DEBUGFS_READ_FILE_OPS(chain_noise);
  1975. DEBUGFS_READ_FILE_OPS(tx_power);
  1976. DEBUGFS_READ_FILE_OPS(power_save_status);
  1977. DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
  1978. DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics);
  1979. DEBUGFS_WRITE_FILE_OPS(csr);
  1980. DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
  1981. /*
  1982. * Create the debugfs files and directories
  1983. *
  1984. */
  1985. int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
  1986. {
  1987. struct iwl_debugfs *dbgfs;
  1988. struct dentry *phyd = priv->hw->wiphy->debugfsdir;
  1989. int ret = 0;
  1990. dbgfs = kzalloc(sizeof(struct iwl_debugfs), GFP_KERNEL);
  1991. if (!dbgfs) {
  1992. ret = -ENOMEM;
  1993. goto err;
  1994. }
  1995. priv->dbgfs = dbgfs;
  1996. dbgfs->name = name;
  1997. dbgfs->dir_drv = debugfs_create_dir(name, phyd);
  1998. if (!dbgfs->dir_drv || IS_ERR(dbgfs->dir_drv)) {
  1999. ret = -ENOENT;
  2000. goto err;
  2001. }
  2002. DEBUGFS_ADD_DIR(data, dbgfs->dir_drv);
  2003. DEBUGFS_ADD_DIR(rf, dbgfs->dir_drv);
  2004. DEBUGFS_ADD_DIR(debug, dbgfs->dir_drv);
  2005. DEBUGFS_ADD_FILE(nvm, data, S_IRUSR);
  2006. DEBUGFS_ADD_FILE(sram, data, S_IWUSR | S_IRUSR);
  2007. DEBUGFS_ADD_FILE(log_event, data, S_IWUSR | S_IRUSR);
  2008. DEBUGFS_ADD_FILE(stations, data, S_IRUSR);
  2009. DEBUGFS_ADD_FILE(channels, data, S_IRUSR);
  2010. DEBUGFS_ADD_FILE(status, data, S_IRUSR);
  2011. DEBUGFS_ADD_FILE(interrupt, data, S_IWUSR | S_IRUSR);
  2012. DEBUGFS_ADD_FILE(qos, data, S_IRUSR);
  2013. DEBUGFS_ADD_FILE(led, data, S_IRUSR);
  2014. DEBUGFS_ADD_FILE(sleep_level_override, data, S_IWUSR | S_IRUSR);
  2015. DEBUGFS_ADD_FILE(current_sleep_command, data, S_IRUSR);
  2016. DEBUGFS_ADD_FILE(thermal_throttling, data, S_IRUSR);
  2017. DEBUGFS_ADD_FILE(disable_ht40, data, S_IWUSR | S_IRUSR);
  2018. DEBUGFS_ADD_FILE(rx_statistics, debug, S_IRUSR);
  2019. DEBUGFS_ADD_FILE(tx_statistics, debug, S_IRUSR);
  2020. DEBUGFS_ADD_FILE(traffic_log, debug, S_IWUSR | S_IRUSR);
  2021. DEBUGFS_ADD_FILE(rx_queue, debug, S_IRUSR);
  2022. DEBUGFS_ADD_FILE(tx_queue, debug, S_IRUSR);
  2023. DEBUGFS_ADD_FILE(tx_power, debug, S_IRUSR);
  2024. DEBUGFS_ADD_FILE(power_save_status, debug, S_IRUSR);
  2025. DEBUGFS_ADD_FILE(clear_ucode_statistics, debug, S_IWUSR);
  2026. DEBUGFS_ADD_FILE(clear_traffic_statistics, debug, S_IWUSR);
  2027. DEBUGFS_ADD_FILE(csr, debug, S_IWUSR);
  2028. if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) {
  2029. DEBUGFS_ADD_FILE(ucode_rx_stats, debug, S_IRUSR);
  2030. DEBUGFS_ADD_FILE(ucode_tx_stats, debug, S_IRUSR);
  2031. DEBUGFS_ADD_FILE(ucode_general_stats, debug, S_IRUSR);
  2032. DEBUGFS_ADD_FILE(sensitivity, debug, S_IRUSR);
  2033. DEBUGFS_ADD_FILE(chain_noise, debug, S_IRUSR);
  2034. DEBUGFS_ADD_FILE(ucode_tracing, debug, S_IWUSR | S_IRUSR);
  2035. }
  2036. DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal);
  2037. DEBUGFS_ADD_BOOL(disable_chain_noise, rf,
  2038. &priv->disable_chain_noise_cal);
  2039. if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) ||
  2040. ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945))
  2041. DEBUGFS_ADD_BOOL(disable_tx_power, rf,
  2042. &priv->disable_tx_power_cal);
  2043. return 0;
  2044. err:
  2045. IWL_ERR(priv, "Can't open the debugfs directory\n");
  2046. iwl_dbgfs_unregister(priv);
  2047. return ret;
  2048. }
  2049. EXPORT_SYMBOL(iwl_dbgfs_register);
  2050. /**
  2051. * Remove the debugfs files and directories
  2052. *
  2053. */
  2054. void iwl_dbgfs_unregister(struct iwl_priv *priv)
  2055. {
  2056. if (!priv->dbgfs)
  2057. return;
  2058. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sleep_level_override);
  2059. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_current_sleep_command);
  2060. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_nvm);
  2061. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram);
  2062. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event);
  2063. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations);
  2064. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_channels);
  2065. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_status);
  2066. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_interrupt);
  2067. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_qos);
  2068. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_led);
  2069. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_thermal_throttling);
  2070. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_disable_ht40);
  2071. DEBUGFS_REMOVE(priv->dbgfs->dir_data);
  2072. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_rx_statistics);
  2073. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_statistics);
  2074. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_traffic_log);
  2075. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_rx_queue);
  2076. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_queue);
  2077. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_tx_power);
  2078. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_power_save_status);
  2079. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
  2080. file_clear_ucode_statistics);
  2081. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
  2082. file_clear_traffic_statistics);
  2083. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.file_csr);
  2084. if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) {
  2085. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
  2086. file_ucode_rx_stats);
  2087. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
  2088. file_ucode_tx_stats);
  2089. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
  2090. file_ucode_general_stats);
  2091. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
  2092. file_sensitivity);
  2093. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
  2094. file_chain_noise);
  2095. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_debug_files.
  2096. file_ucode_tracing);
  2097. }
  2098. DEBUGFS_REMOVE(priv->dbgfs->dir_debug);
  2099. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity);
  2100. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise);
  2101. if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) ||
  2102. ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945))
  2103. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_tx_power);
  2104. DEBUGFS_REMOVE(priv->dbgfs->dir_rf);
  2105. DEBUGFS_REMOVE(priv->dbgfs->dir_drv);
  2106. kfree(priv->dbgfs);
  2107. priv->dbgfs = NULL;
  2108. }
  2109. EXPORT_SYMBOL(iwl_dbgfs_unregister);