Johannes Berg | 820a1a5 | 2013-11-12 16:58:41 +0100 | [diff] [blame] | 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 | |
| 66 | static ssize_t iwl_dbgfs_mac_params_read(struct file *file, |
| 67 | char __user *user_buf, |
| 68 | size_t count, loff_t *ppos) |
| 69 | { |
| 70 | struct ieee80211_vif *vif = file->private_data; |
| 71 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
Johannes Berg | 7f09d70 | 2013-11-12 17:16:38 +0100 | [diff] [blame] | 72 | struct iwl_mvm *mvm = mvmvif->mvm; |
Johannes Berg | 820a1a5 | 2013-11-12 16:58:41 +0100 | [diff] [blame] | 73 | u8 ap_sta_id; |
| 74 | struct ieee80211_chanctx_conf *chanctx_conf; |
| 75 | char buf[512]; |
| 76 | int bufsz = sizeof(buf); |
| 77 | int pos = 0; |
| 78 | int i; |
| 79 | |
| 80 | mutex_lock(&mvm->mutex); |
| 81 | |
| 82 | ap_sta_id = mvmvif->ap_sta_id; |
| 83 | |
| 84 | pos += scnprintf(buf+pos, bufsz-pos, "mac id/color: %d / %d\n", |
| 85 | mvmvif->id, mvmvif->color); |
| 86 | pos += scnprintf(buf+pos, bufsz-pos, "bssid: %pM\n", |
| 87 | vif->bss_conf.bssid); |
| 88 | pos += scnprintf(buf+pos, bufsz-pos, "QoS:\n"); |
| 89 | for (i = 0; i < ARRAY_SIZE(mvmvif->queue_params); i++) |
| 90 | pos += scnprintf(buf+pos, bufsz-pos, |
| 91 | "\t%d: txop:%d - cw_min:%d - cw_max = %d - aifs = %d upasd = %d\n", |
| 92 | i, mvmvif->queue_params[i].txop, |
| 93 | mvmvif->queue_params[i].cw_min, |
| 94 | mvmvif->queue_params[i].cw_max, |
| 95 | mvmvif->queue_params[i].aifs, |
| 96 | mvmvif->queue_params[i].uapsd); |
| 97 | |
| 98 | if (vif->type == NL80211_IFTYPE_STATION && |
| 99 | ap_sta_id != IWL_MVM_STATION_COUNT) { |
| 100 | struct ieee80211_sta *sta; |
| 101 | struct iwl_mvm_sta *mvm_sta; |
| 102 | |
| 103 | sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[ap_sta_id], |
| 104 | lockdep_is_held(&mvm->mutex)); |
| 105 | mvm_sta = (void *)sta->drv_priv; |
| 106 | pos += scnprintf(buf+pos, bufsz-pos, |
| 107 | "ap_sta_id %d - reduced Tx power %d\n", |
| 108 | ap_sta_id, mvm_sta->bt_reduced_txpower); |
| 109 | } |
| 110 | |
| 111 | rcu_read_lock(); |
| 112 | chanctx_conf = rcu_dereference(vif->chanctx_conf); |
| 113 | if (chanctx_conf) |
| 114 | pos += scnprintf(buf+pos, bufsz-pos, |
| 115 | "idle rx chains %d, active rx chains: %d\n", |
| 116 | chanctx_conf->rx_chains_static, |
| 117 | chanctx_conf->rx_chains_dynamic); |
| 118 | rcu_read_unlock(); |
| 119 | |
| 120 | mutex_unlock(&mvm->mutex); |
| 121 | |
| 122 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 123 | } |
| 124 | |
| 125 | #define MVM_DEBUGFS_ADD_FILE_VIF(name, parent, mode) do { \ |
| 126 | if (!debugfs_create_file(#name, mode, parent, vif, \ |
| 127 | &iwl_dbgfs_##name##_ops)) \ |
| 128 | goto err; \ |
| 129 | } while (0) |
| 130 | |
| 131 | MVM_DEBUGFS_READ_FILE_OPS(mac_params); |
| 132 | |
| 133 | void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif) |
| 134 | { |
| 135 | struct dentry *dbgfs_dir = vif->debugfs_dir; |
| 136 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 137 | char buf[100]; |
| 138 | |
| 139 | /* |
| 140 | * Check if debugfs directory already exist before creating it. |
| 141 | * This may happen when, for example, resetting hw or suspend-resume |
| 142 | */ |
| 143 | if (!dbgfs_dir || mvmvif->dbgfs_dir) |
| 144 | return; |
| 145 | |
| 146 | mvmvif->dbgfs_dir = debugfs_create_dir("iwlmvm", dbgfs_dir); |
Johannes Berg | 7f09d70 | 2013-11-12 17:16:38 +0100 | [diff] [blame] | 147 | mvmvif->mvm = mvm; |
Johannes Berg | 820a1a5 | 2013-11-12 16:58:41 +0100 | [diff] [blame] | 148 | |
| 149 | if (!mvmvif->dbgfs_dir) { |
| 150 | IWL_ERR(mvm, "Failed to create debugfs directory under %s\n", |
| 151 | dbgfs_dir->d_name.name); |
| 152 | return; |
| 153 | } |
| 154 | |
| 155 | MVM_DEBUGFS_ADD_FILE_VIF(mac_params, mvmvif->dbgfs_dir, |
| 156 | S_IRUSR); |
| 157 | |
| 158 | /* |
| 159 | * Create symlink for convenience pointing to interface specific |
| 160 | * debugfs entries for the driver. For example, under |
| 161 | * /sys/kernel/debug/iwlwifi/0000\:02\:00.0/iwlmvm/ |
| 162 | * find |
| 163 | * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/ |
| 164 | */ |
| 165 | snprintf(buf, 100, "../../../%s/%s/%s/%s", |
| 166 | dbgfs_dir->d_parent->d_parent->d_name.name, |
| 167 | dbgfs_dir->d_parent->d_name.name, |
| 168 | dbgfs_dir->d_name.name, |
| 169 | mvmvif->dbgfs_dir->d_name.name); |
| 170 | |
| 171 | mvmvif->dbgfs_slink = debugfs_create_symlink(dbgfs_dir->d_name.name, |
| 172 | mvm->debugfs_dir, buf); |
| 173 | if (!mvmvif->dbgfs_slink) |
| 174 | IWL_ERR(mvm, "Can't create debugfs symbolic link under %s\n", |
| 175 | dbgfs_dir->d_name.name); |
| 176 | return; |
| 177 | err: |
| 178 | IWL_ERR(mvm, "Can't create debugfs entity\n"); |
| 179 | } |
| 180 | |
| 181 | void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif) |
| 182 | { |
| 183 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
| 184 | |
| 185 | debugfs_remove(mvmvif->dbgfs_slink); |
| 186 | mvmvif->dbgfs_slink = NULL; |
| 187 | |
| 188 | debugfs_remove_recursive(mvmvif->dbgfs_dir); |
| 189 | mvmvif->dbgfs_dir = NULL; |
| 190 | } |