Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Wireless LAN device driver: station command handling |
| 3 | * |
Xinming Hu | 65da33f | 2014-06-19 21:38:57 -0700 | [diff] [blame] | 4 | * Copyright (C) 2011-2014, Marvell International Ltd. |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 5 | * |
| 6 | * This software file (the "File") is distributed by Marvell International |
| 7 | * Ltd. under the terms of the GNU General Public License Version 2, June 1991 |
| 8 | * (the "License"). You may use, redistribute and/or modify this File in |
| 9 | * accordance with the terms and conditions of the License, a copy of which |
| 10 | * is available by writing to the Free Software Foundation, Inc., |
| 11 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the |
| 12 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. |
| 13 | * |
| 14 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE |
| 16 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about |
| 17 | * this warranty disclaimer. |
| 18 | */ |
| 19 | |
| 20 | #include "decl.h" |
| 21 | #include "ioctl.h" |
| 22 | #include "util.h" |
| 23 | #include "fw.h" |
| 24 | #include "main.h" |
| 25 | #include "wmm.h" |
| 26 | #include "11n.h" |
Yogesh Ashok Powar | 83c78da | 2013-03-18 20:06:03 -0700 | [diff] [blame] | 27 | #include "11ac.h" |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 28 | |
Avinash Patil | d5b036c | 2015-06-22 19:06:20 +0530 | [diff] [blame] | 29 | static bool drcs; |
| 30 | module_param(drcs, bool, 0644); |
| 31 | MODULE_PARM_DESC(drcs, "multi-channel operation:1, single-channel operation:0"); |
| 32 | |
Avinash Patil | 0b4155d | 2014-12-23 19:14:12 +0530 | [diff] [blame] | 33 | static bool disable_auto_ds; |
| 34 | module_param(disable_auto_ds, bool, 0); |
| 35 | MODULE_PARM_DESC(disable_auto_ds, |
| 36 | "deepsleep enabled=0(default), deepsleep disabled=1"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 37 | /* |
| 38 | * This function prepares command to set/get RSSI information. |
| 39 | * |
| 40 | * Preparation includes - |
| 41 | * - Setting command ID, action and proper size |
| 42 | * - Setting data/beacon average factors |
| 43 | * - Resetting SNR/NF/RSSI values in private structure |
| 44 | * - Ensuring correct endian-ness |
| 45 | */ |
| 46 | static int |
| 47 | mwifiex_cmd_802_11_rssi_info(struct mwifiex_private *priv, |
| 48 | struct host_cmd_ds_command *cmd, u16 cmd_action) |
| 49 | { |
| 50 | cmd->command = cpu_to_le16(HostCmd_CMD_RSSI_INFO); |
| 51 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_rssi_info) + |
| 52 | S_DS_GEN); |
| 53 | cmd->params.rssi_info.action = cpu_to_le16(cmd_action); |
| 54 | cmd->params.rssi_info.ndata = cpu_to_le16(priv->data_avg_factor); |
| 55 | cmd->params.rssi_info.nbcn = cpu_to_le16(priv->bcn_avg_factor); |
| 56 | |
| 57 | /* Reset SNR/NF/RSSI values in private structure */ |
| 58 | priv->data_rssi_last = 0; |
| 59 | priv->data_nf_last = 0; |
| 60 | priv->data_rssi_avg = 0; |
| 61 | priv->data_nf_avg = 0; |
| 62 | priv->bcn_rssi_last = 0; |
| 63 | priv->bcn_nf_last = 0; |
| 64 | priv->bcn_rssi_avg = 0; |
| 65 | priv->bcn_nf_avg = 0; |
| 66 | |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | /* |
| 71 | * This function prepares command to set MAC control. |
| 72 | * |
| 73 | * Preparation includes - |
| 74 | * - Setting command ID, action and proper size |
| 75 | * - Ensuring correct endian-ness |
| 76 | */ |
| 77 | static int mwifiex_cmd_mac_control(struct mwifiex_private *priv, |
| 78 | struct host_cmd_ds_command *cmd, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 79 | u16 cmd_action, u16 *action) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 80 | { |
| 81 | struct host_cmd_ds_mac_control *mac_ctrl = &cmd->params.mac_ctrl; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 82 | |
| 83 | if (cmd_action != HostCmd_ACT_GEN_SET) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 84 | mwifiex_dbg(priv->adapter, ERROR, |
| 85 | "mac_control: only support set cmd\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 86 | return -1; |
| 87 | } |
| 88 | |
| 89 | cmd->command = cpu_to_le16(HostCmd_CMD_MAC_CONTROL); |
| 90 | cmd->size = |
| 91 | cpu_to_le16(sizeof(struct host_cmd_ds_mac_control) + S_DS_GEN); |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 92 | mac_ctrl->action = cpu_to_le16(*action); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 93 | |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | /* |
| 98 | * This function prepares command to set/get SNMP MIB. |
| 99 | * |
| 100 | * Preparation includes - |
| 101 | * - Setting command ID, action and proper size |
| 102 | * - Setting SNMP MIB OID number and value |
| 103 | * (as required) |
| 104 | * - Ensuring correct endian-ness |
| 105 | * |
| 106 | * The following SNMP MIB OIDs are supported - |
| 107 | * - FRAG_THRESH_I : Fragmentation threshold |
| 108 | * - RTS_THRESH_I : RTS threshold |
| 109 | * - SHORT_RETRY_LIM_I : Short retry limit |
| 110 | * - DOT11D_I : 11d support |
| 111 | */ |
| 112 | static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, |
| 113 | struct host_cmd_ds_command *cmd, |
| 114 | u16 cmd_action, u32 cmd_oid, |
Amitkumar Karwar | f3c8d25 | 2012-02-02 20:48:57 -0800 | [diff] [blame] | 115 | u16 *ul_temp) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 116 | { |
| 117 | struct host_cmd_ds_802_11_snmp_mib *snmp_mib = &cmd->params.smib; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 118 | |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 119 | mwifiex_dbg(priv->adapter, CMD, |
| 120 | "cmd: SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 121 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SNMP_MIB); |
| 122 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_snmp_mib) |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 123 | - 1 + S_DS_GEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 124 | |
Amitkumar Karwar | f3c8d25 | 2012-02-02 20:48:57 -0800 | [diff] [blame] | 125 | snmp_mib->oid = cpu_to_le16((u16)cmd_oid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 126 | if (cmd_action == HostCmd_ACT_GEN_GET) { |
| 127 | snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_GET); |
| 128 | snmp_mib->buf_size = cpu_to_le16(MAX_SNMP_BUF_SIZE); |
Amitkumar Karwar | f3c8d25 | 2012-02-02 20:48:57 -0800 | [diff] [blame] | 129 | le16_add_cpu(&cmd->size, MAX_SNMP_BUF_SIZE); |
| 130 | } else if (cmd_action == HostCmd_ACT_GEN_SET) { |
| 131 | snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET); |
| 132 | snmp_mib->buf_size = cpu_to_le16(sizeof(u16)); |
| 133 | *((__le16 *) (snmp_mib->value)) = cpu_to_le16(*ul_temp); |
| 134 | le16_add_cpu(&cmd->size, sizeof(u16)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 135 | } |
| 136 | |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 137 | mwifiex_dbg(priv->adapter, CMD, |
| 138 | "cmd: SNMP_CMD: Action=0x%x, OID=0x%x,\t" |
| 139 | "OIDSize=0x%x, Value=0x%x\n", |
| 140 | cmd_action, cmd_oid, le16_to_cpu(snmp_mib->buf_size), |
| 141 | le16_to_cpu(*(__le16 *)snmp_mib->value)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 142 | return 0; |
| 143 | } |
| 144 | |
| 145 | /* |
| 146 | * This function prepares command to get log. |
| 147 | * |
| 148 | * Preparation includes - |
| 149 | * - Setting command ID and proper size |
| 150 | * - Ensuring correct endian-ness |
| 151 | */ |
| 152 | static int |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 153 | mwifiex_cmd_802_11_get_log(struct host_cmd_ds_command *cmd) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 154 | { |
| 155 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_GET_LOG); |
| 156 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_get_log) + |
| 157 | S_DS_GEN); |
| 158 | return 0; |
| 159 | } |
| 160 | |
| 161 | /* |
| 162 | * This function prepares command to set/get Tx data rate configuration. |
| 163 | * |
| 164 | * Preparation includes - |
| 165 | * - Setting command ID, action and proper size |
| 166 | * - Setting configuration index, rate scope and rate drop pattern |
| 167 | * parameters (as required) |
| 168 | * - Ensuring correct endian-ness |
| 169 | */ |
| 170 | static int mwifiex_cmd_tx_rate_cfg(struct mwifiex_private *priv, |
| 171 | struct host_cmd_ds_command *cmd, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 172 | u16 cmd_action, u16 *pbitmap_rates) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 173 | { |
| 174 | struct host_cmd_ds_tx_rate_cfg *rate_cfg = &cmd->params.tx_rate_cfg; |
| 175 | struct mwifiex_rate_scope *rate_scope; |
| 176 | struct mwifiex_rate_drop_pattern *rate_drop; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 177 | u32 i; |
| 178 | |
| 179 | cmd->command = cpu_to_le16(HostCmd_CMD_TX_RATE_CFG); |
| 180 | |
| 181 | rate_cfg->action = cpu_to_le16(cmd_action); |
| 182 | rate_cfg->cfg_index = 0; |
| 183 | |
| 184 | rate_scope = (struct mwifiex_rate_scope *) ((u8 *) rate_cfg + |
| 185 | sizeof(struct host_cmd_ds_tx_rate_cfg)); |
| 186 | rate_scope->type = cpu_to_le16(TLV_TYPE_RATE_SCOPE); |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 187 | rate_scope->length = cpu_to_le16 |
| 188 | (sizeof(*rate_scope) - sizeof(struct mwifiex_ie_types_header)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 189 | if (pbitmap_rates != NULL) { |
| 190 | rate_scope->hr_dsss_rate_bitmap = cpu_to_le16(pbitmap_rates[0]); |
| 191 | rate_scope->ofdm_rate_bitmap = cpu_to_le16(pbitmap_rates[1]); |
| 192 | for (i = 0; |
| 193 | i < sizeof(rate_scope->ht_mcs_rate_bitmap) / sizeof(u16); |
| 194 | i++) |
| 195 | rate_scope->ht_mcs_rate_bitmap[i] = |
| 196 | cpu_to_le16(pbitmap_rates[2 + i]); |
Amitkumar Karwar | a0b7315a | 2014-03-07 19:41:27 -0800 | [diff] [blame] | 197 | if (priv->adapter->fw_api_ver == MWIFIEX_FW_V15) { |
| 198 | for (i = 0; |
| 199 | i < ARRAY_SIZE(rate_scope->vht_mcs_rate_bitmap); |
| 200 | i++) |
| 201 | rate_scope->vht_mcs_rate_bitmap[i] = |
| 202 | cpu_to_le16(pbitmap_rates[10 + i]); |
| 203 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 204 | } else { |
| 205 | rate_scope->hr_dsss_rate_bitmap = |
| 206 | cpu_to_le16(priv->bitmap_rates[0]); |
| 207 | rate_scope->ofdm_rate_bitmap = |
| 208 | cpu_to_le16(priv->bitmap_rates[1]); |
| 209 | for (i = 0; |
| 210 | i < sizeof(rate_scope->ht_mcs_rate_bitmap) / sizeof(u16); |
| 211 | i++) |
| 212 | rate_scope->ht_mcs_rate_bitmap[i] = |
| 213 | cpu_to_le16(priv->bitmap_rates[2 + i]); |
Amitkumar Karwar | a0b7315a | 2014-03-07 19:41:27 -0800 | [diff] [blame] | 214 | if (priv->adapter->fw_api_ver == MWIFIEX_FW_V15) { |
| 215 | for (i = 0; |
| 216 | i < ARRAY_SIZE(rate_scope->vht_mcs_rate_bitmap); |
| 217 | i++) |
| 218 | rate_scope->vht_mcs_rate_bitmap[i] = |
| 219 | cpu_to_le16(priv->bitmap_rates[10 + i]); |
| 220 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | rate_drop = (struct mwifiex_rate_drop_pattern *) ((u8 *) rate_scope + |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 224 | sizeof(struct mwifiex_rate_scope)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 225 | rate_drop->type = cpu_to_le16(TLV_TYPE_RATE_DROP_CONTROL); |
| 226 | rate_drop->length = cpu_to_le16(sizeof(rate_drop->rate_drop_mode)); |
| 227 | rate_drop->rate_drop_mode = 0; |
| 228 | |
| 229 | cmd->size = |
| 230 | cpu_to_le16(S_DS_GEN + sizeof(struct host_cmd_ds_tx_rate_cfg) + |
| 231 | sizeof(struct mwifiex_rate_scope) + |
| 232 | sizeof(struct mwifiex_rate_drop_pattern)); |
| 233 | |
| 234 | return 0; |
| 235 | } |
| 236 | |
| 237 | /* |
| 238 | * This function prepares command to set/get Tx power configuration. |
| 239 | * |
| 240 | * Preparation includes - |
| 241 | * - Setting command ID, action and proper size |
| 242 | * - Setting Tx power mode, power group TLV |
| 243 | * (as required) |
| 244 | * - Ensuring correct endian-ness |
| 245 | */ |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 246 | static int mwifiex_cmd_tx_power_cfg(struct host_cmd_ds_command *cmd, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 247 | u16 cmd_action, |
| 248 | struct host_cmd_ds_txpwr_cfg *txp) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 249 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 250 | struct mwifiex_types_power_group *pg_tlv; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 251 | struct host_cmd_ds_txpwr_cfg *cmd_txp_cfg = &cmd->params.txp_cfg; |
| 252 | |
| 253 | cmd->command = cpu_to_le16(HostCmd_CMD_TXPWR_CFG); |
| 254 | cmd->size = |
| 255 | cpu_to_le16(S_DS_GEN + sizeof(struct host_cmd_ds_txpwr_cfg)); |
| 256 | switch (cmd_action) { |
| 257 | case HostCmd_ACT_GEN_SET: |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 258 | if (txp->mode) { |
| 259 | pg_tlv = (struct mwifiex_types_power_group |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 260 | *) ((unsigned long) txp + |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 261 | sizeof(struct host_cmd_ds_txpwr_cfg)); |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 262 | memmove(cmd_txp_cfg, txp, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 263 | sizeof(struct host_cmd_ds_txpwr_cfg) + |
| 264 | sizeof(struct mwifiex_types_power_group) + |
Amitkumar Karwar | 930fd35 | 2013-10-22 15:24:43 -0700 | [diff] [blame] | 265 | le16_to_cpu(pg_tlv->length)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 266 | |
| 267 | pg_tlv = (struct mwifiex_types_power_group *) ((u8 *) |
| 268 | cmd_txp_cfg + |
| 269 | sizeof(struct host_cmd_ds_txpwr_cfg)); |
| 270 | cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) + |
| 271 | sizeof(struct mwifiex_types_power_group) + |
Amitkumar Karwar | 930fd35 | 2013-10-22 15:24:43 -0700 | [diff] [blame] | 272 | le16_to_cpu(pg_tlv->length)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 273 | } else { |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 274 | memmove(cmd_txp_cfg, txp, sizeof(*txp)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 275 | } |
| 276 | cmd_txp_cfg->action = cpu_to_le16(cmd_action); |
| 277 | break; |
| 278 | case HostCmd_ACT_GEN_GET: |
| 279 | cmd_txp_cfg->action = cpu_to_le16(cmd_action); |
| 280 | break; |
| 281 | } |
| 282 | |
| 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | /* |
Amitkumar Karwar | caa8984 | 2012-06-27 19:57:57 -0700 | [diff] [blame] | 287 | * This function prepares command to get RF Tx power. |
| 288 | */ |
| 289 | static int mwifiex_cmd_rf_tx_power(struct mwifiex_private *priv, |
| 290 | struct host_cmd_ds_command *cmd, |
| 291 | u16 cmd_action, void *data_buf) |
| 292 | { |
| 293 | struct host_cmd_ds_rf_tx_pwr *txp = &cmd->params.txp; |
| 294 | |
| 295 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_tx_pwr) |
| 296 | + S_DS_GEN); |
| 297 | cmd->command = cpu_to_le16(HostCmd_CMD_RF_TX_PWR); |
| 298 | txp->action = cpu_to_le16(cmd_action); |
| 299 | |
| 300 | return 0; |
| 301 | } |
| 302 | |
| 303 | /* |
Amitkumar Karwar | 8a279d5 | 2012-07-02 19:32:33 -0700 | [diff] [blame] | 304 | * This function prepares command to set rf antenna. |
| 305 | */ |
| 306 | static int mwifiex_cmd_rf_antenna(struct mwifiex_private *priv, |
| 307 | struct host_cmd_ds_command *cmd, |
| 308 | u16 cmd_action, |
| 309 | struct mwifiex_ds_ant_cfg *ant_cfg) |
| 310 | { |
| 311 | struct host_cmd_ds_rf_ant_mimo *ant_mimo = &cmd->params.ant_mimo; |
| 312 | struct host_cmd_ds_rf_ant_siso *ant_siso = &cmd->params.ant_siso; |
| 313 | |
| 314 | cmd->command = cpu_to_le16(HostCmd_CMD_RF_ANTENNA); |
| 315 | |
| 316 | if (cmd_action != HostCmd_ACT_GEN_SET) |
| 317 | return 0; |
| 318 | |
| 319 | if (priv->adapter->hw_dev_mcs_support == HT_STREAM_2X2) { |
| 320 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_ant_mimo) + |
| 321 | S_DS_GEN); |
| 322 | ant_mimo->action_tx = cpu_to_le16(HostCmd_ACT_SET_TX); |
| 323 | ant_mimo->tx_ant_mode = cpu_to_le16((u16)ant_cfg->tx_ant); |
| 324 | ant_mimo->action_rx = cpu_to_le16(HostCmd_ACT_SET_RX); |
| 325 | ant_mimo->rx_ant_mode = cpu_to_le16((u16)ant_cfg->rx_ant); |
| 326 | } else { |
| 327 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_ant_siso) + |
| 328 | S_DS_GEN); |
| 329 | ant_siso->action = cpu_to_le16(HostCmd_ACT_SET_BOTH); |
| 330 | ant_siso->ant_mode = cpu_to_le16((u16)ant_cfg->tx_ant); |
| 331 | } |
| 332 | |
| 333 | return 0; |
| 334 | } |
| 335 | |
| 336 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 337 | * This function prepares command to set Host Sleep configuration. |
| 338 | * |
| 339 | * Preparation includes - |
| 340 | * - Setting command ID and proper size |
| 341 | * - Setting Host Sleep action, conditions, ARP filters |
| 342 | * (as required) |
| 343 | * - Ensuring correct endian-ness |
| 344 | */ |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 345 | static int |
| 346 | mwifiex_cmd_802_11_hs_cfg(struct mwifiex_private *priv, |
| 347 | struct host_cmd_ds_command *cmd, |
| 348 | u16 cmd_action, |
| 349 | struct mwifiex_hs_config_param *hscfg_param) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 350 | { |
| 351 | struct mwifiex_adapter *adapter = priv->adapter; |
| 352 | struct host_cmd_ds_802_11_hs_cfg_enh *hs_cfg = &cmd->params.opt_hs_cfg; |
Peter Senna Tschudin | c856197 | 2013-09-22 00:27:43 +0200 | [diff] [blame] | 353 | bool hs_activate = false; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 354 | |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 355 | if (!hscfg_param) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 356 | /* New Activate command */ |
| 357 | hs_activate = true; |
| 358 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_HS_CFG_ENH); |
| 359 | |
| 360 | if (!hs_activate && |
Amitkumar Karwar | cc0b5a6 | 2013-03-04 16:27:57 -0800 | [diff] [blame] | 361 | (hscfg_param->conditions != cpu_to_le32(HS_CFG_CANCEL)) && |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 362 | ((adapter->arp_filter_size > 0) && |
| 363 | (adapter->arp_filter_size <= ARP_FILTER_MAX_BUF_SIZE))) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 364 | mwifiex_dbg(adapter, CMD, |
| 365 | "cmd: Attach %d bytes ArpFilter to HSCfg cmd\n", |
| 366 | adapter->arp_filter_size); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 367 | memcpy(((u8 *) hs_cfg) + |
| 368 | sizeof(struct host_cmd_ds_802_11_hs_cfg_enh), |
| 369 | adapter->arp_filter, adapter->arp_filter_size); |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 370 | cmd->size = cpu_to_le16 |
| 371 | (adapter->arp_filter_size + |
| 372 | sizeof(struct host_cmd_ds_802_11_hs_cfg_enh) |
| 373 | + S_DS_GEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 374 | } else { |
| 375 | cmd->size = cpu_to_le16(S_DS_GEN + sizeof(struct |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 376 | host_cmd_ds_802_11_hs_cfg_enh)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 377 | } |
| 378 | if (hs_activate) { |
| 379 | hs_cfg->action = cpu_to_le16(HS_ACTIVATE); |
Ujjal Roy | 4348d08 | 2013-12-02 23:17:48 -0800 | [diff] [blame] | 380 | hs_cfg->params.hs_activate.resp_ctrl = cpu_to_le16(RESP_NEEDED); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 381 | } else { |
| 382 | hs_cfg->action = cpu_to_le16(HS_CONFIGURE); |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 383 | hs_cfg->params.hs_config.conditions = hscfg_param->conditions; |
| 384 | hs_cfg->params.hs_config.gpio = hscfg_param->gpio; |
| 385 | hs_cfg->params.hs_config.gap = hscfg_param->gap; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 386 | mwifiex_dbg(adapter, CMD, |
| 387 | "cmd: HS_CFG_CMD: condition:0x%x gpio:0x%x gap:0x%x\n", |
| 388 | hs_cfg->params.hs_config.conditions, |
| 389 | hs_cfg->params.hs_config.gpio, |
| 390 | hs_cfg->params.hs_config.gap); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | return 0; |
| 394 | } |
| 395 | |
| 396 | /* |
| 397 | * This function prepares command to set/get MAC address. |
| 398 | * |
| 399 | * Preparation includes - |
| 400 | * - Setting command ID, action and proper size |
| 401 | * - Setting MAC address (for SET only) |
| 402 | * - Ensuring correct endian-ness |
| 403 | */ |
| 404 | static int mwifiex_cmd_802_11_mac_address(struct mwifiex_private *priv, |
| 405 | struct host_cmd_ds_command *cmd, |
| 406 | u16 cmd_action) |
| 407 | { |
| 408 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_MAC_ADDRESS); |
| 409 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_mac_address) + |
| 410 | S_DS_GEN); |
| 411 | cmd->result = 0; |
| 412 | |
| 413 | cmd->params.mac_addr.action = cpu_to_le16(cmd_action); |
| 414 | |
| 415 | if (cmd_action == HostCmd_ACT_GEN_SET) |
| 416 | memcpy(cmd->params.mac_addr.mac_addr, priv->curr_addr, |
| 417 | ETH_ALEN); |
| 418 | return 0; |
| 419 | } |
| 420 | |
| 421 | /* |
| 422 | * This function prepares command to set MAC multicast address. |
| 423 | * |
| 424 | * Preparation includes - |
| 425 | * - Setting command ID, action and proper size |
| 426 | * - Setting MAC multicast address |
| 427 | * - Ensuring correct endian-ness |
| 428 | */ |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 429 | static int |
| 430 | mwifiex_cmd_mac_multicast_adr(struct host_cmd_ds_command *cmd, |
| 431 | u16 cmd_action, |
| 432 | struct mwifiex_multicast_list *mcast_list) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 433 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 434 | struct host_cmd_ds_mac_multicast_adr *mcast_addr = &cmd->params.mc_addr; |
| 435 | |
| 436 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_mac_multicast_adr) + |
| 437 | S_DS_GEN); |
| 438 | cmd->command = cpu_to_le16(HostCmd_CMD_MAC_MULTICAST_ADR); |
| 439 | |
| 440 | mcast_addr->action = cpu_to_le16(cmd_action); |
| 441 | mcast_addr->num_of_adrs = |
| 442 | cpu_to_le16((u16) mcast_list->num_multicast_addr); |
| 443 | memcpy(mcast_addr->mac_list, mcast_list->mac_list, |
| 444 | mcast_list->num_multicast_addr * ETH_ALEN); |
| 445 | |
| 446 | return 0; |
| 447 | } |
| 448 | |
| 449 | /* |
| 450 | * This function prepares command to deauthenticate. |
| 451 | * |
| 452 | * Preparation includes - |
| 453 | * - Setting command ID and proper size |
| 454 | * - Setting AP MAC address and reason code |
| 455 | * - Ensuring correct endian-ness |
| 456 | */ |
| 457 | static int mwifiex_cmd_802_11_deauthenticate(struct mwifiex_private *priv, |
| 458 | struct host_cmd_ds_command *cmd, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 459 | u8 *mac) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 460 | { |
| 461 | struct host_cmd_ds_802_11_deauthenticate *deauth = &cmd->params.deauth; |
| 462 | |
| 463 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_DEAUTHENTICATE); |
| 464 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_deauthenticate) |
| 465 | + S_DS_GEN); |
| 466 | |
| 467 | /* Set AP MAC address */ |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 468 | memcpy(deauth->mac_addr, mac, ETH_ALEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 469 | |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 470 | mwifiex_dbg(priv->adapter, CMD, "cmd: Deauth: %pM\n", deauth->mac_addr); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 471 | |
| 472 | deauth->reason_code = cpu_to_le16(WLAN_REASON_DEAUTH_LEAVING); |
| 473 | |
| 474 | return 0; |
| 475 | } |
| 476 | |
| 477 | /* |
| 478 | * This function prepares command to stop Ad-Hoc network. |
| 479 | * |
| 480 | * Preparation includes - |
| 481 | * - Setting command ID and proper size |
| 482 | * - Ensuring correct endian-ness |
| 483 | */ |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 484 | static int mwifiex_cmd_802_11_ad_hoc_stop(struct host_cmd_ds_command *cmd) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 485 | { |
| 486 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_STOP); |
| 487 | cmd->size = cpu_to_le16(S_DS_GEN); |
| 488 | return 0; |
| 489 | } |
| 490 | |
| 491 | /* |
| 492 | * This function sets WEP key(s) to key parameter TLV(s). |
| 493 | * |
| 494 | * Multi-key parameter TLVs are supported, so we can send multiple |
| 495 | * WEP keys in a single buffer. |
| 496 | */ |
| 497 | static int |
| 498 | mwifiex_set_keyparamset_wep(struct mwifiex_private *priv, |
| 499 | struct mwifiex_ie_type_key_param_set *key_param_set, |
| 500 | u16 *key_param_len) |
| 501 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 502 | int cur_key_param_len; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 503 | u8 i; |
| 504 | |
| 505 | /* Multi-key_param_set TLV is supported */ |
| 506 | for (i = 0; i < NUM_WEP_KEYS; i++) { |
| 507 | if ((priv->wep_key[i].key_length == WLAN_KEY_LEN_WEP40) || |
| 508 | (priv->wep_key[i].key_length == WLAN_KEY_LEN_WEP104)) { |
| 509 | key_param_set->type = |
| 510 | cpu_to_le16(TLV_TYPE_KEY_MATERIAL); |
| 511 | /* Key_param_set WEP fixed length */ |
| 512 | #define KEYPARAMSET_WEP_FIXED_LEN 8 |
| 513 | key_param_set->length = cpu_to_le16((u16) |
| 514 | (priv->wep_key[i]. |
| 515 | key_length + |
| 516 | KEYPARAMSET_WEP_FIXED_LEN)); |
| 517 | key_param_set->key_type_id = |
| 518 | cpu_to_le16(KEY_TYPE_ID_WEP); |
| 519 | key_param_set->key_info = |
Yogesh Ashok Powar | 6a35a0a | 2011-04-06 16:46:56 -0700 | [diff] [blame] | 520 | cpu_to_le16(KEY_ENABLED | KEY_UNICAST | |
| 521 | KEY_MCAST); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 522 | key_param_set->key_len = |
| 523 | cpu_to_le16(priv->wep_key[i].key_length); |
| 524 | /* Set WEP key index */ |
| 525 | key_param_set->key[0] = i; |
| 526 | /* Set default Tx key flag */ |
| 527 | if (i == |
| 528 | (priv-> |
| 529 | wep_key_curr_index & HostCmd_WEP_KEY_INDEX_MASK)) |
| 530 | key_param_set->key[1] = 1; |
| 531 | else |
| 532 | key_param_set->key[1] = 0; |
| 533 | memmove(&key_param_set->key[2], |
| 534 | priv->wep_key[i].key_material, |
| 535 | priv->wep_key[i].key_length); |
| 536 | |
| 537 | cur_key_param_len = priv->wep_key[i].key_length + |
| 538 | KEYPARAMSET_WEP_FIXED_LEN + |
| 539 | sizeof(struct mwifiex_ie_types_header); |
| 540 | *key_param_len += (u16) cur_key_param_len; |
| 541 | key_param_set = |
| 542 | (struct mwifiex_ie_type_key_param_set *) |
| 543 | ((u8 *)key_param_set + |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 544 | cur_key_param_len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 545 | } else if (!priv->wep_key[i].key_length) { |
| 546 | continue; |
| 547 | } else { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 548 | mwifiex_dbg(priv->adapter, ERROR, |
| 549 | "key%d Length = %d is incorrect\n", |
| 550 | (i + 1), priv->wep_key[i].key_length); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 551 | return -1; |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | return 0; |
| 556 | } |
| 557 | |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 558 | /* This function populates key material v2 command |
| 559 | * to set network key for AES & CMAC AES. |
| 560 | */ |
| 561 | static int mwifiex_set_aes_key_v2(struct mwifiex_private *priv, |
| 562 | struct host_cmd_ds_command *cmd, |
| 563 | struct mwifiex_ds_encrypt_key *enc_key, |
| 564 | struct host_cmd_ds_802_11_key_material_v2 *km) |
| 565 | { |
| 566 | struct mwifiex_adapter *adapter = priv->adapter; |
| 567 | u16 size, len = KEY_PARAMS_FIXED_LEN; |
| 568 | |
| 569 | if (enc_key->is_igtk_key) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 570 | mwifiex_dbg(adapter, INFO, |
| 571 | "%s: Set CMAC AES Key\n", __func__); |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 572 | if (enc_key->is_rx_seq_valid) |
| 573 | memcpy(km->key_param_set.key_params.cmac_aes.ipn, |
| 574 | enc_key->pn, enc_key->pn_len); |
| 575 | km->key_param_set.key_info &= cpu_to_le16(~KEY_MCAST); |
| 576 | km->key_param_set.key_info |= cpu_to_le16(KEY_IGTK); |
| 577 | km->key_param_set.key_type = KEY_TYPE_ID_AES_CMAC; |
| 578 | km->key_param_set.key_params.cmac_aes.key_len = |
| 579 | cpu_to_le16(enc_key->key_len); |
| 580 | memcpy(km->key_param_set.key_params.cmac_aes.key, |
| 581 | enc_key->key_material, enc_key->key_len); |
| 582 | len += sizeof(struct mwifiex_cmac_aes_param); |
| 583 | } else { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 584 | mwifiex_dbg(adapter, INFO, |
| 585 | "%s: Set AES Key\n", __func__); |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 586 | if (enc_key->is_rx_seq_valid) |
| 587 | memcpy(km->key_param_set.key_params.aes.pn, |
| 588 | enc_key->pn, enc_key->pn_len); |
| 589 | km->key_param_set.key_type = KEY_TYPE_ID_AES; |
| 590 | km->key_param_set.key_params.aes.key_len = |
| 591 | cpu_to_le16(enc_key->key_len); |
| 592 | memcpy(km->key_param_set.key_params.aes.key, |
| 593 | enc_key->key_material, enc_key->key_len); |
| 594 | len += sizeof(struct mwifiex_aes_param); |
| 595 | } |
| 596 | |
| 597 | km->key_param_set.len = cpu_to_le16(len); |
| 598 | size = len + sizeof(struct mwifiex_ie_types_header) + |
| 599 | sizeof(km->action) + S_DS_GEN; |
| 600 | cmd->size = cpu_to_le16(size); |
| 601 | |
| 602 | return 0; |
| 603 | } |
| 604 | |
| 605 | /* This function prepares command to set/get/reset network key(s). |
| 606 | * This function prepares key material command for V2 format. |
| 607 | * Preparation includes - |
| 608 | * - Setting command ID, action and proper size |
| 609 | * - Setting WEP keys, WAPI keys or WPA keys along with required |
| 610 | * encryption (TKIP, AES) (as required) |
| 611 | * - Ensuring correct endian-ness |
| 612 | */ |
| 613 | static int |
| 614 | mwifiex_cmd_802_11_key_material_v2(struct mwifiex_private *priv, |
| 615 | struct host_cmd_ds_command *cmd, |
| 616 | u16 cmd_action, u32 cmd_oid, |
| 617 | struct mwifiex_ds_encrypt_key *enc_key) |
| 618 | { |
| 619 | struct mwifiex_adapter *adapter = priv->adapter; |
| 620 | u8 *mac = enc_key->mac_addr; |
| 621 | u16 key_info, len = KEY_PARAMS_FIXED_LEN; |
| 622 | struct host_cmd_ds_802_11_key_material_v2 *km = |
| 623 | &cmd->params.key_material_v2; |
| 624 | |
| 625 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_KEY_MATERIAL); |
| 626 | km->action = cpu_to_le16(cmd_action); |
| 627 | |
| 628 | if (cmd_action == HostCmd_ACT_GEN_GET) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 629 | mwifiex_dbg(adapter, INFO, "%s: Get key\n", __func__); |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 630 | km->key_param_set.key_idx = |
| 631 | enc_key->key_index & KEY_INDEX_MASK; |
| 632 | km->key_param_set.type = cpu_to_le16(TLV_TYPE_KEY_PARAM_V2); |
| 633 | km->key_param_set.len = cpu_to_le16(KEY_PARAMS_FIXED_LEN); |
| 634 | memcpy(km->key_param_set.mac_addr, mac, ETH_ALEN); |
| 635 | |
| 636 | if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST) |
| 637 | key_info = KEY_UNICAST; |
| 638 | else |
| 639 | key_info = KEY_MCAST; |
| 640 | |
| 641 | if (enc_key->is_igtk_key) |
| 642 | key_info |= KEY_IGTK; |
| 643 | |
| 644 | km->key_param_set.key_info = cpu_to_le16(key_info); |
| 645 | |
| 646 | cmd->size = cpu_to_le16(sizeof(struct mwifiex_ie_types_header) + |
| 647 | S_DS_GEN + KEY_PARAMS_FIXED_LEN + |
| 648 | sizeof(km->action)); |
| 649 | return 0; |
| 650 | } |
| 651 | |
| 652 | memset(&km->key_param_set, 0, |
| 653 | sizeof(struct mwifiex_ie_type_key_param_set_v2)); |
| 654 | |
| 655 | if (enc_key->key_disable) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 656 | mwifiex_dbg(adapter, INFO, "%s: Remove key\n", __func__); |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 657 | km->action = cpu_to_le16(HostCmd_ACT_GEN_REMOVE); |
| 658 | km->key_param_set.type = cpu_to_le16(TLV_TYPE_KEY_PARAM_V2); |
| 659 | km->key_param_set.len = cpu_to_le16(KEY_PARAMS_FIXED_LEN); |
| 660 | km->key_param_set.key_idx = enc_key->key_index & KEY_INDEX_MASK; |
| 661 | key_info = KEY_MCAST | KEY_UNICAST; |
| 662 | km->key_param_set.key_info = cpu_to_le16(key_info); |
| 663 | memcpy(km->key_param_set.mac_addr, mac, ETH_ALEN); |
| 664 | cmd->size = cpu_to_le16(sizeof(struct mwifiex_ie_types_header) + |
| 665 | S_DS_GEN + KEY_PARAMS_FIXED_LEN + |
| 666 | sizeof(km->action)); |
| 667 | return 0; |
| 668 | } |
| 669 | |
| 670 | km->action = cpu_to_le16(HostCmd_ACT_GEN_SET); |
| 671 | km->key_param_set.key_idx = enc_key->key_index & KEY_INDEX_MASK; |
| 672 | km->key_param_set.type = cpu_to_le16(TLV_TYPE_KEY_PARAM_V2); |
| 673 | key_info = KEY_ENABLED; |
| 674 | memcpy(km->key_param_set.mac_addr, mac, ETH_ALEN); |
| 675 | |
| 676 | if (enc_key->key_len <= WLAN_KEY_LEN_WEP104) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 677 | mwifiex_dbg(adapter, INFO, "%s: Set WEP Key\n", __func__); |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 678 | len += sizeof(struct mwifiex_wep_param); |
| 679 | km->key_param_set.len = cpu_to_le16(len); |
| 680 | km->key_param_set.key_type = KEY_TYPE_ID_WEP; |
| 681 | |
| 682 | if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) { |
| 683 | key_info |= KEY_MCAST | KEY_UNICAST; |
| 684 | } else { |
| 685 | if (enc_key->is_current_wep_key) { |
| 686 | key_info |= KEY_MCAST | KEY_UNICAST; |
| 687 | if (km->key_param_set.key_idx == |
| 688 | (priv->wep_key_curr_index & KEY_INDEX_MASK)) |
| 689 | key_info |= KEY_DEFAULT; |
| 690 | } else { |
| 691 | if (mac) { |
| 692 | if (is_broadcast_ether_addr(mac)) |
| 693 | key_info |= KEY_MCAST; |
| 694 | else |
| 695 | key_info |= KEY_UNICAST | |
| 696 | KEY_DEFAULT; |
| 697 | } else { |
| 698 | key_info |= KEY_MCAST; |
| 699 | } |
| 700 | } |
| 701 | } |
| 702 | km->key_param_set.key_info = cpu_to_le16(key_info); |
| 703 | |
| 704 | km->key_param_set.key_params.wep.key_len = |
| 705 | cpu_to_le16(enc_key->key_len); |
| 706 | memcpy(km->key_param_set.key_params.wep.key, |
| 707 | enc_key->key_material, enc_key->key_len); |
| 708 | |
| 709 | cmd->size = cpu_to_le16(sizeof(struct mwifiex_ie_types_header) + |
| 710 | len + sizeof(km->action) + S_DS_GEN); |
| 711 | return 0; |
| 712 | } |
| 713 | |
| 714 | if (is_broadcast_ether_addr(mac)) |
| 715 | key_info |= KEY_MCAST | KEY_RX_KEY; |
| 716 | else |
| 717 | key_info |= KEY_UNICAST | KEY_TX_KEY | KEY_RX_KEY; |
| 718 | |
| 719 | if (enc_key->is_wapi_key) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 720 | mwifiex_dbg(adapter, INFO, "%s: Set WAPI Key\n", __func__); |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 721 | km->key_param_set.key_type = KEY_TYPE_ID_WAPI; |
| 722 | memcpy(km->key_param_set.key_params.wapi.pn, enc_key->pn, |
| 723 | PN_LEN); |
| 724 | km->key_param_set.key_params.wapi.key_len = |
| 725 | cpu_to_le16(enc_key->key_len); |
| 726 | memcpy(km->key_param_set.key_params.wapi.key, |
| 727 | enc_key->key_material, enc_key->key_len); |
| 728 | if (is_broadcast_ether_addr(mac)) |
| 729 | priv->sec_info.wapi_key_on = true; |
| 730 | |
| 731 | if (!priv->sec_info.wapi_key_on) |
| 732 | key_info |= KEY_DEFAULT; |
| 733 | km->key_param_set.key_info = cpu_to_le16(key_info); |
| 734 | |
| 735 | len += sizeof(struct mwifiex_wapi_param); |
| 736 | km->key_param_set.len = cpu_to_le16(len); |
| 737 | cmd->size = cpu_to_le16(sizeof(struct mwifiex_ie_types_header) + |
| 738 | len + sizeof(km->action) + S_DS_GEN); |
| 739 | return 0; |
| 740 | } |
| 741 | |
| 742 | if (priv->bss_mode == NL80211_IFTYPE_ADHOC) { |
| 743 | key_info |= KEY_DEFAULT; |
| 744 | /* Enable unicast bit for WPA-NONE/ADHOC_AES */ |
| 745 | if (!priv->sec_info.wpa2_enabled && |
| 746 | !is_broadcast_ether_addr(mac)) |
| 747 | key_info |= KEY_UNICAST; |
| 748 | } else { |
| 749 | /* Enable default key for WPA/WPA2 */ |
| 750 | if (!priv->wpa_is_gtk_set) |
| 751 | key_info |= KEY_DEFAULT; |
| 752 | } |
| 753 | |
| 754 | km->key_param_set.key_info = cpu_to_le16(key_info); |
| 755 | |
| 756 | if (enc_key->key_len == WLAN_KEY_LEN_CCMP) |
| 757 | return mwifiex_set_aes_key_v2(priv, cmd, enc_key, km); |
| 758 | |
| 759 | if (enc_key->key_len == WLAN_KEY_LEN_TKIP) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 760 | mwifiex_dbg(adapter, INFO, |
| 761 | "%s: Set TKIP Key\n", __func__); |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 762 | if (enc_key->is_rx_seq_valid) |
| 763 | memcpy(km->key_param_set.key_params.tkip.pn, |
| 764 | enc_key->pn, enc_key->pn_len); |
| 765 | km->key_param_set.key_type = KEY_TYPE_ID_TKIP; |
| 766 | km->key_param_set.key_params.tkip.key_len = |
| 767 | cpu_to_le16(enc_key->key_len); |
| 768 | memcpy(km->key_param_set.key_params.tkip.key, |
| 769 | enc_key->key_material, enc_key->key_len); |
| 770 | |
| 771 | len += sizeof(struct mwifiex_tkip_param); |
| 772 | km->key_param_set.len = cpu_to_le16(len); |
| 773 | cmd->size = cpu_to_le16(sizeof(struct mwifiex_ie_types_header) + |
| 774 | len + sizeof(km->action) + S_DS_GEN); |
| 775 | } |
| 776 | |
| 777 | return 0; |
| 778 | } |
| 779 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 780 | /* |
| 781 | * This function prepares command to set/get/reset network key(s). |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 782 | * This function prepares key material command for V1 format. |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 783 | * |
| 784 | * Preparation includes - |
| 785 | * - Setting command ID, action and proper size |
| 786 | * - Setting WEP keys, WAPI keys or WPA keys along with required |
| 787 | * encryption (TKIP, AES) (as required) |
| 788 | * - Ensuring correct endian-ness |
| 789 | */ |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 790 | static int |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 791 | mwifiex_cmd_802_11_key_material_v1(struct mwifiex_private *priv, |
| 792 | struct host_cmd_ds_command *cmd, |
| 793 | u16 cmd_action, u32 cmd_oid, |
| 794 | struct mwifiex_ds_encrypt_key *enc_key) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 795 | { |
| 796 | struct host_cmd_ds_802_11_key_material *key_material = |
| 797 | &cmd->params.key_material; |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 798 | struct host_cmd_tlv_mac_addr *tlv_mac; |
| 799 | u16 key_param_len = 0, cmd_size; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 800 | int ret = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 801 | |
| 802 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_KEY_MATERIAL); |
| 803 | key_material->action = cpu_to_le16(cmd_action); |
| 804 | |
| 805 | if (cmd_action == HostCmd_ACT_GEN_GET) { |
| 806 | cmd->size = |
| 807 | cpu_to_le16(sizeof(key_material->action) + S_DS_GEN); |
| 808 | return ret; |
| 809 | } |
| 810 | |
| 811 | if (!enc_key) { |
| 812 | memset(&key_material->key_param_set, 0, |
| 813 | (NUM_WEP_KEYS * |
| 814 | sizeof(struct mwifiex_ie_type_key_param_set))); |
| 815 | ret = mwifiex_set_keyparamset_wep(priv, |
| 816 | &key_material->key_param_set, |
| 817 | &key_param_len); |
| 818 | cmd->size = cpu_to_le16(key_param_len + |
| 819 | sizeof(key_material->action) + S_DS_GEN); |
| 820 | return ret; |
| 821 | } else |
| 822 | memset(&key_material->key_param_set, 0, |
| 823 | sizeof(struct mwifiex_ie_type_key_param_set)); |
| 824 | if (enc_key->is_wapi_key) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 825 | mwifiex_dbg(priv->adapter, INFO, "info: Set WAPI Key\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 826 | key_material->key_param_set.key_type_id = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 827 | cpu_to_le16(KEY_TYPE_ID_WAPI); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 828 | if (cmd_oid == KEY_INFO_ENABLED) |
| 829 | key_material->key_param_set.key_info = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 830 | cpu_to_le16(KEY_ENABLED); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 831 | else |
| 832 | key_material->key_param_set.key_info = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 833 | cpu_to_le16(!KEY_ENABLED); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 834 | |
| 835 | key_material->key_param_set.key[0] = enc_key->key_index; |
| 836 | if (!priv->sec_info.wapi_key_on) |
| 837 | key_material->key_param_set.key[1] = 1; |
| 838 | else |
| 839 | /* set 0 when re-key */ |
| 840 | key_material->key_param_set.key[1] = 0; |
| 841 | |
Wei Yongjun | a71bf90 | 2012-08-24 13:25:30 +0800 | [diff] [blame] | 842 | if (!is_broadcast_ether_addr(enc_key->mac_addr)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 843 | /* WAPI pairwise key: unicast */ |
| 844 | key_material->key_param_set.key_info |= |
Yogesh Ashok Powar | 6a35a0a | 2011-04-06 16:46:56 -0700 | [diff] [blame] | 845 | cpu_to_le16(KEY_UNICAST); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 846 | } else { /* WAPI group key: multicast */ |
| 847 | key_material->key_param_set.key_info |= |
Yogesh Ashok Powar | 6a35a0a | 2011-04-06 16:46:56 -0700 | [diff] [blame] | 848 | cpu_to_le16(KEY_MCAST); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 849 | priv->sec_info.wapi_key_on = true; |
| 850 | } |
| 851 | |
| 852 | key_material->key_param_set.type = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 853 | cpu_to_le16(TLV_TYPE_KEY_MATERIAL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 854 | key_material->key_param_set.key_len = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 855 | cpu_to_le16(WAPI_KEY_LEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 856 | memcpy(&key_material->key_param_set.key[2], |
| 857 | enc_key->key_material, enc_key->key_len); |
| 858 | memcpy(&key_material->key_param_set.key[2 + enc_key->key_len], |
Ying Luo | 9d7aba6 | 2012-08-03 18:06:12 -0700 | [diff] [blame] | 859 | enc_key->pn, PN_LEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 860 | key_material->key_param_set.length = |
| 861 | cpu_to_le16(WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN); |
| 862 | |
| 863 | key_param_len = (WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN) + |
| 864 | sizeof(struct mwifiex_ie_types_header); |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 865 | cmd->size = cpu_to_le16(sizeof(key_material->action) |
| 866 | + S_DS_GEN + key_param_len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 867 | return ret; |
| 868 | } |
| 869 | if (enc_key->key_len == WLAN_KEY_LEN_CCMP) { |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 870 | if (enc_key->is_igtk_key) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 871 | mwifiex_dbg(priv->adapter, CMD, "cmd: CMAC_AES\n"); |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 872 | key_material->key_param_set.key_type_id = |
| 873 | cpu_to_le16(KEY_TYPE_ID_AES_CMAC); |
| 874 | if (cmd_oid == KEY_INFO_ENABLED) |
| 875 | key_material->key_param_set.key_info = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 876 | cpu_to_le16(KEY_ENABLED); |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 877 | else |
| 878 | key_material->key_param_set.key_info = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 879 | cpu_to_le16(!KEY_ENABLED); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 880 | |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 881 | key_material->key_param_set.key_info |= |
| 882 | cpu_to_le16(KEY_IGTK); |
| 883 | } else { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 884 | mwifiex_dbg(priv->adapter, CMD, "cmd: WPA_AES\n"); |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 885 | key_material->key_param_set.key_type_id = |
| 886 | cpu_to_le16(KEY_TYPE_ID_AES); |
| 887 | if (cmd_oid == KEY_INFO_ENABLED) |
| 888 | key_material->key_param_set.key_info = |
| 889 | cpu_to_le16(KEY_ENABLED); |
| 890 | else |
| 891 | key_material->key_param_set.key_info = |
| 892 | cpu_to_le16(!KEY_ENABLED); |
| 893 | |
| 894 | if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 895 | /* AES pairwise key: unicast */ |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 896 | key_material->key_param_set.key_info |= |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 897 | cpu_to_le16(KEY_UNICAST); |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 898 | else /* AES group key: multicast */ |
| 899 | key_material->key_param_set.key_info |= |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 900 | cpu_to_le16(KEY_MCAST); |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 901 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 902 | } else if (enc_key->key_len == WLAN_KEY_LEN_TKIP) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 903 | mwifiex_dbg(priv->adapter, CMD, "cmd: WPA_TKIP\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 904 | key_material->key_param_set.key_type_id = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 905 | cpu_to_le16(KEY_TYPE_ID_TKIP); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 906 | key_material->key_param_set.key_info = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 907 | cpu_to_le16(KEY_ENABLED); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 908 | |
| 909 | if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST) |
| 910 | /* TKIP pairwise key: unicast */ |
| 911 | key_material->key_param_set.key_info |= |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 912 | cpu_to_le16(KEY_UNICAST); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 913 | else /* TKIP group key: multicast */ |
| 914 | key_material->key_param_set.key_info |= |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 915 | cpu_to_le16(KEY_MCAST); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 916 | } |
| 917 | |
| 918 | if (key_material->key_param_set.key_type_id) { |
| 919 | key_material->key_param_set.type = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 920 | cpu_to_le16(TLV_TYPE_KEY_MATERIAL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 921 | key_material->key_param_set.key_len = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 922 | cpu_to_le16((u16) enc_key->key_len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 923 | memcpy(key_material->key_param_set.key, enc_key->key_material, |
| 924 | enc_key->key_len); |
| 925 | key_material->key_param_set.length = |
| 926 | cpu_to_le16((u16) enc_key->key_len + |
| 927 | KEYPARAMSET_FIXED_LEN); |
| 928 | |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 929 | key_param_len = (u16)(enc_key->key_len + KEYPARAMSET_FIXED_LEN) |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 930 | + sizeof(struct mwifiex_ie_types_header); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 931 | |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 932 | if (le16_to_cpu(key_material->key_param_set.key_type_id) == |
| 933 | KEY_TYPE_ID_AES_CMAC) { |
| 934 | struct mwifiex_cmac_param *param = |
| 935 | (void *)key_material->key_param_set.key; |
| 936 | |
| 937 | memcpy(param->ipn, enc_key->pn, IGTK_PN_LEN); |
| 938 | memcpy(param->key, enc_key->key_material, |
Bing Zhao | 641c869 | 2012-08-08 19:01:52 -0700 | [diff] [blame] | 939 | WLAN_KEY_LEN_AES_CMAC); |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 940 | |
| 941 | key_param_len = sizeof(struct mwifiex_cmac_param); |
| 942 | key_material->key_param_set.key_len = |
| 943 | cpu_to_le16(key_param_len); |
| 944 | key_param_len += KEYPARAMSET_FIXED_LEN; |
| 945 | key_material->key_param_set.length = |
| 946 | cpu_to_le16(key_param_len); |
| 947 | key_param_len += sizeof(struct mwifiex_ie_types_header); |
| 948 | } |
| 949 | |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 950 | cmd->size = cpu_to_le16(sizeof(key_material->action) + S_DS_GEN |
| 951 | + key_param_len); |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 952 | |
Maithili Hinge | 8342bda | 2014-09-30 16:29:38 +0530 | [diff] [blame] | 953 | if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) { |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 954 | tlv_mac = (void *)((u8 *)&key_material->key_param_set + |
| 955 | key_param_len); |
Amitkumar Karwar | 6b21a69 | 2013-07-22 19:17:57 -0700 | [diff] [blame] | 956 | tlv_mac->header.type = |
| 957 | cpu_to_le16(TLV_TYPE_STA_MAC_ADDR); |
| 958 | tlv_mac->header.len = cpu_to_le16(ETH_ALEN); |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 959 | memcpy(tlv_mac->mac_addr, enc_key->mac_addr, ETH_ALEN); |
| 960 | cmd_size = key_param_len + S_DS_GEN + |
| 961 | sizeof(key_material->action) + |
| 962 | sizeof(struct host_cmd_tlv_mac_addr); |
| 963 | } else { |
| 964 | cmd_size = key_param_len + S_DS_GEN + |
| 965 | sizeof(key_material->action); |
| 966 | } |
| 967 | cmd->size = cpu_to_le16(cmd_size); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 968 | } |
| 969 | |
| 970 | return ret; |
| 971 | } |
| 972 | |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 973 | /* Wrapper function for setting network key depending upon FW KEY API version */ |
| 974 | static int |
| 975 | mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv, |
| 976 | struct host_cmd_ds_command *cmd, |
| 977 | u16 cmd_action, u32 cmd_oid, |
| 978 | struct mwifiex_ds_encrypt_key *enc_key) |
| 979 | { |
Amitkumar Karwar | 4b9fede | 2014-08-19 08:24:25 -0400 | [diff] [blame] | 980 | if (priv->adapter->key_api_major_ver == KEY_API_VER_MAJOR_V2) |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 981 | return mwifiex_cmd_802_11_key_material_v2(priv, cmd, |
| 982 | cmd_action, cmd_oid, |
| 983 | enc_key); |
| 984 | |
| 985 | else |
| 986 | return mwifiex_cmd_802_11_key_material_v1(priv, cmd, |
| 987 | cmd_action, cmd_oid, |
| 988 | enc_key); |
| 989 | } |
| 990 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 991 | /* |
| 992 | * This function prepares command to set/get 11d domain information. |
| 993 | * |
| 994 | * Preparation includes - |
| 995 | * - Setting command ID, action and proper size |
| 996 | * - Setting domain information fields (for SET only) |
| 997 | * - Ensuring correct endian-ness |
| 998 | */ |
| 999 | static int mwifiex_cmd_802_11d_domain_info(struct mwifiex_private *priv, |
| 1000 | struct host_cmd_ds_command *cmd, |
| 1001 | u16 cmd_action) |
| 1002 | { |
| 1003 | struct mwifiex_adapter *adapter = priv->adapter; |
| 1004 | struct host_cmd_ds_802_11d_domain_info *domain_info = |
| 1005 | &cmd->params.domain_info; |
| 1006 | struct mwifiex_ietypes_domain_param_set *domain = |
| 1007 | &domain_info->domain; |
| 1008 | u8 no_of_triplet = adapter->domain_reg.no_of_triplet; |
| 1009 | |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1010 | mwifiex_dbg(adapter, INFO, |
| 1011 | "info: 11D: no_of_triplet=0x%x\n", no_of_triplet); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1012 | |
| 1013 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11D_DOMAIN_INFO); |
| 1014 | domain_info->action = cpu_to_le16(cmd_action); |
| 1015 | if (cmd_action == HostCmd_ACT_GEN_GET) { |
| 1016 | cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN); |
| 1017 | return 0; |
| 1018 | } |
| 1019 | |
| 1020 | /* Set domain info fields */ |
| 1021 | domain->header.type = cpu_to_le16(WLAN_EID_COUNTRY); |
| 1022 | memcpy(domain->country_code, adapter->domain_reg.country_code, |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1023 | sizeof(domain->country_code)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1024 | |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1025 | domain->header.len = |
| 1026 | cpu_to_le16((no_of_triplet * |
| 1027 | sizeof(struct ieee80211_country_ie_triplet)) |
| 1028 | + sizeof(domain->country_code)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1029 | |
| 1030 | if (no_of_triplet) { |
| 1031 | memcpy(domain->triplet, adapter->domain_reg.triplet, |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1032 | no_of_triplet * sizeof(struct |
| 1033 | ieee80211_country_ie_triplet)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1034 | |
| 1035 | cmd->size = cpu_to_le16(sizeof(domain_info->action) + |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1036 | le16_to_cpu(domain->header.len) + |
| 1037 | sizeof(struct mwifiex_ie_types_header) |
| 1038 | + S_DS_GEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1039 | } else { |
| 1040 | cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN); |
| 1041 | } |
| 1042 | |
| 1043 | return 0; |
| 1044 | } |
| 1045 | |
| 1046 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1047 | * This function prepares command to set/get IBSS coalescing status. |
| 1048 | * |
| 1049 | * Preparation includes - |
| 1050 | * - Setting command ID, action and proper size |
| 1051 | * - Setting status to enable or disable (for SET only) |
| 1052 | * - Ensuring correct endian-ness |
| 1053 | */ |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1054 | static int mwifiex_cmd_ibss_coalescing_status(struct host_cmd_ds_command *cmd, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 1055 | u16 cmd_action, u16 *enable) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1056 | { |
| 1057 | struct host_cmd_ds_802_11_ibss_status *ibss_coal = |
| 1058 | &(cmd->params.ibss_coalescing); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1059 | |
| 1060 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_IBSS_COALESCING_STATUS); |
| 1061 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_ibss_status) + |
| 1062 | S_DS_GEN); |
| 1063 | cmd->result = 0; |
| 1064 | ibss_coal->action = cpu_to_le16(cmd_action); |
| 1065 | |
| 1066 | switch (cmd_action) { |
| 1067 | case HostCmd_ACT_GEN_SET: |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 1068 | if (enable) |
| 1069 | ibss_coal->enable = cpu_to_le16(*enable); |
Dan Carpenter | a5e5aa6 | 2011-06-24 16:33:35 +0300 | [diff] [blame] | 1070 | else |
| 1071 | ibss_coal->enable = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1072 | break; |
| 1073 | |
| 1074 | /* In other case.. Nothing to do */ |
| 1075 | case HostCmd_ACT_GEN_GET: |
| 1076 | default: |
| 1077 | break; |
| 1078 | } |
| 1079 | |
| 1080 | return 0; |
| 1081 | } |
| 1082 | |
Chin-ran Lo | c2c6c85 | 2015-05-12 00:48:17 +0530 | [diff] [blame] | 1083 | /* This function prepares command buffer to get/set memory location value. |
| 1084 | */ |
| 1085 | static int |
| 1086 | mwifiex_cmd_mem_access(struct host_cmd_ds_command *cmd, u16 cmd_action, |
| 1087 | void *pdata_buf) |
| 1088 | { |
| 1089 | struct mwifiex_ds_mem_rw *mem_rw = (void *)pdata_buf; |
| 1090 | struct host_cmd_ds_mem_access *mem_access = (void *)&cmd->params.mem; |
| 1091 | |
| 1092 | cmd->command = cpu_to_le16(HostCmd_CMD_MEM_ACCESS); |
| 1093 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_mem_access) + |
| 1094 | S_DS_GEN); |
| 1095 | |
| 1096 | mem_access->action = cpu_to_le16(cmd_action); |
| 1097 | mem_access->addr = cpu_to_le32(mem_rw->addr); |
| 1098 | mem_access->value = cpu_to_le32(mem_rw->value); |
| 1099 | |
| 1100 | return 0; |
| 1101 | } |
| 1102 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1103 | /* |
| 1104 | * This function prepares command to set/get register value. |
| 1105 | * |
| 1106 | * Preparation includes - |
| 1107 | * - Setting command ID, action and proper size |
| 1108 | * - Setting register offset (for both GET and SET) and |
| 1109 | * register value (for SET only) |
| 1110 | * - Ensuring correct endian-ness |
| 1111 | * |
| 1112 | * The following type of registers can be accessed with this function - |
| 1113 | * - MAC register |
| 1114 | * - BBP register |
| 1115 | * - RF register |
| 1116 | * - PMIC register |
| 1117 | * - CAU register |
| 1118 | * - EEPROM |
| 1119 | */ |
| 1120 | static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd, |
| 1121 | u16 cmd_action, void *data_buf) |
| 1122 | { |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 1123 | struct mwifiex_ds_reg_rw *reg_rw = data_buf; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1124 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1125 | switch (le16_to_cpu(cmd->command)) { |
| 1126 | case HostCmd_CMD_MAC_REG_ACCESS: |
| 1127 | { |
| 1128 | struct host_cmd_ds_mac_reg_access *mac_reg; |
| 1129 | |
| 1130 | cmd->size = cpu_to_le16(sizeof(*mac_reg) + S_DS_GEN); |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 1131 | mac_reg = &cmd->params.mac_reg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1132 | mac_reg->action = cpu_to_le16(cmd_action); |
| 1133 | mac_reg->offset = |
| 1134 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
| 1135 | mac_reg->value = reg_rw->value; |
| 1136 | break; |
| 1137 | } |
| 1138 | case HostCmd_CMD_BBP_REG_ACCESS: |
| 1139 | { |
| 1140 | struct host_cmd_ds_bbp_reg_access *bbp_reg; |
| 1141 | |
| 1142 | cmd->size = cpu_to_le16(sizeof(*bbp_reg) + S_DS_GEN); |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 1143 | bbp_reg = &cmd->params.bbp_reg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1144 | bbp_reg->action = cpu_to_le16(cmd_action); |
| 1145 | bbp_reg->offset = |
| 1146 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
| 1147 | bbp_reg->value = (u8) le32_to_cpu(reg_rw->value); |
| 1148 | break; |
| 1149 | } |
| 1150 | case HostCmd_CMD_RF_REG_ACCESS: |
| 1151 | { |
| 1152 | struct host_cmd_ds_rf_reg_access *rf_reg; |
| 1153 | |
| 1154 | cmd->size = cpu_to_le16(sizeof(*rf_reg) + S_DS_GEN); |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 1155 | rf_reg = &cmd->params.rf_reg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1156 | rf_reg->action = cpu_to_le16(cmd_action); |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1157 | rf_reg->offset = cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1158 | rf_reg->value = (u8) le32_to_cpu(reg_rw->value); |
| 1159 | break; |
| 1160 | } |
| 1161 | case HostCmd_CMD_PMIC_REG_ACCESS: |
| 1162 | { |
| 1163 | struct host_cmd_ds_pmic_reg_access *pmic_reg; |
| 1164 | |
| 1165 | cmd->size = cpu_to_le16(sizeof(*pmic_reg) + S_DS_GEN); |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 1166 | pmic_reg = &cmd->params.pmic_reg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1167 | pmic_reg->action = cpu_to_le16(cmd_action); |
| 1168 | pmic_reg->offset = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1169 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1170 | pmic_reg->value = (u8) le32_to_cpu(reg_rw->value); |
| 1171 | break; |
| 1172 | } |
| 1173 | case HostCmd_CMD_CAU_REG_ACCESS: |
| 1174 | { |
| 1175 | struct host_cmd_ds_rf_reg_access *cau_reg; |
| 1176 | |
| 1177 | cmd->size = cpu_to_le16(sizeof(*cau_reg) + S_DS_GEN); |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 1178 | cau_reg = &cmd->params.rf_reg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1179 | cau_reg->action = cpu_to_le16(cmd_action); |
| 1180 | cau_reg->offset = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1181 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1182 | cau_reg->value = (u8) le32_to_cpu(reg_rw->value); |
| 1183 | break; |
| 1184 | } |
| 1185 | case HostCmd_CMD_802_11_EEPROM_ACCESS: |
| 1186 | { |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 1187 | struct mwifiex_ds_read_eeprom *rd_eeprom = data_buf; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1188 | struct host_cmd_ds_802_11_eeprom_access *cmd_eeprom = |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1189 | &cmd->params.eeprom; |
| 1190 | |
| 1191 | cmd->size = cpu_to_le16(sizeof(*cmd_eeprom) + S_DS_GEN); |
| 1192 | cmd_eeprom->action = cpu_to_le16(cmd_action); |
| 1193 | cmd_eeprom->offset = rd_eeprom->offset; |
| 1194 | cmd_eeprom->byte_count = rd_eeprom->byte_count; |
| 1195 | cmd_eeprom->value = 0; |
| 1196 | break; |
| 1197 | } |
| 1198 | default: |
| 1199 | return -1; |
| 1200 | } |
| 1201 | |
| 1202 | return 0; |
| 1203 | } |
| 1204 | |
| 1205 | /* |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 1206 | * This function prepares command to set PCI-Express |
| 1207 | * host buffer configuration |
| 1208 | * |
| 1209 | * Preparation includes - |
| 1210 | * - Setting command ID, action and proper size |
| 1211 | * - Setting host buffer configuration |
| 1212 | * - Ensuring correct endian-ness |
| 1213 | */ |
| 1214 | static int |
| 1215 | mwifiex_cmd_pcie_host_spec(struct mwifiex_private *priv, |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1216 | struct host_cmd_ds_command *cmd, u16 action) |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 1217 | { |
| 1218 | struct host_cmd_ds_pcie_details *host_spec = |
| 1219 | &cmd->params.pcie_host_spec; |
| 1220 | struct pcie_service_card *card = priv->adapter->card; |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 1221 | |
| 1222 | cmd->command = cpu_to_le16(HostCmd_CMD_PCIE_DESC_DETAILS); |
| 1223 | cmd->size = cpu_to_le16(sizeof(struct |
| 1224 | host_cmd_ds_pcie_details) + S_DS_GEN); |
| 1225 | cmd->result = 0; |
| 1226 | |
| 1227 | memset(host_spec, 0, sizeof(struct host_cmd_ds_pcie_details)); |
| 1228 | |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1229 | if (action != HostCmd_ACT_GEN_SET) |
| 1230 | return 0; |
| 1231 | |
| 1232 | /* Send the ring base addresses and count to firmware */ |
| 1233 | host_spec->txbd_addr_lo = (u32)(card->txbd_ring_pbase); |
| 1234 | host_spec->txbd_addr_hi = (u32)(((u64)card->txbd_ring_pbase)>>32); |
| 1235 | host_spec->txbd_count = MWIFIEX_MAX_TXRX_BD; |
| 1236 | host_spec->rxbd_addr_lo = (u32)(card->rxbd_ring_pbase); |
| 1237 | host_spec->rxbd_addr_hi = (u32)(((u64)card->rxbd_ring_pbase)>>32); |
| 1238 | host_spec->rxbd_count = MWIFIEX_MAX_TXRX_BD; |
| 1239 | host_spec->evtbd_addr_lo = (u32)(card->evtbd_ring_pbase); |
| 1240 | host_spec->evtbd_addr_hi = (u32)(((u64)card->evtbd_ring_pbase)>>32); |
| 1241 | host_spec->evtbd_count = MWIFIEX_MAX_EVT_BD; |
Avinash Patil | fc33146 | 2013-01-03 21:21:30 -0800 | [diff] [blame] | 1242 | if (card->sleep_cookie_vbase) { |
| 1243 | host_spec->sleep_cookie_addr_lo = |
| 1244 | (u32)(card->sleep_cookie_pbase); |
| 1245 | host_spec->sleep_cookie_addr_hi = |
| 1246 | (u32)(((u64)(card->sleep_cookie_pbase)) >> 32); |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1247 | mwifiex_dbg(priv->adapter, INFO, |
| 1248 | "sleep_cook_lo phy addr: 0x%x\n", |
| 1249 | host_spec->sleep_cookie_addr_lo); |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 1250 | } |
| 1251 | |
| 1252 | return 0; |
| 1253 | } |
| 1254 | |
| 1255 | /* |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 1256 | * This function prepares command for event subscription, configuration |
| 1257 | * and query. Events can be subscribed or unsubscribed. Current subscribed |
| 1258 | * events can be queried. Also, current subscribed events are reported in |
| 1259 | * every FW response. |
| 1260 | */ |
| 1261 | static int |
| 1262 | mwifiex_cmd_802_11_subsc_evt(struct mwifiex_private *priv, |
| 1263 | struct host_cmd_ds_command *cmd, |
| 1264 | struct mwifiex_ds_misc_subsc_evt *subsc_evt_cfg) |
| 1265 | { |
| 1266 | struct host_cmd_ds_802_11_subsc_evt *subsc_evt = &cmd->params.subsc_evt; |
| 1267 | struct mwifiex_ie_types_rssi_threshold *rssi_tlv; |
| 1268 | u16 event_bitmap; |
| 1269 | u8 *pos; |
| 1270 | |
| 1271 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SUBSCRIBE_EVENT); |
| 1272 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_subsc_evt) + |
| 1273 | S_DS_GEN); |
| 1274 | |
| 1275 | subsc_evt->action = cpu_to_le16(subsc_evt_cfg->action); |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1276 | mwifiex_dbg(priv->adapter, CMD, |
| 1277 | "cmd: action: %d\n", subsc_evt_cfg->action); |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 1278 | |
| 1279 | /*For query requests, no configuration TLV structures are to be added.*/ |
| 1280 | if (subsc_evt_cfg->action == HostCmd_ACT_GEN_GET) |
| 1281 | return 0; |
| 1282 | |
| 1283 | subsc_evt->events = cpu_to_le16(subsc_evt_cfg->events); |
| 1284 | |
| 1285 | event_bitmap = subsc_evt_cfg->events; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1286 | mwifiex_dbg(priv->adapter, CMD, "cmd: event bitmap : %16x\n", |
| 1287 | event_bitmap); |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 1288 | |
| 1289 | if (((subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR) || |
| 1290 | (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_SET)) && |
| 1291 | (event_bitmap == 0)) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1292 | mwifiex_dbg(priv->adapter, ERROR, |
| 1293 | "Error: No event specified\t" |
| 1294 | "for bitwise action type\n"); |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 1295 | return -EINVAL; |
| 1296 | } |
| 1297 | |
| 1298 | /* |
| 1299 | * Append TLV structures for each of the specified events for |
| 1300 | * subscribing or re-configuring. This is not required for |
| 1301 | * bitwise unsubscribing request. |
| 1302 | */ |
| 1303 | if (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR) |
| 1304 | return 0; |
| 1305 | |
| 1306 | pos = ((u8 *)subsc_evt) + |
| 1307 | sizeof(struct host_cmd_ds_802_11_subsc_evt); |
| 1308 | |
| 1309 | if (event_bitmap & BITMASK_BCN_RSSI_LOW) { |
| 1310 | rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos; |
| 1311 | |
| 1312 | rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_LOW); |
| 1313 | rssi_tlv->header.len = |
| 1314 | cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) - |
| 1315 | sizeof(struct mwifiex_ie_types_header)); |
| 1316 | rssi_tlv->abs_value = subsc_evt_cfg->bcn_l_rssi_cfg.abs_value; |
| 1317 | rssi_tlv->evt_freq = subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq; |
| 1318 | |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1319 | mwifiex_dbg(priv->adapter, EVENT, |
| 1320 | "Cfg Beacon Low Rssi event,\t" |
| 1321 | "RSSI:-%d dBm, Freq:%d\n", |
| 1322 | subsc_evt_cfg->bcn_l_rssi_cfg.abs_value, |
| 1323 | subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq); |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 1324 | |
| 1325 | pos += sizeof(struct mwifiex_ie_types_rssi_threshold); |
| 1326 | le16_add_cpu(&cmd->size, |
| 1327 | sizeof(struct mwifiex_ie_types_rssi_threshold)); |
| 1328 | } |
| 1329 | |
| 1330 | if (event_bitmap & BITMASK_BCN_RSSI_HIGH) { |
| 1331 | rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos; |
| 1332 | |
| 1333 | rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_HIGH); |
| 1334 | rssi_tlv->header.len = |
| 1335 | cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) - |
| 1336 | sizeof(struct mwifiex_ie_types_header)); |
| 1337 | rssi_tlv->abs_value = subsc_evt_cfg->bcn_h_rssi_cfg.abs_value; |
| 1338 | rssi_tlv->evt_freq = subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq; |
| 1339 | |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1340 | mwifiex_dbg(priv->adapter, EVENT, |
| 1341 | "Cfg Beacon High Rssi event,\t" |
| 1342 | "RSSI:-%d dBm, Freq:%d\n", |
| 1343 | subsc_evt_cfg->bcn_h_rssi_cfg.abs_value, |
| 1344 | subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq); |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 1345 | |
| 1346 | pos += sizeof(struct mwifiex_ie_types_rssi_threshold); |
| 1347 | le16_add_cpu(&cmd->size, |
| 1348 | sizeof(struct mwifiex_ie_types_rssi_threshold)); |
| 1349 | } |
| 1350 | |
| 1351 | return 0; |
| 1352 | } |
| 1353 | |
Amitkumar Karwar | 7da060c | 2013-03-04 16:27:59 -0800 | [diff] [blame] | 1354 | static int |
| 1355 | mwifiex_cmd_append_rpn_expression(struct mwifiex_private *priv, |
| 1356 | struct mwifiex_mef_entry *mef_entry, |
| 1357 | u8 **buffer) |
| 1358 | { |
| 1359 | struct mwifiex_mef_filter *filter = mef_entry->filter; |
| 1360 | int i, byte_len; |
| 1361 | u8 *stack_ptr = *buffer; |
| 1362 | |
Amitkumar Karwar | 3f4e854 | 2013-08-05 18:51:57 -0700 | [diff] [blame] | 1363 | for (i = 0; i < MWIFIEX_MEF_MAX_FILTERS; i++) { |
Amitkumar Karwar | 7da060c | 2013-03-04 16:27:59 -0800 | [diff] [blame] | 1364 | filter = &mef_entry->filter[i]; |
| 1365 | if (!filter->filt_type) |
| 1366 | break; |
| 1367 | *(__le32 *)stack_ptr = cpu_to_le32((u32)filter->repeat); |
| 1368 | stack_ptr += 4; |
| 1369 | *stack_ptr = TYPE_DNUM; |
| 1370 | stack_ptr += 1; |
| 1371 | |
Amitkumar Karwar | 3f4e854 | 2013-08-05 18:51:57 -0700 | [diff] [blame] | 1372 | byte_len = filter->byte_seq[MWIFIEX_MEF_MAX_BYTESEQ]; |
Amitkumar Karwar | 7da060c | 2013-03-04 16:27:59 -0800 | [diff] [blame] | 1373 | memcpy(stack_ptr, filter->byte_seq, byte_len); |
| 1374 | stack_ptr += byte_len; |
| 1375 | *stack_ptr = byte_len; |
| 1376 | stack_ptr += 1; |
| 1377 | *stack_ptr = TYPE_BYTESEQ; |
| 1378 | stack_ptr += 1; |
| 1379 | |
| 1380 | *(__le32 *)stack_ptr = cpu_to_le32((u32)filter->offset); |
| 1381 | stack_ptr += 4; |
| 1382 | *stack_ptr = TYPE_DNUM; |
| 1383 | stack_ptr += 1; |
| 1384 | |
| 1385 | *stack_ptr = filter->filt_type; |
| 1386 | stack_ptr += 1; |
| 1387 | |
| 1388 | if (filter->filt_action) { |
| 1389 | *stack_ptr = filter->filt_action; |
| 1390 | stack_ptr += 1; |
| 1391 | } |
| 1392 | |
| 1393 | if (stack_ptr - *buffer > STACK_NBYTES) |
| 1394 | return -1; |
| 1395 | } |
| 1396 | |
| 1397 | *buffer = stack_ptr; |
| 1398 | return 0; |
| 1399 | } |
| 1400 | |
| 1401 | static int |
| 1402 | mwifiex_cmd_mef_cfg(struct mwifiex_private *priv, |
| 1403 | struct host_cmd_ds_command *cmd, |
| 1404 | struct mwifiex_ds_mef_cfg *mef) |
| 1405 | { |
| 1406 | struct host_cmd_ds_mef_cfg *mef_cfg = &cmd->params.mef_cfg; |
Maithili Hinge | b533be1 | 2015-03-12 00:38:39 -0700 | [diff] [blame] | 1407 | struct mwifiex_fw_mef_entry *mef_entry = NULL; |
Amitkumar Karwar | 7da060c | 2013-03-04 16:27:59 -0800 | [diff] [blame] | 1408 | u8 *pos = (u8 *)mef_cfg; |
Maithili Hinge | b533be1 | 2015-03-12 00:38:39 -0700 | [diff] [blame] | 1409 | u16 i; |
Amitkumar Karwar | 7da060c | 2013-03-04 16:27:59 -0800 | [diff] [blame] | 1410 | |
| 1411 | cmd->command = cpu_to_le16(HostCmd_CMD_MEF_CFG); |
| 1412 | |
| 1413 | mef_cfg->criteria = cpu_to_le32(mef->criteria); |
| 1414 | mef_cfg->num_entries = cpu_to_le16(mef->num_entries); |
| 1415 | pos += sizeof(*mef_cfg); |
Amitkumar Karwar | 7da060c | 2013-03-04 16:27:59 -0800 | [diff] [blame] | 1416 | |
Maithili Hinge | b533be1 | 2015-03-12 00:38:39 -0700 | [diff] [blame] | 1417 | for (i = 0; i < mef->num_entries; i++) { |
| 1418 | mef_entry = (struct mwifiex_fw_mef_entry *)pos; |
| 1419 | mef_entry->mode = mef->mef_entry[i].mode; |
| 1420 | mef_entry->action = mef->mef_entry[i].action; |
| 1421 | pos += sizeof(*mef_cfg->mef_entry); |
Amitkumar Karwar | 7da060c | 2013-03-04 16:27:59 -0800 | [diff] [blame] | 1422 | |
Maithili Hinge | b533be1 | 2015-03-12 00:38:39 -0700 | [diff] [blame] | 1423 | if (mwifiex_cmd_append_rpn_expression(priv, |
| 1424 | &mef->mef_entry[i], &pos)) |
| 1425 | return -1; |
| 1426 | |
| 1427 | mef_entry->exprsize = |
| 1428 | cpu_to_le16(pos - mef_entry->expr); |
| 1429 | } |
Amitkumar Karwar | 7da060c | 2013-03-04 16:27:59 -0800 | [diff] [blame] | 1430 | cmd->size = cpu_to_le16((u16) (pos - (u8 *)mef_cfg) + S_DS_GEN); |
| 1431 | |
| 1432 | return 0; |
| 1433 | } |
| 1434 | |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 1435 | /* This function parse cal data from ASCII to hex */ |
| 1436 | static u32 mwifiex_parse_cal_cfg(u8 *src, size_t len, u8 *dst) |
| 1437 | { |
| 1438 | u8 *s = src, *d = dst; |
| 1439 | |
| 1440 | while (s - src < len) { |
| 1441 | if (*s && (isspace(*s) || *s == '\t')) { |
| 1442 | s++; |
| 1443 | continue; |
| 1444 | } |
| 1445 | if (isxdigit(*s)) { |
| 1446 | *d++ = simple_strtol(s, NULL, 16); |
| 1447 | s += 2; |
| 1448 | } else { |
| 1449 | s++; |
| 1450 | } |
| 1451 | } |
| 1452 | |
| 1453 | return d - dst; |
| 1454 | } |
| 1455 | |
Bing Zhao | 82efa16 | 2013-12-13 18:33:02 -0800 | [diff] [blame] | 1456 | int mwifiex_dnld_dt_cfgdata(struct mwifiex_private *priv, |
| 1457 | struct device_node *node, const char *prefix) |
Bing Zhao | 699b027 | 2013-12-13 18:33:01 -0800 | [diff] [blame] | 1458 | { |
| 1459 | #ifdef CONFIG_OF |
| 1460 | struct property *prop; |
| 1461 | size_t len = strlen(prefix); |
| 1462 | int ret; |
| 1463 | |
| 1464 | /* look for all matching property names */ |
| 1465 | for_each_property_of_node(node, prop) { |
| 1466 | if (len > strlen(prop->name) || |
| 1467 | strncmp(prop->name, prefix, len)) |
| 1468 | continue; |
| 1469 | |
Bing Zhao | 63791cc | 2014-01-08 15:45:56 -0800 | [diff] [blame] | 1470 | /* property header is 6 bytes, data must fit in cmd buffer */ |
| 1471 | if (prop && prop->value && prop->length > 6 && |
| 1472 | prop->length <= MWIFIEX_SIZE_OF_CMD_BUFFER - S_DS_GEN) { |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 1473 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_CFG_DATA, |
| 1474 | HostCmd_ACT_GEN_SET, 0, |
| 1475 | prop, true); |
Bing Zhao | 699b027 | 2013-12-13 18:33:01 -0800 | [diff] [blame] | 1476 | if (ret) |
| 1477 | return ret; |
| 1478 | } |
| 1479 | } |
| 1480 | #endif |
| 1481 | return 0; |
| 1482 | } |
| 1483 | |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 1484 | /* This function prepares command of set_cfg_data. */ |
| 1485 | static int mwifiex_cmd_cfg_data(struct mwifiex_private *priv, |
Bing Zhao | 699b027 | 2013-12-13 18:33:01 -0800 | [diff] [blame] | 1486 | struct host_cmd_ds_command *cmd, void *data_buf) |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 1487 | { |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 1488 | struct mwifiex_adapter *adapter = priv->adapter; |
Bing Zhao | 699b027 | 2013-12-13 18:33:01 -0800 | [diff] [blame] | 1489 | struct property *prop = data_buf; |
Bing Zhao | d39fbc8 | 2013-12-13 18:33:00 -0800 | [diff] [blame] | 1490 | u32 len; |
| 1491 | u8 *data = (u8 *)cmd + S_DS_GEN; |
Bing Zhao | 699b027 | 2013-12-13 18:33:01 -0800 | [diff] [blame] | 1492 | int ret; |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 1493 | |
Bing Zhao | 699b027 | 2013-12-13 18:33:01 -0800 | [diff] [blame] | 1494 | if (prop) { |
| 1495 | len = prop->length; |
| 1496 | ret = of_property_read_u8_array(adapter->dt_node, prop->name, |
| 1497 | data, len); |
| 1498 | if (ret) |
| 1499 | return ret; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1500 | mwifiex_dbg(adapter, INFO, |
| 1501 | "download cfg_data from device tree: %s\n", |
| 1502 | prop->name); |
Bing Zhao | 699b027 | 2013-12-13 18:33:01 -0800 | [diff] [blame] | 1503 | } else if (adapter->cal_data->data && adapter->cal_data->size > 0) { |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 1504 | len = mwifiex_parse_cal_cfg((u8 *)adapter->cal_data->data, |
Bing Zhao | d39fbc8 | 2013-12-13 18:33:00 -0800 | [diff] [blame] | 1505 | adapter->cal_data->size, data); |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1506 | mwifiex_dbg(adapter, INFO, |
| 1507 | "download cfg_data from config file\n"); |
Bing Zhao | 699b027 | 2013-12-13 18:33:01 -0800 | [diff] [blame] | 1508 | } else { |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 1509 | return -1; |
Bing Zhao | 699b027 | 2013-12-13 18:33:01 -0800 | [diff] [blame] | 1510 | } |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 1511 | |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 1512 | cmd->command = cpu_to_le16(HostCmd_CMD_CFG_DATA); |
Bing Zhao | d39fbc8 | 2013-12-13 18:33:00 -0800 | [diff] [blame] | 1513 | cmd->size = cpu_to_le16(S_DS_GEN + len); |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 1514 | |
| 1515 | return 0; |
| 1516 | } |
| 1517 | |
Amitkumar Karwar | 562fc5b | 2013-08-05 18:52:00 -0700 | [diff] [blame] | 1518 | static int |
Avinash Patil | d5b036c | 2015-06-22 19:06:20 +0530 | [diff] [blame] | 1519 | mwifiex_cmd_set_mc_policy(struct mwifiex_private *priv, |
| 1520 | struct host_cmd_ds_command *cmd, |
| 1521 | u16 cmd_action, void *data_buf) |
| 1522 | { |
| 1523 | struct host_cmd_ds_multi_chan_policy *mc_pol = &cmd->params.mc_policy; |
| 1524 | const u16 *drcs_info = data_buf; |
| 1525 | |
| 1526 | mc_pol->action = cpu_to_le16(cmd_action); |
| 1527 | mc_pol->policy = cpu_to_le16(*drcs_info); |
| 1528 | cmd->command = cpu_to_le16(HostCmd_CMD_MC_POLICY); |
| 1529 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_multi_chan_policy) + |
| 1530 | S_DS_GEN); |
| 1531 | return 0; |
| 1532 | } |
| 1533 | |
| 1534 | static int |
Amitkumar Karwar | 562fc5b | 2013-08-05 18:52:00 -0700 | [diff] [blame] | 1535 | mwifiex_cmd_coalesce_cfg(struct mwifiex_private *priv, |
| 1536 | struct host_cmd_ds_command *cmd, |
| 1537 | u16 cmd_action, void *data_buf) |
| 1538 | { |
| 1539 | struct host_cmd_ds_coalesce_cfg *coalesce_cfg = |
| 1540 | &cmd->params.coalesce_cfg; |
| 1541 | struct mwifiex_ds_coalesce_cfg *cfg = data_buf; |
| 1542 | struct coalesce_filt_field_param *param; |
| 1543 | u16 cnt, idx, length; |
| 1544 | struct coalesce_receive_filt_rule *rule; |
| 1545 | |
| 1546 | cmd->command = cpu_to_le16(HostCmd_CMD_COALESCE_CFG); |
| 1547 | cmd->size = cpu_to_le16(S_DS_GEN); |
| 1548 | |
| 1549 | coalesce_cfg->action = cpu_to_le16(cmd_action); |
| 1550 | coalesce_cfg->num_of_rules = cpu_to_le16(cfg->num_of_rules); |
| 1551 | rule = coalesce_cfg->rule; |
| 1552 | |
| 1553 | for (cnt = 0; cnt < cfg->num_of_rules; cnt++) { |
| 1554 | rule->header.type = cpu_to_le16(TLV_TYPE_COALESCE_RULE); |
| 1555 | rule->max_coalescing_delay = |
| 1556 | cpu_to_le16(cfg->rule[cnt].max_coalescing_delay); |
| 1557 | rule->pkt_type = cfg->rule[cnt].pkt_type; |
| 1558 | rule->num_of_fields = cfg->rule[cnt].num_of_fields; |
| 1559 | |
| 1560 | length = 0; |
| 1561 | |
| 1562 | param = rule->params; |
| 1563 | for (idx = 0; idx < cfg->rule[cnt].num_of_fields; idx++) { |
| 1564 | param->operation = cfg->rule[cnt].params[idx].operation; |
| 1565 | param->operand_len = |
| 1566 | cfg->rule[cnt].params[idx].operand_len; |
| 1567 | param->offset = |
| 1568 | cpu_to_le16(cfg->rule[cnt].params[idx].offset); |
| 1569 | memcpy(param->operand_byte_stream, |
| 1570 | cfg->rule[cnt].params[idx].operand_byte_stream, |
| 1571 | param->operand_len); |
| 1572 | |
| 1573 | length += sizeof(struct coalesce_filt_field_param); |
| 1574 | |
| 1575 | param++; |
| 1576 | } |
| 1577 | |
| 1578 | /* Total rule length is sizeof max_coalescing_delay(u16), |
| 1579 | * num_of_fields(u8), pkt_type(u8) and total length of the all |
| 1580 | * params |
| 1581 | */ |
| 1582 | rule->header.len = cpu_to_le16(length + sizeof(u16) + |
| 1583 | sizeof(u8) + sizeof(u8)); |
| 1584 | |
| 1585 | /* Add the rule length to the command size*/ |
| 1586 | le16_add_cpu(&cmd->size, le16_to_cpu(rule->header.len) + |
| 1587 | sizeof(struct mwifiex_ie_types_header)); |
| 1588 | |
| 1589 | rule = (void *)((u8 *)rule->params + length); |
| 1590 | } |
| 1591 | |
| 1592 | /* Add sizeof action, num_of_rules to total command length */ |
| 1593 | le16_add_cpu(&cmd->size, sizeof(u16) + sizeof(u16)); |
| 1594 | |
| 1595 | return 0; |
| 1596 | } |
| 1597 | |
Avinash Patil | 429d90d | 2014-02-07 16:27:34 -0800 | [diff] [blame] | 1598 | static int |
Xinming Hu | 449b8bb | 2015-06-22 19:06:12 +0530 | [diff] [blame] | 1599 | mwifiex_cmd_tdls_config(struct mwifiex_private *priv, |
| 1600 | struct host_cmd_ds_command *cmd, |
| 1601 | u16 cmd_action, void *data_buf) |
| 1602 | { |
| 1603 | struct host_cmd_ds_tdls_config *tdls_config = &cmd->params.tdls_config; |
| 1604 | struct mwifiex_tdls_init_cs_params *config; |
| 1605 | struct mwifiex_tdls_config *init_config; |
| 1606 | u16 len; |
| 1607 | |
| 1608 | cmd->command = cpu_to_le16(HostCmd_CMD_TDLS_CONFIG); |
| 1609 | cmd->size = cpu_to_le16(S_DS_GEN); |
| 1610 | tdls_config->tdls_action = cpu_to_le16(cmd_action); |
| 1611 | le16_add_cpu(&cmd->size, sizeof(tdls_config->tdls_action)); |
| 1612 | |
| 1613 | switch (cmd_action) { |
| 1614 | case ACT_TDLS_CS_ENABLE_CONFIG: |
| 1615 | init_config = data_buf; |
| 1616 | len = sizeof(*init_config); |
| 1617 | memcpy(tdls_config->tdls_data, init_config, len); |
| 1618 | break; |
| 1619 | case ACT_TDLS_CS_INIT: |
| 1620 | config = data_buf; |
| 1621 | len = sizeof(*config); |
| 1622 | memcpy(tdls_config->tdls_data, config, len); |
| 1623 | break; |
| 1624 | case ACT_TDLS_CS_STOP: |
| 1625 | len = sizeof(struct mwifiex_tdls_stop_cs_params); |
| 1626 | memcpy(tdls_config->tdls_data, data_buf, len); |
| 1627 | break; |
| 1628 | case ACT_TDLS_CS_PARAMS: |
| 1629 | len = sizeof(struct mwifiex_tdls_config_cs_params); |
| 1630 | memcpy(tdls_config->tdls_data, data_buf, len); |
| 1631 | break; |
| 1632 | default: |
| 1633 | mwifiex_dbg(priv->adapter, ERROR, |
| 1634 | "Unknown TDLS configuration\n"); |
| 1635 | return -ENOTSUPP; |
| 1636 | } |
| 1637 | |
| 1638 | le16_add_cpu(&cmd->size, len); |
| 1639 | return 0; |
| 1640 | } |
| 1641 | |
| 1642 | static int |
Avinash Patil | 429d90d | 2014-02-07 16:27:34 -0800 | [diff] [blame] | 1643 | mwifiex_cmd_tdls_oper(struct mwifiex_private *priv, |
| 1644 | struct host_cmd_ds_command *cmd, |
| 1645 | void *data_buf) |
| 1646 | { |
| 1647 | struct host_cmd_ds_tdls_oper *tdls_oper = &cmd->params.tdls_oper; |
| 1648 | struct mwifiex_ds_tdls_oper *oper = data_buf; |
| 1649 | struct mwifiex_sta_node *sta_ptr; |
Avinash Patil | 1f4dfd8 | 2014-02-07 16:30:34 -0800 | [diff] [blame] | 1650 | struct host_cmd_tlv_rates *tlv_rates; |
| 1651 | struct mwifiex_ie_types_htcap *ht_capab; |
| 1652 | struct mwifiex_ie_types_qos_info *wmm_qos_info; |
| 1653 | struct mwifiex_ie_types_extcap *extcap; |
Avinash Patil | 5f6d598 | 2014-02-07 16:30:39 -0800 | [diff] [blame] | 1654 | struct mwifiex_ie_types_vhtcap *vht_capab; |
| 1655 | struct mwifiex_ie_types_aid *aid; |
Avinash Patil | d29caf2 | 2014-05-06 22:02:43 -0700 | [diff] [blame] | 1656 | struct mwifiex_ie_types_tdls_idle_timeout *timeout; |
Avinash Patil | 1f4dfd8 | 2014-02-07 16:30:34 -0800 | [diff] [blame] | 1657 | u8 *pos, qos_info; |
| 1658 | u16 config_len = 0; |
| 1659 | struct station_parameters *params = priv->sta_params; |
Avinash Patil | 429d90d | 2014-02-07 16:27:34 -0800 | [diff] [blame] | 1660 | |
| 1661 | cmd->command = cpu_to_le16(HostCmd_CMD_TDLS_OPER); |
| 1662 | cmd->size = cpu_to_le16(S_DS_GEN); |
Avinash Patil | 1f4dfd8 | 2014-02-07 16:30:34 -0800 | [diff] [blame] | 1663 | le16_add_cpu(&cmd->size, sizeof(struct host_cmd_ds_tdls_oper)); |
Avinash Patil | 429d90d | 2014-02-07 16:27:34 -0800 | [diff] [blame] | 1664 | |
| 1665 | tdls_oper->reason = 0; |
| 1666 | memcpy(tdls_oper->peer_mac, oper->peer_mac, ETH_ALEN); |
| 1667 | sta_ptr = mwifiex_get_sta_entry(priv, oper->peer_mac); |
| 1668 | |
Avinash Patil | 1f4dfd8 | 2014-02-07 16:30:34 -0800 | [diff] [blame] | 1669 | pos = (u8 *)tdls_oper + sizeof(struct host_cmd_ds_tdls_oper); |
| 1670 | |
Avinash Patil | 429d90d | 2014-02-07 16:27:34 -0800 | [diff] [blame] | 1671 | switch (oper->tdls_action) { |
| 1672 | case MWIFIEX_TDLS_DISABLE_LINK: |
| 1673 | tdls_oper->tdls_action = cpu_to_le16(ACT_TDLS_DELETE); |
| 1674 | break; |
Avinash Patil | e48e0de | 2014-02-07 16:30:33 -0800 | [diff] [blame] | 1675 | case MWIFIEX_TDLS_CREATE_LINK: |
| 1676 | tdls_oper->tdls_action = cpu_to_le16(ACT_TDLS_CREATE); |
| 1677 | break; |
Avinash Patil | 1f4dfd8 | 2014-02-07 16:30:34 -0800 | [diff] [blame] | 1678 | case MWIFIEX_TDLS_CONFIG_LINK: |
| 1679 | tdls_oper->tdls_action = cpu_to_le16(ACT_TDLS_CONFIG); |
| 1680 | |
| 1681 | if (!params) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1682 | mwifiex_dbg(priv->adapter, ERROR, |
| 1683 | "TDLS config params not available for %pM\n", |
| 1684 | oper->peer_mac); |
Avinash Patil | 1f4dfd8 | 2014-02-07 16:30:34 -0800 | [diff] [blame] | 1685 | return -ENODATA; |
| 1686 | } |
| 1687 | |
| 1688 | *(__le16 *)pos = cpu_to_le16(params->capability); |
| 1689 | config_len += sizeof(params->capability); |
| 1690 | |
| 1691 | qos_info = params->uapsd_queues | (params->max_sp << 5); |
| 1692 | wmm_qos_info = (struct mwifiex_ie_types_qos_info *)(pos + |
| 1693 | config_len); |
| 1694 | wmm_qos_info->header.type = cpu_to_le16(WLAN_EID_QOS_CAPA); |
| 1695 | wmm_qos_info->header.len = cpu_to_le16(sizeof(qos_info)); |
| 1696 | wmm_qos_info->qos_info = qos_info; |
| 1697 | config_len += sizeof(struct mwifiex_ie_types_qos_info); |
| 1698 | |
| 1699 | if (params->ht_capa) { |
| 1700 | ht_capab = (struct mwifiex_ie_types_htcap *)(pos + |
| 1701 | config_len); |
| 1702 | ht_capab->header.type = |
| 1703 | cpu_to_le16(WLAN_EID_HT_CAPABILITY); |
| 1704 | ht_capab->header.len = |
| 1705 | cpu_to_le16(sizeof(struct ieee80211_ht_cap)); |
| 1706 | memcpy(&ht_capab->ht_cap, params->ht_capa, |
| 1707 | sizeof(struct ieee80211_ht_cap)); |
| 1708 | config_len += sizeof(struct mwifiex_ie_types_htcap); |
| 1709 | } |
| 1710 | |
| 1711 | if (params->supported_rates && params->supported_rates_len) { |
| 1712 | tlv_rates = (struct host_cmd_tlv_rates *)(pos + |
| 1713 | config_len); |
| 1714 | tlv_rates->header.type = |
| 1715 | cpu_to_le16(WLAN_EID_SUPP_RATES); |
| 1716 | tlv_rates->header.len = |
| 1717 | cpu_to_le16(params->supported_rates_len); |
| 1718 | memcpy(tlv_rates->rates, params->supported_rates, |
| 1719 | params->supported_rates_len); |
| 1720 | config_len += sizeof(struct host_cmd_tlv_rates) + |
| 1721 | params->supported_rates_len; |
| 1722 | } |
| 1723 | |
| 1724 | if (params->ext_capab && params->ext_capab_len) { |
| 1725 | extcap = (struct mwifiex_ie_types_extcap *)(pos + |
| 1726 | config_len); |
| 1727 | extcap->header.type = |
| 1728 | cpu_to_le16(WLAN_EID_EXT_CAPABILITY); |
| 1729 | extcap->header.len = cpu_to_le16(params->ext_capab_len); |
| 1730 | memcpy(extcap->ext_capab, params->ext_capab, |
| 1731 | params->ext_capab_len); |
| 1732 | config_len += sizeof(struct mwifiex_ie_types_extcap) + |
| 1733 | params->ext_capab_len; |
| 1734 | } |
Avinash Patil | 5f6d598 | 2014-02-07 16:30:39 -0800 | [diff] [blame] | 1735 | if (params->vht_capa) { |
| 1736 | vht_capab = (struct mwifiex_ie_types_vhtcap *)(pos + |
| 1737 | config_len); |
| 1738 | vht_capab->header.type = |
| 1739 | cpu_to_le16(WLAN_EID_VHT_CAPABILITY); |
| 1740 | vht_capab->header.len = |
| 1741 | cpu_to_le16(sizeof(struct ieee80211_vht_cap)); |
| 1742 | memcpy(&vht_capab->vht_cap, params->vht_capa, |
| 1743 | sizeof(struct ieee80211_vht_cap)); |
| 1744 | config_len += sizeof(struct mwifiex_ie_types_vhtcap); |
| 1745 | } |
| 1746 | if (params->aid) { |
| 1747 | aid = (struct mwifiex_ie_types_aid *)(pos + config_len); |
| 1748 | aid->header.type = cpu_to_le16(WLAN_EID_AID); |
| 1749 | aid->header.len = cpu_to_le16(sizeof(params->aid)); |
| 1750 | aid->aid = cpu_to_le16(params->aid); |
| 1751 | config_len += sizeof(struct mwifiex_ie_types_aid); |
| 1752 | } |
Avinash Patil | 1f4dfd8 | 2014-02-07 16:30:34 -0800 | [diff] [blame] | 1753 | |
Avinash Patil | d29caf2 | 2014-05-06 22:02:43 -0700 | [diff] [blame] | 1754 | timeout = (void *)(pos + config_len); |
| 1755 | timeout->header.type = cpu_to_le16(TLV_TYPE_TDLS_IDLE_TIMEOUT); |
| 1756 | timeout->header.len = cpu_to_le16(sizeof(timeout->value)); |
Bing Zhao | 30fa51c | 2014-07-11 20:57:13 -0700 | [diff] [blame] | 1757 | timeout->value = cpu_to_le16(MWIFIEX_TDLS_IDLE_TIMEOUT_IN_SEC); |
Avinash Patil | d29caf2 | 2014-05-06 22:02:43 -0700 | [diff] [blame] | 1758 | config_len += sizeof(struct mwifiex_ie_types_tdls_idle_timeout); |
| 1759 | |
Avinash Patil | 1f4dfd8 | 2014-02-07 16:30:34 -0800 | [diff] [blame] | 1760 | break; |
Avinash Patil | 429d90d | 2014-02-07 16:27:34 -0800 | [diff] [blame] | 1761 | default: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1762 | mwifiex_dbg(priv->adapter, ERROR, "Unknown TDLS operation\n"); |
Avinash Patil | 429d90d | 2014-02-07 16:27:34 -0800 | [diff] [blame] | 1763 | return -ENOTSUPP; |
| 1764 | } |
| 1765 | |
Avinash Patil | 1f4dfd8 | 2014-02-07 16:30:34 -0800 | [diff] [blame] | 1766 | le16_add_cpu(&cmd->size, config_len); |
Avinash Patil | 429d90d | 2014-02-07 16:27:34 -0800 | [diff] [blame] | 1767 | |
| 1768 | return 0; |
| 1769 | } |
Zhaoyang Liu | 92263a8 | 2015-03-13 17:37:58 +0530 | [diff] [blame] | 1770 | |
| 1771 | /* This function prepares command of sdio rx aggr info. */ |
| 1772 | static int mwifiex_cmd_sdio_rx_aggr_cfg(struct host_cmd_ds_command *cmd, |
| 1773 | u16 cmd_action, void *data_buf) |
| 1774 | { |
| 1775 | struct host_cmd_sdio_sp_rx_aggr_cfg *cfg = |
| 1776 | &cmd->params.sdio_rx_aggr_cfg; |
| 1777 | |
| 1778 | cmd->command = cpu_to_le16(HostCmd_CMD_SDIO_SP_RX_AGGR_CFG); |
| 1779 | cmd->size = |
| 1780 | cpu_to_le16(sizeof(struct host_cmd_sdio_sp_rx_aggr_cfg) + |
| 1781 | S_DS_GEN); |
| 1782 | cfg->action = cmd_action; |
| 1783 | if (cmd_action == HostCmd_ACT_GEN_SET) |
| 1784 | cfg->enable = *(u8 *)data_buf; |
| 1785 | |
| 1786 | return 0; |
| 1787 | } |
| 1788 | |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 1789 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1790 | * This function prepares the commands before sending them to the firmware. |
| 1791 | * |
| 1792 | * This is a generic function which calls specific command preparation |
| 1793 | * routines based upon the command number. |
| 1794 | */ |
| 1795 | int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no, |
| 1796 | u16 cmd_action, u32 cmd_oid, |
| 1797 | void *data_buf, void *cmd_buf) |
| 1798 | { |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 1799 | struct host_cmd_ds_command *cmd_ptr = cmd_buf; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1800 | int ret = 0; |
| 1801 | |
| 1802 | /* Prepare command */ |
| 1803 | switch (cmd_no) { |
| 1804 | case HostCmd_CMD_GET_HW_SPEC: |
| 1805 | ret = mwifiex_cmd_get_hw_spec(priv, cmd_ptr); |
| 1806 | break; |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 1807 | case HostCmd_CMD_CFG_DATA: |
Bing Zhao | 699b027 | 2013-12-13 18:33:01 -0800 | [diff] [blame] | 1808 | ret = mwifiex_cmd_cfg_data(priv, cmd_ptr, data_buf); |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 1809 | break; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1810 | case HostCmd_CMD_MAC_CONTROL: |
| 1811 | ret = mwifiex_cmd_mac_control(priv, cmd_ptr, cmd_action, |
| 1812 | data_buf); |
| 1813 | break; |
| 1814 | case HostCmd_CMD_802_11_MAC_ADDRESS: |
| 1815 | ret = mwifiex_cmd_802_11_mac_address(priv, cmd_ptr, |
| 1816 | cmd_action); |
| 1817 | break; |
| 1818 | case HostCmd_CMD_MAC_MULTICAST_ADR: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1819 | ret = mwifiex_cmd_mac_multicast_adr(cmd_ptr, cmd_action, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1820 | data_buf); |
| 1821 | break; |
| 1822 | case HostCmd_CMD_TX_RATE_CFG: |
| 1823 | ret = mwifiex_cmd_tx_rate_cfg(priv, cmd_ptr, cmd_action, |
| 1824 | data_buf); |
| 1825 | break; |
| 1826 | case HostCmd_CMD_TXPWR_CFG: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1827 | ret = mwifiex_cmd_tx_power_cfg(cmd_ptr, cmd_action, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1828 | data_buf); |
| 1829 | break; |
Amitkumar Karwar | caa8984 | 2012-06-27 19:57:57 -0700 | [diff] [blame] | 1830 | case HostCmd_CMD_RF_TX_PWR: |
| 1831 | ret = mwifiex_cmd_rf_tx_power(priv, cmd_ptr, cmd_action, |
| 1832 | data_buf); |
| 1833 | break; |
Amitkumar Karwar | 8a279d5 | 2012-07-02 19:32:33 -0700 | [diff] [blame] | 1834 | case HostCmd_CMD_RF_ANTENNA: |
| 1835 | ret = mwifiex_cmd_rf_antenna(priv, cmd_ptr, cmd_action, |
| 1836 | data_buf); |
| 1837 | break; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1838 | case HostCmd_CMD_802_11_PS_MODE_ENH: |
| 1839 | ret = mwifiex_cmd_enh_power_mode(priv, cmd_ptr, cmd_action, |
| 1840 | (uint16_t)cmd_oid, data_buf); |
| 1841 | break; |
| 1842 | case HostCmd_CMD_802_11_HS_CFG_ENH: |
| 1843 | ret = mwifiex_cmd_802_11_hs_cfg(priv, cmd_ptr, cmd_action, |
| 1844 | (struct mwifiex_hs_config_param *) data_buf); |
| 1845 | break; |
| 1846 | case HostCmd_CMD_802_11_SCAN: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1847 | ret = mwifiex_cmd_802_11_scan(cmd_ptr, data_buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1848 | break; |
| 1849 | case HostCmd_CMD_802_11_BG_SCAN_QUERY: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1850 | ret = mwifiex_cmd_802_11_bg_scan_query(cmd_ptr); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1851 | break; |
| 1852 | case HostCmd_CMD_802_11_ASSOCIATE: |
| 1853 | ret = mwifiex_cmd_802_11_associate(priv, cmd_ptr, data_buf); |
| 1854 | break; |
| 1855 | case HostCmd_CMD_802_11_DEAUTHENTICATE: |
| 1856 | ret = mwifiex_cmd_802_11_deauthenticate(priv, cmd_ptr, |
| 1857 | data_buf); |
| 1858 | break; |
| 1859 | case HostCmd_CMD_802_11_AD_HOC_START: |
| 1860 | ret = mwifiex_cmd_802_11_ad_hoc_start(priv, cmd_ptr, |
| 1861 | data_buf); |
| 1862 | break; |
| 1863 | case HostCmd_CMD_802_11_GET_LOG: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1864 | ret = mwifiex_cmd_802_11_get_log(cmd_ptr); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1865 | break; |
| 1866 | case HostCmd_CMD_802_11_AD_HOC_JOIN: |
| 1867 | ret = mwifiex_cmd_802_11_ad_hoc_join(priv, cmd_ptr, |
| 1868 | data_buf); |
| 1869 | break; |
| 1870 | case HostCmd_CMD_802_11_AD_HOC_STOP: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1871 | ret = mwifiex_cmd_802_11_ad_hoc_stop(cmd_ptr); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1872 | break; |
| 1873 | case HostCmd_CMD_RSSI_INFO: |
| 1874 | ret = mwifiex_cmd_802_11_rssi_info(priv, cmd_ptr, cmd_action); |
| 1875 | break; |
| 1876 | case HostCmd_CMD_802_11_SNMP_MIB: |
| 1877 | ret = mwifiex_cmd_802_11_snmp_mib(priv, cmd_ptr, cmd_action, |
| 1878 | cmd_oid, data_buf); |
| 1879 | break; |
| 1880 | case HostCmd_CMD_802_11_TX_RATE_QUERY: |
| 1881 | cmd_ptr->command = |
| 1882 | cpu_to_le16(HostCmd_CMD_802_11_TX_RATE_QUERY); |
| 1883 | cmd_ptr->size = |
| 1884 | cpu_to_le16(sizeof(struct host_cmd_ds_tx_rate_query) + |
| 1885 | S_DS_GEN); |
| 1886 | priv->tx_rate = 0; |
| 1887 | ret = 0; |
| 1888 | break; |
| 1889 | case HostCmd_CMD_VERSION_EXT: |
| 1890 | cmd_ptr->command = cpu_to_le16(cmd_no); |
| 1891 | cmd_ptr->params.verext.version_str_sel = |
| 1892 | (u8) (*((u32 *) data_buf)); |
| 1893 | memcpy(&cmd_ptr->params, data_buf, |
| 1894 | sizeof(struct host_cmd_ds_version_ext)); |
| 1895 | cmd_ptr->size = |
| 1896 | cpu_to_le16(sizeof(struct host_cmd_ds_version_ext) + |
| 1897 | S_DS_GEN); |
| 1898 | ret = 0; |
| 1899 | break; |
Stone Piao | 3cec687 | 2012-09-25 20:23:34 -0700 | [diff] [blame] | 1900 | case HostCmd_CMD_MGMT_FRAME_REG: |
| 1901 | cmd_ptr->command = cpu_to_le16(cmd_no); |
| 1902 | cmd_ptr->params.reg_mask.action = cpu_to_le16(cmd_action); |
| 1903 | cmd_ptr->params.reg_mask.mask = cpu_to_le32(*(u32 *)data_buf); |
| 1904 | cmd_ptr->size = |
| 1905 | cpu_to_le16(sizeof(struct host_cmd_ds_mgmt_frame_reg) + |
| 1906 | S_DS_GEN); |
| 1907 | ret = 0; |
| 1908 | break; |
Stone Piao | 7feb4c4 | 2012-09-25 20:23:36 -0700 | [diff] [blame] | 1909 | case HostCmd_CMD_REMAIN_ON_CHAN: |
| 1910 | cmd_ptr->command = cpu_to_le16(cmd_no); |
| 1911 | memcpy(&cmd_ptr->params, data_buf, |
| 1912 | sizeof(struct host_cmd_ds_remain_on_chan)); |
| 1913 | cmd_ptr->size = |
| 1914 | cpu_to_le16(sizeof(struct host_cmd_ds_remain_on_chan) + |
| 1915 | S_DS_GEN); |
| 1916 | break; |
Yogesh Ashok Powar | 83c78da | 2013-03-18 20:06:03 -0700 | [diff] [blame] | 1917 | case HostCmd_CMD_11AC_CFG: |
| 1918 | ret = mwifiex_cmd_11ac_cfg(priv, cmd_ptr, cmd_action, data_buf); |
| 1919 | break; |
Stone Piao | e1a2b7a | 2012-09-25 20:23:41 -0700 | [diff] [blame] | 1920 | case HostCmd_CMD_P2P_MODE_CFG: |
| 1921 | cmd_ptr->command = cpu_to_le16(cmd_no); |
| 1922 | cmd_ptr->params.mode_cfg.action = cpu_to_le16(cmd_action); |
| 1923 | cmd_ptr->params.mode_cfg.mode = cpu_to_le16(*(u16 *)data_buf); |
| 1924 | cmd_ptr->size = |
| 1925 | cpu_to_le16(sizeof(struct host_cmd_ds_p2p_mode_cfg) + |
| 1926 | S_DS_GEN); |
| 1927 | break; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1928 | case HostCmd_CMD_FUNC_INIT: |
| 1929 | if (priv->adapter->hw_status == MWIFIEX_HW_STATUS_RESET) |
| 1930 | priv->adapter->hw_status = MWIFIEX_HW_STATUS_READY; |
| 1931 | cmd_ptr->command = cpu_to_le16(cmd_no); |
| 1932 | cmd_ptr->size = cpu_to_le16(S_DS_GEN); |
| 1933 | break; |
| 1934 | case HostCmd_CMD_FUNC_SHUTDOWN: |
| 1935 | priv->adapter->hw_status = MWIFIEX_HW_STATUS_RESET; |
| 1936 | cmd_ptr->command = cpu_to_le16(cmd_no); |
| 1937 | cmd_ptr->size = cpu_to_le16(S_DS_GEN); |
| 1938 | break; |
| 1939 | case HostCmd_CMD_11N_ADDBA_REQ: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1940 | ret = mwifiex_cmd_11n_addba_req(cmd_ptr, data_buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1941 | break; |
| 1942 | case HostCmd_CMD_11N_DELBA: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1943 | ret = mwifiex_cmd_11n_delba(cmd_ptr, data_buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1944 | break; |
| 1945 | case HostCmd_CMD_11N_ADDBA_RSP: |
| 1946 | ret = mwifiex_cmd_11n_addba_rsp_gen(priv, cmd_ptr, data_buf); |
| 1947 | break; |
| 1948 | case HostCmd_CMD_802_11_KEY_MATERIAL: |
| 1949 | ret = mwifiex_cmd_802_11_key_material(priv, cmd_ptr, |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1950 | cmd_action, cmd_oid, |
| 1951 | data_buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1952 | break; |
| 1953 | case HostCmd_CMD_802_11D_DOMAIN_INFO: |
| 1954 | ret = mwifiex_cmd_802_11d_domain_info(priv, cmd_ptr, |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1955 | cmd_action); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1956 | break; |
| 1957 | case HostCmd_CMD_RECONFIGURE_TX_BUFF: |
| 1958 | ret = mwifiex_cmd_recfg_tx_buf(priv, cmd_ptr, cmd_action, |
| 1959 | data_buf); |
| 1960 | break; |
| 1961 | case HostCmd_CMD_AMSDU_AGGR_CTRL: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1962 | ret = mwifiex_cmd_amsdu_aggr_ctrl(cmd_ptr, cmd_action, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1963 | data_buf); |
| 1964 | break; |
| 1965 | case HostCmd_CMD_11N_CFG: |
Yogesh Ashok Powar | a5f3905 | 2013-02-15 21:44:30 -0800 | [diff] [blame] | 1966 | ret = mwifiex_cmd_11n_cfg(priv, cmd_ptr, cmd_action, data_buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1967 | break; |
| 1968 | case HostCmd_CMD_WMM_GET_STATUS: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1969 | mwifiex_dbg(priv->adapter, CMD, |
| 1970 | "cmd: WMM: WMM_GET_STATUS cmd sent\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1971 | cmd_ptr->command = cpu_to_le16(HostCmd_CMD_WMM_GET_STATUS); |
| 1972 | cmd_ptr->size = |
| 1973 | cpu_to_le16(sizeof(struct host_cmd_ds_wmm_get_status) + |
| 1974 | S_DS_GEN); |
| 1975 | ret = 0; |
| 1976 | break; |
| 1977 | case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1978 | ret = mwifiex_cmd_ibss_coalescing_status(cmd_ptr, cmd_action, |
| 1979 | data_buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1980 | break; |
Amitkumar Karwar | 21f58d20 | 2014-02-11 18:39:56 -0800 | [diff] [blame] | 1981 | case HostCmd_CMD_802_11_SCAN_EXT: |
| 1982 | ret = mwifiex_cmd_802_11_scan_ext(priv, cmd_ptr, data_buf); |
| 1983 | break; |
Chin-ran Lo | c2c6c85 | 2015-05-12 00:48:17 +0530 | [diff] [blame] | 1984 | case HostCmd_CMD_MEM_ACCESS: |
| 1985 | ret = mwifiex_cmd_mem_access(cmd_ptr, cmd_action, data_buf); |
| 1986 | break; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1987 | case HostCmd_CMD_MAC_REG_ACCESS: |
| 1988 | case HostCmd_CMD_BBP_REG_ACCESS: |
| 1989 | case HostCmd_CMD_RF_REG_ACCESS: |
| 1990 | case HostCmd_CMD_PMIC_REG_ACCESS: |
| 1991 | case HostCmd_CMD_CAU_REG_ACCESS: |
| 1992 | case HostCmd_CMD_802_11_EEPROM_ACCESS: |
| 1993 | ret = mwifiex_cmd_reg_access(cmd_ptr, cmd_action, data_buf); |
| 1994 | break; |
| 1995 | case HostCmd_CMD_SET_BSS_MODE: |
| 1996 | cmd_ptr->command = cpu_to_le16(cmd_no); |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 1997 | if (priv->bss_mode == NL80211_IFTYPE_ADHOC) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1998 | cmd_ptr->params.bss_mode.con_type = |
| 1999 | CONNECTION_TYPE_ADHOC; |
Aniket Nagarnaik | ae86c58 | 2015-07-02 06:07:02 -0700 | [diff] [blame] | 2000 | else if (priv->bss_mode == NL80211_IFTYPE_STATION || |
| 2001 | priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2002 | cmd_ptr->params.bss_mode.con_type = |
| 2003 | CONNECTION_TYPE_INFRA; |
Aniket Nagarnaik | ae86c58 | 2015-07-02 06:07:02 -0700 | [diff] [blame] | 2004 | else if (priv->bss_mode == NL80211_IFTYPE_AP || |
| 2005 | priv->bss_mode == NL80211_IFTYPE_P2P_GO) |
Stone Piao | 9197ab9 | 2012-09-25 20:23:42 -0700 | [diff] [blame] | 2006 | cmd_ptr->params.bss_mode.con_type = CONNECTION_TYPE_AP; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2007 | cmd_ptr->size = cpu_to_le16(sizeof(struct |
| 2008 | host_cmd_ds_set_bss_mode) + S_DS_GEN); |
| 2009 | ret = 0; |
| 2010 | break; |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 2011 | case HostCmd_CMD_PCIE_DESC_DETAILS: |
| 2012 | ret = mwifiex_cmd_pcie_host_spec(priv, cmd_ptr, cmd_action); |
| 2013 | break; |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 2014 | case HostCmd_CMD_802_11_SUBSCRIBE_EVENT: |
| 2015 | ret = mwifiex_cmd_802_11_subsc_evt(priv, cmd_ptr, data_buf); |
| 2016 | break; |
Amitkumar Karwar | 7da060c | 2013-03-04 16:27:59 -0800 | [diff] [blame] | 2017 | case HostCmd_CMD_MEF_CFG: |
| 2018 | ret = mwifiex_cmd_mef_cfg(priv, cmd_ptr, data_buf); |
| 2019 | break; |
Amitkumar Karwar | 562fc5b | 2013-08-05 18:52:00 -0700 | [diff] [blame] | 2020 | case HostCmd_CMD_COALESCE_CFG: |
| 2021 | ret = mwifiex_cmd_coalesce_cfg(priv, cmd_ptr, cmd_action, |
| 2022 | data_buf); |
| 2023 | break; |
Avinash Patil | 429d90d | 2014-02-07 16:27:34 -0800 | [diff] [blame] | 2024 | case HostCmd_CMD_TDLS_OPER: |
| 2025 | ret = mwifiex_cmd_tdls_oper(priv, cmd_ptr, data_buf); |
| 2026 | break; |
Xinming Hu | 449b8bb | 2015-06-22 19:06:12 +0530 | [diff] [blame] | 2027 | case HostCmd_CMD_TDLS_CONFIG: |
| 2028 | ret = mwifiex_cmd_tdls_config(priv, cmd_ptr, cmd_action, |
| 2029 | data_buf); |
| 2030 | break; |
Avinash Patil | 85afb18 | 2015-01-28 15:54:21 +0530 | [diff] [blame] | 2031 | case HostCmd_CMD_CHAN_REPORT_REQUEST: |
| 2032 | ret = mwifiex_cmd_issue_chan_report_request(priv, cmd_ptr, |
| 2033 | data_buf); |
| 2034 | break; |
Zhaoyang Liu | 92263a8 | 2015-03-13 17:37:58 +0530 | [diff] [blame] | 2035 | case HostCmd_CMD_SDIO_SP_RX_AGGR_CFG: |
| 2036 | ret = mwifiex_cmd_sdio_rx_aggr_cfg(cmd_ptr, cmd_action, |
| 2037 | data_buf); |
| 2038 | break; |
Avinash Patil | d5b036c | 2015-06-22 19:06:20 +0530 | [diff] [blame] | 2039 | case HostCmd_CMD_MC_POLICY: |
| 2040 | ret = mwifiex_cmd_set_mc_policy(priv, cmd_ptr, cmd_action, |
| 2041 | data_buf); |
| 2042 | break; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2043 | default: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 2044 | mwifiex_dbg(priv->adapter, ERROR, |
| 2045 | "PREP_CMD: unknown cmd- %#x\n", cmd_no); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2046 | ret = -1; |
| 2047 | break; |
| 2048 | } |
| 2049 | return ret; |
| 2050 | } |
| 2051 | |
| 2052 | /* |
| 2053 | * This function issues commands to initialize firmware. |
| 2054 | * |
| 2055 | * This is called after firmware download to bring the card to |
| 2056 | * working state. |
Avinash Patil | 1247cc1 | 2015-01-28 15:42:02 +0530 | [diff] [blame] | 2057 | * Function is also called during reinitialization of virtual |
| 2058 | * interfaces. |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2059 | * |
| 2060 | * The following commands are issued sequentially - |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 2061 | * - Set PCI-Express host buffer configuration (PCIE only) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2062 | * - Function init (for first interface only) |
| 2063 | * - Read MAC address (for first interface only) |
| 2064 | * - Reconfigure Tx buffer size (for first interface only) |
| 2065 | * - Enable auto deep sleep (for first interface only) |
| 2066 | * - Get Tx rate |
| 2067 | * - Get Tx power |
| 2068 | * - Set IBSS coalescing status |
| 2069 | * - Set AMSDU aggregation control |
| 2070 | * - Set 11d control |
| 2071 | * - Set MAC control (this must be the last command to initialize firmware) |
| 2072 | */ |
Avinash Patil | 1247cc1 | 2015-01-28 15:42:02 +0530 | [diff] [blame] | 2073 | int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2074 | { |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 2075 | struct mwifiex_adapter *adapter = priv->adapter; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 2076 | int ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2077 | u16 enable = true; |
| 2078 | struct mwifiex_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl; |
| 2079 | struct mwifiex_ds_auto_ds auto_ds; |
| 2080 | enum state_11d_t state_11d; |
Amitkumar Karwar | cd27bc3 | 2011-07-08 20:40:30 -0700 | [diff] [blame] | 2081 | struct mwifiex_ds_11n_tx_cfg tx_cfg; |
Zhaoyang Liu | 92263a8 | 2015-03-13 17:37:58 +0530 | [diff] [blame] | 2082 | u8 sdio_sp_rx_aggr_enable; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2083 | |
| 2084 | if (first_sta) { |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 2085 | if (priv->adapter->iface_type == MWIFIEX_PCIE) { |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 2086 | ret = mwifiex_send_cmd(priv, |
| 2087 | HostCmd_CMD_PCIE_DESC_DETAILS, |
| 2088 | HostCmd_ACT_GEN_SET, 0, NULL, |
| 2089 | true); |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 2090 | if (ret) |
| 2091 | return -1; |
| 2092 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2093 | |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 2094 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_FUNC_INIT, |
| 2095 | HostCmd_ACT_GEN_SET, 0, NULL, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2096 | if (ret) |
| 2097 | return -1; |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 2098 | |
Bing Zhao | 699b027 | 2013-12-13 18:33:01 -0800 | [diff] [blame] | 2099 | /* Download calibration data to firmware. |
| 2100 | * The cal-data can be read from device tree and/or |
| 2101 | * a configuration file and downloaded to firmware. |
| 2102 | */ |
| 2103 | adapter->dt_node = |
| 2104 | of_find_node_by_name(NULL, "marvell_cfgdata"); |
| 2105 | if (adapter->dt_node) { |
| 2106 | ret = mwifiex_dnld_dt_cfgdata(priv, adapter->dt_node, |
| 2107 | "marvell,caldata"); |
| 2108 | if (ret) |
| 2109 | return -1; |
| 2110 | } |
| 2111 | |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 2112 | if (adapter->cal_data) { |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 2113 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_CFG_DATA, |
| 2114 | HostCmd_ACT_GEN_SET, 0, NULL, |
| 2115 | true); |
Amitkumar Karwar | 388ec38 | 2013-05-17 17:50:25 -0700 | [diff] [blame] | 2116 | if (ret) |
| 2117 | return -1; |
| 2118 | } |
| 2119 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2120 | /* Read MAC address from HW */ |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 2121 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_GET_HW_SPEC, |
| 2122 | HostCmd_ACT_GEN_GET, 0, NULL, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2123 | if (ret) |
| 2124 | return -1; |
| 2125 | |
Zhaoyang Liu | 92263a8 | 2015-03-13 17:37:58 +0530 | [diff] [blame] | 2126 | /** Set SDIO Single Port RX Aggr Info */ |
| 2127 | if (priv->adapter->iface_type == MWIFIEX_SDIO && |
Xinming Hu | 9a9053c | 2015-09-18 06:32:06 -0700 | [diff] [blame^] | 2128 | ISSUPP_SDIO_SPA_ENABLED(priv->adapter->fw_cap_info) && |
| 2129 | !priv->adapter->host_disable_sdio_rx_aggr) { |
Zhaoyang Liu | 92263a8 | 2015-03-13 17:37:58 +0530 | [diff] [blame] | 2130 | sdio_sp_rx_aggr_enable = true; |
| 2131 | ret = mwifiex_send_cmd(priv, |
| 2132 | HostCmd_CMD_SDIO_SP_RX_AGGR_CFG, |
| 2133 | HostCmd_ACT_GEN_SET, 0, |
| 2134 | &sdio_sp_rx_aggr_enable, |
| 2135 | true); |
| 2136 | if (ret) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 2137 | mwifiex_dbg(priv->adapter, ERROR, |
| 2138 | "error while enabling SP aggregation..disable it"); |
Zhaoyang Liu | 92263a8 | 2015-03-13 17:37:58 +0530 | [diff] [blame] | 2139 | adapter->sdio_rx_aggr_enable = false; |
| 2140 | } |
| 2141 | } |
| 2142 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2143 | /* Reconfigure tx buf size */ |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 2144 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_RECONFIGURE_TX_BUFF, |
| 2145 | HostCmd_ACT_GEN_SET, 0, |
| 2146 | &priv->adapter->tx_buf_size, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2147 | if (ret) |
| 2148 | return -1; |
| 2149 | |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 2150 | if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { |
| 2151 | /* Enable IEEE PS by default */ |
| 2152 | priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP; |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 2153 | ret = mwifiex_send_cmd(priv, |
| 2154 | HostCmd_CMD_802_11_PS_MODE_ENH, |
| 2155 | EN_AUTO_PS, BITMAP_STA_PS, NULL, |
| 2156 | true); |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 2157 | if (ret) |
| 2158 | return -1; |
| 2159 | } |
Avinash Patil | d5b036c | 2015-06-22 19:06:20 +0530 | [diff] [blame] | 2160 | |
Avinash Patil | de9e993 | 2015-06-22 19:06:21 +0530 | [diff] [blame] | 2161 | if (drcs) { |
| 2162 | adapter->drcs_enabled = true; |
| 2163 | if (ISSUPP_DRCS_ENABLED(adapter->fw_cap_info)) |
| 2164 | ret = mwifiex_send_cmd(priv, |
| 2165 | HostCmd_CMD_MC_POLICY, |
| 2166 | HostCmd_ACT_GEN_SET, 0, |
| 2167 | &adapter->drcs_enabled, |
| 2168 | true); |
Avinash Patil | d5b036c | 2015-06-22 19:06:20 +0530 | [diff] [blame] | 2169 | if (ret) |
| 2170 | return -1; |
Avinash Patil | de9e993 | 2015-06-22 19:06:21 +0530 | [diff] [blame] | 2171 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2172 | } |
| 2173 | |
| 2174 | /* get tx rate */ |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 2175 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_TX_RATE_CFG, |
| 2176 | HostCmd_ACT_GEN_GET, 0, NULL, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2177 | if (ret) |
| 2178 | return -1; |
| 2179 | priv->data_rate = 0; |
| 2180 | |
| 2181 | /* get tx power */ |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 2182 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_RF_TX_PWR, |
| 2183 | HostCmd_ACT_GEN_GET, 0, NULL, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2184 | if (ret) |
| 2185 | return -1; |
| 2186 | |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 2187 | if (priv->bss_type == MWIFIEX_BSS_TYPE_STA) { |
| 2188 | /* set ibss coalescing_status */ |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 2189 | ret = mwifiex_send_cmd( |
| 2190 | priv, |
| 2191 | HostCmd_CMD_802_11_IBSS_COALESCING_STATUS, |
| 2192 | HostCmd_ACT_GEN_SET, 0, &enable, true); |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 2193 | if (ret) |
| 2194 | return -1; |
| 2195 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2196 | |
| 2197 | memset(&amsdu_aggr_ctrl, 0, sizeof(amsdu_aggr_ctrl)); |
| 2198 | amsdu_aggr_ctrl.enable = true; |
| 2199 | /* Send request to firmware */ |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 2200 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_AMSDU_AGGR_CTRL, |
| 2201 | HostCmd_ACT_GEN_SET, 0, |
| 2202 | &amsdu_aggr_ctrl, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2203 | if (ret) |
| 2204 | return -1; |
| 2205 | /* MAC Control must be the last command in init_fw */ |
| 2206 | /* set MAC Control */ |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 2207 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_MAC_CONTROL, |
| 2208 | HostCmd_ACT_GEN_SET, 0, |
| 2209 | &priv->curr_pkt_filter, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2210 | if (ret) |
| 2211 | return -1; |
| 2212 | |
Avinash Patil | 0b4155d | 2014-12-23 19:14:12 +0530 | [diff] [blame] | 2213 | if (!disable_auto_ds && |
| 2214 | first_sta && priv->adapter->iface_type != MWIFIEX_USB && |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 2215 | priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2216 | /* Enable auto deep sleep */ |
| 2217 | auto_ds.auto_ds = DEEP_SLEEP_ON; |
| 2218 | auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME; |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 2219 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH, |
| 2220 | EN_AUTO_PS, BITMAP_AUTO_DS, |
| 2221 | &auto_ds, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2222 | if (ret) |
| 2223 | return -1; |
| 2224 | } |
| 2225 | |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 2226 | if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { |
| 2227 | /* Send cmd to FW to enable/disable 11D function */ |
| 2228 | state_11d = ENABLE_11D; |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 2229 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_SNMP_MIB, |
| 2230 | HostCmd_ACT_GEN_SET, DOT11D_I, |
| 2231 | &state_11d, true); |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 2232 | if (ret) |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 2233 | mwifiex_dbg(priv->adapter, ERROR, |
| 2234 | "11D: failed to enable 11D\n"); |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 2235 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2236 | |
Amitkumar Karwar | cd27bc3 | 2011-07-08 20:40:30 -0700 | [diff] [blame] | 2237 | /* Send cmd to FW to configure 11n specific configuration |
| 2238 | * (Short GI, Channel BW, Green field support etc.) for transmit |
| 2239 | */ |
| 2240 | tx_cfg.tx_htcap = MWIFIEX_FW_DEF_HTTXCFG; |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 2241 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_11N_CFG, |
| 2242 | HostCmd_ACT_GEN_SET, 0, &tx_cfg, true); |
Amitkumar Karwar | cd27bc3 | 2011-07-08 20:40:30 -0700 | [diff] [blame] | 2243 | |
Avinash Patil | 1247cc1 | 2015-01-28 15:42:02 +0530 | [diff] [blame] | 2244 | if (init) { |
| 2245 | /* set last_init_cmd before sending the command */ |
| 2246 | priv->adapter->last_init_cmd = HostCmd_CMD_11N_CFG; |
| 2247 | ret = -EINPROGRESS; |
| 2248 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 2249 | |
| 2250 | return ret; |
| 2251 | } |