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
36 int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
37 struct net_device *dev)
40 struct netdev_hw_addr *ha;
42 netdev_for_each_mc_addr(ha, dev)
43 memcpy(&mlist->mac_list[i++], ha->addr, ETH_ALEN);
49 * Wait queue completion handler.
51 * This function waits on a cmd wait queue. It also cancels the pending
52 * request after waking up, in case of errors.
54 int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter)
56 bool cancel_flag = false;
57 int status = adapter->cmd_wait_q.status;
59 dev_dbg(adapter->dev, "cmd pending\n");
60 atomic_inc(&adapter->cmd_pending);
62 /* Status pending, wake up main process */
63 queue_work(adapter->workqueue, &adapter->main_work);
65 /* Wait for completion */
66 wait_event_interruptible(adapter->cmd_wait_q.wait,
67 adapter->cmd_wait_q.condition);
68 if (!adapter->cmd_wait_q.condition)
72 mwifiex_cancel_pending_ioctl(adapter);
73 dev_dbg(adapter->dev, "cmd cancel\n");
75 adapter->cmd_wait_q.status = 0;
81 * This function prepares the correct firmware command and
82 * issues it to set the multicast list.
84 * This function can be used to enable promiscuous mode, or enable all
85 * multicast packets, or to enable selective multicast.
87 int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
88 struct mwifiex_multicast_list *mcast_list)
93 old_pkt_filter = priv->curr_pkt_filter;
95 if (mcast_list->mode == MWIFIEX_PROMISC_MODE) {
96 dev_dbg(priv->adapter->dev, "info: Enable Promiscuous mode\n");
97 priv->curr_pkt_filter |= HostCmd_ACT_MAC_PROMISCUOUS_ENABLE;
98 priv->curr_pkt_filter &=
99 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
102 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_PROMISCUOUS_ENABLE;
103 if (mcast_list->mode == MWIFIEX_MULTICAST_MODE) {
104 dev_dbg(priv->adapter->dev,
105 "info: Enabling All Multicast!\n");
106 priv->curr_pkt_filter |=
107 HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
109 priv->curr_pkt_filter &=
110 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
111 if (mcast_list->num_multicast_addr) {
112 dev_dbg(priv->adapter->dev,
113 "info: Set multicast list=%d\n",
114 mcast_list->num_multicast_addr);
115 /* Set multicast addresses to firmware */
116 if (old_pkt_filter == priv->curr_pkt_filter) {
117 /* Send request to firmware */
118 ret = mwifiex_send_cmd_async(priv,
119 HostCmd_CMD_MAC_MULTICAST_ADR,
120 HostCmd_ACT_GEN_SET, 0,
123 /* Send request to firmware */
124 ret = mwifiex_send_cmd_async(priv,
125 HostCmd_CMD_MAC_MULTICAST_ADR,
126 HostCmd_ACT_GEN_SET, 0,
132 dev_dbg(priv->adapter->dev,
133 "info: old_pkt_filter=%#x, curr_pkt_filter=%#x\n",
134 old_pkt_filter, priv->curr_pkt_filter);
135 if (old_pkt_filter != priv->curr_pkt_filter) {
136 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL,
138 0, &priv->curr_pkt_filter);
145 * This function fills bss descriptor structure using provided
148 int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
149 u8 *bssid, s32 rssi, u8 *ie_buf,
150 size_t ie_len, u16 beacon_period,
151 u16 cap_info_bitmap, u8 band,
152 struct mwifiex_bssdescriptor *bss_desc)
156 memcpy(bss_desc->mac_address, bssid, ETH_ALEN);
157 bss_desc->rssi = rssi;
158 bss_desc->beacon_buf = ie_buf;
159 bss_desc->beacon_buf_size = ie_len;
160 bss_desc->beacon_period = beacon_period;
161 bss_desc->cap_info_bitmap = cap_info_bitmap;
162 bss_desc->bss_band = band;
163 if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_PRIVACY) {
164 dev_dbg(priv->adapter->dev, "info: InterpretIE: AP WEP enabled\n");
165 bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_8021X_WEP;
167 bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL;
169 if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_IBSS)
170 bss_desc->bss_mode = NL80211_IFTYPE_ADHOC;
172 bss_desc->bss_mode = NL80211_IFTYPE_STATION;
174 ret = mwifiex_update_bss_desc_with_ie(priv->adapter, bss_desc,
181 * In Ad-Hoc mode, the IBSS is created if not found in scan list.
182 * In both Ad-Hoc and infra mode, an deauthentication is performed
185 int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
186 struct mwifiex_802_11_ssid *req_ssid)
189 struct mwifiex_adapter *adapter = priv->adapter;
190 struct mwifiex_bssdescriptor *bss_desc = NULL;
191 u8 *beacon_ie = NULL;
193 priv->scan_block = false;
196 /* Allocate and fill new bss descriptor */
197 bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor),
200 dev_err(priv->adapter->dev, " failed to alloc bss_desc\n");
204 beacon_ie = kmemdup(bss->information_elements,
205 bss->len_beacon_ies, GFP_KERNEL);
208 dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n");
212 ret = mwifiex_fill_new_bss_desc(priv, bss->bssid, bss->signal,
213 beacon_ie, bss->len_beacon_ies,
214 bss->beacon_interval,
216 *(u8 *)bss->priv, bss_desc);
221 if (priv->bss_mode == NL80211_IFTYPE_STATION) {
223 ret = mwifiex_deauthenticate(priv, NULL);
227 ret = mwifiex_check_network_compatibility(priv, bss_desc);
231 dev_dbg(adapter->dev, "info: SSID found in scan list ... "
234 if (!netif_queue_stopped(priv->netdev))
235 netif_stop_queue(priv->netdev);
237 /* Clear any past association response stored for
238 * application retrieval */
239 priv->assoc_rsp_size = 0;
240 ret = mwifiex_associate(priv, bss_desc);
242 cfg80211_put_bss(bss);
245 /* If the requested SSID matches current SSID, return */
246 if (bss_desc && bss_desc->ssid.ssid_len &&
248 (&priv->curr_bss_params.bss_descriptor.ssid,
255 /* Exit Adhoc mode first */
256 dev_dbg(adapter->dev, "info: Sending Adhoc Stop\n");
257 ret = mwifiex_deauthenticate(priv, NULL);
261 priv->adhoc_is_link_sensed = false;
263 ret = mwifiex_check_network_compatibility(priv, bss_desc);
265 if (!netif_queue_stopped(priv->netdev))
266 netif_stop_queue(priv->netdev);
269 dev_dbg(adapter->dev, "info: network found in scan"
270 " list. Joining...\n");
271 ret = mwifiex_adhoc_join(priv, bss_desc);
273 cfg80211_put_bss(bss);
275 dev_dbg(adapter->dev, "info: Network not found in "
276 "the list, creating adhoc with ssid = %s\n",
278 ret = mwifiex_adhoc_start(priv, req_ssid);
289 * IOCTL request handler to set host sleep configuration.
291 * This function prepares the correct firmware command and
294 int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
295 int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg)
298 struct mwifiex_adapter *adapter = priv->adapter;
306 case HostCmd_ACT_GEN_SET:
307 if (adapter->pps_uapsd_mode) {
308 dev_dbg(adapter->dev, "info: Host Sleep IOCTL"
309 " is blocked in UAPSD/PPS mode\n");
313 if (hs_cfg->is_invoke_hostcmd) {
314 if (hs_cfg->conditions == HOST_SLEEP_CFG_CANCEL) {
315 if (!adapter->is_hs_configured)
316 /* Already cancelled */
318 /* Save previous condition */
319 prev_cond = le32_to_cpu(adapter->hs_cfg
321 adapter->hs_cfg.conditions =
322 cpu_to_le32(hs_cfg->conditions);
323 } else if (hs_cfg->conditions) {
324 adapter->hs_cfg.conditions =
325 cpu_to_le32(hs_cfg->conditions);
326 adapter->hs_cfg.gpio = (u8)hs_cfg->gpio;
328 adapter->hs_cfg.gap = (u8)hs_cfg->gap;
329 } else if (adapter->hs_cfg.conditions ==
331 HOST_SLEEP_CFG_CANCEL)) {
332 /* Return failure if no parameters for HS
337 if (cmd_type == MWIFIEX_SYNC_CMD)
338 status = mwifiex_send_cmd_sync(priv,
339 HostCmd_CMD_802_11_HS_CFG_ENH,
340 HostCmd_ACT_GEN_SET, 0,
343 status = mwifiex_send_cmd_async(priv,
344 HostCmd_CMD_802_11_HS_CFG_ENH,
345 HostCmd_ACT_GEN_SET, 0,
347 if (hs_cfg->conditions == HOST_SLEEP_CFG_CANCEL)
348 /* Restore previous condition */
349 adapter->hs_cfg.conditions =
350 cpu_to_le32(prev_cond);
352 adapter->hs_cfg.conditions =
353 cpu_to_le32(hs_cfg->conditions);
354 adapter->hs_cfg.gpio = (u8)hs_cfg->gpio;
355 adapter->hs_cfg.gap = (u8)hs_cfg->gap;
358 case HostCmd_ACT_GEN_GET:
359 hs_cfg->conditions = le32_to_cpu(adapter->hs_cfg.conditions);
360 hs_cfg->gpio = adapter->hs_cfg.gpio;
361 hs_cfg->gap = adapter->hs_cfg.gap;
372 * Sends IOCTL request to cancel the existing Host Sleep configuration.
374 * This function allocates the IOCTL request buffer, fills it
375 * with requisite parameters and calls the IOCTL handler.
377 int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type)
379 struct mwifiex_ds_hs_cfg hscfg;
381 hscfg.conditions = HOST_SLEEP_CFG_CANCEL;
382 hscfg.is_invoke_hostcmd = true;
384 return mwifiex_set_hs_params(priv, HostCmd_ACT_GEN_SET,
387 EXPORT_SYMBOL_GPL(mwifiex_cancel_hs);
390 * Sends IOCTL request to cancel the existing Host Sleep configuration.
392 * This function allocates the IOCTL request buffer, fills it
393 * with requisite parameters and calls the IOCTL handler.
395 int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
397 struct mwifiex_ds_hs_cfg hscfg;
399 if (adapter->hs_activated) {
400 dev_dbg(adapter->dev, "cmd: HS Already actived\n");
404 adapter->hs_activate_wait_q_woken = false;
406 memset(&hscfg, 0, sizeof(struct mwifiex_hs_config_param));
407 hscfg.is_invoke_hostcmd = true;
409 if (mwifiex_set_hs_params(mwifiex_get_priv(adapter,
410 MWIFIEX_BSS_ROLE_STA),
411 HostCmd_ACT_GEN_SET, MWIFIEX_SYNC_CMD,
413 dev_err(adapter->dev, "IOCTL request HS enable failed\n");
417 wait_event_interruptible(adapter->hs_activate_wait_q,
418 adapter->hs_activate_wait_q_woken);
422 EXPORT_SYMBOL_GPL(mwifiex_enable_hs);
425 * IOCTL request handler to get BSS information.
427 * This function collates the information from different driver structures
428 * to send to the user.
430 int mwifiex_get_bss_info(struct mwifiex_private *priv,
431 struct mwifiex_bss_info *info)
433 struct mwifiex_adapter *adapter = priv->adapter;
434 struct mwifiex_bssdescriptor *bss_desc;
439 bss_desc = &priv->curr_bss_params.bss_descriptor;
441 info->bss_mode = priv->bss_mode;
443 memcpy(&info->ssid, &bss_desc->ssid,
444 sizeof(struct mwifiex_802_11_ssid));
446 memcpy(&info->bssid, &bss_desc->mac_address, ETH_ALEN);
448 info->bss_chan = bss_desc->channel;
450 info->region_code = adapter->region_code;
452 info->media_connected = priv->media_connected;
454 info->max_power_level = priv->max_tx_power_level;
455 info->min_power_level = priv->min_tx_power_level;
457 info->adhoc_state = priv->adhoc_state;
459 info->bcn_nf_last = priv->bcn_nf_last;
461 if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED)
462 info->wep_status = true;
464 info->wep_status = false;
466 info->is_hs_configured = adapter->is_hs_configured;
467 info->is_deep_sleep = adapter->is_deep_sleep;
473 * The function sets band configurations.
475 * it performs extra checks to make sure the Ad-Hoc
476 * band and channel are compatible. Otherwise it returns an error.
479 int mwifiex_set_radio_band_cfg(struct mwifiex_private *priv,
480 struct mwifiex_ds_band_cfg *radio_cfg)
482 struct mwifiex_adapter *adapter = priv->adapter;
483 u8 infra_band, adhoc_band;
486 infra_band = (u8) radio_cfg->config_bands;
487 adhoc_band = (u8) radio_cfg->adhoc_start_band;
488 adhoc_channel = radio_cfg->adhoc_channel;
491 if ((infra_band | adapter->fw_bands) & ~adapter->fw_bands)
494 adapter->config_bands = infra_band;
496 /* SET Ad-hoc Band */
497 if ((adhoc_band | adapter->fw_bands) & ~adapter->fw_bands)
501 adapter->adhoc_start_band = adhoc_band;
502 adapter->chan_offset = (u8) radio_cfg->sec_chan_offset;
504 * If no adhoc_channel is supplied verify if the existing adhoc
505 * channel compiles with new adhoc_band
507 if (!adhoc_channel) {
508 if (!mwifiex_get_cfp_by_band_and_channel_from_cfg80211
509 (priv, adapter->adhoc_start_band,
510 priv->adhoc_channel)) {
511 /* Pass back the default channel */
512 radio_cfg->adhoc_channel = DEFAULT_AD_HOC_CHANNEL;
513 if ((adapter->adhoc_start_band & BAND_A)
514 || (adapter->adhoc_start_band & BAND_AN))
515 radio_cfg->adhoc_channel =
516 DEFAULT_AD_HOC_CHANNEL_A;
518 } else { /* Retrurn error if adhoc_band and
519 adhoc_channel combination is invalid */
520 if (!mwifiex_get_cfp_by_band_and_channel_from_cfg80211
521 (priv, adapter->adhoc_start_band, (u16) adhoc_channel))
523 priv->adhoc_channel = (u8) adhoc_channel;
525 if ((adhoc_band & BAND_GN) || (adhoc_band & BAND_AN))
526 adapter->adhoc_11n_enabled = true;
528 adapter->adhoc_11n_enabled = false;
534 * The function disables auto deep sleep mode.
536 int mwifiex_disable_auto_ds(struct mwifiex_private *priv)
538 struct mwifiex_ds_auto_ds auto_ds;
540 auto_ds.auto_ds = DEEP_SLEEP_OFF;
542 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
543 DIS_AUTO_PS, BITMAP_AUTO_DS, &auto_ds);
545 EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds);
548 * IOCTL request handler to set/get active channel.
550 * This function performs validity checking on channel/frequency
551 * compatibility and returns failure if not valid.
553 int mwifiex_bss_set_channel(struct mwifiex_private *priv,
554 struct mwifiex_chan_freq_power *chan)
556 struct mwifiex_adapter *adapter = priv->adapter;
557 struct mwifiex_chan_freq_power *cfp = NULL;
562 if (!chan->channel && !chan->freq)
564 if (adapter->adhoc_start_band & BAND_AN)
565 adapter->adhoc_start_band = BAND_G | BAND_B | BAND_GN;
566 else if (adapter->adhoc_start_band & BAND_A)
567 adapter->adhoc_start_band = BAND_G | BAND_B;
569 if (chan->channel <= MAX_CHANNEL_BAND_BG)
570 cfp = mwifiex_get_cfp_by_band_and_channel_from_cfg80211
571 (priv, 0, (u16) chan->channel);
573 cfp = mwifiex_get_cfp_by_band_and_channel_from_cfg80211
574 (priv, BAND_A, (u16) chan->channel);
576 if (adapter->adhoc_11n_enabled)
577 adapter->adhoc_start_band = BAND_A
580 adapter->adhoc_start_band = BAND_A;
584 if (chan->freq <= MAX_FREQUENCY_BAND_BG)
585 cfp = mwifiex_get_cfp_by_band_and_freq_from_cfg80211(
586 priv, 0, chan->freq);
588 cfp = mwifiex_get_cfp_by_band_and_freq_from_cfg80211
589 (priv, BAND_A, chan->freq);
591 if (adapter->adhoc_11n_enabled)
592 adapter->adhoc_start_band = BAND_A
595 adapter->adhoc_start_band = BAND_A;
599 if (!cfp || !cfp->channel) {
600 dev_err(adapter->dev, "invalid channel/freq\n");
603 priv->adhoc_channel = (u8) cfp->channel;
604 chan->channel = cfp->channel;
605 chan->freq = cfp->freq;
611 * IOCTL request handler to set/get Ad-Hoc channel.
613 * This function prepares the correct firmware command and
614 * issues it to set or get the ad-hoc channel.
616 static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv,
617 u16 action, u16 *channel)
619 if (action == HostCmd_ACT_GEN_GET) {
620 if (!priv->media_connected) {
621 *channel = priv->adhoc_channel;
625 priv->adhoc_channel = (u8) *channel;
628 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_RF_CHANNEL,
633 * IOCTL request handler to change Ad-Hoc channel.
635 * This function allocates the IOCTL request buffer, fills it
636 * with requisite parameters and calls the IOCTL handler.
638 * The function follows the following steps to perform the change -
639 * - Get current IBSS information
640 * - Get current channel
641 * - If no change is required, return
642 * - If not connected, change channel and return
646 * - Perform specific SSID scan with same SSID
647 * - Start/Join the IBSS
650 mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel)
653 struct mwifiex_bss_info bss_info;
654 struct mwifiex_ssid_bssid ssid_bssid;
656 struct cfg80211_bss *bss = NULL;
657 struct ieee80211_channel *chan;
658 enum ieee80211_band band;
660 memset(&bss_info, 0, sizeof(bss_info));
662 /* Get BSS information */
663 if (mwifiex_get_bss_info(priv, &bss_info))
666 /* Get current channel */
667 ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_GET,
670 if (curr_chan == channel) {
674 dev_dbg(priv->adapter->dev, "cmd: updating channel from %d to %d\n",
677 if (!bss_info.media_connected) {
683 memset(&ssid_bssid, 0, ETH_ALEN);
684 ret = mwifiex_deauthenticate(priv, ssid_bssid.bssid);
686 ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_SET,
689 /* Do specific SSID scanning */
690 if (mwifiex_request_scan(priv, &bss_info.ssid)) {
695 band = mwifiex_band_to_radio_type(priv->curr_bss_params.band);
696 chan = __ieee80211_get_channel(priv->wdev->wiphy,
697 ieee80211_channel_to_frequency(channel, band));
699 /* Find the BSS we want using available scan results */
700 bss = cfg80211_get_bss(priv->wdev->wiphy, chan, bss_info.bssid,
701 bss_info.ssid.ssid, bss_info.ssid.ssid_len,
702 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
704 wiphy_warn(priv->wdev->wiphy, "assoc: bss %pM not in scan results\n",
707 ret = mwifiex_bss_start(priv, bss, &bss_info.ssid);
713 * IOCTL request handler to get rate.
715 * This function prepares the correct firmware command and
716 * issues it to get the current rate if it is connected,
717 * otherwise, the function returns the lowest supported rate
720 static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv,
721 struct mwifiex_rate_cfg *rate_cfg)
723 rate_cfg->is_rate_auto = priv->is_data_rate_auto;
724 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_TX_RATE_QUERY,
725 HostCmd_ACT_GEN_GET, 0, NULL);
729 * IOCTL request handler to set rate.
731 * This function prepares the correct firmware command and
732 * issues it to set the current rate.
734 * The function also performs validation checking on the supplied value.
736 static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv,
737 struct mwifiex_rate_cfg *rate_cfg)
739 u8 rates[MWIFIEX_SUPPORTED_RATES];
742 u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
744 struct mwifiex_adapter *adapter = priv->adapter;
746 if (rate_cfg->is_rate_auto) {
747 memset(bitmap_rates, 0, sizeof(bitmap_rates));
748 /* Support all HR/DSSS rates */
749 bitmap_rates[0] = 0x000F;
750 /* Support all OFDM rates */
751 bitmap_rates[1] = 0x00FF;
752 /* Support all HT-MCSs rate */
753 for (i = 0; i < ARRAY_SIZE(priv->bitmap_rates) - 3; i++)
754 bitmap_rates[i + 2] = 0xFFFF;
755 bitmap_rates[9] = 0x3FFF;
757 memset(rates, 0, sizeof(rates));
758 mwifiex_get_active_data_rates(priv, rates);
760 for (i = 0; (rate[i] && i < MWIFIEX_SUPPORTED_RATES); i++) {
761 dev_dbg(adapter->dev, "info: rate=%#x wanted=%#x\n",
762 rate[i], rate_cfg->rate);
763 if ((rate[i] & 0x7f) == (rate_cfg->rate & 0x7f))
766 if (!rate[i] || (i == MWIFIEX_SUPPORTED_RATES)) {
767 dev_err(adapter->dev, "fixed data rate %#x is out "
768 "of range\n", rate_cfg->rate);
771 memset(bitmap_rates, 0, sizeof(bitmap_rates));
773 rate_index = mwifiex_data_rate_to_index(rate_cfg->rate);
775 /* Only allow b/g rates to be set */
776 if (rate_index >= MWIFIEX_RATE_INDEX_HRDSSS0 &&
777 rate_index <= MWIFIEX_RATE_INDEX_HRDSSS3) {
778 bitmap_rates[0] = 1 << rate_index;
780 rate_index -= 1; /* There is a 0x00 in the table */
781 if (rate_index >= MWIFIEX_RATE_INDEX_OFDM0 &&
782 rate_index <= MWIFIEX_RATE_INDEX_OFDM7)
783 bitmap_rates[1] = 1 << (rate_index -
784 MWIFIEX_RATE_INDEX_OFDM0);
788 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TX_RATE_CFG,
789 HostCmd_ACT_GEN_SET, 0, bitmap_rates);
795 * IOCTL request handler to set/get rate.
797 * This function can be used to set/get either the rate value or the
800 static int mwifiex_rate_ioctl_cfg(struct mwifiex_private *priv,
801 struct mwifiex_rate_cfg *rate_cfg)
808 if (rate_cfg->action == HostCmd_ACT_GEN_GET)
809 status = mwifiex_rate_ioctl_get_rate_value(priv, rate_cfg);
811 status = mwifiex_rate_ioctl_set_rate_value(priv, rate_cfg);
817 * Sends IOCTL request to get the data rate.
819 * This function allocates the IOCTL request buffer, fills it
820 * with requisite parameters and calls the IOCTL handler.
822 int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
823 struct mwifiex_rate_cfg *rate)
827 memset(rate, 0, sizeof(struct mwifiex_rate_cfg));
828 rate->action = HostCmd_ACT_GEN_GET;
829 ret = mwifiex_rate_ioctl_cfg(priv, rate);
832 if (rate->is_rate_auto)
833 rate->rate = mwifiex_index_to_data_rate(priv->tx_rate,
836 rate->rate = priv->data_rate;
845 * IOCTL request handler to set tx power configuration.
847 * This function prepares the correct firmware command and
850 * For non-auto power mode, all the following power groups are set -
851 * - Modulation class HR/DSSS
852 * - Modulation class OFDM
853 * - Modulation class HTBW20
854 * - Modulation class HTBW40
856 int mwifiex_set_tx_power(struct mwifiex_private *priv,
857 struct mwifiex_power_cfg *power_cfg)
860 struct host_cmd_ds_txpwr_cfg *txp_cfg;
861 struct mwifiex_types_power_group *pg_tlv;
862 struct mwifiex_power_group *pg;
866 if (!power_cfg->is_power_auto) {
867 dbm = (u16) power_cfg->power_level;
868 if ((dbm < priv->min_tx_power_level) ||
869 (dbm > priv->max_tx_power_level)) {
870 dev_err(priv->adapter->dev, "txpower value %d dBm"
871 " is out of range (%d dBm-%d dBm)\n",
872 dbm, priv->min_tx_power_level,
873 priv->max_tx_power_level);
877 buf = kzalloc(MWIFIEX_SIZE_OF_CMD_BUFFER, GFP_KERNEL);
879 dev_err(priv->adapter->dev, "%s: failed to alloc cmd buffer\n",
884 txp_cfg = (struct host_cmd_ds_txpwr_cfg *) buf;
885 txp_cfg->action = cpu_to_le16(HostCmd_ACT_GEN_SET);
886 if (!power_cfg->is_power_auto) {
887 txp_cfg->mode = cpu_to_le32(1);
888 pg_tlv = (struct mwifiex_types_power_group *) (buf +
889 sizeof(struct host_cmd_ds_txpwr_cfg));
890 pg_tlv->type = TLV_TYPE_POWER_GROUP;
891 pg_tlv->length = 4 * sizeof(struct mwifiex_power_group);
892 pg = (struct mwifiex_power_group *) (buf +
893 sizeof(struct host_cmd_ds_txpwr_cfg) +
894 sizeof(struct mwifiex_types_power_group));
895 /* Power group for modulation class HR/DSSS */
896 pg->first_rate_code = 0x00;
897 pg->last_rate_code = 0x03;
898 pg->modulation_class = MOD_CLASS_HR_DSSS;
900 pg->power_min = (s8) dbm;
901 pg->power_max = (s8) dbm;
903 /* Power group for modulation class OFDM */
904 pg->first_rate_code = 0x00;
905 pg->last_rate_code = 0x07;
906 pg->modulation_class = MOD_CLASS_OFDM;
908 pg->power_min = (s8) dbm;
909 pg->power_max = (s8) dbm;
911 /* Power group for modulation class HTBW20 */
912 pg->first_rate_code = 0x00;
913 pg->last_rate_code = 0x20;
914 pg->modulation_class = MOD_CLASS_HT;
916 pg->power_min = (s8) dbm;
917 pg->power_max = (s8) dbm;
918 pg->ht_bandwidth = HT_BW_20;
920 /* Power group for modulation class HTBW40 */
921 pg->first_rate_code = 0x00;
922 pg->last_rate_code = 0x20;
923 pg->modulation_class = MOD_CLASS_HT;
925 pg->power_min = (s8) dbm;
926 pg->power_max = (s8) dbm;
927 pg->ht_bandwidth = HT_BW_40;
929 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TXPWR_CFG,
930 HostCmd_ACT_GEN_SET, 0, buf);
937 * IOCTL request handler to get power save mode.
939 * This function prepares the correct firmware command and
942 int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode)
945 struct mwifiex_adapter *adapter = priv->adapter;
949 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
951 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM;
952 sub_cmd = (*ps_mode) ? EN_AUTO_PS : DIS_AUTO_PS;
953 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
954 sub_cmd, BITMAP_STA_PS, NULL);
955 if ((!ret) && (sub_cmd == DIS_AUTO_PS))
956 ret = mwifiex_send_cmd_async(priv,
957 HostCmd_CMD_802_11_PS_MODE_ENH, GET_PS,
964 * IOCTL request handler to set/reset WPA IE.
966 * The supplied WPA IE is treated as a opaque buffer. Only the first field
967 * is checked to determine WPA version. If buffer length is zero, the existing
970 static int mwifiex_set_wpa_ie_helper(struct mwifiex_private *priv,
971 u8 *ie_data_ptr, u16 ie_len)
974 if (ie_len > sizeof(priv->wpa_ie)) {
975 dev_err(priv->adapter->dev,
976 "failed to copy WPA IE, too big\n");
979 memcpy(priv->wpa_ie, ie_data_ptr, ie_len);
980 priv->wpa_ie_len = (u8) ie_len;
981 dev_dbg(priv->adapter->dev, "cmd: Set Wpa_ie_len=%d IE=%#x\n",
982 priv->wpa_ie_len, priv->wpa_ie[0]);
984 if (priv->wpa_ie[0] == WLAN_EID_WPA) {
985 priv->sec_info.wpa_enabled = true;
986 } else if (priv->wpa_ie[0] == WLAN_EID_RSN) {
987 priv->sec_info.wpa2_enabled = true;
989 priv->sec_info.wpa_enabled = false;
990 priv->sec_info.wpa2_enabled = false;
993 memset(priv->wpa_ie, 0, sizeof(priv->wpa_ie));
994 priv->wpa_ie_len = 0;
995 dev_dbg(priv->adapter->dev, "info: reset wpa_ie_len=%d IE=%#x\n",
996 priv->wpa_ie_len, priv->wpa_ie[0]);
997 priv->sec_info.wpa_enabled = false;
998 priv->sec_info.wpa2_enabled = false;
1005 * IOCTL request handler to set/reset WAPI IE.
1007 * The supplied WAPI IE is treated as a opaque buffer. Only the first field
1008 * is checked to internally enable WAPI. If buffer length is zero, the existing
1011 static int mwifiex_set_wapi_ie(struct mwifiex_private *priv,
1012 u8 *ie_data_ptr, u16 ie_len)
1015 if (ie_len > sizeof(priv->wapi_ie)) {
1016 dev_dbg(priv->adapter->dev,
1017 "info: failed to copy WAPI IE, too big\n");
1020 memcpy(priv->wapi_ie, ie_data_ptr, ie_len);
1021 priv->wapi_ie_len = ie_len;
1022 dev_dbg(priv->adapter->dev, "cmd: Set wapi_ie_len=%d IE=%#x\n",
1023 priv->wapi_ie_len, priv->wapi_ie[0]);
1025 if (priv->wapi_ie[0] == WLAN_EID_BSS_AC_ACCESS_DELAY)
1026 priv->sec_info.wapi_enabled = true;
1028 memset(priv->wapi_ie, 0, sizeof(priv->wapi_ie));
1029 priv->wapi_ie_len = ie_len;
1030 dev_dbg(priv->adapter->dev,
1031 "info: Reset wapi_ie_len=%d IE=%#x\n",
1032 priv->wapi_ie_len, priv->wapi_ie[0]);
1033 priv->sec_info.wapi_enabled = false;
1039 * IOCTL request handler to set WAPI key.
1041 * This function prepares the correct firmware command and
1044 static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_private *priv,
1045 struct mwifiex_ds_encrypt_key *encrypt_key)
1048 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1049 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1054 * IOCTL request handler to set WEP network key.
1056 * This function prepares the correct firmware command and
1057 * issues it, after validation checks.
1059 static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
1060 struct mwifiex_ds_encrypt_key *encrypt_key)
1063 struct mwifiex_wep_key *wep_key;
1066 if (priv->wep_key_curr_index >= NUM_WEP_KEYS)
1067 priv->wep_key_curr_index = 0;
1068 wep_key = &priv->wep_key[priv->wep_key_curr_index];
1069 index = encrypt_key->key_index;
1070 if (encrypt_key->key_disable) {
1071 priv->sec_info.wep_status = MWIFIEX_802_11_WEP_DISABLED;
1072 } else if (!encrypt_key->key_len) {
1073 /* Copy the required key as the current key */
1074 wep_key = &priv->wep_key[index];
1075 if (!wep_key->key_length) {
1076 dev_err(priv->adapter->dev,
1077 "key not set, so cannot enable it\n");
1080 priv->wep_key_curr_index = (u16) index;
1081 priv->sec_info.wep_status = MWIFIEX_802_11_WEP_ENABLED;
1083 wep_key = &priv->wep_key[index];
1084 memset(wep_key, 0, sizeof(struct mwifiex_wep_key));
1085 /* Copy the key in the driver */
1086 memcpy(wep_key->key_material,
1087 encrypt_key->key_material,
1088 encrypt_key->key_len);
1089 wep_key->key_index = index;
1090 wep_key->key_length = encrypt_key->key_len;
1091 priv->sec_info.wep_status = MWIFIEX_802_11_WEP_ENABLED;
1093 if (wep_key->key_length) {
1094 /* Send request to firmware */
1095 ret = mwifiex_send_cmd_async(priv,
1096 HostCmd_CMD_802_11_KEY_MATERIAL,
1097 HostCmd_ACT_GEN_SET, 0, NULL);
1101 if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED)
1102 priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE;
1104 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
1106 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_MAC_CONTROL,
1107 HostCmd_ACT_GEN_SET, 0,
1108 &priv->curr_pkt_filter);
1114 * IOCTL request handler to set WPA key.
1116 * This function prepares the correct firmware command and
1117 * issues it, after validation checks.
1119 * Current driver only supports key length of up to 32 bytes.
1121 * This function can also be used to disable a currently set key.
1123 static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_private *priv,
1124 struct mwifiex_ds_encrypt_key *encrypt_key)
1127 u8 remove_key = false;
1128 struct host_cmd_ds_802_11_key_material *ibss_key;
1130 /* Current driver only supports key length of up to 32 bytes */
1131 if (encrypt_key->key_len > WLAN_MAX_KEY_LEN) {
1132 dev_err(priv->adapter->dev, "key length too long\n");
1136 if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
1138 * IBSS/WPA-None uses only one key (Group) for both receiving
1139 * and sending unicast and multicast packets.
1141 /* Send the key as PTK to firmware */
1142 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1143 ret = mwifiex_send_cmd_async(priv,
1144 HostCmd_CMD_802_11_KEY_MATERIAL,
1145 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1150 ibss_key = &priv->aes_key;
1152 sizeof(struct host_cmd_ds_802_11_key_material));
1153 /* Copy the key in the driver */
1154 memcpy(ibss_key->key_param_set.key, encrypt_key->key_material,
1155 encrypt_key->key_len);
1156 memcpy(&ibss_key->key_param_set.key_len, &encrypt_key->key_len,
1157 sizeof(ibss_key->key_param_set.key_len));
1158 ibss_key->key_param_set.key_type_id
1159 = cpu_to_le16(KEY_TYPE_ID_TKIP);
1160 ibss_key->key_param_set.key_info = cpu_to_le16(KEY_ENABLED);
1162 /* Send the key as GTK to firmware */
1163 encrypt_key->key_index = ~MWIFIEX_KEY_INDEX_UNICAST;
1166 if (!encrypt_key->key_index)
1167 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1170 ret = mwifiex_send_cmd_sync(priv,
1171 HostCmd_CMD_802_11_KEY_MATERIAL,
1172 HostCmd_ACT_GEN_SET, !(KEY_INFO_ENABLED),
1175 ret = mwifiex_send_cmd_sync(priv,
1176 HostCmd_CMD_802_11_KEY_MATERIAL,
1177 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1184 * IOCTL request handler to set/get network keys.
1186 * This is a generic key handling function which supports WEP, WPA
1190 mwifiex_sec_ioctl_encrypt_key(struct mwifiex_private *priv,
1191 struct mwifiex_ds_encrypt_key *encrypt_key)
1195 if (encrypt_key->is_wapi_key)
1196 status = mwifiex_sec_ioctl_set_wapi_key(priv, encrypt_key);
1197 else if (encrypt_key->key_len > WLAN_KEY_LEN_WEP104)
1198 status = mwifiex_sec_ioctl_set_wpa_key(priv, encrypt_key);
1200 status = mwifiex_sec_ioctl_set_wep_key(priv, encrypt_key);
1205 * This function returns the driver version.
1208 mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, char *version,
1217 ver.l = adapter->fw_release_number;
1218 sprintf(fw_ver, "%u.%u.%u.p%u", ver.c[2], ver.c[1], ver.c[0], ver.c[3]);
1220 snprintf(version, max_len, driver_version, fw_ver);
1222 dev_dbg(adapter->dev, "info: MWIFIEX VERSION: %s\n", version);
1228 * Sends IOCTL request to get signal information.
1230 * This function allocates the IOCTL request buffer, fills it
1231 * with requisite parameters and calls the IOCTL handler.
1233 int mwifiex_get_signal_info(struct mwifiex_private *priv,
1234 struct mwifiex_ds_get_signal *signal)
1238 signal->selector = ALL_RSSI_INFO_MASK;
1240 /* Signal info can be obtained only if connected */
1241 if (!priv->media_connected) {
1242 dev_dbg(priv->adapter->dev,
1243 "info: Can not get signal in disconnected state\n");
1247 status = mwifiex_send_cmd_sync(priv, HostCmd_CMD_RSSI_INFO,
1248 HostCmd_ACT_GEN_GET, 0, signal);
1251 if (signal->selector & BCN_RSSI_AVG_MASK)
1252 priv->qual_level = signal->bcn_rssi_avg;
1253 if (signal->selector & BCN_NF_AVG_MASK)
1254 priv->qual_noise = signal->bcn_nf_avg;
1261 * Sends IOCTL request to set encoding parameters.
1263 * This function allocates the IOCTL request buffer, fills it
1264 * with requisite parameters and calls the IOCTL handler.
1266 int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
1267 int key_len, u8 key_index, int disable)
1269 struct mwifiex_ds_encrypt_key encrypt_key;
1271 memset(&encrypt_key, 0, sizeof(struct mwifiex_ds_encrypt_key));
1272 encrypt_key.key_len = key_len;
1274 encrypt_key.key_index = key_index;
1276 memcpy(encrypt_key.key_material, key, key_len);
1278 encrypt_key.key_disable = true;
1281 return mwifiex_sec_ioctl_encrypt_key(priv, &encrypt_key);
1285 * Sends IOCTL request to get extended version.
1287 * This function allocates the IOCTL request buffer, fills it
1288 * with requisite parameters and calls the IOCTL handler.
1291 mwifiex_get_ver_ext(struct mwifiex_private *priv)
1293 struct mwifiex_ver_ext ver_ext;
1295 memset(&ver_ext, 0, sizeof(struct host_cmd_ds_version_ext));
1296 if (mwifiex_send_cmd_sync(priv, HostCmd_CMD_VERSION_EXT,
1297 HostCmd_ACT_GEN_GET, 0, &ver_ext))
1304 * Sends IOCTL request to get statistics information.
1306 * This function allocates the IOCTL request buffer, fills it
1307 * with requisite parameters and calls the IOCTL handler.
1310 mwifiex_get_stats_info(struct mwifiex_private *priv,
1311 struct mwifiex_ds_get_stats *log)
1313 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_GET_LOG,
1314 HostCmd_ACT_GEN_GET, 0, log);
1318 * IOCTL request handler to read/write register.
1320 * This function prepares the correct firmware command and
1323 * Access to the following registers are supported -
1330 static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private *priv,
1331 struct mwifiex_ds_reg_rw *reg_rw,
1336 switch (le32_to_cpu(reg_rw->type)) {
1337 case MWIFIEX_REG_MAC:
1338 cmd_no = HostCmd_CMD_MAC_REG_ACCESS;
1340 case MWIFIEX_REG_BBP:
1341 cmd_no = HostCmd_CMD_BBP_REG_ACCESS;
1343 case MWIFIEX_REG_RF:
1344 cmd_no = HostCmd_CMD_RF_REG_ACCESS;
1346 case MWIFIEX_REG_PMIC:
1347 cmd_no = HostCmd_CMD_PMIC_REG_ACCESS;
1349 case MWIFIEX_REG_CAU:
1350 cmd_no = HostCmd_CMD_CAU_REG_ACCESS;
1356 return mwifiex_send_cmd_sync(priv, cmd_no, action, 0, reg_rw);
1361 * Sends IOCTL request to write to a register.
1363 * This function allocates the IOCTL request buffer, fills it
1364 * with requisite parameters and calls the IOCTL handler.
1367 mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
1368 u32 reg_offset, u32 reg_value)
1370 struct mwifiex_ds_reg_rw reg_rw;
1372 reg_rw.type = cpu_to_le32(reg_type);
1373 reg_rw.offset = cpu_to_le32(reg_offset);
1374 reg_rw.value = cpu_to_le32(reg_value);
1376 return mwifiex_reg_mem_ioctl_reg_rw(priv, ®_rw, HostCmd_ACT_GEN_SET);
1380 * Sends IOCTL request to read from a register.
1382 * This function allocates the IOCTL request buffer, fills it
1383 * with requisite parameters and calls the IOCTL handler.
1386 mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
1387 u32 reg_offset, u32 *value)
1390 struct mwifiex_ds_reg_rw reg_rw;
1392 reg_rw.type = cpu_to_le32(reg_type);
1393 reg_rw.offset = cpu_to_le32(reg_offset);
1394 ret = mwifiex_reg_mem_ioctl_reg_rw(priv, ®_rw, HostCmd_ACT_GEN_GET);
1399 *value = le32_to_cpu(reg_rw.value);
1406 * Sends IOCTL request to read from EEPROM.
1408 * This function allocates the IOCTL request buffer, fills it
1409 * with requisite parameters and calls the IOCTL handler.
1412 mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
1416 struct mwifiex_ds_read_eeprom rd_eeprom;
1418 rd_eeprom.offset = cpu_to_le16((u16) offset);
1419 rd_eeprom.byte_count = cpu_to_le16((u16) bytes);
1421 /* Send request to firmware */
1422 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_EEPROM_ACCESS,
1423 HostCmd_ACT_GEN_GET, 0, &rd_eeprom);
1426 memcpy(value, rd_eeprom.value, MAX_EEPROM_DATA);
1431 * This function sets a generic IE. In addition to generic IE, it can
1432 * also handle WPA, WPA2 and WAPI IEs.
1435 mwifiex_set_gen_ie_helper(struct mwifiex_private *priv, u8 *ie_data_ptr,
1439 struct ieee_types_vendor_header *pvendor_ie;
1440 const u8 wpa_oui[] = { 0x00, 0x50, 0xf2, 0x01 };
1441 const u8 wps_oui[] = { 0x00, 0x50, 0xf2, 0x04 };
1443 /* If the passed length is zero, reset the buffer */
1445 priv->gen_ie_buf_len = 0;
1446 priv->wps.session_enable = false;
1449 } else if (!ie_data_ptr) {
1452 pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr;
1453 /* Test to see if it is a WPA IE, if not, then it is a gen IE */
1454 if (((pvendor_ie->element_id == WLAN_EID_WPA)
1455 && (!memcmp(pvendor_ie->oui, wpa_oui, sizeof(wpa_oui))))
1456 || (pvendor_ie->element_id == WLAN_EID_RSN)) {
1458 /* IE is a WPA/WPA2 IE so call set_wpa function */
1459 ret = mwifiex_set_wpa_ie_helper(priv, ie_data_ptr, ie_len);
1460 priv->wps.session_enable = false;
1463 } else if (pvendor_ie->element_id == WLAN_EID_BSS_AC_ACCESS_DELAY) {
1464 /* IE is a WAPI IE so call set_wapi function */
1465 ret = mwifiex_set_wapi_ie(priv, ie_data_ptr, ie_len);
1470 * Verify that the passed length is not larger than the
1471 * available space remaining in the buffer
1473 if (ie_len < (sizeof(priv->gen_ie_buf) - priv->gen_ie_buf_len)) {
1475 /* Test to see if it is a WPS IE, if so, enable
1478 pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr;
1479 if ((pvendor_ie->element_id == WLAN_EID_VENDOR_SPECIFIC)
1480 && (!memcmp(pvendor_ie->oui, wps_oui,
1481 sizeof(wps_oui)))) {
1482 priv->wps.session_enable = true;
1483 dev_dbg(priv->adapter->dev,
1484 "info: WPS Session Enabled.\n");
1487 /* Append the passed data to the end of the
1489 memcpy(priv->gen_ie_buf + priv->gen_ie_buf_len, ie_data_ptr,
1491 /* Increment the stored buffer length by the
1493 priv->gen_ie_buf_len += ie_len;
1495 /* Passed data does not fit in the remaining
1500 /* Return 0, or -1 for error case */
1505 * IOCTL request handler to set/get generic IE.
1507 * In addition to various generic IEs, this function can also be
1508 * used to set the ARP filter.
1510 static int mwifiex_misc_ioctl_gen_ie(struct mwifiex_private *priv,
1511 struct mwifiex_ds_misc_gen_ie *gen_ie,
1514 struct mwifiex_adapter *adapter = priv->adapter;
1516 switch (gen_ie->type) {
1517 case MWIFIEX_IE_TYPE_GEN_IE:
1518 if (action == HostCmd_ACT_GEN_GET) {
1519 gen_ie->len = priv->wpa_ie_len;
1520 memcpy(gen_ie->ie_data, priv->wpa_ie, gen_ie->len);
1522 mwifiex_set_gen_ie_helper(priv, gen_ie->ie_data,
1526 case MWIFIEX_IE_TYPE_ARP_FILTER:
1527 memset(adapter->arp_filter, 0, sizeof(adapter->arp_filter));
1528 if (gen_ie->len > ARP_FILTER_MAX_BUF_SIZE) {
1529 adapter->arp_filter_size = 0;
1530 dev_err(adapter->dev, "invalid ARP filter size\n");
1533 memcpy(adapter->arp_filter, gen_ie->ie_data,
1535 adapter->arp_filter_size = gen_ie->len;
1539 dev_err(adapter->dev, "invalid IE type\n");
1546 * Sends IOCTL request to set a generic IE.
1548 * This function allocates the IOCTL request buffer, fills it
1549 * with requisite parameters and calls the IOCTL handler.
1552 mwifiex_set_gen_ie(struct mwifiex_private *priv, u8 *ie, int ie_len)
1554 struct mwifiex_ds_misc_gen_ie gen_ie;
1556 if (ie_len > IEEE_MAX_IE_SIZE)
1559 gen_ie.type = MWIFIEX_IE_TYPE_GEN_IE;
1560 gen_ie.len = ie_len;
1561 memcpy(gen_ie.ie_data, ie, ie_len);
1562 if (mwifiex_misc_ioctl_gen_ie(priv, &gen_ie, HostCmd_ACT_GEN_SET))