Skip to content

Commit

Permalink
wlcore: handle smart_config_start/stop testmode commands
Browse files Browse the repository at this point in the history
userspace can ask to enter/exit smart_config mode via
smart_config_start and smart_config_stop testmode commands.

Signed-off-by: Eliad Peller <eliad@wizery.com>
  • Loading branch information
elp committed May 13, 2013
1 parent 14fc84b commit 3682f01
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/net/wireless/ti/wl18xx/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,8 @@ static struct wlcore_ops wl18xx_ops = {
.convert_hwaddr = wl18xx_convert_hwaddr,
.lnk_high_prio = wl18xx_lnk_high_prio,
.lnk_low_prio = wl18xx_lnk_low_prio,
.smart_config_start = wl18xx_cmd_smart_config_start,
.smart_config_stop = wl18xx_cmd_smart_config_stop,
};

/* HT cap appropriate for wide channels in 2Ghz */
Expand Down
17 changes: 17 additions & 0 deletions drivers/net/wireless/ti/wlcore/hw_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,21 @@ wlcore_hw_lnk_low_prio(struct wl1271 *wl, u8 hlid,
return wl->ops->lnk_low_prio(wl, hlid, lnk);
}

static inline int
wlcore_smart_config_start(struct wl1271 *wl, u32 group_bitmap)
{
if (!wl->ops->smart_config_start)
return -EINVAL;

return wl->ops->smart_config_start(wl, group_bitmap);
}

static inline int
wlcore_smart_config_stop(struct wl1271 *wl)
{
if (!wl->ops->smart_config_stop)
return -EINVAL;

return wl->ops->smart_config_stop(wl);
}
#endif
63 changes: 63 additions & 0 deletions drivers/net/wireless/ti/wlcore/testmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "acx.h"
#include "ps.h"
#include "io.h"
#include "hw_ops.h"

#define WL1271_TM_MAX_DATA_LENGTH 1024

Expand Down Expand Up @@ -332,6 +333,64 @@ static int wl12xx_tm_cmd_get_mac(struct wl1271 *wl, struct nlattr *tb[])
return ret;
}

static int wlcore_tm_cmd_smart_config_start(struct wl1271 *wl,
struct nlattr *tb[])
{
int ret;

wl1271_debug(DEBUG_CMD, "testmode cmd smart config start");

if (!tb[WL1271_TM_ATTR_GROUP_ID])
return -EINVAL;

mutex_lock(&wl->mutex);

if (unlikely(wl->state != WLCORE_STATE_ON)) {
ret = -EINVAL;
goto out;
}

ret = wl1271_ps_elp_wakeup(wl);
if (ret < 0)
goto out;

ret = wlcore_smart_config_start(wl,
nla_get_u32(tb[WL1271_TM_ATTR_GROUP_ID]));

wl1271_ps_elp_sleep(wl);
out:
mutex_unlock(&wl->mutex);

return ret;
}

static int wlcore_tm_cmd_smart_config_stop(struct wl1271 *wl,
struct nlattr *tb[])
{
int ret;

wl1271_debug(DEBUG_CMD, "testmode cmd smart config stop");

mutex_lock(&wl->mutex);

if (unlikely(wl->state != WLCORE_STATE_ON)) {
ret = -EINVAL;
goto out;
}

ret = wl1271_ps_elp_wakeup(wl);
if (ret < 0)
goto out;

ret = wlcore_smart_config_stop(wl);

wl1271_ps_elp_sleep(wl);
out:
mutex_unlock(&wl->mutex);

return ret;
}

int wl1271_tm_cmd(struct ieee80211_hw *hw, void *data, int len)
{
struct wl1271 *wl = hw->priv;
Expand Down Expand Up @@ -364,6 +423,10 @@ int wl1271_tm_cmd(struct ieee80211_hw *hw, void *data, int len)
return wl1271_tm_cmd_set_plt_mode(wl, tb);
case WL1271_TM_CMD_GET_MAC:
return wl12xx_tm_cmd_get_mac(wl, tb);
case WL1271_TM_CMD_SMART_CONFIG_START:
return wlcore_tm_cmd_smart_config_start(wl, tb);
case WL1271_TM_CMD_SMART_CONFIG_STOP:
return wlcore_tm_cmd_smart_config_stop(wl, tb);
default:
return -EOPNOTSUPP;
}
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/wireless/ti/wlcore/wlcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ struct wlcore_ops {
struct wl1271_link *lnk);
bool (*lnk_low_prio)(struct wl1271 *wl, u8 hlid,
struct wl1271_link *lnk);
int (*smart_config_start)(struct wl1271 *wl, u32 group_bitmap);
int (*smart_config_stop)(struct wl1271 *wl);
};

enum wlcore_partitions {
Expand Down

0 comments on commit 3682f01

Please sign in to comment.