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.
30 * Copies the multicast address list from device to driver.
32 * This function does not validate the destination memory for
33 * size, and the calling function must ensure enough memory is
37 mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
38 struct net_device *dev)
41 struct netdev_hw_addr *ha;
43 netdev_for_each_mc_addr(ha, dev)
44 memcpy(&mlist->mac_list[i++], ha->addr, ETH_ALEN);
50 * Allocate and fills a wait queue with proper parameters.
52 * This function needs to be called before an IOCTL request can be made.
53 * It can handle the following wait options:
54 * MWIFIEX_NO_WAIT - Waiting is disabled
55 * MWIFIEX_IOCTL_WAIT - Waiting is done on IOCTL wait queue
56 * MWIFIEX_CMD_WAIT - Waiting is done on command wait queue
57 * MWIFIEX_WSTATS_WAIT - Waiting is done on stats wait queue
59 struct mwifiex_wait_queue *
60 mwifiex_alloc_fill_wait_queue(struct mwifiex_private *priv,
63 struct mwifiex_wait_queue *wait = NULL;
65 wait = (struct mwifiex_wait_queue *)
66 kzalloc(sizeof(struct mwifiex_wait_queue), GFP_ATOMIC);
68 dev_err(priv->adapter->dev, "%s: fail to alloc buffer\n",
73 wait->bss_index = priv->bss_index;
75 switch (wait_option) {
79 case MWIFIEX_IOCTL_WAIT:
80 priv->ioctl_wait_q_woken = false;
81 wait->start_time = jiffies;
82 wait->wait = &priv->ioctl_wait_q;
83 wait->condition = &priv->ioctl_wait_q_woken;
86 case MWIFIEX_CMD_WAIT:
87 priv->cmd_wait_q_woken = false;
88 wait->start_time = jiffies;
89 wait->wait = &priv->cmd_wait_q;
90 wait->condition = &priv->cmd_wait_q_woken;
93 case MWIFIEX_WSTATS_WAIT:
94 priv->w_stats_wait_q_woken = false;
95 wait->start_time = jiffies;
96 wait->wait = &priv->w_stats_wait_q;
97 wait->condition = &priv->w_stats_wait_q_woken;
106 * Wait queue completion handler.
108 * This function waits on a particular wait queue.
109 * For NO_WAIT option, it returns immediately. It also cancels the
110 * pending IOCTL request after waking up, in case of errors.
113 mwifiex_wait_ioctl_complete(struct mwifiex_private *priv,
114 struct mwifiex_wait_queue *wait,
117 bool cancel_flag = false;
119 switch (wait_option) {
120 case MWIFIEX_NO_WAIT:
122 case MWIFIEX_IOCTL_WAIT:
123 wait_event_interruptible(priv->ioctl_wait_q,
124 priv->ioctl_wait_q_woken);
125 if (!priv->ioctl_wait_q_woken)
128 case MWIFIEX_CMD_WAIT:
129 wait_event_interruptible(priv->cmd_wait_q,
130 priv->cmd_wait_q_woken);
131 if (!priv->cmd_wait_q_woken)
134 case MWIFIEX_WSTATS_WAIT:
135 wait_event_interruptible(priv->w_stats_wait_q,
136 priv->w_stats_wait_q_woken);
137 if (!priv->w_stats_wait_q_woken)
142 mwifiex_cancel_pending_ioctl(priv->adapter, wait);
143 dev_dbg(priv->adapter->dev, "cmd: IOCTL cancel: wait=%p, wait_option=%d\n",
151 * The function waits for the request to complete and issues the
152 * completion handler, if required.
154 int mwifiex_request_ioctl(struct mwifiex_private *priv,
155 struct mwifiex_wait_queue *wait,
156 int status, u8 wait_option)
160 dev_dbg(priv->adapter->dev, "cmd: IOCTL pending: wait=%p, wait_option=%d\n",
162 atomic_inc(&priv->adapter->ioctl_pending);
163 /* Status pending, wake up main process */
164 queue_work(priv->adapter->workqueue, &priv->adapter->main_work);
166 /* Wait for completion */
168 mwifiex_wait_ioctl_complete(priv, wait, wait_option);
169 status = wait->status;
180 EXPORT_SYMBOL_GPL(mwifiex_request_ioctl);
183 * IOCTL request handler to set/get MAC address.
185 * This function prepares the correct firmware command and
186 * issues it to get the extended version information.
188 static int mwifiex_bss_ioctl_mac_address(struct mwifiex_private *priv,
189 struct mwifiex_wait_queue *wait,
194 if ((action == HostCmd_ACT_GEN_GET) && mac) {
195 memcpy(mac, priv->curr_addr, ETH_ALEN);
199 /* Send request to firmware */
200 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_MAC_ADDRESS,
201 action, 0, wait, mac);
209 * Sends IOCTL request to set MAC address.
211 * This function allocates the IOCTL request buffer, fills it
212 * with requisite parameters and calls the IOCTL handler.
214 int mwifiex_request_set_mac_address(struct mwifiex_private *priv)
216 struct mwifiex_wait_queue *wait = NULL;
218 u8 wait_option = MWIFIEX_CMD_WAIT;
220 /* Allocate wait buffer */
221 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
225 status = mwifiex_bss_ioctl_mac_address(priv, wait, HostCmd_ACT_GEN_SET,
228 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
230 memcpy(priv->netdev->dev_addr, priv->curr_addr, ETH_ALEN);
232 dev_err(priv->adapter->dev, "set mac address failed: status=%d"
233 " error_code=%#x\n", status, wait->status);
240 * IOCTL request handler to set multicast list.
242 * This function prepares the correct firmware command and
243 * issues it to set the multicast list.
245 * This function can be used to enable promiscuous mode, or enable all
246 * multicast packets, or to enable selective multicast.
249 mwifiex_bss_ioctl_multicast_list(struct mwifiex_private *priv,
250 struct mwifiex_wait_queue *wait,
252 struct mwifiex_multicast_list *mcast_list)
257 old_pkt_filter = priv->curr_pkt_filter;
258 if (action == HostCmd_ACT_GEN_GET)
261 if (mcast_list->mode == MWIFIEX_PROMISC_MODE) {
262 dev_dbg(priv->adapter->dev, "info: Enable Promiscuous mode\n");
263 priv->curr_pkt_filter |= HostCmd_ACT_MAC_PROMISCUOUS_ENABLE;
264 priv->curr_pkt_filter &=
265 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
268 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_PROMISCUOUS_ENABLE;
269 if (mcast_list->mode == MWIFIEX_MULTICAST_MODE) {
270 dev_dbg(priv->adapter->dev,
271 "info: Enabling All Multicast!\n");
272 priv->curr_pkt_filter |=
273 HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
275 priv->curr_pkt_filter &=
276 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
277 if (mcast_list->num_multicast_addr) {
278 dev_dbg(priv->adapter->dev,
279 "info: Set multicast list=%d\n",
280 mcast_list->num_multicast_addr);
281 /* Set multicast addresses to firmware */
282 if (old_pkt_filter == priv->curr_pkt_filter) {
283 /* Send request to firmware */
284 ret = mwifiex_prepare_cmd(priv,
285 HostCmd_CMD_MAC_MULTICAST_ADR,
286 action, 0, wait, mcast_list);
290 /* Send request to firmware */
291 ret = mwifiex_prepare_cmd(priv,
292 HostCmd_CMD_MAC_MULTICAST_ADR,
299 dev_dbg(priv->adapter->dev,
300 "info: old_pkt_filter=%#x, curr_pkt_filter=%#x\n",
301 old_pkt_filter, priv->curr_pkt_filter);
302 if (old_pkt_filter != priv->curr_pkt_filter) {
303 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_MAC_CONTROL, action,
304 0, wait, &priv->curr_pkt_filter);
313 * Sends IOCTL request to set multicast list.
315 * This function allocates the IOCTL request buffer, fills it
316 * with requisite parameters and calls the IOCTL handler.
319 mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
320 struct net_device *dev)
322 struct mwifiex_wait_queue *wait = NULL;
323 struct mwifiex_multicast_list mcast_list;
324 u8 wait_option = MWIFIEX_NO_WAIT;
327 /* Allocate wait buffer */
328 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
332 if (dev->flags & IFF_PROMISC) {
333 mcast_list.mode = MWIFIEX_PROMISC_MODE;
334 } else if (dev->flags & IFF_ALLMULTI ||
335 netdev_mc_count(dev) > MWIFIEX_MAX_MULTICAST_LIST_SIZE) {
336 mcast_list.mode = MWIFIEX_ALL_MULTI_MODE;
338 mcast_list.mode = MWIFIEX_MULTICAST_MODE;
339 if (netdev_mc_count(dev))
340 mcast_list.num_multicast_addr =
341 mwifiex_copy_mcast_addr(&mcast_list, dev);
343 status = mwifiex_bss_ioctl_multicast_list(priv, wait,
347 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
348 if (wait && status != -EINPROGRESS)
355 * IOCTL request handler to disconnect from a BSS/IBSS.
357 static int mwifiex_bss_ioctl_stop(struct mwifiex_private *priv,
358 struct mwifiex_wait_queue *wait, u8 *mac)
360 return mwifiex_deauthenticate(priv, wait, mac);
364 * Sends IOCTL request to disconnect from a BSS.
366 * This function allocates the IOCTL request buffer, fills it
367 * with requisite parameters and calls the IOCTL handler.
369 int mwifiex_disconnect(struct mwifiex_private *priv, u8 wait_option, u8 *mac)
371 struct mwifiex_wait_queue *wait = NULL;
374 /* Allocate wait buffer */
375 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
379 status = mwifiex_bss_ioctl_stop(priv, wait, mac);
381 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
386 EXPORT_SYMBOL_GPL(mwifiex_disconnect);
389 * IOCTL request handler to join a BSS/IBSS.
391 * In Ad-Hoc mode, the IBSS is created if not found in scan list.
392 * In both Ad-Hoc and infra mode, an deauthentication is performed
395 static int mwifiex_bss_ioctl_start(struct mwifiex_private *priv,
396 struct mwifiex_wait_queue *wait,
397 struct mwifiex_ssid_bssid *ssid_bssid)
400 struct mwifiex_adapter *adapter = priv->adapter;
403 priv->scan_block = false;
407 if (priv->bss_mode == MWIFIEX_BSS_MODE_INFRA) {
409 ret = mwifiex_deauthenticate(priv, NULL, NULL);
413 /* Search for the requested SSID in the scan table */
414 if (ssid_bssid->ssid.ssid_len)
415 i = mwifiex_find_ssid_in_list(priv, &ssid_bssid->ssid,
416 NULL, MWIFIEX_BSS_MODE_INFRA);
418 i = mwifiex_find_bssid_in_list(priv,
419 (u8 *) &ssid_bssid->bssid,
420 MWIFIEX_BSS_MODE_INFRA);
424 dev_dbg(adapter->dev,
425 "info: SSID found in scan list ... associating...\n");
427 /* Clear any past association response stored for
428 * application retrieval */
429 priv->assoc_rsp_size = 0;
430 ret = mwifiex_associate(priv, wait, &adapter->scan_table[i]);
435 /* If the requested SSID matches current SSID, return */
436 if (ssid_bssid->ssid.ssid_len &&
438 (&priv->curr_bss_params.bss_descriptor.ssid,
442 /* Exit Adhoc mode first */
443 dev_dbg(adapter->dev, "info: Sending Adhoc Stop\n");
444 ret = mwifiex_deauthenticate(priv, NULL, NULL);
448 priv->adhoc_is_link_sensed = false;
450 /* Search for the requested network in the scan table */
451 if (ssid_bssid->ssid.ssid_len)
452 i = mwifiex_find_ssid_in_list(priv,
453 &ssid_bssid->ssid, NULL,
454 MWIFIEX_BSS_MODE_IBSS);
456 i = mwifiex_find_bssid_in_list(priv,
457 (u8 *)&ssid_bssid->bssid,
458 MWIFIEX_BSS_MODE_IBSS);
461 dev_dbg(adapter->dev, "info: network found in scan"
462 " list. Joining...\n");
463 ret = mwifiex_adhoc_join(priv, wait,
464 &adapter->scan_table[i]);
467 } else { /* i >= 0 */
468 dev_dbg(adapter->dev, "info: Network not found in "
469 "the list, creating adhoc with ssid = %s\n",
470 ssid_bssid->ssid.ssid);
471 ret = mwifiex_adhoc_start(priv, wait,
485 * Sends IOCTL request to connect with a BSS.
487 * This function allocates the IOCTL request buffer, fills it
488 * with requisite parameters and calls the IOCTL handler.
490 int mwifiex_bss_start(struct mwifiex_private *priv, u8 wait_option,
491 struct mwifiex_ssid_bssid *ssid_bssid)
493 struct mwifiex_wait_queue *wait = NULL;
494 struct mwifiex_ssid_bssid tmp_ssid_bssid;
497 /* Stop the O.S. TX queue if needed */
498 if (!netif_queue_stopped(priv->netdev))
499 netif_stop_queue(priv->netdev);
501 /* Allocate wait buffer */
502 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
507 memcpy(&tmp_ssid_bssid, ssid_bssid,
508 sizeof(struct mwifiex_ssid_bssid));
509 status = mwifiex_bss_ioctl_start(priv, wait, &tmp_ssid_bssid);
511 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
518 * IOCTL request handler to set host sleep configuration.
520 * This function prepares the correct firmware command and
524 mwifiex_pm_ioctl_hs_cfg(struct mwifiex_private *priv,
525 struct mwifiex_wait_queue *wait,
526 u16 action, struct mwifiex_ds_hs_cfg *hs_cfg)
528 struct mwifiex_adapter *adapter = priv->adapter;
533 case HostCmd_ACT_GEN_SET:
534 if (adapter->pps_uapsd_mode) {
535 dev_dbg(adapter->dev, "info: Host Sleep IOCTL"
536 " is blocked in UAPSD/PPS mode\n");
540 if (hs_cfg->is_invoke_hostcmd) {
541 if (hs_cfg->conditions == HOST_SLEEP_CFG_CANCEL) {
542 if (!adapter->is_hs_configured)
543 /* Already cancelled */
545 /* Save previous condition */
546 prev_cond = le32_to_cpu(adapter->hs_cfg
548 adapter->hs_cfg.conditions =
549 cpu_to_le32(hs_cfg->conditions);
550 } else if (hs_cfg->conditions) {
551 adapter->hs_cfg.conditions =
552 cpu_to_le32(hs_cfg->conditions);
553 adapter->hs_cfg.gpio = (u8)hs_cfg->gpio;
555 adapter->hs_cfg.gap = (u8)hs_cfg->gap;
556 } else if (adapter->hs_cfg.conditions ==
558 HOST_SLEEP_CFG_CANCEL)) {
559 /* Return failure if no parameters for HS
564 status = mwifiex_prepare_cmd(priv,
565 HostCmd_CMD_802_11_HS_CFG_ENH,
567 0, wait, &adapter->hs_cfg);
569 status = -EINPROGRESS;
570 if (hs_cfg->conditions == HOST_SLEEP_CFG_CANCEL)
571 /* Restore previous condition */
572 adapter->hs_cfg.conditions =
573 cpu_to_le32(prev_cond);
575 adapter->hs_cfg.conditions =
576 cpu_to_le32(hs_cfg->conditions);
577 adapter->hs_cfg.gpio = (u8)hs_cfg->gpio;
578 adapter->hs_cfg.gap = (u8)hs_cfg->gap;
581 case HostCmd_ACT_GEN_GET:
582 hs_cfg->conditions = le32_to_cpu(adapter->hs_cfg.conditions);
583 hs_cfg->gpio = adapter->hs_cfg.gpio;
584 hs_cfg->gap = adapter->hs_cfg.gap;
595 * Sends IOCTL request to set Host Sleep parameters.
597 * This function allocates the IOCTL request buffer, fills it
598 * with requisite parameters and calls the IOCTL handler.
600 int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
602 struct mwifiex_ds_hs_cfg *hscfg)
605 struct mwifiex_wait_queue *wait = NULL;
610 /* Allocate wait buffer */
611 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
615 ret = mwifiex_pm_ioctl_hs_cfg(priv, wait, action, hscfg);
617 ret = mwifiex_request_ioctl(priv, wait, ret, wait_option);
619 if (wait && (ret != -EINPROGRESS))
625 * Sends IOCTL request to cancel the existing Host Sleep configuration.
627 * This function allocates the IOCTL request buffer, fills it
628 * with requisite parameters and calls the IOCTL handler.
630 int mwifiex_cancel_hs(struct mwifiex_private *priv, u8 wait_option)
633 struct mwifiex_ds_hs_cfg hscfg;
635 /* Cancel Host Sleep */
636 hscfg.conditions = HOST_SLEEP_CFG_CANCEL;
637 hscfg.is_invoke_hostcmd = true;
638 ret = mwifiex_set_hs_params(priv, HostCmd_ACT_GEN_SET,
639 wait_option, &hscfg);
643 EXPORT_SYMBOL_GPL(mwifiex_cancel_hs);
646 * Sends IOCTL request to cancel the existing Host Sleep configuration.
648 * This function allocates the IOCTL request buffer, fills it
649 * with requisite parameters and calls the IOCTL handler.
651 int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
653 struct mwifiex_ds_hs_cfg hscfg;
655 if (adapter->hs_activated) {
656 dev_dbg(adapter->dev, "cmd: HS Already actived\n");
660 /* Enable Host Sleep */
661 adapter->hs_activate_wait_q_woken = false;
663 memset(&hscfg, 0, sizeof(struct mwifiex_hs_config_param));
664 hscfg.is_invoke_hostcmd = true;
666 if (mwifiex_set_hs_params(mwifiex_get_priv(adapter,
667 MWIFIEX_BSS_ROLE_STA),
669 MWIFIEX_IOCTL_WAIT, &hscfg)) {
670 dev_err(adapter->dev, "IOCTL request HS enable failed\n");
674 wait_event_interruptible(adapter->hs_activate_wait_q,
675 adapter->hs_activate_wait_q_woken);
679 EXPORT_SYMBOL_GPL(mwifiex_enable_hs);
682 * IOCTL request handler to get signal information.
684 * This function prepares the correct firmware command and
685 * issues it to get the signal (RSSI) information.
687 * This only works in the connected mode.
689 static int mwifiex_get_info_signal(struct mwifiex_private *priv,
690 struct mwifiex_wait_queue *wait,
691 struct mwifiex_ds_get_signal *signal)
696 dev_err(priv->adapter->dev, "WAIT information is not present\n");
700 /* Signal info can be obtained only if connected */
701 if (!priv->media_connected) {
702 dev_dbg(priv->adapter->dev,
703 "info: Can not get signal in disconnected state\n");
707 /* Send request to firmware */
708 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_RSSI_INFO,
709 HostCmd_ACT_GEN_GET, 0, wait, signal);
718 * IOCTL request handler to get statistics.
720 * This function prepares the correct firmware command and
721 * issues it to get the statistics (RSSI) information.
723 static int mwifiex_get_info_stats(struct mwifiex_private *priv,
724 struct mwifiex_wait_queue *wait,
725 struct mwifiex_ds_get_stats *log)
730 dev_err(priv->adapter->dev, "MWIFIEX IOCTL information is not present\n");
734 /* Send request to firmware */
735 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_GET_LOG,
736 HostCmd_ACT_GEN_GET, 0, wait, log);
745 * IOCTL request handler to get BSS information.
747 * This function collates the information from different driver structures
748 * to send to the user.
750 int mwifiex_get_bss_info(struct mwifiex_private *priv,
751 struct mwifiex_bss_info *info)
753 struct mwifiex_adapter *adapter = priv->adapter;
754 struct mwifiex_bssdescriptor *bss_desc;
760 /* Get current BSS info */
761 bss_desc = &priv->curr_bss_params.bss_descriptor;
764 info->bss_mode = priv->bss_mode;
767 memcpy(&info->ssid, &bss_desc->ssid,
768 sizeof(struct mwifiex_802_11_ssid));
771 memcpy(&info->bssid, &bss_desc->mac_address, ETH_ALEN);
774 info->bss_chan = bss_desc->channel;
777 info->region_code = adapter->region_code;
779 /* Scan table index if connected */
780 info->scan_table_idx = 0;
781 if (priv->media_connected) {
783 mwifiex_find_ssid_in_list(priv, &bss_desc->ssid,
784 bss_desc->mac_address,
787 info->scan_table_idx = tbl_idx;
790 /* Connection status */
791 info->media_connected = priv->media_connected;
794 info->radio_on = adapter->radio_on;
796 /* Tx power information */
797 info->max_power_level = priv->max_tx_power_level;
798 info->min_power_level = priv->min_tx_power_level;
801 info->adhoc_state = priv->adhoc_state;
804 info->bcn_nf_last = priv->bcn_nf_last;
807 if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED)
808 info->wep_status = true;
810 info->wep_status = false;
812 info->is_hs_configured = adapter->is_hs_configured;
813 info->is_deep_sleep = adapter->is_deep_sleep;
819 * IOCTL request handler to get extended version information.
821 * This function prepares the correct firmware command and
822 * issues it to get the extended version information.
824 static int mwifiex_get_info_ver_ext(struct mwifiex_private *priv,
825 struct mwifiex_wait_queue *wait,
826 struct mwifiex_ver_ext *ver_ext)
830 /* Send request to firmware */
831 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_VERSION_EXT,
832 HostCmd_ACT_GEN_GET, 0, wait, ver_ext);
840 * IOCTL request handler to set/get SNMP MIB parameters.
842 * This function prepares the correct firmware command and
845 * Currently the following parameters are supported -
846 * Set/get RTS Threshold
847 * Set/get fragmentation threshold
848 * Set/get retry count
850 int mwifiex_snmp_mib_ioctl(struct mwifiex_private *priv,
851 struct mwifiex_wait_queue *wait,
852 u32 cmd_oid, u16 action, u32 *value)
859 /* Send request to firmware */
860 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_SNMP_MIB,
861 action, cmd_oid, wait, value);
870 * IOCTL request handler to set/get band configurations.
872 * For SET operation, it performs extra checks to make sure the Ad-Hoc
873 * band and channel are compatible. Otherwise it returns an error.
875 * For GET operation, this function retrieves the following information -
879 * - Secondary channel offset
881 int mwifiex_radio_ioctl_band_cfg(struct mwifiex_private *priv,
883 struct mwifiex_ds_band_cfg *radio_cfg)
885 struct mwifiex_adapter *adapter = priv->adapter;
888 u32 adhoc_channel = 0;
890 if (action == HostCmd_ACT_GEN_GET) {
892 radio_cfg->config_bands = adapter->config_bands;
894 radio_cfg->adhoc_start_band = adapter->adhoc_start_band;
896 radio_cfg->adhoc_channel = priv->adhoc_channel;
897 /* Secondary channel offset */
898 radio_cfg->sec_chan_offset = adapter->chan_offset;
902 /* For action = SET */
903 infra_band = (u8) radio_cfg->config_bands;
904 adhoc_band = (u8) radio_cfg->adhoc_start_band;
905 adhoc_channel = radio_cfg->adhoc_channel;
908 if ((infra_band | adapter->fw_bands) & ~adapter->fw_bands)
911 adapter->config_bands = infra_band;
913 /* SET Ad-hoc Band */
914 if ((adhoc_band | adapter->fw_bands) & ~adapter->fw_bands)
918 adapter->adhoc_start_band = adhoc_band;
919 adapter->chan_offset = (u8) radio_cfg->sec_chan_offset;
921 * If no adhoc_channel is supplied verify if the existing adhoc
922 * channel compiles with new adhoc_band
924 if (!adhoc_channel) {
925 if (!mwifiex_get_cfp_by_band_and_channel_from_cfg80211
926 (priv, adapter->adhoc_start_band,
927 priv->adhoc_channel)) {
928 /* Pass back the default channel */
929 radio_cfg->adhoc_channel = DEFAULT_AD_HOC_CHANNEL;
930 if ((adapter->adhoc_start_band & BAND_A)
931 || (adapter->adhoc_start_band & BAND_AN))
932 radio_cfg->adhoc_channel =
933 DEFAULT_AD_HOC_CHANNEL_A;
935 } else { /* Retrurn error if adhoc_band and
936 adhoc_channel combination is invalid */
937 if (!mwifiex_get_cfp_by_band_and_channel_from_cfg80211
938 (priv, adapter->adhoc_start_band, (u16) adhoc_channel))
940 priv->adhoc_channel = (u8) adhoc_channel;
942 if ((adhoc_band & BAND_GN) || (adhoc_band & BAND_AN))
943 adapter->adhoc_11n_enabled = true;
945 adapter->adhoc_11n_enabled = false;
951 * IOCTL request handler to set/get active channel.
953 * This function performs validity checking on channel/frequency
954 * compatibility and returns failure if not valid.
956 int mwifiex_bss_ioctl_channel(struct mwifiex_private *priv, u16 action,
957 struct mwifiex_chan_freq_power *chan)
959 struct mwifiex_adapter *adapter = priv->adapter;
960 struct mwifiex_chan_freq_power *cfp = NULL;
965 if (action == HostCmd_ACT_GEN_GET) {
966 cfp = mwifiex_get_cfp_by_band_and_channel_from_cfg80211(priv,
967 priv->curr_bss_params.band,
968 (u16) priv->curr_bss_params.bss_descriptor.
970 chan->channel = cfp->channel;
971 chan->freq = cfp->freq;
975 if (!chan->channel && !chan->freq)
977 if (adapter->adhoc_start_band & BAND_AN)
978 adapter->adhoc_start_band = BAND_G | BAND_B | BAND_GN;
979 else if (adapter->adhoc_start_band & BAND_A)
980 adapter->adhoc_start_band = BAND_G | BAND_B;
982 if (chan->channel <= MAX_CHANNEL_BAND_BG)
983 cfp = mwifiex_get_cfp_by_band_and_channel_from_cfg80211
984 (priv, 0, (u16) chan->channel);
986 cfp = mwifiex_get_cfp_by_band_and_channel_from_cfg80211
987 (priv, BAND_A, (u16) chan->channel);
989 if (adapter->adhoc_11n_enabled)
990 adapter->adhoc_start_band = BAND_A
993 adapter->adhoc_start_band = BAND_A;
997 if (chan->freq <= MAX_FREQUENCY_BAND_BG)
998 cfp = mwifiex_get_cfp_by_band_and_freq_from_cfg80211(
999 priv, 0, chan->freq);
1001 cfp = mwifiex_get_cfp_by_band_and_freq_from_cfg80211
1002 (priv, BAND_A, chan->freq);
1004 if (adapter->adhoc_11n_enabled)
1005 adapter->adhoc_start_band = BAND_A
1008 adapter->adhoc_start_band = BAND_A;
1012 if (!cfp || !cfp->channel) {
1013 dev_err(adapter->dev, "invalid channel/freq\n");
1016 priv->adhoc_channel = (u8) cfp->channel;
1017 chan->channel = cfp->channel;
1018 chan->freq = cfp->freq;
1024 * IOCTL request handler to set/get BSS mode.
1026 * This function prepares the correct firmware command and
1027 * issues it to set or get the BSS mode.
1029 * In case the mode is changed, a deauthentication is performed
1030 * first by the function automatically.
1032 int mwifiex_bss_ioctl_mode(struct mwifiex_private *priv,
1033 struct mwifiex_wait_queue *wait,
1034 u16 action, int *mode)
1041 if (action == HostCmd_ACT_GEN_GET) {
1042 *mode = priv->bss_mode;
1046 if ((priv->bss_mode == *mode) || (*mode == MWIFIEX_BSS_MODE_AUTO)) {
1047 dev_dbg(priv->adapter->dev,
1048 "info: Already set to required mode! No change!\n");
1049 priv->bss_mode = *mode;
1053 ret = mwifiex_deauthenticate(priv, wait, NULL);
1055 priv->sec_info.authentication_mode = MWIFIEX_AUTH_MODE_OPEN;
1056 priv->bss_mode = *mode;
1057 if (priv->bss_mode != MWIFIEX_BSS_MODE_AUTO) {
1058 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_SET_BSS_MODE,
1059 HostCmd_ACT_GEN_SET, 0, wait, NULL);
1068 * IOCTL request handler to set/get Ad-Hoc channel.
1070 * This function prepares the correct firmware command and
1071 * issues it to set or get the ad-hoc channel.
1073 static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv,
1074 struct mwifiex_wait_queue *wait,
1075 u16 action, u16 *channel)
1079 if (action == HostCmd_ACT_GEN_GET) {
1080 if (!priv->media_connected) {
1081 *channel = priv->adhoc_channel;
1085 priv->adhoc_channel = (u8) *channel;
1088 /* Send request to firmware */
1089 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_RF_CHANNEL,
1090 action, 0, wait, channel);
1098 * IOCTL request handler to find a particular BSS.
1100 * The BSS can be searched with either a BSSID or a SSID. If none of
1101 * these are provided, just the best BSS (best RSSI) is returned.
1103 int mwifiex_bss_ioctl_find_bss(struct mwifiex_private *priv,
1104 struct mwifiex_wait_queue *wait,
1105 struct mwifiex_ssid_bssid *ssid_bssid)
1107 struct mwifiex_adapter *adapter = priv->adapter;
1109 struct mwifiex_bssdescriptor *bss_desc;
1110 u8 zero_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
1114 if (memcmp(ssid_bssid->bssid, zero_mac, sizeof(zero_mac))) {
1115 i = mwifiex_find_bssid_in_list(priv,
1116 (u8 *) ssid_bssid->bssid,
1119 memcpy(mac, ssid_bssid->bssid, sizeof(mac));
1120 dev_err(adapter->dev, "cannot find bssid %pM\n", mac);
1123 bss_desc = &adapter->scan_table[i];
1124 memcpy(&ssid_bssid->ssid, &bss_desc->ssid,
1125 sizeof(struct mwifiex_802_11_ssid));
1126 } else if (ssid_bssid->ssid.ssid_len) {
1127 i = mwifiex_find_ssid_in_list(priv, &ssid_bssid->ssid, NULL,
1130 dev_err(adapter->dev, "cannot find ssid %s\n",
1131 ssid_bssid->ssid.ssid);
1134 bss_desc = &adapter->scan_table[i];
1135 memcpy(ssid_bssid->bssid, bss_desc->mac_address, ETH_ALEN);
1137 ret = mwifiex_find_best_network(priv, ssid_bssid);
1144 * IOCTL request handler to change Ad-Hoc channel.
1146 * This function allocates the IOCTL request buffer, fills it
1147 * with requisite parameters and calls the IOCTL handler.
1149 * The function follows the following steps to perform the change -
1150 * - Get current IBSS information
1151 * - Get current channel
1152 * - If no change is required, return
1153 * - If not connected, change channel and return
1157 * - Perform specific SSID scan with same SSID
1158 * - Start/Join the IBSS
1161 mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel)
1165 struct mwifiex_bss_info bss_info;
1166 struct mwifiex_wait_queue *wait = NULL;
1167 u8 wait_option = MWIFIEX_IOCTL_WAIT;
1168 struct mwifiex_ssid_bssid ssid_bssid;
1171 memset(&bss_info, 0, sizeof(bss_info));
1173 /* Get BSS information */
1174 if (mwifiex_get_bss_info(priv, &bss_info))
1177 /* Allocate wait buffer */
1178 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1182 /* Get current channel */
1183 status = mwifiex_bss_ioctl_ibss_channel(priv, wait, HostCmd_ACT_GEN_GET,
1186 if (mwifiex_request_ioctl(priv, wait, status, wait_option)) {
1190 if (curr_chan == channel) {
1194 dev_dbg(priv->adapter->dev, "cmd: updating channel from %d to %d\n",
1195 curr_chan, channel);
1197 if (!bss_info.media_connected) {
1203 memset(&ssid_bssid, 0, ETH_ALEN);
1204 status = mwifiex_bss_ioctl_stop(priv, wait, ssid_bssid.bssid);
1206 if (mwifiex_request_ioctl(priv, wait, status, wait_option)) {
1211 status = mwifiex_bss_ioctl_ibss_channel(priv, wait, HostCmd_ACT_GEN_SET,
1214 if (mwifiex_request_ioctl(priv, wait, status, wait_option)) {
1219 /* Do specific SSID scanning */
1220 if (mwifiex_request_scan(priv, wait_option, &bss_info.ssid)) {
1224 /* Start/Join Adhoc network */
1225 memset(&ssid_bssid, 0, sizeof(struct mwifiex_ssid_bssid));
1226 memcpy(&ssid_bssid.ssid, &bss_info.ssid,
1227 sizeof(struct mwifiex_802_11_ssid));
1229 status = mwifiex_bss_ioctl_start(priv, wait, &ssid_bssid);
1231 if (mwifiex_request_ioctl(priv, wait, status, wait_option))
1240 * IOCTL request handler to get current driver mode.
1242 * This function allocates the IOCTL request buffer, fills it
1243 * with requisite parameters and calls the IOCTL handler.
1246 mwifiex_drv_get_mode(struct mwifiex_private *priv, u8 wait_option)
1248 struct mwifiex_wait_queue *wait = NULL;
1252 /* Allocate wait buffer */
1253 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1257 status = mwifiex_bss_ioctl_mode(priv, wait, HostCmd_ACT_GEN_GET, &mode);
1259 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
1261 if (wait && (status != -EINPROGRESS))
1267 * IOCTL request handler to get rate.
1269 * This function prepares the correct firmware command and
1270 * issues it to get the current rate if it is connected,
1271 * otherwise, the function returns the lowest supported rate
1274 static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv,
1275 struct mwifiex_wait_queue *wait,
1276 struct mwifiex_rate_cfg *rate_cfg)
1278 struct mwifiex_adapter *adapter = priv->adapter;
1281 rate_cfg->is_rate_auto = priv->is_data_rate_auto;
1282 if (!priv->media_connected) {
1283 switch (adapter->config_bands) {
1285 /* Return the lowest supported rate for B band */
1286 rate_cfg->rate = supported_rates_b[0] & 0x7f;
1289 case BAND_G | BAND_GN:
1290 /* Return the lowest supported rate for G band */
1291 rate_cfg->rate = supported_rates_g[0] & 0x7f;
1293 case BAND_B | BAND_G:
1294 case BAND_A | BAND_B | BAND_G:
1295 case BAND_A | BAND_B:
1296 case BAND_A | BAND_B | BAND_G | BAND_AN | BAND_GN:
1297 case BAND_B | BAND_G | BAND_GN:
1298 /* Return the lowest supported rate for BG band */
1299 rate_cfg->rate = supported_rates_bg[0] & 0x7f;
1302 case BAND_A | BAND_G:
1303 case BAND_A | BAND_G | BAND_AN | BAND_GN:
1304 case BAND_A | BAND_AN:
1305 /* Return the lowest supported rate for A band */
1306 rate_cfg->rate = supported_rates_a[0] & 0x7f;
1309 /* Return the lowest supported rate for N band */
1310 rate_cfg->rate = supported_rates_n[0] & 0x7f;
1313 dev_warn(adapter->dev, "invalid band %#x\n",
1314 adapter->config_bands);
1318 /* Send request to firmware */
1319 ret = mwifiex_prepare_cmd(priv,
1320 HostCmd_CMD_802_11_TX_RATE_QUERY,
1321 HostCmd_ACT_GEN_GET, 0, wait, NULL);
1330 * IOCTL request handler to set rate.
1332 * This function prepares the correct firmware command and
1333 * issues it to set the current rate.
1335 * The function also performs validation checking on the supplied value.
1337 static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv,
1338 struct mwifiex_wait_queue *wait,
1339 struct mwifiex_rate_cfg *rate_cfg)
1341 u8 rates[MWIFIEX_SUPPORTED_RATES];
1344 u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
1347 struct mwifiex_adapter *adapter = priv->adapter;
1349 if (rate_cfg->is_rate_auto) {
1350 memset(bitmap_rates, 0, sizeof(bitmap_rates));
1351 /* Support all HR/DSSS rates */
1352 bitmap_rates[0] = 0x000F;
1353 /* Support all OFDM rates */
1354 bitmap_rates[1] = 0x00FF;
1355 /* Support all HT-MCSs rate */
1356 for (i = 0; i < ARRAY_SIZE(priv->bitmap_rates) - 3; i++)
1357 bitmap_rates[i + 2] = 0xFFFF;
1358 bitmap_rates[9] = 0x3FFF;
1360 memset(rates, 0, sizeof(rates));
1361 mwifiex_get_active_data_rates(priv, rates);
1363 for (i = 0; (rate[i] && i < MWIFIEX_SUPPORTED_RATES); i++) {
1364 dev_dbg(adapter->dev, "info: rate=%#x wanted=%#x\n",
1365 rate[i], rate_cfg->rate);
1366 if ((rate[i] & 0x7f) == (rate_cfg->rate & 0x7f))
1369 if (!rate[i] || (i == MWIFIEX_SUPPORTED_RATES)) {
1370 dev_err(adapter->dev, "fixed data rate %#x is out "
1371 "of range\n", rate_cfg->rate);
1374 memset(bitmap_rates, 0, sizeof(bitmap_rates));
1377 mwifiex_data_rate_to_index(adapter, rate_cfg->rate);
1379 /* Only allow b/g rates to be set */
1380 if (rate_index >= MWIFIEX_RATE_INDEX_HRDSSS0 &&
1381 rate_index <= MWIFIEX_RATE_INDEX_HRDSSS3) {
1382 bitmap_rates[0] = 1 << rate_index;
1384 rate_index -= 1; /* There is a 0x00 in the table */
1385 if (rate_index >= MWIFIEX_RATE_INDEX_OFDM0 &&
1386 rate_index <= MWIFIEX_RATE_INDEX_OFDM7)
1387 bitmap_rates[1] = 1 << (rate_index -
1388 MWIFIEX_RATE_INDEX_OFDM0);
1392 /* Send request to firmware */
1393 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_TX_RATE_CFG,
1394 HostCmd_ACT_GEN_SET, 0, wait, bitmap_rates);
1402 * IOCTL request handler to set/get rate.
1404 * This function can be used to set/get either the rate value or the
1407 static int mwifiex_rate_ioctl_cfg(struct mwifiex_private *priv,
1408 struct mwifiex_wait_queue *wait,
1409 struct mwifiex_rate_cfg *rate_cfg)
1416 if (rate_cfg->action == HostCmd_ACT_GEN_GET)
1417 status = mwifiex_rate_ioctl_get_rate_value(
1418 priv, wait, rate_cfg);
1420 status = mwifiex_rate_ioctl_set_rate_value(
1421 priv, wait, rate_cfg);
1427 * Sends IOCTL request to get the data rate.
1429 * This function allocates the IOCTL request buffer, fills it
1430 * with requisite parameters and calls the IOCTL handler.
1432 int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
1433 struct mwifiex_rate_cfg *rate)
1436 struct mwifiex_wait_queue *wait = NULL;
1437 u8 wait_option = MWIFIEX_IOCTL_WAIT;
1439 /* Allocate wait buffer */
1440 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1444 memset(rate, 0, sizeof(struct mwifiex_rate_cfg));
1445 rate->action = HostCmd_ACT_GEN_GET;
1446 ret = mwifiex_rate_ioctl_cfg(priv, wait, rate);
1448 ret = mwifiex_request_ioctl(priv, wait, ret, wait_option);
1450 if (rate && rate->is_rate_auto)
1451 rate->rate = mwifiex_index_to_data_rate(priv->adapter,
1452 priv->tx_rate, priv->tx_htinfo);
1454 rate->rate = priv->data_rate;
1464 * IOCTL request handler to set tx power configuration.
1466 * This function prepares the correct firmware command and
1469 * For non-auto power mode, all the following power groups are set -
1470 * - Modulation class HR/DSSS
1471 * - Modulation class OFDM
1472 * - Modulation class HTBW20
1473 * - Modulation class HTBW40
1475 static int mwifiex_power_ioctl_set_power(struct mwifiex_private *priv,
1476 struct mwifiex_wait_queue *wait,
1477 struct mwifiex_power_cfg *power_cfg)
1480 struct host_cmd_ds_txpwr_cfg *txp_cfg = NULL;
1481 struct mwifiex_types_power_group *pg_tlv = NULL;
1482 struct mwifiex_power_group *pg = NULL;
1486 if (!power_cfg->is_power_auto) {
1487 dbm = (u16) power_cfg->power_level;
1488 if ((dbm < priv->min_tx_power_level) ||
1489 (dbm > priv->max_tx_power_level)) {
1490 dev_err(priv->adapter->dev, "txpower value %d dBm"
1491 " is out of range (%d dBm-%d dBm)\n",
1492 dbm, priv->min_tx_power_level,
1493 priv->max_tx_power_level);
1497 buf = kzalloc(MWIFIEX_SIZE_OF_CMD_BUFFER, GFP_KERNEL);
1499 dev_err(priv->adapter->dev, "%s: failed to alloc cmd buffer\n",
1504 txp_cfg = (struct host_cmd_ds_txpwr_cfg *) buf;
1505 txp_cfg->action = cpu_to_le16(HostCmd_ACT_GEN_SET);
1506 if (!power_cfg->is_power_auto) {
1507 txp_cfg->mode = cpu_to_le32(1);
1508 pg_tlv = (struct mwifiex_types_power_group *) (buf +
1509 sizeof(struct host_cmd_ds_txpwr_cfg));
1510 pg_tlv->type = TLV_TYPE_POWER_GROUP;
1511 pg_tlv->length = 4 * sizeof(struct mwifiex_power_group);
1512 pg = (struct mwifiex_power_group *) (buf +
1513 sizeof(struct host_cmd_ds_txpwr_cfg) +
1514 sizeof(struct mwifiex_types_power_group));
1515 /* Power group for modulation class HR/DSSS */
1516 pg->first_rate_code = 0x00;
1517 pg->last_rate_code = 0x03;
1518 pg->modulation_class = MOD_CLASS_HR_DSSS;
1520 pg->power_min = (s8) dbm;
1521 pg->power_max = (s8) dbm;
1523 /* Power group for modulation class OFDM */
1524 pg->first_rate_code = 0x00;
1525 pg->last_rate_code = 0x07;
1526 pg->modulation_class = MOD_CLASS_OFDM;
1528 pg->power_min = (s8) dbm;
1529 pg->power_max = (s8) dbm;
1531 /* Power group for modulation class HTBW20 */
1532 pg->first_rate_code = 0x00;
1533 pg->last_rate_code = 0x20;
1534 pg->modulation_class = MOD_CLASS_HT;
1536 pg->power_min = (s8) dbm;
1537 pg->power_max = (s8) dbm;
1538 pg->ht_bandwidth = HT_BW_20;
1540 /* Power group for modulation class HTBW40 */
1541 pg->first_rate_code = 0x00;
1542 pg->last_rate_code = 0x20;
1543 pg->modulation_class = MOD_CLASS_HT;
1545 pg->power_min = (s8) dbm;
1546 pg->power_max = (s8) dbm;
1547 pg->ht_bandwidth = HT_BW_40;
1549 /* Send request to firmware */
1550 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_TXPWR_CFG,
1551 HostCmd_ACT_GEN_SET, 0, wait, buf);
1560 * IOCTL request handler to get power save mode.
1562 * This function prepares the correct firmware command and
1565 static int mwifiex_pm_ioctl_ps_mode(struct mwifiex_private *priv,
1566 struct mwifiex_wait_queue *wait,
1567 u32 *ps_mode, u16 action)
1570 struct mwifiex_adapter *adapter = priv->adapter;
1573 if (action == HostCmd_ACT_GEN_SET) {
1575 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
1577 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM;
1578 sub_cmd = (*ps_mode) ? EN_AUTO_PS : DIS_AUTO_PS;
1579 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
1580 sub_cmd, BITMAP_STA_PS, wait, NULL);
1581 if ((!ret) && (sub_cmd == DIS_AUTO_PS))
1582 ret = mwifiex_prepare_cmd(priv,
1583 HostCmd_CMD_802_11_PS_MODE_ENH, GET_PS,
1586 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
1587 GET_PS, 0, wait, NULL);
1597 * IOCTL request handler to set/reset WPA IE.
1599 * The supplied WPA IE is treated as a opaque buffer. Only the first field
1600 * is checked to determine WPA version. If buffer length is zero, the existing
1603 static int mwifiex_set_wpa_ie_helper(struct mwifiex_private *priv,
1604 u8 *ie_data_ptr, u16 ie_len)
1607 if (ie_len > sizeof(priv->wpa_ie)) {
1608 dev_err(priv->adapter->dev,
1609 "failed to copy WPA IE, too big\n");
1612 memcpy(priv->wpa_ie, ie_data_ptr, ie_len);
1613 priv->wpa_ie_len = (u8) ie_len;
1614 dev_dbg(priv->adapter->dev, "cmd: Set Wpa_ie_len=%d IE=%#x\n",
1615 priv->wpa_ie_len, priv->wpa_ie[0]);
1617 if (priv->wpa_ie[0] == WLAN_EID_WPA) {
1618 priv->sec_info.wpa_enabled = true;
1619 } else if (priv->wpa_ie[0] == WLAN_EID_RSN) {
1620 priv->sec_info.wpa2_enabled = true;
1622 priv->sec_info.wpa_enabled = false;
1623 priv->sec_info.wpa2_enabled = false;
1626 memset(priv->wpa_ie, 0, sizeof(priv->wpa_ie));
1627 priv->wpa_ie_len = 0;
1628 dev_dbg(priv->adapter->dev, "info: reset wpa_ie_len=%d IE=%#x\n",
1629 priv->wpa_ie_len, priv->wpa_ie[0]);
1630 priv->sec_info.wpa_enabled = false;
1631 priv->sec_info.wpa2_enabled = false;
1638 * IOCTL request handler to set/reset WAPI IE.
1640 * The supplied WAPI IE is treated as a opaque buffer. Only the first field
1641 * is checked to internally enable WAPI. If buffer length is zero, the existing
1644 static int mwifiex_set_wapi_ie(struct mwifiex_private *priv,
1645 u8 *ie_data_ptr, u16 ie_len)
1648 if (ie_len > sizeof(priv->wapi_ie)) {
1649 dev_dbg(priv->adapter->dev,
1650 "info: failed to copy WAPI IE, too big\n");
1653 memcpy(priv->wapi_ie, ie_data_ptr, ie_len);
1654 priv->wapi_ie_len = ie_len;
1655 dev_dbg(priv->adapter->dev, "cmd: Set wapi_ie_len=%d IE=%#x\n",
1656 priv->wapi_ie_len, priv->wapi_ie[0]);
1658 if (priv->wapi_ie[0] == WLAN_EID_BSS_AC_ACCESS_DELAY)
1659 priv->sec_info.wapi_enabled = true;
1661 memset(priv->wapi_ie, 0, sizeof(priv->wapi_ie));
1662 priv->wapi_ie_len = ie_len;
1663 dev_dbg(priv->adapter->dev,
1664 "info: Reset wapi_ie_len=%d IE=%#x\n",
1665 priv->wapi_ie_len, priv->wapi_ie[0]);
1666 priv->sec_info.wapi_enabled = false;
1672 * IOCTL request handler to set WAPI key.
1674 * This function prepares the correct firmware command and
1677 static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_adapter *adapter,
1678 struct mwifiex_wait_queue *wait,
1679 struct mwifiex_ds_encrypt_key *encrypt_key)
1682 struct mwifiex_private *priv = adapter->priv[wait->bss_index];
1684 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1685 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1694 * IOCTL request handler to set WEP network key.
1696 * This function prepares the correct firmware command and
1697 * issues it, after validation checks.
1699 static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_adapter *adapter,
1700 struct mwifiex_wait_queue *wait,
1701 struct mwifiex_ds_encrypt_key *encrypt_key)
1704 struct mwifiex_private *priv = adapter->priv[wait->bss_index];
1705 struct mwifiex_wep_key *wep_key = NULL;
1708 if (priv->wep_key_curr_index >= NUM_WEP_KEYS)
1709 priv->wep_key_curr_index = 0;
1710 wep_key = &priv->wep_key[priv->wep_key_curr_index];
1711 index = encrypt_key->key_index;
1712 if (encrypt_key->key_disable) {
1713 priv->sec_info.wep_status = MWIFIEX_802_11_WEP_DISABLED;
1714 } else if (!encrypt_key->key_len) {
1715 /* Copy the required key as the current key */
1716 wep_key = &priv->wep_key[index];
1717 if (!wep_key->key_length) {
1718 dev_err(adapter->dev,
1719 "key not set, so cannot enable it\n");
1722 priv->wep_key_curr_index = (u16) index;
1723 priv->sec_info.wep_status = MWIFIEX_802_11_WEP_ENABLED;
1725 wep_key = &priv->wep_key[index];
1727 memset(wep_key, 0, sizeof(struct mwifiex_wep_key));
1728 /* Copy the key in the driver */
1729 memcpy(wep_key->key_material,
1730 encrypt_key->key_material,
1731 encrypt_key->key_len);
1732 wep_key->key_index = index;
1733 wep_key->key_length = encrypt_key->key_len;
1734 priv->sec_info.wep_status = MWIFIEX_802_11_WEP_ENABLED;
1736 if (wep_key->key_length) {
1737 /* Send request to firmware */
1738 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1739 HostCmd_ACT_GEN_SET, 0, NULL, NULL);
1743 if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED)
1744 priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE;
1746 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
1748 /* Send request to firmware */
1749 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_MAC_CONTROL,
1750 HostCmd_ACT_GEN_SET, 0, wait,
1751 &priv->curr_pkt_filter);
1759 * IOCTL request handler to set WPA key.
1761 * This function prepares the correct firmware command and
1762 * issues it, after validation checks.
1764 * Current driver only supports key length of up to 32 bytes.
1766 * This function can also be used to disable a currently set key.
1768 static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_adapter *adapter,
1769 struct mwifiex_wait_queue *wait,
1770 struct mwifiex_ds_encrypt_key *encrypt_key)
1773 struct mwifiex_private *priv = adapter->priv[wait->bss_index];
1774 u8 remove_key = false;
1775 struct host_cmd_ds_802_11_key_material *ibss_key;
1777 /* Current driver only supports key length of up to 32 bytes */
1778 if (encrypt_key->key_len > MWIFIEX_MAX_KEY_LENGTH) {
1779 dev_err(adapter->dev, "key length too long\n");
1783 if (priv->bss_mode == MWIFIEX_BSS_MODE_IBSS) {
1785 * IBSS/WPA-None uses only one key (Group) for both receiving
1786 * and sending unicast and multicast packets.
1788 /* Send the key as PTK to firmware */
1789 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1790 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1791 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1796 ibss_key = &priv->aes_key;
1798 sizeof(struct host_cmd_ds_802_11_key_material));
1799 /* Copy the key in the driver */
1800 memcpy(ibss_key->key_param_set.key, encrypt_key->key_material,
1801 encrypt_key->key_len);
1802 memcpy(&ibss_key->key_param_set.key_len, &encrypt_key->key_len,
1803 sizeof(ibss_key->key_param_set.key_len));
1804 ibss_key->key_param_set.key_type_id
1805 = cpu_to_le16(KEY_TYPE_ID_TKIP);
1806 ibss_key->key_param_set.key_info
1807 = cpu_to_le16(KEY_INFO_TKIP_ENABLED);
1809 /* Send the key as GTK to firmware */
1810 encrypt_key->key_index = ~MWIFIEX_KEY_INDEX_UNICAST;
1813 if (!encrypt_key->key_index)
1814 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1817 /* Send request to firmware */
1818 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1819 HostCmd_ACT_GEN_SET,
1820 !(KEY_INFO_ENABLED),
1823 /* Send request to firmware */
1824 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1825 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1835 * IOCTL request handler to set/get network keys.
1837 * This is a generic key handling function which supports WEP, WPA
1841 mwifiex_sec_ioctl_encrypt_key(struct mwifiex_private *priv,
1842 struct mwifiex_wait_queue *wait,
1843 struct mwifiex_ds_encrypt_key *encrypt_key)
1846 struct mwifiex_adapter *adapter = priv->adapter;
1848 if (encrypt_key->is_wapi_key)
1849 status = mwifiex_sec_ioctl_set_wapi_key(adapter, wait,
1851 else if (encrypt_key->key_len > WLAN_KEY_LEN_WEP104)
1852 status = mwifiex_sec_ioctl_set_wpa_key(adapter, wait,
1855 status = mwifiex_sec_ioctl_set_wep_key(adapter, wait,
1861 * This function returns the driver version.
1864 mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, char *version,
1873 ver.l = adapter->fw_release_number;
1874 sprintf(fw_ver, "%u.%u.%u.p%u", ver.c[2], ver.c[1], ver.c[0], ver.c[3]);
1876 snprintf(version, max_len, driver_version, fw_ver);
1878 dev_dbg(adapter->dev, "info: MWIFIEX VERSION: %s\n", version);
1884 * Sends IOCTL request to set Tx power. It can be set to either auto
1887 * This function allocates the IOCTL request buffer, fills it
1888 * with requisite parameters and calls the IOCTL handler.
1891 mwifiex_set_tx_power(struct mwifiex_private *priv, int type, int dbm)
1893 struct mwifiex_power_cfg power_cfg;
1894 struct mwifiex_wait_queue *wait = NULL;
1898 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
1902 if (type == NL80211_TX_POWER_FIXED) {
1903 power_cfg.is_power_auto = 0;
1904 power_cfg.power_level = dbm;
1906 power_cfg.is_power_auto = 1;
1908 status = mwifiex_power_ioctl_set_power(priv, wait, &power_cfg);
1910 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT);
1917 * Sends IOCTL request to get scan table.
1919 * This function allocates the IOCTL request buffer, fills it
1920 * with requisite parameters and calls the IOCTL handler.
1922 int mwifiex_get_scan_table(struct mwifiex_private *priv, u8 wait_option,
1923 struct mwifiex_scan_resp *scan_resp)
1925 struct mwifiex_wait_queue *wait = NULL;
1926 struct mwifiex_scan_resp scan;
1929 /* Allocate wait buffer */
1930 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1934 status = mwifiex_scan_networks(priv, wait, HostCmd_ACT_GEN_GET,
1937 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
1940 memcpy(scan_resp, &scan,
1941 sizeof(struct mwifiex_scan_resp));
1944 if (wait && (status != -EINPROGRESS))
1950 * Sends IOCTL request to get signal information.
1952 * This function allocates the IOCTL request buffer, fills it
1953 * with requisite parameters and calls the IOCTL handler.
1955 int mwifiex_get_signal_info(struct mwifiex_private *priv, u8 wait_option,
1956 struct mwifiex_ds_get_signal *signal)
1958 struct mwifiex_ds_get_signal info;
1959 struct mwifiex_wait_queue *wait = NULL;
1962 /* Allocate wait buffer */
1963 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1967 info.selector = ALL_RSSI_INFO_MASK;
1969 status = mwifiex_get_info_signal(priv, wait, &info);
1971 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
1974 memcpy(signal, &info,
1975 sizeof(struct mwifiex_ds_get_signal));
1976 if (info.selector & BCN_RSSI_AVG_MASK)
1977 priv->w_stats.qual.level = info.bcn_rssi_avg;
1978 if (info.selector & BCN_NF_AVG_MASK)
1979 priv->w_stats.qual.noise = info.bcn_nf_avg;
1982 if (wait && (status != -EINPROGRESS))
1988 * Sends IOCTL request to set encoding parameters.
1990 * This function allocates the IOCTL request buffer, fills it
1991 * with requisite parameters and calls the IOCTL handler.
1993 int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
1994 int key_len, u8 key_index, int disable)
1996 struct mwifiex_wait_queue *wait = NULL;
1997 struct mwifiex_ds_encrypt_key encrypt_key;
2001 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
2005 memset(&encrypt_key, 0, sizeof(struct mwifiex_ds_encrypt_key));
2006 encrypt_key.key_len = key_len;
2008 encrypt_key.key_index = key_index;
2010 memcpy(encrypt_key.key_material, key, key_len);
2012 encrypt_key.key_disable = true;
2015 status = mwifiex_sec_ioctl_encrypt_key(priv, wait, &encrypt_key);
2017 if (mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT))
2025 * Sends IOCTL request to set power management parameters.
2027 * This function allocates the IOCTL request buffer, fills it
2028 * with requisite parameters and calls the IOCTL handler.
2031 mwifiex_drv_set_power(struct mwifiex_private *priv, bool power_on)
2035 struct mwifiex_wait_queue *wait = NULL;
2038 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
2043 status = mwifiex_pm_ioctl_ps_mode(priv, wait, &ps_mode,
2044 HostCmd_ACT_GEN_SET);
2046 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT);
2053 * Sends IOCTL request to get extended version.
2055 * This function allocates the IOCTL request buffer, fills it
2056 * with requisite parameters and calls the IOCTL handler.
2059 mwifiex_get_ver_ext(struct mwifiex_private *priv)
2061 struct mwifiex_ver_ext ver_ext;
2062 struct mwifiex_wait_queue *wait = NULL;
2065 u8 wait_option = MWIFIEX_IOCTL_WAIT;
2067 /* Allocate wait buffer */
2068 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
2072 /* get fw version */
2073 memset(&ver_ext, 0, sizeof(struct host_cmd_ds_version_ext));
2074 status = mwifiex_get_info_ver_ext(priv, wait, &ver_ext);
2076 ret = mwifiex_request_ioctl(priv, wait, status, wait_option);
2086 * Sends IOCTL request to get statistics information.
2088 * This function allocates the IOCTL request buffer, fills it
2089 * with requisite parameters and calls the IOCTL handler.
2092 mwifiex_get_stats_info(struct mwifiex_private *priv,
2093 struct mwifiex_ds_get_stats *log)
2097 struct mwifiex_wait_queue *wait = NULL;
2098 struct mwifiex_ds_get_stats get_log;
2099 u8 wait_option = MWIFIEX_IOCTL_WAIT;
2101 /* Allocate wait buffer */
2102 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
2106 memset(&get_log, 0, sizeof(struct mwifiex_ds_get_stats));
2107 status = mwifiex_get_info_stats(priv, wait, &get_log);
2109 /* Send IOCTL request to MWIFIEX */
2110 ret = mwifiex_request_ioctl(priv, wait, status, wait_option);
2113 memcpy(log, &get_log, sizeof(struct
2114 mwifiex_ds_get_stats));
2115 priv->w_stats.discard.fragment = get_log.fcs_error;
2116 priv->w_stats.discard.retries = get_log.retry;
2117 priv->w_stats.discard.misc = get_log.ack_failure;
2125 * IOCTL request handler to read/write register.
2127 * This function prepares the correct firmware command and
2130 * Access to the following registers are supported -
2137 static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private *priv,
2138 struct mwifiex_wait_queue *wait,
2139 struct mwifiex_ds_reg_rw *reg_rw,
2145 switch (le32_to_cpu(reg_rw->type)) {
2146 case MWIFIEX_REG_MAC:
2147 cmd_no = HostCmd_CMD_MAC_REG_ACCESS;
2149 case MWIFIEX_REG_BBP:
2150 cmd_no = HostCmd_CMD_BBP_REG_ACCESS;
2152 case MWIFIEX_REG_RF:
2153 cmd_no = HostCmd_CMD_RF_REG_ACCESS;
2155 case MWIFIEX_REG_PMIC:
2156 cmd_no = HostCmd_CMD_PMIC_REG_ACCESS;
2158 case MWIFIEX_REG_CAU:
2159 cmd_no = HostCmd_CMD_CAU_REG_ACCESS;
2165 /* Send request to firmware */
2166 ret = mwifiex_prepare_cmd(priv, cmd_no, action, 0, wait, reg_rw);
2175 * Sends IOCTL request to write to a register.
2177 * This function allocates the IOCTL request buffer, fills it
2178 * with requisite parameters and calls the IOCTL handler.
2181 mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
2182 u32 reg_offset, u32 reg_value)
2186 struct mwifiex_wait_queue *wait = NULL;
2187 struct mwifiex_ds_reg_rw reg_rw;
2189 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
2193 reg_rw.type = cpu_to_le32(reg_type);
2194 reg_rw.offset = cpu_to_le32(reg_offset);
2195 reg_rw.value = cpu_to_le32(reg_value);
2196 status = mwifiex_reg_mem_ioctl_reg_rw(priv, wait, ®_rw,
2197 HostCmd_ACT_GEN_SET);
2199 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT);
2206 * Sends IOCTL request to read from a register.
2208 * This function allocates the IOCTL request buffer, fills it
2209 * with requisite parameters and calls the IOCTL handler.
2212 mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
2213 u32 reg_offset, u32 *value)
2217 struct mwifiex_wait_queue *wait = NULL;
2218 struct mwifiex_ds_reg_rw reg_rw;
2220 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
2224 reg_rw.type = cpu_to_le32(reg_type);
2225 reg_rw.offset = cpu_to_le32(reg_offset);
2226 status = mwifiex_reg_mem_ioctl_reg_rw(priv, wait, ®_rw,
2227 HostCmd_ACT_GEN_GET);
2229 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT);
2233 *value = le32_to_cpu(reg_rw.value);
2241 * IOCTL request handler to read EEPROM.
2243 * This function prepares the correct firmware command and
2247 mwifiex_reg_mem_ioctl_read_eeprom(struct mwifiex_private *priv,
2248 struct mwifiex_wait_queue *wait,
2249 struct mwifiex_ds_read_eeprom *rd_eeprom)
2253 /* Send request to firmware */
2254 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_EEPROM_ACCESS,
2255 HostCmd_ACT_GEN_GET, 0, wait, rd_eeprom);
2264 * Sends IOCTL request to read from EEPROM.
2266 * This function allocates the IOCTL request buffer, fills it
2267 * with requisite parameters and calls the IOCTL handler.
2270 mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
2275 struct mwifiex_wait_queue *wait = NULL;
2276 struct mwifiex_ds_read_eeprom rd_eeprom;
2278 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
2282 rd_eeprom.offset = cpu_to_le16((u16) offset);
2283 rd_eeprom.byte_count = cpu_to_le16((u16) bytes);
2284 status = mwifiex_reg_mem_ioctl_read_eeprom(priv, wait, &rd_eeprom);
2286 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT);
2290 memcpy(value, rd_eeprom.value, MAX_EEPROM_DATA);
2297 * This function sets a generic IE. In addition to generic IE, it can
2298 * also handle WPA, WPA2 and WAPI IEs.
2301 mwifiex_set_gen_ie_helper(struct mwifiex_private *priv, u8 *ie_data_ptr,
2305 struct ieee_types_vendor_header *pvendor_ie;
2306 const u8 wpa_oui[] = { 0x00, 0x50, 0xf2, 0x01 };
2307 const u8 wps_oui[] = { 0x00, 0x50, 0xf2, 0x04 };
2309 /* If the passed length is zero, reset the buffer */
2311 priv->gen_ie_buf_len = 0;
2312 priv->wps.session_enable = false;
2315 } else if (!ie_data_ptr) {
2318 pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr;
2319 /* Test to see if it is a WPA IE, if not, then it is a gen IE */
2320 if (((pvendor_ie->element_id == WLAN_EID_WPA)
2321 && (!memcmp(pvendor_ie->oui, wpa_oui, sizeof(wpa_oui))))
2322 || (pvendor_ie->element_id == WLAN_EID_RSN)) {
2324 /* IE is a WPA/WPA2 IE so call set_wpa function */
2325 ret = mwifiex_set_wpa_ie_helper(priv, ie_data_ptr, ie_len);
2326 priv->wps.session_enable = false;
2329 } else if (pvendor_ie->element_id == WLAN_EID_BSS_AC_ACCESS_DELAY) {
2330 /* IE is a WAPI IE so call set_wapi function */
2331 ret = mwifiex_set_wapi_ie(priv, ie_data_ptr, ie_len);
2336 * Verify that the passed length is not larger than the
2337 * available space remaining in the buffer
2339 if (ie_len < (sizeof(priv->gen_ie_buf) - priv->gen_ie_buf_len)) {
2341 /* Test to see if it is a WPS IE, if so, enable
2344 pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr;
2345 if ((pvendor_ie->element_id == WLAN_EID_VENDOR_SPECIFIC)
2346 && (!memcmp(pvendor_ie->oui, wps_oui,
2347 sizeof(wps_oui)))) {
2348 priv->wps.session_enable = true;
2349 dev_dbg(priv->adapter->dev,
2350 "info: WPS Session Enabled.\n");
2353 /* Append the passed data to the end of the
2355 memcpy(priv->gen_ie_buf + priv->gen_ie_buf_len, ie_data_ptr,
2357 /* Increment the stored buffer length by the
2359 priv->gen_ie_buf_len += ie_len;
2361 /* Passed data does not fit in the remaining
2366 /* Return 0, or -1 for error case */
2371 * IOCTL request handler to set/get generic IE.
2373 * In addition to various generic IEs, this function can also be
2374 * used to set the ARP filter.
2376 static int mwifiex_misc_ioctl_gen_ie(struct mwifiex_private *priv,
2377 struct mwifiex_ds_misc_gen_ie *gen_ie,
2380 struct mwifiex_adapter *adapter = priv->adapter;
2382 switch (gen_ie->type) {
2383 case MWIFIEX_IE_TYPE_GEN_IE:
2384 if (action == HostCmd_ACT_GEN_GET) {
2385 gen_ie->len = priv->wpa_ie_len;
2386 memcpy(gen_ie->ie_data, priv->wpa_ie, gen_ie->len);
2388 mwifiex_set_gen_ie_helper(priv, gen_ie->ie_data,
2392 case MWIFIEX_IE_TYPE_ARP_FILTER:
2393 memset(adapter->arp_filter, 0, sizeof(adapter->arp_filter));
2394 if (gen_ie->len > ARP_FILTER_MAX_BUF_SIZE) {
2395 adapter->arp_filter_size = 0;
2396 dev_err(adapter->dev, "invalid ARP filter size\n");
2399 memcpy(adapter->arp_filter, gen_ie->ie_data,
2401 adapter->arp_filter_size = gen_ie->len;
2405 dev_err(adapter->dev, "invalid IE type\n");
2412 * Sends IOCTL request to set a generic IE.
2414 * This function allocates the IOCTL request buffer, fills it
2415 * with requisite parameters and calls the IOCTL handler.
2418 mwifiex_set_gen_ie(struct mwifiex_private *priv, u8 *ie, int ie_len)
2420 struct mwifiex_ds_misc_gen_ie gen_ie;
2423 if (ie_len > IW_CUSTOM_MAX)
2426 gen_ie.type = MWIFIEX_IE_TYPE_GEN_IE;
2427 gen_ie.len = ie_len;
2428 memcpy(gen_ie.ie_data, ie, ie_len);
2429 status = mwifiex_misc_ioctl_gen_ie(priv, &gen_ie, HostCmd_ACT_GEN_SET);