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;
58 struct cmd_ctrl_node
*cmd_queued
;
60 if (!adapter
->cmd_queued
)
63 cmd_queued
= adapter
->cmd_queued
;
64 adapter
->cmd_queued
= NULL
;
66 dev_dbg(adapter
->dev
, "cmd pending\n");
67 atomic_inc(&adapter
->cmd_pending
);
69 /* Status pending, wake up main process */
70 queue_work(adapter
->workqueue
, &adapter
->main_work
);
72 /* Wait for completion */
73 wait_event_interruptible(adapter
->cmd_wait_q
.wait
,
74 *(cmd_queued
->condition
));
75 if (!*(cmd_queued
->condition
))
79 mwifiex_cancel_pending_ioctl(adapter
);
80 dev_dbg(adapter
->dev
, "cmd cancel\n");
83 status
= adapter
->cmd_wait_q
.status
;
84 adapter
->cmd_wait_q
.status
= 0;
90 * This function prepares the correct firmware command and
91 * issues it to set the multicast list.
93 * This function can be used to enable promiscuous mode, or enable all
94 * multicast packets, or to enable selective multicast.
96 int mwifiex_request_set_multicast_list(struct mwifiex_private
*priv
,
97 struct mwifiex_multicast_list
*mcast_list
)
102 old_pkt_filter
= priv
->curr_pkt_filter
;
104 if (mcast_list
->mode
== MWIFIEX_PROMISC_MODE
) {
105 dev_dbg(priv
->adapter
->dev
, "info: Enable Promiscuous mode\n");
106 priv
->curr_pkt_filter
|= HostCmd_ACT_MAC_PROMISCUOUS_ENABLE
;
107 priv
->curr_pkt_filter
&=
108 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE
;
111 priv
->curr_pkt_filter
&= ~HostCmd_ACT_MAC_PROMISCUOUS_ENABLE
;
112 if (mcast_list
->mode
== MWIFIEX_MULTICAST_MODE
) {
113 dev_dbg(priv
->adapter
->dev
,
114 "info: Enabling All Multicast!\n");
115 priv
->curr_pkt_filter
|=
116 HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE
;
118 priv
->curr_pkt_filter
&=
119 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE
;
120 if (mcast_list
->num_multicast_addr
) {
121 dev_dbg(priv
->adapter
->dev
,
122 "info: Set multicast list=%d\n",
123 mcast_list
->num_multicast_addr
);
124 /* Set multicast addresses to firmware */
125 if (old_pkt_filter
== priv
->curr_pkt_filter
) {
126 /* Send request to firmware */
127 ret
= mwifiex_send_cmd_async(priv
,
128 HostCmd_CMD_MAC_MULTICAST_ADR
,
129 HostCmd_ACT_GEN_SET
, 0,
132 /* Send request to firmware */
133 ret
= mwifiex_send_cmd_async(priv
,
134 HostCmd_CMD_MAC_MULTICAST_ADR
,
135 HostCmd_ACT_GEN_SET
, 0,
141 dev_dbg(priv
->adapter
->dev
,
142 "info: old_pkt_filter=%#x, curr_pkt_filter=%#x\n",
143 old_pkt_filter
, priv
->curr_pkt_filter
);
144 if (old_pkt_filter
!= priv
->curr_pkt_filter
) {
145 ret
= mwifiex_send_cmd_async(priv
, HostCmd_CMD_MAC_CONTROL
,
147 0, &priv
->curr_pkt_filter
);
154 * This function fills bss descriptor structure using provided
157 int mwifiex_fill_new_bss_desc(struct mwifiex_private
*priv
,
158 struct cfg80211_bss
*bss
,
159 struct mwifiex_bssdescriptor
*bss_desc
)
163 struct mwifiex_bss_priv
*bss_priv
= (void *)bss
->priv
;
165 beacon_ie
= kmemdup(bss
->information_elements
, bss
->len_beacon_ies
,
168 dev_err(priv
->adapter
->dev
, " failed to alloc beacon_ie\n");
172 memcpy(bss_desc
->mac_address
, bss
->bssid
, ETH_ALEN
);
173 bss_desc
->rssi
= bss
->signal
;
174 bss_desc
->beacon_buf
= beacon_ie
;
175 bss_desc
->beacon_buf_size
= bss
->len_beacon_ies
;
176 bss_desc
->beacon_period
= bss
->beacon_interval
;
177 bss_desc
->cap_info_bitmap
= bss
->capability
;
178 bss_desc
->bss_band
= bss_priv
->band
;
179 bss_desc
->fw_tsf
= bss_priv
->fw_tsf
;
180 bss_desc
->timestamp
= bss
->tsf
;
181 if (bss_desc
->cap_info_bitmap
& WLAN_CAPABILITY_PRIVACY
) {
182 dev_dbg(priv
->adapter
->dev
, "info: InterpretIE: AP WEP enabled\n");
183 bss_desc
->privacy
= MWIFIEX_802_11_PRIV_FILTER_8021X_WEP
;
185 bss_desc
->privacy
= MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL
;
187 if (bss_desc
->cap_info_bitmap
& WLAN_CAPABILITY_IBSS
)
188 bss_desc
->bss_mode
= NL80211_IFTYPE_ADHOC
;
190 bss_desc
->bss_mode
= NL80211_IFTYPE_STATION
;
192 ret
= mwifiex_update_bss_desc_with_ie(priv
->adapter
, bss_desc
);
199 * In Ad-Hoc mode, the IBSS is created if not found in scan list.
200 * In both Ad-Hoc and infra mode, an deauthentication is performed
203 int mwifiex_bss_start(struct mwifiex_private
*priv
, struct cfg80211_bss
*bss
,
204 struct cfg80211_ssid
*req_ssid
)
207 struct mwifiex_adapter
*adapter
= priv
->adapter
;
208 struct mwifiex_bssdescriptor
*bss_desc
= NULL
;
210 priv
->scan_block
= false;
213 /* Allocate and fill new bss descriptor */
214 bss_desc
= kzalloc(sizeof(struct mwifiex_bssdescriptor
),
217 dev_err(priv
->adapter
->dev
, " failed to alloc bss_desc\n");
221 ret
= mwifiex_fill_new_bss_desc(priv
, bss
, bss_desc
);
226 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
) {
228 ret
= mwifiex_deauthenticate(priv
, NULL
);
232 ret
= mwifiex_check_network_compatibility(priv
, bss_desc
);
236 dev_dbg(adapter
->dev
, "info: SSID found in scan list ... "
239 if (!netif_queue_stopped(priv
->netdev
))
240 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
241 if (netif_carrier_ok(priv
->netdev
))
242 netif_carrier_off(priv
->netdev
);
244 /* Clear any past association response stored for
245 * application retrieval */
246 priv
->assoc_rsp_size
= 0;
247 ret
= mwifiex_associate(priv
, bss_desc
);
249 /* If auth type is auto and association fails using open mode,
250 * try to connect using shared mode */
251 if (ret
== WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG
&&
252 priv
->sec_info
.is_authtype_auto
&&
253 priv
->sec_info
.wep_enabled
) {
254 priv
->sec_info
.authentication_mode
=
255 NL80211_AUTHTYPE_SHARED_KEY
;
256 ret
= mwifiex_associate(priv
, bss_desc
);
260 cfg80211_put_bss(bss
);
263 /* If the requested SSID matches current SSID, return */
264 if (bss_desc
&& bss_desc
->ssid
.ssid_len
&&
265 (!mwifiex_ssid_cmp(&priv
->curr_bss_params
.bss_descriptor
.
266 ssid
, &bss_desc
->ssid
))) {
271 /* Exit Adhoc mode first */
272 dev_dbg(adapter
->dev
, "info: Sending Adhoc Stop\n");
273 ret
= mwifiex_deauthenticate(priv
, NULL
);
277 priv
->adhoc_is_link_sensed
= false;
279 ret
= mwifiex_check_network_compatibility(priv
, bss_desc
);
281 if (!netif_queue_stopped(priv
->netdev
))
282 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
283 if (netif_carrier_ok(priv
->netdev
))
284 netif_carrier_off(priv
->netdev
);
287 dev_dbg(adapter
->dev
, "info: network found in scan"
288 " list. Joining...\n");
289 ret
= mwifiex_adhoc_join(priv
, bss_desc
);
291 cfg80211_put_bss(bss
);
293 dev_dbg(adapter
->dev
, "info: Network not found in "
294 "the list, creating adhoc with ssid = %s\n",
296 ret
= mwifiex_adhoc_start(priv
, req_ssid
);
306 * IOCTL request handler to set host sleep configuration.
308 * This function prepares the correct firmware command and
311 static int mwifiex_set_hs_params(struct mwifiex_private
*priv
, u16 action
,
312 int cmd_type
, struct mwifiex_ds_hs_cfg
*hs_cfg
)
315 struct mwifiex_adapter
*adapter
= priv
->adapter
;
323 case HostCmd_ACT_GEN_SET
:
324 if (adapter
->pps_uapsd_mode
) {
325 dev_dbg(adapter
->dev
, "info: Host Sleep IOCTL"
326 " is blocked in UAPSD/PPS mode\n");
330 if (hs_cfg
->is_invoke_hostcmd
) {
331 if (hs_cfg
->conditions
== HOST_SLEEP_CFG_CANCEL
) {
332 if (!adapter
->is_hs_configured
)
333 /* Already cancelled */
335 /* Save previous condition */
336 prev_cond
= le32_to_cpu(adapter
->hs_cfg
338 adapter
->hs_cfg
.conditions
=
339 cpu_to_le32(hs_cfg
->conditions
);
340 } else if (hs_cfg
->conditions
) {
341 adapter
->hs_cfg
.conditions
=
342 cpu_to_le32(hs_cfg
->conditions
);
343 adapter
->hs_cfg
.gpio
= (u8
)hs_cfg
->gpio
;
345 adapter
->hs_cfg
.gap
= (u8
)hs_cfg
->gap
;
346 } else if (adapter
->hs_cfg
.conditions
347 == cpu_to_le32(HOST_SLEEP_CFG_CANCEL
)) {
348 /* Return failure if no parameters for HS
353 if (cmd_type
== MWIFIEX_SYNC_CMD
)
354 status
= mwifiex_send_cmd_sync(priv
,
355 HostCmd_CMD_802_11_HS_CFG_ENH
,
356 HostCmd_ACT_GEN_SET
, 0,
359 status
= mwifiex_send_cmd_async(priv
,
360 HostCmd_CMD_802_11_HS_CFG_ENH
,
361 HostCmd_ACT_GEN_SET
, 0,
363 if (hs_cfg
->conditions
== HOST_SLEEP_CFG_CANCEL
)
364 /* Restore previous condition */
365 adapter
->hs_cfg
.conditions
=
366 cpu_to_le32(prev_cond
);
368 adapter
->hs_cfg
.conditions
=
369 cpu_to_le32(hs_cfg
->conditions
);
370 adapter
->hs_cfg
.gpio
= (u8
)hs_cfg
->gpio
;
371 adapter
->hs_cfg
.gap
= (u8
)hs_cfg
->gap
;
374 case HostCmd_ACT_GEN_GET
:
375 hs_cfg
->conditions
= le32_to_cpu(adapter
->hs_cfg
.conditions
);
376 hs_cfg
->gpio
= adapter
->hs_cfg
.gpio
;
377 hs_cfg
->gap
= adapter
->hs_cfg
.gap
;
388 * Sends IOCTL request to cancel the existing Host Sleep configuration.
390 * This function allocates the IOCTL request buffer, fills it
391 * with requisite parameters and calls the IOCTL handler.
393 int mwifiex_cancel_hs(struct mwifiex_private
*priv
, int cmd_type
)
395 struct mwifiex_ds_hs_cfg hscfg
;
397 hscfg
.conditions
= HOST_SLEEP_CFG_CANCEL
;
398 hscfg
.is_invoke_hostcmd
= true;
400 return mwifiex_set_hs_params(priv
, HostCmd_ACT_GEN_SET
,
403 EXPORT_SYMBOL_GPL(mwifiex_cancel_hs
);
406 * Sends IOCTL request to cancel the existing Host Sleep configuration.
408 * This function allocates the IOCTL request buffer, fills it
409 * with requisite parameters and calls the IOCTL handler.
411 int mwifiex_enable_hs(struct mwifiex_adapter
*adapter
)
413 struct mwifiex_ds_hs_cfg hscfg
;
415 if (adapter
->hs_activated
) {
416 dev_dbg(adapter
->dev
, "cmd: HS Already actived\n");
420 adapter
->hs_activate_wait_q_woken
= false;
422 memset(&hscfg
, 0, sizeof(struct mwifiex_ds_hs_cfg
));
423 hscfg
.is_invoke_hostcmd
= true;
425 if (mwifiex_set_hs_params(mwifiex_get_priv(adapter
,
426 MWIFIEX_BSS_ROLE_STA
),
427 HostCmd_ACT_GEN_SET
, MWIFIEX_SYNC_CMD
,
429 dev_err(adapter
->dev
, "IOCTL request HS enable failed\n");
433 wait_event_interruptible(adapter
->hs_activate_wait_q
,
434 adapter
->hs_activate_wait_q_woken
);
438 EXPORT_SYMBOL_GPL(mwifiex_enable_hs
);
441 * IOCTL request handler to get BSS information.
443 * This function collates the information from different driver structures
444 * to send to the user.
446 int mwifiex_get_bss_info(struct mwifiex_private
*priv
,
447 struct mwifiex_bss_info
*info
)
449 struct mwifiex_adapter
*adapter
= priv
->adapter
;
450 struct mwifiex_bssdescriptor
*bss_desc
;
455 bss_desc
= &priv
->curr_bss_params
.bss_descriptor
;
457 info
->bss_mode
= priv
->bss_mode
;
459 memcpy(&info
->ssid
, &bss_desc
->ssid
, sizeof(struct cfg80211_ssid
));
461 memcpy(&info
->bssid
, &bss_desc
->mac_address
, ETH_ALEN
);
463 info
->bss_chan
= bss_desc
->channel
;
465 memcpy(info
->country_code
, adapter
->country_code
,
466 IEEE80211_COUNTRY_STRING_LEN
);
468 info
->media_connected
= priv
->media_connected
;
470 info
->max_power_level
= priv
->max_tx_power_level
;
471 info
->min_power_level
= priv
->min_tx_power_level
;
473 info
->adhoc_state
= priv
->adhoc_state
;
475 info
->bcn_nf_last
= priv
->bcn_nf_last
;
477 if (priv
->sec_info
.wep_enabled
)
478 info
->wep_status
= true;
480 info
->wep_status
= false;
482 info
->is_hs_configured
= adapter
->is_hs_configured
;
483 info
->is_deep_sleep
= adapter
->is_deep_sleep
;
489 * The function disables auto deep sleep mode.
491 int mwifiex_disable_auto_ds(struct mwifiex_private
*priv
)
493 struct mwifiex_ds_auto_ds auto_ds
;
495 auto_ds
.auto_ds
= DEEP_SLEEP_OFF
;
497 return mwifiex_send_cmd_sync(priv
, HostCmd_CMD_802_11_PS_MODE_ENH
,
498 DIS_AUTO_PS
, BITMAP_AUTO_DS
, &auto_ds
);
500 EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds
);
503 * IOCTL request handler to set/get active channel.
505 * This function performs validity checking on channel/frequency
506 * compatibility and returns failure if not valid.
508 int mwifiex_bss_set_channel(struct mwifiex_private
*priv
,
509 struct mwifiex_chan_freq_power
*chan
)
511 struct mwifiex_adapter
*adapter
= priv
->adapter
;
512 struct mwifiex_chan_freq_power
*cfp
= NULL
;
517 if (!chan
->channel
&& !chan
->freq
)
519 if (adapter
->adhoc_start_band
& BAND_AN
)
520 adapter
->adhoc_start_band
= BAND_G
| BAND_B
| BAND_GN
;
521 else if (adapter
->adhoc_start_band
& BAND_A
)
522 adapter
->adhoc_start_band
= BAND_G
| BAND_B
;
524 if (chan
->channel
<= MAX_CHANNEL_BAND_BG
)
525 cfp
= mwifiex_get_cfp(priv
, 0, (u16
) chan
->channel
, 0);
527 cfp
= mwifiex_get_cfp(priv
, BAND_A
,
528 (u16
) chan
->channel
, 0);
530 if (adapter
->adhoc_11n_enabled
)
531 adapter
->adhoc_start_band
= BAND_A
534 adapter
->adhoc_start_band
= BAND_A
;
538 if (chan
->freq
<= MAX_FREQUENCY_BAND_BG
)
539 cfp
= mwifiex_get_cfp(priv
, 0, 0, chan
->freq
);
541 cfp
= mwifiex_get_cfp(priv
, BAND_A
, 0, chan
->freq
);
543 if (adapter
->adhoc_11n_enabled
)
544 adapter
->adhoc_start_band
= BAND_A
547 adapter
->adhoc_start_band
= BAND_A
;
551 if (!cfp
|| !cfp
->channel
) {
552 dev_err(adapter
->dev
, "invalid channel/freq\n");
555 priv
->adhoc_channel
= (u8
) cfp
->channel
;
556 chan
->channel
= cfp
->channel
;
557 chan
->freq
= cfp
->freq
;
563 * IOCTL request handler to set/get Ad-Hoc channel.
565 * This function prepares the correct firmware command and
566 * issues it to set or get the ad-hoc channel.
568 static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private
*priv
,
569 u16 action
, u16
*channel
)
571 if (action
== HostCmd_ACT_GEN_GET
) {
572 if (!priv
->media_connected
) {
573 *channel
= priv
->adhoc_channel
;
577 priv
->adhoc_channel
= (u8
) *channel
;
580 return mwifiex_send_cmd_sync(priv
, HostCmd_CMD_802_11_RF_CHANNEL
,
585 * IOCTL request handler to change Ad-Hoc channel.
587 * This function allocates the IOCTL request buffer, fills it
588 * with requisite parameters and calls the IOCTL handler.
590 * The function follows the following steps to perform the change -
591 * - Get current IBSS information
592 * - Get current channel
593 * - If no change is required, return
594 * - If not connected, change channel and return
598 * - Perform specific SSID scan with same SSID
599 * - Start/Join the IBSS
602 mwifiex_drv_change_adhoc_chan(struct mwifiex_private
*priv
, u16 channel
)
605 struct mwifiex_bss_info bss_info
;
606 struct mwifiex_ssid_bssid ssid_bssid
;
608 struct cfg80211_bss
*bss
= NULL
;
609 struct ieee80211_channel
*chan
;
610 enum ieee80211_band band
;
612 memset(&bss_info
, 0, sizeof(bss_info
));
614 /* Get BSS information */
615 if (mwifiex_get_bss_info(priv
, &bss_info
))
618 /* Get current channel */
619 ret
= mwifiex_bss_ioctl_ibss_channel(priv
, HostCmd_ACT_GEN_GET
,
622 if (curr_chan
== channel
) {
626 dev_dbg(priv
->adapter
->dev
, "cmd: updating channel from %d to %d\n",
629 if (!bss_info
.media_connected
) {
635 memset(&ssid_bssid
, 0, ETH_ALEN
);
636 ret
= mwifiex_deauthenticate(priv
, ssid_bssid
.bssid
);
638 ret
= mwifiex_bss_ioctl_ibss_channel(priv
, HostCmd_ACT_GEN_SET
,
641 /* Do specific SSID scanning */
642 if (mwifiex_request_scan(priv
, &bss_info
.ssid
)) {
647 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
648 chan
= __ieee80211_get_channel(priv
->wdev
->wiphy
,
649 ieee80211_channel_to_frequency(channel
,
652 /* Find the BSS we want using available scan results */
653 bss
= cfg80211_get_bss(priv
->wdev
->wiphy
, chan
, bss_info
.bssid
,
654 bss_info
.ssid
.ssid
, bss_info
.ssid
.ssid_len
,
655 WLAN_CAPABILITY_ESS
, WLAN_CAPABILITY_ESS
);
657 wiphy_warn(priv
->wdev
->wiphy
, "assoc: bss %pM not in scan results\n",
660 ret
= mwifiex_bss_start(priv
, bss
, &bss_info
.ssid
);
666 * IOCTL request handler to get rate.
668 * This function prepares the correct firmware command and
669 * issues it to get the current rate if it is connected,
670 * otherwise, the function returns the lowest supported rate
673 static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private
*priv
,
674 struct mwifiex_rate_cfg
*rate_cfg
)
676 rate_cfg
->is_rate_auto
= priv
->is_data_rate_auto
;
677 return mwifiex_send_cmd_sync(priv
, HostCmd_CMD_802_11_TX_RATE_QUERY
,
678 HostCmd_ACT_GEN_GET
, 0, NULL
);
682 * IOCTL request handler to set rate.
684 * This function prepares the correct firmware command and
685 * issues it to set the current rate.
687 * The function also performs validation checking on the supplied value.
689 static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private
*priv
,
690 struct mwifiex_rate_cfg
*rate_cfg
)
692 u8 rates
[MWIFIEX_SUPPORTED_RATES
];
695 u16 bitmap_rates
[MAX_BITMAP_RATES_SIZE
];
697 struct mwifiex_adapter
*adapter
= priv
->adapter
;
699 if (rate_cfg
->is_rate_auto
) {
700 memset(bitmap_rates
, 0, sizeof(bitmap_rates
));
701 /* Support all HR/DSSS rates */
702 bitmap_rates
[0] = 0x000F;
703 /* Support all OFDM rates */
704 bitmap_rates
[1] = 0x00FF;
705 /* Support all HT-MCSs rate */
706 for (i
= 0; i
< ARRAY_SIZE(priv
->bitmap_rates
) - 3; i
++)
707 bitmap_rates
[i
+ 2] = 0xFFFF;
708 bitmap_rates
[9] = 0x3FFF;
710 memset(rates
, 0, sizeof(rates
));
711 mwifiex_get_active_data_rates(priv
, rates
);
713 for (i
= 0; (rate
[i
] && i
< MWIFIEX_SUPPORTED_RATES
); i
++) {
714 dev_dbg(adapter
->dev
, "info: rate=%#x wanted=%#x\n",
715 rate
[i
], rate_cfg
->rate
);
716 if ((rate
[i
] & 0x7f) == (rate_cfg
->rate
& 0x7f))
719 if ((i
== MWIFIEX_SUPPORTED_RATES
) || !rate
[i
]) {
720 dev_err(adapter
->dev
, "fixed data rate %#x is out "
721 "of range\n", rate_cfg
->rate
);
724 memset(bitmap_rates
, 0, sizeof(bitmap_rates
));
726 rate_index
= mwifiex_data_rate_to_index(rate_cfg
->rate
);
728 /* Only allow b/g rates to be set */
729 if (rate_index
>= MWIFIEX_RATE_INDEX_HRDSSS0
&&
730 rate_index
<= MWIFIEX_RATE_INDEX_HRDSSS3
) {
731 bitmap_rates
[0] = 1 << rate_index
;
733 rate_index
-= 1; /* There is a 0x00 in the table */
734 if (rate_index
>= MWIFIEX_RATE_INDEX_OFDM0
&&
735 rate_index
<= MWIFIEX_RATE_INDEX_OFDM7
)
736 bitmap_rates
[1] = 1 << (rate_index
-
737 MWIFIEX_RATE_INDEX_OFDM0
);
741 ret
= mwifiex_send_cmd_sync(priv
, HostCmd_CMD_TX_RATE_CFG
,
742 HostCmd_ACT_GEN_SET
, 0, bitmap_rates
);
748 * IOCTL request handler to set/get rate.
750 * This function can be used to set/get either the rate value or the
753 static int mwifiex_rate_ioctl_cfg(struct mwifiex_private
*priv
,
754 struct mwifiex_rate_cfg
*rate_cfg
)
761 if (rate_cfg
->action
== HostCmd_ACT_GEN_GET
)
762 status
= mwifiex_rate_ioctl_get_rate_value(priv
, rate_cfg
);
764 status
= mwifiex_rate_ioctl_set_rate_value(priv
, rate_cfg
);
770 * Sends IOCTL request to get the data rate.
772 * This function allocates the IOCTL request buffer, fills it
773 * with requisite parameters and calls the IOCTL handler.
775 int mwifiex_drv_get_data_rate(struct mwifiex_private
*priv
,
776 struct mwifiex_rate_cfg
*rate
)
780 memset(rate
, 0, sizeof(struct mwifiex_rate_cfg
));
781 rate
->action
= HostCmd_ACT_GEN_GET
;
782 ret
= mwifiex_rate_ioctl_cfg(priv
, rate
);
785 if (rate
->is_rate_auto
)
786 rate
->rate
= mwifiex_index_to_data_rate(priv
,
791 rate
->rate
= priv
->data_rate
;
800 * IOCTL request handler to set tx power configuration.
802 * This function prepares the correct firmware command and
805 * For non-auto power mode, all the following power groups are set -
806 * - Modulation class HR/DSSS
807 * - Modulation class OFDM
808 * - Modulation class HTBW20
809 * - Modulation class HTBW40
811 int mwifiex_set_tx_power(struct mwifiex_private
*priv
,
812 struct mwifiex_power_cfg
*power_cfg
)
815 struct host_cmd_ds_txpwr_cfg
*txp_cfg
;
816 struct mwifiex_types_power_group
*pg_tlv
;
817 struct mwifiex_power_group
*pg
;
821 if (!power_cfg
->is_power_auto
) {
822 dbm
= (u16
) power_cfg
->power_level
;
823 if ((dbm
< priv
->min_tx_power_level
) ||
824 (dbm
> priv
->max_tx_power_level
)) {
825 dev_err(priv
->adapter
->dev
, "txpower value %d dBm"
826 " is out of range (%d dBm-%d dBm)\n",
827 dbm
, priv
->min_tx_power_level
,
828 priv
->max_tx_power_level
);
832 buf
= kzalloc(MWIFIEX_SIZE_OF_CMD_BUFFER
, GFP_KERNEL
);
834 dev_err(priv
->adapter
->dev
, "%s: failed to alloc cmd buffer\n",
839 txp_cfg
= (struct host_cmd_ds_txpwr_cfg
*) buf
;
840 txp_cfg
->action
= cpu_to_le16(HostCmd_ACT_GEN_SET
);
841 if (!power_cfg
->is_power_auto
) {
842 txp_cfg
->mode
= cpu_to_le32(1);
843 pg_tlv
= (struct mwifiex_types_power_group
*)
844 (buf
+ sizeof(struct host_cmd_ds_txpwr_cfg
));
845 pg_tlv
->type
= TLV_TYPE_POWER_GROUP
;
846 pg_tlv
->length
= 4 * sizeof(struct mwifiex_power_group
);
847 pg
= (struct mwifiex_power_group
*)
848 (buf
+ sizeof(struct host_cmd_ds_txpwr_cfg
)
849 + sizeof(struct mwifiex_types_power_group
));
850 /* Power group for modulation class HR/DSSS */
851 pg
->first_rate_code
= 0x00;
852 pg
->last_rate_code
= 0x03;
853 pg
->modulation_class
= MOD_CLASS_HR_DSSS
;
855 pg
->power_min
= (s8
) dbm
;
856 pg
->power_max
= (s8
) dbm
;
858 /* Power group for modulation class OFDM */
859 pg
->first_rate_code
= 0x00;
860 pg
->last_rate_code
= 0x07;
861 pg
->modulation_class
= MOD_CLASS_OFDM
;
863 pg
->power_min
= (s8
) dbm
;
864 pg
->power_max
= (s8
) dbm
;
866 /* Power group for modulation class HTBW20 */
867 pg
->first_rate_code
= 0x00;
868 pg
->last_rate_code
= 0x20;
869 pg
->modulation_class
= MOD_CLASS_HT
;
871 pg
->power_min
= (s8
) dbm
;
872 pg
->power_max
= (s8
) dbm
;
873 pg
->ht_bandwidth
= HT_BW_20
;
875 /* Power group for modulation class HTBW40 */
876 pg
->first_rate_code
= 0x00;
877 pg
->last_rate_code
= 0x20;
878 pg
->modulation_class
= MOD_CLASS_HT
;
880 pg
->power_min
= (s8
) dbm
;
881 pg
->power_max
= (s8
) dbm
;
882 pg
->ht_bandwidth
= HT_BW_40
;
884 ret
= mwifiex_send_cmd_sync(priv
, HostCmd_CMD_TXPWR_CFG
,
885 HostCmd_ACT_GEN_SET
, 0, buf
);
892 * IOCTL request handler to get power save mode.
894 * This function prepares the correct firmware command and
897 int mwifiex_drv_set_power(struct mwifiex_private
*priv
, u32
*ps_mode
)
900 struct mwifiex_adapter
*adapter
= priv
->adapter
;
904 adapter
->ps_mode
= MWIFIEX_802_11_POWER_MODE_PSP
;
906 adapter
->ps_mode
= MWIFIEX_802_11_POWER_MODE_CAM
;
907 sub_cmd
= (*ps_mode
) ? EN_AUTO_PS
: DIS_AUTO_PS
;
908 ret
= mwifiex_send_cmd_sync(priv
, HostCmd_CMD_802_11_PS_MODE_ENH
,
909 sub_cmd
, BITMAP_STA_PS
, NULL
);
910 if ((!ret
) && (sub_cmd
== DIS_AUTO_PS
))
911 ret
= mwifiex_send_cmd_async(priv
,
912 HostCmd_CMD_802_11_PS_MODE_ENH
,
919 * IOCTL request handler to set/reset WPA IE.
921 * The supplied WPA IE is treated as a opaque buffer. Only the first field
922 * is checked to determine WPA version. If buffer length is zero, the existing
925 static int mwifiex_set_wpa_ie_helper(struct mwifiex_private
*priv
,
926 u8
*ie_data_ptr
, u16 ie_len
)
929 if (ie_len
> sizeof(priv
->wpa_ie
)) {
930 dev_err(priv
->adapter
->dev
,
931 "failed to copy WPA IE, too big\n");
934 memcpy(priv
->wpa_ie
, ie_data_ptr
, ie_len
);
935 priv
->wpa_ie_len
= (u8
) ie_len
;
936 dev_dbg(priv
->adapter
->dev
, "cmd: Set Wpa_ie_len=%d IE=%#x\n",
937 priv
->wpa_ie_len
, priv
->wpa_ie
[0]);
939 if (priv
->wpa_ie
[0] == WLAN_EID_WPA
) {
940 priv
->sec_info
.wpa_enabled
= true;
941 } else if (priv
->wpa_ie
[0] == WLAN_EID_RSN
) {
942 priv
->sec_info
.wpa2_enabled
= true;
944 priv
->sec_info
.wpa_enabled
= false;
945 priv
->sec_info
.wpa2_enabled
= false;
948 memset(priv
->wpa_ie
, 0, sizeof(priv
->wpa_ie
));
949 priv
->wpa_ie_len
= 0;
950 dev_dbg(priv
->adapter
->dev
, "info: reset wpa_ie_len=%d IE=%#x\n",
951 priv
->wpa_ie_len
, priv
->wpa_ie
[0]);
952 priv
->sec_info
.wpa_enabled
= false;
953 priv
->sec_info
.wpa2_enabled
= false;
960 * IOCTL request handler to set/reset WAPI IE.
962 * The supplied WAPI IE is treated as a opaque buffer. Only the first field
963 * is checked to internally enable WAPI. If buffer length is zero, the existing
966 static int mwifiex_set_wapi_ie(struct mwifiex_private
*priv
,
967 u8
*ie_data_ptr
, u16 ie_len
)
970 if (ie_len
> sizeof(priv
->wapi_ie
)) {
971 dev_dbg(priv
->adapter
->dev
,
972 "info: failed to copy WAPI IE, too big\n");
975 memcpy(priv
->wapi_ie
, ie_data_ptr
, ie_len
);
976 priv
->wapi_ie_len
= ie_len
;
977 dev_dbg(priv
->adapter
->dev
, "cmd: Set wapi_ie_len=%d IE=%#x\n",
978 priv
->wapi_ie_len
, priv
->wapi_ie
[0]);
980 if (priv
->wapi_ie
[0] == WLAN_EID_BSS_AC_ACCESS_DELAY
)
981 priv
->sec_info
.wapi_enabled
= true;
983 memset(priv
->wapi_ie
, 0, sizeof(priv
->wapi_ie
));
984 priv
->wapi_ie_len
= ie_len
;
985 dev_dbg(priv
->adapter
->dev
,
986 "info: Reset wapi_ie_len=%d IE=%#x\n",
987 priv
->wapi_ie_len
, priv
->wapi_ie
[0]);
988 priv
->sec_info
.wapi_enabled
= false;
994 * IOCTL request handler to set/reset WPS IE.
996 * The supplied WPS IE is treated as a opaque buffer. Only the first field
997 * is checked to internally enable WPS. If buffer length is zero, the existing
1000 static int mwifiex_set_wps_ie(struct mwifiex_private
*priv
,
1001 u8
*ie_data_ptr
, u16 ie_len
)
1004 priv
->wps_ie
= kzalloc(MWIFIEX_MAX_VSIE_LEN
, GFP_KERNEL
);
1007 if (ie_len
> sizeof(priv
->wps_ie
)) {
1008 dev_dbg(priv
->adapter
->dev
,
1009 "info: failed to copy WPS IE, too big\n");
1010 kfree(priv
->wps_ie
);
1013 memcpy(priv
->wps_ie
, ie_data_ptr
, ie_len
);
1014 priv
->wps_ie_len
= ie_len
;
1015 dev_dbg(priv
->adapter
->dev
, "cmd: Set wps_ie_len=%d IE=%#x\n",
1016 priv
->wps_ie_len
, priv
->wps_ie
[0]);
1018 kfree(priv
->wps_ie
);
1019 priv
->wps_ie_len
= ie_len
;
1020 dev_dbg(priv
->adapter
->dev
,
1021 "info: Reset wps_ie_len=%d\n", priv
->wps_ie_len
);
1027 * IOCTL request handler to set WAPI key.
1029 * This function prepares the correct firmware command and
1032 static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_private
*priv
,
1033 struct mwifiex_ds_encrypt_key
*encrypt_key
)
1036 return mwifiex_send_cmd_sync(priv
, HostCmd_CMD_802_11_KEY_MATERIAL
,
1037 HostCmd_ACT_GEN_SET
, KEY_INFO_ENABLED
,
1042 * IOCTL request handler to set WEP network key.
1044 * This function prepares the correct firmware command and
1045 * issues it, after validation checks.
1047 static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private
*priv
,
1048 struct mwifiex_ds_encrypt_key
*encrypt_key
)
1051 struct mwifiex_wep_key
*wep_key
;
1054 if (priv
->wep_key_curr_index
>= NUM_WEP_KEYS
)
1055 priv
->wep_key_curr_index
= 0;
1056 wep_key
= &priv
->wep_key
[priv
->wep_key_curr_index
];
1057 index
= encrypt_key
->key_index
;
1058 if (encrypt_key
->key_disable
) {
1059 priv
->sec_info
.wep_enabled
= 0;
1060 } else if (!encrypt_key
->key_len
) {
1061 /* Copy the required key as the current key */
1062 wep_key
= &priv
->wep_key
[index
];
1063 if (!wep_key
->key_length
) {
1064 dev_err(priv
->adapter
->dev
,
1065 "key not set, so cannot enable it\n");
1068 priv
->wep_key_curr_index
= (u16
) index
;
1069 priv
->sec_info
.wep_enabled
= 1;
1071 wep_key
= &priv
->wep_key
[index
];
1072 memset(wep_key
, 0, sizeof(struct mwifiex_wep_key
));
1073 /* Copy the key in the driver */
1074 memcpy(wep_key
->key_material
,
1075 encrypt_key
->key_material
,
1076 encrypt_key
->key_len
);
1077 wep_key
->key_index
= index
;
1078 wep_key
->key_length
= encrypt_key
->key_len
;
1079 priv
->sec_info
.wep_enabled
= 1;
1081 if (wep_key
->key_length
) {
1082 /* Send request to firmware */
1083 ret
= mwifiex_send_cmd_async(priv
,
1084 HostCmd_CMD_802_11_KEY_MATERIAL
,
1085 HostCmd_ACT_GEN_SET
, 0, NULL
);
1089 if (priv
->sec_info
.wep_enabled
)
1090 priv
->curr_pkt_filter
|= HostCmd_ACT_MAC_WEP_ENABLE
;
1092 priv
->curr_pkt_filter
&= ~HostCmd_ACT_MAC_WEP_ENABLE
;
1094 ret
= mwifiex_send_cmd_sync(priv
, HostCmd_CMD_MAC_CONTROL
,
1095 HostCmd_ACT_GEN_SET
, 0,
1096 &priv
->curr_pkt_filter
);
1102 * IOCTL request handler to set WPA key.
1104 * This function prepares the correct firmware command and
1105 * issues it, after validation checks.
1107 * Current driver only supports key length of up to 32 bytes.
1109 * This function can also be used to disable a currently set key.
1111 static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_private
*priv
,
1112 struct mwifiex_ds_encrypt_key
*encrypt_key
)
1115 u8 remove_key
= false;
1116 struct host_cmd_ds_802_11_key_material
*ibss_key
;
1118 /* Current driver only supports key length of up to 32 bytes */
1119 if (encrypt_key
->key_len
> WLAN_MAX_KEY_LEN
) {
1120 dev_err(priv
->adapter
->dev
, "key length too long\n");
1124 if (priv
->bss_mode
== NL80211_IFTYPE_ADHOC
) {
1126 * IBSS/WPA-None uses only one key (Group) for both receiving
1127 * and sending unicast and multicast packets.
1129 /* Send the key as PTK to firmware */
1130 encrypt_key
->key_index
= MWIFIEX_KEY_INDEX_UNICAST
;
1131 ret
= mwifiex_send_cmd_async(priv
,
1132 HostCmd_CMD_802_11_KEY_MATERIAL
,
1133 HostCmd_ACT_GEN_SET
,
1134 KEY_INFO_ENABLED
, encrypt_key
);
1138 ibss_key
= &priv
->aes_key
;
1140 sizeof(struct host_cmd_ds_802_11_key_material
));
1141 /* Copy the key in the driver */
1142 memcpy(ibss_key
->key_param_set
.key
, encrypt_key
->key_material
,
1143 encrypt_key
->key_len
);
1144 memcpy(&ibss_key
->key_param_set
.key_len
, &encrypt_key
->key_len
,
1145 sizeof(ibss_key
->key_param_set
.key_len
));
1146 ibss_key
->key_param_set
.key_type_id
1147 = cpu_to_le16(KEY_TYPE_ID_TKIP
);
1148 ibss_key
->key_param_set
.key_info
= cpu_to_le16(KEY_ENABLED
);
1150 /* Send the key as GTK to firmware */
1151 encrypt_key
->key_index
= ~MWIFIEX_KEY_INDEX_UNICAST
;
1154 if (!encrypt_key
->key_index
)
1155 encrypt_key
->key_index
= MWIFIEX_KEY_INDEX_UNICAST
;
1158 ret
= mwifiex_send_cmd_sync(priv
,
1159 HostCmd_CMD_802_11_KEY_MATERIAL
,
1160 HostCmd_ACT_GEN_SET
,
1161 !KEY_INFO_ENABLED
, encrypt_key
);
1163 ret
= mwifiex_send_cmd_sync(priv
,
1164 HostCmd_CMD_802_11_KEY_MATERIAL
,
1165 HostCmd_ACT_GEN_SET
,
1166 KEY_INFO_ENABLED
, encrypt_key
);
1172 * IOCTL request handler to set/get network keys.
1174 * This is a generic key handling function which supports WEP, WPA
1178 mwifiex_sec_ioctl_encrypt_key(struct mwifiex_private
*priv
,
1179 struct mwifiex_ds_encrypt_key
*encrypt_key
)
1183 if (encrypt_key
->is_wapi_key
)
1184 status
= mwifiex_sec_ioctl_set_wapi_key(priv
, encrypt_key
);
1185 else if (encrypt_key
->key_len
> WLAN_KEY_LEN_WEP104
)
1186 status
= mwifiex_sec_ioctl_set_wpa_key(priv
, encrypt_key
);
1188 status
= mwifiex_sec_ioctl_set_wep_key(priv
, encrypt_key
);
1193 * This function returns the driver version.
1196 mwifiex_drv_get_driver_version(struct mwifiex_adapter
*adapter
, char *version
,
1205 ver
.l
= adapter
->fw_release_number
;
1206 sprintf(fw_ver
, "%u.%u.%u.p%u", ver
.c
[2], ver
.c
[1], ver
.c
[0], ver
.c
[3]);
1208 snprintf(version
, max_len
, driver_version
, fw_ver
);
1210 dev_dbg(adapter
->dev
, "info: MWIFIEX VERSION: %s\n", version
);
1216 * Sends IOCTL request to set encoding parameters.
1218 * This function allocates the IOCTL request buffer, fills it
1219 * with requisite parameters and calls the IOCTL handler.
1221 int mwifiex_set_encode(struct mwifiex_private
*priv
, const u8
*key
,
1222 int key_len
, u8 key_index
, int disable
)
1224 struct mwifiex_ds_encrypt_key encrypt_key
;
1226 memset(&encrypt_key
, 0, sizeof(struct mwifiex_ds_encrypt_key
));
1227 encrypt_key
.key_len
= key_len
;
1229 encrypt_key
.key_index
= key_index
;
1231 memcpy(encrypt_key
.key_material
, key
, key_len
);
1233 encrypt_key
.key_disable
= true;
1236 return mwifiex_sec_ioctl_encrypt_key(priv
, &encrypt_key
);
1240 * Sends IOCTL request to get extended version.
1242 * This function allocates the IOCTL request buffer, fills it
1243 * with requisite parameters and calls the IOCTL handler.
1246 mwifiex_get_ver_ext(struct mwifiex_private
*priv
)
1248 struct mwifiex_ver_ext ver_ext
;
1250 memset(&ver_ext
, 0, sizeof(struct host_cmd_ds_version_ext
));
1251 if (mwifiex_send_cmd_sync(priv
, HostCmd_CMD_VERSION_EXT
,
1252 HostCmd_ACT_GEN_GET
, 0, &ver_ext
))
1259 * Sends IOCTL request to get statistics information.
1261 * This function allocates the IOCTL request buffer, fills it
1262 * with requisite parameters and calls the IOCTL handler.
1265 mwifiex_get_stats_info(struct mwifiex_private
*priv
,
1266 struct mwifiex_ds_get_stats
*log
)
1268 return mwifiex_send_cmd_sync(priv
, HostCmd_CMD_802_11_GET_LOG
,
1269 HostCmd_ACT_GEN_GET
, 0, log
);
1273 * IOCTL request handler to read/write register.
1275 * This function prepares the correct firmware command and
1278 * Access to the following registers are supported -
1285 static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private
*priv
,
1286 struct mwifiex_ds_reg_rw
*reg_rw
,
1291 switch (le32_to_cpu(reg_rw
->type
)) {
1292 case MWIFIEX_REG_MAC
:
1293 cmd_no
= HostCmd_CMD_MAC_REG_ACCESS
;
1295 case MWIFIEX_REG_BBP
:
1296 cmd_no
= HostCmd_CMD_BBP_REG_ACCESS
;
1298 case MWIFIEX_REG_RF
:
1299 cmd_no
= HostCmd_CMD_RF_REG_ACCESS
;
1301 case MWIFIEX_REG_PMIC
:
1302 cmd_no
= HostCmd_CMD_PMIC_REG_ACCESS
;
1304 case MWIFIEX_REG_CAU
:
1305 cmd_no
= HostCmd_CMD_CAU_REG_ACCESS
;
1311 return mwifiex_send_cmd_sync(priv
, cmd_no
, action
, 0, reg_rw
);
1316 * Sends IOCTL request to write to a register.
1318 * This function allocates the IOCTL request buffer, fills it
1319 * with requisite parameters and calls the IOCTL handler.
1322 mwifiex_reg_write(struct mwifiex_private
*priv
, u32 reg_type
,
1323 u32 reg_offset
, u32 reg_value
)
1325 struct mwifiex_ds_reg_rw reg_rw
;
1327 reg_rw
.type
= cpu_to_le32(reg_type
);
1328 reg_rw
.offset
= cpu_to_le32(reg_offset
);
1329 reg_rw
.value
= cpu_to_le32(reg_value
);
1331 return mwifiex_reg_mem_ioctl_reg_rw(priv
, ®_rw
, HostCmd_ACT_GEN_SET
);
1335 * Sends IOCTL request to read from a register.
1337 * This function allocates the IOCTL request buffer, fills it
1338 * with requisite parameters and calls the IOCTL handler.
1341 mwifiex_reg_read(struct mwifiex_private
*priv
, u32 reg_type
,
1342 u32 reg_offset
, u32
*value
)
1345 struct mwifiex_ds_reg_rw reg_rw
;
1347 reg_rw
.type
= cpu_to_le32(reg_type
);
1348 reg_rw
.offset
= cpu_to_le32(reg_offset
);
1349 ret
= mwifiex_reg_mem_ioctl_reg_rw(priv
, ®_rw
, HostCmd_ACT_GEN_GET
);
1354 *value
= le32_to_cpu(reg_rw
.value
);
1361 * Sends IOCTL request to read from EEPROM.
1363 * This function allocates the IOCTL request buffer, fills it
1364 * with requisite parameters and calls the IOCTL handler.
1367 mwifiex_eeprom_read(struct mwifiex_private
*priv
, u16 offset
, u16 bytes
,
1371 struct mwifiex_ds_read_eeprom rd_eeprom
;
1373 rd_eeprom
.offset
= cpu_to_le16((u16
) offset
);
1374 rd_eeprom
.byte_count
= cpu_to_le16((u16
) bytes
);
1376 /* Send request to firmware */
1377 ret
= mwifiex_send_cmd_sync(priv
, HostCmd_CMD_802_11_EEPROM_ACCESS
,
1378 HostCmd_ACT_GEN_GET
, 0, &rd_eeprom
);
1381 memcpy(value
, rd_eeprom
.value
, MAX_EEPROM_DATA
);
1386 * This function sets a generic IE. In addition to generic IE, it can
1387 * also handle WPA, WPA2 and WAPI IEs.
1390 mwifiex_set_gen_ie_helper(struct mwifiex_private
*priv
, u8
*ie_data_ptr
,
1394 struct ieee_types_vendor_header
*pvendor_ie
;
1395 const u8 wpa_oui
[] = { 0x00, 0x50, 0xf2, 0x01 };
1396 const u8 wps_oui
[] = { 0x00, 0x50, 0xf2, 0x04 };
1398 /* If the passed length is zero, reset the buffer */
1400 priv
->gen_ie_buf_len
= 0;
1401 priv
->wps
.session_enable
= false;
1404 } else if (!ie_data_ptr
) {
1407 pvendor_ie
= (struct ieee_types_vendor_header
*) ie_data_ptr
;
1408 /* Test to see if it is a WPA IE, if not, then it is a gen IE */
1409 if (((pvendor_ie
->element_id
== WLAN_EID_WPA
) &&
1410 (!memcmp(pvendor_ie
->oui
, wpa_oui
, sizeof(wpa_oui
)))) ||
1411 (pvendor_ie
->element_id
== WLAN_EID_RSN
)) {
1413 /* IE is a WPA/WPA2 IE so call set_wpa function */
1414 ret
= mwifiex_set_wpa_ie_helper(priv
, ie_data_ptr
, ie_len
);
1415 priv
->wps
.session_enable
= false;
1418 } else if (pvendor_ie
->element_id
== WLAN_EID_BSS_AC_ACCESS_DELAY
) {
1419 /* IE is a WAPI IE so call set_wapi function */
1420 ret
= mwifiex_set_wapi_ie(priv
, ie_data_ptr
, ie_len
);
1425 * Verify that the passed length is not larger than the
1426 * available space remaining in the buffer
1428 if (ie_len
< (sizeof(priv
->gen_ie_buf
) - priv
->gen_ie_buf_len
)) {
1430 /* Test to see if it is a WPS IE, if so, enable
1433 pvendor_ie
= (struct ieee_types_vendor_header
*) ie_data_ptr
;
1434 if ((pvendor_ie
->element_id
== WLAN_EID_VENDOR_SPECIFIC
) &&
1435 (!memcmp(pvendor_ie
->oui
, wps_oui
, sizeof(wps_oui
)))) {
1436 priv
->wps
.session_enable
= true;
1437 dev_dbg(priv
->adapter
->dev
,
1438 "info: WPS Session Enabled.\n");
1439 ret
= mwifiex_set_wps_ie(priv
, ie_data_ptr
, ie_len
);
1442 /* Append the passed data to the end of the
1444 memcpy(priv
->gen_ie_buf
+ priv
->gen_ie_buf_len
, ie_data_ptr
,
1446 /* Increment the stored buffer length by the
1448 priv
->gen_ie_buf_len
+= ie_len
;
1450 /* Passed data does not fit in the remaining
1455 /* Return 0, or -1 for error case */
1460 * IOCTL request handler to set/get generic IE.
1462 * In addition to various generic IEs, this function can also be
1463 * used to set the ARP filter.
1465 static int mwifiex_misc_ioctl_gen_ie(struct mwifiex_private
*priv
,
1466 struct mwifiex_ds_misc_gen_ie
*gen_ie
,
1469 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1471 switch (gen_ie
->type
) {
1472 case MWIFIEX_IE_TYPE_GEN_IE
:
1473 if (action
== HostCmd_ACT_GEN_GET
) {
1474 gen_ie
->len
= priv
->wpa_ie_len
;
1475 memcpy(gen_ie
->ie_data
, priv
->wpa_ie
, gen_ie
->len
);
1477 mwifiex_set_gen_ie_helper(priv
, gen_ie
->ie_data
,
1481 case MWIFIEX_IE_TYPE_ARP_FILTER
:
1482 memset(adapter
->arp_filter
, 0, sizeof(adapter
->arp_filter
));
1483 if (gen_ie
->len
> ARP_FILTER_MAX_BUF_SIZE
) {
1484 adapter
->arp_filter_size
= 0;
1485 dev_err(adapter
->dev
, "invalid ARP filter size\n");
1488 memcpy(adapter
->arp_filter
, gen_ie
->ie_data
,
1490 adapter
->arp_filter_size
= gen_ie
->len
;
1494 dev_err(adapter
->dev
, "invalid IE type\n");
1501 * Sends IOCTL request to set a generic IE.
1503 * This function allocates the IOCTL request buffer, fills it
1504 * with requisite parameters and calls the IOCTL handler.
1507 mwifiex_set_gen_ie(struct mwifiex_private
*priv
, u8
*ie
, int ie_len
)
1509 struct mwifiex_ds_misc_gen_ie gen_ie
;
1511 if (ie_len
> IEEE_MAX_IE_SIZE
)
1514 gen_ie
.type
= MWIFIEX_IE_TYPE_GEN_IE
;
1515 gen_ie
.len
= ie_len
;
1516 memcpy(gen_ie
.ie_data
, ie
, ie_len
);
1517 if (mwifiex_misc_ioctl_gen_ie(priv
, &gen_ie
, HostCmd_ACT_GEN_SET
))