iwl-debugfs.c 76 KB

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