debugfs.c 78 KB

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