iwl-debugfs.c 75 KB

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