Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +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 | * |
Emmanuel Grumbach | 51368bf | 2013-12-30 13:15:54 +0200 | [diff] [blame] | 8 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 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 |
Emmanuel Grumbach | 410dc5a | 2013-02-18 09:22:28 +0200 | [diff] [blame] | 25 | * in the file called COPYING. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 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 | * |
Emmanuel Grumbach | 51368bf | 2013-12-30 13:15:54 +0200 | [diff] [blame] | 33 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 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 "sta.h" |
| 65 | #include "iwl-io.h" |
Alexander Bondar | 119663c | 2013-10-17 14:26:50 +0200 | [diff] [blame] | 66 | #include "iwl-prph.h" |
Johannes Berg | 820a1a5 | 2013-11-12 16:58:41 +0100 | [diff] [blame] | 67 | #include "debugfs.h" |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 68 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 69 | static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 70 | size_t count, loff_t *ppos) |
| 71 | { |
Johannes Berg | 8a0bd16 | 2013-11-12 16:48:03 +0100 | [diff] [blame] | 72 | int ret; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 73 | u32 scd_q_msk; |
| 74 | |
| 75 | if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR) |
| 76 | return -EIO; |
| 77 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 78 | if (sscanf(buf, "%x", &scd_q_msk) != 1) |
| 79 | return -EINVAL; |
| 80 | |
| 81 | IWL_ERR(mvm, "FLUSHING queues: scd_q_msk = 0x%x\n", scd_q_msk); |
| 82 | |
| 83 | mutex_lock(&mvm->mutex); |
| 84 | ret = iwl_mvm_flush_tx_path(mvm, scd_q_msk, true) ? : count; |
| 85 | mutex_unlock(&mvm->mutex); |
| 86 | |
| 87 | return ret; |
| 88 | } |
| 89 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 90 | static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 91 | size_t count, loff_t *ppos) |
| 92 | { |
Emmanuel Grumbach | f327b04 | 2014-01-14 08:30:32 +0200 | [diff] [blame] | 93 | struct iwl_mvm_sta *mvmsta; |
Johannes Berg | 8a0bd16 | 2013-11-12 16:48:03 +0100 | [diff] [blame] | 94 | int sta_id, drain, ret; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 95 | |
| 96 | if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR) |
| 97 | return -EIO; |
| 98 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 99 | if (sscanf(buf, "%d %d", &sta_id, &drain) != 2) |
| 100 | return -EINVAL; |
Johannes Berg | 60765a4 | 2013-10-25 13:06:06 +0200 | [diff] [blame] | 101 | if (sta_id < 0 || sta_id >= IWL_MVM_STATION_COUNT) |
| 102 | return -EINVAL; |
| 103 | if (drain < 0 || drain > 1) |
| 104 | return -EINVAL; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 105 | |
| 106 | mutex_lock(&mvm->mutex); |
| 107 | |
Emmanuel Grumbach | f327b04 | 2014-01-14 08:30:32 +0200 | [diff] [blame] | 108 | mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id); |
| 109 | |
| 110 | if (!mvmsta) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 111 | ret = -ENOENT; |
| 112 | else |
Emmanuel Grumbach | f327b04 | 2014-01-14 08:30:32 +0200 | [diff] [blame] | 113 | ret = iwl_mvm_drain_sta(mvm, mvmsta, drain) ? : count; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 114 | |
| 115 | mutex_unlock(&mvm->mutex); |
| 116 | |
| 117 | return ret; |
| 118 | } |
| 119 | |
| 120 | static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf, |
| 121 | size_t count, loff_t *ppos) |
| 122 | { |
| 123 | struct iwl_mvm *mvm = file->private_data; |
| 124 | const struct fw_img *img; |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 125 | unsigned int ofs, len; |
| 126 | size_t ret; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 127 | u8 *ptr; |
| 128 | |
Johannes Berg | 60191d9 | 2013-05-15 13:08:51 +0200 | [diff] [blame] | 129 | if (!mvm->ucode_loaded) |
| 130 | return -EINVAL; |
| 131 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 132 | /* default is to dump the entire data segment */ |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 133 | img = &mvm->fw->img[mvm->cur_ucode]; |
| 134 | ofs = img->sec[IWL_UCODE_SECTION_DATA].offset; |
| 135 | len = img->sec[IWL_UCODE_SECTION_DATA].len; |
| 136 | |
Emmanuel Grumbach | 01e0efe | 2014-01-06 09:05:54 +0200 | [diff] [blame] | 137 | if (mvm->dbgfs_sram_len) { |
Johannes Berg | 60191d9 | 2013-05-15 13:08:51 +0200 | [diff] [blame] | 138 | ofs = mvm->dbgfs_sram_offset; |
| 139 | len = mvm->dbgfs_sram_len; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 140 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 141 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 142 | ptr = kzalloc(len, GFP_KERNEL); |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 143 | if (!ptr) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 144 | return -ENOMEM; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 145 | |
Johannes Berg | 60191d9 | 2013-05-15 13:08:51 +0200 | [diff] [blame] | 146 | iwl_trans_read_mem_bytes(mvm->trans, ofs, ptr, len); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 147 | |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 148 | ret = simple_read_from_buffer(user_buf, count, ppos, ptr, len); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 149 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 150 | kfree(ptr); |
| 151 | |
| 152 | return ret; |
| 153 | } |
| 154 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 155 | static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf, |
| 156 | size_t count, loff_t *ppos) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 157 | { |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 158 | const struct fw_img *img; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 159 | u32 offset, len; |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 160 | u32 img_offset, img_len; |
| 161 | |
| 162 | if (!mvm->ucode_loaded) |
| 163 | return -EINVAL; |
| 164 | |
| 165 | img = &mvm->fw->img[mvm->cur_ucode]; |
| 166 | img_offset = img->sec[IWL_UCODE_SECTION_DATA].offset; |
| 167 | img_len = img->sec[IWL_UCODE_SECTION_DATA].len; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 168 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 169 | if (sscanf(buf, "%x,%x", &offset, &len) == 2) { |
| 170 | if ((offset & 0x3) || (len & 0x3)) |
| 171 | return -EINVAL; |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 172 | |
| 173 | if (offset + len > img_offset + img_len) |
| 174 | return -EINVAL; |
| 175 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 176 | mvm->dbgfs_sram_offset = offset; |
| 177 | mvm->dbgfs_sram_len = len; |
| 178 | } else { |
| 179 | mvm->dbgfs_sram_offset = 0; |
| 180 | mvm->dbgfs_sram_len = 0; |
| 181 | } |
| 182 | |
| 183 | return count; |
| 184 | } |
| 185 | |
| 186 | static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, |
| 187 | size_t count, loff_t *ppos) |
| 188 | { |
| 189 | struct iwl_mvm *mvm = file->private_data; |
| 190 | struct ieee80211_sta *sta; |
| 191 | char buf[400]; |
| 192 | int i, pos = 0, bufsz = sizeof(buf); |
| 193 | |
| 194 | mutex_lock(&mvm->mutex); |
| 195 | |
| 196 | for (i = 0; i < IWL_MVM_STATION_COUNT; i++) { |
| 197 | pos += scnprintf(buf + pos, bufsz - pos, "%.2d: ", i); |
| 198 | sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i], |
| 199 | lockdep_is_held(&mvm->mutex)); |
| 200 | if (!sta) |
| 201 | pos += scnprintf(buf + pos, bufsz - pos, "N/A\n"); |
| 202 | else if (IS_ERR(sta)) |
| 203 | pos += scnprintf(buf + pos, bufsz - pos, "%ld\n", |
| 204 | PTR_ERR(sta)); |
| 205 | else |
| 206 | pos += scnprintf(buf + pos, bufsz - pos, "%pM\n", |
| 207 | sta->addr); |
| 208 | } |
| 209 | |
| 210 | mutex_unlock(&mvm->mutex); |
| 211 | |
| 212 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 213 | } |
| 214 | |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 215 | static ssize_t iwl_dbgfs_disable_power_off_read(struct file *file, |
| 216 | char __user *user_buf, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 217 | size_t count, loff_t *ppos) |
| 218 | { |
| 219 | struct iwl_mvm *mvm = file->private_data; |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 220 | char buf[64]; |
| 221 | int bufsz = sizeof(buf); |
| 222 | int pos = 0; |
| 223 | |
| 224 | pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d0=%d\n", |
| 225 | mvm->disable_power_off); |
| 226 | pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d3=%d\n", |
| 227 | mvm->disable_power_off_d3); |
| 228 | |
| 229 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 230 | } |
| 231 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 232 | static ssize_t iwl_dbgfs_disable_power_off_write(struct iwl_mvm *mvm, char *buf, |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 233 | size_t count, loff_t *ppos) |
| 234 | { |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 235 | int ret, val; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 236 | |
| 237 | if (!mvm->ucode_loaded) |
| 238 | return -EIO; |
| 239 | |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 240 | if (!strncmp("disable_power_off_d0=", buf, 21)) { |
| 241 | if (sscanf(buf + 21, "%d", &val) != 1) |
| 242 | return -EINVAL; |
| 243 | mvm->disable_power_off = val; |
| 244 | } else if (!strncmp("disable_power_off_d3=", buf, 21)) { |
| 245 | if (sscanf(buf + 21, "%d", &val) != 1) |
| 246 | return -EINVAL; |
| 247 | mvm->disable_power_off_d3 = val; |
| 248 | } else { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 249 | return -EINVAL; |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 250 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 251 | |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 252 | mutex_lock(&mvm->mutex); |
Emmanuel Grumbach | c1cb92f | 2014-01-28 10:17:18 +0200 | [diff] [blame] | 253 | ret = iwl_mvm_power_update_device(mvm); |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 254 | mutex_unlock(&mvm->mutex); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 255 | |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 256 | return ret ?: count; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 257 | } |
| 258 | |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 259 | #define BT_MBOX_MSG(_notif, _num, _field) \ |
| 260 | ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\ |
| 261 | >> BT_MBOX##_num##_##_field##_POS) |
| 262 | |
| 263 | |
| 264 | #define BT_MBOX_PRINT(_num, _field, _end) \ |
| 265 | pos += scnprintf(buf + pos, bufsz - pos, \ |
| 266 | "\t%s: %d%s", \ |
| 267 | #_field, \ |
| 268 | BT_MBOX_MSG(notif, _num, _field), \ |
| 269 | true ? "\n" : ", "); |
| 270 | |
| 271 | static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf, |
| 272 | size_t count, loff_t *ppos) |
| 273 | { |
| 274 | struct iwl_mvm *mvm = file->private_data; |
| 275 | struct iwl_bt_coex_profile_notif *notif = &mvm->last_bt_notif; |
| 276 | char *buf; |
| 277 | int ret, pos = 0, bufsz = sizeof(char) * 1024; |
| 278 | |
| 279 | buf = kmalloc(bufsz, GFP_KERNEL); |
| 280 | if (!buf) |
| 281 | return -ENOMEM; |
| 282 | |
| 283 | mutex_lock(&mvm->mutex); |
| 284 | |
| 285 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n"); |
| 286 | |
| 287 | BT_MBOX_PRINT(0, LE_SLAVE_LAT, false); |
| 288 | BT_MBOX_PRINT(0, LE_PROF1, false); |
| 289 | BT_MBOX_PRINT(0, LE_PROF2, false); |
| 290 | BT_MBOX_PRINT(0, LE_PROF_OTHER, false); |
| 291 | BT_MBOX_PRINT(0, CHL_SEQ_N, false); |
| 292 | BT_MBOX_PRINT(0, INBAND_S, false); |
| 293 | BT_MBOX_PRINT(0, LE_MIN_RSSI, false); |
| 294 | BT_MBOX_PRINT(0, LE_SCAN, false); |
| 295 | BT_MBOX_PRINT(0, LE_ADV, false); |
| 296 | BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false); |
| 297 | BT_MBOX_PRINT(0, OPEN_CON_1, true); |
| 298 | |
| 299 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n"); |
| 300 | |
| 301 | BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false); |
| 302 | BT_MBOX_PRINT(1, IP_SR, false); |
| 303 | BT_MBOX_PRINT(1, LE_MSTR, false); |
| 304 | BT_MBOX_PRINT(1, AGGR_TRFC_LD, false); |
| 305 | BT_MBOX_PRINT(1, MSG_TYPE, false); |
| 306 | BT_MBOX_PRINT(1, SSN, true); |
| 307 | |
| 308 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n"); |
| 309 | |
| 310 | BT_MBOX_PRINT(2, SNIFF_ACT, false); |
| 311 | BT_MBOX_PRINT(2, PAG, false); |
| 312 | BT_MBOX_PRINT(2, INQUIRY, false); |
| 313 | BT_MBOX_PRINT(2, CONN, false); |
| 314 | BT_MBOX_PRINT(2, SNIFF_INTERVAL, false); |
| 315 | BT_MBOX_PRINT(2, DISC, false); |
| 316 | BT_MBOX_PRINT(2, SCO_TX_ACT, false); |
| 317 | BT_MBOX_PRINT(2, SCO_RX_ACT, false); |
| 318 | BT_MBOX_PRINT(2, ESCO_RE_TX, false); |
| 319 | BT_MBOX_PRINT(2, SCO_DURATION, true); |
| 320 | |
| 321 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n"); |
| 322 | |
| 323 | BT_MBOX_PRINT(3, SCO_STATE, false); |
| 324 | BT_MBOX_PRINT(3, SNIFF_STATE, false); |
| 325 | BT_MBOX_PRINT(3, A2DP_STATE, false); |
| 326 | BT_MBOX_PRINT(3, ACL_STATE, false); |
| 327 | BT_MBOX_PRINT(3, MSTR_STATE, false); |
| 328 | BT_MBOX_PRINT(3, OBX_STATE, false); |
| 329 | BT_MBOX_PRINT(3, OPEN_CON_2, false); |
| 330 | BT_MBOX_PRINT(3, TRAFFIC_LOAD, false); |
| 331 | BT_MBOX_PRINT(3, CHL_SEQN_LSB, false); |
| 332 | BT_MBOX_PRINT(3, INBAND_P, false); |
| 333 | BT_MBOX_PRINT(3, MSG_TYPE_2, false); |
| 334 | BT_MBOX_PRINT(3, SSN_2, false); |
| 335 | BT_MBOX_PRINT(3, UPDATE_REQUEST, true); |
| 336 | |
| 337 | pos += scnprintf(buf+pos, bufsz-pos, "bt_status = %d\n", |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 338 | notif->bt_status); |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 339 | pos += scnprintf(buf+pos, bufsz-pos, "bt_open_conn = %d\n", |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 340 | notif->bt_open_conn); |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 341 | pos += scnprintf(buf+pos, bufsz-pos, "bt_traffic_load = %d\n", |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 342 | notif->bt_traffic_load); |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 343 | pos += scnprintf(buf+pos, bufsz-pos, "bt_agg_traffic_load = %d\n", |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 344 | notif->bt_agg_traffic_load); |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 345 | pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n", |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 346 | notif->bt_ci_compliance); |
| 347 | pos += scnprintf(buf+pos, bufsz-pos, "primary_ch_lut = %d\n", |
| 348 | le32_to_cpu(notif->primary_ch_lut)); |
| 349 | pos += scnprintf(buf+pos, bufsz-pos, "secondary_ch_lut = %d\n", |
| 350 | le32_to_cpu(notif->secondary_ch_lut)); |
| 351 | pos += scnprintf(buf+pos, bufsz-pos, "bt_activity_grading = %d\n", |
| 352 | le32_to_cpu(notif->bt_activity_grading)); |
Emmanuel Grumbach | b9fae2d | 2014-02-17 11:24:10 +0200 | [diff] [blame^] | 353 | pos += scnprintf(buf+pos, bufsz-pos, |
| 354 | "antenna isolation = %d CORUN LUT index = %d\n", |
| 355 | mvm->last_ant_isol, mvm->last_corun_lut); |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 356 | |
| 357 | mutex_unlock(&mvm->mutex); |
| 358 | |
| 359 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 360 | kfree(buf); |
| 361 | |
| 362 | return ret; |
| 363 | } |
| 364 | #undef BT_MBOX_PRINT |
| 365 | |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 366 | static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf, |
| 367 | size_t count, loff_t *ppos) |
| 368 | { |
| 369 | struct iwl_mvm *mvm = file->private_data; |
| 370 | struct iwl_bt_coex_ci_cmd *cmd = &mvm->last_bt_ci_cmd; |
| 371 | char buf[256]; |
| 372 | int bufsz = sizeof(buf); |
| 373 | int pos = 0; |
| 374 | |
| 375 | mutex_lock(&mvm->mutex); |
| 376 | |
| 377 | pos += scnprintf(buf+pos, bufsz-pos, "Channel inhibition CMD\n"); |
| 378 | pos += scnprintf(buf+pos, bufsz-pos, |
| 379 | "\tPrimary Channel Bitmap 0x%016llx Fat: %d\n", |
| 380 | le64_to_cpu(cmd->bt_primary_ci), |
| 381 | !!cmd->co_run_bw_primary); |
| 382 | pos += scnprintf(buf+pos, bufsz-pos, |
| 383 | "\tSecondary Channel Bitmap 0x%016llx Fat: %d\n", |
| 384 | le64_to_cpu(cmd->bt_secondary_ci), |
| 385 | !!cmd->co_run_bw_secondary); |
| 386 | |
| 387 | pos += scnprintf(buf+pos, bufsz-pos, "BT Configuration CMD\n"); |
| 388 | pos += scnprintf(buf+pos, bufsz-pos, "\tACK Kill Mask 0x%08x\n", |
| 389 | iwl_bt_ack_kill_msk[mvm->bt_kill_msk]); |
| 390 | pos += scnprintf(buf+pos, bufsz-pos, "\tCTS Kill Mask 0x%08x\n", |
| 391 | iwl_bt_cts_kill_msk[mvm->bt_kill_msk]); |
| 392 | |
| 393 | mutex_unlock(&mvm->mutex); |
| 394 | |
| 395 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 396 | } |
| 397 | |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 398 | #define PRINT_STATS_LE32(_str, _val) \ |
| 399 | pos += scnprintf(buf + pos, bufsz - pos, \ |
| 400 | fmt_table, _str, \ |
| 401 | le32_to_cpu(_val)) |
| 402 | |
| 403 | static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file, |
| 404 | char __user *user_buf, size_t count, |
| 405 | loff_t *ppos) |
| 406 | { |
| 407 | struct iwl_mvm *mvm = file->private_data; |
| 408 | static const char *fmt_table = "\t%-30s %10u\n"; |
| 409 | static const char *fmt_header = "%-32s\n"; |
| 410 | int pos = 0; |
| 411 | char *buf; |
| 412 | int ret; |
Luciano Coelho | 3f61728 | 2013-10-14 13:18:41 +0300 | [diff] [blame] | 413 | /* 43 is the size of each data line, 33 is the size of each header */ |
| 414 | size_t bufsz = |
| 415 | ((sizeof(struct mvm_statistics_rx) / sizeof(__le32)) * 43) + |
| 416 | (4 * 33) + 1; |
| 417 | |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 418 | struct mvm_statistics_rx_phy *ofdm; |
| 419 | struct mvm_statistics_rx_phy *cck; |
| 420 | struct mvm_statistics_rx_non_phy *general; |
| 421 | struct mvm_statistics_rx_ht_phy *ht; |
| 422 | |
| 423 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 424 | if (!buf) |
| 425 | return -ENOMEM; |
| 426 | |
| 427 | mutex_lock(&mvm->mutex); |
| 428 | |
| 429 | ofdm = &mvm->rx_stats.ofdm; |
| 430 | cck = &mvm->rx_stats.cck; |
| 431 | general = &mvm->rx_stats.general; |
| 432 | ht = &mvm->rx_stats.ofdm_ht; |
| 433 | |
| 434 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, |
| 435 | "Statistics_Rx - OFDM"); |
| 436 | PRINT_STATS_LE32("ina_cnt", ofdm->ina_cnt); |
| 437 | PRINT_STATS_LE32("fina_cnt", ofdm->fina_cnt); |
| 438 | PRINT_STATS_LE32("plcp_err", ofdm->plcp_err); |
| 439 | PRINT_STATS_LE32("crc32_err", ofdm->crc32_err); |
| 440 | PRINT_STATS_LE32("overrun_err", ofdm->overrun_err); |
| 441 | PRINT_STATS_LE32("early_overrun_err", ofdm->early_overrun_err); |
| 442 | PRINT_STATS_LE32("crc32_good", ofdm->crc32_good); |
| 443 | PRINT_STATS_LE32("false_alarm_cnt", ofdm->false_alarm_cnt); |
| 444 | PRINT_STATS_LE32("fina_sync_err_cnt", ofdm->fina_sync_err_cnt); |
| 445 | PRINT_STATS_LE32("sfd_timeout", ofdm->sfd_timeout); |
| 446 | PRINT_STATS_LE32("fina_timeout", ofdm->fina_timeout); |
| 447 | PRINT_STATS_LE32("unresponded_rts", ofdm->unresponded_rts); |
| 448 | PRINT_STATS_LE32("rxe_frame_lmt_overrun", |
| 449 | ofdm->rxe_frame_limit_overrun); |
| 450 | PRINT_STATS_LE32("sent_ack_cnt", ofdm->sent_ack_cnt); |
| 451 | PRINT_STATS_LE32("sent_cts_cnt", ofdm->sent_cts_cnt); |
| 452 | PRINT_STATS_LE32("sent_ba_rsp_cnt", ofdm->sent_ba_rsp_cnt); |
| 453 | PRINT_STATS_LE32("dsp_self_kill", ofdm->dsp_self_kill); |
| 454 | PRINT_STATS_LE32("mh_format_err", ofdm->mh_format_err); |
| 455 | PRINT_STATS_LE32("re_acq_main_rssi_sum", ofdm->re_acq_main_rssi_sum); |
| 456 | PRINT_STATS_LE32("reserved", ofdm->reserved); |
| 457 | |
| 458 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, |
| 459 | "Statistics_Rx - CCK"); |
| 460 | PRINT_STATS_LE32("ina_cnt", cck->ina_cnt); |
| 461 | PRINT_STATS_LE32("fina_cnt", cck->fina_cnt); |
| 462 | PRINT_STATS_LE32("plcp_err", cck->plcp_err); |
| 463 | PRINT_STATS_LE32("crc32_err", cck->crc32_err); |
| 464 | PRINT_STATS_LE32("overrun_err", cck->overrun_err); |
| 465 | PRINT_STATS_LE32("early_overrun_err", cck->early_overrun_err); |
| 466 | PRINT_STATS_LE32("crc32_good", cck->crc32_good); |
| 467 | PRINT_STATS_LE32("false_alarm_cnt", cck->false_alarm_cnt); |
| 468 | PRINT_STATS_LE32("fina_sync_err_cnt", cck->fina_sync_err_cnt); |
| 469 | PRINT_STATS_LE32("sfd_timeout", cck->sfd_timeout); |
| 470 | PRINT_STATS_LE32("fina_timeout", cck->fina_timeout); |
| 471 | PRINT_STATS_LE32("unresponded_rts", cck->unresponded_rts); |
| 472 | PRINT_STATS_LE32("rxe_frame_lmt_overrun", |
| 473 | cck->rxe_frame_limit_overrun); |
| 474 | PRINT_STATS_LE32("sent_ack_cnt", cck->sent_ack_cnt); |
| 475 | PRINT_STATS_LE32("sent_cts_cnt", cck->sent_cts_cnt); |
| 476 | PRINT_STATS_LE32("sent_ba_rsp_cnt", cck->sent_ba_rsp_cnt); |
| 477 | PRINT_STATS_LE32("dsp_self_kill", cck->dsp_self_kill); |
| 478 | PRINT_STATS_LE32("mh_format_err", cck->mh_format_err); |
| 479 | PRINT_STATS_LE32("re_acq_main_rssi_sum", cck->re_acq_main_rssi_sum); |
| 480 | PRINT_STATS_LE32("reserved", cck->reserved); |
| 481 | |
| 482 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, |
| 483 | "Statistics_Rx - GENERAL"); |
| 484 | PRINT_STATS_LE32("bogus_cts", general->bogus_cts); |
| 485 | PRINT_STATS_LE32("bogus_ack", general->bogus_ack); |
| 486 | PRINT_STATS_LE32("non_bssid_frames", general->non_bssid_frames); |
| 487 | PRINT_STATS_LE32("filtered_frames", general->filtered_frames); |
| 488 | PRINT_STATS_LE32("non_channel_beacons", general->non_channel_beacons); |
| 489 | PRINT_STATS_LE32("channel_beacons", general->channel_beacons); |
| 490 | PRINT_STATS_LE32("num_missed_bcon", general->num_missed_bcon); |
| 491 | PRINT_STATS_LE32("adc_rx_saturation_time", |
| 492 | general->adc_rx_saturation_time); |
| 493 | PRINT_STATS_LE32("ina_detection_search_time", |
| 494 | general->ina_detection_search_time); |
| 495 | PRINT_STATS_LE32("beacon_silence_rssi_a", |
| 496 | general->beacon_silence_rssi_a); |
| 497 | PRINT_STATS_LE32("beacon_silence_rssi_b", |
| 498 | general->beacon_silence_rssi_b); |
| 499 | PRINT_STATS_LE32("beacon_silence_rssi_c", |
| 500 | general->beacon_silence_rssi_c); |
| 501 | PRINT_STATS_LE32("interference_data_flag", |
| 502 | general->interference_data_flag); |
| 503 | PRINT_STATS_LE32("channel_load", general->channel_load); |
| 504 | PRINT_STATS_LE32("dsp_false_alarms", general->dsp_false_alarms); |
| 505 | PRINT_STATS_LE32("beacon_rssi_a", general->beacon_rssi_a); |
| 506 | PRINT_STATS_LE32("beacon_rssi_b", general->beacon_rssi_b); |
| 507 | PRINT_STATS_LE32("beacon_rssi_c", general->beacon_rssi_c); |
| 508 | PRINT_STATS_LE32("beacon_energy_a", general->beacon_energy_a); |
| 509 | PRINT_STATS_LE32("beacon_energy_b", general->beacon_energy_b); |
| 510 | PRINT_STATS_LE32("beacon_energy_c", general->beacon_energy_c); |
| 511 | PRINT_STATS_LE32("num_bt_kills", general->num_bt_kills); |
Luciano Coelho | 3f61728 | 2013-10-14 13:18:41 +0300 | [diff] [blame] | 512 | PRINT_STATS_LE32("mac_id", general->mac_id); |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 513 | PRINT_STATS_LE32("directed_data_mpdu", general->directed_data_mpdu); |
| 514 | |
| 515 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, |
| 516 | "Statistics_Rx - HT"); |
| 517 | PRINT_STATS_LE32("plcp_err", ht->plcp_err); |
| 518 | PRINT_STATS_LE32("overrun_err", ht->overrun_err); |
| 519 | PRINT_STATS_LE32("early_overrun_err", ht->early_overrun_err); |
| 520 | PRINT_STATS_LE32("crc32_good", ht->crc32_good); |
| 521 | PRINT_STATS_LE32("crc32_err", ht->crc32_err); |
| 522 | PRINT_STATS_LE32("mh_format_err", ht->mh_format_err); |
| 523 | PRINT_STATS_LE32("agg_crc32_good", ht->agg_crc32_good); |
| 524 | PRINT_STATS_LE32("agg_mpdu_cnt", ht->agg_mpdu_cnt); |
| 525 | PRINT_STATS_LE32("agg_cnt", ht->agg_cnt); |
| 526 | PRINT_STATS_LE32("unsupport_mcs", ht->unsupport_mcs); |
| 527 | |
| 528 | mutex_unlock(&mvm->mutex); |
| 529 | |
| 530 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 531 | kfree(buf); |
| 532 | |
| 533 | return ret; |
| 534 | } |
| 535 | #undef PRINT_STAT_LE32 |
| 536 | |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 537 | static ssize_t iwl_dbgfs_frame_stats_read(struct iwl_mvm *mvm, |
| 538 | char __user *user_buf, size_t count, |
| 539 | loff_t *ppos, |
| 540 | struct iwl_mvm_frame_stats *stats) |
| 541 | { |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 542 | char *buff, *pos, *endpos; |
| 543 | int idx, i; |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 544 | int ret; |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 545 | static const size_t bufsz = 1024; |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 546 | |
| 547 | buff = kmalloc(bufsz, GFP_KERNEL); |
| 548 | if (!buff) |
| 549 | return -ENOMEM; |
| 550 | |
| 551 | spin_lock_bh(&mvm->drv_stats_lock); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 552 | |
| 553 | pos = buff; |
| 554 | endpos = pos + bufsz; |
| 555 | |
| 556 | pos += scnprintf(pos, endpos - pos, |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 557 | "Legacy/HT/VHT\t:\t%d/%d/%d\n", |
| 558 | stats->legacy_frames, |
| 559 | stats->ht_frames, |
| 560 | stats->vht_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 561 | pos += scnprintf(pos, endpos - pos, "20/40/80\t:\t%d/%d/%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 562 | stats->bw_20_frames, |
| 563 | stats->bw_40_frames, |
| 564 | stats->bw_80_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 565 | pos += scnprintf(pos, endpos - pos, "NGI/SGI\t\t:\t%d/%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 566 | stats->ngi_frames, |
| 567 | stats->sgi_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 568 | pos += scnprintf(pos, endpos - pos, "SISO/MIMO2\t:\t%d/%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 569 | stats->siso_frames, |
| 570 | stats->mimo2_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 571 | pos += scnprintf(pos, endpos - pos, "FAIL/SCSS\t:\t%d/%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 572 | stats->fail_frames, |
| 573 | stats->success_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 574 | pos += scnprintf(pos, endpos - pos, "MPDUs agg\t:\t%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 575 | stats->agg_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 576 | pos += scnprintf(pos, endpos - pos, "A-MPDUs\t\t:\t%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 577 | stats->ampdu_count); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 578 | pos += scnprintf(pos, endpos - pos, "Avg MPDUs/A-MPDU:\t%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 579 | stats->ampdu_count > 0 ? |
| 580 | (stats->agg_frames / stats->ampdu_count) : 0); |
| 581 | |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 582 | pos += scnprintf(pos, endpos - pos, "Last Rates\n"); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 583 | |
| 584 | idx = stats->last_frame_idx - 1; |
| 585 | for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) { |
| 586 | idx = (idx + 1) % ARRAY_SIZE(stats->last_rates); |
| 587 | if (stats->last_rates[idx] == 0) |
| 588 | continue; |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 589 | pos += scnprintf(pos, endpos - pos, "Rate[%d]: ", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 590 | (int)(ARRAY_SIZE(stats->last_rates) - i)); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 591 | pos += rs_pretty_print_rate(pos, stats->last_rates[idx]); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 592 | } |
| 593 | spin_unlock_bh(&mvm->drv_stats_lock); |
| 594 | |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 595 | ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 596 | kfree(buff); |
| 597 | |
| 598 | return ret; |
| 599 | } |
| 600 | |
| 601 | static ssize_t iwl_dbgfs_drv_rx_stats_read(struct file *file, |
| 602 | char __user *user_buf, size_t count, |
| 603 | loff_t *ppos) |
| 604 | { |
| 605 | struct iwl_mvm *mvm = file->private_data; |
| 606 | |
| 607 | return iwl_dbgfs_frame_stats_read(mvm, user_buf, count, ppos, |
| 608 | &mvm->drv_rx_stats); |
| 609 | } |
| 610 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 611 | static ssize_t iwl_dbgfs_fw_restart_write(struct iwl_mvm *mvm, char *buf, |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 612 | size_t count, loff_t *ppos) |
| 613 | { |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 614 | int ret; |
| 615 | |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 616 | mutex_lock(&mvm->mutex); |
| 617 | |
Eran Harary | 291aa7c | 2013-07-03 11:00:06 +0300 | [diff] [blame] | 618 | /* allow one more restart that we're provoking here */ |
| 619 | if (mvm->restart_fw >= 0) |
| 620 | mvm->restart_fw++; |
| 621 | |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 622 | /* take the return value to make compiler happy - it will fail anyway */ |
| 623 | ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_ERROR, CMD_SYNC, 0, NULL); |
| 624 | |
| 625 | mutex_unlock(&mvm->mutex); |
| 626 | |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 627 | return count; |
| 628 | } |
| 629 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 630 | static ssize_t iwl_dbgfs_fw_nmi_write(struct iwl_mvm *mvm, char *buf, |
Alexander Bondar | 119663c | 2013-10-17 14:26:50 +0200 | [diff] [blame] | 631 | size_t count, loff_t *ppos) |
| 632 | { |
Alexander Bondar | 119663c | 2013-10-17 14:26:50 +0200 | [diff] [blame] | 633 | iwl_write_prph(mvm->trans, DEVICE_SET_NMI_REG, 1); |
| 634 | |
| 635 | return count; |
| 636 | } |
| 637 | |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 638 | static ssize_t |
| 639 | iwl_dbgfs_scan_ant_rxchain_read(struct file *file, |
| 640 | char __user *user_buf, |
| 641 | size_t count, loff_t *ppos) |
| 642 | { |
| 643 | struct iwl_mvm *mvm = file->private_data; |
| 644 | int pos = 0; |
| 645 | char buf[32]; |
| 646 | const size_t bufsz = sizeof(buf); |
| 647 | |
| 648 | /* print which antennas were set for the scan command by the user */ |
| 649 | pos += scnprintf(buf + pos, bufsz - pos, "Antennas for scan: "); |
| 650 | if (mvm->scan_rx_ant & ANT_A) |
| 651 | pos += scnprintf(buf + pos, bufsz - pos, "A"); |
| 652 | if (mvm->scan_rx_ant & ANT_B) |
| 653 | pos += scnprintf(buf + pos, bufsz - pos, "B"); |
| 654 | if (mvm->scan_rx_ant & ANT_C) |
| 655 | pos += scnprintf(buf + pos, bufsz - pos, "C"); |
| 656 | pos += scnprintf(buf + pos, bufsz - pos, " (%hhx)\n", mvm->scan_rx_ant); |
| 657 | |
| 658 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 659 | } |
| 660 | |
| 661 | static ssize_t |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 662 | iwl_dbgfs_scan_ant_rxchain_write(struct iwl_mvm *mvm, char *buf, |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 663 | size_t count, loff_t *ppos) |
| 664 | { |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 665 | u8 scan_rx_ant; |
| 666 | |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 667 | if (sscanf(buf, "%hhx", &scan_rx_ant) != 1) |
| 668 | return -EINVAL; |
| 669 | if (scan_rx_ant > ANT_ABC) |
| 670 | return -EINVAL; |
Johannes Berg | 4ed735e | 2014-02-12 21:47:44 +0100 | [diff] [blame] | 671 | if (scan_rx_ant & ~mvm->fw->valid_rx_ant) |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 672 | return -EINVAL; |
| 673 | |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 674 | mvm->scan_rx_ant = scan_rx_ant; |
| 675 | |
| 676 | return count; |
| 677 | } |
| 678 | |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 679 | #define ADD_TEXT(...) pos += scnprintf(buf + pos, bufsz - pos, __VA_ARGS__) |
| 680 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
| 681 | static ssize_t iwl_dbgfs_bcast_filters_read(struct file *file, |
| 682 | char __user *user_buf, |
| 683 | size_t count, loff_t *ppos) |
| 684 | { |
| 685 | struct iwl_mvm *mvm = file->private_data; |
| 686 | struct iwl_bcast_filter_cmd cmd; |
| 687 | const struct iwl_fw_bcast_filter *filter; |
| 688 | char *buf; |
| 689 | int bufsz = 1024; |
| 690 | int i, j, pos = 0; |
| 691 | ssize_t ret; |
| 692 | |
| 693 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 694 | if (!buf) |
| 695 | return -ENOMEM; |
| 696 | |
| 697 | mutex_lock(&mvm->mutex); |
| 698 | if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) { |
| 699 | ADD_TEXT("None\n"); |
| 700 | mutex_unlock(&mvm->mutex); |
| 701 | goto out; |
| 702 | } |
| 703 | mutex_unlock(&mvm->mutex); |
| 704 | |
| 705 | for (i = 0; cmd.filters[i].attrs[0].mask; i++) { |
| 706 | filter = &cmd.filters[i]; |
| 707 | |
| 708 | ADD_TEXT("Filter [%d]:\n", i); |
| 709 | ADD_TEXT("\tDiscard=%d\n", filter->discard); |
| 710 | ADD_TEXT("\tFrame Type: %s\n", |
| 711 | filter->frame_type ? "IPv4" : "Generic"); |
| 712 | |
| 713 | for (j = 0; j < ARRAY_SIZE(filter->attrs); j++) { |
| 714 | const struct iwl_fw_bcast_filter_attr *attr; |
| 715 | |
| 716 | attr = &filter->attrs[j]; |
| 717 | if (!attr->mask) |
| 718 | break; |
| 719 | |
| 720 | ADD_TEXT("\tAttr [%d]: offset=%d (from %s), mask=0x%x, value=0x%x reserved=0x%x\n", |
| 721 | j, attr->offset, |
| 722 | attr->offset_type ? "IP End" : |
| 723 | "Payload Start", |
| 724 | be32_to_cpu(attr->mask), |
| 725 | be32_to_cpu(attr->val), |
| 726 | le16_to_cpu(attr->reserved1)); |
| 727 | } |
| 728 | } |
| 729 | out: |
| 730 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 731 | kfree(buf); |
| 732 | return ret; |
| 733 | } |
| 734 | |
| 735 | static ssize_t iwl_dbgfs_bcast_filters_write(struct iwl_mvm *mvm, char *buf, |
| 736 | size_t count, loff_t *ppos) |
| 737 | { |
| 738 | int pos, next_pos; |
| 739 | struct iwl_fw_bcast_filter filter = {}; |
| 740 | struct iwl_bcast_filter_cmd cmd; |
| 741 | u32 filter_id, attr_id, mask, value; |
| 742 | int err = 0; |
| 743 | |
| 744 | if (sscanf(buf, "%d %hhi %hhi %n", &filter_id, &filter.discard, |
| 745 | &filter.frame_type, &pos) != 3) |
| 746 | return -EINVAL; |
| 747 | |
| 748 | if (filter_id >= ARRAY_SIZE(mvm->dbgfs_bcast_filtering.cmd.filters) || |
| 749 | filter.frame_type > BCAST_FILTER_FRAME_TYPE_IPV4) |
| 750 | return -EINVAL; |
| 751 | |
| 752 | for (attr_id = 0; attr_id < ARRAY_SIZE(filter.attrs); |
| 753 | attr_id++) { |
| 754 | struct iwl_fw_bcast_filter_attr *attr = |
| 755 | &filter.attrs[attr_id]; |
| 756 | |
| 757 | if (pos >= count) |
| 758 | break; |
| 759 | |
| 760 | if (sscanf(&buf[pos], "%hhi %hhi %i %i %n", |
| 761 | &attr->offset, &attr->offset_type, |
| 762 | &mask, &value, &next_pos) != 4) |
| 763 | return -EINVAL; |
| 764 | |
| 765 | attr->mask = cpu_to_be32(mask); |
| 766 | attr->val = cpu_to_be32(value); |
| 767 | if (mask) |
| 768 | filter.num_attrs++; |
| 769 | |
| 770 | pos += next_pos; |
| 771 | } |
| 772 | |
| 773 | mutex_lock(&mvm->mutex); |
| 774 | memcpy(&mvm->dbgfs_bcast_filtering.cmd.filters[filter_id], |
| 775 | &filter, sizeof(filter)); |
| 776 | |
| 777 | /* send updated bcast filtering configuration */ |
| 778 | if (mvm->dbgfs_bcast_filtering.override && |
| 779 | iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) |
| 780 | err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, CMD_SYNC, |
| 781 | sizeof(cmd), &cmd); |
| 782 | mutex_unlock(&mvm->mutex); |
| 783 | |
| 784 | return err ?: count; |
| 785 | } |
| 786 | |
| 787 | static ssize_t iwl_dbgfs_bcast_filters_macs_read(struct file *file, |
| 788 | char __user *user_buf, |
| 789 | size_t count, loff_t *ppos) |
| 790 | { |
| 791 | struct iwl_mvm *mvm = file->private_data; |
| 792 | struct iwl_bcast_filter_cmd cmd; |
| 793 | char *buf; |
| 794 | int bufsz = 1024; |
| 795 | int i, pos = 0; |
| 796 | ssize_t ret; |
| 797 | |
| 798 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 799 | if (!buf) |
| 800 | return -ENOMEM; |
| 801 | |
| 802 | mutex_lock(&mvm->mutex); |
| 803 | if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) { |
| 804 | ADD_TEXT("None\n"); |
| 805 | mutex_unlock(&mvm->mutex); |
| 806 | goto out; |
| 807 | } |
| 808 | mutex_unlock(&mvm->mutex); |
| 809 | |
| 810 | for (i = 0; i < ARRAY_SIZE(cmd.macs); i++) { |
| 811 | const struct iwl_fw_bcast_mac *mac = &cmd.macs[i]; |
| 812 | |
| 813 | ADD_TEXT("Mac [%d]: discard=%d attached_filters=0x%x\n", |
| 814 | i, mac->default_discard, mac->attached_filters); |
| 815 | } |
| 816 | out: |
| 817 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 818 | kfree(buf); |
| 819 | return ret; |
| 820 | } |
| 821 | |
| 822 | static ssize_t iwl_dbgfs_bcast_filters_macs_write(struct iwl_mvm *mvm, |
| 823 | char *buf, size_t count, |
| 824 | loff_t *ppos) |
| 825 | { |
| 826 | struct iwl_bcast_filter_cmd cmd; |
| 827 | struct iwl_fw_bcast_mac mac = {}; |
| 828 | u32 mac_id, attached_filters; |
| 829 | int err = 0; |
| 830 | |
| 831 | if (!mvm->bcast_filters) |
| 832 | return -ENOENT; |
| 833 | |
| 834 | if (sscanf(buf, "%d %hhi %i", &mac_id, &mac.default_discard, |
| 835 | &attached_filters) != 3) |
| 836 | return -EINVAL; |
| 837 | |
| 838 | if (mac_id >= ARRAY_SIZE(cmd.macs) || |
| 839 | mac.default_discard > 1 || |
| 840 | attached_filters >= BIT(ARRAY_SIZE(cmd.filters))) |
| 841 | return -EINVAL; |
| 842 | |
| 843 | mac.attached_filters = cpu_to_le16(attached_filters); |
| 844 | |
| 845 | mutex_lock(&mvm->mutex); |
| 846 | memcpy(&mvm->dbgfs_bcast_filtering.cmd.macs[mac_id], |
| 847 | &mac, sizeof(mac)); |
| 848 | |
| 849 | /* send updated bcast filtering configuration */ |
| 850 | if (mvm->dbgfs_bcast_filtering.override && |
| 851 | iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) |
| 852 | err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, CMD_SYNC, |
| 853 | sizeof(cmd), &cmd); |
| 854 | mutex_unlock(&mvm->mutex); |
| 855 | |
| 856 | return err ?: count; |
| 857 | } |
| 858 | #endif |
| 859 | |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 860 | #ifdef CONFIG_PM_SLEEP |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 861 | static ssize_t iwl_dbgfs_d3_sram_write(struct iwl_mvm *mvm, char *buf, |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 862 | size_t count, loff_t *ppos) |
| 863 | { |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 864 | int store; |
| 865 | |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 866 | if (sscanf(buf, "%d", &store) != 1) |
| 867 | return -EINVAL; |
| 868 | |
| 869 | mvm->store_d3_resume_sram = store; |
| 870 | |
| 871 | return count; |
| 872 | } |
| 873 | |
| 874 | static ssize_t iwl_dbgfs_d3_sram_read(struct file *file, char __user *user_buf, |
| 875 | size_t count, loff_t *ppos) |
| 876 | { |
| 877 | struct iwl_mvm *mvm = file->private_data; |
| 878 | const struct fw_img *img; |
| 879 | int ofs, len, pos = 0; |
| 880 | size_t bufsz, ret; |
| 881 | char *buf; |
| 882 | u8 *ptr = mvm->d3_resume_sram; |
| 883 | |
| 884 | img = &mvm->fw->img[IWL_UCODE_WOWLAN]; |
| 885 | len = img->sec[IWL_UCODE_SECTION_DATA].len; |
| 886 | |
| 887 | bufsz = len * 4 + 256; |
| 888 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 889 | if (!buf) |
| 890 | return -ENOMEM; |
| 891 | |
| 892 | pos += scnprintf(buf, bufsz, "D3 SRAM capture: %sabled\n", |
| 893 | mvm->store_d3_resume_sram ? "en" : "dis"); |
| 894 | |
| 895 | if (ptr) { |
| 896 | for (ofs = 0; ofs < len; ofs += 16) { |
| 897 | pos += scnprintf(buf + pos, bufsz - pos, |
| 898 | "0x%.4x ", ofs); |
| 899 | hex_dump_to_buffer(ptr + ofs, 16, 16, 1, buf + pos, |
| 900 | bufsz - pos, false); |
| 901 | pos += strlen(buf + pos); |
| 902 | if (bufsz - pos > 0) |
| 903 | buf[pos++] = '\n'; |
| 904 | } |
| 905 | } else { |
| 906 | pos += scnprintf(buf + pos, bufsz - pos, |
| 907 | "(no data captured)\n"); |
| 908 | } |
| 909 | |
| 910 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 911 | |
| 912 | kfree(buf); |
| 913 | |
| 914 | return ret; |
| 915 | } |
| 916 | #endif |
| 917 | |
Eliad Peller | 70d6bab | 2013-11-05 14:45:16 +0200 | [diff] [blame] | 918 | #define PRINT_MVM_REF(ref) do { \ |
| 919 | if (test_bit(ref, mvm->ref_bitmap)) \ |
| 920 | pos += scnprintf(buf + pos, bufsz - pos, \ |
| 921 | "\t(0x%lx) %s\n", \ |
| 922 | BIT(ref), #ref); \ |
| 923 | } while (0) |
| 924 | |
| 925 | static ssize_t iwl_dbgfs_d0i3_refs_read(struct file *file, |
| 926 | char __user *user_buf, |
| 927 | size_t count, loff_t *ppos) |
| 928 | { |
| 929 | struct iwl_mvm *mvm = file->private_data; |
| 930 | int pos = 0; |
| 931 | char buf[256]; |
| 932 | const size_t bufsz = sizeof(buf); |
| 933 | |
| 934 | pos += scnprintf(buf + pos, bufsz - pos, "taken mvm refs: 0x%lx\n", |
| 935 | mvm->ref_bitmap[0]); |
| 936 | |
| 937 | PRINT_MVM_REF(IWL_MVM_REF_UCODE_DOWN); |
| 938 | PRINT_MVM_REF(IWL_MVM_REF_SCAN); |
| 939 | PRINT_MVM_REF(IWL_MVM_REF_ROC); |
| 940 | PRINT_MVM_REF(IWL_MVM_REF_P2P_CLIENT); |
| 941 | PRINT_MVM_REF(IWL_MVM_REF_AP_IBSS); |
Eliad Peller | 0eb8365 | 2013-11-11 18:56:35 +0200 | [diff] [blame] | 942 | PRINT_MVM_REF(IWL_MVM_REF_USER); |
Eliad Peller | 70d6bab | 2013-11-05 14:45:16 +0200 | [diff] [blame] | 943 | |
| 944 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 945 | } |
| 946 | |
Eliad Peller | 0eb8365 | 2013-11-11 18:56:35 +0200 | [diff] [blame] | 947 | static ssize_t iwl_dbgfs_d0i3_refs_write(struct iwl_mvm *mvm, char *buf, |
| 948 | size_t count, loff_t *ppos) |
| 949 | { |
| 950 | unsigned long value; |
| 951 | int ret; |
| 952 | bool taken; |
| 953 | |
| 954 | ret = kstrtoul(buf, 10, &value); |
| 955 | if (ret < 0) |
| 956 | return ret; |
| 957 | |
| 958 | mutex_lock(&mvm->mutex); |
| 959 | |
| 960 | taken = test_bit(IWL_MVM_REF_USER, mvm->ref_bitmap); |
| 961 | if (value == 1 && !taken) |
| 962 | iwl_mvm_ref(mvm, IWL_MVM_REF_USER); |
| 963 | else if (value == 0 && taken) |
| 964 | iwl_mvm_unref(mvm, IWL_MVM_REF_USER); |
| 965 | else |
| 966 | ret = -EINVAL; |
| 967 | |
| 968 | mutex_unlock(&mvm->mutex); |
| 969 | |
| 970 | if (ret < 0) |
| 971 | return ret; |
| 972 | return count; |
| 973 | } |
| 974 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 975 | #define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \ |
| 976 | _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm) |
| 977 | #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz) \ |
| 978 | _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm) |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 979 | #define MVM_DEBUGFS_ADD_FILE_ALIAS(alias, name, parent, mode) do { \ |
| 980 | if (!debugfs_create_file(alias, mode, parent, mvm, \ |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 981 | &iwl_dbgfs_##name##_ops)) \ |
| 982 | goto err; \ |
| 983 | } while (0) |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 984 | #define MVM_DEBUGFS_ADD_FILE(name, parent, mode) \ |
| 985 | MVM_DEBUGFS_ADD_FILE_ALIAS(#name, name, parent, mode) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 986 | |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 987 | static ssize_t |
| 988 | iwl_dbgfs_prph_reg_read(struct file *file, |
| 989 | char __user *user_buf, |
| 990 | size_t count, loff_t *ppos) |
| 991 | { |
| 992 | struct iwl_mvm *mvm = file->private_data; |
| 993 | int pos = 0; |
| 994 | char buf[32]; |
| 995 | const size_t bufsz = sizeof(buf); |
| 996 | |
| 997 | if (!mvm->dbgfs_prph_reg_addr) |
| 998 | return -EINVAL; |
| 999 | |
| 1000 | pos += scnprintf(buf + pos, bufsz - pos, "Reg 0x%x: (0x%x)\n", |
| 1001 | mvm->dbgfs_prph_reg_addr, |
| 1002 | iwl_read_prph(mvm->trans, mvm->dbgfs_prph_reg_addr)); |
| 1003 | |
| 1004 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1005 | } |
| 1006 | |
| 1007 | static ssize_t |
| 1008 | iwl_dbgfs_prph_reg_write(struct iwl_mvm *mvm, char *buf, |
| 1009 | size_t count, loff_t *ppos) |
| 1010 | { |
| 1011 | u8 args; |
| 1012 | u32 value; |
| 1013 | |
| 1014 | args = sscanf(buf, "%i %i", &mvm->dbgfs_prph_reg_addr, &value); |
| 1015 | /* if we only want to set the reg address - nothing more to do */ |
| 1016 | if (args == 1) |
| 1017 | goto out; |
| 1018 | |
| 1019 | /* otherwise, make sure we have both address and value */ |
| 1020 | if (args != 2) |
| 1021 | return -EINVAL; |
| 1022 | |
| 1023 | iwl_write_prph(mvm->trans, mvm->dbgfs_prph_reg_addr, value); |
| 1024 | out: |
| 1025 | return count; |
| 1026 | } |
| 1027 | |
| 1028 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(prph_reg, 64); |
| 1029 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1030 | /* Device wide debugfs entries */ |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1031 | MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush, 16); |
| 1032 | MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain, 8); |
| 1033 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram, 64); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1034 | MVM_DEBUGFS_READ_FILE_OPS(stations); |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 1035 | MVM_DEBUGFS_READ_FILE_OPS(bt_notif); |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 1036 | MVM_DEBUGFS_READ_FILE_OPS(bt_cmd); |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1037 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(disable_power_off, 64); |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 1038 | MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 1039 | MVM_DEBUGFS_READ_FILE_OPS(drv_rx_stats); |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1040 | MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart, 10); |
| 1041 | MVM_DEBUGFS_WRITE_FILE_OPS(fw_nmi, 10); |
| 1042 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain, 8); |
Eliad Peller | 0eb8365 | 2013-11-11 18:56:35 +0200 | [diff] [blame] | 1043 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(d0i3_refs, 8); |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 1044 | |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1045 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
| 1046 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256); |
| 1047 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters_macs, 256); |
| 1048 | #endif |
| 1049 | |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1050 | #ifdef CONFIG_PM_SLEEP |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1051 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram, 8); |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1052 | #endif |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1053 | |
| 1054 | int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir) |
| 1055 | { |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1056 | struct dentry *bcast_dir __maybe_unused; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1057 | char buf[100]; |
| 1058 | |
Johannes Berg | d07913a | 2014-02-26 11:25:58 +0100 | [diff] [blame] | 1059 | spin_lock_init(&mvm->drv_stats_lock); |
| 1060 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1061 | mvm->debugfs_dir = dbgfs_dir; |
| 1062 | |
| 1063 | MVM_DEBUGFS_ADD_FILE(tx_flush, mvm->debugfs_dir, S_IWUSR); |
| 1064 | MVM_DEBUGFS_ADD_FILE(sta_drain, mvm->debugfs_dir, S_IWUSR); |
| 1065 | MVM_DEBUGFS_ADD_FILE(sram, mvm->debugfs_dir, S_IWUSR | S_IRUSR); |
| 1066 | MVM_DEBUGFS_ADD_FILE(stations, dbgfs_dir, S_IRUSR); |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 1067 | MVM_DEBUGFS_ADD_FILE(bt_notif, dbgfs_dir, S_IRUSR); |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 1068 | MVM_DEBUGFS_ADD_FILE(bt_cmd, dbgfs_dir, S_IRUSR); |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 1069 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_DEVICE_PS_CMD) |
| 1070 | MVM_DEBUGFS_ADD_FILE(disable_power_off, mvm->debugfs_dir, |
| 1071 | S_IRUSR | S_IWUSR); |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 1072 | MVM_DEBUGFS_ADD_FILE(fw_rx_stats, mvm->debugfs_dir, S_IRUSR); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 1073 | MVM_DEBUGFS_ADD_FILE(drv_rx_stats, mvm->debugfs_dir, S_IRUSR); |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 1074 | MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, S_IWUSR); |
Alexander Bondar | 119663c | 2013-10-17 14:26:50 +0200 | [diff] [blame] | 1075 | MVM_DEBUGFS_ADD_FILE(fw_nmi, mvm->debugfs_dir, S_IWUSR); |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 1076 | MVM_DEBUGFS_ADD_FILE(scan_ant_rxchain, mvm->debugfs_dir, |
| 1077 | S_IWUSR | S_IRUSR); |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1078 | MVM_DEBUGFS_ADD_FILE(prph_reg, mvm->debugfs_dir, S_IWUSR | S_IRUSR); |
Eliad Peller | 0eb8365 | 2013-11-11 18:56:35 +0200 | [diff] [blame] | 1079 | MVM_DEBUGFS_ADD_FILE(d0i3_refs, mvm->debugfs_dir, S_IRUSR | S_IWUSR); |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1080 | |
| 1081 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
| 1082 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING) { |
| 1083 | bcast_dir = debugfs_create_dir("bcast_filtering", |
| 1084 | mvm->debugfs_dir); |
| 1085 | if (!bcast_dir) |
| 1086 | goto err; |
| 1087 | |
| 1088 | if (!debugfs_create_bool("override", S_IRUSR | S_IWUSR, |
| 1089 | bcast_dir, |
| 1090 | &mvm->dbgfs_bcast_filtering.override)) |
| 1091 | goto err; |
| 1092 | |
| 1093 | MVM_DEBUGFS_ADD_FILE_ALIAS("filters", bcast_filters, |
| 1094 | bcast_dir, S_IWUSR | S_IRUSR); |
| 1095 | MVM_DEBUGFS_ADD_FILE_ALIAS("macs", bcast_filters_macs, |
| 1096 | bcast_dir, S_IWUSR | S_IRUSR); |
| 1097 | } |
| 1098 | #endif |
| 1099 | |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1100 | #ifdef CONFIG_PM_SLEEP |
| 1101 | MVM_DEBUGFS_ADD_FILE(d3_sram, mvm->debugfs_dir, S_IRUSR | S_IWUSR); |
Johannes Berg | debff61 | 2013-05-14 13:53:45 +0200 | [diff] [blame] | 1102 | MVM_DEBUGFS_ADD_FILE(d3_test, mvm->debugfs_dir, S_IRUSR); |
Johannes Berg | b011471 | 2013-06-12 14:55:40 +0200 | [diff] [blame] | 1103 | if (!debugfs_create_bool("d3_wake_sysassert", S_IRUSR | S_IWUSR, |
| 1104 | mvm->debugfs_dir, &mvm->d3_wake_sysassert)) |
| 1105 | goto err; |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1106 | #endif |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1107 | |
Emmanuel Grumbach | 086f736 | 2013-11-18 17:00:03 +0200 | [diff] [blame] | 1108 | if (!debugfs_create_blob("nvm_hw", S_IRUSR, |
| 1109 | mvm->debugfs_dir, &mvm->nvm_hw_blob)) |
| 1110 | goto err; |
| 1111 | if (!debugfs_create_blob("nvm_sw", S_IRUSR, |
| 1112 | mvm->debugfs_dir, &mvm->nvm_sw_blob)) |
| 1113 | goto err; |
| 1114 | if (!debugfs_create_blob("nvm_calib", S_IRUSR, |
| 1115 | mvm->debugfs_dir, &mvm->nvm_calib_blob)) |
| 1116 | goto err; |
| 1117 | if (!debugfs_create_blob("nvm_prod", S_IRUSR, |
| 1118 | mvm->debugfs_dir, &mvm->nvm_prod_blob)) |
| 1119 | goto err; |
| 1120 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1121 | /* |
| 1122 | * Create a symlink with mac80211. It will be removed when mac80211 |
| 1123 | * exists (before the opmode exists which removes the target.) |
| 1124 | */ |
| 1125 | snprintf(buf, 100, "../../%s/%s", |
| 1126 | dbgfs_dir->d_parent->d_parent->d_name.name, |
| 1127 | dbgfs_dir->d_parent->d_name.name); |
| 1128 | if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf)) |
| 1129 | goto err; |
| 1130 | |
| 1131 | return 0; |
| 1132 | err: |
| 1133 | IWL_ERR(mvm, "Can't create the mvm debugfs directory\n"); |
| 1134 | return -ENOMEM; |
| 1135 | } |