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