debugfs-vif.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573
  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. * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of version 2 of the GNU General Public License as
  14. * published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  24. * USA
  25. *
  26. * The full GNU General Public License is included in this distribution
  27. * in the file called COPYING.
  28. *
  29. * Contact Information:
  30. * Intel Linux Wireless <linuxwifi@intel.com>
  31. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  32. *
  33. * BSD LICENSE
  34. *
  35. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  36. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  37. * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
  38. * All rights reserved.
  39. *
  40. * Redistribution and use in source and binary forms, with or without
  41. * modification, are permitted provided that the following conditions
  42. * are met:
  43. *
  44. * * Redistributions of source code must retain the above copyright
  45. * notice, this list of conditions and the following disclaimer.
  46. * * Redistributions in binary form must reproduce the above copyright
  47. * notice, this list of conditions and the following disclaimer in
  48. * the documentation and/or other materials provided with the
  49. * distribution.
  50. * * Neither the name Intel Corporation nor the names of its
  51. * contributors may be used to endorse or promote products derived
  52. * from this software without specific prior written permission.
  53. *
  54. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  55. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  56. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  57. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  58. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  59. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  60. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  61. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  62. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  63. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  64. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  65. *
  66. *****************************************************************************/
  67. #include "mvm.h"
  68. #include "fw/api/tof.h"
  69. #include "debugfs.h"
  70. static void iwl_dbgfs_update_pm(struct iwl_mvm *mvm,
  71. struct ieee80211_vif *vif,
  72. enum iwl_dbgfs_pm_mask param, int val)
  73. {
  74. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  75. struct iwl_dbgfs_pm *dbgfs_pm = &mvmvif->dbgfs_pm;
  76. dbgfs_pm->mask |= param;
  77. switch (param) {
  78. case MVM_DEBUGFS_PM_KEEP_ALIVE: {
  79. int dtimper = vif->bss_conf.dtim_period ?: 1;
  80. int dtimper_msec = dtimper * vif->bss_conf.beacon_int;
  81. IWL_DEBUG_POWER(mvm, "debugfs: set keep_alive= %d sec\n", val);
  82. if (val * MSEC_PER_SEC < 3 * dtimper_msec)
  83. IWL_WARN(mvm,
  84. "debugfs: keep alive period (%ld msec) is less than minimum required (%d msec)\n",
  85. val * MSEC_PER_SEC, 3 * dtimper_msec);
  86. dbgfs_pm->keep_alive_seconds = val;
  87. break;
  88. }
  89. case MVM_DEBUGFS_PM_SKIP_OVER_DTIM:
  90. IWL_DEBUG_POWER(mvm, "skip_over_dtim %s\n",
  91. val ? "enabled" : "disabled");
  92. dbgfs_pm->skip_over_dtim = val;
  93. break;
  94. case MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS:
  95. IWL_DEBUG_POWER(mvm, "skip_dtim_periods=%d\n", val);
  96. dbgfs_pm->skip_dtim_periods = val;
  97. break;
  98. case MVM_DEBUGFS_PM_RX_DATA_TIMEOUT:
  99. IWL_DEBUG_POWER(mvm, "rx_data_timeout=%d\n", val);
  100. dbgfs_pm->rx_data_timeout = val;
  101. break;
  102. case MVM_DEBUGFS_PM_TX_DATA_TIMEOUT:
  103. IWL_DEBUG_POWER(mvm, "tx_data_timeout=%d\n", val);
  104. dbgfs_pm->tx_data_timeout = val;
  105. break;
  106. case MVM_DEBUGFS_PM_LPRX_ENA:
  107. IWL_DEBUG_POWER(mvm, "lprx %s\n", val ? "enabled" : "disabled");
  108. dbgfs_pm->lprx_ena = val;
  109. break;
  110. case MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD:
  111. IWL_DEBUG_POWER(mvm, "lprx_rssi_threshold=%d\n", val);
  112. dbgfs_pm->lprx_rssi_threshold = val;
  113. break;
  114. case MVM_DEBUGFS_PM_SNOOZE_ENABLE:
  115. IWL_DEBUG_POWER(mvm, "snooze_enable=%d\n", val);
  116. dbgfs_pm->snooze_ena = val;
  117. break;
  118. case MVM_DEBUGFS_PM_UAPSD_MISBEHAVING:
  119. IWL_DEBUG_POWER(mvm, "uapsd_misbehaving_enable=%d\n", val);
  120. dbgfs_pm->uapsd_misbehaving = val;
  121. break;
  122. case MVM_DEBUGFS_PM_USE_PS_POLL:
  123. IWL_DEBUG_POWER(mvm, "use_ps_poll=%d\n", val);
  124. dbgfs_pm->use_ps_poll = val;
  125. break;
  126. }
  127. }
  128. static ssize_t iwl_dbgfs_pm_params_write(struct ieee80211_vif *vif, char *buf,
  129. size_t count, loff_t *ppos)
  130. {
  131. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  132. struct iwl_mvm *mvm = mvmvif->mvm;
  133. enum iwl_dbgfs_pm_mask param;
  134. int val, ret;
  135. if (!strncmp("keep_alive=", buf, 11)) {
  136. if (sscanf(buf + 11, "%d", &val) != 1)
  137. return -EINVAL;
  138. param = MVM_DEBUGFS_PM_KEEP_ALIVE;
  139. } else if (!strncmp("skip_over_dtim=", buf, 15)) {
  140. if (sscanf(buf + 15, "%d", &val) != 1)
  141. return -EINVAL;
  142. param = MVM_DEBUGFS_PM_SKIP_OVER_DTIM;
  143. } else if (!strncmp("skip_dtim_periods=", buf, 18)) {
  144. if (sscanf(buf + 18, "%d", &val) != 1)
  145. return -EINVAL;
  146. param = MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS;
  147. } else if (!strncmp("rx_data_timeout=", buf, 16)) {
  148. if (sscanf(buf + 16, "%d", &val) != 1)
  149. return -EINVAL;
  150. param = MVM_DEBUGFS_PM_RX_DATA_TIMEOUT;
  151. } else if (!strncmp("tx_data_timeout=", buf, 16)) {
  152. if (sscanf(buf + 16, "%d", &val) != 1)
  153. return -EINVAL;
  154. param = MVM_DEBUGFS_PM_TX_DATA_TIMEOUT;
  155. } else if (!strncmp("lprx=", buf, 5)) {
  156. if (sscanf(buf + 5, "%d", &val) != 1)
  157. return -EINVAL;
  158. param = MVM_DEBUGFS_PM_LPRX_ENA;
  159. } else if (!strncmp("lprx_rssi_threshold=", buf, 20)) {
  160. if (sscanf(buf + 20, "%d", &val) != 1)
  161. return -EINVAL;
  162. if (val > POWER_LPRX_RSSI_THRESHOLD_MAX || val <
  163. POWER_LPRX_RSSI_THRESHOLD_MIN)
  164. return -EINVAL;
  165. param = MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD;
  166. } else if (!strncmp("snooze_enable=", buf, 14)) {
  167. if (sscanf(buf + 14, "%d", &val) != 1)
  168. return -EINVAL;
  169. param = MVM_DEBUGFS_PM_SNOOZE_ENABLE;
  170. } else if (!strncmp("uapsd_misbehaving=", buf, 18)) {
  171. if (sscanf(buf + 18, "%d", &val) != 1)
  172. return -EINVAL;
  173. param = MVM_DEBUGFS_PM_UAPSD_MISBEHAVING;
  174. } else if (!strncmp("use_ps_poll=", buf, 12)) {
  175. if (sscanf(buf + 12, "%d", &val) != 1)
  176. return -EINVAL;
  177. param = MVM_DEBUGFS_PM_USE_PS_POLL;
  178. } else {
  179. return -EINVAL;
  180. }
  181. mutex_lock(&mvm->mutex);
  182. iwl_dbgfs_update_pm(mvm, vif, param, val);
  183. ret = iwl_mvm_power_update_mac(mvm);
  184. mutex_unlock(&mvm->mutex);
  185. return ret ?: count;
  186. }
  187. static ssize_t iwl_dbgfs_tx_pwr_lmt_read(struct file *file,
  188. char __user *user_buf,
  189. size_t count, loff_t *ppos)
  190. {
  191. struct ieee80211_vif *vif = file->private_data;
  192. char buf[64];
  193. int bufsz = sizeof(buf);
  194. int pos;
  195. pos = scnprintf(buf, bufsz, "bss limit = %d\n",
  196. vif->bss_conf.txpower);
  197. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  198. }
  199. static ssize_t iwl_dbgfs_pm_params_read(struct file *file,
  200. char __user *user_buf,
  201. size_t count, loff_t *ppos)
  202. {
  203. struct ieee80211_vif *vif = file->private_data;
  204. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  205. struct iwl_mvm *mvm = mvmvif->mvm;
  206. char buf[512];
  207. int bufsz = sizeof(buf);
  208. int pos;
  209. pos = iwl_mvm_power_mac_dbgfs_read(mvm, vif, buf, bufsz);
  210. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  211. }
  212. static ssize_t iwl_dbgfs_mac_params_read(struct file *file,
  213. char __user *user_buf,
  214. size_t count, loff_t *ppos)
  215. {
  216. struct ieee80211_vif *vif = file->private_data;
  217. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  218. struct iwl_mvm *mvm = mvmvif->mvm;
  219. u8 ap_sta_id;
  220. struct ieee80211_chanctx_conf *chanctx_conf;
  221. char buf[512];
  222. int bufsz = sizeof(buf);
  223. int pos = 0;
  224. int i;
  225. mutex_lock(&mvm->mutex);
  226. ap_sta_id = mvmvif->ap_sta_id;
  227. switch (ieee80211_vif_type_p2p(vif)) {
  228. case NL80211_IFTYPE_ADHOC:
  229. pos += scnprintf(buf+pos, bufsz-pos, "type: ibss\n");
  230. break;
  231. case NL80211_IFTYPE_STATION:
  232. pos += scnprintf(buf+pos, bufsz-pos, "type: bss\n");
  233. break;
  234. case NL80211_IFTYPE_AP:
  235. pos += scnprintf(buf+pos, bufsz-pos, "type: ap\n");
  236. break;
  237. case NL80211_IFTYPE_P2P_CLIENT:
  238. pos += scnprintf(buf+pos, bufsz-pos, "type: p2p client\n");
  239. break;
  240. case NL80211_IFTYPE_P2P_GO:
  241. pos += scnprintf(buf+pos, bufsz-pos, "type: p2p go\n");
  242. break;
  243. case NL80211_IFTYPE_P2P_DEVICE:
  244. pos += scnprintf(buf+pos, bufsz-pos, "type: p2p dev\n");
  245. break;
  246. default:
  247. break;
  248. }
  249. pos += scnprintf(buf+pos, bufsz-pos, "mac id/color: %d / %d\n",
  250. mvmvif->id, mvmvif->color);
  251. pos += scnprintf(buf+pos, bufsz-pos, "bssid: %pM\n",
  252. vif->bss_conf.bssid);
  253. pos += scnprintf(buf+pos, bufsz-pos, "Load: %d\n",
  254. mvm->tcm.result.load[mvmvif->id]);
  255. pos += scnprintf(buf+pos, bufsz-pos, "QoS:\n");
  256. for (i = 0; i < ARRAY_SIZE(mvmvif->queue_params); i++)
  257. pos += scnprintf(buf+pos, bufsz-pos,
  258. "\t%d: txop:%d - cw_min:%d - cw_max = %d - aifs = %d upasd = %d\n",
  259. i, mvmvif->queue_params[i].txop,
  260. mvmvif->queue_params[i].cw_min,
  261. mvmvif->queue_params[i].cw_max,
  262. mvmvif->queue_params[i].aifs,
  263. mvmvif->queue_params[i].uapsd);
  264. if (vif->type == NL80211_IFTYPE_STATION &&
  265. ap_sta_id != IWL_MVM_INVALID_STA) {
  266. struct iwl_mvm_sta *mvm_sta;
  267. mvm_sta = iwl_mvm_sta_from_staid_protected(mvm, ap_sta_id);
  268. if (mvm_sta) {
  269. pos += scnprintf(buf+pos, bufsz-pos,
  270. "ap_sta_id %d - reduced Tx power %d\n",
  271. ap_sta_id,
  272. mvm_sta->bt_reduced_txpower);
  273. }
  274. }
  275. rcu_read_lock();
  276. chanctx_conf = rcu_dereference(vif->chanctx_conf);
  277. if (chanctx_conf)
  278. pos += scnprintf(buf+pos, bufsz-pos,
  279. "idle rx chains %d, active rx chains: %d\n",
  280. chanctx_conf->rx_chains_static,
  281. chanctx_conf->rx_chains_dynamic);
  282. rcu_read_unlock();
  283. mutex_unlock(&mvm->mutex);
  284. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  285. }
  286. static void iwl_dbgfs_update_bf(struct ieee80211_vif *vif,
  287. enum iwl_dbgfs_bf_mask param, int value)
  288. {
  289. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  290. struct iwl_dbgfs_bf *dbgfs_bf = &mvmvif->dbgfs_bf;
  291. dbgfs_bf->mask |= param;
  292. switch (param) {
  293. case MVM_DEBUGFS_BF_ENERGY_DELTA:
  294. dbgfs_bf->bf_energy_delta = value;
  295. break;
  296. case MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA:
  297. dbgfs_bf->bf_roaming_energy_delta = value;
  298. break;
  299. case MVM_DEBUGFS_BF_ROAMING_STATE:
  300. dbgfs_bf->bf_roaming_state = value;
  301. break;
  302. case MVM_DEBUGFS_BF_TEMP_THRESHOLD:
  303. dbgfs_bf->bf_temp_threshold = value;
  304. break;
  305. case MVM_DEBUGFS_BF_TEMP_FAST_FILTER:
  306. dbgfs_bf->bf_temp_fast_filter = value;
  307. break;
  308. case MVM_DEBUGFS_BF_TEMP_SLOW_FILTER:
  309. dbgfs_bf->bf_temp_slow_filter = value;
  310. break;
  311. case MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER:
  312. dbgfs_bf->bf_enable_beacon_filter = value;
  313. break;
  314. case MVM_DEBUGFS_BF_DEBUG_FLAG:
  315. dbgfs_bf->bf_debug_flag = value;
  316. break;
  317. case MVM_DEBUGFS_BF_ESCAPE_TIMER:
  318. dbgfs_bf->bf_escape_timer = value;
  319. break;
  320. case MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT:
  321. dbgfs_bf->ba_enable_beacon_abort = value;
  322. break;
  323. case MVM_DEBUGFS_BA_ESCAPE_TIMER:
  324. dbgfs_bf->ba_escape_timer = value;
  325. break;
  326. }
  327. }
  328. static ssize_t iwl_dbgfs_bf_params_write(struct ieee80211_vif *vif, char *buf,
  329. size_t count, loff_t *ppos)
  330. {
  331. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  332. struct iwl_mvm *mvm = mvmvif->mvm;
  333. enum iwl_dbgfs_bf_mask param;
  334. int value, ret = 0;
  335. if (!strncmp("bf_energy_delta=", buf, 16)) {
  336. if (sscanf(buf+16, "%d", &value) != 1)
  337. return -EINVAL;
  338. if (value < IWL_BF_ENERGY_DELTA_MIN ||
  339. value > IWL_BF_ENERGY_DELTA_MAX)
  340. return -EINVAL;
  341. param = MVM_DEBUGFS_BF_ENERGY_DELTA;
  342. } else if (!strncmp("bf_roaming_energy_delta=", buf, 24)) {
  343. if (sscanf(buf+24, "%d", &value) != 1)
  344. return -EINVAL;
  345. if (value < IWL_BF_ROAMING_ENERGY_DELTA_MIN ||
  346. value > IWL_BF_ROAMING_ENERGY_DELTA_MAX)
  347. return -EINVAL;
  348. param = MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA;
  349. } else if (!strncmp("bf_roaming_state=", buf, 17)) {
  350. if (sscanf(buf+17, "%d", &value) != 1)
  351. return -EINVAL;
  352. if (value < IWL_BF_ROAMING_STATE_MIN ||
  353. value > IWL_BF_ROAMING_STATE_MAX)
  354. return -EINVAL;
  355. param = MVM_DEBUGFS_BF_ROAMING_STATE;
  356. } else if (!strncmp("bf_temp_threshold=", buf, 18)) {
  357. if (sscanf(buf+18, "%d", &value) != 1)
  358. return -EINVAL;
  359. if (value < IWL_BF_TEMP_THRESHOLD_MIN ||
  360. value > IWL_BF_TEMP_THRESHOLD_MAX)
  361. return -EINVAL;
  362. param = MVM_DEBUGFS_BF_TEMP_THRESHOLD;
  363. } else if (!strncmp("bf_temp_fast_filter=", buf, 20)) {
  364. if (sscanf(buf+20, "%d", &value) != 1)
  365. return -EINVAL;
  366. if (value < IWL_BF_TEMP_FAST_FILTER_MIN ||
  367. value > IWL_BF_TEMP_FAST_FILTER_MAX)
  368. return -EINVAL;
  369. param = MVM_DEBUGFS_BF_TEMP_FAST_FILTER;
  370. } else if (!strncmp("bf_temp_slow_filter=", buf, 20)) {
  371. if (sscanf(buf+20, "%d", &value) != 1)
  372. return -EINVAL;
  373. if (value < IWL_BF_TEMP_SLOW_FILTER_MIN ||
  374. value > IWL_BF_TEMP_SLOW_FILTER_MAX)
  375. return -EINVAL;
  376. param = MVM_DEBUGFS_BF_TEMP_SLOW_FILTER;
  377. } else if (!strncmp("bf_enable_beacon_filter=", buf, 24)) {
  378. if (sscanf(buf+24, "%d", &value) != 1)
  379. return -EINVAL;
  380. if (value < 0 || value > 1)
  381. return -EINVAL;
  382. param = MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER;
  383. } else if (!strncmp("bf_debug_flag=", buf, 14)) {
  384. if (sscanf(buf+14, "%d", &value) != 1)
  385. return -EINVAL;
  386. if (value < 0 || value > 1)
  387. return -EINVAL;
  388. param = MVM_DEBUGFS_BF_DEBUG_FLAG;
  389. } else if (!strncmp("bf_escape_timer=", buf, 16)) {
  390. if (sscanf(buf+16, "%d", &value) != 1)
  391. return -EINVAL;
  392. if (value < IWL_BF_ESCAPE_TIMER_MIN ||
  393. value > IWL_BF_ESCAPE_TIMER_MAX)
  394. return -EINVAL;
  395. param = MVM_DEBUGFS_BF_ESCAPE_TIMER;
  396. } else if (!strncmp("ba_escape_timer=", buf, 16)) {
  397. if (sscanf(buf+16, "%d", &value) != 1)
  398. return -EINVAL;
  399. if (value < IWL_BA_ESCAPE_TIMER_MIN ||
  400. value > IWL_BA_ESCAPE_TIMER_MAX)
  401. return -EINVAL;
  402. param = MVM_DEBUGFS_BA_ESCAPE_TIMER;
  403. } else if (!strncmp("ba_enable_beacon_abort=", buf, 23)) {
  404. if (sscanf(buf+23, "%d", &value) != 1)
  405. return -EINVAL;
  406. if (value < 0 || value > 1)
  407. return -EINVAL;
  408. param = MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT;
  409. } else {
  410. return -EINVAL;
  411. }
  412. mutex_lock(&mvm->mutex);
  413. iwl_dbgfs_update_bf(vif, param, value);
  414. if (param == MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER && !value)
  415. ret = iwl_mvm_disable_beacon_filter(mvm, vif, 0);
  416. else
  417. ret = iwl_mvm_enable_beacon_filter(mvm, vif, 0);
  418. mutex_unlock(&mvm->mutex);
  419. return ret ?: count;
  420. }
  421. static ssize_t iwl_dbgfs_bf_params_read(struct file *file,
  422. char __user *user_buf,
  423. size_t count, loff_t *ppos)
  424. {
  425. struct ieee80211_vif *vif = file->private_data;
  426. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  427. char buf[256];
  428. int pos = 0;
  429. const size_t bufsz = sizeof(buf);
  430. struct iwl_beacon_filter_cmd cmd = {
  431. IWL_BF_CMD_CONFIG_DEFAULTS,
  432. .bf_enable_beacon_filter =
  433. cpu_to_le32(IWL_BF_ENABLE_BEACON_FILTER_DEFAULT),
  434. .ba_enable_beacon_abort =
  435. cpu_to_le32(IWL_BA_ENABLE_BEACON_ABORT_DEFAULT),
  436. };
  437. iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd);
  438. if (mvmvif->bf_data.bf_enabled)
  439. cmd.bf_enable_beacon_filter = cpu_to_le32(1);
  440. else
  441. cmd.bf_enable_beacon_filter = 0;
  442. pos += scnprintf(buf+pos, bufsz-pos, "bf_energy_delta = %d\n",
  443. le32_to_cpu(cmd.bf_energy_delta));
  444. pos += scnprintf(buf+pos, bufsz-pos, "bf_roaming_energy_delta = %d\n",
  445. le32_to_cpu(cmd.bf_roaming_energy_delta));
  446. pos += scnprintf(buf+pos, bufsz-pos, "bf_roaming_state = %d\n",
  447. le32_to_cpu(cmd.bf_roaming_state));
  448. pos += scnprintf(buf+pos, bufsz-pos, "bf_temp_threshold = %d\n",
  449. le32_to_cpu(cmd.bf_temp_threshold));
  450. pos += scnprintf(buf+pos, bufsz-pos, "bf_temp_fast_filter = %d\n",
  451. le32_to_cpu(cmd.bf_temp_fast_filter));
  452. pos += scnprintf(buf+pos, bufsz-pos, "bf_temp_slow_filter = %d\n",
  453. le32_to_cpu(cmd.bf_temp_slow_filter));
  454. pos += scnprintf(buf+pos, bufsz-pos, "bf_enable_beacon_filter = %d\n",
  455. le32_to_cpu(cmd.bf_enable_beacon_filter));
  456. pos += scnprintf(buf+pos, bufsz-pos, "bf_debug_flag = %d\n",
  457. le32_to_cpu(cmd.bf_debug_flag));
  458. pos += scnprintf(buf+pos, bufsz-pos, "bf_escape_timer = %d\n",
  459. le32_to_cpu(cmd.bf_escape_timer));
  460. pos += scnprintf(buf+pos, bufsz-pos, "ba_escape_timer = %d\n",
  461. le32_to_cpu(cmd.ba_escape_timer));
  462. pos += scnprintf(buf+pos, bufsz-pos, "ba_enable_beacon_abort = %d\n",
  463. le32_to_cpu(cmd.ba_enable_beacon_abort));
  464. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  465. }
  466. static inline char *iwl_dbgfs_is_match(char *name, char *buf)
  467. {
  468. int len = strlen(name);
  469. return !strncmp(name, buf, len) ? buf + len : NULL;
  470. }
  471. static ssize_t iwl_dbgfs_os_device_timediff_read(struct file *file,
  472. char __user *user_buf,
  473. size_t count, loff_t *ppos)
  474. {
  475. struct ieee80211_vif *vif = file->private_data;
  476. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  477. struct iwl_mvm *mvm = mvmvif->mvm;
  478. u32 curr_gp2;
  479. u64 curr_os;
  480. s64 diff;
  481. char buf[64];
  482. const size_t bufsz = sizeof(buf);
  483. int pos = 0;
  484. mutex_lock(&mvm->mutex);
  485. iwl_mvm_get_sync_time(mvm, &curr_gp2, &curr_os);
  486. mutex_unlock(&mvm->mutex);
  487. do_div(curr_os, NSEC_PER_USEC);
  488. diff = curr_os - curr_gp2;
  489. pos += scnprintf(buf + pos, bufsz - pos, "diff=%lld\n", diff);
  490. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  491. }
  492. static ssize_t iwl_dbgfs_tof_enable_write(struct ieee80211_vif *vif,
  493. char *buf,
  494. size_t count, loff_t *ppos)
  495. {
  496. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  497. struct iwl_mvm *mvm = mvmvif->mvm;
  498. u32 value;
  499. int ret = -EINVAL;
  500. char *data;
  501. mutex_lock(&mvm->mutex);
  502. data = iwl_dbgfs_is_match("tof_disabled=", buf);
  503. if (data) {
  504. ret = kstrtou32(data, 10, &value);
  505. if (ret == 0)
  506. mvm->tof_data.tof_cfg.tof_disabled = value;
  507. goto out;
  508. }
  509. data = iwl_dbgfs_is_match("one_sided_disabled=", buf);
  510. if (data) {
  511. ret = kstrtou32(data, 10, &value);
  512. if (ret == 0)
  513. mvm->tof_data.tof_cfg.one_sided_disabled = value;
  514. goto out;
  515. }
  516. data = iwl_dbgfs_is_match("is_debug_mode=", buf);
  517. if (data) {
  518. ret = kstrtou32(data, 10, &value);
  519. if (ret == 0)
  520. mvm->tof_data.tof_cfg.is_debug_mode = value;
  521. goto out;
  522. }
  523. data = iwl_dbgfs_is_match("is_buf=", buf);
  524. if (data) {
  525. ret = kstrtou32(data, 10, &value);
  526. if (ret == 0)
  527. mvm->tof_data.tof_cfg.is_buf_required = value;
  528. goto out;
  529. }
  530. data = iwl_dbgfs_is_match("send_tof_cfg=", buf);
  531. if (data) {
  532. ret = kstrtou32(data, 10, &value);
  533. if (ret == 0 && value) {
  534. ret = iwl_mvm_tof_config_cmd(mvm);
  535. goto out;
  536. }
  537. }
  538. out:
  539. mutex_unlock(&mvm->mutex);
  540. return ret ?: count;
  541. }
  542. static ssize_t iwl_dbgfs_tof_enable_read(struct file *file,
  543. char __user *user_buf,
  544. size_t count, loff_t *ppos)
  545. {
  546. struct ieee80211_vif *vif = file->private_data;
  547. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  548. struct iwl_mvm *mvm = mvmvif->mvm;
  549. char buf[256];
  550. int pos = 0;
  551. const size_t bufsz = sizeof(buf);
  552. struct iwl_tof_config_cmd *cmd;
  553. cmd = &mvm->tof_data.tof_cfg;
  554. mutex_lock(&mvm->mutex);
  555. pos += scnprintf(buf + pos, bufsz - pos, "tof_disabled = %d\n",
  556. cmd->tof_disabled);
  557. pos += scnprintf(buf + pos, bufsz - pos, "one_sided_disabled = %d\n",
  558. cmd->one_sided_disabled);
  559. pos += scnprintf(buf + pos, bufsz - pos, "is_debug_mode = %d\n",
  560. cmd->is_debug_mode);
  561. pos += scnprintf(buf + pos, bufsz - pos, "is_buf_required = %d\n",
  562. cmd->is_buf_required);
  563. mutex_unlock(&mvm->mutex);
  564. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  565. }
  566. static ssize_t iwl_dbgfs_tof_responder_params_write(struct ieee80211_vif *vif,
  567. char *buf,
  568. size_t count, loff_t *ppos)
  569. {
  570. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  571. struct iwl_mvm *mvm = mvmvif->mvm;
  572. u32 value;
  573. int ret = 0;
  574. char *data;
  575. mutex_lock(&mvm->mutex);
  576. data = iwl_dbgfs_is_match("burst_period=", buf);
  577. if (data) {
  578. ret = kstrtou32(data, 10, &value);
  579. if (!ret)
  580. mvm->tof_data.responder_cfg.burst_period =
  581. cpu_to_le16(value);
  582. goto out;
  583. }
  584. data = iwl_dbgfs_is_match("min_delta_ftm=", buf);
  585. if (data) {
  586. ret = kstrtou32(data, 10, &value);
  587. if (ret == 0)
  588. mvm->tof_data.responder_cfg.min_delta_ftm = value;
  589. goto out;
  590. }
  591. data = iwl_dbgfs_is_match("burst_duration=", buf);
  592. if (data) {
  593. ret = kstrtou32(data, 10, &value);
  594. if (ret == 0)
  595. mvm->tof_data.responder_cfg.burst_duration = value;
  596. goto out;
  597. }
  598. data = iwl_dbgfs_is_match("num_of_burst_exp=", buf);
  599. if (data) {
  600. ret = kstrtou32(data, 10, &value);
  601. if (ret == 0)
  602. mvm->tof_data.responder_cfg.num_of_burst_exp = value;
  603. goto out;
  604. }
  605. data = iwl_dbgfs_is_match("abort_responder=", buf);
  606. if (data) {
  607. ret = kstrtou32(data, 10, &value);
  608. if (ret == 0)
  609. mvm->tof_data.responder_cfg.abort_responder = value;
  610. goto out;
  611. }
  612. data = iwl_dbgfs_is_match("get_ch_est=", buf);
  613. if (data) {
  614. ret = kstrtou32(data, 10, &value);
  615. if (ret == 0)
  616. mvm->tof_data.responder_cfg.get_ch_est = value;
  617. goto out;
  618. }
  619. data = iwl_dbgfs_is_match("recv_sta_req_params=", buf);
  620. if (data) {
  621. ret = kstrtou32(data, 10, &value);
  622. if (ret == 0)
  623. mvm->tof_data.responder_cfg.recv_sta_req_params = value;
  624. goto out;
  625. }
  626. data = iwl_dbgfs_is_match("channel_num=", buf);
  627. if (data) {
  628. ret = kstrtou32(data, 10, &value);
  629. if (ret == 0)
  630. mvm->tof_data.responder_cfg.channel_num = value;
  631. goto out;
  632. }
  633. data = iwl_dbgfs_is_match("bandwidth=", buf);
  634. if (data) {
  635. ret = kstrtou32(data, 10, &value);
  636. if (ret == 0)
  637. mvm->tof_data.responder_cfg.bandwidth = value;
  638. goto out;
  639. }
  640. data = iwl_dbgfs_is_match("rate=", buf);
  641. if (data) {
  642. ret = kstrtou32(data, 10, &value);
  643. if (ret == 0)
  644. mvm->tof_data.responder_cfg.rate = value;
  645. goto out;
  646. }
  647. data = iwl_dbgfs_is_match("bssid=", buf);
  648. if (data) {
  649. u8 *mac = mvm->tof_data.responder_cfg.bssid;
  650. if (!mac_pton(data, mac)) {
  651. ret = -EINVAL;
  652. goto out;
  653. }
  654. }
  655. data = iwl_dbgfs_is_match("tsf_timer_offset_msecs=", buf);
  656. if (data) {
  657. ret = kstrtou32(data, 10, &value);
  658. if (ret == 0)
  659. mvm->tof_data.responder_cfg.tsf_timer_offset_msecs =
  660. cpu_to_le16(value);
  661. goto out;
  662. }
  663. data = iwl_dbgfs_is_match("toa_offset=", buf);
  664. if (data) {
  665. ret = kstrtou32(data, 10, &value);
  666. if (ret == 0)
  667. mvm->tof_data.responder_cfg.toa_offset =
  668. cpu_to_le16(value);
  669. goto out;
  670. }
  671. data = iwl_dbgfs_is_match("center_freq=", buf);
  672. if (data) {
  673. struct iwl_tof_responder_config_cmd *cmd =
  674. &mvm->tof_data.responder_cfg;
  675. ret = kstrtou32(data, 10, &value);
  676. if (ret == 0 && value) {
  677. enum nl80211_band band = (cmd->channel_num <= 14) ?
  678. NL80211_BAND_2GHZ :
  679. NL80211_BAND_5GHZ;
  680. struct ieee80211_channel chn = {
  681. .band = band,
  682. .center_freq = ieee80211_channel_to_frequency(
  683. cmd->channel_num, band),
  684. };
  685. struct cfg80211_chan_def chandef = {
  686. .chan = &chn,
  687. .center_freq1 =
  688. ieee80211_channel_to_frequency(value,
  689. band),
  690. };
  691. cmd->ctrl_ch_position = iwl_mvm_get_ctrl_pos(&chandef);
  692. }
  693. goto out;
  694. }
  695. data = iwl_dbgfs_is_match("ftm_per_burst=", buf);
  696. if (data) {
  697. ret = kstrtou32(data, 10, &value);
  698. if (ret == 0)
  699. mvm->tof_data.responder_cfg.ftm_per_burst = value;
  700. goto out;
  701. }
  702. data = iwl_dbgfs_is_match("ftm_resp_ts_avail=", buf);
  703. if (data) {
  704. ret = kstrtou32(data, 10, &value);
  705. if (ret == 0)
  706. mvm->tof_data.responder_cfg.ftm_resp_ts_avail = value;
  707. goto out;
  708. }
  709. data = iwl_dbgfs_is_match("asap_mode=", buf);
  710. if (data) {
  711. ret = kstrtou32(data, 10, &value);
  712. if (ret == 0)
  713. mvm->tof_data.responder_cfg.asap_mode = value;
  714. goto out;
  715. }
  716. data = iwl_dbgfs_is_match("send_responder_cfg=", buf);
  717. if (data) {
  718. ret = kstrtou32(data, 10, &value);
  719. if (ret == 0 && value) {
  720. ret = iwl_mvm_tof_responder_cmd(mvm, vif);
  721. goto out;
  722. }
  723. }
  724. out:
  725. mutex_unlock(&mvm->mutex);
  726. return ret ?: count;
  727. }
  728. static ssize_t iwl_dbgfs_tof_responder_params_read(struct file *file,
  729. char __user *user_buf,
  730. size_t count, loff_t *ppos)
  731. {
  732. struct ieee80211_vif *vif = file->private_data;
  733. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  734. struct iwl_mvm *mvm = mvmvif->mvm;
  735. char buf[256];
  736. int pos = 0;
  737. const size_t bufsz = sizeof(buf);
  738. struct iwl_tof_responder_config_cmd *cmd;
  739. cmd = &mvm->tof_data.responder_cfg;
  740. mutex_lock(&mvm->mutex);
  741. pos += scnprintf(buf + pos, bufsz - pos, "burst_period = %d\n",
  742. le16_to_cpu(cmd->burst_period));
  743. pos += scnprintf(buf + pos, bufsz - pos, "burst_duration = %d\n",
  744. cmd->burst_duration);
  745. pos += scnprintf(buf + pos, bufsz - pos, "bandwidth = %d\n",
  746. cmd->bandwidth);
  747. pos += scnprintf(buf + pos, bufsz - pos, "channel_num = %d\n",
  748. cmd->channel_num);
  749. pos += scnprintf(buf + pos, bufsz - pos, "ctrl_ch_position = 0x%x\n",
  750. cmd->ctrl_ch_position);
  751. pos += scnprintf(buf + pos, bufsz - pos, "bssid = %pM\n",
  752. cmd->bssid);
  753. pos += scnprintf(buf + pos, bufsz - pos, "min_delta_ftm = %d\n",
  754. cmd->min_delta_ftm);
  755. pos += scnprintf(buf + pos, bufsz - pos, "num_of_burst_exp = %d\n",
  756. cmd->num_of_burst_exp);
  757. pos += scnprintf(buf + pos, bufsz - pos, "rate = %d\n", cmd->rate);
  758. pos += scnprintf(buf + pos, bufsz - pos, "abort_responder = %d\n",
  759. cmd->abort_responder);
  760. pos += scnprintf(buf + pos, bufsz - pos, "get_ch_est = %d\n",
  761. cmd->get_ch_est);
  762. pos += scnprintf(buf + pos, bufsz - pos, "recv_sta_req_params = %d\n",
  763. cmd->recv_sta_req_params);
  764. pos += scnprintf(buf + pos, bufsz - pos, "ftm_per_burst = %d\n",
  765. cmd->ftm_per_burst);
  766. pos += scnprintf(buf + pos, bufsz - pos, "ftm_resp_ts_avail = %d\n",
  767. cmd->ftm_resp_ts_avail);
  768. pos += scnprintf(buf + pos, bufsz - pos, "asap_mode = %d\n",
  769. cmd->asap_mode);
  770. pos += scnprintf(buf + pos, bufsz - pos,
  771. "tsf_timer_offset_msecs = %d\n",
  772. le16_to_cpu(cmd->tsf_timer_offset_msecs));
  773. pos += scnprintf(buf + pos, bufsz - pos, "toa_offset = %d\n",
  774. le16_to_cpu(cmd->toa_offset));
  775. mutex_unlock(&mvm->mutex);
  776. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  777. }
  778. static ssize_t iwl_dbgfs_tof_range_request_write(struct ieee80211_vif *vif,
  779. char *buf, size_t count,
  780. loff_t *ppos)
  781. {
  782. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  783. struct iwl_mvm *mvm = mvmvif->mvm;
  784. u32 value;
  785. int ret = 0;
  786. char *data;
  787. mutex_lock(&mvm->mutex);
  788. data = iwl_dbgfs_is_match("request_id=", buf);
  789. if (data) {
  790. ret = kstrtou32(data, 10, &value);
  791. if (ret == 0)
  792. mvm->tof_data.range_req.request_id = value;
  793. goto out;
  794. }
  795. data = iwl_dbgfs_is_match("initiator=", buf);
  796. if (data) {
  797. ret = kstrtou32(data, 10, &value);
  798. if (ret == 0)
  799. mvm->tof_data.range_req.initiator = value;
  800. goto out;
  801. }
  802. data = iwl_dbgfs_is_match("one_sided_los_disable=", buf);
  803. if (data) {
  804. ret = kstrtou32(data, 10, &value);
  805. if (ret == 0)
  806. mvm->tof_data.range_req.one_sided_los_disable = value;
  807. goto out;
  808. }
  809. data = iwl_dbgfs_is_match("req_timeout=", buf);
  810. if (data) {
  811. ret = kstrtou32(data, 10, &value);
  812. if (ret == 0)
  813. mvm->tof_data.range_req.req_timeout = value;
  814. goto out;
  815. }
  816. data = iwl_dbgfs_is_match("report_policy=", buf);
  817. if (data) {
  818. ret = kstrtou32(data, 10, &value);
  819. if (ret == 0)
  820. mvm->tof_data.range_req.report_policy = value;
  821. goto out;
  822. }
  823. data = iwl_dbgfs_is_match("macaddr_random=", buf);
  824. if (data) {
  825. ret = kstrtou32(data, 10, &value);
  826. if (ret == 0)
  827. mvm->tof_data.range_req.macaddr_random = value;
  828. goto out;
  829. }
  830. data = iwl_dbgfs_is_match("num_of_ap=", buf);
  831. if (data) {
  832. ret = kstrtou32(data, 10, &value);
  833. if (ret == 0)
  834. mvm->tof_data.range_req.num_of_ap = value;
  835. goto out;
  836. }
  837. data = iwl_dbgfs_is_match("macaddr_template=", buf);
  838. if (data) {
  839. u8 mac[ETH_ALEN];
  840. if (!mac_pton(data, mac)) {
  841. ret = -EINVAL;
  842. goto out;
  843. }
  844. memcpy(mvm->tof_data.range_req.macaddr_template, mac, ETH_ALEN);
  845. goto out;
  846. }
  847. data = iwl_dbgfs_is_match("macaddr_mask=", buf);
  848. if (data) {
  849. u8 mac[ETH_ALEN];
  850. if (!mac_pton(data, mac)) {
  851. ret = -EINVAL;
  852. goto out;
  853. }
  854. memcpy(mvm->tof_data.range_req.macaddr_mask, mac, ETH_ALEN);
  855. goto out;
  856. }
  857. data = iwl_dbgfs_is_match("ap=", buf);
  858. if (data) {
  859. struct iwl_tof_range_req_ap_entry ap = {};
  860. int size = sizeof(struct iwl_tof_range_req_ap_entry);
  861. u16 burst_period;
  862. u8 *mac = ap.bssid;
  863. unsigned int i;
  864. if (sscanf(data, "%u %hhd %hhd %hhd"
  865. "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx"
  866. "%hhd %hhd %hd"
  867. "%hhd %hhd %d"
  868. "%hhx %hhd %hhd %hhd",
  869. &i, &ap.channel_num, &ap.bandwidth,
  870. &ap.ctrl_ch_position,
  871. mac, mac + 1, mac + 2, mac + 3, mac + 4, mac + 5,
  872. &ap.measure_type, &ap.num_of_bursts,
  873. &burst_period,
  874. &ap.samples_per_burst, &ap.retries_per_sample,
  875. &ap.tsf_delta, &ap.location_req, &ap.asap_mode,
  876. &ap.enable_dyn_ack, &ap.rssi) != 20) {
  877. ret = -EINVAL;
  878. goto out;
  879. }
  880. if (i >= IWL_MVM_TOF_MAX_APS) {
  881. IWL_ERR(mvm, "Invalid AP index %d\n", i);
  882. ret = -EINVAL;
  883. goto out;
  884. }
  885. ap.burst_period = cpu_to_le16(burst_period);
  886. memcpy(&mvm->tof_data.range_req.ap[i], &ap, size);
  887. goto out;
  888. }
  889. data = iwl_dbgfs_is_match("send_range_request=", buf);
  890. if (data) {
  891. ret = kstrtou32(data, 10, &value);
  892. if (ret == 0 && value)
  893. ret = iwl_mvm_tof_range_request_cmd(mvm, vif);
  894. goto out;
  895. }
  896. ret = -EINVAL;
  897. out:
  898. mutex_unlock(&mvm->mutex);
  899. return ret ?: count;
  900. }
  901. static ssize_t iwl_dbgfs_tof_range_request_read(struct file *file,
  902. char __user *user_buf,
  903. size_t count, loff_t *ppos)
  904. {
  905. struct ieee80211_vif *vif = file->private_data;
  906. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  907. struct iwl_mvm *mvm = mvmvif->mvm;
  908. char buf[512];
  909. int pos = 0;
  910. const size_t bufsz = sizeof(buf);
  911. struct iwl_tof_range_req_cmd *cmd;
  912. int i;
  913. cmd = &mvm->tof_data.range_req;
  914. mutex_lock(&mvm->mutex);
  915. pos += scnprintf(buf + pos, bufsz - pos, "request_id= %d\n",
  916. cmd->request_id);
  917. pos += scnprintf(buf + pos, bufsz - pos, "initiator= %d\n",
  918. cmd->initiator);
  919. pos += scnprintf(buf + pos, bufsz - pos, "one_sided_los_disable = %d\n",
  920. cmd->one_sided_los_disable);
  921. pos += scnprintf(buf + pos, bufsz - pos, "req_timeout= %d\n",
  922. cmd->req_timeout);
  923. pos += scnprintf(buf + pos, bufsz - pos, "report_policy= %d\n",
  924. cmd->report_policy);
  925. pos += scnprintf(buf + pos, bufsz - pos, "macaddr_random= %d\n",
  926. cmd->macaddr_random);
  927. pos += scnprintf(buf + pos, bufsz - pos, "macaddr_template= %pM\n",
  928. cmd->macaddr_template);
  929. pos += scnprintf(buf + pos, bufsz - pos, "macaddr_mask= %pM\n",
  930. cmd->macaddr_mask);
  931. pos += scnprintf(buf + pos, bufsz - pos, "num_of_ap= %d\n",
  932. cmd->num_of_ap);
  933. for (i = 0; i < cmd->num_of_ap; i++) {
  934. struct iwl_tof_range_req_ap_entry *ap = &cmd->ap[i];
  935. pos += scnprintf(buf + pos, bufsz - pos,
  936. "ap %.2d: channel_num=%hhd bw=%hhd"
  937. " control=%hhd bssid=%pM type=%hhd"
  938. " num_of_bursts=%hhd burst_period=%hd ftm=%hhd"
  939. " retries=%hhd tsf_delta=%d"
  940. " tsf_delta_direction=%hhd location_req=0x%hhx "
  941. " asap=%hhd enable=%hhd rssi=%hhd\n",
  942. i, ap->channel_num, ap->bandwidth,
  943. ap->ctrl_ch_position, ap->bssid,
  944. ap->measure_type, ap->num_of_bursts,
  945. ap->burst_period, ap->samples_per_burst,
  946. ap->retries_per_sample, ap->tsf_delta,
  947. ap->tsf_delta_direction,
  948. ap->location_req, ap->asap_mode,
  949. ap->enable_dyn_ack, ap->rssi);
  950. }
  951. mutex_unlock(&mvm->mutex);
  952. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  953. }
  954. static ssize_t iwl_dbgfs_tof_range_req_ext_write(struct ieee80211_vif *vif,
  955. char *buf,
  956. size_t count, loff_t *ppos)
  957. {
  958. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  959. struct iwl_mvm *mvm = mvmvif->mvm;
  960. u32 value;
  961. int ret = 0;
  962. char *data;
  963. mutex_lock(&mvm->mutex);
  964. data = iwl_dbgfs_is_match("tsf_timer_offset_msec=", buf);
  965. if (data) {
  966. ret = kstrtou32(data, 10, &value);
  967. if (ret == 0)
  968. mvm->tof_data.range_req_ext.tsf_timer_offset_msec =
  969. cpu_to_le16(value);
  970. goto out;
  971. }
  972. data = iwl_dbgfs_is_match("min_delta_ftm=", buf);
  973. if (data) {
  974. ret = kstrtou32(data, 10, &value);
  975. if (ret == 0)
  976. mvm->tof_data.range_req_ext.min_delta_ftm = value;
  977. goto out;
  978. }
  979. data = iwl_dbgfs_is_match("ftm_format_and_bw20M=", buf);
  980. if (data) {
  981. ret = kstrtou32(data, 10, &value);
  982. if (ret == 0)
  983. mvm->tof_data.range_req_ext.ftm_format_and_bw20M =
  984. value;
  985. goto out;
  986. }
  987. data = iwl_dbgfs_is_match("ftm_format_and_bw40M=", buf);
  988. if (data) {
  989. ret = kstrtou32(data, 10, &value);
  990. if (ret == 0)
  991. mvm->tof_data.range_req_ext.ftm_format_and_bw40M =
  992. value;
  993. goto out;
  994. }
  995. data = iwl_dbgfs_is_match("ftm_format_and_bw80M=", buf);
  996. if (data) {
  997. ret = kstrtou32(data, 10, &value);
  998. if (ret == 0)
  999. mvm->tof_data.range_req_ext.ftm_format_and_bw80M =
  1000. value;
  1001. goto out;
  1002. }
  1003. data = iwl_dbgfs_is_match("send_range_req_ext=", buf);
  1004. if (data) {
  1005. ret = kstrtou32(data, 10, &value);
  1006. if (ret == 0 && value)
  1007. ret = iwl_mvm_tof_range_request_ext_cmd(mvm, vif);
  1008. goto out;
  1009. }
  1010. ret = -EINVAL;
  1011. out:
  1012. mutex_unlock(&mvm->mutex);
  1013. return ret ?: count;
  1014. }
  1015. static ssize_t iwl_dbgfs_tof_range_req_ext_read(struct file *file,
  1016. char __user *user_buf,
  1017. size_t count, loff_t *ppos)
  1018. {
  1019. struct ieee80211_vif *vif = file->private_data;
  1020. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1021. struct iwl_mvm *mvm = mvmvif->mvm;
  1022. char buf[256];
  1023. int pos = 0;
  1024. const size_t bufsz = sizeof(buf);
  1025. struct iwl_tof_range_req_ext_cmd *cmd;
  1026. cmd = &mvm->tof_data.range_req_ext;
  1027. mutex_lock(&mvm->mutex);
  1028. pos += scnprintf(buf + pos, bufsz - pos,
  1029. "tsf_timer_offset_msec = %hd\n",
  1030. cmd->tsf_timer_offset_msec);
  1031. pos += scnprintf(buf + pos, bufsz - pos, "min_delta_ftm = %hhd\n",
  1032. cmd->min_delta_ftm);
  1033. pos += scnprintf(buf + pos, bufsz - pos,
  1034. "ftm_format_and_bw20M = %hhd\n",
  1035. cmd->ftm_format_and_bw20M);
  1036. pos += scnprintf(buf + pos, bufsz - pos,
  1037. "ftm_format_and_bw40M = %hhd\n",
  1038. cmd->ftm_format_and_bw40M);
  1039. pos += scnprintf(buf + pos, bufsz - pos,
  1040. "ftm_format_and_bw80M = %hhd\n",
  1041. cmd->ftm_format_and_bw80M);
  1042. mutex_unlock(&mvm->mutex);
  1043. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1044. }
  1045. static ssize_t iwl_dbgfs_tof_range_abort_write(struct ieee80211_vif *vif,
  1046. char *buf,
  1047. size_t count, loff_t *ppos)
  1048. {
  1049. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1050. struct iwl_mvm *mvm = mvmvif->mvm;
  1051. u32 value;
  1052. int abort_id, ret = 0;
  1053. char *data;
  1054. mutex_lock(&mvm->mutex);
  1055. data = iwl_dbgfs_is_match("abort_id=", buf);
  1056. if (data) {
  1057. ret = kstrtou32(data, 10, &value);
  1058. if (ret == 0)
  1059. mvm->tof_data.last_abort_id = value;
  1060. goto out;
  1061. }
  1062. data = iwl_dbgfs_is_match("send_range_abort=", buf);
  1063. if (data) {
  1064. ret = kstrtou32(data, 10, &value);
  1065. if (ret == 0 && value) {
  1066. abort_id = mvm->tof_data.last_abort_id;
  1067. ret = iwl_mvm_tof_range_abort_cmd(mvm, abort_id);
  1068. goto out;
  1069. }
  1070. }
  1071. out:
  1072. mutex_unlock(&mvm->mutex);
  1073. return ret ?: count;
  1074. }
  1075. static ssize_t iwl_dbgfs_tof_range_abort_read(struct file *file,
  1076. char __user *user_buf,
  1077. size_t count, loff_t *ppos)
  1078. {
  1079. struct ieee80211_vif *vif = file->private_data;
  1080. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1081. struct iwl_mvm *mvm = mvmvif->mvm;
  1082. char buf[32];
  1083. int pos = 0;
  1084. const size_t bufsz = sizeof(buf);
  1085. int last_abort_id;
  1086. mutex_lock(&mvm->mutex);
  1087. last_abort_id = mvm->tof_data.last_abort_id;
  1088. mutex_unlock(&mvm->mutex);
  1089. pos += scnprintf(buf + pos, bufsz - pos, "last_abort_id = %d\n",
  1090. last_abort_id);
  1091. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1092. }
  1093. static ssize_t iwl_dbgfs_tof_range_response_read(struct file *file,
  1094. char __user *user_buf,
  1095. size_t count, loff_t *ppos)
  1096. {
  1097. struct ieee80211_vif *vif = file->private_data;
  1098. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1099. struct iwl_mvm *mvm = mvmvif->mvm;
  1100. char *buf;
  1101. int pos = 0;
  1102. const size_t bufsz = sizeof(struct iwl_tof_range_rsp_ntfy) + 256;
  1103. struct iwl_tof_range_rsp_ntfy *cmd;
  1104. int i, ret;
  1105. buf = kzalloc(bufsz, GFP_KERNEL);
  1106. if (!buf)
  1107. return -ENOMEM;
  1108. mutex_lock(&mvm->mutex);
  1109. cmd = &mvm->tof_data.range_resp;
  1110. pos += scnprintf(buf + pos, bufsz - pos, "request_id = %d\n",
  1111. cmd->request_id);
  1112. pos += scnprintf(buf + pos, bufsz - pos, "status = %d\n",
  1113. cmd->request_status);
  1114. pos += scnprintf(buf + pos, bufsz - pos, "last_in_batch = %d\n",
  1115. cmd->last_in_batch);
  1116. pos += scnprintf(buf + pos, bufsz - pos, "num_of_aps = %d\n",
  1117. cmd->num_of_aps);
  1118. for (i = 0; i < cmd->num_of_aps; i++) {
  1119. struct iwl_tof_range_rsp_ap_entry_ntfy *ap = &cmd->ap[i];
  1120. pos += scnprintf(buf + pos, bufsz - pos,
  1121. "ap %.2d: bssid=%pM status=%hhd bw=%hhd"
  1122. " rtt=%d rtt_var=%d rtt_spread=%d"
  1123. " rssi=%hhd rssi_spread=%hhd"
  1124. " range=%d range_var=%d"
  1125. " time_stamp=%d\n",
  1126. i, ap->bssid, ap->measure_status,
  1127. ap->measure_bw,
  1128. ap->rtt, ap->rtt_variance, ap->rtt_spread,
  1129. ap->rssi, ap->rssi_spread, ap->range,
  1130. ap->range_variance, ap->timestamp);
  1131. }
  1132. mutex_unlock(&mvm->mutex);
  1133. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1134. kfree(buf);
  1135. return ret;
  1136. }
  1137. static ssize_t iwl_dbgfs_low_latency_write(struct ieee80211_vif *vif, char *buf,
  1138. size_t count, loff_t *ppos)
  1139. {
  1140. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1141. struct iwl_mvm *mvm = mvmvif->mvm;
  1142. u8 value;
  1143. int ret;
  1144. ret = kstrtou8(buf, 0, &value);
  1145. if (ret)
  1146. return ret;
  1147. if (value > 1)
  1148. return -EINVAL;
  1149. mutex_lock(&mvm->mutex);
  1150. iwl_mvm_update_low_latency(mvm, vif, value, LOW_LATENCY_DEBUGFS);
  1151. mutex_unlock(&mvm->mutex);
  1152. return count;
  1153. }
  1154. static ssize_t iwl_dbgfs_low_latency_read(struct file *file,
  1155. char __user *user_buf,
  1156. size_t count, loff_t *ppos)
  1157. {
  1158. struct ieee80211_vif *vif = file->private_data;
  1159. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1160. char buf[30] = {};
  1161. int len;
  1162. len = scnprintf(buf, sizeof(buf) - 1,
  1163. "traffic=%d\ndbgfs=%d\nvcmd=%d\n",
  1164. !!(mvmvif->low_latency & LOW_LATENCY_TRAFFIC),
  1165. !!(mvmvif->low_latency & LOW_LATENCY_DEBUGFS),
  1166. !!(mvmvif->low_latency & LOW_LATENCY_VCMD));
  1167. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1168. }
  1169. static ssize_t iwl_dbgfs_uapsd_misbehaving_read(struct file *file,
  1170. char __user *user_buf,
  1171. size_t count, loff_t *ppos)
  1172. {
  1173. struct ieee80211_vif *vif = file->private_data;
  1174. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1175. char buf[20];
  1176. int len;
  1177. len = sprintf(buf, "%pM\n", mvmvif->uapsd_misbehaving_bssid);
  1178. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1179. }
  1180. static ssize_t iwl_dbgfs_uapsd_misbehaving_write(struct ieee80211_vif *vif,
  1181. char *buf, size_t count,
  1182. loff_t *ppos)
  1183. {
  1184. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1185. struct iwl_mvm *mvm = mvmvif->mvm;
  1186. bool ret;
  1187. mutex_lock(&mvm->mutex);
  1188. ret = mac_pton(buf, mvmvif->uapsd_misbehaving_bssid);
  1189. mutex_unlock(&mvm->mutex);
  1190. return ret ? count : -EINVAL;
  1191. }
  1192. static ssize_t iwl_dbgfs_rx_phyinfo_write(struct ieee80211_vif *vif, char *buf,
  1193. size_t count, loff_t *ppos)
  1194. {
  1195. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1196. struct iwl_mvm *mvm = mvmvif->mvm;
  1197. struct ieee80211_chanctx_conf *chanctx_conf;
  1198. struct iwl_mvm_phy_ctxt *phy_ctxt;
  1199. u16 value;
  1200. int ret;
  1201. ret = kstrtou16(buf, 0, &value);
  1202. if (ret)
  1203. return ret;
  1204. mutex_lock(&mvm->mutex);
  1205. rcu_read_lock();
  1206. chanctx_conf = rcu_dereference(vif->chanctx_conf);
  1207. /* make sure the channel context is assigned */
  1208. if (!chanctx_conf) {
  1209. rcu_read_unlock();
  1210. mutex_unlock(&mvm->mutex);
  1211. return -EINVAL;
  1212. }
  1213. phy_ctxt = &mvm->phy_ctxts[*(u16 *)chanctx_conf->drv_priv];
  1214. rcu_read_unlock();
  1215. mvm->dbgfs_rx_phyinfo = value;
  1216. ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chanctx_conf->min_def,
  1217. chanctx_conf->rx_chains_static,
  1218. chanctx_conf->rx_chains_dynamic);
  1219. mutex_unlock(&mvm->mutex);
  1220. return ret ?: count;
  1221. }
  1222. static ssize_t iwl_dbgfs_rx_phyinfo_read(struct file *file,
  1223. char __user *user_buf,
  1224. size_t count, loff_t *ppos)
  1225. {
  1226. struct ieee80211_vif *vif = file->private_data;
  1227. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1228. char buf[8];
  1229. int len;
  1230. len = scnprintf(buf, sizeof(buf), "0x%04x\n",
  1231. mvmvif->mvm->dbgfs_rx_phyinfo);
  1232. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1233. }
  1234. static void iwl_dbgfs_quota_check(void *data, u8 *mac,
  1235. struct ieee80211_vif *vif)
  1236. {
  1237. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1238. int *ret = data;
  1239. if (mvmvif->dbgfs_quota_min)
  1240. *ret = -EINVAL;
  1241. }
  1242. static ssize_t iwl_dbgfs_quota_min_write(struct ieee80211_vif *vif, char *buf,
  1243. size_t count, loff_t *ppos)
  1244. {
  1245. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1246. struct iwl_mvm *mvm = mvmvif->mvm;
  1247. u16 value;
  1248. int ret;
  1249. ret = kstrtou16(buf, 0, &value);
  1250. if (ret)
  1251. return ret;
  1252. if (value > 95)
  1253. return -EINVAL;
  1254. mutex_lock(&mvm->mutex);
  1255. mvmvif->dbgfs_quota_min = 0;
  1256. ieee80211_iterate_interfaces(mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
  1257. iwl_dbgfs_quota_check, &ret);
  1258. if (ret == 0) {
  1259. mvmvif->dbgfs_quota_min = value;
  1260. iwl_mvm_update_quotas(mvm, false, NULL);
  1261. }
  1262. mutex_unlock(&mvm->mutex);
  1263. return ret ?: count;
  1264. }
  1265. static ssize_t iwl_dbgfs_quota_min_read(struct file *file,
  1266. char __user *user_buf,
  1267. size_t count, loff_t *ppos)
  1268. {
  1269. struct ieee80211_vif *vif = file->private_data;
  1270. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1271. char buf[10];
  1272. int len;
  1273. len = scnprintf(buf, sizeof(buf), "%d\n", mvmvif->dbgfs_quota_min);
  1274. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1275. }
  1276. static const char * const chanwidths[] = {
  1277. [NL80211_CHAN_WIDTH_20_NOHT] = "noht",
  1278. [NL80211_CHAN_WIDTH_20] = "ht20",
  1279. [NL80211_CHAN_WIDTH_40] = "ht40",
  1280. [NL80211_CHAN_WIDTH_80] = "vht80",
  1281. [NL80211_CHAN_WIDTH_80P80] = "vht80p80",
  1282. [NL80211_CHAN_WIDTH_160] = "vht160",
  1283. };
  1284. #define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \
  1285. _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct ieee80211_vif)
  1286. #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz) \
  1287. _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct ieee80211_vif)
  1288. #define MVM_DEBUGFS_ADD_FILE_VIF(name, parent, mode) do { \
  1289. if (!debugfs_create_file(#name, mode, parent, vif, \
  1290. &iwl_dbgfs_##name##_ops)) \
  1291. goto err; \
  1292. } while (0)
  1293. MVM_DEBUGFS_READ_FILE_OPS(mac_params);
  1294. MVM_DEBUGFS_READ_FILE_OPS(tx_pwr_lmt);
  1295. MVM_DEBUGFS_READ_WRITE_FILE_OPS(pm_params, 32);
  1296. MVM_DEBUGFS_READ_WRITE_FILE_OPS(bf_params, 256);
  1297. MVM_DEBUGFS_READ_WRITE_FILE_OPS(low_latency, 10);
  1298. MVM_DEBUGFS_READ_WRITE_FILE_OPS(uapsd_misbehaving, 20);
  1299. MVM_DEBUGFS_READ_WRITE_FILE_OPS(rx_phyinfo, 10);
  1300. MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_enable, 32);
  1301. MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_range_request, 512);
  1302. MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_range_req_ext, 32);
  1303. MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_range_abort, 32);
  1304. MVM_DEBUGFS_READ_FILE_OPS(tof_range_response);
  1305. MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_responder_params, 32);
  1306. MVM_DEBUGFS_READ_WRITE_FILE_OPS(quota_min, 32);
  1307. MVM_DEBUGFS_READ_FILE_OPS(os_device_timediff);
  1308. void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  1309. {
  1310. struct dentry *dbgfs_dir = vif->debugfs_dir;
  1311. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1312. char buf[100];
  1313. /*
  1314. * Check if debugfs directory already exist before creating it.
  1315. * This may happen when, for example, resetting hw or suspend-resume
  1316. */
  1317. if (!dbgfs_dir || mvmvif->dbgfs_dir)
  1318. return;
  1319. mvmvif->dbgfs_dir = debugfs_create_dir("iwlmvm", dbgfs_dir);
  1320. if (!mvmvif->dbgfs_dir) {
  1321. IWL_ERR(mvm, "Failed to create debugfs directory under %pd\n",
  1322. dbgfs_dir);
  1323. return;
  1324. }
  1325. if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM &&
  1326. ((vif->type == NL80211_IFTYPE_STATION && !vif->p2p) ||
  1327. (vif->type == NL80211_IFTYPE_STATION && vif->p2p)))
  1328. MVM_DEBUGFS_ADD_FILE_VIF(pm_params, mvmvif->dbgfs_dir, 0600);
  1329. MVM_DEBUGFS_ADD_FILE_VIF(tx_pwr_lmt, mvmvif->dbgfs_dir, 0400);
  1330. MVM_DEBUGFS_ADD_FILE_VIF(mac_params, mvmvif->dbgfs_dir, 0400);
  1331. MVM_DEBUGFS_ADD_FILE_VIF(low_latency, mvmvif->dbgfs_dir, 0600);
  1332. MVM_DEBUGFS_ADD_FILE_VIF(uapsd_misbehaving, mvmvif->dbgfs_dir, 0600);
  1333. MVM_DEBUGFS_ADD_FILE_VIF(rx_phyinfo, mvmvif->dbgfs_dir, 0600);
  1334. MVM_DEBUGFS_ADD_FILE_VIF(quota_min, mvmvif->dbgfs_dir, 0600);
  1335. MVM_DEBUGFS_ADD_FILE_VIF(os_device_timediff, mvmvif->dbgfs_dir, 0400);
  1336. if (vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
  1337. mvmvif == mvm->bf_allowed_vif)
  1338. MVM_DEBUGFS_ADD_FILE_VIF(bf_params, mvmvif->dbgfs_dir, 0600);
  1339. if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TOF_SUPPORT) &&
  1340. !vif->p2p && (vif->type != NL80211_IFTYPE_P2P_DEVICE)) {
  1341. if (IWL_MVM_TOF_IS_RESPONDER && vif->type == NL80211_IFTYPE_AP)
  1342. MVM_DEBUGFS_ADD_FILE_VIF(tof_responder_params,
  1343. mvmvif->dbgfs_dir, 0600);
  1344. MVM_DEBUGFS_ADD_FILE_VIF(tof_range_request, mvmvif->dbgfs_dir,
  1345. 0600);
  1346. MVM_DEBUGFS_ADD_FILE_VIF(tof_range_req_ext, mvmvif->dbgfs_dir,
  1347. 0600);
  1348. MVM_DEBUGFS_ADD_FILE_VIF(tof_enable, mvmvif->dbgfs_dir,
  1349. 0600);
  1350. MVM_DEBUGFS_ADD_FILE_VIF(tof_range_abort, mvmvif->dbgfs_dir,
  1351. 0600);
  1352. MVM_DEBUGFS_ADD_FILE_VIF(tof_range_response, mvmvif->dbgfs_dir,
  1353. 0400);
  1354. }
  1355. /*
  1356. * Create symlink for convenience pointing to interface specific
  1357. * debugfs entries for the driver. For example, under
  1358. * /sys/kernel/debug/iwlwifi/0000\:02\:00.0/iwlmvm/
  1359. * find
  1360. * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/
  1361. */
  1362. snprintf(buf, 100, "../../../%pd3/%pd",
  1363. dbgfs_dir,
  1364. mvmvif->dbgfs_dir);
  1365. mvmvif->dbgfs_slink = debugfs_create_symlink(dbgfs_dir->d_name.name,
  1366. mvm->debugfs_dir, buf);
  1367. if (!mvmvif->dbgfs_slink)
  1368. IWL_ERR(mvm, "Can't create debugfs symbolic link under %pd\n",
  1369. dbgfs_dir);
  1370. return;
  1371. err:
  1372. IWL_ERR(mvm, "Can't create debugfs entity\n");
  1373. }
  1374. void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  1375. {
  1376. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1377. debugfs_remove(mvmvif->dbgfs_slink);
  1378. mvmvif->dbgfs_slink = NULL;
  1379. debugfs_remove_recursive(mvmvif->dbgfs_dir);
  1380. mvmvif->dbgfs_dir = NULL;
  1381. }