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. |
Eliad Peller | c779273 | 2015-04-19 11:41:04 +0300 | [diff] [blame] | 9 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH |
Johannes Berg | aab6930 | 2017-03-22 22:05:12 +0100 | [diff] [blame] | 10 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of version 2 of the GNU General Public License as |
| 14 | * published by the Free Software Foundation. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, but |
| 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 | * General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, |
| 24 | * USA |
| 25 | * |
| 26 | * The full GNU General Public License is included in this distribution |
Emmanuel Grumbach | 410dc5a | 2013-02-18 09:22:28 +0200 | [diff] [blame] | 27 | * in the file called COPYING. |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 28 | * |
| 29 | * Contact Information: |
Emmanuel Grumbach | cb2f827 | 2015-11-17 15:39:56 +0200 | [diff] [blame] | 30 | * Intel Linux Wireless <linuxwifi@intel.com> |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 31 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 32 | * |
| 33 | * BSD LICENSE |
| 34 | * |
Emmanuel Grumbach | 51368bf | 2013-12-30 13:15:54 +0200 | [diff] [blame] | 35 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
Eliad Peller | c779273 | 2015-04-19 11:41:04 +0300 | [diff] [blame] | 36 | * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH |
Johannes Berg | aab6930 | 2017-03-22 22:05:12 +0100 | [diff] [blame] | 37 | * Copyright(c) 2016 - 2017 Intel Deutschland GmbH |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 38 | * All rights reserved. |
| 39 | * |
| 40 | * Redistribution and use in source and binary forms, with or without |
| 41 | * modification, are permitted provided that the following conditions |
| 42 | * are met: |
| 43 | * |
| 44 | * * Redistributions of source code must retain the above copyright |
| 45 | * notice, this list of conditions and the following disclaimer. |
| 46 | * * Redistributions in binary form must reproduce the above copyright |
| 47 | * notice, this list of conditions and the following disclaimer in |
| 48 | * the documentation and/or other materials provided with the |
| 49 | * distribution. |
| 50 | * * Neither the name Intel Corporation nor the names of its |
| 51 | * contributors may be used to endorse or promote products derived |
| 52 | * from this software without specific prior written permission. |
| 53 | * |
| 54 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 55 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 56 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 57 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 58 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 59 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 60 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 61 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 62 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 63 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 64 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 65 | * |
| 66 | *****************************************************************************/ |
Emmanuel Grumbach | 192c80a | 2014-03-19 08:25:05 +0200 | [diff] [blame] | 67 | #include <linux/vmalloc.h> |
Emmanuel Grumbach | 9e7dce2 | 2015-10-26 16:14:06 +0200 | [diff] [blame] | 68 | #include <linux/ieee80211.h> |
Sara Sharon | 854d773 | 2016-03-22 15:55:58 +0200 | [diff] [blame] | 69 | #include <linux/netdevice.h> |
Emmanuel Grumbach | 192c80a | 2014-03-19 08:25:05 +0200 | [diff] [blame] | 70 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 71 | #include "mvm.h" |
| 72 | #include "sta.h" |
| 73 | #include "iwl-io.h" |
Johannes Berg | 820a1a5 | 2013-11-12 16:58:41 +0100 | [diff] [blame] | 74 | #include "debugfs.h" |
Johannes Berg | d962f9b | 2017-06-01 10:22:09 +0200 | [diff] [blame] | 75 | #include "fw/error-dump.h" |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 76 | |
Chaya Rachel Ivgi | 00f481b | 2016-02-24 12:19:22 +0200 | [diff] [blame] | 77 | static ssize_t iwl_dbgfs_ctdp_budget_read(struct file *file, |
| 78 | char __user *user_buf, |
| 79 | size_t count, loff_t *ppos) |
| 80 | { |
| 81 | struct iwl_mvm *mvm = file->private_data; |
| 82 | char buf[16]; |
| 83 | int pos, budget; |
| 84 | |
Matt Chen | 0bef1b8 | 2017-06-23 17:50:18 +0800 | [diff] [blame] | 85 | if (!iwl_mvm_is_ctdp_supported(mvm)) |
| 86 | return -EOPNOTSUPP; |
| 87 | |
Johannes Berg | aab6930 | 2017-03-22 22:05:12 +0100 | [diff] [blame] | 88 | if (!iwl_mvm_firmware_running(mvm) || |
Johannes Berg | 702e975 | 2017-06-02 11:56:58 +0200 | [diff] [blame] | 89 | mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) |
Chaya Rachel Ivgi | 00f481b | 2016-02-24 12:19:22 +0200 | [diff] [blame] | 90 | return -EIO; |
| 91 | |
| 92 | mutex_lock(&mvm->mutex); |
| 93 | budget = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_REPORT, 0); |
| 94 | mutex_unlock(&mvm->mutex); |
| 95 | |
| 96 | if (budget < 0) |
| 97 | return budget; |
| 98 | |
| 99 | pos = scnprintf(buf, sizeof(buf), "%d\n", budget); |
| 100 | |
| 101 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 102 | } |
| 103 | |
| 104 | static ssize_t iwl_dbgfs_stop_ctdp_write(struct iwl_mvm *mvm, char *buf, |
| 105 | size_t count, loff_t *ppos) |
| 106 | { |
| 107 | int ret; |
| 108 | |
Matt Chen | 0bef1b8 | 2017-06-23 17:50:18 +0800 | [diff] [blame] | 109 | if (!iwl_mvm_is_ctdp_supported(mvm)) |
| 110 | return -EOPNOTSUPP; |
| 111 | |
Johannes Berg | aab6930 | 2017-03-22 22:05:12 +0100 | [diff] [blame] | 112 | if (!iwl_mvm_firmware_running(mvm) || |
Johannes Berg | 702e975 | 2017-06-02 11:56:58 +0200 | [diff] [blame] | 113 | mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) |
Chaya Rachel Ivgi | 00f481b | 2016-02-24 12:19:22 +0200 | [diff] [blame] | 114 | return -EIO; |
| 115 | |
| 116 | mutex_lock(&mvm->mutex); |
| 117 | ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_STOP, 0); |
| 118 | mutex_unlock(&mvm->mutex); |
| 119 | |
| 120 | return ret ?: count; |
| 121 | } |
| 122 | |
Chaya Rachel Ivgi | 61d8c62 | 2017-06-27 14:13:02 +0300 | [diff] [blame] | 123 | static ssize_t iwl_dbgfs_force_ctkill_write(struct iwl_mvm *mvm, char *buf, |
| 124 | size_t count, loff_t *ppos) |
| 125 | { |
| 126 | if (!iwl_mvm_firmware_running(mvm) || |
| 127 | mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) |
| 128 | return -EIO; |
| 129 | |
| 130 | iwl_mvm_enter_ctkill(mvm); |
| 131 | |
| 132 | return count; |
| 133 | } |
| 134 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 135 | 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] | 136 | size_t count, loff_t *ppos) |
| 137 | { |
Johannes Berg | 8a0bd16 | 2013-11-12 16:48:03 +0100 | [diff] [blame] | 138 | int ret; |
Mordechai Goodstein | d167e81 | 2017-05-10 16:42:53 +0300 | [diff] [blame] | 139 | u32 flush_arg; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 140 | |
Johannes Berg | aab6930 | 2017-03-22 22:05:12 +0100 | [diff] [blame] | 141 | if (!iwl_mvm_firmware_running(mvm) || |
Johannes Berg | 702e975 | 2017-06-02 11:56:58 +0200 | [diff] [blame] | 142 | mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 143 | return -EIO; |
| 144 | |
Mordechai Goodstein | d167e81 | 2017-05-10 16:42:53 +0300 | [diff] [blame] | 145 | if (kstrtou32(buf, 0, &flush_arg)) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 146 | return -EINVAL; |
| 147 | |
Mordechai Goodstein | d167e81 | 2017-05-10 16:42:53 +0300 | [diff] [blame] | 148 | if (iwl_mvm_has_new_tx_api(mvm)) { |
| 149 | IWL_DEBUG_TX_QUEUES(mvm, |
| 150 | "FLUSHING all tids queues on sta_id = %d\n", |
| 151 | flush_arg); |
| 152 | mutex_lock(&mvm->mutex); |
| 153 | ret = iwl_mvm_flush_sta_tids(mvm, flush_arg, 0xFF, 0) ? : count; |
| 154 | mutex_unlock(&mvm->mutex); |
| 155 | return ret; |
| 156 | } |
| 157 | |
| 158 | IWL_DEBUG_TX_QUEUES(mvm, "FLUSHING queues mask to flush = 0x%x\n", |
| 159 | flush_arg); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 160 | |
| 161 | mutex_lock(&mvm->mutex); |
Mordechai Goodstein | d167e81 | 2017-05-10 16:42:53 +0300 | [diff] [blame] | 162 | ret = iwl_mvm_flush_tx_path(mvm, flush_arg, 0) ? : count; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 163 | mutex_unlock(&mvm->mutex); |
| 164 | |
| 165 | return ret; |
| 166 | } |
| 167 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 168 | 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] | 169 | size_t count, loff_t *ppos) |
| 170 | { |
Emmanuel Grumbach | f327b04 | 2014-01-14 08:30:32 +0200 | [diff] [blame] | 171 | struct iwl_mvm_sta *mvmsta; |
Johannes Berg | 8a0bd16 | 2013-11-12 16:48:03 +0100 | [diff] [blame] | 172 | int sta_id, drain, ret; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 173 | |
Johannes Berg | aab6930 | 2017-03-22 22:05:12 +0100 | [diff] [blame] | 174 | if (!iwl_mvm_firmware_running(mvm) || |
Johannes Berg | 702e975 | 2017-06-02 11:56:58 +0200 | [diff] [blame] | 175 | mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 176 | return -EIO; |
| 177 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 178 | if (sscanf(buf, "%d %d", &sta_id, &drain) != 2) |
| 179 | return -EINVAL; |
Johannes Berg | 60765a4 | 2013-10-25 13:06:06 +0200 | [diff] [blame] | 180 | if (sta_id < 0 || sta_id >= IWL_MVM_STATION_COUNT) |
| 181 | return -EINVAL; |
| 182 | if (drain < 0 || drain > 1) |
| 183 | return -EINVAL; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 184 | |
| 185 | mutex_lock(&mvm->mutex); |
| 186 | |
Emmanuel Grumbach | f327b04 | 2014-01-14 08:30:32 +0200 | [diff] [blame] | 187 | mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id); |
| 188 | |
| 189 | if (!mvmsta) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 190 | ret = -ENOENT; |
| 191 | else |
Emmanuel Grumbach | f327b04 | 2014-01-14 08:30:32 +0200 | [diff] [blame] | 192 | ret = iwl_mvm_drain_sta(mvm, mvmsta, drain) ? : count; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 193 | |
| 194 | mutex_unlock(&mvm->mutex); |
| 195 | |
| 196 | return ret; |
| 197 | } |
| 198 | |
| 199 | static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf, |
| 200 | size_t count, loff_t *ppos) |
| 201 | { |
| 202 | struct iwl_mvm *mvm = file->private_data; |
| 203 | const struct fw_img *img; |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 204 | unsigned int ofs, len; |
| 205 | size_t ret; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 206 | u8 *ptr; |
| 207 | |
Johannes Berg | aab6930 | 2017-03-22 22:05:12 +0100 | [diff] [blame] | 208 | if (!iwl_mvm_firmware_running(mvm)) |
Johannes Berg | 60191d9 | 2013-05-15 13:08:51 +0200 | [diff] [blame] | 209 | return -EINVAL; |
| 210 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 211 | /* default is to dump the entire data segment */ |
Johannes Berg | 702e975 | 2017-06-02 11:56:58 +0200 | [diff] [blame] | 212 | img = &mvm->fw->img[mvm->fwrt.cur_fw_img]; |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 213 | ofs = img->sec[IWL_UCODE_SECTION_DATA].offset; |
| 214 | len = img->sec[IWL_UCODE_SECTION_DATA].len; |
| 215 | |
Emmanuel Grumbach | 01e0efe | 2014-01-06 09:05:54 +0200 | [diff] [blame] | 216 | if (mvm->dbgfs_sram_len) { |
Johannes Berg | 60191d9 | 2013-05-15 13:08:51 +0200 | [diff] [blame] | 217 | ofs = mvm->dbgfs_sram_offset; |
| 218 | len = mvm->dbgfs_sram_len; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 219 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 220 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 221 | ptr = kzalloc(len, GFP_KERNEL); |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 222 | if (!ptr) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 223 | return -ENOMEM; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 224 | |
Johannes Berg | 60191d9 | 2013-05-15 13:08:51 +0200 | [diff] [blame] | 225 | iwl_trans_read_mem_bytes(mvm->trans, ofs, ptr, len); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 226 | |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 227 | ret = simple_read_from_buffer(user_buf, count, ppos, ptr, len); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 228 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 229 | kfree(ptr); |
| 230 | |
| 231 | return ret; |
| 232 | } |
| 233 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 234 | static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf, |
| 235 | size_t count, loff_t *ppos) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 236 | { |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 237 | const struct fw_img *img; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 238 | u32 offset, len; |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 239 | u32 img_offset, img_len; |
| 240 | |
Johannes Berg | aab6930 | 2017-03-22 22:05:12 +0100 | [diff] [blame] | 241 | if (!iwl_mvm_firmware_running(mvm)) |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 242 | return -EINVAL; |
| 243 | |
Johannes Berg | 702e975 | 2017-06-02 11:56:58 +0200 | [diff] [blame] | 244 | img = &mvm->fw->img[mvm->fwrt.cur_fw_img]; |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 245 | img_offset = img->sec[IWL_UCODE_SECTION_DATA].offset; |
| 246 | img_len = img->sec[IWL_UCODE_SECTION_DATA].len; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 247 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 248 | if (sscanf(buf, "%x,%x", &offset, &len) == 2) { |
| 249 | if ((offset & 0x3) || (len & 0x3)) |
| 250 | return -EINVAL; |
Emmanuel Grumbach | d510342 | 2013-12-24 14:58:29 +0200 | [diff] [blame] | 251 | |
| 252 | if (offset + len > img_offset + img_len) |
| 253 | return -EINVAL; |
| 254 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 255 | mvm->dbgfs_sram_offset = offset; |
| 256 | mvm->dbgfs_sram_len = len; |
| 257 | } else { |
| 258 | mvm->dbgfs_sram_offset = 0; |
| 259 | mvm->dbgfs_sram_len = 0; |
| 260 | } |
| 261 | |
| 262 | return count; |
| 263 | } |
| 264 | |
Matti Gottlieb | 7280d1f | 2014-07-17 16:41:14 +0300 | [diff] [blame] | 265 | static ssize_t iwl_dbgfs_set_nic_temperature_read(struct file *file, |
| 266 | char __user *user_buf, |
| 267 | size_t count, loff_t *ppos) |
| 268 | { |
| 269 | struct iwl_mvm *mvm = file->private_data; |
| 270 | char buf[16]; |
| 271 | int pos; |
| 272 | |
| 273 | if (!mvm->temperature_test) |
| 274 | pos = scnprintf(buf , sizeof(buf), "disabled\n"); |
| 275 | else |
| 276 | pos = scnprintf(buf , sizeof(buf), "%d\n", mvm->temperature); |
| 277 | |
| 278 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 279 | } |
| 280 | |
| 281 | /* |
| 282 | * Set NIC Temperature |
| 283 | * Cause the driver to ignore the actual NIC temperature reported by the FW |
| 284 | * Enable: any value between IWL_MVM_DEBUG_SET_TEMPERATURE_MIN - |
| 285 | * IWL_MVM_DEBUG_SET_TEMPERATURE_MAX |
| 286 | * Disable: IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE |
| 287 | */ |
| 288 | static ssize_t iwl_dbgfs_set_nic_temperature_write(struct iwl_mvm *mvm, |
| 289 | char *buf, size_t count, |
| 290 | loff_t *ppos) |
| 291 | { |
| 292 | int temperature; |
| 293 | |
Johannes Berg | aab6930 | 2017-03-22 22:05:12 +0100 | [diff] [blame] | 294 | if (!iwl_mvm_firmware_running(mvm) && !mvm->temperature_test) |
Luciano Coelho | a26d4e7 | 2014-08-20 10:21:07 +0300 | [diff] [blame] | 295 | return -EIO; |
| 296 | |
Matti Gottlieb | 7280d1f | 2014-07-17 16:41:14 +0300 | [diff] [blame] | 297 | if (kstrtoint(buf, 10, &temperature)) |
| 298 | return -EINVAL; |
| 299 | /* not a legal temperature */ |
| 300 | if ((temperature > IWL_MVM_DEBUG_SET_TEMPERATURE_MAX && |
| 301 | temperature != IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) || |
| 302 | temperature < IWL_MVM_DEBUG_SET_TEMPERATURE_MIN) |
| 303 | return -EINVAL; |
| 304 | |
| 305 | mutex_lock(&mvm->mutex); |
| 306 | if (temperature == IWL_MVM_DEBUG_SET_TEMPERATURE_DISABLE) { |
Luciano Coelho | b689fa7 | 2014-08-20 17:26:58 +0300 | [diff] [blame] | 307 | if (!mvm->temperature_test) |
| 308 | goto out; |
| 309 | |
Matti Gottlieb | 7280d1f | 2014-07-17 16:41:14 +0300 | [diff] [blame] | 310 | mvm->temperature_test = false; |
Luciano Coelho | b689fa7 | 2014-08-20 17:26:58 +0300 | [diff] [blame] | 311 | /* Since we can't read the temp while awake, just set |
| 312 | * it to zero until we get the next RX stats from the |
| 313 | * firmware. |
| 314 | */ |
| 315 | mvm->temperature = 0; |
Matti Gottlieb | 7280d1f | 2014-07-17 16:41:14 +0300 | [diff] [blame] | 316 | } else { |
| 317 | mvm->temperature_test = true; |
| 318 | mvm->temperature = temperature; |
| 319 | } |
| 320 | IWL_DEBUG_TEMP(mvm, "%sabling debug set temperature (temp = %d)\n", |
| 321 | mvm->temperature_test ? "En" : "Dis" , |
| 322 | mvm->temperature); |
| 323 | /* handle the temperature change */ |
| 324 | iwl_mvm_tt_handler(mvm); |
Luciano Coelho | b689fa7 | 2014-08-20 17:26:58 +0300 | [diff] [blame] | 325 | |
| 326 | out: |
Matti Gottlieb | 7280d1f | 2014-07-17 16:41:14 +0300 | [diff] [blame] | 327 | mutex_unlock(&mvm->mutex); |
| 328 | |
| 329 | return count; |
| 330 | } |
| 331 | |
Luciano Coelho | c549e39 | 2014-09-04 15:58:47 +0300 | [diff] [blame] | 332 | static ssize_t iwl_dbgfs_nic_temp_read(struct file *file, |
| 333 | char __user *user_buf, |
| 334 | size_t count, loff_t *ppos) |
| 335 | { |
| 336 | struct iwl_mvm *mvm = file->private_data; |
| 337 | char buf[16]; |
Chaya Rachel Ivgi | 7869318 | 2015-12-27 13:45:42 +0200 | [diff] [blame] | 338 | int pos, ret; |
| 339 | s32 temp; |
Luciano Coelho | c549e39 | 2014-09-04 15:58:47 +0300 | [diff] [blame] | 340 | |
Johannes Berg | aab6930 | 2017-03-22 22:05:12 +0100 | [diff] [blame] | 341 | if (!iwl_mvm_firmware_running(mvm)) |
Luciano Coelho | c549e39 | 2014-09-04 15:58:47 +0300 | [diff] [blame] | 342 | return -EIO; |
| 343 | |
| 344 | mutex_lock(&mvm->mutex); |
Chaya Rachel Ivgi | 7869318 | 2015-12-27 13:45:42 +0200 | [diff] [blame] | 345 | ret = iwl_mvm_get_temp(mvm, &temp); |
Luciano Coelho | c549e39 | 2014-09-04 15:58:47 +0300 | [diff] [blame] | 346 | mutex_unlock(&mvm->mutex); |
| 347 | |
Chaya Rachel Ivgi | 7869318 | 2015-12-27 13:45:42 +0200 | [diff] [blame] | 348 | if (ret) |
| 349 | return -EIO; |
Luciano Coelho | c549e39 | 2014-09-04 15:58:47 +0300 | [diff] [blame] | 350 | |
| 351 | pos = scnprintf(buf , sizeof(buf), "%d\n", temp); |
| 352 | |
| 353 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 354 | } |
| 355 | |
Haim Dreyfuss | e6ee065 | 2017-05-15 14:27:21 +0300 | [diff] [blame] | 356 | #ifdef CONFIG_ACPI |
| 357 | static ssize_t iwl_dbgfs_sar_geo_profile_read(struct file *file, |
| 358 | char __user *user_buf, |
| 359 | size_t count, loff_t *ppos) |
| 360 | { |
| 361 | struct iwl_mvm *mvm = file->private_data; |
| 362 | char buf[256]; |
| 363 | int pos = 0; |
| 364 | int bufsz = sizeof(buf); |
| 365 | int tbl_idx; |
| 366 | u8 *value; |
| 367 | |
| 368 | if (!iwl_mvm_firmware_running(mvm)) |
| 369 | return -EIO; |
| 370 | |
| 371 | mutex_lock(&mvm->mutex); |
| 372 | tbl_idx = iwl_mvm_get_sar_geo_profile(mvm); |
| 373 | if (tbl_idx < 0) { |
| 374 | mutex_unlock(&mvm->mutex); |
| 375 | return tbl_idx; |
| 376 | } |
| 377 | |
| 378 | if (!tbl_idx) { |
| 379 | pos = scnprintf(buf, bufsz, |
| 380 | "SAR geographic profile disabled\n"); |
| 381 | } else { |
| 382 | value = &mvm->geo_profiles[tbl_idx - 1].values[0]; |
| 383 | |
| 384 | pos += scnprintf(buf + pos, bufsz - pos, |
| 385 | "Use geographic profile %d\n", tbl_idx); |
| 386 | pos += scnprintf(buf + pos, bufsz - pos, |
| 387 | "2.4GHz:\n\tChain A offset: %hhd dBm\n\tChain B offset: %hhd dBm\n\tmax tx power: %hhd dBm\n", |
| 388 | value[1], value[2], value[0]); |
| 389 | pos += scnprintf(buf + pos, bufsz - pos, |
| 390 | "5.2GHz:\n\tChain A offset: %hhd dBm\n\tChain B offset: %hhd dBm\n\tmax tx power: %hhd dBm\n", |
| 391 | value[4], value[5], value[3]); |
| 392 | } |
| 393 | mutex_unlock(&mvm->mutex); |
| 394 | |
| 395 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 396 | } |
| 397 | #endif |
| 398 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 399 | static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, |
| 400 | size_t count, loff_t *ppos) |
| 401 | { |
| 402 | struct iwl_mvm *mvm = file->private_data; |
| 403 | struct ieee80211_sta *sta; |
| 404 | char buf[400]; |
| 405 | int i, pos = 0, bufsz = sizeof(buf); |
| 406 | |
| 407 | mutex_lock(&mvm->mutex); |
| 408 | |
Sara Sharon | 0ae9881 | 2017-01-04 14:53:58 +0200 | [diff] [blame] | 409 | for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 410 | pos += scnprintf(buf + pos, bufsz - pos, "%.2d: ", i); |
| 411 | sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i], |
| 412 | lockdep_is_held(&mvm->mutex)); |
| 413 | if (!sta) |
| 414 | pos += scnprintf(buf + pos, bufsz - pos, "N/A\n"); |
| 415 | else if (IS_ERR(sta)) |
| 416 | pos += scnprintf(buf + pos, bufsz - pos, "%ld\n", |
| 417 | PTR_ERR(sta)); |
| 418 | else |
| 419 | pos += scnprintf(buf + pos, bufsz - pos, "%pM\n", |
| 420 | sta->addr); |
| 421 | } |
| 422 | |
| 423 | mutex_unlock(&mvm->mutex); |
| 424 | |
| 425 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 426 | } |
| 427 | |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 428 | static ssize_t iwl_dbgfs_disable_power_off_read(struct file *file, |
| 429 | char __user *user_buf, |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 430 | size_t count, loff_t *ppos) |
| 431 | { |
| 432 | struct iwl_mvm *mvm = file->private_data; |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 433 | char buf[64]; |
| 434 | int bufsz = sizeof(buf); |
| 435 | int pos = 0; |
| 436 | |
| 437 | pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d0=%d\n", |
| 438 | mvm->disable_power_off); |
| 439 | pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d3=%d\n", |
| 440 | mvm->disable_power_off_d3); |
| 441 | |
| 442 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 443 | } |
| 444 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 445 | 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] | 446 | size_t count, loff_t *ppos) |
| 447 | { |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 448 | int ret, val; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 449 | |
Johannes Berg | aab6930 | 2017-03-22 22:05:12 +0100 | [diff] [blame] | 450 | if (!iwl_mvm_firmware_running(mvm)) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 451 | return -EIO; |
| 452 | |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 453 | if (!strncmp("disable_power_off_d0=", buf, 21)) { |
| 454 | if (sscanf(buf + 21, "%d", &val) != 1) |
| 455 | return -EINVAL; |
| 456 | mvm->disable_power_off = val; |
| 457 | } else if (!strncmp("disable_power_off_d3=", buf, 21)) { |
| 458 | if (sscanf(buf + 21, "%d", &val) != 1) |
| 459 | return -EINVAL; |
| 460 | mvm->disable_power_off_d3 = val; |
| 461 | } else { |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 462 | return -EINVAL; |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 463 | } |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 464 | |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 465 | mutex_lock(&mvm->mutex); |
Emmanuel Grumbach | c1cb92f | 2014-01-28 10:17:18 +0200 | [diff] [blame] | 466 | ret = iwl_mvm_power_update_device(mvm); |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 467 | mutex_unlock(&mvm->mutex); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 468 | |
Alexander Bondar | 64b928c | 2013-09-03 14:18:03 +0300 | [diff] [blame] | 469 | return ret ?: count; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 470 | } |
| 471 | |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 472 | #define BT_MBOX_MSG(_notif, _num, _field) \ |
| 473 | ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\ |
| 474 | >> BT_MBOX##_num##_##_field##_POS) |
| 475 | |
| 476 | |
| 477 | #define BT_MBOX_PRINT(_num, _field, _end) \ |
| 478 | pos += scnprintf(buf + pos, bufsz - pos, \ |
| 479 | "\t%s: %d%s", \ |
| 480 | #_field, \ |
| 481 | BT_MBOX_MSG(notif, _num, _field), \ |
| 482 | true ? "\n" : ", "); |
| 483 | |
Emmanuel Grumbach | 160be57 | 2014-07-02 17:33:52 +0300 | [diff] [blame] | 484 | static |
Emmanuel Grumbach | fbfe378 | 2017-07-23 13:59:47 +0300 | [diff] [blame^] | 485 | int iwl_mvm_coex_dump_mbox(struct iwl_mvm *mvm, |
| 486 | struct iwl_bt_coex_profile_notif *notif, char *buf, |
Emmanuel Grumbach | 160be57 | 2014-07-02 17:33:52 +0300 | [diff] [blame] | 487 | int pos, int bufsz) |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 488 | { |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 489 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n"); |
| 490 | |
| 491 | BT_MBOX_PRINT(0, LE_SLAVE_LAT, false); |
| 492 | BT_MBOX_PRINT(0, LE_PROF1, false); |
| 493 | BT_MBOX_PRINT(0, LE_PROF2, false); |
| 494 | BT_MBOX_PRINT(0, LE_PROF_OTHER, false); |
| 495 | BT_MBOX_PRINT(0, CHL_SEQ_N, false); |
| 496 | BT_MBOX_PRINT(0, INBAND_S, false); |
| 497 | BT_MBOX_PRINT(0, LE_MIN_RSSI, false); |
| 498 | BT_MBOX_PRINT(0, LE_SCAN, false); |
| 499 | BT_MBOX_PRINT(0, LE_ADV, false); |
| 500 | BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false); |
| 501 | BT_MBOX_PRINT(0, OPEN_CON_1, true); |
| 502 | |
| 503 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n"); |
| 504 | |
| 505 | BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false); |
| 506 | BT_MBOX_PRINT(1, IP_SR, false); |
| 507 | BT_MBOX_PRINT(1, LE_MSTR, false); |
| 508 | BT_MBOX_PRINT(1, AGGR_TRFC_LD, false); |
| 509 | BT_MBOX_PRINT(1, MSG_TYPE, false); |
| 510 | BT_MBOX_PRINT(1, SSN, true); |
| 511 | |
| 512 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n"); |
| 513 | |
| 514 | BT_MBOX_PRINT(2, SNIFF_ACT, false); |
| 515 | BT_MBOX_PRINT(2, PAG, false); |
| 516 | BT_MBOX_PRINT(2, INQUIRY, false); |
| 517 | BT_MBOX_PRINT(2, CONN, false); |
| 518 | BT_MBOX_PRINT(2, SNIFF_INTERVAL, false); |
| 519 | BT_MBOX_PRINT(2, DISC, false); |
| 520 | BT_MBOX_PRINT(2, SCO_TX_ACT, false); |
| 521 | BT_MBOX_PRINT(2, SCO_RX_ACT, false); |
| 522 | BT_MBOX_PRINT(2, ESCO_RE_TX, false); |
| 523 | BT_MBOX_PRINT(2, SCO_DURATION, true); |
| 524 | |
| 525 | pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n"); |
| 526 | |
| 527 | BT_MBOX_PRINT(3, SCO_STATE, false); |
| 528 | BT_MBOX_PRINT(3, SNIFF_STATE, false); |
| 529 | BT_MBOX_PRINT(3, A2DP_STATE, false); |
Emmanuel Grumbach | fbfe378 | 2017-07-23 13:59:47 +0300 | [diff] [blame^] | 530 | BT_MBOX_PRINT(3, A2DP_SRC, false); |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 531 | BT_MBOX_PRINT(3, ACL_STATE, false); |
| 532 | BT_MBOX_PRINT(3, MSTR_STATE, false); |
| 533 | BT_MBOX_PRINT(3, OBX_STATE, false); |
| 534 | BT_MBOX_PRINT(3, OPEN_CON_2, false); |
| 535 | BT_MBOX_PRINT(3, TRAFFIC_LOAD, false); |
| 536 | BT_MBOX_PRINT(3, CHL_SEQN_LSB, false); |
| 537 | BT_MBOX_PRINT(3, INBAND_P, false); |
| 538 | BT_MBOX_PRINT(3, MSG_TYPE_2, false); |
| 539 | BT_MBOX_PRINT(3, SSN_2, false); |
Emmanuel Grumbach | fbfe378 | 2017-07-23 13:59:47 +0300 | [diff] [blame^] | 540 | BT_MBOX_PRINT(3, UPDATE_REQUEST, !iwl_mvm_has_new_ats_coex_api(mvm)); |
| 541 | |
| 542 | if (iwl_mvm_has_new_ats_coex_api(mvm)) { |
| 543 | BT_MBOX_PRINT(4, ATS_BT_INTERVAL, false); |
| 544 | BT_MBOX_PRINT(4, ATS_BT_ACTIVE_MAX_TH, true); |
| 545 | } |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 546 | |
Emmanuel Grumbach | 160be57 | 2014-07-02 17:33:52 +0300 | [diff] [blame] | 547 | return pos; |
| 548 | } |
| 549 | |
Emmanuel Grumbach | 160be57 | 2014-07-02 17:33:52 +0300 | [diff] [blame] | 550 | static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf, |
| 551 | size_t count, loff_t *ppos) |
| 552 | { |
| 553 | struct iwl_mvm *mvm = file->private_data; |
Sara Sharon | 97f95c9 | 2016-03-07 16:55:20 +0200 | [diff] [blame] | 554 | struct iwl_bt_coex_profile_notif *notif = &mvm->last_bt_notif; |
Emmanuel Grumbach | 160be57 | 2014-07-02 17:33:52 +0300 | [diff] [blame] | 555 | char *buf; |
| 556 | int ret, pos = 0, bufsz = sizeof(char) * 1024; |
| 557 | |
| 558 | buf = kmalloc(bufsz, GFP_KERNEL); |
| 559 | if (!buf) |
| 560 | return -ENOMEM; |
| 561 | |
| 562 | mutex_lock(&mvm->mutex); |
| 563 | |
Emmanuel Grumbach | fbfe378 | 2017-07-23 13:59:47 +0300 | [diff] [blame^] | 564 | pos += iwl_mvm_coex_dump_mbox(mvm, notif, buf, pos, bufsz); |
Emmanuel Grumbach | 160be57 | 2014-07-02 17:33:52 +0300 | [diff] [blame] | 565 | |
Sara Sharon | 97f95c9 | 2016-03-07 16:55:20 +0200 | [diff] [blame] | 566 | pos += scnprintf(buf + pos, bufsz - pos, "bt_ci_compliance = %d\n", |
| 567 | notif->bt_ci_compliance); |
| 568 | pos += scnprintf(buf + pos, bufsz - pos, "primary_ch_lut = %d\n", |
| 569 | le32_to_cpu(notif->primary_ch_lut)); |
| 570 | pos += scnprintf(buf + pos, bufsz - pos, "secondary_ch_lut = %d\n", |
| 571 | le32_to_cpu(notif->secondary_ch_lut)); |
| 572 | pos += scnprintf(buf + pos, |
| 573 | bufsz - pos, "bt_activity_grading = %d\n", |
| 574 | le32_to_cpu(notif->bt_activity_grading)); |
Sara Sharon | 97f95c9 | 2016-03-07 16:55:20 +0200 | [diff] [blame] | 575 | pos += scnprintf(buf + pos, bufsz - pos, "bt_rrc = %d\n", |
Emmanuel Grumbach | 88c5f47 | 2017-07-23 12:53:46 +0300 | [diff] [blame] | 576 | notif->rrc_status & 0xF); |
Sara Sharon | 97f95c9 | 2016-03-07 16:55:20 +0200 | [diff] [blame] | 577 | pos += scnprintf(buf + pos, bufsz - pos, "bt_ttc = %d\n", |
Emmanuel Grumbach | 88c5f47 | 2017-07-23 12:53:46 +0300 | [diff] [blame] | 578 | notif->ttc_status & 0xF); |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 579 | |
Moshe Harel | c725a46 | 2015-10-27 14:04:12 +0200 | [diff] [blame] | 580 | pos += scnprintf(buf + pos, bufsz - pos, "sync_sco = %d\n", |
| 581 | IWL_MVM_BT_COEX_SYNC2SCO); |
| 582 | pos += scnprintf(buf + pos, bufsz - pos, "mplut = %d\n", |
| 583 | IWL_MVM_BT_COEX_MPLUT); |
Moshe Harel | c725a46 | 2015-10-27 14:04:12 +0200 | [diff] [blame] | 584 | |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 585 | mutex_unlock(&mvm->mutex); |
| 586 | |
| 587 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 588 | kfree(buf); |
| 589 | |
| 590 | return ret; |
| 591 | } |
| 592 | #undef BT_MBOX_PRINT |
| 593 | |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 594 | static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf, |
| 595 | size_t count, loff_t *ppos) |
| 596 | { |
| 597 | struct iwl_mvm *mvm = file->private_data; |
Sara Sharon | 97f95c9 | 2016-03-07 16:55:20 +0200 | [diff] [blame] | 598 | struct iwl_bt_coex_ci_cmd *cmd = &mvm->last_bt_ci_cmd; |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 599 | char buf[256]; |
| 600 | int bufsz = sizeof(buf); |
| 601 | int pos = 0; |
| 602 | |
| 603 | mutex_lock(&mvm->mutex); |
| 604 | |
Sara Sharon | 97f95c9 | 2016-03-07 16:55:20 +0200 | [diff] [blame] | 605 | pos += scnprintf(buf + pos, bufsz - pos, "Channel inhibition CMD\n"); |
| 606 | pos += scnprintf(buf + pos, bufsz - pos, |
| 607 | "\tPrimary Channel Bitmap 0x%016llx\n", |
| 608 | le64_to_cpu(cmd->bt_primary_ci)); |
| 609 | pos += scnprintf(buf + pos, bufsz - pos, |
| 610 | "\tSecondary Channel Bitmap 0x%016llx\n", |
| 611 | le64_to_cpu(cmd->bt_secondary_ci)); |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 612 | |
| 613 | mutex_unlock(&mvm->mutex); |
| 614 | |
| 615 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 616 | } |
| 617 | |
Emmanuel Grumbach | cdb0056 | 2014-03-16 21:55:43 +0200 | [diff] [blame] | 618 | static ssize_t |
| 619 | iwl_dbgfs_bt_tx_prio_write(struct iwl_mvm *mvm, char *buf, |
| 620 | size_t count, loff_t *ppos) |
| 621 | { |
| 622 | u32 bt_tx_prio; |
| 623 | |
| 624 | if (sscanf(buf, "%u", &bt_tx_prio) != 1) |
| 625 | return -EINVAL; |
| 626 | if (bt_tx_prio > 4) |
| 627 | return -EINVAL; |
| 628 | |
| 629 | mvm->bt_tx_prio = bt_tx_prio; |
| 630 | |
| 631 | return count; |
| 632 | } |
| 633 | |
Emmanuel Grumbach | a39979a | 2014-05-28 12:06:41 +0300 | [diff] [blame] | 634 | static ssize_t |
| 635 | iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf, |
| 636 | size_t count, loff_t *ppos) |
| 637 | { |
| 638 | static const char * const modes_str[BT_FORCE_ANT_MAX] = { |
| 639 | [BT_FORCE_ANT_DIS] = "dis", |
| 640 | [BT_FORCE_ANT_AUTO] = "auto", |
| 641 | [BT_FORCE_ANT_BT] = "bt", |
| 642 | [BT_FORCE_ANT_WIFI] = "wifi", |
| 643 | }; |
| 644 | int ret, bt_force_ant_mode; |
| 645 | |
| 646 | for (bt_force_ant_mode = 0; |
| 647 | bt_force_ant_mode < ARRAY_SIZE(modes_str); |
| 648 | bt_force_ant_mode++) { |
| 649 | if (!strcmp(buf, modes_str[bt_force_ant_mode])) |
| 650 | break; |
| 651 | } |
| 652 | |
| 653 | if (bt_force_ant_mode >= ARRAY_SIZE(modes_str)) |
| 654 | return -EINVAL; |
| 655 | |
| 656 | ret = 0; |
| 657 | mutex_lock(&mvm->mutex); |
| 658 | if (mvm->bt_force_ant_mode == bt_force_ant_mode) |
| 659 | goto out; |
| 660 | |
| 661 | mvm->bt_force_ant_mode = bt_force_ant_mode; |
| 662 | IWL_DEBUG_COEX(mvm, "Force mode: %s\n", |
| 663 | modes_str[mvm->bt_force_ant_mode]); |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 664 | |
| 665 | if (iwl_mvm_firmware_running(mvm)) |
Emmanuel Grumbach | b3de3ef | 2017-05-29 14:01:06 +0300 | [diff] [blame] | 666 | ret = iwl_mvm_send_bt_init_conf(mvm); |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 667 | else |
| 668 | ret = 0; |
Emmanuel Grumbach | a39979a | 2014-05-28 12:06:41 +0300 | [diff] [blame] | 669 | |
| 670 | out: |
| 671 | mutex_unlock(&mvm->mutex); |
| 672 | return ret ?: count; |
| 673 | } |
| 674 | |
Johannes Berg | 93d17cc | 2015-01-15 12:59:26 +0100 | [diff] [blame] | 675 | #define PRINT_STATS_LE32(_struct, _memb) \ |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 676 | pos += scnprintf(buf + pos, bufsz - pos, \ |
Johannes Berg | 93d17cc | 2015-01-15 12:59:26 +0100 | [diff] [blame] | 677 | fmt_table, #_memb, \ |
| 678 | le32_to_cpu(_struct->_memb)) |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 679 | |
| 680 | static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file, |
| 681 | char __user *user_buf, size_t count, |
| 682 | loff_t *ppos) |
| 683 | { |
| 684 | struct iwl_mvm *mvm = file->private_data; |
| 685 | static const char *fmt_table = "\t%-30s %10u\n"; |
| 686 | static const char *fmt_header = "%-32s\n"; |
| 687 | int pos = 0; |
| 688 | char *buf; |
| 689 | int ret; |
Liad Kaufman | 678d9b6 | 2017-05-18 18:00:49 +0300 | [diff] [blame] | 690 | size_t bufsz; |
Luciano Coelho | 3f61728 | 2013-10-14 13:18:41 +0300 | [diff] [blame] | 691 | |
Liad Kaufman | 678d9b6 | 2017-05-18 18:00:49 +0300 | [diff] [blame] | 692 | if (iwl_mvm_has_new_rx_stats_api(mvm)) |
| 693 | bufsz = ((sizeof(struct mvm_statistics_rx) / |
| 694 | sizeof(__le32)) * 43) + (4 * 33) + 1; |
| 695 | else |
| 696 | /* 43 = size of each data line; 33 = size of each header */ |
| 697 | bufsz = ((sizeof(struct mvm_statistics_rx_v3) / |
| 698 | sizeof(__le32)) * 43) + (4 * 33) + 1; |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 699 | |
| 700 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 701 | if (!buf) |
| 702 | return -ENOMEM; |
| 703 | |
| 704 | mutex_lock(&mvm->mutex); |
| 705 | |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 706 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, |
| 707 | "Statistics_Rx - OFDM"); |
Liad Kaufman | 678d9b6 | 2017-05-18 18:00:49 +0300 | [diff] [blame] | 708 | if (!iwl_mvm_has_new_rx_stats_api(mvm)) { |
| 709 | struct mvm_statistics_rx_phy_v2 *ofdm = &mvm->rx_stats_v3.ofdm; |
| 710 | |
| 711 | PRINT_STATS_LE32(ofdm, ina_cnt); |
| 712 | PRINT_STATS_LE32(ofdm, fina_cnt); |
| 713 | PRINT_STATS_LE32(ofdm, plcp_err); |
| 714 | PRINT_STATS_LE32(ofdm, crc32_err); |
| 715 | PRINT_STATS_LE32(ofdm, overrun_err); |
| 716 | PRINT_STATS_LE32(ofdm, early_overrun_err); |
| 717 | PRINT_STATS_LE32(ofdm, crc32_good); |
| 718 | PRINT_STATS_LE32(ofdm, false_alarm_cnt); |
| 719 | PRINT_STATS_LE32(ofdm, fina_sync_err_cnt); |
| 720 | PRINT_STATS_LE32(ofdm, sfd_timeout); |
| 721 | PRINT_STATS_LE32(ofdm, fina_timeout); |
| 722 | PRINT_STATS_LE32(ofdm, unresponded_rts); |
| 723 | PRINT_STATS_LE32(ofdm, rxe_frame_lmt_overrun); |
| 724 | PRINT_STATS_LE32(ofdm, sent_ack_cnt); |
| 725 | PRINT_STATS_LE32(ofdm, sent_cts_cnt); |
| 726 | PRINT_STATS_LE32(ofdm, sent_ba_rsp_cnt); |
| 727 | PRINT_STATS_LE32(ofdm, dsp_self_kill); |
| 728 | PRINT_STATS_LE32(ofdm, mh_format_err); |
| 729 | PRINT_STATS_LE32(ofdm, re_acq_main_rssi_sum); |
| 730 | PRINT_STATS_LE32(ofdm, reserved); |
| 731 | } else { |
| 732 | struct mvm_statistics_rx_phy *ofdm = &mvm->rx_stats.ofdm; |
| 733 | |
| 734 | PRINT_STATS_LE32(ofdm, unresponded_rts); |
| 735 | PRINT_STATS_LE32(ofdm, rxe_frame_lmt_overrun); |
| 736 | PRINT_STATS_LE32(ofdm, sent_ba_rsp_cnt); |
| 737 | PRINT_STATS_LE32(ofdm, dsp_self_kill); |
| 738 | PRINT_STATS_LE32(ofdm, reserved); |
| 739 | } |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 740 | |
| 741 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, |
| 742 | "Statistics_Rx - CCK"); |
Liad Kaufman | 678d9b6 | 2017-05-18 18:00:49 +0300 | [diff] [blame] | 743 | if (!iwl_mvm_has_new_rx_stats_api(mvm)) { |
| 744 | struct mvm_statistics_rx_phy_v2 *cck = &mvm->rx_stats_v3.cck; |
| 745 | |
| 746 | PRINT_STATS_LE32(cck, ina_cnt); |
| 747 | PRINT_STATS_LE32(cck, fina_cnt); |
| 748 | PRINT_STATS_LE32(cck, plcp_err); |
| 749 | PRINT_STATS_LE32(cck, crc32_err); |
| 750 | PRINT_STATS_LE32(cck, overrun_err); |
| 751 | PRINT_STATS_LE32(cck, early_overrun_err); |
| 752 | PRINT_STATS_LE32(cck, crc32_good); |
| 753 | PRINT_STATS_LE32(cck, false_alarm_cnt); |
| 754 | PRINT_STATS_LE32(cck, fina_sync_err_cnt); |
| 755 | PRINT_STATS_LE32(cck, sfd_timeout); |
| 756 | PRINT_STATS_LE32(cck, fina_timeout); |
| 757 | PRINT_STATS_LE32(cck, unresponded_rts); |
| 758 | PRINT_STATS_LE32(cck, rxe_frame_lmt_overrun); |
| 759 | PRINT_STATS_LE32(cck, sent_ack_cnt); |
| 760 | PRINT_STATS_LE32(cck, sent_cts_cnt); |
| 761 | PRINT_STATS_LE32(cck, sent_ba_rsp_cnt); |
| 762 | PRINT_STATS_LE32(cck, dsp_self_kill); |
| 763 | PRINT_STATS_LE32(cck, mh_format_err); |
| 764 | PRINT_STATS_LE32(cck, re_acq_main_rssi_sum); |
| 765 | PRINT_STATS_LE32(cck, reserved); |
| 766 | } else { |
| 767 | struct mvm_statistics_rx_phy *cck = &mvm->rx_stats.cck; |
| 768 | |
| 769 | PRINT_STATS_LE32(cck, unresponded_rts); |
| 770 | PRINT_STATS_LE32(cck, rxe_frame_lmt_overrun); |
| 771 | PRINT_STATS_LE32(cck, sent_ba_rsp_cnt); |
| 772 | PRINT_STATS_LE32(cck, dsp_self_kill); |
| 773 | PRINT_STATS_LE32(cck, reserved); |
| 774 | } |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 775 | |
| 776 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, |
| 777 | "Statistics_Rx - GENERAL"); |
Liad Kaufman | 678d9b6 | 2017-05-18 18:00:49 +0300 | [diff] [blame] | 778 | if (!iwl_mvm_has_new_rx_stats_api(mvm)) { |
| 779 | struct mvm_statistics_rx_non_phy_v3 *general = |
| 780 | &mvm->rx_stats_v3.general; |
| 781 | |
| 782 | PRINT_STATS_LE32(general, bogus_cts); |
| 783 | PRINT_STATS_LE32(general, bogus_ack); |
| 784 | PRINT_STATS_LE32(general, non_bssid_frames); |
| 785 | PRINT_STATS_LE32(general, filtered_frames); |
| 786 | PRINT_STATS_LE32(general, non_channel_beacons); |
| 787 | PRINT_STATS_LE32(general, channel_beacons); |
| 788 | PRINT_STATS_LE32(general, num_missed_bcon); |
| 789 | PRINT_STATS_LE32(general, adc_rx_saturation_time); |
| 790 | PRINT_STATS_LE32(general, ina_detection_search_time); |
| 791 | PRINT_STATS_LE32(general, beacon_silence_rssi_a); |
| 792 | PRINT_STATS_LE32(general, beacon_silence_rssi_b); |
| 793 | PRINT_STATS_LE32(general, beacon_silence_rssi_c); |
| 794 | PRINT_STATS_LE32(general, interference_data_flag); |
| 795 | PRINT_STATS_LE32(general, channel_load); |
| 796 | PRINT_STATS_LE32(general, dsp_false_alarms); |
| 797 | PRINT_STATS_LE32(general, beacon_rssi_a); |
| 798 | PRINT_STATS_LE32(general, beacon_rssi_b); |
| 799 | PRINT_STATS_LE32(general, beacon_rssi_c); |
| 800 | PRINT_STATS_LE32(general, beacon_energy_a); |
| 801 | PRINT_STATS_LE32(general, beacon_energy_b); |
| 802 | PRINT_STATS_LE32(general, beacon_energy_c); |
| 803 | PRINT_STATS_LE32(general, num_bt_kills); |
| 804 | PRINT_STATS_LE32(general, mac_id); |
| 805 | PRINT_STATS_LE32(general, directed_data_mpdu); |
| 806 | } else { |
| 807 | struct mvm_statistics_rx_non_phy *general = |
| 808 | &mvm->rx_stats.general; |
| 809 | |
| 810 | PRINT_STATS_LE32(general, bogus_cts); |
| 811 | PRINT_STATS_LE32(general, bogus_ack); |
| 812 | PRINT_STATS_LE32(general, non_channel_beacons); |
| 813 | PRINT_STATS_LE32(general, channel_beacons); |
| 814 | PRINT_STATS_LE32(general, num_missed_bcon); |
| 815 | PRINT_STATS_LE32(general, adc_rx_saturation_time); |
| 816 | PRINT_STATS_LE32(general, ina_detection_search_time); |
| 817 | PRINT_STATS_LE32(general, beacon_silence_rssi_a); |
| 818 | PRINT_STATS_LE32(general, beacon_silence_rssi_b); |
| 819 | PRINT_STATS_LE32(general, beacon_silence_rssi_c); |
| 820 | PRINT_STATS_LE32(general, interference_data_flag); |
| 821 | PRINT_STATS_LE32(general, channel_load); |
| 822 | PRINT_STATS_LE32(general, beacon_rssi_a); |
| 823 | PRINT_STATS_LE32(general, beacon_rssi_b); |
| 824 | PRINT_STATS_LE32(general, beacon_rssi_c); |
| 825 | PRINT_STATS_LE32(general, beacon_energy_a); |
| 826 | PRINT_STATS_LE32(general, beacon_energy_b); |
| 827 | PRINT_STATS_LE32(general, beacon_energy_c); |
| 828 | PRINT_STATS_LE32(general, num_bt_kills); |
| 829 | PRINT_STATS_LE32(general, mac_id); |
| 830 | } |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 831 | |
| 832 | pos += scnprintf(buf + pos, bufsz - pos, fmt_header, |
| 833 | "Statistics_Rx - HT"); |
Liad Kaufman | 678d9b6 | 2017-05-18 18:00:49 +0300 | [diff] [blame] | 834 | if (!iwl_mvm_has_new_rx_stats_api(mvm)) { |
| 835 | struct mvm_statistics_rx_ht_phy_v1 *ht = |
| 836 | &mvm->rx_stats_v3.ofdm_ht; |
| 837 | |
| 838 | PRINT_STATS_LE32(ht, plcp_err); |
| 839 | PRINT_STATS_LE32(ht, overrun_err); |
| 840 | PRINT_STATS_LE32(ht, early_overrun_err); |
| 841 | PRINT_STATS_LE32(ht, crc32_good); |
| 842 | PRINT_STATS_LE32(ht, crc32_err); |
| 843 | PRINT_STATS_LE32(ht, mh_format_err); |
| 844 | PRINT_STATS_LE32(ht, agg_crc32_good); |
| 845 | PRINT_STATS_LE32(ht, agg_mpdu_cnt); |
| 846 | PRINT_STATS_LE32(ht, agg_cnt); |
| 847 | PRINT_STATS_LE32(ht, unsupport_mcs); |
| 848 | } else { |
| 849 | struct mvm_statistics_rx_ht_phy *ht = |
| 850 | &mvm->rx_stats.ofdm_ht; |
| 851 | |
| 852 | PRINT_STATS_LE32(ht, mh_format_err); |
| 853 | PRINT_STATS_LE32(ht, agg_mpdu_cnt); |
| 854 | PRINT_STATS_LE32(ht, agg_cnt); |
| 855 | PRINT_STATS_LE32(ht, unsupport_mcs); |
| 856 | } |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 857 | |
| 858 | mutex_unlock(&mvm->mutex); |
| 859 | |
| 860 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 861 | kfree(buf); |
| 862 | |
| 863 | return ret; |
| 864 | } |
| 865 | #undef PRINT_STAT_LE32 |
| 866 | |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 867 | static ssize_t iwl_dbgfs_frame_stats_read(struct iwl_mvm *mvm, |
| 868 | char __user *user_buf, size_t count, |
| 869 | loff_t *ppos, |
| 870 | struct iwl_mvm_frame_stats *stats) |
| 871 | { |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 872 | char *buff, *pos, *endpos; |
| 873 | int idx, i; |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 874 | int ret; |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 875 | static const size_t bufsz = 1024; |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 876 | |
| 877 | buff = kmalloc(bufsz, GFP_KERNEL); |
| 878 | if (!buff) |
| 879 | return -ENOMEM; |
| 880 | |
| 881 | spin_lock_bh(&mvm->drv_stats_lock); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 882 | |
| 883 | pos = buff; |
| 884 | endpos = pos + bufsz; |
| 885 | |
| 886 | pos += scnprintf(pos, endpos - pos, |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 887 | "Legacy/HT/VHT\t:\t%d/%d/%d\n", |
| 888 | stats->legacy_frames, |
| 889 | stats->ht_frames, |
| 890 | stats->vht_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 891 | 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] | 892 | stats->bw_20_frames, |
| 893 | stats->bw_40_frames, |
| 894 | stats->bw_80_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 895 | 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] | 896 | stats->ngi_frames, |
| 897 | stats->sgi_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 898 | pos += scnprintf(pos, endpos - pos, "SISO/MIMO2\t:\t%d/%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 899 | stats->siso_frames, |
| 900 | stats->mimo2_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 901 | pos += scnprintf(pos, endpos - pos, "FAIL/SCSS\t:\t%d/%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 902 | stats->fail_frames, |
| 903 | stats->success_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 904 | pos += scnprintf(pos, endpos - pos, "MPDUs agg\t:\t%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 905 | stats->agg_frames); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 906 | pos += scnprintf(pos, endpos - pos, "A-MPDUs\t\t:\t%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 907 | stats->ampdu_count); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 908 | pos += scnprintf(pos, endpos - pos, "Avg MPDUs/A-MPDU:\t%d\n", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 909 | stats->ampdu_count > 0 ? |
| 910 | (stats->agg_frames / stats->ampdu_count) : 0); |
| 911 | |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 912 | pos += scnprintf(pos, endpos - pos, "Last Rates\n"); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 913 | |
| 914 | idx = stats->last_frame_idx - 1; |
| 915 | for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) { |
| 916 | idx = (idx + 1) % ARRAY_SIZE(stats->last_rates); |
| 917 | if (stats->last_rates[idx] == 0) |
| 918 | continue; |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 919 | pos += scnprintf(pos, endpos - pos, "Rate[%d]: ", |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 920 | (int)(ARRAY_SIZE(stats->last_rates) - i)); |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 921 | pos += rs_pretty_print_rate(pos, stats->last_rates[idx]); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 922 | } |
| 923 | spin_unlock_bh(&mvm->drv_stats_lock); |
| 924 | |
Eyal Shapira | f754b5c | 2014-02-24 10:24:34 +0200 | [diff] [blame] | 925 | ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 926 | kfree(buff); |
| 927 | |
| 928 | return ret; |
| 929 | } |
| 930 | |
| 931 | static ssize_t iwl_dbgfs_drv_rx_stats_read(struct file *file, |
| 932 | char __user *user_buf, size_t count, |
| 933 | loff_t *ppos) |
| 934 | { |
| 935 | struct iwl_mvm *mvm = file->private_data; |
| 936 | |
| 937 | return iwl_dbgfs_frame_stats_read(mvm, user_buf, count, ppos, |
| 938 | &mvm->drv_rx_stats); |
| 939 | } |
| 940 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 941 | 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] | 942 | size_t count, loff_t *ppos) |
| 943 | { |
Luca Coelho | 758d1a8 | 2016-11-09 10:02:46 +0200 | [diff] [blame] | 944 | int __maybe_unused ret; |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 945 | |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 946 | if (!iwl_mvm_firmware_running(mvm)) |
| 947 | return -EIO; |
| 948 | |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 949 | mutex_lock(&mvm->mutex); |
| 950 | |
Eran Harary | 291aa7c | 2013-07-03 11:00:06 +0300 | [diff] [blame] | 951 | /* allow one more restart that we're provoking here */ |
Johannes Berg | 3b37f4c | 2017-05-30 16:45:31 +0200 | [diff] [blame] | 952 | if (mvm->fw_restart >= 0) |
| 953 | mvm->fw_restart++; |
Eran Harary | 291aa7c | 2013-07-03 11:00:06 +0300 | [diff] [blame] | 954 | |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 955 | /* take the return value to make compiler happy - it will fail anyway */ |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 956 | ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_ERROR, 0, 0, NULL); |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 957 | |
| 958 | mutex_unlock(&mvm->mutex); |
| 959 | |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 960 | return count; |
| 961 | } |
| 962 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 963 | 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] | 964 | size_t count, loff_t *ppos) |
| 965 | { |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 966 | int ret; |
| 967 | |
| 968 | if (!iwl_mvm_firmware_running(mvm)) |
| 969 | return -EIO; |
| 970 | |
| 971 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_NMI); |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 972 | if (ret) |
| 973 | return ret; |
| 974 | |
Liad Kaufman | 4c9706d | 2014-04-27 16:46:09 +0300 | [diff] [blame] | 975 | iwl_force_nmi(mvm->trans); |
Alexander Bondar | 119663c | 2013-10-17 14:26:50 +0200 | [diff] [blame] | 976 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 977 | iwl_mvm_unref(mvm, IWL_MVM_REF_NMI); |
| 978 | |
Alexander Bondar | 119663c | 2013-10-17 14:26:50 +0200 | [diff] [blame] | 979 | return count; |
| 980 | } |
| 981 | |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 982 | static ssize_t |
| 983 | iwl_dbgfs_scan_ant_rxchain_read(struct file *file, |
| 984 | char __user *user_buf, |
| 985 | size_t count, loff_t *ppos) |
| 986 | { |
| 987 | struct iwl_mvm *mvm = file->private_data; |
| 988 | int pos = 0; |
| 989 | char buf[32]; |
| 990 | const size_t bufsz = sizeof(buf); |
| 991 | |
| 992 | /* print which antennas were set for the scan command by the user */ |
| 993 | pos += scnprintf(buf + pos, bufsz - pos, "Antennas for scan: "); |
| 994 | if (mvm->scan_rx_ant & ANT_A) |
| 995 | pos += scnprintf(buf + pos, bufsz - pos, "A"); |
| 996 | if (mvm->scan_rx_ant & ANT_B) |
| 997 | pos += scnprintf(buf + pos, bufsz - pos, "B"); |
| 998 | if (mvm->scan_rx_ant & ANT_C) |
| 999 | pos += scnprintf(buf + pos, bufsz - pos, "C"); |
| 1000 | pos += scnprintf(buf + pos, bufsz - pos, " (%hhx)\n", mvm->scan_rx_ant); |
| 1001 | |
| 1002 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1003 | } |
| 1004 | |
| 1005 | static ssize_t |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1006 | iwl_dbgfs_scan_ant_rxchain_write(struct iwl_mvm *mvm, char *buf, |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 1007 | size_t count, loff_t *ppos) |
| 1008 | { |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 1009 | u8 scan_rx_ant; |
| 1010 | |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 1011 | if (!iwl_mvm_firmware_running(mvm)) |
| 1012 | return -EIO; |
| 1013 | |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 1014 | if (sscanf(buf, "%hhx", &scan_rx_ant) != 1) |
| 1015 | return -EINVAL; |
| 1016 | if (scan_rx_ant > ANT_ABC) |
| 1017 | return -EINVAL; |
Moshe Harel | a054427 | 2014-12-08 21:13:14 +0200 | [diff] [blame] | 1018 | if (scan_rx_ant & ~(iwl_mvm_get_valid_rx_ant(mvm))) |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 1019 | return -EINVAL; |
| 1020 | |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1021 | if (mvm->scan_rx_ant != scan_rx_ant) { |
| 1022 | mvm->scan_rx_ant = scan_rx_ant; |
Johannes Berg | 859d914 | 2015-06-01 17:11:11 +0200 | [diff] [blame] | 1023 | if (fw_has_capa(&mvm->fw->ucode_capa, |
| 1024 | IWL_UCODE_TLV_CAPA_UMAC_SCAN)) |
David Spinadel | d249622 | 2014-05-20 12:46:37 +0300 | [diff] [blame] | 1025 | iwl_mvm_config_scan(mvm); |
| 1026 | } |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 1027 | |
| 1028 | return count; |
| 1029 | } |
| 1030 | |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 1031 | static ssize_t iwl_dbgfs_indirection_tbl_write(struct iwl_mvm *mvm, |
| 1032 | char *buf, size_t count, |
| 1033 | loff_t *ppos) |
| 1034 | { |
| 1035 | struct iwl_rss_config_cmd cmd = { |
| 1036 | .flags = cpu_to_le32(IWL_RSS_ENABLE), |
| 1037 | .hash_mask = IWL_RSS_HASH_TYPE_IPV4_TCP | |
Sara Sharon | 854d773 | 2016-03-22 15:55:58 +0200 | [diff] [blame] | 1038 | IWL_RSS_HASH_TYPE_IPV4_UDP | |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 1039 | IWL_RSS_HASH_TYPE_IPV4_PAYLOAD | |
| 1040 | IWL_RSS_HASH_TYPE_IPV6_TCP | |
Sara Sharon | 854d773 | 2016-03-22 15:55:58 +0200 | [diff] [blame] | 1041 | IWL_RSS_HASH_TYPE_IPV6_UDP | |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 1042 | IWL_RSS_HASH_TYPE_IPV6_PAYLOAD, |
| 1043 | }; |
| 1044 | int ret, i, num_repeats, nbytes = count / 2; |
| 1045 | |
| 1046 | ret = hex2bin(cmd.indirection_table, buf, nbytes); |
| 1047 | if (ret) |
| 1048 | return ret; |
| 1049 | |
| 1050 | /* |
| 1051 | * The input is the redirection table, partial or full. |
| 1052 | * Repeat the pattern if needed. |
| 1053 | * For example, input of 01020F will be repeated 42 times, |
| 1054 | * indirecting RSS hash results to queues 1, 2, 15 (skipping |
| 1055 | * queues 3 - 14). |
| 1056 | */ |
| 1057 | num_repeats = ARRAY_SIZE(cmd.indirection_table) / nbytes; |
| 1058 | for (i = 1; i < num_repeats; i++) |
| 1059 | memcpy(&cmd.indirection_table[i * nbytes], |
| 1060 | cmd.indirection_table, nbytes); |
| 1061 | /* handle cut in the middle pattern for the last places */ |
| 1062 | memcpy(&cmd.indirection_table[i * nbytes], cmd.indirection_table, |
| 1063 | ARRAY_SIZE(cmd.indirection_table) % nbytes); |
| 1064 | |
Sara Sharon | 854d773 | 2016-03-22 15:55:58 +0200 | [diff] [blame] | 1065 | netdev_rss_key_fill(cmd.secret_key, sizeof(cmd.secret_key)); |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 1066 | |
| 1067 | mutex_lock(&mvm->mutex); |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 1068 | if (iwl_mvm_firmware_running(mvm)) |
| 1069 | ret = iwl_mvm_send_cmd_pdu(mvm, RSS_CONFIG_CMD, 0, |
| 1070 | sizeof(cmd), &cmd); |
| 1071 | else |
| 1072 | ret = 0; |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 1073 | mutex_unlock(&mvm->mutex); |
| 1074 | |
| 1075 | return ret ?: count; |
| 1076 | } |
| 1077 | |
Sara Sharon | 4857d6c | 2016-08-09 20:03:52 +0300 | [diff] [blame] | 1078 | static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mvm *mvm, |
| 1079 | char *buf, size_t count, |
| 1080 | loff_t *ppos) |
| 1081 | { |
| 1082 | struct iwl_rx_cmd_buffer rxb = { |
| 1083 | ._rx_page_order = 0, |
| 1084 | .truesize = 0, /* not used */ |
| 1085 | ._offset = 0, |
| 1086 | }; |
| 1087 | struct iwl_rx_packet *pkt; |
| 1088 | struct iwl_rx_mpdu_desc *desc; |
| 1089 | int bin_len = count / 2; |
| 1090 | int ret = -EINVAL; |
| 1091 | |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 1092 | if (!iwl_mvm_firmware_running(mvm)) |
| 1093 | return -EIO; |
| 1094 | |
Sara Sharon | 4857d6c | 2016-08-09 20:03:52 +0300 | [diff] [blame] | 1095 | /* supporting only 9000 descriptor */ |
| 1096 | if (!mvm->trans->cfg->mq_rx_supported) |
| 1097 | return -ENOTSUPP; |
| 1098 | |
| 1099 | rxb._page = alloc_pages(GFP_ATOMIC, 0); |
| 1100 | if (!rxb._page) |
| 1101 | return -ENOMEM; |
| 1102 | pkt = rxb_addr(&rxb); |
| 1103 | |
| 1104 | ret = hex2bin(page_address(rxb._page), buf, bin_len); |
| 1105 | if (ret) |
| 1106 | goto out; |
| 1107 | |
| 1108 | /* avoid invalid memory access */ |
| 1109 | if (bin_len < sizeof(*pkt) + sizeof(*desc)) |
| 1110 | goto out; |
| 1111 | |
| 1112 | /* check this is RX packet */ |
| 1113 | if (WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd) != |
| 1114 | WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD)) |
| 1115 | goto out; |
| 1116 | |
| 1117 | /* check the length in metadata matches actual received length */ |
| 1118 | desc = (void *)pkt->data; |
| 1119 | if (le16_to_cpu(desc->mpdu_len) != |
| 1120 | (bin_len - sizeof(*desc) - sizeof(*pkt))) |
| 1121 | goto out; |
| 1122 | |
| 1123 | local_bh_disable(); |
| 1124 | iwl_mvm_rx_mpdu_mq(mvm, NULL, &rxb, 0); |
| 1125 | local_bh_enable(); |
| 1126 | ret = 0; |
| 1127 | |
| 1128 | out: |
| 1129 | iwl_free_rxb(&rxb); |
| 1130 | |
| 1131 | return ret ?: count; |
| 1132 | } |
| 1133 | |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 1134 | static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file, |
| 1135 | char __user *user_buf, |
| 1136 | size_t count, loff_t *ppos) |
| 1137 | { |
| 1138 | struct iwl_mvm *mvm = file->private_data; |
Emmanuel Grumbach | d2709ad | 2015-01-29 14:58:06 +0200 | [diff] [blame] | 1139 | int conf; |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 1140 | char buf[8]; |
| 1141 | const size_t bufsz = sizeof(buf); |
| 1142 | int pos = 0; |
| 1143 | |
| 1144 | mutex_lock(&mvm->mutex); |
Johannes Berg | 7174beb | 2017-06-01 16:03:19 +0200 | [diff] [blame] | 1145 | conf = mvm->fwrt.dump.conf; |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 1146 | mutex_unlock(&mvm->mutex); |
| 1147 | |
| 1148 | pos += scnprintf(buf + pos, bufsz - pos, "%d\n", conf); |
| 1149 | |
| 1150 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1151 | } |
| 1152 | |
Golan Ben Ami | 321c210 | 2015-07-27 17:02:35 +0300 | [diff] [blame] | 1153 | /* |
| 1154 | * Enable / Disable continuous recording. |
| 1155 | * Cause the FW to start continuous recording, by sending the relevant hcmd. |
| 1156 | * Enable: input of every integer larger than 0, ENABLE_CONT_RECORDING. |
| 1157 | * Disable: for 0 as input, DISABLE_CONT_RECORDING. |
| 1158 | */ |
| 1159 | static ssize_t iwl_dbgfs_cont_recording_write(struct iwl_mvm *mvm, |
| 1160 | char *buf, size_t count, |
| 1161 | loff_t *ppos) |
| 1162 | { |
| 1163 | struct iwl_trans *trans = mvm->trans; |
| 1164 | const struct iwl_fw_dbg_dest_tlv *dest = trans->dbg_dest_tlv; |
| 1165 | struct iwl_continuous_record_cmd cont_rec = {}; |
| 1166 | int ret, rec_mode; |
| 1167 | |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 1168 | if (!iwl_mvm_firmware_running(mvm)) |
| 1169 | return -EIO; |
| 1170 | |
Golan Ben Ami | 321c210 | 2015-07-27 17:02:35 +0300 | [diff] [blame] | 1171 | if (!dest) |
| 1172 | return -EOPNOTSUPP; |
| 1173 | |
| 1174 | if (dest->monitor_mode != SMEM_MODE || |
Sara Sharon | 6e58487 | 2017-03-22 14:07:50 +0200 | [diff] [blame] | 1175 | trans->cfg->device_family < IWL_DEVICE_FAMILY_8000) |
Golan Ben Ami | 321c210 | 2015-07-27 17:02:35 +0300 | [diff] [blame] | 1176 | return -EOPNOTSUPP; |
| 1177 | |
Johannes Berg | 27e070d | 2016-01-14 10:55:22 +0100 | [diff] [blame] | 1178 | ret = kstrtoint(buf, 0, &rec_mode); |
Golan Ben Ami | 321c210 | 2015-07-27 17:02:35 +0300 | [diff] [blame] | 1179 | if (ret) |
| 1180 | return ret; |
| 1181 | |
| 1182 | cont_rec.record_mode.enable_recording = rec_mode ? |
| 1183 | cpu_to_le16(ENABLE_CONT_RECORDING) : |
| 1184 | cpu_to_le16(DISABLE_CONT_RECORDING); |
| 1185 | |
| 1186 | mutex_lock(&mvm->mutex); |
| 1187 | ret = iwl_mvm_send_cmd_pdu(mvm, LDBG_CONFIG_CMD, 0, |
| 1188 | sizeof(cont_rec), &cont_rec); |
| 1189 | mutex_unlock(&mvm->mutex); |
| 1190 | |
| 1191 | return ret ?: count; |
| 1192 | } |
| 1193 | |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 1194 | static ssize_t iwl_dbgfs_fw_dbg_conf_write(struct iwl_mvm *mvm, |
| 1195 | char *buf, size_t count, |
| 1196 | loff_t *ppos) |
| 1197 | { |
Dan Carpenter | 8e8114d | 2015-08-21 11:48:21 +0300 | [diff] [blame] | 1198 | unsigned int conf_id; |
| 1199 | int ret; |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 1200 | |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 1201 | if (!iwl_mvm_firmware_running(mvm)) |
| 1202 | return -EIO; |
| 1203 | |
Dan Carpenter | 8e8114d | 2015-08-21 11:48:21 +0300 | [diff] [blame] | 1204 | ret = kstrtouint(buf, 0, &conf_id); |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 1205 | if (ret) |
| 1206 | return ret; |
| 1207 | |
Emmanuel Grumbach | d2709ad | 2015-01-29 14:58:06 +0200 | [diff] [blame] | 1208 | if (WARN_ON(conf_id >= FW_DBG_CONF_MAX)) |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 1209 | return -EINVAL; |
| 1210 | |
| 1211 | mutex_lock(&mvm->mutex); |
Johannes Berg | 7174beb | 2017-06-01 16:03:19 +0200 | [diff] [blame] | 1212 | ret = iwl_fw_start_dbg_conf(&mvm->fwrt, conf_id); |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 1213 | mutex_unlock(&mvm->mutex); |
| 1214 | |
| 1215 | return ret ?: count; |
| 1216 | } |
| 1217 | |
| 1218 | static ssize_t iwl_dbgfs_fw_dbg_collect_write(struct iwl_mvm *mvm, |
| 1219 | char *buf, size_t count, |
| 1220 | loff_t *ppos) |
| 1221 | { |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 1222 | int ret; |
Liad Kaufman | e93475a | 2015-01-04 11:03:13 +0200 | [diff] [blame] | 1223 | |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 1224 | if (!iwl_mvm_firmware_running(mvm)) |
| 1225 | return -EIO; |
| 1226 | |
| 1227 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE); |
Liad Kaufman | e93475a | 2015-01-04 11:03:13 +0200 | [diff] [blame] | 1228 | if (ret) |
| 1229 | return ret; |
Dan Carpenter | 251fe09 | 2017-03-23 13:40:00 +0300 | [diff] [blame] | 1230 | if (count == 0) |
| 1231 | return 0; |
Liad Kaufman | e93475a | 2015-01-04 11:03:13 +0200 | [diff] [blame] | 1232 | |
Johannes Berg | 7174beb | 2017-06-01 16:03:19 +0200 | [diff] [blame] | 1233 | iwl_fw_dbg_collect(&mvm->fwrt, FW_DBG_TRIGGER_USER, buf, |
| 1234 | (count - 1), NULL); |
Liad Kaufman | e93475a | 2015-01-04 11:03:13 +0200 | [diff] [blame] | 1235 | |
| 1236 | iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE); |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 1237 | |
| 1238 | return count; |
| 1239 | } |
| 1240 | |
Emmanuel Grumbach | 9e7dce2 | 2015-10-26 16:14:06 +0200 | [diff] [blame] | 1241 | static ssize_t iwl_dbgfs_max_amsdu_len_write(struct iwl_mvm *mvm, |
| 1242 | char *buf, size_t count, |
| 1243 | loff_t *ppos) |
| 1244 | { |
| 1245 | unsigned int max_amsdu_len; |
| 1246 | int ret; |
| 1247 | |
| 1248 | ret = kstrtouint(buf, 0, &max_amsdu_len); |
Dan Carpenter | 32afd15 | 2016-05-04 09:19:54 +0300 | [diff] [blame] | 1249 | if (ret) |
| 1250 | return ret; |
Emmanuel Grumbach | 9e7dce2 | 2015-10-26 16:14:06 +0200 | [diff] [blame] | 1251 | |
| 1252 | if (max_amsdu_len > IEEE80211_MAX_MPDU_LEN_VHT_11454) |
| 1253 | return -EINVAL; |
| 1254 | mvm->max_amsdu_len = max_amsdu_len; |
| 1255 | |
| 1256 | return count; |
| 1257 | } |
| 1258 | |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1259 | #define ADD_TEXT(...) pos += scnprintf(buf + pos, bufsz - pos, __VA_ARGS__) |
| 1260 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
| 1261 | static ssize_t iwl_dbgfs_bcast_filters_read(struct file *file, |
| 1262 | char __user *user_buf, |
| 1263 | size_t count, loff_t *ppos) |
| 1264 | { |
| 1265 | struct iwl_mvm *mvm = file->private_data; |
| 1266 | struct iwl_bcast_filter_cmd cmd; |
| 1267 | const struct iwl_fw_bcast_filter *filter; |
| 1268 | char *buf; |
| 1269 | int bufsz = 1024; |
| 1270 | int i, j, pos = 0; |
| 1271 | ssize_t ret; |
| 1272 | |
| 1273 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1274 | if (!buf) |
| 1275 | return -ENOMEM; |
| 1276 | |
| 1277 | mutex_lock(&mvm->mutex); |
| 1278 | if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) { |
| 1279 | ADD_TEXT("None\n"); |
| 1280 | mutex_unlock(&mvm->mutex); |
| 1281 | goto out; |
| 1282 | } |
| 1283 | mutex_unlock(&mvm->mutex); |
| 1284 | |
| 1285 | for (i = 0; cmd.filters[i].attrs[0].mask; i++) { |
| 1286 | filter = &cmd.filters[i]; |
| 1287 | |
| 1288 | ADD_TEXT("Filter [%d]:\n", i); |
| 1289 | ADD_TEXT("\tDiscard=%d\n", filter->discard); |
| 1290 | ADD_TEXT("\tFrame Type: %s\n", |
| 1291 | filter->frame_type ? "IPv4" : "Generic"); |
| 1292 | |
| 1293 | for (j = 0; j < ARRAY_SIZE(filter->attrs); j++) { |
| 1294 | const struct iwl_fw_bcast_filter_attr *attr; |
| 1295 | |
| 1296 | attr = &filter->attrs[j]; |
| 1297 | if (!attr->mask) |
| 1298 | break; |
| 1299 | |
| 1300 | ADD_TEXT("\tAttr [%d]: offset=%d (from %s), mask=0x%x, value=0x%x reserved=0x%x\n", |
| 1301 | j, attr->offset, |
| 1302 | attr->offset_type ? "IP End" : |
| 1303 | "Payload Start", |
| 1304 | be32_to_cpu(attr->mask), |
| 1305 | be32_to_cpu(attr->val), |
| 1306 | le16_to_cpu(attr->reserved1)); |
| 1307 | } |
| 1308 | } |
| 1309 | out: |
| 1310 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1311 | kfree(buf); |
| 1312 | return ret; |
| 1313 | } |
| 1314 | |
| 1315 | static ssize_t iwl_dbgfs_bcast_filters_write(struct iwl_mvm *mvm, char *buf, |
| 1316 | size_t count, loff_t *ppos) |
| 1317 | { |
| 1318 | int pos, next_pos; |
| 1319 | struct iwl_fw_bcast_filter filter = {}; |
| 1320 | struct iwl_bcast_filter_cmd cmd; |
| 1321 | u32 filter_id, attr_id, mask, value; |
| 1322 | int err = 0; |
| 1323 | |
| 1324 | if (sscanf(buf, "%d %hhi %hhi %n", &filter_id, &filter.discard, |
| 1325 | &filter.frame_type, &pos) != 3) |
| 1326 | return -EINVAL; |
| 1327 | |
| 1328 | if (filter_id >= ARRAY_SIZE(mvm->dbgfs_bcast_filtering.cmd.filters) || |
| 1329 | filter.frame_type > BCAST_FILTER_FRAME_TYPE_IPV4) |
| 1330 | return -EINVAL; |
| 1331 | |
| 1332 | for (attr_id = 0; attr_id < ARRAY_SIZE(filter.attrs); |
| 1333 | attr_id++) { |
| 1334 | struct iwl_fw_bcast_filter_attr *attr = |
| 1335 | &filter.attrs[attr_id]; |
| 1336 | |
| 1337 | if (pos >= count) |
| 1338 | break; |
| 1339 | |
| 1340 | if (sscanf(&buf[pos], "%hhi %hhi %i %i %n", |
| 1341 | &attr->offset, &attr->offset_type, |
| 1342 | &mask, &value, &next_pos) != 4) |
| 1343 | return -EINVAL; |
| 1344 | |
| 1345 | attr->mask = cpu_to_be32(mask); |
| 1346 | attr->val = cpu_to_be32(value); |
| 1347 | if (mask) |
| 1348 | filter.num_attrs++; |
| 1349 | |
| 1350 | pos += next_pos; |
| 1351 | } |
| 1352 | |
| 1353 | mutex_lock(&mvm->mutex); |
| 1354 | memcpy(&mvm->dbgfs_bcast_filtering.cmd.filters[filter_id], |
| 1355 | &filter, sizeof(filter)); |
| 1356 | |
| 1357 | /* send updated bcast filtering configuration */ |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 1358 | if (iwl_mvm_firmware_running(mvm) && |
| 1359 | mvm->dbgfs_bcast_filtering.override && |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1360 | iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 1361 | err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0, |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1362 | sizeof(cmd), &cmd); |
| 1363 | mutex_unlock(&mvm->mutex); |
| 1364 | |
| 1365 | return err ?: count; |
| 1366 | } |
| 1367 | |
| 1368 | static ssize_t iwl_dbgfs_bcast_filters_macs_read(struct file *file, |
| 1369 | char __user *user_buf, |
| 1370 | size_t count, loff_t *ppos) |
| 1371 | { |
| 1372 | struct iwl_mvm *mvm = file->private_data; |
| 1373 | struct iwl_bcast_filter_cmd cmd; |
| 1374 | char *buf; |
| 1375 | int bufsz = 1024; |
| 1376 | int i, pos = 0; |
| 1377 | ssize_t ret; |
| 1378 | |
| 1379 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1380 | if (!buf) |
| 1381 | return -ENOMEM; |
| 1382 | |
| 1383 | mutex_lock(&mvm->mutex); |
| 1384 | if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) { |
| 1385 | ADD_TEXT("None\n"); |
| 1386 | mutex_unlock(&mvm->mutex); |
| 1387 | goto out; |
| 1388 | } |
| 1389 | mutex_unlock(&mvm->mutex); |
| 1390 | |
| 1391 | for (i = 0; i < ARRAY_SIZE(cmd.macs); i++) { |
| 1392 | const struct iwl_fw_bcast_mac *mac = &cmd.macs[i]; |
| 1393 | |
| 1394 | ADD_TEXT("Mac [%d]: discard=%d attached_filters=0x%x\n", |
| 1395 | i, mac->default_discard, mac->attached_filters); |
| 1396 | } |
| 1397 | out: |
| 1398 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1399 | kfree(buf); |
| 1400 | return ret; |
| 1401 | } |
| 1402 | |
| 1403 | static ssize_t iwl_dbgfs_bcast_filters_macs_write(struct iwl_mvm *mvm, |
| 1404 | char *buf, size_t count, |
| 1405 | loff_t *ppos) |
| 1406 | { |
| 1407 | struct iwl_bcast_filter_cmd cmd; |
| 1408 | struct iwl_fw_bcast_mac mac = {}; |
| 1409 | u32 mac_id, attached_filters; |
| 1410 | int err = 0; |
| 1411 | |
| 1412 | if (!mvm->bcast_filters) |
| 1413 | return -ENOENT; |
| 1414 | |
| 1415 | if (sscanf(buf, "%d %hhi %i", &mac_id, &mac.default_discard, |
| 1416 | &attached_filters) != 3) |
| 1417 | return -EINVAL; |
| 1418 | |
| 1419 | if (mac_id >= ARRAY_SIZE(cmd.macs) || |
| 1420 | mac.default_discard > 1 || |
| 1421 | attached_filters >= BIT(ARRAY_SIZE(cmd.filters))) |
| 1422 | return -EINVAL; |
| 1423 | |
| 1424 | mac.attached_filters = cpu_to_le16(attached_filters); |
| 1425 | |
| 1426 | mutex_lock(&mvm->mutex); |
| 1427 | memcpy(&mvm->dbgfs_bcast_filtering.cmd.macs[mac_id], |
| 1428 | &mac, sizeof(mac)); |
| 1429 | |
| 1430 | /* send updated bcast filtering configuration */ |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 1431 | if (iwl_mvm_firmware_running(mvm) && |
| 1432 | mvm->dbgfs_bcast_filtering.override && |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1433 | iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) |
Emmanuel Grumbach | a102292 | 2014-05-12 11:36:41 +0300 | [diff] [blame] | 1434 | err = iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0, |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1435 | sizeof(cmd), &cmd); |
| 1436 | mutex_unlock(&mvm->mutex); |
| 1437 | |
| 1438 | return err ?: count; |
| 1439 | } |
| 1440 | #endif |
| 1441 | |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1442 | #ifdef CONFIG_PM_SLEEP |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1443 | 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] | 1444 | size_t count, loff_t *ppos) |
| 1445 | { |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1446 | int store; |
| 1447 | |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1448 | if (sscanf(buf, "%d", &store) != 1) |
| 1449 | return -EINVAL; |
| 1450 | |
| 1451 | mvm->store_d3_resume_sram = store; |
| 1452 | |
| 1453 | return count; |
| 1454 | } |
| 1455 | |
| 1456 | static ssize_t iwl_dbgfs_d3_sram_read(struct file *file, char __user *user_buf, |
| 1457 | size_t count, loff_t *ppos) |
| 1458 | { |
| 1459 | struct iwl_mvm *mvm = file->private_data; |
| 1460 | const struct fw_img *img; |
| 1461 | int ofs, len, pos = 0; |
| 1462 | size_t bufsz, ret; |
| 1463 | char *buf; |
| 1464 | u8 *ptr = mvm->d3_resume_sram; |
| 1465 | |
| 1466 | img = &mvm->fw->img[IWL_UCODE_WOWLAN]; |
| 1467 | len = img->sec[IWL_UCODE_SECTION_DATA].len; |
| 1468 | |
| 1469 | bufsz = len * 4 + 256; |
| 1470 | buf = kzalloc(bufsz, GFP_KERNEL); |
| 1471 | if (!buf) |
| 1472 | return -ENOMEM; |
| 1473 | |
| 1474 | pos += scnprintf(buf, bufsz, "D3 SRAM capture: %sabled\n", |
| 1475 | mvm->store_d3_resume_sram ? "en" : "dis"); |
| 1476 | |
| 1477 | if (ptr) { |
| 1478 | for (ofs = 0; ofs < len; ofs += 16) { |
| 1479 | pos += scnprintf(buf + pos, bufsz - pos, |
Andy Shevchenko | 3cd6e2f | 2015-07-16 15:42:14 +0300 | [diff] [blame] | 1480 | "0x%.4x %16ph\n", ofs, ptr + ofs); |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1481 | } |
| 1482 | } else { |
| 1483 | pos += scnprintf(buf + pos, bufsz - pos, |
| 1484 | "(no data captured)\n"); |
| 1485 | } |
| 1486 | |
| 1487 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1488 | |
| 1489 | kfree(buf); |
| 1490 | |
| 1491 | return ret; |
| 1492 | } |
| 1493 | #endif |
| 1494 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1495 | #define PRINT_MVM_REF(ref) do { \ |
| 1496 | if (mvm->refs[ref]) \ |
| 1497 | pos += scnprintf(buf + pos, bufsz - pos, \ |
| 1498 | "\t(0x%lx): %d %s\n", \ |
| 1499 | BIT(ref), mvm->refs[ref], #ref); \ |
Eliad Peller | 70d6bab | 2013-11-05 14:45:16 +0200 | [diff] [blame] | 1500 | } while (0) |
| 1501 | |
| 1502 | static ssize_t iwl_dbgfs_d0i3_refs_read(struct file *file, |
| 1503 | char __user *user_buf, |
| 1504 | size_t count, loff_t *ppos) |
| 1505 | { |
| 1506 | struct iwl_mvm *mvm = file->private_data; |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1507 | int i, pos = 0; |
Eliad Peller | 70d6bab | 2013-11-05 14:45:16 +0200 | [diff] [blame] | 1508 | char buf[256]; |
| 1509 | const size_t bufsz = sizeof(buf); |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1510 | u32 refs = 0; |
Eliad Peller | 70d6bab | 2013-11-05 14:45:16 +0200 | [diff] [blame] | 1511 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1512 | for (i = 0; i < IWL_MVM_REF_COUNT; i++) |
| 1513 | if (mvm->refs[i]) |
| 1514 | refs |= BIT(i); |
| 1515 | |
| 1516 | pos += scnprintf(buf + pos, bufsz - pos, "taken mvm refs: 0x%x\n", |
| 1517 | refs); |
Eliad Peller | 70d6bab | 2013-11-05 14:45:16 +0200 | [diff] [blame] | 1518 | |
| 1519 | PRINT_MVM_REF(IWL_MVM_REF_UCODE_DOWN); |
| 1520 | PRINT_MVM_REF(IWL_MVM_REF_SCAN); |
| 1521 | PRINT_MVM_REF(IWL_MVM_REF_ROC); |
Eliad Peller | c779273 | 2015-04-19 11:41:04 +0300 | [diff] [blame] | 1522 | PRINT_MVM_REF(IWL_MVM_REF_ROC_AUX); |
Eliad Peller | 70d6bab | 2013-11-05 14:45:16 +0200 | [diff] [blame] | 1523 | PRINT_MVM_REF(IWL_MVM_REF_P2P_CLIENT); |
| 1524 | PRINT_MVM_REF(IWL_MVM_REF_AP_IBSS); |
Eliad Peller | 0eb8365 | 2013-11-11 18:56:35 +0200 | [diff] [blame] | 1525 | PRINT_MVM_REF(IWL_MVM_REF_USER); |
Johannes Berg | 34e611e | 2014-09-12 10:28:01 +0200 | [diff] [blame] | 1526 | PRINT_MVM_REF(IWL_MVM_REF_TX); |
| 1527 | PRINT_MVM_REF(IWL_MVM_REF_TX_AGG); |
| 1528 | PRINT_MVM_REF(IWL_MVM_REF_ADD_IF); |
| 1529 | PRINT_MVM_REF(IWL_MVM_REF_START_AP); |
| 1530 | PRINT_MVM_REF(IWL_MVM_REF_BSS_CHANGED); |
| 1531 | PRINT_MVM_REF(IWL_MVM_REF_PREPARE_TX); |
| 1532 | PRINT_MVM_REF(IWL_MVM_REF_PROTECT_TDLS); |
| 1533 | PRINT_MVM_REF(IWL_MVM_REF_CHECK_CTKILL); |
| 1534 | PRINT_MVM_REF(IWL_MVM_REF_PRPH_READ); |
| 1535 | PRINT_MVM_REF(IWL_MVM_REF_PRPH_WRITE); |
| 1536 | PRINT_MVM_REF(IWL_MVM_REF_NMI); |
| 1537 | PRINT_MVM_REF(IWL_MVM_REF_TM_CMD); |
Eliad Peller | d15a747 | 2014-03-27 18:53:12 +0200 | [diff] [blame] | 1538 | PRINT_MVM_REF(IWL_MVM_REF_EXIT_WORK); |
Eliad Peller | 160acc0 | 2014-11-25 12:34:45 +0200 | [diff] [blame] | 1539 | PRINT_MVM_REF(IWL_MVM_REF_PROTECT_CSA); |
Liad Kaufman | fb2380a | 2015-01-01 17:42:46 +0200 | [diff] [blame] | 1540 | PRINT_MVM_REF(IWL_MVM_REF_FW_DBG_COLLECT); |
Eliad Peller | 08f0d23 | 2015-12-10 15:47:11 +0200 | [diff] [blame] | 1541 | PRINT_MVM_REF(IWL_MVM_REF_INIT_UCODE); |
Luca Coelho | 71b1230 | 2016-03-11 12:12:16 +0200 | [diff] [blame] | 1542 | PRINT_MVM_REF(IWL_MVM_REF_SENDING_CMD); |
Luca Coelho | 16e4dd8 | 2016-03-30 15:05:56 +0300 | [diff] [blame] | 1543 | PRINT_MVM_REF(IWL_MVM_REF_RX); |
Eliad Peller | 70d6bab | 2013-11-05 14:45:16 +0200 | [diff] [blame] | 1544 | |
| 1545 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1546 | } |
| 1547 | |
Eliad Peller | 0eb8365 | 2013-11-11 18:56:35 +0200 | [diff] [blame] | 1548 | static ssize_t iwl_dbgfs_d0i3_refs_write(struct iwl_mvm *mvm, char *buf, |
| 1549 | size_t count, loff_t *ppos) |
| 1550 | { |
| 1551 | unsigned long value; |
| 1552 | int ret; |
| 1553 | bool taken; |
| 1554 | |
| 1555 | ret = kstrtoul(buf, 10, &value); |
| 1556 | if (ret < 0) |
| 1557 | return ret; |
| 1558 | |
| 1559 | mutex_lock(&mvm->mutex); |
| 1560 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1561 | taken = mvm->refs[IWL_MVM_REF_USER]; |
Eliad Peller | 0eb8365 | 2013-11-11 18:56:35 +0200 | [diff] [blame] | 1562 | if (value == 1 && !taken) |
| 1563 | iwl_mvm_ref(mvm, IWL_MVM_REF_USER); |
| 1564 | else if (value == 0 && taken) |
| 1565 | iwl_mvm_unref(mvm, IWL_MVM_REF_USER); |
| 1566 | else |
| 1567 | ret = -EINVAL; |
| 1568 | |
| 1569 | mutex_unlock(&mvm->mutex); |
| 1570 | |
| 1571 | if (ret < 0) |
| 1572 | return ret; |
| 1573 | return count; |
| 1574 | } |
| 1575 | |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1576 | #define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \ |
| 1577 | _MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm) |
| 1578 | #define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz) \ |
| 1579 | _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, bufsz, struct iwl_mvm) |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1580 | #define MVM_DEBUGFS_ADD_FILE_ALIAS(alias, name, parent, mode) do { \ |
| 1581 | if (!debugfs_create_file(alias, mode, parent, mvm, \ |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1582 | &iwl_dbgfs_##name##_ops)) \ |
| 1583 | goto err; \ |
| 1584 | } while (0) |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1585 | #define MVM_DEBUGFS_ADD_FILE(name, parent, mode) \ |
| 1586 | MVM_DEBUGFS_ADD_FILE_ALIAS(#name, name, parent, mode) |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1587 | |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1588 | static ssize_t |
| 1589 | iwl_dbgfs_prph_reg_read(struct file *file, |
| 1590 | char __user *user_buf, |
| 1591 | size_t count, loff_t *ppos) |
| 1592 | { |
| 1593 | struct iwl_mvm *mvm = file->private_data; |
| 1594 | int pos = 0; |
| 1595 | char buf[32]; |
| 1596 | const size_t bufsz = sizeof(buf); |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1597 | int ret; |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1598 | |
| 1599 | if (!mvm->dbgfs_prph_reg_addr) |
| 1600 | return -EINVAL; |
| 1601 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1602 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_READ); |
| 1603 | if (ret) |
| 1604 | return ret; |
| 1605 | |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1606 | pos += scnprintf(buf + pos, bufsz - pos, "Reg 0x%x: (0x%x)\n", |
| 1607 | mvm->dbgfs_prph_reg_addr, |
| 1608 | iwl_read_prph(mvm->trans, mvm->dbgfs_prph_reg_addr)); |
| 1609 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1610 | iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_READ); |
| 1611 | |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1612 | return simple_read_from_buffer(user_buf, count, ppos, buf, pos); |
| 1613 | } |
| 1614 | |
| 1615 | static ssize_t |
| 1616 | iwl_dbgfs_prph_reg_write(struct iwl_mvm *mvm, char *buf, |
| 1617 | size_t count, loff_t *ppos) |
| 1618 | { |
| 1619 | u8 args; |
| 1620 | u32 value; |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1621 | int ret; |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1622 | |
| 1623 | args = sscanf(buf, "%i %i", &mvm->dbgfs_prph_reg_addr, &value); |
| 1624 | /* if we only want to set the reg address - nothing more to do */ |
| 1625 | if (args == 1) |
| 1626 | goto out; |
| 1627 | |
| 1628 | /* otherwise, make sure we have both address and value */ |
| 1629 | if (args != 2) |
| 1630 | return -EINVAL; |
| 1631 | |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1632 | ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE); |
| 1633 | if (ret) |
| 1634 | return ret; |
| 1635 | |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1636 | iwl_write_prph(mvm->trans, mvm->dbgfs_prph_reg_addr, value); |
Eliad Peller | 576eeee | 2014-07-01 18:38:38 +0300 | [diff] [blame] | 1637 | |
| 1638 | iwl_mvm_unref(mvm, IWL_MVM_REF_PRPH_WRITE); |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1639 | out: |
| 1640 | return count; |
| 1641 | } |
| 1642 | |
Emmanuel Grumbach | e504601 | 2015-08-17 10:45:50 +0300 | [diff] [blame] | 1643 | static ssize_t |
| 1644 | iwl_dbgfs_send_echo_cmd_write(struct iwl_mvm *mvm, char *buf, |
| 1645 | size_t count, loff_t *ppos) |
| 1646 | { |
| 1647 | int ret; |
| 1648 | |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 1649 | if (!iwl_mvm_firmware_running(mvm)) |
| 1650 | return -EIO; |
| 1651 | |
Emmanuel Grumbach | e504601 | 2015-08-17 10:45:50 +0300 | [diff] [blame] | 1652 | mutex_lock(&mvm->mutex); |
| 1653 | ret = iwl_mvm_send_cmd_pdu(mvm, ECHO_CMD, 0, 0, NULL); |
| 1654 | mutex_unlock(&mvm->mutex); |
| 1655 | |
| 1656 | return ret ?: count; |
| 1657 | } |
| 1658 | |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1659 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(prph_reg, 64); |
| 1660 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1661 | /* Device wide debugfs entries */ |
Chaya Rachel Ivgi | 00f481b | 2016-02-24 12:19:22 +0200 | [diff] [blame] | 1662 | MVM_DEBUGFS_READ_FILE_OPS(ctdp_budget); |
| 1663 | MVM_DEBUGFS_WRITE_FILE_OPS(stop_ctdp, 8); |
Chaya Rachel Ivgi | 61d8c62 | 2017-06-27 14:13:02 +0300 | [diff] [blame] | 1664 | MVM_DEBUGFS_WRITE_FILE_OPS(force_ctkill, 8); |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1665 | MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush, 16); |
| 1666 | MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain, 8); |
Emmanuel Grumbach | e504601 | 2015-08-17 10:45:50 +0300 | [diff] [blame] | 1667 | MVM_DEBUGFS_WRITE_FILE_OPS(send_echo_cmd, 8); |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1668 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram, 64); |
Matti Gottlieb | 7280d1f | 2014-07-17 16:41:14 +0300 | [diff] [blame] | 1669 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(set_nic_temperature, 64); |
Luciano Coelho | c549e39 | 2014-09-04 15:58:47 +0300 | [diff] [blame] | 1670 | MVM_DEBUGFS_READ_FILE_OPS(nic_temp); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1671 | MVM_DEBUGFS_READ_FILE_OPS(stations); |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 1672 | MVM_DEBUGFS_READ_FILE_OPS(bt_notif); |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 1673 | MVM_DEBUGFS_READ_FILE_OPS(bt_cmd); |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1674 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(disable_power_off, 64); |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 1675 | MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 1676 | MVM_DEBUGFS_READ_FILE_OPS(drv_rx_stats); |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1677 | MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart, 10); |
| 1678 | MVM_DEBUGFS_WRITE_FILE_OPS(fw_nmi, 10); |
Emmanuel Grumbach | cdb0056 | 2014-03-16 21:55:43 +0200 | [diff] [blame] | 1679 | MVM_DEBUGFS_WRITE_FILE_OPS(bt_tx_prio, 10); |
Emmanuel Grumbach | a39979a | 2014-05-28 12:06:41 +0300 | [diff] [blame] | 1680 | MVM_DEBUGFS_WRITE_FILE_OPS(bt_force_ant, 10); |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1681 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain, 8); |
Eliad Peller | 0eb8365 | 2013-11-11 18:56:35 +0200 | [diff] [blame] | 1682 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(d0i3_refs, 8); |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 1683 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(fw_dbg_conf, 8); |
Golan Ben-Ami | c91b865 | 2015-11-30 14:30:21 +0200 | [diff] [blame] | 1684 | MVM_DEBUGFS_WRITE_FILE_OPS(fw_dbg_collect, 64); |
Golan Ben Ami | 321c210 | 2015-07-27 17:02:35 +0300 | [diff] [blame] | 1685 | MVM_DEBUGFS_WRITE_FILE_OPS(cont_recording, 8); |
Emmanuel Grumbach | 9e7dce2 | 2015-10-26 16:14:06 +0200 | [diff] [blame] | 1686 | MVM_DEBUGFS_WRITE_FILE_OPS(max_amsdu_len, 8); |
Sara Sharon | dd4d316 | 2016-02-07 12:50:35 +0200 | [diff] [blame] | 1687 | MVM_DEBUGFS_WRITE_FILE_OPS(indirection_tbl, |
| 1688 | (IWL_RSS_INDIRECTION_TABLE_SIZE * 2)); |
Sara Sharon | 4857d6c | 2016-08-09 20:03:52 +0300 | [diff] [blame] | 1689 | MVM_DEBUGFS_WRITE_FILE_OPS(inject_packet, 512); |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 1690 | |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1691 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
| 1692 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters, 256); |
| 1693 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(bcast_filters_macs, 256); |
| 1694 | #endif |
| 1695 | |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1696 | #ifdef CONFIG_PM_SLEEP |
Johannes Berg | 1fa3f57 | 2013-11-13 09:10:21 +0100 | [diff] [blame] | 1697 | MVM_DEBUGFS_READ_WRITE_FILE_OPS(d3_sram, 8); |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1698 | #endif |
Haim Dreyfuss | e6ee065 | 2017-05-15 14:27:21 +0300 | [diff] [blame] | 1699 | #ifdef CONFIG_ACPI |
| 1700 | MVM_DEBUGFS_READ_FILE_OPS(sar_geo_profile); |
| 1701 | #endif |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1702 | |
Ido Yariv | 2b55f43 | 2016-08-23 14:44:59 -0400 | [diff] [blame] | 1703 | static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf, |
| 1704 | size_t count, loff_t *ppos) |
| 1705 | { |
| 1706 | struct iwl_mvm *mvm = file->private_data; |
| 1707 | struct iwl_dbg_mem_access_cmd cmd = {}; |
| 1708 | struct iwl_dbg_mem_access_rsp *rsp; |
| 1709 | struct iwl_host_cmd hcmd = { |
| 1710 | .flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL, |
| 1711 | .data = { &cmd, }, |
| 1712 | .len = { sizeof(cmd) }, |
| 1713 | }; |
Luca Coelho | 276c4b4 | 2016-09-28 11:32:35 +0300 | [diff] [blame] | 1714 | size_t delta; |
| 1715 | ssize_t ret, len; |
Ido Yariv | 2b55f43 | 2016-08-23 14:44:59 -0400 | [diff] [blame] | 1716 | |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 1717 | if (!iwl_mvm_firmware_running(mvm)) |
| 1718 | return -EIO; |
| 1719 | |
Ido Yariv | 2b55f43 | 2016-08-23 14:44:59 -0400 | [diff] [blame] | 1720 | hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR, |
| 1721 | DEBUG_GROUP, 0); |
| 1722 | cmd.op = cpu_to_le32(DEBUG_MEM_OP_READ); |
| 1723 | |
| 1724 | /* Take care of alignment of both the position and the length */ |
| 1725 | delta = *ppos & 0x3; |
| 1726 | cmd.addr = cpu_to_le32(*ppos - delta); |
| 1727 | cmd.len = cpu_to_le32(min(ALIGN(count + delta, 4) / 4, |
| 1728 | (size_t)DEBUG_MEM_MAX_SIZE_DWORDS)); |
| 1729 | |
| 1730 | mutex_lock(&mvm->mutex); |
| 1731 | ret = iwl_mvm_send_cmd(mvm, &hcmd); |
| 1732 | mutex_unlock(&mvm->mutex); |
| 1733 | |
| 1734 | if (ret < 0) |
| 1735 | return ret; |
| 1736 | |
| 1737 | rsp = (void *)hcmd.resp_pkt->data; |
| 1738 | if (le32_to_cpu(rsp->status) != DEBUG_MEM_STATUS_SUCCESS) { |
| 1739 | ret = -ENXIO; |
| 1740 | goto out; |
| 1741 | } |
| 1742 | |
| 1743 | len = min((size_t)le32_to_cpu(rsp->len) << 2, |
| 1744 | iwl_rx_packet_payload_len(hcmd.resp_pkt) - sizeof(*rsp)); |
| 1745 | len = min(len - delta, count); |
| 1746 | if (len < 0) { |
| 1747 | ret = -EFAULT; |
| 1748 | goto out; |
| 1749 | } |
| 1750 | |
| 1751 | ret = len - copy_to_user(user_buf, (void *)rsp->data + delta, len); |
| 1752 | *ppos += ret; |
| 1753 | |
| 1754 | out: |
| 1755 | iwl_free_resp(&hcmd); |
| 1756 | return ret; |
| 1757 | } |
| 1758 | |
| 1759 | static ssize_t iwl_dbgfs_mem_write(struct file *file, |
| 1760 | const char __user *user_buf, size_t count, |
| 1761 | loff_t *ppos) |
| 1762 | { |
| 1763 | struct iwl_mvm *mvm = file->private_data; |
| 1764 | struct iwl_dbg_mem_access_cmd *cmd; |
| 1765 | struct iwl_dbg_mem_access_rsp *rsp; |
| 1766 | struct iwl_host_cmd hcmd = {}; |
| 1767 | size_t cmd_size; |
| 1768 | size_t data_size; |
| 1769 | u32 op, len; |
| 1770 | ssize_t ret; |
| 1771 | |
Johannes Berg | 504bd62 | 2017-03-22 22:19:41 +0100 | [diff] [blame] | 1772 | if (!iwl_mvm_firmware_running(mvm)) |
| 1773 | return -EIO; |
| 1774 | |
Ido Yariv | 2b55f43 | 2016-08-23 14:44:59 -0400 | [diff] [blame] | 1775 | hcmd.id = iwl_cmd_id(*ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR, |
| 1776 | DEBUG_GROUP, 0); |
| 1777 | |
| 1778 | if (*ppos & 0x3 || count < 4) { |
| 1779 | op = DEBUG_MEM_OP_WRITE_BYTES; |
| 1780 | len = min(count, (size_t)(4 - (*ppos & 0x3))); |
| 1781 | data_size = len; |
| 1782 | } else { |
| 1783 | op = DEBUG_MEM_OP_WRITE; |
| 1784 | len = min(count >> 2, (size_t)DEBUG_MEM_MAX_SIZE_DWORDS); |
| 1785 | data_size = len << 2; |
| 1786 | } |
| 1787 | |
| 1788 | cmd_size = sizeof(*cmd) + ALIGN(data_size, 4); |
| 1789 | cmd = kzalloc(cmd_size, GFP_KERNEL); |
| 1790 | if (!cmd) |
| 1791 | return -ENOMEM; |
| 1792 | |
| 1793 | cmd->op = cpu_to_le32(op); |
| 1794 | cmd->len = cpu_to_le32(len); |
| 1795 | cmd->addr = cpu_to_le32(*ppos); |
| 1796 | if (copy_from_user((void *)cmd->data, user_buf, data_size)) { |
| 1797 | kfree(cmd); |
| 1798 | return -EFAULT; |
| 1799 | } |
| 1800 | |
| 1801 | hcmd.flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL, |
| 1802 | hcmd.data[0] = (void *)cmd; |
| 1803 | hcmd.len[0] = cmd_size; |
| 1804 | |
| 1805 | mutex_lock(&mvm->mutex); |
| 1806 | ret = iwl_mvm_send_cmd(mvm, &hcmd); |
| 1807 | mutex_unlock(&mvm->mutex); |
| 1808 | |
| 1809 | kfree(cmd); |
| 1810 | |
| 1811 | if (ret < 0) |
| 1812 | return ret; |
| 1813 | |
| 1814 | rsp = (void *)hcmd.resp_pkt->data; |
| 1815 | if (rsp->status != DEBUG_MEM_STATUS_SUCCESS) { |
| 1816 | ret = -ENXIO; |
| 1817 | goto out; |
| 1818 | } |
| 1819 | |
| 1820 | ret = data_size; |
| 1821 | *ppos += ret; |
| 1822 | |
| 1823 | out: |
| 1824 | iwl_free_resp(&hcmd); |
| 1825 | return ret; |
| 1826 | } |
| 1827 | |
| 1828 | static const struct file_operations iwl_dbgfs_mem_ops = { |
| 1829 | .read = iwl_dbgfs_mem_read, |
| 1830 | .write = iwl_dbgfs_mem_write, |
| 1831 | .open = simple_open, |
| 1832 | .llseek = default_llseek, |
| 1833 | }; |
| 1834 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1835 | int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir) |
| 1836 | { |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1837 | struct dentry *bcast_dir __maybe_unused; |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1838 | char buf[100]; |
| 1839 | |
Johannes Berg | d07913a | 2014-02-26 11:25:58 +0100 | [diff] [blame] | 1840 | spin_lock_init(&mvm->drv_stats_lock); |
| 1841 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1842 | mvm->debugfs_dir = dbgfs_dir; |
| 1843 | |
| 1844 | MVM_DEBUGFS_ADD_FILE(tx_flush, mvm->debugfs_dir, S_IWUSR); |
| 1845 | MVM_DEBUGFS_ADD_FILE(sta_drain, mvm->debugfs_dir, S_IWUSR); |
| 1846 | MVM_DEBUGFS_ADD_FILE(sram, mvm->debugfs_dir, S_IWUSR | S_IRUSR); |
Matti Gottlieb | 7280d1f | 2014-07-17 16:41:14 +0300 | [diff] [blame] | 1847 | MVM_DEBUGFS_ADD_FILE(set_nic_temperature, mvm->debugfs_dir, |
| 1848 | S_IWUSR | S_IRUSR); |
Luciano Coelho | c549e39 | 2014-09-04 15:58:47 +0300 | [diff] [blame] | 1849 | MVM_DEBUGFS_ADD_FILE(nic_temp, dbgfs_dir, S_IRUSR); |
Chaya Rachel Ivgi | 00f481b | 2016-02-24 12:19:22 +0200 | [diff] [blame] | 1850 | MVM_DEBUGFS_ADD_FILE(ctdp_budget, dbgfs_dir, S_IRUSR); |
| 1851 | MVM_DEBUGFS_ADD_FILE(stop_ctdp, dbgfs_dir, S_IWUSR); |
Chaya Rachel Ivgi | 61d8c62 | 2017-06-27 14:13:02 +0300 | [diff] [blame] | 1852 | MVM_DEBUGFS_ADD_FILE(force_ctkill, dbgfs_dir, S_IWUSR); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1853 | MVM_DEBUGFS_ADD_FILE(stations, dbgfs_dir, S_IRUSR); |
Emmanuel Grumbach | 1094234 | 2013-02-19 11:02:36 +0200 | [diff] [blame] | 1854 | MVM_DEBUGFS_ADD_FILE(bt_notif, dbgfs_dir, S_IRUSR); |
Emmanuel Grumbach | 2de13ca | 2013-06-30 07:43:28 +0300 | [diff] [blame] | 1855 | MVM_DEBUGFS_ADD_FILE(bt_cmd, dbgfs_dir, S_IRUSR); |
Emmanuel Grumbach | 639eaba | 2014-03-30 10:11:13 +0300 | [diff] [blame] | 1856 | MVM_DEBUGFS_ADD_FILE(disable_power_off, mvm->debugfs_dir, |
| 1857 | S_IRUSR | S_IWUSR); |
Matti Gottlieb | 3848ab6 | 2013-07-30 15:29:37 +0300 | [diff] [blame] | 1858 | MVM_DEBUGFS_ADD_FILE(fw_rx_stats, mvm->debugfs_dir, S_IRUSR); |
Eyal Shapira | 5fc0f76 | 2014-01-28 01:35:32 +0200 | [diff] [blame] | 1859 | MVM_DEBUGFS_ADD_FILE(drv_rx_stats, mvm->debugfs_dir, S_IRUSR); |
Emmanuel Grumbach | 490953a | 2013-03-04 08:53:07 +0200 | [diff] [blame] | 1860 | MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, S_IWUSR); |
Alexander Bondar | 119663c | 2013-10-17 14:26:50 +0200 | [diff] [blame] | 1861 | MVM_DEBUGFS_ADD_FILE(fw_nmi, mvm->debugfs_dir, S_IWUSR); |
Emmanuel Grumbach | cdb0056 | 2014-03-16 21:55:43 +0200 | [diff] [blame] | 1862 | MVM_DEBUGFS_ADD_FILE(bt_tx_prio, mvm->debugfs_dir, S_IWUSR); |
Emmanuel Grumbach | a39979a | 2014-05-28 12:06:41 +0300 | [diff] [blame] | 1863 | MVM_DEBUGFS_ADD_FILE(bt_force_ant, mvm->debugfs_dir, S_IWUSR); |
Oren Givon | 91b05d1 | 2013-08-19 08:36:48 +0300 | [diff] [blame] | 1864 | MVM_DEBUGFS_ADD_FILE(scan_ant_rxchain, mvm->debugfs_dir, |
| 1865 | S_IWUSR | S_IRUSR); |
Eliad Peller | f3c221f | 2014-01-09 13:12:54 +0200 | [diff] [blame] | 1866 | 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] | 1867 | MVM_DEBUGFS_ADD_FILE(d0i3_refs, mvm->debugfs_dir, S_IRUSR | S_IWUSR); |
Emmanuel Grumbach | 8c23f95 | 2014-12-04 10:07:47 +0200 | [diff] [blame] | 1868 | MVM_DEBUGFS_ADD_FILE(fw_dbg_conf, mvm->debugfs_dir, S_IRUSR | S_IWUSR); |
| 1869 | MVM_DEBUGFS_ADD_FILE(fw_dbg_collect, mvm->debugfs_dir, S_IWUSR); |
Emmanuel Grumbach | 9e7dce2 | 2015-10-26 16:14:06 +0200 | [diff] [blame] | 1870 | MVM_DEBUGFS_ADD_FILE(max_amsdu_len, mvm->debugfs_dir, S_IWUSR); |
Emmanuel Grumbach | e504601 | 2015-08-17 10:45:50 +0300 | [diff] [blame] | 1871 | MVM_DEBUGFS_ADD_FILE(send_echo_cmd, mvm->debugfs_dir, S_IWUSR); |
Golan Ben Ami | 321c210 | 2015-07-27 17:02:35 +0300 | [diff] [blame] | 1872 | MVM_DEBUGFS_ADD_FILE(cont_recording, mvm->debugfs_dir, S_IWUSR); |
Sara Sharon | 43413a9 | 2015-12-31 11:49:18 +0200 | [diff] [blame] | 1873 | MVM_DEBUGFS_ADD_FILE(indirection_tbl, mvm->debugfs_dir, S_IWUSR); |
Sara Sharon | 4857d6c | 2016-08-09 20:03:52 +0300 | [diff] [blame] | 1874 | MVM_DEBUGFS_ADD_FILE(inject_packet, mvm->debugfs_dir, S_IWUSR); |
Haim Dreyfuss | e6ee065 | 2017-05-15 14:27:21 +0300 | [diff] [blame] | 1875 | #ifdef CONFIG_ACPI |
| 1876 | MVM_DEBUGFS_ADD_FILE(sar_geo_profile, dbgfs_dir, S_IRUSR); |
| 1877 | #endif |
| 1878 | |
Luciano Coelho | cb2513b | 2015-02-27 16:26:57 +0200 | [diff] [blame] | 1879 | if (!debugfs_create_bool("enable_scan_iteration_notif", |
| 1880 | S_IRUSR | S_IWUSR, |
| 1881 | mvm->debugfs_dir, |
| 1882 | &mvm->scan_iter_notif_enabled)) |
| 1883 | goto err; |
Andrei Otcheretianski | c89e333 | 2016-01-26 18:12:28 +0200 | [diff] [blame] | 1884 | if (!debugfs_create_bool("drop_bcn_ap_mode", S_IRUSR | S_IWUSR, |
| 1885 | mvm->debugfs_dir, &mvm->drop_bcn_ap_mode)) |
| 1886 | goto err; |
Eliad Peller | de06a59 | 2014-01-08 10:11:12 +0200 | [diff] [blame] | 1887 | |
| 1888 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
| 1889 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING) { |
| 1890 | bcast_dir = debugfs_create_dir("bcast_filtering", |
| 1891 | mvm->debugfs_dir); |
| 1892 | if (!bcast_dir) |
| 1893 | goto err; |
| 1894 | |
| 1895 | if (!debugfs_create_bool("override", S_IRUSR | S_IWUSR, |
| 1896 | bcast_dir, |
| 1897 | &mvm->dbgfs_bcast_filtering.override)) |
| 1898 | goto err; |
| 1899 | |
| 1900 | MVM_DEBUGFS_ADD_FILE_ALIAS("filters", bcast_filters, |
| 1901 | bcast_dir, S_IWUSR | S_IRUSR); |
| 1902 | MVM_DEBUGFS_ADD_FILE_ALIAS("macs", bcast_filters_macs, |
| 1903 | bcast_dir, S_IWUSR | S_IRUSR); |
| 1904 | } |
| 1905 | #endif |
| 1906 | |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1907 | #ifdef CONFIG_PM_SLEEP |
| 1908 | 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] | 1909 | MVM_DEBUGFS_ADD_FILE(d3_test, mvm->debugfs_dir, S_IRUSR); |
Johannes Berg | b011471 | 2013-06-12 14:55:40 +0200 | [diff] [blame] | 1910 | if (!debugfs_create_bool("d3_wake_sysassert", S_IRUSR | S_IWUSR, |
| 1911 | mvm->debugfs_dir, &mvm->d3_wake_sysassert)) |
| 1912 | goto err; |
Luciano Coelho | 484b3d1 | 2015-03-30 20:46:32 +0300 | [diff] [blame] | 1913 | if (!debugfs_create_u32("last_netdetect_scans", S_IRUSR, |
| 1914 | mvm->debugfs_dir, &mvm->last_netdetect_scans)) |
| 1915 | goto err; |
Johannes Berg | afc66bb | 2013-05-03 11:44:16 +0200 | [diff] [blame] | 1916 | #endif |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1917 | |
Luciano Coelho | bdd5483 | 2014-08-07 18:08:56 +0300 | [diff] [blame] | 1918 | if (!debugfs_create_u8("ps_disabled", S_IRUSR, |
| 1919 | mvm->debugfs_dir, &mvm->ps_disabled)) |
| 1920 | goto err; |
Emmanuel Grumbach | 086f736 | 2013-11-18 17:00:03 +0200 | [diff] [blame] | 1921 | if (!debugfs_create_blob("nvm_hw", S_IRUSR, |
| 1922 | mvm->debugfs_dir, &mvm->nvm_hw_blob)) |
| 1923 | goto err; |
| 1924 | if (!debugfs_create_blob("nvm_sw", S_IRUSR, |
| 1925 | mvm->debugfs_dir, &mvm->nvm_sw_blob)) |
| 1926 | goto err; |
| 1927 | if (!debugfs_create_blob("nvm_calib", S_IRUSR, |
| 1928 | mvm->debugfs_dir, &mvm->nvm_calib_blob)) |
| 1929 | goto err; |
| 1930 | if (!debugfs_create_blob("nvm_prod", S_IRUSR, |
| 1931 | mvm->debugfs_dir, &mvm->nvm_prod_blob)) |
| 1932 | goto err; |
Moshe Harel | 91fac94 | 2015-09-02 12:45:12 +0300 | [diff] [blame] | 1933 | if (!debugfs_create_blob("nvm_phy_sku", S_IRUSR, |
| 1934 | mvm->debugfs_dir, &mvm->nvm_phy_sku_blob)) |
| 1935 | goto err; |
Emmanuel Grumbach | 086f736 | 2013-11-18 17:00:03 +0200 | [diff] [blame] | 1936 | |
Ido Yariv | 2b55f43 | 2016-08-23 14:44:59 -0400 | [diff] [blame] | 1937 | debugfs_create_file("mem", S_IRUSR | S_IWUSR, dbgfs_dir, mvm, |
| 1938 | &iwl_dbgfs_mem_ops); |
| 1939 | |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1940 | /* |
| 1941 | * Create a symlink with mac80211. It will be removed when mac80211 |
| 1942 | * exists (before the opmode exists which removes the target.) |
| 1943 | */ |
Al Viro | 27a2209 | 2016-08-07 12:21:25 -0400 | [diff] [blame] | 1944 | snprintf(buf, 100, "../../%pd2", dbgfs_dir->d_parent); |
Johannes Berg | 8ca151b | 2013-01-24 14:25:36 +0100 | [diff] [blame] | 1945 | if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf)) |
| 1946 | goto err; |
| 1947 | |
| 1948 | return 0; |
| 1949 | err: |
| 1950 | IWL_ERR(mvm, "Can't create the mvm debugfs directory\n"); |
| 1951 | return -ENOMEM; |
| 1952 | } |