iwl-debugfs.c 77 KB

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