debugfs.c 79 KB

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