debugfs.c 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516
  1. /******************************************************************************
  2. *
  3. * This file is provided under a dual BSD/GPLv2 license. When using or
  4. * redistributing this file, you may do so under either license.
  5. *
  6. * GPL LICENSE SUMMARY
  7. *
  8. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  9. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of version 2 of the GNU General Public License as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  23. * USA
  24. *
  25. * The full GNU General Public License is included in this distribution
  26. * in the file called COPYING.
  27. *
  28. * Contact Information:
  29. * Intel Linux Wireless <ilw@linux.intel.com>
  30. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  31. *
  32. * BSD LICENSE
  33. *
  34. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  35. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  36. * All rights reserved.
  37. *
  38. * Redistribution and use in source and binary forms, with or without
  39. * modification, are permitted provided that the following conditions
  40. * are met:
  41. *
  42. * * Redistributions of source code must retain the above copyright
  43. * notice, this list of conditions and the following disclaimer.
  44. * * Redistributions in binary form must reproduce the above copyright
  45. * notice, this list of conditions and the following disclaimer in
  46. * the documentation and/or other materials provided with the
  47. * distribution.
  48. * * Neither the name Intel Corporation nor the names of its
  49. * contributors may be used to endorse or promote products derived
  50. * from this software without specific prior written permission.
  51. *
  52. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  53. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  54. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  55. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  56. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  57. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  58. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  59. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  60. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  61. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  62. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  63. *
  64. *****************************************************************************/
  65. #include <linux/vmalloc.h>
  66. #include "mvm.h"
  67. #include "sta.h"
  68. #include "iwl-io.h"
  69. #include "debugfs.h"
  70. #include "iwl-fw-error-dump.h"
  71. static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf,
  72. size_t count, loff_t *ppos)
  73. {
  74. int ret;
  75. u32 scd_q_msk;
  76. if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
  77. return -EIO;
  78. if (sscanf(buf, "%x", &scd_q_msk) != 1)
  79. return -EINVAL;
  80. IWL_ERR(mvm, "FLUSHING queues: scd_q_msk = 0x%x\n", scd_q_msk);
  81. mutex_lock(&mvm->mutex);
  82. ret = iwl_mvm_flush_tx_path(mvm, scd_q_msk, 0) ? : count;
  83. mutex_unlock(&mvm->mutex);
  84. return ret;
  85. }
  86. static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
  87. size_t count, loff_t *ppos)
  88. {
  89. struct iwl_mvm_sta *mvmsta;
  90. int sta_id, drain, ret;
  91. if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
  92. return -EIO;
  93. if (sscanf(buf, "%d %d", &sta_id, &drain) != 2)
  94. return -EINVAL;
  95. if (sta_id < 0 || sta_id >= IWL_MVM_STATION_COUNT)
  96. return -EINVAL;
  97. if (drain < 0 || drain > 1)
  98. return -EINVAL;
  99. mutex_lock(&mvm->mutex);
  100. mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id);
  101. if (!mvmsta)
  102. ret = -ENOENT;
  103. else
  104. ret = iwl_mvm_drain_sta(mvm, mvmsta, drain) ? : count;
  105. mutex_unlock(&mvm->mutex);
  106. return ret;
  107. }
  108. static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
  109. size_t count, loff_t *ppos)
  110. {
  111. struct iwl_mvm *mvm = file->private_data;
  112. const struct fw_img *img;
  113. unsigned int ofs, len;
  114. size_t ret;
  115. u8 *ptr;
  116. if (!mvm->ucode_loaded)
  117. return -EINVAL;
  118. /* default is to dump the entire data segment */
  119. img = &mvm->fw->img[mvm->cur_ucode];
  120. ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
  121. len = img->sec[IWL_UCODE_SECTION_DATA].len;
  122. if (mvm->dbgfs_sram_len) {
  123. ofs = mvm->dbgfs_sram_offset;
  124. len = mvm->dbgfs_sram_len;
  125. }
  126. ptr = kzalloc(len, GFP_KERNEL);
  127. if (!ptr)
  128. return -ENOMEM;
  129. iwl_trans_read_mem_bytes(mvm->trans, ofs, ptr, len);
  130. ret = simple_read_from_buffer(user_buf, count, ppos, ptr, len);
  131. kfree(ptr);
  132. return ret;
  133. }
  134. static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf,
  135. size_t count, loff_t *ppos)
  136. {
  137. const struct fw_img *img;
  138. u32 offset, len;
  139. u32 img_offset, img_len;
  140. if (!mvm->ucode_loaded)
  141. return -EINVAL;
  142. img = &mvm->fw->img[mvm->cur_ucode];
  143. img_offset = img->sec[IWL_UCODE_SECTION_DATA].offset;
  144. img_len = img->sec[IWL_UCODE_SECTION_DATA].len;
  145. if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
  146. if ((offset & 0x3) || (len & 0x3))
  147. return -EINVAL;
  148. if (offset + len > img_offset + img_len)
  149. return -EINVAL;
  150. mvm->dbgfs_sram_offset = offset;
  151. mvm->dbgfs_sram_len = len;
  152. } else {
  153. mvm->dbgfs_sram_offset = 0;
  154. mvm->dbgfs_sram_len = 0;
  155. }
  156. return count;
  157. }
  158. static ssize_t iwl_dbgfs_set_nic_temperature_read(struct file *file,
  159. char __user *user_buf,
  160. size_t count, loff_t *ppos)
  161. {
  162. struct iwl_mvm *mvm = file->private_data;
  163. char buf[16];
  164. int pos;
  165. if (!mvm->temperature_test)
  166. pos = scnprintf(buf , sizeof(buf), "disabled\n");
  167. else
  168. pos = scnprintf(buf , sizeof(buf), "%d\n", mvm->temperature);
  169. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  170. }
  171. /*
  172. * Set NIC Temperature
  173. * Cause the driver to ignore the actual NIC temperature reported by the FW
  174. * Enable: any value between IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -
  175. * IWL_MVM_DEBUG_SET_TEMPERATURE_MAX
  176. * Disable: IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE
  177. */
  178. static ssize_t iwl_dbgfs_set_nic_temperature_write(struct iwl_mvm *mvm,
  179. char *buf, size_t count,
  180. loff_t *ppos)
  181. {
  182. int temperature;
  183. if (!mvm->ucode_loaded && !mvm->temperature_test)
  184. return -EIO;
  185. if (kstrtoint(buf, 10, &temperature))
  186. return -EINVAL;
  187. /* not a legal temperature */
  188. if ((temperature > IWL_MVM_DEBUG_SET_TEMPERATURE_MAX &&
  189. temperature != IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) ||
  190. temperature < IWL_MVM_DEBUG_SET_TEMPERATURE_MIN)
  191. return -EINVAL;
  192. mutex_lock(&mvm->mutex);
  193. if (temperature == IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) {
  194. if (!mvm->temperature_test)
  195. goto out;
  196. mvm->temperature_test = false;
  197. /* Since we can't read the temp while awake, just set
  198. * it to zero until we get the next RX stats from the
  199. * firmware.
  200. */
  201. mvm->temperature = 0;
  202. } else {
  203. mvm->temperature_test = true;
  204. mvm->temperature = temperature;
  205. }
  206. IWL_DEBUG_TEMP(mvm, "%sabling debug set temperature (temp = %d)\n",
  207. mvm->temperature_test ? "En" : "Dis" ,
  208. mvm->temperature);
  209. /* handle the temperature change */
  210. iwl_mvm_tt_handler(mvm);
  211. out:
  212. mutex_unlock(&mvm->mutex);
  213. return count;
  214. }
  215. static ssize_t iwl_dbgfs_nic_temp_read(struct file *file,
  216. char __user *user_buf,
  217. size_t count, loff_t *ppos)
  218. {
  219. struct iwl_mvm *mvm = file->private_data;
  220. char buf[16];
  221. int pos, temp;
  222. if (!mvm->ucode_loaded)
  223. return -EIO;
  224. mutex_lock(&mvm->mutex);
  225. temp = iwl_mvm_get_temp(mvm);
  226. mutex_unlock(&mvm->mutex);
  227. if (temp < 0)
  228. return temp;
  229. pos = scnprintf(buf , sizeof(buf), "%d\n", temp);
  230. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  231. }
  232. static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
  233. size_t count, loff_t *ppos)
  234. {
  235. struct iwl_mvm *mvm = file->private_data;
  236. struct ieee80211_sta *sta;
  237. char buf[400];
  238. int i, pos = 0, bufsz = sizeof(buf);
  239. mutex_lock(&mvm->mutex);
  240. for (i = 0; i < IWL_MVM_STATION_COUNT; i++) {
  241. pos += scnprintf(buf + pos, bufsz - pos, "%.2d: ", i);
  242. sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
  243. lockdep_is_held(&mvm->mutex));
  244. if (!sta)
  245. pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
  246. else if (IS_ERR(sta))
  247. pos += scnprintf(buf + pos, bufsz - pos, "%ld\n",
  248. PTR_ERR(sta));
  249. else
  250. pos += scnprintf(buf + pos, bufsz - pos, "%pM\n",
  251. sta->addr);
  252. }
  253. mutex_unlock(&mvm->mutex);
  254. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  255. }
  256. static ssize_t iwl_dbgfs_disable_power_off_read(struct file *file,
  257. char __user *user_buf,
  258. size_t count, loff_t *ppos)
  259. {
  260. struct iwl_mvm *mvm = file->private_data;
  261. char buf[64];
  262. int bufsz = sizeof(buf);
  263. int pos = 0;
  264. pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d0=%d\n",
  265. mvm->disable_power_off);
  266. pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d3=%d\n",
  267. mvm->disable_power_off_d3);
  268. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  269. }
  270. static ssize_t iwl_dbgfs_disable_power_off_write(struct iwl_mvm *mvm, char *buf,
  271. size_t count, loff_t *ppos)
  272. {
  273. int ret, val;
  274. if (!mvm->ucode_loaded)
  275. return -EIO;
  276. if (!strncmp("disable_power_off_d0=", buf, 21)) {
  277. if (sscanf(buf + 21, "%d", &val) != 1)
  278. return -EINVAL;
  279. mvm->disable_power_off = val;
  280. } else if (!strncmp("disable_power_off_d3=", buf, 21)) {
  281. if (sscanf(buf + 21, "%d", &val) != 1)
  282. return -EINVAL;
  283. mvm->disable_power_off_d3 = val;
  284. } else {
  285. return -EINVAL;
  286. }
  287. mutex_lock(&mvm->mutex);
  288. ret = iwl_mvm_power_update_device(mvm);
  289. mutex_unlock(&mvm->mutex);
  290. return ret ?: count;
  291. }
  292. #define BT_MBOX_MSG(_notif, _num, _field) \
  293. ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\
  294. >> BT_MBOX##_num##_##_field##_POS)
  295. #define BT_MBOX_PRINT(_num, _field, _end) \
  296. pos += scnprintf(buf + pos, bufsz - pos, \
  297. "\t%s: %d%s", \
  298. #_field, \
  299. BT_MBOX_MSG(notif, _num, _field), \
  300. true ? "\n" : ", ");
  301. static
  302. int iwl_mvm_coex_dump_mbox(struct iwl_bt_coex_profile_notif *notif, char *buf,
  303. int pos, int bufsz)
  304. {
  305. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n");
  306. BT_MBOX_PRINT(0, LE_SLAVE_LAT, false);
  307. BT_MBOX_PRINT(0, LE_PROF1, false);
  308. BT_MBOX_PRINT(0, LE_PROF2, false);
  309. BT_MBOX_PRINT(0, LE_PROF_OTHER, false);
  310. BT_MBOX_PRINT(0, CHL_SEQ_N, false);
  311. BT_MBOX_PRINT(0, INBAND_S, false);
  312. BT_MBOX_PRINT(0, LE_MIN_RSSI, false);
  313. BT_MBOX_PRINT(0, LE_SCAN, false);
  314. BT_MBOX_PRINT(0, LE_ADV, false);
  315. BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false);
  316. BT_MBOX_PRINT(0, OPEN_CON_1, true);
  317. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n");
  318. BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false);
  319. BT_MBOX_PRINT(1, IP_SR, false);
  320. BT_MBOX_PRINT(1, LE_MSTR, false);
  321. BT_MBOX_PRINT(1, AGGR_TRFC_LD, false);
  322. BT_MBOX_PRINT(1, MSG_TYPE, false);
  323. BT_MBOX_PRINT(1, SSN, true);
  324. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n");
  325. BT_MBOX_PRINT(2, SNIFF_ACT, false);
  326. BT_MBOX_PRINT(2, PAG, false);
  327. BT_MBOX_PRINT(2, INQUIRY, false);
  328. BT_MBOX_PRINT(2, CONN, false);
  329. BT_MBOX_PRINT(2, SNIFF_INTERVAL, false);
  330. BT_MBOX_PRINT(2, DISC, false);
  331. BT_MBOX_PRINT(2, SCO_TX_ACT, false);
  332. BT_MBOX_PRINT(2, SCO_RX_ACT, false);
  333. BT_MBOX_PRINT(2, ESCO_RE_TX, false);
  334. BT_MBOX_PRINT(2, SCO_DURATION, true);
  335. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n");
  336. BT_MBOX_PRINT(3, SCO_STATE, false);
  337. BT_MBOX_PRINT(3, SNIFF_STATE, false);
  338. BT_MBOX_PRINT(3, A2DP_STATE, false);
  339. BT_MBOX_PRINT(3, ACL_STATE, false);
  340. BT_MBOX_PRINT(3, MSTR_STATE, false);
  341. BT_MBOX_PRINT(3, OBX_STATE, false);
  342. BT_MBOX_PRINT(3, OPEN_CON_2, false);
  343. BT_MBOX_PRINT(3, TRAFFIC_LOAD, false);
  344. BT_MBOX_PRINT(3, CHL_SEQN_LSB, false);
  345. BT_MBOX_PRINT(3, INBAND_P, false);
  346. BT_MBOX_PRINT(3, MSG_TYPE_2, false);
  347. BT_MBOX_PRINT(3, SSN_2, false);
  348. BT_MBOX_PRINT(3, UPDATE_REQUEST, true);
  349. return pos;
  350. }
  351. static
  352. int iwl_mvm_coex_dump_mbox_old(struct iwl_bt_coex_profile_notif_old *notif,
  353. char *buf, int pos, int bufsz)
  354. {
  355. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n");
  356. BT_MBOX_PRINT(0, LE_SLAVE_LAT, false);
  357. BT_MBOX_PRINT(0, LE_PROF1, false);
  358. BT_MBOX_PRINT(0, LE_PROF2, false);
  359. BT_MBOX_PRINT(0, LE_PROF_OTHER, false);
  360. BT_MBOX_PRINT(0, CHL_SEQ_N, false);
  361. BT_MBOX_PRINT(0, INBAND_S, false);
  362. BT_MBOX_PRINT(0, LE_MIN_RSSI, false);
  363. BT_MBOX_PRINT(0, LE_SCAN, false);
  364. BT_MBOX_PRINT(0, LE_ADV, false);
  365. BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false);
  366. BT_MBOX_PRINT(0, OPEN_CON_1, true);
  367. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n");
  368. BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false);
  369. BT_MBOX_PRINT(1, IP_SR, false);
  370. BT_MBOX_PRINT(1, LE_MSTR, false);
  371. BT_MBOX_PRINT(1, AGGR_TRFC_LD, false);
  372. BT_MBOX_PRINT(1, MSG_TYPE, false);
  373. BT_MBOX_PRINT(1, SSN, true);
  374. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n");
  375. BT_MBOX_PRINT(2, SNIFF_ACT, false);
  376. BT_MBOX_PRINT(2, PAG, false);
  377. BT_MBOX_PRINT(2, INQUIRY, false);
  378. BT_MBOX_PRINT(2, CONN, false);
  379. BT_MBOX_PRINT(2, SNIFF_INTERVAL, false);
  380. BT_MBOX_PRINT(2, DISC, false);
  381. BT_MBOX_PRINT(2, SCO_TX_ACT, false);
  382. BT_MBOX_PRINT(2, SCO_RX_ACT, false);
  383. BT_MBOX_PRINT(2, ESCO_RE_TX, false);
  384. BT_MBOX_PRINT(2, SCO_DURATION, true);
  385. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n");
  386. BT_MBOX_PRINT(3, SCO_STATE, false);
  387. BT_MBOX_PRINT(3, SNIFF_STATE, false);
  388. BT_MBOX_PRINT(3, A2DP_STATE, false);
  389. BT_MBOX_PRINT(3, ACL_STATE, false);
  390. BT_MBOX_PRINT(3, MSTR_STATE, false);
  391. BT_MBOX_PRINT(3, OBX_STATE, false);
  392. BT_MBOX_PRINT(3, OPEN_CON_2, false);
  393. BT_MBOX_PRINT(3, TRAFFIC_LOAD, false);
  394. BT_MBOX_PRINT(3, CHL_SEQN_LSB, false);
  395. BT_MBOX_PRINT(3, INBAND_P, false);
  396. BT_MBOX_PRINT(3, MSG_TYPE_2, false);
  397. BT_MBOX_PRINT(3, SSN_2, false);
  398. BT_MBOX_PRINT(3, UPDATE_REQUEST, true);
  399. return pos;
  400. }
  401. static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf,
  402. size_t count, loff_t *ppos)
  403. {
  404. struct iwl_mvm *mvm = file->private_data;
  405. char *buf;
  406. int ret, pos = 0, bufsz = sizeof(char) * 1024;
  407. buf = kmalloc(bufsz, GFP_KERNEL);
  408. if (!buf)
  409. return -ENOMEM;
  410. mutex_lock(&mvm->mutex);
  411. if (!fw_has_api(&mvm->fw->ucode_capa,
  412. IWL_UCODE_TLV_API_BT_COEX_SPLIT)) {
  413. struct iwl_bt_coex_profile_notif_old *notif =
  414. &mvm->last_bt_notif_old;
  415. pos += iwl_mvm_coex_dump_mbox_old(notif, buf, pos, bufsz);
  416. pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n",
  417. notif->bt_ci_compliance);
  418. pos += scnprintf(buf+pos, bufsz-pos, "primary_ch_lut = %d\n",
  419. le32_to_cpu(notif->primary_ch_lut));
  420. pos += scnprintf(buf+pos, bufsz-pos, "secondary_ch_lut = %d\n",
  421. le32_to_cpu(notif->secondary_ch_lut));
  422. pos += scnprintf(buf+pos,
  423. bufsz-pos, "bt_activity_grading = %d\n",
  424. le32_to_cpu(notif->bt_activity_grading));
  425. pos += scnprintf(buf+pos, bufsz-pos,
  426. "antenna isolation = %d CORUN LUT index = %d\n",
  427. mvm->last_ant_isol, mvm->last_corun_lut);
  428. } else {
  429. struct iwl_bt_coex_profile_notif *notif =
  430. &mvm->last_bt_notif;
  431. pos += iwl_mvm_coex_dump_mbox(notif, buf, pos, bufsz);
  432. pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n",
  433. notif->bt_ci_compliance);
  434. pos += scnprintf(buf+pos, bufsz-pos, "primary_ch_lut = %d\n",
  435. le32_to_cpu(notif->primary_ch_lut));
  436. pos += scnprintf(buf+pos, bufsz-pos, "secondary_ch_lut = %d\n",
  437. le32_to_cpu(notif->secondary_ch_lut));
  438. pos += scnprintf(buf+pos,
  439. bufsz-pos, "bt_activity_grading = %d\n",
  440. le32_to_cpu(notif->bt_activity_grading));
  441. pos += scnprintf(buf+pos, bufsz-pos,
  442. "antenna isolation = %d CORUN LUT index = %d\n",
  443. mvm->last_ant_isol, mvm->last_corun_lut);
  444. }
  445. mutex_unlock(&mvm->mutex);
  446. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  447. kfree(buf);
  448. return ret;
  449. }
  450. #undef BT_MBOX_PRINT
  451. static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf,
  452. size_t count, loff_t *ppos)
  453. {
  454. struct iwl_mvm *mvm = file->private_data;
  455. char buf[256];
  456. int bufsz = sizeof(buf);
  457. int pos = 0;
  458. mutex_lock(&mvm->mutex);
  459. if (!fw_has_api(&mvm->fw->ucode_capa,
  460. IWL_UCODE_TLV_API_BT_COEX_SPLIT)) {
  461. struct iwl_bt_coex_ci_cmd_old *cmd = &mvm->last_bt_ci_cmd_old;
  462. pos += scnprintf(buf+pos, bufsz-pos,
  463. "Channel inhibition CMD\n");
  464. pos += scnprintf(buf+pos, bufsz-pos,
  465. "\tPrimary Channel Bitmap 0x%016llx\n",
  466. le64_to_cpu(cmd->bt_primary_ci));
  467. pos += scnprintf(buf+pos, bufsz-pos,
  468. "\tSecondary Channel Bitmap 0x%016llx\n",
  469. le64_to_cpu(cmd->bt_secondary_ci));
  470. pos += scnprintf(buf+pos, bufsz-pos,
  471. "BT Configuration CMD - 0=default, 1=never, 2=always\n");
  472. pos += scnprintf(buf+pos, bufsz-pos, "\tACK Kill msk idx %d\n",
  473. mvm->bt_ack_kill_msk[0]);
  474. pos += scnprintf(buf+pos, bufsz-pos, "\tCTS Kill msk idx %d\n",
  475. mvm->bt_cts_kill_msk[0]);
  476. } else {
  477. struct iwl_bt_coex_ci_cmd *cmd = &mvm->last_bt_ci_cmd;
  478. pos += scnprintf(buf+pos, bufsz-pos,
  479. "Channel inhibition CMD\n");
  480. pos += scnprintf(buf+pos, bufsz-pos,
  481. "\tPrimary Channel Bitmap 0x%016llx\n",
  482. le64_to_cpu(cmd->bt_primary_ci));
  483. pos += scnprintf(buf+pos, bufsz-pos,
  484. "\tSecondary Channel Bitmap 0x%016llx\n",
  485. le64_to_cpu(cmd->bt_secondary_ci));
  486. }
  487. mutex_unlock(&mvm->mutex);
  488. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  489. }
  490. static ssize_t
  491. iwl_dbgfs_bt_tx_prio_write(struct iwl_mvm *mvm, char *buf,
  492. size_t count, loff_t *ppos)
  493. {
  494. u32 bt_tx_prio;
  495. if (sscanf(buf, "%u", &bt_tx_prio) != 1)
  496. return -EINVAL;
  497. if (bt_tx_prio > 4)
  498. return -EINVAL;
  499. mvm->bt_tx_prio = bt_tx_prio;
  500. return count;
  501. }
  502. static ssize_t
  503. iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf,
  504. size_t count, loff_t *ppos)
  505. {
  506. static const char * const modes_str[BT_FORCE_ANT_MAX] = {
  507. [BT_FORCE_ANT_DIS] = "dis",
  508. [BT_FORCE_ANT_AUTO] = "auto",
  509. [BT_FORCE_ANT_BT] = "bt",
  510. [BT_FORCE_ANT_WIFI] = "wifi",
  511. };
  512. int ret, bt_force_ant_mode;
  513. for (bt_force_ant_mode = 0;
  514. bt_force_ant_mode < ARRAY_SIZE(modes_str);
  515. bt_force_ant_mode++) {
  516. if (!strcmp(buf, modes_str[bt_force_ant_mode]))
  517. break;
  518. }
  519. if (bt_force_ant_mode >= ARRAY_SIZE(modes_str))
  520. return -EINVAL;
  521. ret = 0;
  522. mutex_lock(&mvm->mutex);
  523. if (mvm->bt_force_ant_mode == bt_force_ant_mode)
  524. goto out;
  525. mvm->bt_force_ant_mode = bt_force_ant_mode;
  526. IWL_DEBUG_COEX(mvm, "Force mode: %s\n",
  527. modes_str[mvm->bt_force_ant_mode]);
  528. ret = iwl_send_bt_init_conf(mvm);
  529. out:
  530. mutex_unlock(&mvm->mutex);
  531. return ret ?: count;
  532. }
  533. #define PRINT_STATS_LE32(_struct, _memb) \
  534. pos += scnprintf(buf + pos, bufsz - pos, \
  535. fmt_table, #_memb, \
  536. le32_to_cpu(_struct->_memb))
  537. static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file,
  538. char __user *user_buf, size_t count,
  539. loff_t *ppos)
  540. {
  541. struct iwl_mvm *mvm = file->private_data;
  542. static const char *fmt_table = "\t%-30s %10u\n";
  543. static const char *fmt_header = "%-32s\n";
  544. int pos = 0;
  545. char *buf;
  546. int ret;
  547. /* 43 is the size of each data line, 33 is the size of each header */
  548. size_t bufsz =
  549. ((sizeof(struct mvm_statistics_rx) / sizeof(__le32)) * 43) +
  550. (4 * 33) + 1;
  551. struct mvm_statistics_rx_phy *ofdm;
  552. struct mvm_statistics_rx_phy *cck;
  553. struct mvm_statistics_rx_non_phy *general;
  554. struct mvm_statistics_rx_ht_phy *ht;
  555. buf = kzalloc(bufsz, GFP_KERNEL);
  556. if (!buf)
  557. return -ENOMEM;
  558. mutex_lock(&mvm->mutex);
  559. ofdm = &mvm->rx_stats.ofdm;
  560. cck = &mvm->rx_stats.cck;
  561. general = &mvm->rx_stats.general;
  562. ht = &mvm->rx_stats.ofdm_ht;
  563. pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
  564. "Statistics_Rx - OFDM");
  565. PRINT_STATS_LE32(ofdm, ina_cnt);
  566. PRINT_STATS_LE32(ofdm, fina_cnt);
  567. PRINT_STATS_LE32(ofdm, plcp_err);
  568. PRINT_STATS_LE32(ofdm, crc32_err);
  569. PRINT_STATS_LE32(ofdm, overrun_err);
  570. PRINT_STATS_LE32(ofdm, early_overrun_err);
  571. PRINT_STATS_LE32(ofdm, crc32_good);
  572. PRINT_STATS_LE32(ofdm, false_alarm_cnt);
  573. PRINT_STATS_LE32(ofdm, fina_sync_err_cnt);
  574. PRINT_STATS_LE32(ofdm, sfd_timeout);
  575. PRINT_STATS_LE32(ofdm, fina_timeout);
  576. PRINT_STATS_LE32(ofdm, unresponded_rts);
  577. PRINT_STATS_LE32(ofdm, rxe_frame_lmt_overrun);
  578. PRINT_STATS_LE32(ofdm, sent_ack_cnt);
  579. PRINT_STATS_LE32(ofdm, sent_cts_cnt);
  580. PRINT_STATS_LE32(ofdm, sent_ba_rsp_cnt);
  581. PRINT_STATS_LE32(ofdm, dsp_self_kill);
  582. PRINT_STATS_LE32(ofdm, mh_format_err);
  583. PRINT_STATS_LE32(ofdm, re_acq_main_rssi_sum);
  584. PRINT_STATS_LE32(ofdm, reserved);
  585. pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
  586. "Statistics_Rx - CCK");
  587. PRINT_STATS_LE32(cck, ina_cnt);
  588. PRINT_STATS_LE32(cck, fina_cnt);
  589. PRINT_STATS_LE32(cck, plcp_err);
  590. PRINT_STATS_LE32(cck, crc32_err);
  591. PRINT_STATS_LE32(cck, overrun_err);
  592. PRINT_STATS_LE32(cck, early_overrun_err);
  593. PRINT_STATS_LE32(cck, crc32_good);
  594. PRINT_STATS_LE32(cck, false_alarm_cnt);
  595. PRINT_STATS_LE32(cck, fina_sync_err_cnt);
  596. PRINT_STATS_LE32(cck, sfd_timeout);
  597. PRINT_STATS_LE32(cck, fina_timeout);
  598. PRINT_STATS_LE32(cck, unresponded_rts);
  599. PRINT_STATS_LE32(cck, rxe_frame_lmt_overrun);
  600. PRINT_STATS_LE32(cck, sent_ack_cnt);
  601. PRINT_STATS_LE32(cck, sent_cts_cnt);
  602. PRINT_STATS_LE32(cck, sent_ba_rsp_cnt);
  603. PRINT_STATS_LE32(cck, dsp_self_kill);
  604. PRINT_STATS_LE32(cck, mh_format_err);
  605. PRINT_STATS_LE32(cck, re_acq_main_rssi_sum);
  606. PRINT_STATS_LE32(cck, reserved);
  607. pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
  608. "Statistics_Rx - GENERAL");
  609. PRINT_STATS_LE32(general, bogus_cts);
  610. PRINT_STATS_LE32(general, bogus_ack);
  611. PRINT_STATS_LE32(general, non_bssid_frames);
  612. PRINT_STATS_LE32(general, filtered_frames);
  613. PRINT_STATS_LE32(general, non_channel_beacons);
  614. PRINT_STATS_LE32(general, channel_beacons);
  615. PRINT_STATS_LE32(general, num_missed_bcon);
  616. PRINT_STATS_LE32(general, adc_rx_saturation_time);
  617. PRINT_STATS_LE32(general, ina_detection_search_time);
  618. PRINT_STATS_LE32(general, beacon_silence_rssi_a);
  619. PRINT_STATS_LE32(general, beacon_silence_rssi_b);
  620. PRINT_STATS_LE32(general, beacon_silence_rssi_c);
  621. PRINT_STATS_LE32(general, interference_data_flag);
  622. PRINT_STATS_LE32(general, channel_load);
  623. PRINT_STATS_LE32(general, dsp_false_alarms);
  624. PRINT_STATS_LE32(general, beacon_rssi_a);
  625. PRINT_STATS_LE32(general, beacon_rssi_b);
  626. PRINT_STATS_LE32(general, beacon_rssi_c);
  627. PRINT_STATS_LE32(general, beacon_energy_a);
  628. PRINT_STATS_LE32(general, beacon_energy_b);
  629. PRINT_STATS_LE32(general, beacon_energy_c);
  630. PRINT_STATS_LE32(general, num_bt_kills);
  631. PRINT_STATS_LE32(general, mac_id);
  632. PRINT_STATS_LE32(general, directed_data_mpdu);
  633. pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
  634. "Statistics_Rx - HT");
  635. PRINT_STATS_LE32(ht, plcp_err);
  636. PRINT_STATS_LE32(ht, overrun_err);
  637. PRINT_STATS_LE32(ht, early_overrun_err);
  638. PRINT_STATS_LE32(ht, crc32_good);
  639. PRINT_STATS_LE32(ht, crc32_err);
  640. PRINT_STATS_LE32(ht, mh_format_err);
  641. PRINT_STATS_LE32(ht, agg_crc32_good);
  642. PRINT_STATS_LE32(ht, agg_mpdu_cnt);
  643. PRINT_STATS_LE32(ht, agg_cnt);
  644. PRINT_STATS_LE32(ht, unsupport_mcs);
  645. mutex_unlock(&mvm->mutex);
  646. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  647. kfree(buf);
  648. return ret;
  649. }
  650. #undef PRINT_STAT_LE32
  651. static ssize_t iwl_dbgfs_frame_stats_read(struct iwl_mvm *mvm,
  652. char __user *user_buf, size_t count,
  653. loff_t *ppos,
  654. struct iwl_mvm_frame_stats *stats)
  655. {
  656. char *buff, *pos, *endpos;
  657. int idx, i;
  658. int ret;
  659. static const size_t bufsz = 1024;
  660. buff = kmalloc(bufsz, GFP_KERNEL);
  661. if (!buff)
  662. return -ENOMEM;
  663. spin_lock_bh(&mvm->drv_stats_lock);
  664. pos = buff;
  665. endpos = pos + bufsz;
  666. pos += scnprintf(pos, endpos - pos,
  667. "Legacy/HT/VHT\t:\t%d/%d/%d\n",
  668. stats->legacy_frames,
  669. stats->ht_frames,
  670. stats->vht_frames);
  671. pos += scnprintf(pos, endpos - pos, "20/40/80\t:\t%d/%d/%d\n",
  672. stats->bw_20_frames,
  673. stats->bw_40_frames,
  674. stats->bw_80_frames);
  675. pos += scnprintf(pos, endpos - pos, "NGI/SGI\t\t:\t%d/%d\n",
  676. stats->ngi_frames,
  677. stats->sgi_frames);
  678. pos += scnprintf(pos, endpos - pos, "SISO/MIMO2\t:\t%d/%d\n",
  679. stats->siso_frames,
  680. stats->mimo2_frames);
  681. pos += scnprintf(pos, endpos - pos, "FAIL/SCSS\t:\t%d/%d\n",
  682. stats->fail_frames,
  683. stats->success_frames);
  684. pos += scnprintf(pos, endpos - pos, "MPDUs agg\t:\t%d\n",
  685. stats->agg_frames);
  686. pos += scnprintf(pos, endpos - pos, "A-MPDUs\t\t:\t%d\n",
  687. stats->ampdu_count);
  688. pos += scnprintf(pos, endpos - pos, "Avg MPDUs/A-MPDU:\t%d\n",
  689. stats->ampdu_count > 0 ?
  690. (stats->agg_frames / stats->ampdu_count) : 0);
  691. pos += scnprintf(pos, endpos - pos, "Last Rates\n");
  692. idx = stats->last_frame_idx - 1;
  693. for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) {
  694. idx = (idx + 1) % ARRAY_SIZE(stats->last_rates);
  695. if (stats->last_rates[idx] == 0)
  696. continue;
  697. pos += scnprintf(pos, endpos - pos, "Rate[%d]: ",
  698. (int)(ARRAY_SIZE(stats->last_rates) - i));
  699. pos += rs_pretty_print_rate(pos, stats->last_rates[idx]);
  700. }
  701. spin_unlock_bh(&mvm->drv_stats_lock);
  702. ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
  703. kfree(buff);
  704. return ret;
  705. }
  706. static ssize_t iwl_dbgfs_drv_rx_stats_read(struct file *file,
  707. char __user *user_buf, size_t count,
  708. loff_t *ppos)
  709. {
  710. struct iwl_mvm *mvm = file->private_data;
  711. return iwl_dbgfs_frame_stats_read(mvm, user_buf, count, ppos,
  712. &mvm->drv_rx_stats);
  713. }
  714. static ssize_t iwl_dbgfs_fw_restart_write(struct iwl_mvm *mvm, char *buf,
  715. size_t count, loff_t *ppos)
  716. {
  717. int ret;
  718. mutex_lock(&mvm->mutex);
  719. /* allow one more restart that we're provoking here */
  720. if (mvm->restart_fw >= 0)
  721. mvm->restart_fw++;
  722. /* take the return value to make compiler happy - it will fail anyway */
  723. ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_ERROR, 0, 0, NULL);
  724. mutex_unlock(&mvm->mutex);
  725. return count;
  726. }
  727. static ssize_t iwl_dbgfs_fw_nmi_write(struct iwl_mvm *mvm, char *buf,
  728. size_t count, loff_t *ppos)
  729. {
  730. int ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_NMI);
  731. if (ret)
  732. return ret;
  733. iwl_force_nmi(mvm->trans);
  734. iwl_mvm_unref(mvm, IWL_MVM_REF_NMI);
  735. return count;
  736. }
  737. static ssize_t
  738. iwl_dbgfs_scan_ant_rxchain_read(struct file *file,
  739. char __user *user_buf,
  740. size_t count, loff_t *ppos)
  741. {
  742. struct iwl_mvm *mvm = file->private_data;
  743. int pos = 0;
  744. char buf[32];
  745. const size_t bufsz = sizeof(buf);
  746. /* print which antennas were set for the scan command by the user */
  747. pos += scnprintf(buf + pos, bufsz - pos, "Antennas for scan: ");
  748. if (mvm->scan_rx_ant & ANT_A)
  749. pos += scnprintf(buf + pos, bufsz - pos, "A");
  750. if (mvm->scan_rx_ant & ANT_B)
  751. pos += scnprintf(buf + pos, bufsz - pos, "B");
  752. if (mvm->scan_rx_ant & ANT_C)
  753. pos += scnprintf(buf + pos, bufsz - pos, "C");
  754. pos += scnprintf(buf + pos, bufsz - pos, " (%hhx)\n", mvm->scan_rx_ant);
  755. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  756. }
  757. static ssize_t
  758. iwl_dbgfs_scan_ant_rxchain_write(struct iwl_mvm *mvm, char *buf,
  759. size_t count, loff_t *ppos)
  760. {
  761. u8 scan_rx_ant;
  762. if (sscanf(buf, "%hhx", &scan_rx_ant) != 1)
  763. return -EINVAL;
  764. if (scan_rx_ant > ANT_ABC)
  765. return -EINVAL;
  766. if (scan_rx_ant & ~(iwl_mvm_get_valid_rx_ant(mvm)))
  767. return -EINVAL;
  768. if (mvm->scan_rx_ant != scan_rx_ant) {
  769. mvm->scan_rx_ant = scan_rx_ant;
  770. if (fw_has_capa(&mvm->fw->ucode_capa,
  771. IWL_UCODE_TLV_CAPA_UMAC_SCAN))
  772. iwl_mvm_config_scan(mvm);
  773. }
  774. return count;
  775. }
  776. static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file,
  777. char __user *user_buf,
  778. size_t count, loff_t *ppos)
  779. {
  780. struct iwl_mvm *mvm = file->private_data;
  781. int conf;
  782. char buf[8];
  783. const size_t bufsz = sizeof(buf);
  784. int pos = 0;
  785. mutex_lock(&mvm->mutex);
  786. conf = mvm->fw_dbg_conf;
  787. mutex_unlock(&mvm->mutex);
  788. pos += scnprintf(buf + pos, bufsz - pos, "%d\n", conf);
  789. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  790. }
  791. static ssize_t iwl_dbgfs_fw_dbg_conf_write(struct iwl_mvm *mvm,
  792. char *buf, size_t count,
  793. loff_t *ppos)
  794. {
  795. unsigned int conf_id;
  796. int ret;
  797. ret = kstrtouint(buf, 0, &conf_id);
  798. if (ret)
  799. return ret;
  800. if (WARN_ON(conf_id >= FW_DBG_CONF_MAX))
  801. return -EINVAL;
  802. mutex_lock(&mvm->mutex);
  803. ret = iwl_mvm_start_fw_dbg_conf(mvm, conf_id);
  804. mutex_unlock(&mvm->mutex);
  805. return ret ?: count;
  806. }
  807. static ssize_t iwl_dbgfs_fw_dbg_collect_write(struct iwl_mvm *mvm,
  808. char *buf, size_t count,
  809. loff_t *ppos)
  810. {
  811. int ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE);
  812. if (ret)
  813. return ret;
  814. iwl_mvm_fw_dbg_collect(mvm, FW_DBG_TRIGGER_USER, NULL, 0, NULL);
  815. iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE);
  816. return count;
  817. }
  818. #define ADD_TEXT(...) pos += scnprintf(buf + pos, bufsz - pos, __VA_ARGS__)
  819. #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
  820. static ssize_t iwl_dbgfs_bcast_filters_read(struct file *file,
  821. char __user *user_buf,
  822. size_t count, loff_t *ppos)
  823. {
  824. struct iwl_mvm *mvm = file->private_data;
  825. struct iwl_bcast_filter_cmd cmd;
  826. const struct iwl_fw_bcast_filter *filter;
  827. char *buf;
  828. int bufsz = 1024;
  829. int i, j, pos = 0;
  830. ssize_t ret;
  831. buf = kzalloc(bufsz, GFP_KERNEL);
  832. if (!buf)
  833. return -ENOMEM;
  834. mutex_lock(&mvm->mutex);
  835. if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) {
  836. ADD_TEXT("None\n");
  837. mutex_unlock(&mvm->mutex);
  838. goto out;
  839. }
  840. mutex_unlock(&mvm->mutex);
  841. for (i = 0; cmd.filters[i].attrs[0].mask; i++) {
  842. filter = &cmd.filters[i];
  843. ADD_TEXT("Filter [%d]:\n", i);
  844. ADD_TEXT("\tDiscard=%d\n", filter->discard);
  845. ADD_TEXT("\tFrame Type: %s\n",
  846. filter->frame_type ? "IPv4" : "Generic");
  847. for (j = 0; j < ARRAY_SIZE(filter->attrs); j++) {
  848. const struct iwl_fw_bcast_filter_attr *attr;
  849. attr = &filter->attrs[j];
  850. if (!attr->mask)
  851. break;
  852. ADD_TEXT("\tAttr [%d]: offset=%d (from %s), mask=0x%x, value=0x%x reserved=0x%x\n",
  853. j, attr->offset,
  854. attr->offset_type ? "IP End" :
  855. "Payload Start",
  856. be32_to_cpu(attr->mask),
  857. be32_to_cpu(attr->val),
  858. le16_to_cpu(attr->reserved1));
  859. }
  860. }
  861. out:
  862. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  863. kfree(buf);
  864. return ret;
  865. }
  866. static ssize_t iwl_dbgfs_bcast_filters_write(struct iwl_mvm *mvm, char *buf,
  867. size_t count, loff_t *ppos)
  868. {
  869. int pos, next_pos;
  870. struct iwl_fw_bcast_filter filter = {};
  871. struct iwl_bcast_filter_cmd cmd;
  872. u32 filter_id, attr_id, mask, value;
  873. int err = 0;
  874. if (sscanf(buf, "%d %hhi %hhi %n", &filter_id, &filter.discard,
  875. &filter.frame_type, &pos) != 3)
  876. return -EINVAL;
  877. if (filter_id >= ARRAY_SIZE(mvm->dbgfs_bcast_filtering.cmd.filters) ||
  878. filter.frame_type > BCAST_FILTER_FRAME_TYPE_IPV4)
  879. return -EINVAL;
  880. for (attr_id = 0; attr_id < ARRAY_SIZE(filter.attrs);
  881. attr_id++) {
  882. struct iwl_fw_bcast_filter_attr *attr =
  883. &filter.attrs[attr_id];
  884. if (pos >= count)
  885. break;
  886. if (sscanf(&buf[pos], "%hhi %hhi %i %i %n",
  887. &attr->offset, &attr->offset_type,
  888. &mask, &value, &next_pos) != 4)
  889. return -EINVAL;
  890. attr->mask = cpu_to_be32(mask);
  891. attr->val = cpu_to_be32(value);
  892. if (mask)
  893. filter.num_attrs++;
  894. pos += next_pos;
  895. }
  896. mutex_lock(&mvm->mutex);
  897. memcpy(&mvm->dbgfs_bcast_filtering.cmd.filters[filter_id],
  898. &filter, sizeof(filter));
  899. /* send updated bcast filtering configuration */
  900. if (mvm->dbgfs_bcast_filtering.override &&
  901. iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
  902. err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
  903. sizeof(cmd), &cmd);
  904. mutex_unlock(&mvm->mutex);
  905. return err ?: count;
  906. }
  907. static ssize_t iwl_dbgfs_bcast_filters_macs_read(struct file *file,
  908. char __user *user_buf,
  909. size_t count, loff_t *ppos)
  910. {
  911. struct iwl_mvm *mvm = file->private_data;
  912. struct iwl_bcast_filter_cmd cmd;
  913. char *buf;
  914. int bufsz = 1024;
  915. int i, pos = 0;
  916. ssize_t ret;
  917. buf = kzalloc(bufsz, GFP_KERNEL);
  918. if (!buf)
  919. return -ENOMEM;
  920. mutex_lock(&mvm->mutex);
  921. if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) {
  922. ADD_TEXT("None\n");
  923. mutex_unlock(&mvm->mutex);
  924. goto out;
  925. }
  926. mutex_unlock(&mvm->mutex);
  927. for (i = 0; i < ARRAY_SIZE(cmd.macs); i++) {
  928. const struct iwl_fw_bcast_mac *mac = &cmd.macs[i];
  929. ADD_TEXT("Mac [%d]: discard=%d attached_filters=0x%x\n",
  930. i, mac->default_discard, mac->attached_filters);
  931. }
  932. out:
  933. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  934. kfree(buf);
  935. return ret;
  936. }
  937. static ssize_t iwl_dbgfs_bcast_filters_macs_write(struct iwl_mvm *mvm,
  938. char *buf, size_t count,
  939. loff_t *ppos)
  940. {
  941. struct iwl_bcast_filter_cmd cmd;
  942. struct iwl_fw_bcast_mac mac = {};
  943. u32 mac_id, attached_filters;
  944. int err = 0;
  945. if (!mvm->bcast_filters)
  946. return -ENOENT;
  947. if (sscanf(buf, "%d %hhi %i", &mac_id, &mac.default_discard,
  948. &attached_filters) != 3)
  949. return -EINVAL;
  950. if (mac_id >= ARRAY_SIZE(cmd.macs) ||
  951. mac.default_discard > 1 ||
  952. attached_filters >= BIT(ARRAY_SIZE(cmd.filters)))
  953. return -EINVAL;
  954. mac.attached_filters = cpu_to_le16(attached_filters);
  955. mutex_lock(&mvm->mutex);
  956. memcpy(&mvm->dbgfs_bcast_filtering.cmd.macs[mac_id],
  957. &mac, sizeof(mac));
  958. /* send updated bcast filtering configuration */
  959. if (mvm->dbgfs_bcast_filtering.override &&
  960. iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
  961. err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
  962. sizeof(cmd), &cmd);
  963. mutex_unlock(&mvm->mutex);
  964. return err ?: count;
  965. }
  966. #endif
  967. #ifdef CONFIG_PM_SLEEP
  968. static ssize_t iwl_dbgfs_d3_sram_write(struct iwl_mvm *mvm, char *buf,
  969. size_t count, loff_t *ppos)
  970. {
  971. int store;
  972. if (sscanf(buf, "%d", &store) != 1)
  973. return -EINVAL;
  974. mvm->store_d3_resume_sram = store;
  975. return count;
  976. }
  977. static ssize_t iwl_dbgfs_d3_sram_read(struct file *file, char __user *user_buf,
  978. size_t count, loff_t *ppos)
  979. {
  980. struct iwl_mvm *mvm = file->private_data;
  981. const struct fw_img *img;
  982. int ofs, len, pos = 0;
  983. size_t bufsz, ret;
  984. char *buf;
  985. u8 *ptr = mvm->d3_resume_sram;
  986. img = &mvm->fw->img[IWL_UCODE_WOWLAN];
  987. len = img->sec[IWL_UCODE_SECTION_DATA].len;
  988. bufsz = len * 4 + 256;
  989. buf = kzalloc(bufsz, GFP_KERNEL);
  990. if (!buf)
  991. return -ENOMEM;
  992. pos += scnprintf(buf, bufsz, "D3 SRAM capture: %sabled\n",
  993. mvm->store_d3_resume_sram ? "en" : "dis");
  994. if (ptr) {
  995. for (ofs = 0; ofs < len; ofs += 16) {
  996. pos += scnprintf(buf + pos, bufsz - pos,
  997. "0x%.4x %16ph\n", ofs, ptr + ofs);
  998. }
  999. } else {
  1000. pos += scnprintf(buf + pos, bufsz - pos,
  1001. "(no data captured)\n");
  1002. }
  1003. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1004. kfree(buf);
  1005. return ret;
  1006. }
  1007. #endif
  1008. #define PRINT_MVM_REF(ref) do { \
  1009. if (mvm->refs[ref]) \
  1010. pos += scnprintf(buf + pos, bufsz - pos, \
  1011. "\t(0x%lx): %d %s\n", \
  1012. BIT(ref), mvm->refs[ref], #ref); \
  1013. } while (0)
  1014. static ssize_t iwl_dbgfs_d0i3_refs_read(struct file *file,
  1015. char __user *user_buf,
  1016. size_t count, loff_t *ppos)
  1017. {
  1018. struct iwl_mvm *mvm = file->private_data;
  1019. int i, pos = 0;
  1020. char buf[256];
  1021. const size_t bufsz = sizeof(buf);
  1022. u32 refs = 0;
  1023. for (i = 0; i < IWL_MVM_REF_COUNT; i++)
  1024. if (mvm->refs[i])
  1025. refs |= BIT(i);
  1026. pos += scnprintf(buf + pos, bufsz - pos, "taken mvm refs: 0x%x\n",
  1027. refs);
  1028. PRINT_MVM_REF(IWL_MVM_REF_UCODE_DOWN);
  1029. PRINT_MVM_REF(IWL_MVM_REF_SCAN);
  1030. PRINT_MVM_REF(IWL_MVM_REF_ROC);
  1031. PRINT_MVM_REF(IWL_MVM_REF_ROC_AUX);
  1032. PRINT_MVM_REF(IWL_MVM_REF_P2P_CLIENT);
  1033. PRINT_MVM_REF(IWL_MVM_REF_AP_IBSS);
  1034. PRINT_MVM_REF(IWL_MVM_REF_USER);
  1035. PRINT_MVM_REF(IWL_MVM_REF_TX);
  1036. PRINT_MVM_REF(IWL_MVM_REF_TX_AGG);
  1037. PRINT_MVM_REF(IWL_MVM_REF_ADD_IF);
  1038. PRINT_MVM_REF(IWL_MVM_REF_START_AP);
  1039. PRINT_MVM_REF(IWL_MVM_REF_BSS_CHANGED);
  1040. PRINT_MVM_REF(IWL_MVM_REF_PREPARE_TX);
  1041. PRINT_MVM_REF(IWL_MVM_REF_PROTECT_TDLS);
  1042. PRINT_MVM_REF(IWL_MVM_REF_CHECK_CTKILL);
  1043. PRINT_MVM_REF(IWL_MVM_REF_PRPH_READ);
  1044. PRINT_MVM_REF(IWL_MVM_REF_PRPH_WRITE);
  1045. PRINT_MVM_REF(IWL_MVM_REF_NMI);
  1046. PRINT_MVM_REF(IWL_MVM_REF_TM_CMD);
  1047. PRINT_MVM_REF(IWL_MVM_REF_EXIT_WORK);
  1048. PRINT_MVM_REF(IWL_MVM_REF_PROTECT_CSA);
  1049. PRINT_MVM_REF(IWL_MVM_REF_FW_DBG_COLLECT);
  1050. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1051. }
  1052. static ssize_t iwl_dbgfs_d0i3_refs_write(struct iwl_mvm *mvm, char *buf,
  1053. size_t count, loff_t *ppos)
  1054. {
  1055. unsigned long value;
  1056. int ret;
  1057. bool taken;
  1058. ret = kstrtoul(buf, 10, &value);
  1059. if (ret < 0)
  1060. return ret;
  1061. mutex_lock(&mvm->mutex);
  1062. taken = mvm->refs[IWL_MVM_REF_USER];
  1063. if (value == 1 && !taken)
  1064. iwl_mvm_ref(mvm, IWL_MVM_REF_USER);
  1065. else if (value == 0 && taken)
  1066. iwl_mvm_unref(mvm, IWL_MVM_REF_USER);
  1067. else
  1068. ret = -EINVAL;
  1069. mutex_unlock(&mvm->mutex);
  1070. if (ret < 0)
  1071. return ret;
  1072. return count;
  1073. }
  1074. #define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \
  1075. _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
  1076. #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz) \
  1077. _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
  1078. #define MVM_DEBUGFS_ADD_FILE_ALIAS(alias, name, parent, mode) do { \
  1079. if (!debugfs_create_file(alias, mode, parent, mvm, \
  1080. &iwl_dbgfs_##name##_ops)) \
  1081. goto err; \
  1082. } while (0)
  1083. #define MVM_DEBUGFS_ADD_FILE(name, parent, mode) \
  1084. MVM_DEBUGFS_ADD_FILE_ALIAS(#name, name, parent, mode)
  1085. static ssize_t
  1086. iwl_dbgfs_prph_reg_read(struct file *file,
  1087. char __user *user_buf,
  1088. size_t count, loff_t *ppos)
  1089. {
  1090. struct iwl_mvm *mvm = file->private_data;
  1091. int pos = 0;
  1092. char buf[32];
  1093. const size_t bufsz = sizeof(buf);
  1094. int ret;
  1095. if (!mvm->dbgfs_prph_reg_addr)
  1096. return -EINVAL;
  1097. ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_READ);
  1098. if (ret)
  1099. return ret;
  1100. pos += scnprintf(buf + pos, bufsz - pos, "Reg 0x%x: (0x%x)\n",
  1101. mvm->dbgfs_prph_reg_addr,
  1102. iwl_read_prph(mvm->trans, mvm->dbgfs_prph_reg_addr));
  1103. iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_READ);
  1104. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1105. }
  1106. static ssize_t
  1107. iwl_dbgfs_prph_reg_write(struct iwl_mvm *mvm, char *buf,
  1108. size_t count, loff_t *ppos)
  1109. {
  1110. u8 args;
  1111. u32 value;
  1112. int ret;
  1113. args = sscanf(buf, "%i %i", &mvm->dbgfs_prph_reg_addr, &value);
  1114. /* if we only want to set the reg address - nothing more to do */
  1115. if (args == 1)
  1116. goto out;
  1117. /* otherwise, make sure we have both address and value */
  1118. if (args != 2)
  1119. return -EINVAL;
  1120. ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE);
  1121. if (ret)
  1122. return ret;
  1123. iwl_write_prph(mvm->trans, mvm->dbgfs_prph_reg_addr, value);
  1124. iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE);
  1125. out:
  1126. return count;
  1127. }
  1128. static ssize_t
  1129. iwl_dbgfs_send_echo_cmd_write(struct iwl_mvm *mvm, char *buf,
  1130. size_t count, loff_t *ppos)
  1131. {
  1132. int ret;
  1133. mutex_lock(&mvm->mutex);
  1134. ret = iwl_mvm_send_cmd_pdu(mvm, ECHO_CMD, 0, 0, NULL);
  1135. mutex_unlock(&mvm->mutex);
  1136. return ret ?: count;
  1137. }
  1138. MVM_DEBUGFS_READ_WRITE_FILE_OPS(prph_reg, 64);
  1139. /* Device wide debugfs entries */
  1140. MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush, 16);
  1141. MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain, 8);
  1142. MVM_DEBUGFS_WRITE_FILE_OPS(send_echo_cmd, 8);
  1143. MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram, 64);
  1144. MVM_DEBUGFS_READ_WRITE_FILE_OPS(set_nic_temperature, 64);
  1145. MVM_DEBUGFS_READ_FILE_OPS(nic_temp);
  1146. MVM_DEBUGFS_READ_FILE_OPS(stations);
  1147. MVM_DEBUGFS_READ_FILE_OPS(bt_notif);
  1148. MVM_DEBUGFS_READ_FILE_OPS(bt_cmd);
  1149. MVM_DEBUGFS_READ_WRITE_FILE_OPS(disable_power_off, 64);
  1150. MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats);
  1151. MVM_DEBUGFS_READ_FILE_OPS(drv_rx_stats);
  1152. MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart, 10);
  1153. MVM_DEBUGFS_WRITE_FILE_OPS(fw_nmi, 10);
  1154. MVM_DEBUGFS_WRITE_FILE_OPS(bt_tx_prio, 10);
  1155. MVM_DEBUGFS_WRITE_FILE_OPS(bt_force_ant, 10);
  1156. MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain, 8);
  1157. MVM_DEBUGFS_READ_WRITE_FILE_OPS(d0i3_refs, 8);
  1158. MVM_DEBUGFS_READ_WRITE_FILE_OPS(fw_dbg_conf, 8);
  1159. MVM_DEBUGFS_WRITE_FILE_OPS(fw_dbg_collect, 8);
  1160. #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
  1161. MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256);
  1162. MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters_macs, 256);
  1163. #endif
  1164. #ifdef CONFIG_PM_SLEEP
  1165. MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram, 8);
  1166. #endif
  1167. int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
  1168. {
  1169. struct dentry *bcast_dir __maybe_unused;
  1170. char buf[100];
  1171. spin_lock_init(&mvm->drv_stats_lock);
  1172. mvm->debugfs_dir = dbgfs_dir;
  1173. MVM_DEBUGFS_ADD_FILE(tx_flush, mvm->debugfs_dir, S_IWUSR);
  1174. MVM_DEBUGFS_ADD_FILE(sta_drain, mvm->debugfs_dir, S_IWUSR);
  1175. MVM_DEBUGFS_ADD_FILE(sram, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
  1176. MVM_DEBUGFS_ADD_FILE(set_nic_temperature, mvm->debugfs_dir,
  1177. S_IWUSR | S_IRUSR);
  1178. MVM_DEBUGFS_ADD_FILE(nic_temp, dbgfs_dir, S_IRUSR);
  1179. MVM_DEBUGFS_ADD_FILE(stations, dbgfs_dir, S_IRUSR);
  1180. MVM_DEBUGFS_ADD_FILE(bt_notif, dbgfs_dir, S_IRUSR);
  1181. MVM_DEBUGFS_ADD_FILE(bt_cmd, dbgfs_dir, S_IRUSR);
  1182. MVM_DEBUGFS_ADD_FILE(disable_power_off, mvm->debugfs_dir,
  1183. S_IRUSR | S_IWUSR);
  1184. MVM_DEBUGFS_ADD_FILE(fw_rx_stats, mvm->debugfs_dir, S_IRUSR);
  1185. MVM_DEBUGFS_ADD_FILE(drv_rx_stats, mvm->debugfs_dir, S_IRUSR);
  1186. MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, S_IWUSR);
  1187. MVM_DEBUGFS_ADD_FILE(fw_nmi, mvm->debugfs_dir, S_IWUSR);
  1188. MVM_DEBUGFS_ADD_FILE(bt_tx_prio, mvm->debugfs_dir, S_IWUSR);
  1189. MVM_DEBUGFS_ADD_FILE(bt_force_ant, mvm->debugfs_dir, S_IWUSR);
  1190. MVM_DEBUGFS_ADD_FILE(scan_ant_rxchain, mvm->debugfs_dir,
  1191. S_IWUSR | S_IRUSR);
  1192. MVM_DEBUGFS_ADD_FILE(prph_reg, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
  1193. MVM_DEBUGFS_ADD_FILE(d0i3_refs, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
  1194. MVM_DEBUGFS_ADD_FILE(fw_dbg_conf, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
  1195. MVM_DEBUGFS_ADD_FILE(fw_dbg_collect, mvm->debugfs_dir, S_IWUSR);
  1196. MVM_DEBUGFS_ADD_FILE(send_echo_cmd, mvm->debugfs_dir, S_IWUSR);
  1197. if (!debugfs_create_bool("enable_scan_iteration_notif",
  1198. S_IRUSR | S_IWUSR,
  1199. mvm->debugfs_dir,
  1200. &mvm->scan_iter_notif_enabled))
  1201. goto err;
  1202. #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
  1203. if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING) {
  1204. bcast_dir = debugfs_create_dir("bcast_filtering",
  1205. mvm->debugfs_dir);
  1206. if (!bcast_dir)
  1207. goto err;
  1208. if (!debugfs_create_bool("override", S_IRUSR | S_IWUSR,
  1209. bcast_dir,
  1210. &mvm->dbgfs_bcast_filtering.override))
  1211. goto err;
  1212. MVM_DEBUGFS_ADD_FILE_ALIAS("filters", bcast_filters,
  1213. bcast_dir, S_IWUSR | S_IRUSR);
  1214. MVM_DEBUGFS_ADD_FILE_ALIAS("macs", bcast_filters_macs,
  1215. bcast_dir, S_IWUSR | S_IRUSR);
  1216. }
  1217. #endif
  1218. #ifdef CONFIG_PM_SLEEP
  1219. MVM_DEBUGFS_ADD_FILE(d3_sram, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
  1220. MVM_DEBUGFS_ADD_FILE(d3_test, mvm->debugfs_dir, S_IRUSR);
  1221. if (!debugfs_create_bool("d3_wake_sysassert", S_IRUSR | S_IWUSR,
  1222. mvm->debugfs_dir, &mvm->d3_wake_sysassert))
  1223. goto err;
  1224. if (!debugfs_create_u32("last_netdetect_scans", S_IRUSR,
  1225. mvm->debugfs_dir, &mvm->last_netdetect_scans))
  1226. goto err;
  1227. #endif
  1228. if (!debugfs_create_u8("low_latency_agg_frame_limit", S_IRUSR | S_IWUSR,
  1229. mvm->debugfs_dir,
  1230. &mvm->low_latency_agg_frame_limit))
  1231. goto err;
  1232. if (!debugfs_create_u8("ps_disabled", S_IRUSR,
  1233. mvm->debugfs_dir, &mvm->ps_disabled))
  1234. goto err;
  1235. if (!debugfs_create_blob("nvm_hw", S_IRUSR,
  1236. mvm->debugfs_dir, &mvm->nvm_hw_blob))
  1237. goto err;
  1238. if (!debugfs_create_blob("nvm_sw", S_IRUSR,
  1239. mvm->debugfs_dir, &mvm->nvm_sw_blob))
  1240. goto err;
  1241. if (!debugfs_create_blob("nvm_calib", S_IRUSR,
  1242. mvm->debugfs_dir, &mvm->nvm_calib_blob))
  1243. goto err;
  1244. if (!debugfs_create_blob("nvm_prod", S_IRUSR,
  1245. mvm->debugfs_dir, &mvm->nvm_prod_blob))
  1246. goto err;
  1247. if (!debugfs_create_blob("nvm_phy_sku", S_IRUSR,
  1248. mvm->debugfs_dir, &mvm->nvm_phy_sku_blob))
  1249. goto err;
  1250. /*
  1251. * Create a symlink with mac80211. It will be removed when mac80211
  1252. * exists (before the opmode exists which removes the target.)
  1253. */
  1254. snprintf(buf, 100, "../../%s/%s",
  1255. dbgfs_dir->d_parent->d_parent->d_name.name,
  1256. dbgfs_dir->d_parent->d_name.name);
  1257. if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf))
  1258. goto err;
  1259. return 0;
  1260. err:
  1261. IWL_ERR(mvm, "Can't create the mvm debugfs directory\n");
  1262. return -ENOMEM;
  1263. }