aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath10k/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath10k/debug.c')
-rw-r--r--drivers/net/wireless/ath/ath10k/debug.c122
1 files changed, 107 insertions, 15 deletions
diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index a716758f14b0..d2281e5c2ffe 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -23,6 +23,7 @@
23#include "core.h" 23#include "core.h"
24#include "debug.h" 24#include "debug.h"
25#include "hif.h" 25#include "hif.h"
26#include "wmi-ops.h"
26 27
27/* ms */ 28/* ms */
28#define ATH10K_DEBUG_HTT_STATS_INTERVAL 1000 29#define ATH10K_DEBUG_HTT_STATS_INTERVAL 1000
@@ -123,7 +124,7 @@ EXPORT_SYMBOL(ath10k_info);
123 124
124void ath10k_print_driver_info(struct ath10k *ar) 125void ath10k_print_driver_info(struct ath10k *ar)
125{ 126{
126 ath10k_info(ar, "%s (0x%08x, 0x%08x) fw %s api %d htt %d.%d wmi %d.%d.%d.%d cal %s max_sta %d\n", 127 ath10k_info(ar, "%s (0x%08x, 0x%08x) fw %s api %d htt %d.%d wmi %d cal %s max_sta %d\n",
127 ar->hw_params.name, 128 ar->hw_params.name,
128 ar->target_version, 129 ar->target_version,
129 ar->chip_id, 130 ar->chip_id,
@@ -131,10 +132,7 @@ void ath10k_print_driver_info(struct ath10k *ar)
131 ar->fw_api, 132 ar->fw_api,
132 ar->htt.target_version_major, 133 ar->htt.target_version_major,
133 ar->htt.target_version_minor, 134 ar->htt.target_version_minor,
134 ar->fw_version_major, 135 ar->wmi.op_version,
135 ar->fw_version_minor,
136 ar->fw_version_release,
137 ar->fw_version_build,
138 ath10k_cal_mode_str(ar->cal_mode), 136 ath10k_cal_mode_str(ar->cal_mode),
139 ar->max_num_stations); 137 ar->max_num_stations);
140 ath10k_info(ar, "debug %d debugfs %d tracing %d dfs %d testmode %d\n", 138 ath10k_info(ar, "debug %d debugfs %d tracing %d dfs %d testmode %d\n",
@@ -373,7 +371,7 @@ static int ath10k_debug_fw_stats_request(struct ath10k *ar)
373 371
374 ret = wait_for_completion_timeout(&ar->debug.fw_stats_complete, 372 ret = wait_for_completion_timeout(&ar->debug.fw_stats_complete,
375 1*HZ); 373 1*HZ);
376 if (ret <= 0) 374 if (ret == 0)
377 return -ETIMEDOUT; 375 return -ETIMEDOUT;
378 376
379 spin_lock_bh(&ar->data_lock); 377 spin_lock_bh(&ar->data_lock);
@@ -1320,10 +1318,10 @@ static ssize_t ath10k_read_fw_dbglog(struct file *file,
1320{ 1318{
1321 struct ath10k *ar = file->private_data; 1319 struct ath10k *ar = file->private_data;
1322 unsigned int len; 1320 unsigned int len;
1323 char buf[32]; 1321 char buf[64];
1324 1322
1325 len = scnprintf(buf, sizeof(buf), "0x%08x\n", 1323 len = scnprintf(buf, sizeof(buf), "0x%08x %u\n",
1326 ar->debug.fw_dbglog_mask); 1324 ar->debug.fw_dbglog_mask, ar->debug.fw_dbglog_level);
1327 1325
1328 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 1326 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1329} 1327}
@@ -1333,19 +1331,32 @@ static ssize_t ath10k_write_fw_dbglog(struct file *file,
1333 size_t count, loff_t *ppos) 1331 size_t count, loff_t *ppos)
1334{ 1332{
1335 struct ath10k *ar = file->private_data; 1333 struct ath10k *ar = file->private_data;
1336 unsigned long mask;
1337 int ret; 1334 int ret;
1335 char buf[64];
1336 unsigned int log_level, mask;
1338 1337
1339 ret = kstrtoul_from_user(user_buf, count, 0, &mask); 1338 simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
1340 if (ret) 1339
1341 return ret; 1340 /* make sure that buf is null terminated */
1341 buf[sizeof(buf) - 1] = 0;
1342
1343 ret = sscanf(buf, "%x %u", &mask, &log_level);
1344
1345 if (!ret)
1346 return -EINVAL;
1347
1348 if (ret == 1)
1349 /* default if user did not specify */
1350 log_level = ATH10K_DBGLOG_LEVEL_WARN;
1342 1351
1343 mutex_lock(&ar->conf_mutex); 1352 mutex_lock(&ar->conf_mutex);
1344 1353
1345 ar->debug.fw_dbglog_mask = mask; 1354 ar->debug.fw_dbglog_mask = mask;
1355 ar->debug.fw_dbglog_level = log_level;
1346 1356
1347 if (ar->state == ATH10K_STATE_ON) { 1357 if (ar->state == ATH10K_STATE_ON) {
1348 ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask); 1358 ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask,
1359 ar->debug.fw_dbglog_level);
1349 if (ret) { 1360 if (ret) {
1350 ath10k_warn(ar, "dbglog cfg failed from debugfs: %d\n", 1361 ath10k_warn(ar, "dbglog cfg failed from debugfs: %d\n",
1351 ret); 1362 ret);
@@ -1607,6 +1618,73 @@ static const struct file_operations fops_cal_data = {
1607 .llseek = default_llseek, 1618 .llseek = default_llseek,
1608}; 1619};
1609 1620
1621static ssize_t ath10k_read_nf_cal_period(struct file *file,
1622 char __user *user_buf,
1623 size_t count, loff_t *ppos)
1624{
1625 struct ath10k *ar = file->private_data;
1626 unsigned int len;
1627 char buf[32];
1628
1629 len = scnprintf(buf, sizeof(buf), "%d\n",
1630 ar->debug.nf_cal_period);
1631
1632 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1633}
1634
1635static ssize_t ath10k_write_nf_cal_period(struct file *file,
1636 const char __user *user_buf,
1637 size_t count, loff_t *ppos)
1638{
1639 struct ath10k *ar = file->private_data;
1640 unsigned long period;
1641 int ret;
1642
1643 ret = kstrtoul_from_user(user_buf, count, 0, &period);
1644 if (ret)
1645 return ret;
1646
1647 if (period > WMI_PDEV_PARAM_CAL_PERIOD_MAX)
1648 return -EINVAL;
1649
1650 /* there's no way to switch back to the firmware default */
1651 if (period == 0)
1652 return -EINVAL;
1653
1654 mutex_lock(&ar->conf_mutex);
1655
1656 ar->debug.nf_cal_period = period;
1657
1658 if (ar->state != ATH10K_STATE_ON) {
1659 /* firmware is not running, nothing else to do */
1660 ret = count;
1661 goto exit;
1662 }
1663
1664 ret = ath10k_wmi_pdev_set_param(ar, ar->wmi.pdev_param->cal_period,
1665 ar->debug.nf_cal_period);
1666 if (ret) {
1667 ath10k_warn(ar, "cal period cfg failed from debugfs: %d\n",
1668 ret);
1669 goto exit;
1670 }
1671
1672 ret = count;
1673
1674exit:
1675 mutex_unlock(&ar->conf_mutex);
1676
1677 return ret;
1678}
1679
1680static const struct file_operations fops_nf_cal_period = {
1681 .read = ath10k_read_nf_cal_period,
1682 .write = ath10k_write_nf_cal_period,
1683 .open = simple_open,
1684 .owner = THIS_MODULE,
1685 .llseek = default_llseek,
1686};
1687
1610int ath10k_debug_start(struct ath10k *ar) 1688int ath10k_debug_start(struct ath10k *ar)
1611{ 1689{
1612 int ret; 1690 int ret;
@@ -1620,7 +1698,8 @@ int ath10k_debug_start(struct ath10k *ar)
1620 ret); 1698 ret);
1621 1699
1622 if (ar->debug.fw_dbglog_mask) { 1700 if (ar->debug.fw_dbglog_mask) {
1623 ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask); 1701 ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask,
1702 ATH10K_DBGLOG_LEVEL_WARN);
1624 if (ret) 1703 if (ret)
1625 /* not serious */ 1704 /* not serious */
1626 ath10k_warn(ar, "failed to enable dbglog during start: %d", 1705 ath10k_warn(ar, "failed to enable dbglog during start: %d",
@@ -1642,6 +1721,16 @@ int ath10k_debug_start(struct ath10k *ar)
1642 ath10k_warn(ar, "failed to disable pktlog: %d\n", ret); 1721 ath10k_warn(ar, "failed to disable pktlog: %d\n", ret);
1643 } 1722 }
1644 1723
1724 if (ar->debug.nf_cal_period) {
1725 ret = ath10k_wmi_pdev_set_param(ar,
1726 ar->wmi.pdev_param->cal_period,
1727 ar->debug.nf_cal_period);
1728 if (ret)
1729 /* not serious */
1730 ath10k_warn(ar, "cal period cfg failed from debug start: %d\n",
1731 ret);
1732 }
1733
1645 return ret; 1734 return ret;
1646} 1735}
1647 1736
@@ -1880,6 +1969,9 @@ int ath10k_debug_register(struct ath10k *ar)
1880 debugfs_create_file("cal_data", S_IRUSR, ar->debug.debugfs_phy, 1969 debugfs_create_file("cal_data", S_IRUSR, ar->debug.debugfs_phy,
1881 ar, &fops_cal_data); 1970 ar, &fops_cal_data);
1882 1971
1972 debugfs_create_file("nf_cal_period", S_IRUSR | S_IWUSR,
1973 ar->debug.debugfs_phy, ar, &fops_nf_cal_period);
1974
1883 if (config_enabled(CONFIG_ATH10K_DFS_CERTIFIED)) { 1975 if (config_enabled(CONFIG_ATH10K_DFS_CERTIFIED)) {
1884 debugfs_create_file("dfs_simulate_radar", S_IWUSR, 1976 debugfs_create_file("dfs_simulate_radar", S_IWUSR,
1885 ar->debug.debugfs_phy, ar, 1977 ar->debug.debugfs_phy, ar,