debugfs.c 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440
  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, NL80211_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, NL80211_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. #define fmt_value " %-30s %10u\n"
  593. #define fmt_hex " %-30s 0x%02X\n"
  594. #define fmt_table " %-30s %10u %10u %10u %10u\n"
  595. #define fmt_header "%-32s current cumulative delta max\n"
  596. static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
  597. {
  598. int p = 0;
  599. u32 flag;
  600. lockdep_assert_held(&priv->statistics.lock);
  601. flag = le32_to_cpu(priv->statistics.flag);
  602. p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag);
  603. if (flag & UCODE_STATISTICS_CLEAR_MSK)
  604. p += scnprintf(buf + p, bufsz - p,
  605. "\tStatistics have been cleared\n");
  606. p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
  607. (flag & UCODE_STATISTICS_FREQUENCY_MSK)
  608. ? "2.4 GHz" : "5.2 GHz");
  609. p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
  610. (flag & UCODE_STATISTICS_NARROW_BAND_MSK)
  611. ? "enabled" : "disabled");
  612. return p;
  613. }
  614. static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
  615. char __user *user_buf,
  616. size_t count, loff_t *ppos)
  617. {
  618. struct iwl_priv *priv = file->private_data;
  619. int pos = 0;
  620. char *buf;
  621. int bufsz = sizeof(struct statistics_rx_phy) * 40 +
  622. sizeof(struct statistics_rx_non_phy) * 40 +
  623. sizeof(struct statistics_rx_ht_phy) * 40 + 400;
  624. ssize_t ret;
  625. struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
  626. struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
  627. struct statistics_rx_non_phy *general, *accum_general;
  628. struct statistics_rx_non_phy *delta_general, *max_general;
  629. struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
  630. if (!iwl_is_alive(priv))
  631. return -EAGAIN;
  632. buf = kzalloc(bufsz, GFP_KERNEL);
  633. if (!buf)
  634. return -ENOMEM;
  635. /*
  636. * the statistic information display here is based on
  637. * the last statistics notification from uCode
  638. * might not reflect the current uCode activity
  639. */
  640. spin_lock_bh(&priv->statistics.lock);
  641. ofdm = &priv->statistics.rx_ofdm;
  642. cck = &priv->statistics.rx_cck;
  643. general = &priv->statistics.rx_non_phy;
  644. ht = &priv->statistics.rx_ofdm_ht;
  645. accum_ofdm = &priv->accum_stats.rx_ofdm;
  646. accum_cck = &priv->accum_stats.rx_cck;
  647. accum_general = &priv->accum_stats.rx_non_phy;
  648. accum_ht = &priv->accum_stats.rx_ofdm_ht;
  649. delta_ofdm = &priv->delta_stats.rx_ofdm;
  650. delta_cck = &priv->delta_stats.rx_cck;
  651. delta_general = &priv->delta_stats.rx_non_phy;
  652. delta_ht = &priv->delta_stats.rx_ofdm_ht;
  653. max_ofdm = &priv->max_delta_stats.rx_ofdm;
  654. max_cck = &priv->max_delta_stats.rx_cck;
  655. max_general = &priv->max_delta_stats.rx_non_phy;
  656. max_ht = &priv->max_delta_stats.rx_ofdm_ht;
  657. pos += iwl_statistics_flag(priv, buf, bufsz);
  658. pos += scnprintf(buf + pos, bufsz - pos,
  659. fmt_header, "Statistics_Rx - OFDM:");
  660. pos += scnprintf(buf + pos, bufsz - pos,
  661. fmt_table, "ina_cnt:",
  662. le32_to_cpu(ofdm->ina_cnt),
  663. accum_ofdm->ina_cnt,
  664. delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
  665. pos += scnprintf(buf + pos, bufsz - pos,
  666. fmt_table, "fina_cnt:",
  667. le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
  668. delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
  669. pos += scnprintf(buf + pos, bufsz - pos,
  670. fmt_table, "plcp_err:",
  671. le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
  672. delta_ofdm->plcp_err, max_ofdm->plcp_err);
  673. pos += scnprintf(buf + pos, bufsz - pos,
  674. fmt_table, "crc32_err:",
  675. le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
  676. delta_ofdm->crc32_err, max_ofdm->crc32_err);
  677. pos += scnprintf(buf + pos, bufsz - pos,
  678. fmt_table, "overrun_err:",
  679. le32_to_cpu(ofdm->overrun_err),
  680. accum_ofdm->overrun_err, delta_ofdm->overrun_err,
  681. max_ofdm->overrun_err);
  682. pos += scnprintf(buf + pos, bufsz - pos,
  683. fmt_table, "early_overrun_err:",
  684. le32_to_cpu(ofdm->early_overrun_err),
  685. accum_ofdm->early_overrun_err,
  686. delta_ofdm->early_overrun_err,
  687. max_ofdm->early_overrun_err);
  688. pos += scnprintf(buf + pos, bufsz - pos,
  689. fmt_table, "crc32_good:",
  690. le32_to_cpu(ofdm->crc32_good),
  691. accum_ofdm->crc32_good, delta_ofdm->crc32_good,
  692. max_ofdm->crc32_good);
  693. pos += scnprintf(buf + pos, bufsz - pos,
  694. fmt_table, "false_alarm_cnt:",
  695. le32_to_cpu(ofdm->false_alarm_cnt),
  696. accum_ofdm->false_alarm_cnt,
  697. delta_ofdm->false_alarm_cnt,
  698. max_ofdm->false_alarm_cnt);
  699. pos += scnprintf(buf + pos, bufsz - pos,
  700. fmt_table, "fina_sync_err_cnt:",
  701. le32_to_cpu(ofdm->fina_sync_err_cnt),
  702. accum_ofdm->fina_sync_err_cnt,
  703. delta_ofdm->fina_sync_err_cnt,
  704. max_ofdm->fina_sync_err_cnt);
  705. pos += scnprintf(buf + pos, bufsz - pos,
  706. fmt_table, "sfd_timeout:",
  707. le32_to_cpu(ofdm->sfd_timeout),
  708. accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout,
  709. max_ofdm->sfd_timeout);
  710. pos += scnprintf(buf + pos, bufsz - pos,
  711. fmt_table, "fina_timeout:",
  712. le32_to_cpu(ofdm->fina_timeout),
  713. accum_ofdm->fina_timeout, delta_ofdm->fina_timeout,
  714. max_ofdm->fina_timeout);
  715. pos += scnprintf(buf + pos, bufsz - pos,
  716. fmt_table, "unresponded_rts:",
  717. le32_to_cpu(ofdm->unresponded_rts),
  718. accum_ofdm->unresponded_rts,
  719. delta_ofdm->unresponded_rts,
  720. max_ofdm->unresponded_rts);
  721. pos += scnprintf(buf + pos, bufsz - pos,
  722. fmt_table, "rxe_frame_lmt_ovrun:",
  723. le32_to_cpu(ofdm->rxe_frame_limit_overrun),
  724. accum_ofdm->rxe_frame_limit_overrun,
  725. delta_ofdm->rxe_frame_limit_overrun,
  726. max_ofdm->rxe_frame_limit_overrun);
  727. pos += scnprintf(buf + pos, bufsz - pos,
  728. fmt_table, "sent_ack_cnt:",
  729. le32_to_cpu(ofdm->sent_ack_cnt),
  730. accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt,
  731. max_ofdm->sent_ack_cnt);
  732. pos += scnprintf(buf + pos, bufsz - pos,
  733. fmt_table, "sent_cts_cnt:",
  734. le32_to_cpu(ofdm->sent_cts_cnt),
  735. accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt,
  736. max_ofdm->sent_cts_cnt);
  737. pos += scnprintf(buf + pos, bufsz - pos,
  738. fmt_table, "sent_ba_rsp_cnt:",
  739. le32_to_cpu(ofdm->sent_ba_rsp_cnt),
  740. accum_ofdm->sent_ba_rsp_cnt,
  741. delta_ofdm->sent_ba_rsp_cnt,
  742. max_ofdm->sent_ba_rsp_cnt);
  743. pos += scnprintf(buf + pos, bufsz - pos,
  744. fmt_table, "dsp_self_kill:",
  745. le32_to_cpu(ofdm->dsp_self_kill),
  746. accum_ofdm->dsp_self_kill,
  747. delta_ofdm->dsp_self_kill,
  748. max_ofdm->dsp_self_kill);
  749. pos += scnprintf(buf + pos, bufsz - pos,
  750. fmt_table, "mh_format_err:",
  751. le32_to_cpu(ofdm->mh_format_err),
  752. accum_ofdm->mh_format_err,
  753. delta_ofdm->mh_format_err,
  754. max_ofdm->mh_format_err);
  755. pos += scnprintf(buf + pos, bufsz - pos,
  756. fmt_table, "re_acq_main_rssi_sum:",
  757. le32_to_cpu(ofdm->re_acq_main_rssi_sum),
  758. accum_ofdm->re_acq_main_rssi_sum,
  759. delta_ofdm->re_acq_main_rssi_sum,
  760. max_ofdm->re_acq_main_rssi_sum);
  761. pos += scnprintf(buf + pos, bufsz - pos,
  762. fmt_header, "Statistics_Rx - CCK:");
  763. pos += scnprintf(buf + pos, bufsz - pos,
  764. fmt_table, "ina_cnt:",
  765. le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
  766. delta_cck->ina_cnt, max_cck->ina_cnt);
  767. pos += scnprintf(buf + pos, bufsz - pos,
  768. fmt_table, "fina_cnt:",
  769. le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
  770. delta_cck->fina_cnt, max_cck->fina_cnt);
  771. pos += scnprintf(buf + pos, bufsz - pos,
  772. fmt_table, "plcp_err:",
  773. le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
  774. delta_cck->plcp_err, max_cck->plcp_err);
  775. pos += scnprintf(buf + pos, bufsz - pos,
  776. fmt_table, "crc32_err:",
  777. le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
  778. delta_cck->crc32_err, max_cck->crc32_err);
  779. pos += scnprintf(buf + pos, bufsz - pos,
  780. fmt_table, "overrun_err:",
  781. le32_to_cpu(cck->overrun_err),
  782. accum_cck->overrun_err, delta_cck->overrun_err,
  783. max_cck->overrun_err);
  784. pos += scnprintf(buf + pos, bufsz - pos,
  785. fmt_table, "early_overrun_err:",
  786. le32_to_cpu(cck->early_overrun_err),
  787. accum_cck->early_overrun_err,
  788. delta_cck->early_overrun_err,
  789. max_cck->early_overrun_err);
  790. pos += scnprintf(buf + pos, bufsz - pos,
  791. fmt_table, "crc32_good:",
  792. le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
  793. delta_cck->crc32_good, max_cck->crc32_good);
  794. pos += scnprintf(buf + pos, bufsz - pos,
  795. fmt_table, "false_alarm_cnt:",
  796. le32_to_cpu(cck->false_alarm_cnt),
  797. accum_cck->false_alarm_cnt,
  798. delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt);
  799. pos += scnprintf(buf + pos, bufsz - pos,
  800. fmt_table, "fina_sync_err_cnt:",
  801. le32_to_cpu(cck->fina_sync_err_cnt),
  802. accum_cck->fina_sync_err_cnt,
  803. delta_cck->fina_sync_err_cnt,
  804. max_cck->fina_sync_err_cnt);
  805. pos += scnprintf(buf + pos, bufsz - pos,
  806. fmt_table, "sfd_timeout:",
  807. le32_to_cpu(cck->sfd_timeout),
  808. accum_cck->sfd_timeout, delta_cck->sfd_timeout,
  809. max_cck->sfd_timeout);
  810. pos += scnprintf(buf + pos, bufsz - pos,
  811. fmt_table, "fina_timeout:",
  812. le32_to_cpu(cck->fina_timeout),
  813. accum_cck->fina_timeout, delta_cck->fina_timeout,
  814. max_cck->fina_timeout);
  815. pos += scnprintf(buf + pos, bufsz - pos,
  816. fmt_table, "unresponded_rts:",
  817. le32_to_cpu(cck->unresponded_rts),
  818. accum_cck->unresponded_rts, delta_cck->unresponded_rts,
  819. max_cck->unresponded_rts);
  820. pos += scnprintf(buf + pos, bufsz - pos,
  821. fmt_table, "rxe_frame_lmt_ovrun:",
  822. le32_to_cpu(cck->rxe_frame_limit_overrun),
  823. accum_cck->rxe_frame_limit_overrun,
  824. delta_cck->rxe_frame_limit_overrun,
  825. max_cck->rxe_frame_limit_overrun);
  826. pos += scnprintf(buf + pos, bufsz - pos,
  827. fmt_table, "sent_ack_cnt:",
  828. le32_to_cpu(cck->sent_ack_cnt),
  829. accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt,
  830. max_cck->sent_ack_cnt);
  831. pos += scnprintf(buf + pos, bufsz - pos,
  832. fmt_table, "sent_cts_cnt:",
  833. le32_to_cpu(cck->sent_cts_cnt),
  834. accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt,
  835. max_cck->sent_cts_cnt);
  836. pos += scnprintf(buf + pos, bufsz - pos,
  837. fmt_table, "sent_ba_rsp_cnt:",
  838. le32_to_cpu(cck->sent_ba_rsp_cnt),
  839. accum_cck->sent_ba_rsp_cnt,
  840. delta_cck->sent_ba_rsp_cnt,
  841. max_cck->sent_ba_rsp_cnt);
  842. pos += scnprintf(buf + pos, bufsz - pos,
  843. fmt_table, "dsp_self_kill:",
  844. le32_to_cpu(cck->dsp_self_kill),
  845. accum_cck->dsp_self_kill, delta_cck->dsp_self_kill,
  846. max_cck->dsp_self_kill);
  847. pos += scnprintf(buf + pos, bufsz - pos,
  848. fmt_table, "mh_format_err:",
  849. le32_to_cpu(cck->mh_format_err),
  850. accum_cck->mh_format_err, delta_cck->mh_format_err,
  851. max_cck->mh_format_err);
  852. pos += scnprintf(buf + pos, bufsz - pos,
  853. fmt_table, "re_acq_main_rssi_sum:",
  854. le32_to_cpu(cck->re_acq_main_rssi_sum),
  855. accum_cck->re_acq_main_rssi_sum,
  856. delta_cck->re_acq_main_rssi_sum,
  857. max_cck->re_acq_main_rssi_sum);
  858. pos += scnprintf(buf + pos, bufsz - pos,
  859. fmt_header, "Statistics_Rx - GENERAL:");
  860. pos += scnprintf(buf + pos, bufsz - pos,
  861. fmt_table, "bogus_cts:",
  862. le32_to_cpu(general->bogus_cts),
  863. accum_general->bogus_cts, delta_general->bogus_cts,
  864. max_general->bogus_cts);
  865. pos += scnprintf(buf + pos, bufsz - pos,
  866. fmt_table, "bogus_ack:",
  867. le32_to_cpu(general->bogus_ack),
  868. accum_general->bogus_ack, delta_general->bogus_ack,
  869. max_general->bogus_ack);
  870. pos += scnprintf(buf + pos, bufsz - pos,
  871. fmt_table, "non_bssid_frames:",
  872. le32_to_cpu(general->non_bssid_frames),
  873. accum_general->non_bssid_frames,
  874. delta_general->non_bssid_frames,
  875. max_general->non_bssid_frames);
  876. pos += scnprintf(buf + pos, bufsz - pos,
  877. fmt_table, "filtered_frames:",
  878. le32_to_cpu(general->filtered_frames),
  879. accum_general->filtered_frames,
  880. delta_general->filtered_frames,
  881. max_general->filtered_frames);
  882. pos += scnprintf(buf + pos, bufsz - pos,
  883. fmt_table, "non_channel_beacons:",
  884. le32_to_cpu(general->non_channel_beacons),
  885. accum_general->non_channel_beacons,
  886. delta_general->non_channel_beacons,
  887. max_general->non_channel_beacons);
  888. pos += scnprintf(buf + pos, bufsz - pos,
  889. fmt_table, "channel_beacons:",
  890. le32_to_cpu(general->channel_beacons),
  891. accum_general->channel_beacons,
  892. delta_general->channel_beacons,
  893. max_general->channel_beacons);
  894. pos += scnprintf(buf + pos, bufsz - pos,
  895. fmt_table, "num_missed_bcon:",
  896. le32_to_cpu(general->num_missed_bcon),
  897. accum_general->num_missed_bcon,
  898. delta_general->num_missed_bcon,
  899. max_general->num_missed_bcon);
  900. pos += scnprintf(buf + pos, bufsz - pos,
  901. fmt_table, "adc_rx_saturation_time:",
  902. le32_to_cpu(general->adc_rx_saturation_time),
  903. accum_general->adc_rx_saturation_time,
  904. delta_general->adc_rx_saturation_time,
  905. max_general->adc_rx_saturation_time);
  906. pos += scnprintf(buf + pos, bufsz - pos,
  907. fmt_table, "ina_detect_search_tm:",
  908. le32_to_cpu(general->ina_detection_search_time),
  909. accum_general->ina_detection_search_time,
  910. delta_general->ina_detection_search_time,
  911. max_general->ina_detection_search_time);
  912. pos += scnprintf(buf + pos, bufsz - pos,
  913. fmt_table, "beacon_silence_rssi_a:",
  914. le32_to_cpu(general->beacon_silence_rssi_a),
  915. accum_general->beacon_silence_rssi_a,
  916. delta_general->beacon_silence_rssi_a,
  917. max_general->beacon_silence_rssi_a);
  918. pos += scnprintf(buf + pos, bufsz - pos,
  919. fmt_table, "beacon_silence_rssi_b:",
  920. le32_to_cpu(general->beacon_silence_rssi_b),
  921. accum_general->beacon_silence_rssi_b,
  922. delta_general->beacon_silence_rssi_b,
  923. max_general->beacon_silence_rssi_b);
  924. pos += scnprintf(buf + pos, bufsz - pos,
  925. fmt_table, "beacon_silence_rssi_c:",
  926. le32_to_cpu(general->beacon_silence_rssi_c),
  927. accum_general->beacon_silence_rssi_c,
  928. delta_general->beacon_silence_rssi_c,
  929. max_general->beacon_silence_rssi_c);
  930. pos += scnprintf(buf + pos, bufsz - pos,
  931. fmt_table, "interference_data_flag:",
  932. le32_to_cpu(general->interference_data_flag),
  933. accum_general->interference_data_flag,
  934. delta_general->interference_data_flag,
  935. max_general->interference_data_flag);
  936. pos += scnprintf(buf + pos, bufsz - pos,
  937. fmt_table, "channel_load:",
  938. le32_to_cpu(general->channel_load),
  939. accum_general->channel_load,
  940. delta_general->channel_load,
  941. max_general->channel_load);
  942. pos += scnprintf(buf + pos, bufsz - pos,
  943. fmt_table, "dsp_false_alarms:",
  944. le32_to_cpu(general->dsp_false_alarms),
  945. accum_general->dsp_false_alarms,
  946. delta_general->dsp_false_alarms,
  947. max_general->dsp_false_alarms);
  948. pos += scnprintf(buf + pos, bufsz - pos,
  949. fmt_table, "beacon_rssi_a:",
  950. le32_to_cpu(general->beacon_rssi_a),
  951. accum_general->beacon_rssi_a,
  952. delta_general->beacon_rssi_a,
  953. max_general->beacon_rssi_a);
  954. pos += scnprintf(buf + pos, bufsz - pos,
  955. fmt_table, "beacon_rssi_b:",
  956. le32_to_cpu(general->beacon_rssi_b),
  957. accum_general->beacon_rssi_b,
  958. delta_general->beacon_rssi_b,
  959. max_general->beacon_rssi_b);
  960. pos += scnprintf(buf + pos, bufsz - pos,
  961. fmt_table, "beacon_rssi_c:",
  962. le32_to_cpu(general->beacon_rssi_c),
  963. accum_general->beacon_rssi_c,
  964. delta_general->beacon_rssi_c,
  965. max_general->beacon_rssi_c);
  966. pos += scnprintf(buf + pos, bufsz - pos,
  967. fmt_table, "beacon_energy_a:",
  968. le32_to_cpu(general->beacon_energy_a),
  969. accum_general->beacon_energy_a,
  970. delta_general->beacon_energy_a,
  971. max_general->beacon_energy_a);
  972. pos += scnprintf(buf + pos, bufsz - pos,
  973. fmt_table, "beacon_energy_b:",
  974. le32_to_cpu(general->beacon_energy_b),
  975. accum_general->beacon_energy_b,
  976. delta_general->beacon_energy_b,
  977. max_general->beacon_energy_b);
  978. pos += scnprintf(buf + pos, bufsz - pos,
  979. fmt_table, "beacon_energy_c:",
  980. le32_to_cpu(general->beacon_energy_c),
  981. accum_general->beacon_energy_c,
  982. delta_general->beacon_energy_c,
  983. max_general->beacon_energy_c);
  984. pos += scnprintf(buf + pos, bufsz - pos,
  985. fmt_header, "Statistics_Rx - OFDM_HT:");
  986. pos += scnprintf(buf + pos, bufsz - pos,
  987. fmt_table, "plcp_err:",
  988. le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
  989. delta_ht->plcp_err, max_ht->plcp_err);
  990. pos += scnprintf(buf + pos, bufsz - pos,
  991. fmt_table, "overrun_err:",
  992. le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
  993. delta_ht->overrun_err, max_ht->overrun_err);
  994. pos += scnprintf(buf + pos, bufsz - pos,
  995. fmt_table, "early_overrun_err:",
  996. le32_to_cpu(ht->early_overrun_err),
  997. accum_ht->early_overrun_err,
  998. delta_ht->early_overrun_err,
  999. max_ht->early_overrun_err);
  1000. pos += scnprintf(buf + pos, bufsz - pos,
  1001. fmt_table, "crc32_good:",
  1002. le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
  1003. delta_ht->crc32_good, max_ht->crc32_good);
  1004. pos += scnprintf(buf + pos, bufsz - pos,
  1005. fmt_table, "crc32_err:",
  1006. le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
  1007. delta_ht->crc32_err, max_ht->crc32_err);
  1008. pos += scnprintf(buf + pos, bufsz - pos,
  1009. fmt_table, "mh_format_err:",
  1010. le32_to_cpu(ht->mh_format_err),
  1011. accum_ht->mh_format_err,
  1012. delta_ht->mh_format_err, max_ht->mh_format_err);
  1013. pos += scnprintf(buf + pos, bufsz - pos,
  1014. fmt_table, "agg_crc32_good:",
  1015. le32_to_cpu(ht->agg_crc32_good),
  1016. accum_ht->agg_crc32_good,
  1017. delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
  1018. pos += scnprintf(buf + pos, bufsz - pos,
  1019. fmt_table, "agg_mpdu_cnt:",
  1020. le32_to_cpu(ht->agg_mpdu_cnt),
  1021. accum_ht->agg_mpdu_cnt,
  1022. delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
  1023. pos += scnprintf(buf + pos, bufsz - pos,
  1024. fmt_table, "agg_cnt:",
  1025. le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
  1026. delta_ht->agg_cnt, max_ht->agg_cnt);
  1027. pos += scnprintf(buf + pos, bufsz - pos,
  1028. fmt_table, "unsupport_mcs:",
  1029. le32_to_cpu(ht->unsupport_mcs),
  1030. accum_ht->unsupport_mcs,
  1031. delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
  1032. spin_unlock_bh(&priv->statistics.lock);
  1033. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1034. kfree(buf);
  1035. return ret;
  1036. }
  1037. static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
  1038. char __user *user_buf,
  1039. size_t count, loff_t *ppos)
  1040. {
  1041. struct iwl_priv *priv = file->private_data;
  1042. int pos = 0;
  1043. char *buf;
  1044. int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
  1045. ssize_t ret;
  1046. struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx;
  1047. if (!iwl_is_alive(priv))
  1048. return -EAGAIN;
  1049. buf = kzalloc(bufsz, GFP_KERNEL);
  1050. if (!buf)
  1051. return -ENOMEM;
  1052. /* the statistic information display here is based on
  1053. * the last statistics notification from uCode
  1054. * might not reflect the current uCode activity
  1055. */
  1056. spin_lock_bh(&priv->statistics.lock);
  1057. tx = &priv->statistics.tx;
  1058. accum_tx = &priv->accum_stats.tx;
  1059. delta_tx = &priv->delta_stats.tx;
  1060. max_tx = &priv->max_delta_stats.tx;
  1061. pos += iwl_statistics_flag(priv, buf, bufsz);
  1062. pos += scnprintf(buf + pos, bufsz - pos,
  1063. fmt_header, "Statistics_Tx:");
  1064. pos += scnprintf(buf + pos, bufsz - pos,
  1065. fmt_table, "preamble:",
  1066. le32_to_cpu(tx->preamble_cnt),
  1067. accum_tx->preamble_cnt,
  1068. delta_tx->preamble_cnt, max_tx->preamble_cnt);
  1069. pos += scnprintf(buf + pos, bufsz - pos,
  1070. fmt_table, "rx_detected_cnt:",
  1071. le32_to_cpu(tx->rx_detected_cnt),
  1072. accum_tx->rx_detected_cnt,
  1073. delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt);
  1074. pos += scnprintf(buf + pos, bufsz - pos,
  1075. fmt_table, "bt_prio_defer_cnt:",
  1076. le32_to_cpu(tx->bt_prio_defer_cnt),
  1077. accum_tx->bt_prio_defer_cnt,
  1078. delta_tx->bt_prio_defer_cnt,
  1079. max_tx->bt_prio_defer_cnt);
  1080. pos += scnprintf(buf + pos, bufsz - pos,
  1081. fmt_table, "bt_prio_kill_cnt:",
  1082. le32_to_cpu(tx->bt_prio_kill_cnt),
  1083. accum_tx->bt_prio_kill_cnt,
  1084. delta_tx->bt_prio_kill_cnt,
  1085. max_tx->bt_prio_kill_cnt);
  1086. pos += scnprintf(buf + pos, bufsz - pos,
  1087. fmt_table, "few_bytes_cnt:",
  1088. le32_to_cpu(tx->few_bytes_cnt),
  1089. accum_tx->few_bytes_cnt,
  1090. delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
  1091. pos += scnprintf(buf + pos, bufsz - pos,
  1092. fmt_table, "cts_timeout:",
  1093. le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
  1094. delta_tx->cts_timeout, max_tx->cts_timeout);
  1095. pos += scnprintf(buf + pos, bufsz - pos,
  1096. fmt_table, "ack_timeout:",
  1097. le32_to_cpu(tx->ack_timeout),
  1098. accum_tx->ack_timeout,
  1099. delta_tx->ack_timeout, max_tx->ack_timeout);
  1100. pos += scnprintf(buf + pos, bufsz - pos,
  1101. fmt_table, "expected_ack_cnt:",
  1102. le32_to_cpu(tx->expected_ack_cnt),
  1103. accum_tx->expected_ack_cnt,
  1104. delta_tx->expected_ack_cnt,
  1105. max_tx->expected_ack_cnt);
  1106. pos += scnprintf(buf + pos, bufsz - pos,
  1107. fmt_table, "actual_ack_cnt:",
  1108. le32_to_cpu(tx->actual_ack_cnt),
  1109. accum_tx->actual_ack_cnt,
  1110. delta_tx->actual_ack_cnt,
  1111. max_tx->actual_ack_cnt);
  1112. pos += scnprintf(buf + pos, bufsz - pos,
  1113. fmt_table, "dump_msdu_cnt:",
  1114. le32_to_cpu(tx->dump_msdu_cnt),
  1115. accum_tx->dump_msdu_cnt,
  1116. delta_tx->dump_msdu_cnt,
  1117. max_tx->dump_msdu_cnt);
  1118. pos += scnprintf(buf + pos, bufsz - pos,
  1119. fmt_table, "abort_nxt_frame_mismatch:",
  1120. le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
  1121. accum_tx->burst_abort_next_frame_mismatch_cnt,
  1122. delta_tx->burst_abort_next_frame_mismatch_cnt,
  1123. max_tx->burst_abort_next_frame_mismatch_cnt);
  1124. pos += scnprintf(buf + pos, bufsz - pos,
  1125. fmt_table, "abort_missing_nxt_frame:",
  1126. le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
  1127. accum_tx->burst_abort_missing_next_frame_cnt,
  1128. delta_tx->burst_abort_missing_next_frame_cnt,
  1129. max_tx->burst_abort_missing_next_frame_cnt);
  1130. pos += scnprintf(buf + pos, bufsz - pos,
  1131. fmt_table, "cts_timeout_collision:",
  1132. le32_to_cpu(tx->cts_timeout_collision),
  1133. accum_tx->cts_timeout_collision,
  1134. delta_tx->cts_timeout_collision,
  1135. max_tx->cts_timeout_collision);
  1136. pos += scnprintf(buf + pos, bufsz - pos,
  1137. fmt_table, "ack_ba_timeout_collision:",
  1138. le32_to_cpu(tx->ack_or_ba_timeout_collision),
  1139. accum_tx->ack_or_ba_timeout_collision,
  1140. delta_tx->ack_or_ba_timeout_collision,
  1141. max_tx->ack_or_ba_timeout_collision);
  1142. pos += scnprintf(buf + pos, bufsz - pos,
  1143. fmt_table, "agg ba_timeout:",
  1144. le32_to_cpu(tx->agg.ba_timeout),
  1145. accum_tx->agg.ba_timeout,
  1146. delta_tx->agg.ba_timeout,
  1147. max_tx->agg.ba_timeout);
  1148. pos += scnprintf(buf + pos, bufsz - pos,
  1149. fmt_table, "agg ba_resched_frames:",
  1150. le32_to_cpu(tx->agg.ba_reschedule_frames),
  1151. accum_tx->agg.ba_reschedule_frames,
  1152. delta_tx->agg.ba_reschedule_frames,
  1153. max_tx->agg.ba_reschedule_frames);
  1154. pos += scnprintf(buf + pos, bufsz - pos,
  1155. fmt_table, "agg scd_query_agg_frame:",
  1156. le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
  1157. accum_tx->agg.scd_query_agg_frame_cnt,
  1158. delta_tx->agg.scd_query_agg_frame_cnt,
  1159. max_tx->agg.scd_query_agg_frame_cnt);
  1160. pos += scnprintf(buf + pos, bufsz - pos,
  1161. fmt_table, "agg scd_query_no_agg:",
  1162. le32_to_cpu(tx->agg.scd_query_no_agg),
  1163. accum_tx->agg.scd_query_no_agg,
  1164. delta_tx->agg.scd_query_no_agg,
  1165. max_tx->agg.scd_query_no_agg);
  1166. pos += scnprintf(buf + pos, bufsz - pos,
  1167. fmt_table, "agg scd_query_agg:",
  1168. le32_to_cpu(tx->agg.scd_query_agg),
  1169. accum_tx->agg.scd_query_agg,
  1170. delta_tx->agg.scd_query_agg,
  1171. max_tx->agg.scd_query_agg);
  1172. pos += scnprintf(buf + pos, bufsz - pos,
  1173. fmt_table, "agg scd_query_mismatch:",
  1174. le32_to_cpu(tx->agg.scd_query_mismatch),
  1175. accum_tx->agg.scd_query_mismatch,
  1176. delta_tx->agg.scd_query_mismatch,
  1177. max_tx->agg.scd_query_mismatch);
  1178. pos += scnprintf(buf + pos, bufsz - pos,
  1179. fmt_table, "agg frame_not_ready:",
  1180. le32_to_cpu(tx->agg.frame_not_ready),
  1181. accum_tx->agg.frame_not_ready,
  1182. delta_tx->agg.frame_not_ready,
  1183. max_tx->agg.frame_not_ready);
  1184. pos += scnprintf(buf + pos, bufsz - pos,
  1185. fmt_table, "agg underrun:",
  1186. le32_to_cpu(tx->agg.underrun),
  1187. accum_tx->agg.underrun,
  1188. delta_tx->agg.underrun, max_tx->agg.underrun);
  1189. pos += scnprintf(buf + pos, bufsz - pos,
  1190. fmt_table, "agg bt_prio_kill:",
  1191. le32_to_cpu(tx->agg.bt_prio_kill),
  1192. accum_tx->agg.bt_prio_kill,
  1193. delta_tx->agg.bt_prio_kill,
  1194. max_tx->agg.bt_prio_kill);
  1195. pos += scnprintf(buf + pos, bufsz - pos,
  1196. fmt_table, "agg rx_ba_rsp_cnt:",
  1197. le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
  1198. accum_tx->agg.rx_ba_rsp_cnt,
  1199. delta_tx->agg.rx_ba_rsp_cnt,
  1200. max_tx->agg.rx_ba_rsp_cnt);
  1201. if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) {
  1202. pos += scnprintf(buf + pos, bufsz - pos,
  1203. "tx power: (1/2 dB step)\n");
  1204. if ((priv->nvm_data->valid_tx_ant & ANT_A) &&
  1205. tx->tx_power.ant_a)
  1206. pos += scnprintf(buf + pos, bufsz - pos,
  1207. fmt_hex, "antenna A:",
  1208. tx->tx_power.ant_a);
  1209. if ((priv->nvm_data->valid_tx_ant & ANT_B) &&
  1210. tx->tx_power.ant_b)
  1211. pos += scnprintf(buf + pos, bufsz - pos,
  1212. fmt_hex, "antenna B:",
  1213. tx->tx_power.ant_b);
  1214. if ((priv->nvm_data->valid_tx_ant & ANT_C) &&
  1215. tx->tx_power.ant_c)
  1216. pos += scnprintf(buf + pos, bufsz - pos,
  1217. fmt_hex, "antenna C:",
  1218. tx->tx_power.ant_c);
  1219. }
  1220. spin_unlock_bh(&priv->statistics.lock);
  1221. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1222. kfree(buf);
  1223. return ret;
  1224. }
  1225. static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
  1226. char __user *user_buf,
  1227. size_t count, loff_t *ppos)
  1228. {
  1229. struct iwl_priv *priv = file->private_data;
  1230. int pos = 0;
  1231. char *buf;
  1232. int bufsz = sizeof(struct statistics_general) * 10 + 300;
  1233. ssize_t ret;
  1234. struct statistics_general_common *general, *accum_general;
  1235. struct statistics_general_common *delta_general, *max_general;
  1236. struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
  1237. struct statistics_div *div, *accum_div, *delta_div, *max_div;
  1238. if (!iwl_is_alive(priv))
  1239. return -EAGAIN;
  1240. buf = kzalloc(bufsz, GFP_KERNEL);
  1241. if (!buf)
  1242. return -ENOMEM;
  1243. /* the statistic information display here is based on
  1244. * the last statistics notification from uCode
  1245. * might not reflect the current uCode activity
  1246. */
  1247. spin_lock_bh(&priv->statistics.lock);
  1248. general = &priv->statistics.common;
  1249. dbg = &priv->statistics.common.dbg;
  1250. div = &priv->statistics.common.div;
  1251. accum_general = &priv->accum_stats.common;
  1252. accum_dbg = &priv->accum_stats.common.dbg;
  1253. accum_div = &priv->accum_stats.common.div;
  1254. delta_general = &priv->delta_stats.common;
  1255. max_general = &priv->max_delta_stats.common;
  1256. delta_dbg = &priv->delta_stats.common.dbg;
  1257. max_dbg = &priv->max_delta_stats.common.dbg;
  1258. delta_div = &priv->delta_stats.common.div;
  1259. max_div = &priv->max_delta_stats.common.div;
  1260. pos += iwl_statistics_flag(priv, buf, bufsz);
  1261. pos += scnprintf(buf + pos, bufsz - pos,
  1262. fmt_header, "Statistics_General:");
  1263. pos += scnprintf(buf + pos, bufsz - pos,
  1264. fmt_value, "temperature:",
  1265. le32_to_cpu(general->temperature));
  1266. pos += scnprintf(buf + pos, bufsz - pos,
  1267. fmt_value, "temperature_m:",
  1268. le32_to_cpu(general->temperature_m));
  1269. pos += scnprintf(buf + pos, bufsz - pos,
  1270. fmt_value, "ttl_timestamp:",
  1271. le32_to_cpu(general->ttl_timestamp));
  1272. pos += scnprintf(buf + pos, bufsz - pos,
  1273. fmt_table, "burst_check:",
  1274. le32_to_cpu(dbg->burst_check),
  1275. accum_dbg->burst_check,
  1276. delta_dbg->burst_check, max_dbg->burst_check);
  1277. pos += scnprintf(buf + pos, bufsz - pos,
  1278. fmt_table, "burst_count:",
  1279. le32_to_cpu(dbg->burst_count),
  1280. accum_dbg->burst_count,
  1281. delta_dbg->burst_count, max_dbg->burst_count);
  1282. pos += scnprintf(buf + pos, bufsz - pos,
  1283. fmt_table, "wait_for_silence_timeout_count:",
  1284. le32_to_cpu(dbg->wait_for_silence_timeout_cnt),
  1285. accum_dbg->wait_for_silence_timeout_cnt,
  1286. delta_dbg->wait_for_silence_timeout_cnt,
  1287. max_dbg->wait_for_silence_timeout_cnt);
  1288. pos += scnprintf(buf + pos, bufsz - pos,
  1289. fmt_table, "sleep_time:",
  1290. le32_to_cpu(general->sleep_time),
  1291. accum_general->sleep_time,
  1292. delta_general->sleep_time, max_general->sleep_time);
  1293. pos += scnprintf(buf + pos, bufsz - pos,
  1294. fmt_table, "slots_out:",
  1295. le32_to_cpu(general->slots_out),
  1296. accum_general->slots_out,
  1297. delta_general->slots_out, max_general->slots_out);
  1298. pos += scnprintf(buf + pos, bufsz - pos,
  1299. fmt_table, "slots_idle:",
  1300. le32_to_cpu(general->slots_idle),
  1301. accum_general->slots_idle,
  1302. delta_general->slots_idle, max_general->slots_idle);
  1303. pos += scnprintf(buf + pos, bufsz - pos,
  1304. fmt_table, "tx_on_a:",
  1305. le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
  1306. delta_div->tx_on_a, max_div->tx_on_a);
  1307. pos += scnprintf(buf + pos, bufsz - pos,
  1308. fmt_table, "tx_on_b:",
  1309. le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
  1310. delta_div->tx_on_b, max_div->tx_on_b);
  1311. pos += scnprintf(buf + pos, bufsz - pos,
  1312. fmt_table, "exec_time:",
  1313. le32_to_cpu(div->exec_time), accum_div->exec_time,
  1314. delta_div->exec_time, max_div->exec_time);
  1315. pos += scnprintf(buf + pos, bufsz - pos,
  1316. fmt_table, "probe_time:",
  1317. le32_to_cpu(div->probe_time), accum_div->probe_time,
  1318. delta_div->probe_time, max_div->probe_time);
  1319. pos += scnprintf(buf + pos, bufsz - pos,
  1320. fmt_table, "rx_enable_counter:",
  1321. le32_to_cpu(general->rx_enable_counter),
  1322. accum_general->rx_enable_counter,
  1323. delta_general->rx_enable_counter,
  1324. max_general->rx_enable_counter);
  1325. pos += scnprintf(buf + pos, bufsz - pos,
  1326. fmt_table, "num_of_sos_states:",
  1327. le32_to_cpu(general->num_of_sos_states),
  1328. accum_general->num_of_sos_states,
  1329. delta_general->num_of_sos_states,
  1330. max_general->num_of_sos_states);
  1331. spin_unlock_bh(&priv->statistics.lock);
  1332. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1333. kfree(buf);
  1334. return ret;
  1335. }
  1336. static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
  1337. char __user *user_buf,
  1338. size_t count, loff_t *ppos)
  1339. {
  1340. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  1341. int pos = 0;
  1342. char *buf;
  1343. int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200;
  1344. ssize_t ret;
  1345. struct statistics_bt_activity *bt, *accum_bt;
  1346. if (!iwl_is_alive(priv))
  1347. return -EAGAIN;
  1348. if (!priv->bt_enable_flag)
  1349. return -EINVAL;
  1350. /* make request to uCode to retrieve statistics information */
  1351. mutex_lock(&priv->mutex);
  1352. ret = iwl_send_statistics_request(priv, 0, false);
  1353. mutex_unlock(&priv->mutex);
  1354. if (ret)
  1355. return -EAGAIN;
  1356. buf = kzalloc(bufsz, GFP_KERNEL);
  1357. if (!buf)
  1358. return -ENOMEM;
  1359. /*
  1360. * the statistic information display here is based on
  1361. * the last statistics notification from uCode
  1362. * might not reflect the current uCode activity
  1363. */
  1364. spin_lock_bh(&priv->statistics.lock);
  1365. bt = &priv->statistics.bt_activity;
  1366. accum_bt = &priv->accum_stats.bt_activity;
  1367. pos += iwl_statistics_flag(priv, buf, bufsz);
  1368. pos += scnprintf(buf + pos, bufsz - pos, "Statistics_BT:\n");
  1369. pos += scnprintf(buf + pos, bufsz - pos,
  1370. "\t\t\tcurrent\t\t\taccumulative\n");
  1371. pos += scnprintf(buf + pos, bufsz - pos,
  1372. "hi_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
  1373. le32_to_cpu(bt->hi_priority_tx_req_cnt),
  1374. accum_bt->hi_priority_tx_req_cnt);
  1375. pos += scnprintf(buf + pos, bufsz - pos,
  1376. "hi_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
  1377. le32_to_cpu(bt->hi_priority_tx_denied_cnt),
  1378. accum_bt->hi_priority_tx_denied_cnt);
  1379. pos += scnprintf(buf + pos, bufsz - pos,
  1380. "lo_priority_tx_req_cnt:\t\t%u\t\t\t%u\n",
  1381. le32_to_cpu(bt->lo_priority_tx_req_cnt),
  1382. accum_bt->lo_priority_tx_req_cnt);
  1383. pos += scnprintf(buf + pos, bufsz - pos,
  1384. "lo_priority_tx_denied_cnt:\t%u\t\t\t%u\n",
  1385. le32_to_cpu(bt->lo_priority_tx_denied_cnt),
  1386. accum_bt->lo_priority_tx_denied_cnt);
  1387. pos += scnprintf(buf + pos, bufsz - pos,
  1388. "hi_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
  1389. le32_to_cpu(bt->hi_priority_rx_req_cnt),
  1390. accum_bt->hi_priority_rx_req_cnt);
  1391. pos += scnprintf(buf + pos, bufsz - pos,
  1392. "hi_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
  1393. le32_to_cpu(bt->hi_priority_rx_denied_cnt),
  1394. accum_bt->hi_priority_rx_denied_cnt);
  1395. pos += scnprintf(buf + pos, bufsz - pos,
  1396. "lo_priority_rx_req_cnt:\t\t%u\t\t\t%u\n",
  1397. le32_to_cpu(bt->lo_priority_rx_req_cnt),
  1398. accum_bt->lo_priority_rx_req_cnt);
  1399. pos += scnprintf(buf + pos, bufsz - pos,
  1400. "lo_priority_rx_denied_cnt:\t%u\t\t\t%u\n",
  1401. le32_to_cpu(bt->lo_priority_rx_denied_cnt),
  1402. accum_bt->lo_priority_rx_denied_cnt);
  1403. pos += scnprintf(buf + pos, bufsz - pos,
  1404. "(rx)num_bt_kills:\t\t%u\t\t\t%u\n",
  1405. le32_to_cpu(priv->statistics.num_bt_kills),
  1406. priv->statistics.accum_num_bt_kills);
  1407. spin_unlock_bh(&priv->statistics.lock);
  1408. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1409. kfree(buf);
  1410. return ret;
  1411. }
  1412. static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file,
  1413. char __user *user_buf,
  1414. size_t count, loff_t *ppos)
  1415. {
  1416. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  1417. int pos = 0;
  1418. char *buf;
  1419. int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) +
  1420. (sizeof(struct reply_agg_tx_error_statistics) * 24) + 200;
  1421. ssize_t ret;
  1422. if (!iwl_is_alive(priv))
  1423. return -EAGAIN;
  1424. buf = kzalloc(bufsz, GFP_KERNEL);
  1425. if (!buf)
  1426. return -ENOMEM;
  1427. pos += scnprintf(buf + pos, bufsz - pos, "Statistics_TX_Error:\n");
  1428. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t\t%u\n",
  1429. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_DELAY),
  1430. priv->reply_tx_stats.pp_delay);
  1431. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1432. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_FEW_BYTES),
  1433. priv->reply_tx_stats.pp_few_bytes);
  1434. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1435. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_BT_PRIO),
  1436. priv->reply_tx_stats.pp_bt_prio);
  1437. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1438. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_QUIET_PERIOD),
  1439. priv->reply_tx_stats.pp_quiet_period);
  1440. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1441. iwl_get_tx_fail_reason(TX_STATUS_POSTPONE_CALC_TTAK),
  1442. priv->reply_tx_stats.pp_calc_ttak);
  1443. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1444. iwl_get_tx_fail_reason(
  1445. TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY),
  1446. priv->reply_tx_stats.int_crossed_retry);
  1447. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1448. iwl_get_tx_fail_reason(TX_STATUS_FAIL_SHORT_LIMIT),
  1449. priv->reply_tx_stats.short_limit);
  1450. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1451. iwl_get_tx_fail_reason(TX_STATUS_FAIL_LONG_LIMIT),
  1452. priv->reply_tx_stats.long_limit);
  1453. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1454. iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_UNDERRUN),
  1455. priv->reply_tx_stats.fifo_underrun);
  1456. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1457. iwl_get_tx_fail_reason(TX_STATUS_FAIL_DRAIN_FLOW),
  1458. priv->reply_tx_stats.drain_flow);
  1459. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1460. iwl_get_tx_fail_reason(TX_STATUS_FAIL_RFKILL_FLUSH),
  1461. priv->reply_tx_stats.rfkill_flush);
  1462. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1463. iwl_get_tx_fail_reason(TX_STATUS_FAIL_LIFE_EXPIRE),
  1464. priv->reply_tx_stats.life_expire);
  1465. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1466. iwl_get_tx_fail_reason(TX_STATUS_FAIL_DEST_PS),
  1467. priv->reply_tx_stats.dest_ps);
  1468. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1469. iwl_get_tx_fail_reason(TX_STATUS_FAIL_HOST_ABORTED),
  1470. priv->reply_tx_stats.host_abort);
  1471. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1472. iwl_get_tx_fail_reason(TX_STATUS_FAIL_BT_RETRY),
  1473. priv->reply_tx_stats.pp_delay);
  1474. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1475. iwl_get_tx_fail_reason(TX_STATUS_FAIL_STA_INVALID),
  1476. priv->reply_tx_stats.sta_invalid);
  1477. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1478. iwl_get_tx_fail_reason(TX_STATUS_FAIL_FRAG_DROPPED),
  1479. priv->reply_tx_stats.frag_drop);
  1480. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1481. iwl_get_tx_fail_reason(TX_STATUS_FAIL_TID_DISABLE),
  1482. priv->reply_tx_stats.tid_disable);
  1483. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1484. iwl_get_tx_fail_reason(TX_STATUS_FAIL_FIFO_FLUSHED),
  1485. priv->reply_tx_stats.fifo_flush);
  1486. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1487. iwl_get_tx_fail_reason(
  1488. TX_STATUS_FAIL_INSUFFICIENT_CF_POLL),
  1489. priv->reply_tx_stats.insuff_cf_poll);
  1490. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1491. iwl_get_tx_fail_reason(TX_STATUS_FAIL_PASSIVE_NO_RX),
  1492. priv->reply_tx_stats.fail_hw_drop);
  1493. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1494. iwl_get_tx_fail_reason(
  1495. TX_STATUS_FAIL_NO_BEACON_ON_RADAR),
  1496. priv->reply_tx_stats.sta_color_mismatch);
  1497. pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
  1498. priv->reply_tx_stats.unknown);
  1499. pos += scnprintf(buf + pos, bufsz - pos,
  1500. "\nStatistics_Agg_TX_Error:\n");
  1501. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1502. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_UNDERRUN_MSK),
  1503. priv->reply_agg_tx_stats.underrun);
  1504. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1505. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_BT_PRIO_MSK),
  1506. priv->reply_agg_tx_stats.bt_prio);
  1507. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1508. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_FEW_BYTES_MSK),
  1509. priv->reply_agg_tx_stats.few_bytes);
  1510. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1511. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_ABORT_MSK),
  1512. priv->reply_agg_tx_stats.abort);
  1513. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1514. iwl_get_agg_tx_fail_reason(
  1515. AGG_TX_STATE_LAST_SENT_TTL_MSK),
  1516. priv->reply_agg_tx_stats.last_sent_ttl);
  1517. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1518. iwl_get_agg_tx_fail_reason(
  1519. AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK),
  1520. priv->reply_agg_tx_stats.last_sent_try);
  1521. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1522. iwl_get_agg_tx_fail_reason(
  1523. AGG_TX_STATE_LAST_SENT_BT_KILL_MSK),
  1524. priv->reply_agg_tx_stats.last_sent_bt_kill);
  1525. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1526. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_SCD_QUERY_MSK),
  1527. priv->reply_agg_tx_stats.scd_query);
  1528. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t%u\n",
  1529. iwl_get_agg_tx_fail_reason(
  1530. AGG_TX_STATE_TEST_BAD_CRC32_MSK),
  1531. priv->reply_agg_tx_stats.bad_crc32);
  1532. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1533. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_RESPONSE_MSK),
  1534. priv->reply_agg_tx_stats.response);
  1535. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1536. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DUMP_TX_MSK),
  1537. priv->reply_agg_tx_stats.dump_tx);
  1538. pos += scnprintf(buf + pos, bufsz - pos, "%s:\t\t\t%u\n",
  1539. iwl_get_agg_tx_fail_reason(AGG_TX_STATE_DELAY_TX_MSK),
  1540. priv->reply_agg_tx_stats.delay_tx);
  1541. pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
  1542. priv->reply_agg_tx_stats.unknown);
  1543. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1544. kfree(buf);
  1545. return ret;
  1546. }
  1547. static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
  1548. char __user *user_buf,
  1549. size_t count, loff_t *ppos) {
  1550. struct iwl_priv *priv = file->private_data;
  1551. int pos = 0;
  1552. int cnt = 0;
  1553. char *buf;
  1554. int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100;
  1555. ssize_t ret;
  1556. struct iwl_sensitivity_data *data;
  1557. data = &priv->sensitivity_data;
  1558. buf = kzalloc(bufsz, GFP_KERNEL);
  1559. if (!buf)
  1560. return -ENOMEM;
  1561. pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n",
  1562. data->auto_corr_ofdm);
  1563. pos += scnprintf(buf + pos, bufsz - pos,
  1564. "auto_corr_ofdm_mrc:\t\t %u\n",
  1565. data->auto_corr_ofdm_mrc);
  1566. pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n",
  1567. data->auto_corr_ofdm_x1);
  1568. pos += scnprintf(buf + pos, bufsz - pos,
  1569. "auto_corr_ofdm_mrc_x1:\t\t %u\n",
  1570. data->auto_corr_ofdm_mrc_x1);
  1571. pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n",
  1572. data->auto_corr_cck);
  1573. pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n",
  1574. data->auto_corr_cck_mrc);
  1575. pos += scnprintf(buf + pos, bufsz - pos,
  1576. "last_bad_plcp_cnt_ofdm:\t\t %u\n",
  1577. data->last_bad_plcp_cnt_ofdm);
  1578. pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n",
  1579. data->last_fa_cnt_ofdm);
  1580. pos += scnprintf(buf + pos, bufsz - pos,
  1581. "last_bad_plcp_cnt_cck:\t\t %u\n",
  1582. data->last_bad_plcp_cnt_cck);
  1583. pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n",
  1584. data->last_fa_cnt_cck);
  1585. pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n",
  1586. data->nrg_curr_state);
  1587. pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n",
  1588. data->nrg_prev_state);
  1589. pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t");
  1590. for (cnt = 0; cnt < 10; cnt++) {
  1591. pos += scnprintf(buf + pos, bufsz - pos, " %u",
  1592. data->nrg_value[cnt]);
  1593. }
  1594. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  1595. pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t");
  1596. for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) {
  1597. pos += scnprintf(buf + pos, bufsz - pos, " %u",
  1598. data->nrg_silence_rssi[cnt]);
  1599. }
  1600. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  1601. pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n",
  1602. data->nrg_silence_ref);
  1603. pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n",
  1604. data->nrg_energy_idx);
  1605. pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n",
  1606. data->nrg_silence_idx);
  1607. pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n",
  1608. data->nrg_th_cck);
  1609. pos += scnprintf(buf + pos, bufsz - pos,
  1610. "nrg_auto_corr_silence_diff:\t %u\n",
  1611. data->nrg_auto_corr_silence_diff);
  1612. pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n",
  1613. data->num_in_cck_no_fa);
  1614. pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
  1615. data->nrg_th_ofdm);
  1616. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1617. kfree(buf);
  1618. return ret;
  1619. }
  1620. static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
  1621. char __user *user_buf,
  1622. size_t count, loff_t *ppos) {
  1623. struct iwl_priv *priv = file->private_data;
  1624. int pos = 0;
  1625. int cnt = 0;
  1626. char *buf;
  1627. int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100;
  1628. ssize_t ret;
  1629. struct iwl_chain_noise_data *data;
  1630. data = &priv->chain_noise_data;
  1631. buf = kzalloc(bufsz, GFP_KERNEL);
  1632. if (!buf)
  1633. return -ENOMEM;
  1634. pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n",
  1635. data->active_chains);
  1636. pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n",
  1637. data->chain_noise_a);
  1638. pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n",
  1639. data->chain_noise_b);
  1640. pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n",
  1641. data->chain_noise_c);
  1642. pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n",
  1643. data->chain_signal_a);
  1644. pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n",
  1645. data->chain_signal_b);
  1646. pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n",
  1647. data->chain_signal_c);
  1648. pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n",
  1649. data->beacon_count);
  1650. pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t");
  1651. for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
  1652. pos += scnprintf(buf + pos, bufsz - pos, " %u",
  1653. data->disconn_array[cnt]);
  1654. }
  1655. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  1656. pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t");
  1657. for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) {
  1658. pos += scnprintf(buf + pos, bufsz - pos, " %u",
  1659. data->delta_gain_code[cnt]);
  1660. }
  1661. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  1662. pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n",
  1663. data->radio_write);
  1664. pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
  1665. data->state);
  1666. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1667. kfree(buf);
  1668. return ret;
  1669. }
  1670. static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
  1671. char __user *user_buf,
  1672. size_t count, loff_t *ppos)
  1673. {
  1674. struct iwl_priv *priv = file->private_data;
  1675. char buf[60];
  1676. int pos = 0;
  1677. const size_t bufsz = sizeof(buf);
  1678. u32 pwrsave_status;
  1679. pwrsave_status = iwl_read32(priv->trans, CSR_GP_CNTRL) &
  1680. CSR_GP_REG_POWER_SAVE_STATUS_MSK;
  1681. pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
  1682. pos += scnprintf(buf + pos, bufsz - pos, "%s\n",
  1683. (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" :
  1684. (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" :
  1685. (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
  1686. "error");
  1687. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1688. }
  1689. static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
  1690. const char __user *user_buf,
  1691. size_t count, loff_t *ppos)
  1692. {
  1693. struct iwl_priv *priv = file->private_data;
  1694. char buf[8];
  1695. int buf_size;
  1696. int clear;
  1697. memset(buf, 0, sizeof(buf));
  1698. buf_size = min(count, sizeof(buf) - 1);
  1699. if (copy_from_user(buf, user_buf, buf_size))
  1700. return -EFAULT;
  1701. if (sscanf(buf, "%d", &clear) != 1)
  1702. return -EFAULT;
  1703. /* make request to uCode to retrieve statistics information */
  1704. mutex_lock(&priv->mutex);
  1705. iwl_send_statistics_request(priv, 0, true);
  1706. mutex_unlock(&priv->mutex);
  1707. return count;
  1708. }
  1709. static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
  1710. char __user *user_buf,
  1711. size_t count, loff_t *ppos) {
  1712. struct iwl_priv *priv = file->private_data;
  1713. int pos = 0;
  1714. char buf[128];
  1715. const size_t bufsz = sizeof(buf);
  1716. pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
  1717. priv->event_log.ucode_trace ? "On" : "Off");
  1718. pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n",
  1719. priv->event_log.non_wraps_count);
  1720. pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n",
  1721. priv->event_log.wraps_once_count);
  1722. pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
  1723. priv->event_log.wraps_more_count);
  1724. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1725. }
  1726. static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
  1727. const char __user *user_buf,
  1728. size_t count, loff_t *ppos)
  1729. {
  1730. struct iwl_priv *priv = file->private_data;
  1731. char buf[8];
  1732. int buf_size;
  1733. int trace;
  1734. memset(buf, 0, sizeof(buf));
  1735. buf_size = min(count, sizeof(buf) - 1);
  1736. if (copy_from_user(buf, user_buf, buf_size))
  1737. return -EFAULT;
  1738. if (sscanf(buf, "%d", &trace) != 1)
  1739. return -EFAULT;
  1740. if (trace) {
  1741. priv->event_log.ucode_trace = true;
  1742. if (iwl_is_alive(priv)) {
  1743. /* start collecting data now */
  1744. mod_timer(&priv->ucode_trace, jiffies);
  1745. }
  1746. } else {
  1747. priv->event_log.ucode_trace = false;
  1748. del_timer_sync(&priv->ucode_trace);
  1749. }
  1750. return count;
  1751. }
  1752. static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
  1753. char __user *user_buf,
  1754. size_t count, loff_t *ppos) {
  1755. struct iwl_priv *priv = file->private_data;
  1756. int len = 0;
  1757. char buf[20];
  1758. len = sprintf(buf, "0x%04X\n",
  1759. le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags));
  1760. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1761. }
  1762. static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
  1763. char __user *user_buf,
  1764. size_t count, loff_t *ppos) {
  1765. struct iwl_priv *priv = file->private_data;
  1766. int len = 0;
  1767. char buf[20];
  1768. len = sprintf(buf, "0x%04X\n",
  1769. le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags));
  1770. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1771. }
  1772. static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
  1773. char __user *user_buf,
  1774. size_t count, loff_t *ppos) {
  1775. struct iwl_priv *priv = file->private_data;
  1776. int pos = 0;
  1777. char buf[12];
  1778. const size_t bufsz = sizeof(buf);
  1779. pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
  1780. priv->missed_beacon_threshold);
  1781. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1782. }
  1783. static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
  1784. const char __user *user_buf,
  1785. size_t count, loff_t *ppos)
  1786. {
  1787. struct iwl_priv *priv = file->private_data;
  1788. char buf[8];
  1789. int buf_size;
  1790. int missed;
  1791. memset(buf, 0, sizeof(buf));
  1792. buf_size = min(count, sizeof(buf) - 1);
  1793. if (copy_from_user(buf, user_buf, buf_size))
  1794. return -EFAULT;
  1795. if (sscanf(buf, "%d", &missed) != 1)
  1796. return -EINVAL;
  1797. if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN ||
  1798. missed > IWL_MISSED_BEACON_THRESHOLD_MAX)
  1799. priv->missed_beacon_threshold =
  1800. IWL_MISSED_BEACON_THRESHOLD_DEF;
  1801. else
  1802. priv->missed_beacon_threshold = missed;
  1803. return count;
  1804. }
  1805. static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
  1806. char __user *user_buf,
  1807. size_t count, loff_t *ppos) {
  1808. struct iwl_priv *priv = file->private_data;
  1809. int pos = 0;
  1810. char buf[12];
  1811. const size_t bufsz = sizeof(buf);
  1812. pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
  1813. priv->plcp_delta_threshold);
  1814. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1815. }
  1816. static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
  1817. const char __user *user_buf,
  1818. size_t count, loff_t *ppos) {
  1819. struct iwl_priv *priv = file->private_data;
  1820. char buf[8];
  1821. int buf_size;
  1822. int plcp;
  1823. memset(buf, 0, sizeof(buf));
  1824. buf_size = min(count, sizeof(buf) - 1);
  1825. if (copy_from_user(buf, user_buf, buf_size))
  1826. return -EFAULT;
  1827. if (sscanf(buf, "%d", &plcp) != 1)
  1828. return -EINVAL;
  1829. if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) ||
  1830. (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX))
  1831. priv->plcp_delta_threshold =
  1832. IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE;
  1833. else
  1834. priv->plcp_delta_threshold = plcp;
  1835. return count;
  1836. }
  1837. static ssize_t iwl_dbgfs_rf_reset_read(struct file *file,
  1838. char __user *user_buf,
  1839. size_t count, loff_t *ppos)
  1840. {
  1841. struct iwl_priv *priv = file->private_data;
  1842. int pos = 0;
  1843. char buf[300];
  1844. const size_t bufsz = sizeof(buf);
  1845. struct iwl_rf_reset *rf_reset = &priv->rf_reset;
  1846. pos += scnprintf(buf + pos, bufsz - pos,
  1847. "RF reset statistics\n");
  1848. pos += scnprintf(buf + pos, bufsz - pos,
  1849. "\tnumber of reset request: %d\n",
  1850. rf_reset->reset_request_count);
  1851. pos += scnprintf(buf + pos, bufsz - pos,
  1852. "\tnumber of reset request success: %d\n",
  1853. rf_reset->reset_success_count);
  1854. pos += scnprintf(buf + pos, bufsz - pos,
  1855. "\tnumber of reset request reject: %d\n",
  1856. rf_reset->reset_reject_count);
  1857. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1858. }
  1859. static ssize_t iwl_dbgfs_rf_reset_write(struct file *file,
  1860. const char __user *user_buf,
  1861. size_t count, loff_t *ppos) {
  1862. struct iwl_priv *priv = file->private_data;
  1863. int ret;
  1864. ret = iwl_force_rf_reset(priv, true);
  1865. return ret ? ret : count;
  1866. }
  1867. static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
  1868. const char __user *user_buf,
  1869. size_t count, loff_t *ppos) {
  1870. struct iwl_priv *priv = file->private_data;
  1871. char buf[8];
  1872. int buf_size;
  1873. int flush;
  1874. memset(buf, 0, sizeof(buf));
  1875. buf_size = min(count, sizeof(buf) - 1);
  1876. if (copy_from_user(buf, user_buf, buf_size))
  1877. return -EFAULT;
  1878. if (sscanf(buf, "%d", &flush) != 1)
  1879. return -EINVAL;
  1880. if (iwl_is_rfkill(priv))
  1881. return -EFAULT;
  1882. iwlagn_dev_txfifo_flush(priv);
  1883. return count;
  1884. }
  1885. static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file,
  1886. char __user *user_buf,
  1887. size_t count, loff_t *ppos) {
  1888. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  1889. int pos = 0;
  1890. char buf[200];
  1891. const size_t bufsz = sizeof(buf);
  1892. if (!priv->bt_enable_flag) {
  1893. pos += scnprintf(buf + pos, bufsz - pos, "BT coex disabled\n");
  1894. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1895. }
  1896. pos += scnprintf(buf + pos, bufsz - pos, "BT enable flag: 0x%x\n",
  1897. priv->bt_enable_flag);
  1898. pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n",
  1899. priv->bt_full_concurrent ? "full concurrency" : "3-wire");
  1900. pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, "
  1901. "last traffic notif: %d\n",
  1902. priv->bt_status ? "On" : "Off", priv->last_bt_traffic_load);
  1903. pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, "
  1904. "kill_ack_mask: %x, kill_cts_mask: %x\n",
  1905. priv->bt_ch_announce, priv->kill_ack_mask,
  1906. priv->kill_cts_mask);
  1907. pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: ");
  1908. switch (priv->bt_traffic_load) {
  1909. case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
  1910. pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n");
  1911. break;
  1912. case IWL_BT_COEX_TRAFFIC_LOAD_HIGH:
  1913. pos += scnprintf(buf + pos, bufsz - pos, "High\n");
  1914. break;
  1915. case IWL_BT_COEX_TRAFFIC_LOAD_LOW:
  1916. pos += scnprintf(buf + pos, bufsz - pos, "Low\n");
  1917. break;
  1918. case IWL_BT_COEX_TRAFFIC_LOAD_NONE:
  1919. default:
  1920. pos += scnprintf(buf + pos, bufsz - pos, "None\n");
  1921. break;
  1922. }
  1923. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1924. }
  1925. static ssize_t iwl_dbgfs_protection_mode_read(struct file *file,
  1926. char __user *user_buf,
  1927. size_t count, loff_t *ppos)
  1928. {
  1929. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  1930. int pos = 0;
  1931. char buf[40];
  1932. const size_t bufsz = sizeof(buf);
  1933. if (priv->cfg->ht_params)
  1934. pos += scnprintf(buf + pos, bufsz - pos,
  1935. "use %s for aggregation\n",
  1936. (priv->hw_params.use_rts_for_aggregation) ?
  1937. "rts/cts" : "cts-to-self");
  1938. else
  1939. pos += scnprintf(buf + pos, bufsz - pos, "N/A");
  1940. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1941. }
  1942. static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
  1943. const char __user *user_buf,
  1944. size_t count, loff_t *ppos) {
  1945. struct iwl_priv *priv = file->private_data;
  1946. char buf[8];
  1947. int buf_size;
  1948. int rts;
  1949. if (!priv->cfg->ht_params)
  1950. return -EINVAL;
  1951. memset(buf, 0, sizeof(buf));
  1952. buf_size = min(count, sizeof(buf) - 1);
  1953. if (copy_from_user(buf, user_buf, buf_size))
  1954. return -EFAULT;
  1955. if (sscanf(buf, "%d", &rts) != 1)
  1956. return -EINVAL;
  1957. if (rts)
  1958. priv->hw_params.use_rts_for_aggregation = true;
  1959. else
  1960. priv->hw_params.use_rts_for_aggregation = false;
  1961. return count;
  1962. }
  1963. static int iwl_cmd_echo_test(struct iwl_priv *priv)
  1964. {
  1965. int ret;
  1966. struct iwl_host_cmd cmd = {
  1967. .id = REPLY_ECHO,
  1968. .len = { 0 },
  1969. };
  1970. ret = iwl_dvm_send_cmd(priv, &cmd);
  1971. if (ret)
  1972. IWL_ERR(priv, "echo testing fail: 0X%x\n", ret);
  1973. else
  1974. IWL_DEBUG_INFO(priv, "echo testing pass\n");
  1975. return ret;
  1976. }
  1977. static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
  1978. const char __user *user_buf,
  1979. size_t count, loff_t *ppos)
  1980. {
  1981. struct iwl_priv *priv = file->private_data;
  1982. char buf[8];
  1983. int buf_size;
  1984. memset(buf, 0, sizeof(buf));
  1985. buf_size = min(count, sizeof(buf) - 1);
  1986. if (copy_from_user(buf, user_buf, buf_size))
  1987. return -EFAULT;
  1988. iwl_cmd_echo_test(priv);
  1989. return count;
  1990. }
  1991. #ifdef CONFIG_IWLWIFI_DEBUG
  1992. static ssize_t iwl_dbgfs_log_event_read(struct file *file,
  1993. char __user *user_buf,
  1994. size_t count, loff_t *ppos)
  1995. {
  1996. struct iwl_priv *priv = file->private_data;
  1997. char *buf = NULL;
  1998. ssize_t ret;
  1999. ret = iwl_dump_nic_event_log(priv, true, &buf);
  2000. if (ret > 0)
  2001. ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
  2002. kfree(buf);
  2003. return ret;
  2004. }
  2005. static ssize_t iwl_dbgfs_log_event_write(struct file *file,
  2006. const char __user *user_buf,
  2007. size_t count, loff_t *ppos)
  2008. {
  2009. struct iwl_priv *priv = file->private_data;
  2010. u32 event_log_flag;
  2011. char buf[8];
  2012. int buf_size;
  2013. /* check that the interface is up */
  2014. if (!iwl_is_ready(priv))
  2015. return -EAGAIN;
  2016. memset(buf, 0, sizeof(buf));
  2017. buf_size = min(count, sizeof(buf) - 1);
  2018. if (copy_from_user(buf, user_buf, buf_size))
  2019. return -EFAULT;
  2020. if (sscanf(buf, "%d", &event_log_flag) != 1)
  2021. return -EFAULT;
  2022. if (event_log_flag == 1)
  2023. iwl_dump_nic_event_log(priv, true, NULL);
  2024. return count;
  2025. }
  2026. #endif
  2027. static ssize_t iwl_dbgfs_calib_disabled_read(struct file *file,
  2028. char __user *user_buf,
  2029. size_t count, loff_t *ppos)
  2030. {
  2031. struct iwl_priv *priv = file->private_data;
  2032. char buf[120];
  2033. int pos = 0;
  2034. const size_t bufsz = sizeof(buf);
  2035. pos += scnprintf(buf + pos, bufsz - pos,
  2036. "Sensitivity calibrations %s\n",
  2037. (priv->calib_disabled &
  2038. IWL_SENSITIVITY_CALIB_DISABLED) ?
  2039. "DISABLED" : "ENABLED");
  2040. pos += scnprintf(buf + pos, bufsz - pos,
  2041. "Chain noise calibrations %s\n",
  2042. (priv->calib_disabled &
  2043. IWL_CHAIN_NOISE_CALIB_DISABLED) ?
  2044. "DISABLED" : "ENABLED");
  2045. pos += scnprintf(buf + pos, bufsz - pos,
  2046. "Tx power calibrations %s\n",
  2047. (priv->calib_disabled &
  2048. IWL_TX_POWER_CALIB_DISABLED) ?
  2049. "DISABLED" : "ENABLED");
  2050. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  2051. }
  2052. static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
  2053. const char __user *user_buf,
  2054. size_t count, loff_t *ppos)
  2055. {
  2056. struct iwl_priv *priv = file->private_data;
  2057. char buf[8];
  2058. u32 calib_disabled;
  2059. int buf_size;
  2060. memset(buf, 0, sizeof(buf));
  2061. buf_size = min(count, sizeof(buf) - 1);
  2062. if (copy_from_user(buf, user_buf, buf_size))
  2063. return -EFAULT;
  2064. if (sscanf(buf, "%x", &calib_disabled) != 1)
  2065. return -EFAULT;
  2066. priv->calib_disabled = calib_disabled;
  2067. return count;
  2068. }
  2069. static ssize_t iwl_dbgfs_fw_restart_write(struct file *file,
  2070. const char __user *user_buf,
  2071. size_t count, loff_t *ppos)
  2072. {
  2073. struct iwl_priv *priv = file->private_data;
  2074. bool fw_restart = iwlwifi_mod_params.fw_restart;
  2075. int __maybe_unused ret;
  2076. iwlwifi_mod_params.fw_restart = true;
  2077. mutex_lock(&priv->mutex);
  2078. /* take the return value to make compiler happy - it will fail anyway */
  2079. ret = iwl_dvm_send_cmd_pdu(priv, REPLY_ERROR, 0, 0, NULL);
  2080. mutex_unlock(&priv->mutex);
  2081. iwlwifi_mod_params.fw_restart = fw_restart;
  2082. return count;
  2083. }
  2084. DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
  2085. DEBUGFS_READ_FILE_OPS(ucode_tx_stats);
  2086. DEBUGFS_READ_FILE_OPS(ucode_general_stats);
  2087. DEBUGFS_READ_FILE_OPS(sensitivity);
  2088. DEBUGFS_READ_FILE_OPS(chain_noise);
  2089. DEBUGFS_READ_FILE_OPS(power_save_status);
  2090. DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics);
  2091. DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
  2092. DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
  2093. DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
  2094. DEBUGFS_READ_WRITE_FILE_OPS(rf_reset);
  2095. DEBUGFS_READ_FILE_OPS(rxon_flags);
  2096. DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
  2097. DEBUGFS_WRITE_FILE_OPS(txfifo_flush);
  2098. DEBUGFS_READ_FILE_OPS(ucode_bt_stats);
  2099. DEBUGFS_READ_FILE_OPS(bt_traffic);
  2100. DEBUGFS_READ_WRITE_FILE_OPS(protection_mode);
  2101. DEBUGFS_READ_FILE_OPS(reply_tx_error);
  2102. DEBUGFS_WRITE_FILE_OPS(echo_test);
  2103. DEBUGFS_WRITE_FILE_OPS(fw_restart);
  2104. #ifdef CONFIG_IWLWIFI_DEBUG
  2105. DEBUGFS_READ_WRITE_FILE_OPS(log_event);
  2106. #endif
  2107. DEBUGFS_READ_WRITE_FILE_OPS(calib_disabled);
  2108. /*
  2109. * Create the debugfs files and directories
  2110. *
  2111. */
  2112. int iwl_dbgfs_register(struct iwl_priv *priv, struct dentry *dbgfs_dir)
  2113. {
  2114. struct dentry *dir_data, *dir_rf, *dir_debug;
  2115. priv->debugfs_dir = dbgfs_dir;
  2116. dir_data = debugfs_create_dir("data", dbgfs_dir);
  2117. if (!dir_data)
  2118. goto err;
  2119. dir_rf = debugfs_create_dir("rf", dbgfs_dir);
  2120. if (!dir_rf)
  2121. goto err;
  2122. dir_debug = debugfs_create_dir("debug", dbgfs_dir);
  2123. if (!dir_debug)
  2124. goto err;
  2125. DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR);
  2126. DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR);
  2127. DEBUGFS_ADD_FILE(wowlan_sram, dir_data, S_IRUSR);
  2128. DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR);
  2129. DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR);
  2130. DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR);
  2131. DEBUGFS_ADD_FILE(rx_handlers, dir_data, S_IWUSR | S_IRUSR);
  2132. DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR);
  2133. DEBUGFS_ADD_FILE(sleep_level_override, dir_data, S_IWUSR | S_IRUSR);
  2134. DEBUGFS_ADD_FILE(current_sleep_command, dir_data, S_IRUSR);
  2135. DEBUGFS_ADD_FILE(thermal_throttling, dir_data, S_IRUSR);
  2136. DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
  2137. DEBUGFS_ADD_FILE(temperature, dir_data, S_IRUSR);
  2138. DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);
  2139. DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR);
  2140. DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
  2141. DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
  2142. DEBUGFS_ADD_FILE(rf_reset, dir_debug, S_IWUSR | S_IRUSR);
  2143. DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
  2144. DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
  2145. DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR);
  2146. DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR);
  2147. DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR);
  2148. DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
  2149. DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
  2150. DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
  2151. DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR);
  2152. DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR);
  2153. DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
  2154. DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
  2155. DEBUGFS_ADD_FILE(echo_test, dir_debug, S_IWUSR);
  2156. DEBUGFS_ADD_FILE(fw_restart, dir_debug, S_IWUSR);
  2157. #ifdef CONFIG_IWLWIFI_DEBUG
  2158. DEBUGFS_ADD_FILE(log_event, dir_debug, S_IWUSR | S_IRUSR);
  2159. #endif
  2160. if (iwl_advanced_bt_coexist(priv))
  2161. DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR);
  2162. /* Calibrations disabled/enabled status*/
  2163. DEBUGFS_ADD_FILE(calib_disabled, dir_rf, S_IWUSR | S_IRUSR);
  2164. /*
  2165. * Create a symlink with mac80211. This is not very robust, as it does
  2166. * not remove the symlink created. The implicit assumption is that
  2167. * when the opmode exits, mac80211 will also exit, and will remove
  2168. * this symlink as part of its cleanup.
  2169. */
  2170. if (priv->mac80211_registered) {
  2171. char buf[100];
  2172. struct dentry *mac80211_dir, *dev_dir;
  2173. dev_dir = dbgfs_dir->d_parent;
  2174. mac80211_dir = priv->hw->wiphy->debugfsdir;
  2175. snprintf(buf, 100, "../../%pd2", dev_dir);
  2176. if (!debugfs_create_symlink("iwlwifi", mac80211_dir, buf))
  2177. goto err;
  2178. }
  2179. return 0;
  2180. err:
  2181. IWL_ERR(priv, "failed to create the dvm debugfs entries\n");
  2182. return -ENOMEM;
  2183. }