debugfs.c 79 KB

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