2 * Marvell Wireless LAN device driver: functions for station ioctl
4 * Copyright (C) 2011, Marvell International Ltd.
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
29 static int disconnect_on_suspend = 1;
30 module_param(disconnect_on_suspend, int, 0644);
33 * Copies the multicast address list from device to driver.
35 * This function does not validate the destination memory for
36 * size, and the calling function must ensure enough memory is
39 int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
40 struct net_device *dev)
43 struct netdev_hw_addr *ha;
45 netdev_for_each_mc_addr(ha, dev)
46 memcpy(&mlist->mac_list[i++], ha->addr, ETH_ALEN);
52 * Wait queue completion handler.
54 * This function waits on a cmd wait queue. It also cancels the pending
55 * request after waking up, in case of errors.
57 int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter)
59 bool cancel_flag = false;
61 struct cmd_ctrl_node *cmd_queued;
64 if (!adapter->cmd_queued)
67 cmd_queued = adapter->cmd_queued;
68 adapter->cmd_queued = NULL;
70 dev_dbg(adapter->dev, "cmd pending\n");
71 atomic_inc(&adapter->cmd_pending);
73 /* Wait for completion */
74 ret = wait_event_interruptible_timeout(adapter->cmd_wait_q.wait,
75 *(cmd_queued->condition),
76 msecs_to_jiffies(MWIFIEX_QUEUE_TIMEOUT_MSEC));
79 /* Let's give waiting one more try, and then reboot */
80 ret = wait_event_interruptible_timeout(adapter->cmd_wait_q.wait,
81 *(cmd_queued->condition),
82 msecs_to_jiffies(MWIFIEX_QUEUE_TIMEOUT_MSEC));
86 if (!*(cmd_queued->condition))
90 mwifiex_cancel_pending_ioctl(adapter);
91 dev_dbg(adapter->dev, "cmd cancel\n");
94 status = adapter->cmd_wait_q.status;
95 adapter->cmd_wait_q.status = 0;
101 * This function prepares the correct firmware command and
102 * issues it to set the multicast list.
104 * This function can be used to enable promiscuous mode, or enable all
105 * multicast packets, or to enable selective multicast.
107 int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
108 struct mwifiex_multicast_list *mcast_list)
113 old_pkt_filter = priv->curr_pkt_filter;
115 if (mcast_list->mode == MWIFIEX_PROMISC_MODE) {
116 dev_dbg(priv->adapter->dev, "info: Enable Promiscuous mode\n");
117 priv->curr_pkt_filter |= HostCmd_ACT_MAC_PROMISCUOUS_ENABLE;
118 priv->curr_pkt_filter &=
119 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
122 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_PROMISCUOUS_ENABLE;
123 if (mcast_list->mode == MWIFIEX_MULTICAST_MODE) {
124 dev_dbg(priv->adapter->dev,
125 "info: Enabling All Multicast!\n");
126 priv->curr_pkt_filter |=
127 HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
129 priv->curr_pkt_filter &=
130 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
131 if (mcast_list->num_multicast_addr) {
132 dev_dbg(priv->adapter->dev,
133 "info: Set multicast list=%d\n",
134 mcast_list->num_multicast_addr);
135 /* Set multicast addresses to firmware */
136 if (old_pkt_filter == priv->curr_pkt_filter) {
137 /* Send request to firmware */
138 ret = mwifiex_send_cmd_async(priv,
139 HostCmd_CMD_MAC_MULTICAST_ADR,
140 HostCmd_ACT_GEN_SET, 0,
143 /* Send request to firmware */
144 ret = mwifiex_send_cmd_async(priv,
145 HostCmd_CMD_MAC_MULTICAST_ADR,
146 HostCmd_ACT_GEN_SET, 0,
152 dev_dbg(priv->adapter->dev,
153 "info: old_pkt_filter=%#x, curr_pkt_filter=%#x\n",
154 old_pkt_filter, priv->curr_pkt_filter);
155 if (old_pkt_filter != priv->curr_pkt_filter) {
156 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL,
158 0, &priv->curr_pkt_filter);
165 * This function fills bss descriptor structure using provided
168 int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
169 struct cfg80211_bss *bss,
170 struct mwifiex_bssdescriptor *bss_desc)
174 struct mwifiex_bss_priv *bss_priv = (void *)bss->priv;
176 beacon_ie = kmemdup(bss->information_elements, bss->len_beacon_ies,
179 dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n");
183 memcpy(bss_desc->mac_address, bss->bssid, ETH_ALEN);
184 bss_desc->rssi = bss->signal;
185 bss_desc->beacon_buf = beacon_ie;
186 bss_desc->beacon_buf_size = bss->len_beacon_ies;
187 bss_desc->beacon_period = bss->beacon_interval;
188 bss_desc->cap_info_bitmap = bss->capability;
189 bss_desc->bss_band = bss_priv->band;
190 bss_desc->fw_tsf = bss_priv->fw_tsf;
191 bss_desc->timestamp = bss->tsf;
192 if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_PRIVACY) {
193 dev_dbg(priv->adapter->dev, "info: InterpretIE: AP WEP enabled\n");
194 bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_8021X_WEP;
196 bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL;
198 if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_IBSS)
199 bss_desc->bss_mode = NL80211_IFTYPE_ADHOC;
201 bss_desc->bss_mode = NL80211_IFTYPE_STATION;
203 ret = mwifiex_update_bss_desc_with_ie(priv->adapter, bss_desc);
209 static int mwifiex_process_country_ie(struct mwifiex_private *priv,
210 struct cfg80211_bss *bss)
212 u8 *country_ie, country_ie_len;
213 struct mwifiex_802_11d_domain_reg *domain_info =
214 &priv->adapter->domain_reg;
216 country_ie = (u8 *)ieee80211_bss_get_ie(bss, WLAN_EID_COUNTRY);
221 country_ie_len = country_ie[1];
222 if (country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN)
225 domain_info->country_code[0] = country_ie[2];
226 domain_info->country_code[1] = country_ie[3];
227 domain_info->country_code[2] = ' ';
229 country_ie_len -= IEEE80211_COUNTRY_STRING_LEN;
231 domain_info->no_of_triplet =
232 country_ie_len / sizeof(struct ieee80211_country_ie_triplet);
234 memcpy((u8 *)domain_info->triplet,
235 &country_ie[2] + IEEE80211_COUNTRY_STRING_LEN, country_ie_len);
237 if (mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11D_DOMAIN_INFO,
238 HostCmd_ACT_GEN_SET, 0, NULL)) {
239 wiphy_err(priv->wdev->wiphy,
240 "11D: setting domain info in FW\n");
248 * In Ad-Hoc mode, the IBSS is created if not found in scan list.
249 * In both Ad-Hoc and infra mode, an deauthentication is performed
252 int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
253 struct cfg80211_ssid *req_ssid)
256 struct mwifiex_adapter *adapter = priv->adapter;
257 struct mwifiex_bssdescriptor *bss_desc = NULL;
259 priv->scan_block = false;
262 mwifiex_process_country_ie(priv, bss);
264 /* Allocate and fill new bss descriptor */
265 bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor),
268 dev_err(priv->adapter->dev, " failed to alloc bss_desc\n");
272 ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc);
277 if (priv->bss_mode == NL80211_IFTYPE_STATION) {
279 ret = mwifiex_deauthenticate(priv, NULL);
283 ret = mwifiex_check_network_compatibility(priv, bss_desc);
287 dev_dbg(adapter->dev, "info: SSID found in scan list ... "
290 if (!netif_queue_stopped(priv->netdev))
291 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
292 if (netif_carrier_ok(priv->netdev))
293 netif_carrier_off(priv->netdev);
295 /* Clear any past association response stored for
296 * application retrieval */
297 priv->assoc_rsp_size = 0;
298 ret = mwifiex_associate(priv, bss_desc);
300 /* If auth type is auto and association fails using open mode,
301 * try to connect using shared mode */
302 if (ret == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG &&
303 priv->sec_info.is_authtype_auto &&
304 priv->sec_info.wep_enabled) {
305 priv->sec_info.authentication_mode =
306 NL80211_AUTHTYPE_SHARED_KEY;
307 ret = mwifiex_associate(priv, bss_desc);
311 cfg80211_put_bss(bss);
314 /* If the requested SSID matches current SSID, return */
315 if (bss_desc && bss_desc->ssid.ssid_len &&
316 (!mwifiex_ssid_cmp(&priv->curr_bss_params.bss_descriptor.
317 ssid, &bss_desc->ssid))) {
322 /* Exit Adhoc mode first */
323 dev_dbg(adapter->dev, "info: Sending Adhoc Stop\n");
324 ret = mwifiex_deauthenticate(priv, NULL);
328 priv->adhoc_is_link_sensed = false;
330 ret = mwifiex_check_network_compatibility(priv, bss_desc);
332 if (!netif_queue_stopped(priv->netdev))
333 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
334 if (netif_carrier_ok(priv->netdev))
335 netif_carrier_off(priv->netdev);
338 dev_dbg(adapter->dev, "info: network found in scan"
339 " list. Joining...\n");
340 ret = mwifiex_adhoc_join(priv, bss_desc);
342 cfg80211_put_bss(bss);
344 dev_dbg(adapter->dev, "info: Network not found in "
345 "the list, creating adhoc with ssid = %s\n",
347 ret = mwifiex_adhoc_start(priv, req_ssid);
357 * IOCTL request handler to set host sleep configuration.
359 * This function prepares the correct firmware command and
362 static int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
363 int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg)
366 struct mwifiex_adapter *adapter = priv->adapter;
374 case HostCmd_ACT_GEN_SET:
375 if (adapter->pps_uapsd_mode) {
376 dev_dbg(adapter->dev, "info: Host Sleep IOCTL"
377 " is blocked in UAPSD/PPS mode\n");
381 if (hs_cfg->is_invoke_hostcmd) {
382 if (hs_cfg->conditions == HOST_SLEEP_CFG_CANCEL) {
383 if (!adapter->is_hs_configured)
384 /* Already cancelled */
386 /* Save previous condition */
387 prev_cond = le32_to_cpu(adapter->hs_cfg
389 adapter->hs_cfg.conditions =
390 cpu_to_le32(hs_cfg->conditions);
391 } else if (hs_cfg->conditions) {
392 adapter->hs_cfg.conditions =
393 cpu_to_le32(hs_cfg->conditions);
394 adapter->hs_cfg.gpio = (u8)hs_cfg->gpio;
396 adapter->hs_cfg.gap = (u8)hs_cfg->gap;
397 } else if (adapter->hs_cfg.conditions
398 == cpu_to_le32(HOST_SLEEP_CFG_CANCEL)) {
399 /* Return failure if no parameters for HS
404 if (cmd_type == MWIFIEX_SYNC_CMD)
405 status = mwifiex_send_cmd_sync(priv,
406 HostCmd_CMD_802_11_HS_CFG_ENH,
407 HostCmd_ACT_GEN_SET, 0,
410 status = mwifiex_send_cmd_async(priv,
411 HostCmd_CMD_802_11_HS_CFG_ENH,
412 HostCmd_ACT_GEN_SET, 0,
414 if (hs_cfg->conditions == HOST_SLEEP_CFG_CANCEL)
415 /* Restore previous condition */
416 adapter->hs_cfg.conditions =
417 cpu_to_le32(prev_cond);
419 adapter->hs_cfg.conditions =
420 cpu_to_le32(hs_cfg->conditions);
421 adapter->hs_cfg.gpio = (u8)hs_cfg->gpio;
422 adapter->hs_cfg.gap = (u8)hs_cfg->gap;
425 case HostCmd_ACT_GEN_GET:
426 hs_cfg->conditions = le32_to_cpu(adapter->hs_cfg.conditions);
427 hs_cfg->gpio = adapter->hs_cfg.gpio;
428 hs_cfg->gap = adapter->hs_cfg.gap;
439 * Sends IOCTL request to cancel the existing Host Sleep configuration.
441 * This function allocates the IOCTL request buffer, fills it
442 * with requisite parameters and calls the IOCTL handler.
444 int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type)
446 struct mwifiex_ds_hs_cfg hscfg;
448 hscfg.conditions = HOST_SLEEP_CFG_CANCEL;
449 hscfg.is_invoke_hostcmd = true;
451 return mwifiex_set_hs_params(priv, HostCmd_ACT_GEN_SET,
454 EXPORT_SYMBOL_GPL(mwifiex_cancel_hs);
457 * Sends IOCTL request to cancel the existing Host Sleep configuration.
459 * This function allocates the IOCTL request buffer, fills it
460 * with requisite parameters and calls the IOCTL handler.
462 int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
464 struct mwifiex_ds_hs_cfg hscfg;
465 struct mwifiex_private *priv;
468 if (disconnect_on_suspend) {
469 for (i = 0; i < adapter->priv_num; i++) {
470 priv = adapter->priv[i];
471 if (priv && priv->media_connected)
472 mwifiex_deauthenticate(priv, NULL);
476 if (adapter->hs_activated) {
477 dev_dbg(adapter->dev, "cmd: HS Already actived\n");
481 adapter->hs_activate_wait_q_woken = false;
483 memset(&hscfg, 0, sizeof(struct mwifiex_ds_hs_cfg));
484 hscfg.is_invoke_hostcmd = true;
486 if (mwifiex_set_hs_params(mwifiex_get_priv(adapter,
487 MWIFIEX_BSS_ROLE_STA),
488 HostCmd_ACT_GEN_SET, MWIFIEX_SYNC_CMD,
490 dev_err(adapter->dev, "IOCTL request HS enable failed\n");
494 wait_event_interruptible(adapter->hs_activate_wait_q,
495 adapter->hs_activate_wait_q_woken);
499 EXPORT_SYMBOL_GPL(mwifiex_enable_hs);
502 * IOCTL request handler to get BSS information.
504 * This function collates the information from different driver structures
505 * to send to the user.
507 int mwifiex_get_bss_info(struct mwifiex_private *priv,
508 struct mwifiex_bss_info *info)
510 struct mwifiex_adapter *adapter = priv->adapter;
511 struct mwifiex_bssdescriptor *bss_desc;
516 bss_desc = &priv->curr_bss_params.bss_descriptor;
518 info->bss_mode = priv->bss_mode;
520 memcpy(&info->ssid, &bss_desc->ssid, sizeof(struct cfg80211_ssid));
522 memcpy(&info->bssid, &bss_desc->mac_address, ETH_ALEN);
524 info->bss_chan = bss_desc->channel;
526 memcpy(info->country_code, priv->country_code,
527 IEEE80211_COUNTRY_STRING_LEN);
529 info->media_connected = priv->media_connected;
531 info->max_power_level = priv->max_tx_power_level;
532 info->min_power_level = priv->min_tx_power_level;
534 info->adhoc_state = priv->adhoc_state;
536 info->bcn_nf_last = priv->bcn_nf_last;
538 if (priv->sec_info.wep_enabled)
539 info->wep_status = true;
541 info->wep_status = false;
543 info->is_hs_configured = adapter->is_hs_configured;
544 info->is_deep_sleep = adapter->is_deep_sleep;
550 * The function disables auto deep sleep mode.
552 int mwifiex_disable_auto_ds(struct mwifiex_private *priv)
554 struct mwifiex_ds_auto_ds auto_ds;
556 auto_ds.auto_ds = DEEP_SLEEP_OFF;
558 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
559 DIS_AUTO_PS, BITMAP_AUTO_DS, &auto_ds);
561 EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds);
564 * IOCTL request handler to set/get active channel.
566 * This function performs validity checking on channel/frequency
567 * compatibility and returns failure if not valid.
569 int mwifiex_bss_set_channel(struct mwifiex_private *priv,
570 struct mwifiex_chan_freq_power *chan)
572 struct mwifiex_adapter *adapter = priv->adapter;
573 struct mwifiex_chan_freq_power *cfp = NULL;
578 if (!chan->channel && !chan->freq)
580 if (adapter->adhoc_start_band & BAND_AN)
581 adapter->adhoc_start_band = BAND_G | BAND_B | BAND_GN;
582 else if (adapter->adhoc_start_band & BAND_A)
583 adapter->adhoc_start_band = BAND_G | BAND_B;
585 if (chan->channel <= MAX_CHANNEL_BAND_BG)
586 cfp = mwifiex_get_cfp(priv, 0, (u16) chan->channel, 0);
588 cfp = mwifiex_get_cfp(priv, BAND_A,
589 (u16) chan->channel, 0);
591 if (adapter->adhoc_11n_enabled)
592 adapter->adhoc_start_band = BAND_A
595 adapter->adhoc_start_band = BAND_A;
599 if (chan->freq <= MAX_FREQUENCY_BAND_BG)
600 cfp = mwifiex_get_cfp(priv, 0, 0, chan->freq);
602 cfp = mwifiex_get_cfp(priv, BAND_A, 0, chan->freq);
604 if (adapter->adhoc_11n_enabled)
605 adapter->adhoc_start_band = BAND_A
608 adapter->adhoc_start_band = BAND_A;
612 if (!cfp || !cfp->channel) {
613 dev_err(adapter->dev, "invalid channel/freq\n");
616 priv->adhoc_channel = (u8) cfp->channel;
617 chan->channel = cfp->channel;
618 chan->freq = cfp->freq;
624 * IOCTL request handler to set/get Ad-Hoc channel.
626 * This function prepares the correct firmware command and
627 * issues it to set or get the ad-hoc channel.
629 static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv,
630 u16 action, u16 *channel)
632 if (action == HostCmd_ACT_GEN_GET) {
633 if (!priv->media_connected) {
634 *channel = priv->adhoc_channel;
638 priv->adhoc_channel = (u8) *channel;
641 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_RF_CHANNEL,
646 * IOCTL request handler to change Ad-Hoc channel.
648 * This function allocates the IOCTL request buffer, fills it
649 * with requisite parameters and calls the IOCTL handler.
651 * The function follows the following steps to perform the change -
652 * - Get current IBSS information
653 * - Get current channel
654 * - If no change is required, return
655 * - If not connected, change channel and return
659 * - Perform specific SSID scan with same SSID
660 * - Start/Join the IBSS
663 mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel)
666 struct mwifiex_bss_info bss_info;
667 struct mwifiex_ssid_bssid ssid_bssid;
669 struct cfg80211_bss *bss = NULL;
670 struct ieee80211_channel *chan;
671 enum ieee80211_band band;
673 memset(&bss_info, 0, sizeof(bss_info));
675 /* Get BSS information */
676 if (mwifiex_get_bss_info(priv, &bss_info))
679 /* Get current channel */
680 ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_GET,
683 if (curr_chan == channel) {
687 dev_dbg(priv->adapter->dev, "cmd: updating channel from %d to %d\n",
690 if (!bss_info.media_connected) {
696 memset(&ssid_bssid, 0, ETH_ALEN);
697 ret = mwifiex_deauthenticate(priv, ssid_bssid.bssid);
699 ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_SET,
702 /* Do specific SSID scanning */
703 if (mwifiex_request_scan(priv, &bss_info.ssid)) {
708 band = mwifiex_band_to_radio_type(priv->curr_bss_params.band);
709 chan = __ieee80211_get_channel(priv->wdev->wiphy,
710 ieee80211_channel_to_frequency(channel,
713 /* Find the BSS we want using available scan results */
714 bss = cfg80211_get_bss(priv->wdev->wiphy, chan, bss_info.bssid,
715 bss_info.ssid.ssid, bss_info.ssid.ssid_len,
716 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
718 wiphy_warn(priv->wdev->wiphy, "assoc: bss %pM not in scan results\n",
721 ret = mwifiex_bss_start(priv, bss, &bss_info.ssid);
727 * IOCTL request handler to get rate.
729 * This function prepares the correct firmware command and
730 * issues it to get the current rate if it is connected,
731 * otherwise, the function returns the lowest supported rate
734 static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv,
735 struct mwifiex_rate_cfg *rate_cfg)
737 rate_cfg->is_rate_auto = priv->is_data_rate_auto;
738 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_TX_RATE_QUERY,
739 HostCmd_ACT_GEN_GET, 0, NULL);
743 * IOCTL request handler to set rate.
745 * This function prepares the correct firmware command and
746 * issues it to set the current rate.
748 * The function also performs validation checking on the supplied value.
750 static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv,
751 struct mwifiex_rate_cfg *rate_cfg)
753 u8 rates[MWIFIEX_SUPPORTED_RATES];
756 u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
758 struct mwifiex_adapter *adapter = priv->adapter;
760 if (rate_cfg->is_rate_auto) {
761 memset(bitmap_rates, 0, sizeof(bitmap_rates));
762 /* Support all HR/DSSS rates */
763 bitmap_rates[0] = 0x000F;
764 /* Support all OFDM rates */
765 bitmap_rates[1] = 0x00FF;
766 /* Support all HT-MCSs rate */
767 for (i = 0; i < ARRAY_SIZE(priv->bitmap_rates) - 3; i++)
768 bitmap_rates[i + 2] = 0xFFFF;
769 bitmap_rates[9] = 0x3FFF;
771 memset(rates, 0, sizeof(rates));
772 mwifiex_get_active_data_rates(priv, rates);
774 for (i = 0; (rate[i] && i < MWIFIEX_SUPPORTED_RATES); i++) {
775 dev_dbg(adapter->dev, "info: rate=%#x wanted=%#x\n",
776 rate[i], rate_cfg->rate);
777 if ((rate[i] & 0x7f) == (rate_cfg->rate & 0x7f))
780 if ((i == MWIFIEX_SUPPORTED_RATES) || !rate[i]) {
781 dev_err(adapter->dev, "fixed data rate %#x is out "
782 "of range\n", rate_cfg->rate);
785 memset(bitmap_rates, 0, sizeof(bitmap_rates));
787 rate_index = mwifiex_data_rate_to_index(rate_cfg->rate);
789 /* Only allow b/g rates to be set */
790 if (rate_index >= MWIFIEX_RATE_INDEX_HRDSSS0 &&
791 rate_index <= MWIFIEX_RATE_INDEX_HRDSSS3) {
792 bitmap_rates[0] = 1 << rate_index;
794 rate_index -= 1; /* There is a 0x00 in the table */
795 if (rate_index >= MWIFIEX_RATE_INDEX_OFDM0 &&
796 rate_index <= MWIFIEX_RATE_INDEX_OFDM7)
797 bitmap_rates[1] = 1 << (rate_index -
798 MWIFIEX_RATE_INDEX_OFDM0);
802 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TX_RATE_CFG,
803 HostCmd_ACT_GEN_SET, 0, bitmap_rates);
809 * IOCTL request handler to set/get rate.
811 * This function can be used to set/get either the rate value or the
814 static int mwifiex_rate_ioctl_cfg(struct mwifiex_private *priv,
815 struct mwifiex_rate_cfg *rate_cfg)
822 if (rate_cfg->action == HostCmd_ACT_GEN_GET)
823 status = mwifiex_rate_ioctl_get_rate_value(priv, rate_cfg);
825 status = mwifiex_rate_ioctl_set_rate_value(priv, rate_cfg);
831 * Sends IOCTL request to get the data rate.
833 * This function allocates the IOCTL request buffer, fills it
834 * with requisite parameters and calls the IOCTL handler.
836 int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
837 struct mwifiex_rate_cfg *rate)
841 memset(rate, 0, sizeof(struct mwifiex_rate_cfg));
842 rate->action = HostCmd_ACT_GEN_GET;
843 ret = mwifiex_rate_ioctl_cfg(priv, rate);
846 if (rate->is_rate_auto)
847 rate->rate = mwifiex_index_to_data_rate(priv,
852 rate->rate = priv->data_rate;
861 * IOCTL request handler to set tx power configuration.
863 * This function prepares the correct firmware command and
866 * For non-auto power mode, all the following power groups are set -
867 * - Modulation class HR/DSSS
868 * - Modulation class OFDM
869 * - Modulation class HTBW20
870 * - Modulation class HTBW40
872 int mwifiex_set_tx_power(struct mwifiex_private *priv,
873 struct mwifiex_power_cfg *power_cfg)
876 struct host_cmd_ds_txpwr_cfg *txp_cfg;
877 struct mwifiex_types_power_group *pg_tlv;
878 struct mwifiex_power_group *pg;
882 if (!power_cfg->is_power_auto) {
883 dbm = (u16) power_cfg->power_level;
884 if ((dbm < priv->min_tx_power_level) ||
885 (dbm > priv->max_tx_power_level)) {
886 dev_err(priv->adapter->dev, "txpower value %d dBm"
887 " is out of range (%d dBm-%d dBm)\n",
888 dbm, priv->min_tx_power_level,
889 priv->max_tx_power_level);
893 buf = kzalloc(MWIFIEX_SIZE_OF_CMD_BUFFER, GFP_KERNEL);
895 dev_err(priv->adapter->dev, "%s: failed to alloc cmd buffer\n",
900 txp_cfg = (struct host_cmd_ds_txpwr_cfg *) buf;
901 txp_cfg->action = cpu_to_le16(HostCmd_ACT_GEN_SET);
902 if (!power_cfg->is_power_auto) {
903 txp_cfg->mode = cpu_to_le32(1);
904 pg_tlv = (struct mwifiex_types_power_group *)
905 (buf + sizeof(struct host_cmd_ds_txpwr_cfg));
906 pg_tlv->type = TLV_TYPE_POWER_GROUP;
907 pg_tlv->length = 4 * sizeof(struct mwifiex_power_group);
908 pg = (struct mwifiex_power_group *)
909 (buf + sizeof(struct host_cmd_ds_txpwr_cfg)
910 + sizeof(struct mwifiex_types_power_group));
911 /* Power group for modulation class HR/DSSS */
912 pg->first_rate_code = 0x00;
913 pg->last_rate_code = 0x03;
914 pg->modulation_class = MOD_CLASS_HR_DSSS;
916 pg->power_min = (s8) dbm;
917 pg->power_max = (s8) dbm;
919 /* Power group for modulation class OFDM */
920 pg->first_rate_code = 0x00;
921 pg->last_rate_code = 0x07;
922 pg->modulation_class = MOD_CLASS_OFDM;
924 pg->power_min = (s8) dbm;
925 pg->power_max = (s8) dbm;
927 /* Power group for modulation class HTBW20 */
928 pg->first_rate_code = 0x00;
929 pg->last_rate_code = 0x20;
930 pg->modulation_class = MOD_CLASS_HT;
932 pg->power_min = (s8) dbm;
933 pg->power_max = (s8) dbm;
934 pg->ht_bandwidth = HT_BW_20;
936 /* Power group for modulation class HTBW40 */
937 pg->first_rate_code = 0x00;
938 pg->last_rate_code = 0x20;
939 pg->modulation_class = MOD_CLASS_HT;
941 pg->power_min = (s8) dbm;
942 pg->power_max = (s8) dbm;
943 pg->ht_bandwidth = HT_BW_40;
945 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TXPWR_CFG,
946 HostCmd_ACT_GEN_SET, 0, buf);
953 * IOCTL request handler to get power save mode.
955 * This function prepares the correct firmware command and
958 int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode)
961 struct mwifiex_adapter *adapter = priv->adapter;
965 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
967 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM;
968 sub_cmd = (*ps_mode) ? EN_AUTO_PS : DIS_AUTO_PS;
969 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
970 sub_cmd, BITMAP_STA_PS, NULL);
971 if ((!ret) && (sub_cmd == DIS_AUTO_PS))
972 ret = mwifiex_send_cmd_async(priv,
973 HostCmd_CMD_802_11_PS_MODE_ENH,
980 * IOCTL request handler to set/reset WPA IE.
982 * The supplied WPA IE is treated as a opaque buffer. Only the first field
983 * is checked to determine WPA version. If buffer length is zero, the existing
986 static int mwifiex_set_wpa_ie_helper(struct mwifiex_private *priv,
987 u8 *ie_data_ptr, u16 ie_len)
990 if (ie_len > sizeof(priv->wpa_ie)) {
991 dev_err(priv->adapter->dev,
992 "failed to copy WPA IE, too big\n");
995 memcpy(priv->wpa_ie, ie_data_ptr, ie_len);
996 priv->wpa_ie_len = (u8) ie_len;
997 dev_dbg(priv->adapter->dev, "cmd: Set Wpa_ie_len=%d IE=%#x\n",
998 priv->wpa_ie_len, priv->wpa_ie[0]);
1000 if (priv->wpa_ie[0] == WLAN_EID_WPA) {
1001 priv->sec_info.wpa_enabled = true;
1002 } else if (priv->wpa_ie[0] == WLAN_EID_RSN) {
1003 priv->sec_info.wpa2_enabled = true;
1005 priv->sec_info.wpa_enabled = false;
1006 priv->sec_info.wpa2_enabled = false;
1009 memset(priv->wpa_ie, 0, sizeof(priv->wpa_ie));
1010 priv->wpa_ie_len = 0;
1011 dev_dbg(priv->adapter->dev, "info: reset wpa_ie_len=%d IE=%#x\n",
1012 priv->wpa_ie_len, priv->wpa_ie[0]);
1013 priv->sec_info.wpa_enabled = false;
1014 priv->sec_info.wpa2_enabled = false;
1021 * IOCTL request handler to set/reset WAPI IE.
1023 * The supplied WAPI IE is treated as a opaque buffer. Only the first field
1024 * is checked to internally enable WAPI. If buffer length is zero, the existing
1027 static int mwifiex_set_wapi_ie(struct mwifiex_private *priv,
1028 u8 *ie_data_ptr, u16 ie_len)
1031 if (ie_len > sizeof(priv->wapi_ie)) {
1032 dev_dbg(priv->adapter->dev,
1033 "info: failed to copy WAPI IE, too big\n");
1036 memcpy(priv->wapi_ie, ie_data_ptr, ie_len);
1037 priv->wapi_ie_len = ie_len;
1038 dev_dbg(priv->adapter->dev, "cmd: Set wapi_ie_len=%d IE=%#x\n",
1039 priv->wapi_ie_len, priv->wapi_ie[0]);
1041 if (priv->wapi_ie[0] == WLAN_EID_BSS_AC_ACCESS_DELAY)
1042 priv->sec_info.wapi_enabled = true;
1044 memset(priv->wapi_ie, 0, sizeof(priv->wapi_ie));
1045 priv->wapi_ie_len = ie_len;
1046 dev_dbg(priv->adapter->dev,
1047 "info: Reset wapi_ie_len=%d IE=%#x\n",
1048 priv->wapi_ie_len, priv->wapi_ie[0]);
1049 priv->sec_info.wapi_enabled = false;
1055 * IOCTL request handler to set/reset WPS IE.
1057 * The supplied WPS IE is treated as a opaque buffer. Only the first field
1058 * is checked to internally enable WPS. If buffer length is zero, the existing
1061 static int mwifiex_set_wps_ie(struct mwifiex_private *priv,
1062 u8 *ie_data_ptr, u16 ie_len)
1065 priv->wps_ie = kzalloc(MWIFIEX_MAX_VSIE_LEN, GFP_KERNEL);
1068 if (ie_len > sizeof(priv->wps_ie)) {
1069 dev_dbg(priv->adapter->dev,
1070 "info: failed to copy WPS IE, too big\n");
1071 kfree(priv->wps_ie);
1074 memcpy(priv->wps_ie, ie_data_ptr, ie_len);
1075 priv->wps_ie_len = ie_len;
1076 dev_dbg(priv->adapter->dev, "cmd: Set wps_ie_len=%d IE=%#x\n",
1077 priv->wps_ie_len, priv->wps_ie[0]);
1079 kfree(priv->wps_ie);
1080 priv->wps_ie_len = ie_len;
1081 dev_dbg(priv->adapter->dev,
1082 "info: Reset wps_ie_len=%d\n", priv->wps_ie_len);
1088 * IOCTL request handler to set WAPI key.
1090 * This function prepares the correct firmware command and
1093 static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_private *priv,
1094 struct mwifiex_ds_encrypt_key *encrypt_key)
1097 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1098 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1103 * IOCTL request handler to set WEP network key.
1105 * This function prepares the correct firmware command and
1106 * issues it, after validation checks.
1108 static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
1109 struct mwifiex_ds_encrypt_key *encrypt_key)
1112 struct mwifiex_wep_key *wep_key;
1115 if (priv->wep_key_curr_index >= NUM_WEP_KEYS)
1116 priv->wep_key_curr_index = 0;
1117 wep_key = &priv->wep_key[priv->wep_key_curr_index];
1118 index = encrypt_key->key_index;
1119 if (encrypt_key->key_disable) {
1120 priv->sec_info.wep_enabled = 0;
1121 } else if (!encrypt_key->key_len) {
1122 /* Copy the required key as the current key */
1123 wep_key = &priv->wep_key[index];
1124 if (!wep_key->key_length) {
1125 dev_err(priv->adapter->dev,
1126 "key not set, so cannot enable it\n");
1129 priv->wep_key_curr_index = (u16) index;
1130 priv->sec_info.wep_enabled = 1;
1132 wep_key = &priv->wep_key[index];
1133 memset(wep_key, 0, sizeof(struct mwifiex_wep_key));
1134 /* Copy the key in the driver */
1135 memcpy(wep_key->key_material,
1136 encrypt_key->key_material,
1137 encrypt_key->key_len);
1138 wep_key->key_index = index;
1139 wep_key->key_length = encrypt_key->key_len;
1140 priv->sec_info.wep_enabled = 1;
1142 if (wep_key->key_length) {
1143 /* Send request to firmware */
1144 ret = mwifiex_send_cmd_async(priv,
1145 HostCmd_CMD_802_11_KEY_MATERIAL,
1146 HostCmd_ACT_GEN_SET, 0, NULL);
1150 if (priv->sec_info.wep_enabled)
1151 priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE;
1153 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
1155 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_MAC_CONTROL,
1156 HostCmd_ACT_GEN_SET, 0,
1157 &priv->curr_pkt_filter);
1163 * IOCTL request handler to set WPA key.
1165 * This function prepares the correct firmware command and
1166 * issues it, after validation checks.
1168 * Current driver only supports key length of up to 32 bytes.
1170 * This function can also be used to disable a currently set key.
1172 static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_private *priv,
1173 struct mwifiex_ds_encrypt_key *encrypt_key)
1176 u8 remove_key = false;
1177 struct host_cmd_ds_802_11_key_material *ibss_key;
1179 /* Current driver only supports key length of up to 32 bytes */
1180 if (encrypt_key->key_len > WLAN_MAX_KEY_LEN) {
1181 dev_err(priv->adapter->dev, "key length too long\n");
1185 if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
1187 * IBSS/WPA-None uses only one key (Group) for both receiving
1188 * and sending unicast and multicast packets.
1190 /* Send the key as PTK to firmware */
1191 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1192 ret = mwifiex_send_cmd_async(priv,
1193 HostCmd_CMD_802_11_KEY_MATERIAL,
1194 HostCmd_ACT_GEN_SET,
1195 KEY_INFO_ENABLED, encrypt_key);
1199 ibss_key = &priv->aes_key;
1201 sizeof(struct host_cmd_ds_802_11_key_material));
1202 /* Copy the key in the driver */
1203 memcpy(ibss_key->key_param_set.key, encrypt_key->key_material,
1204 encrypt_key->key_len);
1205 memcpy(&ibss_key->key_param_set.key_len, &encrypt_key->key_len,
1206 sizeof(ibss_key->key_param_set.key_len));
1207 ibss_key->key_param_set.key_type_id
1208 = cpu_to_le16(KEY_TYPE_ID_TKIP);
1209 ibss_key->key_param_set.key_info = cpu_to_le16(KEY_ENABLED);
1211 /* Send the key as GTK to firmware */
1212 encrypt_key->key_index = ~MWIFIEX_KEY_INDEX_UNICAST;
1215 if (!encrypt_key->key_index)
1216 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1219 ret = mwifiex_send_cmd_sync(priv,
1220 HostCmd_CMD_802_11_KEY_MATERIAL,
1221 HostCmd_ACT_GEN_SET,
1222 !KEY_INFO_ENABLED, encrypt_key);
1224 ret = mwifiex_send_cmd_sync(priv,
1225 HostCmd_CMD_802_11_KEY_MATERIAL,
1226 HostCmd_ACT_GEN_SET,
1227 KEY_INFO_ENABLED, encrypt_key);
1233 * IOCTL request handler to set/get network keys.
1235 * This is a generic key handling function which supports WEP, WPA
1239 mwifiex_sec_ioctl_encrypt_key(struct mwifiex_private *priv,
1240 struct mwifiex_ds_encrypt_key *encrypt_key)
1244 if (encrypt_key->is_wapi_key)
1245 status = mwifiex_sec_ioctl_set_wapi_key(priv, encrypt_key);
1246 else if (encrypt_key->key_len > WLAN_KEY_LEN_WEP104)
1247 status = mwifiex_sec_ioctl_set_wpa_key(priv, encrypt_key);
1249 status = mwifiex_sec_ioctl_set_wep_key(priv, encrypt_key);
1254 * This function returns the driver version.
1257 mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, char *version,
1266 ver.l = adapter->fw_release_number;
1267 sprintf(fw_ver, "%u.%u.%u.p%u", ver.c[2], ver.c[1], ver.c[0], ver.c[3]);
1269 snprintf(version, max_len, driver_version, fw_ver);
1271 dev_dbg(adapter->dev, "info: MWIFIEX VERSION: %s\n", version);
1277 * Sends IOCTL request to set encoding parameters.
1279 * This function allocates the IOCTL request buffer, fills it
1280 * with requisite parameters and calls the IOCTL handler.
1282 int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
1283 int key_len, u8 key_index, int disable)
1285 struct mwifiex_ds_encrypt_key encrypt_key;
1287 memset(&encrypt_key, 0, sizeof(struct mwifiex_ds_encrypt_key));
1288 encrypt_key.key_len = key_len;
1290 encrypt_key.key_index = key_index;
1292 memcpy(encrypt_key.key_material, key, key_len);
1294 encrypt_key.key_disable = true;
1297 return mwifiex_sec_ioctl_encrypt_key(priv, &encrypt_key);
1301 * Sends IOCTL request to get extended version.
1303 * This function allocates the IOCTL request buffer, fills it
1304 * with requisite parameters and calls the IOCTL handler.
1307 mwifiex_get_ver_ext(struct mwifiex_private *priv)
1309 struct mwifiex_ver_ext ver_ext;
1311 memset(&ver_ext, 0, sizeof(struct host_cmd_ds_version_ext));
1312 if (mwifiex_send_cmd_sync(priv, HostCmd_CMD_VERSION_EXT,
1313 HostCmd_ACT_GEN_GET, 0, &ver_ext))
1320 * Sends IOCTL request to get statistics information.
1322 * This function allocates the IOCTL request buffer, fills it
1323 * with requisite parameters and calls the IOCTL handler.
1326 mwifiex_get_stats_info(struct mwifiex_private *priv,
1327 struct mwifiex_ds_get_stats *log)
1329 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_GET_LOG,
1330 HostCmd_ACT_GEN_GET, 0, log);
1334 * IOCTL request handler to read/write register.
1336 * This function prepares the correct firmware command and
1339 * Access to the following registers are supported -
1346 static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private *priv,
1347 struct mwifiex_ds_reg_rw *reg_rw,
1352 switch (le32_to_cpu(reg_rw->type)) {
1353 case MWIFIEX_REG_MAC:
1354 cmd_no = HostCmd_CMD_MAC_REG_ACCESS;
1356 case MWIFIEX_REG_BBP:
1357 cmd_no = HostCmd_CMD_BBP_REG_ACCESS;
1359 case MWIFIEX_REG_RF:
1360 cmd_no = HostCmd_CMD_RF_REG_ACCESS;
1362 case MWIFIEX_REG_PMIC:
1363 cmd_no = HostCmd_CMD_PMIC_REG_ACCESS;
1365 case MWIFIEX_REG_CAU:
1366 cmd_no = HostCmd_CMD_CAU_REG_ACCESS;
1372 return mwifiex_send_cmd_sync(priv, cmd_no, action, 0, reg_rw);
1377 * Sends IOCTL request to write to a register.
1379 * This function allocates the IOCTL request buffer, fills it
1380 * with requisite parameters and calls the IOCTL handler.
1383 mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
1384 u32 reg_offset, u32 reg_value)
1386 struct mwifiex_ds_reg_rw reg_rw;
1388 reg_rw.type = cpu_to_le32(reg_type);
1389 reg_rw.offset = cpu_to_le32(reg_offset);
1390 reg_rw.value = cpu_to_le32(reg_value);
1392 return mwifiex_reg_mem_ioctl_reg_rw(priv, ®_rw, HostCmd_ACT_GEN_SET);
1396 * Sends IOCTL request to read from a register.
1398 * This function allocates the IOCTL request buffer, fills it
1399 * with requisite parameters and calls the IOCTL handler.
1402 mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
1403 u32 reg_offset, u32 *value)
1406 struct mwifiex_ds_reg_rw reg_rw;
1408 reg_rw.type = cpu_to_le32(reg_type);
1409 reg_rw.offset = cpu_to_le32(reg_offset);
1410 ret = mwifiex_reg_mem_ioctl_reg_rw(priv, ®_rw, HostCmd_ACT_GEN_GET);
1415 *value = le32_to_cpu(reg_rw.value);
1422 * Sends IOCTL request to read from EEPROM.
1424 * This function allocates the IOCTL request buffer, fills it
1425 * with requisite parameters and calls the IOCTL handler.
1428 mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
1432 struct mwifiex_ds_read_eeprom rd_eeprom;
1434 rd_eeprom.offset = cpu_to_le16((u16) offset);
1435 rd_eeprom.byte_count = cpu_to_le16((u16) bytes);
1437 /* Send request to firmware */
1438 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_EEPROM_ACCESS,
1439 HostCmd_ACT_GEN_GET, 0, &rd_eeprom);
1442 memcpy(value, rd_eeprom.value, MAX_EEPROM_DATA);
1447 * This function sets a generic IE. In addition to generic IE, it can
1448 * also handle WPA, WPA2 and WAPI IEs.
1451 mwifiex_set_gen_ie_helper(struct mwifiex_private *priv, u8 *ie_data_ptr,
1455 struct ieee_types_vendor_header *pvendor_ie;
1456 const u8 wpa_oui[] = { 0x00, 0x50, 0xf2, 0x01 };
1457 const u8 wps_oui[] = { 0x00, 0x50, 0xf2, 0x04 };
1459 /* If the passed length is zero, reset the buffer */
1461 priv->gen_ie_buf_len = 0;
1462 priv->wps.session_enable = false;
1465 } else if (!ie_data_ptr) {
1468 pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr;
1469 /* Test to see if it is a WPA IE, if not, then it is a gen IE */
1470 if (((pvendor_ie->element_id == WLAN_EID_WPA) &&
1471 (!memcmp(pvendor_ie->oui, wpa_oui, sizeof(wpa_oui)))) ||
1472 (pvendor_ie->element_id == WLAN_EID_RSN)) {
1474 /* IE is a WPA/WPA2 IE so call set_wpa function */
1475 ret = mwifiex_set_wpa_ie_helper(priv, ie_data_ptr, ie_len);
1476 priv->wps.session_enable = false;
1479 } else if (pvendor_ie->element_id == WLAN_EID_BSS_AC_ACCESS_DELAY) {
1480 /* IE is a WAPI IE so call set_wapi function */
1481 ret = mwifiex_set_wapi_ie(priv, ie_data_ptr, ie_len);
1486 * Verify that the passed length is not larger than the
1487 * available space remaining in the buffer
1489 if (ie_len < (sizeof(priv->gen_ie_buf) - priv->gen_ie_buf_len)) {
1491 /* Test to see if it is a WPS IE, if so, enable
1494 pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr;
1495 if ((pvendor_ie->element_id == WLAN_EID_VENDOR_SPECIFIC) &&
1496 (!memcmp(pvendor_ie->oui, wps_oui, sizeof(wps_oui)))) {
1497 priv->wps.session_enable = true;
1498 dev_dbg(priv->adapter->dev,
1499 "info: WPS Session Enabled.\n");
1500 ret = mwifiex_set_wps_ie(priv, ie_data_ptr, ie_len);
1503 /* Append the passed data to the end of the
1505 memcpy(priv->gen_ie_buf + priv->gen_ie_buf_len, ie_data_ptr,
1507 /* Increment the stored buffer length by the
1509 priv->gen_ie_buf_len += ie_len;
1511 /* Passed data does not fit in the remaining
1516 /* Return 0, or -1 for error case */
1521 * IOCTL request handler to set/get generic IE.
1523 * In addition to various generic IEs, this function can also be
1524 * used to set the ARP filter.
1526 static int mwifiex_misc_ioctl_gen_ie(struct mwifiex_private *priv,
1527 struct mwifiex_ds_misc_gen_ie *gen_ie,
1530 struct mwifiex_adapter *adapter = priv->adapter;
1532 switch (gen_ie->type) {
1533 case MWIFIEX_IE_TYPE_GEN_IE:
1534 if (action == HostCmd_ACT_GEN_GET) {
1535 gen_ie->len = priv->wpa_ie_len;
1536 memcpy(gen_ie->ie_data, priv->wpa_ie, gen_ie->len);
1538 mwifiex_set_gen_ie_helper(priv, gen_ie->ie_data,
1542 case MWIFIEX_IE_TYPE_ARP_FILTER:
1543 memset(adapter->arp_filter, 0, sizeof(adapter->arp_filter));
1544 if (gen_ie->len > ARP_FILTER_MAX_BUF_SIZE) {
1545 adapter->arp_filter_size = 0;
1546 dev_err(adapter->dev, "invalid ARP filter size\n");
1549 memcpy(adapter->arp_filter, gen_ie->ie_data,
1551 adapter->arp_filter_size = gen_ie->len;
1555 dev_err(adapter->dev, "invalid IE type\n");
1562 * Sends IOCTL request to set a generic IE.
1564 * This function allocates the IOCTL request buffer, fills it
1565 * with requisite parameters and calls the IOCTL handler.
1568 mwifiex_set_gen_ie(struct mwifiex_private *priv, u8 *ie, int ie_len)
1570 struct mwifiex_ds_misc_gen_ie gen_ie;
1572 if (ie_len > IEEE_MAX_IE_SIZE)
1575 gen_ie.type = MWIFIEX_IE_TYPE_GEN_IE;
1576 gen_ie.len = ie_len;
1577 memcpy(gen_ie.ie_data, ie, ie_len);
1578 if (mwifiex_misc_ioctl_gen_ie(priv, &gen_ie, HostCmd_ACT_GEN_SET))