0001
0002
0003
0004
0005
0006
0007
0008 #include "decl.h"
0009 #include "ioctl.h"
0010 #include "util.h"
0011 #include "fw.h"
0012 #include "main.h"
0013 #include "wmm.h"
0014 #include "11n.h"
0015 #include "11ac.h"
0016
0017 static bool drcs;
0018 module_param(drcs, bool, 0644);
0019 MODULE_PARM_DESC(drcs, "multi-channel operation:1, single-channel operation:0");
0020
0021 static bool disable_auto_ds;
0022 module_param(disable_auto_ds, bool, 0);
0023 MODULE_PARM_DESC(disable_auto_ds,
0024 "deepsleep enabled=0(default), deepsleep disabled=1");
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 static int
0035 mwifiex_cmd_802_11_rssi_info(struct mwifiex_private *priv,
0036 struct host_cmd_ds_command *cmd, u16 cmd_action)
0037 {
0038 cmd->command = cpu_to_le16(HostCmd_CMD_RSSI_INFO);
0039 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_rssi_info) +
0040 S_DS_GEN);
0041 cmd->params.rssi_info.action = cpu_to_le16(cmd_action);
0042 cmd->params.rssi_info.ndata = cpu_to_le16(priv->data_avg_factor);
0043 cmd->params.rssi_info.nbcn = cpu_to_le16(priv->bcn_avg_factor);
0044
0045
0046 priv->data_rssi_last = 0;
0047 priv->data_nf_last = 0;
0048 priv->data_rssi_avg = 0;
0049 priv->data_nf_avg = 0;
0050 priv->bcn_rssi_last = 0;
0051 priv->bcn_nf_last = 0;
0052 priv->bcn_rssi_avg = 0;
0053 priv->bcn_nf_avg = 0;
0054
0055 return 0;
0056 }
0057
0058
0059
0060
0061
0062
0063
0064
0065 static int mwifiex_cmd_mac_control(struct mwifiex_private *priv,
0066 struct host_cmd_ds_command *cmd,
0067 u16 cmd_action, u32 *action)
0068 {
0069 struct host_cmd_ds_mac_control *mac_ctrl = &cmd->params.mac_ctrl;
0070
0071 if (cmd_action != HostCmd_ACT_GEN_SET) {
0072 mwifiex_dbg(priv->adapter, ERROR,
0073 "mac_control: only support set cmd\n");
0074 return -1;
0075 }
0076
0077 cmd->command = cpu_to_le16(HostCmd_CMD_MAC_CONTROL);
0078 cmd->size =
0079 cpu_to_le16(sizeof(struct host_cmd_ds_mac_control) + S_DS_GEN);
0080 mac_ctrl->action = cpu_to_le32(*action);
0081
0082 return 0;
0083 }
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100 static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv,
0101 struct host_cmd_ds_command *cmd,
0102 u16 cmd_action, u32 cmd_oid,
0103 u16 *ul_temp)
0104 {
0105 struct host_cmd_ds_802_11_snmp_mib *snmp_mib = &cmd->params.smib;
0106
0107 mwifiex_dbg(priv->adapter, CMD,
0108 "cmd: SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid);
0109 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SNMP_MIB);
0110 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_snmp_mib)
0111 - 1 + S_DS_GEN);
0112
0113 snmp_mib->oid = cpu_to_le16((u16)cmd_oid);
0114 if (cmd_action == HostCmd_ACT_GEN_GET) {
0115 snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_GET);
0116 snmp_mib->buf_size = cpu_to_le16(MAX_SNMP_BUF_SIZE);
0117 le16_unaligned_add_cpu(&cmd->size, MAX_SNMP_BUF_SIZE);
0118 } else if (cmd_action == HostCmd_ACT_GEN_SET) {
0119 snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET);
0120 snmp_mib->buf_size = cpu_to_le16(sizeof(u16));
0121 put_unaligned_le16(*ul_temp, snmp_mib->value);
0122 le16_unaligned_add_cpu(&cmd->size, sizeof(u16));
0123 }
0124
0125 mwifiex_dbg(priv->adapter, CMD,
0126 "cmd: SNMP_CMD: Action=0x%x, OID=0x%x,\t"
0127 "OIDSize=0x%x, Value=0x%x\n",
0128 cmd_action, cmd_oid, le16_to_cpu(snmp_mib->buf_size),
0129 get_unaligned_le16(snmp_mib->value));
0130 return 0;
0131 }
0132
0133
0134
0135
0136
0137
0138
0139
0140 static int
0141 mwifiex_cmd_802_11_get_log(struct host_cmd_ds_command *cmd)
0142 {
0143 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_GET_LOG);
0144 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_get_log) +
0145 S_DS_GEN);
0146 return 0;
0147 }
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158 static int mwifiex_cmd_tx_rate_cfg(struct mwifiex_private *priv,
0159 struct host_cmd_ds_command *cmd,
0160 u16 cmd_action, u16 *pbitmap_rates)
0161 {
0162 struct host_cmd_ds_tx_rate_cfg *rate_cfg = &cmd->params.tx_rate_cfg;
0163 struct mwifiex_rate_scope *rate_scope;
0164 struct mwifiex_rate_drop_pattern *rate_drop;
0165 u32 i;
0166
0167 cmd->command = cpu_to_le16(HostCmd_CMD_TX_RATE_CFG);
0168
0169 rate_cfg->action = cpu_to_le16(cmd_action);
0170 rate_cfg->cfg_index = 0;
0171
0172 rate_scope = (struct mwifiex_rate_scope *) ((u8 *) rate_cfg +
0173 sizeof(struct host_cmd_ds_tx_rate_cfg));
0174 rate_scope->type = cpu_to_le16(TLV_TYPE_RATE_SCOPE);
0175 rate_scope->length = cpu_to_le16
0176 (sizeof(*rate_scope) - sizeof(struct mwifiex_ie_types_header));
0177 if (pbitmap_rates != NULL) {
0178 rate_scope->hr_dsss_rate_bitmap = cpu_to_le16(pbitmap_rates[0]);
0179 rate_scope->ofdm_rate_bitmap = cpu_to_le16(pbitmap_rates[1]);
0180 for (i = 0; i < ARRAY_SIZE(rate_scope->ht_mcs_rate_bitmap); i++)
0181 rate_scope->ht_mcs_rate_bitmap[i] =
0182 cpu_to_le16(pbitmap_rates[2 + i]);
0183 if (priv->adapter->fw_api_ver == MWIFIEX_FW_V15) {
0184 for (i = 0;
0185 i < ARRAY_SIZE(rate_scope->vht_mcs_rate_bitmap);
0186 i++)
0187 rate_scope->vht_mcs_rate_bitmap[i] =
0188 cpu_to_le16(pbitmap_rates[10 + i]);
0189 }
0190 } else {
0191 rate_scope->hr_dsss_rate_bitmap =
0192 cpu_to_le16(priv->bitmap_rates[0]);
0193 rate_scope->ofdm_rate_bitmap =
0194 cpu_to_le16(priv->bitmap_rates[1]);
0195 for (i = 0; i < ARRAY_SIZE(rate_scope->ht_mcs_rate_bitmap); i++)
0196 rate_scope->ht_mcs_rate_bitmap[i] =
0197 cpu_to_le16(priv->bitmap_rates[2 + i]);
0198 if (priv->adapter->fw_api_ver == MWIFIEX_FW_V15) {
0199 for (i = 0;
0200 i < ARRAY_SIZE(rate_scope->vht_mcs_rate_bitmap);
0201 i++)
0202 rate_scope->vht_mcs_rate_bitmap[i] =
0203 cpu_to_le16(priv->bitmap_rates[10 + i]);
0204 }
0205 }
0206
0207 rate_drop = (struct mwifiex_rate_drop_pattern *) ((u8 *) rate_scope +
0208 sizeof(struct mwifiex_rate_scope));
0209 rate_drop->type = cpu_to_le16(TLV_TYPE_RATE_DROP_CONTROL);
0210 rate_drop->length = cpu_to_le16(sizeof(rate_drop->rate_drop_mode));
0211 rate_drop->rate_drop_mode = 0;
0212
0213 cmd->size =
0214 cpu_to_le16(S_DS_GEN + sizeof(struct host_cmd_ds_tx_rate_cfg) +
0215 sizeof(struct mwifiex_rate_scope) +
0216 sizeof(struct mwifiex_rate_drop_pattern));
0217
0218 return 0;
0219 }
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230 static int mwifiex_cmd_tx_power_cfg(struct host_cmd_ds_command *cmd,
0231 u16 cmd_action,
0232 struct host_cmd_ds_txpwr_cfg *txp)
0233 {
0234 struct mwifiex_types_power_group *pg_tlv;
0235 struct host_cmd_ds_txpwr_cfg *cmd_txp_cfg = &cmd->params.txp_cfg;
0236
0237 cmd->command = cpu_to_le16(HostCmd_CMD_TXPWR_CFG);
0238 cmd->size =
0239 cpu_to_le16(S_DS_GEN + sizeof(struct host_cmd_ds_txpwr_cfg));
0240 switch (cmd_action) {
0241 case HostCmd_ACT_GEN_SET:
0242 if (txp->mode) {
0243 pg_tlv = (struct mwifiex_types_power_group
0244 *) ((unsigned long) txp +
0245 sizeof(struct host_cmd_ds_txpwr_cfg));
0246 memmove(cmd_txp_cfg, txp,
0247 sizeof(struct host_cmd_ds_txpwr_cfg) +
0248 sizeof(struct mwifiex_types_power_group) +
0249 le16_to_cpu(pg_tlv->length));
0250
0251 pg_tlv = (struct mwifiex_types_power_group *) ((u8 *)
0252 cmd_txp_cfg +
0253 sizeof(struct host_cmd_ds_txpwr_cfg));
0254 cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) +
0255 sizeof(struct mwifiex_types_power_group) +
0256 le16_to_cpu(pg_tlv->length));
0257 } else {
0258 memmove(cmd_txp_cfg, txp, sizeof(*txp));
0259 }
0260 cmd_txp_cfg->action = cpu_to_le16(cmd_action);
0261 break;
0262 case HostCmd_ACT_GEN_GET:
0263 cmd_txp_cfg->action = cpu_to_le16(cmd_action);
0264 break;
0265 }
0266
0267 return 0;
0268 }
0269
0270
0271
0272
0273 static int mwifiex_cmd_rf_tx_power(struct mwifiex_private *priv,
0274 struct host_cmd_ds_command *cmd,
0275 u16 cmd_action, void *data_buf)
0276 {
0277 struct host_cmd_ds_rf_tx_pwr *txp = &cmd->params.txp;
0278
0279 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_tx_pwr)
0280 + S_DS_GEN);
0281 cmd->command = cpu_to_le16(HostCmd_CMD_RF_TX_PWR);
0282 txp->action = cpu_to_le16(cmd_action);
0283
0284 return 0;
0285 }
0286
0287
0288
0289
0290 static int mwifiex_cmd_rf_antenna(struct mwifiex_private *priv,
0291 struct host_cmd_ds_command *cmd,
0292 u16 cmd_action,
0293 struct mwifiex_ds_ant_cfg *ant_cfg)
0294 {
0295 struct host_cmd_ds_rf_ant_mimo *ant_mimo = &cmd->params.ant_mimo;
0296 struct host_cmd_ds_rf_ant_siso *ant_siso = &cmd->params.ant_siso;
0297
0298 cmd->command = cpu_to_le16(HostCmd_CMD_RF_ANTENNA);
0299
0300 switch (cmd_action) {
0301 case HostCmd_ACT_GEN_SET:
0302 if (priv->adapter->hw_dev_mcs_support == HT_STREAM_2X2) {
0303 cmd->size = cpu_to_le16(sizeof(struct
0304 host_cmd_ds_rf_ant_mimo)
0305 + S_DS_GEN);
0306 ant_mimo->action_tx = cpu_to_le16(HostCmd_ACT_SET_TX);
0307 ant_mimo->tx_ant_mode = cpu_to_le16((u16)ant_cfg->
0308 tx_ant);
0309 ant_mimo->action_rx = cpu_to_le16(HostCmd_ACT_SET_RX);
0310 ant_mimo->rx_ant_mode = cpu_to_le16((u16)ant_cfg->
0311 rx_ant);
0312 } else {
0313 cmd->size = cpu_to_le16(sizeof(struct
0314 host_cmd_ds_rf_ant_siso) +
0315 S_DS_GEN);
0316 ant_siso->action = cpu_to_le16(HostCmd_ACT_SET_BOTH);
0317 ant_siso->ant_mode = cpu_to_le16((u16)ant_cfg->tx_ant);
0318 }
0319 break;
0320 case HostCmd_ACT_GEN_GET:
0321 if (priv->adapter->hw_dev_mcs_support == HT_STREAM_2X2) {
0322 cmd->size = cpu_to_le16(sizeof(struct
0323 host_cmd_ds_rf_ant_mimo) +
0324 S_DS_GEN);
0325 ant_mimo->action_tx = cpu_to_le16(HostCmd_ACT_GET_TX);
0326 ant_mimo->action_rx = cpu_to_le16(HostCmd_ACT_GET_RX);
0327 } else {
0328 cmd->size = cpu_to_le16(sizeof(struct
0329 host_cmd_ds_rf_ant_siso) +
0330 S_DS_GEN);
0331 ant_siso->action = cpu_to_le16(HostCmd_ACT_GET_BOTH);
0332 }
0333 break;
0334 }
0335 return 0;
0336 }
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347 static int
0348 mwifiex_cmd_802_11_hs_cfg(struct mwifiex_private *priv,
0349 struct host_cmd_ds_command *cmd,
0350 u16 cmd_action,
0351 struct mwifiex_hs_config_param *hscfg_param)
0352 {
0353 struct mwifiex_adapter *adapter = priv->adapter;
0354 struct host_cmd_ds_802_11_hs_cfg_enh *hs_cfg = &cmd->params.opt_hs_cfg;
0355 u8 *tlv = (u8 *)hs_cfg + sizeof(struct host_cmd_ds_802_11_hs_cfg_enh);
0356 struct mwifiex_ps_param_in_hs *psparam_tlv = NULL;
0357 bool hs_activate = false;
0358 u16 size;
0359
0360 if (!hscfg_param)
0361
0362 hs_activate = true;
0363 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_HS_CFG_ENH);
0364
0365 if (!hs_activate &&
0366 (hscfg_param->conditions != cpu_to_le32(HS_CFG_CANCEL)) &&
0367 ((adapter->arp_filter_size > 0) &&
0368 (adapter->arp_filter_size <= ARP_FILTER_MAX_BUF_SIZE))) {
0369 mwifiex_dbg(adapter, CMD,
0370 "cmd: Attach %d bytes ArpFilter to HSCfg cmd\n",
0371 adapter->arp_filter_size);
0372 memcpy(((u8 *) hs_cfg) +
0373 sizeof(struct host_cmd_ds_802_11_hs_cfg_enh),
0374 adapter->arp_filter, adapter->arp_filter_size);
0375 size = adapter->arp_filter_size +
0376 sizeof(struct host_cmd_ds_802_11_hs_cfg_enh)
0377 + S_DS_GEN;
0378 tlv = (u8 *)hs_cfg
0379 + sizeof(struct host_cmd_ds_802_11_hs_cfg_enh)
0380 + adapter->arp_filter_size;
0381 } else {
0382 size = S_DS_GEN + sizeof(struct host_cmd_ds_802_11_hs_cfg_enh);
0383 }
0384 if (hs_activate) {
0385 hs_cfg->action = cpu_to_le16(HS_ACTIVATE);
0386 hs_cfg->params.hs_activate.resp_ctrl = cpu_to_le16(RESP_NEEDED);
0387
0388 adapter->hs_activated_manually = true;
0389 mwifiex_dbg(priv->adapter, CMD,
0390 "cmd: Activating host sleep manually\n");
0391 } else {
0392 hs_cfg->action = cpu_to_le16(HS_CONFIGURE);
0393 hs_cfg->params.hs_config.conditions = hscfg_param->conditions;
0394 hs_cfg->params.hs_config.gpio = hscfg_param->gpio;
0395 hs_cfg->params.hs_config.gap = hscfg_param->gap;
0396
0397 size += sizeof(struct mwifiex_ps_param_in_hs);
0398 psparam_tlv = (struct mwifiex_ps_param_in_hs *)tlv;
0399 psparam_tlv->header.type =
0400 cpu_to_le16(TLV_TYPE_PS_PARAMS_IN_HS);
0401 psparam_tlv->header.len =
0402 cpu_to_le16(sizeof(struct mwifiex_ps_param_in_hs)
0403 - sizeof(struct mwifiex_ie_types_header));
0404 psparam_tlv->hs_wake_int = cpu_to_le32(HS_DEF_WAKE_INTERVAL);
0405 psparam_tlv->hs_inact_timeout =
0406 cpu_to_le32(HS_DEF_INACTIVITY_TIMEOUT);
0407
0408 mwifiex_dbg(adapter, CMD,
0409 "cmd: HS_CFG_CMD: condition:0x%x gpio:0x%x gap:0x%x\n",
0410 hs_cfg->params.hs_config.conditions,
0411 hs_cfg->params.hs_config.gpio,
0412 hs_cfg->params.hs_config.gap);
0413 }
0414 cmd->size = cpu_to_le16(size);
0415
0416 return 0;
0417 }
0418
0419
0420
0421
0422
0423
0424
0425
0426
0427 static int mwifiex_cmd_802_11_mac_address(struct mwifiex_private *priv,
0428 struct host_cmd_ds_command *cmd,
0429 u16 cmd_action)
0430 {
0431 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_MAC_ADDRESS);
0432 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_mac_address) +
0433 S_DS_GEN);
0434 cmd->result = 0;
0435
0436 cmd->params.mac_addr.action = cpu_to_le16(cmd_action);
0437
0438 if (cmd_action == HostCmd_ACT_GEN_SET)
0439 memcpy(cmd->params.mac_addr.mac_addr, priv->curr_addr,
0440 ETH_ALEN);
0441 return 0;
0442 }
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452 static int
0453 mwifiex_cmd_mac_multicast_adr(struct host_cmd_ds_command *cmd,
0454 u16 cmd_action,
0455 struct mwifiex_multicast_list *mcast_list)
0456 {
0457 struct host_cmd_ds_mac_multicast_adr *mcast_addr = &cmd->params.mc_addr;
0458
0459 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_mac_multicast_adr) +
0460 S_DS_GEN);
0461 cmd->command = cpu_to_le16(HostCmd_CMD_MAC_MULTICAST_ADR);
0462
0463 mcast_addr->action = cpu_to_le16(cmd_action);
0464 mcast_addr->num_of_adrs =
0465 cpu_to_le16((u16) mcast_list->num_multicast_addr);
0466 memcpy(mcast_addr->mac_list, mcast_list->mac_list,
0467 mcast_list->num_multicast_addr * ETH_ALEN);
0468
0469 return 0;
0470 }
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480 static int mwifiex_cmd_802_11_deauthenticate(struct mwifiex_private *priv,
0481 struct host_cmd_ds_command *cmd,
0482 u8 *mac)
0483 {
0484 struct host_cmd_ds_802_11_deauthenticate *deauth = &cmd->params.deauth;
0485
0486 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_DEAUTHENTICATE);
0487 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_deauthenticate)
0488 + S_DS_GEN);
0489
0490
0491 memcpy(deauth->mac_addr, mac, ETH_ALEN);
0492
0493 mwifiex_dbg(priv->adapter, CMD, "cmd: Deauth: %pM\n", deauth->mac_addr);
0494
0495 deauth->reason_code = cpu_to_le16(WLAN_REASON_DEAUTH_LEAVING);
0496
0497 return 0;
0498 }
0499
0500
0501
0502
0503
0504
0505
0506
0507 static int mwifiex_cmd_802_11_ad_hoc_stop(struct host_cmd_ds_command *cmd)
0508 {
0509 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_STOP);
0510 cmd->size = cpu_to_le16(S_DS_GEN);
0511 return 0;
0512 }
0513
0514
0515
0516
0517
0518
0519
0520 static int
0521 mwifiex_set_keyparamset_wep(struct mwifiex_private *priv,
0522 struct mwifiex_ie_type_key_param_set *key_param_set,
0523 u16 *key_param_len)
0524 {
0525 int cur_key_param_len;
0526 u8 i;
0527
0528
0529 for (i = 0; i < NUM_WEP_KEYS; i++) {
0530 if ((priv->wep_key[i].key_length == WLAN_KEY_LEN_WEP40) ||
0531 (priv->wep_key[i].key_length == WLAN_KEY_LEN_WEP104)) {
0532 key_param_set->type =
0533 cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
0534
0535 #define KEYPARAMSET_WEP_FIXED_LEN 8
0536 key_param_set->length = cpu_to_le16((u16)
0537 (priv->wep_key[i].
0538 key_length +
0539 KEYPARAMSET_WEP_FIXED_LEN));
0540 key_param_set->key_type_id =
0541 cpu_to_le16(KEY_TYPE_ID_WEP);
0542 key_param_set->key_info =
0543 cpu_to_le16(KEY_ENABLED | KEY_UNICAST |
0544 KEY_MCAST);
0545 key_param_set->key_len =
0546 cpu_to_le16(priv->wep_key[i].key_length);
0547
0548 key_param_set->key[0] = i;
0549
0550 if (i ==
0551 (priv->
0552 wep_key_curr_index & HostCmd_WEP_KEY_INDEX_MASK))
0553 key_param_set->key[1] = 1;
0554 else
0555 key_param_set->key[1] = 0;
0556 memmove(&key_param_set->key[2],
0557 priv->wep_key[i].key_material,
0558 priv->wep_key[i].key_length);
0559
0560 cur_key_param_len = priv->wep_key[i].key_length +
0561 KEYPARAMSET_WEP_FIXED_LEN +
0562 sizeof(struct mwifiex_ie_types_header);
0563 *key_param_len += (u16) cur_key_param_len;
0564 key_param_set =
0565 (struct mwifiex_ie_type_key_param_set *)
0566 ((u8 *)key_param_set +
0567 cur_key_param_len);
0568 } else if (!priv->wep_key[i].key_length) {
0569 continue;
0570 } else {
0571 mwifiex_dbg(priv->adapter, ERROR,
0572 "key%d Length = %d is incorrect\n",
0573 (i + 1), priv->wep_key[i].key_length);
0574 return -1;
0575 }
0576 }
0577
0578 return 0;
0579 }
0580
0581
0582
0583
0584 static int mwifiex_set_aes_key_v2(struct mwifiex_private *priv,
0585 struct host_cmd_ds_command *cmd,
0586 struct mwifiex_ds_encrypt_key *enc_key,
0587 struct host_cmd_ds_802_11_key_material_v2 *km)
0588 {
0589 struct mwifiex_adapter *adapter = priv->adapter;
0590 u16 size, len = KEY_PARAMS_FIXED_LEN;
0591
0592 if (enc_key->is_igtk_key) {
0593 mwifiex_dbg(adapter, INFO,
0594 "%s: Set CMAC AES Key\n", __func__);
0595 if (enc_key->is_rx_seq_valid)
0596 memcpy(km->key_param_set.key_params.cmac_aes.ipn,
0597 enc_key->pn, enc_key->pn_len);
0598 km->key_param_set.key_info &= cpu_to_le16(~KEY_MCAST);
0599 km->key_param_set.key_info |= cpu_to_le16(KEY_IGTK);
0600 km->key_param_set.key_type = KEY_TYPE_ID_AES_CMAC;
0601 km->key_param_set.key_params.cmac_aes.key_len =
0602 cpu_to_le16(enc_key->key_len);
0603 memcpy(km->key_param_set.key_params.cmac_aes.key,
0604 enc_key->key_material, enc_key->key_len);
0605 len += sizeof(struct mwifiex_cmac_aes_param);
0606 } else if (enc_key->is_igtk_def_key) {
0607 mwifiex_dbg(adapter, INFO,
0608 "%s: Set CMAC default Key index\n", __func__);
0609 km->key_param_set.key_type = KEY_TYPE_ID_AES_CMAC_DEF;
0610 km->key_param_set.key_idx = enc_key->key_index & KEY_INDEX_MASK;
0611 } else {
0612 mwifiex_dbg(adapter, INFO,
0613 "%s: Set AES Key\n", __func__);
0614 if (enc_key->is_rx_seq_valid)
0615 memcpy(km->key_param_set.key_params.aes.pn,
0616 enc_key->pn, enc_key->pn_len);
0617 km->key_param_set.key_type = KEY_TYPE_ID_AES;
0618 km->key_param_set.key_params.aes.key_len =
0619 cpu_to_le16(enc_key->key_len);
0620 memcpy(km->key_param_set.key_params.aes.key,
0621 enc_key->key_material, enc_key->key_len);
0622 len += sizeof(struct mwifiex_aes_param);
0623 }
0624
0625 km->key_param_set.len = cpu_to_le16(len);
0626 size = len + sizeof(struct mwifiex_ie_types_header) +
0627 sizeof(km->action) + S_DS_GEN;
0628 cmd->size = cpu_to_le16(size);
0629
0630 return 0;
0631 }
0632
0633
0634
0635
0636
0637
0638
0639
0640
0641 static int
0642 mwifiex_cmd_802_11_key_material_v2(struct mwifiex_private *priv,
0643 struct host_cmd_ds_command *cmd,
0644 u16 cmd_action, u32 cmd_oid,
0645 struct mwifiex_ds_encrypt_key *enc_key)
0646 {
0647 struct mwifiex_adapter *adapter = priv->adapter;
0648 u8 *mac = enc_key->mac_addr;
0649 u16 key_info, len = KEY_PARAMS_FIXED_LEN;
0650 struct host_cmd_ds_802_11_key_material_v2 *km =
0651 &cmd->params.key_material_v2;
0652
0653 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_KEY_MATERIAL);
0654 km->action = cpu_to_le16(cmd_action);
0655
0656 if (cmd_action == HostCmd_ACT_GEN_GET) {
0657 mwifiex_dbg(adapter, INFO, "%s: Get key\n", __func__);
0658 km->key_param_set.key_idx =
0659 enc_key->key_index & KEY_INDEX_MASK;
0660 km->key_param_set.type = cpu_to_le16(TLV_TYPE_KEY_PARAM_V2);
0661 km->key_param_set.len = cpu_to_le16(KEY_PARAMS_FIXED_LEN);
0662 memcpy(km->key_param_set.mac_addr, mac, ETH_ALEN);
0663
0664 if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST)
0665 key_info = KEY_UNICAST;
0666 else
0667 key_info = KEY_MCAST;
0668
0669 if (enc_key->is_igtk_key)
0670 key_info |= KEY_IGTK;
0671
0672 km->key_param_set.key_info = cpu_to_le16(key_info);
0673
0674 cmd->size = cpu_to_le16(sizeof(struct mwifiex_ie_types_header) +
0675 S_DS_GEN + KEY_PARAMS_FIXED_LEN +
0676 sizeof(km->action));
0677 return 0;
0678 }
0679
0680 memset(&km->key_param_set, 0,
0681 sizeof(struct mwifiex_ie_type_key_param_set_v2));
0682
0683 if (enc_key->key_disable) {
0684 mwifiex_dbg(adapter, INFO, "%s: Remove key\n", __func__);
0685 km->action = cpu_to_le16(HostCmd_ACT_GEN_REMOVE);
0686 km->key_param_set.type = cpu_to_le16(TLV_TYPE_KEY_PARAM_V2);
0687 km->key_param_set.len = cpu_to_le16(KEY_PARAMS_FIXED_LEN);
0688 km->key_param_set.key_idx = enc_key->key_index & KEY_INDEX_MASK;
0689 key_info = KEY_MCAST | KEY_UNICAST;
0690 km->key_param_set.key_info = cpu_to_le16(key_info);
0691 memcpy(km->key_param_set.mac_addr, mac, ETH_ALEN);
0692 cmd->size = cpu_to_le16(sizeof(struct mwifiex_ie_types_header) +
0693 S_DS_GEN + KEY_PARAMS_FIXED_LEN +
0694 sizeof(km->action));
0695 return 0;
0696 }
0697
0698 km->action = cpu_to_le16(HostCmd_ACT_GEN_SET);
0699 km->key_param_set.key_idx = enc_key->key_index & KEY_INDEX_MASK;
0700 km->key_param_set.type = cpu_to_le16(TLV_TYPE_KEY_PARAM_V2);
0701 key_info = KEY_ENABLED;
0702 memcpy(km->key_param_set.mac_addr, mac, ETH_ALEN);
0703
0704 if (enc_key->key_len <= WLAN_KEY_LEN_WEP104) {
0705 mwifiex_dbg(adapter, INFO, "%s: Set WEP Key\n", __func__);
0706 len += sizeof(struct mwifiex_wep_param);
0707 km->key_param_set.len = cpu_to_le16(len);
0708 km->key_param_set.key_type = KEY_TYPE_ID_WEP;
0709
0710 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) {
0711 key_info |= KEY_MCAST | KEY_UNICAST;
0712 } else {
0713 if (enc_key->is_current_wep_key) {
0714 key_info |= KEY_MCAST | KEY_UNICAST;
0715 if (km->key_param_set.key_idx ==
0716 (priv->wep_key_curr_index & KEY_INDEX_MASK))
0717 key_info |= KEY_DEFAULT;
0718 } else {
0719 if (is_broadcast_ether_addr(mac))
0720 key_info |= KEY_MCAST;
0721 else
0722 key_info |= KEY_UNICAST | KEY_DEFAULT;
0723 }
0724 }
0725 km->key_param_set.key_info = cpu_to_le16(key_info);
0726
0727 km->key_param_set.key_params.wep.key_len =
0728 cpu_to_le16(enc_key->key_len);
0729 memcpy(km->key_param_set.key_params.wep.key,
0730 enc_key->key_material, enc_key->key_len);
0731
0732 cmd->size = cpu_to_le16(sizeof(struct mwifiex_ie_types_header) +
0733 len + sizeof(km->action) + S_DS_GEN);
0734 return 0;
0735 }
0736
0737 if (is_broadcast_ether_addr(mac))
0738 key_info |= KEY_MCAST | KEY_RX_KEY;
0739 else
0740 key_info |= KEY_UNICAST | KEY_TX_KEY | KEY_RX_KEY;
0741
0742 if (enc_key->is_wapi_key) {
0743 mwifiex_dbg(adapter, INFO, "%s: Set WAPI Key\n", __func__);
0744 km->key_param_set.key_type = KEY_TYPE_ID_WAPI;
0745 memcpy(km->key_param_set.key_params.wapi.pn, enc_key->pn,
0746 PN_LEN);
0747 km->key_param_set.key_params.wapi.key_len =
0748 cpu_to_le16(enc_key->key_len);
0749 memcpy(km->key_param_set.key_params.wapi.key,
0750 enc_key->key_material, enc_key->key_len);
0751 if (is_broadcast_ether_addr(mac))
0752 priv->sec_info.wapi_key_on = true;
0753
0754 if (!priv->sec_info.wapi_key_on)
0755 key_info |= KEY_DEFAULT;
0756 km->key_param_set.key_info = cpu_to_le16(key_info);
0757
0758 len += sizeof(struct mwifiex_wapi_param);
0759 km->key_param_set.len = cpu_to_le16(len);
0760 cmd->size = cpu_to_le16(sizeof(struct mwifiex_ie_types_header) +
0761 len + sizeof(km->action) + S_DS_GEN);
0762 return 0;
0763 }
0764
0765 if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
0766 key_info |= KEY_DEFAULT;
0767
0768 if (!priv->sec_info.wpa2_enabled &&
0769 !is_broadcast_ether_addr(mac))
0770 key_info |= KEY_UNICAST;
0771 } else {
0772
0773 if (!priv->wpa_is_gtk_set)
0774 key_info |= KEY_DEFAULT;
0775 }
0776
0777 km->key_param_set.key_info = cpu_to_le16(key_info);
0778
0779 if (enc_key->key_len == WLAN_KEY_LEN_CCMP)
0780 return mwifiex_set_aes_key_v2(priv, cmd, enc_key, km);
0781
0782 if (enc_key->key_len == WLAN_KEY_LEN_TKIP) {
0783 mwifiex_dbg(adapter, INFO,
0784 "%s: Set TKIP Key\n", __func__);
0785 if (enc_key->is_rx_seq_valid)
0786 memcpy(km->key_param_set.key_params.tkip.pn,
0787 enc_key->pn, enc_key->pn_len);
0788 km->key_param_set.key_type = KEY_TYPE_ID_TKIP;
0789 km->key_param_set.key_params.tkip.key_len =
0790 cpu_to_le16(enc_key->key_len);
0791 memcpy(km->key_param_set.key_params.tkip.key,
0792 enc_key->key_material, enc_key->key_len);
0793
0794 len += sizeof(struct mwifiex_tkip_param);
0795 km->key_param_set.len = cpu_to_le16(len);
0796 cmd->size = cpu_to_le16(sizeof(struct mwifiex_ie_types_header) +
0797 len + sizeof(km->action) + S_DS_GEN);
0798 }
0799
0800 return 0;
0801 }
0802
0803
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813 static int
0814 mwifiex_cmd_802_11_key_material_v1(struct mwifiex_private *priv,
0815 struct host_cmd_ds_command *cmd,
0816 u16 cmd_action, u32 cmd_oid,
0817 struct mwifiex_ds_encrypt_key *enc_key)
0818 {
0819 struct host_cmd_ds_802_11_key_material *key_material =
0820 &cmd->params.key_material;
0821 struct host_cmd_tlv_mac_addr *tlv_mac;
0822 u16 key_param_len = 0, cmd_size;
0823 int ret = 0;
0824
0825 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_KEY_MATERIAL);
0826 key_material->action = cpu_to_le16(cmd_action);
0827
0828 if (cmd_action == HostCmd_ACT_GEN_GET) {
0829 cmd->size =
0830 cpu_to_le16(sizeof(key_material->action) + S_DS_GEN);
0831 return ret;
0832 }
0833
0834 if (!enc_key) {
0835 struct host_cmd_ds_802_11_key_material_wep *key_material_wep =
0836 (struct host_cmd_ds_802_11_key_material_wep *)key_material;
0837 memset(key_material_wep->key_param_set, 0,
0838 sizeof(key_material_wep->key_param_set));
0839 ret = mwifiex_set_keyparamset_wep(priv,
0840 &key_material_wep->key_param_set[0],
0841 &key_param_len);
0842 cmd->size = cpu_to_le16(key_param_len +
0843 sizeof(key_material_wep->action) + S_DS_GEN);
0844 return ret;
0845 } else
0846 memset(&key_material->key_param_set, 0,
0847 sizeof(struct mwifiex_ie_type_key_param_set));
0848 if (enc_key->is_wapi_key) {
0849 struct mwifiex_ie_type_key_param_set *set;
0850
0851 mwifiex_dbg(priv->adapter, INFO, "info: Set WAPI Key\n");
0852 set = &key_material->key_param_set;
0853 set->key_type_id = cpu_to_le16(KEY_TYPE_ID_WAPI);
0854 if (cmd_oid == KEY_INFO_ENABLED)
0855 set->key_info = cpu_to_le16(KEY_ENABLED);
0856 else
0857 set->key_info = cpu_to_le16(!KEY_ENABLED);
0858
0859 set->key[0] = enc_key->key_index;
0860 if (!priv->sec_info.wapi_key_on)
0861 set->key[1] = 1;
0862 else
0863
0864 set->key[1] = 0;
0865
0866 if (!is_broadcast_ether_addr(enc_key->mac_addr)) {
0867
0868 set->key_info |= cpu_to_le16(KEY_UNICAST);
0869 } else {
0870 set->key_info |= cpu_to_le16(KEY_MCAST);
0871 priv->sec_info.wapi_key_on = true;
0872 }
0873
0874 set->type = cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
0875 set->key_len = cpu_to_le16(WAPI_KEY_LEN);
0876 memcpy(&set->key[2], enc_key->key_material, enc_key->key_len);
0877 memcpy(&set->key[2 + enc_key->key_len], enc_key->pn, PN_LEN);
0878 set->length = cpu_to_le16(WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN);
0879
0880 key_param_len = (WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN) +
0881 sizeof(struct mwifiex_ie_types_header);
0882 cmd->size = cpu_to_le16(sizeof(key_material->action)
0883 + S_DS_GEN + key_param_len);
0884 return ret;
0885 }
0886 if (enc_key->key_len == WLAN_KEY_LEN_CCMP) {
0887 if (enc_key->is_igtk_key) {
0888 mwifiex_dbg(priv->adapter, CMD, "cmd: CMAC_AES\n");
0889 key_material->key_param_set.key_type_id =
0890 cpu_to_le16(KEY_TYPE_ID_AES_CMAC);
0891 if (cmd_oid == KEY_INFO_ENABLED)
0892 key_material->key_param_set.key_info =
0893 cpu_to_le16(KEY_ENABLED);
0894 else
0895 key_material->key_param_set.key_info =
0896 cpu_to_le16(!KEY_ENABLED);
0897
0898 key_material->key_param_set.key_info |=
0899 cpu_to_le16(KEY_IGTK);
0900 } else {
0901 mwifiex_dbg(priv->adapter, CMD, "cmd: WPA_AES\n");
0902 key_material->key_param_set.key_type_id =
0903 cpu_to_le16(KEY_TYPE_ID_AES);
0904 if (cmd_oid == KEY_INFO_ENABLED)
0905 key_material->key_param_set.key_info =
0906 cpu_to_le16(KEY_ENABLED);
0907 else
0908 key_material->key_param_set.key_info =
0909 cpu_to_le16(!KEY_ENABLED);
0910
0911 if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST)
0912
0913 key_material->key_param_set.key_info |=
0914 cpu_to_le16(KEY_UNICAST);
0915 else
0916 key_material->key_param_set.key_info |=
0917 cpu_to_le16(KEY_MCAST);
0918 }
0919 } else if (enc_key->key_len == WLAN_KEY_LEN_TKIP) {
0920 mwifiex_dbg(priv->adapter, CMD, "cmd: WPA_TKIP\n");
0921 key_material->key_param_set.key_type_id =
0922 cpu_to_le16(KEY_TYPE_ID_TKIP);
0923 key_material->key_param_set.key_info =
0924 cpu_to_le16(KEY_ENABLED);
0925
0926 if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST)
0927
0928 key_material->key_param_set.key_info |=
0929 cpu_to_le16(KEY_UNICAST);
0930 else
0931 key_material->key_param_set.key_info |=
0932 cpu_to_le16(KEY_MCAST);
0933 }
0934
0935 if (key_material->key_param_set.key_type_id) {
0936 key_material->key_param_set.type =
0937 cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
0938 key_material->key_param_set.key_len =
0939 cpu_to_le16((u16) enc_key->key_len);
0940 memcpy(key_material->key_param_set.key, enc_key->key_material,
0941 enc_key->key_len);
0942 key_material->key_param_set.length =
0943 cpu_to_le16((u16) enc_key->key_len +
0944 KEYPARAMSET_FIXED_LEN);
0945
0946 key_param_len = (u16)(enc_key->key_len + KEYPARAMSET_FIXED_LEN)
0947 + sizeof(struct mwifiex_ie_types_header);
0948
0949 if (le16_to_cpu(key_material->key_param_set.key_type_id) ==
0950 KEY_TYPE_ID_AES_CMAC) {
0951 struct mwifiex_cmac_param *param =
0952 (void *)key_material->key_param_set.key;
0953
0954 memcpy(param->ipn, enc_key->pn, IGTK_PN_LEN);
0955 memcpy(param->key, enc_key->key_material,
0956 WLAN_KEY_LEN_AES_CMAC);
0957
0958 key_param_len = sizeof(struct mwifiex_cmac_param);
0959 key_material->key_param_set.key_len =
0960 cpu_to_le16(key_param_len);
0961 key_param_len += KEYPARAMSET_FIXED_LEN;
0962 key_material->key_param_set.length =
0963 cpu_to_le16(key_param_len);
0964 key_param_len += sizeof(struct mwifiex_ie_types_header);
0965 }
0966
0967 cmd->size = cpu_to_le16(sizeof(key_material->action) + S_DS_GEN
0968 + key_param_len);
0969
0970 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) {
0971 tlv_mac = (void *)((u8 *)&key_material->key_param_set +
0972 key_param_len);
0973 tlv_mac->header.type =
0974 cpu_to_le16(TLV_TYPE_STA_MAC_ADDR);
0975 tlv_mac->header.len = cpu_to_le16(ETH_ALEN);
0976 memcpy(tlv_mac->mac_addr, enc_key->mac_addr, ETH_ALEN);
0977 cmd_size = key_param_len + S_DS_GEN +
0978 sizeof(key_material->action) +
0979 sizeof(struct host_cmd_tlv_mac_addr);
0980 } else {
0981 cmd_size = key_param_len + S_DS_GEN +
0982 sizeof(key_material->action);
0983 }
0984 cmd->size = cpu_to_le16(cmd_size);
0985 }
0986
0987 return ret;
0988 }
0989
0990
0991 static int
0992 mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv,
0993 struct host_cmd_ds_command *cmd,
0994 u16 cmd_action, u32 cmd_oid,
0995 struct mwifiex_ds_encrypt_key *enc_key)
0996 {
0997 if (priv->adapter->key_api_major_ver == KEY_API_VER_MAJOR_V2)
0998 return mwifiex_cmd_802_11_key_material_v2(priv, cmd,
0999 cmd_action, cmd_oid,
1000 enc_key);
1001
1002 else
1003 return mwifiex_cmd_802_11_key_material_v1(priv, cmd,
1004 cmd_action, cmd_oid,
1005 enc_key);
1006 }
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016 static int mwifiex_cmd_802_11d_domain_info(struct mwifiex_private *priv,
1017 struct host_cmd_ds_command *cmd,
1018 u16 cmd_action)
1019 {
1020 struct mwifiex_adapter *adapter = priv->adapter;
1021 struct host_cmd_ds_802_11d_domain_info *domain_info =
1022 &cmd->params.domain_info;
1023 struct mwifiex_ietypes_domain_param_set *domain =
1024 &domain_info->domain;
1025 u8 no_of_triplet = adapter->domain_reg.no_of_triplet;
1026
1027 mwifiex_dbg(adapter, INFO,
1028 "info: 11D: no_of_triplet=0x%x\n", no_of_triplet);
1029
1030 cmd->command = cpu_to_le16(HostCmd_CMD_802_11D_DOMAIN_INFO);
1031 domain_info->action = cpu_to_le16(cmd_action);
1032 if (cmd_action == HostCmd_ACT_GEN_GET) {
1033 cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN);
1034 return 0;
1035 }
1036
1037
1038 domain->header.type = cpu_to_le16(WLAN_EID_COUNTRY);
1039 memcpy(domain->country_code, adapter->domain_reg.country_code,
1040 sizeof(domain->country_code));
1041
1042 domain->header.len =
1043 cpu_to_le16((no_of_triplet *
1044 sizeof(struct ieee80211_country_ie_triplet))
1045 + sizeof(domain->country_code));
1046
1047 if (no_of_triplet) {
1048 memcpy(domain->triplet, adapter->domain_reg.triplet,
1049 no_of_triplet * sizeof(struct
1050 ieee80211_country_ie_triplet));
1051
1052 cmd->size = cpu_to_le16(sizeof(domain_info->action) +
1053 le16_to_cpu(domain->header.len) +
1054 sizeof(struct mwifiex_ie_types_header)
1055 + S_DS_GEN);
1056 } else {
1057 cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN);
1058 }
1059
1060 return 0;
1061 }
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071 static int mwifiex_cmd_ibss_coalescing_status(struct host_cmd_ds_command *cmd,
1072 u16 cmd_action, u16 *enable)
1073 {
1074 struct host_cmd_ds_802_11_ibss_status *ibss_coal =
1075 &(cmd->params.ibss_coalescing);
1076
1077 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_IBSS_COALESCING_STATUS);
1078 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_ibss_status) +
1079 S_DS_GEN);
1080 cmd->result = 0;
1081 ibss_coal->action = cpu_to_le16(cmd_action);
1082
1083 switch (cmd_action) {
1084 case HostCmd_ACT_GEN_SET:
1085 if (enable)
1086 ibss_coal->enable = cpu_to_le16(*enable);
1087 else
1088 ibss_coal->enable = 0;
1089 break;
1090
1091
1092 case HostCmd_ACT_GEN_GET:
1093 default:
1094 break;
1095 }
1096
1097 return 0;
1098 }
1099
1100
1101
1102 static int
1103 mwifiex_cmd_mem_access(struct host_cmd_ds_command *cmd, u16 cmd_action,
1104 void *pdata_buf)
1105 {
1106 struct mwifiex_ds_mem_rw *mem_rw = (void *)pdata_buf;
1107 struct host_cmd_ds_mem_access *mem_access = (void *)&cmd->params.mem;
1108
1109 cmd->command = cpu_to_le16(HostCmd_CMD_MEM_ACCESS);
1110 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_mem_access) +
1111 S_DS_GEN);
1112
1113 mem_access->action = cpu_to_le16(cmd_action);
1114 mem_access->addr = cpu_to_le32(mem_rw->addr);
1115 mem_access->value = cpu_to_le32(mem_rw->value);
1116
1117 return 0;
1118 }
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137 static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd,
1138 u16 cmd_action, void *data_buf)
1139 {
1140 struct mwifiex_ds_reg_rw *reg_rw = data_buf;
1141
1142 switch (le16_to_cpu(cmd->command)) {
1143 case HostCmd_CMD_MAC_REG_ACCESS:
1144 {
1145 struct host_cmd_ds_mac_reg_access *mac_reg;
1146
1147 cmd->size = cpu_to_le16(sizeof(*mac_reg) + S_DS_GEN);
1148 mac_reg = &cmd->params.mac_reg;
1149 mac_reg->action = cpu_to_le16(cmd_action);
1150 mac_reg->offset = cpu_to_le16((u16) reg_rw->offset);
1151 mac_reg->value = cpu_to_le32(reg_rw->value);
1152 break;
1153 }
1154 case HostCmd_CMD_BBP_REG_ACCESS:
1155 {
1156 struct host_cmd_ds_bbp_reg_access *bbp_reg;
1157
1158 cmd->size = cpu_to_le16(sizeof(*bbp_reg) + S_DS_GEN);
1159 bbp_reg = &cmd->params.bbp_reg;
1160 bbp_reg->action = cpu_to_le16(cmd_action);
1161 bbp_reg->offset = cpu_to_le16((u16) reg_rw->offset);
1162 bbp_reg->value = (u8) reg_rw->value;
1163 break;
1164 }
1165 case HostCmd_CMD_RF_REG_ACCESS:
1166 {
1167 struct host_cmd_ds_rf_reg_access *rf_reg;
1168
1169 cmd->size = cpu_to_le16(sizeof(*rf_reg) + S_DS_GEN);
1170 rf_reg = &cmd->params.rf_reg;
1171 rf_reg->action = cpu_to_le16(cmd_action);
1172 rf_reg->offset = cpu_to_le16((u16) reg_rw->offset);
1173 rf_reg->value = (u8) reg_rw->value;
1174 break;
1175 }
1176 case HostCmd_CMD_PMIC_REG_ACCESS:
1177 {
1178 struct host_cmd_ds_pmic_reg_access *pmic_reg;
1179
1180 cmd->size = cpu_to_le16(sizeof(*pmic_reg) + S_DS_GEN);
1181 pmic_reg = &cmd->params.pmic_reg;
1182 pmic_reg->action = cpu_to_le16(cmd_action);
1183 pmic_reg->offset = cpu_to_le16((u16) reg_rw->offset);
1184 pmic_reg->value = (u8) reg_rw->value;
1185 break;
1186 }
1187 case HostCmd_CMD_CAU_REG_ACCESS:
1188 {
1189 struct host_cmd_ds_rf_reg_access *cau_reg;
1190
1191 cmd->size = cpu_to_le16(sizeof(*cau_reg) + S_DS_GEN);
1192 cau_reg = &cmd->params.rf_reg;
1193 cau_reg->action = cpu_to_le16(cmd_action);
1194 cau_reg->offset = cpu_to_le16((u16) reg_rw->offset);
1195 cau_reg->value = (u8) reg_rw->value;
1196 break;
1197 }
1198 case HostCmd_CMD_802_11_EEPROM_ACCESS:
1199 {
1200 struct mwifiex_ds_read_eeprom *rd_eeprom = data_buf;
1201 struct host_cmd_ds_802_11_eeprom_access *cmd_eeprom =
1202 &cmd->params.eeprom;
1203
1204 cmd->size = cpu_to_le16(sizeof(*cmd_eeprom) + S_DS_GEN);
1205 cmd_eeprom->action = cpu_to_le16(cmd_action);
1206 cmd_eeprom->offset = cpu_to_le16(rd_eeprom->offset);
1207 cmd_eeprom->byte_count = cpu_to_le16(rd_eeprom->byte_count);
1208 cmd_eeprom->value = 0;
1209 break;
1210 }
1211 default:
1212 return -1;
1213 }
1214
1215 return 0;
1216 }
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227 static int
1228 mwifiex_cmd_pcie_host_spec(struct mwifiex_private *priv,
1229 struct host_cmd_ds_command *cmd, u16 action)
1230 {
1231 struct host_cmd_ds_pcie_details *host_spec =
1232 &cmd->params.pcie_host_spec;
1233 struct pcie_service_card *card = priv->adapter->card;
1234
1235 cmd->command = cpu_to_le16(HostCmd_CMD_PCIE_DESC_DETAILS);
1236 cmd->size = cpu_to_le16(sizeof(struct
1237 host_cmd_ds_pcie_details) + S_DS_GEN);
1238 cmd->result = 0;
1239
1240 memset(host_spec, 0, sizeof(struct host_cmd_ds_pcie_details));
1241
1242 if (action != HostCmd_ACT_GEN_SET)
1243 return 0;
1244
1245
1246 host_spec->txbd_addr_lo = cpu_to_le32((u32)(card->txbd_ring_pbase));
1247 host_spec->txbd_addr_hi =
1248 cpu_to_le32((u32)(((u64)card->txbd_ring_pbase) >> 32));
1249 host_spec->txbd_count = cpu_to_le32(MWIFIEX_MAX_TXRX_BD);
1250 host_spec->rxbd_addr_lo = cpu_to_le32((u32)(card->rxbd_ring_pbase));
1251 host_spec->rxbd_addr_hi =
1252 cpu_to_le32((u32)(((u64)card->rxbd_ring_pbase) >> 32));
1253 host_spec->rxbd_count = cpu_to_le32(MWIFIEX_MAX_TXRX_BD);
1254 host_spec->evtbd_addr_lo = cpu_to_le32((u32)(card->evtbd_ring_pbase));
1255 host_spec->evtbd_addr_hi =
1256 cpu_to_le32((u32)(((u64)card->evtbd_ring_pbase) >> 32));
1257 host_spec->evtbd_count = cpu_to_le32(MWIFIEX_MAX_EVT_BD);
1258 if (card->sleep_cookie_vbase) {
1259 host_spec->sleep_cookie_addr_lo =
1260 cpu_to_le32((u32)(card->sleep_cookie_pbase));
1261 host_spec->sleep_cookie_addr_hi = cpu_to_le32((u32)(((u64)
1262 (card->sleep_cookie_pbase)) >> 32));
1263 mwifiex_dbg(priv->adapter, INFO,
1264 "sleep_cook_lo phy addr: 0x%x\n",
1265 host_spec->sleep_cookie_addr_lo);
1266 }
1267
1268 return 0;
1269 }
1270
1271
1272
1273
1274
1275
1276
1277 static int
1278 mwifiex_cmd_802_11_subsc_evt(struct mwifiex_private *priv,
1279 struct host_cmd_ds_command *cmd,
1280 struct mwifiex_ds_misc_subsc_evt *subsc_evt_cfg)
1281 {
1282 struct host_cmd_ds_802_11_subsc_evt *subsc_evt = &cmd->params.subsc_evt;
1283 struct mwifiex_ie_types_rssi_threshold *rssi_tlv;
1284 u16 event_bitmap;
1285 u8 *pos;
1286
1287 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SUBSCRIBE_EVENT);
1288 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_subsc_evt) +
1289 S_DS_GEN);
1290
1291 subsc_evt->action = cpu_to_le16(subsc_evt_cfg->action);
1292 mwifiex_dbg(priv->adapter, CMD,
1293 "cmd: action: %d\n", subsc_evt_cfg->action);
1294
1295
1296 if (subsc_evt_cfg->action == HostCmd_ACT_GEN_GET)
1297 return 0;
1298
1299 subsc_evt->events = cpu_to_le16(subsc_evt_cfg->events);
1300
1301 event_bitmap = subsc_evt_cfg->events;
1302 mwifiex_dbg(priv->adapter, CMD, "cmd: event bitmap : %16x\n",
1303 event_bitmap);
1304
1305 if (((subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR) ||
1306 (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_SET)) &&
1307 (event_bitmap == 0)) {
1308 mwifiex_dbg(priv->adapter, ERROR,
1309 "Error: No event specified\t"
1310 "for bitwise action type\n");
1311 return -EINVAL;
1312 }
1313
1314
1315
1316
1317
1318
1319 if (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR)
1320 return 0;
1321
1322 pos = ((u8 *)subsc_evt) +
1323 sizeof(struct host_cmd_ds_802_11_subsc_evt);
1324
1325 if (event_bitmap & BITMASK_BCN_RSSI_LOW) {
1326 rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos;
1327
1328 rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_LOW);
1329 rssi_tlv->header.len =
1330 cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) -
1331 sizeof(struct mwifiex_ie_types_header));
1332 rssi_tlv->abs_value = subsc_evt_cfg->bcn_l_rssi_cfg.abs_value;
1333 rssi_tlv->evt_freq = subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq;
1334
1335 mwifiex_dbg(priv->adapter, EVENT,
1336 "Cfg Beacon Low Rssi event,\t"
1337 "RSSI:-%d dBm, Freq:%d\n",
1338 subsc_evt_cfg->bcn_l_rssi_cfg.abs_value,
1339 subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq);
1340
1341 pos += sizeof(struct mwifiex_ie_types_rssi_threshold);
1342 le16_unaligned_add_cpu(&cmd->size,
1343 sizeof(
1344 struct mwifiex_ie_types_rssi_threshold));
1345 }
1346
1347 if (event_bitmap & BITMASK_BCN_RSSI_HIGH) {
1348 rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos;
1349
1350 rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_HIGH);
1351 rssi_tlv->header.len =
1352 cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) -
1353 sizeof(struct mwifiex_ie_types_header));
1354 rssi_tlv->abs_value = subsc_evt_cfg->bcn_h_rssi_cfg.abs_value;
1355 rssi_tlv->evt_freq = subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq;
1356
1357 mwifiex_dbg(priv->adapter, EVENT,
1358 "Cfg Beacon High Rssi event,\t"
1359 "RSSI:-%d dBm, Freq:%d\n",
1360 subsc_evt_cfg->bcn_h_rssi_cfg.abs_value,
1361 subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq);
1362
1363 pos += sizeof(struct mwifiex_ie_types_rssi_threshold);
1364 le16_unaligned_add_cpu(&cmd->size,
1365 sizeof(
1366 struct mwifiex_ie_types_rssi_threshold));
1367 }
1368
1369 return 0;
1370 }
1371
1372 static int
1373 mwifiex_cmd_append_rpn_expression(struct mwifiex_private *priv,
1374 struct mwifiex_mef_entry *mef_entry,
1375 u8 **buffer)
1376 {
1377 struct mwifiex_mef_filter *filter = mef_entry->filter;
1378 int i, byte_len;
1379 u8 *stack_ptr = *buffer;
1380
1381 for (i = 0; i < MWIFIEX_MEF_MAX_FILTERS; i++) {
1382 filter = &mef_entry->filter[i];
1383 if (!filter->filt_type)
1384 break;
1385 put_unaligned_le32((u32)filter->repeat, stack_ptr);
1386 stack_ptr += 4;
1387 *stack_ptr = TYPE_DNUM;
1388 stack_ptr += 1;
1389
1390 byte_len = filter->byte_seq[MWIFIEX_MEF_MAX_BYTESEQ];
1391 memcpy(stack_ptr, filter->byte_seq, byte_len);
1392 stack_ptr += byte_len;
1393 *stack_ptr = byte_len;
1394 stack_ptr += 1;
1395 *stack_ptr = TYPE_BYTESEQ;
1396 stack_ptr += 1;
1397 put_unaligned_le32((u32)filter->offset, stack_ptr);
1398 stack_ptr += 4;
1399 *stack_ptr = TYPE_DNUM;
1400 stack_ptr += 1;
1401
1402 *stack_ptr = filter->filt_type;
1403 stack_ptr += 1;
1404
1405 if (filter->filt_action) {
1406 *stack_ptr = filter->filt_action;
1407 stack_ptr += 1;
1408 }
1409
1410 if (stack_ptr - *buffer > STACK_NBYTES)
1411 return -1;
1412 }
1413
1414 *buffer = stack_ptr;
1415 return 0;
1416 }
1417
1418 static int
1419 mwifiex_cmd_mef_cfg(struct mwifiex_private *priv,
1420 struct host_cmd_ds_command *cmd,
1421 struct mwifiex_ds_mef_cfg *mef)
1422 {
1423 struct host_cmd_ds_mef_cfg *mef_cfg = &cmd->params.mef_cfg;
1424 struct mwifiex_fw_mef_entry *mef_entry = NULL;
1425 u8 *pos = (u8 *)mef_cfg;
1426 u16 i;
1427
1428 cmd->command = cpu_to_le16(HostCmd_CMD_MEF_CFG);
1429
1430 mef_cfg->criteria = cpu_to_le32(mef->criteria);
1431 mef_cfg->num_entries = cpu_to_le16(mef->num_entries);
1432 pos += sizeof(*mef_cfg);
1433
1434 for (i = 0; i < mef->num_entries; i++) {
1435 mef_entry = (struct mwifiex_fw_mef_entry *)pos;
1436 mef_entry->mode = mef->mef_entry[i].mode;
1437 mef_entry->action = mef->mef_entry[i].action;
1438 pos += sizeof(*mef_cfg->mef_entry);
1439
1440 if (mwifiex_cmd_append_rpn_expression(priv,
1441 &mef->mef_entry[i], &pos))
1442 return -1;
1443
1444 mef_entry->exprsize =
1445 cpu_to_le16(pos - mef_entry->expr);
1446 }
1447 cmd->size = cpu_to_le16((u16) (pos - (u8 *)mef_cfg) + S_DS_GEN);
1448
1449 return 0;
1450 }
1451
1452
1453 static u32 mwifiex_parse_cal_cfg(u8 *src, size_t len, u8 *dst)
1454 {
1455 u8 *s = src, *d = dst;
1456
1457 while (s - src < len) {
1458 if (*s && (isspace(*s) || *s == '\t')) {
1459 s++;
1460 continue;
1461 }
1462 if (isxdigit(*s)) {
1463 *d++ = simple_strtol(s, NULL, 16);
1464 s += 2;
1465 } else {
1466 s++;
1467 }
1468 }
1469
1470 return d - dst;
1471 }
1472
1473 int mwifiex_dnld_dt_cfgdata(struct mwifiex_private *priv,
1474 struct device_node *node, const char *prefix)
1475 {
1476 #ifdef CONFIG_OF
1477 struct property *prop;
1478 size_t len = strlen(prefix);
1479 int ret;
1480
1481
1482 for_each_property_of_node(node, prop) {
1483 if (len > strlen(prop->name) ||
1484 strncmp(prop->name, prefix, len))
1485 continue;
1486
1487
1488 if (prop->value && prop->length > 6 &&
1489 prop->length <= MWIFIEX_SIZE_OF_CMD_BUFFER - S_DS_GEN) {
1490 ret = mwifiex_send_cmd(priv, HostCmd_CMD_CFG_DATA,
1491 HostCmd_ACT_GEN_SET, 0,
1492 prop, true);
1493 if (ret)
1494 return ret;
1495 }
1496 }
1497 #endif
1498 return 0;
1499 }
1500
1501
1502 static int mwifiex_cmd_cfg_data(struct mwifiex_private *priv,
1503 struct host_cmd_ds_command *cmd, void *data_buf)
1504 {
1505 struct mwifiex_adapter *adapter = priv->adapter;
1506 struct property *prop = data_buf;
1507 u32 len;
1508 u8 *data = (u8 *)cmd + S_DS_GEN;
1509 int ret;
1510
1511 if (prop) {
1512 len = prop->length;
1513 ret = of_property_read_u8_array(adapter->dt_node, prop->name,
1514 data, len);
1515 if (ret)
1516 return ret;
1517 mwifiex_dbg(adapter, INFO,
1518 "download cfg_data from device tree: %s\n",
1519 prop->name);
1520 } else if (adapter->cal_data->data && adapter->cal_data->size > 0) {
1521 len = mwifiex_parse_cal_cfg((u8 *)adapter->cal_data->data,
1522 adapter->cal_data->size, data);
1523 mwifiex_dbg(adapter, INFO,
1524 "download cfg_data from config file\n");
1525 } else {
1526 return -1;
1527 }
1528
1529 cmd->command = cpu_to_le16(HostCmd_CMD_CFG_DATA);
1530 cmd->size = cpu_to_le16(S_DS_GEN + len);
1531
1532 return 0;
1533 }
1534
1535 static int
1536 mwifiex_cmd_set_mc_policy(struct mwifiex_private *priv,
1537 struct host_cmd_ds_command *cmd,
1538 u16 cmd_action, void *data_buf)
1539 {
1540 struct host_cmd_ds_multi_chan_policy *mc_pol = &cmd->params.mc_policy;
1541 const u16 *drcs_info = data_buf;
1542
1543 mc_pol->action = cpu_to_le16(cmd_action);
1544 mc_pol->policy = cpu_to_le16(*drcs_info);
1545 cmd->command = cpu_to_le16(HostCmd_CMD_MC_POLICY);
1546 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_multi_chan_policy) +
1547 S_DS_GEN);
1548 return 0;
1549 }
1550
1551 static int mwifiex_cmd_robust_coex(struct mwifiex_private *priv,
1552 struct host_cmd_ds_command *cmd,
1553 u16 cmd_action, bool *is_timeshare)
1554 {
1555 struct host_cmd_ds_robust_coex *coex = &cmd->params.coex;
1556 struct mwifiex_ie_types_robust_coex *coex_tlv;
1557
1558 cmd->command = cpu_to_le16(HostCmd_CMD_ROBUST_COEX);
1559 cmd->size = cpu_to_le16(sizeof(*coex) + sizeof(*coex_tlv) + S_DS_GEN);
1560
1561 coex->action = cpu_to_le16(cmd_action);
1562 coex_tlv = (struct mwifiex_ie_types_robust_coex *)
1563 ((u8 *)coex + sizeof(*coex));
1564 coex_tlv->header.type = cpu_to_le16(TLV_TYPE_ROBUST_COEX);
1565 coex_tlv->header.len = cpu_to_le16(sizeof(coex_tlv->mode));
1566
1567 if (coex->action == HostCmd_ACT_GEN_GET)
1568 return 0;
1569
1570 if (*is_timeshare)
1571 coex_tlv->mode = cpu_to_le32(MWIFIEX_COEX_MODE_TIMESHARE);
1572 else
1573 coex_tlv->mode = cpu_to_le32(MWIFIEX_COEX_MODE_SPATIAL);
1574
1575 return 0;
1576 }
1577
1578 static int mwifiex_cmd_gtk_rekey_offload(struct mwifiex_private *priv,
1579 struct host_cmd_ds_command *cmd,
1580 u16 cmd_action,
1581 struct cfg80211_gtk_rekey_data *data)
1582 {
1583 struct host_cmd_ds_gtk_rekey_params *rekey = &cmd->params.rekey;
1584 u64 rekey_ctr;
1585
1586 cmd->command = cpu_to_le16(HostCmd_CMD_GTK_REKEY_OFFLOAD_CFG);
1587 cmd->size = cpu_to_le16(sizeof(*rekey) + S_DS_GEN);
1588
1589 rekey->action = cpu_to_le16(cmd_action);
1590 if (cmd_action == HostCmd_ACT_GEN_SET) {
1591 memcpy(rekey->kek, data->kek, NL80211_KEK_LEN);
1592 memcpy(rekey->kck, data->kck, NL80211_KCK_LEN);
1593 rekey_ctr = be64_to_cpup((__be64 *)data->replay_ctr);
1594 rekey->replay_ctr_low = cpu_to_le32((u32)rekey_ctr);
1595 rekey->replay_ctr_high =
1596 cpu_to_le32((u32)((u64)rekey_ctr >> 32));
1597 }
1598
1599 return 0;
1600 }
1601
1602 static int mwifiex_cmd_chan_region_cfg(struct mwifiex_private *priv,
1603 struct host_cmd_ds_command *cmd,
1604 u16 cmd_action)
1605 {
1606 struct host_cmd_ds_chan_region_cfg *reg = &cmd->params.reg_cfg;
1607
1608 cmd->command = cpu_to_le16(HostCmd_CMD_CHAN_REGION_CFG);
1609 cmd->size = cpu_to_le16(sizeof(*reg) + S_DS_GEN);
1610
1611 if (cmd_action == HostCmd_ACT_GEN_GET)
1612 reg->action = cpu_to_le16(cmd_action);
1613
1614 return 0;
1615 }
1616
1617 static int
1618 mwifiex_cmd_coalesce_cfg(struct mwifiex_private *priv,
1619 struct host_cmd_ds_command *cmd,
1620 u16 cmd_action, void *data_buf)
1621 {
1622 struct host_cmd_ds_coalesce_cfg *coalesce_cfg =
1623 &cmd->params.coalesce_cfg;
1624 struct mwifiex_ds_coalesce_cfg *cfg = data_buf;
1625 struct coalesce_filt_field_param *param;
1626 u16 cnt, idx, length;
1627 struct coalesce_receive_filt_rule *rule;
1628
1629 cmd->command = cpu_to_le16(HostCmd_CMD_COALESCE_CFG);
1630 cmd->size = cpu_to_le16(S_DS_GEN);
1631
1632 coalesce_cfg->action = cpu_to_le16(cmd_action);
1633 coalesce_cfg->num_of_rules = cpu_to_le16(cfg->num_of_rules);
1634 rule = coalesce_cfg->rule;
1635
1636 for (cnt = 0; cnt < cfg->num_of_rules; cnt++) {
1637 rule->header.type = cpu_to_le16(TLV_TYPE_COALESCE_RULE);
1638 rule->max_coalescing_delay =
1639 cpu_to_le16(cfg->rule[cnt].max_coalescing_delay);
1640 rule->pkt_type = cfg->rule[cnt].pkt_type;
1641 rule->num_of_fields = cfg->rule[cnt].num_of_fields;
1642
1643 length = 0;
1644
1645 param = rule->params;
1646 for (idx = 0; idx < cfg->rule[cnt].num_of_fields; idx++) {
1647 param->operation = cfg->rule[cnt].params[idx].operation;
1648 param->operand_len =
1649 cfg->rule[cnt].params[idx].operand_len;
1650 param->offset =
1651 cpu_to_le16(cfg->rule[cnt].params[idx].offset);
1652 memcpy(param->operand_byte_stream,
1653 cfg->rule[cnt].params[idx].operand_byte_stream,
1654 param->operand_len);
1655
1656 length += sizeof(struct coalesce_filt_field_param);
1657
1658 param++;
1659 }
1660
1661
1662
1663
1664
1665 rule->header.len = cpu_to_le16(length + sizeof(u16) +
1666 sizeof(u8) + sizeof(u8));
1667
1668
1669 le16_unaligned_add_cpu(&cmd->size,
1670 le16_to_cpu(rule->header.len) +
1671 sizeof(struct mwifiex_ie_types_header));
1672
1673 rule = (void *)((u8 *)rule->params + length);
1674 }
1675
1676
1677 le16_unaligned_add_cpu(&cmd->size, sizeof(u16) + sizeof(u16));
1678
1679 return 0;
1680 }
1681
1682 static int
1683 mwifiex_cmd_tdls_config(struct mwifiex_private *priv,
1684 struct host_cmd_ds_command *cmd,
1685 u16 cmd_action, void *data_buf)
1686 {
1687 struct host_cmd_ds_tdls_config *tdls_config = &cmd->params.tdls_config;
1688 struct mwifiex_tdls_init_cs_params *config;
1689 struct mwifiex_tdls_config *init_config;
1690 u16 len;
1691
1692 cmd->command = cpu_to_le16(HostCmd_CMD_TDLS_CONFIG);
1693 cmd->size = cpu_to_le16(S_DS_GEN);
1694 tdls_config->tdls_action = cpu_to_le16(cmd_action);
1695 le16_unaligned_add_cpu(&cmd->size, sizeof(tdls_config->tdls_action));
1696
1697 switch (cmd_action) {
1698 case ACT_TDLS_CS_ENABLE_CONFIG:
1699 init_config = data_buf;
1700 len = sizeof(*init_config);
1701 memcpy(tdls_config->tdls_data, init_config, len);
1702 break;
1703 case ACT_TDLS_CS_INIT:
1704 config = data_buf;
1705 len = sizeof(*config);
1706 memcpy(tdls_config->tdls_data, config, len);
1707 break;
1708 case ACT_TDLS_CS_STOP:
1709 len = sizeof(struct mwifiex_tdls_stop_cs_params);
1710 memcpy(tdls_config->tdls_data, data_buf, len);
1711 break;
1712 case ACT_TDLS_CS_PARAMS:
1713 len = sizeof(struct mwifiex_tdls_config_cs_params);
1714 memcpy(tdls_config->tdls_data, data_buf, len);
1715 break;
1716 default:
1717 mwifiex_dbg(priv->adapter, ERROR,
1718 "Unknown TDLS configuration\n");
1719 return -EOPNOTSUPP;
1720 }
1721
1722 le16_unaligned_add_cpu(&cmd->size, len);
1723 return 0;
1724 }
1725
1726 static int
1727 mwifiex_cmd_tdls_oper(struct mwifiex_private *priv,
1728 struct host_cmd_ds_command *cmd,
1729 void *data_buf)
1730 {
1731 struct host_cmd_ds_tdls_oper *tdls_oper = &cmd->params.tdls_oper;
1732 struct mwifiex_ds_tdls_oper *oper = data_buf;
1733 struct host_cmd_tlv_rates *tlv_rates;
1734 struct mwifiex_ie_types_htcap *ht_capab;
1735 struct mwifiex_ie_types_qos_info *wmm_qos_info;
1736 struct mwifiex_ie_types_extcap *extcap;
1737 struct mwifiex_ie_types_vhtcap *vht_capab;
1738 struct mwifiex_ie_types_aid *aid;
1739 struct mwifiex_ie_types_tdls_idle_timeout *timeout;
1740 u8 *pos;
1741 u16 config_len = 0;
1742 struct station_parameters *params = priv->sta_params;
1743
1744 cmd->command = cpu_to_le16(HostCmd_CMD_TDLS_OPER);
1745 cmd->size = cpu_to_le16(S_DS_GEN);
1746 le16_unaligned_add_cpu(&cmd->size,
1747 sizeof(struct host_cmd_ds_tdls_oper));
1748
1749 tdls_oper->reason = 0;
1750 memcpy(tdls_oper->peer_mac, oper->peer_mac, ETH_ALEN);
1751
1752 pos = (u8 *)tdls_oper + sizeof(struct host_cmd_ds_tdls_oper);
1753
1754 switch (oper->tdls_action) {
1755 case MWIFIEX_TDLS_DISABLE_LINK:
1756 tdls_oper->tdls_action = cpu_to_le16(ACT_TDLS_DELETE);
1757 break;
1758 case MWIFIEX_TDLS_CREATE_LINK:
1759 tdls_oper->tdls_action = cpu_to_le16(ACT_TDLS_CREATE);
1760 break;
1761 case MWIFIEX_TDLS_CONFIG_LINK:
1762 tdls_oper->tdls_action = cpu_to_le16(ACT_TDLS_CONFIG);
1763
1764 if (!params) {
1765 mwifiex_dbg(priv->adapter, ERROR,
1766 "TDLS config params not available for %pM\n",
1767 oper->peer_mac);
1768 return -ENODATA;
1769 }
1770
1771 put_unaligned_le16(params->capability, pos);
1772 config_len += sizeof(params->capability);
1773
1774 wmm_qos_info = (void *)(pos + config_len);
1775 wmm_qos_info->header.type = cpu_to_le16(WLAN_EID_QOS_CAPA);
1776 wmm_qos_info->header.len =
1777 cpu_to_le16(sizeof(wmm_qos_info->qos_info));
1778 wmm_qos_info->qos_info = 0;
1779 config_len += sizeof(struct mwifiex_ie_types_qos_info);
1780
1781 if (params->link_sta_params.ht_capa) {
1782 ht_capab = (struct mwifiex_ie_types_htcap *)(pos +
1783 config_len);
1784 ht_capab->header.type =
1785 cpu_to_le16(WLAN_EID_HT_CAPABILITY);
1786 ht_capab->header.len =
1787 cpu_to_le16(sizeof(struct ieee80211_ht_cap));
1788 memcpy(&ht_capab->ht_cap, params->link_sta_params.ht_capa,
1789 sizeof(struct ieee80211_ht_cap));
1790 config_len += sizeof(struct mwifiex_ie_types_htcap);
1791 }
1792
1793 if (params->link_sta_params.supported_rates &&
1794 params->link_sta_params.supported_rates_len) {
1795 tlv_rates = (struct host_cmd_tlv_rates *)(pos +
1796 config_len);
1797 tlv_rates->header.type =
1798 cpu_to_le16(WLAN_EID_SUPP_RATES);
1799 tlv_rates->header.len =
1800 cpu_to_le16(params->link_sta_params.supported_rates_len);
1801 memcpy(tlv_rates->rates,
1802 params->link_sta_params.supported_rates,
1803 params->link_sta_params.supported_rates_len);
1804 config_len += sizeof(struct host_cmd_tlv_rates) +
1805 params->link_sta_params.supported_rates_len;
1806 }
1807
1808 if (params->ext_capab && params->ext_capab_len) {
1809 extcap = (struct mwifiex_ie_types_extcap *)(pos +
1810 config_len);
1811 extcap->header.type =
1812 cpu_to_le16(WLAN_EID_EXT_CAPABILITY);
1813 extcap->header.len = cpu_to_le16(params->ext_capab_len);
1814 memcpy(extcap->ext_capab, params->ext_capab,
1815 params->ext_capab_len);
1816 config_len += sizeof(struct mwifiex_ie_types_extcap) +
1817 params->ext_capab_len;
1818 }
1819 if (params->link_sta_params.vht_capa) {
1820 vht_capab = (struct mwifiex_ie_types_vhtcap *)(pos +
1821 config_len);
1822 vht_capab->header.type =
1823 cpu_to_le16(WLAN_EID_VHT_CAPABILITY);
1824 vht_capab->header.len =
1825 cpu_to_le16(sizeof(struct ieee80211_vht_cap));
1826 memcpy(&vht_capab->vht_cap, params->link_sta_params.vht_capa,
1827 sizeof(struct ieee80211_vht_cap));
1828 config_len += sizeof(struct mwifiex_ie_types_vhtcap);
1829 }
1830 if (params->aid) {
1831 aid = (struct mwifiex_ie_types_aid *)(pos + config_len);
1832 aid->header.type = cpu_to_le16(WLAN_EID_AID);
1833 aid->header.len = cpu_to_le16(sizeof(params->aid));
1834 aid->aid = cpu_to_le16(params->aid);
1835 config_len += sizeof(struct mwifiex_ie_types_aid);
1836 }
1837
1838 timeout = (void *)(pos + config_len);
1839 timeout->header.type = cpu_to_le16(TLV_TYPE_TDLS_IDLE_TIMEOUT);
1840 timeout->header.len = cpu_to_le16(sizeof(timeout->value));
1841 timeout->value = cpu_to_le16(MWIFIEX_TDLS_IDLE_TIMEOUT_IN_SEC);
1842 config_len += sizeof(struct mwifiex_ie_types_tdls_idle_timeout);
1843
1844 break;
1845 default:
1846 mwifiex_dbg(priv->adapter, ERROR, "Unknown TDLS operation\n");
1847 return -EOPNOTSUPP;
1848 }
1849
1850 le16_unaligned_add_cpu(&cmd->size, config_len);
1851
1852 return 0;
1853 }
1854
1855
1856 static int mwifiex_cmd_sdio_rx_aggr_cfg(struct host_cmd_ds_command *cmd,
1857 u16 cmd_action, void *data_buf)
1858 {
1859 struct host_cmd_sdio_sp_rx_aggr_cfg *cfg =
1860 &cmd->params.sdio_rx_aggr_cfg;
1861
1862 cmd->command = cpu_to_le16(HostCmd_CMD_SDIO_SP_RX_AGGR_CFG);
1863 cmd->size =
1864 cpu_to_le16(sizeof(struct host_cmd_sdio_sp_rx_aggr_cfg) +
1865 S_DS_GEN);
1866 cfg->action = cmd_action;
1867 if (cmd_action == HostCmd_ACT_GEN_SET)
1868 cfg->enable = *(u8 *)data_buf;
1869
1870 return 0;
1871 }
1872
1873
1874
1875
1876
1877
1878
1879 static int mwifiex_cmd_get_wakeup_reason(struct mwifiex_private *priv,
1880 struct host_cmd_ds_command *cmd)
1881 {
1882 cmd->command = cpu_to_le16(HostCmd_CMD_HS_WAKEUP_REASON);
1883 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_wakeup_reason) +
1884 S_DS_GEN);
1885
1886 return 0;
1887 }
1888
1889 static int mwifiex_cmd_get_chan_info(struct host_cmd_ds_command *cmd,
1890 u16 cmd_action)
1891 {
1892 struct host_cmd_ds_sta_configure *sta_cfg_cmd = &cmd->params.sta_cfg;
1893 struct host_cmd_tlv_channel_band *tlv_band_channel =
1894 (struct host_cmd_tlv_channel_band *)sta_cfg_cmd->tlv_buffer;
1895
1896 cmd->command = cpu_to_le16(HostCmd_CMD_STA_CONFIGURE);
1897 cmd->size = cpu_to_le16(sizeof(*sta_cfg_cmd) +
1898 sizeof(*tlv_band_channel) + S_DS_GEN);
1899 sta_cfg_cmd->action = cpu_to_le16(cmd_action);
1900 memset(tlv_band_channel, 0, sizeof(*tlv_band_channel));
1901 tlv_band_channel->header.type = cpu_to_le16(TLV_TYPE_CHANNELBANDLIST);
1902 tlv_band_channel->header.len = cpu_to_le16(sizeof(*tlv_band_channel) -
1903 sizeof(struct mwifiex_ie_types_header));
1904
1905 return 0;
1906 }
1907
1908
1909 static int mwifiex_is_cmd_supported(struct mwifiex_private *priv, u16 cmd_no)
1910 {
1911 if (!ISSUPP_ADHOC_ENABLED(priv->adapter->fw_cap_info)) {
1912 switch (cmd_no) {
1913 case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS:
1914 case HostCmd_CMD_802_11_AD_HOC_START:
1915 case HostCmd_CMD_802_11_AD_HOC_JOIN:
1916 case HostCmd_CMD_802_11_AD_HOC_STOP:
1917 return -EOPNOTSUPP;
1918 default:
1919 break;
1920 }
1921 }
1922
1923 return 0;
1924 }
1925
1926
1927
1928
1929
1930
1931
1932 int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
1933 u16 cmd_action, u32 cmd_oid,
1934 void *data_buf, void *cmd_buf)
1935 {
1936 struct host_cmd_ds_command *cmd_ptr = cmd_buf;
1937 int ret = 0;
1938
1939 if (mwifiex_is_cmd_supported(priv, cmd_no)) {
1940 mwifiex_dbg(priv->adapter, ERROR,
1941 "0x%x command not supported by firmware\n",
1942 cmd_no);
1943 return -EOPNOTSUPP;
1944 }
1945
1946
1947 switch (cmd_no) {
1948 case HostCmd_CMD_GET_HW_SPEC:
1949 ret = mwifiex_cmd_get_hw_spec(priv, cmd_ptr);
1950 break;
1951 case HostCmd_CMD_CFG_DATA:
1952 ret = mwifiex_cmd_cfg_data(priv, cmd_ptr, data_buf);
1953 break;
1954 case HostCmd_CMD_MAC_CONTROL:
1955 ret = mwifiex_cmd_mac_control(priv, cmd_ptr, cmd_action,
1956 data_buf);
1957 break;
1958 case HostCmd_CMD_802_11_MAC_ADDRESS:
1959 ret = mwifiex_cmd_802_11_mac_address(priv, cmd_ptr,
1960 cmd_action);
1961 break;
1962 case HostCmd_CMD_MAC_MULTICAST_ADR:
1963 ret = mwifiex_cmd_mac_multicast_adr(cmd_ptr, cmd_action,
1964 data_buf);
1965 break;
1966 case HostCmd_CMD_TX_RATE_CFG:
1967 ret = mwifiex_cmd_tx_rate_cfg(priv, cmd_ptr, cmd_action,
1968 data_buf);
1969 break;
1970 case HostCmd_CMD_TXPWR_CFG:
1971 ret = mwifiex_cmd_tx_power_cfg(cmd_ptr, cmd_action,
1972 data_buf);
1973 break;
1974 case HostCmd_CMD_RF_TX_PWR:
1975 ret = mwifiex_cmd_rf_tx_power(priv, cmd_ptr, cmd_action,
1976 data_buf);
1977 break;
1978 case HostCmd_CMD_RF_ANTENNA:
1979 ret = mwifiex_cmd_rf_antenna(priv, cmd_ptr, cmd_action,
1980 data_buf);
1981 break;
1982 case HostCmd_CMD_802_11_PS_MODE_ENH:
1983 ret = mwifiex_cmd_enh_power_mode(priv, cmd_ptr, cmd_action,
1984 (uint16_t)cmd_oid, data_buf);
1985 break;
1986 case HostCmd_CMD_802_11_HS_CFG_ENH:
1987 ret = mwifiex_cmd_802_11_hs_cfg(priv, cmd_ptr, cmd_action,
1988 (struct mwifiex_hs_config_param *) data_buf);
1989 break;
1990 case HostCmd_CMD_802_11_SCAN:
1991 ret = mwifiex_cmd_802_11_scan(cmd_ptr, data_buf);
1992 break;
1993 case HostCmd_CMD_802_11_BG_SCAN_CONFIG:
1994 ret = mwifiex_cmd_802_11_bg_scan_config(priv, cmd_ptr,
1995 data_buf);
1996 break;
1997 case HostCmd_CMD_802_11_BG_SCAN_QUERY:
1998 ret = mwifiex_cmd_802_11_bg_scan_query(cmd_ptr);
1999 break;
2000 case HostCmd_CMD_802_11_ASSOCIATE:
2001 ret = mwifiex_cmd_802_11_associate(priv, cmd_ptr, data_buf);
2002 break;
2003 case HostCmd_CMD_802_11_DEAUTHENTICATE:
2004 ret = mwifiex_cmd_802_11_deauthenticate(priv, cmd_ptr,
2005 data_buf);
2006 break;
2007 case HostCmd_CMD_802_11_AD_HOC_START:
2008 ret = mwifiex_cmd_802_11_ad_hoc_start(priv, cmd_ptr,
2009 data_buf);
2010 break;
2011 case HostCmd_CMD_802_11_GET_LOG:
2012 ret = mwifiex_cmd_802_11_get_log(cmd_ptr);
2013 break;
2014 case HostCmd_CMD_802_11_AD_HOC_JOIN:
2015 ret = mwifiex_cmd_802_11_ad_hoc_join(priv, cmd_ptr,
2016 data_buf);
2017 break;
2018 case HostCmd_CMD_802_11_AD_HOC_STOP:
2019 ret = mwifiex_cmd_802_11_ad_hoc_stop(cmd_ptr);
2020 break;
2021 case HostCmd_CMD_RSSI_INFO:
2022 ret = mwifiex_cmd_802_11_rssi_info(priv, cmd_ptr, cmd_action);
2023 break;
2024 case HostCmd_CMD_802_11_SNMP_MIB:
2025 ret = mwifiex_cmd_802_11_snmp_mib(priv, cmd_ptr, cmd_action,
2026 cmd_oid, data_buf);
2027 break;
2028 case HostCmd_CMD_802_11_TX_RATE_QUERY:
2029 cmd_ptr->command =
2030 cpu_to_le16(HostCmd_CMD_802_11_TX_RATE_QUERY);
2031 cmd_ptr->size =
2032 cpu_to_le16(sizeof(struct host_cmd_ds_tx_rate_query) +
2033 S_DS_GEN);
2034 priv->tx_rate = 0;
2035 ret = 0;
2036 break;
2037 case HostCmd_CMD_VERSION_EXT:
2038 cmd_ptr->command = cpu_to_le16(cmd_no);
2039 cmd_ptr->params.verext.version_str_sel =
2040 (u8)(get_unaligned((u32 *)data_buf));
2041 memcpy(&cmd_ptr->params, data_buf,
2042 sizeof(struct host_cmd_ds_version_ext));
2043 cmd_ptr->size =
2044 cpu_to_le16(sizeof(struct host_cmd_ds_version_ext) +
2045 S_DS_GEN);
2046 ret = 0;
2047 break;
2048 case HostCmd_CMD_MGMT_FRAME_REG:
2049 cmd_ptr->command = cpu_to_le16(cmd_no);
2050 cmd_ptr->params.reg_mask.action = cpu_to_le16(cmd_action);
2051 cmd_ptr->params.reg_mask.mask = cpu_to_le32(
2052 get_unaligned((u32 *)data_buf));
2053 cmd_ptr->size =
2054 cpu_to_le16(sizeof(struct host_cmd_ds_mgmt_frame_reg) +
2055 S_DS_GEN);
2056 ret = 0;
2057 break;
2058 case HostCmd_CMD_REMAIN_ON_CHAN:
2059 cmd_ptr->command = cpu_to_le16(cmd_no);
2060 memcpy(&cmd_ptr->params, data_buf,
2061 sizeof(struct host_cmd_ds_remain_on_chan));
2062 cmd_ptr->size =
2063 cpu_to_le16(sizeof(struct host_cmd_ds_remain_on_chan) +
2064 S_DS_GEN);
2065 break;
2066 case HostCmd_CMD_11AC_CFG:
2067 ret = mwifiex_cmd_11ac_cfg(priv, cmd_ptr, cmd_action, data_buf);
2068 break;
2069 case HostCmd_CMD_PACKET_AGGR_CTRL:
2070 cmd_ptr->command = cpu_to_le16(cmd_no);
2071 cmd_ptr->params.pkt_aggr_ctrl.action = cpu_to_le16(cmd_action);
2072 cmd_ptr->params.pkt_aggr_ctrl.enable =
2073 cpu_to_le16(*(u16 *)data_buf);
2074 cmd_ptr->size =
2075 cpu_to_le16(sizeof(struct host_cmd_ds_pkt_aggr_ctrl) +
2076 S_DS_GEN);
2077 break;
2078 case HostCmd_CMD_P2P_MODE_CFG:
2079 cmd_ptr->command = cpu_to_le16(cmd_no);
2080 cmd_ptr->params.mode_cfg.action = cpu_to_le16(cmd_action);
2081 cmd_ptr->params.mode_cfg.mode = cpu_to_le16(
2082 get_unaligned((u16 *)data_buf));
2083 cmd_ptr->size =
2084 cpu_to_le16(sizeof(struct host_cmd_ds_p2p_mode_cfg) +
2085 S_DS_GEN);
2086 break;
2087 case HostCmd_CMD_FUNC_INIT:
2088 if (priv->adapter->hw_status == MWIFIEX_HW_STATUS_RESET)
2089 priv->adapter->hw_status = MWIFIEX_HW_STATUS_READY;
2090 cmd_ptr->command = cpu_to_le16(cmd_no);
2091 cmd_ptr->size = cpu_to_le16(S_DS_GEN);
2092 break;
2093 case HostCmd_CMD_FUNC_SHUTDOWN:
2094 priv->adapter->hw_status = MWIFIEX_HW_STATUS_RESET;
2095 cmd_ptr->command = cpu_to_le16(cmd_no);
2096 cmd_ptr->size = cpu_to_le16(S_DS_GEN);
2097 break;
2098 case HostCmd_CMD_11N_ADDBA_REQ:
2099 ret = mwifiex_cmd_11n_addba_req(cmd_ptr, data_buf);
2100 break;
2101 case HostCmd_CMD_11N_DELBA:
2102 ret = mwifiex_cmd_11n_delba(cmd_ptr, data_buf);
2103 break;
2104 case HostCmd_CMD_11N_ADDBA_RSP:
2105 ret = mwifiex_cmd_11n_addba_rsp_gen(priv, cmd_ptr, data_buf);
2106 break;
2107 case HostCmd_CMD_802_11_KEY_MATERIAL:
2108 ret = mwifiex_cmd_802_11_key_material(priv, cmd_ptr,
2109 cmd_action, cmd_oid,
2110 data_buf);
2111 break;
2112 case HostCmd_CMD_802_11D_DOMAIN_INFO:
2113 ret = mwifiex_cmd_802_11d_domain_info(priv, cmd_ptr,
2114 cmd_action);
2115 break;
2116 case HostCmd_CMD_RECONFIGURE_TX_BUFF:
2117 ret = mwifiex_cmd_recfg_tx_buf(priv, cmd_ptr, cmd_action,
2118 data_buf);
2119 break;
2120 case HostCmd_CMD_AMSDU_AGGR_CTRL:
2121 ret = mwifiex_cmd_amsdu_aggr_ctrl(cmd_ptr, cmd_action,
2122 data_buf);
2123 break;
2124 case HostCmd_CMD_11N_CFG:
2125 ret = mwifiex_cmd_11n_cfg(priv, cmd_ptr, cmd_action, data_buf);
2126 break;
2127 case HostCmd_CMD_WMM_GET_STATUS:
2128 mwifiex_dbg(priv->adapter, CMD,
2129 "cmd: WMM: WMM_GET_STATUS cmd sent\n");
2130 cmd_ptr->command = cpu_to_le16(HostCmd_CMD_WMM_GET_STATUS);
2131 cmd_ptr->size =
2132 cpu_to_le16(sizeof(struct host_cmd_ds_wmm_get_status) +
2133 S_DS_GEN);
2134 ret = 0;
2135 break;
2136 case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS:
2137 ret = mwifiex_cmd_ibss_coalescing_status(cmd_ptr, cmd_action,
2138 data_buf);
2139 break;
2140 case HostCmd_CMD_802_11_SCAN_EXT:
2141 ret = mwifiex_cmd_802_11_scan_ext(priv, cmd_ptr, data_buf);
2142 break;
2143 case HostCmd_CMD_MEM_ACCESS:
2144 ret = mwifiex_cmd_mem_access(cmd_ptr, cmd_action, data_buf);
2145 break;
2146 case HostCmd_CMD_MAC_REG_ACCESS:
2147 case HostCmd_CMD_BBP_REG_ACCESS:
2148 case HostCmd_CMD_RF_REG_ACCESS:
2149 case HostCmd_CMD_PMIC_REG_ACCESS:
2150 case HostCmd_CMD_CAU_REG_ACCESS:
2151 case HostCmd_CMD_802_11_EEPROM_ACCESS:
2152 ret = mwifiex_cmd_reg_access(cmd_ptr, cmd_action, data_buf);
2153 break;
2154 case HostCmd_CMD_SET_BSS_MODE:
2155 cmd_ptr->command = cpu_to_le16(cmd_no);
2156 if (priv->bss_mode == NL80211_IFTYPE_ADHOC)
2157 cmd_ptr->params.bss_mode.con_type =
2158 CONNECTION_TYPE_ADHOC;
2159 else if (priv->bss_mode == NL80211_IFTYPE_STATION ||
2160 priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT)
2161 cmd_ptr->params.bss_mode.con_type =
2162 CONNECTION_TYPE_INFRA;
2163 else if (priv->bss_mode == NL80211_IFTYPE_AP ||
2164 priv->bss_mode == NL80211_IFTYPE_P2P_GO)
2165 cmd_ptr->params.bss_mode.con_type = CONNECTION_TYPE_AP;
2166 cmd_ptr->size = cpu_to_le16(sizeof(struct
2167 host_cmd_ds_set_bss_mode) + S_DS_GEN);
2168 ret = 0;
2169 break;
2170 case HostCmd_CMD_PCIE_DESC_DETAILS:
2171 ret = mwifiex_cmd_pcie_host_spec(priv, cmd_ptr, cmd_action);
2172 break;
2173 case HostCmd_CMD_802_11_SUBSCRIBE_EVENT:
2174 ret = mwifiex_cmd_802_11_subsc_evt(priv, cmd_ptr, data_buf);
2175 break;
2176 case HostCmd_CMD_MEF_CFG:
2177 ret = mwifiex_cmd_mef_cfg(priv, cmd_ptr, data_buf);
2178 break;
2179 case HostCmd_CMD_COALESCE_CFG:
2180 ret = mwifiex_cmd_coalesce_cfg(priv, cmd_ptr, cmd_action,
2181 data_buf);
2182 break;
2183 case HostCmd_CMD_TDLS_OPER:
2184 ret = mwifiex_cmd_tdls_oper(priv, cmd_ptr, data_buf);
2185 break;
2186 case HostCmd_CMD_TDLS_CONFIG:
2187 ret = mwifiex_cmd_tdls_config(priv, cmd_ptr, cmd_action,
2188 data_buf);
2189 break;
2190 case HostCmd_CMD_CHAN_REPORT_REQUEST:
2191 ret = mwifiex_cmd_issue_chan_report_request(priv, cmd_ptr,
2192 data_buf);
2193 break;
2194 case HostCmd_CMD_SDIO_SP_RX_AGGR_CFG:
2195 ret = mwifiex_cmd_sdio_rx_aggr_cfg(cmd_ptr, cmd_action,
2196 data_buf);
2197 break;
2198 case HostCmd_CMD_HS_WAKEUP_REASON:
2199 ret = mwifiex_cmd_get_wakeup_reason(priv, cmd_ptr);
2200 break;
2201 case HostCmd_CMD_MC_POLICY:
2202 ret = mwifiex_cmd_set_mc_policy(priv, cmd_ptr, cmd_action,
2203 data_buf);
2204 break;
2205 case HostCmd_CMD_ROBUST_COEX:
2206 ret = mwifiex_cmd_robust_coex(priv, cmd_ptr, cmd_action,
2207 data_buf);
2208 break;
2209 case HostCmd_CMD_GTK_REKEY_OFFLOAD_CFG:
2210 ret = mwifiex_cmd_gtk_rekey_offload(priv, cmd_ptr, cmd_action,
2211 data_buf);
2212 break;
2213 case HostCmd_CMD_CHAN_REGION_CFG:
2214 ret = mwifiex_cmd_chan_region_cfg(priv, cmd_ptr, cmd_action);
2215 break;
2216 case HostCmd_CMD_FW_DUMP_EVENT:
2217 cmd_ptr->command = cpu_to_le16(cmd_no);
2218 cmd_ptr->size = cpu_to_le16(S_DS_GEN);
2219 break;
2220 case HostCmd_CMD_STA_CONFIGURE:
2221 ret = mwifiex_cmd_get_chan_info(cmd_ptr, cmd_action);
2222 break;
2223 default:
2224 mwifiex_dbg(priv->adapter, ERROR,
2225 "PREP_CMD: unknown cmd- %#x\n", cmd_no);
2226 ret = -1;
2227 break;
2228 }
2229 return ret;
2230 }
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253 int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init)
2254 {
2255 struct mwifiex_adapter *adapter = priv->adapter;
2256 int ret;
2257 struct mwifiex_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl;
2258 struct mwifiex_ds_auto_ds auto_ds;
2259 enum state_11d_t state_11d;
2260 struct mwifiex_ds_11n_tx_cfg tx_cfg;
2261 u8 sdio_sp_rx_aggr_enable;
2262 u16 packet_aggr_enable;
2263 int data;
2264
2265 if (first_sta) {
2266 if (priv->adapter->iface_type == MWIFIEX_PCIE) {
2267 ret = mwifiex_send_cmd(priv,
2268 HostCmd_CMD_PCIE_DESC_DETAILS,
2269 HostCmd_ACT_GEN_SET, 0, NULL,
2270 true);
2271 if (ret)
2272 return -1;
2273 }
2274
2275 ret = mwifiex_send_cmd(priv, HostCmd_CMD_FUNC_INIT,
2276 HostCmd_ACT_GEN_SET, 0, NULL, true);
2277 if (ret)
2278 return -1;
2279
2280
2281
2282
2283
2284 if (adapter->dt_node) {
2285 if (of_property_read_u32(adapter->dt_node,
2286 "marvell,wakeup-pin",
2287 &data) == 0) {
2288 pr_debug("Wakeup pin = 0x%x\n", data);
2289 adapter->hs_cfg.gpio = data;
2290 }
2291
2292 mwifiex_dnld_dt_cfgdata(priv, adapter->dt_node,
2293 "marvell,caldata");
2294 }
2295
2296 if (adapter->cal_data)
2297 mwifiex_send_cmd(priv, HostCmd_CMD_CFG_DATA,
2298 HostCmd_ACT_GEN_SET, 0, NULL, true);
2299
2300
2301 ret = mwifiex_send_cmd(priv, HostCmd_CMD_GET_HW_SPEC,
2302 HostCmd_ACT_GEN_GET, 0, NULL, true);
2303 if (ret)
2304 return -1;
2305
2306
2307 if (priv->adapter->iface_type == MWIFIEX_SDIO &&
2308 ISSUPP_SDIO_SPA_ENABLED(priv->adapter->fw_cap_info) &&
2309 !priv->adapter->host_disable_sdio_rx_aggr) {
2310 sdio_sp_rx_aggr_enable = true;
2311 ret = mwifiex_send_cmd(priv,
2312 HostCmd_CMD_SDIO_SP_RX_AGGR_CFG,
2313 HostCmd_ACT_GEN_SET, 0,
2314 &sdio_sp_rx_aggr_enable,
2315 true);
2316 if (ret) {
2317 mwifiex_dbg(priv->adapter, ERROR,
2318 "error while enabling SP aggregation..disable it");
2319 adapter->sdio_rx_aggr_enable = false;
2320 }
2321 }
2322
2323
2324 ret = mwifiex_send_cmd(priv, HostCmd_CMD_RECONFIGURE_TX_BUFF,
2325 HostCmd_ACT_GEN_SET, 0,
2326 &priv->adapter->tx_buf_size, true);
2327 if (ret)
2328 return -1;
2329
2330 if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
2331
2332 priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
2333 ret = mwifiex_send_cmd(priv,
2334 HostCmd_CMD_802_11_PS_MODE_ENH,
2335 EN_AUTO_PS, BITMAP_STA_PS, NULL,
2336 true);
2337 if (ret)
2338 return -1;
2339 }
2340
2341 if (drcs) {
2342 adapter->drcs_enabled = true;
2343 if (ISSUPP_DRCS_ENABLED(adapter->fw_cap_info))
2344 ret = mwifiex_send_cmd(priv,
2345 HostCmd_CMD_MC_POLICY,
2346 HostCmd_ACT_GEN_SET, 0,
2347 &adapter->drcs_enabled,
2348 true);
2349 if (ret)
2350 return -1;
2351 }
2352
2353 mwifiex_send_cmd(priv, HostCmd_CMD_CHAN_REGION_CFG,
2354 HostCmd_ACT_GEN_GET, 0, NULL, true);
2355 }
2356
2357
2358 ret = mwifiex_send_cmd(priv, HostCmd_CMD_TX_RATE_CFG,
2359 HostCmd_ACT_GEN_GET, 0, NULL, true);
2360 if (ret)
2361 return -1;
2362 priv->data_rate = 0;
2363
2364
2365 ret = mwifiex_send_cmd(priv, HostCmd_CMD_RF_TX_PWR,
2366 HostCmd_ACT_GEN_GET, 0, NULL, true);
2367 if (ret)
2368 return -1;
2369
2370 memset(&amsdu_aggr_ctrl, 0, sizeof(amsdu_aggr_ctrl));
2371 amsdu_aggr_ctrl.enable = true;
2372
2373 ret = mwifiex_send_cmd(priv, HostCmd_CMD_AMSDU_AGGR_CTRL,
2374 HostCmd_ACT_GEN_SET, 0,
2375 &amsdu_aggr_ctrl, true);
2376 if (ret)
2377 return -1;
2378
2379
2380 ret = mwifiex_send_cmd(priv, HostCmd_CMD_MAC_CONTROL,
2381 HostCmd_ACT_GEN_SET, 0,
2382 &priv->curr_pkt_filter, true);
2383 if (ret)
2384 return -1;
2385
2386 if (!disable_auto_ds && first_sta &&
2387 priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
2388
2389 auto_ds.auto_ds = DEEP_SLEEP_ON;
2390 auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME;
2391 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
2392 EN_AUTO_PS, BITMAP_AUTO_DS,
2393 &auto_ds, true);
2394 if (ret)
2395 return -1;
2396 }
2397
2398 if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
2399
2400 state_11d = ENABLE_11D;
2401 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_SNMP_MIB,
2402 HostCmd_ACT_GEN_SET, DOT11D_I,
2403 &state_11d, true);
2404 if (ret)
2405 mwifiex_dbg(priv->adapter, ERROR,
2406 "11D: failed to enable 11D\n");
2407 }
2408
2409
2410 if (aggr_ctrl) {
2411 packet_aggr_enable = true;
2412 mwifiex_send_cmd(priv, HostCmd_CMD_PACKET_AGGR_CTRL,
2413 HostCmd_ACT_GEN_SET, 0,
2414 &packet_aggr_enable, true);
2415 }
2416
2417
2418
2419
2420 tx_cfg.tx_htcap = MWIFIEX_FW_DEF_HTTXCFG;
2421 ret = mwifiex_send_cmd(priv, HostCmd_CMD_11N_CFG,
2422 HostCmd_ACT_GEN_SET, 0, &tx_cfg, true);
2423
2424 if (init) {
2425
2426 priv->adapter->last_init_cmd = HostCmd_CMD_11N_CFG;
2427 ret = -EINPROGRESS;
2428 }
2429
2430 return ret;
2431 }