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