ath10k: add debugfs entry to configure quiet period
authorRajkumar Manoharan <rmanohar@qti.qualcomm.com>
Sun, 15 Mar 2015 15:06:20 +0000 (20:36 +0530)
committerKalle Valo <kvalo@qca.qualcomm.com>
Mon, 23 Mar 2015 15:15:59 +0000 (17:15 +0200)
Add support to configure quiet period (in milliseconds) via debugfs.
This is useful to experiment different quiet period values along with
different throttle ratio.

echo 100 > /sys/kernel/debug/ieee80211/phyX/ath10k/quiet_period

Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath10k/debug.c
drivers/net/wireless/ath/ath10k/thermal.c
drivers/net/wireless/ath/ath10k/thermal.h

index 301081db1ef60a9f7a68a9452d7155965520cc39..812365c12638d1e6a2fb8b917d9667b1218178c9 100644 (file)
@@ -1991,6 +1991,49 @@ static const struct file_operations fops_pktlog_filter = {
        .open = simple_open
 };
 
+static ssize_t ath10k_write_quiet_period(struct file *file,
+                                        const char __user *ubuf,
+                                        size_t count, loff_t *ppos)
+{
+       struct ath10k *ar = file->private_data;
+       u32 period;
+
+       if (kstrtouint_from_user(ubuf, count, 0, &period))
+               return -EINVAL;
+
+       if (period < ATH10K_QUIET_PERIOD_MIN) {
+               ath10k_warn(ar, "Quiet period %u can not be lesser than 25ms\n",
+                           period);
+               return -EINVAL;
+       }
+       mutex_lock(&ar->conf_mutex);
+       ar->thermal.quiet_period = period;
+       mutex_unlock(&ar->conf_mutex);
+
+       return count;
+}
+
+static ssize_t ath10k_read_quiet_period(struct file *file, char __user *ubuf,
+                                       size_t count, loff_t *ppos)
+{
+       char buf[32];
+       struct ath10k *ar = file->private_data;
+       int len = 0;
+
+       mutex_lock(&ar->conf_mutex);
+       len = scnprintf(buf, sizeof(buf) - len, "%d\n",
+                       ar->thermal.quiet_period);
+       mutex_unlock(&ar->conf_mutex);
+
+       return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+}
+
+static const struct file_operations fops_quiet_period = {
+       .read = ath10k_read_quiet_period,
+       .write = ath10k_write_quiet_period,
+       .open = simple_open
+};
+
 int ath10k_debug_create(struct ath10k *ar)
 {
        ar->debug.fw_crash_data = vzalloc(sizeof(*ar->debug.fw_crash_data));
@@ -2088,6 +2131,9 @@ int ath10k_debug_register(struct ath10k *ar)
        debugfs_create_file("pktlog_filter", S_IRUGO | S_IWUSR,
                            ar->debug.debugfs_phy, ar, &fops_pktlog_filter);
 
+       debugfs_create_file("quiet_period", S_IRUGO | S_IWUSR,
+                           ar->debug.debugfs_phy, ar, &fops_quiet_period);
+
        return 0;
 }
 
index 747fea7e975ec8b20ad078782b8e72f2a36a627d..d3fd2ab4d86acd5cd640d2bc9e9663b75d4e6363 100644 (file)
@@ -96,8 +96,7 @@ static int ath10k_thermal_set_cur_dutycycle(struct thermal_cooling_device *cdev,
                ret = -ENETDOWN;
                goto out;
        }
-       period = max(ATH10K_QUIET_PERIOD_MIN,
-                    (ATH10K_QUIET_PERIOD_DEFAULT / num_bss));
+       period = ar->thermal.quiet_period;
        duration = (period * duty_cycle) / 100;
        enabled = duration ? 1 : 0;
 
@@ -207,6 +206,7 @@ int ath10k_thermal_register(struct ath10k *ar)
        }
 
        ar->thermal.cdev = cdev;
+       ar->thermal.quiet_period = ATH10K_QUIET_PERIOD_DEFAULT;
 
        /* Do not register hwmon device when temperature reading is not
         * supported by firmware
index 5e87d9a8fe2500065f84c7d814630c11894eeafa..050f41dd0398381cdbc3404ab86583d17fe074cf 100644 (file)
@@ -29,6 +29,7 @@ struct ath10k_thermal {
 
        /* protected by conf_mutex */
        u32 duty_cycle;
+       u32 quiet_period;
        /* temperature value in Celcius degree
         * protected by data_lock
         */