ath6kl: Fix listen interval handling
authorSujith Manoharan <c_manoha@qca.qualcomm.com>
Tue, 10 Jan 2012 04:24:10 +0000 (09:54 +0530)
committerKalle Valo <kvalo@qca.qualcomm.com>
Thu, 12 Jan 2012 11:36:37 +0000 (13:36 +0200)
This patch addresses a few problems with the commit:

"ath6kl: Implement support for listen interval from userspace"

* The debugfs file required for reading/writing the listen interval
  wasn't created. Fix this.

* The interface index was being hardcoded to zero. Fix this.

* Two separate parameters, "listen_interval_time and listen_interval_beacons"
  were being used. This fails to work as expected because the FW assigns
  higher precedence to "listen_interval_beacons" and "listen_interval_time"
  ends up being never used at all.

  To handle this, fix the host driver to exclusively use listen interval
  based on units of beacon intervals.

To set the listen interval, a user would now do something like this:

echo "10" > /sys/kernel/debug/ieee80211/*/ath6kl/listen_interval

kvalo: fix two checkpatch warnings

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath6kl/cfg80211.c
drivers/net/wireless/ath/ath6kl/core.h
drivers/net/wireless/ath/ath6kl/debug.c
drivers/net/wireless/ath/ath6kl/main.c

index 9b26bba..1a98c92 100644 (file)
@@ -2725,8 +2725,7 @@ struct ath6kl *ath6kl_core_alloc(struct device *dev)
        clear_bit(SKIP_SCAN, &ar->flag);
        clear_bit(DESTROY_IN_PROGRESS, &ar->flag);
 
-       ar->listen_intvl_t = A_DEFAULT_LISTEN_INTERVAL;
-       ar->listen_intvl_b = 0;
+       ar->listen_intvl_b = A_DEFAULT_LISTEN_INTERVAL;
        ar->tx_pwr = 0;
 
        ar->intra_bss = 1;
index 793c6a5..f4da5e1 100644 (file)
@@ -55,7 +55,7 @@
 #define MAX_DEFAULT_SEND_QUEUE_DEPTH      (MAX_DEF_COOKIE_NUM / WMM_NUM_AC)
 
 #define DISCON_TIMER_INTVAL               10000  /* in msec */
-#define A_DEFAULT_LISTEN_INTERVAL         100
+#define A_DEFAULT_LISTEN_INTERVAL         1      /* beacon intervals */
 #define A_MAX_WOW_LISTEN_INTERVAL         1000
 
 /* includes also the null byte */
@@ -534,7 +534,6 @@ struct ath6kl {
        spinlock_t lock;
        struct semaphore sem;
        u16 listen_intvl_b;
-       u16 listen_intvl_t;
        u8 lrssi_roam_threshold;
        struct ath6kl_version version;
        u32 target_type;
index eb808b4..fa7243b 100644 (file)
@@ -1505,57 +1505,46 @@ static const struct file_operations fops_bgscan_int = {
 };
 
 static ssize_t ath6kl_listen_int_write(struct file *file,
-                                               const char __user *user_buf,
-                                               size_t count, loff_t *ppos)
+                                      const char __user *user_buf,
+                                      size_t count, loff_t *ppos)
 {
        struct ath6kl *ar = file->private_data;
-       u16 listen_int_t, listen_int_b;
+       struct ath6kl_vif *vif;
+       u16 listen_interval;
        char buf[32];
-       char *sptr, *token;
        ssize_t len;
 
+       vif = ath6kl_vif_first(ar);
+       if (!vif)
+               return -EIO;
+
        len = min(count, sizeof(buf) - 1);
        if (copy_from_user(buf, user_buf, len))
                return -EFAULT;
 
        buf[len] = '\0';
-       sptr = buf;
-
-       token = strsep(&sptr, " ");
-       if (!token)
-               return -EINVAL;
-
-       if (kstrtou16(token, 0, &listen_int_t))
-               return -EINVAL;
-
-       if (kstrtou16(sptr, 0, &listen_int_b))
-               return -EINVAL;
-
-       if ((listen_int_t < 15) || (listen_int_t > 5000))
+       if (kstrtou16(buf, 0, &listen_interval))
                return -EINVAL;
 
-       if ((listen_int_b < 1) || (listen_int_b > 50))
+       if ((listen_interval < 1) || (listen_interval > 50))
                return -EINVAL;
 
-       ar->listen_intvl_t = listen_int_t;
-       ar->listen_intvl_b = listen_int_b;
-
-       ath6kl_wmi_listeninterval_cmd(ar->wmi, 0, ar->listen_intvl_t,
+       ar->listen_intvl_b = listen_interval;
+       ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx, 0,
                                      ar->listen_intvl_b);
 
        return count;
 }
 
 static ssize_t ath6kl_listen_int_read(struct file *file,
-                                               char __user *user_buf,
-                                               size_t count, loff_t *ppos)
+                                     char __user *user_buf,
+                                     size_t count, loff_t *ppos)
 {
        struct ath6kl *ar = file->private_data;
        char buf[32];
        int len;
 
-       len = scnprintf(buf, sizeof(buf), "%u %u\n", ar->listen_intvl_t,
-                                       ar->listen_intvl_b);
+       len = scnprintf(buf, sizeof(buf), "%u\n", ar->listen_intvl_b);
 
        return simple_read_from_buffer(user_buf, count, ppos, buf, len);
 }
@@ -1710,6 +1699,9 @@ int ath6kl_debug_init(struct ath6kl *ar)
        debugfs_create_file("bgscan_interval", S_IWUSR,
                                ar->debugfs_phy, ar, &fops_bgscan_int);
 
+       debugfs_create_file("listen_interval", S_IRUSR | S_IWUSR,
+                           ar->debugfs_phy, ar, &fops_listen_int);
+
        debugfs_create_file("power_params", S_IWUSR, ar->debugfs_phy, ar,
                                                &fops_power_params);
 
index 8742eaa..4c26572 100644 (file)
@@ -584,10 +584,11 @@ void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid,
        memcpy(vif->bssid, bssid, sizeof(vif->bssid));
        vif->bss_ch = channel;
 
-       if ((vif->nw_type == INFRA_NETWORK))
+       if ((vif->nw_type == INFRA_NETWORK)) {
+               ar->listen_intvl_b = listen_int;
                ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx,
-                                             ar->listen_intvl_t,
-                                             ar->listen_intvl_b);
+                                             0, ar->listen_intvl_b);
+       }
 
        netif_wake_queue(vif->ndev);