Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Wireless LAN device driver: station command handling |
| 3 | * |
| 4 | * Copyright (C) 2011, Marvell International Ltd. |
| 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" |
| 27 | |
| 28 | /* |
| 29 | * This function prepares command to set/get RSSI information. |
| 30 | * |
| 31 | * Preparation includes - |
| 32 | * - Setting command ID, action and proper size |
| 33 | * - Setting data/beacon average factors |
| 34 | * - Resetting SNR/NF/RSSI values in private structure |
| 35 | * - Ensuring correct endian-ness |
| 36 | */ |
| 37 | static int |
| 38 | mwifiex_cmd_802_11_rssi_info(struct mwifiex_private *priv, |
| 39 | struct host_cmd_ds_command *cmd, u16 cmd_action) |
| 40 | { |
| 41 | cmd->command = cpu_to_le16(HostCmd_CMD_RSSI_INFO); |
| 42 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_rssi_info) + |
| 43 | S_DS_GEN); |
| 44 | cmd->params.rssi_info.action = cpu_to_le16(cmd_action); |
| 45 | cmd->params.rssi_info.ndata = cpu_to_le16(priv->data_avg_factor); |
| 46 | cmd->params.rssi_info.nbcn = cpu_to_le16(priv->bcn_avg_factor); |
| 47 | |
| 48 | /* Reset SNR/NF/RSSI values in private structure */ |
| 49 | priv->data_rssi_last = 0; |
| 50 | priv->data_nf_last = 0; |
| 51 | priv->data_rssi_avg = 0; |
| 52 | priv->data_nf_avg = 0; |
| 53 | priv->bcn_rssi_last = 0; |
| 54 | priv->bcn_nf_last = 0; |
| 55 | priv->bcn_rssi_avg = 0; |
| 56 | priv->bcn_nf_avg = 0; |
| 57 | |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | /* |
| 62 | * This function prepares command to set MAC control. |
| 63 | * |
| 64 | * Preparation includes - |
| 65 | * - Setting command ID, action and proper size |
| 66 | * - Ensuring correct endian-ness |
| 67 | */ |
| 68 | static int mwifiex_cmd_mac_control(struct mwifiex_private *priv, |
| 69 | struct host_cmd_ds_command *cmd, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 70 | u16 cmd_action, u16 *action) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 71 | { |
| 72 | struct host_cmd_ds_mac_control *mac_ctrl = &cmd->params.mac_ctrl; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 73 | |
| 74 | if (cmd_action != HostCmd_ACT_GEN_SET) { |
| 75 | dev_err(priv->adapter->dev, |
| 76 | "mac_control: only support set cmd\n"); |
| 77 | return -1; |
| 78 | } |
| 79 | |
| 80 | cmd->command = cpu_to_le16(HostCmd_CMD_MAC_CONTROL); |
| 81 | cmd->size = |
| 82 | 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] | 83 | mac_ctrl->action = cpu_to_le16(*action); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 84 | |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | /* |
| 89 | * This function prepares command to set/get SNMP MIB. |
| 90 | * |
| 91 | * Preparation includes - |
| 92 | * - Setting command ID, action and proper size |
| 93 | * - Setting SNMP MIB OID number and value |
| 94 | * (as required) |
| 95 | * - Ensuring correct endian-ness |
| 96 | * |
| 97 | * The following SNMP MIB OIDs are supported - |
| 98 | * - FRAG_THRESH_I : Fragmentation threshold |
| 99 | * - RTS_THRESH_I : RTS threshold |
| 100 | * - SHORT_RETRY_LIM_I : Short retry limit |
| 101 | * - DOT11D_I : 11d support |
| 102 | */ |
| 103 | static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, |
| 104 | struct host_cmd_ds_command *cmd, |
| 105 | u16 cmd_action, u32 cmd_oid, |
Amitkumar Karwar | f3c8d25 | 2012-02-02 20:48:57 -0800 | [diff] [blame] | 106 | u16 *ul_temp) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 107 | { |
| 108 | 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] | 109 | |
| 110 | dev_dbg(priv->adapter->dev, "cmd: SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid); |
| 111 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SNMP_MIB); |
| 112 | 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] | 113 | - 1 + S_DS_GEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 114 | |
Amitkumar Karwar | f3c8d25 | 2012-02-02 20:48:57 -0800 | [diff] [blame] | 115 | snmp_mib->oid = cpu_to_le16((u16)cmd_oid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 116 | if (cmd_action == HostCmd_ACT_GEN_GET) { |
| 117 | snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_GET); |
| 118 | snmp_mib->buf_size = cpu_to_le16(MAX_SNMP_BUF_SIZE); |
Amitkumar Karwar | f3c8d25 | 2012-02-02 20:48:57 -0800 | [diff] [blame] | 119 | le16_add_cpu(&cmd->size, MAX_SNMP_BUF_SIZE); |
| 120 | } else if (cmd_action == HostCmd_ACT_GEN_SET) { |
| 121 | snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET); |
| 122 | snmp_mib->buf_size = cpu_to_le16(sizeof(u16)); |
| 123 | *((__le16 *) (snmp_mib->value)) = cpu_to_le16(*ul_temp); |
| 124 | le16_add_cpu(&cmd->size, sizeof(u16)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 125 | } |
| 126 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 127 | dev_dbg(priv->adapter->dev, |
| 128 | "cmd: SNMP_CMD: Action=0x%x, OID=0x%x, OIDSize=0x%x," |
| 129 | " Value=0x%x\n", |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 130 | cmd_action, cmd_oid, le16_to_cpu(snmp_mib->buf_size), |
| 131 | le16_to_cpu(*(__le16 *) snmp_mib->value)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | /* |
| 136 | * This function prepares command to get log. |
| 137 | * |
| 138 | * Preparation includes - |
| 139 | * - Setting command ID and proper size |
| 140 | * - Ensuring correct endian-ness |
| 141 | */ |
| 142 | static int |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 143 | mwifiex_cmd_802_11_get_log(struct host_cmd_ds_command *cmd) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 144 | { |
| 145 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_GET_LOG); |
| 146 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_get_log) + |
| 147 | S_DS_GEN); |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | /* |
| 152 | * This function prepares command to set/get Tx data rate configuration. |
| 153 | * |
| 154 | * Preparation includes - |
| 155 | * - Setting command ID, action and proper size |
| 156 | * - Setting configuration index, rate scope and rate drop pattern |
| 157 | * parameters (as required) |
| 158 | * - Ensuring correct endian-ness |
| 159 | */ |
| 160 | static int mwifiex_cmd_tx_rate_cfg(struct mwifiex_private *priv, |
| 161 | struct host_cmd_ds_command *cmd, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 162 | u16 cmd_action, u16 *pbitmap_rates) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 163 | { |
| 164 | struct host_cmd_ds_tx_rate_cfg *rate_cfg = &cmd->params.tx_rate_cfg; |
| 165 | struct mwifiex_rate_scope *rate_scope; |
| 166 | struct mwifiex_rate_drop_pattern *rate_drop; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 167 | u32 i; |
| 168 | |
| 169 | cmd->command = cpu_to_le16(HostCmd_CMD_TX_RATE_CFG); |
| 170 | |
| 171 | rate_cfg->action = cpu_to_le16(cmd_action); |
| 172 | rate_cfg->cfg_index = 0; |
| 173 | |
| 174 | rate_scope = (struct mwifiex_rate_scope *) ((u8 *) rate_cfg + |
| 175 | sizeof(struct host_cmd_ds_tx_rate_cfg)); |
| 176 | rate_scope->type = cpu_to_le16(TLV_TYPE_RATE_SCOPE); |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 177 | rate_scope->length = cpu_to_le16 |
| 178 | (sizeof(*rate_scope) - sizeof(struct mwifiex_ie_types_header)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 179 | if (pbitmap_rates != NULL) { |
| 180 | rate_scope->hr_dsss_rate_bitmap = cpu_to_le16(pbitmap_rates[0]); |
| 181 | rate_scope->ofdm_rate_bitmap = cpu_to_le16(pbitmap_rates[1]); |
| 182 | for (i = 0; |
| 183 | i < sizeof(rate_scope->ht_mcs_rate_bitmap) / sizeof(u16); |
| 184 | i++) |
| 185 | rate_scope->ht_mcs_rate_bitmap[i] = |
| 186 | cpu_to_le16(pbitmap_rates[2 + i]); |
| 187 | } else { |
| 188 | rate_scope->hr_dsss_rate_bitmap = |
| 189 | cpu_to_le16(priv->bitmap_rates[0]); |
| 190 | rate_scope->ofdm_rate_bitmap = |
| 191 | cpu_to_le16(priv->bitmap_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(priv->bitmap_rates[2 + i]); |
| 197 | } |
| 198 | |
| 199 | rate_drop = (struct mwifiex_rate_drop_pattern *) ((u8 *) rate_scope + |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 200 | sizeof(struct mwifiex_rate_scope)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 201 | rate_drop->type = cpu_to_le16(TLV_TYPE_RATE_DROP_CONTROL); |
| 202 | rate_drop->length = cpu_to_le16(sizeof(rate_drop->rate_drop_mode)); |
| 203 | rate_drop->rate_drop_mode = 0; |
| 204 | |
| 205 | cmd->size = |
| 206 | cpu_to_le16(S_DS_GEN + sizeof(struct host_cmd_ds_tx_rate_cfg) + |
| 207 | sizeof(struct mwifiex_rate_scope) + |
| 208 | sizeof(struct mwifiex_rate_drop_pattern)); |
| 209 | |
| 210 | return 0; |
| 211 | } |
| 212 | |
| 213 | /* |
| 214 | * This function prepares command to set/get Tx power configuration. |
| 215 | * |
| 216 | * Preparation includes - |
| 217 | * - Setting command ID, action and proper size |
| 218 | * - Setting Tx power mode, power group TLV |
| 219 | * (as required) |
| 220 | * - Ensuring correct endian-ness |
| 221 | */ |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 222 | 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] | 223 | u16 cmd_action, |
| 224 | struct host_cmd_ds_txpwr_cfg *txp) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 225 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 226 | struct mwifiex_types_power_group *pg_tlv; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 227 | struct host_cmd_ds_txpwr_cfg *cmd_txp_cfg = &cmd->params.txp_cfg; |
| 228 | |
| 229 | cmd->command = cpu_to_le16(HostCmd_CMD_TXPWR_CFG); |
| 230 | cmd->size = |
| 231 | cpu_to_le16(S_DS_GEN + sizeof(struct host_cmd_ds_txpwr_cfg)); |
| 232 | switch (cmd_action) { |
| 233 | case HostCmd_ACT_GEN_SET: |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 234 | if (txp->mode) { |
| 235 | pg_tlv = (struct mwifiex_types_power_group |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 236 | *) ((unsigned long) txp + |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 237 | sizeof(struct host_cmd_ds_txpwr_cfg)); |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 238 | memmove(cmd_txp_cfg, txp, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 239 | sizeof(struct host_cmd_ds_txpwr_cfg) + |
| 240 | sizeof(struct mwifiex_types_power_group) + |
| 241 | pg_tlv->length); |
| 242 | |
| 243 | pg_tlv = (struct mwifiex_types_power_group *) ((u8 *) |
| 244 | cmd_txp_cfg + |
| 245 | sizeof(struct host_cmd_ds_txpwr_cfg)); |
| 246 | cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) + |
| 247 | sizeof(struct mwifiex_types_power_group) + |
| 248 | pg_tlv->length); |
| 249 | } else { |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 250 | memmove(cmd_txp_cfg, txp, sizeof(*txp)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 251 | } |
| 252 | cmd_txp_cfg->action = cpu_to_le16(cmd_action); |
| 253 | break; |
| 254 | case HostCmd_ACT_GEN_GET: |
| 255 | cmd_txp_cfg->action = cpu_to_le16(cmd_action); |
| 256 | break; |
| 257 | } |
| 258 | |
| 259 | return 0; |
| 260 | } |
| 261 | |
| 262 | /* |
Amitkumar Karwar | caa8984 | 2012-06-27 19:57:57 -0700 | [diff] [blame] | 263 | * This function prepares command to get RF Tx power. |
| 264 | */ |
| 265 | static int mwifiex_cmd_rf_tx_power(struct mwifiex_private *priv, |
| 266 | struct host_cmd_ds_command *cmd, |
| 267 | u16 cmd_action, void *data_buf) |
| 268 | { |
| 269 | struct host_cmd_ds_rf_tx_pwr *txp = &cmd->params.txp; |
| 270 | |
| 271 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_tx_pwr) |
| 272 | + S_DS_GEN); |
| 273 | cmd->command = cpu_to_le16(HostCmd_CMD_RF_TX_PWR); |
| 274 | txp->action = cpu_to_le16(cmd_action); |
| 275 | |
| 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | /* |
Amitkumar Karwar | 8a279d5 | 2012-07-02 19:32:33 -0700 | [diff] [blame] | 280 | * This function prepares command to set rf antenna. |
| 281 | */ |
| 282 | static int mwifiex_cmd_rf_antenna(struct mwifiex_private *priv, |
| 283 | struct host_cmd_ds_command *cmd, |
| 284 | u16 cmd_action, |
| 285 | struct mwifiex_ds_ant_cfg *ant_cfg) |
| 286 | { |
| 287 | struct host_cmd_ds_rf_ant_mimo *ant_mimo = &cmd->params.ant_mimo; |
| 288 | struct host_cmd_ds_rf_ant_siso *ant_siso = &cmd->params.ant_siso; |
| 289 | |
| 290 | cmd->command = cpu_to_le16(HostCmd_CMD_RF_ANTENNA); |
| 291 | |
| 292 | if (cmd_action != HostCmd_ACT_GEN_SET) |
| 293 | return 0; |
| 294 | |
| 295 | if (priv->adapter->hw_dev_mcs_support == HT_STREAM_2X2) { |
| 296 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_ant_mimo) + |
| 297 | S_DS_GEN); |
| 298 | ant_mimo->action_tx = cpu_to_le16(HostCmd_ACT_SET_TX); |
| 299 | ant_mimo->tx_ant_mode = cpu_to_le16((u16)ant_cfg->tx_ant); |
| 300 | ant_mimo->action_rx = cpu_to_le16(HostCmd_ACT_SET_RX); |
| 301 | ant_mimo->rx_ant_mode = cpu_to_le16((u16)ant_cfg->rx_ant); |
| 302 | } else { |
| 303 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_ant_siso) + |
| 304 | S_DS_GEN); |
| 305 | ant_siso->action = cpu_to_le16(HostCmd_ACT_SET_BOTH); |
| 306 | ant_siso->ant_mode = cpu_to_le16((u16)ant_cfg->tx_ant); |
| 307 | } |
| 308 | |
| 309 | return 0; |
| 310 | } |
| 311 | |
| 312 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 313 | * This function prepares command to set Host Sleep configuration. |
| 314 | * |
| 315 | * Preparation includes - |
| 316 | * - Setting command ID and proper size |
| 317 | * - Setting Host Sleep action, conditions, ARP filters |
| 318 | * (as required) |
| 319 | * - Ensuring correct endian-ness |
| 320 | */ |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 321 | static int |
| 322 | mwifiex_cmd_802_11_hs_cfg(struct mwifiex_private *priv, |
| 323 | struct host_cmd_ds_command *cmd, |
| 324 | u16 cmd_action, |
| 325 | struct mwifiex_hs_config_param *hscfg_param) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 326 | { |
| 327 | struct mwifiex_adapter *adapter = priv->adapter; |
| 328 | struct host_cmd_ds_802_11_hs_cfg_enh *hs_cfg = &cmd->params.opt_hs_cfg; |
| 329 | u16 hs_activate = false; |
| 330 | |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 331 | if (!hscfg_param) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 332 | /* New Activate command */ |
| 333 | hs_activate = true; |
| 334 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_HS_CFG_ENH); |
| 335 | |
| 336 | if (!hs_activate && |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 337 | (hscfg_param->conditions != cpu_to_le32(HOST_SLEEP_CFG_CANCEL)) && |
| 338 | ((adapter->arp_filter_size > 0) && |
| 339 | (adapter->arp_filter_size <= ARP_FILTER_MAX_BUF_SIZE))) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 340 | dev_dbg(adapter->dev, |
| 341 | "cmd: Attach %d bytes ArpFilter to HSCfg cmd\n", |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 342 | adapter->arp_filter_size); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 343 | memcpy(((u8 *) hs_cfg) + |
| 344 | sizeof(struct host_cmd_ds_802_11_hs_cfg_enh), |
| 345 | adapter->arp_filter, adapter->arp_filter_size); |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 346 | cmd->size = cpu_to_le16 |
| 347 | (adapter->arp_filter_size + |
| 348 | sizeof(struct host_cmd_ds_802_11_hs_cfg_enh) |
| 349 | + S_DS_GEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 350 | } else { |
| 351 | cmd->size = cpu_to_le16(S_DS_GEN + sizeof(struct |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 352 | host_cmd_ds_802_11_hs_cfg_enh)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 353 | } |
| 354 | if (hs_activate) { |
| 355 | hs_cfg->action = cpu_to_le16(HS_ACTIVATE); |
| 356 | hs_cfg->params.hs_activate.resp_ctrl = RESP_NEEDED; |
| 357 | } else { |
| 358 | hs_cfg->action = cpu_to_le16(HS_CONFIGURE); |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 359 | hs_cfg->params.hs_config.conditions = hscfg_param->conditions; |
| 360 | hs_cfg->params.hs_config.gpio = hscfg_param->gpio; |
| 361 | hs_cfg->params.hs_config.gap = hscfg_param->gap; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 362 | dev_dbg(adapter->dev, |
| 363 | "cmd: HS_CFG_CMD: condition:0x%x gpio:0x%x gap:0x%x\n", |
| 364 | hs_cfg->params.hs_config.conditions, |
| 365 | hs_cfg->params.hs_config.gpio, |
| 366 | hs_cfg->params.hs_config.gap); |
| 367 | } |
| 368 | |
| 369 | return 0; |
| 370 | } |
| 371 | |
| 372 | /* |
| 373 | * This function prepares command to set/get MAC address. |
| 374 | * |
| 375 | * Preparation includes - |
| 376 | * - Setting command ID, action and proper size |
| 377 | * - Setting MAC address (for SET only) |
| 378 | * - Ensuring correct endian-ness |
| 379 | */ |
| 380 | static int mwifiex_cmd_802_11_mac_address(struct mwifiex_private *priv, |
| 381 | struct host_cmd_ds_command *cmd, |
| 382 | u16 cmd_action) |
| 383 | { |
| 384 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_MAC_ADDRESS); |
| 385 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_mac_address) + |
| 386 | S_DS_GEN); |
| 387 | cmd->result = 0; |
| 388 | |
| 389 | cmd->params.mac_addr.action = cpu_to_le16(cmd_action); |
| 390 | |
| 391 | if (cmd_action == HostCmd_ACT_GEN_SET) |
| 392 | memcpy(cmd->params.mac_addr.mac_addr, priv->curr_addr, |
| 393 | ETH_ALEN); |
| 394 | return 0; |
| 395 | } |
| 396 | |
| 397 | /* |
| 398 | * This function prepares command to set MAC multicast address. |
| 399 | * |
| 400 | * Preparation includes - |
| 401 | * - Setting command ID, action and proper size |
| 402 | * - Setting MAC multicast address |
| 403 | * - Ensuring correct endian-ness |
| 404 | */ |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 405 | static int |
| 406 | mwifiex_cmd_mac_multicast_adr(struct host_cmd_ds_command *cmd, |
| 407 | u16 cmd_action, |
| 408 | struct mwifiex_multicast_list *mcast_list) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 409 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 410 | struct host_cmd_ds_mac_multicast_adr *mcast_addr = &cmd->params.mc_addr; |
| 411 | |
| 412 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_mac_multicast_adr) + |
| 413 | S_DS_GEN); |
| 414 | cmd->command = cpu_to_le16(HostCmd_CMD_MAC_MULTICAST_ADR); |
| 415 | |
| 416 | mcast_addr->action = cpu_to_le16(cmd_action); |
| 417 | mcast_addr->num_of_adrs = |
| 418 | cpu_to_le16((u16) mcast_list->num_multicast_addr); |
| 419 | memcpy(mcast_addr->mac_list, mcast_list->mac_list, |
| 420 | mcast_list->num_multicast_addr * ETH_ALEN); |
| 421 | |
| 422 | return 0; |
| 423 | } |
| 424 | |
| 425 | /* |
| 426 | * This function prepares command to deauthenticate. |
| 427 | * |
| 428 | * Preparation includes - |
| 429 | * - Setting command ID and proper size |
| 430 | * - Setting AP MAC address and reason code |
| 431 | * - Ensuring correct endian-ness |
| 432 | */ |
| 433 | static int mwifiex_cmd_802_11_deauthenticate(struct mwifiex_private *priv, |
| 434 | struct host_cmd_ds_command *cmd, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 435 | u8 *mac) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 436 | { |
| 437 | struct host_cmd_ds_802_11_deauthenticate *deauth = &cmd->params.deauth; |
| 438 | |
| 439 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_DEAUTHENTICATE); |
| 440 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_deauthenticate) |
| 441 | + S_DS_GEN); |
| 442 | |
| 443 | /* Set AP MAC address */ |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 444 | memcpy(deauth->mac_addr, mac, ETH_ALEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 445 | |
| 446 | dev_dbg(priv->adapter->dev, "cmd: Deauth: %pM\n", deauth->mac_addr); |
| 447 | |
| 448 | deauth->reason_code = cpu_to_le16(WLAN_REASON_DEAUTH_LEAVING); |
| 449 | |
| 450 | return 0; |
| 451 | } |
| 452 | |
| 453 | /* |
| 454 | * This function prepares command to stop Ad-Hoc network. |
| 455 | * |
| 456 | * Preparation includes - |
| 457 | * - Setting command ID and proper size |
| 458 | * - Ensuring correct endian-ness |
| 459 | */ |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 460 | 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] | 461 | { |
| 462 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_STOP); |
| 463 | cmd->size = cpu_to_le16(S_DS_GEN); |
| 464 | return 0; |
| 465 | } |
| 466 | |
| 467 | /* |
| 468 | * This function sets WEP key(s) to key parameter TLV(s). |
| 469 | * |
| 470 | * Multi-key parameter TLVs are supported, so we can send multiple |
| 471 | * WEP keys in a single buffer. |
| 472 | */ |
| 473 | static int |
| 474 | mwifiex_set_keyparamset_wep(struct mwifiex_private *priv, |
| 475 | struct mwifiex_ie_type_key_param_set *key_param_set, |
| 476 | u16 *key_param_len) |
| 477 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 478 | int cur_key_param_len; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 479 | u8 i; |
| 480 | |
| 481 | /* Multi-key_param_set TLV is supported */ |
| 482 | for (i = 0; i < NUM_WEP_KEYS; i++) { |
| 483 | if ((priv->wep_key[i].key_length == WLAN_KEY_LEN_WEP40) || |
| 484 | (priv->wep_key[i].key_length == WLAN_KEY_LEN_WEP104)) { |
| 485 | key_param_set->type = |
| 486 | cpu_to_le16(TLV_TYPE_KEY_MATERIAL); |
| 487 | /* Key_param_set WEP fixed length */ |
| 488 | #define KEYPARAMSET_WEP_FIXED_LEN 8 |
| 489 | key_param_set->length = cpu_to_le16((u16) |
| 490 | (priv->wep_key[i]. |
| 491 | key_length + |
| 492 | KEYPARAMSET_WEP_FIXED_LEN)); |
| 493 | key_param_set->key_type_id = |
| 494 | cpu_to_le16(KEY_TYPE_ID_WEP); |
| 495 | key_param_set->key_info = |
Yogesh Ashok Powar | 6a35a0a | 2011-04-06 16:46:56 -0700 | [diff] [blame] | 496 | cpu_to_le16(KEY_ENABLED | KEY_UNICAST | |
| 497 | KEY_MCAST); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 498 | key_param_set->key_len = |
| 499 | cpu_to_le16(priv->wep_key[i].key_length); |
| 500 | /* Set WEP key index */ |
| 501 | key_param_set->key[0] = i; |
| 502 | /* Set default Tx key flag */ |
| 503 | if (i == |
| 504 | (priv-> |
| 505 | wep_key_curr_index & HostCmd_WEP_KEY_INDEX_MASK)) |
| 506 | key_param_set->key[1] = 1; |
| 507 | else |
| 508 | key_param_set->key[1] = 0; |
| 509 | memmove(&key_param_set->key[2], |
| 510 | priv->wep_key[i].key_material, |
| 511 | priv->wep_key[i].key_length); |
| 512 | |
| 513 | cur_key_param_len = priv->wep_key[i].key_length + |
| 514 | KEYPARAMSET_WEP_FIXED_LEN + |
| 515 | sizeof(struct mwifiex_ie_types_header); |
| 516 | *key_param_len += (u16) cur_key_param_len; |
| 517 | key_param_set = |
| 518 | (struct mwifiex_ie_type_key_param_set *) |
| 519 | ((u8 *)key_param_set + |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 520 | cur_key_param_len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 521 | } else if (!priv->wep_key[i].key_length) { |
| 522 | continue; |
| 523 | } else { |
| 524 | dev_err(priv->adapter->dev, |
| 525 | "key%d Length = %d is incorrect\n", |
| 526 | (i + 1), priv->wep_key[i].key_length); |
| 527 | return -1; |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | return 0; |
| 532 | } |
| 533 | |
| 534 | /* |
| 535 | * This function prepares command to set/get/reset network key(s). |
| 536 | * |
| 537 | * Preparation includes - |
| 538 | * - Setting command ID, action and proper size |
| 539 | * - Setting WEP keys, WAPI keys or WPA keys along with required |
| 540 | * encryption (TKIP, AES) (as required) |
| 541 | * - Ensuring correct endian-ness |
| 542 | */ |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 543 | static int |
| 544 | mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv, |
| 545 | struct host_cmd_ds_command *cmd, |
| 546 | u16 cmd_action, u32 cmd_oid, |
| 547 | struct mwifiex_ds_encrypt_key *enc_key) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 548 | { |
| 549 | struct host_cmd_ds_802_11_key_material *key_material = |
| 550 | &cmd->params.key_material; |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 551 | struct host_cmd_tlv_mac_addr *tlv_mac; |
| 552 | u16 key_param_len = 0, cmd_size; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 553 | int ret = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 554 | |
| 555 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_KEY_MATERIAL); |
| 556 | key_material->action = cpu_to_le16(cmd_action); |
| 557 | |
| 558 | if (cmd_action == HostCmd_ACT_GEN_GET) { |
| 559 | cmd->size = |
| 560 | cpu_to_le16(sizeof(key_material->action) + S_DS_GEN); |
| 561 | return ret; |
| 562 | } |
| 563 | |
| 564 | if (!enc_key) { |
| 565 | memset(&key_material->key_param_set, 0, |
| 566 | (NUM_WEP_KEYS * |
| 567 | sizeof(struct mwifiex_ie_type_key_param_set))); |
| 568 | ret = mwifiex_set_keyparamset_wep(priv, |
| 569 | &key_material->key_param_set, |
| 570 | &key_param_len); |
| 571 | cmd->size = cpu_to_le16(key_param_len + |
| 572 | sizeof(key_material->action) + S_DS_GEN); |
| 573 | return ret; |
| 574 | } else |
| 575 | memset(&key_material->key_param_set, 0, |
| 576 | sizeof(struct mwifiex_ie_type_key_param_set)); |
| 577 | if (enc_key->is_wapi_key) { |
| 578 | dev_dbg(priv->adapter->dev, "info: Set WAPI Key\n"); |
| 579 | key_material->key_param_set.key_type_id = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 580 | cpu_to_le16(KEY_TYPE_ID_WAPI); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 581 | if (cmd_oid == KEY_INFO_ENABLED) |
| 582 | key_material->key_param_set.key_info = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 583 | cpu_to_le16(KEY_ENABLED); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 584 | else |
| 585 | key_material->key_param_set.key_info = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 586 | cpu_to_le16(!KEY_ENABLED); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 587 | |
| 588 | key_material->key_param_set.key[0] = enc_key->key_index; |
| 589 | if (!priv->sec_info.wapi_key_on) |
| 590 | key_material->key_param_set.key[1] = 1; |
| 591 | else |
| 592 | /* set 0 when re-key */ |
| 593 | key_material->key_param_set.key[1] = 0; |
| 594 | |
Wei Yongjun | a71bf90 | 2012-08-24 13:25:30 +0800 | [diff] [blame] | 595 | if (!is_broadcast_ether_addr(enc_key->mac_addr)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 596 | /* WAPI pairwise key: unicast */ |
| 597 | key_material->key_param_set.key_info |= |
Yogesh Ashok Powar | 6a35a0a | 2011-04-06 16:46:56 -0700 | [diff] [blame] | 598 | cpu_to_le16(KEY_UNICAST); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 599 | } else { /* WAPI group key: multicast */ |
| 600 | key_material->key_param_set.key_info |= |
Yogesh Ashok Powar | 6a35a0a | 2011-04-06 16:46:56 -0700 | [diff] [blame] | 601 | cpu_to_le16(KEY_MCAST); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 602 | priv->sec_info.wapi_key_on = true; |
| 603 | } |
| 604 | |
| 605 | key_material->key_param_set.type = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 606 | cpu_to_le16(TLV_TYPE_KEY_MATERIAL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 607 | key_material->key_param_set.key_len = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 608 | cpu_to_le16(WAPI_KEY_LEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 609 | memcpy(&key_material->key_param_set.key[2], |
| 610 | enc_key->key_material, enc_key->key_len); |
| 611 | memcpy(&key_material->key_param_set.key[2 + enc_key->key_len], |
Ying Luo | 9d7aba6 | 2012-08-03 18:06:12 -0700 | [diff] [blame] | 612 | enc_key->pn, PN_LEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 613 | key_material->key_param_set.length = |
| 614 | cpu_to_le16(WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN); |
| 615 | |
| 616 | key_param_len = (WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN) + |
| 617 | sizeof(struct mwifiex_ie_types_header); |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 618 | cmd->size = cpu_to_le16(sizeof(key_material->action) |
| 619 | + S_DS_GEN + key_param_len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 620 | return ret; |
| 621 | } |
| 622 | if (enc_key->key_len == WLAN_KEY_LEN_CCMP) { |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 623 | if (enc_key->is_igtk_key) { |
| 624 | dev_dbg(priv->adapter->dev, "cmd: CMAC_AES\n"); |
| 625 | key_material->key_param_set.key_type_id = |
| 626 | cpu_to_le16(KEY_TYPE_ID_AES_CMAC); |
| 627 | if (cmd_oid == KEY_INFO_ENABLED) |
| 628 | key_material->key_param_set.key_info = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 629 | cpu_to_le16(KEY_ENABLED); |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 630 | else |
| 631 | key_material->key_param_set.key_info = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 632 | cpu_to_le16(!KEY_ENABLED); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 633 | |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 634 | key_material->key_param_set.key_info |= |
| 635 | cpu_to_le16(KEY_IGTK); |
| 636 | } else { |
| 637 | dev_dbg(priv->adapter->dev, "cmd: WPA_AES\n"); |
| 638 | key_material->key_param_set.key_type_id = |
| 639 | cpu_to_le16(KEY_TYPE_ID_AES); |
| 640 | if (cmd_oid == KEY_INFO_ENABLED) |
| 641 | key_material->key_param_set.key_info = |
| 642 | cpu_to_le16(KEY_ENABLED); |
| 643 | else |
| 644 | key_material->key_param_set.key_info = |
| 645 | cpu_to_le16(!KEY_ENABLED); |
| 646 | |
| 647 | if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 648 | /* AES pairwise key: unicast */ |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 649 | key_material->key_param_set.key_info |= |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 650 | cpu_to_le16(KEY_UNICAST); |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 651 | else /* AES group key: multicast */ |
| 652 | key_material->key_param_set.key_info |= |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 653 | cpu_to_le16(KEY_MCAST); |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 654 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 655 | } else if (enc_key->key_len == WLAN_KEY_LEN_TKIP) { |
| 656 | dev_dbg(priv->adapter->dev, "cmd: WPA_TKIP\n"); |
| 657 | key_material->key_param_set.key_type_id = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 658 | cpu_to_le16(KEY_TYPE_ID_TKIP); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 659 | key_material->key_param_set.key_info = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 660 | cpu_to_le16(KEY_ENABLED); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 661 | |
| 662 | if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST) |
| 663 | /* TKIP pairwise key: unicast */ |
| 664 | key_material->key_param_set.key_info |= |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 665 | cpu_to_le16(KEY_UNICAST); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 666 | else /* TKIP group key: multicast */ |
| 667 | key_material->key_param_set.key_info |= |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 668 | cpu_to_le16(KEY_MCAST); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 669 | } |
| 670 | |
| 671 | if (key_material->key_param_set.key_type_id) { |
| 672 | key_material->key_param_set.type = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 673 | cpu_to_le16(TLV_TYPE_KEY_MATERIAL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 674 | key_material->key_param_set.key_len = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 675 | cpu_to_le16((u16) enc_key->key_len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 676 | memcpy(key_material->key_param_set.key, enc_key->key_material, |
| 677 | enc_key->key_len); |
| 678 | key_material->key_param_set.length = |
| 679 | cpu_to_le16((u16) enc_key->key_len + |
| 680 | KEYPARAMSET_FIXED_LEN); |
| 681 | |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 682 | key_param_len = (u16)(enc_key->key_len + KEYPARAMSET_FIXED_LEN) |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 683 | + sizeof(struct mwifiex_ie_types_header); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 684 | |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 685 | if (le16_to_cpu(key_material->key_param_set.key_type_id) == |
| 686 | KEY_TYPE_ID_AES_CMAC) { |
| 687 | struct mwifiex_cmac_param *param = |
| 688 | (void *)key_material->key_param_set.key; |
| 689 | |
| 690 | memcpy(param->ipn, enc_key->pn, IGTK_PN_LEN); |
| 691 | memcpy(param->key, enc_key->key_material, |
Bing Zhao | 641c869 | 2012-08-08 19:01:52 -0700 | [diff] [blame] | 692 | WLAN_KEY_LEN_AES_CMAC); |
Ying Luo | b877f4c | 2012-08-03 18:06:14 -0700 | [diff] [blame] | 693 | |
| 694 | key_param_len = sizeof(struct mwifiex_cmac_param); |
| 695 | key_material->key_param_set.key_len = |
| 696 | cpu_to_le16(key_param_len); |
| 697 | key_param_len += KEYPARAMSET_FIXED_LEN; |
| 698 | key_material->key_param_set.length = |
| 699 | cpu_to_le16(key_param_len); |
| 700 | key_param_len += sizeof(struct mwifiex_ie_types_header); |
| 701 | } |
| 702 | |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 703 | cmd->size = cpu_to_le16(sizeof(key_material->action) + S_DS_GEN |
| 704 | + key_param_len); |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 705 | |
| 706 | if (priv->bss_type == MWIFIEX_BSS_TYPE_UAP) { |
| 707 | tlv_mac = (void *)((u8 *)&key_material->key_param_set + |
| 708 | key_param_len); |
| 709 | tlv_mac->tlv.type = cpu_to_le16(TLV_TYPE_STA_MAC_ADDR); |
| 710 | tlv_mac->tlv.len = cpu_to_le16(ETH_ALEN); |
| 711 | memcpy(tlv_mac->mac_addr, enc_key->mac_addr, ETH_ALEN); |
| 712 | cmd_size = key_param_len + S_DS_GEN + |
| 713 | sizeof(key_material->action) + |
| 714 | sizeof(struct host_cmd_tlv_mac_addr); |
| 715 | } else { |
| 716 | cmd_size = key_param_len + S_DS_GEN + |
| 717 | sizeof(key_material->action); |
| 718 | } |
| 719 | cmd->size = cpu_to_le16(cmd_size); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 720 | } |
| 721 | |
| 722 | return ret; |
| 723 | } |
| 724 | |
| 725 | /* |
| 726 | * This function prepares command to set/get 11d domain information. |
| 727 | * |
| 728 | * Preparation includes - |
| 729 | * - Setting command ID, action and proper size |
| 730 | * - Setting domain information fields (for SET only) |
| 731 | * - Ensuring correct endian-ness |
| 732 | */ |
| 733 | static int mwifiex_cmd_802_11d_domain_info(struct mwifiex_private *priv, |
| 734 | struct host_cmd_ds_command *cmd, |
| 735 | u16 cmd_action) |
| 736 | { |
| 737 | struct mwifiex_adapter *adapter = priv->adapter; |
| 738 | struct host_cmd_ds_802_11d_domain_info *domain_info = |
| 739 | &cmd->params.domain_info; |
| 740 | struct mwifiex_ietypes_domain_param_set *domain = |
| 741 | &domain_info->domain; |
| 742 | u8 no_of_triplet = adapter->domain_reg.no_of_triplet; |
| 743 | |
| 744 | dev_dbg(adapter->dev, "info: 11D: no_of_triplet=0x%x\n", no_of_triplet); |
| 745 | |
| 746 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11D_DOMAIN_INFO); |
| 747 | domain_info->action = cpu_to_le16(cmd_action); |
| 748 | if (cmd_action == HostCmd_ACT_GEN_GET) { |
| 749 | cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN); |
| 750 | return 0; |
| 751 | } |
| 752 | |
| 753 | /* Set domain info fields */ |
| 754 | domain->header.type = cpu_to_le16(WLAN_EID_COUNTRY); |
| 755 | memcpy(domain->country_code, adapter->domain_reg.country_code, |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 756 | sizeof(domain->country_code)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 757 | |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 758 | domain->header.len = |
| 759 | cpu_to_le16((no_of_triplet * |
| 760 | sizeof(struct ieee80211_country_ie_triplet)) |
| 761 | + sizeof(domain->country_code)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 762 | |
| 763 | if (no_of_triplet) { |
| 764 | memcpy(domain->triplet, adapter->domain_reg.triplet, |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 765 | no_of_triplet * sizeof(struct |
| 766 | ieee80211_country_ie_triplet)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 767 | |
| 768 | cmd->size = cpu_to_le16(sizeof(domain_info->action) + |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 769 | le16_to_cpu(domain->header.len) + |
| 770 | sizeof(struct mwifiex_ie_types_header) |
| 771 | + S_DS_GEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 772 | } else { |
| 773 | cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN); |
| 774 | } |
| 775 | |
| 776 | return 0; |
| 777 | } |
| 778 | |
| 779 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 780 | * This function prepares command to set/get IBSS coalescing status. |
| 781 | * |
| 782 | * Preparation includes - |
| 783 | * - Setting command ID, action and proper size |
| 784 | * - Setting status to enable or disable (for SET only) |
| 785 | * - Ensuring correct endian-ness |
| 786 | */ |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 787 | 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] | 788 | u16 cmd_action, u16 *enable) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 789 | { |
| 790 | struct host_cmd_ds_802_11_ibss_status *ibss_coal = |
| 791 | &(cmd->params.ibss_coalescing); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 792 | |
| 793 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_IBSS_COALESCING_STATUS); |
| 794 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_ibss_status) + |
| 795 | S_DS_GEN); |
| 796 | cmd->result = 0; |
| 797 | ibss_coal->action = cpu_to_le16(cmd_action); |
| 798 | |
| 799 | switch (cmd_action) { |
| 800 | case HostCmd_ACT_GEN_SET: |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 801 | if (enable) |
| 802 | ibss_coal->enable = cpu_to_le16(*enable); |
Dan Carpenter | a5e5aa6 | 2011-06-24 16:33:35 +0300 | [diff] [blame] | 803 | else |
| 804 | ibss_coal->enable = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 805 | break; |
| 806 | |
| 807 | /* In other case.. Nothing to do */ |
| 808 | case HostCmd_ACT_GEN_GET: |
| 809 | default: |
| 810 | break; |
| 811 | } |
| 812 | |
| 813 | return 0; |
| 814 | } |
| 815 | |
| 816 | /* |
| 817 | * This function prepares command to set/get register value. |
| 818 | * |
| 819 | * Preparation includes - |
| 820 | * - Setting command ID, action and proper size |
| 821 | * - Setting register offset (for both GET and SET) and |
| 822 | * register value (for SET only) |
| 823 | * - Ensuring correct endian-ness |
| 824 | * |
| 825 | * The following type of registers can be accessed with this function - |
| 826 | * - MAC register |
| 827 | * - BBP register |
| 828 | * - RF register |
| 829 | * - PMIC register |
| 830 | * - CAU register |
| 831 | * - EEPROM |
| 832 | */ |
| 833 | static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd, |
| 834 | u16 cmd_action, void *data_buf) |
| 835 | { |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 836 | struct mwifiex_ds_reg_rw *reg_rw = data_buf; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 837 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 838 | switch (le16_to_cpu(cmd->command)) { |
| 839 | case HostCmd_CMD_MAC_REG_ACCESS: |
| 840 | { |
| 841 | struct host_cmd_ds_mac_reg_access *mac_reg; |
| 842 | |
| 843 | cmd->size = cpu_to_le16(sizeof(*mac_reg) + S_DS_GEN); |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 844 | mac_reg = &cmd->params.mac_reg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 845 | mac_reg->action = cpu_to_le16(cmd_action); |
| 846 | mac_reg->offset = |
| 847 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
| 848 | mac_reg->value = reg_rw->value; |
| 849 | break; |
| 850 | } |
| 851 | case HostCmd_CMD_BBP_REG_ACCESS: |
| 852 | { |
| 853 | struct host_cmd_ds_bbp_reg_access *bbp_reg; |
| 854 | |
| 855 | cmd->size = cpu_to_le16(sizeof(*bbp_reg) + S_DS_GEN); |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 856 | bbp_reg = &cmd->params.bbp_reg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 857 | bbp_reg->action = cpu_to_le16(cmd_action); |
| 858 | bbp_reg->offset = |
| 859 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
| 860 | bbp_reg->value = (u8) le32_to_cpu(reg_rw->value); |
| 861 | break; |
| 862 | } |
| 863 | case HostCmd_CMD_RF_REG_ACCESS: |
| 864 | { |
| 865 | struct host_cmd_ds_rf_reg_access *rf_reg; |
| 866 | |
| 867 | cmd->size = cpu_to_le16(sizeof(*rf_reg) + S_DS_GEN); |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 868 | rf_reg = &cmd->params.rf_reg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 869 | rf_reg->action = cpu_to_le16(cmd_action); |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 870 | 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] | 871 | rf_reg->value = (u8) le32_to_cpu(reg_rw->value); |
| 872 | break; |
| 873 | } |
| 874 | case HostCmd_CMD_PMIC_REG_ACCESS: |
| 875 | { |
| 876 | struct host_cmd_ds_pmic_reg_access *pmic_reg; |
| 877 | |
| 878 | cmd->size = cpu_to_le16(sizeof(*pmic_reg) + S_DS_GEN); |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 879 | pmic_reg = &cmd->params.pmic_reg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 880 | pmic_reg->action = cpu_to_le16(cmd_action); |
| 881 | pmic_reg->offset = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 882 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 883 | pmic_reg->value = (u8) le32_to_cpu(reg_rw->value); |
| 884 | break; |
| 885 | } |
| 886 | case HostCmd_CMD_CAU_REG_ACCESS: |
| 887 | { |
| 888 | struct host_cmd_ds_rf_reg_access *cau_reg; |
| 889 | |
| 890 | cmd->size = cpu_to_le16(sizeof(*cau_reg) + S_DS_GEN); |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 891 | cau_reg = &cmd->params.rf_reg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 892 | cau_reg->action = cpu_to_le16(cmd_action); |
| 893 | cau_reg->offset = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 894 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 895 | cau_reg->value = (u8) le32_to_cpu(reg_rw->value); |
| 896 | break; |
| 897 | } |
| 898 | case HostCmd_CMD_802_11_EEPROM_ACCESS: |
| 899 | { |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 900 | struct mwifiex_ds_read_eeprom *rd_eeprom = data_buf; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 901 | struct host_cmd_ds_802_11_eeprom_access *cmd_eeprom = |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 902 | &cmd->params.eeprom; |
| 903 | |
| 904 | cmd->size = cpu_to_le16(sizeof(*cmd_eeprom) + S_DS_GEN); |
| 905 | cmd_eeprom->action = cpu_to_le16(cmd_action); |
| 906 | cmd_eeprom->offset = rd_eeprom->offset; |
| 907 | cmd_eeprom->byte_count = rd_eeprom->byte_count; |
| 908 | cmd_eeprom->value = 0; |
| 909 | break; |
| 910 | } |
| 911 | default: |
| 912 | return -1; |
| 913 | } |
| 914 | |
| 915 | return 0; |
| 916 | } |
| 917 | |
| 918 | /* |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 919 | * This function prepares command to set PCI-Express |
| 920 | * host buffer configuration |
| 921 | * |
| 922 | * Preparation includes - |
| 923 | * - Setting command ID, action and proper size |
| 924 | * - Setting host buffer configuration |
| 925 | * - Ensuring correct endian-ness |
| 926 | */ |
| 927 | static int |
| 928 | mwifiex_cmd_pcie_host_spec(struct mwifiex_private *priv, |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 929 | struct host_cmd_ds_command *cmd, u16 action) |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 930 | { |
| 931 | struct host_cmd_ds_pcie_details *host_spec = |
| 932 | &cmd->params.pcie_host_spec; |
| 933 | struct pcie_service_card *card = priv->adapter->card; |
| 934 | phys_addr_t *buf_pa; |
| 935 | |
| 936 | cmd->command = cpu_to_le16(HostCmd_CMD_PCIE_DESC_DETAILS); |
| 937 | cmd->size = cpu_to_le16(sizeof(struct |
| 938 | host_cmd_ds_pcie_details) + S_DS_GEN); |
| 939 | cmd->result = 0; |
| 940 | |
| 941 | memset(host_spec, 0, sizeof(struct host_cmd_ds_pcie_details)); |
| 942 | |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 943 | if (action != HostCmd_ACT_GEN_SET) |
| 944 | return 0; |
| 945 | |
| 946 | /* Send the ring base addresses and count to firmware */ |
| 947 | host_spec->txbd_addr_lo = (u32)(card->txbd_ring_pbase); |
| 948 | host_spec->txbd_addr_hi = (u32)(((u64)card->txbd_ring_pbase)>>32); |
| 949 | host_spec->txbd_count = MWIFIEX_MAX_TXRX_BD; |
| 950 | host_spec->rxbd_addr_lo = (u32)(card->rxbd_ring_pbase); |
| 951 | host_spec->rxbd_addr_hi = (u32)(((u64)card->rxbd_ring_pbase)>>32); |
| 952 | host_spec->rxbd_count = MWIFIEX_MAX_TXRX_BD; |
| 953 | host_spec->evtbd_addr_lo = (u32)(card->evtbd_ring_pbase); |
| 954 | host_spec->evtbd_addr_hi = (u32)(((u64)card->evtbd_ring_pbase)>>32); |
| 955 | host_spec->evtbd_count = MWIFIEX_MAX_EVT_BD; |
| 956 | if (card->sleep_cookie) { |
| 957 | buf_pa = MWIFIEX_SKB_PACB(card->sleep_cookie); |
| 958 | host_spec->sleep_cookie_addr_lo = (u32) *buf_pa; |
| 959 | host_spec->sleep_cookie_addr_hi = (u32) (((u64)*buf_pa) >> 32); |
| 960 | dev_dbg(priv->adapter->dev, "sleep_cook_lo phy addr: 0x%x\n", |
| 961 | host_spec->sleep_cookie_addr_lo); |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 962 | } |
| 963 | |
| 964 | return 0; |
| 965 | } |
| 966 | |
| 967 | /* |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 968 | * This function prepares command for event subscription, configuration |
| 969 | * and query. Events can be subscribed or unsubscribed. Current subscribed |
| 970 | * events can be queried. Also, current subscribed events are reported in |
| 971 | * every FW response. |
| 972 | */ |
| 973 | static int |
| 974 | mwifiex_cmd_802_11_subsc_evt(struct mwifiex_private *priv, |
| 975 | struct host_cmd_ds_command *cmd, |
| 976 | struct mwifiex_ds_misc_subsc_evt *subsc_evt_cfg) |
| 977 | { |
| 978 | struct host_cmd_ds_802_11_subsc_evt *subsc_evt = &cmd->params.subsc_evt; |
| 979 | struct mwifiex_ie_types_rssi_threshold *rssi_tlv; |
| 980 | u16 event_bitmap; |
| 981 | u8 *pos; |
| 982 | |
| 983 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SUBSCRIBE_EVENT); |
| 984 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_subsc_evt) + |
| 985 | S_DS_GEN); |
| 986 | |
| 987 | subsc_evt->action = cpu_to_le16(subsc_evt_cfg->action); |
| 988 | dev_dbg(priv->adapter->dev, "cmd: action: %d\n", subsc_evt_cfg->action); |
| 989 | |
| 990 | /*For query requests, no configuration TLV structures are to be added.*/ |
| 991 | if (subsc_evt_cfg->action == HostCmd_ACT_GEN_GET) |
| 992 | return 0; |
| 993 | |
| 994 | subsc_evt->events = cpu_to_le16(subsc_evt_cfg->events); |
| 995 | |
| 996 | event_bitmap = subsc_evt_cfg->events; |
| 997 | dev_dbg(priv->adapter->dev, "cmd: event bitmap : %16x\n", |
| 998 | event_bitmap); |
| 999 | |
| 1000 | if (((subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR) || |
| 1001 | (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_SET)) && |
| 1002 | (event_bitmap == 0)) { |
| 1003 | dev_dbg(priv->adapter->dev, "Error: No event specified " |
| 1004 | "for bitwise action type\n"); |
| 1005 | return -EINVAL; |
| 1006 | } |
| 1007 | |
| 1008 | /* |
| 1009 | * Append TLV structures for each of the specified events for |
| 1010 | * subscribing or re-configuring. This is not required for |
| 1011 | * bitwise unsubscribing request. |
| 1012 | */ |
| 1013 | if (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR) |
| 1014 | return 0; |
| 1015 | |
| 1016 | pos = ((u8 *)subsc_evt) + |
| 1017 | sizeof(struct host_cmd_ds_802_11_subsc_evt); |
| 1018 | |
| 1019 | if (event_bitmap & BITMASK_BCN_RSSI_LOW) { |
| 1020 | rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos; |
| 1021 | |
| 1022 | rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_LOW); |
| 1023 | rssi_tlv->header.len = |
| 1024 | cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) - |
| 1025 | sizeof(struct mwifiex_ie_types_header)); |
| 1026 | rssi_tlv->abs_value = subsc_evt_cfg->bcn_l_rssi_cfg.abs_value; |
| 1027 | rssi_tlv->evt_freq = subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq; |
| 1028 | |
| 1029 | dev_dbg(priv->adapter->dev, "Cfg Beacon Low Rssi event, " |
| 1030 | "RSSI:-%d dBm, Freq:%d\n", |
| 1031 | subsc_evt_cfg->bcn_l_rssi_cfg.abs_value, |
| 1032 | subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq); |
| 1033 | |
| 1034 | pos += sizeof(struct mwifiex_ie_types_rssi_threshold); |
| 1035 | le16_add_cpu(&cmd->size, |
| 1036 | sizeof(struct mwifiex_ie_types_rssi_threshold)); |
| 1037 | } |
| 1038 | |
| 1039 | if (event_bitmap & BITMASK_BCN_RSSI_HIGH) { |
| 1040 | rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos; |
| 1041 | |
| 1042 | rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_HIGH); |
| 1043 | rssi_tlv->header.len = |
| 1044 | cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) - |
| 1045 | sizeof(struct mwifiex_ie_types_header)); |
| 1046 | rssi_tlv->abs_value = subsc_evt_cfg->bcn_h_rssi_cfg.abs_value; |
| 1047 | rssi_tlv->evt_freq = subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq; |
| 1048 | |
Bing Zhao | d35ccaa | 2012-04-09 20:06:53 -0700 | [diff] [blame] | 1049 | dev_dbg(priv->adapter->dev, "Cfg Beacon High Rssi event, " |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 1050 | "RSSI:-%d dBm, Freq:%d\n", |
| 1051 | subsc_evt_cfg->bcn_h_rssi_cfg.abs_value, |
| 1052 | subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq); |
| 1053 | |
| 1054 | pos += sizeof(struct mwifiex_ie_types_rssi_threshold); |
| 1055 | le16_add_cpu(&cmd->size, |
| 1056 | sizeof(struct mwifiex_ie_types_rssi_threshold)); |
| 1057 | } |
| 1058 | |
| 1059 | return 0; |
| 1060 | } |
| 1061 | |
| 1062 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1063 | * This function prepares the commands before sending them to the firmware. |
| 1064 | * |
| 1065 | * This is a generic function which calls specific command preparation |
| 1066 | * routines based upon the command number. |
| 1067 | */ |
| 1068 | int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no, |
| 1069 | u16 cmd_action, u32 cmd_oid, |
| 1070 | void *data_buf, void *cmd_buf) |
| 1071 | { |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 1072 | struct host_cmd_ds_command *cmd_ptr = cmd_buf; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1073 | int ret = 0; |
| 1074 | |
| 1075 | /* Prepare command */ |
| 1076 | switch (cmd_no) { |
| 1077 | case HostCmd_CMD_GET_HW_SPEC: |
| 1078 | ret = mwifiex_cmd_get_hw_spec(priv, cmd_ptr); |
| 1079 | break; |
| 1080 | case HostCmd_CMD_MAC_CONTROL: |
| 1081 | ret = mwifiex_cmd_mac_control(priv, cmd_ptr, cmd_action, |
| 1082 | data_buf); |
| 1083 | break; |
| 1084 | case HostCmd_CMD_802_11_MAC_ADDRESS: |
| 1085 | ret = mwifiex_cmd_802_11_mac_address(priv, cmd_ptr, |
| 1086 | cmd_action); |
| 1087 | break; |
| 1088 | case HostCmd_CMD_MAC_MULTICAST_ADR: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1089 | ret = mwifiex_cmd_mac_multicast_adr(cmd_ptr, cmd_action, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1090 | data_buf); |
| 1091 | break; |
| 1092 | case HostCmd_CMD_TX_RATE_CFG: |
| 1093 | ret = mwifiex_cmd_tx_rate_cfg(priv, cmd_ptr, cmd_action, |
| 1094 | data_buf); |
| 1095 | break; |
| 1096 | case HostCmd_CMD_TXPWR_CFG: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1097 | ret = mwifiex_cmd_tx_power_cfg(cmd_ptr, cmd_action, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1098 | data_buf); |
| 1099 | break; |
Amitkumar Karwar | caa8984 | 2012-06-27 19:57:57 -0700 | [diff] [blame] | 1100 | case HostCmd_CMD_RF_TX_PWR: |
| 1101 | ret = mwifiex_cmd_rf_tx_power(priv, cmd_ptr, cmd_action, |
| 1102 | data_buf); |
| 1103 | break; |
Amitkumar Karwar | 8a279d5 | 2012-07-02 19:32:33 -0700 | [diff] [blame] | 1104 | case HostCmd_CMD_RF_ANTENNA: |
| 1105 | ret = mwifiex_cmd_rf_antenna(priv, cmd_ptr, cmd_action, |
| 1106 | data_buf); |
| 1107 | break; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1108 | case HostCmd_CMD_802_11_PS_MODE_ENH: |
| 1109 | ret = mwifiex_cmd_enh_power_mode(priv, cmd_ptr, cmd_action, |
| 1110 | (uint16_t)cmd_oid, data_buf); |
| 1111 | break; |
| 1112 | case HostCmd_CMD_802_11_HS_CFG_ENH: |
| 1113 | ret = mwifiex_cmd_802_11_hs_cfg(priv, cmd_ptr, cmd_action, |
| 1114 | (struct mwifiex_hs_config_param *) data_buf); |
| 1115 | break; |
| 1116 | case HostCmd_CMD_802_11_SCAN: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1117 | ret = mwifiex_cmd_802_11_scan(cmd_ptr, data_buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1118 | break; |
| 1119 | case HostCmd_CMD_802_11_BG_SCAN_QUERY: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1120 | ret = mwifiex_cmd_802_11_bg_scan_query(cmd_ptr); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1121 | break; |
| 1122 | case HostCmd_CMD_802_11_ASSOCIATE: |
| 1123 | ret = mwifiex_cmd_802_11_associate(priv, cmd_ptr, data_buf); |
| 1124 | break; |
| 1125 | case HostCmd_CMD_802_11_DEAUTHENTICATE: |
| 1126 | ret = mwifiex_cmd_802_11_deauthenticate(priv, cmd_ptr, |
| 1127 | data_buf); |
| 1128 | break; |
| 1129 | case HostCmd_CMD_802_11_AD_HOC_START: |
| 1130 | ret = mwifiex_cmd_802_11_ad_hoc_start(priv, cmd_ptr, |
| 1131 | data_buf); |
| 1132 | break; |
| 1133 | case HostCmd_CMD_802_11_GET_LOG: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1134 | ret = mwifiex_cmd_802_11_get_log(cmd_ptr); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1135 | break; |
| 1136 | case HostCmd_CMD_802_11_AD_HOC_JOIN: |
| 1137 | ret = mwifiex_cmd_802_11_ad_hoc_join(priv, cmd_ptr, |
| 1138 | data_buf); |
| 1139 | break; |
| 1140 | case HostCmd_CMD_802_11_AD_HOC_STOP: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1141 | ret = mwifiex_cmd_802_11_ad_hoc_stop(cmd_ptr); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1142 | break; |
| 1143 | case HostCmd_CMD_RSSI_INFO: |
| 1144 | ret = mwifiex_cmd_802_11_rssi_info(priv, cmd_ptr, cmd_action); |
| 1145 | break; |
| 1146 | case HostCmd_CMD_802_11_SNMP_MIB: |
| 1147 | ret = mwifiex_cmd_802_11_snmp_mib(priv, cmd_ptr, cmd_action, |
| 1148 | cmd_oid, data_buf); |
| 1149 | break; |
| 1150 | case HostCmd_CMD_802_11_TX_RATE_QUERY: |
| 1151 | cmd_ptr->command = |
| 1152 | cpu_to_le16(HostCmd_CMD_802_11_TX_RATE_QUERY); |
| 1153 | cmd_ptr->size = |
| 1154 | cpu_to_le16(sizeof(struct host_cmd_ds_tx_rate_query) + |
| 1155 | S_DS_GEN); |
| 1156 | priv->tx_rate = 0; |
| 1157 | ret = 0; |
| 1158 | break; |
| 1159 | case HostCmd_CMD_VERSION_EXT: |
| 1160 | cmd_ptr->command = cpu_to_le16(cmd_no); |
| 1161 | cmd_ptr->params.verext.version_str_sel = |
| 1162 | (u8) (*((u32 *) data_buf)); |
| 1163 | memcpy(&cmd_ptr->params, data_buf, |
| 1164 | sizeof(struct host_cmd_ds_version_ext)); |
| 1165 | cmd_ptr->size = |
| 1166 | cpu_to_le16(sizeof(struct host_cmd_ds_version_ext) + |
| 1167 | S_DS_GEN); |
| 1168 | ret = 0; |
| 1169 | break; |
Stone Piao | 3cec687 | 2012-09-25 20:23:34 -0700 | [diff] [blame] | 1170 | case HostCmd_CMD_MGMT_FRAME_REG: |
| 1171 | cmd_ptr->command = cpu_to_le16(cmd_no); |
| 1172 | cmd_ptr->params.reg_mask.action = cpu_to_le16(cmd_action); |
| 1173 | cmd_ptr->params.reg_mask.mask = cpu_to_le32(*(u32 *)data_buf); |
| 1174 | cmd_ptr->size = |
| 1175 | cpu_to_le16(sizeof(struct host_cmd_ds_mgmt_frame_reg) + |
| 1176 | S_DS_GEN); |
| 1177 | ret = 0; |
| 1178 | break; |
Stone Piao | 7feb4c4 | 2012-09-25 20:23:36 -0700 | [diff] [blame] | 1179 | case HostCmd_CMD_REMAIN_ON_CHAN: |
| 1180 | cmd_ptr->command = cpu_to_le16(cmd_no); |
| 1181 | memcpy(&cmd_ptr->params, data_buf, |
| 1182 | sizeof(struct host_cmd_ds_remain_on_chan)); |
| 1183 | cmd_ptr->size = |
| 1184 | cpu_to_le16(sizeof(struct host_cmd_ds_remain_on_chan) + |
| 1185 | S_DS_GEN); |
| 1186 | break; |
Stone Piao | e1a2b7a | 2012-09-25 20:23:41 -0700 | [diff] [blame^] | 1187 | case HostCmd_CMD_P2P_MODE_CFG: |
| 1188 | cmd_ptr->command = cpu_to_le16(cmd_no); |
| 1189 | cmd_ptr->params.mode_cfg.action = cpu_to_le16(cmd_action); |
| 1190 | cmd_ptr->params.mode_cfg.mode = cpu_to_le16(*(u16 *)data_buf); |
| 1191 | cmd_ptr->size = |
| 1192 | cpu_to_le16(sizeof(struct host_cmd_ds_p2p_mode_cfg) + |
| 1193 | S_DS_GEN); |
| 1194 | break; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1195 | case HostCmd_CMD_FUNC_INIT: |
| 1196 | if (priv->adapter->hw_status == MWIFIEX_HW_STATUS_RESET) |
| 1197 | priv->adapter->hw_status = MWIFIEX_HW_STATUS_READY; |
| 1198 | cmd_ptr->command = cpu_to_le16(cmd_no); |
| 1199 | cmd_ptr->size = cpu_to_le16(S_DS_GEN); |
| 1200 | break; |
| 1201 | case HostCmd_CMD_FUNC_SHUTDOWN: |
| 1202 | priv->adapter->hw_status = MWIFIEX_HW_STATUS_RESET; |
| 1203 | cmd_ptr->command = cpu_to_le16(cmd_no); |
| 1204 | cmd_ptr->size = cpu_to_le16(S_DS_GEN); |
| 1205 | break; |
| 1206 | case HostCmd_CMD_11N_ADDBA_REQ: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1207 | ret = mwifiex_cmd_11n_addba_req(cmd_ptr, data_buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1208 | break; |
| 1209 | case HostCmd_CMD_11N_DELBA: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1210 | ret = mwifiex_cmd_11n_delba(cmd_ptr, data_buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1211 | break; |
| 1212 | case HostCmd_CMD_11N_ADDBA_RSP: |
| 1213 | ret = mwifiex_cmd_11n_addba_rsp_gen(priv, cmd_ptr, data_buf); |
| 1214 | break; |
| 1215 | case HostCmd_CMD_802_11_KEY_MATERIAL: |
| 1216 | ret = mwifiex_cmd_802_11_key_material(priv, cmd_ptr, |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1217 | cmd_action, cmd_oid, |
| 1218 | data_buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1219 | break; |
| 1220 | case HostCmd_CMD_802_11D_DOMAIN_INFO: |
| 1221 | ret = mwifiex_cmd_802_11d_domain_info(priv, cmd_ptr, |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1222 | cmd_action); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1223 | break; |
| 1224 | case HostCmd_CMD_RECONFIGURE_TX_BUFF: |
| 1225 | ret = mwifiex_cmd_recfg_tx_buf(priv, cmd_ptr, cmd_action, |
| 1226 | data_buf); |
| 1227 | break; |
| 1228 | case HostCmd_CMD_AMSDU_AGGR_CTRL: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1229 | ret = mwifiex_cmd_amsdu_aggr_ctrl(cmd_ptr, cmd_action, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1230 | data_buf); |
| 1231 | break; |
| 1232 | case HostCmd_CMD_11N_CFG: |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1233 | ret = mwifiex_cmd_11n_cfg(cmd_ptr, cmd_action, data_buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1234 | break; |
| 1235 | case HostCmd_CMD_WMM_GET_STATUS: |
| 1236 | dev_dbg(priv->adapter->dev, |
| 1237 | "cmd: WMM: WMM_GET_STATUS cmd sent\n"); |
| 1238 | cmd_ptr->command = cpu_to_le16(HostCmd_CMD_WMM_GET_STATUS); |
| 1239 | cmd_ptr->size = |
| 1240 | cpu_to_le16(sizeof(struct host_cmd_ds_wmm_get_status) + |
| 1241 | S_DS_GEN); |
| 1242 | ret = 0; |
| 1243 | break; |
| 1244 | case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 1245 | ret = mwifiex_cmd_ibss_coalescing_status(cmd_ptr, cmd_action, |
| 1246 | data_buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1247 | break; |
| 1248 | case HostCmd_CMD_MAC_REG_ACCESS: |
| 1249 | case HostCmd_CMD_BBP_REG_ACCESS: |
| 1250 | case HostCmd_CMD_RF_REG_ACCESS: |
| 1251 | case HostCmd_CMD_PMIC_REG_ACCESS: |
| 1252 | case HostCmd_CMD_CAU_REG_ACCESS: |
| 1253 | case HostCmd_CMD_802_11_EEPROM_ACCESS: |
| 1254 | ret = mwifiex_cmd_reg_access(cmd_ptr, cmd_action, data_buf); |
| 1255 | break; |
| 1256 | case HostCmd_CMD_SET_BSS_MODE: |
| 1257 | cmd_ptr->command = cpu_to_le16(cmd_no); |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 1258 | if (priv->bss_mode == NL80211_IFTYPE_ADHOC) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1259 | cmd_ptr->params.bss_mode.con_type = |
| 1260 | CONNECTION_TYPE_ADHOC; |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 1261 | else if (priv->bss_mode == NL80211_IFTYPE_STATION) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1262 | cmd_ptr->params.bss_mode.con_type = |
| 1263 | CONNECTION_TYPE_INFRA; |
| 1264 | cmd_ptr->size = cpu_to_le16(sizeof(struct |
| 1265 | host_cmd_ds_set_bss_mode) + S_DS_GEN); |
| 1266 | ret = 0; |
| 1267 | break; |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 1268 | case HostCmd_CMD_PCIE_DESC_DETAILS: |
| 1269 | ret = mwifiex_cmd_pcie_host_spec(priv, cmd_ptr, cmd_action); |
| 1270 | break; |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 1271 | case HostCmd_CMD_802_11_SUBSCRIBE_EVENT: |
| 1272 | ret = mwifiex_cmd_802_11_subsc_evt(priv, cmd_ptr, data_buf); |
| 1273 | break; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1274 | default: |
| 1275 | dev_err(priv->adapter->dev, |
| 1276 | "PREP_CMD: unknown cmd- %#x\n", cmd_no); |
| 1277 | ret = -1; |
| 1278 | break; |
| 1279 | } |
| 1280 | return ret; |
| 1281 | } |
| 1282 | |
| 1283 | /* |
| 1284 | * This function issues commands to initialize firmware. |
| 1285 | * |
| 1286 | * This is called after firmware download to bring the card to |
| 1287 | * working state. |
| 1288 | * |
| 1289 | * The following commands are issued sequentially - |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 1290 | * - Set PCI-Express host buffer configuration (PCIE only) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1291 | * - Function init (for first interface only) |
| 1292 | * - Read MAC address (for first interface only) |
| 1293 | * - Reconfigure Tx buffer size (for first interface only) |
| 1294 | * - Enable auto deep sleep (for first interface only) |
| 1295 | * - Get Tx rate |
| 1296 | * - Get Tx power |
| 1297 | * - Set IBSS coalescing status |
| 1298 | * - Set AMSDU aggregation control |
| 1299 | * - Set 11d control |
| 1300 | * - Set MAC control (this must be the last command to initialize firmware) |
| 1301 | */ |
| 1302 | int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta) |
| 1303 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 1304 | int ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1305 | u16 enable = true; |
| 1306 | struct mwifiex_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl; |
| 1307 | struct mwifiex_ds_auto_ds auto_ds; |
| 1308 | enum state_11d_t state_11d; |
Amitkumar Karwar | cd27bc3 | 2011-07-08 20:40:30 -0700 | [diff] [blame] | 1309 | struct mwifiex_ds_11n_tx_cfg tx_cfg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1310 | |
| 1311 | if (first_sta) { |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 1312 | if (priv->adapter->iface_type == MWIFIEX_PCIE) { |
Stone Piao | 7bff9c9 | 2012-09-25 20:23:39 -0700 | [diff] [blame] | 1313 | ret = mwifiex_send_cmd_sync(priv, |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 1314 | HostCmd_CMD_PCIE_DESC_DETAILS, |
| 1315 | HostCmd_ACT_GEN_SET, 0, NULL); |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 1316 | if (ret) |
| 1317 | return -1; |
| 1318 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1319 | |
Stone Piao | 7bff9c9 | 2012-09-25 20:23:39 -0700 | [diff] [blame] | 1320 | ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_FUNC_INIT, |
| 1321 | HostCmd_ACT_GEN_SET, 0, NULL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1322 | if (ret) |
| 1323 | return -1; |
| 1324 | /* Read MAC address from HW */ |
Stone Piao | 7bff9c9 | 2012-09-25 20:23:39 -0700 | [diff] [blame] | 1325 | ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_GET_HW_SPEC, |
| 1326 | HostCmd_ACT_GEN_GET, 0, NULL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1327 | if (ret) |
| 1328 | return -1; |
| 1329 | |
| 1330 | /* Reconfigure tx buf size */ |
Stone Piao | 7bff9c9 | 2012-09-25 20:23:39 -0700 | [diff] [blame] | 1331 | ret = mwifiex_send_cmd_sync(priv, |
| 1332 | HostCmd_CMD_RECONFIGURE_TX_BUFF, |
| 1333 | HostCmd_ACT_GEN_SET, 0, |
| 1334 | &priv->adapter->tx_buf_size); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1335 | if (ret) |
| 1336 | return -1; |
| 1337 | |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 1338 | if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { |
| 1339 | /* Enable IEEE PS by default */ |
| 1340 | priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP; |
Stone Piao | 7bff9c9 | 2012-09-25 20:23:39 -0700 | [diff] [blame] | 1341 | ret = mwifiex_send_cmd_sync( |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 1342 | priv, HostCmd_CMD_802_11_PS_MODE_ENH, |
| 1343 | EN_AUTO_PS, BITMAP_STA_PS, NULL); |
| 1344 | if (ret) |
| 1345 | return -1; |
| 1346 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1347 | } |
| 1348 | |
| 1349 | /* get tx rate */ |
Stone Piao | 7bff9c9 | 2012-09-25 20:23:39 -0700 | [diff] [blame] | 1350 | ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TX_RATE_CFG, |
| 1351 | HostCmd_ACT_GEN_GET, 0, NULL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1352 | if (ret) |
| 1353 | return -1; |
| 1354 | priv->data_rate = 0; |
| 1355 | |
| 1356 | /* get tx power */ |
Stone Piao | 7bff9c9 | 2012-09-25 20:23:39 -0700 | [diff] [blame] | 1357 | ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_RF_TX_PWR, |
| 1358 | HostCmd_ACT_GEN_GET, 0, NULL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1359 | if (ret) |
| 1360 | return -1; |
| 1361 | |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 1362 | if (priv->bss_type == MWIFIEX_BSS_TYPE_STA) { |
| 1363 | /* set ibss coalescing_status */ |
Stone Piao | 7bff9c9 | 2012-09-25 20:23:39 -0700 | [diff] [blame] | 1364 | ret = mwifiex_send_cmd_sync( |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 1365 | priv, HostCmd_CMD_802_11_IBSS_COALESCING_STATUS, |
| 1366 | HostCmd_ACT_GEN_SET, 0, &enable); |
| 1367 | if (ret) |
| 1368 | return -1; |
| 1369 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1370 | |
| 1371 | memset(&amsdu_aggr_ctrl, 0, sizeof(amsdu_aggr_ctrl)); |
| 1372 | amsdu_aggr_ctrl.enable = true; |
| 1373 | /* Send request to firmware */ |
Stone Piao | 7bff9c9 | 2012-09-25 20:23:39 -0700 | [diff] [blame] | 1374 | ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_AMSDU_AGGR_CTRL, |
| 1375 | HostCmd_ACT_GEN_SET, 0, |
| 1376 | &amsdu_aggr_ctrl); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1377 | if (ret) |
| 1378 | return -1; |
| 1379 | /* MAC Control must be the last command in init_fw */ |
| 1380 | /* set MAC Control */ |
Stone Piao | 7bff9c9 | 2012-09-25 20:23:39 -0700 | [diff] [blame] | 1381 | ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_MAC_CONTROL, |
| 1382 | HostCmd_ACT_GEN_SET, 0, |
| 1383 | &priv->curr_pkt_filter); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1384 | if (ret) |
| 1385 | return -1; |
| 1386 | |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 1387 | if (first_sta && priv->adapter->iface_type != MWIFIEX_USB && |
| 1388 | priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1389 | /* Enable auto deep sleep */ |
| 1390 | auto_ds.auto_ds = DEEP_SLEEP_ON; |
| 1391 | auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME; |
Stone Piao | 7bff9c9 | 2012-09-25 20:23:39 -0700 | [diff] [blame] | 1392 | ret = mwifiex_send_cmd_sync(priv, |
| 1393 | HostCmd_CMD_802_11_PS_MODE_ENH, |
| 1394 | EN_AUTO_PS, BITMAP_AUTO_DS, |
| 1395 | &auto_ds); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1396 | if (ret) |
| 1397 | return -1; |
| 1398 | } |
| 1399 | |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 1400 | if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { |
| 1401 | /* Send cmd to FW to enable/disable 11D function */ |
| 1402 | state_11d = ENABLE_11D; |
Stone Piao | 7bff9c9 | 2012-09-25 20:23:39 -0700 | [diff] [blame] | 1403 | ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB, |
| 1404 | HostCmd_ACT_GEN_SET, DOT11D_I, |
| 1405 | &state_11d); |
Avinash Patil | 0378538 | 2012-05-08 18:30:14 -0700 | [diff] [blame] | 1406 | if (ret) |
| 1407 | dev_err(priv->adapter->dev, |
| 1408 | "11D: failed to enable 11D\n"); |
| 1409 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1410 | |
Stone Piao | 7bff9c9 | 2012-09-25 20:23:39 -0700 | [diff] [blame] | 1411 | /* set last_init_cmd before sending the command */ |
| 1412 | priv->adapter->last_init_cmd = HostCmd_CMD_11N_CFG; |
| 1413 | |
Amitkumar Karwar | cd27bc3 | 2011-07-08 20:40:30 -0700 | [diff] [blame] | 1414 | /* Send cmd to FW to configure 11n specific configuration |
| 1415 | * (Short GI, Channel BW, Green field support etc.) for transmit |
| 1416 | */ |
| 1417 | tx_cfg.tx_htcap = MWIFIEX_FW_DEF_HTTXCFG; |
Stone Piao | 7bff9c9 | 2012-09-25 20:23:39 -0700 | [diff] [blame] | 1418 | ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_11N_CFG, |
| 1419 | HostCmd_ACT_GEN_SET, 0, &tx_cfg); |
Amitkumar Karwar | cd27bc3 | 2011-07-08 20:40:30 -0700 | [diff] [blame] | 1420 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1421 | ret = -EINPROGRESS; |
| 1422 | |
| 1423 | return ret; |
| 1424 | } |