2 * Marvell Wireless LAN device driver: CFG80211
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.
24 * This function maps the nl802.11 channel type into driver channel type.
26 * The mapping is as follows -
27 * NL80211_CHAN_NO_HT -> NO_SEC_CHANNEL
28 * NL80211_CHAN_HT20 -> NO_SEC_CHANNEL
29 * NL80211_CHAN_HT40PLUS -> SEC_CHANNEL_ABOVE
30 * NL80211_CHAN_HT40MINUS -> SEC_CHANNEL_BELOW
31 * Others -> NO_SEC_CHANNEL
34 mwifiex_cfg80211_channel_type_to_mwifiex_channels(enum nl80211_channel_type
37 switch (channel_type
) {
38 case NL80211_CHAN_NO_HT
:
39 case NL80211_CHAN_HT20
:
40 return NO_SEC_CHANNEL
;
41 case NL80211_CHAN_HT40PLUS
:
42 return SEC_CHANNEL_ABOVE
;
43 case NL80211_CHAN_HT40MINUS
:
44 return SEC_CHANNEL_BELOW
;
46 return NO_SEC_CHANNEL
;
51 * This function maps the driver channel type into nl802.11 channel type.
53 * The mapping is as follows -
54 * NO_SEC_CHANNEL -> NL80211_CHAN_HT20
55 * SEC_CHANNEL_ABOVE -> NL80211_CHAN_HT40PLUS
56 * SEC_CHANNEL_BELOW -> NL80211_CHAN_HT40MINUS
57 * Others -> NL80211_CHAN_HT20
59 static enum nl80211_channel_type
60 mwifiex_channels_to_cfg80211_channel_type(int channel_type
)
62 switch (channel_type
) {
64 return NL80211_CHAN_HT20
;
65 case SEC_CHANNEL_ABOVE
:
66 return NL80211_CHAN_HT40PLUS
;
67 case SEC_CHANNEL_BELOW
:
68 return NL80211_CHAN_HT40MINUS
;
70 return NL80211_CHAN_HT20
;
75 * This function checks whether WEP is set.
78 mwifiex_is_alg_wep(u32 cipher
)
83 case WLAN_CIPHER_SUITE_WEP40
:
84 case WLAN_CIPHER_SUITE_WEP104
:
95 * This function retrieves the private structure from kernel wiphy structure.
97 static void *mwifiex_cfg80211_get_priv(struct wiphy
*wiphy
)
99 return (void *) (*(unsigned long *) wiphy_priv(wiphy
));
103 * CFG802.11 operation handler to delete a network key.
106 mwifiex_cfg80211_del_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
107 u8 key_index
, bool pairwise
, const u8
*mac_addr
)
109 struct mwifiex_private
*priv
= mwifiex_cfg80211_get_priv(wiphy
);
111 if (mwifiex_set_encode(priv
, NULL
, 0, key_index
, 1)) {
112 wiphy_err(wiphy
, "deleting the crypto keys\n");
116 wiphy_dbg(wiphy
, "info: crypto keys deleted\n");
121 * CFG802.11 operation handler to set Tx power.
124 mwifiex_cfg80211_set_tx_power(struct wiphy
*wiphy
,
125 enum nl80211_tx_power_setting type
,
128 struct mwifiex_private
*priv
= mwifiex_cfg80211_get_priv(wiphy
);
129 struct mwifiex_power_cfg power_cfg
;
131 if (type
== NL80211_TX_POWER_FIXED
) {
132 power_cfg
.is_power_auto
= 0;
133 power_cfg
.power_level
= dbm
;
135 power_cfg
.is_power_auto
= 1;
138 return mwifiex_set_tx_power(priv
, &power_cfg
);
142 * CFG802.11 operation handler to set Power Save option.
144 * The timeout value, if provided, is currently ignored.
147 mwifiex_cfg80211_set_power_mgmt(struct wiphy
*wiphy
,
148 struct net_device
*dev
,
149 bool enabled
, int timeout
)
151 struct mwifiex_private
*priv
= mwifiex_cfg80211_get_priv(wiphy
);
156 "info: ignoring the timeout value"
157 " for IEEE power save\n");
161 return mwifiex_drv_set_power(priv
, &ps_mode
);
165 * CFG802.11 operation handler to set the default network key.
168 mwifiex_cfg80211_set_default_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
169 u8 key_index
, bool unicast
,
172 struct mwifiex_private
*priv
= mwifiex_cfg80211_get_priv(wiphy
);
174 /* Return if WEP key not configured */
175 if (priv
->sec_info
.wep_status
== MWIFIEX_802_11_WEP_DISABLED
)
178 if (mwifiex_set_encode(priv
, NULL
, 0, key_index
, 0)) {
179 wiphy_err(wiphy
, "set default Tx key index\n");
187 * CFG802.11 operation handler to add a network key.
190 mwifiex_cfg80211_add_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
191 u8 key_index
, bool pairwise
, const u8
*mac_addr
,
192 struct key_params
*params
)
194 struct mwifiex_private
*priv
= mwifiex_cfg80211_get_priv(wiphy
);
196 if (mwifiex_set_encode(priv
, params
->key
, params
->key_len
,
198 wiphy_err(wiphy
, "crypto keys added\n");
206 * This function sends domain information to the firmware.
208 * The following information are passed to the firmware -
210 * - Sub bands (first channel, number of channels, maximum Tx power)
212 static int mwifiex_send_domain_info_cmd_fw(struct wiphy
*wiphy
)
214 u8 no_of_triplet
= 0;
215 struct ieee80211_country_ie_triplet
*t
;
216 u8 no_of_parsed_chan
= 0;
217 u8 first_chan
= 0, next_chan
= 0, max_pwr
= 0;
219 enum ieee80211_band band
;
220 struct ieee80211_supported_band
*sband
;
221 struct ieee80211_channel
*ch
;
222 struct mwifiex_private
*priv
= mwifiex_cfg80211_get_priv(wiphy
);
223 struct mwifiex_adapter
*adapter
= priv
->adapter
;
224 struct mwifiex_802_11d_domain_reg
*domain_info
= &adapter
->domain_reg
;
226 /* Set country code */
227 domain_info
->country_code
[0] = priv
->country_code
[0];
228 domain_info
->country_code
[1] = priv
->country_code
[1];
229 domain_info
->country_code
[2] = ' ';
231 band
= mwifiex_band_to_radio_type(adapter
->config_bands
);
232 if (!wiphy
->bands
[band
]) {
233 wiphy_err(wiphy
, "11D: setting domain info in FW\n");
237 sband
= wiphy
->bands
[band
];
239 for (i
= 0; i
< sband
->n_channels
; i
++) {
240 ch
= &sband
->channels
[i
];
241 if (ch
->flags
& IEEE80211_CHAN_DISABLED
)
246 first_chan
= (u32
) ch
->hw_value
;
247 next_chan
= first_chan
;
248 max_pwr
= ch
->max_power
;
249 no_of_parsed_chan
= 1;
253 if (ch
->hw_value
== next_chan
+ 1 &&
254 ch
->max_power
== max_pwr
) {
258 t
= &domain_info
->triplet
[no_of_triplet
];
259 t
->chans
.first_channel
= first_chan
;
260 t
->chans
.num_channels
= no_of_parsed_chan
;
261 t
->chans
.max_power
= max_pwr
;
263 first_chan
= (u32
) ch
->hw_value
;
264 next_chan
= first_chan
;
265 max_pwr
= ch
->max_power
;
266 no_of_parsed_chan
= 1;
271 t
= &domain_info
->triplet
[no_of_triplet
];
272 t
->chans
.first_channel
= first_chan
;
273 t
->chans
.num_channels
= no_of_parsed_chan
;
274 t
->chans
.max_power
= max_pwr
;
278 domain_info
->no_of_triplet
= no_of_triplet
;
280 if (mwifiex_send_cmd_async(priv
, HostCmd_CMD_802_11D_DOMAIN_INFO
,
281 HostCmd_ACT_GEN_SET
, 0, NULL
)) {
282 wiphy_err(wiphy
, "11D: setting domain info in FW\n");
290 * CFG802.11 regulatory domain callback function.
292 * This function is called when the regulatory domain is changed due to the
293 * following reasons -
295 * - Set by system core
297 * - Set bt Country IE
299 static int mwifiex_reg_notifier(struct wiphy
*wiphy
,
300 struct regulatory_request
*request
)
302 struct mwifiex_private
*priv
= mwifiex_cfg80211_get_priv(wiphy
);
304 wiphy_dbg(wiphy
, "info: cfg80211 regulatory domain callback for domain"
305 " %c%c\n", request
->alpha2
[0], request
->alpha2
[1]);
307 memcpy(priv
->country_code
, request
->alpha2
, sizeof(request
->alpha2
));
309 switch (request
->initiator
) {
310 case NL80211_REGDOM_SET_BY_DRIVER
:
311 case NL80211_REGDOM_SET_BY_CORE
:
312 case NL80211_REGDOM_SET_BY_USER
:
314 /* Todo: apply driver specific changes in channel flags based
315 on the request initiator if necessary. */
316 case NL80211_REGDOM_SET_BY_COUNTRY_IE
:
319 mwifiex_send_domain_info_cmd_fw(wiphy
);
325 * This function sets the RF channel.
327 * This function creates multiple IOCTL requests, populates them accordingly
328 * and issues them to set the band/channel and frequency.
331 mwifiex_set_rf_channel(struct mwifiex_private
*priv
,
332 struct ieee80211_channel
*chan
,
333 enum nl80211_channel_type channel_type
)
335 struct mwifiex_chan_freq_power cfp
;
336 struct mwifiex_ds_band_cfg band_cfg
;
337 u32 config_bands
= 0;
338 struct wiphy
*wiphy
= priv
->wdev
->wiphy
;
341 memset(&band_cfg
, 0, sizeof(band_cfg
));
342 /* Set appropriate bands */
343 if (chan
->band
== IEEE80211_BAND_2GHZ
)
344 config_bands
= BAND_B
| BAND_G
| BAND_GN
;
346 config_bands
= BAND_AN
| BAND_A
;
347 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
348 || priv
->bss_mode
== NL80211_IFTYPE_UNSPECIFIED
) {
349 band_cfg
.config_bands
= config_bands
;
350 } else if (priv
->bss_mode
== NL80211_IFTYPE_ADHOC
) {
351 band_cfg
.config_bands
= config_bands
;
352 band_cfg
.adhoc_start_band
= config_bands
;
355 band_cfg
.sec_chan_offset
=
356 mwifiex_cfg80211_channel_type_to_mwifiex_channels
359 if (mwifiex_set_radio_band_cfg(priv
, &band_cfg
))
362 mwifiex_send_domain_info_cmd_fw(wiphy
);
365 wiphy_dbg(wiphy
, "info: setting band %d, channel offset %d and "
366 "mode %d\n", config_bands
, band_cfg
.sec_chan_offset
,
371 memset(&cfp
, 0, sizeof(cfp
));
372 cfp
.freq
= chan
->center_freq
;
373 cfp
.channel
= ieee80211_frequency_to_channel(chan
->center_freq
);
375 if (mwifiex_bss_set_channel(priv
, &cfp
))
378 return mwifiex_drv_change_adhoc_chan(priv
, cfp
.channel
);
382 * CFG802.11 operation handler to set channel.
384 * This function can only be used when station is not connected.
387 mwifiex_cfg80211_set_channel(struct wiphy
*wiphy
, struct net_device
*dev
,
388 struct ieee80211_channel
*chan
,
389 enum nl80211_channel_type channel_type
)
391 struct mwifiex_private
*priv
= mwifiex_cfg80211_get_priv(wiphy
);
393 if (priv
->media_connected
) {
394 wiphy_err(wiphy
, "This setting is valid only when station "
395 "is not connected\n");
399 return mwifiex_set_rf_channel(priv
, chan
, channel_type
);
403 * This function sets the fragmentation threshold.
405 * The fragmentation threshold value must lie between MWIFIEX_FRAG_MIN_VALUE
406 * and MWIFIEX_FRAG_MAX_VALUE.
409 mwifiex_set_frag(struct mwifiex_private
*priv
, u32 frag_thr
)
413 if (frag_thr
< MWIFIEX_FRAG_MIN_VALUE
414 || frag_thr
> MWIFIEX_FRAG_MAX_VALUE
)
417 /* Send request to firmware */
418 ret
= mwifiex_send_cmd_sync(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
419 HostCmd_ACT_GEN_SET
, FRAG_THRESH_I
,
426 * This function sets the RTS threshold.
428 * The rts value must lie between MWIFIEX_RTS_MIN_VALUE
429 * and MWIFIEX_RTS_MAX_VALUE.
432 mwifiex_set_rts(struct mwifiex_private
*priv
, u32 rts_thr
)
434 if (rts_thr
< MWIFIEX_RTS_MIN_VALUE
|| rts_thr
> MWIFIEX_RTS_MAX_VALUE
)
435 rts_thr
= MWIFIEX_RTS_MAX_VALUE
;
437 return mwifiex_send_cmd_sync(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
438 HostCmd_ACT_GEN_SET
, RTS_THRESH_I
,
443 * CFG802.11 operation handler to set wiphy parameters.
445 * This function can be used to set the RTS threshold and the
446 * Fragmentation threshold of the driver.
449 mwifiex_cfg80211_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
451 struct mwifiex_private
*priv
= mwifiex_cfg80211_get_priv(wiphy
);
455 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
456 ret
= mwifiex_set_rts(priv
, wiphy
->rts_threshold
);
461 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
)
462 ret
= mwifiex_set_frag(priv
, wiphy
->frag_threshold
);
468 * CFG802.11 operation handler to change interface type.
471 mwifiex_cfg80211_change_virtual_intf(struct wiphy
*wiphy
,
472 struct net_device
*dev
,
473 enum nl80211_iftype type
, u32
*flags
,
474 struct vif_params
*params
)
477 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
479 if (priv
->bss_mode
== type
) {
480 wiphy_warn(wiphy
, "already set to required type\n");
484 priv
->bss_mode
= type
;
487 case NL80211_IFTYPE_ADHOC
:
488 dev
->ieee80211_ptr
->iftype
= NL80211_IFTYPE_ADHOC
;
489 wiphy_dbg(wiphy
, "info: setting interface type to adhoc\n");
491 case NL80211_IFTYPE_STATION
:
492 dev
->ieee80211_ptr
->iftype
= NL80211_IFTYPE_STATION
;
493 wiphy_dbg(wiphy
, "info: setting interface type to managed\n");
495 case NL80211_IFTYPE_UNSPECIFIED
:
496 dev
->ieee80211_ptr
->iftype
= NL80211_IFTYPE_STATION
;
497 wiphy_dbg(wiphy
, "info: setting interface type to auto\n");
500 wiphy_err(wiphy
, "unknown interface type: %d\n", type
);
504 mwifiex_deauthenticate(priv
, NULL
);
506 priv
->sec_info
.authentication_mode
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
508 ret
= mwifiex_send_cmd_sync(priv
, HostCmd_CMD_SET_BSS_MODE
,
509 HostCmd_ACT_GEN_SET
, 0, NULL
);
515 * This function dumps the station information on a buffer.
517 * The following information are shown -
518 * - Total bytes transmitted
519 * - Total bytes received
520 * - Total packets transmitted
521 * - Total packets received
522 * - Signal quality level
523 * - Transmission rate
526 mwifiex_dump_station_info(struct mwifiex_private
*priv
,
527 struct station_info
*sinfo
)
529 struct mwifiex_ds_get_signal signal
;
530 struct mwifiex_rate_cfg rate
;
533 sinfo
->filled
= STATION_INFO_RX_BYTES
| STATION_INFO_TX_BYTES
|
534 STATION_INFO_RX_PACKETS
|
535 STATION_INFO_TX_PACKETS
536 | STATION_INFO_SIGNAL
| STATION_INFO_TX_BITRATE
;
538 /* Get signal information from the firmware */
539 memset(&signal
, 0, sizeof(struct mwifiex_ds_get_signal
));
540 if (mwifiex_get_signal_info(priv
, &signal
)) {
541 dev_err(priv
->adapter
->dev
, "getting signal information\n");
545 if (mwifiex_drv_get_data_rate(priv
, &rate
)) {
546 dev_err(priv
->adapter
->dev
, "getting data rate\n");
550 sinfo
->rx_bytes
= priv
->stats
.rx_bytes
;
551 sinfo
->tx_bytes
= priv
->stats
.tx_bytes
;
552 sinfo
->rx_packets
= priv
->stats
.rx_packets
;
553 sinfo
->tx_packets
= priv
->stats
.tx_packets
;
554 sinfo
->signal
= priv
->w_stats
.qual
.level
;
555 sinfo
->txrate
.legacy
= rate
.rate
;
561 * CFG802.11 operation handler to get station information.
563 * This function only works in connected mode, and dumps the
564 * requested station information, if available.
567 mwifiex_cfg80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
568 u8
*mac
, struct station_info
*sinfo
)
570 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
572 mwifiex_dump_station_info(priv
, sinfo
);
574 if (!priv
->media_connected
)
576 if (memcmp(mac
, priv
->cfg_bssid
, ETH_ALEN
))
579 return mwifiex_dump_station_info(priv
, sinfo
);
582 /* Supported rates to be advertised to the cfg80211 */
584 static struct ieee80211_rate mwifiex_rates
[] = {
585 {.bitrate
= 10, .hw_value
= 2, },
586 {.bitrate
= 20, .hw_value
= 4, },
587 {.bitrate
= 55, .hw_value
= 11, },
588 {.bitrate
= 110, .hw_value
= 22, },
589 {.bitrate
= 220, .hw_value
= 44, },
590 {.bitrate
= 60, .hw_value
= 12, },
591 {.bitrate
= 90, .hw_value
= 18, },
592 {.bitrate
= 120, .hw_value
= 24, },
593 {.bitrate
= 180, .hw_value
= 36, },
594 {.bitrate
= 240, .hw_value
= 48, },
595 {.bitrate
= 360, .hw_value
= 72, },
596 {.bitrate
= 480, .hw_value
= 96, },
597 {.bitrate
= 540, .hw_value
= 108, },
598 {.bitrate
= 720, .hw_value
= 144, },
601 /* Channel definitions to be advertised to cfg80211 */
603 static struct ieee80211_channel mwifiex_channels_2ghz
[] = {
604 {.center_freq
= 2412, .hw_value
= 1, },
605 {.center_freq
= 2417, .hw_value
= 2, },
606 {.center_freq
= 2422, .hw_value
= 3, },
607 {.center_freq
= 2427, .hw_value
= 4, },
608 {.center_freq
= 2432, .hw_value
= 5, },
609 {.center_freq
= 2437, .hw_value
= 6, },
610 {.center_freq
= 2442, .hw_value
= 7, },
611 {.center_freq
= 2447, .hw_value
= 8, },
612 {.center_freq
= 2452, .hw_value
= 9, },
613 {.center_freq
= 2457, .hw_value
= 10, },
614 {.center_freq
= 2462, .hw_value
= 11, },
615 {.center_freq
= 2467, .hw_value
= 12, },
616 {.center_freq
= 2472, .hw_value
= 13, },
617 {.center_freq
= 2484, .hw_value
= 14, },
620 static struct ieee80211_supported_band mwifiex_band_2ghz
= {
621 .channels
= mwifiex_channels_2ghz
,
622 .n_channels
= ARRAY_SIZE(mwifiex_channels_2ghz
),
623 .bitrates
= mwifiex_rates
,
627 static struct ieee80211_channel mwifiex_channels_5ghz
[] = {
628 {.center_freq
= 5040, .hw_value
= 8, },
629 {.center_freq
= 5060, .hw_value
= 12, },
630 {.center_freq
= 5080, .hw_value
= 16, },
631 {.center_freq
= 5170, .hw_value
= 34, },
632 {.center_freq
= 5190, .hw_value
= 38, },
633 {.center_freq
= 5210, .hw_value
= 42, },
634 {.center_freq
= 5230, .hw_value
= 46, },
635 {.center_freq
= 5180, .hw_value
= 36, },
636 {.center_freq
= 5200, .hw_value
= 40, },
637 {.center_freq
= 5220, .hw_value
= 44, },
638 {.center_freq
= 5240, .hw_value
= 48, },
639 {.center_freq
= 5260, .hw_value
= 52, },
640 {.center_freq
= 5280, .hw_value
= 56, },
641 {.center_freq
= 5300, .hw_value
= 60, },
642 {.center_freq
= 5320, .hw_value
= 64, },
643 {.center_freq
= 5500, .hw_value
= 100, },
644 {.center_freq
= 5520, .hw_value
= 104, },
645 {.center_freq
= 5540, .hw_value
= 108, },
646 {.center_freq
= 5560, .hw_value
= 112, },
647 {.center_freq
= 5580, .hw_value
= 116, },
648 {.center_freq
= 5600, .hw_value
= 120, },
649 {.center_freq
= 5620, .hw_value
= 124, },
650 {.center_freq
= 5640, .hw_value
= 128, },
651 {.center_freq
= 5660, .hw_value
= 132, },
652 {.center_freq
= 5680, .hw_value
= 136, },
653 {.center_freq
= 5700, .hw_value
= 140, },
654 {.center_freq
= 5745, .hw_value
= 149, },
655 {.center_freq
= 5765, .hw_value
= 153, },
656 {.center_freq
= 5785, .hw_value
= 157, },
657 {.center_freq
= 5805, .hw_value
= 161, },
658 {.center_freq
= 5825, .hw_value
= 165, },
661 static struct ieee80211_supported_band mwifiex_band_5ghz
= {
662 .channels
= mwifiex_channels_5ghz
,
663 .n_channels
= ARRAY_SIZE(mwifiex_channels_5ghz
),
664 .bitrates
= mwifiex_rates
- 4,
665 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
) + 4,
669 /* Supported crypto cipher suits to be advertised to cfg80211 */
671 static const u32 mwifiex_cipher_suites
[] = {
672 WLAN_CIPHER_SUITE_WEP40
,
673 WLAN_CIPHER_SUITE_WEP104
,
674 WLAN_CIPHER_SUITE_TKIP
,
675 WLAN_CIPHER_SUITE_CCMP
,
679 * CFG802.11 operation handler for disconnection request.
681 * This function does not work when there is already a disconnection
682 * procedure going on.
685 mwifiex_cfg80211_disconnect(struct wiphy
*wiphy
, struct net_device
*dev
,
688 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
690 if (priv
->disconnect
)
693 priv
->disconnect
= 1;
694 if (mwifiex_deauthenticate(priv
, NULL
))
697 wiphy_dbg(wiphy
, "info: successfully disconnected from %pM:"
698 " reason code %d\n", priv
->cfg_bssid
, reason_code
);
700 queue_work(priv
->workqueue
, &priv
->cfg_workqueue
);
706 * This function informs the CFG802.11 subsystem of a new IBSS.
708 * The following information are sent to the CFG802.11 subsystem
709 * to register the new IBSS. If we do not register the new IBSS,
710 * a kernel panic will result.
716 static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private
*priv
)
718 struct ieee80211_channel
*chan
;
719 struct mwifiex_bss_info bss_info
;
721 u8 ie_buf
[IEEE80211_MAX_SSID_LEN
+ sizeof(struct ieee_types_header
)];
723 if (mwifiex_get_bss_info(priv
, &bss_info
))
726 ie_buf
[0] = WLAN_EID_SSID
;
727 ie_buf
[1] = bss_info
.ssid
.ssid_len
;
729 memcpy(&ie_buf
[sizeof(struct ieee_types_header
)],
731 bss_info
.ssid
.ssid_len
);
732 ie_len
= ie_buf
[1] + sizeof(struct ieee_types_header
);
734 chan
= __ieee80211_get_channel(priv
->wdev
->wiphy
,
735 ieee80211_channel_to_frequency(bss_info
.bss_chan
,
736 priv
->curr_bss_params
.band
));
738 cfg80211_inform_bss(priv
->wdev
->wiphy
, chan
,
739 bss_info
.bssid
, 0, WLAN_CAPABILITY_IBSS
,
740 0, ie_buf
, ie_len
, 0, GFP_KERNEL
);
741 memcpy(priv
->cfg_bssid
, bss_info
.bssid
, ETH_ALEN
);
747 * This function informs the CFG802.11 subsystem of a new BSS connection.
749 * The following information are sent to the CFG802.11 subsystem
750 * to register the new BSS connection. If we do not register the new BSS,
751 * a kernel panic will result.
757 * - Supported rates IE
758 * - Extended capabilities IE
759 * - DS parameter set IE
761 * - Vendor Specific IE (221)
765 static int mwifiex_inform_bss_from_scan_result(struct mwifiex_private
*priv
,
766 struct mwifiex_802_11_ssid
*ssid
)
768 struct mwifiex_scan_resp scan_resp
;
769 struct mwifiex_bssdescriptor
*scan_table
;
771 struct ieee80211_channel
*chan
;
776 u8 element_id
, element_len
;
778 memset(&scan_resp
, 0, sizeof(scan_resp
));
779 scan_resp
.scan_table
= (u8
*) priv
->adapter
->scan_table
;
780 scan_resp
.num_in_scan_table
= priv
->adapter
->num_in_scan_table
;
782 #define MAX_IE_BUF 2048
783 ie_buf
= kzalloc(MAX_IE_BUF
, GFP_KERNEL
);
785 dev_err(priv
->adapter
->dev
, "%s: failed to alloc ie_buf\n",
790 scan_table
= (struct mwifiex_bssdescriptor
*) scan_resp
.scan_table
;
791 for (i
= 0; i
< scan_resp
.num_in_scan_table
; i
++) {
793 /* Inform specific BSS only */
794 if (memcmp(ssid
->ssid
, scan_table
[i
].ssid
.ssid
,
798 memset(ie_buf
, 0, MAX_IE_BUF
);
799 ie_buf
[0] = WLAN_EID_SSID
;
800 ie_buf
[1] = scan_table
[i
].ssid
.ssid_len
;
801 memcpy(&ie_buf
[sizeof(struct ieee_types_header
)],
802 scan_table
[i
].ssid
.ssid
, ie_buf
[1]);
804 ie
= ie_buf
+ ie_buf
[1] + sizeof(struct ieee_types_header
);
805 ie_len
= ie_buf
[1] + sizeof(struct ieee_types_header
);
807 ie
[0] = WLAN_EID_SUPP_RATES
;
809 for (j
= 0; j
< sizeof(scan_table
[i
].supported_rates
); j
++) {
810 if (!scan_table
[i
].supported_rates
[j
])
813 ie
[j
+ sizeof(struct ieee_types_header
)] =
814 scan_table
[i
].supported_rates
[j
];
818 ie_len
+= ie
[1] + sizeof(struct ieee_types_header
);
820 beacon
= scan_table
[i
].beacon_buf
;
821 beacon_size
= scan_table
[i
].beacon_buf_size
;
823 /* Skip time stamp, beacon interval and capability */
826 beacon
+= sizeof(scan_table
[i
].beacon_period
)
827 + sizeof(scan_table
[i
].time_stamp
) +
828 +sizeof(scan_table
[i
].cap_info_bitmap
);
830 beacon_size
-= sizeof(scan_table
[i
].beacon_period
)
831 + sizeof(scan_table
[i
].time_stamp
)
832 + sizeof(scan_table
[i
].cap_info_bitmap
);
835 while (beacon_size
>= sizeof(struct ieee_types_header
)) {
836 ie
= ie_buf
+ ie_len
;
837 element_id
= *beacon
;
838 element_len
= *(beacon
+ 1);
839 if (beacon_size
< (int) element_len
+
840 sizeof(struct ieee_types_header
)) {
841 dev_err(priv
->adapter
->dev
, "%s: in processing"
842 " IE, bytes left < IE length\n",
846 switch (element_id
) {
847 case WLAN_EID_EXT_CAPABILITY
:
848 case WLAN_EID_DS_PARAMS
:
849 case WLAN_EID_HT_CAPABILITY
:
850 case WLAN_EID_VENDOR_SPECIFIC
:
852 case WLAN_EID_BSS_AC_ACCESS_DELAY
:
855 memcpy(&ie
[sizeof(struct ieee_types_header
)],
857 + sizeof(struct ieee_types_header
),
860 sizeof(struct ieee_types_header
);
865 beacon
+= element_len
+
866 sizeof(struct ieee_types_header
);
867 beacon_size
-= element_len
+
868 sizeof(struct ieee_types_header
);
870 chan
= ieee80211_get_channel(priv
->wdev
->wiphy
,
872 cfg80211_inform_bss(priv
->wdev
->wiphy
, chan
,
873 scan_table
[i
].mac_address
,
874 0, scan_table
[i
].cap_info_bitmap
,
875 scan_table
[i
].beacon_period
,
877 scan_table
[i
].rssi
, GFP_KERNEL
);
885 * This function connects with a BSS.
887 * This function handles both Infra and Ad-Hoc modes. It also performs
888 * validity checking on the provided parameters, disconnects from the
889 * current BSS (if any), sets up the association/scan parameters,
890 * including security settings, and performs specific SSID scan before
893 * For Infra mode, the function returns failure if the specified SSID
894 * is not found in scan table. However, for Ad-Hoc mode, it can create
895 * the IBSS if it does not exist. On successful completion in either case,
896 * the function notifies the CFG802.11 subsystem of the new BSS connection,
897 * otherwise the kernel will panic.
900 mwifiex_cfg80211_assoc(struct mwifiex_private
*priv
, size_t ssid_len
, u8
*ssid
,
901 u8
*bssid
, int mode
, struct ieee80211_channel
*channel
,
902 struct cfg80211_connect_params
*sme
, bool privacy
)
904 struct mwifiex_802_11_ssid req_ssid
;
905 struct mwifiex_ssid_bssid ssid_bssid
;
909 memset(&req_ssid
, 0, sizeof(struct mwifiex_802_11_ssid
));
910 memset(&ssid_bssid
, 0, sizeof(struct mwifiex_ssid_bssid
));
912 req_ssid
.ssid_len
= ssid_len
;
913 if (ssid_len
> IEEE80211_MAX_SSID_LEN
) {
914 dev_err(priv
->adapter
->dev
, "invalid SSID - aborting\n");
918 memcpy(req_ssid
.ssid
, ssid
, ssid_len
);
919 if (!req_ssid
.ssid_len
|| req_ssid
.ssid
[0] < 0x20) {
920 dev_err(priv
->adapter
->dev
, "invalid SSID - aborting\n");
924 /* disconnect before try to associate */
925 mwifiex_deauthenticate(priv
, NULL
);
928 ret
= mwifiex_set_rf_channel(priv
, channel
,
929 mwifiex_channels_to_cfg80211_channel_type
930 (priv
->adapter
->chan_offset
));
932 ret
= mwifiex_set_encode(priv
, NULL
, 0, 0, 1); /* Disable keys */
934 if (mode
== NL80211_IFTYPE_ADHOC
) {
935 /* "privacy" is set only for ad-hoc mode */
938 * Keep WLAN_CIPHER_SUITE_WEP104 for now so that
939 * the firmware can find a matching network from the
940 * scan. The cfg80211 does not give us the encryption
941 * mode at this stage so just setting it to WEP here.
943 priv
->sec_info
.encryption_mode
=
944 WLAN_CIPHER_SUITE_WEP104
;
945 priv
->sec_info
.authentication_mode
=
946 NL80211_AUTHTYPE_OPEN_SYSTEM
;
952 /* Now handle infra mode. "sme" is valid for infra mode only */
953 if (sme
->auth_type
== NL80211_AUTHTYPE_AUTOMATIC
954 || sme
->auth_type
== NL80211_AUTHTYPE_OPEN_SYSTEM
)
955 auth_type
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
956 else if (sme
->auth_type
== NL80211_AUTHTYPE_SHARED_KEY
)
957 auth_type
= NL80211_AUTHTYPE_SHARED_KEY
;
959 if (sme
->crypto
.n_ciphers_pairwise
) {
960 priv
->sec_info
.encryption_mode
=
961 sme
->crypto
.ciphers_pairwise
[0];
962 priv
->sec_info
.authentication_mode
= auth_type
;
965 if (sme
->crypto
.cipher_group
) {
966 priv
->sec_info
.encryption_mode
= sme
->crypto
.cipher_group
;
967 priv
->sec_info
.authentication_mode
= auth_type
;
970 ret
= mwifiex_set_gen_ie(priv
, sme
->ie
, sme
->ie_len
);
973 if (mwifiex_is_alg_wep(0) | mwifiex_is_alg_wep(0)) {
974 dev_dbg(priv
->adapter
->dev
,
975 "info: setting wep encryption"
976 " with key len %d\n", sme
->key_len
);
977 ret
= mwifiex_set_encode(priv
, sme
->key
, sme
->key_len
,
982 /* Do specific SSID scanning */
983 if (mwifiex_request_scan(priv
, &req_ssid
)) {
984 dev_err(priv
->adapter
->dev
, "scan error\n");
989 memcpy(&ssid_bssid
.ssid
, &req_ssid
, sizeof(struct mwifiex_802_11_ssid
));
991 if (mode
!= NL80211_IFTYPE_ADHOC
) {
992 if (mwifiex_find_best_bss(priv
, &ssid_bssid
))
994 /* Inform the BSS information to kernel, otherwise
995 * kernel will give a panic after successful assoc */
996 if (mwifiex_inform_bss_from_scan_result(priv
, &req_ssid
))
1000 dev_dbg(priv
->adapter
->dev
, "info: trying to associate to %s and bssid %pM\n",
1001 (char *) req_ssid
.ssid
, ssid_bssid
.bssid
);
1003 memcpy(&priv
->cfg_bssid
, ssid_bssid
.bssid
, 6);
1005 /* Connect to BSS by ESSID */
1006 memset(&ssid_bssid
.bssid
, 0, ETH_ALEN
);
1008 if (!netif_queue_stopped(priv
->netdev
))
1009 netif_stop_queue(priv
->netdev
);
1011 if (mwifiex_bss_start(priv
, &ssid_bssid
))
1014 if (mode
== NL80211_IFTYPE_ADHOC
) {
1015 /* Inform the BSS information to kernel, otherwise
1016 * kernel will give a panic after successful assoc */
1017 if (mwifiex_cfg80211_inform_ibss_bss(priv
))
1025 * CFG802.11 operation handler for association request.
1027 * This function does not work when the current mode is set to Ad-Hoc, or
1028 * when there is already an association procedure going on. The given BSS
1029 * information is used to associate.
1032 mwifiex_cfg80211_connect(struct wiphy
*wiphy
, struct net_device
*dev
,
1033 struct cfg80211_connect_params
*sme
)
1035 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1038 if (priv
->assoc_request
)
1041 if (priv
->bss_mode
== NL80211_IFTYPE_ADHOC
) {
1042 wiphy_err(wiphy
, "received infra assoc request "
1043 "when station is in ibss mode\n");
1047 priv
->assoc_request
= -EINPROGRESS
;
1049 wiphy_dbg(wiphy
, "info: Trying to associate to %s and bssid %pM\n",
1050 (char *) sme
->ssid
, sme
->bssid
);
1052 ret
= mwifiex_cfg80211_assoc(priv
, sme
->ssid_len
, sme
->ssid
, sme
->bssid
,
1053 priv
->bss_mode
, sme
->channel
, sme
, 0);
1055 priv
->assoc_request
= 1;
1057 priv
->assoc_result
= ret
;
1058 queue_work(priv
->workqueue
, &priv
->cfg_workqueue
);
1063 * CFG802.11 operation handler to join an IBSS.
1065 * This function does not work in any mode other than Ad-Hoc, or if
1066 * a join operation is already in progress.
1069 mwifiex_cfg80211_join_ibss(struct wiphy
*wiphy
, struct net_device
*dev
,
1070 struct cfg80211_ibss_params
*params
)
1072 struct mwifiex_private
*priv
= mwifiex_cfg80211_get_priv(wiphy
);
1075 if (priv
->ibss_join_request
)
1078 if (priv
->bss_mode
!= NL80211_IFTYPE_ADHOC
) {
1079 wiphy_err(wiphy
, "request to join ibss received "
1080 "when station is not in ibss mode\n");
1084 priv
->ibss_join_request
= -EINPROGRESS
;
1086 wiphy_dbg(wiphy
, "info: trying to join to %s and bssid %pM\n",
1087 (char *) params
->ssid
, params
->bssid
);
1089 ret
= mwifiex_cfg80211_assoc(priv
, params
->ssid_len
, params
->ssid
,
1090 params
->bssid
, priv
->bss_mode
,
1091 params
->channel
, NULL
, params
->privacy
);
1093 priv
->ibss_join_request
= 1;
1095 priv
->ibss_join_result
= ret
;
1096 queue_work(priv
->workqueue
, &priv
->cfg_workqueue
);
1101 * CFG802.11 operation handler to leave an IBSS.
1103 * This function does not work if a leave operation is
1104 * already in progress.
1107 mwifiex_cfg80211_leave_ibss(struct wiphy
*wiphy
, struct net_device
*dev
)
1109 struct mwifiex_private
*priv
= mwifiex_cfg80211_get_priv(wiphy
);
1111 if (priv
->disconnect
)
1114 priv
->disconnect
= 1;
1116 wiphy_dbg(wiphy
, "info: disconnecting from essid %pM\n",
1118 if (mwifiex_deauthenticate(priv
, NULL
))
1121 queue_work(priv
->workqueue
, &priv
->cfg_workqueue
);
1127 * CFG802.11 operation handler for scan request.
1129 * This function issues a scan request to the firmware based upon
1130 * the user specified scan configuration. On successfull completion,
1131 * it also informs the results.
1134 mwifiex_cfg80211_scan(struct wiphy
*wiphy
, struct net_device
*dev
,
1135 struct cfg80211_scan_request
*request
)
1137 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1139 wiphy_dbg(wiphy
, "info: received scan request on %s\n", dev
->name
);
1141 if (priv
->scan_request
&& priv
->scan_request
!= request
)
1144 priv
->scan_request
= request
;
1146 queue_work(priv
->workqueue
, &priv
->cfg_workqueue
);
1151 * This function sets up the CFG802.11 specific HT capability fields
1152 * with default values.
1154 * The following default values are set -
1155 * - HT Supported = True
1156 * - Maximum AMPDU length factor = IEEE80211_HT_MAX_AMPDU_64K
1157 * - Minimum AMPDU spacing = IEEE80211_HT_MPDU_DENSITY_NONE
1158 * - HT Capabilities supported by firmware
1159 * - MCS information, Rx mask = 0xff
1160 * - MCD information, Tx parameters = IEEE80211_HT_MCS_TX_DEFINED (0x01)
1163 mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap
*ht_info
,
1164 struct mwifiex_private
*priv
)
1167 struct ieee80211_mcs_info mcs_set
;
1168 u8
*mcs
= (u8
*)&mcs_set
;
1169 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1171 ht_info
->ht_supported
= true;
1172 ht_info
->ampdu_factor
= IEEE80211_HT_MAX_AMPDU_64K
;
1173 ht_info
->ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
1175 memset(&ht_info
->mcs
, 0, sizeof(ht_info
->mcs
));
1177 /* Fill HT capability information */
1178 if (ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
1179 ht_info
->cap
|= IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
1181 ht_info
->cap
&= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
1183 if (ISSUPP_SHORTGI20(adapter
->hw_dot_11n_dev_cap
))
1184 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_20
;
1186 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_20
;
1188 if (ISSUPP_SHORTGI40(adapter
->hw_dot_11n_dev_cap
))
1189 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_40
;
1191 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_40
;
1193 if (ISSUPP_RXSTBC(adapter
->hw_dot_11n_dev_cap
))
1194 ht_info
->cap
|= 1 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
1196 ht_info
->cap
&= ~(3 << IEEE80211_HT_CAP_RX_STBC_SHIFT
);
1198 if (ISSUPP_TXSTBC(adapter
->hw_dot_11n_dev_cap
))
1199 ht_info
->cap
|= IEEE80211_HT_CAP_TX_STBC
;
1201 ht_info
->cap
&= ~IEEE80211_HT_CAP_TX_STBC
;
1203 ht_info
->cap
&= ~IEEE80211_HT_CAP_MAX_AMSDU
;
1204 ht_info
->cap
|= IEEE80211_HT_CAP_SM_PS
;
1206 rx_mcs_supp
= GET_RXMCSSUPP(adapter
->hw_dev_mcs_support
);
1207 /* Set MCS for 1x1 */
1208 memset(mcs
, 0xff, rx_mcs_supp
);
1209 /* Clear all the other values */
1210 memset(&mcs
[rx_mcs_supp
], 0,
1211 sizeof(struct ieee80211_mcs_info
) - rx_mcs_supp
);
1212 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
||
1213 ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
1214 /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
1215 SETHT_MCS32(mcs_set
.rx_mask
);
1217 memcpy((u8
*) &ht_info
->mcs
, mcs
, sizeof(struct ieee80211_mcs_info
));
1219 ht_info
->mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
1222 /* station cfg80211 operations */
1223 static struct cfg80211_ops mwifiex_cfg80211_ops
= {
1224 .change_virtual_intf
= mwifiex_cfg80211_change_virtual_intf
,
1225 .scan
= mwifiex_cfg80211_scan
,
1226 .connect
= mwifiex_cfg80211_connect
,
1227 .disconnect
= mwifiex_cfg80211_disconnect
,
1228 .get_station
= mwifiex_cfg80211_get_station
,
1229 .set_wiphy_params
= mwifiex_cfg80211_set_wiphy_params
,
1230 .set_channel
= mwifiex_cfg80211_set_channel
,
1231 .join_ibss
= mwifiex_cfg80211_join_ibss
,
1232 .leave_ibss
= mwifiex_cfg80211_leave_ibss
,
1233 .add_key
= mwifiex_cfg80211_add_key
,
1234 .del_key
= mwifiex_cfg80211_del_key
,
1235 .set_default_key
= mwifiex_cfg80211_set_default_key
,
1236 .set_power_mgmt
= mwifiex_cfg80211_set_power_mgmt
,
1237 .set_tx_power
= mwifiex_cfg80211_set_tx_power
,
1241 * This function registers the device with CFG802.11 subsystem.
1243 * The function creates the wireless device/wiphy, populates it with
1244 * default parameters and handler function pointers, and finally
1245 * registers the device.
1247 int mwifiex_register_cfg80211(struct net_device
*dev
, u8
*mac
,
1248 struct mwifiex_private
*priv
)
1251 void *wdev_priv
= NULL
;
1252 struct wireless_dev
*wdev
;
1254 wdev
= kzalloc(sizeof(struct wireless_dev
), GFP_KERNEL
);
1256 dev_err(priv
->adapter
->dev
, "%s: allocating wireless device\n",
1261 wiphy_new(&mwifiex_cfg80211_ops
,
1262 sizeof(struct mwifiex_private
*));
1265 wdev
->iftype
= NL80211_IFTYPE_STATION
;
1266 wdev
->wiphy
->max_scan_ssids
= 10;
1267 wdev
->wiphy
->interface_modes
=
1268 BIT(NL80211_IFTYPE_STATION
) | BIT(NL80211_IFTYPE_ADHOC
);
1270 wdev
->wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &mwifiex_band_2ghz
;
1271 mwifiex_setup_ht_caps(
1272 &wdev
->wiphy
->bands
[IEEE80211_BAND_2GHZ
]->ht_cap
, priv
);
1274 if (priv
->adapter
->config_bands
& BAND_A
) {
1275 wdev
->wiphy
->bands
[IEEE80211_BAND_5GHZ
] = &mwifiex_band_5ghz
;
1276 mwifiex_setup_ht_caps(
1277 &wdev
->wiphy
->bands
[IEEE80211_BAND_5GHZ
]->ht_cap
, priv
);
1279 wdev
->wiphy
->bands
[IEEE80211_BAND_5GHZ
] = NULL
;
1282 /* Initialize cipher suits */
1283 wdev
->wiphy
->cipher_suites
= mwifiex_cipher_suites
;
1284 wdev
->wiphy
->n_cipher_suites
= ARRAY_SIZE(mwifiex_cipher_suites
);
1286 memcpy(wdev
->wiphy
->perm_addr
, mac
, 6);
1287 wdev
->wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
1289 /* We are using custom domains */
1290 wdev
->wiphy
->flags
|= WIPHY_FLAG_CUSTOM_REGULATORY
;
1292 wdev
->wiphy
->reg_notifier
= mwifiex_reg_notifier
;
1294 /* Set struct mwifiex_private pointer in wiphy_priv */
1295 wdev_priv
= wiphy_priv(wdev
->wiphy
);
1297 *(unsigned long *) wdev_priv
= (unsigned long) priv
;
1299 ret
= wiphy_register(wdev
->wiphy
);
1301 dev_err(priv
->adapter
->dev
, "%s: registering cfg80211 device\n",
1303 wiphy_free(wdev
->wiphy
);
1306 dev_dbg(priv
->adapter
->dev
,
1307 "info: successfully registered wiphy device\n");
1310 dev_net_set(dev
, wiphy_net(wdev
->wiphy
));
1311 dev
->ieee80211_ptr
= wdev
;
1312 memcpy(dev
->dev_addr
, wdev
->wiphy
->perm_addr
, 6);
1313 memcpy(dev
->perm_addr
, wdev
->wiphy
->perm_addr
, 6);
1314 SET_NETDEV_DEV(dev
, wiphy_dev(wdev
->wiphy
));
1317 dev
->flags
|= IFF_BROADCAST
| IFF_MULTICAST
;
1318 dev
->watchdog_timeo
= MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT
;
1319 dev
->hard_header_len
+= MWIFIEX_MIN_DATA_HEADER_LEN
;
1325 * This function handles the result of different pending network operations.
1327 * The following operations are handled and CFG802.11 subsystem is
1328 * notified accordingly -
1329 * - Scan request completion
1330 * - Association request completion
1331 * - IBSS join request completion
1332 * - Disconnect request completion
1335 mwifiex_cfg80211_results(struct work_struct
*work
)
1337 struct mwifiex_private
*priv
=
1338 container_of(work
, struct mwifiex_private
, cfg_workqueue
);
1339 struct mwifiex_user_scan_cfg
*scan_req
;
1341 struct ieee80211_channel
*chan
;
1343 if (priv
->scan_request
) {
1344 scan_req
= kzalloc(sizeof(struct mwifiex_user_scan_cfg
),
1347 dev_err(priv
->adapter
->dev
, "failed to alloc "
1351 for (i
= 0; i
< priv
->scan_request
->n_ssids
; i
++) {
1352 memcpy(scan_req
->ssid_list
[i
].ssid
,
1353 priv
->scan_request
->ssids
[i
].ssid
,
1354 priv
->scan_request
->ssids
[i
].ssid_len
);
1355 scan_req
->ssid_list
[i
].max_len
=
1356 priv
->scan_request
->ssids
[i
].ssid_len
;
1358 for (i
= 0; i
< priv
->scan_request
->n_channels
; i
++) {
1359 chan
= priv
->scan_request
->channels
[i
];
1360 scan_req
->chan_list
[i
].chan_number
= chan
->hw_value
;
1361 scan_req
->chan_list
[i
].radio_type
= chan
->band
;
1362 if (chan
->flags
& IEEE80211_CHAN_DISABLED
)
1363 scan_req
->chan_list
[i
].scan_type
=
1364 MWIFIEX_SCAN_TYPE_PASSIVE
;
1366 scan_req
->chan_list
[i
].scan_type
=
1367 MWIFIEX_SCAN_TYPE_ACTIVE
;
1368 scan_req
->chan_list
[i
].scan_time
= 0;
1370 if (mwifiex_set_user_scan_ioctl(priv
, scan_req
)) {
1374 if (mwifiex_inform_bss_from_scan_result(priv
, NULL
))
1377 priv
->scan_result_status
= ret
;
1378 dev_dbg(priv
->adapter
->dev
, "info: %s: sending scan results\n",
1380 cfg80211_scan_done(priv
->scan_request
,
1381 (priv
->scan_result_status
< 0));
1382 priv
->scan_request
= NULL
;
1386 if (priv
->assoc_request
== 1) {
1387 if (!priv
->assoc_result
) {
1388 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
1390 WLAN_STATUS_SUCCESS
,
1392 dev_dbg(priv
->adapter
->dev
,
1393 "info: associated to bssid %pM successfully\n",
1396 dev_dbg(priv
->adapter
->dev
,
1397 "info: association to bssid %pM failed\n",
1399 memset(priv
->cfg_bssid
, 0, ETH_ALEN
);
1401 priv
->assoc_request
= 0;
1402 priv
->assoc_result
= 0;
1405 if (priv
->ibss_join_request
== 1) {
1406 if (!priv
->ibss_join_result
) {
1407 cfg80211_ibss_joined(priv
->netdev
, priv
->cfg_bssid
,
1409 dev_dbg(priv
->adapter
->dev
,
1410 "info: joined/created adhoc network with bssid"
1411 " %pM successfully\n", priv
->cfg_bssid
);
1413 dev_dbg(priv
->adapter
->dev
,
1414 "info: failed creating/joining adhoc network\n");
1416 priv
->ibss_join_request
= 0;
1417 priv
->ibss_join_result
= 0;
1420 if (priv
->disconnect
) {
1421 memset(priv
->cfg_bssid
, 0, ETH_ALEN
);
1422 priv
->disconnect
= 0;