Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wl18xx: add debugfs file to emulate radar event

Add debugfs file to emulate radar detection through
a special fw cmd (which in turn will generate radar
event)

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

authored by

Eliad Peller and committed by
Kalle Valo
e7d32324 750e9d15

+79
+26
drivers/net/wireless/ti/wl18xx/cmd.c
··· 198 198 kfree(cmd); 199 199 return ret; 200 200 } 201 + 202 + int wl18xx_cmd_radar_detection_debug(struct wl1271 *wl, u8 channel) 203 + { 204 + struct wl18xx_cmd_dfs_radar_debug *cmd; 205 + int ret = 0; 206 + 207 + wl1271_debug(DEBUG_CMD, "cmd radar detection debug (chan %d)", 208 + channel); 209 + 210 + cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 211 + if (!cmd) 212 + return -ENOMEM; 213 + 214 + cmd->channel = channel; 215 + 216 + ret = wl1271_cmd_send(wl, CMD_DFS_RADAR_DETECTION_DEBUG, 217 + cmd, sizeof(*cmd), 0); 218 + if (ret < 0) { 219 + wl1271_error("failed to send radar detection debug command"); 220 + goto out_free; 221 + } 222 + 223 + out_free: 224 + kfree(cmd); 225 + return ret; 226 + }
+8
drivers/net/wireless/ti/wl18xx/cmd.h
··· 59 59 u8 key[16]; 60 60 } __packed; 61 61 62 + struct wl18xx_cmd_dfs_radar_debug { 63 + struct wl1271_cmd_header header; 64 + 65 + u8 channel; 66 + u8 padding[3]; 67 + } __packed; 68 + 62 69 /* cac_start and cac_stop share the same params */ 63 70 struct wlcore_cmd_cac_start { 64 71 struct wl1271_cmd_header header; ··· 84 77 int wl18xx_cmd_smart_config_set_group_key(struct wl1271 *wl, u16 group_id, 85 78 u8 key_len, u8 *key); 86 79 int wl18xx_cmd_set_cac(struct wl1271 *wl, struct wl12xx_vif *wlvif, bool start); 80 + int wl18xx_cmd_radar_detection_debug(struct wl1271 *wl, u8 channel); 87 81 #endif
+43
drivers/net/wireless/ti/wl18xx/debugfs.c
··· 22 22 23 23 #include "../wlcore/debugfs.h" 24 24 #include "../wlcore/wlcore.h" 25 + #include "../wlcore/debug.h" 26 + #include "../wlcore/ps.h" 25 27 26 28 #include "wl18xx.h" 27 29 #include "acx.h" 30 + #include "cmd.h" 28 31 #include "debugfs.h" 29 32 30 33 #define WL18XX_DEBUGFS_FWSTATS_FILE(a, b, c) \ ··· 242 239 .llseek = default_llseek, 243 240 }; 244 241 242 + static ssize_t radar_detection_write(struct file *file, 243 + const char __user *user_buf, 244 + size_t count, loff_t *ppos) 245 + { 246 + struct wl1271 *wl = file->private_data; 247 + int ret; 248 + u8 channel; 249 + 250 + ret = kstrtou8_from_user(user_buf, count, 10, &channel); 251 + if (ret < 0) { 252 + wl1271_warning("illegal channel"); 253 + return -EINVAL; 254 + } 255 + 256 + mutex_lock(&wl->mutex); 257 + 258 + if (unlikely(wl->state != WLCORE_STATE_ON)) 259 + goto out; 260 + 261 + ret = wl1271_ps_elp_wakeup(wl); 262 + if (ret < 0) 263 + goto out; 264 + 265 + ret = wl18xx_cmd_radar_detection_debug(wl, channel); 266 + if (ret < 0) 267 + count = ret; 268 + 269 + wl1271_ps_elp_sleep(wl); 270 + out: 271 + mutex_unlock(&wl->mutex); 272 + return count; 273 + } 274 + 275 + static const struct file_operations radar_detection_ops = { 276 + .write = radar_detection_write, 277 + .open = simple_open, 278 + .llseek = default_llseek, 279 + }; 280 + 245 281 int wl18xx_debugfs_add_files(struct wl1271 *wl, 246 282 struct dentry *rootdir) 247 283 { ··· 432 390 DEBUGFS_FWSTATS_ADD(mem, fw_gen_free_mem_blks); 433 391 434 392 DEBUGFS_ADD(conf, moddir); 393 + DEBUGFS_ADD(radar_detection, moddir); 435 394 436 395 return 0; 437 396
+2
drivers/net/wireless/ti/wlcore/ps.c
··· 102 102 ieee80211_queue_delayed_work(wl->hw, &wl->elp_work, 103 103 msecs_to_jiffies(timeout)); 104 104 } 105 + EXPORT_SYMBOL_GPL(wl1271_ps_elp_sleep); 105 106 106 107 int wl1271_ps_elp_wakeup(struct wl1271 *wl) 107 108 { ··· 170 169 out: 171 170 return 0; 172 171 } 172 + EXPORT_SYMBOL_GPL(wl1271_ps_elp_wakeup); 173 173 174 174 int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, 175 175 enum wl1271_cmd_ps_mode mode)