debugfs.c 78 KB

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