wlcore/wl18xx: add radar_debug_mode handling
authorEliad Peller <eliad@wizery.com>
Sun, 6 Mar 2016 22:28:09 +0000 (00:28 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 10 Mar 2016 13:00:23 +0000 (15:00 +0200)
Add debugfs key (under CFG80211_CERTIFICATION_ONUS
configuration) to set/clear radar_debug_mode.
In this mode, the driver simply ignores radar
events (but prints them).

The fw is notified about this mode through
a special generic_cfg_feature command.

This mode is relevant only for ap mode. look for
it when initializing ap vif.

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ti/wl18xx/debugfs.c
drivers/net/wireless/ti/wl18xx/event.c
drivers/net/wireless/ti/wlcore/init.c
drivers/net/wireless/ti/wlcore/wlcore.h

index 4edfe28395f03be65d2deabbd15d03ccc13a1af0..86ccf84ea0c6bb0fb8e01a31fa481520df0447db 100644 (file)
@@ -345,6 +345,69 @@ static const struct file_operations dynamic_fw_traces_ops = {
        .llseek = default_llseek,
 };
 
+#ifdef CONFIG_CFG80211_CERTIFICATION_ONUS
+static ssize_t radar_debug_mode_write(struct file *file,
+                                     const char __user *user_buf,
+                                     size_t count, loff_t *ppos)
+{
+       struct wl1271 *wl = file->private_data;
+       struct wl12xx_vif *wlvif;
+       unsigned long value;
+       int ret;
+
+       ret = kstrtoul_from_user(user_buf, count, 10, &value);
+       if (ret < 0) {
+               wl1271_warning("illegal radar_debug_mode value!");
+               return -EINVAL;
+       }
+
+       /* valid values: 0/1 */
+       if (!(value == 0 || value == 1)) {
+               wl1271_warning("value is not in valid!");
+               return -EINVAL;
+       }
+
+       mutex_lock(&wl->mutex);
+
+       wl->radar_debug_mode = value;
+
+       if (unlikely(wl->state != WLCORE_STATE_ON))
+               goto out;
+
+       ret = wl1271_ps_elp_wakeup(wl);
+       if (ret < 0)
+               goto out;
+
+       wl12xx_for_each_wlvif_ap(wl, wlvif) {
+               wlcore_cmd_generic_cfg(wl, wlvif,
+                                      WLCORE_CFG_FEATURE_RADAR_DEBUG,
+                                      wl->radar_debug_mode, 0);
+       }
+
+       wl1271_ps_elp_sleep(wl);
+out:
+       mutex_unlock(&wl->mutex);
+       return count;
+}
+
+static ssize_t radar_debug_mode_read(struct file *file,
+                                    char __user *userbuf,
+                                    size_t count, loff_t *ppos)
+{
+       struct wl1271 *wl = file->private_data;
+
+       return wl1271_format_buffer(userbuf, count, ppos,
+                                   "%d\n", wl->radar_debug_mode);
+}
+
+static const struct file_operations radar_debug_mode_ops = {
+       .write = radar_debug_mode_write,
+       .read = radar_debug_mode_read,
+       .open = simple_open,
+       .llseek = default_llseek,
+};
+#endif /* CFG80211_CERTIFICATION_ONUS */
+
 int wl18xx_debugfs_add_files(struct wl1271 *wl,
                             struct dentry *rootdir)
 {
@@ -510,6 +573,9 @@ int wl18xx_debugfs_add_files(struct wl1271 *wl,
 
        DEBUGFS_ADD(conf, moddir);
        DEBUGFS_ADD(radar_detection, moddir);
+#ifdef CONFIG_CFG80211_CERTIFICATION_ONUS
+       DEBUGFS_ADD(radar_debug_mode, moddir);
+#endif
        DEBUGFS_ADD(dynamic_fw_traces, moddir);
 
        return 0;
index 719907a0a2c225f51d1daf007b54160f15bf667b..ff6e46dd61f8df450a6b2d15aa67dab0385be2e7 100644 (file)
@@ -146,7 +146,8 @@ int wl18xx_process_mailbox_events(struct wl1271 *wl)
                            mbox->radar_channel,
                            wl18xx_radar_type_decode(mbox->radar_type));
 
-               ieee80211_radar_detected(wl->hw);
+               if (!wl->radar_debug_mode)
+                       ieee80211_radar_detected(wl->hw);
        }
 
        if (vector & PERIODIC_SCAN_REPORT_EVENT_ID) {
index e92f2639af2c8835d5c2faddd2c5630e99f89067..d0b7734030ef70ddc8c2bc9b124021fca187834b 100644 (file)
@@ -558,6 +558,11 @@ static int wl12xx_init_ap_role(struct wl1271 *wl, struct wl12xx_vif *wlvif)
        if (ret < 0)
                return ret;
 
+       if (wl->radar_debug_mode)
+               wlcore_cmd_generic_cfg(wl, wlvif,
+                                      WLCORE_CFG_FEATURE_RADAR_DEBUG,
+                                      wl->radar_debug_mode, 0);
+
        return 0;
 }
 
index dda01b118c26f98997dbf09e1354ff7e0be25e9f..72c31a8edcfb30490963d6700ae0f7104c4358e2 100644 (file)
@@ -463,6 +463,7 @@ struct wl1271 {
 
        /* the current dfs region */
        enum nl80211_dfs_regions dfs_region;
+       bool radar_debug_mode;
 
        /* size of the private FW status data */
        size_t fw_status_len;