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