| 1 | |
| 2 | |
| 3 | * Copyright (c) 2005-2011 Atheros Communications Inc.
|
| 4 | * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
|
| 5 | * Copyright (c) 2018, The Linux Foundation. All rights reserved.
|
| 6 | * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
|
| 7 |
|
| 8 |
|
| 9 | #include <linux/module.h>
|
| 10 | #include <linux/debugfs.h>
|
| 11 | #include <linux/export.h>
|
| 12 | #include <linux/vmalloc.h>
|
| 13 | #include <linux/crc32.h>
|
| 14 | #include <linux/firmware.h>
|
| 15 | #include <linux/kstrtox.h>
|
| 16 |
|
| 17 | #include "core.h"
|
| 18 | #include "debug.h"
|
| 19 | #include "hif.h"
|
| 20 | #include "wmi-ops.h"
|
| 21 |
|
| 22 |
|
| 23 | #define ATH10K_DEBUG_HTT_STATS_INTERVAL 1000
|
| 24 |
|
| 25 | #define ATH10K_DEBUG_CAL_DATA_LEN 12064
|
| 26 |
|
| 27 | void ath10k_info(struct ath10k *ar, const char *fmt, ...)
|
| 28 | {
|
| 29 | struct va_format vaf = {
|
| 30 | .fmt = fmt,
|
| 31 | };
|
| 32 | va_list args;
|
| 33 |
|
| 34 | va_start(args, fmt);
|
| 35 | vaf.va = &args;
|
| 36 | dev_info(ar->dev, "%pV", &vaf);
|
| 37 | trace_ath10k_log_info(ar, &vaf);
|
| 38 | va_end(args);
|
| 39 | }
|
| 40 | EXPORT_SYMBOL(ath10k_info);
|
| 41 |
|
| 42 | void ath10k_debug_print_hwfw_info(struct ath10k *ar)
|
| 43 | {
|
| 44 | const struct firmware *firmware;
|
| 45 | char fw_features[128] = {};
|
| 46 | u32 crc = 0;
|
| 47 |
|
| 48 | ath10k_core_get_fw_features_str(ar, fw_features, sizeof(fw_features));
|
| 49 |
|
| 50 | ath10k_info(ar, "%s target 0x%08x chip_id 0x%08x sub %04x:%04x",
|
| 51 | ar->hw_params.name,
|
| 52 | ar->target_version,
|
| 53 | ar->bus_param.chip_id,
|
| 54 | ar->id.subsystem_vendor, ar->id.subsystem_device);
|
| 55 |
|
| 56 | ath10k_info(ar, "kconfig debug %d debugfs %d tracing %d dfs %d testmode %d\n",
|
| 57 | IS_ENABLED(CONFIG_ATH10K_DEBUG),
|
| 58 | IS_ENABLED(CONFIG_ATH10K_DEBUGFS),
|
| 59 | IS_ENABLED(CONFIG_ATH10K_TRACING),
|
| 60 | IS_ENABLED(CONFIG_ATH10K_DFS_CERTIFIED),
|
| 61 | IS_ENABLED(CONFIG_NL80211_TESTMODE));
|
| 62 |
|
| 63 | firmware = ar->normal_mode_fw.fw_file.firmware;
|
| 64 | if (firmware)
|
| 65 | crc = crc32_le(0, firmware->data, firmware->size);
|
| 66 |
|
| 67 | ath10k_info(ar, "firmware ver %s api %d features %s crc32 %08x\n",
|
| 68 | ar->hw->wiphy->fw_version,
|
| 69 | ar->fw_api,
|
| 70 | fw_features,
|
| 71 | crc);
|
| 72 | }
|
| 73 |
|
| 74 | void ath10k_debug_print_board_info(struct ath10k *ar)
|
| 75 | {
|
| 76 | char boardinfo[100];
|
| 77 | const struct firmware *board;
|
| 78 | u32 crc;
|
| 79 |
|
| 80 | if (ar->id.bmi_ids_valid)
|
| 81 | scnprintf(boardinfo, sizeof(boardinfo), "%d:%d",
|
| 82 | ar->id.bmi_chip_id, ar->id.bmi_board_id);
|
| 83 | else
|
| 84 | scnprintf(boardinfo, sizeof(boardinfo), "N/A");
|
| 85 |
|
| 86 | board = ar->normal_mode_fw.board;
|
| 87 | if (!IS_ERR_OR_NULL(board))
|
| 88 | crc = crc32_le(0, board->data, board->size);
|
| 89 | else
|
| 90 | crc = 0;
|
| 91 |
|
| 92 | ath10k_info(ar, "board_file api %d bmi_id %s crc32 %08x",
|
| 93 | ar->bd_api,
|
| 94 | boardinfo,
|
| 95 | crc);
|
| 96 | }
|
| 97 |
|
| 98 | void ath10k_debug_print_boot_info(struct ath10k *ar)
|
| 99 | {
|
| 100 | ath10k_info(ar, "htt-ver %d.%d wmi-op %d htt-op %d cal %s max-sta %d raw %d hwcrypto %d\n",
|
| 101 | ar->htt.target_version_major,
|
| 102 | ar->htt.target_version_minor,
|
| 103 | ar->normal_mode_fw.fw_file.wmi_op_version,
|
| 104 | ar->normal_mode_fw.fw_file.htt_op_version,
|
| 105 | ath10k_cal_mode_str(ar->cal_mode),
|
| 106 | ar->max_num_stations,
|
| 107 | test_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags),
|
| 108 | !test_bit(ATH10K_FLAG_HW_CRYPTO_DISABLED, &ar->dev_flags));
|
| 109 | }
|
| 110 |
|
| 111 | void ath10k_print_driver_info(struct ath10k *ar)
|
| 112 | {
|
| 113 | ath10k_debug_print_hwfw_info(ar);
|
| 114 | ath10k_debug_print_board_info(ar);
|
| 115 | ath10k_debug_print_boot_info(ar);
|
| 116 | }
|
| 117 | EXPORT_SYMBOL(ath10k_print_driver_info);
|
| 118 |
|
| 119 | void ath10k_err(struct ath10k *ar, const char *fmt, ...)
|
| 120 | {
|
| 121 | struct va_format vaf = {
|
| 122 | .fmt = fmt,
|
| 123 | };
|
| 124 | va_list args;
|
| 125 |
|
| 126 | va_start(args, fmt);
|
| 127 | vaf.va = &args;
|
| 128 | dev_err(ar->dev, "%pV", &vaf);
|
| 129 | trace_ath10k_log_err(ar, &vaf);
|
| 130 | va_end(args);
|
| 131 | }
|
| 132 | EXPORT_SYMBOL(ath10k_err);
|
| 133 |
|
| 134 | void ath10k_warn(struct ath10k *ar, const char *fmt, ...)
|
| 135 | {
|
| 136 | struct va_format vaf = {
|
| 137 | .fmt = fmt,
|
| 138 | };
|
| 139 | va_list args;
|
| 140 |
|
| 141 | va_start(args, fmt);
|
| 142 | vaf.va = &args;
|
| 143 | dev_warn_ratelimited(ar->dev, "%pV", &vaf);
|
| 144 | trace_ath10k_log_warn(ar, &vaf);
|
| 145 |
|
| 146 | va_end(args);
|
| 147 | }
|
| 148 | EXPORT_SYMBOL(ath10k_warn);
|
| 149 |
|
| 150 | #ifdef CONFIG_ATH10K_DEBUGFS
|
| 151 |
|
| 152 | static ssize_t ath10k_read_wmi_services(struct file *file,
|
| 153 | char __user *user_buf,
|
| 154 | size_t count, loff_t *ppos)
|
| 155 | {
|
| 156 | struct ath10k *ar = file->private_data;
|
| 157 | char *buf;
|
| 158 | size_t len = 0, buf_len = 8192;
|
| 159 | const char *name;
|
| 160 | ssize_t ret_cnt;
|
| 161 | bool enabled;
|
| 162 | int i;
|
| 163 |
|
| 164 | buf = kzalloc(buf_len, GFP_KERNEL);
|
| 165 | if (!buf)
|
| 166 | return -ENOMEM;
|
| 167 |
|
| 168 | mutex_lock(&ar->conf_mutex);
|
| 169 |
|
| 170 | spin_lock_bh(&ar->data_lock);
|
| 171 | for (i = 0; i < WMI_SERVICE_MAX; i++) {
|
| 172 | enabled = test_bit(i, ar->wmi.svc_map);
|
| 173 | name = wmi_service_name(i);
|
| 174 |
|
| 175 | if (!name) {
|
| 176 | if (enabled)
|
| 177 | len += scnprintf(buf + len, buf_len - len,
|
| 178 | "%-40s %s (bit %d)\n",
|
| 179 | "unknown", "enabled", i);
|
| 180 |
|
| 181 | continue;
|
| 182 | }
|
| 183 |
|
| 184 | len += scnprintf(buf + len, buf_len - len,
|
| 185 | "%-40s %s\n",
|
| 186 | name, enabled ? "enabled" : "-");
|
| 187 | }
|
| 188 | spin_unlock_bh(&ar->data_lock);
|
| 189 |
|
| 190 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 191 |
|
| 192 | mutex_unlock(&ar->conf_mutex);
|
| 193 |
|
| 194 | kfree(buf);
|
| 195 | return ret_cnt;
|
| 196 | }
|
| 197 |
|
| 198 | static const struct file_operations fops_wmi_services = {
|
| 199 | .read = ath10k_read_wmi_services,
|
| 200 | .open = simple_open,
|
| 201 | .owner = THIS_MODULE,
|
| 202 | .llseek = default_llseek,
|
| 203 | };
|
| 204 |
|
| 205 | static void ath10k_fw_stats_pdevs_free(struct list_head *head)
|
| 206 | {
|
| 207 | struct ath10k_fw_stats_pdev *i, *tmp;
|
| 208 |
|
| 209 | list_for_each_entry_safe(i, tmp, head, list) {
|
| 210 | list_del(&i->list);
|
| 211 | kfree(i);
|
| 212 | }
|
| 213 | }
|
| 214 |
|
| 215 | static void ath10k_fw_stats_vdevs_free(struct list_head *head)
|
| 216 | {
|
| 217 | struct ath10k_fw_stats_vdev *i, *tmp;
|
| 218 |
|
| 219 | list_for_each_entry_safe(i, tmp, head, list) {
|
| 220 | list_del(&i->list);
|
| 221 | kfree(i);
|
| 222 | }
|
| 223 | }
|
| 224 |
|
| 225 | static void ath10k_fw_stats_peers_free(struct list_head *head)
|
| 226 | {
|
| 227 | struct ath10k_fw_stats_peer *i, *tmp;
|
| 228 |
|
| 229 | list_for_each_entry_safe(i, tmp, head, list) {
|
| 230 | list_del(&i->list);
|
| 231 | kfree(i);
|
| 232 | }
|
| 233 | }
|
| 234 |
|
| 235 | static void ath10k_fw_extd_stats_peers_free(struct list_head *head)
|
| 236 | {
|
| 237 | struct ath10k_fw_extd_stats_peer *i, *tmp;
|
| 238 |
|
| 239 | list_for_each_entry_safe(i, tmp, head, list) {
|
| 240 | list_del(&i->list);
|
| 241 | kfree(i);
|
| 242 | }
|
| 243 | }
|
| 244 |
|
| 245 | static void ath10k_debug_fw_stats_reset(struct ath10k *ar)
|
| 246 | {
|
| 247 | spin_lock_bh(&ar->data_lock);
|
| 248 | ar->debug.fw_stats_done = false;
|
| 249 | ar->debug.fw_stats.extended = false;
|
| 250 | ath10k_fw_stats_pdevs_free(&ar->debug.fw_stats.pdevs);
|
| 251 | ath10k_fw_stats_vdevs_free(&ar->debug.fw_stats.vdevs);
|
| 252 | ath10k_fw_stats_peers_free(&ar->debug.fw_stats.peers);
|
| 253 | ath10k_fw_extd_stats_peers_free(&ar->debug.fw_stats.peers_extd);
|
| 254 | spin_unlock_bh(&ar->data_lock);
|
| 255 | }
|
| 256 |
|
| 257 | void ath10k_debug_fw_stats_process(struct ath10k *ar, struct sk_buff *skb)
|
| 258 | {
|
| 259 | struct ath10k_fw_stats stats = {};
|
| 260 | bool is_start, is_started, is_end;
|
| 261 | size_t num_peers;
|
| 262 | size_t num_vdevs;
|
| 263 | int ret;
|
| 264 |
|
| 265 | INIT_LIST_HEAD(&stats.pdevs);
|
| 266 | INIT_LIST_HEAD(&stats.vdevs);
|
| 267 | INIT_LIST_HEAD(&stats.peers);
|
| 268 | INIT_LIST_HEAD(&stats.peers_extd);
|
| 269 |
|
| 270 | spin_lock_bh(&ar->data_lock);
|
| 271 | ret = ath10k_wmi_pull_fw_stats(ar, skb, &stats);
|
| 272 | if (ret) {
|
| 273 | ath10k_warn(ar, "failed to pull fw stats: %d\n", ret);
|
| 274 | goto free;
|
| 275 | }
|
| 276 |
|
| 277 | |
| 278 | * splits the stats data and delivers it in a ping-pong fashion of
|
| 279 | * request cmd-update event.
|
| 280 | *
|
| 281 | * However there is no explicit end-of-data. Instead start-of-data is
|
| 282 | * used as an implicit one. This works as follows:
|
| 283 | * a) discard stat update events until one with pdev stats is
|
| 284 | * delivered - this skips session started at end of (b)
|
| 285 | * b) consume stat update events until another one with pdev stats is
|
| 286 | * delivered which is treated as end-of-data and is itself discarded
|
| 287 |
|
| 288 | if (ath10k_peer_stats_enabled(ar))
|
| 289 | ath10k_sta_update_rx_duration(ar, &stats);
|
| 290 |
|
| 291 | if (ar->debug.fw_stats_done) {
|
| 292 | if (!ath10k_peer_stats_enabled(ar))
|
| 293 | ath10k_warn(ar, "received unsolicited stats update event\n");
|
| 294 |
|
| 295 | goto free;
|
| 296 | }
|
| 297 |
|
| 298 | num_peers = list_count_nodes(&ar->debug.fw_stats.peers);
|
| 299 | num_vdevs = list_count_nodes(&ar->debug.fw_stats.vdevs);
|
| 300 | is_start = (list_empty(&ar->debug.fw_stats.pdevs) &&
|
| 301 | !list_empty(&stats.pdevs));
|
| 302 | is_end = (!list_empty(&ar->debug.fw_stats.pdevs) &&
|
| 303 | !list_empty(&stats.pdevs));
|
| 304 |
|
| 305 | if (is_start)
|
| 306 | list_splice_tail_init(&stats.pdevs, &ar->debug.fw_stats.pdevs);
|
| 307 |
|
| 308 | if (is_end)
|
| 309 | ar->debug.fw_stats_done = true;
|
| 310 |
|
| 311 | if (stats.extended)
|
| 312 | ar->debug.fw_stats.extended = true;
|
| 313 |
|
| 314 | is_started = !list_empty(&ar->debug.fw_stats.pdevs);
|
| 315 |
|
| 316 | if (is_started && !is_end) {
|
| 317 | if (num_peers >= ATH10K_MAX_NUM_PEER_IDS) {
|
| 318 | |
| 319 | * prevent firmware from DoS-ing the host.
|
| 320 |
|
| 321 | ath10k_fw_stats_peers_free(&ar->debug.fw_stats.peers);
|
| 322 | ath10k_fw_extd_stats_peers_free(&ar->debug.fw_stats.peers_extd);
|
| 323 | ath10k_warn(ar, "dropping fw peer stats\n");
|
| 324 | goto free;
|
| 325 | }
|
| 326 |
|
| 327 | if (num_vdevs >= BITS_PER_LONG) {
|
| 328 | ath10k_fw_stats_vdevs_free(&ar->debug.fw_stats.vdevs);
|
| 329 | ath10k_warn(ar, "dropping fw vdev stats\n");
|
| 330 | goto free;
|
| 331 | }
|
| 332 |
|
| 333 | if (!list_empty(&stats.peers))
|
| 334 | list_splice_tail_init(&stats.peers_extd,
|
| 335 | &ar->debug.fw_stats.peers_extd);
|
| 336 |
|
| 337 | list_splice_tail_init(&stats.peers, &ar->debug.fw_stats.peers);
|
| 338 | list_splice_tail_init(&stats.vdevs, &ar->debug.fw_stats.vdevs);
|
| 339 | }
|
| 340 |
|
| 341 | complete(&ar->debug.fw_stats_complete);
|
| 342 |
|
| 343 | free:
|
| 344 | |
| 345 | * resources if that is not the case.
|
| 346 |
|
| 347 | ath10k_fw_stats_pdevs_free(&stats.pdevs);
|
| 348 | ath10k_fw_stats_vdevs_free(&stats.vdevs);
|
| 349 | ath10k_fw_stats_peers_free(&stats.peers);
|
| 350 | ath10k_fw_extd_stats_peers_free(&stats.peers_extd);
|
| 351 |
|
| 352 | spin_unlock_bh(&ar->data_lock);
|
| 353 | }
|
| 354 |
|
| 355 | int ath10k_debug_fw_stats_request(struct ath10k *ar)
|
| 356 | {
|
| 357 | unsigned long timeout, time_left;
|
| 358 | int ret;
|
| 359 |
|
| 360 | lockdep_assert_held(&ar->conf_mutex);
|
| 361 |
|
| 362 | timeout = jiffies + msecs_to_jiffies(1 * HZ);
|
| 363 |
|
| 364 | ath10k_debug_fw_stats_reset(ar);
|
| 365 |
|
| 366 | for (;;) {
|
| 367 | if (time_after(jiffies, timeout))
|
| 368 | return -ETIMEDOUT;
|
| 369 |
|
| 370 | reinit_completion(&ar->debug.fw_stats_complete);
|
| 371 |
|
| 372 | ret = ath10k_wmi_request_stats(ar, ar->fw_stats_req_mask);
|
| 373 | if (ret) {
|
| 374 | ath10k_warn(ar, "could not request stats (%d)\n", ret);
|
| 375 | return ret;
|
| 376 | }
|
| 377 |
|
| 378 | time_left =
|
| 379 | wait_for_completion_timeout(&ar->debug.fw_stats_complete,
|
| 380 | 1 * HZ);
|
| 381 | if (!time_left)
|
| 382 | return -ETIMEDOUT;
|
| 383 |
|
| 384 | spin_lock_bh(&ar->data_lock);
|
| 385 | if (ar->debug.fw_stats_done) {
|
| 386 | spin_unlock_bh(&ar->data_lock);
|
| 387 | break;
|
| 388 | }
|
| 389 | spin_unlock_bh(&ar->data_lock);
|
| 390 | }
|
| 391 |
|
| 392 | return 0;
|
| 393 | }
|
| 394 |
|
| 395 | static int ath10k_fw_stats_open(struct inode *inode, struct file *file)
|
| 396 | {
|
| 397 | struct ath10k *ar = inode->i_private;
|
| 398 | void *buf = NULL;
|
| 399 | int ret;
|
| 400 |
|
| 401 | mutex_lock(&ar->conf_mutex);
|
| 402 |
|
| 403 | if (ar->state != ATH10K_STATE_ON) {
|
| 404 | ret = -ENETDOWN;
|
| 405 | goto err_unlock;
|
| 406 | }
|
| 407 |
|
| 408 | buf = vmalloc(ATH10K_FW_STATS_BUF_SIZE);
|
| 409 | if (!buf) {
|
| 410 | ret = -ENOMEM;
|
| 411 | goto err_unlock;
|
| 412 | }
|
| 413 |
|
| 414 | ret = ath10k_debug_fw_stats_request(ar);
|
| 415 | if (ret) {
|
| 416 | ath10k_warn(ar, "failed to request fw stats: %d\n", ret);
|
| 417 | goto err_free;
|
| 418 | }
|
| 419 |
|
| 420 | ret = ath10k_wmi_fw_stats_fill(ar, &ar->debug.fw_stats, buf);
|
| 421 | if (ret) {
|
| 422 | ath10k_warn(ar, "failed to fill fw stats: %d\n", ret);
|
| 423 | goto err_free;
|
| 424 | }
|
| 425 |
|
| 426 | file->private_data = buf;
|
| 427 |
|
| 428 | mutex_unlock(&ar->conf_mutex);
|
| 429 | return 0;
|
| 430 |
|
| 431 | err_free:
|
| 432 | vfree(buf);
|
| 433 |
|
| 434 | err_unlock:
|
| 435 | mutex_unlock(&ar->conf_mutex);
|
| 436 | return ret;
|
| 437 | }
|
| 438 |
|
| 439 | static int ath10k_fw_stats_release(struct inode *inode, struct file *file)
|
| 440 | {
|
| 441 | vfree(file->private_data);
|
| 442 |
|
| 443 | return 0;
|
| 444 | }
|
| 445 |
|
| 446 | static ssize_t ath10k_fw_stats_read(struct file *file, char __user *user_buf,
|
| 447 | size_t count, loff_t *ppos)
|
| 448 | {
|
| 449 | const char *buf = file->private_data;
|
| 450 | size_t len = strlen(buf);
|
| 451 |
|
| 452 | return simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 453 | }
|
| 454 |
|
| 455 | static const struct file_operations fops_fw_stats = {
|
| 456 | .open = ath10k_fw_stats_open,
|
| 457 | .release = ath10k_fw_stats_release,
|
| 458 | .read = ath10k_fw_stats_read,
|
| 459 | .owner = THIS_MODULE,
|
| 460 | .llseek = default_llseek,
|
| 461 | };
|
| 462 |
|
| 463 | static ssize_t ath10k_debug_fw_reset_stats_read(struct file *file,
|
| 464 | char __user *user_buf,
|
| 465 | size_t count, loff_t *ppos)
|
| 466 | {
|
| 467 | struct ath10k *ar = file->private_data;
|
| 468 | int ret;
|
| 469 | size_t len = 0, buf_len = 500;
|
| 470 | char *buf;
|
| 471 |
|
| 472 | buf = kmalloc(buf_len, GFP_KERNEL);
|
| 473 | if (!buf)
|
| 474 | return -ENOMEM;
|
| 475 |
|
| 476 | spin_lock_bh(&ar->data_lock);
|
| 477 |
|
| 478 | len += scnprintf(buf + len, buf_len - len,
|
| 479 | "fw_crash_counter\t\t%d\n", ar->stats.fw_crash_counter);
|
| 480 | len += scnprintf(buf + len, buf_len - len,
|
| 481 | "fw_warm_reset_counter\t\t%d\n",
|
| 482 | ar->stats.fw_warm_reset_counter);
|
| 483 | len += scnprintf(buf + len, buf_len - len,
|
| 484 | "fw_cold_reset_counter\t\t%d\n",
|
| 485 | ar->stats.fw_cold_reset_counter);
|
| 486 |
|
| 487 | spin_unlock_bh(&ar->data_lock);
|
| 488 |
|
| 489 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 490 |
|
| 491 | kfree(buf);
|
| 492 |
|
| 493 | return ret;
|
| 494 | }
|
| 495 |
|
| 496 | static const struct file_operations fops_fw_reset_stats = {
|
| 497 | .open = simple_open,
|
| 498 | .read = ath10k_debug_fw_reset_stats_read,
|
| 499 | .owner = THIS_MODULE,
|
| 500 | .llseek = default_llseek,
|
| 501 | };
|
| 502 |
|
| 503 |
|
| 504 | static int ath10k_debug_fw_assert(struct ath10k *ar)
|
| 505 | {
|
| 506 | struct wmi_vdev_install_key_cmd *cmd;
|
| 507 | struct sk_buff *skb;
|
| 508 |
|
| 509 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + 16);
|
| 510 | if (!skb)
|
| 511 | return -ENOMEM;
|
| 512 |
|
| 513 | cmd = (struct wmi_vdev_install_key_cmd *)skb->data;
|
| 514 | memset(cmd, 0, sizeof(*cmd));
|
| 515 |
|
| 516 |
|
| 517 | cmd->vdev_id = __cpu_to_le32(0x7ffe);
|
| 518 |
|
| 519 | return ath10k_wmi_cmd_send(ar, skb,
|
| 520 | ar->wmi.cmd->vdev_install_key_cmdid);
|
| 521 | }
|
| 522 |
|
| 523 | static ssize_t ath10k_read_simulate_fw_crash(struct file *file,
|
| 524 | char __user *user_buf,
|
| 525 | size_t count, loff_t *ppos)
|
| 526 | {
|
| 527 | const char buf[] =
|
| 528 | "To simulate firmware crash write one of the keywords to this file:\n"
|
| 529 | "`soft` - this will send WMI_FORCE_FW_HANG_ASSERT to firmware if FW supports that command.\n"
|
| 530 | "`hard` - this will send to firmware command with illegal parameters causing firmware crash.\n"
|
| 531 | "`assert` - this will send special illegal parameter to firmware to cause assert failure and crash.\n"
|
| 532 | "`hw-restart` - this will simply queue hw restart without fw/hw actually crashing.\n";
|
| 533 |
|
| 534 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
|
| 535 | }
|
| 536 |
|
| 537 | |
| 538 | * 'soft': Call wmi command causing firmware hang. This firmware hang is
|
| 539 | * recoverable by warm firmware reset.
|
| 540 | * 'hard': Force firmware crash by setting any vdev parameter for not allowed
|
| 541 | * vdev id. This is hard firmware crash because it is recoverable only by cold
|
| 542 | * firmware reset.
|
| 543 |
|
| 544 | static ssize_t ath10k_write_simulate_fw_crash(struct file *file,
|
| 545 | const char __user *user_buf,
|
| 546 | size_t count, loff_t *ppos)
|
| 547 | {
|
| 548 | struct ath10k *ar = file->private_data;
|
| 549 | char buf[32] = {};
|
| 550 | ssize_t rc;
|
| 551 | int ret;
|
| 552 |
|
| 553 |
|
| 554 | if (*ppos != 0 || count >= sizeof(buf) || count == 0)
|
| 555 | return -EINVAL;
|
| 556 |
|
| 557 | rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
|
| 558 | if (rc < 0)
|
| 559 | return rc;
|
| 560 |
|
| 561 |
|
| 562 | if (buf[*ppos - 1] == '\n')
|
| 563 | buf[*ppos - 1] = '\0';
|
| 564 |
|
| 565 | mutex_lock(&ar->conf_mutex);
|
| 566 |
|
| 567 | if (ar->state != ATH10K_STATE_ON &&
|
| 568 | ar->state != ATH10K_STATE_RESTARTED) {
|
| 569 | ret = -ENETDOWN;
|
| 570 | goto exit;
|
| 571 | }
|
| 572 |
|
| 573 | if (!strcmp(buf, "soft")) {
|
| 574 | ath10k_info(ar, "simulating soft firmware crash\n");
|
| 575 | ret = ath10k_wmi_force_fw_hang(ar, WMI_FORCE_FW_HANG_ASSERT, 0);
|
| 576 | } else if (!strcmp(buf, "hard")) {
|
| 577 | ath10k_info(ar, "simulating hard firmware crash\n");
|
| 578 | |
| 579 | * firmware variants in order to force a firmware crash.
|
| 580 |
|
| 581 | ret = ath10k_wmi_vdev_set_param(ar, 0x7fff,
|
| 582 | ar->wmi.vdev_param->rts_threshold,
|
| 583 | 0);
|
| 584 | } else if (!strcmp(buf, "assert")) {
|
| 585 | ath10k_info(ar, "simulating firmware assert crash\n");
|
| 586 | ret = ath10k_debug_fw_assert(ar);
|
| 587 | } else if (!strcmp(buf, "hw-restart")) {
|
| 588 | ath10k_info(ar, "user requested hw restart\n");
|
| 589 | ath10k_core_start_recovery(ar);
|
| 590 | ret = 0;
|
| 591 | } else {
|
| 592 | ret = -EINVAL;
|
| 593 | goto exit;
|
| 594 | }
|
| 595 |
|
| 596 | if (ret) {
|
| 597 | ath10k_warn(ar, "failed to simulate firmware crash: %d\n", ret);
|
| 598 | goto exit;
|
| 599 | }
|
| 600 |
|
| 601 | ret = count;
|
| 602 |
|
| 603 | exit:
|
| 604 | mutex_unlock(&ar->conf_mutex);
|
| 605 | return ret;
|
| 606 | }
|
| 607 |
|
| 608 | static const struct file_operations fops_simulate_fw_crash = {
|
| 609 | .read = ath10k_read_simulate_fw_crash,
|
| 610 | .write = ath10k_write_simulate_fw_crash,
|
| 611 | .open = simple_open,
|
| 612 | .owner = THIS_MODULE,
|
| 613 | .llseek = default_llseek,
|
| 614 | };
|
| 615 |
|
| 616 | static ssize_t ath10k_read_chip_id(struct file *file, char __user *user_buf,
|
| 617 | size_t count, loff_t *ppos)
|
| 618 | {
|
| 619 | struct ath10k *ar = file->private_data;
|
| 620 | size_t len;
|
| 621 | char buf[50];
|
| 622 |
|
| 623 | len = scnprintf(buf, sizeof(buf), "0x%08x\n", ar->bus_param.chip_id);
|
| 624 |
|
| 625 | return simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 626 | }
|
| 627 |
|
| 628 | static const struct file_operations fops_chip_id = {
|
| 629 | .read = ath10k_read_chip_id,
|
| 630 | .open = simple_open,
|
| 631 | .owner = THIS_MODULE,
|
| 632 | .llseek = default_llseek,
|
| 633 | };
|
| 634 |
|
| 635 | static ssize_t ath10k_reg_addr_read(struct file *file,
|
| 636 | char __user *user_buf,
|
| 637 | size_t count, loff_t *ppos)
|
| 638 | {
|
| 639 | struct ath10k *ar = file->private_data;
|
| 640 | u8 buf[32];
|
| 641 | size_t len = 0;
|
| 642 | u32 reg_addr;
|
| 643 |
|
| 644 | mutex_lock(&ar->conf_mutex);
|
| 645 | reg_addr = ar->debug.reg_addr;
|
| 646 | mutex_unlock(&ar->conf_mutex);
|
| 647 |
|
| 648 | len += scnprintf(buf + len, sizeof(buf) - len, "0x%x\n", reg_addr);
|
| 649 |
|
| 650 | return simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 651 | }
|
| 652 |
|
| 653 | static ssize_t ath10k_reg_addr_write(struct file *file,
|
| 654 | const char __user *user_buf,
|
| 655 | size_t count, loff_t *ppos)
|
| 656 | {
|
| 657 | struct ath10k *ar = file->private_data;
|
| 658 | u32 reg_addr;
|
| 659 | int ret;
|
| 660 |
|
| 661 | ret = kstrtou32_from_user(user_buf, count, 0, ®_addr);
|
| 662 | if (ret)
|
| 663 | return ret;
|
| 664 |
|
| 665 | if (!IS_ALIGNED(reg_addr, 4))
|
| 666 | return -EFAULT;
|
| 667 |
|
| 668 | mutex_lock(&ar->conf_mutex);
|
| 669 | ar->debug.reg_addr = reg_addr;
|
| 670 | mutex_unlock(&ar->conf_mutex);
|
| 671 |
|
| 672 | return count;
|
| 673 | }
|
| 674 |
|
| 675 | static const struct file_operations fops_reg_addr = {
|
| 676 | .read = ath10k_reg_addr_read,
|
| 677 | .write = ath10k_reg_addr_write,
|
| 678 | .open = simple_open,
|
| 679 | .owner = THIS_MODULE,
|
| 680 | .llseek = default_llseek,
|
| 681 | };
|
| 682 |
|
| 683 | static ssize_t ath10k_reg_value_read(struct file *file,
|
| 684 | char __user *user_buf,
|
| 685 | size_t count, loff_t *ppos)
|
| 686 | {
|
| 687 | struct ath10k *ar = file->private_data;
|
| 688 | u8 buf[48];
|
| 689 | size_t len;
|
| 690 | u32 reg_addr, reg_val;
|
| 691 | int ret;
|
| 692 |
|
| 693 | mutex_lock(&ar->conf_mutex);
|
| 694 |
|
| 695 | if (ar->state != ATH10K_STATE_ON &&
|
| 696 | ar->state != ATH10K_STATE_UTF) {
|
| 697 | ret = -ENETDOWN;
|
| 698 | goto exit;
|
| 699 | }
|
| 700 |
|
| 701 | reg_addr = ar->debug.reg_addr;
|
| 702 |
|
| 703 | reg_val = ath10k_hif_read32(ar, reg_addr);
|
| 704 | len = scnprintf(buf, sizeof(buf), "0x%08x:0x%08x\n", reg_addr, reg_val);
|
| 705 |
|
| 706 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 707 |
|
| 708 | exit:
|
| 709 | mutex_unlock(&ar->conf_mutex);
|
| 710 |
|
| 711 | return ret;
|
| 712 | }
|
| 713 |
|
| 714 | static ssize_t ath10k_reg_value_write(struct file *file,
|
| 715 | const char __user *user_buf,
|
| 716 | size_t count, loff_t *ppos)
|
| 717 | {
|
| 718 | struct ath10k *ar = file->private_data;
|
| 719 | u32 reg_addr, reg_val;
|
| 720 | int ret;
|
| 721 |
|
| 722 | mutex_lock(&ar->conf_mutex);
|
| 723 |
|
| 724 | if (ar->state != ATH10K_STATE_ON &&
|
| 725 | ar->state != ATH10K_STATE_UTF) {
|
| 726 | ret = -ENETDOWN;
|
| 727 | goto exit;
|
| 728 | }
|
| 729 |
|
| 730 | reg_addr = ar->debug.reg_addr;
|
| 731 |
|
| 732 | ret = kstrtou32_from_user(user_buf, count, 0, ®_val);
|
| 733 | if (ret)
|
| 734 | goto exit;
|
| 735 |
|
| 736 | ath10k_hif_write32(ar, reg_addr, reg_val);
|
| 737 |
|
| 738 | ret = count;
|
| 739 |
|
| 740 | exit:
|
| 741 | mutex_unlock(&ar->conf_mutex);
|
| 742 |
|
| 743 | return ret;
|
| 744 | }
|
| 745 |
|
| 746 | static const struct file_operations fops_reg_value = {
|
| 747 | .read = ath10k_reg_value_read,
|
| 748 | .write = ath10k_reg_value_write,
|
| 749 | .open = simple_open,
|
| 750 | .owner = THIS_MODULE,
|
| 751 | .llseek = default_llseek,
|
| 752 | };
|
| 753 |
|
| 754 | static ssize_t ath10k_mem_value_read(struct file *file,
|
| 755 | char __user *user_buf,
|
| 756 | size_t count, loff_t *ppos)
|
| 757 | {
|
| 758 | struct ath10k *ar = file->private_data;
|
| 759 | u8 *buf;
|
| 760 | int ret;
|
| 761 |
|
| 762 | if (*ppos < 0)
|
| 763 | return -EINVAL;
|
| 764 |
|
| 765 | if (!count)
|
| 766 | return 0;
|
| 767 |
|
| 768 | mutex_lock(&ar->conf_mutex);
|
| 769 |
|
| 770 | buf = vmalloc(count);
|
| 771 | if (!buf) {
|
| 772 | ret = -ENOMEM;
|
| 773 | goto exit;
|
| 774 | }
|
| 775 |
|
| 776 | if (ar->state != ATH10K_STATE_ON &&
|
| 777 | ar->state != ATH10K_STATE_UTF) {
|
| 778 | ret = -ENETDOWN;
|
| 779 | goto exit;
|
| 780 | }
|
| 781 |
|
| 782 | ret = ath10k_hif_diag_read(ar, *ppos, buf, count);
|
| 783 | if (ret) {
|
| 784 | ath10k_warn(ar, "failed to read address 0x%08x via diagnose window from debugfs: %d\n",
|
| 785 | (u32)(*ppos), ret);
|
| 786 | goto exit;
|
| 787 | }
|
| 788 |
|
| 789 | ret = copy_to_user(user_buf, buf, count);
|
| 790 | if (ret) {
|
| 791 | ret = -EFAULT;
|
| 792 | goto exit;
|
| 793 | }
|
| 794 |
|
| 795 | count -= ret;
|
| 796 | *ppos += count;
|
| 797 | ret = count;
|
| 798 |
|
| 799 | exit:
|
| 800 | vfree(buf);
|
| 801 | mutex_unlock(&ar->conf_mutex);
|
| 802 |
|
| 803 | return ret;
|
| 804 | }
|
| 805 |
|
| 806 | static ssize_t ath10k_mem_value_write(struct file *file,
|
| 807 | const char __user *user_buf,
|
| 808 | size_t count, loff_t *ppos)
|
| 809 | {
|
| 810 | struct ath10k *ar = file->private_data;
|
| 811 | u8 *buf;
|
| 812 | int ret;
|
| 813 |
|
| 814 | if (*ppos < 0)
|
| 815 | return -EINVAL;
|
| 816 |
|
| 817 | if (!count)
|
| 818 | return 0;
|
| 819 |
|
| 820 | mutex_lock(&ar->conf_mutex);
|
| 821 |
|
| 822 | buf = vmalloc(count);
|
| 823 | if (!buf) {
|
| 824 | ret = -ENOMEM;
|
| 825 | goto exit;
|
| 826 | }
|
| 827 |
|
| 828 | if (ar->state != ATH10K_STATE_ON &&
|
| 829 | ar->state != ATH10K_STATE_UTF) {
|
| 830 | ret = -ENETDOWN;
|
| 831 | goto exit;
|
| 832 | }
|
| 833 |
|
| 834 | ret = copy_from_user(buf, user_buf, count);
|
| 835 | if (ret) {
|
| 836 | ret = -EFAULT;
|
| 837 | goto exit;
|
| 838 | }
|
| 839 |
|
| 840 | ret = ath10k_hif_diag_write(ar, *ppos, buf, count);
|
| 841 | if (ret) {
|
| 842 | ath10k_warn(ar, "failed to write address 0x%08x via diagnose window from debugfs: %d\n",
|
| 843 | (u32)(*ppos), ret);
|
| 844 | goto exit;
|
| 845 | }
|
| 846 |
|
| 847 | *ppos += count;
|
| 848 | ret = count;
|
| 849 |
|
| 850 | exit:
|
| 851 | vfree(buf);
|
| 852 | mutex_unlock(&ar->conf_mutex);
|
| 853 |
|
| 854 | return ret;
|
| 855 | }
|
| 856 |
|
| 857 | static const struct file_operations fops_mem_value = {
|
| 858 | .read = ath10k_mem_value_read,
|
| 859 | .write = ath10k_mem_value_write,
|
| 860 | .open = simple_open,
|
| 861 | .owner = THIS_MODULE,
|
| 862 | .llseek = default_llseek,
|
| 863 | };
|
| 864 |
|
| 865 | static int ath10k_debug_htt_stats_req(struct ath10k *ar)
|
| 866 | {
|
| 867 | u64 cookie;
|
| 868 | int ret;
|
| 869 |
|
| 870 | lockdep_assert_held(&ar->conf_mutex);
|
| 871 |
|
| 872 | if (ar->debug.htt_stats_mask == 0)
|
| 873 |
|
| 874 | return 0;
|
| 875 |
|
| 876 | if (ar->state != ATH10K_STATE_ON)
|
| 877 | return 0;
|
| 878 |
|
| 879 | cookie = get_jiffies_64();
|
| 880 |
|
| 881 | ret = ath10k_htt_h2t_stats_req(&ar->htt, ar->debug.htt_stats_mask,
|
| 882 | ar->debug.reset_htt_stats, cookie);
|
| 883 | if (ret) {
|
| 884 | ath10k_warn(ar, "failed to send htt stats request: %d\n", ret);
|
| 885 | return ret;
|
| 886 | }
|
| 887 |
|
| 888 | queue_delayed_work(ar->workqueue, &ar->debug.htt_stats_dwork,
|
| 889 | msecs_to_jiffies(ATH10K_DEBUG_HTT_STATS_INTERVAL));
|
| 890 |
|
| 891 | return 0;
|
| 892 | }
|
| 893 |
|
| 894 | static void ath10k_debug_htt_stats_dwork(struct work_struct *work)
|
| 895 | {
|
| 896 | struct ath10k *ar = container_of(work, struct ath10k,
|
| 897 | debug.htt_stats_dwork.work);
|
| 898 |
|
| 899 | mutex_lock(&ar->conf_mutex);
|
| 900 |
|
| 901 | ath10k_debug_htt_stats_req(ar);
|
| 902 |
|
| 903 | mutex_unlock(&ar->conf_mutex);
|
| 904 | }
|
| 905 |
|
| 906 | static ssize_t ath10k_read_htt_stats_mask(struct file *file,
|
| 907 | char __user *user_buf,
|
| 908 | size_t count, loff_t *ppos)
|
| 909 | {
|
| 910 | struct ath10k *ar = file->private_data;
|
| 911 | char buf[32];
|
| 912 | size_t len;
|
| 913 |
|
| 914 | len = scnprintf(buf, sizeof(buf), "%lu\n", ar->debug.htt_stats_mask);
|
| 915 |
|
| 916 | return simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 917 | }
|
| 918 |
|
| 919 | static ssize_t ath10k_write_htt_stats_mask(struct file *file,
|
| 920 | const char __user *user_buf,
|
| 921 | size_t count, loff_t *ppos)
|
| 922 | {
|
| 923 | struct ath10k *ar = file->private_data;
|
| 924 | unsigned long mask;
|
| 925 | int ret;
|
| 926 |
|
| 927 | ret = kstrtoul_from_user(user_buf, count, 0, &mask);
|
| 928 | if (ret)
|
| 929 | return ret;
|
| 930 |
|
| 931 |
|
| 932 | if (mask > HTT_STATS_BIT_MASK)
|
| 933 | return -E2BIG;
|
| 934 |
|
| 935 | mutex_lock(&ar->conf_mutex);
|
| 936 |
|
| 937 | ar->debug.htt_stats_mask = mask;
|
| 938 |
|
| 939 | ret = ath10k_debug_htt_stats_req(ar);
|
| 940 | if (ret)
|
| 941 | goto out;
|
| 942 |
|
| 943 | ret = count;
|
| 944 |
|
| 945 | out:
|
| 946 | mutex_unlock(&ar->conf_mutex);
|
| 947 |
|
| 948 | return ret;
|
| 949 | }
|
| 950 |
|
| 951 | static const struct file_operations fops_htt_stats_mask = {
|
| 952 | .read = ath10k_read_htt_stats_mask,
|
| 953 | .write = ath10k_write_htt_stats_mask,
|
| 954 | .open = simple_open,
|
| 955 | .owner = THIS_MODULE,
|
| 956 | .llseek = default_llseek,
|
| 957 | };
|
| 958 |
|
| 959 | static ssize_t ath10k_read_htt_max_amsdu_ampdu(struct file *file,
|
| 960 | char __user *user_buf,
|
| 961 | size_t count, loff_t *ppos)
|
| 962 | {
|
| 963 | struct ath10k *ar = file->private_data;
|
| 964 | char buf[64];
|
| 965 | u8 amsdu, ampdu;
|
| 966 | size_t len;
|
| 967 |
|
| 968 | mutex_lock(&ar->conf_mutex);
|
| 969 |
|
| 970 | amsdu = ar->htt.max_num_amsdu;
|
| 971 | ampdu = ar->htt.max_num_ampdu;
|
| 972 | mutex_unlock(&ar->conf_mutex);
|
| 973 |
|
| 974 | len = scnprintf(buf, sizeof(buf), "%u %u\n", amsdu, ampdu);
|
| 975 |
|
| 976 | return simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 977 | }
|
| 978 |
|
| 979 | static ssize_t ath10k_write_htt_max_amsdu_ampdu(struct file *file,
|
| 980 | const char __user *user_buf,
|
| 981 | size_t count, loff_t *ppos)
|
| 982 | {
|
| 983 | struct ath10k *ar = file->private_data;
|
| 984 | int res;
|
| 985 | char buf[64] = {};
|
| 986 | unsigned int amsdu, ampdu;
|
| 987 |
|
| 988 | res = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
|
| 989 | user_buf, count);
|
| 990 | if (res <= 0)
|
| 991 | return res;
|
| 992 |
|
| 993 | res = sscanf(buf, "%u %u", &amsdu, &du);
|
| 994 |
|
| 995 | if (res != 2)
|
| 996 | return -EINVAL;
|
| 997 |
|
| 998 | mutex_lock(&ar->conf_mutex);
|
| 999 |
|
| 1000 | res = ath10k_htt_h2t_aggr_cfg_msg(&ar->htt, ampdu, amsdu);
|
| 1001 | if (res)
|
| 1002 | goto out;
|
| 1003 |
|
| 1004 | res = count;
|
| 1005 | ar->htt.max_num_amsdu = amsdu;
|
| 1006 | ar->htt.max_num_ampdu = ampdu;
|
| 1007 |
|
| 1008 | out:
|
| 1009 | mutex_unlock(&ar->conf_mutex);
|
| 1010 | return res;
|
| 1011 | }
|
| 1012 |
|
| 1013 | static const struct file_operations fops_htt_max_amsdu_ampdu = {
|
| 1014 | .read = ath10k_read_htt_max_amsdu_ampdu,
|
| 1015 | .write = ath10k_write_htt_max_amsdu_ampdu,
|
| 1016 | .open = simple_open,
|
| 1017 | .owner = THIS_MODULE,
|
| 1018 | .llseek = default_llseek,
|
| 1019 | };
|
| 1020 |
|
| 1021 | static ssize_t ath10k_read_fw_dbglog(struct file *file,
|
| 1022 | char __user *user_buf,
|
| 1023 | size_t count, loff_t *ppos)
|
| 1024 | {
|
| 1025 | struct ath10k *ar = file->private_data;
|
| 1026 | size_t len;
|
| 1027 | char buf[96];
|
| 1028 |
|
| 1029 | len = scnprintf(buf, sizeof(buf), "0x%16llx %u\n",
|
| 1030 | ar->debug.fw_dbglog_mask, ar->debug.fw_dbglog_level);
|
| 1031 |
|
| 1032 | return simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 1033 | }
|
| 1034 |
|
| 1035 | static ssize_t ath10k_write_fw_dbglog(struct file *file,
|
| 1036 | const char __user *user_buf,
|
| 1037 | size_t count, loff_t *ppos)
|
| 1038 | {
|
| 1039 | struct ath10k *ar = file->private_data;
|
| 1040 | int ret;
|
| 1041 | char buf[96] = {};
|
| 1042 | unsigned int log_level;
|
| 1043 | u64 mask;
|
| 1044 |
|
| 1045 | ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
|
| 1046 | user_buf, count);
|
| 1047 | if (ret <= 0)
|
| 1048 | return ret;
|
| 1049 |
|
| 1050 | ret = sscanf(buf, "%llx %u", &mask, &log_level);
|
| 1051 |
|
| 1052 | if (!ret)
|
| 1053 | return -EINVAL;
|
| 1054 |
|
| 1055 | if (ret == 1)
|
| 1056 |
|
| 1057 | log_level = ATH10K_DBGLOG_LEVEL_WARN;
|
| 1058 |
|
| 1059 | mutex_lock(&ar->conf_mutex);
|
| 1060 |
|
| 1061 | ar->debug.fw_dbglog_mask = mask;
|
| 1062 | ar->debug.fw_dbglog_level = log_level;
|
| 1063 |
|
| 1064 | if (ar->state == ATH10K_STATE_ON) {
|
| 1065 | ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask,
|
| 1066 | ar->debug.fw_dbglog_level);
|
| 1067 | if (ret) {
|
| 1068 | ath10k_warn(ar, "dbglog cfg failed from debugfs: %d\n",
|
| 1069 | ret);
|
| 1070 | goto exit;
|
| 1071 | }
|
| 1072 | }
|
| 1073 |
|
| 1074 | ret = count;
|
| 1075 |
|
| 1076 | exit:
|
| 1077 | mutex_unlock(&ar->conf_mutex);
|
| 1078 |
|
| 1079 | return ret;
|
| 1080 | }
|
| 1081 |
|
| 1082 | |
| 1083 | * move the stats storage out of ath10k_debug, or always have ath10k_debug
|
| 1084 | * struct available..
|
| 1085 |
|
| 1086 |
|
| 1087 |
|
| 1088 | static const char ath10k_gstrings_stats[][ETH_GSTRING_LEN] = {
|
| 1089 | "tx_pkts_nic",
|
| 1090 | "tx_bytes_nic",
|
| 1091 | "rx_pkts_nic",
|
| 1092 | "rx_bytes_nic",
|
| 1093 | "d_noise_floor",
|
| 1094 | "d_cycle_count",
|
| 1095 | "d_phy_error",
|
| 1096 | "d_rts_bad",
|
| 1097 | "d_rts_good",
|
| 1098 | "d_tx_power",
|
| 1099 | "d_rx_crc_err",
|
| 1100 | "d_rx_crc_err_drop",
|
| 1101 | "d_no_beacon",
|
| 1102 | "d_tx_mpdus_queued",
|
| 1103 | "d_tx_msdu_queued",
|
| 1104 | "d_tx_msdu_dropped",
|
| 1105 | "d_local_enqued",
|
| 1106 | "d_local_freed",
|
| 1107 | "d_tx_ppdu_hw_queued",
|
| 1108 | "d_tx_ppdu_reaped",
|
| 1109 | "d_tx_fifo_underrun",
|
| 1110 | "d_tx_ppdu_abort",
|
| 1111 | "d_tx_mpdu_requeued",
|
| 1112 | "d_tx_excessive_retries",
|
| 1113 | "d_tx_hw_rate",
|
| 1114 | "d_tx_dropped_sw_retries",
|
| 1115 | "d_tx_illegal_rate",
|
| 1116 | "d_tx_continuous_xretries",
|
| 1117 | "d_tx_timeout",
|
| 1118 | "d_tx_mpdu_txop_limit",
|
| 1119 | "d_pdev_resets",
|
| 1120 | "d_rx_mid_ppdu_route_change",
|
| 1121 | "d_rx_status",
|
| 1122 | "d_rx_extra_frags_ring0",
|
| 1123 | "d_rx_extra_frags_ring1",
|
| 1124 | "d_rx_extra_frags_ring2",
|
| 1125 | "d_rx_extra_frags_ring3",
|
| 1126 | "d_rx_msdu_htt",
|
| 1127 | "d_rx_mpdu_htt",
|
| 1128 | "d_rx_msdu_stack",
|
| 1129 | "d_rx_mpdu_stack",
|
| 1130 | "d_rx_phy_err",
|
| 1131 | "d_rx_phy_err_drops",
|
| 1132 | "d_rx_mpdu_errors",
|
| 1133 | "d_fw_crash_count",
|
| 1134 | "d_fw_warm_reset_count",
|
| 1135 | "d_fw_cold_reset_count",
|
| 1136 | };
|
| 1137 |
|
| 1138 | #define ATH10K_SSTATS_LEN ARRAY_SIZE(ath10k_gstrings_stats)
|
| 1139 |
|
| 1140 | void ath10k_debug_get_et_strings(struct ieee80211_hw *hw,
|
| 1141 | struct ieee80211_vif *vif,
|
| 1142 | u32 sset, u8 *data)
|
| 1143 | {
|
| 1144 | if (sset == ETH_SS_STATS)
|
| 1145 | memcpy(data, ath10k_gstrings_stats,
|
| 1146 | sizeof(ath10k_gstrings_stats));
|
| 1147 | }
|
| 1148 |
|
| 1149 | int ath10k_debug_get_et_sset_count(struct ieee80211_hw *hw,
|
| 1150 | struct ieee80211_vif *vif, int sset)
|
| 1151 | {
|
| 1152 | if (sset == ETH_SS_STATS)
|
| 1153 | return ATH10K_SSTATS_LEN;
|
| 1154 |
|
| 1155 | return 0;
|
| 1156 | }
|
| 1157 |
|
| 1158 | void ath10k_debug_get_et_stats(struct ieee80211_hw *hw,
|
| 1159 | struct ieee80211_vif *vif,
|
| 1160 | struct ethtool_stats *stats, u64 *data)
|
| 1161 | {
|
| 1162 | struct ath10k *ar = hw->priv;
|
| 1163 | static const struct ath10k_fw_stats_pdev zero_stats = {};
|
| 1164 | const struct ath10k_fw_stats_pdev *pdev_stats;
|
| 1165 | int i = 0, ret;
|
| 1166 |
|
| 1167 | mutex_lock(&ar->conf_mutex);
|
| 1168 |
|
| 1169 | if (ar->state == ATH10K_STATE_ON) {
|
| 1170 | ret = ath10k_debug_fw_stats_request(ar);
|
| 1171 | if (ret) {
|
| 1172 |
|
| 1173 | ath10k_warn(ar,
|
| 1174 | "failed to get fw stats for ethtool: %d\n",
|
| 1175 | ret);
|
| 1176 | }
|
| 1177 | }
|
| 1178 |
|
| 1179 | pdev_stats = list_first_entry_or_null(&ar->debug.fw_stats.pdevs,
|
| 1180 | struct ath10k_fw_stats_pdev,
|
| 1181 | list);
|
| 1182 | if (!pdev_stats) {
|
| 1183 |
|
| 1184 | pdev_stats = &zero_stats;
|
| 1185 | }
|
| 1186 |
|
| 1187 | spin_lock_bh(&ar->data_lock);
|
| 1188 |
|
| 1189 | data[i++] = pdev_stats->hw_reaped;
|
| 1190 | data[i++] = 0;
|
| 1191 | data[i++] = pdev_stats->htt_mpdus;
|
| 1192 | data[i++] = 0;
|
| 1193 | data[i++] = pdev_stats->ch_noise_floor;
|
| 1194 | data[i++] = pdev_stats->cycle_count;
|
| 1195 | data[i++] = pdev_stats->phy_err_count;
|
| 1196 | data[i++] = pdev_stats->rts_bad;
|
| 1197 | data[i++] = pdev_stats->rts_good;
|
| 1198 | data[i++] = pdev_stats->chan_tx_power;
|
| 1199 | data[i++] = pdev_stats->fcs_bad;
|
| 1200 | data[i++] = ar->stats.rx_crc_err_drop;
|
| 1201 | data[i++] = pdev_stats->no_beacons;
|
| 1202 | data[i++] = pdev_stats->mpdu_enqued;
|
| 1203 | data[i++] = pdev_stats->msdu_enqued;
|
| 1204 | data[i++] = pdev_stats->wmm_drop;
|
| 1205 | data[i++] = pdev_stats->local_enqued;
|
| 1206 | data[i++] = pdev_stats->local_freed;
|
| 1207 | data[i++] = pdev_stats->hw_queued;
|
| 1208 | data[i++] = pdev_stats->hw_reaped;
|
| 1209 | data[i++] = pdev_stats->underrun;
|
| 1210 | data[i++] = pdev_stats->tx_abort;
|
| 1211 | data[i++] = pdev_stats->mpdus_requeued;
|
| 1212 | data[i++] = pdev_stats->tx_ko;
|
| 1213 | data[i++] = pdev_stats->data_rc;
|
| 1214 | data[i++] = pdev_stats->sw_retry_failure;
|
| 1215 | data[i++] = pdev_stats->illgl_rate_phy_err;
|
| 1216 | data[i++] = pdev_stats->pdev_cont_xretry;
|
| 1217 | data[i++] = pdev_stats->pdev_tx_timeout;
|
| 1218 | data[i++] = pdev_stats->txop_ovf;
|
| 1219 | data[i++] = pdev_stats->pdev_resets;
|
| 1220 | data[i++] = pdev_stats->mid_ppdu_route_change;
|
| 1221 | data[i++] = pdev_stats->status_rcvd;
|
| 1222 | data[i++] = pdev_stats->r0_frags;
|
| 1223 | data[i++] = pdev_stats->r1_frags;
|
| 1224 | data[i++] = pdev_stats->r2_frags;
|
| 1225 | data[i++] = pdev_stats->r3_frags;
|
| 1226 | data[i++] = pdev_stats->htt_msdus;
|
| 1227 | data[i++] = pdev_stats->htt_mpdus;
|
| 1228 | data[i++] = pdev_stats->loc_msdus;
|
| 1229 | data[i++] = pdev_stats->loc_mpdus;
|
| 1230 | data[i++] = pdev_stats->phy_errs;
|
| 1231 | data[i++] = pdev_stats->phy_err_drop;
|
| 1232 | data[i++] = pdev_stats->mpdu_errs;
|
| 1233 | data[i++] = ar->stats.fw_crash_counter;
|
| 1234 | data[i++] = ar->stats.fw_warm_reset_counter;
|
| 1235 | data[i++] = ar->stats.fw_cold_reset_counter;
|
| 1236 |
|
| 1237 | spin_unlock_bh(&ar->data_lock);
|
| 1238 |
|
| 1239 | mutex_unlock(&ar->conf_mutex);
|
| 1240 |
|
| 1241 | WARN_ON(i != ATH10K_SSTATS_LEN);
|
| 1242 | }
|
| 1243 |
|
| 1244 | static const struct file_operations fops_fw_dbglog = {
|
| 1245 | .read = ath10k_read_fw_dbglog,
|
| 1246 | .write = ath10k_write_fw_dbglog,
|
| 1247 | .open = simple_open,
|
| 1248 | .owner = THIS_MODULE,
|
| 1249 | .llseek = default_llseek,
|
| 1250 | };
|
| 1251 |
|
| 1252 | static int ath10k_debug_cal_data_fetch(struct ath10k *ar)
|
| 1253 | {
|
| 1254 | u32 hi_addr;
|
| 1255 | __le32 addr;
|
| 1256 | int ret;
|
| 1257 |
|
| 1258 | lockdep_assert_held(&ar->conf_mutex);
|
| 1259 |
|
| 1260 | if (WARN_ON(ar->hw_params.cal_data_len > ATH10K_DEBUG_CAL_DATA_LEN))
|
| 1261 | return -EINVAL;
|
| 1262 |
|
| 1263 | if (ar->hw_params.cal_data_len == 0)
|
| 1264 | return -EOPNOTSUPP;
|
| 1265 |
|
| 1266 | hi_addr = host_interest_item_address(HI_ITEM(hi_board_data));
|
| 1267 |
|
| 1268 | ret = ath10k_hif_diag_read(ar, hi_addr, &addr, sizeof(addr));
|
| 1269 | if (ret) {
|
| 1270 | ath10k_warn(ar, "failed to read hi_board_data address: %d\n",
|
| 1271 | ret);
|
| 1272 | return ret;
|
| 1273 | }
|
| 1274 |
|
| 1275 | ret = ath10k_hif_diag_read(ar, le32_to_cpu(addr), ar->debug.cal_data,
|
| 1276 | ar->hw_params.cal_data_len);
|
| 1277 | if (ret) {
|
| 1278 | ath10k_warn(ar, "failed to read calibration data: %d\n", ret);
|
| 1279 | return ret;
|
| 1280 | }
|
| 1281 |
|
| 1282 | return 0;
|
| 1283 | }
|
| 1284 |
|
| 1285 | static int ath10k_debug_cal_data_open(struct inode *inode, struct file *file)
|
| 1286 | {
|
| 1287 | struct ath10k *ar = inode->i_private;
|
| 1288 |
|
| 1289 | mutex_lock(&ar->conf_mutex);
|
| 1290 |
|
| 1291 | if (ar->state == ATH10K_STATE_ON ||
|
| 1292 | ar->state == ATH10K_STATE_UTF) {
|
| 1293 | ath10k_debug_cal_data_fetch(ar);
|
| 1294 | }
|
| 1295 |
|
| 1296 | file->private_data = ar;
|
| 1297 | mutex_unlock(&ar->conf_mutex);
|
| 1298 |
|
| 1299 | return 0;
|
| 1300 | }
|
| 1301 |
|
| 1302 | static ssize_t ath10k_debug_cal_data_read(struct file *file,
|
| 1303 | char __user *user_buf,
|
| 1304 | size_t count, loff_t *ppos)
|
| 1305 | {
|
| 1306 | struct ath10k *ar = file->private_data;
|
| 1307 |
|
| 1308 | mutex_lock(&ar->conf_mutex);
|
| 1309 |
|
| 1310 | count = simple_read_from_buffer(user_buf, count, ppos,
|
| 1311 | ar->debug.cal_data,
|
| 1312 | ar->hw_params.cal_data_len);
|
| 1313 |
|
| 1314 | mutex_unlock(&ar->conf_mutex);
|
| 1315 |
|
| 1316 | return count;
|
| 1317 | }
|
| 1318 |
|
| 1319 | static ssize_t ath10k_write_ani_enable(struct file *file,
|
| 1320 | const char __user *user_buf,
|
| 1321 | size_t count, loff_t *ppos)
|
| 1322 | {
|
| 1323 | struct ath10k *ar = file->private_data;
|
| 1324 | int ret;
|
| 1325 | u8 enable;
|
| 1326 |
|
| 1327 | if (kstrtou8_from_user(user_buf, count, 0, &enable))
|
| 1328 | return -EINVAL;
|
| 1329 |
|
| 1330 | mutex_lock(&ar->conf_mutex);
|
| 1331 |
|
| 1332 | if (ar->ani_enabled == enable) {
|
| 1333 | ret = count;
|
| 1334 | goto exit;
|
| 1335 | }
|
| 1336 |
|
| 1337 | ret = ath10k_wmi_pdev_set_param(ar, ar->wmi.pdev_param->ani_enable,
|
| 1338 | enable);
|
| 1339 | if (ret) {
|
| 1340 | ath10k_warn(ar, "ani_enable failed from debugfs: %d\n", ret);
|
| 1341 | goto exit;
|
| 1342 | }
|
| 1343 | ar->ani_enabled = enable;
|
| 1344 |
|
| 1345 | ret = count;
|
| 1346 |
|
| 1347 | exit:
|
| 1348 | mutex_unlock(&ar->conf_mutex);
|
| 1349 |
|
| 1350 | return ret;
|
| 1351 | }
|
| 1352 |
|
| 1353 | static ssize_t ath10k_read_ani_enable(struct file *file, char __user *user_buf,
|
| 1354 | size_t count, loff_t *ppos)
|
| 1355 | {
|
| 1356 | struct ath10k *ar = file->private_data;
|
| 1357 | size_t len;
|
| 1358 | char buf[32];
|
| 1359 |
|
| 1360 | len = scnprintf(buf, sizeof(buf), "%d\n", ar->ani_enabled);
|
| 1361 |
|
| 1362 | return simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 1363 | }
|
| 1364 |
|
| 1365 | static const struct file_operations fops_ani_enable = {
|
| 1366 | .read = ath10k_read_ani_enable,
|
| 1367 | .write = ath10k_write_ani_enable,
|
| 1368 | .open = simple_open,
|
| 1369 | .owner = THIS_MODULE,
|
| 1370 | .llseek = default_llseek,
|
| 1371 | };
|
| 1372 |
|
| 1373 | static const struct file_operations fops_cal_data = {
|
| 1374 | .open = ath10k_debug_cal_data_open,
|
| 1375 | .read = ath10k_debug_cal_data_read,
|
| 1376 | .owner = THIS_MODULE,
|
| 1377 | .llseek = default_llseek,
|
| 1378 | };
|
| 1379 |
|
| 1380 | static ssize_t ath10k_read_nf_cal_period(struct file *file,
|
| 1381 | char __user *user_buf,
|
| 1382 | size_t count, loff_t *ppos)
|
| 1383 | {
|
| 1384 | struct ath10k *ar = file->private_data;
|
| 1385 | size_t len;
|
| 1386 | char buf[32];
|
| 1387 |
|
| 1388 | len = scnprintf(buf, sizeof(buf), "%d\n", ar->debug.nf_cal_period);
|
| 1389 |
|
| 1390 | return simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 1391 | }
|
| 1392 |
|
| 1393 | static ssize_t ath10k_write_nf_cal_period(struct file *file,
|
| 1394 | const char __user *user_buf,
|
| 1395 | size_t count, loff_t *ppos)
|
| 1396 | {
|
| 1397 | struct ath10k *ar = file->private_data;
|
| 1398 | unsigned long period;
|
| 1399 | int ret;
|
| 1400 |
|
| 1401 | ret = kstrtoul_from_user(user_buf, count, 0, &period);
|
| 1402 | if (ret)
|
| 1403 | return ret;
|
| 1404 |
|
| 1405 | if (period > WMI_PDEV_PARAM_CAL_PERIOD_MAX)
|
| 1406 | return -EINVAL;
|
| 1407 |
|
| 1408 |
|
| 1409 | if (period == 0)
|
| 1410 | return -EINVAL;
|
| 1411 |
|
| 1412 | mutex_lock(&ar->conf_mutex);
|
| 1413 |
|
| 1414 | ar->debug.nf_cal_period = period;
|
| 1415 |
|
| 1416 | if (ar->state != ATH10K_STATE_ON) {
|
| 1417 |
|
| 1418 | ret = count;
|
| 1419 | goto exit;
|
| 1420 | }
|
| 1421 |
|
| 1422 | ret = ath10k_wmi_pdev_set_param(ar, ar->wmi.pdev_param->cal_period,
|
| 1423 | ar->debug.nf_cal_period);
|
| 1424 | if (ret) {
|
| 1425 | ath10k_warn(ar, "cal period cfg failed from debugfs: %d\n",
|
| 1426 | ret);
|
| 1427 | goto exit;
|
| 1428 | }
|
| 1429 |
|
| 1430 | ret = count;
|
| 1431 |
|
| 1432 | exit:
|
| 1433 | mutex_unlock(&ar->conf_mutex);
|
| 1434 |
|
| 1435 | return ret;
|
| 1436 | }
|
| 1437 |
|
| 1438 | static const struct file_operations fops_nf_cal_period = {
|
| 1439 | .read = ath10k_read_nf_cal_period,
|
| 1440 | .write = ath10k_write_nf_cal_period,
|
| 1441 | .open = simple_open,
|
| 1442 | .owner = THIS_MODULE,
|
| 1443 | .llseek = default_llseek,
|
| 1444 | };
|
| 1445 |
|
| 1446 | #define ATH10K_TPC_CONFIG_BUF_SIZE (1024 * 1024)
|
| 1447 |
|
| 1448 | static int ath10k_debug_tpc_stats_request(struct ath10k *ar)
|
| 1449 | {
|
| 1450 | int ret;
|
| 1451 | unsigned long time_left;
|
| 1452 |
|
| 1453 | lockdep_assert_held(&ar->conf_mutex);
|
| 1454 |
|
| 1455 | reinit_completion(&ar->debug.tpc_complete);
|
| 1456 |
|
| 1457 | ret = ath10k_wmi_pdev_get_tpc_config(ar, WMI_TPC_CONFIG_PARAM);
|
| 1458 | if (ret) {
|
| 1459 | ath10k_warn(ar, "failed to request tpc config: %d\n", ret);
|
| 1460 | return ret;
|
| 1461 | }
|
| 1462 |
|
| 1463 | time_left = wait_for_completion_timeout(&ar->debug.tpc_complete,
|
| 1464 | 1 * HZ);
|
| 1465 | if (time_left == 0)
|
| 1466 | return -ETIMEDOUT;
|
| 1467 |
|
| 1468 | return 0;
|
| 1469 | }
|
| 1470 |
|
| 1471 | void ath10k_debug_tpc_stats_process(struct ath10k *ar,
|
| 1472 | struct ath10k_tpc_stats *tpc_stats)
|
| 1473 | {
|
| 1474 | spin_lock_bh(&ar->data_lock);
|
| 1475 |
|
| 1476 | kfree(ar->debug.tpc_stats);
|
| 1477 | ar->debug.tpc_stats = tpc_stats;
|
| 1478 | complete(&ar->debug.tpc_complete);
|
| 1479 |
|
| 1480 | spin_unlock_bh(&ar->data_lock);
|
| 1481 | }
|
| 1482 |
|
| 1483 | void
|
| 1484 | ath10k_debug_tpc_stats_final_process(struct ath10k *ar,
|
| 1485 | struct ath10k_tpc_stats_final *tpc_stats)
|
| 1486 | {
|
| 1487 | spin_lock_bh(&ar->data_lock);
|
| 1488 |
|
| 1489 | kfree(ar->debug.tpc_stats_final);
|
| 1490 | ar->debug.tpc_stats_final = tpc_stats;
|
| 1491 | complete(&ar->debug.tpc_complete);
|
| 1492 |
|
| 1493 | spin_unlock_bh(&ar->data_lock);
|
| 1494 | }
|
| 1495 |
|
| 1496 | static void ath10k_tpc_stats_print(struct ath10k_tpc_stats *tpc_stats,
|
| 1497 | unsigned int j, char *buf, size_t *len)
|
| 1498 | {
|
| 1499 | int i;
|
| 1500 | size_t buf_len;
|
| 1501 | static const char table_str[][5] = { "CDD",
|
| 1502 | "STBC",
|
| 1503 | "TXBF" };
|
| 1504 | static const char pream_str[][6] = { "CCK",
|
| 1505 | "OFDM",
|
| 1506 | "HT20",
|
| 1507 | "HT40",
|
| 1508 | "VHT20",
|
| 1509 | "VHT40",
|
| 1510 | "VHT80",
|
| 1511 | "HTCUP" };
|
| 1512 |
|
| 1513 | buf_len = ATH10K_TPC_CONFIG_BUF_SIZE;
|
| 1514 | *len += scnprintf(buf + *len, buf_len - *len,
|
| 1515 | "********************************\n");
|
| 1516 | *len += scnprintf(buf + *len, buf_len - *len,
|
| 1517 | "******************* %s POWER TABLE ****************\n",
|
| 1518 | table_str[j]);
|
| 1519 | *len += scnprintf(buf + *len, buf_len - *len,
|
| 1520 | "********************************\n");
|
| 1521 | *len += scnprintf(buf + *len, buf_len - *len,
|
| 1522 | "No. Preamble Rate_code ");
|
| 1523 |
|
| 1524 | for (i = 0; i < tpc_stats->num_tx_chain; i++)
|
| 1525 | *len += scnprintf(buf + *len, buf_len - *len,
|
| 1526 | "tpc_value%d ", i);
|
| 1527 |
|
| 1528 | *len += scnprintf(buf + *len, buf_len - *len, "\n");
|
| 1529 |
|
| 1530 | for (i = 0; i < tpc_stats->rate_max; i++) {
|
| 1531 | *len += scnprintf(buf + *len, buf_len - *len,
|
| 1532 | "%8d %s 0x%2x %s\n", i,
|
| 1533 | pream_str[tpc_stats->tpc_table[j].pream_idx[i]],
|
| 1534 | tpc_stats->tpc_table[j].rate_code[i],
|
| 1535 | tpc_stats->tpc_table[j].tpc_value[i]);
|
| 1536 | }
|
| 1537 |
|
| 1538 | *len += scnprintf(buf + *len, buf_len - *len,
|
| 1539 | "***********************************\n");
|
| 1540 | }
|
| 1541 |
|
| 1542 | static void ath10k_tpc_stats_fill(struct ath10k *ar,
|
| 1543 | struct ath10k_tpc_stats *tpc_stats,
|
| 1544 | char *buf)
|
| 1545 | {
|
| 1546 | int j;
|
| 1547 | size_t len, buf_len;
|
| 1548 |
|
| 1549 | len = 0;
|
| 1550 | buf_len = ATH10K_TPC_CONFIG_BUF_SIZE;
|
| 1551 |
|
| 1552 | spin_lock_bh(&ar->data_lock);
|
| 1553 |
|
| 1554 | if (!tpc_stats) {
|
| 1555 | ath10k_warn(ar, "failed to get tpc stats\n");
|
| 1556 | goto unlock;
|
| 1557 | }
|
| 1558 |
|
| 1559 | len += scnprintf(buf + len, buf_len - len, "\n");
|
| 1560 | len += scnprintf(buf + len, buf_len - len,
|
| 1561 | "*************************************\n");
|
| 1562 | len += scnprintf(buf + len, buf_len - len,
|
| 1563 | "TPC config for channel %4d mode %d\n",
|
| 1564 | tpc_stats->chan_freq,
|
| 1565 | tpc_stats->phy_mode);
|
| 1566 | len += scnprintf(buf + len, buf_len - len,
|
| 1567 | "*************************************\n");
|
| 1568 | len += scnprintf(buf + len, buf_len - len,
|
| 1569 | "CTL = 0x%2x Reg. Domain = %2d\n",
|
| 1570 | tpc_stats->ctl,
|
| 1571 | tpc_stats->reg_domain);
|
| 1572 | len += scnprintf(buf + len, buf_len - len,
|
| 1573 | "Antenna Gain = %2d Reg. Max Antenna Gain = %2d\n",
|
| 1574 | tpc_stats->twice_antenna_gain,
|
| 1575 | tpc_stats->twice_antenna_reduction);
|
| 1576 | len += scnprintf(buf + len, buf_len - len,
|
| 1577 | "Power Limit = %2d Reg. Max Power = %2d\n",
|
| 1578 | tpc_stats->power_limit,
|
| 1579 | tpc_stats->twice_max_rd_power / 2);
|
| 1580 | len += scnprintf(buf + len, buf_len - len,
|
| 1581 | "Num tx chains = %2d Num supported rates = %2d\n",
|
| 1582 | tpc_stats->num_tx_chain,
|
| 1583 | tpc_stats->rate_max);
|
| 1584 |
|
| 1585 | for (j = 0; j < WMI_TPC_FLAG; j++) {
|
| 1586 | switch (j) {
|
| 1587 | case WMI_TPC_TABLE_TYPE_CDD:
|
| 1588 | if (tpc_stats->flag[j] == ATH10K_TPC_TABLE_TYPE_FLAG) {
|
| 1589 | len += scnprintf(buf + len, buf_len - len,
|
| 1590 | "CDD not supported\n");
|
| 1591 | break;
|
| 1592 | }
|
| 1593 |
|
| 1594 | ath10k_tpc_stats_print(tpc_stats, j, buf, &len);
|
| 1595 | break;
|
| 1596 | case WMI_TPC_TABLE_TYPE_STBC:
|
| 1597 | if (tpc_stats->flag[j] == ATH10K_TPC_TABLE_TYPE_FLAG) {
|
| 1598 | len += scnprintf(buf + len, buf_len - len,
|
| 1599 | "STBC not supported\n");
|
| 1600 | break;
|
| 1601 | }
|
| 1602 |
|
| 1603 | ath10k_tpc_stats_print(tpc_stats, j, buf, &len);
|
| 1604 | break;
|
| 1605 | case WMI_TPC_TABLE_TYPE_TXBF:
|
| 1606 | if (tpc_stats->flag[j] == ATH10K_TPC_TABLE_TYPE_FLAG) {
|
| 1607 | len += scnprintf(buf + len, buf_len - len,
|
| 1608 | "TXBF not supported\n***************************\n");
|
| 1609 | break;
|
| 1610 | }
|
| 1611 |
|
| 1612 | ath10k_tpc_stats_print(tpc_stats, j, buf, &len);
|
| 1613 | break;
|
| 1614 | default:
|
| 1615 | len += scnprintf(buf + len, buf_len - len,
|
| 1616 | "Invalid Type\n");
|
| 1617 | break;
|
| 1618 | }
|
| 1619 | }
|
| 1620 |
|
| 1621 | unlock:
|
| 1622 | spin_unlock_bh(&ar->data_lock);
|
| 1623 |
|
| 1624 | if (len >= buf_len)
|
| 1625 | buf[len - 1] = 0;
|
| 1626 | else
|
| 1627 | buf[len] = 0;
|
| 1628 | }
|
| 1629 |
|
| 1630 | static int ath10k_tpc_stats_open(struct inode *inode, struct file *file)
|
| 1631 | {
|
| 1632 | struct ath10k *ar = inode->i_private;
|
| 1633 | void *buf = NULL;
|
| 1634 | int ret;
|
| 1635 |
|
| 1636 | mutex_lock(&ar->conf_mutex);
|
| 1637 |
|
| 1638 | if (ar->state != ATH10K_STATE_ON) {
|
| 1639 | ret = -ENETDOWN;
|
| 1640 | goto err_unlock;
|
| 1641 | }
|
| 1642 |
|
| 1643 | buf = vmalloc(ATH10K_TPC_CONFIG_BUF_SIZE);
|
| 1644 | if (!buf) {
|
| 1645 | ret = -ENOMEM;
|
| 1646 | goto err_unlock;
|
| 1647 | }
|
| 1648 |
|
| 1649 | ret = ath10k_debug_tpc_stats_request(ar);
|
| 1650 | if (ret) {
|
| 1651 | ath10k_warn(ar, "failed to request tpc config stats: %d\n",
|
| 1652 | ret);
|
| 1653 | goto err_free;
|
| 1654 | }
|
| 1655 |
|
| 1656 | ath10k_tpc_stats_fill(ar, ar->debug.tpc_stats, buf);
|
| 1657 | file->private_data = buf;
|
| 1658 |
|
| 1659 | mutex_unlock(&ar->conf_mutex);
|
| 1660 | return 0;
|
| 1661 |
|
| 1662 | err_free:
|
| 1663 | vfree(buf);
|
| 1664 |
|
| 1665 | err_unlock:
|
| 1666 | mutex_unlock(&ar->conf_mutex);
|
| 1667 | return ret;
|
| 1668 | }
|
| 1669 |
|
| 1670 | static int ath10k_tpc_stats_release(struct inode *inode, struct file *file)
|
| 1671 | {
|
| 1672 | vfree(file->private_data);
|
| 1673 |
|
| 1674 | return 0;
|
| 1675 | }
|
| 1676 |
|
| 1677 | static ssize_t ath10k_tpc_stats_read(struct file *file, char __user *user_buf,
|
| 1678 | size_t count, loff_t *ppos)
|
| 1679 | {
|
| 1680 | const char *buf = file->private_data;
|
| 1681 | size_t len = strlen(buf);
|
| 1682 |
|
| 1683 | return simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 1684 | }
|
| 1685 |
|
| 1686 | static const struct file_operations fops_tpc_stats = {
|
| 1687 | .open = ath10k_tpc_stats_open,
|
| 1688 | .release = ath10k_tpc_stats_release,
|
| 1689 | .read = ath10k_tpc_stats_read,
|
| 1690 | .owner = THIS_MODULE,
|
| 1691 | .llseek = default_llseek,
|
| 1692 | };
|
| 1693 |
|
| 1694 | int ath10k_debug_start(struct ath10k *ar)
|
| 1695 | {
|
| 1696 | int ret;
|
| 1697 |
|
| 1698 | lockdep_assert_held(&ar->conf_mutex);
|
| 1699 |
|
| 1700 | ret = ath10k_debug_htt_stats_req(ar);
|
| 1701 | if (ret)
|
| 1702 |
|
| 1703 | ath10k_warn(ar, "failed to start htt stats workqueue: %d\n",
|
| 1704 | ret);
|
| 1705 |
|
| 1706 | if (ar->debug.fw_dbglog_mask) {
|
| 1707 | ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask,
|
| 1708 | ATH10K_DBGLOG_LEVEL_WARN);
|
| 1709 | if (ret)
|
| 1710 |
|
| 1711 | ath10k_warn(ar, "failed to enable dbglog during start: %d",
|
| 1712 | ret);
|
| 1713 | }
|
| 1714 |
|
| 1715 | if (ar->pktlog_filter) {
|
| 1716 | ret = ath10k_wmi_pdev_pktlog_enable(ar,
|
| 1717 | ar->pktlog_filter);
|
| 1718 | if (ret)
|
| 1719 |
|
| 1720 | ath10k_warn(ar,
|
| 1721 | "failed to enable pktlog filter %x: %d\n",
|
| 1722 | ar->pktlog_filter, ret);
|
| 1723 | } else {
|
| 1724 | ret = ath10k_wmi_pdev_pktlog_disable(ar);
|
| 1725 | if (ret)
|
| 1726 |
|
| 1727 | ath10k_warn(ar, "failed to disable pktlog: %d\n", ret);
|
| 1728 | }
|
| 1729 |
|
| 1730 | if (ar->debug.nf_cal_period &&
|
| 1731 | !test_bit(ATH10K_FW_FEATURE_NON_BMI,
|
| 1732 | ar->normal_mode_fw.fw_file.fw_features)) {
|
| 1733 | ret = ath10k_wmi_pdev_set_param(ar,
|
| 1734 | ar->wmi.pdev_param->cal_period,
|
| 1735 | ar->debug.nf_cal_period);
|
| 1736 | if (ret)
|
| 1737 |
|
| 1738 | ath10k_warn(ar, "cal period cfg failed from debug start: %d\n",
|
| 1739 | ret);
|
| 1740 | }
|
| 1741 |
|
| 1742 | return ret;
|
| 1743 | }
|
| 1744 |
|
| 1745 | void ath10k_debug_stop(struct ath10k *ar)
|
| 1746 | {
|
| 1747 | lockdep_assert_held(&ar->conf_mutex);
|
| 1748 |
|
| 1749 | if (!test_bit(ATH10K_FW_FEATURE_NON_BMI,
|
| 1750 | ar->normal_mode_fw.fw_file.fw_features))
|
| 1751 | ath10k_debug_cal_data_fetch(ar);
|
| 1752 |
|
| 1753 | |
| 1754 | * ath10k_debug_destroy(). The check for htt_stats_mask is to avoid
|
| 1755 | * warning from timer_delete().
|
| 1756 |
|
| 1757 | if (ar->debug.htt_stats_mask != 0)
|
| 1758 | cancel_delayed_work(&ar->debug.htt_stats_dwork);
|
| 1759 |
|
| 1760 | ath10k_wmi_pdev_pktlog_disable(ar);
|
| 1761 | }
|
| 1762 |
|
| 1763 | static ssize_t ath10k_write_simulate_radar(struct file *file,
|
| 1764 | const char __user *user_buf,
|
| 1765 | size_t count, loff_t *ppos)
|
| 1766 | {
|
| 1767 | struct ath10k *ar = file->private_data;
|
| 1768 | struct ath10k_vif *arvif;
|
| 1769 |
|
| 1770 | |
| 1771 | * sharing the same channel and if the channel is disabled, all the
|
| 1772 | * vifs will share the same 'is_started' state.
|
| 1773 |
|
| 1774 | arvif = list_first_entry(&ar->arvifs, typeof(*arvif), list);
|
| 1775 | if (!arvif->is_started)
|
| 1776 | return -EINVAL;
|
| 1777 |
|
| 1778 | ieee80211_radar_detected(ar->hw, NULL);
|
| 1779 |
|
| 1780 | return count;
|
| 1781 | }
|
| 1782 |
|
| 1783 | static const struct file_operations fops_simulate_radar = {
|
| 1784 | .write = ath10k_write_simulate_radar,
|
| 1785 | .open = simple_open,
|
| 1786 | .owner = THIS_MODULE,
|
| 1787 | .llseek = default_llseek,
|
| 1788 | };
|
| 1789 |
|
| 1790 | #define ATH10K_DFS_STAT(s, p) (\
|
| 1791 | len += scnprintf(buf + len, size - len, "%-28s : %10u\n", s, \
|
| 1792 | ar->debug.dfs_stats.p))
|
| 1793 |
|
| 1794 | #define ATH10K_DFS_POOL_STAT(s, p) (\
|
| 1795 | len += scnprintf(buf + len, size - len, "%-28s : %10u\n", s, \
|
| 1796 | ar->debug.dfs_pool_stats.p))
|
| 1797 |
|
| 1798 | static ssize_t ath10k_read_dfs_stats(struct file *file, char __user *user_buf,
|
| 1799 | size_t count, loff_t *ppos)
|
| 1800 | {
|
| 1801 | int retval = 0, len = 0;
|
| 1802 | const int size = 8000;
|
| 1803 | struct ath10k *ar = file->private_data;
|
| 1804 | char *buf;
|
| 1805 |
|
| 1806 | buf = kzalloc(size, GFP_KERNEL);
|
| 1807 | if (buf == NULL)
|
| 1808 | return -ENOMEM;
|
| 1809 |
|
| 1810 | if (!ar->dfs_detector) {
|
| 1811 | len += scnprintf(buf + len, size - len, "DFS not enabled\n");
|
| 1812 | goto exit;
|
| 1813 | }
|
| 1814 |
|
| 1815 | ar->debug.dfs_pool_stats =
|
| 1816 | ar->dfs_detector->get_stats(ar->dfs_detector);
|
| 1817 |
|
| 1818 | len += scnprintf(buf + len, size - len, "Pulse detector statistics:\n");
|
| 1819 |
|
| 1820 | ATH10K_DFS_STAT("reported phy errors", phy_errors);
|
| 1821 | ATH10K_DFS_STAT("pulse events reported", pulses_total);
|
| 1822 | ATH10K_DFS_STAT("DFS pulses detected", pulses_detected);
|
| 1823 | ATH10K_DFS_STAT("DFS pulses discarded", pulses_discarded);
|
| 1824 | ATH10K_DFS_STAT("Radars detected", radar_detected);
|
| 1825 |
|
| 1826 | len += scnprintf(buf + len, size - len, "Global Pool statistics:\n");
|
| 1827 | ATH10K_DFS_POOL_STAT("Pool references", pool_reference);
|
| 1828 | ATH10K_DFS_POOL_STAT("Pulses allocated", pulse_allocated);
|
| 1829 | ATH10K_DFS_POOL_STAT("Pulses alloc error", pulse_alloc_error);
|
| 1830 | ATH10K_DFS_POOL_STAT("Pulses in use", pulse_used);
|
| 1831 | ATH10K_DFS_POOL_STAT("Seqs. allocated", pseq_allocated);
|
| 1832 | ATH10K_DFS_POOL_STAT("Seqs. alloc error", pseq_alloc_error);
|
| 1833 | ATH10K_DFS_POOL_STAT("Seqs. in use", pseq_used);
|
| 1834 |
|
| 1835 | exit:
|
| 1836 | if (len > size)
|
| 1837 | len = size;
|
| 1838 |
|
| 1839 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 1840 | kfree(buf);
|
| 1841 |
|
| 1842 | return retval;
|
| 1843 | }
|
| 1844 |
|
| 1845 | static const struct file_operations fops_dfs_stats = {
|
| 1846 | .read = ath10k_read_dfs_stats,
|
| 1847 | .open = simple_open,
|
| 1848 | .owner = THIS_MODULE,
|
| 1849 | .llseek = default_llseek,
|
| 1850 | };
|
| 1851 |
|
| 1852 | static ssize_t ath10k_write_pktlog_filter(struct file *file,
|
| 1853 | const char __user *ubuf,
|
| 1854 | size_t count, loff_t *ppos)
|
| 1855 | {
|
| 1856 | struct ath10k *ar = file->private_data;
|
| 1857 | u32 filter;
|
| 1858 | int ret;
|
| 1859 |
|
| 1860 | if (kstrtouint_from_user(ubuf, count, 0, &filter))
|
| 1861 | return -EINVAL;
|
| 1862 |
|
| 1863 | mutex_lock(&ar->conf_mutex);
|
| 1864 |
|
| 1865 | if (ar->state != ATH10K_STATE_ON) {
|
| 1866 | ar->pktlog_filter = filter;
|
| 1867 | ret = count;
|
| 1868 | goto out;
|
| 1869 | }
|
| 1870 |
|
| 1871 | if (filter == ar->pktlog_filter) {
|
| 1872 | ret = count;
|
| 1873 | goto out;
|
| 1874 | }
|
| 1875 |
|
| 1876 | if (filter) {
|
| 1877 | ret = ath10k_wmi_pdev_pktlog_enable(ar, filter);
|
| 1878 | if (ret) {
|
| 1879 | ath10k_warn(ar, "failed to enable pktlog filter %x: %d\n",
|
| 1880 | ar->pktlog_filter, ret);
|
| 1881 | goto out;
|
| 1882 | }
|
| 1883 | } else {
|
| 1884 | ret = ath10k_wmi_pdev_pktlog_disable(ar);
|
| 1885 | if (ret) {
|
| 1886 | ath10k_warn(ar, "failed to disable pktlog: %d\n", ret);
|
| 1887 | goto out;
|
| 1888 | }
|
| 1889 | }
|
| 1890 |
|
| 1891 | ar->pktlog_filter = filter;
|
| 1892 | ret = count;
|
| 1893 |
|
| 1894 | out:
|
| 1895 | mutex_unlock(&ar->conf_mutex);
|
| 1896 | return ret;
|
| 1897 | }
|
| 1898 |
|
| 1899 | static ssize_t ath10k_read_pktlog_filter(struct file *file, char __user *ubuf,
|
| 1900 | size_t count, loff_t *ppos)
|
| 1901 | {
|
| 1902 | char buf[32];
|
| 1903 | struct ath10k *ar = file->private_data;
|
| 1904 | int len = 0;
|
| 1905 |
|
| 1906 | mutex_lock(&ar->conf_mutex);
|
| 1907 | len = scnprintf(buf, sizeof(buf) - len, "%08x\n",
|
| 1908 | ar->pktlog_filter);
|
| 1909 | mutex_unlock(&ar->conf_mutex);
|
| 1910 |
|
| 1911 | return simple_read_from_buffer(ubuf, count, ppos, buf, len);
|
| 1912 | }
|
| 1913 |
|
| 1914 | static const struct file_operations fops_pktlog_filter = {
|
| 1915 | .read = ath10k_read_pktlog_filter,
|
| 1916 | .write = ath10k_write_pktlog_filter,
|
| 1917 | .open = simple_open
|
| 1918 | };
|
| 1919 |
|
| 1920 | static ssize_t ath10k_write_quiet_period(struct file *file,
|
| 1921 | const char __user *ubuf,
|
| 1922 | size_t count, loff_t *ppos)
|
| 1923 | {
|
| 1924 | struct ath10k *ar = file->private_data;
|
| 1925 | u32 period;
|
| 1926 |
|
| 1927 | if (kstrtouint_from_user(ubuf, count, 0, &period))
|
| 1928 | return -EINVAL;
|
| 1929 |
|
| 1930 | if (period < ATH10K_QUIET_PERIOD_MIN) {
|
| 1931 | ath10k_warn(ar, "Quiet period %u can not be lesser than 25ms\n",
|
| 1932 | period);
|
| 1933 | return -EINVAL;
|
| 1934 | }
|
| 1935 | mutex_lock(&ar->conf_mutex);
|
| 1936 | ar->thermal.quiet_period = period;
|
| 1937 | ath10k_thermal_set_throttling(ar);
|
| 1938 | mutex_unlock(&ar->conf_mutex);
|
| 1939 |
|
| 1940 | return count;
|
| 1941 | }
|
| 1942 |
|
| 1943 | static ssize_t ath10k_read_quiet_period(struct file *file, char __user *ubuf,
|
| 1944 | size_t count, loff_t *ppos)
|
| 1945 | {
|
| 1946 | char buf[32];
|
| 1947 | struct ath10k *ar = file->private_data;
|
| 1948 | int len = 0;
|
| 1949 |
|
| 1950 | mutex_lock(&ar->conf_mutex);
|
| 1951 | len = scnprintf(buf, sizeof(buf) - len, "%d\n",
|
| 1952 | ar->thermal.quiet_period);
|
| 1953 | mutex_unlock(&ar->conf_mutex);
|
| 1954 |
|
| 1955 | return simple_read_from_buffer(ubuf, count, ppos, buf, len);
|
| 1956 | }
|
| 1957 |
|
| 1958 | static const struct file_operations fops_quiet_period = {
|
| 1959 | .read = ath10k_read_quiet_period,
|
| 1960 | .write = ath10k_write_quiet_period,
|
| 1961 | .open = simple_open
|
| 1962 | };
|
| 1963 |
|
| 1964 | static ssize_t ath10k_write_btcoex(struct file *file,
|
| 1965 | const char __user *ubuf,
|
| 1966 | size_t count, loff_t *ppos)
|
| 1967 | {
|
| 1968 | struct ath10k *ar = file->private_data;
|
| 1969 | ssize_t ret;
|
| 1970 | bool val;
|
| 1971 | u32 pdev_param;
|
| 1972 |
|
| 1973 | ret = kstrtobool_from_user(ubuf, count, &val);
|
| 1974 | if (ret)
|
| 1975 | return ret;
|
| 1976 |
|
| 1977 | if (!ar->coex_support)
|
| 1978 | return -EOPNOTSUPP;
|
| 1979 |
|
| 1980 | mutex_lock(&ar->conf_mutex);
|
| 1981 |
|
| 1982 | if (ar->state != ATH10K_STATE_ON &&
|
| 1983 | ar->state != ATH10K_STATE_RESTARTED) {
|
| 1984 | ret = -ENETDOWN;
|
| 1985 | goto exit;
|
| 1986 | }
|
| 1987 |
|
| 1988 | if (!(test_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags) ^ val)) {
|
| 1989 | ret = count;
|
| 1990 | goto exit;
|
| 1991 | }
|
| 1992 |
|
| 1993 | pdev_param = ar->wmi.pdev_param->enable_btcoex;
|
| 1994 | if (test_bit(ATH10K_FW_FEATURE_BTCOEX_PARAM,
|
| 1995 | ar->running_fw->fw_file.fw_features)) {
|
| 1996 | ret = ath10k_wmi_pdev_set_param(ar, pdev_param, val);
|
| 1997 | if (ret) {
|
| 1998 | ath10k_warn(ar, "failed to enable btcoex: %zd\n", ret);
|
| 1999 | ret = count;
|
| 2000 | goto exit;
|
| 2001 | }
|
| 2002 | } else {
|
| 2003 | ath10k_info(ar, "restarting firmware due to btcoex change");
|
| 2004 | ath10k_core_start_recovery(ar);
|
| 2005 | }
|
| 2006 |
|
| 2007 | if (val)
|
| 2008 | set_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags);
|
| 2009 | else
|
| 2010 | clear_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags);
|
| 2011 |
|
| 2012 | ret = count;
|
| 2013 |
|
| 2014 | exit:
|
| 2015 | mutex_unlock(&ar->conf_mutex);
|
| 2016 |
|
| 2017 | return ret;
|
| 2018 | }
|
| 2019 |
|
| 2020 | static ssize_t ath10k_read_btcoex(struct file *file, char __user *ubuf,
|
| 2021 | size_t count, loff_t *ppos)
|
| 2022 | {
|
| 2023 | char buf[32];
|
| 2024 | struct ath10k *ar = file->private_data;
|
| 2025 | int len = 0;
|
| 2026 |
|
| 2027 | mutex_lock(&ar->conf_mutex);
|
| 2028 | len = scnprintf(buf, sizeof(buf) - len, "%d\n",
|
| 2029 | test_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags));
|
| 2030 | mutex_unlock(&ar->conf_mutex);
|
| 2031 |
|
| 2032 | return simple_read_from_buffer(ubuf, count, ppos, buf, len);
|
| 2033 | }
|
| 2034 |
|
| 2035 | static const struct file_operations fops_btcoex = {
|
| 2036 | .read = ath10k_read_btcoex,
|
| 2037 | .write = ath10k_write_btcoex,
|
| 2038 | .open = simple_open
|
| 2039 | };
|
| 2040 |
|
| 2041 | static ssize_t ath10k_write_enable_extd_tx_stats(struct file *file,
|
| 2042 | const char __user *ubuf,
|
| 2043 | size_t count, loff_t *ppos)
|
| 2044 | {
|
| 2045 | struct ath10k *ar = file->private_data;
|
| 2046 | u32 filter;
|
| 2047 | int ret;
|
| 2048 |
|
| 2049 | if (kstrtouint_from_user(ubuf, count, 0, &filter))
|
| 2050 | return -EINVAL;
|
| 2051 |
|
| 2052 | mutex_lock(&ar->conf_mutex);
|
| 2053 |
|
| 2054 | if (ar->state != ATH10K_STATE_ON) {
|
| 2055 | ar->debug.enable_extd_tx_stats = filter;
|
| 2056 | ret = count;
|
| 2057 | goto out;
|
| 2058 | }
|
| 2059 |
|
| 2060 | if (filter == ar->debug.enable_extd_tx_stats) {
|
| 2061 | ret = count;
|
| 2062 | goto out;
|
| 2063 | }
|
| 2064 |
|
| 2065 | ar->debug.enable_extd_tx_stats = filter;
|
| 2066 | ret = count;
|
| 2067 |
|
| 2068 | out:
|
| 2069 | mutex_unlock(&ar->conf_mutex);
|
| 2070 | return ret;
|
| 2071 | }
|
| 2072 |
|
| 2073 | static ssize_t ath10k_read_enable_extd_tx_stats(struct file *file,
|
| 2074 | char __user *ubuf,
|
| 2075 | size_t count, loff_t *ppos)
|
| 2076 |
|
| 2077 | {
|
| 2078 | char buf[32];
|
| 2079 | struct ath10k *ar = file->private_data;
|
| 2080 | int len = 0;
|
| 2081 |
|
| 2082 | mutex_lock(&ar->conf_mutex);
|
| 2083 | len = scnprintf(buf, sizeof(buf) - len, "%08x\n",
|
| 2084 | ar->debug.enable_extd_tx_stats);
|
| 2085 | mutex_unlock(&ar->conf_mutex);
|
| 2086 |
|
| 2087 | return simple_read_from_buffer(ubuf, count, ppos, buf, len);
|
| 2088 | }
|
| 2089 |
|
| 2090 | static const struct file_operations fops_enable_extd_tx_stats = {
|
| 2091 | .read = ath10k_read_enable_extd_tx_stats,
|
| 2092 | .write = ath10k_write_enable_extd_tx_stats,
|
| 2093 | .open = simple_open
|
| 2094 | };
|
| 2095 |
|
| 2096 | static ssize_t ath10k_write_peer_stats(struct file *file,
|
| 2097 | const char __user *ubuf,
|
| 2098 | size_t count, loff_t *ppos)
|
| 2099 | {
|
| 2100 | struct ath10k *ar = file->private_data;
|
| 2101 | ssize_t ret;
|
| 2102 | bool val;
|
| 2103 |
|
| 2104 | ret = kstrtobool_from_user(ubuf, count, &val);
|
| 2105 | if (ret)
|
| 2106 | return ret;
|
| 2107 |
|
| 2108 | mutex_lock(&ar->conf_mutex);
|
| 2109 |
|
| 2110 | if (ar->state != ATH10K_STATE_ON &&
|
| 2111 | ar->state != ATH10K_STATE_RESTARTED) {
|
| 2112 | ret = -ENETDOWN;
|
| 2113 | goto exit;
|
| 2114 | }
|
| 2115 |
|
| 2116 | if (!(test_bit(ATH10K_FLAG_PEER_STATS, &ar->dev_flags) ^ val)) {
|
| 2117 | ret = count;
|
| 2118 | goto exit;
|
| 2119 | }
|
| 2120 |
|
| 2121 | if (val)
|
| 2122 | set_bit(ATH10K_FLAG_PEER_STATS, &ar->dev_flags);
|
| 2123 | else
|
| 2124 | clear_bit(ATH10K_FLAG_PEER_STATS, &ar->dev_flags);
|
| 2125 |
|
| 2126 | ath10k_info(ar, "restarting firmware due to Peer stats change");
|
| 2127 |
|
| 2128 | ath10k_core_start_recovery(ar);
|
| 2129 | ret = count;
|
| 2130 |
|
| 2131 | exit:
|
| 2132 | mutex_unlock(&ar->conf_mutex);
|
| 2133 | return ret;
|
| 2134 | }
|
| 2135 |
|
| 2136 | static ssize_t ath10k_read_peer_stats(struct file *file, char __user *ubuf,
|
| 2137 | size_t count, loff_t *ppos)
|
| 2138 |
|
| 2139 | {
|
| 2140 | char buf[32];
|
| 2141 | struct ath10k *ar = file->private_data;
|
| 2142 | int len = 0;
|
| 2143 |
|
| 2144 | mutex_lock(&ar->conf_mutex);
|
| 2145 | len = scnprintf(buf, sizeof(buf) - len, "%d\n",
|
| 2146 | test_bit(ATH10K_FLAG_PEER_STATS, &ar->dev_flags));
|
| 2147 | mutex_unlock(&ar->conf_mutex);
|
| 2148 |
|
| 2149 | return simple_read_from_buffer(ubuf, count, ppos, buf, len);
|
| 2150 | }
|
| 2151 |
|
| 2152 | static const struct file_operations fops_peer_stats = {
|
| 2153 | .read = ath10k_read_peer_stats,
|
| 2154 | .write = ath10k_write_peer_stats,
|
| 2155 | .open = simple_open
|
| 2156 | };
|
| 2157 |
|
| 2158 | static ssize_t ath10k_debug_fw_checksums_read(struct file *file,
|
| 2159 | char __user *user_buf,
|
| 2160 | size_t count, loff_t *ppos)
|
| 2161 | {
|
| 2162 | struct ath10k *ar = file->private_data;
|
| 2163 | size_t len = 0, buf_len = 4096;
|
| 2164 | ssize_t ret_cnt;
|
| 2165 | char *buf;
|
| 2166 |
|
| 2167 | buf = kzalloc(buf_len, GFP_KERNEL);
|
| 2168 | if (!buf)
|
| 2169 | return -ENOMEM;
|
| 2170 |
|
| 2171 | mutex_lock(&ar->conf_mutex);
|
| 2172 |
|
| 2173 | len += scnprintf(buf + len, buf_len - len,
|
| 2174 | "firmware-N.bin\t\t%08x\n",
|
| 2175 | crc32_le(0, ar->normal_mode_fw.fw_file.firmware->data,
|
| 2176 | ar->normal_mode_fw.fw_file.firmware->size));
|
| 2177 | len += scnprintf(buf + len, buf_len - len,
|
| 2178 | "athwlan\t\t\t%08x\n",
|
| 2179 | crc32_le(0, ar->normal_mode_fw.fw_file.firmware_data,
|
| 2180 | ar->normal_mode_fw.fw_file.firmware_len));
|
| 2181 | len += scnprintf(buf + len, buf_len - len,
|
| 2182 | "otp\t\t\t%08x\n",
|
| 2183 | crc32_le(0, ar->normal_mode_fw.fw_file.otp_data,
|
| 2184 | ar->normal_mode_fw.fw_file.otp_len));
|
| 2185 | len += scnprintf(buf + len, buf_len - len,
|
| 2186 | "codeswap\t\t%08x\n",
|
| 2187 | crc32_le(0, ar->normal_mode_fw.fw_file.codeswap_data,
|
| 2188 | ar->normal_mode_fw.fw_file.codeswap_len));
|
| 2189 | len += scnprintf(buf + len, buf_len - len,
|
| 2190 | "board-N.bin\t\t%08x\n",
|
| 2191 | crc32_le(0, ar->normal_mode_fw.board->data,
|
| 2192 | ar->normal_mode_fw.board->size));
|
| 2193 | len += scnprintf(buf + len, buf_len - len,
|
| 2194 | "board\t\t\t%08x\n",
|
| 2195 | crc32_le(0, ar->normal_mode_fw.board_data,
|
| 2196 | ar->normal_mode_fw.board_len));
|
| 2197 |
|
| 2198 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 2199 |
|
| 2200 | mutex_unlock(&ar->conf_mutex);
|
| 2201 |
|
| 2202 | kfree(buf);
|
| 2203 | return ret_cnt;
|
| 2204 | }
|
| 2205 |
|
| 2206 | static const struct file_operations fops_fw_checksums = {
|
| 2207 | .read = ath10k_debug_fw_checksums_read,
|
| 2208 | .open = simple_open,
|
| 2209 | .owner = THIS_MODULE,
|
| 2210 | .llseek = default_llseek,
|
| 2211 | };
|
| 2212 |
|
| 2213 | static ssize_t ath10k_sta_tid_stats_mask_read(struct file *file,
|
| 2214 | char __user *user_buf,
|
| 2215 | size_t count, loff_t *ppos)
|
| 2216 | {
|
| 2217 | struct ath10k *ar = file->private_data;
|
| 2218 | char buf[32];
|
| 2219 | size_t len;
|
| 2220 |
|
| 2221 | len = scnprintf(buf, sizeof(buf), "0x%08x\n", ar->sta_tid_stats_mask);
|
| 2222 | return simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 2223 | }
|
| 2224 |
|
| 2225 | static ssize_t ath10k_sta_tid_stats_mask_write(struct file *file,
|
| 2226 | const char __user *user_buf,
|
| 2227 | size_t count, loff_t *ppos)
|
| 2228 | {
|
| 2229 | struct ath10k *ar = file->private_data;
|
| 2230 | ssize_t ret;
|
| 2231 | u32 mask;
|
| 2232 |
|
| 2233 | ret = kstrtoint_from_user(user_buf, count, 0, &mask);
|
| 2234 | if (ret)
|
| 2235 | return ret;
|
| 2236 |
|
| 2237 | ar->sta_tid_stats_mask = mask;
|
| 2238 |
|
| 2239 | return count;
|
| 2240 | }
|
| 2241 |
|
| 2242 | static const struct file_operations fops_sta_tid_stats_mask = {
|
| 2243 | .read = ath10k_sta_tid_stats_mask_read,
|
| 2244 | .write = ath10k_sta_tid_stats_mask_write,
|
| 2245 | .open = simple_open,
|
| 2246 | .owner = THIS_MODULE,
|
| 2247 | .llseek = default_llseek,
|
| 2248 | };
|
| 2249 |
|
| 2250 | static int ath10k_debug_tpc_stats_final_request(struct ath10k *ar)
|
| 2251 | {
|
| 2252 | int ret;
|
| 2253 | unsigned long time_left;
|
| 2254 |
|
| 2255 | lockdep_assert_held(&ar->conf_mutex);
|
| 2256 |
|
| 2257 | reinit_completion(&ar->debug.tpc_complete);
|
| 2258 |
|
| 2259 | ret = ath10k_wmi_pdev_get_tpc_table_cmdid(ar, WMI_TPC_CONFIG_PARAM);
|
| 2260 | if (ret) {
|
| 2261 | ath10k_warn(ar, "failed to request tpc table cmdid: %d\n", ret);
|
| 2262 | return ret;
|
| 2263 | }
|
| 2264 |
|
| 2265 | time_left = wait_for_completion_timeout(&ar->debug.tpc_complete,
|
| 2266 | 1 * HZ);
|
| 2267 | if (time_left == 0)
|
| 2268 | return -ETIMEDOUT;
|
| 2269 |
|
| 2270 | return 0;
|
| 2271 | }
|
| 2272 |
|
| 2273 | static int ath10k_tpc_stats_final_open(struct inode *inode, struct file *file)
|
| 2274 | {
|
| 2275 | struct ath10k *ar = inode->i_private;
|
| 2276 | void *buf;
|
| 2277 | int ret;
|
| 2278 |
|
| 2279 | mutex_lock(&ar->conf_mutex);
|
| 2280 |
|
| 2281 | if (ar->state != ATH10K_STATE_ON) {
|
| 2282 | ret = -ENETDOWN;
|
| 2283 | goto err_unlock;
|
| 2284 | }
|
| 2285 |
|
| 2286 | buf = vmalloc(ATH10K_TPC_CONFIG_BUF_SIZE);
|
| 2287 | if (!buf) {
|
| 2288 | ret = -ENOMEM;
|
| 2289 | goto err_unlock;
|
| 2290 | }
|
| 2291 |
|
| 2292 | ret = ath10k_debug_tpc_stats_final_request(ar);
|
| 2293 | if (ret) {
|
| 2294 | ath10k_warn(ar, "failed to request tpc stats final: %d\n",
|
| 2295 | ret);
|
| 2296 | goto err_free;
|
| 2297 | }
|
| 2298 |
|
| 2299 | ath10k_tpc_stats_fill(ar, ar->debug.tpc_stats, buf);
|
| 2300 | file->private_data = buf;
|
| 2301 |
|
| 2302 | mutex_unlock(&ar->conf_mutex);
|
| 2303 | return 0;
|
| 2304 |
|
| 2305 | err_free:
|
| 2306 | vfree(buf);
|
| 2307 |
|
| 2308 | err_unlock:
|
| 2309 | mutex_unlock(&ar->conf_mutex);
|
| 2310 | return ret;
|
| 2311 | }
|
| 2312 |
|
| 2313 | static int ath10k_tpc_stats_final_release(struct inode *inode,
|
| 2314 | struct file *file)
|
| 2315 | {
|
| 2316 | vfree(file->private_data);
|
| 2317 |
|
| 2318 | return 0;
|
| 2319 | }
|
| 2320 |
|
| 2321 | static ssize_t ath10k_tpc_stats_final_read(struct file *file,
|
| 2322 | char __user *user_buf,
|
| 2323 | size_t count, loff_t *ppos)
|
| 2324 | {
|
| 2325 | const char *buf = file->private_data;
|
| 2326 | unsigned int len = strlen(buf);
|
| 2327 |
|
| 2328 | return simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 2329 | }
|
| 2330 |
|
| 2331 | static const struct file_operations fops_tpc_stats_final = {
|
| 2332 | .open = ath10k_tpc_stats_final_open,
|
| 2333 | .release = ath10k_tpc_stats_final_release,
|
| 2334 | .read = ath10k_tpc_stats_final_read,
|
| 2335 | .owner = THIS_MODULE,
|
| 2336 | .llseek = default_llseek,
|
| 2337 | };
|
| 2338 |
|
| 2339 | static ssize_t ath10k_write_warm_hw_reset(struct file *file,
|
| 2340 | const char __user *user_buf,
|
| 2341 | size_t count, loff_t *ppos)
|
| 2342 | {
|
| 2343 | struct ath10k *ar = file->private_data;
|
| 2344 | int ret;
|
| 2345 | bool val;
|
| 2346 |
|
| 2347 | if (kstrtobool_from_user(user_buf, count, &val))
|
| 2348 | return -EFAULT;
|
| 2349 |
|
| 2350 | if (!val)
|
| 2351 | return -EINVAL;
|
| 2352 |
|
| 2353 | mutex_lock(&ar->conf_mutex);
|
| 2354 |
|
| 2355 | if (ar->state != ATH10K_STATE_ON) {
|
| 2356 | ret = -ENETDOWN;
|
| 2357 | goto exit;
|
| 2358 | }
|
| 2359 |
|
| 2360 | ret = ath10k_wmi_pdev_set_param(ar, ar->wmi.pdev_param->pdev_reset,
|
| 2361 | WMI_RST_MODE_WARM_RESET);
|
| 2362 |
|
| 2363 | if (ret) {
|
| 2364 | ath10k_warn(ar, "failed to enable warm hw reset: %d\n", ret);
|
| 2365 | goto exit;
|
| 2366 | }
|
| 2367 |
|
| 2368 | ret = count;
|
| 2369 |
|
| 2370 | exit:
|
| 2371 | mutex_unlock(&ar->conf_mutex);
|
| 2372 | return ret;
|
| 2373 | }
|
| 2374 |
|
| 2375 | static const struct file_operations fops_warm_hw_reset = {
|
| 2376 | .write = ath10k_write_warm_hw_reset,
|
| 2377 | .open = simple_open,
|
| 2378 | .owner = THIS_MODULE,
|
| 2379 | .llseek = default_llseek,
|
| 2380 | };
|
| 2381 |
|
| 2382 | static void ath10k_peer_ps_state_disable(void *data,
|
| 2383 | struct ieee80211_sta *sta)
|
| 2384 | {
|
| 2385 | struct ath10k *ar = data;
|
| 2386 | struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
|
| 2387 |
|
| 2388 | spin_lock_bh(&ar->data_lock);
|
| 2389 | arsta->peer_ps_state = WMI_PEER_PS_STATE_DISABLED;
|
| 2390 | spin_unlock_bh(&ar->data_lock);
|
| 2391 | }
|
| 2392 |
|
| 2393 | static ssize_t ath10k_write_ps_state_enable(struct file *file,
|
| 2394 | const char __user *user_buf,
|
| 2395 | size_t count, loff_t *ppos)
|
| 2396 | {
|
| 2397 | struct ath10k *ar = file->private_data;
|
| 2398 | int ret;
|
| 2399 | u32 param;
|
| 2400 | u8 ps_state_enable;
|
| 2401 |
|
| 2402 | if (kstrtou8_from_user(user_buf, count, 0, &ps_state_enable))
|
| 2403 | return -EINVAL;
|
| 2404 |
|
| 2405 | if (ps_state_enable > 1)
|
| 2406 | return -EINVAL;
|
| 2407 |
|
| 2408 | mutex_lock(&ar->conf_mutex);
|
| 2409 |
|
| 2410 | if (ar->ps_state_enable == ps_state_enable) {
|
| 2411 | ret = count;
|
| 2412 | goto exit;
|
| 2413 | }
|
| 2414 |
|
| 2415 | param = ar->wmi.pdev_param->peer_sta_ps_statechg_enable;
|
| 2416 | ret = ath10k_wmi_pdev_set_param(ar, param, ps_state_enable);
|
| 2417 | if (ret) {
|
| 2418 | ath10k_warn(ar, "failed to enable ps_state_enable: %d\n",
|
| 2419 | ret);
|
| 2420 | goto exit;
|
| 2421 | }
|
| 2422 | ar->ps_state_enable = ps_state_enable;
|
| 2423 |
|
| 2424 | if (!ar->ps_state_enable)
|
| 2425 | ieee80211_iterate_stations_atomic(ar->hw,
|
| 2426 | ath10k_peer_ps_state_disable,
|
| 2427 | ar);
|
| 2428 |
|
| 2429 | ret = count;
|
| 2430 |
|
| 2431 | exit:
|
| 2432 | mutex_unlock(&ar->conf_mutex);
|
| 2433 |
|
| 2434 | return ret;
|
| 2435 | }
|
| 2436 |
|
| 2437 | static ssize_t ath10k_read_ps_state_enable(struct file *file,
|
| 2438 | char __user *user_buf,
|
| 2439 | size_t count, loff_t *ppos)
|
| 2440 | {
|
| 2441 | struct ath10k *ar = file->private_data;
|
| 2442 | int len = 0;
|
| 2443 | char buf[32];
|
| 2444 |
|
| 2445 | mutex_lock(&ar->conf_mutex);
|
| 2446 | len = scnprintf(buf, sizeof(buf) - len, "%d\n",
|
| 2447 | ar->ps_state_enable);
|
| 2448 | mutex_unlock(&ar->conf_mutex);
|
| 2449 |
|
| 2450 | return simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
| 2451 | }
|
| 2452 |
|
| 2453 | static const struct file_operations fops_ps_state_enable = {
|
| 2454 | .read = ath10k_read_ps_state_enable,
|
| 2455 | .write = ath10k_write_ps_state_enable,
|
| 2456 | .open = simple_open,
|
| 2457 | .owner = THIS_MODULE,
|
| 2458 | .llseek = default_llseek,
|
| 2459 | };
|
| 2460 |
|
| 2461 | static ssize_t ath10k_write_reset_htt_stats(struct file *file,
|
| 2462 | const char __user *user_buf,
|
| 2463 | size_t count, loff_t *ppos)
|
| 2464 | {
|
| 2465 | struct ath10k *ar = file->private_data;
|
| 2466 | unsigned long reset;
|
| 2467 | int ret;
|
| 2468 |
|
| 2469 | ret = kstrtoul_from_user(user_buf, count, 0, &reset);
|
| 2470 | if (ret)
|
| 2471 | return ret;
|
| 2472 |
|
| 2473 | if (reset == 0 || reset > 0x1ffff)
|
| 2474 | return -EINVAL;
|
| 2475 |
|
| 2476 | mutex_lock(&ar->conf_mutex);
|
| 2477 |
|
| 2478 | ar->debug.reset_htt_stats = reset;
|
| 2479 |
|
| 2480 | ret = ath10k_debug_htt_stats_req(ar);
|
| 2481 | if (ret)
|
| 2482 | goto out;
|
| 2483 |
|
| 2484 | ar->debug.reset_htt_stats = 0;
|
| 2485 | ret = count;
|
| 2486 |
|
| 2487 | out:
|
| 2488 | mutex_unlock(&ar->conf_mutex);
|
| 2489 | return ret;
|
| 2490 | }
|
| 2491 |
|
| 2492 | static const struct file_operations fops_reset_htt_stats = {
|
| 2493 | .write = ath10k_write_reset_htt_stats,
|
| 2494 | .owner = THIS_MODULE,
|
| 2495 | .open = simple_open,
|
| 2496 | .llseek = default_llseek,
|
| 2497 | };
|
| 2498 |
|
| 2499 | int ath10k_debug_create(struct ath10k *ar)
|
| 2500 | {
|
| 2501 | ar->debug.cal_data = vzalloc(ATH10K_DEBUG_CAL_DATA_LEN);
|
| 2502 | if (!ar->debug.cal_data)
|
| 2503 | return -ENOMEM;
|
| 2504 |
|
| 2505 | INIT_LIST_HEAD(&ar->debug.fw_stats.pdevs);
|
| 2506 | INIT_LIST_HEAD(&ar->debug.fw_stats.vdevs);
|
| 2507 | INIT_LIST_HEAD(&ar->debug.fw_stats.peers);
|
| 2508 | INIT_LIST_HEAD(&ar->debug.fw_stats.peers_extd);
|
| 2509 |
|
| 2510 | return 0;
|
| 2511 | }
|
| 2512 |
|
| 2513 | void ath10k_debug_destroy(struct ath10k *ar)
|
| 2514 | {
|
| 2515 | vfree(ar->debug.cal_data);
|
| 2516 | ar->debug.cal_data = NULL;
|
| 2517 |
|
| 2518 | ath10k_debug_fw_stats_reset(ar);
|
| 2519 |
|
| 2520 | kfree(ar->debug.tpc_stats);
|
| 2521 | kfree(ar->debug.tpc_stats_final);
|
| 2522 | }
|
| 2523 |
|
| 2524 | int ath10k_debug_register(struct ath10k *ar)
|
| 2525 | {
|
| 2526 | ar->debug.debugfs_phy = debugfs_create_dir("ath10k",
|
| 2527 | ar->hw->wiphy->debugfsdir);
|
| 2528 | if (IS_ERR_OR_NULL(ar->debug.debugfs_phy)) {
|
| 2529 | if (IS_ERR(ar->debug.debugfs_phy))
|
| 2530 | return PTR_ERR(ar->debug.debugfs_phy);
|
| 2531 |
|
| 2532 | return -ENOMEM;
|
| 2533 | }
|
| 2534 |
|
| 2535 | INIT_DELAYED_WORK(&ar->debug.htt_stats_dwork,
|
| 2536 | ath10k_debug_htt_stats_dwork);
|
| 2537 |
|
| 2538 | init_completion(&ar->debug.tpc_complete);
|
| 2539 | init_completion(&ar->debug.fw_stats_complete);
|
| 2540 |
|
| 2541 | debugfs_create_file("fw_stats", 0400, ar->debug.debugfs_phy, ar,
|
| 2542 | &fops_fw_stats);
|
| 2543 |
|
| 2544 | debugfs_create_file("fw_reset_stats", 0400, ar->debug.debugfs_phy, ar,
|
| 2545 | &fops_fw_reset_stats);
|
| 2546 |
|
| 2547 | debugfs_create_file("wmi_services", 0400, ar->debug.debugfs_phy, ar,
|
| 2548 | &fops_wmi_services);
|
| 2549 |
|
| 2550 | debugfs_create_file("simulate_fw_crash", 0600, ar->debug.debugfs_phy, ar,
|
| 2551 | &fops_simulate_fw_crash);
|
| 2552 |
|
| 2553 | debugfs_create_file("reg_addr", 0600, ar->debug.debugfs_phy, ar,
|
| 2554 | &fops_reg_addr);
|
| 2555 |
|
| 2556 | debugfs_create_file("reg_value", 0600, ar->debug.debugfs_phy, ar,
|
| 2557 | &fops_reg_value);
|
| 2558 |
|
| 2559 | debugfs_create_file("mem_value", 0600, ar->debug.debugfs_phy, ar,
|
| 2560 | &fops_mem_value);
|
| 2561 |
|
| 2562 | debugfs_create_file("chip_id", 0400, ar->debug.debugfs_phy, ar,
|
| 2563 | &fops_chip_id);
|
| 2564 |
|
| 2565 | debugfs_create_file("htt_stats_mask", 0600, ar->debug.debugfs_phy, ar,
|
| 2566 | &fops_htt_stats_mask);
|
| 2567 |
|
| 2568 | debugfs_create_file("htt_max_amsdu_ampdu", 0600, ar->debug.debugfs_phy, ar,
|
| 2569 | &fops_htt_max_amsdu_ampdu);
|
| 2570 |
|
| 2571 | debugfs_create_file("fw_dbglog", 0600, ar->debug.debugfs_phy, ar,
|
| 2572 | &fops_fw_dbglog);
|
| 2573 |
|
| 2574 | if (!test_bit(ATH10K_FW_FEATURE_NON_BMI,
|
| 2575 | ar->normal_mode_fw.fw_file.fw_features)) {
|
| 2576 | debugfs_create_file("cal_data", 0400, ar->debug.debugfs_phy, ar,
|
| 2577 | &fops_cal_data);
|
| 2578 |
|
| 2579 | debugfs_create_file("nf_cal_period", 0600, ar->debug.debugfs_phy, ar,
|
| 2580 | &fops_nf_cal_period);
|
| 2581 | }
|
| 2582 |
|
| 2583 | debugfs_create_file("ani_enable", 0600, ar->debug.debugfs_phy, ar,
|
| 2584 | &fops_ani_enable);
|
| 2585 |
|
| 2586 | if (IS_ENABLED(CONFIG_ATH10K_DFS_CERTIFIED)) {
|
| 2587 | debugfs_create_file("dfs_simulate_radar", 0200, ar->debug.debugfs_phy,
|
| 2588 | ar, &fops_simulate_radar);
|
| 2589 |
|
| 2590 | debugfs_create_bool("dfs_block_radar_events", 0200,
|
| 2591 | ar->debug.debugfs_phy,
|
| 2592 | &ar->dfs_block_radar_events);
|
| 2593 |
|
| 2594 | debugfs_create_file("dfs_stats", 0400, ar->debug.debugfs_phy, ar,
|
| 2595 | &fops_dfs_stats);
|
| 2596 | }
|
| 2597 |
|
| 2598 | debugfs_create_file("pktlog_filter", 0644, ar->debug.debugfs_phy, ar,
|
| 2599 | &fops_pktlog_filter);
|
| 2600 |
|
| 2601 | if (test_bit(WMI_SERVICE_THERM_THROT, ar->wmi.svc_map))
|
| 2602 | debugfs_create_file("quiet_period", 0644, ar->debug.debugfs_phy, ar,
|
| 2603 | &fops_quiet_period);
|
| 2604 |
|
| 2605 | debugfs_create_file("tpc_stats", 0400, ar->debug.debugfs_phy, ar,
|
| 2606 | &fops_tpc_stats);
|
| 2607 |
|
| 2608 | if (test_bit(WMI_SERVICE_COEX_GPIO, ar->wmi.svc_map))
|
| 2609 | debugfs_create_file("btcoex", 0644, ar->debug.debugfs_phy, ar,
|
| 2610 | &fops_btcoex);
|
| 2611 |
|
| 2612 | if (test_bit(WMI_SERVICE_PEER_STATS, ar->wmi.svc_map)) {
|
| 2613 | debugfs_create_file("peer_stats", 0644, ar->debug.debugfs_phy, ar,
|
| 2614 | &fops_peer_stats);
|
| 2615 |
|
| 2616 | debugfs_create_file("enable_extd_tx_stats", 0644,
|
| 2617 | ar->debug.debugfs_phy, ar,
|
| 2618 | &fops_enable_extd_tx_stats);
|
| 2619 | }
|
| 2620 |
|
| 2621 | debugfs_create_file("fw_checksums", 0400, ar->debug.debugfs_phy, ar,
|
| 2622 | &fops_fw_checksums);
|
| 2623 |
|
| 2624 | if (IS_ENABLED(CONFIG_MAC80211_DEBUGFS))
|
| 2625 | debugfs_create_file("sta_tid_stats_mask", 0600,
|
| 2626 | ar->debug.debugfs_phy,
|
| 2627 | ar, &fops_sta_tid_stats_mask);
|
| 2628 |
|
| 2629 | if (test_bit(WMI_SERVICE_TPC_STATS_FINAL, ar->wmi.svc_map))
|
| 2630 | debugfs_create_file("tpc_stats_final", 0400,
|
| 2631 | ar->debug.debugfs_phy, ar,
|
| 2632 | &fops_tpc_stats_final);
|
| 2633 |
|
| 2634 | if (test_bit(WMI_SERVICE_RESET_CHIP, ar->wmi.svc_map))
|
| 2635 | debugfs_create_file("warm_hw_reset", 0600,
|
| 2636 | ar->debug.debugfs_phy, ar,
|
| 2637 | &fops_warm_hw_reset);
|
| 2638 |
|
| 2639 | debugfs_create_file("ps_state_enable", 0600, ar->debug.debugfs_phy, ar,
|
| 2640 | &fops_ps_state_enable);
|
| 2641 |
|
| 2642 | debugfs_create_file("reset_htt_stats", 0200, ar->debug.debugfs_phy, ar,
|
| 2643 | &fops_reset_htt_stats);
|
| 2644 |
|
| 2645 | return 0;
|
| 2646 | }
|
| 2647 |
|
| 2648 | void ath10k_debug_unregister(struct ath10k *ar)
|
| 2649 | {
|
| 2650 | cancel_delayed_work_sync(&ar->debug.htt_stats_dwork);
|
| 2651 | }
|
| 2652 |
|
| 2653 | #endif
|
| 2654 |
|
| 2655 | #ifdef CONFIG_ATH10K_DEBUG
|
| 2656 | void __ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
|
| 2657 | const char *fmt, ...)
|
| 2658 | {
|
| 2659 | struct va_format vaf;
|
| 2660 | va_list args;
|
| 2661 |
|
| 2662 | va_start(args, fmt);
|
| 2663 |
|
| 2664 | vaf.fmt = fmt;
|
| 2665 | vaf.va = &args;
|
| 2666 |
|
| 2667 | if (ath10k_debug_mask & mask)
|
| 2668 | dev_printk(KERN_DEBUG, ar->dev, "%pV", &vaf);
|
| 2669 |
|
| 2670 | trace_ath10k_log_dbg(ar, mask, &vaf);
|
| 2671 |
|
| 2672 | va_end(args);
|
| 2673 | }
|
| 2674 | EXPORT_SYMBOL(__ath10k_dbg);
|
| 2675 |
|
| 2676 | void ath10k_dbg_dump(struct ath10k *ar,
|
| 2677 | enum ath10k_debug_mask mask,
|
| 2678 | const char *msg, const char *prefix,
|
| 2679 | const void *buf, size_t len)
|
| 2680 | {
|
| 2681 | char linebuf[256];
|
| 2682 | size_t linebuflen;
|
| 2683 | const void *ptr;
|
| 2684 |
|
| 2685 | if (ath10k_debug_mask & mask) {
|
| 2686 | if (msg)
|
| 2687 | __ath10k_dbg(ar, mask, "%s\n", msg);
|
| 2688 |
|
| 2689 | for (ptr = buf; (ptr - buf) < len; ptr += 16) {
|
| 2690 | linebuflen = 0;
|
| 2691 | linebuflen += scnprintf(linebuf + linebuflen,
|
| 2692 | sizeof(linebuf) - linebuflen,
|
| 2693 | "%s%08x: ",
|
| 2694 | (prefix ? prefix : ""),
|
| 2695 | (unsigned int)(ptr - buf));
|
| 2696 | hex_dump_to_buffer(ptr, len - (ptr - buf), 16, 1,
|
| 2697 | linebuf + linebuflen,
|
| 2698 | sizeof(linebuf) - linebuflen, true);
|
| 2699 | dev_printk(KERN_DEBUG, ar->dev, "%s\n", linebuf);
|
| 2700 | }
|
| 2701 | }
|
| 2702 |
|
| 2703 |
|
| 2704 | trace_ath10k_log_dbg_dump(ar, msg ? msg : "", prefix ? prefix : "",
|
| 2705 | buf, len);
|
| 2706 | }
|
| 2707 | EXPORT_SYMBOL(ath10k_dbg_dump);
|
| 2708 |
|
| 2709 | #endif
|