debugfs.c 79 KB

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