debugfs.c 78 KB

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