2 * Marvell Wireless LAN device driver: functions for station ioctl
4 * Copyright (C) 2011-2014, 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
;
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
,
58 struct cmd_ctrl_node
*cmd_queued
)
62 /* Wait for completion */
63 status
= wait_event_interruptible_timeout(adapter
->cmd_wait_q
.wait
,
64 *(cmd_queued
->condition
),
69 mwifiex_dbg(adapter
, ERROR
, "cmd_wait_q terminated: %d\n",
71 mwifiex_cancel_all_pending_cmd(adapter
);
75 status
= adapter
->cmd_wait_q
.status
;
76 adapter
->cmd_wait_q
.status
= 0;
82 * This function prepares the correct firmware command and
83 * issues it to set the multicast list.
85 * This function can be used to enable promiscuous mode, or enable all
86 * multicast packets, or to enable selective multicast.
88 int mwifiex_request_set_multicast_list(struct mwifiex_private
*priv
,
89 struct mwifiex_multicast_list
*mcast_list
)
94 old_pkt_filter
= priv
->curr_pkt_filter
;
96 if (mcast_list
->mode
== MWIFIEX_PROMISC_MODE
) {
97 mwifiex_dbg(priv
->adapter
, INFO
,
98 "info: Enable Promiscuous mode\n");
99 priv
->curr_pkt_filter
|= HostCmd_ACT_MAC_PROMISCUOUS_ENABLE
;
100 priv
->curr_pkt_filter
&=
101 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE
;
104 priv
->curr_pkt_filter
&= ~HostCmd_ACT_MAC_PROMISCUOUS_ENABLE
;
105 if (mcast_list
->mode
== MWIFIEX_ALL_MULTI_MODE
) {
106 mwifiex_dbg(priv
->adapter
, INFO
,
107 "info: Enabling All Multicast!\n");
108 priv
->curr_pkt_filter
|=
109 HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE
;
111 priv
->curr_pkt_filter
&=
112 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE
;
113 mwifiex_dbg(priv
->adapter
, INFO
,
114 "info: Set multicast list=%d\n",
115 mcast_list
->num_multicast_addr
);
116 /* Send multicast addresses to firmware */
117 ret
= mwifiex_send_cmd(priv
,
118 HostCmd_CMD_MAC_MULTICAST_ADR
,
119 HostCmd_ACT_GEN_SET
, 0,
123 mwifiex_dbg(priv
->adapter
, INFO
,
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(priv
, HostCmd_CMD_MAC_CONTROL
,
129 0, &priv
->curr_pkt_filter
, false);
136 * This function fills bss descriptor structure using provided
138 * beacon_ie buffer is allocated in this function. It is caller's
139 * responsibility to free the memory.
141 int mwifiex_fill_new_bss_desc(struct mwifiex_private
*priv
,
142 struct cfg80211_bss
*bss
,
143 struct mwifiex_bssdescriptor
*bss_desc
)
146 size_t beacon_ie_len
;
147 struct mwifiex_bss_priv
*bss_priv
= (void *)bss
->priv
;
148 const struct cfg80211_bss_ies
*ies
;
151 ies
= rcu_dereference(bss
->ies
);
152 beacon_ie
= kmemdup(ies
->data
, ies
->len
, GFP_ATOMIC
);
153 beacon_ie_len
= ies
->len
;
154 bss_desc
->timestamp
= ies
->tsf
;
158 mwifiex_dbg(priv
->adapter
, ERROR
,
159 " failed to alloc beacon_ie\n");
163 memcpy(bss_desc
->mac_address
, bss
->bssid
, ETH_ALEN
);
164 bss_desc
->rssi
= bss
->signal
;
165 /* The caller of this function will free beacon_ie */
166 bss_desc
->beacon_buf
= beacon_ie
;
167 bss_desc
->beacon_buf_size
= beacon_ie_len
;
168 bss_desc
->beacon_period
= bss
->beacon_interval
;
169 bss_desc
->cap_info_bitmap
= bss
->capability
;
170 bss_desc
->bss_band
= bss_priv
->band
;
171 bss_desc
->fw_tsf
= bss_priv
->fw_tsf
;
172 if (bss_desc
->cap_info_bitmap
& WLAN_CAPABILITY_PRIVACY
) {
173 mwifiex_dbg(priv
->adapter
, INFO
,
174 "info: InterpretIE: AP WEP enabled\n");
175 bss_desc
->privacy
= MWIFIEX_802_11_PRIV_FILTER_8021X_WEP
;
177 bss_desc
->privacy
= MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL
;
179 if (bss_desc
->cap_info_bitmap
& WLAN_CAPABILITY_IBSS
)
180 bss_desc
->bss_mode
= NL80211_IFTYPE_ADHOC
;
182 bss_desc
->bss_mode
= NL80211_IFTYPE_STATION
;
184 /* Disable 11ac by default. Enable it only where there
185 * exist VHT_CAP IE in AP beacon
187 bss_desc
->disable_11ac
= true;
189 if (bss_desc
->cap_info_bitmap
& WLAN_CAPABILITY_SPECTRUM_MGMT
)
190 bss_desc
->sensed_11h
= true;
192 return mwifiex_update_bss_desc_with_ie(priv
->adapter
, bss_desc
);
195 void mwifiex_dnld_txpwr_table(struct mwifiex_private
*priv
)
197 if (priv
->adapter
->dt_node
) {
198 char txpwr
[] = {"marvell,00_txpwrlimit"};
200 memcpy(&txpwr
[8], priv
->adapter
->country_code
, 2);
201 mwifiex_dnld_dt_cfgdata(priv
, priv
->adapter
->dt_node
, txpwr
);
205 static int mwifiex_process_country_ie(struct mwifiex_private
*priv
,
206 struct cfg80211_bss
*bss
)
208 const u8
*country_ie
;
210 struct mwifiex_802_11d_domain_reg
*domain_info
=
211 &priv
->adapter
->domain_reg
;
214 country_ie
= ieee80211_bss_get_ie(bss
, WLAN_EID_COUNTRY
);
220 country_ie_len
= country_ie
[1];
221 if (country_ie_len
< IEEE80211_COUNTRY_IE_MIN_LEN
) {
226 if (!strncmp(priv
->adapter
->country_code
, &country_ie
[2], 2)) {
228 mwifiex_dbg(priv
->adapter
, INFO
,
229 "11D: skip setting domain info in FW\n");
232 memcpy(priv
->adapter
->country_code
, &country_ie
[2], 2);
234 domain_info
->country_code
[0] = country_ie
[2];
235 domain_info
->country_code
[1] = country_ie
[3];
236 domain_info
->country_code
[2] = ' ';
238 country_ie_len
-= IEEE80211_COUNTRY_STRING_LEN
;
240 domain_info
->no_of_triplet
=
241 country_ie_len
/ sizeof(struct ieee80211_country_ie_triplet
);
243 memcpy((u8
*)domain_info
->triplet
,
244 &country_ie
[2] + IEEE80211_COUNTRY_STRING_LEN
, country_ie_len
);
248 if (mwifiex_send_cmd(priv
, HostCmd_CMD_802_11D_DOMAIN_INFO
,
249 HostCmd_ACT_GEN_SET
, 0, NULL
, false)) {
250 mwifiex_dbg(priv
->adapter
, ERROR
,
251 "11D: setting domain info in FW fail\n");
255 mwifiex_dnld_txpwr_table(priv
);
261 * In Ad-Hoc mode, the IBSS is created if not found in scan list.
262 * In both Ad-Hoc and infra mode, an deauthentication is performed
265 int mwifiex_bss_start(struct mwifiex_private
*priv
, struct cfg80211_bss
*bss
,
266 struct cfg80211_ssid
*req_ssid
)
269 struct mwifiex_adapter
*adapter
= priv
->adapter
;
270 struct mwifiex_bssdescriptor
*bss_desc
= NULL
;
272 priv
->scan_block
= false;
275 if (adapter
->region_code
== 0x00)
276 mwifiex_process_country_ie(priv
, bss
);
278 /* Allocate and fill new bss descriptor */
279 bss_desc
= kzalloc(sizeof(struct mwifiex_bssdescriptor
),
284 ret
= mwifiex_fill_new_bss_desc(priv
, bss
, bss_desc
);
289 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
||
290 priv
->bss_mode
== NL80211_IFTYPE_P2P_CLIENT
) {
296 if (mwifiex_band_to_radio_type(bss_desc
->bss_band
) ==
297 HostCmd_SCAN_RADIO_TYPE_BG
) {
298 config_bands
= BAND_B
| BAND_G
| BAND_GN
;
300 config_bands
= BAND_A
| BAND_AN
;
301 if (adapter
->fw_bands
& BAND_AAC
)
302 config_bands
|= BAND_AAC
;
305 if (!((config_bands
| adapter
->fw_bands
) & ~adapter
->fw_bands
))
306 adapter
->config_bands
= config_bands
;
308 ret
= mwifiex_check_network_compatibility(priv
, bss_desc
);
312 if (mwifiex_11h_get_csa_closed_channel(priv
) ==
313 (u8
)bss_desc
->channel
) {
314 mwifiex_dbg(adapter
, ERROR
,
315 "Attempt to reconnect on csa closed chan(%d)\n",
321 mwifiex_dbg(adapter
, INFO
,
322 "info: SSID found in scan list ...\t"
325 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
326 if (netif_carrier_ok(priv
->netdev
))
327 netif_carrier_off(priv
->netdev
);
329 /* Clear any past association response stored for
330 * application retrieval */
331 priv
->assoc_rsp_size
= 0;
332 ret
= mwifiex_associate(priv
, bss_desc
);
334 /* If auth type is auto and association fails using open mode,
335 * try to connect using shared mode */
336 if (ret
== WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG
&&
337 priv
->sec_info
.is_authtype_auto
&&
338 priv
->sec_info
.wep_enabled
) {
339 priv
->sec_info
.authentication_mode
=
340 NL80211_AUTHTYPE_SHARED_KEY
;
341 ret
= mwifiex_associate(priv
, bss_desc
);
345 cfg80211_put_bss(priv
->adapter
->wiphy
, bss
);
348 /* If the requested SSID matches current SSID, return */
349 if (bss_desc
&& bss_desc
->ssid
.ssid_len
&&
350 (!mwifiex_ssid_cmp(&priv
->curr_bss_params
.bss_descriptor
.
351 ssid
, &bss_desc
->ssid
))) {
356 priv
->adhoc_is_link_sensed
= false;
358 ret
= mwifiex_check_network_compatibility(priv
, bss_desc
);
360 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
361 if (netif_carrier_ok(priv
->netdev
))
362 netif_carrier_off(priv
->netdev
);
365 mwifiex_dbg(adapter
, INFO
,
366 "info: network found in scan\t"
367 " list. Joining...\n");
368 ret
= mwifiex_adhoc_join(priv
, bss_desc
);
370 cfg80211_put_bss(priv
->adapter
->wiphy
, bss
);
372 mwifiex_dbg(adapter
, INFO
,
373 "info: Network not found in\t"
374 "the list, creating adhoc with ssid = %s\n",
376 ret
= mwifiex_adhoc_start(priv
, req_ssid
);
381 /* beacon_ie buffer was allocated in function
382 * mwifiex_fill_new_bss_desc(). Free it now.
385 kfree(bss_desc
->beacon_buf
);
389 priv
->attempted_bss_desc
= NULL
;
395 * IOCTL request handler to set host sleep configuration.
397 * This function prepares the correct firmware command and
400 int mwifiex_set_hs_params(struct mwifiex_private
*priv
, u16 action
,
401 int cmd_type
, struct mwifiex_ds_hs_cfg
*hs_cfg
)
404 struct mwifiex_adapter
*adapter
= priv
->adapter
;
412 case HostCmd_ACT_GEN_SET
:
413 if (adapter
->pps_uapsd_mode
) {
414 mwifiex_dbg(adapter
, INFO
,
415 "info: Host Sleep IOCTL\t"
416 "is blocked in UAPSD/PPS mode\n");
420 if (hs_cfg
->is_invoke_hostcmd
) {
421 if (hs_cfg
->conditions
== HS_CFG_CANCEL
) {
422 if (!adapter
->is_hs_configured
)
423 /* Already cancelled */
425 /* Save previous condition */
426 prev_cond
= le32_to_cpu(adapter
->hs_cfg
428 adapter
->hs_cfg
.conditions
=
429 cpu_to_le32(hs_cfg
->conditions
);
430 } else if (hs_cfg
->conditions
) {
431 adapter
->hs_cfg
.conditions
=
432 cpu_to_le32(hs_cfg
->conditions
);
433 adapter
->hs_cfg
.gpio
= (u8
)hs_cfg
->gpio
;
435 adapter
->hs_cfg
.gap
= (u8
)hs_cfg
->gap
;
436 } else if (adapter
->hs_cfg
.conditions
==
437 cpu_to_le32(HS_CFG_CANCEL
)) {
438 /* Return failure if no parameters for HS
444 status
= mwifiex_send_cmd(priv
,
445 HostCmd_CMD_802_11_HS_CFG_ENH
,
446 HostCmd_ACT_GEN_SET
, 0,
448 cmd_type
== MWIFIEX_SYNC_CMD
);
450 if (hs_cfg
->conditions
== HS_CFG_CANCEL
)
451 /* Restore previous condition */
452 adapter
->hs_cfg
.conditions
=
453 cpu_to_le32(prev_cond
);
455 adapter
->hs_cfg
.conditions
=
456 cpu_to_le32(hs_cfg
->conditions
);
457 adapter
->hs_cfg
.gpio
= (u8
)hs_cfg
->gpio
;
458 adapter
->hs_cfg
.gap
= (u8
)hs_cfg
->gap
;
461 case HostCmd_ACT_GEN_GET
:
462 hs_cfg
->conditions
= le32_to_cpu(adapter
->hs_cfg
.conditions
);
463 hs_cfg
->gpio
= adapter
->hs_cfg
.gpio
;
464 hs_cfg
->gap
= adapter
->hs_cfg
.gap
;
475 * Sends IOCTL request to cancel the existing Host Sleep configuration.
477 * This function allocates the IOCTL request buffer, fills it
478 * with requisite parameters and calls the IOCTL handler.
480 int mwifiex_cancel_hs(struct mwifiex_private
*priv
, int cmd_type
)
482 struct mwifiex_ds_hs_cfg hscfg
;
484 hscfg
.conditions
= HS_CFG_CANCEL
;
485 hscfg
.is_invoke_hostcmd
= true;
487 return mwifiex_set_hs_params(priv
, HostCmd_ACT_GEN_SET
,
490 EXPORT_SYMBOL_GPL(mwifiex_cancel_hs
);
493 * Sends IOCTL request to cancel the existing Host Sleep configuration.
495 * This function allocates the IOCTL request buffer, fills it
496 * with requisite parameters and calls the IOCTL handler.
498 int mwifiex_enable_hs(struct mwifiex_adapter
*adapter
)
500 struct mwifiex_ds_hs_cfg hscfg
;
501 struct mwifiex_private
*priv
;
504 if (disconnect_on_suspend
) {
505 for (i
= 0; i
< adapter
->priv_num
; i
++) {
506 priv
= adapter
->priv
[i
];
508 mwifiex_deauthenticate(priv
, NULL
);
512 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
514 if (priv
&& priv
->sched_scanning
) {
516 if (priv
->wdev
.wiphy
->wowlan_config
&&
517 !priv
->wdev
.wiphy
->wowlan_config
->nd_config
) {
519 mwifiex_dbg(adapter
, CMD
, "aborting bgscan!\n");
520 mwifiex_stop_bg_scan(priv
);
521 cfg80211_sched_scan_stopped(priv
->wdev
.wiphy
, 0);
527 if (adapter
->hs_activated
) {
528 mwifiex_dbg(adapter
, CMD
,
529 "cmd: HS Already activated\n");
533 adapter
->hs_activate_wait_q_woken
= false;
535 memset(&hscfg
, 0, sizeof(hscfg
));
536 hscfg
.is_invoke_hostcmd
= true;
538 adapter
->hs_enabling
= true;
539 mwifiex_cancel_all_pending_cmd(adapter
);
541 if (mwifiex_set_hs_params(mwifiex_get_priv(adapter
,
542 MWIFIEX_BSS_ROLE_STA
),
543 HostCmd_ACT_GEN_SET
, MWIFIEX_SYNC_CMD
,
545 mwifiex_dbg(adapter
, ERROR
,
546 "IOCTL request HS enable failed\n");
550 if (wait_event_interruptible_timeout(adapter
->hs_activate_wait_q
,
551 adapter
->hs_activate_wait_q_woken
,
553 mwifiex_dbg(adapter
, ERROR
,
554 "hs_activate_wait_q terminated\n");
560 EXPORT_SYMBOL_GPL(mwifiex_enable_hs
);
563 * IOCTL request handler to get BSS information.
565 * This function collates the information from different driver structures
566 * to send to the user.
568 int mwifiex_get_bss_info(struct mwifiex_private
*priv
,
569 struct mwifiex_bss_info
*info
)
571 struct mwifiex_adapter
*adapter
= priv
->adapter
;
572 struct mwifiex_bssdescriptor
*bss_desc
;
577 bss_desc
= &priv
->curr_bss_params
.bss_descriptor
;
579 info
->bss_mode
= priv
->bss_mode
;
581 memcpy(&info
->ssid
, &bss_desc
->ssid
, sizeof(struct cfg80211_ssid
));
583 memcpy(&info
->bssid
, &bss_desc
->mac_address
, ETH_ALEN
);
585 info
->bss_chan
= bss_desc
->channel
;
587 memcpy(info
->country_code
, adapter
->country_code
,
588 IEEE80211_COUNTRY_STRING_LEN
);
590 info
->media_connected
= priv
->media_connected
;
592 info
->max_power_level
= priv
->max_tx_power_level
;
593 info
->min_power_level
= priv
->min_tx_power_level
;
595 info
->adhoc_state
= priv
->adhoc_state
;
597 info
->bcn_nf_last
= priv
->bcn_nf_last
;
599 if (priv
->sec_info
.wep_enabled
)
600 info
->wep_status
= true;
602 info
->wep_status
= false;
604 info
->is_hs_configured
= adapter
->is_hs_configured
;
605 info
->is_deep_sleep
= adapter
->is_deep_sleep
;
611 * The function disables auto deep sleep mode.
613 int mwifiex_disable_auto_ds(struct mwifiex_private
*priv
)
615 struct mwifiex_ds_auto_ds auto_ds
= {
616 .auto_ds
= DEEP_SLEEP_OFF
,
619 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_PS_MODE_ENH
,
620 DIS_AUTO_PS
, BITMAP_AUTO_DS
, &auto_ds
, true);
622 EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds
);
625 * Sends IOCTL request to get the data rate.
627 * This function allocates the IOCTL request buffer, fills it
628 * with requisite parameters and calls the IOCTL handler.
630 int mwifiex_drv_get_data_rate(struct mwifiex_private
*priv
, u32
*rate
)
634 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_TX_RATE_QUERY
,
635 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
638 if (priv
->is_data_rate_auto
)
639 *rate
= mwifiex_index_to_data_rate(priv
, priv
->tx_rate
,
642 *rate
= priv
->data_rate
;
649 * IOCTL request handler to set tx power configuration.
651 * This function prepares the correct firmware command and
654 * For non-auto power mode, all the following power groups are set -
655 * - Modulation class HR/DSSS
656 * - Modulation class OFDM
657 * - Modulation class HTBW20
658 * - Modulation class HTBW40
660 int mwifiex_set_tx_power(struct mwifiex_private
*priv
,
661 struct mwifiex_power_cfg
*power_cfg
)
664 struct host_cmd_ds_txpwr_cfg
*txp_cfg
;
665 struct mwifiex_types_power_group
*pg_tlv
;
666 struct mwifiex_power_group
*pg
;
670 if (!power_cfg
->is_power_auto
) {
671 dbm
= (u16
) power_cfg
->power_level
;
672 if ((dbm
< priv
->min_tx_power_level
) ||
673 (dbm
> priv
->max_tx_power_level
)) {
674 mwifiex_dbg(priv
->adapter
, ERROR
,
675 "txpower value %d dBm\t"
676 "is out of range (%d dBm-%d dBm)\n",
677 dbm
, priv
->min_tx_power_level
,
678 priv
->max_tx_power_level
);
682 buf
= kzalloc(MWIFIEX_SIZE_OF_CMD_BUFFER
, GFP_KERNEL
);
686 txp_cfg
= (struct host_cmd_ds_txpwr_cfg
*) buf
;
687 txp_cfg
->action
= cpu_to_le16(HostCmd_ACT_GEN_SET
);
688 if (!power_cfg
->is_power_auto
) {
689 txp_cfg
->mode
= cpu_to_le32(1);
690 pg_tlv
= (struct mwifiex_types_power_group
*)
691 (buf
+ sizeof(struct host_cmd_ds_txpwr_cfg
));
692 pg_tlv
->type
= cpu_to_le16(TLV_TYPE_POWER_GROUP
);
694 cpu_to_le16(4 * sizeof(struct mwifiex_power_group
));
695 pg
= (struct mwifiex_power_group
*)
696 (buf
+ sizeof(struct host_cmd_ds_txpwr_cfg
)
697 + sizeof(struct mwifiex_types_power_group
));
698 /* Power group for modulation class HR/DSSS */
699 pg
->first_rate_code
= 0x00;
700 pg
->last_rate_code
= 0x03;
701 pg
->modulation_class
= MOD_CLASS_HR_DSSS
;
703 pg
->power_min
= (s8
) dbm
;
704 pg
->power_max
= (s8
) dbm
;
706 /* Power group for modulation class OFDM */
707 pg
->first_rate_code
= 0x00;
708 pg
->last_rate_code
= 0x07;
709 pg
->modulation_class
= MOD_CLASS_OFDM
;
711 pg
->power_min
= (s8
) dbm
;
712 pg
->power_max
= (s8
) dbm
;
714 /* Power group for modulation class HTBW20 */
715 pg
->first_rate_code
= 0x00;
716 pg
->last_rate_code
= 0x20;
717 pg
->modulation_class
= MOD_CLASS_HT
;
719 pg
->power_min
= (s8
) dbm
;
720 pg
->power_max
= (s8
) dbm
;
721 pg
->ht_bandwidth
= HT_BW_20
;
723 /* Power group for modulation class HTBW40 */
724 pg
->first_rate_code
= 0x00;
725 pg
->last_rate_code
= 0x20;
726 pg
->modulation_class
= MOD_CLASS_HT
;
728 pg
->power_min
= (s8
) dbm
;
729 pg
->power_max
= (s8
) dbm
;
730 pg
->ht_bandwidth
= HT_BW_40
;
732 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_TXPWR_CFG
,
733 HostCmd_ACT_GEN_SET
, 0, buf
, true);
740 * IOCTL request handler to get power save mode.
742 * This function prepares the correct firmware command and
745 int mwifiex_drv_set_power(struct mwifiex_private
*priv
, u32
*ps_mode
)
748 struct mwifiex_adapter
*adapter
= priv
->adapter
;
752 adapter
->ps_mode
= MWIFIEX_802_11_POWER_MODE_PSP
;
754 adapter
->ps_mode
= MWIFIEX_802_11_POWER_MODE_CAM
;
755 sub_cmd
= (*ps_mode
) ? EN_AUTO_PS
: DIS_AUTO_PS
;
756 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_PS_MODE_ENH
,
757 sub_cmd
, BITMAP_STA_PS
, NULL
, true);
758 if ((!ret
) && (sub_cmd
== DIS_AUTO_PS
))
759 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_PS_MODE_ENH
,
760 GET_PS
, 0, NULL
, false);
766 * IOCTL request handler to set/reset WPA IE.
768 * The supplied WPA IE is treated as a opaque buffer. Only the first field
769 * is checked to determine WPA version. If buffer length is zero, the existing
772 static int mwifiex_set_wpa_ie(struct mwifiex_private
*priv
,
773 u8
*ie_data_ptr
, u16 ie_len
)
776 if (ie_len
> sizeof(priv
->wpa_ie
)) {
777 mwifiex_dbg(priv
->adapter
, ERROR
,
778 "failed to copy WPA IE, too big\n");
781 memcpy(priv
->wpa_ie
, ie_data_ptr
, ie_len
);
782 priv
->wpa_ie_len
= ie_len
;
783 mwifiex_dbg(priv
->adapter
, CMD
,
784 "cmd: Set Wpa_ie_len=%d IE=%#x\n",
785 priv
->wpa_ie_len
, priv
->wpa_ie
[0]);
787 if (priv
->wpa_ie
[0] == WLAN_EID_VENDOR_SPECIFIC
) {
788 priv
->sec_info
.wpa_enabled
= true;
789 } else if (priv
->wpa_ie
[0] == WLAN_EID_RSN
) {
790 priv
->sec_info
.wpa2_enabled
= true;
792 priv
->sec_info
.wpa_enabled
= false;
793 priv
->sec_info
.wpa2_enabled
= false;
796 memset(priv
->wpa_ie
, 0, sizeof(priv
->wpa_ie
));
797 priv
->wpa_ie_len
= 0;
798 mwifiex_dbg(priv
->adapter
, INFO
,
799 "info: reset wpa_ie_len=%d IE=%#x\n",
800 priv
->wpa_ie_len
, priv
->wpa_ie
[0]);
801 priv
->sec_info
.wpa_enabled
= false;
802 priv
->sec_info
.wpa2_enabled
= false;
809 * IOCTL request handler to set/reset WAPI IE.
811 * The supplied WAPI IE is treated as a opaque buffer. Only the first field
812 * is checked to internally enable WAPI. If buffer length is zero, the existing
815 static int mwifiex_set_wapi_ie(struct mwifiex_private
*priv
,
816 u8
*ie_data_ptr
, u16 ie_len
)
819 if (ie_len
> sizeof(priv
->wapi_ie
)) {
820 mwifiex_dbg(priv
->adapter
, ERROR
,
821 "info: failed to copy WAPI IE, too big\n");
824 memcpy(priv
->wapi_ie
, ie_data_ptr
, ie_len
);
825 priv
->wapi_ie_len
= ie_len
;
826 mwifiex_dbg(priv
->adapter
, CMD
,
827 "cmd: Set wapi_ie_len=%d IE=%#x\n",
828 priv
->wapi_ie_len
, priv
->wapi_ie
[0]);
830 if (priv
->wapi_ie
[0] == WLAN_EID_BSS_AC_ACCESS_DELAY
)
831 priv
->sec_info
.wapi_enabled
= true;
833 memset(priv
->wapi_ie
, 0, sizeof(priv
->wapi_ie
));
834 priv
->wapi_ie_len
= ie_len
;
835 mwifiex_dbg(priv
->adapter
, INFO
,
836 "info: Reset wapi_ie_len=%d IE=%#x\n",
837 priv
->wapi_ie_len
, priv
->wapi_ie
[0]);
838 priv
->sec_info
.wapi_enabled
= false;
844 * IOCTL request handler to set/reset WPS IE.
846 * The supplied WPS IE is treated as a opaque buffer. Only the first field
847 * is checked to internally enable WPS. If buffer length is zero, the existing
850 static int mwifiex_set_wps_ie(struct mwifiex_private
*priv
,
851 u8
*ie_data_ptr
, u16 ie_len
)
854 if (ie_len
> MWIFIEX_MAX_VSIE_LEN
) {
855 mwifiex_dbg(priv
->adapter
, ERROR
,
856 "info: failed to copy WPS IE, too big\n");
860 priv
->wps_ie
= kzalloc(MWIFIEX_MAX_VSIE_LEN
, GFP_KERNEL
);
864 memcpy(priv
->wps_ie
, ie_data_ptr
, ie_len
);
865 priv
->wps_ie_len
= ie_len
;
866 mwifiex_dbg(priv
->adapter
, CMD
,
867 "cmd: Set wps_ie_len=%d IE=%#x\n",
868 priv
->wps_ie_len
, priv
->wps_ie
[0]);
871 priv
->wps_ie_len
= ie_len
;
872 mwifiex_dbg(priv
->adapter
, INFO
,
873 "info: Reset wps_ie_len=%d\n", priv
->wps_ie_len
);
879 * IOCTL request handler to set WAPI key.
881 * This function prepares the correct firmware command and
884 static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_private
*priv
,
885 struct mwifiex_ds_encrypt_key
*encrypt_key
)
888 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_KEY_MATERIAL
,
889 HostCmd_ACT_GEN_SET
, KEY_INFO_ENABLED
,
894 * IOCTL request handler to set WEP network key.
896 * This function prepares the correct firmware command and
897 * issues it, after validation checks.
899 static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private
*priv
,
900 struct mwifiex_ds_encrypt_key
*encrypt_key
)
902 struct mwifiex_adapter
*adapter
= priv
->adapter
;
904 struct mwifiex_wep_key
*wep_key
;
907 if (priv
->wep_key_curr_index
>= NUM_WEP_KEYS
)
908 priv
->wep_key_curr_index
= 0;
909 wep_key
= &priv
->wep_key
[priv
->wep_key_curr_index
];
910 index
= encrypt_key
->key_index
;
911 if (encrypt_key
->key_disable
) {
912 priv
->sec_info
.wep_enabled
= 0;
913 } else if (!encrypt_key
->key_len
) {
914 /* Copy the required key as the current key */
915 wep_key
= &priv
->wep_key
[index
];
916 if (!wep_key
->key_length
) {
917 mwifiex_dbg(adapter
, ERROR
,
918 "key not set, so cannot enable it\n");
922 if (adapter
->key_api_major_ver
== KEY_API_VER_MAJOR_V2
) {
923 memcpy(encrypt_key
->key_material
,
924 wep_key
->key_material
, wep_key
->key_length
);
925 encrypt_key
->key_len
= wep_key
->key_length
;
928 priv
->wep_key_curr_index
= (u16
) index
;
929 priv
->sec_info
.wep_enabled
= 1;
931 wep_key
= &priv
->wep_key
[index
];
932 memset(wep_key
, 0, sizeof(struct mwifiex_wep_key
));
933 /* Copy the key in the driver */
934 memcpy(wep_key
->key_material
,
935 encrypt_key
->key_material
,
936 encrypt_key
->key_len
);
937 wep_key
->key_index
= index
;
938 wep_key
->key_length
= encrypt_key
->key_len
;
939 priv
->sec_info
.wep_enabled
= 1;
941 if (wep_key
->key_length
) {
944 if (encrypt_key
->key_disable
) {
945 memset(&priv
->wep_key
[index
], 0,
946 sizeof(struct mwifiex_wep_key
));
950 if (adapter
->key_api_major_ver
== KEY_API_VER_MAJOR_V2
)
951 enc_key
= encrypt_key
;
955 /* Send request to firmware */
956 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_KEY_MATERIAL
,
957 HostCmd_ACT_GEN_SET
, 0, enc_key
, false);
963 if (priv
->sec_info
.wep_enabled
)
964 priv
->curr_pkt_filter
|= HostCmd_ACT_MAC_WEP_ENABLE
;
966 priv
->curr_pkt_filter
&= ~HostCmd_ACT_MAC_WEP_ENABLE
;
968 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_MAC_CONTROL
,
969 HostCmd_ACT_GEN_SET
, 0,
970 &priv
->curr_pkt_filter
, true);
976 * IOCTL request handler to set WPA key.
978 * This function prepares the correct firmware command and
979 * issues it, after validation checks.
981 * Current driver only supports key length of up to 32 bytes.
983 * This function can also be used to disable a currently set key.
985 static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_private
*priv
,
986 struct mwifiex_ds_encrypt_key
*encrypt_key
)
989 u8 remove_key
= false;
990 struct host_cmd_ds_802_11_key_material
*ibss_key
;
992 /* Current driver only supports key length of up to 32 bytes */
993 if (encrypt_key
->key_len
> WLAN_MAX_KEY_LEN
) {
994 mwifiex_dbg(priv
->adapter
, ERROR
,
995 "key length too long\n");
999 if (priv
->bss_mode
== NL80211_IFTYPE_ADHOC
) {
1001 * IBSS/WPA-None uses only one key (Group) for both receiving
1002 * and sending unicast and multicast packets.
1004 /* Send the key as PTK to firmware */
1005 encrypt_key
->key_index
= MWIFIEX_KEY_INDEX_UNICAST
;
1006 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_KEY_MATERIAL
,
1007 HostCmd_ACT_GEN_SET
,
1008 KEY_INFO_ENABLED
, encrypt_key
, false);
1012 ibss_key
= &priv
->aes_key
;
1014 sizeof(struct host_cmd_ds_802_11_key_material
));
1015 /* Copy the key in the driver */
1016 memcpy(ibss_key
->key_param_set
.key
, encrypt_key
->key_material
,
1017 encrypt_key
->key_len
);
1018 memcpy(&ibss_key
->key_param_set
.key_len
, &encrypt_key
->key_len
,
1019 sizeof(ibss_key
->key_param_set
.key_len
));
1020 ibss_key
->key_param_set
.key_type_id
1021 = cpu_to_le16(KEY_TYPE_ID_TKIP
);
1022 ibss_key
->key_param_set
.key_info
= cpu_to_le16(KEY_ENABLED
);
1024 /* Send the key as GTK to firmware */
1025 encrypt_key
->key_index
= ~MWIFIEX_KEY_INDEX_UNICAST
;
1028 if (!encrypt_key
->key_index
)
1029 encrypt_key
->key_index
= MWIFIEX_KEY_INDEX_UNICAST
;
1032 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_KEY_MATERIAL
,
1033 HostCmd_ACT_GEN_SET
,
1034 !KEY_INFO_ENABLED
, encrypt_key
, true);
1036 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_KEY_MATERIAL
,
1037 HostCmd_ACT_GEN_SET
,
1038 KEY_INFO_ENABLED
, encrypt_key
, true);
1044 * IOCTL request handler to set/get network keys.
1046 * This is a generic key handling function which supports WEP, WPA
1050 mwifiex_sec_ioctl_encrypt_key(struct mwifiex_private
*priv
,
1051 struct mwifiex_ds_encrypt_key
*encrypt_key
)
1055 if (encrypt_key
->is_wapi_key
)
1056 status
= mwifiex_sec_ioctl_set_wapi_key(priv
, encrypt_key
);
1057 else if (encrypt_key
->key_len
> WLAN_KEY_LEN_WEP104
)
1058 status
= mwifiex_sec_ioctl_set_wpa_key(priv
, encrypt_key
);
1060 status
= mwifiex_sec_ioctl_set_wep_key(priv
, encrypt_key
);
1065 * This function returns the driver version.
1068 mwifiex_drv_get_driver_version(struct mwifiex_adapter
*adapter
, char *version
,
1077 ver
.l
= cpu_to_le32(adapter
->fw_release_number
);
1078 sprintf(fw_ver
, "%u.%u.%u.p%u", ver
.c
[2], ver
.c
[1], ver
.c
[0], ver
.c
[3]);
1080 snprintf(version
, max_len
, driver_version
, fw_ver
);
1082 mwifiex_dbg(adapter
, MSG
, "info: MWIFIEX VERSION: %s\n", version
);
1088 * Sends IOCTL request to set encoding parameters.
1090 * This function allocates the IOCTL request buffer, fills it
1091 * with requisite parameters and calls the IOCTL handler.
1093 int mwifiex_set_encode(struct mwifiex_private
*priv
, struct key_params
*kp
,
1094 const u8
*key
, int key_len
, u8 key_index
,
1095 const u8
*mac_addr
, int disable
)
1097 struct mwifiex_ds_encrypt_key encrypt_key
;
1099 memset(&encrypt_key
, 0, sizeof(encrypt_key
));
1100 encrypt_key
.key_len
= key_len
;
1101 encrypt_key
.key_index
= key_index
;
1103 if (kp
&& kp
->cipher
== WLAN_CIPHER_SUITE_AES_CMAC
)
1104 encrypt_key
.is_igtk_key
= true;
1108 memcpy(encrypt_key
.key_material
, key
, key_len
);
1110 encrypt_key
.is_current_wep_key
= true;
1113 memcpy(encrypt_key
.mac_addr
, mac_addr
, ETH_ALEN
);
1114 if (kp
&& kp
->seq
&& kp
->seq_len
) {
1115 memcpy(encrypt_key
.pn
, kp
->seq
, kp
->seq_len
);
1116 encrypt_key
.pn_len
= kp
->seq_len
;
1117 encrypt_key
.is_rx_seq_valid
= true;
1120 encrypt_key
.key_disable
= true;
1122 memcpy(encrypt_key
.mac_addr
, mac_addr
, ETH_ALEN
);
1125 return mwifiex_sec_ioctl_encrypt_key(priv
, &encrypt_key
);
1129 * Sends IOCTL request to get extended version.
1131 * This function allocates the IOCTL request buffer, fills it
1132 * with requisite parameters and calls the IOCTL handler.
1135 mwifiex_get_ver_ext(struct mwifiex_private
*priv
, u32 version_str_sel
)
1137 struct mwifiex_ver_ext ver_ext
;
1139 memset(&ver_ext
, 0, sizeof(ver_ext
));
1140 ver_ext
.version_str_sel
= version_str_sel
;
1141 if (mwifiex_send_cmd(priv
, HostCmd_CMD_VERSION_EXT
,
1142 HostCmd_ACT_GEN_GET
, 0, &ver_ext
, true))
1149 mwifiex_remain_on_chan_cfg(struct mwifiex_private
*priv
, u16 action
,
1150 struct ieee80211_channel
*chan
,
1151 unsigned int duration
)
1153 struct host_cmd_ds_remain_on_chan roc_cfg
;
1156 memset(&roc_cfg
, 0, sizeof(roc_cfg
));
1157 roc_cfg
.action
= cpu_to_le16(action
);
1158 if (action
== HostCmd_ACT_GEN_SET
) {
1159 roc_cfg
.band_cfg
= chan
->band
;
1160 sc
= mwifiex_chan_type_to_sec_chan_offset(NL80211_CHAN_NO_HT
);
1161 roc_cfg
.band_cfg
|= (sc
<< 2);
1164 ieee80211_frequency_to_channel(chan
->center_freq
);
1165 roc_cfg
.duration
= cpu_to_le32(duration
);
1167 if (mwifiex_send_cmd(priv
, HostCmd_CMD_REMAIN_ON_CHAN
,
1168 action
, 0, &roc_cfg
, true)) {
1169 mwifiex_dbg(priv
->adapter
, ERROR
,
1170 "failed to remain on channel\n");
1174 return roc_cfg
.status
;
1178 * Sends IOCTL request to get statistics information.
1180 * This function allocates the IOCTL request buffer, fills it
1181 * with requisite parameters and calls the IOCTL handler.
1184 mwifiex_get_stats_info(struct mwifiex_private
*priv
,
1185 struct mwifiex_ds_get_stats
*log
)
1187 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_GET_LOG
,
1188 HostCmd_ACT_GEN_GET
, 0, log
, true);
1192 * IOCTL request handler to read/write register.
1194 * This function prepares the correct firmware command and
1197 * Access to the following registers are supported -
1204 static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private
*priv
,
1205 struct mwifiex_ds_reg_rw
*reg_rw
,
1210 switch (reg_rw
->type
) {
1211 case MWIFIEX_REG_MAC
:
1212 cmd_no
= HostCmd_CMD_MAC_REG_ACCESS
;
1214 case MWIFIEX_REG_BBP
:
1215 cmd_no
= HostCmd_CMD_BBP_REG_ACCESS
;
1217 case MWIFIEX_REG_RF
:
1218 cmd_no
= HostCmd_CMD_RF_REG_ACCESS
;
1220 case MWIFIEX_REG_PMIC
:
1221 cmd_no
= HostCmd_CMD_PMIC_REG_ACCESS
;
1223 case MWIFIEX_REG_CAU
:
1224 cmd_no
= HostCmd_CMD_CAU_REG_ACCESS
;
1230 return mwifiex_send_cmd(priv
, cmd_no
, action
, 0, reg_rw
, true);
1234 * Sends IOCTL request to write to a register.
1236 * This function allocates the IOCTL request buffer, fills it
1237 * with requisite parameters and calls the IOCTL handler.
1240 mwifiex_reg_write(struct mwifiex_private
*priv
, u32 reg_type
,
1241 u32 reg_offset
, u32 reg_value
)
1243 struct mwifiex_ds_reg_rw reg_rw
;
1245 reg_rw
.type
= reg_type
;
1246 reg_rw
.offset
= reg_offset
;
1247 reg_rw
.value
= reg_value
;
1249 return mwifiex_reg_mem_ioctl_reg_rw(priv
, ®_rw
, HostCmd_ACT_GEN_SET
);
1253 * Sends IOCTL request to read from a register.
1255 * This function allocates the IOCTL request buffer, fills it
1256 * with requisite parameters and calls the IOCTL handler.
1259 mwifiex_reg_read(struct mwifiex_private
*priv
, u32 reg_type
,
1260 u32 reg_offset
, u32
*value
)
1263 struct mwifiex_ds_reg_rw reg_rw
;
1265 reg_rw
.type
= reg_type
;
1266 reg_rw
.offset
= reg_offset
;
1267 ret
= mwifiex_reg_mem_ioctl_reg_rw(priv
, ®_rw
, HostCmd_ACT_GEN_GET
);
1272 *value
= reg_rw
.value
;
1279 * Sends IOCTL request to read from EEPROM.
1281 * This function allocates the IOCTL request buffer, fills it
1282 * with requisite parameters and calls the IOCTL handler.
1285 mwifiex_eeprom_read(struct mwifiex_private
*priv
, u16 offset
, u16 bytes
,
1289 struct mwifiex_ds_read_eeprom rd_eeprom
;
1291 rd_eeprom
.offset
= offset
;
1292 rd_eeprom
.byte_count
= bytes
;
1294 /* Send request to firmware */
1295 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_EEPROM_ACCESS
,
1296 HostCmd_ACT_GEN_GET
, 0, &rd_eeprom
, true);
1299 memcpy(value
, rd_eeprom
.value
, min((u16
)MAX_EEPROM_DATA
,
1300 rd_eeprom
.byte_count
));
1305 * This function sets a generic IE. In addition to generic IE, it can
1306 * also handle WPA, WPA2 and WAPI IEs.
1309 mwifiex_set_gen_ie_helper(struct mwifiex_private
*priv
, u8
*ie_data_ptr
,
1312 struct ieee_types_vendor_header
*pvendor_ie
;
1313 const u8 wpa_oui
[] = { 0x00, 0x50, 0xf2, 0x01 };
1314 const u8 wps_oui
[] = { 0x00, 0x50, 0xf2, 0x04 };
1315 u16 unparsed_len
= ie_len
, cur_ie_len
;
1317 /* If the passed length is zero, reset the buffer */
1319 priv
->gen_ie_buf_len
= 0;
1320 priv
->wps
.session_enable
= false;
1322 } else if (!ie_data_ptr
||
1323 ie_len
<= sizeof(struct ieee_types_header
)) {
1326 pvendor_ie
= (struct ieee_types_vendor_header
*) ie_data_ptr
;
1328 while (pvendor_ie
) {
1329 cur_ie_len
= pvendor_ie
->len
+ sizeof(struct ieee_types_header
);
1331 if (pvendor_ie
->element_id
== WLAN_EID_RSN
) {
1332 /* IE is a WPA/WPA2 IE so call set_wpa function */
1333 mwifiex_set_wpa_ie(priv
, (u8
*)pvendor_ie
, cur_ie_len
);
1334 priv
->wps
.session_enable
= false;
1338 if (pvendor_ie
->element_id
== WLAN_EID_BSS_AC_ACCESS_DELAY
) {
1339 /* IE is a WAPI IE so call set_wapi function */
1340 mwifiex_set_wapi_ie(priv
, (u8
*)pvendor_ie
,
1345 if (pvendor_ie
->element_id
== WLAN_EID_VENDOR_SPECIFIC
) {
1346 /* Test to see if it is a WPA IE, if not, then
1349 if (!memcmp(pvendor_ie
->oui
, wpa_oui
,
1351 /* IE is a WPA/WPA2 IE so call set_wpa function
1353 mwifiex_set_wpa_ie(priv
, (u8
*)pvendor_ie
,
1355 priv
->wps
.session_enable
= false;
1359 if (!memcmp(pvendor_ie
->oui
, wps_oui
,
1361 /* Test to see if it is a WPS IE,
1362 * if so, enable wps session flag
1364 priv
->wps
.session_enable
= true;
1365 mwifiex_dbg(priv
->adapter
, MSG
,
1366 "WPS Session Enabled.\n");
1367 mwifiex_set_wps_ie(priv
, (u8
*)pvendor_ie
,
1373 /* Saved in gen_ie, such as P2P IE.etc.*/
1375 /* Verify that the passed length is not larger than the
1376 * available space remaining in the buffer
1379 (sizeof(priv
->gen_ie_buf
) - priv
->gen_ie_buf_len
)) {
1380 /* Append the passed data to the end
1381 * of the genIeBuffer
1383 memcpy(priv
->gen_ie_buf
+ priv
->gen_ie_buf_len
,
1384 (u8
*)pvendor_ie
, cur_ie_len
);
1385 /* Increment the stored buffer length by the
1388 priv
->gen_ie_buf_len
+= cur_ie_len
;
1392 unparsed_len
-= cur_ie_len
;
1394 if (unparsed_len
<= sizeof(struct ieee_types_header
))
1397 pvendor_ie
= (struct ieee_types_vendor_header
*)
1398 (((u8
*)pvendor_ie
) + cur_ie_len
);
1405 * IOCTL request handler to set/get generic IE.
1407 * In addition to various generic IEs, this function can also be
1408 * used to set the ARP filter.
1410 static int mwifiex_misc_ioctl_gen_ie(struct mwifiex_private
*priv
,
1411 struct mwifiex_ds_misc_gen_ie
*gen_ie
,
1414 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1416 switch (gen_ie
->type
) {
1417 case MWIFIEX_IE_TYPE_GEN_IE
:
1418 if (action
== HostCmd_ACT_GEN_GET
) {
1419 gen_ie
->len
= priv
->wpa_ie_len
;
1420 memcpy(gen_ie
->ie_data
, priv
->wpa_ie
, gen_ie
->len
);
1422 mwifiex_set_gen_ie_helper(priv
, gen_ie
->ie_data
,
1426 case MWIFIEX_IE_TYPE_ARP_FILTER
:
1427 memset(adapter
->arp_filter
, 0, sizeof(adapter
->arp_filter
));
1428 if (gen_ie
->len
> ARP_FILTER_MAX_BUF_SIZE
) {
1429 adapter
->arp_filter_size
= 0;
1430 mwifiex_dbg(adapter
, ERROR
,
1431 "invalid ARP filter size\n");
1434 memcpy(adapter
->arp_filter
, gen_ie
->ie_data
,
1436 adapter
->arp_filter_size
= gen_ie
->len
;
1440 mwifiex_dbg(adapter
, ERROR
, "invalid IE type\n");
1447 * Sends IOCTL request to set a generic IE.
1449 * This function allocates the IOCTL request buffer, fills it
1450 * with requisite parameters and calls the IOCTL handler.
1453 mwifiex_set_gen_ie(struct mwifiex_private
*priv
, const u8
*ie
, int ie_len
)
1455 struct mwifiex_ds_misc_gen_ie gen_ie
;
1457 if (ie_len
> IEEE_MAX_IE_SIZE
)
1460 gen_ie
.type
= MWIFIEX_IE_TYPE_GEN_IE
;
1461 gen_ie
.len
= ie_len
;
1462 memcpy(gen_ie
.ie_data
, ie
, ie_len
);
1463 if (mwifiex_misc_ioctl_gen_ie(priv
, &gen_ie
, HostCmd_ACT_GEN_SET
))
1469 /* This function get Host Sleep wake up reason.
1472 int mwifiex_get_wakeup_reason(struct mwifiex_private
*priv
, u16 action
,
1474 struct mwifiex_ds_wakeup_reason
*wakeup_reason
)
1478 status
= mwifiex_send_cmd(priv
, HostCmd_CMD_HS_WAKEUP_REASON
,
1479 HostCmd_ACT_GEN_GET
, 0, wakeup_reason
,
1480 cmd_type
== MWIFIEX_SYNC_CMD
);
1485 int mwifiex_get_chan_info(struct mwifiex_private
*priv
,
1486 struct mwifiex_channel_band
*channel_band
)
1490 status
= mwifiex_send_cmd(priv
, HostCmd_CMD_STA_CONFIGURE
,
1491 HostCmd_ACT_GEN_GET
, 0, channel_band
,