1 //------------------------------------------------------------------------------
2 // Copyright (c) 2004-2010 Atheros Communications Inc.
3 // All rights reserved.
7 // Permission to use, copy, modify, and/or distribute this software for any
8 // purpose with or without fee is hereby granted, provided that the above
9 // copyright notice and this permission notice appear in all copies.
11 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 // Author(s): ="Atheros"
22 //------------------------------------------------------------------------------
24 #include <linux/wireless.h>
25 #include <linux/ieee80211.h>
26 #include <net/cfg80211.h>
28 #include "ar6000_drv.h"
31 extern A_WAITQUEUE_HEAD arEvent;
32 extern unsigned int wmitimeout;
33 extern int reconnect_flag;
36 #define RATETAB_ENT(_rate, _rateid, _flags) { \
39 .hw_value = (_rateid), \
42 #define CHAN2G(_channel, _freq, _flags) { \
43 .band = IEEE80211_BAND_2GHZ, \
44 .hw_value = (_channel), \
45 .center_freq = (_freq), \
47 .max_antenna_gain = 0, \
51 #define CHAN5G(_channel, _flags) { \
52 .band = IEEE80211_BAND_5GHZ, \
53 .hw_value = (_channel), \
54 .center_freq = 5000 + (5 * (_channel)), \
56 .max_antenna_gain = 0, \
61 ieee80211_rate ar6k_rates[] = {
62 RATETAB_ENT(10, 0x1, 0),
63 RATETAB_ENT(20, 0x2, 0),
64 RATETAB_ENT(55, 0x4, 0),
65 RATETAB_ENT(110, 0x8, 0),
66 RATETAB_ENT(60, 0x10, 0),
67 RATETAB_ENT(90, 0x20, 0),
68 RATETAB_ENT(120, 0x40, 0),
69 RATETAB_ENT(180, 0x80, 0),
70 RATETAB_ENT(240, 0x100, 0),
71 RATETAB_ENT(360, 0x200, 0),
72 RATETAB_ENT(480, 0x400, 0),
73 RATETAB_ENT(540, 0x800, 0),
76 #define ar6k_a_rates (ar6k_rates + 4)
77 #define ar6k_a_rates_size 8
78 #define ar6k_g_rates (ar6k_rates + 0)
79 #define ar6k_g_rates_size 12
82 ieee80211_channel ar6k_2ghz_channels[] = {
100 ieee80211_channel ar6k_5ghz_a_channels[] = {
101 CHAN5G(34, 0), CHAN5G(36, 0),
102 CHAN5G(38, 0), CHAN5G(40, 0),
103 CHAN5G(42, 0), CHAN5G(44, 0),
104 CHAN5G(46, 0), CHAN5G(48, 0),
105 CHAN5G(52, 0), CHAN5G(56, 0),
106 CHAN5G(60, 0), CHAN5G(64, 0),
107 CHAN5G(100, 0), CHAN5G(104, 0),
108 CHAN5G(108, 0), CHAN5G(112, 0),
109 CHAN5G(116, 0), CHAN5G(120, 0),
110 CHAN5G(124, 0), CHAN5G(128, 0),
111 CHAN5G(132, 0), CHAN5G(136, 0),
112 CHAN5G(140, 0), CHAN5G(149, 0),
113 CHAN5G(153, 0), CHAN5G(157, 0),
114 CHAN5G(161, 0), CHAN5G(165, 0),
115 CHAN5G(184, 0), CHAN5G(188, 0),
116 CHAN5G(192, 0), CHAN5G(196, 0),
117 CHAN5G(200, 0), CHAN5G(204, 0),
118 CHAN5G(208, 0), CHAN5G(212, 0),
123 ieee80211_supported_band ar6k_band_2ghz = {
124 .n_channels = ARRAY_SIZE(ar6k_2ghz_channels),
125 .channels = ar6k_2ghz_channels,
126 .n_bitrates = ar6k_g_rates_size,
127 .bitrates = ar6k_g_rates,
131 ieee80211_supported_band ar6k_band_5ghz = {
132 .n_channels = ARRAY_SIZE(ar6k_5ghz_a_channels),
133 .channels = ar6k_5ghz_a_channels,
134 .n_bitrates = ar6k_a_rates_size,
135 .bitrates = ar6k_a_rates,
139 ar6k_set_wpa_version(struct ar6_softc *ar, enum nl80211_wpa_versions wpa_version)
142 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: %u\n", __func__, wpa_version));
145 ar->arAuthMode = NONE_AUTH;
146 } else if (wpa_version & NL80211_WPA_VERSION_1) {
147 ar->arAuthMode = WPA_AUTH;
148 } else if (wpa_version & NL80211_WPA_VERSION_2) {
149 ar->arAuthMode = WPA2_AUTH;
151 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
152 ("%s: %u not spported\n", __func__, wpa_version));
160 ar6k_set_auth_type(struct ar6_softc *ar, enum nl80211_auth_type auth_type)
163 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: 0x%x\n", __func__, auth_type));
166 case NL80211_AUTHTYPE_OPEN_SYSTEM:
167 ar->arDot11AuthMode = OPEN_AUTH;
169 case NL80211_AUTHTYPE_SHARED_KEY:
170 ar->arDot11AuthMode = SHARED_AUTH;
172 case NL80211_AUTHTYPE_NETWORK_EAP:
173 ar->arDot11AuthMode = LEAP_AUTH;
176 ar->arDot11AuthMode = OPEN_AUTH;
177 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
178 ("%s: 0x%x not spported\n", __func__, auth_type));
186 ar6k_set_cipher(struct ar6_softc *ar, u32 cipher, bool ucast)
188 u8 *ar_cipher = ucast ? &ar->arPairwiseCrypto :
190 u8 *ar_cipher_len = ucast ? &ar->arPairwiseCryptoLen :
191 &ar->arGroupCryptoLen;
193 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
194 ("%s: cipher 0x%x, ucast %u\n", __func__, cipher, ucast));
198 case IW_AUTH_CIPHER_NONE:
199 *ar_cipher = NONE_CRYPT;
202 case WLAN_CIPHER_SUITE_WEP40:
203 *ar_cipher = WEP_CRYPT;
206 case WLAN_CIPHER_SUITE_WEP104:
207 *ar_cipher = WEP_CRYPT;
210 case WLAN_CIPHER_SUITE_TKIP:
211 *ar_cipher = TKIP_CRYPT;
214 case WLAN_CIPHER_SUITE_CCMP:
215 *ar_cipher = AES_CRYPT;
219 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
220 ("%s: cipher 0x%x not supported\n", __func__, cipher));
228 ar6k_set_key_mgmt(struct ar6_softc *ar, u32 key_mgmt)
230 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: 0x%x\n", __func__, key_mgmt));
232 if (WLAN_AKM_SUITE_PSK == key_mgmt) {
233 if (WPA_AUTH == ar->arAuthMode) {
234 ar->arAuthMode = WPA_PSK_AUTH;
235 } else if (WPA2_AUTH == ar->arAuthMode) {
236 ar->arAuthMode = WPA2_PSK_AUTH;
238 } else if (WLAN_AKM_SUITE_8021X != key_mgmt) {
239 ar->arAuthMode = NONE_AUTH;
244 ar6k_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
245 struct cfg80211_connect_params *sme)
247 struct ar6_softc *ar = ar6k_priv(dev);
250 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__));
251 ar->smeState = SME_CONNECTING;
253 if(ar->arWmiReady == false) {
254 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready yet\n", __func__));
258 if(ar->arWlanState == WLAN_DISABLED) {
259 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
263 if(ar->bIsDestroyProgress) {
264 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: destroy in progress\n", __func__));
268 if(!sme->ssid_len || IEEE80211_MAX_SSID_LEN < sme->ssid_len) {
269 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: ssid invalid\n", __func__));
273 if(ar->arSkipScan == true &&
274 ((sme->channel && sme->channel->center_freq == 0) ||
275 (sme->bssid && !sme->bssid[0] && !sme->bssid[1] && !sme->bssid[2] &&
276 !sme->bssid[3] && !sme->bssid[4] && !sme->bssid[5])))
278 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s:SkipScan: channel or bssid invalid\n", __func__));
282 if(down_interruptible(&ar->arSem)) {
283 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: busy, couldn't get access\n", __func__));
287 if(ar->bIsDestroyProgress) {
288 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: busy, destroy in progress\n", __func__));
293 if(ar->arTxPending[wmi_get_control_ep(ar->arWmi)]) {
295 * sleep until the command queue drains
297 wait_event_interruptible_timeout(arEvent,
298 ar->arTxPending[wmi_get_control_ep(ar->arWmi)] == 0, wmitimeout * HZ);
299 if (signal_pending(current)) {
300 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: cmd queue drain timeout\n", __func__));
306 if(ar->arConnected == true &&
307 ar->arSsidLen == sme->ssid_len &&
308 !memcmp(ar->arSsid, sme->ssid, ar->arSsidLen)) {
309 reconnect_flag = true;
310 status = wmi_reconnect_cmd(ar->arWmi,
316 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: wmi_reconnect_cmd failed\n", __func__));
320 } else if(ar->arSsidLen == sme->ssid_len &&
321 !memcmp(ar->arSsid, sme->ssid, ar->arSsidLen)) {
322 ar6000_disconnect(ar);
325 A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
326 ar->arSsidLen = sme->ssid_len;
327 memcpy(ar->arSsid, sme->ssid, sme->ssid_len);
330 ar->arChannelHint = sme->channel->center_freq;
333 A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid));
335 if(memcmp(&sme->bssid, bcast_mac, AR6000_ETH_ADDR_LEN)) {
336 memcpy(ar->arReqBssid, sme->bssid, sizeof(ar->arReqBssid));
340 ar6k_set_wpa_version(ar, sme->crypto.wpa_versions);
341 ar6k_set_auth_type(ar, sme->auth_type);
343 if(sme->crypto.n_ciphers_pairwise) {
344 ar6k_set_cipher(ar, sme->crypto.ciphers_pairwise[0], true);
346 ar6k_set_cipher(ar, IW_AUTH_CIPHER_NONE, true);
348 ar6k_set_cipher(ar, sme->crypto.cipher_group, false);
350 if(sme->crypto.n_akm_suites) {
351 ar6k_set_key_mgmt(ar, sme->crypto.akm_suites[0]);
355 (NONE_AUTH == ar->arAuthMode) &&
356 (WEP_CRYPT == ar->arPairwiseCrypto)) {
357 struct ar_key *key = NULL;
359 if(sme->key_idx < WMI_MIN_KEY_INDEX || sme->key_idx > WMI_MAX_KEY_INDEX) {
360 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
361 ("%s: key index %d out of bounds\n", __func__, sme->key_idx));
366 key = &ar->keys[sme->key_idx];
367 key->key_len = sme->key_len;
368 memcpy(key->key, sme->key, key->key_len);
369 key->cipher = ar->arPairwiseCrypto;
370 ar->arDefTxKeyIndex = sme->key_idx;
372 wmi_addKey_cmd(ar->arWmi, sme->key_idx,
373 ar->arPairwiseCrypto,
374 GROUP_USAGE | TX_USAGE,
377 key->key, KEY_OP_INIT_VAL, NULL,
381 if (!ar->arUserBssFilter) {
382 if (wmi_bssfilter_cmd(ar->arWmi, ALL_BSS_FILTER, 0) != 0) {
383 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Couldn't set bss filtering\n", __func__));
389 ar->arNetworkType = ar->arNextMode;
391 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: Connect called with authmode %d dot11 auth %d"\
392 " PW crypto %d PW crypto Len %d GRP crypto %d"\
393 " GRP crypto Len %d channel hint %u\n",
394 __func__, ar->arAuthMode, ar->arDot11AuthMode,
395 ar->arPairwiseCrypto, ar->arPairwiseCryptoLen,
396 ar->arGroupCrypto, ar->arGroupCryptoLen, ar->arChannelHint));
399 status = wmi_connect_cmd(ar->arWmi, ar->arNetworkType,
400 ar->arDot11AuthMode, ar->arAuthMode,
401 ar->arPairwiseCrypto, ar->arPairwiseCryptoLen,
402 ar->arGroupCrypto,ar->arGroupCryptoLen,
403 ar->arSsidLen, ar->arSsid,
404 ar->arReqBssid, ar->arChannelHint,
405 ar->arConnectCtrlFlags);
409 if (A_EINVAL == status) {
410 A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
412 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Invalid request\n", __func__));
415 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: wmi_connect_cmd failed\n", __func__));
419 if ((!(ar->arConnectCtrlFlags & CONNECT_DO_WPA_OFFLOAD)) &&
420 ((WPA_PSK_AUTH == ar->arAuthMode) || (WPA2_PSK_AUTH == ar->arAuthMode)))
422 A_TIMEOUT_MS(&ar->disconnect_timer, A_DISCONNECT_TIMER_INTERVAL, 0);
425 ar->arConnectCtrlFlags &= ~CONNECT_DO_WPA_OFFLOAD;
426 ar->arConnectPending = true;
432 ar6k_cfg80211_connect_event(struct ar6_softc *ar, u16 channel,
433 u8 *bssid, u16 listenInterval,
434 u16 beaconInterval,NETWORK_TYPE networkType,
435 u8 beaconIeLen, u8 assocReqLen,
436 u8 assocRespLen, u8 *assocInfo)
440 struct cfg80211_bss *bss = NULL;
441 struct ieee80211_mgmt *mgmt = NULL;
442 struct ieee80211_channel *ibss_channel = NULL;
443 s32 signal = 50 * 100;
445 unsigned char ie_buf[256];
446 unsigned char *ptr_ie_buf = ie_buf;
447 unsigned char *ieeemgmtbuf = NULL;
448 u8 source_mac[ATH_MAC_LEN];
450 u8 assocReqIeOffset = sizeof(u16) + /* capinfo*/
451 sizeof(u16); /* listen interval */
452 u8 assocRespIeOffset = sizeof(u16) + /* capinfo*/
453 sizeof(u16) + /* status Code */
454 sizeof(u16); /* associd */
455 u8 *assocReqIe = assocInfo + beaconIeLen + assocReqIeOffset;
456 u8 *assocRespIe = assocInfo + beaconIeLen + assocReqLen + assocRespIeOffset;
458 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__));
460 assocReqLen -= assocReqIeOffset;
461 assocRespLen -= assocRespIeOffset;
463 if((ADHOC_NETWORK & networkType)) {
464 if(NL80211_IFTYPE_ADHOC != ar->wdev->iftype) {
465 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
466 ("%s: ath6k not in ibss mode\n", __func__));
471 if((INFRA_NETWORK & networkType)) {
472 if(NL80211_IFTYPE_STATION != ar->wdev->iftype) {
473 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
474 ("%s: ath6k not in station mode\n", __func__));
479 /* Before informing the join/connect event, make sure that
480 * bss entry is present in scan list, if it not present
481 * construct and insert into scan list, otherwise that
482 * event will be dropped on the way by cfg80211, due to
483 * this keys will not be plumbed in case of WEP and
484 * application will not be aware of join/connect status. */
485 bss = cfg80211_get_bss(ar->wdev->wiphy, NULL, bssid,
486 ar->wdev->ssid, ar->wdev->ssid_len,
487 ((ADHOC_NETWORK & networkType) ? WLAN_CAPABILITY_IBSS : WLAN_CAPABILITY_ESS),
488 ((ADHOC_NETWORK & networkType) ? WLAN_CAPABILITY_IBSS : WLAN_CAPABILITY_ESS));
491 if (ADHOC_NETWORK & networkType) {
492 /* construct 802.11 mgmt beacon */
494 *ptr_ie_buf++ = WLAN_EID_SSID;
495 *ptr_ie_buf++ = ar->arSsidLen;
496 memcpy(ptr_ie_buf, ar->arSsid, ar->arSsidLen);
497 ptr_ie_buf +=ar->arSsidLen;
499 *ptr_ie_buf++ = WLAN_EID_IBSS_PARAMS;
500 *ptr_ie_buf++ = 2; /* length */
501 *ptr_ie_buf++ = 0; /* ATIM window */
502 *ptr_ie_buf++ = 0; /* ATIM window */
504 /* TODO: update ibss params and include supported rates,
505 * DS param set, extened support rates, wmm. */
507 ie_buf_len = ptr_ie_buf - ie_buf;
510 capability |= IEEE80211_CAPINFO_IBSS;
511 if(WEP_CRYPT == ar->arPairwiseCrypto) {
512 capability |= IEEE80211_CAPINFO_PRIVACY;
514 memcpy(source_mac, ar->arNetDev->dev_addr, ATH_MAC_LEN);
517 capability = *(u16 *)(&assocInfo[beaconIeLen]);
518 memcpy(source_mac, bssid, ATH_MAC_LEN);
519 ptr_ie_buf = assocReqIe;
520 ie_buf_len = assocReqLen;
523 size = offsetof(struct ieee80211_mgmt, u)
524 + sizeof(mgmt->u.beacon)
527 ieeemgmtbuf = A_MALLOC_NOWAIT(size);
529 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
530 ("%s: ieeeMgmtbuf alloc error\n", __func__));
534 A_MEMZERO(ieeemgmtbuf, size);
535 mgmt = (struct ieee80211_mgmt *)ieeemgmtbuf;
536 mgmt->frame_control = (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
537 memcpy(mgmt->da, bcast_mac, ATH_MAC_LEN);
538 memcpy(mgmt->sa, source_mac, ATH_MAC_LEN);
539 memcpy(mgmt->bssid, bssid, ATH_MAC_LEN);
540 mgmt->u.beacon.beacon_int = beaconInterval;
541 mgmt->u.beacon.capab_info = capability;
542 memcpy(mgmt->u.beacon.variable, ptr_ie_buf, ie_buf_len);
544 ibss_channel = ieee80211_get_channel(ar->wdev->wiphy, (int)channel);
546 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
547 ("%s: inform bss with bssid %pM channel %d beaconInterval %d "
548 "capability 0x%x\n", __func__, mgmt->bssid,
549 ibss_channel->hw_value, beaconInterval, capability));
551 bss = cfg80211_inform_bss_frame(ar->wdev->wiphy,
556 cfg80211_put_bss(bss);
559 if((ADHOC_NETWORK & networkType)) {
560 cfg80211_ibss_joined(ar->arNetDev, bssid, GFP_KERNEL);
564 if (false == ar->arConnected) {
565 /* inform connect result to cfg80211 */
566 ar->smeState = SME_DISCONNECTED;
567 cfg80211_connect_result(ar->arNetDev, bssid,
568 assocReqIe, assocReqLen,
569 assocRespIe, assocRespLen,
570 WLAN_STATUS_SUCCESS, GFP_KERNEL);
572 /* inform roam event to cfg80211 */
573 cfg80211_roamed(ar->arNetDev, bssid,
574 assocReqIe, assocReqLen,
575 assocRespIe, assocRespLen,
581 ar6k_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev,
584 struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
586 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: reason=%u\n", __func__, reason_code));
588 if(ar->arWmiReady == false) {
589 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__));
593 if(ar->arWlanState == WLAN_DISABLED) {
594 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
598 if(ar->bIsDestroyProgress) {
599 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: busy, destroy in progress\n", __func__));
603 if(down_interruptible(&ar->arSem)) {
604 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: busy, couldn't get access\n", __func__));
609 ar6000_disconnect(ar);
610 A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
613 if (ar->arSkipScan == false) {
614 A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid));
623 ar6k_cfg80211_disconnect_event(struct ar6_softc *ar, u8 reason,
624 u8 *bssid, u8 assocRespLen,
625 u8 *assocInfo, u16 protocolReasonStatus)
628 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: reason=%u\n", __func__, reason));
630 if (ar->scan_request) {
631 cfg80211_scan_done(ar->scan_request, true);
632 ar->scan_request = NULL;
634 if((ADHOC_NETWORK & ar->arNetworkType)) {
635 if(NL80211_IFTYPE_ADHOC != ar->wdev->iftype) {
636 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
637 ("%s: ath6k not in ibss mode\n", __func__));
640 A_MEMZERO(bssid, ETH_ALEN);
641 cfg80211_ibss_joined(ar->arNetDev, bssid, GFP_KERNEL);
645 if((INFRA_NETWORK & ar->arNetworkType)) {
646 if(NL80211_IFTYPE_STATION != ar->wdev->iftype) {
647 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
648 ("%s: ath6k not in station mode\n", __func__));
653 if(true == ar->arConnectPending) {
654 if(NO_NETWORK_AVAIL == reason) {
655 /* connect cmd failed */
656 wmi_disconnect_cmd(ar->arWmi);
657 } else if (reason == DISCONNECT_CMD) {
658 /* connection loss due to disconnect cmd or low rssi */
659 ar->arConnectPending = false;
660 if (ar->smeState == SME_CONNECTING) {
661 cfg80211_connect_result(ar->arNetDev, bssid,
664 WLAN_STATUS_UNSPECIFIED_FAILURE,
667 cfg80211_disconnected(ar->arNetDev, reason, NULL, 0, GFP_KERNEL);
669 ar->smeState = SME_DISCONNECTED;
672 if (reason != DISCONNECT_CMD) {
673 wmi_disconnect_cmd(ar->arWmi);
679 ar6k_cfg80211_scan_node(void *arg, bss_t *ni)
681 struct wiphy *wiphy = (struct wiphy *)arg;
683 unsigned char *ieeemgmtbuf = NULL;
684 struct ieee80211_mgmt *mgmt;
685 struct ieee80211_channel *channel;
686 struct ieee80211_supported_band *band;
687 struct ieee80211_common_ie *cie;
693 #define CHAN_IS_11A(x) (!((x >= 2412) && (x <= 2484)))
694 if(CHAN_IS_11A(cie->ie_chan)) {
696 band = wiphy->bands[IEEE80211_BAND_5GHZ];
697 } else if((cie->ie_erp) || (cie->ie_xrates)) {
699 band = wiphy->bands[IEEE80211_BAND_2GHZ];
702 band = wiphy->bands[IEEE80211_BAND_2GHZ];
705 size = ni->ni_framelen + offsetof(struct ieee80211_mgmt, u);
706 ieeemgmtbuf = A_MALLOC_NOWAIT(size);
709 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: ieeeMgmtbuf alloc error\n", __func__));
714 TODO: Update target to include 802.11 mac header while sending bss info.
715 Target removes 802.11 mac header while sending the bss info to host,
716 cfg80211 needs it, for time being just filling the da, sa and bssid fields alone.
718 mgmt = (struct ieee80211_mgmt *)ieeemgmtbuf;
719 memcpy(mgmt->da, bcast_mac, ATH_MAC_LEN);
720 memcpy(mgmt->sa, ni->ni_macaddr, ATH_MAC_LEN);
721 memcpy(mgmt->bssid, ni->ni_macaddr, ATH_MAC_LEN);
722 memcpy(ieeemgmtbuf + offsetof(struct ieee80211_mgmt, u),
723 ni->ni_buf, ni->ni_framelen);
726 channel = ieee80211_get_channel(wiphy, freq);
727 signal = ni->ni_snr * 100;
729 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
730 ("%s: bssid %pM channel %d freq %d size %d\n", __func__,
731 mgmt->bssid, channel->hw_value, freq, size));
732 cfg80211_inform_bss_frame(wiphy, channel, mgmt,
740 ar6k_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
741 struct cfg80211_scan_request *request)
743 struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(ndev);
747 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__));
749 if(ar->arWmiReady == false) {
750 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__));
754 if(ar->arWlanState == WLAN_DISABLED) {
755 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
759 if (!ar->arUserBssFilter) {
760 if (wmi_bssfilter_cmd(ar->arWmi,
761 (ar->arConnected ? ALL_BUT_BSS_FILTER : ALL_BSS_FILTER),
763 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Couldn't set bss filtering\n", __func__));
768 if(request->n_ssids &&
769 request->ssids[0].ssid_len) {
772 if(request->n_ssids > (MAX_PROBED_SSID_INDEX - 1)) {
773 request->n_ssids = MAX_PROBED_SSID_INDEX - 1;
776 for (i = 0; i < request->n_ssids; i++) {
777 wmi_probedSsid_cmd(ar->arWmi, i+1, SPECIFIC_SSID_FLAG,
778 request->ssids[i].ssid_len,
779 request->ssids[i].ssid);
783 if(ar->arConnected) {
787 if(wmi_startscan_cmd(ar->arWmi, WMI_LONG_SCAN, forceFgScan, false, \
788 0, 0, 0, NULL) != 0) {
789 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: wmi_startscan_cmd failed\n", __func__));
793 ar->scan_request = request;
799 ar6k_cfg80211_scanComplete_event(struct ar6_softc *ar, int status)
802 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: status %d\n", __func__, status));
806 /* Translate data to cfg80211 mgmt format */
807 wmi_iterate_nodes(ar->arWmi, ar6k_cfg80211_scan_node, ar->wdev->wiphy);
809 cfg80211_scan_done(ar->scan_request,
810 ((status & A_ECANCELED) || (status & A_EBUSY)) ? true : false);
812 if(ar->scan_request->n_ssids &&
813 ar->scan_request->ssids[0].ssid_len) {
816 for (i = 0; i < ar->scan_request->n_ssids; i++) {
817 wmi_probedSsid_cmd(ar->arWmi, i+1, DISABLE_SSID_FLAG,
821 ar->scan_request = NULL;
826 ar6k_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
827 u8 key_index, bool pairwise, const u8 *mac_addr,
828 struct key_params *params)
830 struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(ndev);
831 struct ar_key *key = NULL;
836 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s:\n", __func__));
838 if(ar->arWmiReady == false) {
839 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__));
843 if(ar->arWlanState == WLAN_DISABLED) {
844 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
848 if(key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) {
849 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
850 ("%s: key index %d out of bounds\n", __func__, key_index));
854 key = &ar->keys[key_index];
855 A_MEMZERO(key, sizeof(struct ar_key));
857 if(!mac_addr || is_broadcast_ether_addr(mac_addr)) {
858 key_usage = GROUP_USAGE;
860 key_usage = PAIRWISE_USAGE;
864 if(params->key_len > WLAN_MAX_KEY_LEN ||
865 params->seq_len > IW_ENCODE_SEQ_MAX_SIZE)
868 key->key_len = params->key_len;
869 memcpy(key->key, params->key, key->key_len);
870 key->seq_len = params->seq_len;
871 memcpy(key->seq, params->seq, key->seq_len);
872 key->cipher = params->cipher;
875 switch (key->cipher) {
876 case WLAN_CIPHER_SUITE_WEP40:
877 case WLAN_CIPHER_SUITE_WEP104:
878 key_type = WEP_CRYPT;
881 case WLAN_CIPHER_SUITE_TKIP:
882 key_type = TKIP_CRYPT;
885 case WLAN_CIPHER_SUITE_CCMP:
886 key_type = AES_CRYPT;
893 if (((WPA_PSK_AUTH == ar->arAuthMode) || (WPA2_PSK_AUTH == ar->arAuthMode)) &&
894 (GROUP_USAGE & key_usage))
896 A_UNTIMEOUT(&ar->disconnect_timer);
899 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
900 ("%s: index %d, key_len %d, key_type 0x%x,"\
901 " key_usage 0x%x, seq_len %d\n",
902 __func__, key_index, key->key_len, key_type,
903 key_usage, key->seq_len));
905 ar->arDefTxKeyIndex = key_index;
906 status = wmi_addKey_cmd(ar->arWmi, ar->arDefTxKeyIndex, key_type, key_usage,
907 key->key_len, key->seq, key->key, KEY_OP_INIT_VAL,
908 (u8 *)mac_addr, SYNC_BOTH_WMIFLAG);
919 ar6k_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev,
920 u8 key_index, bool pairwise, const u8 *mac_addr)
922 struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(ndev);
924 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: index %d\n", __func__, key_index));
926 if(ar->arWmiReady == false) {
927 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__));
931 if(ar->arWlanState == WLAN_DISABLED) {
932 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
936 if(key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) {
937 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
938 ("%s: key index %d out of bounds\n", __func__, key_index));
942 if(!ar->keys[key_index].key_len) {
943 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: index %d is empty\n", __func__, key_index));
947 ar->keys[key_index].key_len = 0;
949 return wmi_deleteKey_cmd(ar->arWmi, key_index);
954 ar6k_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev,
955 u8 key_index, bool pairwise, const u8 *mac_addr,
957 void (*callback)(void *cookie, struct key_params*))
959 struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(ndev);
960 struct ar_key *key = NULL;
961 struct key_params params;
963 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: index %d\n", __func__, key_index));
965 if(ar->arWmiReady == false) {
966 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__));
970 if(ar->arWlanState == WLAN_DISABLED) {
971 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
975 if(key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) {
976 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
977 ("%s: key index %d out of bounds\n", __func__, key_index));
981 key = &ar->keys[key_index];
982 A_MEMZERO(¶ms, sizeof(params));
983 params.cipher = key->cipher;
984 params.key_len = key->key_len;
985 params.seq_len = key->seq_len;
986 params.seq = key->seq;
987 params.key = key->key;
989 callback(cookie, ¶ms);
991 return key->key_len ? 0 : -ENOENT;
996 ar6k_cfg80211_set_default_key(struct wiphy *wiphy, struct net_device *ndev,
997 u8 key_index, bool unicast, bool multicast)
999 struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(ndev);
1000 struct ar_key *key = NULL;
1004 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: index %d\n", __func__, key_index));
1006 if(ar->arWmiReady == false) {
1007 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__));
1011 if(ar->arWlanState == WLAN_DISABLED) {
1012 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
1016 if(key_index < WMI_MIN_KEY_INDEX || key_index > WMI_MAX_KEY_INDEX) {
1017 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
1018 ("%s: key index %d out of bounds\n",
1019 __func__, key_index));
1023 if(!ar->keys[key_index].key_len) {
1024 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: invalid key index %d\n",
1025 __func__, key_index));
1029 ar->arDefTxKeyIndex = key_index;
1030 key = &ar->keys[ar->arDefTxKeyIndex];
1031 key_usage = GROUP_USAGE;
1032 if (WEP_CRYPT == ar->arPairwiseCrypto) {
1033 key_usage |= TX_USAGE;
1036 status = wmi_addKey_cmd(ar->arWmi, ar->arDefTxKeyIndex,
1037 ar->arPairwiseCrypto, key_usage,
1038 key->key_len, key->seq, key->key, KEY_OP_INIT_VAL,
1039 NULL, SYNC_BOTH_WMIFLAG);
1048 ar6k_cfg80211_set_default_mgmt_key(struct wiphy *wiphy, struct net_device *ndev,
1051 struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(ndev);
1053 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: index %d\n", __func__, key_index));
1055 if(ar->arWmiReady == false) {
1056 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__));
1060 if(ar->arWlanState == WLAN_DISABLED) {
1061 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
1065 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: not supported\n", __func__));
1070 ar6k_cfg80211_tkip_micerr_event(struct ar6_softc *ar, u8 keyid, bool ismcast)
1072 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
1073 ("%s: keyid %d, ismcast %d\n", __func__, keyid, ismcast));
1075 cfg80211_michael_mic_failure(ar->arNetDev, ar->arBssid,
1076 (ismcast ? NL80211_KEYTYPE_GROUP : NL80211_KEYTYPE_PAIRWISE),
1077 keyid, NULL, GFP_KERNEL);
1081 ar6k_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1083 struct ar6_softc *ar = (struct ar6_softc *)wiphy_priv(wiphy);
1085 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: changed 0x%x\n", __func__, changed));
1087 if(ar->arWmiReady == false) {
1088 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__));
1092 if(ar->arWlanState == WLAN_DISABLED) {
1093 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
1097 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1098 if (wmi_set_rts_cmd(ar->arWmi,wiphy->rts_threshold) != 0){
1099 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: wmi_set_rts_cmd failed\n", __func__));
1108 ar6k_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev,
1110 const struct cfg80211_bitrate_mask *mask)
1112 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Setting rates: Not supported\n"));
1116 /* The type nl80211_tx_power_setting replaces the following data type from 2.6.36 onwards */
1118 ar6k_cfg80211_set_txpower(struct wiphy *wiphy, enum nl80211_tx_power_setting type, int dbm)
1120 struct ar6_softc *ar = (struct ar6_softc *)wiphy_priv(wiphy);
1123 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: type 0x%x, dbm %d\n", __func__, type, dbm));
1125 if(ar->arWmiReady == false) {
1126 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__));
1130 if(ar->arWlanState == WLAN_DISABLED) {
1131 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
1135 ar->arTxPwrSet = false;
1137 case NL80211_TX_POWER_AUTOMATIC:
1139 case NL80211_TX_POWER_LIMITED:
1140 ar->arTxPwr = ar_dbm = dbm;
1141 ar->arTxPwrSet = true;
1144 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: type 0x%x not supported\n", __func__, type));
1148 wmi_set_txPwr_cmd(ar->arWmi, ar_dbm);
1154 ar6k_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm)
1156 struct ar6_softc *ar = (struct ar6_softc *)wiphy_priv(wiphy);
1158 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__));
1160 if(ar->arWmiReady == false) {
1161 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__));
1165 if(ar->arWlanState == WLAN_DISABLED) {
1166 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
1170 if((ar->arConnected == true)) {
1173 if(wmi_get_txPwr_cmd(ar->arWmi) != 0) {
1174 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: wmi_get_txPwr_cmd failed\n", __func__));
1178 wait_event_interruptible_timeout(arEvent, ar->arTxPwr != 0, 5 * HZ);
1180 if(signal_pending(current)) {
1181 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Target did not respond\n", __func__));
1191 ar6k_cfg80211_set_power_mgmt(struct wiphy *wiphy,
1192 struct net_device *dev,
1193 bool pmgmt, int timeout)
1195 struct ar6_softc *ar = ar6k_priv(dev);
1196 WMI_POWER_MODE_CMD pwrMode;
1198 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: pmgmt %d, timeout %d\n", __func__, pmgmt, timeout));
1200 if(ar->arWmiReady == false) {
1201 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__));
1205 if(ar->arWlanState == WLAN_DISABLED) {
1206 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
1211 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: Max Perf\n", __func__));
1212 pwrMode.powerMode = REC_POWER;
1214 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: Rec Power\n", __func__));
1215 pwrMode.powerMode = MAX_PERF_POWER;
1218 if(wmi_powermode_cmd(ar->arWmi, pwrMode.powerMode) != 0) {
1219 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: wmi_powermode_cmd failed\n", __func__));
1226 static struct net_device *
1227 ar6k_cfg80211_add_virtual_intf(struct wiphy *wiphy, char *name,
1228 enum nl80211_iftype type, u32 *flags,
1229 struct vif_params *params)
1232 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: not supported\n", __func__));
1234 /* Multiple virtual interface is not supported.
1235 * The default interface supports STA and IBSS type
1237 return ERR_PTR(-EOPNOTSUPP);
1241 ar6k_cfg80211_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev)
1244 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: not supported\n", __func__));
1246 /* Multiple virtual interface is not supported.
1247 * The default interface supports STA and IBSS type
1253 ar6k_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
1254 enum nl80211_iftype type, u32 *flags,
1255 struct vif_params *params)
1257 struct ar6_softc *ar = ar6k_priv(ndev);
1258 struct wireless_dev *wdev = ar->wdev;
1260 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: type %u\n", __func__, type));
1262 if(ar->arWmiReady == false) {
1263 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__));
1267 if(ar->arWlanState == WLAN_DISABLED) {
1268 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
1273 case NL80211_IFTYPE_STATION:
1274 ar->arNextMode = INFRA_NETWORK;
1276 case NL80211_IFTYPE_ADHOC:
1277 ar->arNextMode = ADHOC_NETWORK;
1280 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: type %u\n", __func__, type));
1284 wdev->iftype = type;
1290 ar6k_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
1291 struct cfg80211_ibss_params *ibss_param)
1293 struct ar6_softc *ar = ar6k_priv(dev);
1296 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__));
1298 if(ar->arWmiReady == false) {
1299 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__));
1303 if(ar->arWlanState == WLAN_DISABLED) {
1304 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
1308 if(!ibss_param->ssid_len || IEEE80211_MAX_SSID_LEN < ibss_param->ssid_len) {
1309 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: ssid invalid\n", __func__));
1313 ar->arSsidLen = ibss_param->ssid_len;
1314 memcpy(ar->arSsid, ibss_param->ssid, ar->arSsidLen);
1316 if(ibss_param->channel) {
1317 ar->arChannelHint = ibss_param->channel->center_freq;
1320 if(ibss_param->channel_fixed) {
1321 /* TODO: channel_fixed: The channel should be fixed, do not search for
1322 * IBSSs to join on other channels. Target firmware does not support this
1323 * feature, needs to be updated.*/
1326 A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid));
1327 if(ibss_param->bssid) {
1328 if(memcmp(&ibss_param->bssid, bcast_mac, AR6000_ETH_ADDR_LEN)) {
1329 memcpy(ar->arReqBssid, ibss_param->bssid, sizeof(ar->arReqBssid));
1333 ar6k_set_wpa_version(ar, 0);
1334 ar6k_set_auth_type(ar, NL80211_AUTHTYPE_OPEN_SYSTEM);
1336 if(ibss_param->privacy) {
1337 ar6k_set_cipher(ar, WLAN_CIPHER_SUITE_WEP40, true);
1338 ar6k_set_cipher(ar, WLAN_CIPHER_SUITE_WEP40, false);
1340 ar6k_set_cipher(ar, IW_AUTH_CIPHER_NONE, true);
1341 ar6k_set_cipher(ar, IW_AUTH_CIPHER_NONE, false);
1344 ar->arNetworkType = ar->arNextMode;
1346 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: Connect called with authmode %d dot11 auth %d"\
1347 " PW crypto %d PW crypto Len %d GRP crypto %d"\
1348 " GRP crypto Len %d channel hint %u\n",
1349 __func__, ar->arAuthMode, ar->arDot11AuthMode,
1350 ar->arPairwiseCrypto, ar->arPairwiseCryptoLen,
1351 ar->arGroupCrypto, ar->arGroupCryptoLen, ar->arChannelHint));
1353 status = wmi_connect_cmd(ar->arWmi, ar->arNetworkType,
1354 ar->arDot11AuthMode, ar->arAuthMode,
1355 ar->arPairwiseCrypto, ar->arPairwiseCryptoLen,
1356 ar->arGroupCrypto,ar->arGroupCryptoLen,
1357 ar->arSsidLen, ar->arSsid,
1358 ar->arReqBssid, ar->arChannelHint,
1359 ar->arConnectCtrlFlags);
1360 ar->arConnectPending = true;
1366 ar6k_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
1368 struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
1370 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__));
1372 if(ar->arWmiReady == false) {
1373 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wmi not ready\n", __func__));
1377 if(ar->arWlanState == WLAN_DISABLED) {
1378 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Wlan disabled\n", __func__));
1382 ar6000_disconnect(ar);
1383 A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
1391 u32 cipher_suites[] = {
1392 WLAN_CIPHER_SUITE_WEP40,
1393 WLAN_CIPHER_SUITE_WEP104,
1394 WLAN_CIPHER_SUITE_TKIP,
1395 WLAN_CIPHER_SUITE_CCMP,
1399 cfg80211_ops ar6k_cfg80211_ops = {
1400 .change_virtual_intf = ar6k_cfg80211_change_iface,
1401 .add_virtual_intf = ar6k_cfg80211_add_virtual_intf,
1402 .del_virtual_intf = ar6k_cfg80211_del_virtual_intf,
1403 .scan = ar6k_cfg80211_scan,
1404 .connect = ar6k_cfg80211_connect,
1405 .disconnect = ar6k_cfg80211_disconnect,
1406 .add_key = ar6k_cfg80211_add_key,
1407 .get_key = ar6k_cfg80211_get_key,
1408 .del_key = ar6k_cfg80211_del_key,
1409 .set_default_key = ar6k_cfg80211_set_default_key,
1410 .set_default_mgmt_key = ar6k_cfg80211_set_default_mgmt_key,
1411 .set_wiphy_params = ar6k_cfg80211_set_wiphy_params,
1412 .set_bitrate_mask = ar6k_cfg80211_set_bitrate_mask,
1413 .set_tx_power = ar6k_cfg80211_set_txpower,
1414 .get_tx_power = ar6k_cfg80211_get_txpower,
1415 .set_power_mgmt = ar6k_cfg80211_set_power_mgmt,
1416 .join_ibss = ar6k_cfg80211_join_ibss,
1417 .leave_ibss = ar6k_cfg80211_leave_ibss,
1420 struct wireless_dev *
1421 ar6k_cfg80211_init(struct device *dev)
1424 struct wireless_dev *wdev;
1426 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__));
1428 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
1430 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
1431 ("%s: Couldn't allocate wireless device\n", __func__));
1432 return ERR_PTR(-ENOMEM);
1435 /* create a new wiphy for use with cfg80211 */
1436 wdev->wiphy = wiphy_new(&ar6k_cfg80211_ops, sizeof(struct ar6_softc));
1438 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
1439 ("%s: Couldn't allocate wiphy device\n", __func__));
1441 return ERR_PTR(-ENOMEM);
1444 /* set device pointer for wiphy */
1445 set_wiphy_dev(wdev->wiphy, dev);
1447 wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
1448 BIT(NL80211_IFTYPE_ADHOC);
1449 /* max num of ssids that can be probed during scanning */
1450 wdev->wiphy->max_scan_ssids = MAX_PROBED_SSID_INDEX;
1451 wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &ar6k_band_2ghz;
1452 wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = &ar6k_band_5ghz;
1453 wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
1455 wdev->wiphy->cipher_suites = cipher_suites;
1456 wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
1458 ret = wiphy_register(wdev->wiphy);
1460 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
1461 ("%s: Couldn't register wiphy device\n", __func__));
1462 wiphy_free(wdev->wiphy);
1463 return ERR_PTR(ret);
1470 ar6k_cfg80211_deinit(struct ar6_softc *ar)
1472 struct wireless_dev *wdev = ar->wdev;
1474 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: \n", __func__));
1476 if(ar->scan_request) {
1477 cfg80211_scan_done(ar->scan_request, true);
1478 ar->scan_request = NULL;
1484 wiphy_unregister(wdev->wiphy);
1485 wiphy_free(wdev->wiphy);