hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/net/wireless/ath/ath10k/debug.c
....@@ -1,19 +1,8 @@
1
+// SPDX-License-Identifier: ISC
12 /*
23 * Copyright (c) 2005-2011 Atheros Communications Inc.
34 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
45 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
5
- *
6
- * Permission to use, copy, modify, and/or distribute this software for any
7
- * purpose with or without fee is hereby granted, provided that the above
8
- * copyright notice and this permission notice appear in all copies.
9
- *
10
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
176 */
187
198 #include <linux/module.h>
....@@ -58,7 +47,7 @@
5847 ath10k_info(ar, "%s target 0x%08x chip_id 0x%08x sub %04x:%04x",
5948 ar->hw_params.name,
6049 ar->target_version,
61
- ar->chip_id,
50
+ ar->bus_param.chip_id,
6251 ar->id.subsystem_vendor, ar->id.subsystem_device);
6352
6453 ath10k_info(ar, "kconfig debug %d debugfs %d tracing %d dfs %d testmode %d\n",
....@@ -316,6 +305,9 @@
316305 if (is_end)
317306 ar->debug.fw_stats_done = true;
318307
308
+ if (stats.extended)
309
+ ar->debug.fw_stats.extended = true;
310
+
319311 is_started = !list_empty(&ar->debug.fw_stats.pdevs);
320312
321313 if (is_started && !is_end) {
....@@ -357,7 +349,7 @@
357349 spin_unlock_bh(&ar->data_lock);
358350 }
359351
360
-static int ath10k_debug_fw_stats_request(struct ath10k *ar)
352
+int ath10k_debug_fw_stats_request(struct ath10k *ar)
361353 {
362354 unsigned long timeout, time_left;
363355 int ret;
....@@ -625,7 +617,7 @@
625617 size_t len;
626618 char buf[50];
627619
628
- len = scnprintf(buf, sizeof(buf), "0x%08x\n", ar->chip_id);
620
+ len = scnprintf(buf, sizeof(buf), "0x%08x\n", ar->bus_param.chip_id);
629621
630622 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
631623 }
....@@ -786,7 +778,7 @@
786778
787779 ret = ath10k_hif_diag_read(ar, *ppos, buf, count);
788780 if (ret) {
789
- ath10k_warn(ar, "failed to read address 0x%08x via diagnose window fnrom debugfs: %d\n",
781
+ ath10k_warn(ar, "failed to read address 0x%08x via diagnose window from debugfs: %d\n",
790782 (u32)(*ppos), ret);
791783 goto exit;
792784 }
....@@ -884,7 +876,7 @@
884876 cookie = get_jiffies_64();
885877
886878 ret = ath10k_htt_h2t_stats_req(&ar->htt, ar->debug.htt_stats_mask,
887
- cookie);
879
+ ar->debug.reset_htt_stats, cookie);
888880 if (ret) {
889881 ath10k_warn(ar, "failed to send htt stats request: %d\n", ret);
890882 return ret;
....@@ -933,8 +925,8 @@
933925 if (ret)
934926 return ret;
935927
936
- /* max 8 bit masks (for now) */
937
- if (mask > 0xff)
928
+ /* max 17 bit masks (for now) */
929
+ if (mask > HTT_STATS_BIT_MASK)
938930 return -E2BIG;
939931
940932 mutex_lock(&ar->conf_mutex);
....@@ -1102,6 +1094,7 @@
11021094 "d_rts_good",
11031095 "d_tx_power", /* in .5 dbM I think */
11041096 "d_rx_crc_err", /* fcs_bad */
1097
+ "d_rx_crc_err_drop", /* frame with FCS error, dropped late in kernel */
11051098 "d_no_beacon",
11061099 "d_tx_mpdus_queued",
11071100 "d_tx_msdu_queued",
....@@ -1201,6 +1194,7 @@
12011194 data[i++] = pdev_stats->rts_good;
12021195 data[i++] = pdev_stats->chan_tx_power;
12031196 data[i++] = pdev_stats->fcs_bad;
1197
+ data[i++] = ar->stats.rx_crc_err_drop;
12041198 data[i++] = pdev_stats->no_beacons;
12051199 data[i++] = pdev_stats->mpdu_enqued;
12061200 data[i++] = pdev_stats->msdu_enqued;
....@@ -1262,6 +1256,9 @@
12621256
12631257 if (WARN_ON(ar->hw_params.cal_data_len > ATH10K_DEBUG_CAL_DATA_LEN))
12641258 return -EINVAL;
1259
+
1260
+ if (ar->hw_params.cal_data_len == 0)
1261
+ return -EOPNOTSUPP;
12651262
12661263 hi_addr = host_interest_item_address(HI_ITEM(hi_board_data));
12671264
....@@ -1981,6 +1978,9 @@
19811978 if (strtobool(buf, &val) != 0)
19821979 return -EINVAL;
19831980
1981
+ if (!ar->coex_support)
1982
+ return -EOPNOTSUPP;
1983
+
19841984 mutex_lock(&ar->conf_mutex);
19851985
19861986 if (ar->state != ATH10K_STATE_ON &&
....@@ -2039,6 +2039,61 @@
20392039 static const struct file_operations fops_btcoex = {
20402040 .read = ath10k_read_btcoex,
20412041 .write = ath10k_write_btcoex,
2042
+ .open = simple_open
2043
+};
2044
+
2045
+static ssize_t ath10k_write_enable_extd_tx_stats(struct file *file,
2046
+ const char __user *ubuf,
2047
+ size_t count, loff_t *ppos)
2048
+{
2049
+ struct ath10k *ar = file->private_data;
2050
+ u32 filter;
2051
+ int ret;
2052
+
2053
+ if (kstrtouint_from_user(ubuf, count, 0, &filter))
2054
+ return -EINVAL;
2055
+
2056
+ mutex_lock(&ar->conf_mutex);
2057
+
2058
+ if (ar->state != ATH10K_STATE_ON) {
2059
+ ar->debug.enable_extd_tx_stats = filter;
2060
+ ret = count;
2061
+ goto out;
2062
+ }
2063
+
2064
+ if (filter == ar->debug.enable_extd_tx_stats) {
2065
+ ret = count;
2066
+ goto out;
2067
+ }
2068
+
2069
+ ar->debug.enable_extd_tx_stats = filter;
2070
+ ret = count;
2071
+
2072
+out:
2073
+ mutex_unlock(&ar->conf_mutex);
2074
+ return ret;
2075
+}
2076
+
2077
+static ssize_t ath10k_read_enable_extd_tx_stats(struct file *file,
2078
+ char __user *ubuf,
2079
+ size_t count, loff_t *ppos)
2080
+
2081
+{
2082
+ char buf[32];
2083
+ struct ath10k *ar = file->private_data;
2084
+ int len = 0;
2085
+
2086
+ mutex_lock(&ar->conf_mutex);
2087
+ len = scnprintf(buf, sizeof(buf) - len, "%08x\n",
2088
+ ar->debug.enable_extd_tx_stats);
2089
+ mutex_unlock(&ar->conf_mutex);
2090
+
2091
+ return simple_read_from_buffer(ubuf, count, ppos, buf, len);
2092
+}
2093
+
2094
+static const struct file_operations fops_enable_extd_tx_stats = {
2095
+ .read = ath10k_read_enable_extd_tx_stats,
2096
+ .write = ath10k_write_enable_extd_tx_stats,
20422097 .open = simple_open
20432098 };
20442099
....@@ -2318,9 +2373,6 @@
23182373 goto exit;
23192374 }
23202375
2321
- if (!(test_bit(WMI_SERVICE_RESET_CHIP, ar->wmi.svc_map)))
2322
- ath10k_warn(ar, "wmi service for reset chip is not available\n");
2323
-
23242376 ret = ath10k_wmi_pdev_set_param(ar, ar->wmi.pdev_param->pdev_reset,
23252377 WMI_RST_MODE_WARM_RESET);
23262378
....@@ -2340,6 +2392,123 @@
23402392 .write = ath10k_write_warm_hw_reset,
23412393 .open = simple_open,
23422394 .owner = THIS_MODULE,
2395
+ .llseek = default_llseek,
2396
+};
2397
+
2398
+static void ath10k_peer_ps_state_disable(void *data,
2399
+ struct ieee80211_sta *sta)
2400
+{
2401
+ struct ath10k *ar = data;
2402
+ struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
2403
+
2404
+ spin_lock_bh(&ar->data_lock);
2405
+ arsta->peer_ps_state = WMI_PEER_PS_STATE_DISABLED;
2406
+ spin_unlock_bh(&ar->data_lock);
2407
+}
2408
+
2409
+static ssize_t ath10k_write_ps_state_enable(struct file *file,
2410
+ const char __user *user_buf,
2411
+ size_t count, loff_t *ppos)
2412
+{
2413
+ struct ath10k *ar = file->private_data;
2414
+ int ret;
2415
+ u32 param;
2416
+ u8 ps_state_enable;
2417
+
2418
+ if (kstrtou8_from_user(user_buf, count, 0, &ps_state_enable))
2419
+ return -EINVAL;
2420
+
2421
+ if (ps_state_enable > 1)
2422
+ return -EINVAL;
2423
+
2424
+ mutex_lock(&ar->conf_mutex);
2425
+
2426
+ if (ar->ps_state_enable == ps_state_enable) {
2427
+ ret = count;
2428
+ goto exit;
2429
+ }
2430
+
2431
+ param = ar->wmi.pdev_param->peer_sta_ps_statechg_enable;
2432
+ ret = ath10k_wmi_pdev_set_param(ar, param, ps_state_enable);
2433
+ if (ret) {
2434
+ ath10k_warn(ar, "failed to enable ps_state_enable: %d\n",
2435
+ ret);
2436
+ goto exit;
2437
+ }
2438
+ ar->ps_state_enable = ps_state_enable;
2439
+
2440
+ if (!ar->ps_state_enable)
2441
+ ieee80211_iterate_stations_atomic(ar->hw,
2442
+ ath10k_peer_ps_state_disable,
2443
+ ar);
2444
+
2445
+ ret = count;
2446
+
2447
+exit:
2448
+ mutex_unlock(&ar->conf_mutex);
2449
+
2450
+ return ret;
2451
+}
2452
+
2453
+static ssize_t ath10k_read_ps_state_enable(struct file *file,
2454
+ char __user *user_buf,
2455
+ size_t count, loff_t *ppos)
2456
+{
2457
+ struct ath10k *ar = file->private_data;
2458
+ int len = 0;
2459
+ char buf[32];
2460
+
2461
+ mutex_lock(&ar->conf_mutex);
2462
+ len = scnprintf(buf, sizeof(buf) - len, "%d\n",
2463
+ ar->ps_state_enable);
2464
+ mutex_unlock(&ar->conf_mutex);
2465
+
2466
+ return simple_read_from_buffer(user_buf, count, ppos, buf, len);
2467
+}
2468
+
2469
+static const struct file_operations fops_ps_state_enable = {
2470
+ .read = ath10k_read_ps_state_enable,
2471
+ .write = ath10k_write_ps_state_enable,
2472
+ .open = simple_open,
2473
+ .owner = THIS_MODULE,
2474
+ .llseek = default_llseek,
2475
+};
2476
+
2477
+static ssize_t ath10k_write_reset_htt_stats(struct file *file,
2478
+ const char __user *user_buf,
2479
+ size_t count, loff_t *ppos)
2480
+{
2481
+ struct ath10k *ar = file->private_data;
2482
+ unsigned long reset;
2483
+ int ret;
2484
+
2485
+ ret = kstrtoul_from_user(user_buf, count, 0, &reset);
2486
+ if (ret)
2487
+ return ret;
2488
+
2489
+ if (reset == 0 || reset > 0x1ffff)
2490
+ return -EINVAL;
2491
+
2492
+ mutex_lock(&ar->conf_mutex);
2493
+
2494
+ ar->debug.reset_htt_stats = reset;
2495
+
2496
+ ret = ath10k_debug_htt_stats_req(ar);
2497
+ if (ret)
2498
+ goto out;
2499
+
2500
+ ar->debug.reset_htt_stats = 0;
2501
+ ret = count;
2502
+
2503
+out:
2504
+ mutex_unlock(&ar->conf_mutex);
2505
+ return ret;
2506
+}
2507
+
2508
+static const struct file_operations fops_reset_htt_stats = {
2509
+ .write = ath10k_write_reset_htt_stats,
2510
+ .owner = THIS_MODULE,
2511
+ .open = simple_open,
23432512 .llseek = default_llseek,
23442513 };
23452514
....@@ -2445,8 +2614,9 @@
24452614 debugfs_create_file("pktlog_filter", 0644, ar->debug.debugfs_phy, ar,
24462615 &fops_pktlog_filter);
24472616
2448
- debugfs_create_file("quiet_period", 0644, ar->debug.debugfs_phy, ar,
2449
- &fops_quiet_period);
2617
+ if (test_bit(WMI_SERVICE_THERM_THROT, ar->wmi.svc_map))
2618
+ debugfs_create_file("quiet_period", 0644, ar->debug.debugfs_phy, ar,
2619
+ &fops_quiet_period);
24502620
24512621 debugfs_create_file("tpc_stats", 0400, ar->debug.debugfs_phy, ar,
24522622 &fops_tpc_stats);
....@@ -2455,9 +2625,14 @@
24552625 debugfs_create_file("btcoex", 0644, ar->debug.debugfs_phy, ar,
24562626 &fops_btcoex);
24572627
2458
- if (test_bit(WMI_SERVICE_PEER_STATS, ar->wmi.svc_map))
2628
+ if (test_bit(WMI_SERVICE_PEER_STATS, ar->wmi.svc_map)) {
24592629 debugfs_create_file("peer_stats", 0644, ar->debug.debugfs_phy, ar,
24602630 &fops_peer_stats);
2631
+
2632
+ debugfs_create_file("enable_extd_tx_stats", 0644,
2633
+ ar->debug.debugfs_phy, ar,
2634
+ &fops_enable_extd_tx_stats);
2635
+ }
24612636
24622637 debugfs_create_file("fw_checksums", 0400, ar->debug.debugfs_phy, ar,
24632638 &fops_fw_checksums);
....@@ -2472,8 +2647,16 @@
24722647 ar->debug.debugfs_phy, ar,
24732648 &fops_tpc_stats_final);
24742649
2475
- debugfs_create_file("warm_hw_reset", 0600, ar->debug.debugfs_phy, ar,
2476
- &fops_warm_hw_reset);
2650
+ if (test_bit(WMI_SERVICE_RESET_CHIP, ar->wmi.svc_map))
2651
+ debugfs_create_file("warm_hw_reset", 0600,
2652
+ ar->debug.debugfs_phy, ar,
2653
+ &fops_warm_hw_reset);
2654
+
2655
+ debugfs_create_file("ps_state_enable", 0600, ar->debug.debugfs_phy, ar,
2656
+ &fops_ps_state_enable);
2657
+
2658
+ debugfs_create_file("reset_htt_stats", 0200, ar->debug.debugfs_phy, ar,
2659
+ &fops_reset_htt_stats);
24772660
24782661 return 0;
24792662 }
....@@ -2486,8 +2669,8 @@
24862669 #endif /* CONFIG_ATH10K_DEBUGFS */
24872670
24882671 #ifdef CONFIG_ATH10K_DEBUG
2489
-void ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
2490
- const char *fmt, ...)
2672
+void __ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask,
2673
+ const char *fmt, ...)
24912674 {
24922675 struct va_format vaf;
24932676 va_list args;
....@@ -2504,7 +2687,7 @@
25042687
25052688 va_end(args);
25062689 }
2507
-EXPORT_SYMBOL(ath10k_dbg);
2690
+EXPORT_SYMBOL(__ath10k_dbg);
25082691
25092692 void ath10k_dbg_dump(struct ath10k *ar,
25102693 enum ath10k_debug_mask mask,
....@@ -2517,7 +2700,7 @@
25172700
25182701 if (ath10k_debug_mask & mask) {
25192702 if (msg)
2520
- ath10k_dbg(ar, mask, "%s\n", msg);
2703
+ __ath10k_dbg(ar, mask, "%s\n", msg);
25212704
25222705 for (ptr = buf; (ptr - buf) < len; ptr += 16) {
25232706 linebuflen = 0;