debugfs.c 78 KB

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