debugfs-vif.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 - 2013 Intel Corporation. All rights reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of version 2 of the GNU General Public License as
  12. * published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  22. * USA
  23. *
  24. * The full GNU General Public License is included in this distribution
  25. * in the file called COPYING.
  26. *
  27. * Contact Information:
  28. * Intel Linux Wireless <ilw@linux.intel.com>
  29. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  30. *
  31. * BSD LICENSE
  32. *
  33. * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
  34. * All rights reserved.
  35. *
  36. * Redistribution and use in source and binary forms, with or without
  37. * modification, are permitted provided that the following conditions
  38. * are met:
  39. *
  40. * * Redistributions of source code must retain the above copyright
  41. * notice, this list of conditions and the following disclaimer.
  42. * * Redistributions in binary form must reproduce the above copyright
  43. * notice, this list of conditions and the following disclaimer in
  44. * the documentation and/or other materials provided with the
  45. * distribution.
  46. * * Neither the name Intel Corporation nor the names of its
  47. * contributors may be used to endorse or promote products derived
  48. * from this software without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  51. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  52. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  53. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  54. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  55. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  56. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  57. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  58. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  59. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  60. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  61. *
  62. *****************************************************************************/
  63. #include "mvm.h"
  64. #include "debugfs.h"
  65. static ssize_t iwl_dbgfs_mac_params_read(struct file *file,
  66. char __user *user_buf,
  67. size_t count, loff_t *ppos)
  68. {
  69. struct ieee80211_vif *vif = file->private_data;
  70. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  71. struct iwl_mvm *mvm = mvmvif->mvm;
  72. u8 ap_sta_id;
  73. struct ieee80211_chanctx_conf *chanctx_conf;
  74. char buf[512];
  75. int bufsz = sizeof(buf);
  76. int pos = 0;
  77. int i;
  78. mutex_lock(&mvm->mutex);
  79. ap_sta_id = mvmvif->ap_sta_id;
  80. pos += scnprintf(buf+pos, bufsz-pos, "mac id/color: %d / %d\n",
  81. mvmvif->id, mvmvif->color);
  82. pos += scnprintf(buf+pos, bufsz-pos, "bssid: %pM\n",
  83. vif->bss_conf.bssid);
  84. pos += scnprintf(buf+pos, bufsz-pos, "QoS:\n");
  85. for (i = 0; i < ARRAY_SIZE(mvmvif->queue_params); i++)
  86. pos += scnprintf(buf+pos, bufsz-pos,
  87. "\t%d: txop:%d - cw_min:%d - cw_max = %d - aifs = %d upasd = %d\n",
  88. i, mvmvif->queue_params[i].txop,
  89. mvmvif->queue_params[i].cw_min,
  90. mvmvif->queue_params[i].cw_max,
  91. mvmvif->queue_params[i].aifs,
  92. mvmvif->queue_params[i].uapsd);
  93. if (vif->type == NL80211_IFTYPE_STATION &&
  94. ap_sta_id != IWL_MVM_STATION_COUNT) {
  95. struct ieee80211_sta *sta;
  96. struct iwl_mvm_sta *mvm_sta;
  97. sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[ap_sta_id],
  98. lockdep_is_held(&mvm->mutex));
  99. mvm_sta = (void *)sta->drv_priv;
  100. pos += scnprintf(buf+pos, bufsz-pos,
  101. "ap_sta_id %d - reduced Tx power %d\n",
  102. ap_sta_id, mvm_sta->bt_reduced_txpower);
  103. }
  104. rcu_read_lock();
  105. chanctx_conf = rcu_dereference(vif->chanctx_conf);
  106. if (chanctx_conf)
  107. pos += scnprintf(buf+pos, bufsz-pos,
  108. "idle rx chains %d, active rx chains: %d\n",
  109. chanctx_conf->rx_chains_static,
  110. chanctx_conf->rx_chains_dynamic);
  111. rcu_read_unlock();
  112. mutex_unlock(&mvm->mutex);
  113. return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
  114. }
  115. #define MVM_DEBUGFS_ADD_FILE_VIF(name, parent, mode) do { \
  116. if (!debugfs_create_file(#name, mode, parent, vif, \
  117. &iwl_dbgfs_##name##_ops)) \
  118. goto err; \
  119. } while (0)
  120. MVM_DEBUGFS_READ_FILE_OPS(mac_params);
  121. void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  122. {
  123. struct dentry *dbgfs_dir = vif->debugfs_dir;
  124. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  125. char buf[100];
  126. /*
  127. * Check if debugfs directory already exist before creating it.
  128. * This may happen when, for example, resetting hw or suspend-resume
  129. */
  130. if (!dbgfs_dir || mvmvif->dbgfs_dir)
  131. return;
  132. mvmvif->dbgfs_dir = debugfs_create_dir("iwlmvm", dbgfs_dir);
  133. mvmvif->mvm = mvm;
  134. if (!mvmvif->dbgfs_dir) {
  135. IWL_ERR(mvm, "Failed to create debugfs directory under %s\n",
  136. dbgfs_dir->d_name.name);
  137. return;
  138. }
  139. MVM_DEBUGFS_ADD_FILE_VIF(mac_params, mvmvif->dbgfs_dir,
  140. S_IRUSR);
  141. /*
  142. * Create symlink for convenience pointing to interface specific
  143. * debugfs entries for the driver. For example, under
  144. * /sys/kernel/debug/iwlwifi/0000\:02\:00.0/iwlmvm/
  145. * find
  146. * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/
  147. */
  148. snprintf(buf, 100, "../../../%s/%s/%s/%s",
  149. dbgfs_dir->d_parent->d_parent->d_name.name,
  150. dbgfs_dir->d_parent->d_name.name,
  151. dbgfs_dir->d_name.name,
  152. mvmvif->dbgfs_dir->d_name.name);
  153. mvmvif->dbgfs_slink = debugfs_create_symlink(dbgfs_dir->d_name.name,
  154. mvm->debugfs_dir, buf);
  155. if (!mvmvif->dbgfs_slink)
  156. IWL_ERR(mvm, "Can't create debugfs symbolic link under %s\n",
  157. dbgfs_dir->d_name.name);
  158. return;
  159. err:
  160. IWL_ERR(mvm, "Can't create debugfs entity\n");
  161. }
  162. void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  163. {
  164. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  165. debugfs_remove(mvmvif->dbgfs_slink);
  166. mvmvif->dbgfs_slink = NULL;
  167. debugfs_remove_recursive(mvmvif->dbgfs_dir);
  168. mvmvif->dbgfs_dir = NULL;
  169. }