iwl-debugfs.c 84 KB

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