debugfs.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048
  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 - 2013 Intel Corporation. All rights reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of version 2 of the GNU General Public License as
  12. * published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  22. * USA
  23. *
  24. * The full GNU General Public License is included in this distribution
  25. * in the file called COPYING.
  26. *
  27. * Contact Information:
  28. * Intel Linux Wireless <ilw@linux.intel.com>
  29. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  30. *
  31. * BSD LICENSE
  32. *
  33. * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
  34. * All rights reserved.
  35. *
  36. * Redistribution and use in source and binary forms, with or without
  37. * modification, are permitted provided that the following conditions
  38. * are met:
  39. *
  40. * * Redistributions of source code must retain the above copyright
  41. * notice, this list of conditions and the following disclaimer.
  42. * * Redistributions in binary form must reproduce the above copyright
  43. * notice, this list of conditions and the following disclaimer in
  44. * the documentation and/or other materials provided with the
  45. * distribution.
  46. * * Neither the name Intel Corporation nor the names of its
  47. * contributors may be used to endorse or promote products derived
  48. * from this software without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  51. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  52. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  53. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  54. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  55. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  56. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  57. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  58. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  59. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  60. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  61. *
  62. *****************************************************************************/
  63. #include "mvm.h"
  64. #include "sta.h"
  65. #include "iwl-io.h"
  66. struct iwl_dbgfs_mvm_ctx {
  67. struct iwl_mvm *mvm;
  68. struct ieee80211_vif *vif;
  69. };
  70. static ssize_t iwl_dbgfs_tx_flush_write(struct file *file,
  71. const char __user *user_buf,
  72. size_t count, loff_t *ppos)
  73. {
  74. struct iwl_mvm *mvm = file->private_data;
  75. char buf[16];
  76. int buf_size, ret;
  77. u32 scd_q_msk;
  78. if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
  79. return -EIO;
  80. memset(buf, 0, sizeof(buf));
  81. buf_size = min(count, sizeof(buf) - 1);
  82. if (copy_from_user(buf, user_buf, buf_size))
  83. return -EFAULT;
  84. if (sscanf(buf, "%x", &scd_q_msk) != 1)
  85. return -EINVAL;
  86. IWL_ERR(mvm, "FLUSHING queues: scd_q_msk = 0x%x\n", scd_q_msk);
  87. mutex_lock(&mvm->mutex);
  88. ret = iwl_mvm_flush_tx_path(mvm, scd_q_msk, true) ? : count;
  89. mutex_unlock(&mvm->mutex);
  90. return ret;
  91. }
  92. static ssize_t iwl_dbgfs_sta_drain_write(struct file *file,
  93. const char __user *user_buf,
  94. size_t count, loff_t *ppos)
  95. {
  96. struct iwl_mvm *mvm = file->private_data;
  97. struct ieee80211_sta *sta;
  98. char buf[8];
  99. int buf_size, sta_id, drain, ret;
  100. if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
  101. return -EIO;
  102. memset(buf, 0, sizeof(buf));
  103. buf_size = min(count, sizeof(buf) - 1);
  104. if (copy_from_user(buf, user_buf, buf_size))
  105. return -EFAULT;
  106. if (sscanf(buf, "%d %d", &sta_id, &drain) != 2)
  107. return -EINVAL;
  108. mutex_lock(&mvm->mutex);
  109. sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
  110. lockdep_is_held(&mvm->mutex));
  111. if (IS_ERR_OR_NULL(sta))
  112. ret = -ENOENT;
  113. else
  114. ret = iwl_mvm_drain_sta(mvm, (void *)sta->drv_priv, drain) ? :
  115. count;
  116. mutex_unlock(&mvm->mutex);
  117. return ret;
  118. }
  119. static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
  120. size_t count, loff_t *ppos)
  121. {
  122. struct iwl_mvm *mvm = file->private_data;
  123. const struct fw_img *img;
  124. int ofs, len, pos = 0;
  125. size_t bufsz, ret;
  126. char *buf;
  127. u8 *ptr;
  128. if (!mvm->ucode_loaded)
  129. return -EINVAL;
  130. /* default is to dump the entire data segment */
  131. if (!mvm->dbgfs_sram_offset && !mvm->dbgfs_sram_len) {
  132. img = &mvm->fw->img[mvm->cur_ucode];
  133. ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
  134. len = img->sec[IWL_UCODE_SECTION_DATA].len;
  135. } else {
  136. ofs = mvm->dbgfs_sram_offset;
  137. len = mvm->dbgfs_sram_len;
  138. }
  139. bufsz = len * 4 + 256;
  140. buf = kzalloc(bufsz, GFP_KERNEL);
  141. if (!buf)
  142. return -ENOMEM;
  143. ptr = kzalloc(len, GFP_KERNEL);
  144. if (!ptr) {
  145. kfree(buf);
  146. return -ENOMEM;
  147. }
  148. pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", len);
  149. pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", ofs);
  150. iwl_trans_read_mem_bytes(mvm->trans, ofs, ptr, len);
  151. for (ofs = 0; ofs < len; ofs += 16) {
  152. pos += scnprintf(buf + pos, bufsz - pos, "0x%.4x ", ofs);
  153. hex_dump_to_buffer(ptr + ofs, 16, 16, 1, buf + pos,
  154. bufsz - pos, false);
  155. pos += strlen(buf + pos);
  156. if (bufsz - pos > 0)
  157. buf[pos++] = '\n';
  158. }
  159. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  160. kfree(buf);
  161. kfree(ptr);
  162. return ret;
  163. }
  164. static ssize_t iwl_dbgfs_sram_write(struct file *file,
  165. const char __user *user_buf, size_t count,
  166. loff_t *ppos)
  167. {
  168. struct iwl_mvm *mvm = file->private_data;
  169. char buf[64];
  170. int buf_size;
  171. u32 offset, len;
  172. memset(buf, 0, sizeof(buf));
  173. buf_size = min(count, sizeof(buf) - 1);
  174. if (copy_from_user(buf, user_buf, buf_size))
  175. return -EFAULT;
  176. if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
  177. if ((offset & 0x3) || (len & 0x3))
  178. return -EINVAL;
  179. mvm->dbgfs_sram_offset = offset;
  180. mvm->dbgfs_sram_len = len;
  181. } else {
  182. mvm->dbgfs_sram_offset = 0;
  183. mvm->dbgfs_sram_len = 0;
  184. }
  185. return count;
  186. }
  187. static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
  188. size_t count, loff_t *ppos)
  189. {
  190. struct iwl_mvm *mvm = file->private_data;
  191. struct ieee80211_sta *sta;
  192. char buf[400];
  193. int i, pos = 0, bufsz = sizeof(buf);
  194. mutex_lock(&mvm->mutex);
  195. for (i = 0; i < IWL_MVM_STATION_COUNT; i++) {
  196. pos += scnprintf(buf + pos, bufsz - pos, "%.2d: ", i);
  197. sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
  198. lockdep_is_held(&mvm->mutex));
  199. if (!sta)
  200. pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
  201. else if (IS_ERR(sta))
  202. pos += scnprintf(buf + pos, bufsz - pos, "%ld\n",
  203. PTR_ERR(sta));
  204. else
  205. pos += scnprintf(buf + pos, bufsz - pos, "%pM\n",
  206. sta->addr);
  207. }
  208. mutex_unlock(&mvm->mutex);
  209. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  210. }
  211. static ssize_t iwl_dbgfs_power_down_allow_write(struct file *file,
  212. const char __user *user_buf,
  213. size_t count, loff_t *ppos)
  214. {
  215. struct iwl_mvm *mvm = file->private_data;
  216. char buf[8] = {};
  217. int allow;
  218. if (!mvm->ucode_loaded)
  219. return -EIO;
  220. if (copy_from_user(buf, user_buf, sizeof(buf)))
  221. return -EFAULT;
  222. if (sscanf(buf, "%d", &allow) != 1)
  223. return -EINVAL;
  224. IWL_DEBUG_POWER(mvm, "%s device power down\n",
  225. allow ? "allow" : "prevent");
  226. /*
  227. * TODO: Send REPLY_DEBUG_CMD (0xf0) when FW support it
  228. */
  229. return count;
  230. }
  231. static ssize_t iwl_dbgfs_power_down_d3_allow_write(struct file *file,
  232. const char __user *user_buf,
  233. size_t count, loff_t *ppos)
  234. {
  235. struct iwl_mvm *mvm = file->private_data;
  236. char buf[8] = {};
  237. int allow;
  238. if (copy_from_user(buf, user_buf, sizeof(buf)))
  239. return -EFAULT;
  240. if (sscanf(buf, "%d", &allow) != 1)
  241. return -EINVAL;
  242. IWL_DEBUG_POWER(mvm, "%s device power down in d3\n",
  243. allow ? "allow" : "prevent");
  244. /*
  245. * TODO: When WoWLAN FW alive notification happens, driver will send
  246. * REPLY_DEBUG_CMD setting power_down_allow flag according to
  247. * mvm->prevent_power_down_d3
  248. */
  249. mvm->prevent_power_down_d3 = !allow;
  250. return count;
  251. }
  252. static void iwl_dbgfs_update_pm(struct iwl_mvm *mvm,
  253. struct ieee80211_vif *vif,
  254. enum iwl_dbgfs_pm_mask param, int val)
  255. {
  256. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  257. struct iwl_dbgfs_pm *dbgfs_pm = &mvmvif->dbgfs_pm;
  258. dbgfs_pm->mask |= param;
  259. switch (param) {
  260. case MVM_DEBUGFS_PM_KEEP_ALIVE: {
  261. struct ieee80211_hw *hw = mvm->hw;
  262. int dtimper = hw->conf.ps_dtim_period ?: 1;
  263. int dtimper_msec = dtimper * vif->bss_conf.beacon_int;
  264. IWL_DEBUG_POWER(mvm, "debugfs: set keep_alive= %d sec\n", val);
  265. if (val * MSEC_PER_SEC < 3 * dtimper_msec) {
  266. IWL_WARN(mvm,
  267. "debugfs: keep alive period (%ld msec) is less than minimum required (%d msec)\n",
  268. val * MSEC_PER_SEC, 3 * dtimper_msec);
  269. }
  270. dbgfs_pm->keep_alive_seconds = val;
  271. break;
  272. }
  273. case MVM_DEBUGFS_PM_SKIP_OVER_DTIM:
  274. IWL_DEBUG_POWER(mvm, "skip_over_dtim %s\n",
  275. val ? "enabled" : "disabled");
  276. dbgfs_pm->skip_over_dtim = val;
  277. break;
  278. case MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS:
  279. IWL_DEBUG_POWER(mvm, "skip_dtim_periods=%d\n", val);
  280. dbgfs_pm->skip_dtim_periods = val;
  281. break;
  282. case MVM_DEBUGFS_PM_RX_DATA_TIMEOUT:
  283. IWL_DEBUG_POWER(mvm, "rx_data_timeout=%d\n", val);
  284. dbgfs_pm->rx_data_timeout = val;
  285. break;
  286. case MVM_DEBUGFS_PM_TX_DATA_TIMEOUT:
  287. IWL_DEBUG_POWER(mvm, "tx_data_timeout=%d\n", val);
  288. dbgfs_pm->tx_data_timeout = val;
  289. break;
  290. case MVM_DEBUGFS_PM_DISABLE_POWER_OFF:
  291. IWL_DEBUG_POWER(mvm, "disable_power_off=%d\n", val);
  292. dbgfs_pm->disable_power_off = val;
  293. case MVM_DEBUGFS_PM_LPRX_ENA:
  294. IWL_DEBUG_POWER(mvm, "lprx %s\n", val ? "enabled" : "disabled");
  295. dbgfs_pm->lprx_ena = val;
  296. break;
  297. case MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD:
  298. IWL_DEBUG_POWER(mvm, "lprx_rssi_threshold=%d\n", val);
  299. dbgfs_pm->lprx_rssi_threshold = val;
  300. break;
  301. }
  302. }
  303. static ssize_t iwl_dbgfs_pm_params_write(struct file *file,
  304. const char __user *user_buf,
  305. size_t count, loff_t *ppos)
  306. {
  307. struct ieee80211_vif *vif = file->private_data;
  308. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  309. struct iwl_mvm *mvm = mvmvif->dbgfs_data;
  310. enum iwl_dbgfs_pm_mask param;
  311. char buf[32] = {};
  312. int val;
  313. int ret;
  314. if (copy_from_user(buf, user_buf, sizeof(buf)))
  315. return -EFAULT;
  316. if (!strncmp("keep_alive=", buf, 11)) {
  317. if (sscanf(buf + 11, "%d", &val) != 1)
  318. return -EINVAL;
  319. param = MVM_DEBUGFS_PM_KEEP_ALIVE;
  320. } else if (!strncmp("skip_over_dtim=", buf, 15)) {
  321. if (sscanf(buf + 15, "%d", &val) != 1)
  322. return -EINVAL;
  323. param = MVM_DEBUGFS_PM_SKIP_OVER_DTIM;
  324. } else if (!strncmp("skip_dtim_periods=", buf, 18)) {
  325. if (sscanf(buf + 18, "%d", &val) != 1)
  326. return -EINVAL;
  327. param = MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS;
  328. } else if (!strncmp("rx_data_timeout=", buf, 16)) {
  329. if (sscanf(buf + 16, "%d", &val) != 1)
  330. return -EINVAL;
  331. param = MVM_DEBUGFS_PM_RX_DATA_TIMEOUT;
  332. } else if (!strncmp("tx_data_timeout=", buf, 16)) {
  333. if (sscanf(buf + 16, "%d", &val) != 1)
  334. return -EINVAL;
  335. param = MVM_DEBUGFS_PM_TX_DATA_TIMEOUT;
  336. } else if (!strncmp("disable_power_off=", buf, 18)) {
  337. if (sscanf(buf + 18, "%d", &val) != 1)
  338. return -EINVAL;
  339. param = MVM_DEBUGFS_PM_DISABLE_POWER_OFF;
  340. } else if (!strncmp("lprx=", buf, 5)) {
  341. if (sscanf(buf + 5, "%d", &val) != 1)
  342. return -EINVAL;
  343. param = MVM_DEBUGFS_PM_LPRX_ENA;
  344. } else if (!strncmp("lprx_rssi_threshold=", buf, 20)) {
  345. if (sscanf(buf + 20, "%d", &val) != 1)
  346. return -EINVAL;
  347. if (val > POWER_LPRX_RSSI_THRESHOLD_MAX || val <
  348. POWER_LPRX_RSSI_THRESHOLD_MIN)
  349. return -EINVAL;
  350. param = MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD;
  351. } else {
  352. return -EINVAL;
  353. }
  354. mutex_lock(&mvm->mutex);
  355. iwl_dbgfs_update_pm(mvm, vif, param, val);
  356. ret = iwl_mvm_power_update_mode(mvm, vif);
  357. mutex_unlock(&mvm->mutex);
  358. return ret ?: count;
  359. }
  360. static ssize_t iwl_dbgfs_pm_params_read(struct file *file,
  361. char __user *user_buf,
  362. size_t count, loff_t *ppos)
  363. {
  364. struct ieee80211_vif *vif = file->private_data;
  365. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  366. struct iwl_mvm *mvm = mvmvif->dbgfs_data;
  367. struct iwl_powertable_cmd cmd = {};
  368. char buf[256];
  369. int bufsz = sizeof(buf);
  370. int pos = 0;
  371. iwl_mvm_power_build_cmd(mvm, vif, &cmd);
  372. pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off = %d\n",
  373. (cmd.flags &
  374. cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK)) ?
  375. 0 : 1);
  376. pos += scnprintf(buf+pos, bufsz-pos, "skip_dtim_periods = %d\n",
  377. le32_to_cpu(cmd.skip_dtim_periods));
  378. pos += scnprintf(buf+pos, bufsz-pos, "power_scheme = %d\n",
  379. iwlmvm_mod_params.power_scheme);
  380. pos += scnprintf(buf+pos, bufsz-pos, "flags = 0x%x\n",
  381. le16_to_cpu(cmd.flags));
  382. pos += scnprintf(buf+pos, bufsz-pos, "keep_alive = %d\n",
  383. cmd.keep_alive_seconds);
  384. if (cmd.flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)) {
  385. pos += scnprintf(buf+pos, bufsz-pos, "skip_over_dtim = %d\n",
  386. (cmd.flags &
  387. cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK)) ?
  388. 1 : 0);
  389. pos += scnprintf(buf+pos, bufsz-pos, "rx_data_timeout = %d\n",
  390. le32_to_cpu(cmd.rx_data_timeout));
  391. pos += scnprintf(buf+pos, bufsz-pos, "tx_data_timeout = %d\n",
  392. le32_to_cpu(cmd.tx_data_timeout));
  393. if (cmd.flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK))
  394. pos += scnprintf(buf+pos, bufsz-pos,
  395. "lprx_rssi_threshold = %d\n",
  396. le32_to_cpu(cmd.lprx_rssi_threshold));
  397. }
  398. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  399. }
  400. static ssize_t iwl_dbgfs_mac_params_read(struct file *file,
  401. char __user *user_buf,
  402. size_t count, loff_t *ppos)
  403. {
  404. struct ieee80211_vif *vif = file->private_data;
  405. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  406. struct iwl_mvm *mvm = mvmvif->dbgfs_data;
  407. u8 ap_sta_id;
  408. struct ieee80211_chanctx_conf *chanctx_conf;
  409. char buf[512];
  410. int bufsz = sizeof(buf);
  411. int pos = 0;
  412. int i;
  413. mutex_lock(&mvm->mutex);
  414. ap_sta_id = mvmvif->ap_sta_id;
  415. pos += scnprintf(buf+pos, bufsz-pos, "mac id/color: %d / %d\n",
  416. mvmvif->id, mvmvif->color);
  417. pos += scnprintf(buf+pos, bufsz-pos, "bssid: %pM\n",
  418. vif->bss_conf.bssid);
  419. pos += scnprintf(buf+pos, bufsz-pos, "QoS:\n");
  420. for (i = 0; i < ARRAY_SIZE(mvmvif->queue_params); i++) {
  421. pos += scnprintf(buf+pos, bufsz-pos,
  422. "\t%d: txop:%d - cw_min:%d - cw_max = %d - aifs = %d upasd = %d\n",
  423. i, mvmvif->queue_params[i].txop,
  424. mvmvif->queue_params[i].cw_min,
  425. mvmvif->queue_params[i].cw_max,
  426. mvmvif->queue_params[i].aifs,
  427. mvmvif->queue_params[i].uapsd);
  428. }
  429. if (vif->type == NL80211_IFTYPE_STATION &&
  430. ap_sta_id != IWL_MVM_STATION_COUNT) {
  431. struct ieee80211_sta *sta;
  432. struct iwl_mvm_sta *mvm_sta;
  433. sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[ap_sta_id],
  434. lockdep_is_held(&mvm->mutex));
  435. mvm_sta = (void *)sta->drv_priv;
  436. pos += scnprintf(buf+pos, bufsz-pos,
  437. "ap_sta_id %d - reduced Tx power %d\n",
  438. ap_sta_id, mvm_sta->bt_reduced_txpower);
  439. }
  440. rcu_read_lock();
  441. chanctx_conf = rcu_dereference(vif->chanctx_conf);
  442. if (chanctx_conf) {
  443. pos += scnprintf(buf+pos, bufsz-pos,
  444. "idle rx chains %d, active rx chains: %d\n",
  445. chanctx_conf->rx_chains_static,
  446. chanctx_conf->rx_chains_dynamic);
  447. }
  448. rcu_read_unlock();
  449. mutex_unlock(&mvm->mutex);
  450. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  451. }
  452. #define BT_MBOX_MSG(_notif, _num, _field) \
  453. ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\
  454. >> BT_MBOX##_num##_##_field##_POS)
  455. #define BT_MBOX_PRINT(_num, _field, _end) \
  456. pos += scnprintf(buf + pos, bufsz - pos, \
  457. "\t%s: %d%s", \
  458. #_field, \
  459. BT_MBOX_MSG(notif, _num, _field), \
  460. true ? "\n" : ", ");
  461. static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf,
  462. size_t count, loff_t *ppos)
  463. {
  464. struct iwl_mvm *mvm = file->private_data;
  465. struct iwl_bt_coex_profile_notif *notif = &mvm->last_bt_notif;
  466. char *buf;
  467. int ret, pos = 0, bufsz = sizeof(char) * 1024;
  468. buf = kmalloc(bufsz, GFP_KERNEL);
  469. if (!buf)
  470. return -ENOMEM;
  471. mutex_lock(&mvm->mutex);
  472. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n");
  473. BT_MBOX_PRINT(0, LE_SLAVE_LAT, false);
  474. BT_MBOX_PRINT(0, LE_PROF1, false);
  475. BT_MBOX_PRINT(0, LE_PROF2, false);
  476. BT_MBOX_PRINT(0, LE_PROF_OTHER, false);
  477. BT_MBOX_PRINT(0, CHL_SEQ_N, false);
  478. BT_MBOX_PRINT(0, INBAND_S, false);
  479. BT_MBOX_PRINT(0, LE_MIN_RSSI, false);
  480. BT_MBOX_PRINT(0, LE_SCAN, false);
  481. BT_MBOX_PRINT(0, LE_ADV, false);
  482. BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false);
  483. BT_MBOX_PRINT(0, OPEN_CON_1, true);
  484. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n");
  485. BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false);
  486. BT_MBOX_PRINT(1, IP_SR, false);
  487. BT_MBOX_PRINT(1, LE_MSTR, false);
  488. BT_MBOX_PRINT(1, AGGR_TRFC_LD, false);
  489. BT_MBOX_PRINT(1, MSG_TYPE, false);
  490. BT_MBOX_PRINT(1, SSN, true);
  491. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n");
  492. BT_MBOX_PRINT(2, SNIFF_ACT, false);
  493. BT_MBOX_PRINT(2, PAG, false);
  494. BT_MBOX_PRINT(2, INQUIRY, false);
  495. BT_MBOX_PRINT(2, CONN, false);
  496. BT_MBOX_PRINT(2, SNIFF_INTERVAL, false);
  497. BT_MBOX_PRINT(2, DISC, false);
  498. BT_MBOX_PRINT(2, SCO_TX_ACT, false);
  499. BT_MBOX_PRINT(2, SCO_RX_ACT, false);
  500. BT_MBOX_PRINT(2, ESCO_RE_TX, false);
  501. BT_MBOX_PRINT(2, SCO_DURATION, true);
  502. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n");
  503. BT_MBOX_PRINT(3, SCO_STATE, false);
  504. BT_MBOX_PRINT(3, SNIFF_STATE, false);
  505. BT_MBOX_PRINT(3, A2DP_STATE, false);
  506. BT_MBOX_PRINT(3, ACL_STATE, false);
  507. BT_MBOX_PRINT(3, MSTR_STATE, false);
  508. BT_MBOX_PRINT(3, OBX_STATE, false);
  509. BT_MBOX_PRINT(3, OPEN_CON_2, false);
  510. BT_MBOX_PRINT(3, TRAFFIC_LOAD, false);
  511. BT_MBOX_PRINT(3, CHL_SEQN_LSB, false);
  512. BT_MBOX_PRINT(3, INBAND_P, false);
  513. BT_MBOX_PRINT(3, MSG_TYPE_2, false);
  514. BT_MBOX_PRINT(3, SSN_2, false);
  515. BT_MBOX_PRINT(3, UPDATE_REQUEST, true);
  516. pos += scnprintf(buf+pos, bufsz-pos, "bt_status = %d\n",
  517. notif->bt_status);
  518. pos += scnprintf(buf+pos, bufsz-pos, "bt_open_conn = %d\n",
  519. notif->bt_open_conn);
  520. pos += scnprintf(buf+pos, bufsz-pos, "bt_traffic_load = %d\n",
  521. notif->bt_traffic_load);
  522. pos += scnprintf(buf+pos, bufsz-pos, "bt_agg_traffic_load = %d\n",
  523. notif->bt_agg_traffic_load);
  524. pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n",
  525. notif->bt_ci_compliance);
  526. mutex_unlock(&mvm->mutex);
  527. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  528. kfree(buf);
  529. return ret;
  530. }
  531. #undef BT_MBOX_PRINT
  532. static ssize_t iwl_dbgfs_fw_restart_write(struct file *file,
  533. const char __user *user_buf,
  534. size_t count, loff_t *ppos)
  535. {
  536. struct iwl_mvm *mvm = file->private_data;
  537. bool restart_fw = iwlwifi_mod_params.restart_fw;
  538. int ret;
  539. iwlwifi_mod_params.restart_fw = true;
  540. mutex_lock(&mvm->mutex);
  541. /* take the return value to make compiler happy - it will fail anyway */
  542. ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_ERROR, CMD_SYNC, 0, NULL);
  543. mutex_unlock(&mvm->mutex);
  544. iwlwifi_mod_params.restart_fw = restart_fw;
  545. return count;
  546. }
  547. static void iwl_dbgfs_update_bf(struct ieee80211_vif *vif,
  548. enum iwl_dbgfs_bf_mask param, int value)
  549. {
  550. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  551. struct iwl_dbgfs_bf *dbgfs_bf = &mvmvif->dbgfs_bf;
  552. dbgfs_bf->mask |= param;
  553. switch (param) {
  554. case MVM_DEBUGFS_BF_ENERGY_DELTA:
  555. dbgfs_bf->bf_energy_delta = value;
  556. break;
  557. case MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA:
  558. dbgfs_bf->bf_roaming_energy_delta = value;
  559. break;
  560. case MVM_DEBUGFS_BF_ROAMING_STATE:
  561. dbgfs_bf->bf_roaming_state = value;
  562. break;
  563. case MVM_DEBUGFS_BF_TEMPERATURE_DELTA:
  564. dbgfs_bf->bf_temperature_delta = value;
  565. break;
  566. case MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER:
  567. dbgfs_bf->bf_enable_beacon_filter = value;
  568. break;
  569. case MVM_DEBUGFS_BF_DEBUG_FLAG:
  570. dbgfs_bf->bf_debug_flag = value;
  571. break;
  572. case MVM_DEBUGFS_BF_ESCAPE_TIMER:
  573. dbgfs_bf->bf_escape_timer = value;
  574. break;
  575. case MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT:
  576. dbgfs_bf->ba_enable_beacon_abort = value;
  577. break;
  578. case MVM_DEBUGFS_BA_ESCAPE_TIMER:
  579. dbgfs_bf->ba_escape_timer = value;
  580. break;
  581. }
  582. }
  583. static ssize_t iwl_dbgfs_bf_params_write(struct file *file,
  584. const char __user *user_buf,
  585. size_t count, loff_t *ppos)
  586. {
  587. struct ieee80211_vif *vif = file->private_data;
  588. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  589. struct iwl_mvm *mvm = mvmvif->dbgfs_data;
  590. enum iwl_dbgfs_bf_mask param;
  591. char buf[256];
  592. int buf_size;
  593. int value;
  594. int ret = 0;
  595. memset(buf, 0, sizeof(buf));
  596. buf_size = min(count, sizeof(buf) - 1);
  597. if (copy_from_user(buf, user_buf, buf_size))
  598. return -EFAULT;
  599. if (!strncmp("bf_energy_delta=", buf, 16)) {
  600. if (sscanf(buf+16, "%d", &value) != 1)
  601. return -EINVAL;
  602. if (value < IWL_BF_ENERGY_DELTA_MIN ||
  603. value > IWL_BF_ENERGY_DELTA_MAX)
  604. return -EINVAL;
  605. param = MVM_DEBUGFS_BF_ENERGY_DELTA;
  606. } else if (!strncmp("bf_roaming_energy_delta=", buf, 24)) {
  607. if (sscanf(buf+24, "%d", &value) != 1)
  608. return -EINVAL;
  609. if (value < IWL_BF_ROAMING_ENERGY_DELTA_MIN ||
  610. value > IWL_BF_ROAMING_ENERGY_DELTA_MAX)
  611. return -EINVAL;
  612. param = MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA;
  613. } else if (!strncmp("bf_roaming_state=", buf, 17)) {
  614. if (sscanf(buf+17, "%d", &value) != 1)
  615. return -EINVAL;
  616. if (value < IWL_BF_ROAMING_STATE_MIN ||
  617. value > IWL_BF_ROAMING_STATE_MAX)
  618. return -EINVAL;
  619. param = MVM_DEBUGFS_BF_ROAMING_STATE;
  620. } else if (!strncmp("bf_temperature_delta=", buf, 21)) {
  621. if (sscanf(buf+21, "%d", &value) != 1)
  622. return -EINVAL;
  623. if (value < IWL_BF_TEMPERATURE_DELTA_MIN ||
  624. value > IWL_BF_TEMPERATURE_DELTA_MAX)
  625. return -EINVAL;
  626. param = MVM_DEBUGFS_BF_TEMPERATURE_DELTA;
  627. } else if (!strncmp("bf_enable_beacon_filter=", buf, 24)) {
  628. if (sscanf(buf+24, "%d", &value) != 1)
  629. return -EINVAL;
  630. if (value < 0 || value > 1)
  631. return -EINVAL;
  632. param = MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER;
  633. } else if (!strncmp("bf_debug_flag=", buf, 14)) {
  634. if (sscanf(buf+14, "%d", &value) != 1)
  635. return -EINVAL;
  636. if (value < 0 || value > 1)
  637. return -EINVAL;
  638. param = MVM_DEBUGFS_BF_DEBUG_FLAG;
  639. } else if (!strncmp("bf_escape_timer=", buf, 16)) {
  640. if (sscanf(buf+16, "%d", &value) != 1)
  641. return -EINVAL;
  642. if (value < IWL_BF_ESCAPE_TIMER_MIN ||
  643. value > IWL_BF_ESCAPE_TIMER_MAX)
  644. return -EINVAL;
  645. param = MVM_DEBUGFS_BF_ESCAPE_TIMER;
  646. } else if (!strncmp("ba_escape_timer=", buf, 16)) {
  647. if (sscanf(buf+16, "%d", &value) != 1)
  648. return -EINVAL;
  649. if (value < IWL_BA_ESCAPE_TIMER_MIN ||
  650. value > IWL_BA_ESCAPE_TIMER_MAX)
  651. return -EINVAL;
  652. param = MVM_DEBUGFS_BA_ESCAPE_TIMER;
  653. } else if (!strncmp("ba_enable_beacon_abort=", buf, 23)) {
  654. if (sscanf(buf+23, "%d", &value) != 1)
  655. return -EINVAL;
  656. if (value < 0 || value > 1)
  657. return -EINVAL;
  658. param = MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT;
  659. } else {
  660. return -EINVAL;
  661. }
  662. mutex_lock(&mvm->mutex);
  663. iwl_dbgfs_update_bf(vif, param, value);
  664. if (param == MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER && !value) {
  665. ret = iwl_mvm_disable_beacon_filter(mvm, vif);
  666. } else {
  667. if (mvmvif->bf_enabled)
  668. ret = iwl_mvm_enable_beacon_filter(mvm, vif);
  669. else
  670. ret = iwl_mvm_disable_beacon_filter(mvm, vif);
  671. }
  672. mutex_unlock(&mvm->mutex);
  673. return ret ?: count;
  674. }
  675. static ssize_t iwl_dbgfs_bf_params_read(struct file *file,
  676. char __user *user_buf,
  677. size_t count, loff_t *ppos)
  678. {
  679. struct ieee80211_vif *vif = file->private_data;
  680. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  681. char buf[256];
  682. int pos = 0;
  683. const size_t bufsz = sizeof(buf);
  684. struct iwl_beacon_filter_cmd cmd = {
  685. .bf_energy_delta = IWL_BF_ENERGY_DELTA_DEFAULT,
  686. .bf_roaming_energy_delta = IWL_BF_ROAMING_ENERGY_DELTA_DEFAULT,
  687. .bf_roaming_state = IWL_BF_ROAMING_STATE_DEFAULT,
  688. .bf_temperature_delta = IWL_BF_TEMPERATURE_DELTA_DEFAULT,
  689. .bf_enable_beacon_filter = IWL_BF_ENABLE_BEACON_FILTER_DEFAULT,
  690. .bf_debug_flag = IWL_BF_DEBUG_FLAG_DEFAULT,
  691. .bf_escape_timer = cpu_to_le32(IWL_BF_ESCAPE_TIMER_DEFAULT),
  692. .ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER_DEFAULT),
  693. .ba_enable_beacon_abort = IWL_BA_ENABLE_BEACON_ABORT_DEFAULT,
  694. };
  695. iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd);
  696. if (mvmvif->bf_enabled)
  697. cmd.bf_enable_beacon_filter = 1;
  698. else
  699. cmd.bf_enable_beacon_filter = 0;
  700. pos += scnprintf(buf+pos, bufsz-pos, "bf_energy_delta = %d\n",
  701. cmd.bf_energy_delta);
  702. pos += scnprintf(buf+pos, bufsz-pos, "bf_roaming_energy_delta = %d\n",
  703. cmd.bf_roaming_energy_delta);
  704. pos += scnprintf(buf+pos, bufsz-pos, "bf_roaming_state = %d\n",
  705. cmd.bf_roaming_state);
  706. pos += scnprintf(buf+pos, bufsz-pos, "bf_temperature_delta = %d\n",
  707. cmd.bf_temperature_delta);
  708. pos += scnprintf(buf+pos, bufsz-pos, "bf_enable_beacon_filter = %d\n",
  709. cmd.bf_enable_beacon_filter);
  710. pos += scnprintf(buf+pos, bufsz-pos, "bf_debug_flag = %d\n",
  711. cmd.bf_debug_flag);
  712. pos += scnprintf(buf+pos, bufsz-pos, "bf_escape_timer = %d\n",
  713. cmd.bf_escape_timer);
  714. pos += scnprintf(buf+pos, bufsz-pos, "ba_escape_timer = %d\n",
  715. cmd.ba_escape_timer);
  716. pos += scnprintf(buf+pos, bufsz-pos, "ba_enable_beacon_abort = %d\n",
  717. cmd.ba_enable_beacon_abort);
  718. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  719. }
  720. #ifdef CONFIG_PM_SLEEP
  721. static ssize_t iwl_dbgfs_d3_sram_write(struct file *file,
  722. const char __user *user_buf,
  723. size_t count, loff_t *ppos)
  724. {
  725. struct iwl_mvm *mvm = file->private_data;
  726. char buf[8] = {};
  727. int store;
  728. if (copy_from_user(buf, user_buf, sizeof(buf)))
  729. return -EFAULT;
  730. if (sscanf(buf, "%d", &store) != 1)
  731. return -EINVAL;
  732. mvm->store_d3_resume_sram = store;
  733. return count;
  734. }
  735. static ssize_t iwl_dbgfs_d3_sram_read(struct file *file, char __user *user_buf,
  736. size_t count, loff_t *ppos)
  737. {
  738. struct iwl_mvm *mvm = file->private_data;
  739. const struct fw_img *img;
  740. int ofs, len, pos = 0;
  741. size_t bufsz, ret;
  742. char *buf;
  743. u8 *ptr = mvm->d3_resume_sram;
  744. img = &mvm->fw->img[IWL_UCODE_WOWLAN];
  745. len = img->sec[IWL_UCODE_SECTION_DATA].len;
  746. bufsz = len * 4 + 256;
  747. buf = kzalloc(bufsz, GFP_KERNEL);
  748. if (!buf)
  749. return -ENOMEM;
  750. pos += scnprintf(buf, bufsz, "D3 SRAM capture: %sabled\n",
  751. mvm->store_d3_resume_sram ? "en" : "dis");
  752. if (ptr) {
  753. for (ofs = 0; ofs < len; ofs += 16) {
  754. pos += scnprintf(buf + pos, bufsz - pos,
  755. "0x%.4x ", ofs);
  756. hex_dump_to_buffer(ptr + ofs, 16, 16, 1, buf + pos,
  757. bufsz - pos, false);
  758. pos += strlen(buf + pos);
  759. if (bufsz - pos > 0)
  760. buf[pos++] = '\n';
  761. }
  762. } else {
  763. pos += scnprintf(buf + pos, bufsz - pos,
  764. "(no data captured)\n");
  765. }
  766. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  767. kfree(buf);
  768. return ret;
  769. }
  770. #endif
  771. #define MVM_DEBUGFS_READ_FILE_OPS(name) \
  772. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  773. .read = iwl_dbgfs_##name##_read, \
  774. .open = simple_open, \
  775. .llseek = generic_file_llseek, \
  776. }
  777. #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name) \
  778. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  779. .write = iwl_dbgfs_##name##_write, \
  780. .read = iwl_dbgfs_##name##_read, \
  781. .open = simple_open, \
  782. .llseek = generic_file_llseek, \
  783. };
  784. #define MVM_DEBUGFS_WRITE_FILE_OPS(name) \
  785. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  786. .write = iwl_dbgfs_##name##_write, \
  787. .open = simple_open, \
  788. .llseek = generic_file_llseek, \
  789. };
  790. #define MVM_DEBUGFS_ADD_FILE(name, parent, mode) do { \
  791. if (!debugfs_create_file(#name, mode, parent, mvm, \
  792. &iwl_dbgfs_##name##_ops)) \
  793. goto err; \
  794. } while (0)
  795. #define MVM_DEBUGFS_ADD_FILE_VIF(name, parent, mode) do { \
  796. if (!debugfs_create_file(#name, mode, parent, vif, \
  797. &iwl_dbgfs_##name##_ops)) \
  798. goto err; \
  799. } while (0)
  800. /* Device wide debugfs entries */
  801. MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush);
  802. MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain);
  803. MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram);
  804. MVM_DEBUGFS_READ_FILE_OPS(stations);
  805. MVM_DEBUGFS_READ_FILE_OPS(bt_notif);
  806. MVM_DEBUGFS_WRITE_FILE_OPS(power_down_allow);
  807. MVM_DEBUGFS_WRITE_FILE_OPS(power_down_d3_allow);
  808. MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart);
  809. #ifdef CONFIG_PM_SLEEP
  810. MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram);
  811. #endif
  812. /* Interface specific debugfs entries */
  813. MVM_DEBUGFS_READ_FILE_OPS(mac_params);
  814. MVM_DEBUGFS_READ_WRITE_FILE_OPS(pm_params);
  815. MVM_DEBUGFS_READ_WRITE_FILE_OPS(bf_params);
  816. int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
  817. {
  818. char buf[100];
  819. mvm->debugfs_dir = dbgfs_dir;
  820. MVM_DEBUGFS_ADD_FILE(tx_flush, mvm->debugfs_dir, S_IWUSR);
  821. MVM_DEBUGFS_ADD_FILE(sta_drain, mvm->debugfs_dir, S_IWUSR);
  822. MVM_DEBUGFS_ADD_FILE(sram, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
  823. MVM_DEBUGFS_ADD_FILE(stations, dbgfs_dir, S_IRUSR);
  824. MVM_DEBUGFS_ADD_FILE(bt_notif, dbgfs_dir, S_IRUSR);
  825. MVM_DEBUGFS_ADD_FILE(power_down_allow, mvm->debugfs_dir, S_IWUSR);
  826. MVM_DEBUGFS_ADD_FILE(power_down_d3_allow, mvm->debugfs_dir, S_IWUSR);
  827. MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, S_IWUSR);
  828. #ifdef CONFIG_PM_SLEEP
  829. MVM_DEBUGFS_ADD_FILE(d3_sram, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
  830. MVM_DEBUGFS_ADD_FILE(d3_test, mvm->debugfs_dir, S_IRUSR);
  831. if (!debugfs_create_bool("d3_wake_sysassert", S_IRUSR | S_IWUSR,
  832. mvm->debugfs_dir, &mvm->d3_wake_sysassert))
  833. goto err;
  834. #endif
  835. /*
  836. * Create a symlink with mac80211. It will be removed when mac80211
  837. * exists (before the opmode exists which removes the target.)
  838. */
  839. snprintf(buf, 100, "../../%s/%s",
  840. dbgfs_dir->d_parent->d_parent->d_name.name,
  841. dbgfs_dir->d_parent->d_name.name);
  842. if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf))
  843. goto err;
  844. return 0;
  845. err:
  846. IWL_ERR(mvm, "Can't create the mvm debugfs directory\n");
  847. return -ENOMEM;
  848. }
  849. void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  850. {
  851. struct dentry *dbgfs_dir = vif->debugfs_dir;
  852. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  853. char buf[100];
  854. if (!dbgfs_dir)
  855. return;
  856. mvmvif->dbgfs_dir = debugfs_create_dir("iwlmvm", dbgfs_dir);
  857. mvmvif->dbgfs_data = mvm;
  858. if (!mvmvif->dbgfs_dir) {
  859. IWL_ERR(mvm, "Failed to create debugfs directory under %s\n",
  860. dbgfs_dir->d_name.name);
  861. return;
  862. }
  863. if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM &&
  864. vif->type == NL80211_IFTYPE_STATION && !vif->p2p)
  865. MVM_DEBUGFS_ADD_FILE_VIF(pm_params, mvmvif->dbgfs_dir, S_IWUSR |
  866. S_IRUSR);
  867. MVM_DEBUGFS_ADD_FILE_VIF(mac_params, mvmvif->dbgfs_dir,
  868. S_IRUSR);
  869. if (vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
  870. mvmvif == mvm->bf_allowed_vif)
  871. MVM_DEBUGFS_ADD_FILE_VIF(bf_params, mvmvif->dbgfs_dir,
  872. S_IRUSR | S_IWUSR);
  873. /*
  874. * Create symlink for convenience pointing to interface specific
  875. * debugfs entries for the driver. For example, under
  876. * /sys/kernel/debug/iwlwifi/0000\:02\:00.0/iwlmvm/
  877. * find
  878. * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/
  879. */
  880. snprintf(buf, 100, "../../../%s/%s/%s/%s",
  881. dbgfs_dir->d_parent->d_parent->d_name.name,
  882. dbgfs_dir->d_parent->d_name.name,
  883. dbgfs_dir->d_name.name,
  884. mvmvif->dbgfs_dir->d_name.name);
  885. mvmvif->dbgfs_slink = debugfs_create_symlink(dbgfs_dir->d_name.name,
  886. mvm->debugfs_dir, buf);
  887. if (!mvmvif->dbgfs_slink)
  888. IWL_ERR(mvm, "Can't create debugfs symbolic link under %s\n",
  889. dbgfs_dir->d_name.name);
  890. return;
  891. err:
  892. IWL_ERR(mvm, "Can't create debugfs entity\n");
  893. }
  894. void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  895. {
  896. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  897. debugfs_remove(mvmvif->dbgfs_slink);
  898. mvmvif->dbgfs_slink = NULL;
  899. debugfs_remove_recursive(mvmvif->dbgfs_dir);
  900. mvmvif->dbgfs_dir = NULL;
  901. }