iwl-debugfs.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. /******************************************************************************
  2. *
  3. * GPL LICENSE SUMMARY
  4. *
  5. * Copyright(c) 2008 - 2009 Intel Corporation. All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of version 2 of the GNU General Public License as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  19. * USA
  20. *
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called LICENSE.GPL.
  23. *
  24. * Contact Information:
  25. * Intel Linux Wireless <ilw@linux.intel.com>
  26. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  27. *****************************************************************************/
  28. #include <linux/kernel.h>
  29. #include <linux/module.h>
  30. #include <linux/debugfs.h>
  31. #include <linux/ieee80211.h>
  32. #include <net/mac80211.h>
  33. #include "iwl-dev.h"
  34. #include "iwl-debug.h"
  35. #include "iwl-core.h"
  36. #include "iwl-io.h"
  37. /* create and remove of files */
  38. #define DEBUGFS_ADD_DIR(name, parent) do { \
  39. dbgfs->dir_##name = debugfs_create_dir(#name, parent); \
  40. if (!(dbgfs->dir_##name)) \
  41. goto err; \
  42. } while (0)
  43. #define DEBUGFS_ADD_FILE(name, parent) do { \
  44. dbgfs->dbgfs_##parent##_files.file_##name = \
  45. debugfs_create_file(#name, 0644, dbgfs->dir_##parent, priv, \
  46. &iwl_dbgfs_##name##_ops); \
  47. if (!(dbgfs->dbgfs_##parent##_files.file_##name)) \
  48. goto err; \
  49. } while (0)
  50. #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \
  51. dbgfs->dbgfs_##parent##_files.file_##name = \
  52. debugfs_create_bool(#name, 0644, dbgfs->dir_##parent, ptr); \
  53. if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \
  54. || !dbgfs->dbgfs_##parent##_files.file_##name) \
  55. goto err; \
  56. } while (0)
  57. #define DEBUGFS_ADD_X32(name, parent, ptr) do { \
  58. dbgfs->dbgfs_##parent##_files.file_##name = \
  59. debugfs_create_x32(#name, 0444, dbgfs->dir_##parent, ptr); \
  60. if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name) \
  61. || !dbgfs->dbgfs_##parent##_files.file_##name) \
  62. goto err; \
  63. } while (0)
  64. #define DEBUGFS_REMOVE(name) do { \
  65. debugfs_remove(name); \
  66. name = NULL; \
  67. } while (0);
  68. /* file operation */
  69. #define DEBUGFS_READ_FUNC(name) \
  70. static ssize_t iwl_dbgfs_##name##_read(struct file *file, \
  71. char __user *user_buf, \
  72. size_t count, loff_t *ppos);
  73. #define DEBUGFS_WRITE_FUNC(name) \
  74. static ssize_t iwl_dbgfs_##name##_write(struct file *file, \
  75. const char __user *user_buf, \
  76. size_t count, loff_t *ppos);
  77. static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file)
  78. {
  79. file->private_data = inode->i_private;
  80. return 0;
  81. }
  82. #define DEBUGFS_READ_FILE_OPS(name) \
  83. DEBUGFS_READ_FUNC(name); \
  84. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  85. .read = iwl_dbgfs_##name##_read, \
  86. .open = iwl_dbgfs_open_file_generic, \
  87. };
  88. #define DEBUGFS_WRITE_FILE_OPS(name) \
  89. DEBUGFS_WRITE_FUNC(name); \
  90. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  91. .write = iwl_dbgfs_##name##_write, \
  92. .open = iwl_dbgfs_open_file_generic, \
  93. };
  94. #define DEBUGFS_READ_WRITE_FILE_OPS(name) \
  95. DEBUGFS_READ_FUNC(name); \
  96. DEBUGFS_WRITE_FUNC(name); \
  97. static const struct file_operations iwl_dbgfs_##name##_ops = { \
  98. .write = iwl_dbgfs_##name##_write, \
  99. .read = iwl_dbgfs_##name##_read, \
  100. .open = iwl_dbgfs_open_file_generic, \
  101. };
  102. static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
  103. char __user *user_buf,
  104. size_t count, loff_t *ppos) {
  105. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  106. char buf[256];
  107. int pos = 0;
  108. const size_t bufsz = sizeof(buf);
  109. pos += scnprintf(buf + pos, bufsz - pos, "mgmt: %u\n",
  110. priv->tx_stats[0].cnt);
  111. pos += scnprintf(buf + pos, bufsz - pos, "ctrl: %u\n",
  112. priv->tx_stats[1].cnt);
  113. pos += scnprintf(buf + pos, bufsz - pos, "data: %u\n",
  114. priv->tx_stats[2].cnt);
  115. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  116. }
  117. static ssize_t iwl_dbgfs_rx_statistics_read(struct file *file,
  118. char __user *user_buf,
  119. size_t count, loff_t *ppos) {
  120. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  121. char buf[256];
  122. int pos = 0;
  123. const size_t bufsz = sizeof(buf);
  124. pos += scnprintf(buf + pos, bufsz - pos, "mgmt: %u\n",
  125. priv->rx_stats[0].cnt);
  126. pos += scnprintf(buf + pos, bufsz - pos, "ctrl: %u\n",
  127. priv->rx_stats[1].cnt);
  128. pos += scnprintf(buf + pos, bufsz - pos, "data: %u\n",
  129. priv->rx_stats[2].cnt);
  130. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  131. }
  132. #define BYTE1_MASK 0x000000ff;
  133. #define BYTE2_MASK 0x0000ffff;
  134. #define BYTE3_MASK 0x00ffffff;
  135. static ssize_t iwl_dbgfs_sram_read(struct file *file,
  136. char __user *user_buf,
  137. size_t count, loff_t *ppos)
  138. {
  139. u32 val;
  140. char buf[1024];
  141. ssize_t ret;
  142. int i;
  143. int pos = 0;
  144. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  145. const size_t bufsz = sizeof(buf);
  146. iwl_grab_nic_access(priv);
  147. for (i = priv->dbgfs->sram_len; i > 0; i -= 4) {
  148. val = iwl_read_targ_mem(priv, priv->dbgfs->sram_offset + \
  149. priv->dbgfs->sram_len - i);
  150. if (i < 4) {
  151. switch (i) {
  152. case 1:
  153. val &= BYTE1_MASK;
  154. break;
  155. case 2:
  156. val &= BYTE2_MASK;
  157. break;
  158. case 3:
  159. val &= BYTE3_MASK;
  160. break;
  161. }
  162. }
  163. pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val);
  164. }
  165. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  166. iwl_release_nic_access(priv);
  167. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  168. return ret;
  169. }
  170. static ssize_t iwl_dbgfs_sram_write(struct file *file,
  171. const char __user *user_buf,
  172. size_t count, loff_t *ppos)
  173. {
  174. struct iwl_priv *priv = file->private_data;
  175. char buf[64];
  176. int buf_size;
  177. u32 offset, len;
  178. memset(buf, 0, sizeof(buf));
  179. buf_size = min(count, sizeof(buf) - 1);
  180. if (copy_from_user(buf, user_buf, buf_size))
  181. return -EFAULT;
  182. if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
  183. priv->dbgfs->sram_offset = offset;
  184. priv->dbgfs->sram_len = len;
  185. } else {
  186. priv->dbgfs->sram_offset = 0;
  187. priv->dbgfs->sram_len = 0;
  188. }
  189. return count;
  190. }
  191. static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
  192. size_t count, loff_t *ppos)
  193. {
  194. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  195. struct iwl_station_entry *station;
  196. int max_sta = priv->hw_params.max_stations;
  197. char *buf;
  198. int i, j, pos = 0;
  199. ssize_t ret;
  200. /* Add 30 for initial string */
  201. const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations);
  202. buf = kmalloc(bufsz, GFP_KERNEL);
  203. if (!buf)
  204. return -ENOMEM;
  205. pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n",
  206. priv->num_stations);
  207. for (i = 0; i < max_sta; i++) {
  208. station = &priv->stations[i];
  209. if (station->used) {
  210. pos += scnprintf(buf + pos, bufsz - pos,
  211. "station %d:\ngeneral data:\n", i+1);
  212. pos += scnprintf(buf + pos, bufsz - pos, "id: %u\n",
  213. station->sta.sta.sta_id);
  214. pos += scnprintf(buf + pos, bufsz - pos, "mode: %u\n",
  215. station->sta.mode);
  216. pos += scnprintf(buf + pos, bufsz - pos,
  217. "flags: 0x%x\n",
  218. station->sta.station_flags_msk);
  219. pos += scnprintf(buf + pos, bufsz - pos,
  220. "ps_status: %u\n", station->ps_status);
  221. pos += scnprintf(buf + pos, bufsz - pos, "tid data:\n");
  222. pos += scnprintf(buf + pos, bufsz - pos,
  223. "seq_num\t\ttxq_id");
  224. pos += scnprintf(buf + pos, bufsz - pos,
  225. "\tframe_count\twait_for_ba\t");
  226. pos += scnprintf(buf + pos, bufsz - pos,
  227. "start_idx\tbitmap0\t");
  228. pos += scnprintf(buf + pos, bufsz - pos,
  229. "bitmap1\trate_n_flags");
  230. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  231. for (j = 0; j < MAX_TID_COUNT; j++) {
  232. pos += scnprintf(buf + pos, bufsz - pos,
  233. "[%d]:\t\t%u", j,
  234. station->tid[j].seq_number);
  235. pos += scnprintf(buf + pos, bufsz - pos,
  236. "\t%u\t\t%u\t\t%u\t\t",
  237. station->tid[j].agg.txq_id,
  238. station->tid[j].agg.frame_count,
  239. station->tid[j].agg.wait_for_ba);
  240. pos += scnprintf(buf + pos, bufsz - pos,
  241. "%u\t%llu\t%u",
  242. station->tid[j].agg.start_idx,
  243. (unsigned long long)station->tid[j].agg.bitmap,
  244. station->tid[j].agg.rate_n_flags);
  245. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  246. }
  247. pos += scnprintf(buf + pos, bufsz - pos, "\n");
  248. }
  249. }
  250. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  251. kfree(buf);
  252. return ret;
  253. }
  254. static ssize_t iwl_dbgfs_eeprom_read(struct file *file,
  255. char __user *user_buf,
  256. size_t count,
  257. loff_t *ppos)
  258. {
  259. ssize_t ret;
  260. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  261. int pos = 0, ofs = 0, buf_size = 0;
  262. const u8 *ptr;
  263. char *buf;
  264. size_t eeprom_len = priv->cfg->eeprom_size;
  265. buf_size = 4 * eeprom_len + 256;
  266. if (eeprom_len % 16) {
  267. IWL_ERR(priv, "EEPROM size is not multiple of 16.\n");
  268. return -ENODATA;
  269. }
  270. /* 4 characters for byte 0xYY */
  271. buf = kzalloc(buf_size, GFP_KERNEL);
  272. if (!buf) {
  273. IWL_ERR(priv, "Can not allocate Buffer\n");
  274. return -ENOMEM;
  275. }
  276. ptr = priv->eeprom;
  277. for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
  278. pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
  279. hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
  280. buf_size - pos, 0);
  281. pos += strlen(buf);
  282. if (buf_size - pos > 0)
  283. buf[pos++] = '\n';
  284. }
  285. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  286. kfree(buf);
  287. return ret;
  288. }
  289. static ssize_t iwl_dbgfs_log_event_write(struct file *file,
  290. const char __user *user_buf,
  291. size_t count, loff_t *ppos)
  292. {
  293. struct iwl_priv *priv = file->private_data;
  294. u32 event_log_flag;
  295. char buf[8];
  296. int buf_size;
  297. memset(buf, 0, sizeof(buf));
  298. buf_size = min(count, sizeof(buf) - 1);
  299. if (copy_from_user(buf, user_buf, buf_size))
  300. return -EFAULT;
  301. if (sscanf(buf, "%d", &event_log_flag) != 1)
  302. return -EFAULT;
  303. if (event_log_flag == 1)
  304. iwl_dump_nic_event_log(priv);
  305. return count;
  306. }
  307. static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
  308. size_t count, loff_t *ppos)
  309. {
  310. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  311. struct ieee80211_channel *channels = NULL;
  312. const struct ieee80211_supported_band *supp_band = NULL;
  313. int pos = 0, i, bufsz = PAGE_SIZE;
  314. char *buf;
  315. ssize_t ret;
  316. if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status))
  317. return -EAGAIN;
  318. buf = kzalloc(bufsz, GFP_KERNEL);
  319. if (!buf) {
  320. IWL_ERR(priv, "Can not allocate Buffer\n");
  321. return -ENOMEM;
  322. }
  323. supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ);
  324. channels = supp_band->channels;
  325. pos += scnprintf(buf + pos, bufsz - pos,
  326. "Displaying %d channels in 2.4GHz band 802.11bg):\n",
  327. supp_band->n_channels);
  328. for (i = 0; i < supp_band->n_channels; i++)
  329. pos += scnprintf(buf + pos, bufsz - pos,
  330. "%d: %ddBm: BSS%s%s, %s.\n",
  331. ieee80211_frequency_to_channel(
  332. channels[i].center_freq),
  333. channels[i].max_power,
  334. channels[i].flags & IEEE80211_CHAN_RADAR ?
  335. " (IEEE 802.11h required)" : "",
  336. (!(channels[i].flags & IEEE80211_CHAN_NO_IBSS)
  337. || (channels[i].flags &
  338. IEEE80211_CHAN_RADAR)) ? "" :
  339. ", IBSS",
  340. channels[i].flags &
  341. IEEE80211_CHAN_PASSIVE_SCAN ?
  342. "passive only" : "active/passive");
  343. supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
  344. channels = supp_band->channels;
  345. pos += scnprintf(buf + pos, bufsz - pos,
  346. "Displaying %d channels in 5.2GHz band (802.11a)\n",
  347. supp_band->n_channels);
  348. for (i = 0; i < supp_band->n_channels; i++)
  349. pos += scnprintf(buf + pos, bufsz - pos,
  350. "%d: %ddBm: BSS%s%s, %s.\n",
  351. ieee80211_frequency_to_channel(
  352. channels[i].center_freq),
  353. channels[i].max_power,
  354. channels[i].flags & IEEE80211_CHAN_RADAR ?
  355. " (IEEE 802.11h required)" : "",
  356. ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
  357. || (channels[i].flags &
  358. IEEE80211_CHAN_RADAR)) ? "" :
  359. ", IBSS",
  360. channels[i].flags &
  361. IEEE80211_CHAN_PASSIVE_SCAN ?
  362. "passive only" : "active/passive");
  363. ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  364. kfree(buf);
  365. return ret;
  366. }
  367. static ssize_t iwl_dbgfs_status_read(struct file *file,
  368. char __user *user_buf,
  369. size_t count, loff_t *ppos) {
  370. struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
  371. char buf[512];
  372. int pos = 0;
  373. const size_t bufsz = sizeof(buf);
  374. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n",
  375. test_bit(STATUS_HCMD_ACTIVE, &priv->status));
  376. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_SYNC_ACTIVE: %d\n",
  377. test_bit(STATUS_HCMD_SYNC_ACTIVE, &priv->status));
  378. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n",
  379. test_bit(STATUS_INT_ENABLED, &priv->status));
  380. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n",
  381. test_bit(STATUS_RF_KILL_HW, &priv->status));
  382. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_SW:\t %d\n",
  383. test_bit(STATUS_RF_KILL_SW, &priv->status));
  384. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n",
  385. test_bit(STATUS_INIT, &priv->status));
  386. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n",
  387. test_bit(STATUS_ALIVE, &priv->status));
  388. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n",
  389. test_bit(STATUS_READY, &priv->status));
  390. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n",
  391. test_bit(STATUS_TEMPERATURE, &priv->status));
  392. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n",
  393. test_bit(STATUS_GEO_CONFIGURED, &priv->status));
  394. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n",
  395. test_bit(STATUS_EXIT_PENDING, &priv->status));
  396. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_IN_SUSPEND:\t %d\n",
  397. test_bit(STATUS_IN_SUSPEND, &priv->status));
  398. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n",
  399. test_bit(STATUS_STATISTICS, &priv->status));
  400. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n",
  401. test_bit(STATUS_SCANNING, &priv->status));
  402. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n",
  403. test_bit(STATUS_SCAN_ABORTING, &priv->status));
  404. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n",
  405. test_bit(STATUS_SCAN_HW, &priv->status));
  406. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n",
  407. test_bit(STATUS_POWER_PMI, &priv->status));
  408. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
  409. test_bit(STATUS_FW_ERROR, &priv->status));
  410. pos += scnprintf(buf + pos, bufsz - pos, "STATUS_MODE_PENDING:\t %d\n",
  411. test_bit(STATUS_MODE_PENDING, &priv->status));
  412. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  413. }
  414. DEBUGFS_READ_WRITE_FILE_OPS(sram);
  415. DEBUGFS_WRITE_FILE_OPS(log_event);
  416. DEBUGFS_READ_FILE_OPS(eeprom);
  417. DEBUGFS_READ_FILE_OPS(stations);
  418. DEBUGFS_READ_FILE_OPS(rx_statistics);
  419. DEBUGFS_READ_FILE_OPS(tx_statistics);
  420. DEBUGFS_READ_FILE_OPS(channels);
  421. DEBUGFS_READ_FILE_OPS(status);
  422. /*
  423. * Create the debugfs files and directories
  424. *
  425. */
  426. int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
  427. {
  428. struct iwl_debugfs *dbgfs;
  429. struct dentry *phyd = priv->hw->wiphy->debugfsdir;
  430. int ret = 0;
  431. dbgfs = kzalloc(sizeof(struct iwl_debugfs), GFP_KERNEL);
  432. if (!dbgfs) {
  433. ret = -ENOMEM;
  434. goto err;
  435. }
  436. priv->dbgfs = dbgfs;
  437. dbgfs->name = name;
  438. dbgfs->dir_drv = debugfs_create_dir(name, phyd);
  439. if (!dbgfs->dir_drv || IS_ERR(dbgfs->dir_drv)) {
  440. ret = -ENOENT;
  441. goto err;
  442. }
  443. DEBUGFS_ADD_DIR(data, dbgfs->dir_drv);
  444. DEBUGFS_ADD_DIR(rf, dbgfs->dir_drv);
  445. DEBUGFS_ADD_FILE(eeprom, data);
  446. DEBUGFS_ADD_FILE(sram, data);
  447. DEBUGFS_ADD_FILE(log_event, data);
  448. DEBUGFS_ADD_FILE(stations, data);
  449. DEBUGFS_ADD_FILE(rx_statistics, data);
  450. DEBUGFS_ADD_FILE(tx_statistics, data);
  451. DEBUGFS_ADD_FILE(channels, data);
  452. DEBUGFS_ADD_FILE(status, data);
  453. DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal);
  454. DEBUGFS_ADD_BOOL(disable_chain_noise, rf,
  455. &priv->disable_chain_noise_cal);
  456. DEBUGFS_ADD_BOOL(disable_tx_power, rf, &priv->disable_tx_power_cal);
  457. return 0;
  458. err:
  459. IWL_ERR(priv, "Can't open the debugfs directory\n");
  460. iwl_dbgfs_unregister(priv);
  461. return ret;
  462. }
  463. EXPORT_SYMBOL(iwl_dbgfs_register);
  464. /**
  465. * Remove the debugfs files and directories
  466. *
  467. */
  468. void iwl_dbgfs_unregister(struct iwl_priv *priv)
  469. {
  470. if (!priv->dbgfs)
  471. return;
  472. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_eeprom);
  473. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_rx_statistics);
  474. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_tx_statistics);
  475. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram);
  476. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event);
  477. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations);
  478. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_channels);
  479. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_status);
  480. DEBUGFS_REMOVE(priv->dbgfs->dir_data);
  481. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity);
  482. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise);
  483. DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_tx_power);
  484. DEBUGFS_REMOVE(priv->dbgfs->dir_rf);
  485. DEBUGFS_REMOVE(priv->dbgfs->dir_drv);
  486. kfree(priv->dbgfs);
  487. priv->dbgfs = NULL;
  488. }
  489. EXPORT_SYMBOL(iwl_dbgfs_unregister);