2 * Marvell Wireless LAN device driver: functions for station ioctl
4 * Copyright (C) 2011, Marvell International Ltd.
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
29 static int disconnect_on_suspend = 1;
30 module_param(disconnect_on_suspend, int, 0644);
33 * Copies the multicast address list from device to driver.
35 * This function does not validate the destination memory for
36 * size, and the calling function must ensure enough memory is
39 int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
40 struct net_device *dev)
43 struct netdev_hw_addr *ha;
45 netdev_for_each_mc_addr(ha, dev)
46 memcpy(&mlist->mac_list[i++], ha->addr, ETH_ALEN);
52 * Wait queue completion handler.
54 * This function waits on a cmd wait queue. It also cancels the pending
55 * request after waking up, in case of errors.
57 int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter)
60 struct cmd_ctrl_node *cmd_queued;
62 if (!adapter->cmd_queued)
65 cmd_queued = adapter->cmd_queued;
66 adapter->cmd_queued = NULL;
68 dev_dbg(adapter->dev, "cmd pending\n");
69 atomic_inc(&adapter->cmd_pending);
71 /* Wait for completion */
72 status = wait_event_interruptible(adapter->cmd_wait_q.wait,
73 *(cmd_queued->condition));
75 dev_err(adapter->dev, "cmd_wait_q terminated: %d\n", status);
79 status = adapter->cmd_wait_q.status;
80 adapter->cmd_wait_q.status = 0;
86 * This function prepares the correct firmware command and
87 * issues it to set the multicast list.
89 * This function can be used to enable promiscuous mode, or enable all
90 * multicast packets, or to enable selective multicast.
92 int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
93 struct mwifiex_multicast_list *mcast_list)
98 old_pkt_filter = priv->curr_pkt_filter;
100 if (mcast_list->mode == MWIFIEX_PROMISC_MODE) {
101 dev_dbg(priv->adapter->dev, "info: Enable Promiscuous mode\n");
102 priv->curr_pkt_filter |= HostCmd_ACT_MAC_PROMISCUOUS_ENABLE;
103 priv->curr_pkt_filter &=
104 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
107 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_PROMISCUOUS_ENABLE;
108 if (mcast_list->mode == MWIFIEX_MULTICAST_MODE) {
109 dev_dbg(priv->adapter->dev,
110 "info: Enabling All Multicast!\n");
111 priv->curr_pkt_filter |=
112 HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
114 priv->curr_pkt_filter &=
115 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
116 if (mcast_list->num_multicast_addr) {
117 dev_dbg(priv->adapter->dev,
118 "info: Set multicast list=%d\n",
119 mcast_list->num_multicast_addr);
120 /* Set multicast addresses to firmware */
121 if (old_pkt_filter == priv->curr_pkt_filter) {
122 /* Send request to firmware */
123 ret = mwifiex_send_cmd_async(priv,
124 HostCmd_CMD_MAC_MULTICAST_ADR,
125 HostCmd_ACT_GEN_SET, 0,
128 /* Send request to firmware */
129 ret = mwifiex_send_cmd_async(priv,
130 HostCmd_CMD_MAC_MULTICAST_ADR,
131 HostCmd_ACT_GEN_SET, 0,
137 dev_dbg(priv->adapter->dev,
138 "info: old_pkt_filter=%#x, curr_pkt_filter=%#x\n",
139 old_pkt_filter, priv->curr_pkt_filter);
140 if (old_pkt_filter != priv->curr_pkt_filter) {
141 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL,
143 0, &priv->curr_pkt_filter);
150 * This function fills bss descriptor structure using provided
153 int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
154 struct cfg80211_bss *bss,
155 struct mwifiex_bssdescriptor *bss_desc,
156 u8 *beacon_ie, size_t beacon_ie_len)
158 struct mwifiex_bss_priv *bss_priv = (void *)bss->priv;
160 memcpy(bss_desc->mac_address, bss->bssid, ETH_ALEN);
161 bss_desc->rssi = bss->signal;
162 bss_desc->beacon_buf = beacon_ie;
163 bss_desc->beacon_buf_size = beacon_ie_len;
164 bss_desc->beacon_period = bss->beacon_interval;
165 bss_desc->cap_info_bitmap = bss->capability;
166 bss_desc->bss_band = bss_priv->band;
167 bss_desc->fw_tsf = bss_priv->fw_tsf;
168 bss_desc->timestamp = bss->tsf;
169 if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_PRIVACY) {
170 dev_dbg(priv->adapter->dev, "info: InterpretIE: AP WEP enabled\n");
171 bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_8021X_WEP;
173 bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL;
175 if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_IBSS)
176 bss_desc->bss_mode = NL80211_IFTYPE_ADHOC;
178 bss_desc->bss_mode = NL80211_IFTYPE_STATION;
180 return mwifiex_update_bss_desc_with_ie(priv->adapter, bss_desc);
183 static int mwifiex_process_country_ie(struct mwifiex_private *priv,
184 struct cfg80211_bss *bss)
186 u8 *country_ie, country_ie_len;
187 struct mwifiex_802_11d_domain_reg *domain_info =
188 &priv->adapter->domain_reg;
190 country_ie = (u8 *)ieee80211_bss_get_ie(bss, WLAN_EID_COUNTRY);
195 country_ie_len = country_ie[1];
196 if (country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN)
199 domain_info->country_code[0] = country_ie[2];
200 domain_info->country_code[1] = country_ie[3];
201 domain_info->country_code[2] = ' ';
203 country_ie_len -= IEEE80211_COUNTRY_STRING_LEN;
205 domain_info->no_of_triplet =
206 country_ie_len / sizeof(struct ieee80211_country_ie_triplet);
208 memcpy((u8 *)domain_info->triplet,
209 &country_ie[2] + IEEE80211_COUNTRY_STRING_LEN, country_ie_len);
211 if (mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11D_DOMAIN_INFO,
212 HostCmd_ACT_GEN_SET, 0, NULL)) {
213 wiphy_err(priv->wdev->wiphy,
214 "11D: setting domain info in FW\n");
222 * In Ad-Hoc mode, the IBSS is created if not found in scan list.
223 * In both Ad-Hoc and infra mode, an deauthentication is performed
226 int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
227 struct cfg80211_ssid *req_ssid)
230 struct mwifiex_adapter *adapter = priv->adapter;
231 struct mwifiex_bssdescriptor *bss_desc = NULL;
232 u8 *beacon_ie = NULL;
233 size_t beacon_ie_len = bss->len_information_elements;
235 priv->scan_block = false;
238 mwifiex_process_country_ie(priv, bss);
240 /* Allocate and fill new bss descriptor */
241 bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor),
244 dev_err(priv->adapter->dev, " failed to alloc bss_desc\n");
248 beacon_ie = kmemdup(bss->information_elements, beacon_ie_len,
255 ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc, beacon_ie,
261 if (priv->bss_mode == NL80211_IFTYPE_STATION) {
263 ret = mwifiex_deauthenticate(priv, NULL);
267 ret = mwifiex_check_network_compatibility(priv, bss_desc);
271 dev_dbg(adapter->dev, "info: SSID found in scan list ... "
274 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
275 if (netif_carrier_ok(priv->netdev))
276 netif_carrier_off(priv->netdev);
278 /* Clear any past association response stored for
279 * application retrieval */
280 priv->assoc_rsp_size = 0;
281 ret = mwifiex_associate(priv, bss_desc);
283 /* If auth type is auto and association fails using open mode,
284 * try to connect using shared mode */
285 if (ret == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG &&
286 priv->sec_info.is_authtype_auto &&
287 priv->sec_info.wep_enabled) {
288 priv->sec_info.authentication_mode =
289 NL80211_AUTHTYPE_SHARED_KEY;
290 ret = mwifiex_associate(priv, bss_desc);
294 cfg80211_put_bss(bss);
297 /* If the requested SSID matches current SSID, return */
298 if (bss_desc && bss_desc->ssid.ssid_len &&
299 (!mwifiex_ssid_cmp(&priv->curr_bss_params.bss_descriptor.
300 ssid, &bss_desc->ssid))) {
305 /* Exit Adhoc mode first */
306 dev_dbg(adapter->dev, "info: Sending Adhoc Stop\n");
307 ret = mwifiex_deauthenticate(priv, NULL);
311 priv->adhoc_is_link_sensed = false;
313 ret = mwifiex_check_network_compatibility(priv, bss_desc);
315 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
316 if (netif_carrier_ok(priv->netdev))
317 netif_carrier_off(priv->netdev);
320 dev_dbg(adapter->dev, "info: network found in scan"
321 " list. Joining...\n");
322 ret = mwifiex_adhoc_join(priv, bss_desc);
324 cfg80211_put_bss(bss);
326 dev_dbg(adapter->dev, "info: Network not found in "
327 "the list, creating adhoc with ssid = %s\n",
329 ret = mwifiex_adhoc_start(priv, req_ssid);
340 * IOCTL request handler to set host sleep configuration.
342 * This function prepares the correct firmware command and
345 static int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
346 int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg)
349 struct mwifiex_adapter *adapter = priv->adapter;
357 case HostCmd_ACT_GEN_SET:
358 if (adapter->pps_uapsd_mode) {
359 dev_dbg(adapter->dev, "info: Host Sleep IOCTL"
360 " is blocked in UAPSD/PPS mode\n");
364 if (hs_cfg->is_invoke_hostcmd) {
365 if (hs_cfg->conditions == HOST_SLEEP_CFG_CANCEL) {
366 if (!adapter->is_hs_configured)
367 /* Already cancelled */
369 /* Save previous condition */
370 prev_cond = le32_to_cpu(adapter->hs_cfg
372 adapter->hs_cfg.conditions =
373 cpu_to_le32(hs_cfg->conditions);
374 } else if (hs_cfg->conditions) {
375 adapter->hs_cfg.conditions =
376 cpu_to_le32(hs_cfg->conditions);
377 adapter->hs_cfg.gpio = (u8)hs_cfg->gpio;
379 adapter->hs_cfg.gap = (u8)hs_cfg->gap;
380 } else if (adapter->hs_cfg.conditions
381 == cpu_to_le32(HOST_SLEEP_CFG_CANCEL)) {
382 /* Return failure if no parameters for HS
387 if (cmd_type == MWIFIEX_SYNC_CMD)
388 status = mwifiex_send_cmd_sync(priv,
389 HostCmd_CMD_802_11_HS_CFG_ENH,
390 HostCmd_ACT_GEN_SET, 0,
393 status = mwifiex_send_cmd_async(priv,
394 HostCmd_CMD_802_11_HS_CFG_ENH,
395 HostCmd_ACT_GEN_SET, 0,
397 if (hs_cfg->conditions == HOST_SLEEP_CFG_CANCEL)
398 /* Restore previous condition */
399 adapter->hs_cfg.conditions =
400 cpu_to_le32(prev_cond);
402 adapter->hs_cfg.conditions =
403 cpu_to_le32(hs_cfg->conditions);
404 adapter->hs_cfg.gpio = (u8)hs_cfg->gpio;
405 adapter->hs_cfg.gap = (u8)hs_cfg->gap;
408 case HostCmd_ACT_GEN_GET:
409 hs_cfg->conditions = le32_to_cpu(adapter->hs_cfg.conditions);
410 hs_cfg->gpio = adapter->hs_cfg.gpio;
411 hs_cfg->gap = adapter->hs_cfg.gap;
422 * Sends IOCTL request to cancel the existing Host Sleep configuration.
424 * This function allocates the IOCTL request buffer, fills it
425 * with requisite parameters and calls the IOCTL handler.
427 int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type)
429 struct mwifiex_ds_hs_cfg hscfg;
431 hscfg.conditions = HOST_SLEEP_CFG_CANCEL;
432 hscfg.is_invoke_hostcmd = true;
434 return mwifiex_set_hs_params(priv, HostCmd_ACT_GEN_SET,
437 EXPORT_SYMBOL_GPL(mwifiex_cancel_hs);
440 * Sends IOCTL request to cancel the existing Host Sleep configuration.
442 * This function allocates the IOCTL request buffer, fills it
443 * with requisite parameters and calls the IOCTL handler.
445 int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
447 struct mwifiex_ds_hs_cfg hscfg;
448 struct mwifiex_private *priv;
451 if (disconnect_on_suspend) {
452 for (i = 0; i < adapter->priv_num; i++) {
453 priv = adapter->priv[i];
454 if (priv && priv->media_connected)
455 mwifiex_deauthenticate(priv, NULL);
459 if (adapter->hs_activated) {
460 dev_dbg(adapter->dev, "cmd: HS Already actived\n");
464 adapter->hs_activate_wait_q_woken = false;
466 memset(&hscfg, 0, sizeof(struct mwifiex_ds_hs_cfg));
467 hscfg.is_invoke_hostcmd = true;
469 if (mwifiex_set_hs_params(mwifiex_get_priv(adapter,
470 MWIFIEX_BSS_ROLE_STA),
471 HostCmd_ACT_GEN_SET, MWIFIEX_SYNC_CMD,
473 dev_err(adapter->dev, "IOCTL request HS enable failed\n");
477 if (wait_event_interruptible(adapter->hs_activate_wait_q,
478 adapter->hs_activate_wait_q_woken)) {
479 dev_err(adapter->dev, "hs_activate_wait_q terminated\n");
485 EXPORT_SYMBOL_GPL(mwifiex_enable_hs);
488 * IOCTL request handler to get BSS information.
490 * This function collates the information from different driver structures
491 * to send to the user.
493 int mwifiex_get_bss_info(struct mwifiex_private *priv,
494 struct mwifiex_bss_info *info)
496 struct mwifiex_adapter *adapter = priv->adapter;
497 struct mwifiex_bssdescriptor *bss_desc;
502 bss_desc = &priv->curr_bss_params.bss_descriptor;
504 info->bss_mode = priv->bss_mode;
506 memcpy(&info->ssid, &bss_desc->ssid, sizeof(struct cfg80211_ssid));
508 memcpy(&info->bssid, &bss_desc->mac_address, ETH_ALEN);
510 info->bss_chan = bss_desc->channel;
512 memcpy(info->country_code, priv->country_code,
513 IEEE80211_COUNTRY_STRING_LEN);
515 info->media_connected = priv->media_connected;
517 info->max_power_level = priv->max_tx_power_level;
518 info->min_power_level = priv->min_tx_power_level;
520 info->adhoc_state = priv->adhoc_state;
522 info->bcn_nf_last = priv->bcn_nf_last;
524 if (priv->sec_info.wep_enabled)
525 info->wep_status = true;
527 info->wep_status = false;
529 info->is_hs_configured = adapter->is_hs_configured;
530 info->is_deep_sleep = adapter->is_deep_sleep;
536 * The function disables auto deep sleep mode.
538 int mwifiex_disable_auto_ds(struct mwifiex_private *priv)
540 struct mwifiex_ds_auto_ds auto_ds;
542 auto_ds.auto_ds = DEEP_SLEEP_OFF;
544 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
545 DIS_AUTO_PS, BITMAP_AUTO_DS, &auto_ds);
547 EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds);
550 * IOCTL request handler to set/get active channel.
552 * This function performs validity checking on channel/frequency
553 * compatibility and returns failure if not valid.
555 int mwifiex_bss_set_channel(struct mwifiex_private *priv,
556 struct mwifiex_chan_freq_power *chan)
558 struct mwifiex_adapter *adapter = priv->adapter;
559 struct mwifiex_chan_freq_power *cfp = NULL;
564 if (!chan->channel && !chan->freq)
566 if (adapter->adhoc_start_band & BAND_AN)
567 adapter->adhoc_start_band = BAND_G | BAND_B | BAND_GN;
568 else if (adapter->adhoc_start_band & BAND_A)
569 adapter->adhoc_start_band = BAND_G | BAND_B;
571 if (chan->channel <= MAX_CHANNEL_BAND_BG)
572 cfp = mwifiex_get_cfp(priv, 0, (u16) chan->channel, 0);
574 cfp = mwifiex_get_cfp(priv, BAND_A,
575 (u16) chan->channel, 0);
577 if (adapter->adhoc_11n_enabled)
578 adapter->adhoc_start_band = BAND_A
581 adapter->adhoc_start_band = BAND_A;
585 if (chan->freq <= MAX_FREQUENCY_BAND_BG)
586 cfp = mwifiex_get_cfp(priv, 0, 0, chan->freq);
588 cfp = mwifiex_get_cfp(priv, BAND_A, 0, chan->freq);
590 if (adapter->adhoc_11n_enabled)
591 adapter->adhoc_start_band = BAND_A
594 adapter->adhoc_start_band = BAND_A;
598 if (!cfp || !cfp->channel) {
599 dev_err(adapter->dev, "invalid channel/freq\n");
602 priv->adhoc_channel = (u8) cfp->channel;
603 chan->channel = cfp->channel;
604 chan->freq = cfp->freq;
610 * IOCTL request handler to set/get Ad-Hoc channel.
612 * This function prepares the correct firmware command and
613 * issues it to set or get the ad-hoc channel.
615 static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv,
616 u16 action, u16 *channel)
618 if (action == HostCmd_ACT_GEN_GET) {
619 if (!priv->media_connected) {
620 *channel = priv->adhoc_channel;
624 priv->adhoc_channel = (u8) *channel;
627 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_RF_CHANNEL,
632 * IOCTL request handler to change Ad-Hoc channel.
634 * This function allocates the IOCTL request buffer, fills it
635 * with requisite parameters and calls the IOCTL handler.
637 * The function follows the following steps to perform the change -
638 * - Get current IBSS information
639 * - Get current channel
640 * - If no change is required, return
641 * - If not connected, change channel and return
645 * - Perform specific SSID scan with same SSID
646 * - Start/Join the IBSS
649 mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel)
652 struct mwifiex_bss_info bss_info;
653 struct mwifiex_ssid_bssid ssid_bssid;
655 struct cfg80211_bss *bss = NULL;
656 struct ieee80211_channel *chan;
657 enum ieee80211_band band;
659 memset(&bss_info, 0, sizeof(bss_info));
661 /* Get BSS information */
662 if (mwifiex_get_bss_info(priv, &bss_info))
665 /* Get current channel */
666 ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_GET,
669 if (curr_chan == channel) {
673 dev_dbg(priv->adapter->dev, "cmd: updating channel from %d to %d\n",
676 if (!bss_info.media_connected) {
682 memset(&ssid_bssid, 0, ETH_ALEN);
683 ret = mwifiex_deauthenticate(priv, ssid_bssid.bssid);
685 ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_SET,
688 /* Do specific SSID scanning */
689 if (mwifiex_request_scan(priv, &bss_info.ssid)) {
694 band = mwifiex_band_to_radio_type(priv->curr_bss_params.band);
695 chan = __ieee80211_get_channel(priv->wdev->wiphy,
696 ieee80211_channel_to_frequency(channel,
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 ((i == MWIFIEX_SUPPORTED_RATES) || !rate[i]) {
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,
838 rate->rate = priv->data_rate;
847 * IOCTL request handler to set tx power configuration.
849 * This function prepares the correct firmware command and
852 * For non-auto power mode, all the following power groups are set -
853 * - Modulation class HR/DSSS
854 * - Modulation class OFDM
855 * - Modulation class HTBW20
856 * - Modulation class HTBW40
858 int mwifiex_set_tx_power(struct mwifiex_private *priv,
859 struct mwifiex_power_cfg *power_cfg)
862 struct host_cmd_ds_txpwr_cfg *txp_cfg;
863 struct mwifiex_types_power_group *pg_tlv;
864 struct mwifiex_power_group *pg;
868 if (!power_cfg->is_power_auto) {
869 dbm = (u16) power_cfg->power_level;
870 if ((dbm < priv->min_tx_power_level) ||
871 (dbm > priv->max_tx_power_level)) {
872 dev_err(priv->adapter->dev, "txpower value %d dBm"
873 " is out of range (%d dBm-%d dBm)\n",
874 dbm, priv->min_tx_power_level,
875 priv->max_tx_power_level);
879 buf = kzalloc(MWIFIEX_SIZE_OF_CMD_BUFFER, GFP_KERNEL);
881 dev_err(priv->adapter->dev, "%s: failed to alloc cmd buffer\n",
886 txp_cfg = (struct host_cmd_ds_txpwr_cfg *) buf;
887 txp_cfg->action = cpu_to_le16(HostCmd_ACT_GEN_SET);
888 if (!power_cfg->is_power_auto) {
889 txp_cfg->mode = cpu_to_le32(1);
890 pg_tlv = (struct mwifiex_types_power_group *)
891 (buf + sizeof(struct host_cmd_ds_txpwr_cfg));
892 pg_tlv->type = TLV_TYPE_POWER_GROUP;
893 pg_tlv->length = 4 * sizeof(struct mwifiex_power_group);
894 pg = (struct mwifiex_power_group *)
895 (buf + sizeof(struct host_cmd_ds_txpwr_cfg)
896 + sizeof(struct mwifiex_types_power_group));
897 /* Power group for modulation class HR/DSSS */
898 pg->first_rate_code = 0x00;
899 pg->last_rate_code = 0x03;
900 pg->modulation_class = MOD_CLASS_HR_DSSS;
902 pg->power_min = (s8) dbm;
903 pg->power_max = (s8) dbm;
905 /* Power group for modulation class OFDM */
906 pg->first_rate_code = 0x00;
907 pg->last_rate_code = 0x07;
908 pg->modulation_class = MOD_CLASS_OFDM;
910 pg->power_min = (s8) dbm;
911 pg->power_max = (s8) dbm;
913 /* Power group for modulation class HTBW20 */
914 pg->first_rate_code = 0x00;
915 pg->last_rate_code = 0x20;
916 pg->modulation_class = MOD_CLASS_HT;
918 pg->power_min = (s8) dbm;
919 pg->power_max = (s8) dbm;
920 pg->ht_bandwidth = HT_BW_20;
922 /* Power group for modulation class HTBW40 */
923 pg->first_rate_code = 0x00;
924 pg->last_rate_code = 0x20;
925 pg->modulation_class = MOD_CLASS_HT;
927 pg->power_min = (s8) dbm;
928 pg->power_max = (s8) dbm;
929 pg->ht_bandwidth = HT_BW_40;
931 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TXPWR_CFG,
932 HostCmd_ACT_GEN_SET, 0, buf);
939 * IOCTL request handler to get power save mode.
941 * This function prepares the correct firmware command and
944 int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode)
947 struct mwifiex_adapter *adapter = priv->adapter;
951 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
953 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM;
954 sub_cmd = (*ps_mode) ? EN_AUTO_PS : DIS_AUTO_PS;
955 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
956 sub_cmd, BITMAP_STA_PS, NULL);
957 if ((!ret) && (sub_cmd == DIS_AUTO_PS))
958 ret = mwifiex_send_cmd_async(priv,
959 HostCmd_CMD_802_11_PS_MODE_ENH,
966 * IOCTL request handler to set/reset WPA IE.
968 * The supplied WPA IE is treated as a opaque buffer. Only the first field
969 * is checked to determine WPA version. If buffer length is zero, the existing
972 static int mwifiex_set_wpa_ie_helper(struct mwifiex_private *priv,
973 u8 *ie_data_ptr, u16 ie_len)
976 if (ie_len > sizeof(priv->wpa_ie)) {
977 dev_err(priv->adapter->dev,
978 "failed to copy WPA IE, too big\n");
981 memcpy(priv->wpa_ie, ie_data_ptr, ie_len);
982 priv->wpa_ie_len = (u8) ie_len;
983 dev_dbg(priv->adapter->dev, "cmd: Set Wpa_ie_len=%d IE=%#x\n",
984 priv->wpa_ie_len, priv->wpa_ie[0]);
986 if (priv->wpa_ie[0] == WLAN_EID_WPA) {
987 priv->sec_info.wpa_enabled = true;
988 } else if (priv->wpa_ie[0] == WLAN_EID_RSN) {
989 priv->sec_info.wpa2_enabled = true;
991 priv->sec_info.wpa_enabled = false;
992 priv->sec_info.wpa2_enabled = false;
995 memset(priv->wpa_ie, 0, sizeof(priv->wpa_ie));
996 priv->wpa_ie_len = 0;
997 dev_dbg(priv->adapter->dev, "info: reset wpa_ie_len=%d IE=%#x\n",
998 priv->wpa_ie_len, priv->wpa_ie[0]);
999 priv->sec_info.wpa_enabled = false;
1000 priv->sec_info.wpa2_enabled = false;
1007 * IOCTL request handler to set/reset WAPI IE.
1009 * The supplied WAPI IE is treated as a opaque buffer. Only the first field
1010 * is checked to internally enable WAPI. If buffer length is zero, the existing
1013 static int mwifiex_set_wapi_ie(struct mwifiex_private *priv,
1014 u8 *ie_data_ptr, u16 ie_len)
1017 if (ie_len > sizeof(priv->wapi_ie)) {
1018 dev_dbg(priv->adapter->dev,
1019 "info: failed to copy WAPI IE, too big\n");
1022 memcpy(priv->wapi_ie, ie_data_ptr, ie_len);
1023 priv->wapi_ie_len = ie_len;
1024 dev_dbg(priv->adapter->dev, "cmd: Set wapi_ie_len=%d IE=%#x\n",
1025 priv->wapi_ie_len, priv->wapi_ie[0]);
1027 if (priv->wapi_ie[0] == WLAN_EID_BSS_AC_ACCESS_DELAY)
1028 priv->sec_info.wapi_enabled = true;
1030 memset(priv->wapi_ie, 0, sizeof(priv->wapi_ie));
1031 priv->wapi_ie_len = ie_len;
1032 dev_dbg(priv->adapter->dev,
1033 "info: Reset wapi_ie_len=%d IE=%#x\n",
1034 priv->wapi_ie_len, priv->wapi_ie[0]);
1035 priv->sec_info.wapi_enabled = false;
1041 * IOCTL request handler to set/reset WPS IE.
1043 * The supplied WPS IE is treated as a opaque buffer. Only the first field
1044 * is checked to internally enable WPS. If buffer length is zero, the existing
1047 static int mwifiex_set_wps_ie(struct mwifiex_private *priv,
1048 u8 *ie_data_ptr, u16 ie_len)
1051 priv->wps_ie = kzalloc(MWIFIEX_MAX_VSIE_LEN, GFP_KERNEL);
1054 if (ie_len > sizeof(priv->wps_ie)) {
1055 dev_dbg(priv->adapter->dev,
1056 "info: failed to copy WPS IE, too big\n");
1057 kfree(priv->wps_ie);
1060 memcpy(priv->wps_ie, ie_data_ptr, ie_len);
1061 priv->wps_ie_len = ie_len;
1062 dev_dbg(priv->adapter->dev, "cmd: Set wps_ie_len=%d IE=%#x\n",
1063 priv->wps_ie_len, priv->wps_ie[0]);
1065 kfree(priv->wps_ie);
1066 priv->wps_ie_len = ie_len;
1067 dev_dbg(priv->adapter->dev,
1068 "info: Reset wps_ie_len=%d\n", priv->wps_ie_len);
1074 * IOCTL request handler to set WAPI key.
1076 * This function prepares the correct firmware command and
1079 static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_private *priv,
1080 struct mwifiex_ds_encrypt_key *encrypt_key)
1083 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1084 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1089 * IOCTL request handler to set WEP network key.
1091 * This function prepares the correct firmware command and
1092 * issues it, after validation checks.
1094 static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
1095 struct mwifiex_ds_encrypt_key *encrypt_key)
1098 struct mwifiex_wep_key *wep_key;
1101 if (priv->wep_key_curr_index >= NUM_WEP_KEYS)
1102 priv->wep_key_curr_index = 0;
1103 wep_key = &priv->wep_key[priv->wep_key_curr_index];
1104 index = encrypt_key->key_index;
1105 if (encrypt_key->key_disable) {
1106 priv->sec_info.wep_enabled = 0;
1107 } else if (!encrypt_key->key_len) {
1108 /* Copy the required key as the current key */
1109 wep_key = &priv->wep_key[index];
1110 if (!wep_key->key_length) {
1111 dev_err(priv->adapter->dev,
1112 "key not set, so cannot enable it\n");
1115 priv->wep_key_curr_index = (u16) index;
1116 priv->sec_info.wep_enabled = 1;
1118 wep_key = &priv->wep_key[index];
1119 memset(wep_key, 0, sizeof(struct mwifiex_wep_key));
1120 /* Copy the key in the driver */
1121 memcpy(wep_key->key_material,
1122 encrypt_key->key_material,
1123 encrypt_key->key_len);
1124 wep_key->key_index = index;
1125 wep_key->key_length = encrypt_key->key_len;
1126 priv->sec_info.wep_enabled = 1;
1128 if (wep_key->key_length) {
1129 /* Send request to firmware */
1130 ret = mwifiex_send_cmd_async(priv,
1131 HostCmd_CMD_802_11_KEY_MATERIAL,
1132 HostCmd_ACT_GEN_SET, 0, NULL);
1136 if (priv->sec_info.wep_enabled)
1137 priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE;
1139 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
1141 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_MAC_CONTROL,
1142 HostCmd_ACT_GEN_SET, 0,
1143 &priv->curr_pkt_filter);
1149 * IOCTL request handler to set WPA key.
1151 * This function prepares the correct firmware command and
1152 * issues it, after validation checks.
1154 * Current driver only supports key length of up to 32 bytes.
1156 * This function can also be used to disable a currently set key.
1158 static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_private *priv,
1159 struct mwifiex_ds_encrypt_key *encrypt_key)
1162 u8 remove_key = false;
1163 struct host_cmd_ds_802_11_key_material *ibss_key;
1165 /* Current driver only supports key length of up to 32 bytes */
1166 if (encrypt_key->key_len > WLAN_MAX_KEY_LEN) {
1167 dev_err(priv->adapter->dev, "key length too long\n");
1171 if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
1173 * IBSS/WPA-None uses only one key (Group) for both receiving
1174 * and sending unicast and multicast packets.
1176 /* Send the key as PTK to firmware */
1177 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1178 ret = mwifiex_send_cmd_async(priv,
1179 HostCmd_CMD_802_11_KEY_MATERIAL,
1180 HostCmd_ACT_GEN_SET,
1181 KEY_INFO_ENABLED, encrypt_key);
1185 ibss_key = &priv->aes_key;
1187 sizeof(struct host_cmd_ds_802_11_key_material));
1188 /* Copy the key in the driver */
1189 memcpy(ibss_key->key_param_set.key, encrypt_key->key_material,
1190 encrypt_key->key_len);
1191 memcpy(&ibss_key->key_param_set.key_len, &encrypt_key->key_len,
1192 sizeof(ibss_key->key_param_set.key_len));
1193 ibss_key->key_param_set.key_type_id
1194 = cpu_to_le16(KEY_TYPE_ID_TKIP);
1195 ibss_key->key_param_set.key_info = cpu_to_le16(KEY_ENABLED);
1197 /* Send the key as GTK to firmware */
1198 encrypt_key->key_index = ~MWIFIEX_KEY_INDEX_UNICAST;
1201 if (!encrypt_key->key_index)
1202 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1205 ret = mwifiex_send_cmd_sync(priv,
1206 HostCmd_CMD_802_11_KEY_MATERIAL,
1207 HostCmd_ACT_GEN_SET,
1208 !KEY_INFO_ENABLED, encrypt_key);
1210 ret = mwifiex_send_cmd_sync(priv,
1211 HostCmd_CMD_802_11_KEY_MATERIAL,
1212 HostCmd_ACT_GEN_SET,
1213 KEY_INFO_ENABLED, encrypt_key);
1219 * IOCTL request handler to set/get network keys.
1221 * This is a generic key handling function which supports WEP, WPA
1225 mwifiex_sec_ioctl_encrypt_key(struct mwifiex_private *priv,
1226 struct mwifiex_ds_encrypt_key *encrypt_key)
1230 if (encrypt_key->is_wapi_key)
1231 status = mwifiex_sec_ioctl_set_wapi_key(priv, encrypt_key);
1232 else if (encrypt_key->key_len > WLAN_KEY_LEN_WEP104)
1233 status = mwifiex_sec_ioctl_set_wpa_key(priv, encrypt_key);
1235 status = mwifiex_sec_ioctl_set_wep_key(priv, encrypt_key);
1240 * This function returns the driver version.
1243 mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, char *version,
1252 ver.l = adapter->fw_release_number;
1253 sprintf(fw_ver, "%u.%u.%u.p%u", ver.c[2], ver.c[1], ver.c[0], ver.c[3]);
1255 snprintf(version, max_len, driver_version, fw_ver);
1257 dev_dbg(adapter->dev, "info: MWIFIEX VERSION: %s\n", version);
1263 * Sends IOCTL request to set encoding parameters.
1265 * This function allocates the IOCTL request buffer, fills it
1266 * with requisite parameters and calls the IOCTL handler.
1268 int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
1269 int key_len, u8 key_index, int disable)
1271 struct mwifiex_ds_encrypt_key encrypt_key;
1273 memset(&encrypt_key, 0, sizeof(struct mwifiex_ds_encrypt_key));
1274 encrypt_key.key_len = key_len;
1276 encrypt_key.key_index = key_index;
1278 memcpy(encrypt_key.key_material, key, key_len);
1280 encrypt_key.key_disable = true;
1283 return mwifiex_sec_ioctl_encrypt_key(priv, &encrypt_key);
1287 * Sends IOCTL request to get extended version.
1289 * This function allocates the IOCTL request buffer, fills it
1290 * with requisite parameters and calls the IOCTL handler.
1293 mwifiex_get_ver_ext(struct mwifiex_private *priv)
1295 struct mwifiex_ver_ext ver_ext;
1297 memset(&ver_ext, 0, sizeof(struct host_cmd_ds_version_ext));
1298 if (mwifiex_send_cmd_sync(priv, HostCmd_CMD_VERSION_EXT,
1299 HostCmd_ACT_GEN_GET, 0, &ver_ext))
1306 * Sends IOCTL request to get statistics information.
1308 * This function allocates the IOCTL request buffer, fills it
1309 * with requisite parameters and calls the IOCTL handler.
1312 mwifiex_get_stats_info(struct mwifiex_private *priv,
1313 struct mwifiex_ds_get_stats *log)
1315 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_GET_LOG,
1316 HostCmd_ACT_GEN_GET, 0, log);
1320 * IOCTL request handler to read/write register.
1322 * This function prepares the correct firmware command and
1325 * Access to the following registers are supported -
1332 static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private *priv,
1333 struct mwifiex_ds_reg_rw *reg_rw,
1338 switch (le32_to_cpu(reg_rw->type)) {
1339 case MWIFIEX_REG_MAC:
1340 cmd_no = HostCmd_CMD_MAC_REG_ACCESS;
1342 case MWIFIEX_REG_BBP:
1343 cmd_no = HostCmd_CMD_BBP_REG_ACCESS;
1345 case MWIFIEX_REG_RF:
1346 cmd_no = HostCmd_CMD_RF_REG_ACCESS;
1348 case MWIFIEX_REG_PMIC:
1349 cmd_no = HostCmd_CMD_PMIC_REG_ACCESS;
1351 case MWIFIEX_REG_CAU:
1352 cmd_no = HostCmd_CMD_CAU_REG_ACCESS;
1358 return mwifiex_send_cmd_sync(priv, cmd_no, action, 0, reg_rw);
1363 * Sends IOCTL request to write to a register.
1365 * This function allocates the IOCTL request buffer, fills it
1366 * with requisite parameters and calls the IOCTL handler.
1369 mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
1370 u32 reg_offset, u32 reg_value)
1372 struct mwifiex_ds_reg_rw reg_rw;
1374 reg_rw.type = cpu_to_le32(reg_type);
1375 reg_rw.offset = cpu_to_le32(reg_offset);
1376 reg_rw.value = cpu_to_le32(reg_value);
1378 return mwifiex_reg_mem_ioctl_reg_rw(priv, ®_rw, HostCmd_ACT_GEN_SET);
1382 * Sends IOCTL request to read from a register.
1384 * This function allocates the IOCTL request buffer, fills it
1385 * with requisite parameters and calls the IOCTL handler.
1388 mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
1389 u32 reg_offset, u32 *value)
1392 struct mwifiex_ds_reg_rw reg_rw;
1394 reg_rw.type = cpu_to_le32(reg_type);
1395 reg_rw.offset = cpu_to_le32(reg_offset);
1396 ret = mwifiex_reg_mem_ioctl_reg_rw(priv, ®_rw, HostCmd_ACT_GEN_GET);
1401 *value = le32_to_cpu(reg_rw.value);
1408 * Sends IOCTL request to read from EEPROM.
1410 * This function allocates the IOCTL request buffer, fills it
1411 * with requisite parameters and calls the IOCTL handler.
1414 mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
1418 struct mwifiex_ds_read_eeprom rd_eeprom;
1420 rd_eeprom.offset = cpu_to_le16((u16) offset);
1421 rd_eeprom.byte_count = cpu_to_le16((u16) bytes);
1423 /* Send request to firmware */
1424 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_EEPROM_ACCESS,
1425 HostCmd_ACT_GEN_GET, 0, &rd_eeprom);
1428 memcpy(value, rd_eeprom.value, MAX_EEPROM_DATA);
1433 * This function sets a generic IE. In addition to generic IE, it can
1434 * also handle WPA, WPA2 and WAPI IEs.
1437 mwifiex_set_gen_ie_helper(struct mwifiex_private *priv, u8 *ie_data_ptr,
1441 struct ieee_types_vendor_header *pvendor_ie;
1442 const u8 wpa_oui[] = { 0x00, 0x50, 0xf2, 0x01 };
1443 const u8 wps_oui[] = { 0x00, 0x50, 0xf2, 0x04 };
1445 /* If the passed length is zero, reset the buffer */
1447 priv->gen_ie_buf_len = 0;
1448 priv->wps.session_enable = false;
1451 } else if (!ie_data_ptr) {
1454 pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr;
1455 /* Test to see if it is a WPA IE, if not, then it is a gen IE */
1456 if (((pvendor_ie->element_id == WLAN_EID_WPA) &&
1457 (!memcmp(pvendor_ie->oui, wpa_oui, sizeof(wpa_oui)))) ||
1458 (pvendor_ie->element_id == WLAN_EID_RSN)) {
1460 /* IE is a WPA/WPA2 IE so call set_wpa function */
1461 ret = mwifiex_set_wpa_ie_helper(priv, ie_data_ptr, ie_len);
1462 priv->wps.session_enable = false;
1465 } else if (pvendor_ie->element_id == WLAN_EID_BSS_AC_ACCESS_DELAY) {
1466 /* IE is a WAPI IE so call set_wapi function */
1467 ret = mwifiex_set_wapi_ie(priv, ie_data_ptr, ie_len);
1472 * Verify that the passed length is not larger than the
1473 * available space remaining in the buffer
1475 if (ie_len < (sizeof(priv->gen_ie_buf) - priv->gen_ie_buf_len)) {
1477 /* Test to see if it is a WPS IE, if so, enable
1480 pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr;
1481 if ((pvendor_ie->element_id == WLAN_EID_VENDOR_SPECIFIC) &&
1482 (!memcmp(pvendor_ie->oui, wps_oui, sizeof(wps_oui)))) {
1483 priv->wps.session_enable = true;
1484 dev_dbg(priv->adapter->dev,
1485 "info: WPS Session Enabled.\n");
1486 ret = mwifiex_set_wps_ie(priv, ie_data_ptr, ie_len);
1489 /* Append the passed data to the end of the
1491 memcpy(priv->gen_ie_buf + priv->gen_ie_buf_len, ie_data_ptr,
1493 /* Increment the stored buffer length by the
1495 priv->gen_ie_buf_len += ie_len;
1497 /* Passed data does not fit in the remaining
1502 /* Return 0, or -1 for error case */
1507 * IOCTL request handler to set/get generic IE.
1509 * In addition to various generic IEs, this function can also be
1510 * used to set the ARP filter.
1512 static int mwifiex_misc_ioctl_gen_ie(struct mwifiex_private *priv,
1513 struct mwifiex_ds_misc_gen_ie *gen_ie,
1516 struct mwifiex_adapter *adapter = priv->adapter;
1518 switch (gen_ie->type) {
1519 case MWIFIEX_IE_TYPE_GEN_IE:
1520 if (action == HostCmd_ACT_GEN_GET) {
1521 gen_ie->len = priv->wpa_ie_len;
1522 memcpy(gen_ie->ie_data, priv->wpa_ie, gen_ie->len);
1524 mwifiex_set_gen_ie_helper(priv, gen_ie->ie_data,
1528 case MWIFIEX_IE_TYPE_ARP_FILTER:
1529 memset(adapter->arp_filter, 0, sizeof(adapter->arp_filter));
1530 if (gen_ie->len > ARP_FILTER_MAX_BUF_SIZE) {
1531 adapter->arp_filter_size = 0;
1532 dev_err(adapter->dev, "invalid ARP filter size\n");
1535 memcpy(adapter->arp_filter, gen_ie->ie_data,
1537 adapter->arp_filter_size = gen_ie->len;
1541 dev_err(adapter->dev, "invalid IE type\n");
1548 * Sends IOCTL request to set a generic IE.
1550 * This function allocates the IOCTL request buffer, fills it
1551 * with requisite parameters and calls the IOCTL handler.
1554 mwifiex_set_gen_ie(struct mwifiex_private *priv, u8 *ie, int ie_len)
1556 struct mwifiex_ds_misc_gen_ie gen_ie;
1558 if (ie_len > IEEE_MAX_IE_SIZE)
1561 gen_ie.type = MWIFIEX_IE_TYPE_GEN_IE;
1562 gen_ie.len = ie_len;
1563 memcpy(gen_ie.ie_data, ie, ie_len);
1564 if (mwifiex_misc_ioctl_gen_ie(priv, &gen_ie, HostCmd_ACT_GEN_SET))