debugfs.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026
  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. break;
  294. }
  295. }
  296. static ssize_t iwl_dbgfs_pm_params_write(struct file *file,
  297. const char __user *user_buf,
  298. size_t count, loff_t *ppos)
  299. {
  300. struct ieee80211_vif *vif = file->private_data;
  301. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  302. struct iwl_mvm *mvm = mvmvif->dbgfs_data;
  303. enum iwl_dbgfs_pm_mask param;
  304. char buf[32] = {};
  305. int val;
  306. int ret;
  307. if (copy_from_user(buf, user_buf, sizeof(buf)))
  308. return -EFAULT;
  309. if (!strncmp("keep_alive=", buf, 11)) {
  310. if (sscanf(buf + 11, "%d", &val) != 1)
  311. return -EINVAL;
  312. param = MVM_DEBUGFS_PM_KEEP_ALIVE;
  313. } else if (!strncmp("skip_over_dtim=", buf, 15)) {
  314. if (sscanf(buf + 15, "%d", &val) != 1)
  315. return -EINVAL;
  316. param = MVM_DEBUGFS_PM_SKIP_OVER_DTIM;
  317. } else if (!strncmp("skip_dtim_periods=", buf, 18)) {
  318. if (sscanf(buf + 18, "%d", &val) != 1)
  319. return -EINVAL;
  320. param = MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS;
  321. } else if (!strncmp("rx_data_timeout=", buf, 16)) {
  322. if (sscanf(buf + 16, "%d", &val) != 1)
  323. return -EINVAL;
  324. param = MVM_DEBUGFS_PM_RX_DATA_TIMEOUT;
  325. } else if (!strncmp("tx_data_timeout=", buf, 16)) {
  326. if (sscanf(buf + 16, "%d", &val) != 1)
  327. return -EINVAL;
  328. param = MVM_DEBUGFS_PM_TX_DATA_TIMEOUT;
  329. } else if (!strncmp("disable_power_off=", buf, 18)) {
  330. if (sscanf(buf + 18, "%d", &val) != 1)
  331. return -EINVAL;
  332. param = MVM_DEBUGFS_PM_DISABLE_POWER_OFF;
  333. } else {
  334. return -EINVAL;
  335. }
  336. mutex_lock(&mvm->mutex);
  337. iwl_dbgfs_update_pm(mvm, vif, param, val);
  338. ret = iwl_mvm_power_update_mode(mvm, vif);
  339. mutex_unlock(&mvm->mutex);
  340. return ret ?: count;
  341. }
  342. static ssize_t iwl_dbgfs_pm_params_read(struct file *file,
  343. char __user *user_buf,
  344. size_t count, loff_t *ppos)
  345. {
  346. struct ieee80211_vif *vif = file->private_data;
  347. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  348. struct iwl_mvm *mvm = mvmvif->dbgfs_data;
  349. struct iwl_powertable_cmd cmd = {};
  350. char buf[256];
  351. int bufsz = sizeof(buf);
  352. int pos = 0;
  353. iwl_mvm_power_build_cmd(mvm, vif, &cmd);
  354. pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off = %d\n",
  355. (cmd.flags &
  356. cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK)) ?
  357. 0 : 1);
  358. pos += scnprintf(buf+pos, bufsz-pos, "skip_dtim_periods = %d\n",
  359. le32_to_cpu(cmd.skip_dtim_periods));
  360. pos += scnprintf(buf+pos, bufsz-pos, "power_scheme = %d\n",
  361. iwlmvm_mod_params.power_scheme);
  362. pos += scnprintf(buf+pos, bufsz-pos, "flags = %d\n",
  363. le16_to_cpu(cmd.flags));
  364. pos += scnprintf(buf+pos, bufsz-pos, "keep_alive = %d\n",
  365. cmd.keep_alive_seconds);
  366. if (cmd.flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)) {
  367. pos += scnprintf(buf+pos, bufsz-pos, "skip_over_dtim = %d\n",
  368. (cmd.flags &
  369. cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK)) ?
  370. 1 : 0);
  371. pos += scnprintf(buf+pos, bufsz-pos, "rx_data_timeout = %d\n",
  372. le32_to_cpu(cmd.rx_data_timeout));
  373. pos += scnprintf(buf+pos, bufsz-pos, "tx_data_timeout = %d\n",
  374. le32_to_cpu(cmd.tx_data_timeout));
  375. }
  376. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  377. }
  378. static ssize_t iwl_dbgfs_mac_params_read(struct file *file,
  379. char __user *user_buf,
  380. size_t count, loff_t *ppos)
  381. {
  382. struct ieee80211_vif *vif = file->private_data;
  383. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  384. struct iwl_mvm *mvm = mvmvif->dbgfs_data;
  385. u8 ap_sta_id;
  386. struct ieee80211_chanctx_conf *chanctx_conf;
  387. char buf[512];
  388. int bufsz = sizeof(buf);
  389. int pos = 0;
  390. int i;
  391. mutex_lock(&mvm->mutex);
  392. ap_sta_id = mvmvif->ap_sta_id;
  393. pos += scnprintf(buf+pos, bufsz-pos, "mac id/color: %d / %d\n",
  394. mvmvif->id, mvmvif->color);
  395. pos += scnprintf(buf+pos, bufsz-pos, "bssid: %pM\n",
  396. vif->bss_conf.bssid);
  397. pos += scnprintf(buf+pos, bufsz-pos, "QoS:\n");
  398. for (i = 0; i < ARRAY_SIZE(mvmvif->queue_params); i++) {
  399. pos += scnprintf(buf+pos, bufsz-pos,
  400. "\t%d: txop:%d - cw_min:%d - cw_max = %d - aifs = %d upasd = %d\n",
  401. i, mvmvif->queue_params[i].txop,
  402. mvmvif->queue_params[i].cw_min,
  403. mvmvif->queue_params[i].cw_max,
  404. mvmvif->queue_params[i].aifs,
  405. mvmvif->queue_params[i].uapsd);
  406. }
  407. if (vif->type == NL80211_IFTYPE_STATION &&
  408. ap_sta_id != IWL_MVM_STATION_COUNT) {
  409. struct ieee80211_sta *sta;
  410. struct iwl_mvm_sta *mvm_sta;
  411. sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[ap_sta_id],
  412. lockdep_is_held(&mvm->mutex));
  413. mvm_sta = (void *)sta->drv_priv;
  414. pos += scnprintf(buf+pos, bufsz-pos,
  415. "ap_sta_id %d - reduced Tx power %d\n",
  416. ap_sta_id, mvm_sta->bt_reduced_txpower);
  417. }
  418. rcu_read_lock();
  419. chanctx_conf = rcu_dereference(vif->chanctx_conf);
  420. if (chanctx_conf) {
  421. pos += scnprintf(buf+pos, bufsz-pos,
  422. "idle rx chains %d, active rx chains: %d\n",
  423. chanctx_conf->rx_chains_static,
  424. chanctx_conf->rx_chains_dynamic);
  425. }
  426. rcu_read_unlock();
  427. mutex_unlock(&mvm->mutex);
  428. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  429. }
  430. #define BT_MBOX_MSG(_notif, _num, _field) \
  431. ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\
  432. >> BT_MBOX##_num##_##_field##_POS)
  433. #define BT_MBOX_PRINT(_num, _field, _end) \
  434. pos += scnprintf(buf + pos, bufsz - pos, \
  435. "\t%s: %d%s", \
  436. #_field, \
  437. BT_MBOX_MSG(notif, _num, _field), \
  438. true ? "\n" : ", ");
  439. static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf,
  440. size_t count, loff_t *ppos)
  441. {
  442. struct iwl_mvm *mvm = file->private_data;
  443. struct iwl_bt_coex_profile_notif *notif = &mvm->last_bt_notif;
  444. char *buf;
  445. int ret, pos = 0, bufsz = sizeof(char) * 1024;
  446. buf = kmalloc(bufsz, GFP_KERNEL);
  447. if (!buf)
  448. return -ENOMEM;
  449. mutex_lock(&mvm->mutex);
  450. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n");
  451. BT_MBOX_PRINT(0, LE_SLAVE_LAT, false);
  452. BT_MBOX_PRINT(0, LE_PROF1, false);
  453. BT_MBOX_PRINT(0, LE_PROF2, false);
  454. BT_MBOX_PRINT(0, LE_PROF_OTHER, false);
  455. BT_MBOX_PRINT(0, CHL_SEQ_N, false);
  456. BT_MBOX_PRINT(0, INBAND_S, false);
  457. BT_MBOX_PRINT(0, LE_MIN_RSSI, false);
  458. BT_MBOX_PRINT(0, LE_SCAN, false);
  459. BT_MBOX_PRINT(0, LE_ADV, false);
  460. BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false);
  461. BT_MBOX_PRINT(0, OPEN_CON_1, true);
  462. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n");
  463. BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false);
  464. BT_MBOX_PRINT(1, IP_SR, false);
  465. BT_MBOX_PRINT(1, LE_MSTR, false);
  466. BT_MBOX_PRINT(1, AGGR_TRFC_LD, false);
  467. BT_MBOX_PRINT(1, MSG_TYPE, false);
  468. BT_MBOX_PRINT(1, SSN, true);
  469. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n");
  470. BT_MBOX_PRINT(2, SNIFF_ACT, false);
  471. BT_MBOX_PRINT(2, PAG, false);
  472. BT_MBOX_PRINT(2, INQUIRY, false);
  473. BT_MBOX_PRINT(2, CONN, false);
  474. BT_MBOX_PRINT(2, SNIFF_INTERVAL, false);
  475. BT_MBOX_PRINT(2, DISC, false);
  476. BT_MBOX_PRINT(2, SCO_TX_ACT, false);
  477. BT_MBOX_PRINT(2, SCO_RX_ACT, false);
  478. BT_MBOX_PRINT(2, ESCO_RE_TX, false);
  479. BT_MBOX_PRINT(2, SCO_DURATION, true);
  480. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n");
  481. BT_MBOX_PRINT(3, SCO_STATE, false);
  482. BT_MBOX_PRINT(3, SNIFF_STATE, false);
  483. BT_MBOX_PRINT(3, A2DP_STATE, false);
  484. BT_MBOX_PRINT(3, ACL_STATE, false);
  485. BT_MBOX_PRINT(3, MSTR_STATE, false);
  486. BT_MBOX_PRINT(3, OBX_STATE, false);
  487. BT_MBOX_PRINT(3, OPEN_CON_2, false);
  488. BT_MBOX_PRINT(3, TRAFFIC_LOAD, false);
  489. BT_MBOX_PRINT(3, CHL_SEQN_LSB, false);
  490. BT_MBOX_PRINT(3, INBAND_P, false);
  491. BT_MBOX_PRINT(3, MSG_TYPE_2, false);
  492. BT_MBOX_PRINT(3, SSN_2, false);
  493. BT_MBOX_PRINT(3, UPDATE_REQUEST, true);
  494. pos += scnprintf(buf+pos, bufsz-pos, "bt_status = %d\n",
  495. notif->bt_status);
  496. pos += scnprintf(buf+pos, bufsz-pos, "bt_open_conn = %d\n",
  497. notif->bt_open_conn);
  498. pos += scnprintf(buf+pos, bufsz-pos, "bt_traffic_load = %d\n",
  499. notif->bt_traffic_load);
  500. pos += scnprintf(buf+pos, bufsz-pos, "bt_agg_traffic_load = %d\n",
  501. notif->bt_agg_traffic_load);
  502. pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n",
  503. notif->bt_ci_compliance);
  504. mutex_unlock(&mvm->mutex);
  505. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  506. kfree(buf);
  507. return ret;
  508. }
  509. #undef BT_MBOX_PRINT
  510. static ssize_t iwl_dbgfs_fw_restart_write(struct file *file,
  511. const char __user *user_buf,
  512. size_t count, loff_t *ppos)
  513. {
  514. struct iwl_mvm *mvm = file->private_data;
  515. bool restart_fw = iwlwifi_mod_params.restart_fw;
  516. int ret;
  517. iwlwifi_mod_params.restart_fw = true;
  518. mutex_lock(&mvm->mutex);
  519. /* take the return value to make compiler happy - it will fail anyway */
  520. ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_ERROR, CMD_SYNC, 0, NULL);
  521. mutex_unlock(&mvm->mutex);
  522. iwlwifi_mod_params.restart_fw = restart_fw;
  523. return count;
  524. }
  525. static void iwl_dbgfs_update_bf(struct ieee80211_vif *vif,
  526. enum iwl_dbgfs_bf_mask param, int value)
  527. {
  528. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  529. struct iwl_dbgfs_bf *dbgfs_bf = &mvmvif->dbgfs_bf;
  530. dbgfs_bf->mask |= param;
  531. switch (param) {
  532. case MVM_DEBUGFS_BF_ENERGY_DELTA:
  533. dbgfs_bf->bf_energy_delta = value;
  534. break;
  535. case MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA:
  536. dbgfs_bf->bf_roaming_energy_delta = value;
  537. break;
  538. case MVM_DEBUGFS_BF_ROAMING_STATE:
  539. dbgfs_bf->bf_roaming_state = value;
  540. break;
  541. case MVM_DEBUGFS_BF_TEMPERATURE_DELTA:
  542. dbgfs_bf->bf_temperature_delta = value;
  543. break;
  544. case MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER:
  545. dbgfs_bf->bf_enable_beacon_filter = value;
  546. break;
  547. case MVM_DEBUGFS_BF_DEBUG_FLAG:
  548. dbgfs_bf->bf_debug_flag = value;
  549. break;
  550. case MVM_DEBUGFS_BF_ESCAPE_TIMER:
  551. dbgfs_bf->bf_escape_timer = value;
  552. break;
  553. case MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT:
  554. dbgfs_bf->ba_enable_beacon_abort = value;
  555. break;
  556. case MVM_DEBUGFS_BA_ESCAPE_TIMER:
  557. dbgfs_bf->ba_escape_timer = value;
  558. break;
  559. }
  560. }
  561. static ssize_t iwl_dbgfs_bf_params_write(struct file *file,
  562. const char __user *user_buf,
  563. size_t count, loff_t *ppos)
  564. {
  565. struct ieee80211_vif *vif = file->private_data;
  566. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  567. struct iwl_mvm *mvm = mvmvif->dbgfs_data;
  568. enum iwl_dbgfs_bf_mask param;
  569. char buf[256];
  570. int buf_size;
  571. int value;
  572. int ret = 0;
  573. memset(buf, 0, sizeof(buf));
  574. buf_size = min(count, sizeof(buf) - 1);
  575. if (copy_from_user(buf, user_buf, buf_size))
  576. return -EFAULT;
  577. if (!strncmp("bf_energy_delta=", buf, 16)) {
  578. if (sscanf(buf+16, "%d", &value) != 1)
  579. return -EINVAL;
  580. if (value < IWL_BF_ENERGY_DELTA_MIN ||
  581. value > IWL_BF_ENERGY_DELTA_MAX)
  582. return -EINVAL;
  583. param = MVM_DEBUGFS_BF_ENERGY_DELTA;
  584. } else if (!strncmp("bf_roaming_energy_delta=", buf, 24)) {
  585. if (sscanf(buf+24, "%d", &value) != 1)
  586. return -EINVAL;
  587. if (value < IWL_BF_ROAMING_ENERGY_DELTA_MIN ||
  588. value > IWL_BF_ROAMING_ENERGY_DELTA_MAX)
  589. return -EINVAL;
  590. param = MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA;
  591. } else if (!strncmp("bf_roaming_state=", buf, 17)) {
  592. if (sscanf(buf+17, "%d", &value) != 1)
  593. return -EINVAL;
  594. if (value < IWL_BF_ROAMING_STATE_MIN ||
  595. value > IWL_BF_ROAMING_STATE_MAX)
  596. return -EINVAL;
  597. param = MVM_DEBUGFS_BF_ROAMING_STATE;
  598. } else if (!strncmp("bf_temperature_delta=", buf, 21)) {
  599. if (sscanf(buf+21, "%d", &value) != 1)
  600. return -EINVAL;
  601. if (value < IWL_BF_TEMPERATURE_DELTA_MIN ||
  602. value > IWL_BF_TEMPERATURE_DELTA_MAX)
  603. return -EINVAL;
  604. param = MVM_DEBUGFS_BF_TEMPERATURE_DELTA;
  605. } else if (!strncmp("bf_enable_beacon_filter=", buf, 24)) {
  606. if (sscanf(buf+24, "%d", &value) != 1)
  607. return -EINVAL;
  608. if (value < 0 || value > 1)
  609. return -EINVAL;
  610. param = MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER;
  611. } else if (!strncmp("bf_debug_flag=", buf, 14)) {
  612. if (sscanf(buf+14, "%d", &value) != 1)
  613. return -EINVAL;
  614. if (value < 0 || value > 1)
  615. return -EINVAL;
  616. param = MVM_DEBUGFS_BF_DEBUG_FLAG;
  617. } else if (!strncmp("bf_escape_timer=", buf, 16)) {
  618. if (sscanf(buf+16, "%d", &value) != 1)
  619. return -EINVAL;
  620. if (value < IWL_BF_ESCAPE_TIMER_MIN ||
  621. value > IWL_BF_ESCAPE_TIMER_MAX)
  622. return -EINVAL;
  623. param = MVM_DEBUGFS_BF_ESCAPE_TIMER;
  624. } else if (!strncmp("ba_escape_timer=", buf, 16)) {
  625. if (sscanf(buf+16, "%d", &value) != 1)
  626. return -EINVAL;
  627. if (value < IWL_BA_ESCAPE_TIMER_MIN ||
  628. value > IWL_BA_ESCAPE_TIMER_MAX)
  629. return -EINVAL;
  630. param = MVM_DEBUGFS_BA_ESCAPE_TIMER;
  631. } else if (!strncmp("ba_enable_beacon_abort=", buf, 23)) {
  632. if (sscanf(buf+23, "%d", &value) != 1)
  633. return -EINVAL;
  634. if (value < 0 || value > 1)
  635. return -EINVAL;
  636. param = MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT;
  637. } else {
  638. return -EINVAL;
  639. }
  640. mutex_lock(&mvm->mutex);
  641. iwl_dbgfs_update_bf(vif, param, value);
  642. if (param == MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER && !value) {
  643. ret = iwl_mvm_disable_beacon_filter(mvm, vif);
  644. } else {
  645. if (mvmvif->bf_enabled)
  646. ret = iwl_mvm_enable_beacon_filter(mvm, vif);
  647. else
  648. ret = iwl_mvm_disable_beacon_filter(mvm, vif);
  649. }
  650. mutex_unlock(&mvm->mutex);
  651. return ret ?: count;
  652. }
  653. static ssize_t iwl_dbgfs_bf_params_read(struct file *file,
  654. char __user *user_buf,
  655. size_t count, loff_t *ppos)
  656. {
  657. struct ieee80211_vif *vif = file->private_data;
  658. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  659. char buf[256];
  660. int pos = 0;
  661. const size_t bufsz = sizeof(buf);
  662. struct iwl_beacon_filter_cmd cmd = {
  663. .bf_energy_delta = IWL_BF_ENERGY_DELTA_DEFAULT,
  664. .bf_roaming_energy_delta = IWL_BF_ROAMING_ENERGY_DELTA_DEFAULT,
  665. .bf_roaming_state = IWL_BF_ROAMING_STATE_DEFAULT,
  666. .bf_temperature_delta = IWL_BF_TEMPERATURE_DELTA_DEFAULT,
  667. .bf_enable_beacon_filter = IWL_BF_ENABLE_BEACON_FILTER_DEFAULT,
  668. .bf_debug_flag = IWL_BF_DEBUG_FLAG_DEFAULT,
  669. .bf_escape_timer = cpu_to_le32(IWL_BF_ESCAPE_TIMER_DEFAULT),
  670. .ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER_DEFAULT),
  671. .ba_enable_beacon_abort = IWL_BA_ENABLE_BEACON_ABORT_DEFAULT,
  672. };
  673. iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd);
  674. if (mvmvif->bf_enabled)
  675. cmd.bf_enable_beacon_filter = 1;
  676. else
  677. cmd.bf_enable_beacon_filter = 0;
  678. pos += scnprintf(buf+pos, bufsz-pos, "bf_energy_delta = %d\n",
  679. cmd.bf_energy_delta);
  680. pos += scnprintf(buf+pos, bufsz-pos, "bf_roaming_energy_delta = %d\n",
  681. cmd.bf_roaming_energy_delta);
  682. pos += scnprintf(buf+pos, bufsz-pos, "bf_roaming_state = %d\n",
  683. cmd.bf_roaming_state);
  684. pos += scnprintf(buf+pos, bufsz-pos, "bf_temperature_delta = %d\n",
  685. cmd.bf_temperature_delta);
  686. pos += scnprintf(buf+pos, bufsz-pos, "bf_enable_beacon_filter = %d\n",
  687. cmd.bf_enable_beacon_filter);
  688. pos += scnprintf(buf+pos, bufsz-pos, "bf_debug_flag = %d\n",
  689. cmd.bf_debug_flag);
  690. pos += scnprintf(buf+pos, bufsz-pos, "bf_escape_timer = %d\n",
  691. cmd.bf_escape_timer);
  692. pos += scnprintf(buf+pos, bufsz-pos, "ba_escape_timer = %d\n",
  693. cmd.ba_escape_timer);
  694. pos += scnprintf(buf+pos, bufsz-pos, "ba_enable_beacon_abort = %d\n",
  695. cmd.ba_enable_beacon_abort);
  696. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  697. }
  698. #ifdef CONFIG_PM_SLEEP
  699. static ssize_t iwl_dbgfs_d3_sram_write(struct file *file,
  700. const char __user *user_buf,
  701. size_t count, loff_t *ppos)
  702. {
  703. struct iwl_mvm *mvm = file->private_data;
  704. char buf[8] = {};
  705. int store;
  706. if (copy_from_user(buf, user_buf, sizeof(buf)))
  707. return -EFAULT;
  708. if (sscanf(buf, "%d", &store) != 1)
  709. return -EINVAL;
  710. mvm->store_d3_resume_sram = store;
  711. return count;
  712. }
  713. static ssize_t iwl_dbgfs_d3_sram_read(struct file *file, char __user *user_buf,
  714. size_t count, loff_t *ppos)
  715. {
  716. struct iwl_mvm *mvm = file->private_data;
  717. const struct fw_img *img;
  718. int ofs, len, pos = 0;
  719. size_t bufsz, ret;
  720. char *buf;
  721. u8 *ptr = mvm->d3_resume_sram;
  722. img = &mvm->fw->img[IWL_UCODE_WOWLAN];
  723. len = img->sec[IWL_UCODE_SECTION_DATA].len;
  724. bufsz = len * 4 + 256;
  725. buf = kzalloc(bufsz, GFP_KERNEL);
  726. if (!buf)
  727. return -ENOMEM;
  728. pos += scnprintf(buf, bufsz, "D3 SRAM capture: %sabled\n",
  729. mvm->store_d3_resume_sram ? "en" : "dis");
  730. if (ptr) {
  731. for (ofs = 0; ofs < len; ofs += 16) {
  732. pos += scnprintf(buf + pos, bufsz - pos,
  733. "0x%.4x ", ofs);
  734. hex_dump_to_buffer(ptr + ofs, 16, 16, 1, buf + pos,
  735. bufsz - pos, false);
  736. pos += strlen(buf + pos);
  737. if (bufsz - pos > 0)
  738. buf[pos++] = '\n';
  739. }
  740. } else {
  741. pos += scnprintf(buf + pos, bufsz - pos,
  742. "(no data captured)\n");
  743. }
  744. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  745. kfree(buf);
  746. return ret;
  747. }
  748. #endif
  749. #define MVM_DEBUGFS_READ_FILE_OPS(name) \
  750. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  751. .read = iwl_dbgfs_##name##_read, \
  752. .open = simple_open, \
  753. .llseek = generic_file_llseek, \
  754. }
  755. #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name) \
  756. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  757. .write = iwl_dbgfs_##name##_write, \
  758. .read = iwl_dbgfs_##name##_read, \
  759. .open = simple_open, \
  760. .llseek = generic_file_llseek, \
  761. };
  762. #define MVM_DEBUGFS_WRITE_FILE_OPS(name) \
  763. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  764. .write = iwl_dbgfs_##name##_write, \
  765. .open = simple_open, \
  766. .llseek = generic_file_llseek, \
  767. };
  768. #define MVM_DEBUGFS_ADD_FILE(name, parent, mode) do { \
  769. if (!debugfs_create_file(#name, mode, parent, mvm, \
  770. &iwl_dbgfs_##name##_ops)) \
  771. goto err; \
  772. } while (0)
  773. #define MVM_DEBUGFS_ADD_FILE_VIF(name, parent, mode) do { \
  774. if (!debugfs_create_file(#name, mode, parent, vif, \
  775. &iwl_dbgfs_##name##_ops)) \
  776. goto err; \
  777. } while (0)
  778. /* Device wide debugfs entries */
  779. MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush);
  780. MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain);
  781. MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram);
  782. MVM_DEBUGFS_READ_FILE_OPS(stations);
  783. MVM_DEBUGFS_READ_FILE_OPS(bt_notif);
  784. MVM_DEBUGFS_WRITE_FILE_OPS(power_down_allow);
  785. MVM_DEBUGFS_WRITE_FILE_OPS(power_down_d3_allow);
  786. MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart);
  787. #ifdef CONFIG_PM_SLEEP
  788. MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram);
  789. #endif
  790. /* Interface specific debugfs entries */
  791. MVM_DEBUGFS_READ_FILE_OPS(mac_params);
  792. MVM_DEBUGFS_READ_WRITE_FILE_OPS(pm_params);
  793. MVM_DEBUGFS_READ_WRITE_FILE_OPS(bf_params);
  794. int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
  795. {
  796. char buf[100];
  797. mvm->debugfs_dir = dbgfs_dir;
  798. MVM_DEBUGFS_ADD_FILE(tx_flush, mvm->debugfs_dir, S_IWUSR);
  799. MVM_DEBUGFS_ADD_FILE(sta_drain, mvm->debugfs_dir, S_IWUSR);
  800. MVM_DEBUGFS_ADD_FILE(sram, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
  801. MVM_DEBUGFS_ADD_FILE(stations, dbgfs_dir, S_IRUSR);
  802. MVM_DEBUGFS_ADD_FILE(bt_notif, dbgfs_dir, S_IRUSR);
  803. MVM_DEBUGFS_ADD_FILE(power_down_allow, mvm->debugfs_dir, S_IWUSR);
  804. MVM_DEBUGFS_ADD_FILE(power_down_d3_allow, mvm->debugfs_dir, S_IWUSR);
  805. MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, S_IWUSR);
  806. #ifdef CONFIG_PM_SLEEP
  807. MVM_DEBUGFS_ADD_FILE(d3_sram, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
  808. MVM_DEBUGFS_ADD_FILE(d3_test, mvm->debugfs_dir, S_IRUSR);
  809. if (!debugfs_create_bool("d3_wake_sysassert", S_IRUSR | S_IWUSR,
  810. mvm->debugfs_dir, &mvm->d3_wake_sysassert))
  811. goto err;
  812. #endif
  813. /*
  814. * Create a symlink with mac80211. It will be removed when mac80211
  815. * exists (before the opmode exists which removes the target.)
  816. */
  817. snprintf(buf, 100, "../../%s/%s",
  818. dbgfs_dir->d_parent->d_parent->d_name.name,
  819. dbgfs_dir->d_parent->d_name.name);
  820. if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf))
  821. goto err;
  822. return 0;
  823. err:
  824. IWL_ERR(mvm, "Can't create the mvm debugfs directory\n");
  825. return -ENOMEM;
  826. }
  827. void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  828. {
  829. struct dentry *dbgfs_dir = vif->debugfs_dir;
  830. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  831. char buf[100];
  832. if (!dbgfs_dir)
  833. return;
  834. mvmvif->dbgfs_dir = debugfs_create_dir("iwlmvm", dbgfs_dir);
  835. mvmvif->dbgfs_data = mvm;
  836. if (!mvmvif->dbgfs_dir) {
  837. IWL_ERR(mvm, "Failed to create debugfs directory under %s\n",
  838. dbgfs_dir->d_name.name);
  839. return;
  840. }
  841. if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM &&
  842. vif->type == NL80211_IFTYPE_STATION && !vif->p2p)
  843. MVM_DEBUGFS_ADD_FILE_VIF(pm_params, mvmvif->dbgfs_dir, S_IWUSR |
  844. S_IRUSR);
  845. MVM_DEBUGFS_ADD_FILE_VIF(mac_params, mvmvif->dbgfs_dir,
  846. S_IRUSR);
  847. if (vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
  848. mvmvif == mvm->bf_allowed_vif)
  849. MVM_DEBUGFS_ADD_FILE_VIF(bf_params, mvmvif->dbgfs_dir,
  850. S_IRUSR | S_IWUSR);
  851. /*
  852. * Create symlink for convenience pointing to interface specific
  853. * debugfs entries for the driver. For example, under
  854. * /sys/kernel/debug/iwlwifi/0000\:02\:00.0/iwlmvm/
  855. * find
  856. * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/
  857. */
  858. snprintf(buf, 100, "../../../%s/%s/%s/%s",
  859. dbgfs_dir->d_parent->d_parent->d_name.name,
  860. dbgfs_dir->d_parent->d_name.name,
  861. dbgfs_dir->d_name.name,
  862. mvmvif->dbgfs_dir->d_name.name);
  863. mvmvif->dbgfs_slink = debugfs_create_symlink(dbgfs_dir->d_name.name,
  864. mvm->debugfs_dir, buf);
  865. if (!mvmvif->dbgfs_slink)
  866. IWL_ERR(mvm, "Can't create debugfs symbolic link under %s\n",
  867. dbgfs_dir->d_name.name);
  868. return;
  869. err:
  870. IWL_ERR(mvm, "Can't create debugfs entity\n");
  871. }
  872. void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  873. {
  874. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  875. debugfs_remove(mvmvif->dbgfs_slink);
  876. mvmvif->dbgfs_slink = NULL;
  877. debugfs_remove_recursive(mvmvif->dbgfs_dir);
  878. mvmvif->dbgfs_dir = NULL;
  879. }