2 * This file is part of wl18xx
4 * Copyright (C) 2011 Texas Instruments Inc.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 #include "../wlcore/cmd.h"
23 #include "../wlcore/debug.h"
24 #include "../wlcore/hw_ops.h"
28 int wl18xx_cmd_channel_switch(struct wl1271 *wl,
29 struct wl12xx_vif *wlvif,
30 struct ieee80211_channel_switch *ch_switch)
32 struct wl18xx_cmd_channel_switch *cmd;
36 wl1271_debug(DEBUG_ACX, "cmd channel switch (count=%d)",
39 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
45 cmd->role_id = wlvif->role_id;
46 cmd->channel = ch_switch->chandef.chan->hw_value;
47 cmd->switch_time = ch_switch->count;
48 cmd->stop_tx = ch_switch->block_tx;
50 switch (ch_switch->chandef.chan->band) {
51 case IEEE80211_BAND_2GHZ:
52 cmd->band = WLCORE_BAND_2_4GHZ;
54 case IEEE80211_BAND_5GHZ:
55 cmd->band = WLCORE_BAND_5GHZ;
58 wl1271_error("invalid channel switch band: %d",
59 ch_switch->chandef.chan->band);
64 supported_rates = CONF_TX_ENABLED_RATES | CONF_TX_MCS_RATES;
65 if (wlvif->bss_type == BSS_TYPE_STA_BSS)
66 supported_rates |= wlcore_hw_sta_get_ap_rate_mask(wl, wlvif);
69 wlcore_hw_ap_get_mimo_wide_rate_mask(wl, wlvif);
71 supported_rates &= ~CONF_TX_CCK_RATES;
72 cmd->local_supported_rates = cpu_to_le32(supported_rates);
73 cmd->channel_type = wlvif->channel_type;
75 ret = wl1271_cmd_send(wl, CMD_CHANNEL_SWITCH, cmd, sizeof(*cmd), 0);
77 wl1271_error("failed to send channel switch command");
87 int wl18xx_cmd_smart_config_start(struct wl1271 *wl, u32 group_bitmap)
89 struct wl18xx_cmd_smart_config_start *cmd;
92 wl1271_debug(DEBUG_CMD, "cmd smart config start group_bitmap=0x%x",
95 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
101 cmd->group_id_bitmask = cpu_to_le32(group_bitmap);
103 ret = wl1271_cmd_send(wl, CMD_SMART_CONFIG_START, cmd, sizeof(*cmd), 0);
105 wl1271_error("failed to send smart config start command");
115 int wl18xx_cmd_smart_config_stop(struct wl1271 *wl)
117 struct wl1271_cmd_header *cmd;
120 wl1271_debug(DEBUG_CMD, "cmd smart config stop");
122 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
128 ret = wl1271_cmd_send(wl, CMD_SMART_CONFIG_STOP, cmd, sizeof(*cmd), 0);
130 wl1271_error("failed to send smart config stop command");
140 int wl18xx_cmd_smart_config_set_group_key(struct wl1271 *wl, u16 group_id,
143 struct wl18xx_cmd_smart_config_set_group_key *cmd;
146 wl1271_debug(DEBUG_CMD, "cmd smart config set group key id=0x%x",
149 if (key_len != sizeof(cmd->key)) {
150 wl1271_error("invalid group key size: %d", key_len);
154 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
160 cmd->group_id = cpu_to_le32(group_id);
161 memcpy(cmd->key, key, key_len);
163 ret = wl1271_cmd_send(wl, CMD_SMART_CONFIG_SET_GROUP_KEY, cmd,
166 wl1271_error("failed to send smart config set group key cmd");
176 int wl18xx_cmd_set_cac(struct wl1271 *wl, struct wl12xx_vif *wlvif, bool start)
178 struct wlcore_cmd_cac_start *cmd;
181 wl1271_debug(DEBUG_CMD, "cmd cac (channel %d) %s",
182 wlvif->channel, start ? "start" : "stop");
184 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
188 cmd->role_id = wlvif->role_id;
189 cmd->channel = wlvif->channel;
190 if (wlvif->band == IEEE80211_BAND_5GHZ)
191 cmd->band = WLCORE_BAND_5GHZ;
192 cmd->bandwidth = wlcore_get_native_channel_type(wlvif->channel_type);
194 ret = wl1271_cmd_send(wl,
195 start ? CMD_CAC_START : CMD_CAC_STOP,
196 cmd, sizeof(*cmd), 0);
198 wl1271_error("failed to send cac command");
207 int wl18xx_cmd_radar_detection_debug(struct wl1271 *wl, u8 channel)
209 struct wl18xx_cmd_dfs_radar_debug *cmd;
212 wl1271_debug(DEBUG_CMD, "cmd radar detection debug (chan %d)",
215 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
219 cmd->channel = channel;
221 ret = wl1271_cmd_send(wl, CMD_DFS_RADAR_DETECTION_DEBUG,
222 cmd, sizeof(*cmd), 0);
224 wl1271_error("failed to send radar detection debug command");
233 int wl18xx_cmd_dfs_master_restart(struct wl1271 *wl, struct wl12xx_vif *wlvif)
235 struct wl18xx_cmd_dfs_master_restart *cmd;
238 wl1271_debug(DEBUG_CMD, "cmd dfs master restart (role %d)",
241 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
245 cmd->role_id = wlvif->role_id;
247 ret = wl1271_cmd_send(wl, CMD_DFS_MASTER_RESTART,
248 cmd, sizeof(*cmd), 0);
250 wl1271_error("failed to send dfs master restart command");