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 | *****************************************************************************/ |
Emmanuel Grumbach | 192c80a | 2014-03-19 08:25:05 +0200 | [diff] [blame] | 63 | #include <linux/vmalloc.h> |
| 64 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 65 | #include "mvm.h" |
| 66 | #include "sta.h" |
| 67 | #include "iwl-io.h" |
Johannes Berg | 820a1a5 | 2013-11-12 16:58:41 +0100 | [diff] [blame] | 68 | #include "debugfs.h" |
Johannes Berg | 4d07500 | 2014-04-24 10:41:31 +0200 | [diff] [blame] | 69 | #include "iwl-fw-error-dump.h" |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 70 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 71 | 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] | 72 | size_t count, loff_t *ppos) |
| 73 | { |
Johannes Berg | 8a0bd16 | 2013-11-12 16:48:03 +0100 | [diff] [blame] | 74 | int ret; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 75 | u32 scd_q_msk; |
| 76 | |
| 77 | if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR) |
| 78 | return -EIO; |
| 79 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 80 | if (sscanf(buf, "%x", &scd_q_msk) != 1) |
| 81 | return -EINVAL; |
| 82 | |
| 83 | IWL_ERR(mvm, "FLUSHING queues: scd_q_msk = 0x%x\n", scd_q_msk); |
| 84 | |
| 85 | mutex_lock(&mvm->mutex); |
| 86 | ret = iwl_mvm_flush_tx_path(mvm, scd_q_msk, true) ? : count; |
| 87 | mutex_unlock(&mvm->mutex); |
| 88 | |
| 89 | return ret; |
| 90 | } |
| 91 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 92 | 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] | 93 | size_t count, loff_t *ppos) |
| 94 | { |
Emmanuel Grumbach | f327b04 | 2014-01-14 08:30:32 +0200 | [diff] [blame] | 95 | struct iwl_mvm_sta *mvmsta; |
Johannes Berg | 8a0bd16 | 2013-11-12 16:48:03 +0100 | [diff] [blame] | 96 | int sta_id, drain, ret; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 97 | |
| 98 | if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR) |
| 99 | return -EIO; |
| 100 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 101 | if (sscanf(buf, "%d %d", &sta_id, &drain) != 2) |
| 102 | return -EINVAL; |
Johannes Berg | 60765a4 | 2013-10-25 13:06:06 +0200 | [diff] [blame] | 103 | if (sta_id < 0 || sta_id >= IWL_MVM_STATION_COUNT) |
| 104 | return -EINVAL; |
| 105 | if (drain < 0 || drain > 1) |
| 106 | return -EINVAL; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 107 | |
| 108 | mutex_lock(&mvm->mutex); |
| 109 | |
Emmanuel Grumbach | f327b04 | 2014-01-14 08:30:32 +0200 | [diff] [blame] | 110 | mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id); |
| 111 | |
| 112 | if (!mvmsta) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 113 | ret = -ENOENT; |
| 114 | else |
Emmanuel Grumbach | f327b04 | 2014-01-14 08:30:32 +0200 | [diff] [blame] | 115 | ret = iwl_mvm_drain_sta(mvm, mvmsta, drain) ? : count; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 116 | |
| 117 | mutex_unlock(&mvm->mutex); |
| 118 | |
| 119 | return ret; |
| 120 | } |
| 121 | |
Emmanuel Grumbach | 1bd3cbc | 2014-03-18 21:15:06 +0200 | [diff] [blame] | 122 | static int iwl_dbgfs_fw_error_dump_open(struct inode *inode, struct file *file) |
| 123 | { |
| 124 | struct iwl_mvm *mvm = inode->i_private; |
| 125 | int ret; |
| 126 | |
| 127 | if (!mvm) |
| 128 | return -EINVAL; |
| 129 | |
| 130 | mutex_lock(&mvm->mutex); |
| 131 | if (!mvm->fw_error_dump) { |
| 132 | ret = -ENODATA; |
| 133 | goto out; |
| 134 | } |
| 135 | |
| 136 | file->private_data = mvm->fw_error_dump; |
| 137 | mvm->fw_error_dump = NULL; |
Emmanuel Grumbach | 1bd3cbc | 2014-03-18 21:15:06 +0200 | [diff] [blame] | 138 | ret = 0; |
| 139 | |
| 140 | out: |
| 141 | mutex_unlock(&mvm->mutex); |
| 142 | return ret; |
| 143 | } |
| 144 | |
| 145 | static ssize_t iwl_dbgfs_fw_error_dump_read(struct file *file, |
| 146 | char __user *user_buf, |
| 147 | size_t count, loff_t *ppos) |
| 148 | { |
Emmanuel Grumbach | 48eb7b3 | 2014-07-08 19:45:17 +0300 | [diff] [blame] | 149 | struct iwl_mvm_dump_ptrs *dump_ptrs = (void *)file->private_data; |
| 150 | ssize_t bytes_read = 0; |
| 151 | ssize_t bytes_read_trans = 0; |
Emmanuel Grumbach | 1bd3cbc | 2014-03-18 21:15:06 +0200 | [diff] [blame] | 152 | |
Emmanuel Grumbach | 48eb7b3 | 2014-07-08 19:45:17 +0300 | [diff] [blame] | 153 | if (*ppos < dump_ptrs->op_mode_len) |
| 154 | bytes_read += |
| 155 | simple_read_from_buffer(user_buf, count, ppos, |
| 156 | dump_ptrs->op_mode_ptr, |
| 157 | dump_ptrs->op_mode_len); |
| 158 | |
| 159 | if (bytes_read < 0 || *ppos < dump_ptrs->op_mode_len) |
| 160 | return bytes_read; |
| 161 | |
| 162 | if (dump_ptrs->trans_ptr) { |
| 163 | *ppos -= dump_ptrs->op_mode_len; |
| 164 | bytes_read_trans = |
| 165 | simple_read_from_buffer(user_buf + bytes_read, |
| 166 | count - bytes_read, ppos, |
| 167 | dump_ptrs->trans_ptr->data, |
| 168 | dump_ptrs->trans_ptr->len); |
| 169 | *ppos += dump_ptrs->op_mode_len; |
| 170 | |
| 171 | if (bytes_read_trans >= 0) |
| 172 | bytes_read += bytes_read_trans; |
| 173 | else if (!bytes_read) |
| 174 | /* propagate the failure */ |
| 175 | return bytes_read_trans; |
| 176 | } |
| 177 | |
| 178 | return bytes_read; |
| 179 | |
Emmanuel Grumbach | 1bd3cbc | 2014-03-18 21:15:06 +0200 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | static int iwl_dbgfs_fw_error_dump_release(struct inode *inode, |
| 183 | struct file *file) |
| 184 | { |
Emmanuel Grumbach | 48eb7b3 | 2014-07-08 19:45:17 +0300 | [diff] [blame] | 185 | struct iwl_mvm_dump_ptrs *dump_ptrs = (void *)file->private_data; |
| 186 | |
| 187 | vfree(dump_ptrs->op_mode_ptr); |
| 188 | vfree(dump_ptrs->trans_ptr); |
| 189 | kfree(dump_ptrs); |
Emmanuel Grumbach | 1bd3cbc | 2014-03-18 21:15:06 +0200 | [diff] [blame] | 190 | |
| 191 | return 0; |
| 192 | } |
| 193 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 194 | static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf, |
| 195 | size_t count, loff_t *ppos) |
| 196 | { |
| 197 | struct iwl_mvm *mvm = file->private_data; |
| 198 | const struct fw_img *img; |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 199 | unsigned int ofs, len; |
| 200 | size_t ret; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 201 | u8 *ptr; |
| 202 | |
Johannes Berg | 60191d9 | 2013-05-15 13:08:51 +0200 | [diff] [blame] | 203 | if (!mvm->ucode_loaded) |
| 204 | return -EINVAL; |
| 205 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 206 | /* default is to dump the entire data segment */ |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 207 | img = &mvm->fw->img[mvm->cur_ucode]; |
| 208 | ofs = img->sec[IWL_UCODE_SECTION_DATA].offset; |
| 209 | len = img->sec[IWL_UCODE_SECTION_DATA].len; |
| 210 | |
Emmanuel Grumbach | 01e0efe | 2014-01-06 09:05:54 +0200 | [diff] [blame] | 211 | if (mvm->dbgfs_sram_len) { |
Johannes Berg | 60191d9 | 2013-05-15 13:08:51 +0200 | [diff] [blame] | 212 | ofs = mvm->dbgfs_sram_offset; |
| 213 | len = mvm->dbgfs_sram_len; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 214 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 215 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 216 | ptr = kzalloc(len, GFP_KERNEL); |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 217 | if (!ptr) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 218 | return -ENOMEM; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 219 | |
Johannes Berg | 60191d9 | 2013-05-15 13:08:51 +0200 | [diff] [blame] | 220 | iwl_trans_read_mem_bytes(mvm->trans, ofs, ptr, len); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 221 | |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 222 | ret = simple_read_from_buffer(user_buf, count, ppos, ptr, len); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 223 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 224 | kfree(ptr); |
| 225 | |
| 226 | return ret; |
| 227 | } |
| 228 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 229 | static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf, |
| 230 | size_t count, loff_t *ppos) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 231 | { |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 232 | const struct fw_img *img; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 233 | u32 offset, len; |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 234 | u32 img_offset, img_len; |
| 235 | |
| 236 | if (!mvm->ucode_loaded) |
| 237 | return -EINVAL; |
| 238 | |
| 239 | img = &mvm->fw->img[mvm->cur_ucode]; |
| 240 | img_offset = img->sec[IWL_UCODE_SECTION_DATA].offset; |
| 241 | img_len = img->sec[IWL_UCODE_SECTION_DATA].len; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 242 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 243 | if (sscanf(buf, "%x,%x", &offset, &len) == 2) { |
| 244 | if ((offset & 0x3) || (len & 0x3)) |
| 245 | return -EINVAL; |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 246 | |
| 247 | if (offset + len > img_offset + img_len) |
| 248 | return -EINVAL; |
| 249 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 250 | mvm->dbgfs_sram_offset = offset; |
| 251 | mvm->dbgfs_sram_len = len; |
| 252 | } else { |
| 253 | mvm->dbgfs_sram_offset = 0; |
| 254 | mvm->dbgfs_sram_len = 0; |
| 255 | } |
| 256 | |
| 257 | return count; |
| 258 | } |
| 259 | |
Matti Gottlieb | 7280d1f | 2014-07-17 16:41:14 +0300 | [diff] [blame] | 260 | static ssize_t iwl_dbgfs_set_nic_temperature_read(struct file *file, |
| 261 | char __user *user_buf, |
| 262 | size_t count, loff_t *ppos) |
| 263 | { |
| 264 | struct iwl_mvm *mvm = file->private_data; |
| 265 | char buf[16]; |
| 266 | int pos; |
| 267 | |
| 268 | if (!mvm->temperature_test) |
| 269 | pos = scnprintf(buf , sizeof(buf), "disabled\n"); |
| 270 | else |
| 271 | pos = scnprintf(buf , sizeof(buf), "%d\n", mvm->temperature); |
| 272 | |
| 273 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 274 | } |
| 275 | |
| 276 | /* |
| 277 | * Set NIC Temperature |
| 278 | * Cause the driver to ignore the actual NIC temperature reported by the FW |
| 279 | * Enable: any value between IWL_MVM_DEBUG_SET_TEMPERATURE_MIN - |
| 280 | * IWL_MVM_DEBUG_SET_TEMPERATURE_MAX |
| 281 | * Disable: IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE |
| 282 | */ |
| 283 | static ssize_t iwl_dbgfs_set_nic_temperature_write(struct iwl_mvm *mvm, |
| 284 | char *buf, size_t count, |
| 285 | loff_t *ppos) |
| 286 | { |
| 287 | int temperature; |
| 288 | |
| 289 | if (kstrtoint(buf, 10, &temperature)) |
| 290 | return -EINVAL; |
| 291 | /* not a legal temperature */ |
| 292 | if ((temperature > IWL_MVM_DEBUG_SET_TEMPERATURE_MAX && |
| 293 | temperature != IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) || |
| 294 | temperature < IWL_MVM_DEBUG_SET_TEMPERATURE_MIN) |
| 295 | return -EINVAL; |
| 296 | |
| 297 | mutex_lock(&mvm->mutex); |
| 298 | if (temperature == IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) { |
Luciano Coelho | b689fa7 | 2014-08-20 17:26:58 +0300 | [diff] [blame] | 299 | if (!mvm->temperature_test) |
| 300 | goto out; |
| 301 | |
Matti Gottlieb | 7280d1f | 2014-07-17 16:41:14 +0300 | [diff] [blame] | 302 | mvm->temperature_test = false; |
Luciano Coelho | b689fa7 | 2014-08-20 17:26:58 +0300 | [diff] [blame] | 303 | /* Since we can't read the temp while awake, just set |
| 304 | * it to zero until we get the next RX stats from the |
| 305 | * firmware. |
| 306 | */ |
| 307 | mvm->temperature = 0; |
Matti Gottlieb | 7280d1f | 2014-07-17 16:41:14 +0300 | [diff] [blame] | 308 | } else { |
| 309 | mvm->temperature_test = true; |
| 310 | mvm->temperature = temperature; |
| 311 | } |
| 312 | IWL_DEBUG_TEMP(mvm, "%sabling debug set temperature (temp = %d)\n", |
| 313 | mvm->temperature_test ? "En" : "Dis" , |
| 314 | mvm->temperature); |
| 315 | /* handle the temperature change */ |
| 316 | iwl_mvm_tt_handler(mvm); |
Luciano Coelho | b689fa7 | 2014-08-20 17:26:58 +0300 | [diff] [blame] | 317 | |
| 318 | out: |
Matti Gottlieb | 7280d1f | 2014-07-17 16:41:14 +0300 | [diff] [blame] | 319 | mutex_unlock(&mvm->mutex); |
| 320 | |
| 321 | return count; |
| 322 | } |
| 323 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 324 | static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, |
| 325 | size_t count, loff_t *ppos) |
| 326 | { |
| 327 | struct iwl_mvm *mvm = file->private_data; |
| 328 | struct ieee80211_sta *sta; |
| 329 | char buf[400]; |
| 330 | int i, pos = 0, bufsz = sizeof(buf); |
| 331 | |
| 332 | mutex_lock(&mvm->mutex); |
| 333 | |
| 334 | for (i = 0; i < IWL_MVM_STATION_COUNT; i++) { |
| 335 | pos += scnprintf(buf + pos, bufsz - pos, "%.2d: ", i); |
| 336 | sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i], |
| 337 | lockdep_is_held(&mvm->mutex)); |
| 338 | if (!sta) |
| 339 | pos += scnprintf(buf + pos, bufsz - pos, "N/A\n"); |
| 340 | else if (IS_ERR(sta)) |
| 341 | pos += scnprintf(buf + pos, bufsz - pos, "%ld\n", |
| 342 | PTR_ERR(sta)); |
| 343 | else |
| 344 | pos += scnprintf(buf + pos, bufsz - pos, "%pM\n", |
| 345 | sta->addr); |
| 346 | } |
| 347 | |
| 348 | mutex_unlock(&mvm->mutex); |
| 349 | |
| 350 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 351 | } |
| 352 | |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 353 | static ssize_t iwl_dbgfs_disable_power_off_read(struct file *file, |
| 354 | char __user *user_buf, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 355 | size_t count, loff_t *ppos) |
| 356 | { |
| 357 | struct iwl_mvm *mvm = file->private_data; |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 358 | char buf[64]; |
| 359 | int bufsz = sizeof(buf); |
| 360 | int pos = 0; |
| 361 | |
| 362 | pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d0=%d\n", |
| 363 | mvm->disable_power_off); |
| 364 | pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d3=%d\n", |
| 365 | mvm->disable_power_off_d3); |
| 366 | |
| 367 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 368 | } |
| 369 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 370 | 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] | 371 | size_t count, loff_t *ppos) |
| 372 | { |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 373 | int ret, val; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 374 | |
| 375 | if (!mvm->ucode_loaded) |
| 376 | return -EIO; |
| 377 | |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 378 | if (!strncmp("disable_power_off_d0=", buf, 21)) { |
| 379 | if (sscanf(buf + 21, "%d", &val) != 1) |
| 380 | return -EINVAL; |
| 381 | mvm->disable_power_off = val; |
| 382 | } else if (!strncmp("disable_power_off_d3=", buf, 21)) { |
| 383 | if (sscanf(buf + 21, "%d", &val) != 1) |
| 384 | return -EINVAL; |
| 385 | mvm->disable_power_off_d3 = val; |
| 386 | } else { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 387 | return -EINVAL; |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 388 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 389 | |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 390 | mutex_lock(&mvm->mutex); |
Emmanuel Grumbach | c1cb92f | 2014-01-28 10:17:18 +0200 | [diff] [blame] | 391 | ret = iwl_mvm_power_update_device(mvm); |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 392 | mutex_unlock(&mvm->mutex); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 393 | |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 394 | return ret ?: count; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 395 | } |
| 396 | |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 397 | #define BT_MBOX_MSG(_notif, _num, _field) \ |
| 398 | ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\ |
| 399 | >> BT_MBOX##_num##_##_field##_POS) |
| 400 | |
| 401 | |
| 402 | #define BT_MBOX_PRINT(_num, _field, _end) \ |
| 403 | pos += scnprintf(buf + pos, bufsz - pos, \ |
| 404 | "\t%s: %d%s", \ |
| 405 | #_field, \ |
| 406 | BT_MBOX_MSG(notif, _num, _field), \ |
| 407 | true ? "\n" : ", "); |
| 408 | |
Emmanuel Grumbach | 160be57 | 2014-07-02 17:33:52 +0300 | [diff] [blame] | 409 | static |
| 410 | int iwl_mvm_coex_dump_mbox(struct iwl_bt_coex_profile_notif *notif, char *buf, |
| 411 | int pos, int bufsz) |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 412 | { |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 413 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n"); |
| 414 | |
| 415 | BT_MBOX_PRINT(0, LE_SLAVE_LAT, false); |
| 416 | BT_MBOX_PRINT(0, LE_PROF1, false); |
| 417 | BT_MBOX_PRINT(0, LE_PROF2, false); |
| 418 | BT_MBOX_PRINT(0, LE_PROF_OTHER, false); |
| 419 | BT_MBOX_PRINT(0, CHL_SEQ_N, false); |
| 420 | BT_MBOX_PRINT(0, INBAND_S, false); |
| 421 | BT_MBOX_PRINT(0, LE_MIN_RSSI, false); |
| 422 | BT_MBOX_PRINT(0, LE_SCAN, false); |
| 423 | BT_MBOX_PRINT(0, LE_ADV, false); |
| 424 | BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false); |
| 425 | BT_MBOX_PRINT(0, OPEN_CON_1, true); |
| 426 | |
| 427 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n"); |
| 428 | |
| 429 | BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false); |
| 430 | BT_MBOX_PRINT(1, IP_SR, false); |
| 431 | BT_MBOX_PRINT(1, LE_MSTR, false); |
| 432 | BT_MBOX_PRINT(1, AGGR_TRFC_LD, false); |
| 433 | BT_MBOX_PRINT(1, MSG_TYPE, false); |
| 434 | BT_MBOX_PRINT(1, SSN, true); |
| 435 | |
| 436 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n"); |
| 437 | |
| 438 | BT_MBOX_PRINT(2, SNIFF_ACT, false); |
| 439 | BT_MBOX_PRINT(2, PAG, false); |
| 440 | BT_MBOX_PRINT(2, INQUIRY, false); |
| 441 | BT_MBOX_PRINT(2, CONN, false); |
| 442 | BT_MBOX_PRINT(2, SNIFF_INTERVAL, false); |
| 443 | BT_MBOX_PRINT(2, DISC, false); |
| 444 | BT_MBOX_PRINT(2, SCO_TX_ACT, false); |
| 445 | BT_MBOX_PRINT(2, SCO_RX_ACT, false); |
| 446 | BT_MBOX_PRINT(2, ESCO_RE_TX, false); |
| 447 | BT_MBOX_PRINT(2, SCO_DURATION, true); |
| 448 | |
| 449 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n"); |
| 450 | |
| 451 | BT_MBOX_PRINT(3, SCO_STATE, false); |
| 452 | BT_MBOX_PRINT(3, SNIFF_STATE, false); |
| 453 | BT_MBOX_PRINT(3, A2DP_STATE, false); |
| 454 | BT_MBOX_PRINT(3, ACL_STATE, false); |
| 455 | BT_MBOX_PRINT(3, MSTR_STATE, false); |
| 456 | BT_MBOX_PRINT(3, OBX_STATE, false); |
| 457 | BT_MBOX_PRINT(3, OPEN_CON_2, false); |
| 458 | BT_MBOX_PRINT(3, TRAFFIC_LOAD, false); |
| 459 | BT_MBOX_PRINT(3, CHL_SEQN_LSB, false); |
| 460 | BT_MBOX_PRINT(3, INBAND_P, false); |
| 461 | BT_MBOX_PRINT(3, MSG_TYPE_2, false); |
| 462 | BT_MBOX_PRINT(3, SSN_2, false); |
| 463 | BT_MBOX_PRINT(3, UPDATE_REQUEST, true); |
| 464 | |
Emmanuel Grumbach | 160be57 | 2014-07-02 17:33:52 +0300 | [diff] [blame] | 465 | return pos; |
| 466 | } |
| 467 | |
| 468 | static |
| 469 | int iwl_mvm_coex_dump_mbox_old(struct iwl_bt_coex_profile_notif_old *notif, |
| 470 | char *buf, int pos, int bufsz) |
| 471 | { |
| 472 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n"); |
| 473 | |
| 474 | BT_MBOX_PRINT(0, LE_SLAVE_LAT, false); |
| 475 | BT_MBOX_PRINT(0, LE_PROF1, false); |
| 476 | BT_MBOX_PRINT(0, LE_PROF2, false); |
| 477 | BT_MBOX_PRINT(0, LE_PROF_OTHER, false); |
| 478 | BT_MBOX_PRINT(0, CHL_SEQ_N, false); |
| 479 | BT_MBOX_PRINT(0, INBAND_S, false); |
| 480 | BT_MBOX_PRINT(0, LE_MIN_RSSI, false); |
| 481 | BT_MBOX_PRINT(0, LE_SCAN, false); |
| 482 | BT_MBOX_PRINT(0, LE_ADV, false); |
| 483 | BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false); |
| 484 | BT_MBOX_PRINT(0, OPEN_CON_1, true); |
| 485 | |
| 486 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n"); |
| 487 | |
| 488 | BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false); |
| 489 | BT_MBOX_PRINT(1, IP_SR, false); |
| 490 | BT_MBOX_PRINT(1, LE_MSTR, false); |
| 491 | BT_MBOX_PRINT(1, AGGR_TRFC_LD, false); |
| 492 | BT_MBOX_PRINT(1, MSG_TYPE, false); |
| 493 | BT_MBOX_PRINT(1, SSN, true); |
| 494 | |
| 495 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n"); |
| 496 | |
| 497 | BT_MBOX_PRINT(2, SNIFF_ACT, false); |
| 498 | BT_MBOX_PRINT(2, PAG, false); |
| 499 | BT_MBOX_PRINT(2, INQUIRY, false); |
| 500 | BT_MBOX_PRINT(2, CONN, false); |
| 501 | BT_MBOX_PRINT(2, SNIFF_INTERVAL, false); |
| 502 | BT_MBOX_PRINT(2, DISC, false); |
| 503 | BT_MBOX_PRINT(2, SCO_TX_ACT, false); |
| 504 | BT_MBOX_PRINT(2, SCO_RX_ACT, false); |
| 505 | BT_MBOX_PRINT(2, ESCO_RE_TX, false); |
| 506 | BT_MBOX_PRINT(2, SCO_DURATION, true); |
| 507 | |
| 508 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n"); |
| 509 | |
| 510 | BT_MBOX_PRINT(3, SCO_STATE, false); |
| 511 | BT_MBOX_PRINT(3, SNIFF_STATE, false); |
| 512 | BT_MBOX_PRINT(3, A2DP_STATE, false); |
| 513 | BT_MBOX_PRINT(3, ACL_STATE, false); |
| 514 | BT_MBOX_PRINT(3, MSTR_STATE, false); |
| 515 | BT_MBOX_PRINT(3, OBX_STATE, false); |
| 516 | BT_MBOX_PRINT(3, OPEN_CON_2, false); |
| 517 | BT_MBOX_PRINT(3, TRAFFIC_LOAD, false); |
| 518 | BT_MBOX_PRINT(3, CHL_SEQN_LSB, false); |
| 519 | BT_MBOX_PRINT(3, INBAND_P, false); |
| 520 | BT_MBOX_PRINT(3, MSG_TYPE_2, false); |
| 521 | BT_MBOX_PRINT(3, SSN_2, false); |
| 522 | BT_MBOX_PRINT(3, UPDATE_REQUEST, true); |
| 523 | |
| 524 | return pos; |
| 525 | } |
| 526 | |
| 527 | static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf, |
| 528 | size_t count, loff_t *ppos) |
| 529 | { |
| 530 | struct iwl_mvm *mvm = file->private_data; |
| 531 | char *buf; |
| 532 | int ret, pos = 0, bufsz = sizeof(char) * 1024; |
| 533 | |
| 534 | buf = kmalloc(bufsz, GFP_KERNEL); |
| 535 | if (!buf) |
| 536 | return -ENOMEM; |
| 537 | |
| 538 | mutex_lock(&mvm->mutex); |
| 539 | |
| 540 | if (!(mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_BT_COEX_SPLIT)) { |
| 541 | struct iwl_bt_coex_profile_notif_old *notif = |
| 542 | &mvm->last_bt_notif_old; |
| 543 | |
| 544 | pos += iwl_mvm_coex_dump_mbox_old(notif, buf, pos, bufsz); |
| 545 | |
| 546 | pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n", |
| 547 | notif->bt_ci_compliance); |
| 548 | pos += scnprintf(buf+pos, bufsz-pos, "primary_ch_lut = %d\n", |
| 549 | le32_to_cpu(notif->primary_ch_lut)); |
| 550 | pos += scnprintf(buf+pos, bufsz-pos, "secondary_ch_lut = %d\n", |
| 551 | le32_to_cpu(notif->secondary_ch_lut)); |
| 552 | pos += scnprintf(buf+pos, |
| 553 | bufsz-pos, "bt_activity_grading = %d\n", |
| 554 | le32_to_cpu(notif->bt_activity_grading)); |
| 555 | pos += scnprintf(buf+pos, bufsz-pos, |
| 556 | "antenna isolation = %d CORUN LUT index = %d\n", |
| 557 | mvm->last_ant_isol, mvm->last_corun_lut); |
| 558 | } else { |
| 559 | struct iwl_bt_coex_profile_notif *notif = |
| 560 | &mvm->last_bt_notif; |
| 561 | |
| 562 | pos += iwl_mvm_coex_dump_mbox(notif, buf, pos, bufsz); |
| 563 | |
| 564 | pos += scnprintf(buf+pos, bufsz-pos, "bt_ci_compliance = %d\n", |
| 565 | notif->bt_ci_compliance); |
| 566 | pos += scnprintf(buf+pos, bufsz-pos, "primary_ch_lut = %d\n", |
| 567 | le32_to_cpu(notif->primary_ch_lut)); |
| 568 | pos += scnprintf(buf+pos, bufsz-pos, "secondary_ch_lut = %d\n", |
| 569 | le32_to_cpu(notif->secondary_ch_lut)); |
| 570 | pos += scnprintf(buf+pos, |
| 571 | bufsz-pos, "bt_activity_grading = %d\n", |
| 572 | le32_to_cpu(notif->bt_activity_grading)); |
| 573 | pos += scnprintf(buf+pos, bufsz-pos, |
| 574 | "antenna isolation = %d CORUN LUT index = %d\n", |
| 575 | mvm->last_ant_isol, mvm->last_corun_lut); |
| 576 | } |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 577 | |
| 578 | mutex_unlock(&mvm->mutex); |
| 579 | |
| 580 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 581 | kfree(buf); |
| 582 | |
| 583 | return ret; |
| 584 | } |
| 585 | #undef BT_MBOX_PRINT |
| 586 | |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 587 | static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf, |
| 588 | size_t count, loff_t *ppos) |
| 589 | { |
| 590 | struct iwl_mvm *mvm = file->private_data; |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 591 | char buf[256]; |
| 592 | int bufsz = sizeof(buf); |
| 593 | int pos = 0; |
| 594 | |
| 595 | mutex_lock(&mvm->mutex); |
| 596 | |
Emmanuel Grumbach | 160be57 | 2014-07-02 17:33:52 +0300 | [diff] [blame] | 597 | if (!(mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_BT_COEX_SPLIT)) { |
| 598 | struct iwl_bt_coex_ci_cmd_old *cmd = &mvm->last_bt_ci_cmd_old; |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 599 | |
Emmanuel Grumbach | 160be57 | 2014-07-02 17:33:52 +0300 | [diff] [blame] | 600 | pos += scnprintf(buf+pos, bufsz-pos, |
| 601 | "Channel inhibition CMD\n"); |
| 602 | pos += scnprintf(buf+pos, bufsz-pos, |
| 603 | "\tPrimary Channel Bitmap 0x%016llx\n", |
| 604 | le64_to_cpu(cmd->bt_primary_ci)); |
| 605 | pos += scnprintf(buf+pos, bufsz-pos, |
| 606 | "\tSecondary Channel Bitmap 0x%016llx\n", |
| 607 | le64_to_cpu(cmd->bt_secondary_ci)); |
| 608 | |
| 609 | pos += scnprintf(buf+pos, bufsz-pos, "BT Configuration CMD\n"); |
| 610 | pos += scnprintf(buf+pos, bufsz-pos, "\tACK Kill Mask 0x%08x\n", |
Emmanuel Grumbach | 1459f26 | 2014-07-06 09:34:38 +0300 | [diff] [blame] | 611 | iwl_bt_ctl_kill_msk[mvm->bt_ack_kill_msk[0]]); |
Emmanuel Grumbach | 160be57 | 2014-07-02 17:33:52 +0300 | [diff] [blame] | 612 | pos += scnprintf(buf+pos, bufsz-pos, "\tCTS Kill Mask 0x%08x\n", |
Emmanuel Grumbach | 1459f26 | 2014-07-06 09:34:38 +0300 | [diff] [blame] | 613 | iwl_bt_ctl_kill_msk[mvm->bt_cts_kill_msk[0]]); |
Emmanuel Grumbach | 160be57 | 2014-07-02 17:33:52 +0300 | [diff] [blame] | 614 | |
| 615 | } else { |
| 616 | struct iwl_bt_coex_ci_cmd *cmd = &mvm->last_bt_ci_cmd; |
| 617 | |
| 618 | pos += scnprintf(buf+pos, bufsz-pos, |
| 619 | "Channel inhibition CMD\n"); |
| 620 | pos += scnprintf(buf+pos, bufsz-pos, |
| 621 | "\tPrimary Channel Bitmap 0x%016llx\n", |
| 622 | le64_to_cpu(cmd->bt_primary_ci)); |
| 623 | pos += scnprintf(buf+pos, bufsz-pos, |
| 624 | "\tSecondary Channel Bitmap 0x%016llx\n", |
| 625 | le64_to_cpu(cmd->bt_secondary_ci)); |
| 626 | |
| 627 | pos += scnprintf(buf+pos, bufsz-pos, "BT Configuration CMD\n"); |
Emmanuel Grumbach | 1459f26 | 2014-07-06 09:34:38 +0300 | [diff] [blame] | 628 | pos += scnprintf(buf+pos, bufsz-pos, |
| 629 | "\tPrimary: ACK Kill Mask 0x%08x\n", |
| 630 | iwl_bt_ctl_kill_msk[mvm->bt_ack_kill_msk[0]]); |
| 631 | pos += scnprintf(buf+pos, bufsz-pos, |
| 632 | "\tPrimary: CTS Kill Mask 0x%08x\n", |
| 633 | iwl_bt_ctl_kill_msk[mvm->bt_cts_kill_msk[0]]); |
| 634 | pos += scnprintf(buf+pos, bufsz-pos, |
| 635 | "\tSecondary: ACK Kill Mask 0x%08x\n", |
| 636 | iwl_bt_ctl_kill_msk[mvm->bt_ack_kill_msk[1]]); |
| 637 | pos += scnprintf(buf+pos, bufsz-pos, |
| 638 | "\tSecondary: CTS Kill Mask 0x%08x\n", |
| 639 | iwl_bt_ctl_kill_msk[mvm->bt_cts_kill_msk[1]]); |
| 640 | |
Emmanuel Grumbach | 160be57 | 2014-07-02 17:33:52 +0300 | [diff] [blame] | 641 | } |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 642 | |
| 643 | mutex_unlock(&mvm->mutex); |
| 644 | |
| 645 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 646 | } |
| 647 | |
Emmanuel Grumbach | cdb0056 | 2014-03-16 21:55:43 +0200 | [diff] [blame] | 648 | static ssize_t |
| 649 | iwl_dbgfs_bt_tx_prio_write(struct iwl_mvm *mvm, char *buf, |
| 650 | size_t count, loff_t *ppos) |
| 651 | { |
| 652 | u32 bt_tx_prio; |
| 653 | |
| 654 | if (sscanf(buf, "%u", &bt_tx_prio) != 1) |
| 655 | return -EINVAL; |
| 656 | if (bt_tx_prio > 4) |
| 657 | return -EINVAL; |
| 658 | |
| 659 | mvm->bt_tx_prio = bt_tx_prio; |
| 660 | |
| 661 | return count; |
| 662 | } |
| 663 | |
Emmanuel Grumbach | a39979a | 2014-05-28 12:06:41 +0300 | [diff] [blame] | 664 | static ssize_t |
| 665 | iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf, |
| 666 | size_t count, loff_t *ppos) |
| 667 | { |
| 668 | static const char * const modes_str[BT_FORCE_ANT_MAX] = { |
| 669 | [BT_FORCE_ANT_DIS] = "dis", |
| 670 | [BT_FORCE_ANT_AUTO] = "auto", |
| 671 | [BT_FORCE_ANT_BT] = "bt", |
| 672 | [BT_FORCE_ANT_WIFI] = "wifi", |
| 673 | }; |
| 674 | int ret, bt_force_ant_mode; |
| 675 | |
| 676 | for (bt_force_ant_mode = 0; |
| 677 | bt_force_ant_mode < ARRAY_SIZE(modes_str); |
| 678 | bt_force_ant_mode++) { |
| 679 | if (!strcmp(buf, modes_str[bt_force_ant_mode])) |
| 680 | break; |
| 681 | } |
| 682 | |
| 683 | if (bt_force_ant_mode >= ARRAY_SIZE(modes_str)) |
| 684 | return -EINVAL; |
| 685 | |
| 686 | ret = 0; |
| 687 | mutex_lock(&mvm->mutex); |
| 688 | if (mvm->bt_force_ant_mode == bt_force_ant_mode) |
| 689 | goto out; |
| 690 | |
| 691 | mvm->bt_force_ant_mode = bt_force_ant_mode; |
| 692 | IWL_DEBUG_COEX(mvm, "Force mode: %s\n", |
| 693 | modes_str[mvm->bt_force_ant_mode]); |
| 694 | ret = iwl_send_bt_init_conf(mvm); |
| 695 | |
| 696 | out: |
| 697 | mutex_unlock(&mvm->mutex); |
| 698 | return ret ?: count; |
| 699 | } |
| 700 | |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 701 | #define PRINT_STATS_LE32(_str, _val) \ |
| 702 | pos += scnprintf(buf + pos, bufsz - pos, \ |
| 703 | fmt_table, _str, \ |
| 704 | le32_to_cpu(_val)) |
| 705 | |
| 706 | static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file, |
| 707 | char __user *user_buf, size_t count, |
| 708 | loff_t *ppos) |
| 709 | { |
| 710 | struct iwl_mvm *mvm = file->private_data; |
| 711 | static const char *fmt_table = "\t%-30s %10u\n"; |
| 712 | static const char *fmt_header = "%-32s\n"; |
| 713 | int pos = 0; |
| 714 | char *buf; |
| 715 | int ret; |
Luciano Coelho | 3f61728 | 2013-10-14 13:18:41 +0300 | [diff] [blame] | 716 | /* 43 is the size of each data line, 33 is the size of each header */ |
| 717 | size_t bufsz = |
| 718 | ((sizeof(struct mvm_statistics_rx) / sizeof(__le32)) * 43) + |
| 719 | (4 * 33) + 1; |
| 720 | |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 721 | struct mvm_statistics_rx_phy *ofdm; |
| 722 | struct mvm_statistics_rx_phy *cck; |
| 723 | struct mvm_statistics_rx_non_phy *general; |
| 724 | struct mvm_statistics_rx_ht_phy *ht; |
| 725 | |
| 726 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 727 | if (!buf) |
| 728 | return -ENOMEM; |
| 729 | |
| 730 | mutex_lock(&mvm->mutex); |
| 731 | |
| 732 | ofdm = &mvm->rx_stats.ofdm; |
| 733 | cck = &mvm->rx_stats.cck; |
| 734 | general = &mvm->rx_stats.general; |
| 735 | ht = &mvm->rx_stats.ofdm_ht; |
| 736 | |
| 737 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, |
| 738 | "Statistics_Rx - OFDM"); |
| 739 | PRINT_STATS_LE32("ina_cnt", ofdm->ina_cnt); |
| 740 | PRINT_STATS_LE32("fina_cnt", ofdm->fina_cnt); |
| 741 | PRINT_STATS_LE32("plcp_err", ofdm->plcp_err); |
| 742 | PRINT_STATS_LE32("crc32_err", ofdm->crc32_err); |
| 743 | PRINT_STATS_LE32("overrun_err", ofdm->overrun_err); |
| 744 | PRINT_STATS_LE32("early_overrun_err", ofdm->early_overrun_err); |
| 745 | PRINT_STATS_LE32("crc32_good", ofdm->crc32_good); |
| 746 | PRINT_STATS_LE32("false_alarm_cnt", ofdm->false_alarm_cnt); |
| 747 | PRINT_STATS_LE32("fina_sync_err_cnt", ofdm->fina_sync_err_cnt); |
| 748 | PRINT_STATS_LE32("sfd_timeout", ofdm->sfd_timeout); |
| 749 | PRINT_STATS_LE32("fina_timeout", ofdm->fina_timeout); |
| 750 | PRINT_STATS_LE32("unresponded_rts", ofdm->unresponded_rts); |
| 751 | PRINT_STATS_LE32("rxe_frame_lmt_overrun", |
| 752 | ofdm->rxe_frame_limit_overrun); |
| 753 | PRINT_STATS_LE32("sent_ack_cnt", ofdm->sent_ack_cnt); |
| 754 | PRINT_STATS_LE32("sent_cts_cnt", ofdm->sent_cts_cnt); |
| 755 | PRINT_STATS_LE32("sent_ba_rsp_cnt", ofdm->sent_ba_rsp_cnt); |
| 756 | PRINT_STATS_LE32("dsp_self_kill", ofdm->dsp_self_kill); |
| 757 | PRINT_STATS_LE32("mh_format_err", ofdm->mh_format_err); |
| 758 | PRINT_STATS_LE32("re_acq_main_rssi_sum", ofdm->re_acq_main_rssi_sum); |
| 759 | PRINT_STATS_LE32("reserved", ofdm->reserved); |
| 760 | |
| 761 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, |
| 762 | "Statistics_Rx - CCK"); |
| 763 | PRINT_STATS_LE32("ina_cnt", cck->ina_cnt); |
| 764 | PRINT_STATS_LE32("fina_cnt", cck->fina_cnt); |
| 765 | PRINT_STATS_LE32("plcp_err", cck->plcp_err); |
| 766 | PRINT_STATS_LE32("crc32_err", cck->crc32_err); |
| 767 | PRINT_STATS_LE32("overrun_err", cck->overrun_err); |
| 768 | PRINT_STATS_LE32("early_overrun_err", cck->early_overrun_err); |
| 769 | PRINT_STATS_LE32("crc32_good", cck->crc32_good); |
| 770 | PRINT_STATS_LE32("false_alarm_cnt", cck->false_alarm_cnt); |
| 771 | PRINT_STATS_LE32("fina_sync_err_cnt", cck->fina_sync_err_cnt); |
| 772 | PRINT_STATS_LE32("sfd_timeout", cck->sfd_timeout); |
| 773 | PRINT_STATS_LE32("fina_timeout", cck->fina_timeout); |
| 774 | PRINT_STATS_LE32("unresponded_rts", cck->unresponded_rts); |
| 775 | PRINT_STATS_LE32("rxe_frame_lmt_overrun", |
| 776 | cck->rxe_frame_limit_overrun); |
| 777 | PRINT_STATS_LE32("sent_ack_cnt", cck->sent_ack_cnt); |
| 778 | PRINT_STATS_LE32("sent_cts_cnt", cck->sent_cts_cnt); |
| 779 | PRINT_STATS_LE32("sent_ba_rsp_cnt", cck->sent_ba_rsp_cnt); |
| 780 | PRINT_STATS_LE32("dsp_self_kill", cck->dsp_self_kill); |
| 781 | PRINT_STATS_LE32("mh_format_err", cck->mh_format_err); |
| 782 | PRINT_STATS_LE32("re_acq_main_rssi_sum", cck->re_acq_main_rssi_sum); |
| 783 | PRINT_STATS_LE32("reserved", cck->reserved); |
| 784 | |
| 785 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, |
| 786 | "Statistics_Rx - GENERAL"); |
| 787 | PRINT_STATS_LE32("bogus_cts", general->bogus_cts); |
| 788 | PRINT_STATS_LE32("bogus_ack", general->bogus_ack); |
| 789 | PRINT_STATS_LE32("non_bssid_frames", general->non_bssid_frames); |
| 790 | PRINT_STATS_LE32("filtered_frames", general->filtered_frames); |
| 791 | PRINT_STATS_LE32("non_channel_beacons", general->non_channel_beacons); |
| 792 | PRINT_STATS_LE32("channel_beacons", general->channel_beacons); |
| 793 | PRINT_STATS_LE32("num_missed_bcon", general->num_missed_bcon); |
| 794 | PRINT_STATS_LE32("adc_rx_saturation_time", |
| 795 | general->adc_rx_saturation_time); |
| 796 | PRINT_STATS_LE32("ina_detection_search_time", |
| 797 | general->ina_detection_search_time); |
| 798 | PRINT_STATS_LE32("beacon_silence_rssi_a", |
| 799 | general->beacon_silence_rssi_a); |
| 800 | PRINT_STATS_LE32("beacon_silence_rssi_b", |
| 801 | general->beacon_silence_rssi_b); |
| 802 | PRINT_STATS_LE32("beacon_silence_rssi_c", |
| 803 | general->beacon_silence_rssi_c); |
| 804 | PRINT_STATS_LE32("interference_data_flag", |
| 805 | general->interference_data_flag); |
| 806 | PRINT_STATS_LE32("channel_load", general->channel_load); |
| 807 | PRINT_STATS_LE32("dsp_false_alarms", general->dsp_false_alarms); |
| 808 | PRINT_STATS_LE32("beacon_rssi_a", general->beacon_rssi_a); |
| 809 | PRINT_STATS_LE32("beacon_rssi_b", general->beacon_rssi_b); |
| 810 | PRINT_STATS_LE32("beacon_rssi_c", general->beacon_rssi_c); |
| 811 | PRINT_STATS_LE32("beacon_energy_a", general->beacon_energy_a); |
| 812 | PRINT_STATS_LE32("beacon_energy_b", general->beacon_energy_b); |
| 813 | PRINT_STATS_LE32("beacon_energy_c", general->beacon_energy_c); |
| 814 | PRINT_STATS_LE32("num_bt_kills", general->num_bt_kills); |
Luciano Coelho | 3f61728 | 2013-10-14 13:18:41 +0300 | [diff] [blame] | 815 | PRINT_STATS_LE32("mac_id", general->mac_id); |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 816 | PRINT_STATS_LE32("directed_data_mpdu", general->directed_data_mpdu); |
| 817 | |
| 818 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, |
| 819 | "Statistics_Rx - HT"); |
| 820 | PRINT_STATS_LE32("plcp_err", ht->plcp_err); |
| 821 | PRINT_STATS_LE32("overrun_err", ht->overrun_err); |
| 822 | PRINT_STATS_LE32("early_overrun_err", ht->early_overrun_err); |
| 823 | PRINT_STATS_LE32("crc32_good", ht->crc32_good); |
| 824 | PRINT_STATS_LE32("crc32_err", ht->crc32_err); |
| 825 | PRINT_STATS_LE32("mh_format_err", ht->mh_format_err); |
| 826 | PRINT_STATS_LE32("agg_crc32_good", ht->agg_crc32_good); |
| 827 | PRINT_STATS_LE32("agg_mpdu_cnt", ht->agg_mpdu_cnt); |
| 828 | PRINT_STATS_LE32("agg_cnt", ht->agg_cnt); |
| 829 | PRINT_STATS_LE32("unsupport_mcs", ht->unsupport_mcs); |
| 830 | |
| 831 | mutex_unlock(&mvm->mutex); |
| 832 | |
| 833 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 834 | kfree(buf); |
| 835 | |
| 836 | return ret; |
| 837 | } |
| 838 | #undef PRINT_STAT_LE32 |
| 839 | |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 840 | static ssize_t iwl_dbgfs_frame_stats_read(struct iwl_mvm *mvm, |
| 841 | char __user *user_buf, size_t count, |
| 842 | loff_t *ppos, |
| 843 | struct iwl_mvm_frame_stats *stats) |
| 844 | { |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 845 | char *buff, *pos, *endpos; |
| 846 | int idx, i; |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 847 | int ret; |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 848 | static const size_t bufsz = 1024; |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 849 | |
| 850 | buff = kmalloc(bufsz, GFP_KERNEL); |
| 851 | if (!buff) |
| 852 | return -ENOMEM; |
| 853 | |
| 854 | spin_lock_bh(&mvm->drv_stats_lock); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 855 | |
| 856 | pos = buff; |
| 857 | endpos = pos + bufsz; |
| 858 | |
| 859 | pos += scnprintf(pos, endpos - pos, |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 860 | "Legacy/HT/VHT\t:\t%d/%d/%d\n", |
| 861 | stats->legacy_frames, |
| 862 | stats->ht_frames, |
| 863 | stats->vht_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 864 | 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] | 865 | stats->bw_20_frames, |
| 866 | stats->bw_40_frames, |
| 867 | stats->bw_80_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 868 | 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] | 869 | stats->ngi_frames, |
| 870 | stats->sgi_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 871 | pos += scnprintf(pos, endpos - pos, "SISO/MIMO2\t:\t%d/%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 872 | stats->siso_frames, |
| 873 | stats->mimo2_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 874 | pos += scnprintf(pos, endpos - pos, "FAIL/SCSS\t:\t%d/%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 875 | stats->fail_frames, |
| 876 | stats->success_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 877 | pos += scnprintf(pos, endpos - pos, "MPDUs agg\t:\t%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 878 | stats->agg_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 879 | pos += scnprintf(pos, endpos - pos, "A-MPDUs\t\t:\t%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 880 | stats->ampdu_count); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 881 | pos += scnprintf(pos, endpos - pos, "Avg MPDUs/A-MPDU:\t%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 882 | stats->ampdu_count > 0 ? |
| 883 | (stats->agg_frames / stats->ampdu_count) : 0); |
| 884 | |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 885 | pos += scnprintf(pos, endpos - pos, "Last Rates\n"); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 886 | |
| 887 | idx = stats->last_frame_idx - 1; |
| 888 | for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) { |
| 889 | idx = (idx + 1) % ARRAY_SIZE(stats->last_rates); |
| 890 | if (stats->last_rates[idx] == 0) |
| 891 | continue; |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 892 | pos += scnprintf(pos, endpos - pos, "Rate[%d]: ", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 893 | (int)(ARRAY_SIZE(stats->last_rates) - i)); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 894 | pos += rs_pretty_print_rate(pos, stats->last_rates[idx]); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 895 | } |
| 896 | spin_unlock_bh(&mvm->drv_stats_lock); |
| 897 | |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 898 | ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 899 | kfree(buff); |
| 900 | |
| 901 | return ret; |
| 902 | } |
| 903 | |
| 904 | static ssize_t iwl_dbgfs_drv_rx_stats_read(struct file *file, |
| 905 | char __user *user_buf, size_t count, |
| 906 | loff_t *ppos) |
| 907 | { |
| 908 | struct iwl_mvm *mvm = file->private_data; |
| 909 | |
| 910 | return iwl_dbgfs_frame_stats_read(mvm, user_buf, count, ppos, |
| 911 | &mvm->drv_rx_stats); |
| 912 | } |
| 913 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 914 | 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] | 915 | size_t count, loff_t *ppos) |
| 916 | { |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 917 | int ret; |
| 918 | |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 919 | mutex_lock(&mvm->mutex); |
| 920 | |
Eran Harary | 291aa7c | 2013-07-03 11:00:06 +0300 | [diff] [blame] | 921 | /* allow one more restart that we're provoking here */ |
| 922 | if (mvm->restart_fw >= 0) |
| 923 | mvm->restart_fw++; |
| 924 | |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 925 | /* take the return value to make compiler happy - it will fail anyway */ |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 926 | ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_ERROR, 0, 0, NULL); |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 927 | |
| 928 | mutex_unlock(&mvm->mutex); |
| 929 | |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 930 | return count; |
| 931 | } |
| 932 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 933 | 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] | 934 | size_t count, loff_t *ppos) |
| 935 | { |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 936 | int ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_NMI); |
| 937 | if (ret) |
| 938 | return ret; |
| 939 | |
Liad Kaufman | 4c9706d | 2014-04-27 16:46:09 +0300 | [diff] [blame] | 940 | iwl_force_nmi(mvm->trans); |
Alexander Bondar | 119663c | 2013-10-17 14:26:50 +0200 | [diff] [blame] | 941 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 942 | iwl_mvm_unref(mvm, IWL_MVM_REF_NMI); |
| 943 | |
Alexander Bondar | 119663c | 2013-10-17 14:26:50 +0200 | [diff] [blame] | 944 | return count; |
| 945 | } |
| 946 | |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 947 | static ssize_t |
| 948 | iwl_dbgfs_scan_ant_rxchain_read(struct file *file, |
| 949 | char __user *user_buf, |
| 950 | size_t count, loff_t *ppos) |
| 951 | { |
| 952 | struct iwl_mvm *mvm = file->private_data; |
| 953 | int pos = 0; |
| 954 | char buf[32]; |
| 955 | const size_t bufsz = sizeof(buf); |
| 956 | |
| 957 | /* print which antennas were set for the scan command by the user */ |
| 958 | pos += scnprintf(buf + pos, bufsz - pos, "Antennas for scan: "); |
| 959 | if (mvm->scan_rx_ant & ANT_A) |
| 960 | pos += scnprintf(buf + pos, bufsz - pos, "A"); |
| 961 | if (mvm->scan_rx_ant & ANT_B) |
| 962 | pos += scnprintf(buf + pos, bufsz - pos, "B"); |
| 963 | if (mvm->scan_rx_ant & ANT_C) |
| 964 | pos += scnprintf(buf + pos, bufsz - pos, "C"); |
| 965 | pos += scnprintf(buf + pos, bufsz - pos, " (%hhx)\n", mvm->scan_rx_ant); |
| 966 | |
| 967 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 968 | } |
| 969 | |
| 970 | static ssize_t |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 971 | iwl_dbgfs_scan_ant_rxchain_write(struct iwl_mvm *mvm, char *buf, |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 972 | size_t count, loff_t *ppos) |
| 973 | { |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 974 | u8 scan_rx_ant; |
| 975 | |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 976 | if (sscanf(buf, "%hhx", &scan_rx_ant) != 1) |
| 977 | return -EINVAL; |
| 978 | if (scan_rx_ant > ANT_ABC) |
| 979 | return -EINVAL; |
Johannes Berg | 4ed735e | 2014-02-12 21:47:44 +0100 | [diff] [blame] | 980 | if (scan_rx_ant & ~mvm->fw->valid_rx_ant) |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 981 | return -EINVAL; |
| 982 | |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 983 | mvm->scan_rx_ant = scan_rx_ant; |
| 984 | |
| 985 | return count; |
| 986 | } |
| 987 | |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 988 | #define ADD_TEXT(...) pos += scnprintf(buf + pos, bufsz - pos, __VA_ARGS__) |
| 989 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
| 990 | static ssize_t iwl_dbgfs_bcast_filters_read(struct file *file, |
| 991 | char __user *user_buf, |
| 992 | size_t count, loff_t *ppos) |
| 993 | { |
| 994 | struct iwl_mvm *mvm = file->private_data; |
| 995 | struct iwl_bcast_filter_cmd cmd; |
| 996 | const struct iwl_fw_bcast_filter *filter; |
| 997 | char *buf; |
| 998 | int bufsz = 1024; |
| 999 | int i, j, pos = 0; |
| 1000 | ssize_t ret; |
| 1001 | |
| 1002 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1003 | if (!buf) |
| 1004 | return -ENOMEM; |
| 1005 | |
| 1006 | mutex_lock(&mvm->mutex); |
| 1007 | if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) { |
| 1008 | ADD_TEXT("None\n"); |
| 1009 | mutex_unlock(&mvm->mutex); |
| 1010 | goto out; |
| 1011 | } |
| 1012 | mutex_unlock(&mvm->mutex); |
| 1013 | |
| 1014 | for (i = 0; cmd.filters[i].attrs[0].mask; i++) { |
| 1015 | filter = &cmd.filters[i]; |
| 1016 | |
| 1017 | ADD_TEXT("Filter [%d]:\n", i); |
| 1018 | ADD_TEXT("\tDiscard=%d\n", filter->discard); |
| 1019 | ADD_TEXT("\tFrame Type: %s\n", |
| 1020 | filter->frame_type ? "IPv4" : "Generic"); |
| 1021 | |
| 1022 | for (j = 0; j < ARRAY_SIZE(filter->attrs); j++) { |
| 1023 | const struct iwl_fw_bcast_filter_attr *attr; |
| 1024 | |
| 1025 | attr = &filter->attrs[j]; |
| 1026 | if (!attr->mask) |
| 1027 | break; |
| 1028 | |
| 1029 | ADD_TEXT("\tAttr [%d]: offset=%d (from %s), mask=0x%x, value=0x%x reserved=0x%x\n", |
| 1030 | j, attr->offset, |
| 1031 | attr->offset_type ? "IP End" : |
| 1032 | "Payload Start", |
| 1033 | be32_to_cpu(attr->mask), |
| 1034 | be32_to_cpu(attr->val), |
| 1035 | le16_to_cpu(attr->reserved1)); |
| 1036 | } |
| 1037 | } |
| 1038 | out: |
| 1039 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1040 | kfree(buf); |
| 1041 | return ret; |
| 1042 | } |
| 1043 | |
| 1044 | static ssize_t iwl_dbgfs_bcast_filters_write(struct iwl_mvm *mvm, char *buf, |
| 1045 | size_t count, loff_t *ppos) |
| 1046 | { |
| 1047 | int pos, next_pos; |
| 1048 | struct iwl_fw_bcast_filter filter = {}; |
| 1049 | struct iwl_bcast_filter_cmd cmd; |
| 1050 | u32 filter_id, attr_id, mask, value; |
| 1051 | int err = 0; |
| 1052 | |
| 1053 | if (sscanf(buf, "%d %hhi %hhi %n", &filter_id, &filter.discard, |
| 1054 | &filter.frame_type, &pos) != 3) |
| 1055 | return -EINVAL; |
| 1056 | |
| 1057 | if (filter_id >= ARRAY_SIZE(mvm->dbgfs_bcast_filtering.cmd.filters) || |
| 1058 | filter.frame_type > BCAST_FILTER_FRAME_TYPE_IPV4) |
| 1059 | return -EINVAL; |
| 1060 | |
| 1061 | for (attr_id = 0; attr_id < ARRAY_SIZE(filter.attrs); |
| 1062 | attr_id++) { |
| 1063 | struct iwl_fw_bcast_filter_attr *attr = |
| 1064 | &filter.attrs[attr_id]; |
| 1065 | |
| 1066 | if (pos >= count) |
| 1067 | break; |
| 1068 | |
| 1069 | if (sscanf(&buf[pos], "%hhi %hhi %i %i %n", |
| 1070 | &attr->offset, &attr->offset_type, |
| 1071 | &mask, &value, &next_pos) != 4) |
| 1072 | return -EINVAL; |
| 1073 | |
| 1074 | attr->mask = cpu_to_be32(mask); |
| 1075 | attr->val = cpu_to_be32(value); |
| 1076 | if (mask) |
| 1077 | filter.num_attrs++; |
| 1078 | |
| 1079 | pos += next_pos; |
| 1080 | } |
| 1081 | |
| 1082 | mutex_lock(&mvm->mutex); |
| 1083 | memcpy(&mvm->dbgfs_bcast_filtering.cmd.filters[filter_id], |
| 1084 | &filter, sizeof(filter)); |
| 1085 | |
| 1086 | /* send updated bcast filtering configuration */ |
| 1087 | if (mvm->dbgfs_bcast_filtering.override && |
| 1088 | iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 1089 | err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0, |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1090 | sizeof(cmd), &cmd); |
| 1091 | mutex_unlock(&mvm->mutex); |
| 1092 | |
| 1093 | return err ?: count; |
| 1094 | } |
| 1095 | |
| 1096 | static ssize_t iwl_dbgfs_bcast_filters_macs_read(struct file *file, |
| 1097 | char __user *user_buf, |
| 1098 | size_t count, loff_t *ppos) |
| 1099 | { |
| 1100 | struct iwl_mvm *mvm = file->private_data; |
| 1101 | struct iwl_bcast_filter_cmd cmd; |
| 1102 | char *buf; |
| 1103 | int bufsz = 1024; |
| 1104 | int i, pos = 0; |
| 1105 | ssize_t ret; |
| 1106 | |
| 1107 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1108 | if (!buf) |
| 1109 | return -ENOMEM; |
| 1110 | |
| 1111 | mutex_lock(&mvm->mutex); |
| 1112 | if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) { |
| 1113 | ADD_TEXT("None\n"); |
| 1114 | mutex_unlock(&mvm->mutex); |
| 1115 | goto out; |
| 1116 | } |
| 1117 | mutex_unlock(&mvm->mutex); |
| 1118 | |
| 1119 | for (i = 0; i < ARRAY_SIZE(cmd.macs); i++) { |
| 1120 | const struct iwl_fw_bcast_mac *mac = &cmd.macs[i]; |
| 1121 | |
| 1122 | ADD_TEXT("Mac [%d]: discard=%d attached_filters=0x%x\n", |
| 1123 | i, mac->default_discard, mac->attached_filters); |
| 1124 | } |
| 1125 | out: |
| 1126 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1127 | kfree(buf); |
| 1128 | return ret; |
| 1129 | } |
| 1130 | |
| 1131 | static ssize_t iwl_dbgfs_bcast_filters_macs_write(struct iwl_mvm *mvm, |
| 1132 | char *buf, size_t count, |
| 1133 | loff_t *ppos) |
| 1134 | { |
| 1135 | struct iwl_bcast_filter_cmd cmd; |
| 1136 | struct iwl_fw_bcast_mac mac = {}; |
| 1137 | u32 mac_id, attached_filters; |
| 1138 | int err = 0; |
| 1139 | |
| 1140 | if (!mvm->bcast_filters) |
| 1141 | return -ENOENT; |
| 1142 | |
| 1143 | if (sscanf(buf, "%d %hhi %i", &mac_id, &mac.default_discard, |
| 1144 | &attached_filters) != 3) |
| 1145 | return -EINVAL; |
| 1146 | |
| 1147 | if (mac_id >= ARRAY_SIZE(cmd.macs) || |
| 1148 | mac.default_discard > 1 || |
| 1149 | attached_filters >= BIT(ARRAY_SIZE(cmd.filters))) |
| 1150 | return -EINVAL; |
| 1151 | |
| 1152 | mac.attached_filters = cpu_to_le16(attached_filters); |
| 1153 | |
| 1154 | mutex_lock(&mvm->mutex); |
| 1155 | memcpy(&mvm->dbgfs_bcast_filtering.cmd.macs[mac_id], |
| 1156 | &mac, sizeof(mac)); |
| 1157 | |
| 1158 | /* send updated bcast filtering configuration */ |
| 1159 | if (mvm->dbgfs_bcast_filtering.override && |
| 1160 | iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 1161 | err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0, |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1162 | sizeof(cmd), &cmd); |
| 1163 | mutex_unlock(&mvm->mutex); |
| 1164 | |
| 1165 | return err ?: count; |
| 1166 | } |
| 1167 | #endif |
| 1168 | |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1169 | #ifdef CONFIG_PM_SLEEP |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1170 | 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] | 1171 | size_t count, loff_t *ppos) |
| 1172 | { |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1173 | int store; |
| 1174 | |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1175 | if (sscanf(buf, "%d", &store) != 1) |
| 1176 | return -EINVAL; |
| 1177 | |
| 1178 | mvm->store_d3_resume_sram = store; |
| 1179 | |
| 1180 | return count; |
| 1181 | } |
| 1182 | |
| 1183 | static ssize_t iwl_dbgfs_d3_sram_read(struct file *file, char __user *user_buf, |
| 1184 | size_t count, loff_t *ppos) |
| 1185 | { |
| 1186 | struct iwl_mvm *mvm = file->private_data; |
| 1187 | const struct fw_img *img; |
| 1188 | int ofs, len, pos = 0; |
| 1189 | size_t bufsz, ret; |
| 1190 | char *buf; |
| 1191 | u8 *ptr = mvm->d3_resume_sram; |
| 1192 | |
| 1193 | img = &mvm->fw->img[IWL_UCODE_WOWLAN]; |
| 1194 | len = img->sec[IWL_UCODE_SECTION_DATA].len; |
| 1195 | |
| 1196 | bufsz = len * 4 + 256; |
| 1197 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1198 | if (!buf) |
| 1199 | return -ENOMEM; |
| 1200 | |
| 1201 | pos += scnprintf(buf, bufsz, "D3 SRAM capture: %sabled\n", |
| 1202 | mvm->store_d3_resume_sram ? "en" : "dis"); |
| 1203 | |
| 1204 | if (ptr) { |
| 1205 | for (ofs = 0; ofs < len; ofs += 16) { |
| 1206 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1207 | "0x%.4x ", ofs); |
| 1208 | hex_dump_to_buffer(ptr + ofs, 16, 16, 1, buf + pos, |
| 1209 | bufsz - pos, false); |
| 1210 | pos += strlen(buf + pos); |
| 1211 | if (bufsz - pos > 0) |
| 1212 | buf[pos++] = '\n'; |
| 1213 | } |
| 1214 | } else { |
| 1215 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1216 | "(no data captured)\n"); |
| 1217 | } |
| 1218 | |
| 1219 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1220 | |
| 1221 | kfree(buf); |
| 1222 | |
| 1223 | return ret; |
| 1224 | } |
| 1225 | #endif |
| 1226 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1227 | #define PRINT_MVM_REF(ref) do { \ |
| 1228 | if (mvm->refs[ref]) \ |
| 1229 | pos += scnprintf(buf + pos, bufsz - pos, \ |
| 1230 | "\t(0x%lx): %d %s\n", \ |
| 1231 | BIT(ref), mvm->refs[ref], #ref); \ |
Eliad Peller | 70d6bab | 2013-11-05 14:45:16 +0200 | [diff] [blame] | 1232 | } while (0) |
| 1233 | |
| 1234 | static ssize_t iwl_dbgfs_d0i3_refs_read(struct file *file, |
| 1235 | char __user *user_buf, |
| 1236 | size_t count, loff_t *ppos) |
| 1237 | { |
| 1238 | struct iwl_mvm *mvm = file->private_data; |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1239 | int i, pos = 0; |
Eliad Peller | 70d6bab | 2013-11-05 14:45:16 +0200 | [diff] [blame] | 1240 | char buf[256]; |
| 1241 | const size_t bufsz = sizeof(buf); |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1242 | u32 refs = 0; |
Eliad Peller | 70d6bab | 2013-11-05 14:45:16 +0200 | [diff] [blame] | 1243 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1244 | for (i = 0; i < IWL_MVM_REF_COUNT; i++) |
| 1245 | if (mvm->refs[i]) |
| 1246 | refs |= BIT(i); |
| 1247 | |
| 1248 | pos += scnprintf(buf + pos, bufsz - pos, "taken mvm refs: 0x%x\n", |
| 1249 | refs); |
Eliad Peller | 70d6bab | 2013-11-05 14:45:16 +0200 | [diff] [blame] | 1250 | |
| 1251 | PRINT_MVM_REF(IWL_MVM_REF_UCODE_DOWN); |
| 1252 | PRINT_MVM_REF(IWL_MVM_REF_SCAN); |
| 1253 | PRINT_MVM_REF(IWL_MVM_REF_ROC); |
| 1254 | PRINT_MVM_REF(IWL_MVM_REF_P2P_CLIENT); |
| 1255 | PRINT_MVM_REF(IWL_MVM_REF_AP_IBSS); |
Eliad Peller | 0eb8365 | 2013-11-11 18:56:35 +0200 | [diff] [blame] | 1256 | PRINT_MVM_REF(IWL_MVM_REF_USER); |
Eliad Peller | d15a747 | 2014-03-27 18:53:12 +0200 | [diff] [blame] | 1257 | PRINT_MVM_REF(IWL_MVM_REF_EXIT_WORK); |
Eliad Peller | 70d6bab | 2013-11-05 14:45:16 +0200 | [diff] [blame] | 1258 | |
| 1259 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1260 | } |
| 1261 | |
Eliad Peller | 0eb8365 | 2013-11-11 18:56:35 +0200 | [diff] [blame] | 1262 | static ssize_t iwl_dbgfs_d0i3_refs_write(struct iwl_mvm *mvm, char *buf, |
| 1263 | size_t count, loff_t *ppos) |
| 1264 | { |
| 1265 | unsigned long value; |
| 1266 | int ret; |
| 1267 | bool taken; |
| 1268 | |
| 1269 | ret = kstrtoul(buf, 10, &value); |
| 1270 | if (ret < 0) |
| 1271 | return ret; |
| 1272 | |
| 1273 | mutex_lock(&mvm->mutex); |
| 1274 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1275 | taken = mvm->refs[IWL_MVM_REF_USER]; |
Eliad Peller | 0eb8365 | 2013-11-11 18:56:35 +0200 | [diff] [blame] | 1276 | if (value == 1 && !taken) |
| 1277 | iwl_mvm_ref(mvm, IWL_MVM_REF_USER); |
| 1278 | else if (value == 0 && taken) |
| 1279 | iwl_mvm_unref(mvm, IWL_MVM_REF_USER); |
| 1280 | else |
| 1281 | ret = -EINVAL; |
| 1282 | |
| 1283 | mutex_unlock(&mvm->mutex); |
| 1284 | |
| 1285 | if (ret < 0) |
| 1286 | return ret; |
| 1287 | return count; |
| 1288 | } |
| 1289 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1290 | #define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \ |
| 1291 | _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm) |
| 1292 | #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz) \ |
| 1293 | _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm) |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1294 | #define MVM_DEBUGFS_ADD_FILE_ALIAS(alias, name, parent, mode) do { \ |
| 1295 | if (!debugfs_create_file(alias, mode, parent, mvm, \ |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1296 | &iwl_dbgfs_##name##_ops)) \ |
| 1297 | goto err; \ |
| 1298 | } while (0) |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1299 | #define MVM_DEBUGFS_ADD_FILE(name, parent, mode) \ |
| 1300 | MVM_DEBUGFS_ADD_FILE_ALIAS(#name, name, parent, mode) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1301 | |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1302 | static ssize_t |
| 1303 | iwl_dbgfs_prph_reg_read(struct file *file, |
| 1304 | char __user *user_buf, |
| 1305 | size_t count, loff_t *ppos) |
| 1306 | { |
| 1307 | struct iwl_mvm *mvm = file->private_data; |
| 1308 | int pos = 0; |
| 1309 | char buf[32]; |
| 1310 | const size_t bufsz = sizeof(buf); |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1311 | int ret; |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1312 | |
| 1313 | if (!mvm->dbgfs_prph_reg_addr) |
| 1314 | return -EINVAL; |
| 1315 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1316 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_READ); |
| 1317 | if (ret) |
| 1318 | return ret; |
| 1319 | |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1320 | pos += scnprintf(buf + pos, bufsz - pos, "Reg 0x%x: (0x%x)\n", |
| 1321 | mvm->dbgfs_prph_reg_addr, |
| 1322 | iwl_read_prph(mvm->trans, mvm->dbgfs_prph_reg_addr)); |
| 1323 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1324 | iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_READ); |
| 1325 | |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1326 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1327 | } |
| 1328 | |
| 1329 | static ssize_t |
| 1330 | iwl_dbgfs_prph_reg_write(struct iwl_mvm *mvm, char *buf, |
| 1331 | size_t count, loff_t *ppos) |
| 1332 | { |
| 1333 | u8 args; |
| 1334 | u32 value; |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1335 | int ret; |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1336 | |
| 1337 | args = sscanf(buf, "%i %i", &mvm->dbgfs_prph_reg_addr, &value); |
| 1338 | /* if we only want to set the reg address - nothing more to do */ |
| 1339 | if (args == 1) |
| 1340 | goto out; |
| 1341 | |
| 1342 | /* otherwise, make sure we have both address and value */ |
| 1343 | if (args != 2) |
| 1344 | return -EINVAL; |
| 1345 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1346 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE); |
| 1347 | if (ret) |
| 1348 | return ret; |
| 1349 | |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1350 | iwl_write_prph(mvm->trans, mvm->dbgfs_prph_reg_addr, value); |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1351 | |
| 1352 | iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE); |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1353 | out: |
| 1354 | return count; |
| 1355 | } |
| 1356 | |
| 1357 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(prph_reg, 64); |
| 1358 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1359 | /* Device wide debugfs entries */ |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1360 | MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush, 16); |
| 1361 | MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain, 8); |
| 1362 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram, 64); |
Matti Gottlieb | 7280d1f | 2014-07-17 16:41:14 +0300 | [diff] [blame] | 1363 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(set_nic_temperature, 64); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1364 | MVM_DEBUGFS_READ_FILE_OPS(stations); |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 1365 | MVM_DEBUGFS_READ_FILE_OPS(bt_notif); |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 1366 | MVM_DEBUGFS_READ_FILE_OPS(bt_cmd); |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1367 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(disable_power_off, 64); |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 1368 | MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 1369 | MVM_DEBUGFS_READ_FILE_OPS(drv_rx_stats); |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1370 | MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart, 10); |
| 1371 | MVM_DEBUGFS_WRITE_FILE_OPS(fw_nmi, 10); |
Emmanuel Grumbach | cdb0056 | 2014-03-16 21:55:43 +0200 | [diff] [blame] | 1372 | MVM_DEBUGFS_WRITE_FILE_OPS(bt_tx_prio, 10); |
Emmanuel Grumbach | a39979a | 2014-05-28 12:06:41 +0300 | [diff] [blame] | 1373 | MVM_DEBUGFS_WRITE_FILE_OPS(bt_force_ant, 10); |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1374 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain, 8); |
Eliad Peller | 0eb8365 | 2013-11-11 18:56:35 +0200 | [diff] [blame] | 1375 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(d0i3_refs, 8); |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 1376 | |
Emmanuel Grumbach | 1bd3cbc | 2014-03-18 21:15:06 +0200 | [diff] [blame] | 1377 | static const struct file_operations iwl_dbgfs_fw_error_dump_ops = { |
Emmanuel Grumbach | 3a58d98e | 2014-04-13 09:38:48 +0300 | [diff] [blame] | 1378 | .open = iwl_dbgfs_fw_error_dump_open, |
| 1379 | .read = iwl_dbgfs_fw_error_dump_read, |
| 1380 | .release = iwl_dbgfs_fw_error_dump_release, |
Emmanuel Grumbach | 1bd3cbc | 2014-03-18 21:15:06 +0200 | [diff] [blame] | 1381 | }; |
| 1382 | |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1383 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
| 1384 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256); |
| 1385 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters_macs, 256); |
| 1386 | #endif |
| 1387 | |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1388 | #ifdef CONFIG_PM_SLEEP |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1389 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram, 8); |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1390 | #endif |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1391 | |
| 1392 | int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir) |
| 1393 | { |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1394 | struct dentry *bcast_dir __maybe_unused; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1395 | char buf[100]; |
| 1396 | |
Johannes Berg | d07913a | 2014-02-26 11:25:58 +0100 | [diff] [blame] | 1397 | spin_lock_init(&mvm->drv_stats_lock); |
| 1398 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1399 | mvm->debugfs_dir = dbgfs_dir; |
| 1400 | |
| 1401 | MVM_DEBUGFS_ADD_FILE(tx_flush, mvm->debugfs_dir, S_IWUSR); |
| 1402 | MVM_DEBUGFS_ADD_FILE(sta_drain, mvm->debugfs_dir, S_IWUSR); |
| 1403 | MVM_DEBUGFS_ADD_FILE(sram, mvm->debugfs_dir, S_IWUSR | S_IRUSR); |
Matti Gottlieb | 7280d1f | 2014-07-17 16:41:14 +0300 | [diff] [blame] | 1404 | MVM_DEBUGFS_ADD_FILE(set_nic_temperature, mvm->debugfs_dir, |
| 1405 | S_IWUSR | S_IRUSR); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1406 | MVM_DEBUGFS_ADD_FILE(stations, dbgfs_dir, S_IRUSR); |
Emmanuel Grumbach | 1bd3cbc | 2014-03-18 21:15:06 +0200 | [diff] [blame] | 1407 | MVM_DEBUGFS_ADD_FILE(fw_error_dump, dbgfs_dir, S_IRUSR); |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 1408 | MVM_DEBUGFS_ADD_FILE(bt_notif, dbgfs_dir, S_IRUSR); |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 1409 | MVM_DEBUGFS_ADD_FILE(bt_cmd, dbgfs_dir, S_IRUSR); |
Emmanuel Grumbach | 639eaba | 2014-03-30 10:11:13 +0300 | [diff] [blame] | 1410 | MVM_DEBUGFS_ADD_FILE(disable_power_off, mvm->debugfs_dir, |
| 1411 | S_IRUSR | S_IWUSR); |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 1412 | MVM_DEBUGFS_ADD_FILE(fw_rx_stats, mvm->debugfs_dir, S_IRUSR); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 1413 | MVM_DEBUGFS_ADD_FILE(drv_rx_stats, mvm->debugfs_dir, S_IRUSR); |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 1414 | MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, S_IWUSR); |
Alexander Bondar | 119663c | 2013-10-17 14:26:50 +0200 | [diff] [blame] | 1415 | MVM_DEBUGFS_ADD_FILE(fw_nmi, mvm->debugfs_dir, S_IWUSR); |
Emmanuel Grumbach | cdb0056 | 2014-03-16 21:55:43 +0200 | [diff] [blame] | 1416 | MVM_DEBUGFS_ADD_FILE(bt_tx_prio, mvm->debugfs_dir, S_IWUSR); |
Emmanuel Grumbach | a39979a | 2014-05-28 12:06:41 +0300 | [diff] [blame] | 1417 | MVM_DEBUGFS_ADD_FILE(bt_force_ant, mvm->debugfs_dir, S_IWUSR); |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 1418 | MVM_DEBUGFS_ADD_FILE(scan_ant_rxchain, mvm->debugfs_dir, |
| 1419 | S_IWUSR | S_IRUSR); |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1420 | 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] | 1421 | 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] | 1422 | |
| 1423 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
| 1424 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING) { |
| 1425 | bcast_dir = debugfs_create_dir("bcast_filtering", |
| 1426 | mvm->debugfs_dir); |
| 1427 | if (!bcast_dir) |
| 1428 | goto err; |
| 1429 | |
| 1430 | if (!debugfs_create_bool("override", S_IRUSR | S_IWUSR, |
| 1431 | bcast_dir, |
| 1432 | &mvm->dbgfs_bcast_filtering.override)) |
| 1433 | goto err; |
| 1434 | |
| 1435 | MVM_DEBUGFS_ADD_FILE_ALIAS("filters", bcast_filters, |
| 1436 | bcast_dir, S_IWUSR | S_IRUSR); |
| 1437 | MVM_DEBUGFS_ADD_FILE_ALIAS("macs", bcast_filters_macs, |
| 1438 | bcast_dir, S_IWUSR | S_IRUSR); |
| 1439 | } |
| 1440 | #endif |
| 1441 | |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1442 | #ifdef CONFIG_PM_SLEEP |
| 1443 | 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] | 1444 | MVM_DEBUGFS_ADD_FILE(d3_test, mvm->debugfs_dir, S_IRUSR); |
Johannes Berg | b011471 | 2013-06-12 14:55:40 +0200 | [diff] [blame] | 1445 | if (!debugfs_create_bool("d3_wake_sysassert", S_IRUSR | S_IWUSR, |
| 1446 | mvm->debugfs_dir, &mvm->d3_wake_sysassert)) |
| 1447 | goto err; |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1448 | #endif |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1449 | |
Eyal Shapira | 9ecd051 | 2014-08-28 02:21:05 +0300 | [diff] [blame^] | 1450 | if (!debugfs_create_u8("low_latency_agg_frame_limit", S_IRUSR | S_IWUSR, |
| 1451 | mvm->debugfs_dir, |
| 1452 | &mvm->low_latency_agg_frame_limit)) |
| 1453 | goto err; |
Luciano Coelho | bdd5483 | 2014-08-07 18:08:56 +0300 | [diff] [blame] | 1454 | if (!debugfs_create_u8("ps_disabled", S_IRUSR, |
| 1455 | mvm->debugfs_dir, &mvm->ps_disabled)) |
| 1456 | goto err; |
Emmanuel Grumbach | 086f736 | 2013-11-18 17:00:03 +0200 | [diff] [blame] | 1457 | if (!debugfs_create_blob("nvm_hw", S_IRUSR, |
| 1458 | mvm->debugfs_dir, &mvm->nvm_hw_blob)) |
| 1459 | goto err; |
| 1460 | if (!debugfs_create_blob("nvm_sw", S_IRUSR, |
| 1461 | mvm->debugfs_dir, &mvm->nvm_sw_blob)) |
| 1462 | goto err; |
| 1463 | if (!debugfs_create_blob("nvm_calib", S_IRUSR, |
| 1464 | mvm->debugfs_dir, &mvm->nvm_calib_blob)) |
| 1465 | goto err; |
| 1466 | if (!debugfs_create_blob("nvm_prod", S_IRUSR, |
| 1467 | mvm->debugfs_dir, &mvm->nvm_prod_blob)) |
| 1468 | goto err; |
| 1469 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1470 | /* |
| 1471 | * Create a symlink with mac80211. It will be removed when mac80211 |
| 1472 | * exists (before the opmode exists which removes the target.) |
| 1473 | */ |
| 1474 | snprintf(buf, 100, "../../%s/%s", |
| 1475 | dbgfs_dir->d_parent->d_parent->d_name.name, |
| 1476 | dbgfs_dir->d_parent->d_name.name); |
| 1477 | if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf)) |
| 1478 | goto err; |
| 1479 | |
| 1480 | return 0; |
| 1481 | err: |
| 1482 | IWL_ERR(mvm, "Can't create the mvm debugfs directory\n"); |
| 1483 | return -ENOMEM; |
| 1484 | } |