iwl-debugfs.c 76 KB

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