iwl-debugfs.c 76 KB

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