iwl-debugfs.c 79 KB

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