debugfs.c 78 KB

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