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 "cfg80211.h"
0016
0017 static int disconnect_on_suspend;
0018 module_param(disconnect_on_suspend, int, 0644);
0019
0020
0021
0022
0023
0024
0025
0026
0027 int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
0028 struct net_device *dev)
0029 {
0030 int i = 0;
0031 struct netdev_hw_addr *ha;
0032
0033 netdev_for_each_mc_addr(ha, dev)
0034 memcpy(&mlist->mac_list[i++], ha->addr, ETH_ALEN);
0035
0036 return i;
0037 }
0038
0039
0040
0041
0042
0043
0044
0045 int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter,
0046 struct cmd_ctrl_node *cmd_queued)
0047 {
0048 int status;
0049
0050
0051 status = wait_event_interruptible_timeout(adapter->cmd_wait_q.wait,
0052 *(cmd_queued->condition),
0053 (12 * HZ));
0054 if (status <= 0) {
0055 if (status == 0)
0056 status = -ETIMEDOUT;
0057 mwifiex_dbg(adapter, ERROR, "cmd_wait_q terminated: %d\n",
0058 status);
0059 mwifiex_cancel_all_pending_cmd(adapter);
0060 return status;
0061 }
0062
0063 status = adapter->cmd_wait_q.status;
0064 adapter->cmd_wait_q.status = 0;
0065
0066 return status;
0067 }
0068
0069
0070
0071
0072
0073
0074
0075
0076 int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
0077 struct mwifiex_multicast_list *mcast_list)
0078 {
0079 int ret = 0;
0080 u16 old_pkt_filter;
0081
0082 old_pkt_filter = priv->curr_pkt_filter;
0083
0084 if (mcast_list->mode == MWIFIEX_PROMISC_MODE) {
0085 mwifiex_dbg(priv->adapter, INFO,
0086 "info: Enable Promiscuous mode\n");
0087 priv->curr_pkt_filter |= HostCmd_ACT_MAC_PROMISCUOUS_ENABLE;
0088 priv->curr_pkt_filter &=
0089 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
0090 } else {
0091
0092 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_PROMISCUOUS_ENABLE;
0093 if (mcast_list->mode == MWIFIEX_ALL_MULTI_MODE) {
0094 mwifiex_dbg(priv->adapter, INFO,
0095 "info: Enabling All Multicast!\n");
0096 priv->curr_pkt_filter |=
0097 HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
0098 } else {
0099 priv->curr_pkt_filter &=
0100 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
0101 mwifiex_dbg(priv->adapter, INFO,
0102 "info: Set multicast list=%d\n",
0103 mcast_list->num_multicast_addr);
0104
0105 ret = mwifiex_send_cmd(priv,
0106 HostCmd_CMD_MAC_MULTICAST_ADR,
0107 HostCmd_ACT_GEN_SET, 0,
0108 mcast_list, false);
0109 }
0110 }
0111 mwifiex_dbg(priv->adapter, INFO,
0112 "info: old_pkt_filter=%#x, curr_pkt_filter=%#x\n",
0113 old_pkt_filter, priv->curr_pkt_filter);
0114 if (old_pkt_filter != priv->curr_pkt_filter) {
0115 ret = mwifiex_send_cmd(priv, HostCmd_CMD_MAC_CONTROL,
0116 HostCmd_ACT_GEN_SET,
0117 0, &priv->curr_pkt_filter, false);
0118 }
0119
0120 return ret;
0121 }
0122
0123
0124
0125
0126
0127
0128
0129 int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
0130 struct cfg80211_bss *bss,
0131 struct mwifiex_bssdescriptor *bss_desc)
0132 {
0133 u8 *beacon_ie;
0134 size_t beacon_ie_len;
0135 struct mwifiex_bss_priv *bss_priv = (void *)bss->priv;
0136 const struct cfg80211_bss_ies *ies;
0137
0138 rcu_read_lock();
0139 ies = rcu_dereference(bss->ies);
0140 beacon_ie = kmemdup(ies->data, ies->len, GFP_ATOMIC);
0141 beacon_ie_len = ies->len;
0142 bss_desc->timestamp = ies->tsf;
0143 rcu_read_unlock();
0144
0145 if (!beacon_ie) {
0146 mwifiex_dbg(priv->adapter, ERROR,
0147 " failed to alloc beacon_ie\n");
0148 return -ENOMEM;
0149 }
0150
0151 memcpy(bss_desc->mac_address, bss->bssid, ETH_ALEN);
0152 bss_desc->rssi = bss->signal;
0153
0154 bss_desc->beacon_buf = beacon_ie;
0155 bss_desc->beacon_buf_size = beacon_ie_len;
0156 bss_desc->beacon_period = bss->beacon_interval;
0157 bss_desc->cap_info_bitmap = bss->capability;
0158 bss_desc->bss_band = bss_priv->band;
0159 bss_desc->fw_tsf = bss_priv->fw_tsf;
0160 if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_PRIVACY) {
0161 mwifiex_dbg(priv->adapter, INFO,
0162 "info: InterpretIE: AP WEP enabled\n");
0163 bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_8021X_WEP;
0164 } else {
0165 bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL;
0166 }
0167 if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_IBSS)
0168 bss_desc->bss_mode = NL80211_IFTYPE_ADHOC;
0169 else
0170 bss_desc->bss_mode = NL80211_IFTYPE_STATION;
0171
0172
0173
0174
0175 bss_desc->disable_11ac = true;
0176
0177 if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_SPECTRUM_MGMT)
0178 bss_desc->sensed_11h = true;
0179
0180 return mwifiex_update_bss_desc_with_ie(priv->adapter, bss_desc);
0181 }
0182
0183 void mwifiex_dnld_txpwr_table(struct mwifiex_private *priv)
0184 {
0185 if (priv->adapter->dt_node) {
0186 char txpwr[] = {"marvell,00_txpwrlimit"};
0187
0188 memcpy(&txpwr[8], priv->adapter->country_code, 2);
0189 mwifiex_dnld_dt_cfgdata(priv, priv->adapter->dt_node, txpwr);
0190 }
0191 }
0192
0193 static int mwifiex_process_country_ie(struct mwifiex_private *priv,
0194 struct cfg80211_bss *bss)
0195 {
0196 const u8 *country_ie;
0197 u8 country_ie_len;
0198 struct mwifiex_802_11d_domain_reg *domain_info =
0199 &priv->adapter->domain_reg;
0200
0201 rcu_read_lock();
0202 country_ie = ieee80211_bss_get_ie(bss, WLAN_EID_COUNTRY);
0203 if (!country_ie) {
0204 rcu_read_unlock();
0205 return 0;
0206 }
0207
0208 country_ie_len = country_ie[1];
0209 if (country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN) {
0210 rcu_read_unlock();
0211 return 0;
0212 }
0213
0214 if (!strncmp(priv->adapter->country_code, &country_ie[2], 2)) {
0215 rcu_read_unlock();
0216 mwifiex_dbg(priv->adapter, INFO,
0217 "11D: skip setting domain info in FW\n");
0218 return 0;
0219 }
0220
0221 if (country_ie_len >
0222 (IEEE80211_COUNTRY_STRING_LEN + MWIFIEX_MAX_TRIPLET_802_11D)) {
0223 rcu_read_unlock();
0224 mwifiex_dbg(priv->adapter, ERROR,
0225 "11D: country_ie_len overflow!, deauth AP\n");
0226 return -EINVAL;
0227 }
0228
0229 memcpy(priv->adapter->country_code, &country_ie[2], 2);
0230
0231 domain_info->country_code[0] = country_ie[2];
0232 domain_info->country_code[1] = country_ie[3];
0233 domain_info->country_code[2] = ' ';
0234
0235 country_ie_len -= IEEE80211_COUNTRY_STRING_LEN;
0236
0237 domain_info->no_of_triplet =
0238 country_ie_len / sizeof(struct ieee80211_country_ie_triplet);
0239
0240 memcpy((u8 *)domain_info->triplet,
0241 &country_ie[2] + IEEE80211_COUNTRY_STRING_LEN, country_ie_len);
0242
0243 rcu_read_unlock();
0244
0245 if (mwifiex_send_cmd(priv, HostCmd_CMD_802_11D_DOMAIN_INFO,
0246 HostCmd_ACT_GEN_SET, 0, NULL, false)) {
0247 mwifiex_dbg(priv->adapter, ERROR,
0248 "11D: setting domain info in FW fail\n");
0249 return -1;
0250 }
0251
0252 mwifiex_dnld_txpwr_table(priv);
0253
0254 return 0;
0255 }
0256
0257
0258
0259
0260
0261
0262 int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
0263 struct cfg80211_ssid *req_ssid)
0264 {
0265 int ret;
0266 struct mwifiex_adapter *adapter = priv->adapter;
0267 struct mwifiex_bssdescriptor *bss_desc = NULL;
0268
0269 priv->scan_block = false;
0270
0271 if (bss) {
0272 if (adapter->region_code == 0x00 &&
0273 mwifiex_process_country_ie(priv, bss))
0274 return -EINVAL;
0275
0276
0277 bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor),
0278 GFP_KERNEL);
0279 if (!bss_desc)
0280 return -ENOMEM;
0281
0282 ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc);
0283 if (ret)
0284 goto done;
0285 }
0286
0287 if (priv->bss_mode == NL80211_IFTYPE_STATION ||
0288 priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) {
0289 u8 config_bands;
0290
0291 if (!bss_desc)
0292 return -1;
0293
0294 if (mwifiex_band_to_radio_type(bss_desc->bss_band) ==
0295 HostCmd_SCAN_RADIO_TYPE_BG) {
0296 config_bands = BAND_B | BAND_G | BAND_GN;
0297 } else {
0298 config_bands = BAND_A | BAND_AN;
0299 if (adapter->fw_bands & BAND_AAC)
0300 config_bands |= BAND_AAC;
0301 }
0302
0303 if (!((config_bands | adapter->fw_bands) & ~adapter->fw_bands))
0304 adapter->config_bands = config_bands;
0305
0306 ret = mwifiex_check_network_compatibility(priv, bss_desc);
0307 if (ret)
0308 goto done;
0309
0310 if (mwifiex_11h_get_csa_closed_channel(priv) ==
0311 (u8)bss_desc->channel) {
0312 mwifiex_dbg(adapter, ERROR,
0313 "Attempt to reconnect on csa closed chan(%d)\n",
0314 bss_desc->channel);
0315 ret = -1;
0316 goto done;
0317 }
0318
0319 mwifiex_dbg(adapter, INFO,
0320 "info: SSID found in scan list ...\t"
0321 "associating...\n");
0322
0323 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
0324 if (netif_carrier_ok(priv->netdev))
0325 netif_carrier_off(priv->netdev);
0326
0327
0328
0329 priv->assoc_rsp_size = 0;
0330 ret = mwifiex_associate(priv, bss_desc);
0331
0332
0333
0334 if (ret == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG &&
0335 priv->sec_info.is_authtype_auto &&
0336 priv->sec_info.wep_enabled) {
0337 priv->sec_info.authentication_mode =
0338 NL80211_AUTHTYPE_SHARED_KEY;
0339 ret = mwifiex_associate(priv, bss_desc);
0340 }
0341
0342 if (bss)
0343 cfg80211_put_bss(priv->adapter->wiphy, bss);
0344 } else {
0345
0346
0347 if (bss_desc && bss_desc->ssid.ssid_len &&
0348 (!mwifiex_ssid_cmp(&priv->curr_bss_params.bss_descriptor.
0349 ssid, &bss_desc->ssid))) {
0350 ret = 0;
0351 goto done;
0352 }
0353
0354 priv->adhoc_is_link_sensed = false;
0355
0356 ret = mwifiex_check_network_compatibility(priv, bss_desc);
0357
0358 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
0359 if (netif_carrier_ok(priv->netdev))
0360 netif_carrier_off(priv->netdev);
0361
0362 if (!ret) {
0363 mwifiex_dbg(adapter, INFO,
0364 "info: network found in scan\t"
0365 " list. Joining...\n");
0366 ret = mwifiex_adhoc_join(priv, bss_desc);
0367 if (bss)
0368 cfg80211_put_bss(priv->adapter->wiphy, bss);
0369 } else {
0370 mwifiex_dbg(adapter, INFO,
0371 "info: Network not found in\t"
0372 "the list, creating adhoc with ssid = %s\n",
0373 req_ssid->ssid);
0374 ret = mwifiex_adhoc_start(priv, req_ssid);
0375 }
0376 }
0377
0378 done:
0379
0380
0381
0382 if (bss_desc)
0383 kfree(bss_desc->beacon_buf);
0384 kfree(bss_desc);
0385
0386 if (ret < 0)
0387 priv->attempted_bss_desc = NULL;
0388
0389 return ret;
0390 }
0391
0392
0393
0394
0395
0396
0397
0398 int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
0399 int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg)
0400
0401 {
0402 struct mwifiex_adapter *adapter = priv->adapter;
0403 int status = 0;
0404 u32 prev_cond = 0;
0405
0406 if (!hs_cfg)
0407 return -ENOMEM;
0408
0409 switch (action) {
0410 case HostCmd_ACT_GEN_SET:
0411 if (adapter->pps_uapsd_mode) {
0412 mwifiex_dbg(adapter, INFO,
0413 "info: Host Sleep IOCTL\t"
0414 "is blocked in UAPSD/PPS mode\n");
0415 status = -1;
0416 break;
0417 }
0418 if (hs_cfg->is_invoke_hostcmd) {
0419 if (hs_cfg->conditions == HS_CFG_CANCEL) {
0420 if (!test_bit(MWIFIEX_IS_HS_CONFIGURED,
0421 &adapter->work_flags))
0422
0423 break;
0424
0425 prev_cond = le32_to_cpu(adapter->hs_cfg
0426 .conditions);
0427 adapter->hs_cfg.conditions =
0428 cpu_to_le32(hs_cfg->conditions);
0429 } else if (hs_cfg->conditions) {
0430 adapter->hs_cfg.conditions =
0431 cpu_to_le32(hs_cfg->conditions);
0432 adapter->hs_cfg.gpio = (u8)hs_cfg->gpio;
0433 if (hs_cfg->gap)
0434 adapter->hs_cfg.gap = (u8)hs_cfg->gap;
0435 } else if (adapter->hs_cfg.conditions ==
0436 cpu_to_le32(HS_CFG_CANCEL)) {
0437
0438
0439 status = -1;
0440 break;
0441 }
0442
0443 status = mwifiex_send_cmd(priv,
0444 HostCmd_CMD_802_11_HS_CFG_ENH,
0445 HostCmd_ACT_GEN_SET, 0,
0446 &adapter->hs_cfg,
0447 cmd_type == MWIFIEX_SYNC_CMD);
0448
0449 if (hs_cfg->conditions == HS_CFG_CANCEL)
0450
0451 adapter->hs_cfg.conditions =
0452 cpu_to_le32(prev_cond);
0453 } else {
0454 adapter->hs_cfg.conditions =
0455 cpu_to_le32(hs_cfg->conditions);
0456 adapter->hs_cfg.gpio = (u8)hs_cfg->gpio;
0457 adapter->hs_cfg.gap = (u8)hs_cfg->gap;
0458 }
0459 break;
0460 case HostCmd_ACT_GEN_GET:
0461 hs_cfg->conditions = le32_to_cpu(adapter->hs_cfg.conditions);
0462 hs_cfg->gpio = adapter->hs_cfg.gpio;
0463 hs_cfg->gap = adapter->hs_cfg.gap;
0464 break;
0465 default:
0466 status = -1;
0467 break;
0468 }
0469
0470 return status;
0471 }
0472
0473
0474
0475
0476
0477
0478
0479 int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type)
0480 {
0481 struct mwifiex_ds_hs_cfg hscfg;
0482
0483 hscfg.conditions = HS_CFG_CANCEL;
0484 hscfg.is_invoke_hostcmd = true;
0485
0486 return mwifiex_set_hs_params(priv, HostCmd_ACT_GEN_SET,
0487 cmd_type, &hscfg);
0488 }
0489 EXPORT_SYMBOL_GPL(mwifiex_cancel_hs);
0490
0491
0492
0493
0494
0495
0496
0497 int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
0498 {
0499 struct mwifiex_ds_hs_cfg hscfg;
0500 struct mwifiex_private *priv;
0501 int i;
0502
0503 if (disconnect_on_suspend) {
0504 for (i = 0; i < adapter->priv_num; i++) {
0505 priv = adapter->priv[i];
0506 if (priv)
0507 mwifiex_deauthenticate(priv, NULL);
0508 }
0509 }
0510
0511 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA);
0512
0513 if (priv && priv->sched_scanning) {
0514 #ifdef CONFIG_PM
0515 if (priv->wdev.wiphy->wowlan_config &&
0516 !priv->wdev.wiphy->wowlan_config->nd_config) {
0517 #endif
0518 mwifiex_dbg(adapter, CMD, "aborting bgscan!\n");
0519 mwifiex_stop_bg_scan(priv);
0520 cfg80211_sched_scan_stopped(priv->wdev.wiphy, 0);
0521 #ifdef CONFIG_PM
0522 }
0523 #endif
0524 }
0525
0526 if (adapter->hs_activated) {
0527 mwifiex_dbg(adapter, CMD,
0528 "cmd: HS Already activated\n");
0529 return true;
0530 }
0531
0532 adapter->hs_activate_wait_q_woken = false;
0533
0534 memset(&hscfg, 0, sizeof(hscfg));
0535 hscfg.is_invoke_hostcmd = true;
0536
0537 set_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags);
0538 mwifiex_cancel_all_pending_cmd(adapter);
0539
0540 if (mwifiex_set_hs_params(mwifiex_get_priv(adapter,
0541 MWIFIEX_BSS_ROLE_STA),
0542 HostCmd_ACT_GEN_SET, MWIFIEX_SYNC_CMD,
0543 &hscfg)) {
0544 mwifiex_dbg(adapter, ERROR,
0545 "IOCTL request HS enable failed\n");
0546 return false;
0547 }
0548
0549 if (wait_event_interruptible_timeout(adapter->hs_activate_wait_q,
0550 adapter->hs_activate_wait_q_woken,
0551 (10 * HZ)) <= 0) {
0552 mwifiex_dbg(adapter, ERROR,
0553 "hs_activate_wait_q terminated\n");
0554 return false;
0555 }
0556
0557 return true;
0558 }
0559 EXPORT_SYMBOL_GPL(mwifiex_enable_hs);
0560
0561
0562
0563
0564
0565
0566
0567 int mwifiex_get_bss_info(struct mwifiex_private *priv,
0568 struct mwifiex_bss_info *info)
0569 {
0570 struct mwifiex_adapter *adapter = priv->adapter;
0571 struct mwifiex_bssdescriptor *bss_desc;
0572
0573 if (!info)
0574 return -1;
0575
0576 bss_desc = &priv->curr_bss_params.bss_descriptor;
0577
0578 info->bss_mode = priv->bss_mode;
0579
0580 memcpy(&info->ssid, &bss_desc->ssid, sizeof(struct cfg80211_ssid));
0581
0582 memcpy(&info->bssid, &bss_desc->mac_address, ETH_ALEN);
0583
0584 info->bss_chan = bss_desc->channel;
0585
0586 memcpy(info->country_code, adapter->country_code,
0587 IEEE80211_COUNTRY_STRING_LEN);
0588
0589 info->media_connected = priv->media_connected;
0590
0591 info->max_power_level = priv->max_tx_power_level;
0592 info->min_power_level = priv->min_tx_power_level;
0593
0594 info->adhoc_state = priv->adhoc_state;
0595
0596 info->bcn_nf_last = priv->bcn_nf_last;
0597
0598 if (priv->sec_info.wep_enabled)
0599 info->wep_status = true;
0600 else
0601 info->wep_status = false;
0602
0603 info->is_hs_configured = test_bit(MWIFIEX_IS_HS_CONFIGURED,
0604 &adapter->work_flags);
0605 info->is_deep_sleep = adapter->is_deep_sleep;
0606
0607 return 0;
0608 }
0609
0610
0611
0612
0613 int mwifiex_disable_auto_ds(struct mwifiex_private *priv)
0614 {
0615 struct mwifiex_ds_auto_ds auto_ds = {
0616 .auto_ds = DEEP_SLEEP_OFF,
0617 };
0618
0619 return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
0620 DIS_AUTO_PS, BITMAP_AUTO_DS, &auto_ds, true);
0621 }
0622 EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds);
0623
0624
0625
0626
0627
0628
0629
0630 int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate)
0631 {
0632 int ret;
0633
0634 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_TX_RATE_QUERY,
0635 HostCmd_ACT_GEN_GET, 0, NULL, true);
0636
0637 if (!ret) {
0638 if (priv->is_data_rate_auto)
0639 *rate = mwifiex_index_to_data_rate(priv, priv->tx_rate,
0640 priv->tx_htinfo);
0641 else
0642 *rate = priv->data_rate;
0643 }
0644
0645 return ret;
0646 }
0647
0648
0649
0650
0651
0652
0653
0654
0655
0656
0657
0658
0659
0660 int mwifiex_set_tx_power(struct mwifiex_private *priv,
0661 struct mwifiex_power_cfg *power_cfg)
0662 {
0663 int ret;
0664 struct host_cmd_ds_txpwr_cfg *txp_cfg;
0665 struct mwifiex_types_power_group *pg_tlv;
0666 struct mwifiex_power_group *pg;
0667 u8 *buf;
0668 u16 dbm = 0;
0669
0670 if (!power_cfg->is_power_auto) {
0671 dbm = (u16) power_cfg->power_level;
0672 if ((dbm < priv->min_tx_power_level) ||
0673 (dbm > priv->max_tx_power_level)) {
0674 mwifiex_dbg(priv->adapter, ERROR,
0675 "txpower value %d dBm\t"
0676 "is out of range (%d dBm-%d dBm)\n",
0677 dbm, priv->min_tx_power_level,
0678 priv->max_tx_power_level);
0679 return -1;
0680 }
0681 }
0682 buf = kzalloc(MWIFIEX_SIZE_OF_CMD_BUFFER, GFP_KERNEL);
0683 if (!buf)
0684 return -ENOMEM;
0685
0686 txp_cfg = (struct host_cmd_ds_txpwr_cfg *) buf;
0687 txp_cfg->action = cpu_to_le16(HostCmd_ACT_GEN_SET);
0688 if (!power_cfg->is_power_auto) {
0689 u16 dbm_min = power_cfg->is_power_fixed ?
0690 dbm : priv->min_tx_power_level;
0691
0692 txp_cfg->mode = cpu_to_le32(1);
0693 pg_tlv = (struct mwifiex_types_power_group *)
0694 (buf + sizeof(struct host_cmd_ds_txpwr_cfg));
0695 pg_tlv->type = cpu_to_le16(TLV_TYPE_POWER_GROUP);
0696 pg_tlv->length =
0697 cpu_to_le16(4 * sizeof(struct mwifiex_power_group));
0698 pg = (struct mwifiex_power_group *)
0699 (buf + sizeof(struct host_cmd_ds_txpwr_cfg)
0700 + sizeof(struct mwifiex_types_power_group));
0701
0702 pg->first_rate_code = 0x00;
0703 pg->last_rate_code = 0x03;
0704 pg->modulation_class = MOD_CLASS_HR_DSSS;
0705 pg->power_step = 0;
0706 pg->power_min = (s8) dbm_min;
0707 pg->power_max = (s8) dbm;
0708 pg++;
0709
0710 pg->first_rate_code = 0x00;
0711 pg->last_rate_code = 0x07;
0712 pg->modulation_class = MOD_CLASS_OFDM;
0713 pg->power_step = 0;
0714 pg->power_min = (s8) dbm_min;
0715 pg->power_max = (s8) dbm;
0716 pg++;
0717
0718 pg->first_rate_code = 0x00;
0719 pg->last_rate_code = 0x20;
0720 pg->modulation_class = MOD_CLASS_HT;
0721 pg->power_step = 0;
0722 pg->power_min = (s8) dbm_min;
0723 pg->power_max = (s8) dbm;
0724 pg->ht_bandwidth = HT_BW_20;
0725 pg++;
0726
0727 pg->first_rate_code = 0x00;
0728 pg->last_rate_code = 0x20;
0729 pg->modulation_class = MOD_CLASS_HT;
0730 pg->power_step = 0;
0731 pg->power_min = (s8) dbm_min;
0732 pg->power_max = (s8) dbm;
0733 pg->ht_bandwidth = HT_BW_40;
0734 }
0735 ret = mwifiex_send_cmd(priv, HostCmd_CMD_TXPWR_CFG,
0736 HostCmd_ACT_GEN_SET, 0, buf, true);
0737
0738 kfree(buf);
0739 return ret;
0740 }
0741
0742
0743
0744
0745
0746
0747
0748 int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode)
0749 {
0750 int ret;
0751 struct mwifiex_adapter *adapter = priv->adapter;
0752 u16 sub_cmd;
0753
0754 if (*ps_mode)
0755 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
0756 else
0757 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM;
0758 sub_cmd = (*ps_mode) ? EN_AUTO_PS : DIS_AUTO_PS;
0759 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
0760 sub_cmd, BITMAP_STA_PS, NULL, true);
0761 if ((!ret) && (sub_cmd == DIS_AUTO_PS))
0762 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
0763 GET_PS, 0, NULL, false);
0764
0765 return ret;
0766 }
0767
0768
0769
0770
0771
0772
0773
0774
0775 static int mwifiex_set_wpa_ie(struct mwifiex_private *priv,
0776 u8 *ie_data_ptr, u16 ie_len)
0777 {
0778 if (ie_len) {
0779 if (ie_len > sizeof(priv->wpa_ie)) {
0780 mwifiex_dbg(priv->adapter, ERROR,
0781 "failed to copy WPA IE, too big\n");
0782 return -1;
0783 }
0784 memcpy(priv->wpa_ie, ie_data_ptr, ie_len);
0785 priv->wpa_ie_len = ie_len;
0786 mwifiex_dbg(priv->adapter, CMD,
0787 "cmd: Set Wpa_ie_len=%d IE=%#x\n",
0788 priv->wpa_ie_len, priv->wpa_ie[0]);
0789
0790 if (priv->wpa_ie[0] == WLAN_EID_VENDOR_SPECIFIC) {
0791 priv->sec_info.wpa_enabled = true;
0792 } else if (priv->wpa_ie[0] == WLAN_EID_RSN) {
0793 priv->sec_info.wpa2_enabled = true;
0794 } else {
0795 priv->sec_info.wpa_enabled = false;
0796 priv->sec_info.wpa2_enabled = false;
0797 }
0798 } else {
0799 memset(priv->wpa_ie, 0, sizeof(priv->wpa_ie));
0800 priv->wpa_ie_len = 0;
0801 mwifiex_dbg(priv->adapter, INFO,
0802 "info: reset wpa_ie_len=%d IE=%#x\n",
0803 priv->wpa_ie_len, priv->wpa_ie[0]);
0804 priv->sec_info.wpa_enabled = false;
0805 priv->sec_info.wpa2_enabled = false;
0806 }
0807
0808 return 0;
0809 }
0810
0811
0812
0813
0814
0815
0816
0817
0818 static int mwifiex_set_wapi_ie(struct mwifiex_private *priv,
0819 u8 *ie_data_ptr, u16 ie_len)
0820 {
0821 if (ie_len) {
0822 if (ie_len > sizeof(priv->wapi_ie)) {
0823 mwifiex_dbg(priv->adapter, ERROR,
0824 "info: failed to copy WAPI IE, too big\n");
0825 return -1;
0826 }
0827 memcpy(priv->wapi_ie, ie_data_ptr, ie_len);
0828 priv->wapi_ie_len = ie_len;
0829 mwifiex_dbg(priv->adapter, CMD,
0830 "cmd: Set wapi_ie_len=%d IE=%#x\n",
0831 priv->wapi_ie_len, priv->wapi_ie[0]);
0832
0833 if (priv->wapi_ie[0] == WLAN_EID_BSS_AC_ACCESS_DELAY)
0834 priv->sec_info.wapi_enabled = true;
0835 } else {
0836 memset(priv->wapi_ie, 0, sizeof(priv->wapi_ie));
0837 priv->wapi_ie_len = ie_len;
0838 mwifiex_dbg(priv->adapter, INFO,
0839 "info: Reset wapi_ie_len=%d IE=%#x\n",
0840 priv->wapi_ie_len, priv->wapi_ie[0]);
0841 priv->sec_info.wapi_enabled = false;
0842 }
0843 return 0;
0844 }
0845
0846
0847
0848
0849
0850
0851
0852
0853 static int mwifiex_set_wps_ie(struct mwifiex_private *priv,
0854 u8 *ie_data_ptr, u16 ie_len)
0855 {
0856 if (ie_len) {
0857 if (ie_len > MWIFIEX_MAX_VSIE_LEN) {
0858 mwifiex_dbg(priv->adapter, ERROR,
0859 "info: failed to copy WPS IE, too big\n");
0860 return -1;
0861 }
0862
0863 priv->wps_ie = kzalloc(MWIFIEX_MAX_VSIE_LEN, GFP_KERNEL);
0864 if (!priv->wps_ie)
0865 return -ENOMEM;
0866
0867 memcpy(priv->wps_ie, ie_data_ptr, ie_len);
0868 priv->wps_ie_len = ie_len;
0869 mwifiex_dbg(priv->adapter, CMD,
0870 "cmd: Set wps_ie_len=%d IE=%#x\n",
0871 priv->wps_ie_len, priv->wps_ie[0]);
0872 } else {
0873 kfree(priv->wps_ie);
0874 priv->wps_ie_len = ie_len;
0875 mwifiex_dbg(priv->adapter, INFO,
0876 "info: Reset wps_ie_len=%d\n", priv->wps_ie_len);
0877 }
0878 return 0;
0879 }
0880
0881
0882
0883
0884
0885
0886
0887 static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_private *priv,
0888 struct mwifiex_ds_encrypt_key *encrypt_key)
0889 {
0890
0891 return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
0892 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
0893 encrypt_key, true);
0894 }
0895
0896
0897
0898
0899
0900
0901
0902 static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
0903 struct mwifiex_ds_encrypt_key *encrypt_key)
0904 {
0905 struct mwifiex_adapter *adapter = priv->adapter;
0906 int ret;
0907 struct mwifiex_wep_key *wep_key;
0908 int index;
0909
0910 if (priv->wep_key_curr_index >= NUM_WEP_KEYS)
0911 priv->wep_key_curr_index = 0;
0912 wep_key = &priv->wep_key[priv->wep_key_curr_index];
0913 index = encrypt_key->key_index;
0914 if (encrypt_key->key_disable) {
0915 priv->sec_info.wep_enabled = 0;
0916 } else if (!encrypt_key->key_len) {
0917
0918 wep_key = &priv->wep_key[index];
0919 if (!wep_key->key_length) {
0920 mwifiex_dbg(adapter, ERROR,
0921 "key not set, so cannot enable it\n");
0922 return -1;
0923 }
0924
0925 if (adapter->key_api_major_ver == KEY_API_VER_MAJOR_V2) {
0926 memcpy(encrypt_key->key_material,
0927 wep_key->key_material, wep_key->key_length);
0928 encrypt_key->key_len = wep_key->key_length;
0929 }
0930
0931 priv->wep_key_curr_index = (u16) index;
0932 priv->sec_info.wep_enabled = 1;
0933 } else {
0934 wep_key = &priv->wep_key[index];
0935 memset(wep_key, 0, sizeof(struct mwifiex_wep_key));
0936
0937 memcpy(wep_key->key_material,
0938 encrypt_key->key_material,
0939 encrypt_key->key_len);
0940 wep_key->key_index = index;
0941 wep_key->key_length = encrypt_key->key_len;
0942 priv->sec_info.wep_enabled = 1;
0943 }
0944 if (wep_key->key_length) {
0945 void *enc_key;
0946
0947 if (encrypt_key->key_disable) {
0948 memset(&priv->wep_key[index], 0,
0949 sizeof(struct mwifiex_wep_key));
0950 goto done;
0951 }
0952
0953 if (adapter->key_api_major_ver == KEY_API_VER_MAJOR_V2)
0954 enc_key = encrypt_key;
0955 else
0956 enc_key = NULL;
0957
0958
0959 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
0960 HostCmd_ACT_GEN_SET, 0, enc_key, false);
0961 if (ret)
0962 return ret;
0963 }
0964
0965 done:
0966 if (priv->sec_info.wep_enabled)
0967 priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE;
0968 else
0969 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
0970
0971 ret = mwifiex_send_cmd(priv, HostCmd_CMD_MAC_CONTROL,
0972 HostCmd_ACT_GEN_SET, 0,
0973 &priv->curr_pkt_filter, true);
0974
0975 return ret;
0976 }
0977
0978
0979
0980
0981
0982
0983
0984
0985
0986
0987
0988 static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_private *priv,
0989 struct mwifiex_ds_encrypt_key *encrypt_key)
0990 {
0991 int ret;
0992 u8 remove_key = false;
0993 struct host_cmd_ds_802_11_key_material *ibss_key;
0994
0995
0996 if (encrypt_key->key_len > WLAN_MAX_KEY_LEN) {
0997 mwifiex_dbg(priv->adapter, ERROR,
0998 "key length too long\n");
0999 return -1;
1000 }
1001
1002 if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
1003
1004
1005
1006
1007
1008 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1009 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1010 HostCmd_ACT_GEN_SET,
1011 KEY_INFO_ENABLED, encrypt_key, false);
1012 if (ret)
1013 return ret;
1014
1015 ibss_key = &priv->aes_key;
1016 memset(ibss_key, 0,
1017 sizeof(struct host_cmd_ds_802_11_key_material));
1018
1019 memcpy(ibss_key->key_param_set.key, encrypt_key->key_material,
1020 encrypt_key->key_len);
1021 memcpy(&ibss_key->key_param_set.key_len, &encrypt_key->key_len,
1022 sizeof(ibss_key->key_param_set.key_len));
1023 ibss_key->key_param_set.key_type_id
1024 = cpu_to_le16(KEY_TYPE_ID_TKIP);
1025 ibss_key->key_param_set.key_info = cpu_to_le16(KEY_ENABLED);
1026
1027
1028 encrypt_key->key_index = ~MWIFIEX_KEY_INDEX_UNICAST;
1029 }
1030
1031 if (!encrypt_key->key_index)
1032 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1033
1034 if (remove_key)
1035 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1036 HostCmd_ACT_GEN_SET,
1037 !KEY_INFO_ENABLED, encrypt_key, true);
1038 else
1039 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1040 HostCmd_ACT_GEN_SET,
1041 KEY_INFO_ENABLED, encrypt_key, true);
1042
1043 return ret;
1044 }
1045
1046
1047
1048
1049
1050
1051
1052 static int
1053 mwifiex_sec_ioctl_encrypt_key(struct mwifiex_private *priv,
1054 struct mwifiex_ds_encrypt_key *encrypt_key)
1055 {
1056 int status;
1057
1058 if (encrypt_key->is_wapi_key)
1059 status = mwifiex_sec_ioctl_set_wapi_key(priv, encrypt_key);
1060 else if (encrypt_key->key_len > WLAN_KEY_LEN_WEP104)
1061 status = mwifiex_sec_ioctl_set_wpa_key(priv, encrypt_key);
1062 else
1063 status = mwifiex_sec_ioctl_set_wep_key(priv, encrypt_key);
1064 return status;
1065 }
1066
1067
1068
1069
1070 int
1071 mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, char *version,
1072 int max_len)
1073 {
1074 union {
1075 __le32 l;
1076 u8 c[4];
1077 } ver;
1078 char fw_ver[32];
1079
1080 ver.l = cpu_to_le32(adapter->fw_release_number);
1081 sprintf(fw_ver, "%u.%u.%u.p%u", ver.c[2], ver.c[1], ver.c[0], ver.c[3]);
1082
1083 snprintf(version, max_len, driver_version, fw_ver);
1084
1085 mwifiex_dbg(adapter, MSG, "info: MWIFIEX VERSION: %s\n", version);
1086
1087 return 0;
1088 }
1089
1090
1091
1092
1093
1094
1095
1096 int mwifiex_set_encode(struct mwifiex_private *priv, struct key_params *kp,
1097 const u8 *key, int key_len, u8 key_index,
1098 const u8 *mac_addr, int disable)
1099 {
1100 struct mwifiex_ds_encrypt_key encrypt_key;
1101
1102 memset(&encrypt_key, 0, sizeof(encrypt_key));
1103 encrypt_key.key_len = key_len;
1104 encrypt_key.key_index = key_index;
1105
1106 if (kp && kp->cipher == WLAN_CIPHER_SUITE_AES_CMAC)
1107 encrypt_key.is_igtk_key = true;
1108
1109 if (!disable) {
1110 if (key_len)
1111 memcpy(encrypt_key.key_material, key, key_len);
1112 else
1113 encrypt_key.is_current_wep_key = true;
1114
1115 if (mac_addr)
1116 memcpy(encrypt_key.mac_addr, mac_addr, ETH_ALEN);
1117 if (kp && kp->seq && kp->seq_len) {
1118 memcpy(encrypt_key.pn, kp->seq, kp->seq_len);
1119 encrypt_key.pn_len = kp->seq_len;
1120 encrypt_key.is_rx_seq_valid = true;
1121 }
1122 } else {
1123 encrypt_key.key_disable = true;
1124 if (mac_addr)
1125 memcpy(encrypt_key.mac_addr, mac_addr, ETH_ALEN);
1126 }
1127
1128 return mwifiex_sec_ioctl_encrypt_key(priv, &encrypt_key);
1129 }
1130
1131
1132
1133
1134
1135
1136
1137 int
1138 mwifiex_get_ver_ext(struct mwifiex_private *priv, u32 version_str_sel)
1139 {
1140 struct mwifiex_ver_ext ver_ext;
1141
1142 memset(&ver_ext, 0, sizeof(ver_ext));
1143 ver_ext.version_str_sel = version_str_sel;
1144 if (mwifiex_send_cmd(priv, HostCmd_CMD_VERSION_EXT,
1145 HostCmd_ACT_GEN_GET, 0, &ver_ext, true))
1146 return -1;
1147
1148 return 0;
1149 }
1150
1151 int
1152 mwifiex_remain_on_chan_cfg(struct mwifiex_private *priv, u16 action,
1153 struct ieee80211_channel *chan,
1154 unsigned int duration)
1155 {
1156 struct host_cmd_ds_remain_on_chan roc_cfg;
1157 u8 sc;
1158
1159 memset(&roc_cfg, 0, sizeof(roc_cfg));
1160 roc_cfg.action = cpu_to_le16(action);
1161 if (action == HostCmd_ACT_GEN_SET) {
1162 roc_cfg.band_cfg = chan->band;
1163 sc = mwifiex_chan_type_to_sec_chan_offset(NL80211_CHAN_NO_HT);
1164 roc_cfg.band_cfg |= (sc << 2);
1165
1166 roc_cfg.channel =
1167 ieee80211_frequency_to_channel(chan->center_freq);
1168 roc_cfg.duration = cpu_to_le32(duration);
1169 }
1170 if (mwifiex_send_cmd(priv, HostCmd_CMD_REMAIN_ON_CHAN,
1171 action, 0, &roc_cfg, true)) {
1172 mwifiex_dbg(priv->adapter, ERROR,
1173 "failed to remain on channel\n");
1174 return -1;
1175 }
1176
1177 return roc_cfg.status;
1178 }
1179
1180
1181
1182
1183
1184
1185
1186 int
1187 mwifiex_get_stats_info(struct mwifiex_private *priv,
1188 struct mwifiex_ds_get_stats *log)
1189 {
1190 return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_GET_LOG,
1191 HostCmd_ACT_GEN_GET, 0, log, true);
1192 }
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207 static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private *priv,
1208 struct mwifiex_ds_reg_rw *reg_rw,
1209 u16 action)
1210 {
1211 u16 cmd_no;
1212
1213 switch (reg_rw->type) {
1214 case MWIFIEX_REG_MAC:
1215 cmd_no = HostCmd_CMD_MAC_REG_ACCESS;
1216 break;
1217 case MWIFIEX_REG_BBP:
1218 cmd_no = HostCmd_CMD_BBP_REG_ACCESS;
1219 break;
1220 case MWIFIEX_REG_RF:
1221 cmd_no = HostCmd_CMD_RF_REG_ACCESS;
1222 break;
1223 case MWIFIEX_REG_PMIC:
1224 cmd_no = HostCmd_CMD_PMIC_REG_ACCESS;
1225 break;
1226 case MWIFIEX_REG_CAU:
1227 cmd_no = HostCmd_CMD_CAU_REG_ACCESS;
1228 break;
1229 default:
1230 return -1;
1231 }
1232
1233 return mwifiex_send_cmd(priv, cmd_no, action, 0, reg_rw, true);
1234 }
1235
1236
1237
1238
1239
1240
1241
1242 int
1243 mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
1244 u32 reg_offset, u32 reg_value)
1245 {
1246 struct mwifiex_ds_reg_rw reg_rw;
1247
1248 reg_rw.type = reg_type;
1249 reg_rw.offset = reg_offset;
1250 reg_rw.value = reg_value;
1251
1252 return mwifiex_reg_mem_ioctl_reg_rw(priv, ®_rw, HostCmd_ACT_GEN_SET);
1253 }
1254
1255
1256
1257
1258
1259
1260
1261 int
1262 mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
1263 u32 reg_offset, u32 *value)
1264 {
1265 int ret;
1266 struct mwifiex_ds_reg_rw reg_rw;
1267
1268 reg_rw.type = reg_type;
1269 reg_rw.offset = reg_offset;
1270 ret = mwifiex_reg_mem_ioctl_reg_rw(priv, ®_rw, HostCmd_ACT_GEN_GET);
1271
1272 if (ret)
1273 goto done;
1274
1275 *value = reg_rw.value;
1276
1277 done:
1278 return ret;
1279 }
1280
1281
1282
1283
1284
1285
1286
1287 int
1288 mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
1289 u8 *value)
1290 {
1291 int ret;
1292 struct mwifiex_ds_read_eeprom rd_eeprom;
1293
1294 rd_eeprom.offset = offset;
1295 rd_eeprom.byte_count = bytes;
1296
1297
1298 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_EEPROM_ACCESS,
1299 HostCmd_ACT_GEN_GET, 0, &rd_eeprom, true);
1300
1301 if (!ret)
1302 memcpy(value, rd_eeprom.value, min((u16)MAX_EEPROM_DATA,
1303 rd_eeprom.byte_count));
1304 return ret;
1305 }
1306
1307
1308
1309
1310
1311 static int
1312 mwifiex_set_gen_ie_helper(struct mwifiex_private *priv, u8 *ie_data_ptr,
1313 u16 ie_len)
1314 {
1315 struct ieee_types_vendor_header *pvendor_ie;
1316 static const u8 wpa_oui[] = { 0x00, 0x50, 0xf2, 0x01 };
1317 static const u8 wps_oui[] = { 0x00, 0x50, 0xf2, 0x04 };
1318 u16 unparsed_len = ie_len, cur_ie_len;
1319
1320
1321 if (!ie_len) {
1322 priv->gen_ie_buf_len = 0;
1323 priv->wps.session_enable = false;
1324 return 0;
1325 } else if (!ie_data_ptr ||
1326 ie_len <= sizeof(struct ieee_types_header)) {
1327 return -1;
1328 }
1329 pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr;
1330
1331 while (pvendor_ie) {
1332 cur_ie_len = pvendor_ie->len + sizeof(struct ieee_types_header);
1333
1334 if (pvendor_ie->element_id == WLAN_EID_RSN) {
1335
1336 mwifiex_set_wpa_ie(priv, (u8 *)pvendor_ie, cur_ie_len);
1337 priv->wps.session_enable = false;
1338 goto next_ie;
1339 }
1340
1341 if (pvendor_ie->element_id == WLAN_EID_BSS_AC_ACCESS_DELAY) {
1342
1343 mwifiex_set_wapi_ie(priv, (u8 *)pvendor_ie,
1344 cur_ie_len);
1345 goto next_ie;
1346 }
1347
1348 if (pvendor_ie->element_id == WLAN_EID_VENDOR_SPECIFIC) {
1349
1350
1351
1352 if (!memcmp(&pvendor_ie->oui, wpa_oui,
1353 sizeof(wpa_oui))) {
1354
1355
1356 mwifiex_set_wpa_ie(priv, (u8 *)pvendor_ie,
1357 cur_ie_len);
1358 priv->wps.session_enable = false;
1359 goto next_ie;
1360 }
1361
1362 if (!memcmp(&pvendor_ie->oui, wps_oui,
1363 sizeof(wps_oui))) {
1364
1365
1366
1367 priv->wps.session_enable = true;
1368 mwifiex_dbg(priv->adapter, MSG,
1369 "WPS Session Enabled.\n");
1370 mwifiex_set_wps_ie(priv, (u8 *)pvendor_ie,
1371 cur_ie_len);
1372 goto next_ie;
1373 }
1374 }
1375
1376
1377
1378
1379
1380
1381 if (cur_ie_len <
1382 (sizeof(priv->gen_ie_buf) - priv->gen_ie_buf_len)) {
1383
1384
1385
1386 memcpy(priv->gen_ie_buf + priv->gen_ie_buf_len,
1387 (u8 *)pvendor_ie, cur_ie_len);
1388
1389
1390
1391 priv->gen_ie_buf_len += cur_ie_len;
1392 }
1393
1394 next_ie:
1395 unparsed_len -= cur_ie_len;
1396
1397 if (unparsed_len <= sizeof(struct ieee_types_header))
1398 pvendor_ie = NULL;
1399 else
1400 pvendor_ie = (struct ieee_types_vendor_header *)
1401 (((u8 *)pvendor_ie) + cur_ie_len);
1402 }
1403
1404 return 0;
1405 }
1406
1407
1408
1409
1410
1411
1412
1413 static int mwifiex_misc_ioctl_gen_ie(struct mwifiex_private *priv,
1414 struct mwifiex_ds_misc_gen_ie *gen_ie,
1415 u16 action)
1416 {
1417 struct mwifiex_adapter *adapter = priv->adapter;
1418
1419 switch (gen_ie->type) {
1420 case MWIFIEX_IE_TYPE_GEN_IE:
1421 if (action == HostCmd_ACT_GEN_GET) {
1422 gen_ie->len = priv->wpa_ie_len;
1423 memcpy(gen_ie->ie_data, priv->wpa_ie, gen_ie->len);
1424 } else {
1425 mwifiex_set_gen_ie_helper(priv, gen_ie->ie_data,
1426 (u16) gen_ie->len);
1427 }
1428 break;
1429 case MWIFIEX_IE_TYPE_ARP_FILTER:
1430 memset(adapter->arp_filter, 0, sizeof(adapter->arp_filter));
1431 if (gen_ie->len > ARP_FILTER_MAX_BUF_SIZE) {
1432 adapter->arp_filter_size = 0;
1433 mwifiex_dbg(adapter, ERROR,
1434 "invalid ARP filter size\n");
1435 return -1;
1436 } else {
1437 memcpy(adapter->arp_filter, gen_ie->ie_data,
1438 gen_ie->len);
1439 adapter->arp_filter_size = gen_ie->len;
1440 }
1441 break;
1442 default:
1443 mwifiex_dbg(adapter, ERROR, "invalid IE type\n");
1444 return -1;
1445 }
1446 return 0;
1447 }
1448
1449
1450
1451
1452
1453
1454
1455 int
1456 mwifiex_set_gen_ie(struct mwifiex_private *priv, const u8 *ie, int ie_len)
1457 {
1458 struct mwifiex_ds_misc_gen_ie gen_ie;
1459
1460 if (ie_len > IEEE_MAX_IE_SIZE)
1461 return -EFAULT;
1462
1463 gen_ie.type = MWIFIEX_IE_TYPE_GEN_IE;
1464 gen_ie.len = ie_len;
1465 memcpy(gen_ie.ie_data, ie, ie_len);
1466 if (mwifiex_misc_ioctl_gen_ie(priv, &gen_ie, HostCmd_ACT_GEN_SET))
1467 return -EFAULT;
1468
1469 return 0;
1470 }
1471
1472
1473
1474
1475 int mwifiex_get_wakeup_reason(struct mwifiex_private *priv, u16 action,
1476 int cmd_type,
1477 struct mwifiex_ds_wakeup_reason *wakeup_reason)
1478 {
1479 int status = 0;
1480
1481 status = mwifiex_send_cmd(priv, HostCmd_CMD_HS_WAKEUP_REASON,
1482 HostCmd_ACT_GEN_GET, 0, wakeup_reason,
1483 cmd_type == MWIFIEX_SYNC_CMD);
1484
1485 return status;
1486 }
1487
1488 int mwifiex_get_chan_info(struct mwifiex_private *priv,
1489 struct mwifiex_channel_band *channel_band)
1490 {
1491 int status = 0;
1492
1493 status = mwifiex_send_cmd(priv, HostCmd_CMD_STA_CONFIGURE,
1494 HostCmd_ACT_GEN_GET, 0, channel_band,
1495 MWIFIEX_SYNC_CMD);
1496
1497 return status;
1498 }