1 // SPDX-License-Identifier: GPL-2.0-only
3 * This file is part of wl18xx
5 * Copyright (C) 2011 Texas Instruments Inc.
8 #include "../wlcore/cmd.h"
9 #include "../wlcore/debug.h"
10 #include "../wlcore/hw_ops.h"
14 int wl18xx_cmd_channel_switch(struct wl1271 *wl,
15 struct wl12xx_vif *wlvif,
16 struct ieee80211_channel_switch *ch_switch)
18 struct wl18xx_cmd_channel_switch *cmd;
22 wl1271_debug(DEBUG_ACX, "cmd channel switch (count=%d)",
25 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
31 cmd->role_id = wlvif->role_id;
32 cmd->channel = ch_switch->chandef.chan->hw_value;
33 cmd->switch_time = ch_switch->count;
34 cmd->stop_tx = ch_switch->block_tx;
36 switch (ch_switch->chandef.chan->band) {
37 case NL80211_BAND_2GHZ:
38 cmd->band = WLCORE_BAND_2_4GHZ;
40 case NL80211_BAND_5GHZ:
41 cmd->band = WLCORE_BAND_5GHZ;
44 wl1271_error("invalid channel switch band: %d",
45 ch_switch->chandef.chan->band);
50 supported_rates = CONF_TX_ENABLED_RATES | CONF_TX_MCS_RATES;
51 if (wlvif->bss_type == BSS_TYPE_STA_BSS)
52 supported_rates |= wlcore_hw_sta_get_ap_rate_mask(wl, wlvif);
55 wlcore_hw_ap_get_mimo_wide_rate_mask(wl, wlvif);
57 supported_rates &= ~CONF_TX_CCK_RATES;
58 cmd->local_supported_rates = cpu_to_le32(supported_rates);
59 cmd->channel_type = wlvif->channel_type;
61 ret = wl1271_cmd_send(wl, CMD_CHANNEL_SWITCH, cmd, sizeof(*cmd), 0);
63 wl1271_error("failed to send channel switch command");
73 int wl18xx_cmd_smart_config_start(struct wl1271 *wl, u32 group_bitmap)
75 struct wl18xx_cmd_smart_config_start *cmd;
78 wl1271_debug(DEBUG_CMD, "cmd smart config start group_bitmap=0x%x",
81 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
87 cmd->group_id_bitmask = cpu_to_le32(group_bitmap);
89 ret = wl1271_cmd_send(wl, CMD_SMART_CONFIG_START, cmd, sizeof(*cmd), 0);
91 wl1271_error("failed to send smart config start command");
101 int wl18xx_cmd_smart_config_stop(struct wl1271 *wl)
103 struct wl1271_cmd_header *cmd;
106 wl1271_debug(DEBUG_CMD, "cmd smart config stop");
108 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
114 ret = wl1271_cmd_send(wl, CMD_SMART_CONFIG_STOP, cmd, sizeof(*cmd), 0);
116 wl1271_error("failed to send smart config stop command");
126 int wl18xx_cmd_smart_config_set_group_key(struct wl1271 *wl, u16 group_id,
129 struct wl18xx_cmd_smart_config_set_group_key *cmd;
132 wl1271_debug(DEBUG_CMD, "cmd smart config set group key id=0x%x",
135 if (key_len != sizeof(cmd->key)) {
136 wl1271_error("invalid group key size: %d", key_len);
140 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
146 cmd->group_id = cpu_to_le32(group_id);
147 memcpy(cmd->key, key, key_len);
149 ret = wl1271_cmd_send(wl, CMD_SMART_CONFIG_SET_GROUP_KEY, cmd,
152 wl1271_error("failed to send smart config set group key cmd");
162 int wl18xx_cmd_set_cac(struct wl1271 *wl, struct wl12xx_vif *wlvif, bool start)
164 struct wlcore_cmd_cac_start *cmd;
167 wl1271_debug(DEBUG_CMD, "cmd cac (channel %d) %s",
168 wlvif->channel, start ? "start" : "stop");
170 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
174 cmd->role_id = wlvif->role_id;
175 cmd->channel = wlvif->channel;
176 if (wlvif->band == NL80211_BAND_5GHZ)
177 cmd->band = WLCORE_BAND_5GHZ;
178 cmd->bandwidth = wlcore_get_native_channel_type(wlvif->channel_type);
180 ret = wl1271_cmd_send(wl,
181 start ? CMD_CAC_START : CMD_CAC_STOP,
182 cmd, sizeof(*cmd), 0);
184 wl1271_error("failed to send cac command");
193 int wl18xx_cmd_radar_detection_debug(struct wl1271 *wl, u8 channel)
195 struct wl18xx_cmd_dfs_radar_debug *cmd;
198 wl1271_debug(DEBUG_CMD, "cmd radar detection debug (chan %d)",
201 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
205 cmd->channel = channel;
207 ret = wl1271_cmd_send(wl, CMD_DFS_RADAR_DETECTION_DEBUG,
208 cmd, sizeof(*cmd), 0);
210 wl1271_error("failed to send radar detection debug command");
219 int wl18xx_cmd_dfs_master_restart(struct wl1271 *wl, struct wl12xx_vif *wlvif)
221 struct wl18xx_cmd_dfs_master_restart *cmd;
224 wl1271_debug(DEBUG_CMD, "cmd dfs master restart (role %d)",
227 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
231 cmd->role_id = wlvif->role_id;
233 ret = wl1271_cmd_send(wl, CMD_DFS_MASTER_RESTART,
234 cmd, sizeof(*cmd), 0);
236 wl1271_error("failed to send dfs master restart command");