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_ALL_MULTI_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 /* Send multicast addresses to firmware */
116 ret = mwifiex_send_cmd_async(priv,
117 HostCmd_CMD_MAC_MULTICAST_ADR,
118 HostCmd_ACT_GEN_SET, 0,
123 dev_dbg(priv->adapter->dev,
124 "info: old_pkt_filter=%#x, curr_pkt_filter=%#x\n",
125 old_pkt_filter, priv->curr_pkt_filter);
126 if (old_pkt_filter != priv->curr_pkt_filter) {
127 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL,
129 0, &priv->curr_pkt_filter);
136 * In Ad-Hoc mode, the IBSS is created if not found in scan list.
137 * In both Ad-Hoc and infra mode, an deauthentication is performed
140 int mwifiex_bss_start(struct mwifiex_private *priv,
141 struct mwifiex_ssid_bssid *ssid_bssid)
144 struct mwifiex_adapter *adapter = priv->adapter;
147 priv->scan_block = false;
151 if (priv->bss_mode == NL80211_IFTYPE_STATION) {
153 ret = mwifiex_deauthenticate(priv, NULL);
157 /* Search for the requested SSID in the scan table */
158 if (ssid_bssid->ssid.ssid_len)
159 i = mwifiex_find_ssid_in_list(priv, &ssid_bssid->ssid,
160 NULL, NL80211_IFTYPE_STATION);
162 i = mwifiex_find_bssid_in_list(priv,
163 (u8 *) &ssid_bssid->bssid,
164 NL80211_IFTYPE_STATION);
168 dev_dbg(adapter->dev,
169 "info: SSID found in scan list ... associating...\n");
171 /* Clear any past association response stored for
172 * application retrieval */
173 priv->assoc_rsp_size = 0;
174 ret = mwifiex_associate(priv, &adapter->scan_table[i]);
179 /* If the requested SSID matches current SSID, return */
180 if (ssid_bssid->ssid.ssid_len &&
182 (&priv->curr_bss_params.bss_descriptor.ssid,
186 /* Exit Adhoc mode first */
187 dev_dbg(adapter->dev, "info: Sending Adhoc Stop\n");
188 ret = mwifiex_deauthenticate(priv, NULL);
192 priv->adhoc_is_link_sensed = false;
194 /* Search for the requested network in the scan table */
195 if (ssid_bssid->ssid.ssid_len)
196 i = mwifiex_find_ssid_in_list(priv,
197 &ssid_bssid->ssid, NULL,
198 NL80211_IFTYPE_ADHOC);
200 i = mwifiex_find_bssid_in_list(priv,
201 (u8 *)&ssid_bssid->bssid,
202 NL80211_IFTYPE_ADHOC);
205 dev_dbg(adapter->dev, "info: network found in scan"
206 " list. Joining...\n");
207 ret = mwifiex_adhoc_join(priv, &adapter->scan_table[i]);
211 dev_dbg(adapter->dev, "info: Network not found in "
212 "the list, creating adhoc with ssid = %s\n",
213 ssid_bssid->ssid.ssid);
214 ret = mwifiex_adhoc_start(priv, &ssid_bssid->ssid);
224 * IOCTL request handler to set host sleep configuration.
226 * This function prepares the correct firmware command and
229 int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
230 int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg)
233 struct mwifiex_adapter *adapter = priv->adapter;
241 case HostCmd_ACT_GEN_SET:
242 if (adapter->pps_uapsd_mode) {
243 dev_dbg(adapter->dev, "info: Host Sleep IOCTL"
244 " is blocked in UAPSD/PPS mode\n");
248 if (hs_cfg->is_invoke_hostcmd) {
249 if (hs_cfg->conditions == HOST_SLEEP_CFG_CANCEL) {
250 if (!adapter->is_hs_configured)
251 /* Already cancelled */
253 /* Save previous condition */
254 prev_cond = le32_to_cpu(adapter->hs_cfg
256 adapter->hs_cfg.conditions =
257 cpu_to_le32(hs_cfg->conditions);
258 } else if (hs_cfg->conditions) {
259 adapter->hs_cfg.conditions =
260 cpu_to_le32(hs_cfg->conditions);
261 adapter->hs_cfg.gpio = (u8)hs_cfg->gpio;
263 adapter->hs_cfg.gap = (u8)hs_cfg->gap;
264 } else if (adapter->hs_cfg.conditions ==
266 HOST_SLEEP_CFG_CANCEL)) {
267 /* Return failure if no parameters for HS
272 if (cmd_type == MWIFIEX_SYNC_CMD)
273 status = mwifiex_send_cmd_sync(priv,
274 HostCmd_CMD_802_11_HS_CFG_ENH,
275 HostCmd_ACT_GEN_SET, 0,
278 status = mwifiex_send_cmd_async(priv,
279 HostCmd_CMD_802_11_HS_CFG_ENH,
280 HostCmd_ACT_GEN_SET, 0,
282 if (hs_cfg->conditions == HOST_SLEEP_CFG_CANCEL)
283 /* Restore previous condition */
284 adapter->hs_cfg.conditions =
285 cpu_to_le32(prev_cond);
287 adapter->hs_cfg.conditions =
288 cpu_to_le32(hs_cfg->conditions);
289 adapter->hs_cfg.gpio = (u8)hs_cfg->gpio;
290 adapter->hs_cfg.gap = (u8)hs_cfg->gap;
293 case HostCmd_ACT_GEN_GET:
294 hs_cfg->conditions = le32_to_cpu(adapter->hs_cfg.conditions);
295 hs_cfg->gpio = adapter->hs_cfg.gpio;
296 hs_cfg->gap = adapter->hs_cfg.gap;
307 * Sends IOCTL request to cancel the existing Host Sleep configuration.
309 * This function allocates the IOCTL request buffer, fills it
310 * with requisite parameters and calls the IOCTL handler.
312 int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type)
314 struct mwifiex_ds_hs_cfg hscfg;
316 hscfg.conditions = HOST_SLEEP_CFG_CANCEL;
317 hscfg.is_invoke_hostcmd = true;
319 return mwifiex_set_hs_params(priv, HostCmd_ACT_GEN_SET,
322 EXPORT_SYMBOL_GPL(mwifiex_cancel_hs);
325 * Sends IOCTL request to cancel the existing Host Sleep configuration.
327 * This function allocates the IOCTL request buffer, fills it
328 * with requisite parameters and calls the IOCTL handler.
330 int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
332 struct mwifiex_ds_hs_cfg hscfg;
334 if (adapter->hs_activated) {
335 dev_dbg(adapter->dev, "cmd: HS Already actived\n");
339 adapter->hs_activate_wait_q_woken = false;
341 memset(&hscfg, 0, sizeof(struct mwifiex_hs_config_param));
342 hscfg.is_invoke_hostcmd = true;
344 if (mwifiex_set_hs_params(mwifiex_get_priv(adapter,
345 MWIFIEX_BSS_ROLE_STA),
346 HostCmd_ACT_GEN_SET, MWIFIEX_SYNC_CMD,
348 dev_err(adapter->dev, "IOCTL request HS enable failed\n");
352 wait_event_interruptible(adapter->hs_activate_wait_q,
353 adapter->hs_activate_wait_q_woken);
357 EXPORT_SYMBOL_GPL(mwifiex_enable_hs);
360 * IOCTL request handler to get BSS information.
362 * This function collates the information from different driver structures
363 * to send to the user.
365 int mwifiex_get_bss_info(struct mwifiex_private *priv,
366 struct mwifiex_bss_info *info)
368 struct mwifiex_adapter *adapter = priv->adapter;
369 struct mwifiex_bssdescriptor *bss_desc;
375 bss_desc = &priv->curr_bss_params.bss_descriptor;
377 info->bss_mode = priv->bss_mode;
379 memcpy(&info->ssid, &bss_desc->ssid,
380 sizeof(struct mwifiex_802_11_ssid));
382 memcpy(&info->bssid, &bss_desc->mac_address, ETH_ALEN);
384 info->bss_chan = bss_desc->channel;
386 info->region_code = adapter->region_code;
388 /* Scan table index if connected */
389 info->scan_table_idx = 0;
390 if (priv->media_connected) {
392 mwifiex_find_ssid_in_list(priv, &bss_desc->ssid,
393 bss_desc->mac_address,
396 info->scan_table_idx = tbl_idx;
399 info->media_connected = priv->media_connected;
401 info->max_power_level = priv->max_tx_power_level;
402 info->min_power_level = priv->min_tx_power_level;
404 info->adhoc_state = priv->adhoc_state;
406 info->bcn_nf_last = priv->bcn_nf_last;
408 if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED)
409 info->wep_status = true;
411 info->wep_status = false;
413 info->is_hs_configured = adapter->is_hs_configured;
414 info->is_deep_sleep = adapter->is_deep_sleep;
420 * The function sets band configurations.
422 * it performs extra checks to make sure the Ad-Hoc
423 * band and channel are compatible. Otherwise it returns an error.
426 int mwifiex_set_radio_band_cfg(struct mwifiex_private *priv,
427 struct mwifiex_ds_band_cfg *radio_cfg)
429 struct mwifiex_adapter *adapter = priv->adapter;
430 u8 infra_band, adhoc_band;
433 infra_band = (u8) radio_cfg->config_bands;
434 adhoc_band = (u8) radio_cfg->adhoc_start_band;
435 adhoc_channel = radio_cfg->adhoc_channel;
438 if ((infra_band | adapter->fw_bands) & ~adapter->fw_bands)
441 adapter->config_bands = infra_band;
443 /* SET Ad-hoc Band */
444 if ((adhoc_band | adapter->fw_bands) & ~adapter->fw_bands)
448 adapter->adhoc_start_band = adhoc_band;
449 adapter->chan_offset = (u8) radio_cfg->sec_chan_offset;
451 * If no adhoc_channel is supplied verify if the existing adhoc
452 * channel compiles with new adhoc_band
454 if (!adhoc_channel) {
455 if (!mwifiex_get_cfp_by_band_and_channel_from_cfg80211
456 (priv, adapter->adhoc_start_band,
457 priv->adhoc_channel)) {
458 /* Pass back the default channel */
459 radio_cfg->adhoc_channel = DEFAULT_AD_HOC_CHANNEL;
460 if ((adapter->adhoc_start_band & BAND_A)
461 || (adapter->adhoc_start_band & BAND_AN))
462 radio_cfg->adhoc_channel =
463 DEFAULT_AD_HOC_CHANNEL_A;
465 } else { /* Retrurn error if adhoc_band and
466 adhoc_channel combination is invalid */
467 if (!mwifiex_get_cfp_by_band_and_channel_from_cfg80211
468 (priv, adapter->adhoc_start_band, (u16) adhoc_channel))
470 priv->adhoc_channel = (u8) adhoc_channel;
472 if ((adhoc_band & BAND_GN) || (adhoc_band & BAND_AN))
473 adapter->adhoc_11n_enabled = true;
475 adapter->adhoc_11n_enabled = false;
481 * IOCTL request handler to set/get active channel.
483 * This function performs validity checking on channel/frequency
484 * compatibility and returns failure if not valid.
486 int mwifiex_bss_set_channel(struct mwifiex_private *priv,
487 struct mwifiex_chan_freq_power *chan)
489 struct mwifiex_adapter *adapter = priv->adapter;
490 struct mwifiex_chan_freq_power *cfp = NULL;
495 if (!chan->channel && !chan->freq)
497 if (adapter->adhoc_start_band & BAND_AN)
498 adapter->adhoc_start_band = BAND_G | BAND_B | BAND_GN;
499 else if (adapter->adhoc_start_band & BAND_A)
500 adapter->adhoc_start_band = BAND_G | BAND_B;
502 if (chan->channel <= MAX_CHANNEL_BAND_BG)
503 cfp = mwifiex_get_cfp_by_band_and_channel_from_cfg80211
504 (priv, 0, (u16) chan->channel);
506 cfp = mwifiex_get_cfp_by_band_and_channel_from_cfg80211
507 (priv, BAND_A, (u16) chan->channel);
509 if (adapter->adhoc_11n_enabled)
510 adapter->adhoc_start_band = BAND_A
513 adapter->adhoc_start_band = BAND_A;
517 if (chan->freq <= MAX_FREQUENCY_BAND_BG)
518 cfp = mwifiex_get_cfp_by_band_and_freq_from_cfg80211(
519 priv, 0, chan->freq);
521 cfp = mwifiex_get_cfp_by_band_and_freq_from_cfg80211
522 (priv, BAND_A, chan->freq);
524 if (adapter->adhoc_11n_enabled)
525 adapter->adhoc_start_band = BAND_A
528 adapter->adhoc_start_band = BAND_A;
532 if (!cfp || !cfp->channel) {
533 dev_err(adapter->dev, "invalid channel/freq\n");
536 priv->adhoc_channel = (u8) cfp->channel;
537 chan->channel = cfp->channel;
538 chan->freq = cfp->freq;
544 * IOCTL request handler to set/get Ad-Hoc channel.
546 * This function prepares the correct firmware command and
547 * issues it to set or get the ad-hoc channel.
549 static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv,
550 u16 action, u16 *channel)
552 if (action == HostCmd_ACT_GEN_GET) {
553 if (!priv->media_connected) {
554 *channel = priv->adhoc_channel;
558 priv->adhoc_channel = (u8) *channel;
561 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_RF_CHANNEL,
566 * IOCTL request handler to find a particular BSS.
568 * The BSS can be searched with either a BSSID or a SSID. If none of
569 * these are provided, just the best BSS (best RSSI) is returned.
571 int mwifiex_bss_ioctl_find_bss(struct mwifiex_private *priv,
572 struct mwifiex_ssid_bssid *ssid_bssid)
574 struct mwifiex_adapter *adapter = priv->adapter;
575 struct mwifiex_bssdescriptor *bss_desc;
576 u8 zero_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
580 if (memcmp(ssid_bssid->bssid, zero_mac, sizeof(zero_mac))) {
581 i = mwifiex_find_bssid_in_list(priv,
582 (u8 *) ssid_bssid->bssid,
585 memcpy(mac, ssid_bssid->bssid, sizeof(mac));
586 dev_err(adapter->dev, "cannot find bssid %pM\n", mac);
589 bss_desc = &adapter->scan_table[i];
590 memcpy(&ssid_bssid->ssid, &bss_desc->ssid,
591 sizeof(struct mwifiex_802_11_ssid));
592 } else if (ssid_bssid->ssid.ssid_len) {
593 i = mwifiex_find_ssid_in_list(priv, &ssid_bssid->ssid, NULL,
596 dev_err(adapter->dev, "cannot find ssid %s\n",
597 ssid_bssid->ssid.ssid);
600 bss_desc = &adapter->scan_table[i];
601 memcpy(ssid_bssid->bssid, bss_desc->mac_address, ETH_ALEN);
603 return mwifiex_find_best_network(priv, ssid_bssid);
610 * IOCTL request handler to change Ad-Hoc channel.
612 * This function allocates the IOCTL request buffer, fills it
613 * with requisite parameters and calls the IOCTL handler.
615 * The function follows the following steps to perform the change -
616 * - Get current IBSS information
617 * - Get current channel
618 * - If no change is required, return
619 * - If not connected, change channel and return
623 * - Perform specific SSID scan with same SSID
624 * - Start/Join the IBSS
627 mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel)
630 struct mwifiex_bss_info bss_info;
631 struct mwifiex_ssid_bssid ssid_bssid;
634 memset(&bss_info, 0, sizeof(bss_info));
636 /* Get BSS information */
637 if (mwifiex_get_bss_info(priv, &bss_info))
640 /* Get current channel */
641 ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_GET,
644 if (curr_chan == channel) {
648 dev_dbg(priv->adapter->dev, "cmd: updating channel from %d to %d\n",
651 if (!bss_info.media_connected) {
657 memset(&ssid_bssid, 0, ETH_ALEN);
658 ret = mwifiex_deauthenticate(priv, ssid_bssid.bssid);
660 ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_SET,
663 /* Do specific SSID scanning */
664 if (mwifiex_request_scan(priv, &bss_info.ssid)) {
668 /* Start/Join Adhoc network */
669 memset(&ssid_bssid, 0, sizeof(struct mwifiex_ssid_bssid));
670 memcpy(&ssid_bssid.ssid, &bss_info.ssid,
671 sizeof(struct mwifiex_802_11_ssid));
673 ret = mwifiex_bss_start(priv, &ssid_bssid);
679 * IOCTL request handler to get rate.
681 * This function prepares the correct firmware command and
682 * issues it to get the current rate if it is connected,
683 * otherwise, the function returns the lowest supported rate
686 static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv,
687 struct mwifiex_rate_cfg *rate_cfg)
689 struct mwifiex_adapter *adapter = priv->adapter;
691 rate_cfg->is_rate_auto = priv->is_data_rate_auto;
692 if (!priv->media_connected) {
693 switch (adapter->config_bands) {
695 /* Return the lowest supported rate for B band */
696 rate_cfg->rate = supported_rates_b[0] & 0x7f;
699 case BAND_G | BAND_GN:
700 /* Return the lowest supported rate for G band */
701 rate_cfg->rate = supported_rates_g[0] & 0x7f;
703 case BAND_B | BAND_G:
704 case BAND_A | BAND_B | BAND_G:
705 case BAND_A | BAND_B:
706 case BAND_A | BAND_B | BAND_G | BAND_AN | BAND_GN:
707 case BAND_B | BAND_G | BAND_GN:
708 /* Return the lowest supported rate for BG band */
709 rate_cfg->rate = supported_rates_bg[0] & 0x7f;
712 case BAND_A | BAND_G:
713 case BAND_A | BAND_G | BAND_AN | BAND_GN:
714 case BAND_A | BAND_AN:
715 /* Return the lowest supported rate for A band */
716 rate_cfg->rate = supported_rates_a[0] & 0x7f;
719 /* Return the lowest supported rate for N band */
720 rate_cfg->rate = supported_rates_n[0] & 0x7f;
723 dev_warn(adapter->dev, "invalid band %#x\n",
724 adapter->config_bands);
728 return mwifiex_send_cmd_sync(priv,
729 HostCmd_CMD_802_11_TX_RATE_QUERY,
730 HostCmd_ACT_GEN_GET, 0, NULL);
737 * IOCTL request handler to set rate.
739 * This function prepares the correct firmware command and
740 * issues it to set the current rate.
742 * The function also performs validation checking on the supplied value.
744 static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv,
745 struct mwifiex_rate_cfg *rate_cfg)
747 u8 rates[MWIFIEX_SUPPORTED_RATES];
750 u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
752 struct mwifiex_adapter *adapter = priv->adapter;
754 if (rate_cfg->is_rate_auto) {
755 memset(bitmap_rates, 0, sizeof(bitmap_rates));
756 /* Support all HR/DSSS rates */
757 bitmap_rates[0] = 0x000F;
758 /* Support all OFDM rates */
759 bitmap_rates[1] = 0x00FF;
760 /* Support all HT-MCSs rate */
761 for (i = 0; i < ARRAY_SIZE(priv->bitmap_rates) - 3; i++)
762 bitmap_rates[i + 2] = 0xFFFF;
763 bitmap_rates[9] = 0x3FFF;
765 memset(rates, 0, sizeof(rates));
766 mwifiex_get_active_data_rates(priv, rates);
768 for (i = 0; (rate[i] && i < MWIFIEX_SUPPORTED_RATES); i++) {
769 dev_dbg(adapter->dev, "info: rate=%#x wanted=%#x\n",
770 rate[i], rate_cfg->rate);
771 if ((rate[i] & 0x7f) == (rate_cfg->rate & 0x7f))
774 if (!rate[i] || (i == MWIFIEX_SUPPORTED_RATES)) {
775 dev_err(adapter->dev, "fixed data rate %#x is out "
776 "of range\n", rate_cfg->rate);
779 memset(bitmap_rates, 0, sizeof(bitmap_rates));
781 rate_index = mwifiex_data_rate_to_index(rate_cfg->rate);
783 /* Only allow b/g rates to be set */
784 if (rate_index >= MWIFIEX_RATE_INDEX_HRDSSS0 &&
785 rate_index <= MWIFIEX_RATE_INDEX_HRDSSS3) {
786 bitmap_rates[0] = 1 << rate_index;
788 rate_index -= 1; /* There is a 0x00 in the table */
789 if (rate_index >= MWIFIEX_RATE_INDEX_OFDM0 &&
790 rate_index <= MWIFIEX_RATE_INDEX_OFDM7)
791 bitmap_rates[1] = 1 << (rate_index -
792 MWIFIEX_RATE_INDEX_OFDM0);
796 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TX_RATE_CFG,
797 HostCmd_ACT_GEN_SET, 0, bitmap_rates);
803 * IOCTL request handler to set/get rate.
805 * This function can be used to set/get either the rate value or the
808 static int mwifiex_rate_ioctl_cfg(struct mwifiex_private *priv,
809 struct mwifiex_rate_cfg *rate_cfg)
816 if (rate_cfg->action == HostCmd_ACT_GEN_GET)
817 status = mwifiex_rate_ioctl_get_rate_value(priv, rate_cfg);
819 status = mwifiex_rate_ioctl_set_rate_value(priv, rate_cfg);
825 * Sends IOCTL request to get the data rate.
827 * This function allocates the IOCTL request buffer, fills it
828 * with requisite parameters and calls the IOCTL handler.
830 int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
831 struct mwifiex_rate_cfg *rate)
835 memset(rate, 0, sizeof(struct mwifiex_rate_cfg));
836 rate->action = HostCmd_ACT_GEN_GET;
837 ret = mwifiex_rate_ioctl_cfg(priv, rate);
840 if (rate && rate->is_rate_auto)
841 rate->rate = mwifiex_index_to_data_rate(priv->tx_rate,
844 rate->rate = priv->data_rate;
853 * IOCTL request handler to set tx power configuration.
855 * This function prepares the correct firmware command and
858 * For non-auto power mode, all the following power groups are set -
859 * - Modulation class HR/DSSS
860 * - Modulation class OFDM
861 * - Modulation class HTBW20
862 * - Modulation class HTBW40
864 int mwifiex_set_tx_power(struct mwifiex_private *priv,
865 struct mwifiex_power_cfg *power_cfg)
868 struct host_cmd_ds_txpwr_cfg *txp_cfg;
869 struct mwifiex_types_power_group *pg_tlv;
870 struct mwifiex_power_group *pg;
874 if (!power_cfg->is_power_auto) {
875 dbm = (u16) power_cfg->power_level;
876 if ((dbm < priv->min_tx_power_level) ||
877 (dbm > priv->max_tx_power_level)) {
878 dev_err(priv->adapter->dev, "txpower value %d dBm"
879 " is out of range (%d dBm-%d dBm)\n",
880 dbm, priv->min_tx_power_level,
881 priv->max_tx_power_level);
885 buf = kzalloc(MWIFIEX_SIZE_OF_CMD_BUFFER, GFP_KERNEL);
887 dev_err(priv->adapter->dev, "%s: failed to alloc cmd buffer\n",
892 txp_cfg = (struct host_cmd_ds_txpwr_cfg *) buf;
893 txp_cfg->action = cpu_to_le16(HostCmd_ACT_GEN_SET);
894 if (!power_cfg->is_power_auto) {
895 txp_cfg->mode = cpu_to_le32(1);
896 pg_tlv = (struct mwifiex_types_power_group *) (buf +
897 sizeof(struct host_cmd_ds_txpwr_cfg));
898 pg_tlv->type = TLV_TYPE_POWER_GROUP;
899 pg_tlv->length = 4 * sizeof(struct mwifiex_power_group);
900 pg = (struct mwifiex_power_group *) (buf +
901 sizeof(struct host_cmd_ds_txpwr_cfg) +
902 sizeof(struct mwifiex_types_power_group));
903 /* Power group for modulation class HR/DSSS */
904 pg->first_rate_code = 0x00;
905 pg->last_rate_code = 0x03;
906 pg->modulation_class = MOD_CLASS_HR_DSSS;
908 pg->power_min = (s8) dbm;
909 pg->power_max = (s8) dbm;
911 /* Power group for modulation class OFDM */
912 pg->first_rate_code = 0x00;
913 pg->last_rate_code = 0x07;
914 pg->modulation_class = MOD_CLASS_OFDM;
916 pg->power_min = (s8) dbm;
917 pg->power_max = (s8) dbm;
919 /* Power group for modulation class HTBW20 */
920 pg->first_rate_code = 0x00;
921 pg->last_rate_code = 0x20;
922 pg->modulation_class = MOD_CLASS_HT;
924 pg->power_min = (s8) dbm;
925 pg->power_max = (s8) dbm;
926 pg->ht_bandwidth = HT_BW_20;
928 /* Power group for modulation class HTBW40 */
929 pg->first_rate_code = 0x00;
930 pg->last_rate_code = 0x20;
931 pg->modulation_class = MOD_CLASS_HT;
933 pg->power_min = (s8) dbm;
934 pg->power_max = (s8) dbm;
935 pg->ht_bandwidth = HT_BW_40;
937 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TXPWR_CFG,
938 HostCmd_ACT_GEN_SET, 0, buf);
945 * IOCTL request handler to get power save mode.
947 * This function prepares the correct firmware command and
950 int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode)
953 struct mwifiex_adapter *adapter = priv->adapter;
957 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
959 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM;
960 sub_cmd = (*ps_mode) ? EN_AUTO_PS : DIS_AUTO_PS;
961 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
962 sub_cmd, BITMAP_STA_PS, NULL);
963 if ((!ret) && (sub_cmd == DIS_AUTO_PS))
964 ret = mwifiex_send_cmd_async(priv,
965 HostCmd_CMD_802_11_PS_MODE_ENH, GET_PS,
972 * IOCTL request handler to set/reset WPA IE.
974 * The supplied WPA IE is treated as a opaque buffer. Only the first field
975 * is checked to determine WPA version. If buffer length is zero, the existing
978 static int mwifiex_set_wpa_ie_helper(struct mwifiex_private *priv,
979 u8 *ie_data_ptr, u16 ie_len)
982 if (ie_len > sizeof(priv->wpa_ie)) {
983 dev_err(priv->adapter->dev,
984 "failed to copy WPA IE, too big\n");
987 memcpy(priv->wpa_ie, ie_data_ptr, ie_len);
988 priv->wpa_ie_len = (u8) ie_len;
989 dev_dbg(priv->adapter->dev, "cmd: Set Wpa_ie_len=%d IE=%#x\n",
990 priv->wpa_ie_len, priv->wpa_ie[0]);
992 if (priv->wpa_ie[0] == WLAN_EID_WPA) {
993 priv->sec_info.wpa_enabled = true;
994 } else if (priv->wpa_ie[0] == WLAN_EID_RSN) {
995 priv->sec_info.wpa2_enabled = true;
997 priv->sec_info.wpa_enabled = false;
998 priv->sec_info.wpa2_enabled = false;
1001 memset(priv->wpa_ie, 0, sizeof(priv->wpa_ie));
1002 priv->wpa_ie_len = 0;
1003 dev_dbg(priv->adapter->dev, "info: reset wpa_ie_len=%d IE=%#x\n",
1004 priv->wpa_ie_len, priv->wpa_ie[0]);
1005 priv->sec_info.wpa_enabled = false;
1006 priv->sec_info.wpa2_enabled = false;
1013 * IOCTL request handler to set/reset WAPI IE.
1015 * The supplied WAPI IE is treated as a opaque buffer. Only the first field
1016 * is checked to internally enable WAPI. If buffer length is zero, the existing
1019 static int mwifiex_set_wapi_ie(struct mwifiex_private *priv,
1020 u8 *ie_data_ptr, u16 ie_len)
1023 if (ie_len > sizeof(priv->wapi_ie)) {
1024 dev_dbg(priv->adapter->dev,
1025 "info: failed to copy WAPI IE, too big\n");
1028 memcpy(priv->wapi_ie, ie_data_ptr, ie_len);
1029 priv->wapi_ie_len = ie_len;
1030 dev_dbg(priv->adapter->dev, "cmd: Set wapi_ie_len=%d IE=%#x\n",
1031 priv->wapi_ie_len, priv->wapi_ie[0]);
1033 if (priv->wapi_ie[0] == WLAN_EID_BSS_AC_ACCESS_DELAY)
1034 priv->sec_info.wapi_enabled = true;
1036 memset(priv->wapi_ie, 0, sizeof(priv->wapi_ie));
1037 priv->wapi_ie_len = ie_len;
1038 dev_dbg(priv->adapter->dev,
1039 "info: Reset wapi_ie_len=%d IE=%#x\n",
1040 priv->wapi_ie_len, priv->wapi_ie[0]);
1041 priv->sec_info.wapi_enabled = false;
1047 * IOCTL request handler to set WAPI key.
1049 * This function prepares the correct firmware command and
1052 static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_private *priv,
1053 struct mwifiex_ds_encrypt_key *encrypt_key)
1056 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1057 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1062 * IOCTL request handler to set WEP network key.
1064 * This function prepares the correct firmware command and
1065 * issues it, after validation checks.
1067 static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
1068 struct mwifiex_ds_encrypt_key *encrypt_key)
1071 struct mwifiex_wep_key *wep_key;
1074 if (priv->wep_key_curr_index >= NUM_WEP_KEYS)
1075 priv->wep_key_curr_index = 0;
1076 wep_key = &priv->wep_key[priv->wep_key_curr_index];
1077 index = encrypt_key->key_index;
1078 if (encrypt_key->key_disable) {
1079 priv->sec_info.wep_status = MWIFIEX_802_11_WEP_DISABLED;
1080 } else if (!encrypt_key->key_len) {
1081 /* Copy the required key as the current key */
1082 wep_key = &priv->wep_key[index];
1083 if (!wep_key->key_length) {
1084 dev_err(priv->adapter->dev,
1085 "key not set, so cannot enable it\n");
1088 priv->wep_key_curr_index = (u16) index;
1089 priv->sec_info.wep_status = MWIFIEX_802_11_WEP_ENABLED;
1091 wep_key = &priv->wep_key[index];
1092 memset(wep_key, 0, sizeof(struct mwifiex_wep_key));
1093 /* Copy the key in the driver */
1094 memcpy(wep_key->key_material,
1095 encrypt_key->key_material,
1096 encrypt_key->key_len);
1097 wep_key->key_index = index;
1098 wep_key->key_length = encrypt_key->key_len;
1099 priv->sec_info.wep_status = MWIFIEX_802_11_WEP_ENABLED;
1101 if (wep_key->key_length) {
1102 /* Send request to firmware */
1103 ret = mwifiex_send_cmd_async(priv,
1104 HostCmd_CMD_802_11_KEY_MATERIAL,
1105 HostCmd_ACT_GEN_SET, 0, NULL);
1109 if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED)
1110 priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE;
1112 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
1114 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_MAC_CONTROL,
1115 HostCmd_ACT_GEN_SET, 0,
1116 &priv->curr_pkt_filter);
1122 * IOCTL request handler to set WPA key.
1124 * This function prepares the correct firmware command and
1125 * issues it, after validation checks.
1127 * Current driver only supports key length of up to 32 bytes.
1129 * This function can also be used to disable a currently set key.
1131 static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_private *priv,
1132 struct mwifiex_ds_encrypt_key *encrypt_key)
1135 u8 remove_key = false;
1136 struct host_cmd_ds_802_11_key_material *ibss_key;
1138 /* Current driver only supports key length of up to 32 bytes */
1139 if (encrypt_key->key_len > WLAN_MAX_KEY_LEN) {
1140 dev_err(priv->adapter->dev, "key length too long\n");
1144 if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
1146 * IBSS/WPA-None uses only one key (Group) for both receiving
1147 * and sending unicast and multicast packets.
1149 /* Send the key as PTK to firmware */
1150 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1151 ret = mwifiex_send_cmd_async(priv,
1152 HostCmd_CMD_802_11_KEY_MATERIAL,
1153 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1158 ibss_key = &priv->aes_key;
1160 sizeof(struct host_cmd_ds_802_11_key_material));
1161 /* Copy the key in the driver */
1162 memcpy(ibss_key->key_param_set.key, encrypt_key->key_material,
1163 encrypt_key->key_len);
1164 memcpy(&ibss_key->key_param_set.key_len, &encrypt_key->key_len,
1165 sizeof(ibss_key->key_param_set.key_len));
1166 ibss_key->key_param_set.key_type_id
1167 = cpu_to_le16(KEY_TYPE_ID_TKIP);
1168 ibss_key->key_param_set.key_info = cpu_to_le16(KEY_ENABLED);
1170 /* Send the key as GTK to firmware */
1171 encrypt_key->key_index = ~MWIFIEX_KEY_INDEX_UNICAST;
1174 if (!encrypt_key->key_index)
1175 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1178 ret = mwifiex_send_cmd_sync(priv,
1179 HostCmd_CMD_802_11_KEY_MATERIAL,
1180 HostCmd_ACT_GEN_SET, !(KEY_INFO_ENABLED),
1183 ret = mwifiex_send_cmd_sync(priv,
1184 HostCmd_CMD_802_11_KEY_MATERIAL,
1185 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1192 * IOCTL request handler to set/get network keys.
1194 * This is a generic key handling function which supports WEP, WPA
1198 mwifiex_sec_ioctl_encrypt_key(struct mwifiex_private *priv,
1199 struct mwifiex_ds_encrypt_key *encrypt_key)
1203 if (encrypt_key->is_wapi_key)
1204 status = mwifiex_sec_ioctl_set_wapi_key(priv, encrypt_key);
1205 else if (encrypt_key->key_len > WLAN_KEY_LEN_WEP104)
1206 status = mwifiex_sec_ioctl_set_wpa_key(priv, encrypt_key);
1208 status = mwifiex_sec_ioctl_set_wep_key(priv, encrypt_key);
1213 * This function returns the driver version.
1216 mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, char *version,
1225 ver.l = adapter->fw_release_number;
1226 sprintf(fw_ver, "%u.%u.%u.p%u", ver.c[2], ver.c[1], ver.c[0], ver.c[3]);
1228 snprintf(version, max_len, driver_version, fw_ver);
1230 dev_dbg(adapter->dev, "info: MWIFIEX VERSION: %s\n", version);
1236 * Sends IOCTL request to get signal information.
1238 * This function allocates the IOCTL request buffer, fills it
1239 * with requisite parameters and calls the IOCTL handler.
1241 int mwifiex_get_signal_info(struct mwifiex_private *priv,
1242 struct mwifiex_ds_get_signal *signal)
1246 signal->selector = ALL_RSSI_INFO_MASK;
1248 /* Signal info can be obtained only if connected */
1249 if (!priv->media_connected) {
1250 dev_dbg(priv->adapter->dev,
1251 "info: Can not get signal in disconnected state\n");
1255 status = mwifiex_send_cmd_sync(priv, HostCmd_CMD_RSSI_INFO,
1256 HostCmd_ACT_GEN_GET, 0, signal);
1259 if (signal->selector & BCN_RSSI_AVG_MASK)
1260 priv->w_stats.qual.level = signal->bcn_rssi_avg;
1261 if (signal->selector & BCN_NF_AVG_MASK)
1262 priv->w_stats.qual.noise = signal->bcn_nf_avg;
1269 * Sends IOCTL request to set encoding parameters.
1271 * This function allocates the IOCTL request buffer, fills it
1272 * with requisite parameters and calls the IOCTL handler.
1274 int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
1275 int key_len, u8 key_index, int disable)
1277 struct mwifiex_ds_encrypt_key encrypt_key;
1279 memset(&encrypt_key, 0, sizeof(struct mwifiex_ds_encrypt_key));
1280 encrypt_key.key_len = key_len;
1282 encrypt_key.key_index = key_index;
1284 memcpy(encrypt_key.key_material, key, key_len);
1286 encrypt_key.key_disable = true;
1289 return mwifiex_sec_ioctl_encrypt_key(priv, &encrypt_key);
1293 * Sends IOCTL request to get extended version.
1295 * This function allocates the IOCTL request buffer, fills it
1296 * with requisite parameters and calls the IOCTL handler.
1299 mwifiex_get_ver_ext(struct mwifiex_private *priv)
1301 struct mwifiex_ver_ext ver_ext;
1303 memset(&ver_ext, 0, sizeof(struct host_cmd_ds_version_ext));
1304 if (mwifiex_send_cmd_sync(priv, HostCmd_CMD_VERSION_EXT,
1305 HostCmd_ACT_GEN_GET, 0, &ver_ext))
1312 * Sends IOCTL request to get statistics information.
1314 * This function allocates the IOCTL request buffer, fills it
1315 * with requisite parameters and calls the IOCTL handler.
1318 mwifiex_get_stats_info(struct mwifiex_private *priv,
1319 struct mwifiex_ds_get_stats *log)
1323 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_GET_LOG,
1324 HostCmd_ACT_GEN_GET, 0, log);
1327 priv->w_stats.discard.fragment = log->fcs_error;
1328 priv->w_stats.discard.retries = log->retry;
1329 priv->w_stats.discard.misc = log->ack_failure;
1336 * IOCTL request handler to read/write register.
1338 * This function prepares the correct firmware command and
1341 * Access to the following registers are supported -
1348 static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private *priv,
1349 struct mwifiex_ds_reg_rw *reg_rw,
1354 switch (le32_to_cpu(reg_rw->type)) {
1355 case MWIFIEX_REG_MAC:
1356 cmd_no = HostCmd_CMD_MAC_REG_ACCESS;
1358 case MWIFIEX_REG_BBP:
1359 cmd_no = HostCmd_CMD_BBP_REG_ACCESS;
1361 case MWIFIEX_REG_RF:
1362 cmd_no = HostCmd_CMD_RF_REG_ACCESS;
1364 case MWIFIEX_REG_PMIC:
1365 cmd_no = HostCmd_CMD_PMIC_REG_ACCESS;
1367 case MWIFIEX_REG_CAU:
1368 cmd_no = HostCmd_CMD_CAU_REG_ACCESS;
1374 return mwifiex_send_cmd_sync(priv, cmd_no, action, 0, reg_rw);
1379 * Sends IOCTL request to write to a register.
1381 * This function allocates the IOCTL request buffer, fills it
1382 * with requisite parameters and calls the IOCTL handler.
1385 mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
1386 u32 reg_offset, u32 reg_value)
1388 struct mwifiex_ds_reg_rw reg_rw;
1390 reg_rw.type = cpu_to_le32(reg_type);
1391 reg_rw.offset = cpu_to_le32(reg_offset);
1392 reg_rw.value = cpu_to_le32(reg_value);
1394 return mwifiex_reg_mem_ioctl_reg_rw(priv, ®_rw, HostCmd_ACT_GEN_SET);
1398 * Sends IOCTL request to read from a register.
1400 * This function allocates the IOCTL request buffer, fills it
1401 * with requisite parameters and calls the IOCTL handler.
1404 mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
1405 u32 reg_offset, u32 *value)
1408 struct mwifiex_ds_reg_rw reg_rw;
1410 reg_rw.type = cpu_to_le32(reg_type);
1411 reg_rw.offset = cpu_to_le32(reg_offset);
1412 ret = mwifiex_reg_mem_ioctl_reg_rw(priv, ®_rw, HostCmd_ACT_GEN_GET);
1417 *value = le32_to_cpu(reg_rw.value);
1424 * Sends IOCTL request to read from EEPROM.
1426 * This function allocates the IOCTL request buffer, fills it
1427 * with requisite parameters and calls the IOCTL handler.
1430 mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
1434 struct mwifiex_ds_read_eeprom rd_eeprom;
1436 rd_eeprom.offset = cpu_to_le16((u16) offset);
1437 rd_eeprom.byte_count = cpu_to_le16((u16) bytes);
1439 /* Send request to firmware */
1440 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_EEPROM_ACCESS,
1441 HostCmd_ACT_GEN_GET, 0, &rd_eeprom);
1444 memcpy(value, rd_eeprom.value, MAX_EEPROM_DATA);
1449 * This function sets a generic IE. In addition to generic IE, it can
1450 * also handle WPA, WPA2 and WAPI IEs.
1453 mwifiex_set_gen_ie_helper(struct mwifiex_private *priv, u8 *ie_data_ptr,
1457 struct ieee_types_vendor_header *pvendor_ie;
1458 const u8 wpa_oui[] = { 0x00, 0x50, 0xf2, 0x01 };
1459 const u8 wps_oui[] = { 0x00, 0x50, 0xf2, 0x04 };
1461 /* If the passed length is zero, reset the buffer */
1463 priv->gen_ie_buf_len = 0;
1464 priv->wps.session_enable = false;
1467 } else if (!ie_data_ptr) {
1470 pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr;
1471 /* Test to see if it is a WPA IE, if not, then it is a gen IE */
1472 if (((pvendor_ie->element_id == WLAN_EID_WPA)
1473 && (!memcmp(pvendor_ie->oui, wpa_oui, sizeof(wpa_oui))))
1474 || (pvendor_ie->element_id == WLAN_EID_RSN)) {
1476 /* IE is a WPA/WPA2 IE so call set_wpa function */
1477 ret = mwifiex_set_wpa_ie_helper(priv, ie_data_ptr, ie_len);
1478 priv->wps.session_enable = false;
1481 } else if (pvendor_ie->element_id == WLAN_EID_BSS_AC_ACCESS_DELAY) {
1482 /* IE is a WAPI IE so call set_wapi function */
1483 ret = mwifiex_set_wapi_ie(priv, ie_data_ptr, ie_len);
1488 * Verify that the passed length is not larger than the
1489 * available space remaining in the buffer
1491 if (ie_len < (sizeof(priv->gen_ie_buf) - priv->gen_ie_buf_len)) {
1493 /* Test to see if it is a WPS IE, if so, enable
1496 pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr;
1497 if ((pvendor_ie->element_id == WLAN_EID_VENDOR_SPECIFIC)
1498 && (!memcmp(pvendor_ie->oui, wps_oui,
1499 sizeof(wps_oui)))) {
1500 priv->wps.session_enable = true;
1501 dev_dbg(priv->adapter->dev,
1502 "info: WPS Session Enabled.\n");
1505 /* Append the passed data to the end of the
1507 memcpy(priv->gen_ie_buf + priv->gen_ie_buf_len, ie_data_ptr,
1509 /* Increment the stored buffer length by the
1511 priv->gen_ie_buf_len += ie_len;
1513 /* Passed data does not fit in the remaining
1518 /* Return 0, or -1 for error case */
1523 * IOCTL request handler to set/get generic IE.
1525 * In addition to various generic IEs, this function can also be
1526 * used to set the ARP filter.
1528 static int mwifiex_misc_ioctl_gen_ie(struct mwifiex_private *priv,
1529 struct mwifiex_ds_misc_gen_ie *gen_ie,
1532 struct mwifiex_adapter *adapter = priv->adapter;
1534 switch (gen_ie->type) {
1535 case MWIFIEX_IE_TYPE_GEN_IE:
1536 if (action == HostCmd_ACT_GEN_GET) {
1537 gen_ie->len = priv->wpa_ie_len;
1538 memcpy(gen_ie->ie_data, priv->wpa_ie, gen_ie->len);
1540 mwifiex_set_gen_ie_helper(priv, gen_ie->ie_data,
1544 case MWIFIEX_IE_TYPE_ARP_FILTER:
1545 memset(adapter->arp_filter, 0, sizeof(adapter->arp_filter));
1546 if (gen_ie->len > ARP_FILTER_MAX_BUF_SIZE) {
1547 adapter->arp_filter_size = 0;
1548 dev_err(adapter->dev, "invalid ARP filter size\n");
1551 memcpy(adapter->arp_filter, gen_ie->ie_data,
1553 adapter->arp_filter_size = gen_ie->len;
1557 dev_err(adapter->dev, "invalid IE type\n");
1564 * Sends IOCTL request to set a generic IE.
1566 * This function allocates the IOCTL request buffer, fills it
1567 * with requisite parameters and calls the IOCTL handler.
1570 mwifiex_set_gen_ie(struct mwifiex_private *priv, u8 *ie, int ie_len)
1572 struct mwifiex_ds_misc_gen_ie gen_ie;
1574 if (ie_len > IW_CUSTOM_MAX)
1577 gen_ie.type = MWIFIEX_IE_TYPE_GEN_IE;
1578 gen_ie.len = ie_len;
1579 memcpy(gen_ie.ie_data, ie, ie_len);
1580 if (mwifiex_misc_ioctl_gen_ie(priv, &gen_ie, HostCmd_ACT_GEN_SET))