debugfs-vif.c 45 KB

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