debugfs.c 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526
  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 - 2014 Intel Mobile Communications GmbH
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of version 2 of the GNU General Public License as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  23. * USA
  24. *
  25. * The full GNU General Public License is included in this distribution
  26. * in the file called COPYING.
  27. *
  28. * Contact Information:
  29. * Intel Linux Wireless <ilw@linux.intel.com>
  30. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  31. *
  32. * BSD LICENSE
  33. *
  34. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  35. * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
  36. * All rights reserved.
  37. *
  38. * Redistribution and use in source and binary forms, with or without
  39. * modification, are permitted provided that the following conditions
  40. * are met:
  41. *
  42. * * Redistributions of source code must retain the above copyright
  43. * notice, this list of conditions and the following disclaimer.
  44. * * Redistributions in binary form must reproduce the above copyright
  45. * notice, this list of conditions and the following disclaimer in
  46. * the documentation and/or other materials provided with the
  47. * distribution.
  48. * * Neither the name Intel Corporation nor the names of its
  49. * contributors may be used to endorse or promote products derived
  50. * from this software without specific prior written permission.
  51. *
  52. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  53. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  54. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  55. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  56. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  57. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  58. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  59. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  60. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  61. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  62. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  63. *
  64. *****************************************************************************/
  65. #include <linux/vmalloc.h>
  66. #include "mvm.h"
  67. #include "sta.h"
  68. #include "iwl-io.h"
  69. #include "debugfs.h"
  70. #include "iwl-fw-error-dump.h"
  71. static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf,
  72. size_t count, loff_t *ppos)
  73. {
  74. int ret;
  75. u32 scd_q_msk;
  76. if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
  77. return -EIO;
  78. if (sscanf(buf, "%x", &scd_q_msk) != 1)
  79. return -EINVAL;
  80. IWL_ERR(mvm, "FLUSHING queues: scd_q_msk = 0x%x\n", scd_q_msk);
  81. mutex_lock(&mvm->mutex);
  82. ret = iwl_mvm_flush_tx_path(mvm, scd_q_msk, true) ? : count;
  83. mutex_unlock(&mvm->mutex);
  84. return ret;
  85. }
  86. static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
  87. size_t count, loff_t *ppos)
  88. {
  89. struct iwl_mvm_sta *mvmsta;
  90. int sta_id, drain, ret;
  91. if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
  92. return -EIO;
  93. if (sscanf(buf, "%d %d", &sta_id, &drain) != 2)
  94. return -EINVAL;
  95. if (sta_id < 0 || sta_id >= IWL_MVM_STATION_COUNT)
  96. return -EINVAL;
  97. if (drain < 0 || drain > 1)
  98. return -EINVAL;
  99. mutex_lock(&mvm->mutex);
  100. mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id);
  101. if (!mvmsta)
  102. ret = -ENOENT;
  103. else
  104. ret = iwl_mvm_drain_sta(mvm, mvmsta, drain) ? : count;
  105. mutex_unlock(&mvm->mutex);
  106. return ret;
  107. }
  108. static int iwl_dbgfs_fw_error_dump_open(struct inode *inode, struct file *file)
  109. {
  110. struct iwl_mvm *mvm = inode->i_private;
  111. int ret;
  112. if (!mvm)
  113. return -EINVAL;
  114. mutex_lock(&mvm->mutex);
  115. if (!mvm->fw_error_dump) {
  116. ret = -ENODATA;
  117. goto out;
  118. }
  119. file->private_data = mvm->fw_error_dump;
  120. mvm->fw_error_dump = NULL;
  121. ret = 0;
  122. out:
  123. mutex_unlock(&mvm->mutex);
  124. return ret;
  125. }
  126. static ssize_t iwl_dbgfs_fw_error_dump_read(struct file *file,
  127. char __user *user_buf,
  128. size_t count, loff_t *ppos)
  129. {
  130. struct iwl_mvm_dump_ptrs *dump_ptrs = (void *)file->private_data;
  131. ssize_t bytes_read = 0;
  132. ssize_t bytes_read_trans = 0;
  133. if (*ppos < dump_ptrs->op_mode_len)
  134. bytes_read +=
  135. simple_read_from_buffer(user_buf, count, ppos,
  136. dump_ptrs->op_mode_ptr,
  137. dump_ptrs->op_mode_len);
  138. if (bytes_read < 0 || *ppos < dump_ptrs->op_mode_len)
  139. return bytes_read;
  140. if (dump_ptrs->trans_ptr) {
  141. *ppos -= dump_ptrs->op_mode_len;
  142. bytes_read_trans =
  143. simple_read_from_buffer(user_buf + bytes_read,
  144. count - bytes_read, ppos,
  145. dump_ptrs->trans_ptr->data,
  146. dump_ptrs->trans_ptr->len);
  147. *ppos += dump_ptrs->op_mode_len;
  148. if (bytes_read_trans >= 0)
  149. bytes_read += bytes_read_trans;
  150. else if (!bytes_read)
  151. /* propagate the failure */
  152. return bytes_read_trans;
  153. }
  154. return bytes_read;
  155. }
  156. static int iwl_dbgfs_fw_error_dump_release(struct inode *inode,
  157. struct file *file)
  158. {
  159. struct iwl_mvm_dump_ptrs *dump_ptrs = (void *)file->private_data;
  160. vfree(dump_ptrs->op_mode_ptr);
  161. vfree(dump_ptrs->trans_ptr);
  162. kfree(dump_ptrs);
  163. return 0;
  164. }
  165. static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
  166. size_t count, loff_t *ppos)
  167. {
  168. struct iwl_mvm *mvm = file->private_data;
  169. const struct fw_img *img;
  170. unsigned int ofs, len;
  171. size_t ret;
  172. u8 *ptr;
  173. if (!mvm->ucode_loaded)
  174. return -EINVAL;
  175. /* default is to dump the entire data segment */
  176. img = &mvm->fw->img[mvm->cur_ucode];
  177. ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
  178. len = img->sec[IWL_UCODE_SECTION_DATA].len;
  179. if (mvm->dbgfs_sram_len) {
  180. ofs = mvm->dbgfs_sram_offset;
  181. len = mvm->dbgfs_sram_len;
  182. }
  183. ptr = kzalloc(len, GFP_KERNEL);
  184. if (!ptr)
  185. return -ENOMEM;
  186. iwl_trans_read_mem_bytes(mvm->trans, ofs, ptr, len);
  187. ret = simple_read_from_buffer(user_buf, count, ppos, ptr, len);
  188. kfree(ptr);
  189. return ret;
  190. }
  191. static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf,
  192. size_t count, loff_t *ppos)
  193. {
  194. const struct fw_img *img;
  195. u32 offset, len;
  196. u32 img_offset, img_len;
  197. if (!mvm->ucode_loaded)
  198. return -EINVAL;
  199. img = &mvm->fw->img[mvm->cur_ucode];
  200. img_offset = img->sec[IWL_UCODE_SECTION_DATA].offset;
  201. img_len = img->sec[IWL_UCODE_SECTION_DATA].len;
  202. if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
  203. if ((offset & 0x3) || (len & 0x3))
  204. return -EINVAL;
  205. if (offset + len > img_offset + img_len)
  206. return -EINVAL;
  207. mvm->dbgfs_sram_offset = offset;
  208. mvm->dbgfs_sram_len = len;
  209. } else {
  210. mvm->dbgfs_sram_offset = 0;
  211. mvm->dbgfs_sram_len = 0;
  212. }
  213. return count;
  214. }
  215. static ssize_t iwl_dbgfs_set_nic_temperature_read(struct file *file,
  216. char __user *user_buf,
  217. size_t count, loff_t *ppos)
  218. {
  219. struct iwl_mvm *mvm = file->private_data;
  220. char buf[16];
  221. int pos;
  222. if (!mvm->temperature_test)
  223. pos = scnprintf(buf , sizeof(buf), "disabled\n");
  224. else
  225. pos = scnprintf(buf , sizeof(buf), "%d\n", mvm->temperature);
  226. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  227. }
  228. /*
  229. * Set NIC Temperature
  230. * Cause the driver to ignore the actual NIC temperature reported by the FW
  231. * Enable: any value between IWL_MVM_DEBUG_SET_TEMPERATURE_MIN -
  232. * IWL_MVM_DEBUG_SET_TEMPERATURE_MAX
  233. * Disable: IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE
  234. */
  235. static ssize_t iwl_dbgfs_set_nic_temperature_write(struct iwl_mvm *mvm,
  236. char *buf, size_t count,
  237. loff_t *ppos)
  238. {
  239. int temperature;
  240. if (!mvm->ucode_loaded && !mvm->temperature_test)
  241. return -EIO;
  242. if (kstrtoint(buf, 10, &temperature))
  243. return -EINVAL;
  244. /* not a legal temperature */
  245. if ((temperature > IWL_MVM_DEBUG_SET_TEMPERATURE_MAX &&
  246. temperature != IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) ||
  247. temperature < IWL_MVM_DEBUG_SET_TEMPERATURE_MIN)
  248. return -EINVAL;
  249. mutex_lock(&mvm->mutex);
  250. if (temperature == IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) {
  251. if (!mvm->temperature_test)
  252. goto out;
  253. mvm->temperature_test = false;
  254. /* Since we can't read the temp while awake, just set
  255. * it to zero until we get the next RX stats from the
  256. * firmware.
  257. */
  258. mvm->temperature = 0;
  259. } else {
  260. mvm->temperature_test = true;
  261. mvm->temperature = temperature;
  262. }
  263. IWL_DEBUG_TEMP(mvm, "%sabling debug set temperature (temp = %d)\n",
  264. mvm->temperature_test ? "En" : "Dis" ,
  265. mvm->temperature);
  266. /* handle the temperature change */
  267. iwl_mvm_tt_handler(mvm);
  268. out:
  269. mutex_unlock(&mvm->mutex);
  270. return count;
  271. }
  272. static ssize_t iwl_dbgfs_nic_temp_read(struct file *file,
  273. char __user *user_buf,
  274. size_t count, loff_t *ppos)
  275. {
  276. struct iwl_mvm *mvm = file->private_data;
  277. char buf[16];
  278. int pos, temp;
  279. if (!mvm->ucode_loaded)
  280. return -EIO;
  281. mutex_lock(&mvm->mutex);
  282. temp = iwl_mvm_get_temp(mvm);
  283. mutex_unlock(&mvm->mutex);
  284. if (temp < 0)
  285. return temp;
  286. pos = scnprintf(buf , sizeof(buf), "%d\n", temp);
  287. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  288. }
  289. static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
  290. size_t count, loff_t *ppos)
  291. {
  292. struct iwl_mvm *mvm = file->private_data;
  293. struct ieee80211_sta *sta;
  294. char buf[400];
  295. int i, pos = 0, bufsz = sizeof(buf);
  296. mutex_lock(&mvm->mutex);
  297. for (i = 0; i < IWL_MVM_STATION_COUNT; i++) {
  298. pos += scnprintf(buf + pos, bufsz - pos, "%.2d: ", i);
  299. sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
  300. lockdep_is_held(&mvm->mutex));
  301. if (!sta)
  302. pos += scnprintf(buf + pos, bufsz - pos, "N/A\n");
  303. else if (IS_ERR(sta))
  304. pos += scnprintf(buf + pos, bufsz - pos, "%ld\n",
  305. PTR_ERR(sta));
  306. else
  307. pos += scnprintf(buf + pos, bufsz - pos, "%pM\n",
  308. sta->addr);
  309. }
  310. mutex_unlock(&mvm->mutex);
  311. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  312. }
  313. static ssize_t iwl_dbgfs_disable_power_off_read(struct file *file,
  314. char __user *user_buf,
  315. size_t count, loff_t *ppos)
  316. {
  317. struct iwl_mvm *mvm = file->private_data;
  318. char buf[64];
  319. int bufsz = sizeof(buf);
  320. int pos = 0;
  321. pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d0=%d\n",
  322. mvm->disable_power_off);
  323. pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d3=%d\n",
  324. mvm->disable_power_off_d3);
  325. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  326. }
  327. static ssize_t iwl_dbgfs_disable_power_off_write(struct iwl_mvm *mvm, char *buf,
  328. size_t count, loff_t *ppos)
  329. {
  330. int ret, val;
  331. if (!mvm->ucode_loaded)
  332. return -EIO;
  333. if (!strncmp("disable_power_off_d0=", buf, 21)) {
  334. if (sscanf(buf + 21, "%d", &val) != 1)
  335. return -EINVAL;
  336. mvm->disable_power_off = val;
  337. } else if (!strncmp("disable_power_off_d3=", buf, 21)) {
  338. if (sscanf(buf + 21, "%d", &val) != 1)
  339. return -EINVAL;
  340. mvm->disable_power_off_d3 = val;
  341. } else {
  342. return -EINVAL;
  343. }
  344. mutex_lock(&mvm->mutex);
  345. ret = iwl_mvm_power_update_device(mvm);
  346. mutex_unlock(&mvm->mutex);
  347. return ret ?: count;
  348. }
  349. #define BT_MBOX_MSG(_notif, _num, _field) \
  350. ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\
  351. >> BT_MBOX##_num##_##_field##_POS)
  352. #define BT_MBOX_PRINT(_num, _field, _end) \
  353. pos += scnprintf(buf + pos, bufsz - pos, \
  354. "\t%s: %d%s", \
  355. #_field, \
  356. BT_MBOX_MSG(notif, _num, _field), \
  357. true ? "\n" : ", ");
  358. static
  359. int iwl_mvm_coex_dump_mbox(struct iwl_bt_coex_profile_notif *notif, char *buf,
  360. int pos, int bufsz)
  361. {
  362. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n");
  363. BT_MBOX_PRINT(0, LE_SLAVE_LAT, false);
  364. BT_MBOX_PRINT(0, LE_PROF1, false);
  365. BT_MBOX_PRINT(0, LE_PROF2, false);
  366. BT_MBOX_PRINT(0, LE_PROF_OTHER, false);
  367. BT_MBOX_PRINT(0, CHL_SEQ_N, false);
  368. BT_MBOX_PRINT(0, INBAND_S, false);
  369. BT_MBOX_PRINT(0, LE_MIN_RSSI, false);
  370. BT_MBOX_PRINT(0, LE_SCAN, false);
  371. BT_MBOX_PRINT(0, LE_ADV, false);
  372. BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false);
  373. BT_MBOX_PRINT(0, OPEN_CON_1, true);
  374. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n");
  375. BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false);
  376. BT_MBOX_PRINT(1, IP_SR, false);
  377. BT_MBOX_PRINT(1, LE_MSTR, false);
  378. BT_MBOX_PRINT(1, AGGR_TRFC_LD, false);
  379. BT_MBOX_PRINT(1, MSG_TYPE, false);
  380. BT_MBOX_PRINT(1, SSN, true);
  381. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n");
  382. BT_MBOX_PRINT(2, SNIFF_ACT, false);
  383. BT_MBOX_PRINT(2, PAG, false);
  384. BT_MBOX_PRINT(2, INQUIRY, false);
  385. BT_MBOX_PRINT(2, CONN, false);
  386. BT_MBOX_PRINT(2, SNIFF_INTERVAL, false);
  387. BT_MBOX_PRINT(2, DISC, false);
  388. BT_MBOX_PRINT(2, SCO_TX_ACT, false);
  389. BT_MBOX_PRINT(2, SCO_RX_ACT, false);
  390. BT_MBOX_PRINT(2, ESCO_RE_TX, false);
  391. BT_MBOX_PRINT(2, SCO_DURATION, true);
  392. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n");
  393. BT_MBOX_PRINT(3, SCO_STATE, false);
  394. BT_MBOX_PRINT(3, SNIFF_STATE, false);
  395. BT_MBOX_PRINT(3, A2DP_STATE, false);
  396. BT_MBOX_PRINT(3, ACL_STATE, false);
  397. BT_MBOX_PRINT(3, MSTR_STATE, false);
  398. BT_MBOX_PRINT(3, OBX_STATE, false);
  399. BT_MBOX_PRINT(3, OPEN_CON_2, false);
  400. BT_MBOX_PRINT(3, TRAFFIC_LOAD, false);
  401. BT_MBOX_PRINT(3, CHL_SEQN_LSB, false);
  402. BT_MBOX_PRINT(3, INBAND_P, false);
  403. BT_MBOX_PRINT(3, MSG_TYPE_2, false);
  404. BT_MBOX_PRINT(3, SSN_2, false);
  405. BT_MBOX_PRINT(3, UPDATE_REQUEST, true);
  406. return pos;
  407. }
  408. static
  409. int iwl_mvm_coex_dump_mbox_old(struct iwl_bt_coex_profile_notif_old *notif,
  410. char *buf, int pos, int bufsz)
  411. {
  412. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n");
  413. BT_MBOX_PRINT(0, LE_SLAVE_LAT, false);
  414. BT_MBOX_PRINT(0, LE_PROF1, false);
  415. BT_MBOX_PRINT(0, LE_PROF2, false);
  416. BT_MBOX_PRINT(0, LE_PROF_OTHER, false);
  417. BT_MBOX_PRINT(0, CHL_SEQ_N, false);
  418. BT_MBOX_PRINT(0, INBAND_S, false);
  419. BT_MBOX_PRINT(0, LE_MIN_RSSI, false);
  420. BT_MBOX_PRINT(0, LE_SCAN, false);
  421. BT_MBOX_PRINT(0, LE_ADV, false);
  422. BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false);
  423. BT_MBOX_PRINT(0, OPEN_CON_1, true);
  424. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n");
  425. BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false);
  426. BT_MBOX_PRINT(1, IP_SR, false);
  427. BT_MBOX_PRINT(1, LE_MSTR, false);
  428. BT_MBOX_PRINT(1, AGGR_TRFC_LD, false);
  429. BT_MBOX_PRINT(1, MSG_TYPE, false);
  430. BT_MBOX_PRINT(1, SSN, true);
  431. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n");
  432. BT_MBOX_PRINT(2, SNIFF_ACT, false);
  433. BT_MBOX_PRINT(2, PAG, false);
  434. BT_MBOX_PRINT(2, INQUIRY, false);
  435. BT_MBOX_PRINT(2, CONN, false);
  436. BT_MBOX_PRINT(2, SNIFF_INTERVAL, false);
  437. BT_MBOX_PRINT(2, DISC, false);
  438. BT_MBOX_PRINT(2, SCO_TX_ACT, false);
  439. BT_MBOX_PRINT(2, SCO_RX_ACT, false);
  440. BT_MBOX_PRINT(2, ESCO_RE_TX, false);
  441. BT_MBOX_PRINT(2, SCO_DURATION, true);
  442. pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n");
  443. BT_MBOX_PRINT(3, SCO_STATE, false);
  444. BT_MBOX_PRINT(3, SNIFF_STATE, false);
  445. BT_MBOX_PRINT(3, A2DP_STATE, false);
  446. BT_MBOX_PRINT(3, ACL_STATE, false);
  447. BT_MBOX_PRINT(3, MSTR_STATE, false);
  448. BT_MBOX_PRINT(3, OBX_STATE, false);
  449. BT_MBOX_PRINT(3, OPEN_CON_2, false);
  450. BT_MBOX_PRINT(3, TRAFFIC_LOAD, false);
  451. BT_MBOX_PRINT(3, CHL_SEQN_LSB, false);
  452. BT_MBOX_PRINT(3, INBAND_P, false);
  453. BT_MBOX_PRINT(3, MSG_TYPE_2, false);
  454. BT_MBOX_PRINT(3, SSN_2, false);
  455. BT_MBOX_PRINT(3, UPDATE_REQUEST, true);
  456. return pos;
  457. }
  458. static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf,
  459. size_t count, loff_t *ppos)
  460. {
  461. struct iwl_mvm *mvm = file->private_data;
  462. char *buf;
  463. int ret, pos = 0, bufsz = sizeof(char) * 1024;
  464. buf = kmalloc(bufsz, GFP_KERNEL);
  465. if (!buf)
  466. return -ENOMEM;
  467. mutex_lock(&mvm->mutex);
  468. if (!(mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_BT_COEX_SPLIT)) {
  469. struct iwl_bt_coex_profile_notif_old *notif =
  470. &mvm->last_bt_notif_old;
  471. pos += iwl_mvm_coex_dump_mbox_old(notif, buf, pos, bufsz);
  472. pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n",
  473. notif->bt_ci_compliance);
  474. pos += scnprintf(buf+pos, bufsz-pos, "primary_ch_lut = %d\n",
  475. le32_to_cpu(notif->primary_ch_lut));
  476. pos += scnprintf(buf+pos, bufsz-pos, "secondary_ch_lut = %d\n",
  477. le32_to_cpu(notif->secondary_ch_lut));
  478. pos += scnprintf(buf+pos,
  479. bufsz-pos, "bt_activity_grading = %d\n",
  480. le32_to_cpu(notif->bt_activity_grading));
  481. pos += scnprintf(buf+pos, bufsz-pos,
  482. "antenna isolation = %d CORUN LUT index = %d\n",
  483. mvm->last_ant_isol, mvm->last_corun_lut);
  484. } else {
  485. struct iwl_bt_coex_profile_notif *notif =
  486. &mvm->last_bt_notif;
  487. pos += iwl_mvm_coex_dump_mbox(notif, buf, pos, bufsz);
  488. pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n",
  489. notif->bt_ci_compliance);
  490. pos += scnprintf(buf+pos, bufsz-pos, "primary_ch_lut = %d\n",
  491. le32_to_cpu(notif->primary_ch_lut));
  492. pos += scnprintf(buf+pos, bufsz-pos, "secondary_ch_lut = %d\n",
  493. le32_to_cpu(notif->secondary_ch_lut));
  494. pos += scnprintf(buf+pos,
  495. bufsz-pos, "bt_activity_grading = %d\n",
  496. le32_to_cpu(notif->bt_activity_grading));
  497. pos += scnprintf(buf+pos, bufsz-pos,
  498. "antenna isolation = %d CORUN LUT index = %d\n",
  499. mvm->last_ant_isol, mvm->last_corun_lut);
  500. }
  501. mutex_unlock(&mvm->mutex);
  502. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  503. kfree(buf);
  504. return ret;
  505. }
  506. #undef BT_MBOX_PRINT
  507. static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf,
  508. size_t count, loff_t *ppos)
  509. {
  510. struct iwl_mvm *mvm = file->private_data;
  511. char buf[256];
  512. int bufsz = sizeof(buf);
  513. int pos = 0;
  514. mutex_lock(&mvm->mutex);
  515. if (!(mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_BT_COEX_SPLIT)) {
  516. struct iwl_bt_coex_ci_cmd_old *cmd = &mvm->last_bt_ci_cmd_old;
  517. pos += scnprintf(buf+pos, bufsz-pos,
  518. "Channel inhibition CMD\n");
  519. pos += scnprintf(buf+pos, bufsz-pos,
  520. "\tPrimary Channel Bitmap 0x%016llx\n",
  521. le64_to_cpu(cmd->bt_primary_ci));
  522. pos += scnprintf(buf+pos, bufsz-pos,
  523. "\tSecondary Channel Bitmap 0x%016llx\n",
  524. le64_to_cpu(cmd->bt_secondary_ci));
  525. pos += scnprintf(buf+pos, bufsz-pos, "BT Configuration CMD\n");
  526. pos += scnprintf(buf+pos, bufsz-pos, "\tACK Kill Mask 0x%08x\n",
  527. iwl_bt_ctl_kill_msk[mvm->bt_ack_kill_msk[0]]);
  528. pos += scnprintf(buf+pos, bufsz-pos, "\tCTS Kill Mask 0x%08x\n",
  529. iwl_bt_ctl_kill_msk[mvm->bt_cts_kill_msk[0]]);
  530. } else {
  531. struct iwl_bt_coex_ci_cmd *cmd = &mvm->last_bt_ci_cmd;
  532. pos += scnprintf(buf+pos, bufsz-pos,
  533. "Channel inhibition CMD\n");
  534. pos += scnprintf(buf+pos, bufsz-pos,
  535. "\tPrimary Channel Bitmap 0x%016llx\n",
  536. le64_to_cpu(cmd->bt_primary_ci));
  537. pos += scnprintf(buf+pos, bufsz-pos,
  538. "\tSecondary Channel Bitmap 0x%016llx\n",
  539. le64_to_cpu(cmd->bt_secondary_ci));
  540. pos += scnprintf(buf+pos, bufsz-pos, "BT Configuration CMD\n");
  541. pos += scnprintf(buf+pos, bufsz-pos,
  542. "\tPrimary: ACK Kill Mask 0x%08x\n",
  543. iwl_bt_ctl_kill_msk[mvm->bt_ack_kill_msk[0]]);
  544. pos += scnprintf(buf+pos, bufsz-pos,
  545. "\tPrimary: CTS Kill Mask 0x%08x\n",
  546. iwl_bt_ctl_kill_msk[mvm->bt_cts_kill_msk[0]]);
  547. pos += scnprintf(buf+pos, bufsz-pos,
  548. "\tSecondary: ACK Kill Mask 0x%08x\n",
  549. iwl_bt_ctl_kill_msk[mvm->bt_ack_kill_msk[1]]);
  550. pos += scnprintf(buf+pos, bufsz-pos,
  551. "\tSecondary: CTS Kill Mask 0x%08x\n",
  552. iwl_bt_ctl_kill_msk[mvm->bt_cts_kill_msk[1]]);
  553. }
  554. mutex_unlock(&mvm->mutex);
  555. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  556. }
  557. static ssize_t
  558. iwl_dbgfs_bt_tx_prio_write(struct iwl_mvm *mvm, char *buf,
  559. size_t count, loff_t *ppos)
  560. {
  561. u32 bt_tx_prio;
  562. if (sscanf(buf, "%u", &bt_tx_prio) != 1)
  563. return -EINVAL;
  564. if (bt_tx_prio > 4)
  565. return -EINVAL;
  566. mvm->bt_tx_prio = bt_tx_prio;
  567. return count;
  568. }
  569. static ssize_t
  570. iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf,
  571. size_t count, loff_t *ppos)
  572. {
  573. static const char * const modes_str[BT_FORCE_ANT_MAX] = {
  574. [BT_FORCE_ANT_DIS] = "dis",
  575. [BT_FORCE_ANT_AUTO] = "auto",
  576. [BT_FORCE_ANT_BT] = "bt",
  577. [BT_FORCE_ANT_WIFI] = "wifi",
  578. };
  579. int ret, bt_force_ant_mode;
  580. for (bt_force_ant_mode = 0;
  581. bt_force_ant_mode < ARRAY_SIZE(modes_str);
  582. bt_force_ant_mode++) {
  583. if (!strcmp(buf, modes_str[bt_force_ant_mode]))
  584. break;
  585. }
  586. if (bt_force_ant_mode >= ARRAY_SIZE(modes_str))
  587. return -EINVAL;
  588. ret = 0;
  589. mutex_lock(&mvm->mutex);
  590. if (mvm->bt_force_ant_mode == bt_force_ant_mode)
  591. goto out;
  592. mvm->bt_force_ant_mode = bt_force_ant_mode;
  593. IWL_DEBUG_COEX(mvm, "Force mode: %s\n",
  594. modes_str[mvm->bt_force_ant_mode]);
  595. ret = iwl_send_bt_init_conf(mvm);
  596. out:
  597. mutex_unlock(&mvm->mutex);
  598. return ret ?: count;
  599. }
  600. #define PRINT_STATS_LE32(_str, _val) \
  601. pos += scnprintf(buf + pos, bufsz - pos, \
  602. fmt_table, _str, \
  603. le32_to_cpu(_val))
  604. static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file,
  605. char __user *user_buf, size_t count,
  606. loff_t *ppos)
  607. {
  608. struct iwl_mvm *mvm = file->private_data;
  609. static const char *fmt_table = "\t%-30s %10u\n";
  610. static const char *fmt_header = "%-32s\n";
  611. int pos = 0;
  612. char *buf;
  613. int ret;
  614. /* 43 is the size of each data line, 33 is the size of each header */
  615. size_t bufsz =
  616. ((sizeof(struct mvm_statistics_rx) / sizeof(__le32)) * 43) +
  617. (4 * 33) + 1;
  618. struct mvm_statistics_rx_phy *ofdm;
  619. struct mvm_statistics_rx_phy *cck;
  620. struct mvm_statistics_rx_non_phy *general;
  621. struct mvm_statistics_rx_ht_phy *ht;
  622. buf = kzalloc(bufsz, GFP_KERNEL);
  623. if (!buf)
  624. return -ENOMEM;
  625. mutex_lock(&mvm->mutex);
  626. ofdm = &mvm->rx_stats.ofdm;
  627. cck = &mvm->rx_stats.cck;
  628. general = &mvm->rx_stats.general;
  629. ht = &mvm->rx_stats.ofdm_ht;
  630. pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
  631. "Statistics_Rx - OFDM");
  632. PRINT_STATS_LE32("ina_cnt", ofdm->ina_cnt);
  633. PRINT_STATS_LE32("fina_cnt", ofdm->fina_cnt);
  634. PRINT_STATS_LE32("plcp_err", ofdm->plcp_err);
  635. PRINT_STATS_LE32("crc32_err", ofdm->crc32_err);
  636. PRINT_STATS_LE32("overrun_err", ofdm->overrun_err);
  637. PRINT_STATS_LE32("early_overrun_err", ofdm->early_overrun_err);
  638. PRINT_STATS_LE32("crc32_good", ofdm->crc32_good);
  639. PRINT_STATS_LE32("false_alarm_cnt", ofdm->false_alarm_cnt);
  640. PRINT_STATS_LE32("fina_sync_err_cnt", ofdm->fina_sync_err_cnt);
  641. PRINT_STATS_LE32("sfd_timeout", ofdm->sfd_timeout);
  642. PRINT_STATS_LE32("fina_timeout", ofdm->fina_timeout);
  643. PRINT_STATS_LE32("unresponded_rts", ofdm->unresponded_rts);
  644. PRINT_STATS_LE32("rxe_frame_lmt_overrun",
  645. ofdm->rxe_frame_limit_overrun);
  646. PRINT_STATS_LE32("sent_ack_cnt", ofdm->sent_ack_cnt);
  647. PRINT_STATS_LE32("sent_cts_cnt", ofdm->sent_cts_cnt);
  648. PRINT_STATS_LE32("sent_ba_rsp_cnt", ofdm->sent_ba_rsp_cnt);
  649. PRINT_STATS_LE32("dsp_self_kill", ofdm->dsp_self_kill);
  650. PRINT_STATS_LE32("mh_format_err", ofdm->mh_format_err);
  651. PRINT_STATS_LE32("re_acq_main_rssi_sum", ofdm->re_acq_main_rssi_sum);
  652. PRINT_STATS_LE32("reserved", ofdm->reserved);
  653. pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
  654. "Statistics_Rx - CCK");
  655. PRINT_STATS_LE32("ina_cnt", cck->ina_cnt);
  656. PRINT_STATS_LE32("fina_cnt", cck->fina_cnt);
  657. PRINT_STATS_LE32("plcp_err", cck->plcp_err);
  658. PRINT_STATS_LE32("crc32_err", cck->crc32_err);
  659. PRINT_STATS_LE32("overrun_err", cck->overrun_err);
  660. PRINT_STATS_LE32("early_overrun_err", cck->early_overrun_err);
  661. PRINT_STATS_LE32("crc32_good", cck->crc32_good);
  662. PRINT_STATS_LE32("false_alarm_cnt", cck->false_alarm_cnt);
  663. PRINT_STATS_LE32("fina_sync_err_cnt", cck->fina_sync_err_cnt);
  664. PRINT_STATS_LE32("sfd_timeout", cck->sfd_timeout);
  665. PRINT_STATS_LE32("fina_timeout", cck->fina_timeout);
  666. PRINT_STATS_LE32("unresponded_rts", cck->unresponded_rts);
  667. PRINT_STATS_LE32("rxe_frame_lmt_overrun",
  668. cck->rxe_frame_limit_overrun);
  669. PRINT_STATS_LE32("sent_ack_cnt", cck->sent_ack_cnt);
  670. PRINT_STATS_LE32("sent_cts_cnt", cck->sent_cts_cnt);
  671. PRINT_STATS_LE32("sent_ba_rsp_cnt", cck->sent_ba_rsp_cnt);
  672. PRINT_STATS_LE32("dsp_self_kill", cck->dsp_self_kill);
  673. PRINT_STATS_LE32("mh_format_err", cck->mh_format_err);
  674. PRINT_STATS_LE32("re_acq_main_rssi_sum", cck->re_acq_main_rssi_sum);
  675. PRINT_STATS_LE32("reserved", cck->reserved);
  676. pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
  677. "Statistics_Rx - GENERAL");
  678. PRINT_STATS_LE32("bogus_cts", general->bogus_cts);
  679. PRINT_STATS_LE32("bogus_ack", general->bogus_ack);
  680. PRINT_STATS_LE32("non_bssid_frames", general->non_bssid_frames);
  681. PRINT_STATS_LE32("filtered_frames", general->filtered_frames);
  682. PRINT_STATS_LE32("non_channel_beacons", general->non_channel_beacons);
  683. PRINT_STATS_LE32("channel_beacons", general->channel_beacons);
  684. PRINT_STATS_LE32("num_missed_bcon", general->num_missed_bcon);
  685. PRINT_STATS_LE32("adc_rx_saturation_time",
  686. general->adc_rx_saturation_time);
  687. PRINT_STATS_LE32("ina_detection_search_time",
  688. general->ina_detection_search_time);
  689. PRINT_STATS_LE32("beacon_silence_rssi_a",
  690. general->beacon_silence_rssi_a);
  691. PRINT_STATS_LE32("beacon_silence_rssi_b",
  692. general->beacon_silence_rssi_b);
  693. PRINT_STATS_LE32("beacon_silence_rssi_c",
  694. general->beacon_silence_rssi_c);
  695. PRINT_STATS_LE32("interference_data_flag",
  696. general->interference_data_flag);
  697. PRINT_STATS_LE32("channel_load", general->channel_load);
  698. PRINT_STATS_LE32("dsp_false_alarms", general->dsp_false_alarms);
  699. PRINT_STATS_LE32("beacon_rssi_a", general->beacon_rssi_a);
  700. PRINT_STATS_LE32("beacon_rssi_b", general->beacon_rssi_b);
  701. PRINT_STATS_LE32("beacon_rssi_c", general->beacon_rssi_c);
  702. PRINT_STATS_LE32("beacon_energy_a", general->beacon_energy_a);
  703. PRINT_STATS_LE32("beacon_energy_b", general->beacon_energy_b);
  704. PRINT_STATS_LE32("beacon_energy_c", general->beacon_energy_c);
  705. PRINT_STATS_LE32("num_bt_kills", general->num_bt_kills);
  706. PRINT_STATS_LE32("mac_id", general->mac_id);
  707. PRINT_STATS_LE32("directed_data_mpdu", general->directed_data_mpdu);
  708. pos += scnprintf(buf + pos, bufsz - pos, fmt_header,
  709. "Statistics_Rx - HT");
  710. PRINT_STATS_LE32("plcp_err", ht->plcp_err);
  711. PRINT_STATS_LE32("overrun_err", ht->overrun_err);
  712. PRINT_STATS_LE32("early_overrun_err", ht->early_overrun_err);
  713. PRINT_STATS_LE32("crc32_good", ht->crc32_good);
  714. PRINT_STATS_LE32("crc32_err", ht->crc32_err);
  715. PRINT_STATS_LE32("mh_format_err", ht->mh_format_err);
  716. PRINT_STATS_LE32("agg_crc32_good", ht->agg_crc32_good);
  717. PRINT_STATS_LE32("agg_mpdu_cnt", ht->agg_mpdu_cnt);
  718. PRINT_STATS_LE32("agg_cnt", ht->agg_cnt);
  719. PRINT_STATS_LE32("unsupport_mcs", ht->unsupport_mcs);
  720. mutex_unlock(&mvm->mutex);
  721. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  722. kfree(buf);
  723. return ret;
  724. }
  725. #undef PRINT_STAT_LE32
  726. static ssize_t iwl_dbgfs_frame_stats_read(struct iwl_mvm *mvm,
  727. char __user *user_buf, size_t count,
  728. loff_t *ppos,
  729. struct iwl_mvm_frame_stats *stats)
  730. {
  731. char *buff, *pos, *endpos;
  732. int idx, i;
  733. int ret;
  734. static const size_t bufsz = 1024;
  735. buff = kmalloc(bufsz, GFP_KERNEL);
  736. if (!buff)
  737. return -ENOMEM;
  738. spin_lock_bh(&mvm->drv_stats_lock);
  739. pos = buff;
  740. endpos = pos + bufsz;
  741. pos += scnprintf(pos, endpos - pos,
  742. "Legacy/HT/VHT\t:\t%d/%d/%d\n",
  743. stats->legacy_frames,
  744. stats->ht_frames,
  745. stats->vht_frames);
  746. pos += scnprintf(pos, endpos - pos, "20/40/80\t:\t%d/%d/%d\n",
  747. stats->bw_20_frames,
  748. stats->bw_40_frames,
  749. stats->bw_80_frames);
  750. pos += scnprintf(pos, endpos - pos, "NGI/SGI\t\t:\t%d/%d\n",
  751. stats->ngi_frames,
  752. stats->sgi_frames);
  753. pos += scnprintf(pos, endpos - pos, "SISO/MIMO2\t:\t%d/%d\n",
  754. stats->siso_frames,
  755. stats->mimo2_frames);
  756. pos += scnprintf(pos, endpos - pos, "FAIL/SCSS\t:\t%d/%d\n",
  757. stats->fail_frames,
  758. stats->success_frames);
  759. pos += scnprintf(pos, endpos - pos, "MPDUs agg\t:\t%d\n",
  760. stats->agg_frames);
  761. pos += scnprintf(pos, endpos - pos, "A-MPDUs\t\t:\t%d\n",
  762. stats->ampdu_count);
  763. pos += scnprintf(pos, endpos - pos, "Avg MPDUs/A-MPDU:\t%d\n",
  764. stats->ampdu_count > 0 ?
  765. (stats->agg_frames / stats->ampdu_count) : 0);
  766. pos += scnprintf(pos, endpos - pos, "Last Rates\n");
  767. idx = stats->last_frame_idx - 1;
  768. for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) {
  769. idx = (idx + 1) % ARRAY_SIZE(stats->last_rates);
  770. if (stats->last_rates[idx] == 0)
  771. continue;
  772. pos += scnprintf(pos, endpos - pos, "Rate[%d]: ",
  773. (int)(ARRAY_SIZE(stats->last_rates) - i));
  774. pos += rs_pretty_print_rate(pos, stats->last_rates[idx]);
  775. }
  776. spin_unlock_bh(&mvm->drv_stats_lock);
  777. ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
  778. kfree(buff);
  779. return ret;
  780. }
  781. static ssize_t iwl_dbgfs_drv_rx_stats_read(struct file *file,
  782. char __user *user_buf, size_t count,
  783. loff_t *ppos)
  784. {
  785. struct iwl_mvm *mvm = file->private_data;
  786. return iwl_dbgfs_frame_stats_read(mvm, user_buf, count, ppos,
  787. &mvm->drv_rx_stats);
  788. }
  789. static ssize_t iwl_dbgfs_fw_restart_write(struct iwl_mvm *mvm, char *buf,
  790. size_t count, loff_t *ppos)
  791. {
  792. int ret;
  793. mutex_lock(&mvm->mutex);
  794. /* allow one more restart that we're provoking here */
  795. if (mvm->restart_fw >= 0)
  796. mvm->restart_fw++;
  797. /* take the return value to make compiler happy - it will fail anyway */
  798. ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_ERROR, 0, 0, NULL);
  799. mutex_unlock(&mvm->mutex);
  800. return count;
  801. }
  802. static ssize_t iwl_dbgfs_fw_nmi_write(struct iwl_mvm *mvm, char *buf,
  803. size_t count, loff_t *ppos)
  804. {
  805. int ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_NMI);
  806. if (ret)
  807. return ret;
  808. iwl_force_nmi(mvm->trans);
  809. iwl_mvm_unref(mvm, IWL_MVM_REF_NMI);
  810. return count;
  811. }
  812. static ssize_t
  813. iwl_dbgfs_scan_ant_rxchain_read(struct file *file,
  814. char __user *user_buf,
  815. size_t count, loff_t *ppos)
  816. {
  817. struct iwl_mvm *mvm = file->private_data;
  818. int pos = 0;
  819. char buf[32];
  820. const size_t bufsz = sizeof(buf);
  821. /* print which antennas were set for the scan command by the user */
  822. pos += scnprintf(buf + pos, bufsz - pos, "Antennas for scan: ");
  823. if (mvm->scan_rx_ant & ANT_A)
  824. pos += scnprintf(buf + pos, bufsz - pos, "A");
  825. if (mvm->scan_rx_ant & ANT_B)
  826. pos += scnprintf(buf + pos, bufsz - pos, "B");
  827. if (mvm->scan_rx_ant & ANT_C)
  828. pos += scnprintf(buf + pos, bufsz - pos, "C");
  829. pos += scnprintf(buf + pos, bufsz - pos, " (%hhx)\n", mvm->scan_rx_ant);
  830. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  831. }
  832. static ssize_t
  833. iwl_dbgfs_scan_ant_rxchain_write(struct iwl_mvm *mvm, char *buf,
  834. size_t count, loff_t *ppos)
  835. {
  836. u8 scan_rx_ant;
  837. if (sscanf(buf, "%hhx", &scan_rx_ant) != 1)
  838. return -EINVAL;
  839. if (scan_rx_ant > ANT_ABC)
  840. return -EINVAL;
  841. if (scan_rx_ant & ~mvm->fw->valid_rx_ant)
  842. return -EINVAL;
  843. mvm->scan_rx_ant = scan_rx_ant;
  844. return count;
  845. }
  846. #define ADD_TEXT(...) pos += scnprintf(buf + pos, bufsz - pos, __VA_ARGS__)
  847. #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
  848. static ssize_t iwl_dbgfs_bcast_filters_read(struct file *file,
  849. char __user *user_buf,
  850. size_t count, loff_t *ppos)
  851. {
  852. struct iwl_mvm *mvm = file->private_data;
  853. struct iwl_bcast_filter_cmd cmd;
  854. const struct iwl_fw_bcast_filter *filter;
  855. char *buf;
  856. int bufsz = 1024;
  857. int i, j, pos = 0;
  858. ssize_t ret;
  859. buf = kzalloc(bufsz, GFP_KERNEL);
  860. if (!buf)
  861. return -ENOMEM;
  862. mutex_lock(&mvm->mutex);
  863. if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) {
  864. ADD_TEXT("None\n");
  865. mutex_unlock(&mvm->mutex);
  866. goto out;
  867. }
  868. mutex_unlock(&mvm->mutex);
  869. for (i = 0; cmd.filters[i].attrs[0].mask; i++) {
  870. filter = &cmd.filters[i];
  871. ADD_TEXT("Filter [%d]:\n", i);
  872. ADD_TEXT("\tDiscard=%d\n", filter->discard);
  873. ADD_TEXT("\tFrame Type: %s\n",
  874. filter->frame_type ? "IPv4" : "Generic");
  875. for (j = 0; j < ARRAY_SIZE(filter->attrs); j++) {
  876. const struct iwl_fw_bcast_filter_attr *attr;
  877. attr = &filter->attrs[j];
  878. if (!attr->mask)
  879. break;
  880. ADD_TEXT("\tAttr [%d]: offset=%d (from %s), mask=0x%x, value=0x%x reserved=0x%x\n",
  881. j, attr->offset,
  882. attr->offset_type ? "IP End" :
  883. "Payload Start",
  884. be32_to_cpu(attr->mask),
  885. be32_to_cpu(attr->val),
  886. le16_to_cpu(attr->reserved1));
  887. }
  888. }
  889. out:
  890. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  891. kfree(buf);
  892. return ret;
  893. }
  894. static ssize_t iwl_dbgfs_bcast_filters_write(struct iwl_mvm *mvm, char *buf,
  895. size_t count, loff_t *ppos)
  896. {
  897. int pos, next_pos;
  898. struct iwl_fw_bcast_filter filter = {};
  899. struct iwl_bcast_filter_cmd cmd;
  900. u32 filter_id, attr_id, mask, value;
  901. int err = 0;
  902. if (sscanf(buf, "%d %hhi %hhi %n", &filter_id, &filter.discard,
  903. &filter.frame_type, &pos) != 3)
  904. return -EINVAL;
  905. if (filter_id >= ARRAY_SIZE(mvm->dbgfs_bcast_filtering.cmd.filters) ||
  906. filter.frame_type > BCAST_FILTER_FRAME_TYPE_IPV4)
  907. return -EINVAL;
  908. for (attr_id = 0; attr_id < ARRAY_SIZE(filter.attrs);
  909. attr_id++) {
  910. struct iwl_fw_bcast_filter_attr *attr =
  911. &filter.attrs[attr_id];
  912. if (pos >= count)
  913. break;
  914. if (sscanf(&buf[pos], "%hhi %hhi %i %i %n",
  915. &attr->offset, &attr->offset_type,
  916. &mask, &value, &next_pos) != 4)
  917. return -EINVAL;
  918. attr->mask = cpu_to_be32(mask);
  919. attr->val = cpu_to_be32(value);
  920. if (mask)
  921. filter.num_attrs++;
  922. pos += next_pos;
  923. }
  924. mutex_lock(&mvm->mutex);
  925. memcpy(&mvm->dbgfs_bcast_filtering.cmd.filters[filter_id],
  926. &filter, sizeof(filter));
  927. /* send updated bcast filtering configuration */
  928. if (mvm->dbgfs_bcast_filtering.override &&
  929. iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
  930. err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
  931. sizeof(cmd), &cmd);
  932. mutex_unlock(&mvm->mutex);
  933. return err ?: count;
  934. }
  935. static ssize_t iwl_dbgfs_bcast_filters_macs_read(struct file *file,
  936. char __user *user_buf,
  937. size_t count, loff_t *ppos)
  938. {
  939. struct iwl_mvm *mvm = file->private_data;
  940. struct iwl_bcast_filter_cmd cmd;
  941. char *buf;
  942. int bufsz = 1024;
  943. int i, pos = 0;
  944. ssize_t ret;
  945. buf = kzalloc(bufsz, GFP_KERNEL);
  946. if (!buf)
  947. return -ENOMEM;
  948. mutex_lock(&mvm->mutex);
  949. if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) {
  950. ADD_TEXT("None\n");
  951. mutex_unlock(&mvm->mutex);
  952. goto out;
  953. }
  954. mutex_unlock(&mvm->mutex);
  955. for (i = 0; i < ARRAY_SIZE(cmd.macs); i++) {
  956. const struct iwl_fw_bcast_mac *mac = &cmd.macs[i];
  957. ADD_TEXT("Mac [%d]: discard=%d attached_filters=0x%x\n",
  958. i, mac->default_discard, mac->attached_filters);
  959. }
  960. out:
  961. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  962. kfree(buf);
  963. return ret;
  964. }
  965. static ssize_t iwl_dbgfs_bcast_filters_macs_write(struct iwl_mvm *mvm,
  966. char *buf, size_t count,
  967. loff_t *ppos)
  968. {
  969. struct iwl_bcast_filter_cmd cmd;
  970. struct iwl_fw_bcast_mac mac = {};
  971. u32 mac_id, attached_filters;
  972. int err = 0;
  973. if (!mvm->bcast_filters)
  974. return -ENOENT;
  975. if (sscanf(buf, "%d %hhi %i", &mac_id, &mac.default_discard,
  976. &attached_filters) != 3)
  977. return -EINVAL;
  978. if (mac_id >= ARRAY_SIZE(cmd.macs) ||
  979. mac.default_discard > 1 ||
  980. attached_filters >= BIT(ARRAY_SIZE(cmd.filters)))
  981. return -EINVAL;
  982. mac.attached_filters = cpu_to_le16(attached_filters);
  983. mutex_lock(&mvm->mutex);
  984. memcpy(&mvm->dbgfs_bcast_filtering.cmd.macs[mac_id],
  985. &mac, sizeof(mac));
  986. /* send updated bcast filtering configuration */
  987. if (mvm->dbgfs_bcast_filtering.override &&
  988. iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
  989. err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
  990. sizeof(cmd), &cmd);
  991. mutex_unlock(&mvm->mutex);
  992. return err ?: count;
  993. }
  994. #endif
  995. #ifdef CONFIG_PM_SLEEP
  996. static ssize_t iwl_dbgfs_d3_sram_write(struct iwl_mvm *mvm, char *buf,
  997. size_t count, loff_t *ppos)
  998. {
  999. int store;
  1000. if (sscanf(buf, "%d", &store) != 1)
  1001. return -EINVAL;
  1002. mvm->store_d3_resume_sram = store;
  1003. return count;
  1004. }
  1005. static ssize_t iwl_dbgfs_d3_sram_read(struct file *file, char __user *user_buf,
  1006. size_t count, loff_t *ppos)
  1007. {
  1008. struct iwl_mvm *mvm = file->private_data;
  1009. const struct fw_img *img;
  1010. int ofs, len, pos = 0;
  1011. size_t bufsz, ret;
  1012. char *buf;
  1013. u8 *ptr = mvm->d3_resume_sram;
  1014. img = &mvm->fw->img[IWL_UCODE_WOWLAN];
  1015. len = img->sec[IWL_UCODE_SECTION_DATA].len;
  1016. bufsz = len * 4 + 256;
  1017. buf = kzalloc(bufsz, GFP_KERNEL);
  1018. if (!buf)
  1019. return -ENOMEM;
  1020. pos += scnprintf(buf, bufsz, "D3 SRAM capture: %sabled\n",
  1021. mvm->store_d3_resume_sram ? "en" : "dis");
  1022. if (ptr) {
  1023. for (ofs = 0; ofs < len; ofs += 16) {
  1024. pos += scnprintf(buf + pos, bufsz - pos,
  1025. "0x%.4x ", ofs);
  1026. hex_dump_to_buffer(ptr + ofs, 16, 16, 1, buf + pos,
  1027. bufsz - pos, false);
  1028. pos += strlen(buf + pos);
  1029. if (bufsz - pos > 0)
  1030. buf[pos++] = '\n';
  1031. }
  1032. } else {
  1033. pos += scnprintf(buf + pos, bufsz - pos,
  1034. "(no data captured)\n");
  1035. }
  1036. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1037. kfree(buf);
  1038. return ret;
  1039. }
  1040. #endif
  1041. #define PRINT_MVM_REF(ref) do { \
  1042. if (mvm->refs[ref]) \
  1043. pos += scnprintf(buf + pos, bufsz - pos, \
  1044. "\t(0x%lx): %d %s\n", \
  1045. BIT(ref), mvm->refs[ref], #ref); \
  1046. } while (0)
  1047. static ssize_t iwl_dbgfs_d0i3_refs_read(struct file *file,
  1048. char __user *user_buf,
  1049. size_t count, loff_t *ppos)
  1050. {
  1051. struct iwl_mvm *mvm = file->private_data;
  1052. int i, pos = 0;
  1053. char buf[256];
  1054. const size_t bufsz = sizeof(buf);
  1055. u32 refs = 0;
  1056. for (i = 0; i < IWL_MVM_REF_COUNT; i++)
  1057. if (mvm->refs[i])
  1058. refs |= BIT(i);
  1059. pos += scnprintf(buf + pos, bufsz - pos, "taken mvm refs: 0x%x\n",
  1060. refs);
  1061. PRINT_MVM_REF(IWL_MVM_REF_UCODE_DOWN);
  1062. PRINT_MVM_REF(IWL_MVM_REF_SCAN);
  1063. PRINT_MVM_REF(IWL_MVM_REF_ROC);
  1064. PRINT_MVM_REF(IWL_MVM_REF_P2P_CLIENT);
  1065. PRINT_MVM_REF(IWL_MVM_REF_AP_IBSS);
  1066. PRINT_MVM_REF(IWL_MVM_REF_USER);
  1067. PRINT_MVM_REF(IWL_MVM_REF_TX);
  1068. PRINT_MVM_REF(IWL_MVM_REF_TX_AGG);
  1069. PRINT_MVM_REF(IWL_MVM_REF_ADD_IF);
  1070. PRINT_MVM_REF(IWL_MVM_REF_START_AP);
  1071. PRINT_MVM_REF(IWL_MVM_REF_BSS_CHANGED);
  1072. PRINT_MVM_REF(IWL_MVM_REF_PREPARE_TX);
  1073. PRINT_MVM_REF(IWL_MVM_REF_PROTECT_TDLS);
  1074. PRINT_MVM_REF(IWL_MVM_REF_CHECK_CTKILL);
  1075. PRINT_MVM_REF(IWL_MVM_REF_PRPH_READ);
  1076. PRINT_MVM_REF(IWL_MVM_REF_PRPH_WRITE);
  1077. PRINT_MVM_REF(IWL_MVM_REF_NMI);
  1078. PRINT_MVM_REF(IWL_MVM_REF_TM_CMD);
  1079. PRINT_MVM_REF(IWL_MVM_REF_EXIT_WORK);
  1080. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1081. }
  1082. static ssize_t iwl_dbgfs_d0i3_refs_write(struct iwl_mvm *mvm, char *buf,
  1083. size_t count, loff_t *ppos)
  1084. {
  1085. unsigned long value;
  1086. int ret;
  1087. bool taken;
  1088. ret = kstrtoul(buf, 10, &value);
  1089. if (ret < 0)
  1090. return ret;
  1091. mutex_lock(&mvm->mutex);
  1092. taken = mvm->refs[IWL_MVM_REF_USER];
  1093. if (value == 1 && !taken)
  1094. iwl_mvm_ref(mvm, IWL_MVM_REF_USER);
  1095. else if (value == 0 && taken)
  1096. iwl_mvm_unref(mvm, IWL_MVM_REF_USER);
  1097. else
  1098. ret = -EINVAL;
  1099. mutex_unlock(&mvm->mutex);
  1100. if (ret < 0)
  1101. return ret;
  1102. return count;
  1103. }
  1104. #define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \
  1105. _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
  1106. #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz) \
  1107. _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm)
  1108. #define MVM_DEBUGFS_ADD_FILE_ALIAS(alias, name, parent, mode) do { \
  1109. if (!debugfs_create_file(alias, mode, parent, mvm, \
  1110. &iwl_dbgfs_##name##_ops)) \
  1111. goto err; \
  1112. } while (0)
  1113. #define MVM_DEBUGFS_ADD_FILE(name, parent, mode) \
  1114. MVM_DEBUGFS_ADD_FILE_ALIAS(#name, name, parent, mode)
  1115. static ssize_t
  1116. iwl_dbgfs_prph_reg_read(struct file *file,
  1117. char __user *user_buf,
  1118. size_t count, loff_t *ppos)
  1119. {
  1120. struct iwl_mvm *mvm = file->private_data;
  1121. int pos = 0;
  1122. char buf[32];
  1123. const size_t bufsz = sizeof(buf);
  1124. int ret;
  1125. if (!mvm->dbgfs_prph_reg_addr)
  1126. return -EINVAL;
  1127. ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_READ);
  1128. if (ret)
  1129. return ret;
  1130. pos += scnprintf(buf + pos, bufsz - pos, "Reg 0x%x: (0x%x)\n",
  1131. mvm->dbgfs_prph_reg_addr,
  1132. iwl_read_prph(mvm->trans, mvm->dbgfs_prph_reg_addr));
  1133. iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_READ);
  1134. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  1135. }
  1136. static ssize_t
  1137. iwl_dbgfs_prph_reg_write(struct iwl_mvm *mvm, char *buf,
  1138. size_t count, loff_t *ppos)
  1139. {
  1140. u8 args;
  1141. u32 value;
  1142. int ret;
  1143. args = sscanf(buf, "%i %i", &mvm->dbgfs_prph_reg_addr, &value);
  1144. /* if we only want to set the reg address - nothing more to do */
  1145. if (args == 1)
  1146. goto out;
  1147. /* otherwise, make sure we have both address and value */
  1148. if (args != 2)
  1149. return -EINVAL;
  1150. ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE);
  1151. if (ret)
  1152. return ret;
  1153. iwl_write_prph(mvm->trans, mvm->dbgfs_prph_reg_addr, value);
  1154. iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE);
  1155. out:
  1156. return count;
  1157. }
  1158. MVM_DEBUGFS_READ_WRITE_FILE_OPS(prph_reg, 64);
  1159. /* Device wide debugfs entries */
  1160. MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush, 16);
  1161. MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain, 8);
  1162. MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram, 64);
  1163. MVM_DEBUGFS_READ_WRITE_FILE_OPS(set_nic_temperature, 64);
  1164. MVM_DEBUGFS_READ_FILE_OPS(nic_temp);
  1165. MVM_DEBUGFS_READ_FILE_OPS(stations);
  1166. MVM_DEBUGFS_READ_FILE_OPS(bt_notif);
  1167. MVM_DEBUGFS_READ_FILE_OPS(bt_cmd);
  1168. MVM_DEBUGFS_READ_WRITE_FILE_OPS(disable_power_off, 64);
  1169. MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats);
  1170. MVM_DEBUGFS_READ_FILE_OPS(drv_rx_stats);
  1171. MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart, 10);
  1172. MVM_DEBUGFS_WRITE_FILE_OPS(fw_nmi, 10);
  1173. MVM_DEBUGFS_WRITE_FILE_OPS(bt_tx_prio, 10);
  1174. MVM_DEBUGFS_WRITE_FILE_OPS(bt_force_ant, 10);
  1175. MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain, 8);
  1176. MVM_DEBUGFS_READ_WRITE_FILE_OPS(d0i3_refs, 8);
  1177. static const struct file_operations iwl_dbgfs_fw_error_dump_ops = {
  1178. .open = iwl_dbgfs_fw_error_dump_open,
  1179. .read = iwl_dbgfs_fw_error_dump_read,
  1180. .release = iwl_dbgfs_fw_error_dump_release,
  1181. };
  1182. #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
  1183. MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256);
  1184. MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters_macs, 256);
  1185. #endif
  1186. #ifdef CONFIG_PM_SLEEP
  1187. MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram, 8);
  1188. #endif
  1189. int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
  1190. {
  1191. struct dentry *bcast_dir __maybe_unused;
  1192. char buf[100];
  1193. spin_lock_init(&mvm->drv_stats_lock);
  1194. mvm->debugfs_dir = dbgfs_dir;
  1195. MVM_DEBUGFS_ADD_FILE(tx_flush, mvm->debugfs_dir, S_IWUSR);
  1196. MVM_DEBUGFS_ADD_FILE(sta_drain, mvm->debugfs_dir, S_IWUSR);
  1197. MVM_DEBUGFS_ADD_FILE(sram, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
  1198. MVM_DEBUGFS_ADD_FILE(set_nic_temperature, mvm->debugfs_dir,
  1199. S_IWUSR | S_IRUSR);
  1200. MVM_DEBUGFS_ADD_FILE(nic_temp, dbgfs_dir, S_IRUSR);
  1201. MVM_DEBUGFS_ADD_FILE(stations, dbgfs_dir, S_IRUSR);
  1202. MVM_DEBUGFS_ADD_FILE(fw_error_dump, dbgfs_dir, S_IRUSR);
  1203. MVM_DEBUGFS_ADD_FILE(bt_notif, dbgfs_dir, S_IRUSR);
  1204. MVM_DEBUGFS_ADD_FILE(bt_cmd, dbgfs_dir, S_IRUSR);
  1205. MVM_DEBUGFS_ADD_FILE(disable_power_off, mvm->debugfs_dir,
  1206. S_IRUSR | S_IWUSR);
  1207. MVM_DEBUGFS_ADD_FILE(fw_rx_stats, mvm->debugfs_dir, S_IRUSR);
  1208. MVM_DEBUGFS_ADD_FILE(drv_rx_stats, mvm->debugfs_dir, S_IRUSR);
  1209. MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, S_IWUSR);
  1210. MVM_DEBUGFS_ADD_FILE(fw_nmi, mvm->debugfs_dir, S_IWUSR);
  1211. MVM_DEBUGFS_ADD_FILE(bt_tx_prio, mvm->debugfs_dir, S_IWUSR);
  1212. MVM_DEBUGFS_ADD_FILE(bt_force_ant, mvm->debugfs_dir, S_IWUSR);
  1213. MVM_DEBUGFS_ADD_FILE(scan_ant_rxchain, mvm->debugfs_dir,
  1214. S_IWUSR | S_IRUSR);
  1215. MVM_DEBUGFS_ADD_FILE(prph_reg, mvm->debugfs_dir, S_IWUSR | S_IRUSR);
  1216. MVM_DEBUGFS_ADD_FILE(d0i3_refs, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
  1217. #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
  1218. if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING) {
  1219. bcast_dir = debugfs_create_dir("bcast_filtering",
  1220. mvm->debugfs_dir);
  1221. if (!bcast_dir)
  1222. goto err;
  1223. if (!debugfs_create_bool("override", S_IRUSR | S_IWUSR,
  1224. bcast_dir,
  1225. &mvm->dbgfs_bcast_filtering.override))
  1226. goto err;
  1227. MVM_DEBUGFS_ADD_FILE_ALIAS("filters", bcast_filters,
  1228. bcast_dir, S_IWUSR | S_IRUSR);
  1229. MVM_DEBUGFS_ADD_FILE_ALIAS("macs", bcast_filters_macs,
  1230. bcast_dir, S_IWUSR | S_IRUSR);
  1231. }
  1232. #endif
  1233. #ifdef CONFIG_PM_SLEEP
  1234. MVM_DEBUGFS_ADD_FILE(d3_sram, mvm->debugfs_dir, S_IRUSR | S_IWUSR);
  1235. MVM_DEBUGFS_ADD_FILE(d3_test, mvm->debugfs_dir, S_IRUSR);
  1236. if (!debugfs_create_bool("d3_wake_sysassert", S_IRUSR | S_IWUSR,
  1237. mvm->debugfs_dir, &mvm->d3_wake_sysassert))
  1238. goto err;
  1239. #endif
  1240. if (!debugfs_create_u8("low_latency_agg_frame_limit", S_IRUSR | S_IWUSR,
  1241. mvm->debugfs_dir,
  1242. &mvm->low_latency_agg_frame_limit))
  1243. goto err;
  1244. if (!debugfs_create_u8("ps_disabled", S_IRUSR,
  1245. mvm->debugfs_dir, &mvm->ps_disabled))
  1246. goto err;
  1247. if (!debugfs_create_blob("nvm_hw", S_IRUSR,
  1248. mvm->debugfs_dir, &mvm->nvm_hw_blob))
  1249. goto err;
  1250. if (!debugfs_create_blob("nvm_sw", S_IRUSR,
  1251. mvm->debugfs_dir, &mvm->nvm_sw_blob))
  1252. goto err;
  1253. if (!debugfs_create_blob("nvm_calib", S_IRUSR,
  1254. mvm->debugfs_dir, &mvm->nvm_calib_blob))
  1255. goto err;
  1256. if (!debugfs_create_blob("nvm_prod", S_IRUSR,
  1257. mvm->debugfs_dir, &mvm->nvm_prod_blob))
  1258. goto err;
  1259. /*
  1260. * Create a symlink with mac80211. It will be removed when mac80211
  1261. * exists (before the opmode exists which removes the target.)
  1262. */
  1263. snprintf(buf, 100, "../../%s/%s",
  1264. dbgfs_dir->d_parent->d_parent->d_name.name,
  1265. dbgfs_dir->d_parent->d_name.name);
  1266. if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf))
  1267. goto err;
  1268. return 0;
  1269. err:
  1270. IWL_ERR(mvm, "Can't create the mvm debugfs directory\n");
  1271. return -ENOMEM;
  1272. }