iwl-debugfs.c 76 KB

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