debugfs-vif.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570
  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. iwl_mvm_get_sync_time(mvm, &curr_gp2, &curr_os);
  485. do_div(curr_os, NSEC_PER_USEC);
  486. diff = curr_os - curr_gp2;
  487. pos += scnprintf(buf + pos, bufsz - pos, "diff=%lld\n", diff);
  488. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  489. }
  490. static ssize_t iwl_dbgfs_tof_enable_write(struct ieee80211_vif *vif,
  491. char *buf,
  492. size_t count, loff_t *ppos)
  493. {
  494. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  495. struct iwl_mvm *mvm = mvmvif->mvm;
  496. u32 value;
  497. int ret = -EINVAL;
  498. char *data;
  499. mutex_lock(&mvm->mutex);
  500. data = iwl_dbgfs_is_match("tof_disabled=", buf);
  501. if (data) {
  502. ret = kstrtou32(data, 10, &value);
  503. if (ret == 0)
  504. mvm->tof_data.tof_cfg.tof_disabled = value;
  505. goto out;
  506. }
  507. data = iwl_dbgfs_is_match("one_sided_disabled=", buf);
  508. if (data) {
  509. ret = kstrtou32(data, 10, &value);
  510. if (ret == 0)
  511. mvm->tof_data.tof_cfg.one_sided_disabled = value;
  512. goto out;
  513. }
  514. data = iwl_dbgfs_is_match("is_debug_mode=", buf);
  515. if (data) {
  516. ret = kstrtou32(data, 10, &value);
  517. if (ret == 0)
  518. mvm->tof_data.tof_cfg.is_debug_mode = value;
  519. goto out;
  520. }
  521. data = iwl_dbgfs_is_match("is_buf=", buf);
  522. if (data) {
  523. ret = kstrtou32(data, 10, &value);
  524. if (ret == 0)
  525. mvm->tof_data.tof_cfg.is_buf_required = value;
  526. goto out;
  527. }
  528. data = iwl_dbgfs_is_match("send_tof_cfg=", buf);
  529. if (data) {
  530. ret = kstrtou32(data, 10, &value);
  531. if (ret == 0 && value) {
  532. ret = iwl_mvm_tof_config_cmd(mvm);
  533. goto out;
  534. }
  535. }
  536. out:
  537. mutex_unlock(&mvm->mutex);
  538. return ret ?: count;
  539. }
  540. static ssize_t iwl_dbgfs_tof_enable_read(struct file *file,
  541. char __user *user_buf,
  542. size_t count, loff_t *ppos)
  543. {
  544. struct ieee80211_vif *vif = file->private_data;
  545. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  546. struct iwl_mvm *mvm = mvmvif->mvm;
  547. char buf[256];
  548. int pos = 0;
  549. const size_t bufsz = sizeof(buf);
  550. struct iwl_tof_config_cmd *cmd;
  551. cmd = &mvm->tof_data.tof_cfg;
  552. mutex_lock(&mvm->mutex);
  553. pos += scnprintf(buf + pos, bufsz - pos, "tof_disabled = %d\n",
  554. cmd->tof_disabled);
  555. pos += scnprintf(buf + pos, bufsz - pos, "one_sided_disabled = %d\n",
  556. cmd->one_sided_disabled);
  557. pos += scnprintf(buf + pos, bufsz - pos, "is_debug_mode = %d\n",
  558. cmd->is_debug_mode);
  559. pos += scnprintf(buf + pos, bufsz - pos, "is_buf_required = %d\n",
  560. cmd->is_buf_required);
  561. mutex_unlock(&mvm->mutex);
  562. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  563. }
  564. static ssize_t iwl_dbgfs_tof_responder_params_write(struct ieee80211_vif *vif,
  565. char *buf,
  566. size_t count, loff_t *ppos)
  567. {
  568. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  569. struct iwl_mvm *mvm = mvmvif->mvm;
  570. u32 value;
  571. int ret = 0;
  572. char *data;
  573. mutex_lock(&mvm->mutex);
  574. data = iwl_dbgfs_is_match("burst_period=", buf);
  575. if (data) {
  576. ret = kstrtou32(data, 10, &value);
  577. if (!ret)
  578. mvm->tof_data.responder_cfg.burst_period =
  579. cpu_to_le16(value);
  580. goto out;
  581. }
  582. data = iwl_dbgfs_is_match("min_delta_ftm=", buf);
  583. if (data) {
  584. ret = kstrtou32(data, 10, &value);
  585. if (ret == 0)
  586. mvm->tof_data.responder_cfg.min_delta_ftm = value;
  587. goto out;
  588. }
  589. data = iwl_dbgfs_is_match("burst_duration=", buf);
  590. if (data) {
  591. ret = kstrtou32(data, 10, &value);
  592. if (ret == 0)
  593. mvm->tof_data.responder_cfg.burst_duration = value;
  594. goto out;
  595. }
  596. data = iwl_dbgfs_is_match("num_of_burst_exp=", buf);
  597. if (data) {
  598. ret = kstrtou32(data, 10, &value);
  599. if (ret == 0)
  600. mvm->tof_data.responder_cfg.num_of_burst_exp = value;
  601. goto out;
  602. }
  603. data = iwl_dbgfs_is_match("abort_responder=", buf);
  604. if (data) {
  605. ret = kstrtou32(data, 10, &value);
  606. if (ret == 0)
  607. mvm->tof_data.responder_cfg.abort_responder = value;
  608. goto out;
  609. }
  610. data = iwl_dbgfs_is_match("get_ch_est=", buf);
  611. if (data) {
  612. ret = kstrtou32(data, 10, &value);
  613. if (ret == 0)
  614. mvm->tof_data.responder_cfg.get_ch_est = value;
  615. goto out;
  616. }
  617. data = iwl_dbgfs_is_match("recv_sta_req_params=", buf);
  618. if (data) {
  619. ret = kstrtou32(data, 10, &value);
  620. if (ret == 0)
  621. mvm->tof_data.responder_cfg.recv_sta_req_params = value;
  622. goto out;
  623. }
  624. data = iwl_dbgfs_is_match("channel_num=", buf);
  625. if (data) {
  626. ret = kstrtou32(data, 10, &value);
  627. if (ret == 0)
  628. mvm->tof_data.responder_cfg.channel_num = value;
  629. goto out;
  630. }
  631. data = iwl_dbgfs_is_match("bandwidth=", buf);
  632. if (data) {
  633. ret = kstrtou32(data, 10, &value);
  634. if (ret == 0)
  635. mvm->tof_data.responder_cfg.bandwidth = value;
  636. goto out;
  637. }
  638. data = iwl_dbgfs_is_match("rate=", buf);
  639. if (data) {
  640. ret = kstrtou32(data, 10, &value);
  641. if (ret == 0)
  642. mvm->tof_data.responder_cfg.rate = value;
  643. goto out;
  644. }
  645. data = iwl_dbgfs_is_match("bssid=", buf);
  646. if (data) {
  647. u8 *mac = mvm->tof_data.responder_cfg.bssid;
  648. if (!mac_pton(data, mac)) {
  649. ret = -EINVAL;
  650. goto out;
  651. }
  652. }
  653. data = iwl_dbgfs_is_match("tsf_timer_offset_msecs=", buf);
  654. if (data) {
  655. ret = kstrtou32(data, 10, &value);
  656. if (ret == 0)
  657. mvm->tof_data.responder_cfg.tsf_timer_offset_msecs =
  658. cpu_to_le16(value);
  659. goto out;
  660. }
  661. data = iwl_dbgfs_is_match("toa_offset=", buf);
  662. if (data) {
  663. ret = kstrtou32(data, 10, &value);
  664. if (ret == 0)
  665. mvm->tof_data.responder_cfg.toa_offset =
  666. cpu_to_le16(value);
  667. goto out;
  668. }
  669. data = iwl_dbgfs_is_match("center_freq=", buf);
  670. if (data) {
  671. struct iwl_tof_responder_config_cmd *cmd =
  672. &mvm->tof_data.responder_cfg;
  673. ret = kstrtou32(data, 10, &value);
  674. if (ret == 0 && value) {
  675. enum nl80211_band band = (cmd->channel_num <= 14) ?
  676. NL80211_BAND_2GHZ :
  677. NL80211_BAND_5GHZ;
  678. struct ieee80211_channel chn = {
  679. .band = band,
  680. .center_freq = ieee80211_channel_to_frequency(
  681. cmd->channel_num, band),
  682. };
  683. struct cfg80211_chan_def chandef = {
  684. .chan = &chn,
  685. .center_freq1 =
  686. ieee80211_channel_to_frequency(value,
  687. band),
  688. };
  689. cmd->ctrl_ch_position = iwl_mvm_get_ctrl_pos(&chandef);
  690. }
  691. goto out;
  692. }
  693. data = iwl_dbgfs_is_match("ftm_per_burst=", buf);
  694. if (data) {
  695. ret = kstrtou32(data, 10, &value);
  696. if (ret == 0)
  697. mvm->tof_data.responder_cfg.ftm_per_burst = value;
  698. goto out;
  699. }
  700. data = iwl_dbgfs_is_match("ftm_resp_ts_avail=", buf);
  701. if (data) {
  702. ret = kstrtou32(data, 10, &value);
  703. if (ret == 0)
  704. mvm->tof_data.responder_cfg.ftm_resp_ts_avail = value;
  705. goto out;
  706. }
  707. data = iwl_dbgfs_is_match("asap_mode=", buf);
  708. if (data) {
  709. ret = kstrtou32(data, 10, &value);
  710. if (ret == 0)
  711. mvm->tof_data.responder_cfg.asap_mode = value;
  712. goto out;
  713. }
  714. data = iwl_dbgfs_is_match("send_responder_cfg=", buf);
  715. if (data) {
  716. ret = kstrtou32(data, 10, &value);
  717. if (ret == 0 && value) {
  718. ret = iwl_mvm_tof_responder_cmd(mvm, vif);
  719. goto out;
  720. }
  721. }
  722. out:
  723. mutex_unlock(&mvm->mutex);
  724. return ret ?: count;
  725. }
  726. static ssize_t iwl_dbgfs_tof_responder_params_read(struct file *file,
  727. char __user *user_buf,
  728. size_t count, loff_t *ppos)
  729. {
  730. struct ieee80211_vif *vif = file->private_data;
  731. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  732. struct iwl_mvm *mvm = mvmvif->mvm;
  733. char buf[256];
  734. int pos = 0;
  735. const size_t bufsz = sizeof(buf);
  736. struct iwl_tof_responder_config_cmd *cmd;
  737. cmd = &mvm->tof_data.responder_cfg;
  738. mutex_lock(&mvm->mutex);
  739. pos += scnprintf(buf + pos, bufsz - pos, "burst_period = %d\n",
  740. le16_to_cpu(cmd->burst_period));
  741. pos += scnprintf(buf + pos, bufsz - pos, "burst_duration = %d\n",
  742. cmd->burst_duration);
  743. pos += scnprintf(buf + pos, bufsz - pos, "bandwidth = %d\n",
  744. cmd->bandwidth);
  745. pos += scnprintf(buf + pos, bufsz - pos, "channel_num = %d\n",
  746. cmd->channel_num);
  747. pos += scnprintf(buf + pos, bufsz - pos, "ctrl_ch_position = 0x%x\n",
  748. cmd->ctrl_ch_position);
  749. pos += scnprintf(buf + pos, bufsz - pos, "bssid = %pM\n",
  750. cmd->bssid);
  751. pos += scnprintf(buf + pos, bufsz - pos, "min_delta_ftm = %d\n",
  752. cmd->min_delta_ftm);
  753. pos += scnprintf(buf + pos, bufsz - pos, "num_of_burst_exp = %d\n",
  754. cmd->num_of_burst_exp);
  755. pos += scnprintf(buf + pos, bufsz - pos, "rate = %d\n", cmd->rate);
  756. pos += scnprintf(buf + pos, bufsz - pos, "abort_responder = %d\n",
  757. cmd->abort_responder);
  758. pos += scnprintf(buf + pos, bufsz - pos, "get_ch_est = %d\n",
  759. cmd->get_ch_est);
  760. pos += scnprintf(buf + pos, bufsz - pos, "recv_sta_req_params = %d\n",
  761. cmd->recv_sta_req_params);
  762. pos += scnprintf(buf + pos, bufsz - pos, "ftm_per_burst = %d\n",
  763. cmd->ftm_per_burst);
  764. pos += scnprintf(buf + pos, bufsz - pos, "ftm_resp_ts_avail = %d\n",
  765. cmd->ftm_resp_ts_avail);
  766. pos += scnprintf(buf + pos, bufsz - pos, "asap_mode = %d\n",
  767. cmd->asap_mode);
  768. pos += scnprintf(buf + pos, bufsz - pos,
  769. "tsf_timer_offset_msecs = %d\n",
  770. le16_to_cpu(cmd->tsf_timer_offset_msecs));
  771. pos += scnprintf(buf + pos, bufsz - pos, "toa_offset = %d\n",
  772. le16_to_cpu(cmd->toa_offset));
  773. mutex_unlock(&mvm->mutex);
  774. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  775. }
  776. static ssize_t iwl_dbgfs_tof_range_request_write(struct ieee80211_vif *vif,
  777. char *buf, size_t count,
  778. loff_t *ppos)
  779. {
  780. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  781. struct iwl_mvm *mvm = mvmvif->mvm;
  782. u32 value;
  783. int ret = 0;
  784. char *data;
  785. mutex_lock(&mvm->mutex);
  786. data = iwl_dbgfs_is_match("request_id=", buf);
  787. if (data) {
  788. ret = kstrtou32(data, 10, &value);
  789. if (ret == 0)
  790. mvm->tof_data.range_req.request_id = value;
  791. goto out;
  792. }
  793. data = iwl_dbgfs_is_match("initiator=", buf);
  794. if (data) {
  795. ret = kstrtou32(data, 10, &value);
  796. if (ret == 0)
  797. mvm->tof_data.range_req.initiator = value;
  798. goto out;
  799. }
  800. data = iwl_dbgfs_is_match("one_sided_los_disable=", buf);
  801. if (data) {
  802. ret = kstrtou32(data, 10, &value);
  803. if (ret == 0)
  804. mvm->tof_data.range_req.one_sided_los_disable = value;
  805. goto out;
  806. }
  807. data = iwl_dbgfs_is_match("req_timeout=", buf);
  808. if (data) {
  809. ret = kstrtou32(data, 10, &value);
  810. if (ret == 0)
  811. mvm->tof_data.range_req.req_timeout = value;
  812. goto out;
  813. }
  814. data = iwl_dbgfs_is_match("report_policy=", buf);
  815. if (data) {
  816. ret = kstrtou32(data, 10, &value);
  817. if (ret == 0)
  818. mvm->tof_data.range_req.report_policy = value;
  819. goto out;
  820. }
  821. data = iwl_dbgfs_is_match("macaddr_random=", buf);
  822. if (data) {
  823. ret = kstrtou32(data, 10, &value);
  824. if (ret == 0)
  825. mvm->tof_data.range_req.macaddr_random = value;
  826. goto out;
  827. }
  828. data = iwl_dbgfs_is_match("num_of_ap=", buf);
  829. if (data) {
  830. ret = kstrtou32(data, 10, &value);
  831. if (ret == 0)
  832. mvm->tof_data.range_req.num_of_ap = value;
  833. goto out;
  834. }
  835. data = iwl_dbgfs_is_match("macaddr_template=", buf);
  836. if (data) {
  837. u8 mac[ETH_ALEN];
  838. if (!mac_pton(data, mac)) {
  839. ret = -EINVAL;
  840. goto out;
  841. }
  842. memcpy(mvm->tof_data.range_req.macaddr_template, mac, ETH_ALEN);
  843. goto out;
  844. }
  845. data = iwl_dbgfs_is_match("macaddr_mask=", buf);
  846. if (data) {
  847. u8 mac[ETH_ALEN];
  848. if (!mac_pton(data, mac)) {
  849. ret = -EINVAL;
  850. goto out;
  851. }
  852. memcpy(mvm->tof_data.range_req.macaddr_mask, mac, ETH_ALEN);
  853. goto out;
  854. }
  855. data = iwl_dbgfs_is_match("ap=", buf);
  856. if (data) {
  857. struct iwl_tof_range_req_ap_entry ap = {};
  858. int size = sizeof(struct iwl_tof_range_req_ap_entry);
  859. u16 burst_period;
  860. u8 *mac = ap.bssid;
  861. unsigned int i;
  862. if (sscanf(data, "%u %hhd %hhd %hhd"
  863. "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx"
  864. "%hhd %hhd %hd"
  865. "%hhd %hhd %d"
  866. "%hhx %hhd %hhd %hhd",
  867. &i, &ap.channel_num, &ap.bandwidth,
  868. &ap.ctrl_ch_position,
  869. mac, mac + 1, mac + 2, mac + 3, mac + 4, mac + 5,
  870. &ap.measure_type, &ap.num_of_bursts,
  871. &burst_period,
  872. &ap.samples_per_burst, &ap.retries_per_sample,
  873. &ap.tsf_delta, &ap.location_req, &ap.asap_mode,
  874. &ap.enable_dyn_ack, &ap.rssi) != 20) {
  875. ret = -EINVAL;
  876. goto out;
  877. }
  878. if (i >= IWL_MVM_TOF_MAX_APS) {
  879. IWL_ERR(mvm, "Invalid AP index %d\n", i);
  880. ret = -EINVAL;
  881. goto out;
  882. }
  883. ap.burst_period = cpu_to_le16(burst_period);
  884. memcpy(&mvm->tof_data.range_req.ap[i], &ap, size);
  885. goto out;
  886. }
  887. data = iwl_dbgfs_is_match("send_range_request=", buf);
  888. if (data) {
  889. ret = kstrtou32(data, 10, &value);
  890. if (ret == 0 && value)
  891. ret = iwl_mvm_tof_range_request_cmd(mvm, vif);
  892. goto out;
  893. }
  894. ret = -EINVAL;
  895. out:
  896. mutex_unlock(&mvm->mutex);
  897. return ret ?: count;
  898. }
  899. static ssize_t iwl_dbgfs_tof_range_request_read(struct file *file,
  900. char __user *user_buf,
  901. size_t count, loff_t *ppos)
  902. {
  903. struct ieee80211_vif *vif = file->private_data;
  904. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  905. struct iwl_mvm *mvm = mvmvif->mvm;
  906. char buf[512];
  907. int pos = 0;
  908. const size_t bufsz = sizeof(buf);
  909. struct iwl_tof_range_req_cmd *cmd;
  910. int i;
  911. cmd = &mvm->tof_data.range_req;
  912. mutex_lock(&mvm->mutex);
  913. pos += scnprintf(buf + pos, bufsz - pos, "request_id= %d\n",
  914. cmd->request_id);
  915. pos += scnprintf(buf + pos, bufsz - pos, "initiator= %d\n",
  916. cmd->initiator);
  917. pos += scnprintf(buf + pos, bufsz - pos, "one_sided_los_disable = %d\n",
  918. cmd->one_sided_los_disable);
  919. pos += scnprintf(buf + pos, bufsz - pos, "req_timeout= %d\n",
  920. cmd->req_timeout);
  921. pos += scnprintf(buf + pos, bufsz - pos, "report_policy= %d\n",
  922. cmd->report_policy);
  923. pos += scnprintf(buf + pos, bufsz - pos, "macaddr_random= %d\n",
  924. cmd->macaddr_random);
  925. pos += scnprintf(buf + pos, bufsz - pos, "macaddr_template= %pM\n",
  926. cmd->macaddr_template);
  927. pos += scnprintf(buf + pos, bufsz - pos, "macaddr_mask= %pM\n",
  928. cmd->macaddr_mask);
  929. pos += scnprintf(buf + pos, bufsz - pos, "num_of_ap= %d\n",
  930. cmd->num_of_ap);
  931. for (i = 0; i < cmd->num_of_ap; i++) {
  932. struct iwl_tof_range_req_ap_entry *ap = &cmd->ap[i];
  933. pos += scnprintf(buf + pos, bufsz - pos,
  934. "ap %.2d: channel_num=%hhd bw=%hhd"
  935. " control=%hhd bssid=%pM type=%hhd"
  936. " num_of_bursts=%hhd burst_period=%hd ftm=%hhd"
  937. " retries=%hhd tsf_delta=%d"
  938. " tsf_delta_direction=%hhd location_req=0x%hhx "
  939. " asap=%hhd enable=%hhd rssi=%hhd\n",
  940. i, ap->channel_num, ap->bandwidth,
  941. ap->ctrl_ch_position, ap->bssid,
  942. ap->measure_type, ap->num_of_bursts,
  943. ap->burst_period, ap->samples_per_burst,
  944. ap->retries_per_sample, ap->tsf_delta,
  945. ap->tsf_delta_direction,
  946. ap->location_req, ap->asap_mode,
  947. ap->enable_dyn_ack, ap->rssi);
  948. }
  949. mutex_unlock(&mvm->mutex);
  950. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  951. }
  952. static ssize_t iwl_dbgfs_tof_range_req_ext_write(struct ieee80211_vif *vif,
  953. char *buf,
  954. size_t count, loff_t *ppos)
  955. {
  956. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  957. struct iwl_mvm *mvm = mvmvif->mvm;
  958. u32 value;
  959. int ret = 0;
  960. char *data;
  961. mutex_lock(&mvm->mutex);
  962. data = iwl_dbgfs_is_match("tsf_timer_offset_msec=", buf);
  963. if (data) {
  964. ret = kstrtou32(data, 10, &value);
  965. if (ret == 0)
  966. mvm->tof_data.range_req_ext.tsf_timer_offset_msec =
  967. cpu_to_le16(value);
  968. goto out;
  969. }
  970. data = iwl_dbgfs_is_match("min_delta_ftm=", buf);
  971. if (data) {
  972. ret = kstrtou32(data, 10, &value);
  973. if (ret == 0)
  974. mvm->tof_data.range_req_ext.min_delta_ftm = value;
  975. goto out;
  976. }
  977. data = iwl_dbgfs_is_match("ftm_format_and_bw20M=", buf);
  978. if (data) {
  979. ret = kstrtou32(data, 10, &value);
  980. if (ret == 0)
  981. mvm->tof_data.range_req_ext.ftm_format_and_bw20M =
  982. value;
  983. goto out;
  984. }
  985. data = iwl_dbgfs_is_match("ftm_format_and_bw40M=", buf);
  986. if (data) {
  987. ret = kstrtou32(data, 10, &value);
  988. if (ret == 0)
  989. mvm->tof_data.range_req_ext.ftm_format_and_bw40M =
  990. value;
  991. goto out;
  992. }
  993. data = iwl_dbgfs_is_match("ftm_format_and_bw80M=", buf);
  994. if (data) {
  995. ret = kstrtou32(data, 10, &value);
  996. if (ret == 0)
  997. mvm->tof_data.range_req_ext.ftm_format_and_bw80M =
  998. value;
  999. goto out;
  1000. }
  1001. data = iwl_dbgfs_is_match("send_range_req_ext=", buf);
  1002. if (data) {
  1003. ret = kstrtou32(data, 10, &value);
  1004. if (ret == 0 && value)
  1005. ret = iwl_mvm_tof_range_request_ext_cmd(mvm, vif);
  1006. goto out;
  1007. }
  1008. ret = -EINVAL;
  1009. out:
  1010. mutex_unlock(&mvm->mutex);
  1011. return ret ?: count;
  1012. }
  1013. static ssize_t iwl_dbgfs_tof_range_req_ext_read(struct file *file,
  1014. char __user *user_buf,
  1015. size_t count, loff_t *ppos)
  1016. {
  1017. struct ieee80211_vif *vif = file->private_data;
  1018. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1019. struct iwl_mvm *mvm = mvmvif->mvm;
  1020. char buf[256];
  1021. int pos = 0;
  1022. const size_t bufsz = sizeof(buf);
  1023. struct iwl_tof_range_req_ext_cmd *cmd;
  1024. cmd = &mvm->tof_data.range_req_ext;
  1025. mutex_lock(&mvm->mutex);
  1026. pos += scnprintf(buf + pos, bufsz - pos,
  1027. "tsf_timer_offset_msec = %hd\n",
  1028. cmd->tsf_timer_offset_msec);
  1029. pos += scnprintf(buf + pos, bufsz - pos, "min_delta_ftm = %hhd\n",
  1030. cmd->min_delta_ftm);
  1031. pos += scnprintf(buf + pos, bufsz - pos,
  1032. "ftm_format_and_bw20M = %hhd\n",
  1033. cmd->ftm_format_and_bw20M);
  1034. pos += scnprintf(buf + pos, bufsz - pos,
  1035. "ftm_format_and_bw40M = %hhd\n",
  1036. cmd->ftm_format_and_bw40M);
  1037. pos += scnprintf(buf + pos, bufsz - pos,
  1038. "ftm_format_and_bw80M = %hhd\n",
  1039. cmd->ftm_format_and_bw80M);
  1040. mutex_unlock(&mvm->mutex);
  1041. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1042. }
  1043. static ssize_t iwl_dbgfs_tof_range_abort_write(struct ieee80211_vif *vif,
  1044. char *buf,
  1045. size_t count, loff_t *ppos)
  1046. {
  1047. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1048. struct iwl_mvm *mvm = mvmvif->mvm;
  1049. u32 value;
  1050. int abort_id, ret = 0;
  1051. char *data;
  1052. mutex_lock(&mvm->mutex);
  1053. data = iwl_dbgfs_is_match("abort_id=", buf);
  1054. if (data) {
  1055. ret = kstrtou32(data, 10, &value);
  1056. if (ret == 0)
  1057. mvm->tof_data.last_abort_id = value;
  1058. goto out;
  1059. }
  1060. data = iwl_dbgfs_is_match("send_range_abort=", buf);
  1061. if (data) {
  1062. ret = kstrtou32(data, 10, &value);
  1063. if (ret == 0 && value) {
  1064. abort_id = mvm->tof_data.last_abort_id;
  1065. ret = iwl_mvm_tof_range_abort_cmd(mvm, abort_id);
  1066. goto out;
  1067. }
  1068. }
  1069. out:
  1070. mutex_unlock(&mvm->mutex);
  1071. return ret ?: count;
  1072. }
  1073. static ssize_t iwl_dbgfs_tof_range_abort_read(struct file *file,
  1074. char __user *user_buf,
  1075. size_t count, loff_t *ppos)
  1076. {
  1077. struct ieee80211_vif *vif = file->private_data;
  1078. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1079. struct iwl_mvm *mvm = mvmvif->mvm;
  1080. char buf[32];
  1081. int pos = 0;
  1082. const size_t bufsz = sizeof(buf);
  1083. int last_abort_id;
  1084. mutex_lock(&mvm->mutex);
  1085. last_abort_id = mvm->tof_data.last_abort_id;
  1086. mutex_unlock(&mvm->mutex);
  1087. pos += scnprintf(buf + pos, bufsz - pos, "last_abort_id = %d\n",
  1088. last_abort_id);
  1089. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1090. }
  1091. static ssize_t iwl_dbgfs_tof_range_response_read(struct file *file,
  1092. char __user *user_buf,
  1093. size_t count, loff_t *ppos)
  1094. {
  1095. struct ieee80211_vif *vif = file->private_data;
  1096. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1097. struct iwl_mvm *mvm = mvmvif->mvm;
  1098. char *buf;
  1099. int pos = 0;
  1100. const size_t bufsz = sizeof(struct iwl_tof_range_rsp_ntfy) + 256;
  1101. struct iwl_tof_range_rsp_ntfy *cmd;
  1102. int i, ret;
  1103. buf = kzalloc(bufsz, GFP_KERNEL);
  1104. if (!buf)
  1105. return -ENOMEM;
  1106. mutex_lock(&mvm->mutex);
  1107. cmd = &mvm->tof_data.range_resp;
  1108. pos += scnprintf(buf + pos, bufsz - pos, "request_id = %d\n",
  1109. cmd->request_id);
  1110. pos += scnprintf(buf + pos, bufsz - pos, "status = %d\n",
  1111. cmd->request_status);
  1112. pos += scnprintf(buf + pos, bufsz - pos, "last_in_batch = %d\n",
  1113. cmd->last_in_batch);
  1114. pos += scnprintf(buf + pos, bufsz - pos, "num_of_aps = %d\n",
  1115. cmd->num_of_aps);
  1116. for (i = 0; i < cmd->num_of_aps; i++) {
  1117. struct iwl_tof_range_rsp_ap_entry_ntfy *ap = &cmd->ap[i];
  1118. pos += scnprintf(buf + pos, bufsz - pos,
  1119. "ap %.2d: bssid=%pM status=%hhd bw=%hhd"
  1120. " rtt=%d rtt_var=%d rtt_spread=%d"
  1121. " rssi=%hhd rssi_spread=%hhd"
  1122. " range=%d range_var=%d"
  1123. " time_stamp=%d\n",
  1124. i, ap->bssid, ap->measure_status,
  1125. ap->measure_bw,
  1126. ap->rtt, ap->rtt_variance, ap->rtt_spread,
  1127. ap->rssi, ap->rssi_spread, ap->range,
  1128. ap->range_variance, ap->timestamp);
  1129. }
  1130. mutex_unlock(&mvm->mutex);
  1131. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1132. kfree(buf);
  1133. return ret;
  1134. }
  1135. static ssize_t iwl_dbgfs_low_latency_write(struct ieee80211_vif *vif, char *buf,
  1136. size_t count, loff_t *ppos)
  1137. {
  1138. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1139. struct iwl_mvm *mvm = mvmvif->mvm;
  1140. u8 value;
  1141. int ret;
  1142. ret = kstrtou8(buf, 0, &value);
  1143. if (ret)
  1144. return ret;
  1145. if (value > 1)
  1146. return -EINVAL;
  1147. mutex_lock(&mvm->mutex);
  1148. iwl_mvm_update_low_latency(mvm, vif, value, LOW_LATENCY_DEBUGFS);
  1149. mutex_unlock(&mvm->mutex);
  1150. return count;
  1151. }
  1152. static ssize_t iwl_dbgfs_low_latency_read(struct file *file,
  1153. char __user *user_buf,
  1154. size_t count, loff_t *ppos)
  1155. {
  1156. struct ieee80211_vif *vif = file->private_data;
  1157. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1158. char buf[30] = {};
  1159. int len;
  1160. len = scnprintf(buf, sizeof(buf) - 1,
  1161. "traffic=%d\ndbgfs=%d\nvcmd=%d\n",
  1162. !!(mvmvif->low_latency & LOW_LATENCY_TRAFFIC),
  1163. !!(mvmvif->low_latency & LOW_LATENCY_DEBUGFS),
  1164. !!(mvmvif->low_latency & LOW_LATENCY_VCMD));
  1165. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1166. }
  1167. static ssize_t iwl_dbgfs_uapsd_misbehaving_read(struct file *file,
  1168. char __user *user_buf,
  1169. size_t count, loff_t *ppos)
  1170. {
  1171. struct ieee80211_vif *vif = file->private_data;
  1172. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1173. char buf[20];
  1174. int len;
  1175. len = sprintf(buf, "%pM\n", mvmvif->uapsd_misbehaving_bssid);
  1176. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1177. }
  1178. static ssize_t iwl_dbgfs_uapsd_misbehaving_write(struct ieee80211_vif *vif,
  1179. char *buf, size_t count,
  1180. loff_t *ppos)
  1181. {
  1182. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1183. struct iwl_mvm *mvm = mvmvif->mvm;
  1184. bool ret;
  1185. mutex_lock(&mvm->mutex);
  1186. ret = mac_pton(buf, mvmvif->uapsd_misbehaving_bssid);
  1187. mutex_unlock(&mvm->mutex);
  1188. return ret ? count : -EINVAL;
  1189. }
  1190. static ssize_t iwl_dbgfs_rx_phyinfo_write(struct ieee80211_vif *vif, char *buf,
  1191. size_t count, loff_t *ppos)
  1192. {
  1193. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1194. struct iwl_mvm *mvm = mvmvif->mvm;
  1195. struct ieee80211_chanctx_conf *chanctx_conf;
  1196. struct iwl_mvm_phy_ctxt *phy_ctxt;
  1197. u16 value;
  1198. int ret;
  1199. ret = kstrtou16(buf, 0, &value);
  1200. if (ret)
  1201. return ret;
  1202. mutex_lock(&mvm->mutex);
  1203. rcu_read_lock();
  1204. chanctx_conf = rcu_dereference(vif->chanctx_conf);
  1205. /* make sure the channel context is assigned */
  1206. if (!chanctx_conf) {
  1207. rcu_read_unlock();
  1208. mutex_unlock(&mvm->mutex);
  1209. return -EINVAL;
  1210. }
  1211. phy_ctxt = &mvm->phy_ctxts[*(u16 *)chanctx_conf->drv_priv];
  1212. rcu_read_unlock();
  1213. mvm->dbgfs_rx_phyinfo = value;
  1214. ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chanctx_conf->min_def,
  1215. chanctx_conf->rx_chains_static,
  1216. chanctx_conf->rx_chains_dynamic);
  1217. mutex_unlock(&mvm->mutex);
  1218. return ret ?: count;
  1219. }
  1220. static ssize_t iwl_dbgfs_rx_phyinfo_read(struct file *file,
  1221. char __user *user_buf,
  1222. size_t count, loff_t *ppos)
  1223. {
  1224. struct ieee80211_vif *vif = file->private_data;
  1225. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1226. char buf[8];
  1227. int len;
  1228. len = scnprintf(buf, sizeof(buf), "0x%04x\n",
  1229. mvmvif->mvm->dbgfs_rx_phyinfo);
  1230. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1231. }
  1232. static void iwl_dbgfs_quota_check(void *data, u8 *mac,
  1233. struct ieee80211_vif *vif)
  1234. {
  1235. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1236. int *ret = data;
  1237. if (mvmvif->dbgfs_quota_min)
  1238. *ret = -EINVAL;
  1239. }
  1240. static ssize_t iwl_dbgfs_quota_min_write(struct ieee80211_vif *vif, char *buf,
  1241. size_t count, loff_t *ppos)
  1242. {
  1243. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1244. struct iwl_mvm *mvm = mvmvif->mvm;
  1245. u16 value;
  1246. int ret;
  1247. ret = kstrtou16(buf, 0, &value);
  1248. if (ret)
  1249. return ret;
  1250. if (value > 95)
  1251. return -EINVAL;
  1252. mutex_lock(&mvm->mutex);
  1253. mvmvif->dbgfs_quota_min = 0;
  1254. ieee80211_iterate_interfaces(mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
  1255. iwl_dbgfs_quota_check, &ret);
  1256. if (ret == 0) {
  1257. mvmvif->dbgfs_quota_min = value;
  1258. iwl_mvm_update_quotas(mvm, false, NULL);
  1259. }
  1260. mutex_unlock(&mvm->mutex);
  1261. return ret ?: count;
  1262. }
  1263. static ssize_t iwl_dbgfs_quota_min_read(struct file *file,
  1264. char __user *user_buf,
  1265. size_t count, loff_t *ppos)
  1266. {
  1267. struct ieee80211_vif *vif = file->private_data;
  1268. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1269. char buf[10];
  1270. int len;
  1271. len = scnprintf(buf, sizeof(buf), "%d\n", mvmvif->dbgfs_quota_min);
  1272. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  1273. }
  1274. static const char * const chanwidths[] = {
  1275. [NL80211_CHAN_WIDTH_20_NOHT] = "noht",
  1276. [NL80211_CHAN_WIDTH_20] = "ht20",
  1277. [NL80211_CHAN_WIDTH_40] = "ht40",
  1278. [NL80211_CHAN_WIDTH_80] = "vht80",
  1279. [NL80211_CHAN_WIDTH_80P80] = "vht80p80",
  1280. [NL80211_CHAN_WIDTH_160] = "vht160",
  1281. };
  1282. #define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \
  1283. _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct ieee80211_vif)
  1284. #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz) \
  1285. _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct ieee80211_vif)
  1286. #define MVM_DEBUGFS_ADD_FILE_VIF(name, parent, mode) do { \
  1287. if (!debugfs_create_file(#name, mode, parent, vif, \
  1288. &iwl_dbgfs_##name##_ops)) \
  1289. goto err; \
  1290. } while (0)
  1291. MVM_DEBUGFS_READ_FILE_OPS(mac_params);
  1292. MVM_DEBUGFS_READ_FILE_OPS(tx_pwr_lmt);
  1293. MVM_DEBUGFS_READ_WRITE_FILE_OPS(pm_params, 32);
  1294. MVM_DEBUGFS_READ_WRITE_FILE_OPS(bf_params, 256);
  1295. MVM_DEBUGFS_READ_WRITE_FILE_OPS(low_latency, 10);
  1296. MVM_DEBUGFS_READ_WRITE_FILE_OPS(uapsd_misbehaving, 20);
  1297. MVM_DEBUGFS_READ_WRITE_FILE_OPS(rx_phyinfo, 10);
  1298. MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_enable, 32);
  1299. MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_range_request, 512);
  1300. MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_range_req_ext, 32);
  1301. MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_range_abort, 32);
  1302. MVM_DEBUGFS_READ_FILE_OPS(tof_range_response);
  1303. MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_responder_params, 32);
  1304. MVM_DEBUGFS_READ_WRITE_FILE_OPS(quota_min, 32);
  1305. MVM_DEBUGFS_READ_FILE_OPS(os_device_timediff);
  1306. void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  1307. {
  1308. struct dentry *dbgfs_dir = vif->debugfs_dir;
  1309. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1310. char buf[100];
  1311. /*
  1312. * Check if debugfs directory already exist before creating it.
  1313. * This may happen when, for example, resetting hw or suspend-resume
  1314. */
  1315. if (!dbgfs_dir || mvmvif->dbgfs_dir)
  1316. return;
  1317. mvmvif->dbgfs_dir = debugfs_create_dir("iwlmvm", dbgfs_dir);
  1318. if (!mvmvif->dbgfs_dir) {
  1319. IWL_ERR(mvm, "Failed to create debugfs directory under %pd\n",
  1320. dbgfs_dir);
  1321. return;
  1322. }
  1323. if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM &&
  1324. ((vif->type == NL80211_IFTYPE_STATION && !vif->p2p) ||
  1325. (vif->type == NL80211_IFTYPE_STATION && vif->p2p)))
  1326. MVM_DEBUGFS_ADD_FILE_VIF(pm_params, mvmvif->dbgfs_dir, 0600);
  1327. MVM_DEBUGFS_ADD_FILE_VIF(tx_pwr_lmt, mvmvif->dbgfs_dir, 0400);
  1328. MVM_DEBUGFS_ADD_FILE_VIF(mac_params, mvmvif->dbgfs_dir, 0400);
  1329. MVM_DEBUGFS_ADD_FILE_VIF(low_latency, mvmvif->dbgfs_dir, 0600);
  1330. MVM_DEBUGFS_ADD_FILE_VIF(uapsd_misbehaving, mvmvif->dbgfs_dir, 0600);
  1331. MVM_DEBUGFS_ADD_FILE_VIF(rx_phyinfo, mvmvif->dbgfs_dir, 0600);
  1332. MVM_DEBUGFS_ADD_FILE_VIF(quota_min, mvmvif->dbgfs_dir, 0600);
  1333. MVM_DEBUGFS_ADD_FILE_VIF(os_device_timediff, mvmvif->dbgfs_dir, 0400);
  1334. if (vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
  1335. mvmvif == mvm->bf_allowed_vif)
  1336. MVM_DEBUGFS_ADD_FILE_VIF(bf_params, mvmvif->dbgfs_dir, 0600);
  1337. if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TOF_SUPPORT) &&
  1338. !vif->p2p && (vif->type != NL80211_IFTYPE_P2P_DEVICE)) {
  1339. if (IWL_MVM_TOF_IS_RESPONDER && vif->type == NL80211_IFTYPE_AP)
  1340. MVM_DEBUGFS_ADD_FILE_VIF(tof_responder_params,
  1341. mvmvif->dbgfs_dir, 0600);
  1342. MVM_DEBUGFS_ADD_FILE_VIF(tof_range_request, mvmvif->dbgfs_dir,
  1343. 0600);
  1344. MVM_DEBUGFS_ADD_FILE_VIF(tof_range_req_ext, mvmvif->dbgfs_dir,
  1345. 0600);
  1346. MVM_DEBUGFS_ADD_FILE_VIF(tof_enable, mvmvif->dbgfs_dir,
  1347. 0600);
  1348. MVM_DEBUGFS_ADD_FILE_VIF(tof_range_abort, mvmvif->dbgfs_dir,
  1349. 0600);
  1350. MVM_DEBUGFS_ADD_FILE_VIF(tof_range_response, mvmvif->dbgfs_dir,
  1351. 0400);
  1352. }
  1353. /*
  1354. * Create symlink for convenience pointing to interface specific
  1355. * debugfs entries for the driver. For example, under
  1356. * /sys/kernel/debug/iwlwifi/0000\:02\:00.0/iwlmvm/
  1357. * find
  1358. * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/
  1359. */
  1360. snprintf(buf, 100, "../../../%pd3/%pd",
  1361. dbgfs_dir,
  1362. mvmvif->dbgfs_dir);
  1363. mvmvif->dbgfs_slink = debugfs_create_symlink(dbgfs_dir->d_name.name,
  1364. mvm->debugfs_dir, buf);
  1365. if (!mvmvif->dbgfs_slink)
  1366. IWL_ERR(mvm, "Can't create debugfs symbolic link under %pd\n",
  1367. dbgfs_dir);
  1368. return;
  1369. err:
  1370. IWL_ERR(mvm, "Can't create debugfs entity\n");
  1371. }
  1372. void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  1373. {
  1374. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1375. debugfs_remove(mvmvif->dbgfs_slink);
  1376. mvmvif->dbgfs_slink = NULL;
  1377. debugfs_remove_recursive(mvmvif->dbgfs_dir);
  1378. mvmvif->dbgfs_dir = NULL;
  1379. }