19 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21 #include <linux/kernel.h>
22 #include <linux/if_arp.h>
23 #include <linux/sched.h>
25 #include <linux/netdevice.h>
26 #include <linux/bitops.h>
39 #define BRCMF_SCAN_IE_LEN_MAX 2048
40 #define BRCMF_PNO_VERSION 2
41 #define BRCMF_PNO_TIME 30
42 #define BRCMF_PNO_REPEAT 4
43 #define BRCMF_PNO_FREQ_EXPO_MAX 3
44 #define BRCMF_PNO_MAX_PFN_COUNT 16
45 #define BRCMF_PNO_ENABLE_ADAPTSCAN_BIT 6
46 #define BRCMF_PNO_HIDDEN_BIT 2
47 #define BRCMF_PNO_WPA_AUTH_ANY 0xFFFFFFFF
48 #define BRCMF_PNO_SCAN_COMPLETE 1
49 #define BRCMF_PNO_SCAN_INCOMPLETE 0
53 #define TLV_BODY_OFF 2
55 #define WPA_OUI "\x00\x50\xF2"
56 #define WPA_OUI_TYPE 1
57 #define RSN_OUI "\x00\x0F\xAC"
58 #define WME_OUI_TYPE 2
60 #define VS_IE_FIXED_HDR_LEN 6
61 #define WPA_IE_VERSION_LEN 2
62 #define WPA_IE_MIN_OUI_LEN 4
63 #define WPA_IE_SUITE_COUNT_LEN 2
65 #define WPA_CIPHER_NONE 0
66 #define WPA_CIPHER_WEP_40 1
67 #define WPA_CIPHER_TKIP 2
68 #define WPA_CIPHER_AES_CCM 4
69 #define WPA_CIPHER_WEP_104 5
71 #define RSN_AKM_NONE 0
72 #define RSN_AKM_UNSPECIFIED 1
75 #define RSN_CAP_PTK_REPLAY_CNTR_MASK 0x000C
77 #define VNDR_IE_CMD_LEN 4
80 #define VNDR_IE_COUNT_OFFSET 4
81 #define VNDR_IE_PKTFLAG_OFFSET 8
82 #define VNDR_IE_VSIE_OFFSET 12
83 #define VNDR_IE_HDR_SIZE 12
84 #define VNDR_IE_BEACON_FLAG 0x1
85 #define VNDR_IE_PRBRSP_FLAG 0x2
86 #define MAX_VNDR_IE_NUMBER 5
88 #define DOT11_MGMT_HDR_LEN 24
89 #define DOT11_BCN_PRB_FIXED_LEN 12
91 #define BRCMF_ASSOC_PARAMS_FIXED_SIZE \
92 (sizeof(struct brcmf_assoc_params_le) - sizeof(u16))
94 static const u8 ether_bcast[
ETH_ALEN] = {255, 255, 255, 255, 255, 255};
102 WL_INFO(
"device is not ready : status (%d)\n",
109 #define CHAN2G(_channel, _freq, _flags) { \
110 .band = IEEE80211_BAND_2GHZ, \
111 .center_freq = (_freq), \
112 .hw_value = (_channel), \
114 .max_antenna_gain = 0, \
118 #define CHAN5G(_channel, _flags) { \
119 .band = IEEE80211_BAND_5GHZ, \
120 .center_freq = 5000 + (5 * (_channel)), \
121 .hw_value = (_channel), \
123 .max_antenna_gain = 0, \
127 #define RATE_TO_BASE100KBPS(rate) (((rate) * 10) / 2)
128 #define RATETAB_ENT(_rateid, _flags) \
130 .bitrate = RATE_TO_BASE100KBPS(_rateid), \
131 .hw_value = (_rateid), \
150 #define wl_a_rates (__wl_rates + 4)
151 #define wl_a_rates_size 8
152 #define wl_g_rates (__wl_rates + 0)
153 #define wl_g_rates_size 12
254 .channels = __wl_2ghz_channels,
262 .channels = __wl_5ghz_a_channels,
263 .n_channels =
ARRAY_SIZE(__wl_5ghz_a_channels),
270 .channels = __wl_5ghz_n_channels,
271 .n_channels =
ARRAY_SIZE(__wl_5ghz_n_channels),
276 static const u32 __wl_cipher_suites[] = {
316 #define QDBM_OFFSET 153
317 #define QDBM_TABLE_LEN 40
322 #define QDBM_TABLE_LOW_BOUND 6493
329 #define QDBM_TABLE_HIGH_BOUND 64938
333 6683, 7079, 7499, 7943, 8414, 8913, 9441, 10000,
334 10593, 11220, 11885, 12589, 13335, 14125, 14962, 15849,
335 16788, 17783, 18836, 19953, 21135, 22387, 23714, 25119,
336 26607, 28184, 29854, 31623, 33497, 35481, 37584, 39811,
337 42170, 44668, 47315, 50119, 53088, 56234, 59566, 63096
340 static u16 brcmf_qdbm_to_mw(
u8 qdbm)
360 return (nqdBm_to_mW_map[idx] + factor / 2) / factor;
363 static u8 brcmf_mw_to_qdbm(
u16 mw)
383 boundary = nqdBm_to_mW_map[qdbm] + (nqdBm_to_mW_map[qdbm + 1] -
384 nqdBm_to_mW_map[qdbm]) / 2;
385 if (mw_uint < boundary)
416 buf, buflen, bssidx);
421 WL_ERR(
"error (%d)\n", err);
427 brcmf_dev_iovar_getbuf_bsscfg(
struct net_device *ndev,
s8 *name,
428 void *param,
s32 paramlen,
429 void *buf,
s32 buflen,
s32 bssidx)
435 buf, buflen, bssidx);
440 WL_ERR(
"error (%d)\n", err);
466 convert_key_from_CPU(key, &key_le);
468 err = brcmf_dev_iovar_setbuf_bsscfg(ndev,
"wsec_key", &key_le,
474 WL_ERR(
"wsec_key error (%d)\n", err);
479 brcmf_cfg80211_change_iface(
struct wiphy *wiphy,
struct net_device *ndev,
488 WL_TRACE(
"Enter, ndev=%p, type=%d\n", ndev, type);
493 WL_ERR(
"type (%d) : currently we do not support this type\n",
526 WL_ERR(
"WLC_SET_INFRA error (%d)\n", err);
556 WL_ERR(
"error (%d)\n", err);
578 WL_ERR(
"error (%d)\n", err);
586 brcmf_dev_intvar_set_bsscfg(
struct net_device *ndev,
s8 *name,
u32 val,
594 return brcmf_dev_iovar_setbuf_bsscfg(ndev, name, &val_le,
595 sizeof(val_le), buf,
sizeof(buf),
600 brcmf_dev_intvar_get_bsscfg(
struct net_device *ndev,
s8 *name,
s32 *val,
607 memset(buf, 0,
sizeof(buf));
608 err = brcmf_dev_iovar_getbuf_bsscfg(ndev, name, val,
sizeof(*val), buf,
609 sizeof(buf), bssidx);
611 memcpy(&val_le, buf,
sizeof(val_le));
628 static void brcmf_set_mpc(
struct net_device *ndev,
int mpc)
634 err = brcmf_dev_intvar_set(ndev,
"mpc", mpc);
636 WL_ERR(
"fail to set mpc\n");
661 brcmf_dev_iovar_setbuf(
struct net_device *ndev,
s8 * iovar,
void *param,
673 brcmf_dev_iovar_getbuf(
struct net_device *ndev,
s8 * iovar,
void *param,
700 brcmf_iscan_prep(¶ms->
params_le, ssid);
706 err = brcmf_dev_iovar_setbuf(iscan->
ndev,
"iscan", params, params_size,
710 WL_INFO(
"system busy : iscan canceled\n");
712 WL_ERR(
"error (%d)\n", err);
728 memset(&ssid, 0,
sizeof(ssid));
734 &passive_scan,
sizeof(passive_scan));
736 WL_ERR(
"error (%d)\n", err);
739 brcmf_set_mpc(ndev, 0);
743 brcmf_set_mpc(ndev, 1);
753 brcmf_cfg80211_iscan(
struct wiphy *wiphy,
struct net_device *ndev,
767 WL_ERR(
"Scanning already : status (%lu)\n", cfg->
status);
771 WL_ERR(
"Scanning being aborted : status (%lu)\n",
776 WL_ERR(
"Connecting : status (%lu)\n",
785 ssids = request->
ssids;
797 err = brcmf_do_iscan(cfg);
803 WL_SCAN(
"ssid \"%s\", ssid_len (%d)\n",
818 &passive_scan,
sizeof(passive_scan));
820 WL_ERR(
"WLC_SET_PASSIVE_SCAN error (%d)\n", err);
823 brcmf_set_mpc(ndev, 0);
828 WL_INFO(
"system busy : scan for \"%s\" "
829 "canceled\n", sr->
ssid_le.SSID);
831 WL_ERR(
"WLC_SCAN error (%d)\n", err);
833 brcmf_set_mpc(ndev, 1);
876 WL_SCAN(
"### List of channelspecs to scan ### %d\n", n_channels);
877 if (n_channels > 0) {
878 for (i = 0; i < n_channels; i++) {
893 if (req_channel->
flags &
901 WL_SCAN(
"Chan : %d, Channel spec: %x\n",
906 WL_SCAN(
"Scanning all channels\n");
909 WL_SCAN(
"### List of SSIDs to scan ### %d\n", n_ssids);
912 n_channels *
sizeof(
u16);
914 ptr = (
char *)params_le + offset;
915 for (i = 0; i < n_ssids; i++) {
916 memset(&ssid_le, 0,
sizeof(ssid_le));
920 request->
ssids[i].ssid_len);
921 if (!ssid_le.SSID_len)
922 WL_SCAN(
"%d: Broadcast scan\n", i);
924 WL_SCAN(
"%d: scan for %s size =%d\n", i,
925 ssid_le.SSID, ssid_le.SSID_len);
926 memcpy(ptr, &ssid_le,
sizeof(ssid_le));
927 ptr +=
sizeof(ssid_le);
931 if ((request->
ssids) && request->
ssids->ssid_len) {
933 request->
ssids->ssid_len);
937 request->
ssids->ssid_len);
967 WL_SCAN(
"ABORT scan in firmware\n");
968 memset(¶ms_le, 0,
sizeof(params_le));
983 WL_ERR(
"Scan abort failed\n");
990 WL_SCAN(
"scheduled scan completed\n");
994 brcmf_set_mpc(ndev, 1);
995 }
else if (scan_request) {
996 WL_SCAN(
"ESCAN Completed scan: %s\n",
997 aborted ?
"Aborted" :
"Done");
999 brcmf_set_mpc(ndev, 1);
1002 WL_ERR(
"Scan complete while device not scanning\n");
1020 if (request !=
NULL) {
1022 params_size +=
sizeof(
u32) * ((request->
n_channels + 1) / 2);
1034 brcmf_escan_prep(¶ms->
params_le, request);
1039 err = brcmf_dev_iovar_setbuf(ndev,
"escan", params, params_size,
1043 WL_INFO(
"system busy : escan canceled\n");
1045 WL_ERR(
"error (%d)\n", err);
1067 &passive_scan,
sizeof(passive_scan));
1069 WL_ERR(
"error (%d)\n", err);
1072 brcmf_set_mpc(ndev, 0);
1080 brcmf_set_mpc(ndev, 1);
1085 brcmf_cfg80211_escan(
struct wiphy *wiphy,
struct net_device *ndev,
1101 WL_ERR(
"Scanning already : status (%lu)\n", cfg->
status);
1105 WL_ERR(
"Scanning being aborted : status (%lu)\n",
1110 WL_ERR(
"Connecting : status (%lu)\n",
1122 ssids = request->
ssids;
1133 err = brcmf_do_escan(cfg, wiphy, ndev, request);
1139 WL_SCAN(
"ssid \"%s\", ssid_len (%d)\n",
1154 &passive_scan,
sizeof(passive_scan));
1156 WL_ERR(
"WLC_SET_PASSIVE_SCAN error (%d)\n", err);
1159 brcmf_set_mpc(ndev, 0);
1164 WL_INFO(
"BUSY: scan for \"%s\" canceled\n",
1167 WL_ERR(
"WLC_SCAN error (%d)\n", err);
1169 brcmf_set_mpc(ndev, 1);
1185 brcmf_cfg80211_scan(
struct wiphy *wiphy,
1194 if (!check_sys_up(wiphy))
1198 err = brcmf_cfg80211_iscan(wiphy, ndev, request,
NULL);
1200 err = brcmf_cfg80211_escan(wiphy, ndev, request,
NULL);
1203 WL_ERR(
"scan error (%d)\n", err);
1213 err = brcmf_dev_intvar_set(ndev,
"rtsthresh", rts_threshold);
1215 WL_ERR(
"Error (%d)\n", err);
1224 err = brcmf_dev_intvar_set(ndev,
"fragthresh", frag_threshold);
1226 WL_ERR(
"Error (%d)\n", err);
1236 err = brcmf_exec_dcmd_u32(ndev, cmd, &retry);
1238 WL_ERR(
"cmd (%d) , error (%d)\n", cmd, err);
1244 static s32 brcmf_cfg80211_set_wiphy_params(
struct wiphy *wiphy,
u32 changed)
1251 if (!check_sys_up(wiphy))
1257 err = brcmf_set_rts(ndev, cfg->
conf->rts_threshold);
1264 err = brcmf_set_frag(ndev, cfg->
conf->frag_threshold);
1271 err = brcmf_set_retry(ndev, cfg->
conf->retry_long,
true);
1278 err = brcmf_set_retry(ndev, cfg->
conf->retry_short,
false);
1290 memset(prof, 0,
sizeof(*prof));
1294 size_t *join_params_size)
1314 WL_CONN(
"join_params->params.chanspec_list[0]= %#X,"
1315 "channel %d, chanspec %#X\n",
1316 chanspec, ch, chanspec);
1328 ndev = cfg_to_ndev(cfg);
1329 WL_INFO(
"Call WLC_DISASSOC to stop excess roaming\n ");
1332 WL_ERR(
"WLC_DISASSOC failed (%d)\n", err);
1339 brcmf_cfg80211_join_ibss(
struct wiphy *wiphy,
struct net_device *ndev,
1345 size_t join_params_size = 0;
1351 if (!check_sys_up(wiphy))
1357 WL_CONN(
"SSID: NULL, Not supported\n");
1366 WL_CONN(
"No BSSID specified\n");
1371 WL_CONN(
"no channel specified\n");
1374 WL_CONN(
"fixed channel required\n");
1376 WL_CONN(
"no fixed channel required\n");
1386 WL_CONN(
"no beacon interval specified\n");
1391 WL_CONN(
"no basic rates specified\n");
1394 WL_CONN(
"privacy required\n");
1396 WL_CONN(
"no privacy required\n");
1402 err = brcmf_dev_intvar_set(ndev,
"wsec", wsec);
1404 WL_ERR(
"wsec failed (%d)\n", err);
1416 WL_ERR(
"WLC_SET_BCNPRD failed (%d)\n", err);
1428 join_params_size =
sizeof(join_params.
ssid_le);
1431 if (params->
bssid) {
1433 join_params_size =
sizeof(join_params.
ssid_le) +
1447 params->
channel->center_freq);
1450 brcmf_ch_to_chanspec(cfg->
channel,
1451 &join_params, &join_params_size);
1455 target_channel = cfg->
channel;
1459 WL_ERR(
"WLC_SET_CHANNEL failed (%d)\n", err);
1469 &join_params, join_params_size);
1471 WL_ERR(
"WLC_SET_SSID failed (%d)\n", err);
1483 brcmf_cfg80211_leave_ibss(
struct wiphy *wiphy,
struct net_device *ndev)
1489 if (!check_sys_up(wiphy))
1492 brcmf_link_down(cfg);
1514 WL_CONN(
"setting wpa_auth to 0x%0x\n", val);
1515 err = brcmf_dev_intvar_set(ndev,
"wpa_auth", val);
1517 WL_ERR(
"set wpa_auth failed (%d)\n", err);
1520 sec = &profile->
sec;
1555 err = brcmf_dev_intvar_set(ndev,
"auth", val);
1557 WL_ERR(
"set auth failed (%d)\n", err);
1560 sec = &profile->
sec;
1566 brcmf_set_set_cipher(
struct net_device *ndev,
1576 if (sme->
crypto.n_ciphers_pairwise) {
1577 switch (sme->
crypto.ciphers_pairwise[0]) {
1592 WL_ERR(
"invalid cipher pairwise (%d)\n",
1593 sme->
crypto.ciphers_pairwise[0]);
1597 if (sme->
crypto.cipher_group) {
1598 switch (sme->
crypto.cipher_group) {
1613 WL_ERR(
"invalid cipher group (%d)\n",
1614 sme->
crypto.cipher_group);
1619 WL_CONN(
"pval (%d) gval (%d)\n", pval, gval);
1620 err = brcmf_dev_intvar_set(ndev,
"wsec", pval | gval);
1622 WL_ERR(
"error (%d)\n", err);
1626 sec = &profile->
sec;
1642 if (sme->
crypto.n_akm_suites) {
1643 err = brcmf_dev_intvar_get(ndev,
"wpa_auth", &val);
1645 WL_ERR(
"could not get wpa_auth (%d)\n", err);
1649 switch (sme->
crypto.akm_suites[0]) {
1657 WL_ERR(
"invalid cipher group (%d)\n",
1658 sme->
crypto.cipher_group);
1662 switch (sme->
crypto.akm_suites[0]) {
1670 WL_ERR(
"invalid cipher group (%d)\n",
1671 sme->
crypto.cipher_group);
1676 WL_CONN(
"setting wpa_auth to %d\n", val);
1677 err = brcmf_dev_intvar_set(ndev,
"wpa_auth", val);
1679 WL_ERR(
"could not set wpa_auth (%d)\n", err);
1683 sec = &profile->
sec;
1706 sec = &profile->
sec;
1707 WL_CONN(
"wpa_versions 0x%x cipher_pairwise 0x%x\n",
1717 memset(&key, 0,
sizeof(key));
1720 if (key.
len >
sizeof(key.
data)) {
1721 WL_ERR(
"Too long key length (%u)\n", key.
len);
1734 WL_ERR(
"Invalid algorithm (%d)\n",
1735 sme->
crypto.ciphers_pairwise[0]);
1739 WL_CONN(
"key length (%d) key index (%d) algo (%d)\n",
1742 bssidx = brcmf_find_bssidx(cfg, ndev);
1743 err = send_key_to_dongle(cfg, bssidx, ndev, &key);
1748 WL_CONN(
"set auth_type to shared key\n");
1750 err = brcmf_dev_intvar_set_bsscfg(ndev,
"auth", val, bssidx);
1752 WL_ERR(
"set auth failed (%d)\n", err);
1758 brcmf_cfg80211_connect(
struct wiphy *wiphy,
struct net_device *ndev,
1765 size_t join_params_size;
1771 if (!check_sys_up(wiphy))
1775 WL_ERR(
"Invalid ssid\n");
1784 WL_CONN(
"channel (%d), center_req (%d)\n",
1791 err = brcmf_set_wpa_version(ndev, sme);
1793 WL_ERR(
"wl_set_wpa_version failed (%d)\n", err);
1797 err = brcmf_set_auth_type(ndev, sme);
1799 WL_ERR(
"wl_set_auth_type failed (%d)\n", err);
1803 err = brcmf_set_set_cipher(ndev, sme);
1805 WL_ERR(
"wl_set_set_cipher failed (%d)\n", err);
1809 err = brcmf_set_key_mgmt(ndev, sme);
1811 WL_ERR(
"wl_set_key_mgmt failed (%d)\n", err);
1815 err = brcmf_set_sharedkey(ndev, sme);
1817 WL_ERR(
"brcmf_set_sharedkey failed (%d)\n", err);
1821 memset(&join_params, 0,
sizeof(join_params));
1822 join_params_size =
sizeof(join_params.
ssid_le);
1833 WL_CONN(
"ssid \"%s\", len (%d)\n",
1836 brcmf_ch_to_chanspec(cfg->
channel,
1837 &join_params, &join_params_size);
1839 &join_params, join_params_size);
1841 WL_ERR(
"WLC_SET_SSID failed (%d)\n", err);
1851 brcmf_cfg80211_disconnect(
struct wiphy *wiphy,
struct net_device *ndev,
1859 WL_TRACE(
"Enter. Reason code = %d\n", reason_code);
1860 if (!check_sys_up(wiphy))
1870 WL_ERR(
"error (%d)\n", err);
1879 brcmf_cfg80211_set_tx_power(
struct wiphy *wiphy,
1891 if (!check_sys_up(wiphy))
1900 WL_ERR(
"TX_POWER_FIXED - dbm is negative\n");
1910 WL_ERR(
"WLC_SET_RADIO error (%d)\n", err);
1915 txpwrmw = (
u16) dbm;
1916 err = brcmf_dev_intvar_set(ndev,
"qtxpower",
1917 (
s32) (brcmf_mw_to_qdbm(txpwrmw)));
1919 WL_ERR(
"qtxpower error (%d)\n", err);
1927 static s32 brcmf_cfg80211_get_tx_power(
struct wiphy *wiphy,
s32 *dbm)
1936 if (!check_sys_up(wiphy))
1939 err = brcmf_dev_intvar_get(ndev,
"qtxpower", &txpwrdbm);
1941 WL_ERR(
"error (%d)\n", err);
1946 *dbm = (
s32) brcmf_qdbm_to_mw(result);
1954 brcmf_cfg80211_config_default_key(
struct wiphy *wiphy,
struct net_device *ndev,
1955 u8 key_idx,
bool unicast,
bool multicast)
1964 WL_CONN(
"key index (%d)\n", key_idx);
1965 if (!check_sys_up(wiphy))
1968 bssidx = brcmf_find_bssidx(cfg, ndev);
1969 err = brcmf_dev_intvar_get_bsscfg(ndev,
"wsec", &wsec, bssidx);
1971 WL_ERR(
"WLC_GET_WSEC error (%d)\n", err);
1981 WL_ERR(
"error (%d)\n", err);
1989 brcmf_add_keyext(
struct wiphy *wiphy,
struct net_device *ndev,
1998 memset(&key, 0,
sizeof(key));
2002 if (!is_multicast_ether_addr(mac_addr))
2005 bssidx = brcmf_find_bssidx(cfg, ndev);
2009 err = send_key_to_dongle(cfg, bssidx, ndev, &key);
2011 WL_ERR(
"key delete error (%d)\n", err);
2013 if (key.
len >
sizeof(key.
data)) {
2014 WL_ERR(
"Invalid key length (%d)\n", key.
len);
2023 memcpy(keybuf, &key.
data[24],
sizeof(keybuf));
2025 memcpy(&key.
data[16], keybuf,
sizeof(keybuf));
2032 ivptr = (
u8 *) params->
seq;
2033 key.
rxiv.hi = (ivptr[5] << 24) | (ivptr[4] << 16) |
2034 (ivptr[3] << 8) | ivptr[2];
2035 key.
rxiv.lo = (ivptr[1] << 8) | ivptr[0];
2039 switch (params->
cipher) {
2042 WL_CONN(
"WLAN_CIPHER_SUITE_WEP40\n");
2046 WL_CONN(
"WLAN_CIPHER_SUITE_WEP104\n");
2050 WL_CONN(
"WLAN_CIPHER_SUITE_TKIP\n");
2054 WL_CONN(
"WLAN_CIPHER_SUITE_AES_CMAC\n");
2058 WL_CONN(
"WLAN_CIPHER_SUITE_CCMP\n");
2064 convert_key_from_CPU(&key, &key_le);
2067 err = brcmf_dev_iovar_setbuf_bsscfg(ndev,
"wsec_key", &key_le,
2072 WL_ERR(
"wsec_key error (%d)\n", err);
2078 brcmf_cfg80211_add_key(
struct wiphy *wiphy,
struct net_device *ndev,
2079 u8 key_idx,
bool pairwise,
const u8 *mac_addr,
2091 WL_CONN(
"key index (%d)\n", key_idx);
2092 if (!check_sys_up(wiphy))
2097 return brcmf_add_keyext(wiphy, ndev, key_idx, mac_addr, params);
2099 memset(&key, 0,
sizeof(key));
2104 if (key.
len >
sizeof(key.
data)) {
2105 WL_ERR(
"Too long key length (%u)\n", key.
len);
2112 switch (params->
cipher) {
2116 WL_CONN(
"WLAN_CIPHER_SUITE_WEP40\n");
2121 WL_CONN(
"WLAN_CIPHER_SUITE_WEP104\n");
2126 memcpy(keybuf, &key.
data[24],
sizeof(keybuf));
2128 memcpy(&key.
data[16], keybuf,
sizeof(keybuf));
2132 WL_CONN(
"WLAN_CIPHER_SUITE_TKIP\n");
2137 WL_CONN(
"WLAN_CIPHER_SUITE_AES_CMAC\n");
2142 WL_CONN(
"WLAN_CIPHER_SUITE_CCMP\n");
2150 bssidx = brcmf_find_bssidx(cfg, ndev);
2151 err = send_key_to_dongle(cfg, bssidx, ndev, &key);
2155 err = brcmf_dev_intvar_get_bsscfg(ndev,
"wsec", &wsec, bssidx);
2157 WL_ERR(
"get wsec error (%d)\n", err);
2161 err = brcmf_dev_intvar_set_bsscfg(ndev,
"wsec", wsec, bssidx);
2163 WL_ERR(
"set wsec error (%d)\n", err);
2173 brcmf_cfg80211_del_key(
struct wiphy *wiphy,
struct net_device *ndev,
2174 u8 key_idx,
bool pairwise,
const u8 *mac_addr)
2182 if (!check_sys_up(wiphy))
2185 memset(&key, 0,
sizeof(key));
2191 WL_CONN(
"key index (%d)\n", key_idx);
2194 bssidx = brcmf_find_bssidx(cfg, ndev);
2195 err = send_key_to_dongle(cfg, bssidx, ndev, &key);
2200 WL_ERR(
"invalid key index (%d)\n", key_idx);
2211 brcmf_cfg80211_get_key(
struct wiphy *wiphy,
struct net_device *ndev,
2212 u8 key_idx,
bool pairwise,
const u8 *mac_addr,
void *
cookie,
2224 WL_CONN(
"key index (%d)\n", key_idx);
2225 if (!check_sys_up(wiphy))
2228 memset(¶ms, 0,
sizeof(params));
2230 bssidx = brcmf_find_bssidx(cfg, ndev);
2231 err = brcmf_dev_intvar_get_bsscfg(ndev,
"wsec", &wsec, bssidx);
2233 WL_ERR(
"WLC_GET_WSEC error (%d)\n", err);
2240 sec = &profile->
sec;
2243 WL_CONN(
"WLAN_CIPHER_SUITE_WEP40\n");
2246 WL_CONN(
"WLAN_CIPHER_SUITE_WEP104\n");
2251 WL_CONN(
"WLAN_CIPHER_SUITE_TKIP\n");
2255 WL_CONN(
"WLAN_CIPHER_SUITE_AES_CMAC\n");
2258 WL_ERR(
"Invalid algo (0x%x)\n", wsec);
2270 brcmf_cfg80211_config_default_mgmt_key(
struct wiphy *wiphy,
2279 brcmf_cfg80211_get_station(
struct wiphy *wiphy,
struct net_device *ndev,
2292 if (!check_sys_up(wiphy))
2296 err = brcmf_dev_iovar_getbuf(ndev,
"sta_info", mac,
ETH_ALEN,
2300 WL_ERR(
"GET STA INFO failed, %d\n", err);
2311 WL_TRACE(
"STA idle time : %d ms, connected time :%d sec\n",
2315 WL_ERR(
"Wrong Mac address cfg_mac-%pM wl_bssid-%pM\n",
2323 WL_ERR(
"Could not get rate (%d)\n", err);
2327 sinfo->
txrate.legacy = rate * 5;
2328 WL_CONN(
"Rate %d Mbps\n", rate / 2);
2332 memset(&scb_val, 0,
sizeof(scb_val));
2336 WL_ERR(
"Could not get rssi (%d)\n", err);
2342 WL_CONN(
"RSSI %d dBm\n", rssi);
2353 brcmf_cfg80211_set_power_mgmt(
struct wiphy *wiphy,
struct net_device *ndev,
2372 WL_INFO(
"Device is not ready, storing the value in cfg_info struct\n");
2377 WL_INFO(
"power save %s\n", (pm ?
"enabled" :
"disabled"));
2382 WL_ERR(
"net_device is not ready yet\n");
2384 WL_ERR(
"error (%d)\n", err);
2392 brcmf_cfg80211_set_bitrate_mask(
struct wiphy *wiphy,
struct net_device *ndev,
2405 if (!check_sys_up(wiphy))
2411 sizeof(rateset_le));
2413 WL_ERR(
"could not get current rateset (%d)\n", err);
2422 val =
wl_g_rates[legacy - 1].bitrate * 100000;
2426 rate = rateset_le.rates[
val] & 0x7f;
2429 rate = val / 500000;
2431 WL_CONN(
"rate %d mbps\n", rate / 2);
2438 err_bg = brcmf_dev_intvar_set(ndev,
"bg_rate", rate);
2439 err_a = brcmf_dev_intvar_set(ndev,
"a_rate", rate);
2440 if (err_bg && err_a) {
2441 WL_ERR(
"could not set fixed rate (%d) (%d)\n", err_bg, err_a);
2442 err = err_bg | err_a;
2453 struct wiphy *wiphy = cfg_to_wiphy(cfg);
2460 u16 notify_capability;
2461 u16 notify_interval;
2463 size_t notify_ielen;
2467 WL_ERR(
"Bss info is larger than buffer. Discarding\n");
2480 notify_channel = ieee80211_get_channel(wiphy, freq);
2488 WL_CONN(
"bssid: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
2491 WL_CONN(
"Channel: %d(%d)\n", channel, freq);
2492 WL_CONN(
"Capability: %X\n", notify_capability);
2493 WL_CONN(
"Beacon interval: %d\n", notify_interval);
2494 WL_CONN(
"Signal: %d\n", notify_signal);
2497 0, notify_capability, notify_interval, notify_ie,
2526 WL_ERR(
"Version %d != WL_BSS_INFO_VERSION\n",
2532 bi = next_bss_le(bss_list, bi);
2533 err = brcmf_inform_single_bss(cfg, bi);
2543 struct wiphy *wiphy = cfg_to_wiphy(cfg);
2552 u16 notify_capability;
2553 u16 notify_interval;
2555 size_t notify_ielen;
2570 WL_ERR(
"WLC_GET_BSS_INFO failed: %d\n", err);
2585 notify_channel = ieee80211_get_channel(wiphy, freq);
2593 WL_CONN(
"channel: %d(%d)\n", channel, freq);
2594 WL_CONN(
"capability: %X\n", notify_capability);
2595 WL_CONN(
"beacon interval: %d\n", notify_interval);
2596 WL_CONN(
"signal: %d\n", notify_signal);
2599 0, notify_capability, notify_interval,
2600 notify_ie, notify_ielen, notify_signal,
GFP_KERNEL);
2628 static struct brcmf_tlv *brcmf_parse_tlvs(
void *buf,
int buflen,
uint key)
2655 brcmf_tlv_has_ie(
u8 *ie,
u8 **tlvs,
u32 *tlvs_len,
2661 type == ie[TLV_BODY_OFF + oui_len]) {
2670 *tlvs_len -= (
int)(ie - *tlvs);
2682 while ((ie = brcmf_parse_tlvs(parse, len,
WLAN_EID_WPA))) {
2683 if (brcmf_tlv_has_ie((
u8 *)ie, &parse, &len,
2703 if (brcmf_is_ibssmode(cfg))
2706 ssid = &profile->
ssid;
2712 WL_ERR(
"Could not get bss info %d\n", err);
2713 goto update_bss_info_out;
2717 err = brcmf_inform_single_bss(cfg, bi);
2719 goto update_bss_info_out;
2727 dtim_period = tim->
data[1];
2735 err = brcmf_dev_intvar_get(cfg_to_ndev(cfg),
2736 "dtim_assoc", &var);
2738 WL_ERR(
"wl dtim_assoc failed (%d)\n", err);
2739 goto update_bss_info_out;
2741 dtim_period = (
u8)var;
2747 update_bss_info_out:
2770 memset(&ssid, 0,
sizeof(ssid));
2775 WL_INFO(
"Terminating scan in progress\n");
2782 brcmf_notify_escan_complete(cfg, escan->
ndev,
true,
true);
2795 WL_ERR(
"Scan complete while device not scanning\n");
2799 WL_SCAN(
"ISCAN Completed scan: %s\n",
2800 aborted ?
"Aborted" :
"Done");
2802 brcmf_set_mpc(ndev, 1);
2837 memset(&list, 0,
sizeof(list));
2839 err = brcmf_dev_iovar_getbuf(iscan->
ndev,
"iscanresults", &list,
2843 WL_ERR(
"error (%d)\n", err);
2852 WL_SCAN(
"status = %d\n", *status);
2864 brcmf_inform_bss(cfg);
2865 brcmf_notify_iscan_complete(iscan,
false);
2887 brcmf_inform_bss(cfg);
2902 brcmf_notify_iscan_complete(iscan,
true);
2921 if (brcmf_get_iscan_results(iscan, &status, &cfg->
bss_list)) {
2929 static void brcmf_iscan_timer(
unsigned long data)
2937 brcmf_wakeup_iscan(iscan);
2955 memset(el, 0,
sizeof(*el));
2969 iscan->
ndev = cfg_to_ndev(cfg);
2970 brcmf_init_iscan_eloop(&iscan->
el);
2973 iscan->
timer.data = (
unsigned long) iscan;
2974 iscan->
timer.function = brcmf_iscan_timer;
2975 err = brcmf_invoke_iscan(cfg);
2983 static void brcmf_cfg80211_escan_timeout_worker(
struct work_struct *work)
2989 brcmf_notify_escan_complete(cfg,
2993 static void brcmf_escan_timeout(
unsigned long data)
2999 WL_ERR(
"timer expired\n");
3022 if (bss_info_rssi > bss_rssi)
3056 WL_ERR(
"scan not ready ndev %p wl->escan_on %d drv_status %x\n",
3063 WL_SCAN(
"ESCAN Partial result\n");
3065 if (!escan_result_le) {
3066 WL_ERR(
"Invalid escan result (NULL pointer)\n");
3070 WL_SCAN(
"result without cfg80211 request\n");
3075 WL_ERR(
"Invalid bss_count %d: ignoring\n",
3084 WL_ERR(
"Invalid bss_info length %d: ignoring\n",
3089 if (!(cfg_to_wiphy(cfg)->interface_modes &
3093 WL_ERR(
"Ignoring IBSS result\n");
3101 WL_ERR(
"Buffer is too small: ignoring\n");
3105 for (i = 0; i < list->
count; i++) {
3107 ((
unsigned char *)bss +
3109 if (brcmf_compare_update_same_bss(bss, bss_info_le))
3113 bss_info_le, bi_length);
3115 list->buflen += bi_length;
3122 brcmf_inform_bss(cfg);
3124 brcmf_notify_escan_complete(cfg, ndev, aborted,
3127 WL_ERR(
"Unexpected scan result 0x%x\n", status);
3138 brcmf_cfg80211_escan_handler;
3145 brcmf_cfg80211_escan_timeout_worker);
3151 if (ms < 1000 /
HZ) {
3159 static s32 brcmf_cfg80211_resume(
struct wiphy *wiphy)
3171 brcmf_invoke_iscan(wiphy_to_cfg(wiphy));
3177 static s32 brcmf_cfg80211_suspend(
struct wiphy *wiphy,
3198 WL_INFO(
"Disassociating from AP"
3199 " while entering suspend state\n");
3200 brcmf_link_down(cfg);
3211 brcmf_abort_scanning(cfg);
3217 brcmf_set_mpc(ndev, 1);
3252 WL_ERR(
"error (%d)\n", err);
3261 brcmf_update_pmklist(
struct net_device *ndev,
3269 WL_CONN(
"No of elements %d\n", pmkid_len);
3270 for (i = 0; i < pmkid_len; i++) {
3271 WL_CONN(
"PMKID[%d]: %pM =\n", i,
3272 &pmk_list->
pmkids.pmkid[i].BSSID);
3278 brcmf_dev_bufvar_set(ndev,
"pmkid_info", (
char *)pmk_list,
3285 brcmf_cfg80211_set_pmksa(
struct wiphy *wiphy,
struct net_device *ndev,
3295 if (!check_sys_up(wiphy))
3299 for (i = 0; i < pmkid_len; i++)
3305 if (i == pmkid_len) {
3312 WL_CONN(
"set_pmksa,IW_PMKSA_ADD - PMKID: %pM =\n",
3313 pmkids->
pmkid[pmkid_len].BSSID);
3317 err = brcmf_update_pmklist(ndev, cfg->
pmk_list, err);
3324 brcmf_cfg80211_del_pmksa(
struct wiphy *wiphy,
struct net_device *ndev,
3333 if (!check_sys_up(wiphy))
3339 WL_CONN(
"del_pmksa,IW_PMKSA_REMOVE - PMKID: %pM =\n",
3345 for (i = 0; i < pmkid_len; i++)
3352 && (i < pmkid_len)) {
3354 sizeof(
struct pmkid));
3355 for (; i < (pmkid_len - 1); i++) {
3357 &cfg->
pmk_list->pmkids.pmkid[i + 1].BSSID,
3360 &cfg->
pmk_list->pmkids.pmkid[i + 1].PMKID,
3367 err = brcmf_update_pmklist(ndev, cfg->
pmk_list, err);
3375 brcmf_cfg80211_flush_pmksa(
struct wiphy *wiphy,
struct net_device *ndev)
3381 if (!check_sys_up(wiphy))
3385 err = brcmf_update_pmklist(ndev, cfg->
pmk_list, err);
3409 struct wiphy *wiphy = cfg_to_wiphy(cfg);
3411 int channel_req = 0;
3420 WL_SCAN(
"PFN NET LOST event. Do Nothing\n");
3433 WL_SCAN(
"PFN NET FOUND event. count: %d\n", result_count);
3434 if (result_count > 0) {
3437 request = kzalloc(
sizeof(*request),
GFP_KERNEL);
3438 ssid = kcalloc(result_count,
sizeof(*ssid),
GFP_KERNEL);
3439 channel = kcalloc(result_count,
sizeof(*channel),
GFP_KERNEL);
3440 if (!request || !ssid || !channel) {
3445 request->
wiphy = wiphy;
3449 for (i = 0; i < result_count; i++) {
3450 netinfo = &netinfo_start[
i];
3452 WL_ERR(
"Invalid netinfo ptr. index: %d\n", i);
3457 WL_SCAN(
"SSID:%s Channel:%d\n",
3463 channel_req = netinfo->
channel;
3471 channel[
i].
band = band;
3479 request->
ssids = &ssid[0];
3483 brcmf_abort_scanning(cfg);
3487 err = brcmf_do_escan(cfg, wiphy, ndev, request);
3495 WL_ERR(
"FALSE PNO Event. (pfn_count == 0)\n");
3512 #ifndef CONFIG_BRCMISCAN
3513 static int brcmf_dev_pno_clean(
struct net_device *ndev)
3519 ret = brcmf_dev_intvar_set(ndev,
"pfn", 0);
3522 ret = brcmf_dev_iovar_setbuf(ndev,
"pfnclear",
NULL, 0,
3523 iovbuf,
sizeof(iovbuf));
3526 WL_ERR(
"failed code %d\n", ret);
3531 static int brcmf_dev_pno_config(
struct net_device *ndev)
3536 memset(&pfn_param, 0,
sizeof(pfn_param));
3547 return brcmf_dev_iovar_setbuf(ndev,
"pfn_set",
3548 &pfn_param,
sizeof(pfn_param),
3549 iovbuf,
sizeof(iovbuf));
3553 brcmf_cfg80211_sched_scan_start(
struct wiphy *wiphy,
3563 WL_SCAN(
"Enter n_match_sets:%d n_ssids:%d\n",
3566 WL_ERR(
"Scanning already : status (%lu)\n", cfg->
status);
3571 WL_ERR(
"Invalid sched scan req!! n_ssids:%d\n",
3572 request ? request->
n_ssids : 0);
3577 for (i = 0; i < request->
n_ssids; i++) {
3579 WL_SCAN(
">>> Active scan req for ssid (%s)\n",
3580 request->
ssids[i].ssid);
3591 ret = brcmf_dev_pno_clean(ndev);
3593 WL_ERR(
"failed error=%d\n", ret);
3598 ret = brcmf_dev_pno_config(ndev);
3600 WL_ERR(
"PNO setup failed!! ret=%d\n", ret);
3613 WL_ERR(
"skip broadcast ssid\n");
3623 ret = brcmf_dev_iovar_setbuf(ndev,
"pfn_add",
3625 iovbuf,
sizeof(iovbuf));
3626 WL_SCAN(
">>> PNO filter %s for ssid (%s)\n",
3627 ret == 0 ?
"set" :
"failed",
3631 if (brcmf_dev_intvar_set(ndev,
"pfn", 1) < 0) {
3632 WL_ERR(
"PNO enable failed!! ret=%d\n", ret);
3642 static int brcmf_cfg80211_sched_scan_stop(
struct wiphy *wiphy,
3648 brcmf_dev_pno_clean(ndev);
3650 brcmf_notify_escan_complete(cfg, ndev,
true,
true);
3655 #ifdef CONFIG_NL80211_TESTMODE
3656 static int brcmf_cfg80211_testmode(
struct wiphy *wiphy,
void *data,
int len)
3666 reply = cfg80211_testmode_alloc_reply_skb(wiphy,
sizeof(*dcmd));
3668 ret = cfg80211_testmode_reply(reply);
3674 static s32 brcmf_configure_opensecurity(
struct net_device *ndev,
s32 bssidx)
3679 err = brcmf_dev_intvar_set_bsscfg(ndev,
"auth", 0, bssidx);
3681 WL_ERR(
"auth error %d\n", err);
3685 err = brcmf_dev_intvar_set_bsscfg(ndev,
"wsec", 0, bssidx);
3687 WL_ERR(
"wsec error %d\n", err);
3691 err = brcmf_dev_intvar_set_bsscfg(ndev,
"wpa_auth",
3694 WL_ERR(
"wpa_auth error %d\n", err);
3701 static bool brcmf_valid_wpa_oui(
u8 *oui,
bool is_rsn_ie)
3711 bool is_rsn_ie,
s32 bssidx)
3725 u32 wme_bss_disable;
3732 data = (
u8 *)wpa_ie;
3741 WL_ERR(
"no multicast cipher suite\n");
3745 if (!brcmf_valid_wpa_oui(&data[offset], is_rsn_ie)) {
3753 switch (data[offset]) {
3769 WL_ERR(
"Invalid multi cast cipher info\n");
3775 count = data[
offset] + (data[offset + 1] << 8);
3780 WL_ERR(
"no unicast cipher suite\n");
3783 for (i = 0; i <
count; i++) {
3784 if (!brcmf_valid_wpa_oui(&data[offset], is_rsn_ie)) {
3790 switch (data[offset]) {
3804 WL_ERR(
"Ivalid unicast security info\n");
3809 count = data[
offset] + (data[offset + 1] << 8);
3814 WL_ERR(
"no auth key mgmt suite\n");
3817 for (i = 0; i <
count; i++) {
3818 if (!brcmf_valid_wpa_oui(&data[offset], is_rsn_ie)) {
3824 switch (data[offset]) {
3840 WL_ERR(
"Ivalid key mgmt info\n");
3846 wme_bss_disable = 1;
3848 rsn_cap = data[
offset] + (data[offset + 1] << 8);
3850 wme_bss_disable = 0;
3853 err = brcmf_dev_intvar_set_bsscfg(ndev,
"wme_bss_disable",
3854 wme_bss_disable, bssidx);
3856 WL_ERR(
"wme_bss_disable error %d\n", err);
3864 err = brcmf_dev_intvar_set_bsscfg(ndev,
"auth", auth, bssidx);
3866 WL_ERR(
"auth error %d\n", err);
3870 err = brcmf_dev_intvar_set_bsscfg(ndev,
"wsec", wsec, bssidx);
3872 WL_ERR(
"wsec error %d\n", err);
3876 err = brcmf_dev_intvar_set_bsscfg(ndev,
"wpa_auth", wpa_auth, bssidx);
3878 WL_ERR(
"wpa_auth error %d\n", err);
3887 brcmf_parse_vndr_ies(
u8 *vndr_ie_buf,
u32 vndr_ie_len,
3896 remaining_len = (
s32)vndr_ie_len;
3897 memset(vndr_ies, 0,
sizeof(*vndr_ies));
3906 WL_ERR(
"invalid vndr ie. length is too small %d\n",
3914 WL_TRACE(
"Found WPA/WME oui. Do not add it\n");
3921 parsed_info->
ie_ptr = (
char *)vndrie;
3927 WL_TRACE(
"** OUI %02x %02x %02x, type 0x%02x\n",
3928 parsed_info->
vndrie.oui[0],
3929 parsed_info->
vndrie.oui[1],
3930 parsed_info->
vndrie.oui[2],
3931 parsed_info->
vndrie.oui_type);
3936 remaining_len -= ie->
len;
3937 if (remaining_len <= 2)
3946 brcmf_vndr_ie(
u8 *iebuf,
s32 pktflag,
u8 *ie_ptr,
u32 ie_len,
s8 *add_del_cmd)
3969 u8 *vndr_ie_buf,
u32 vndr_ie_len)
3975 int mgmt_ie_buf_len;
3976 u32 *mgmt_ie_len = 0;
3977 u32 del_add_ie_buf_len = 0;
3978 u32 total_ie_buf_len = 0;
3979 u32 parsed_ie_buf_len = 0;
3985 int remained_buf_len;
3987 WL_TRACE(
"bssidx %d, pktflag : 0x%02X\n", bssidx, pktflag);
3991 curr_ie_buf = iovar_ie_buf;
3996 mgmt_ie_buf = cfg->
ap_info->probe_res_ie;
3997 mgmt_ie_len = &cfg->
ap_info->probe_res_ie_len;
3999 sizeof(cfg->
ap_info->probe_res_ie);
4002 mgmt_ie_buf = cfg->
ap_info->beacon_ie;
4003 mgmt_ie_len = &cfg->
ap_info->beacon_ie_len;
4004 mgmt_ie_buf_len =
sizeof(cfg->
ap_info->beacon_ie);
4008 WL_ERR(
"not suitable type\n");
4014 WL_ERR(
"not suitable type\n");
4018 if (vndr_ie_len > mgmt_ie_buf_len) {
4020 WL_ERR(
"extra IE size too big\n");
4025 if (vndr_ie_buf && vndr_ie_len && curr_ie_buf) {
4027 brcmf_parse_vndr_ies(vndr_ie_buf, vndr_ie_len, &new_vndr_ies);
4028 for (i = 0; i < new_vndr_ies.
count; i++) {
4029 vndrie_info = &new_vndr_ies.
ie_info[
i];
4032 parsed_ie_buf_len += vndrie_info->
ie_len;
4036 if (mgmt_ie_buf !=
NULL) {
4037 if (parsed_ie_buf_len && (parsed_ie_buf_len == *mgmt_ie_len) &&
4038 (
memcmp(mgmt_ie_buf, curr_ie_buf,
4039 parsed_ie_buf_len) == 0)) {
4040 WL_TRACE(
"Previous mgmt IE is equals to current IE");
4045 brcmf_parse_vndr_ies(mgmt_ie_buf, *mgmt_ie_len, &old_vndr_ies);
4048 for (i = 0; i < old_vndr_ies.
count; i++) {
4049 vndrie_info = &old_vndr_ies.
ie_info[
i];
4051 WL_TRACE(
"DEL ID : %d, Len: %d , OUI:%02x:%02x:%02x\n",
4054 vndrie_info->
vndrie.oui[0],
4055 vndrie_info->
vndrie.oui[1],
4056 vndrie_info->
vndrie.oui[2]);
4058 del_add_ie_buf_len = brcmf_vndr_ie(curr_ie_buf, pktflag,
4062 curr_ie_buf += del_add_ie_buf_len;
4063 total_ie_buf_len += del_add_ie_buf_len;
4069 if (mgmt_ie_buf && parsed_ie_buf_len) {
4072 remained_buf_len = mgmt_ie_buf_len;
4075 for (i = 0; i < new_vndr_ies.
count; i++) {
4076 vndrie_info = &new_vndr_ies.
ie_info[
i];
4078 WL_TRACE(
"ADDED ID : %d, Len: %d, OUI:%02x:%02x:%02x\n",
4081 vndrie_info->
vndrie.oui[0],
4082 vndrie_info->
vndrie.oui[1],
4083 vndrie_info->
vndrie.oui[2]);
4085 del_add_ie_buf_len = brcmf_vndr_ie(curr_ie_buf, pktflag,
4090 remained_buf_len -= vndrie_info->
ie_len;
4091 if (remained_buf_len < 0) {
4092 WL_ERR(
"no space in mgmt_ie_buf: len left %d",
4100 *mgmt_ie_len += vndrie_info->
ie_len;
4102 curr_ie_buf += del_add_ie_buf_len;
4103 total_ie_buf_len += del_add_ie_buf_len;
4106 if (total_ie_buf_len) {
4107 err = brcmf_dev_iovar_setbuf_bsscfg(ndev,
"vndr_ie",
4113 WL_ERR(
"vndr ie set error : %d\n", err);
4117 kfree(iovar_ie_buf);
4122 brcmf_cfg80211_start_ap(
struct wiphy *wiphy,
struct net_device *ndev,
4136 WL_TRACE(
"channel_type=%d, beacon_interval=%d, dtim_period=%d,\n",
4139 WL_TRACE(
"ssid=%s(%d), auth_type=%d, inactivity_timeout=%d\n",
4144 WL_ERR(
"Not in AP creation mode\n");
4148 memset(&ssid_le, 0,
sizeof(ssid_le));
4151 ssid_ie = brcmf_parse_tlvs(
4152 (
u8 *)&settings->
beacon.head[ie_offset],
4153 settings->
beacon.head_len - ie_offset,
4160 WL_TRACE(
"SSID is (%s) in Head\n", ssid_le.SSID);
4166 brcmf_set_mpc(ndev, 0);
4168 err = brcmf_exec_dcmd_u32(ndev,
BRCMF_C_DOWN, &ioctl_value);
4170 WL_ERR(
"BRCMF_C_DOWN error %d\n", err);
4176 WL_ERR(
"SET INFRA error %d\n", err);
4182 WL_ERR(
"setting AP mode failed %d\n", err);
4187 rsn_ie = brcmf_parse_tlvs((
u8 *)settings->
beacon.tail,
4192 settings->
beacon.tail_len);
4199 if ((wpa_ie !=
NULL || rsn_ie !=
NULL)) {
4201 if (wpa_ie !=
NULL) {
4203 err = brcmf_configure_wpaie(ndev, wpa_ie,
false,
4213 err = brcmf_configure_wpaie(ndev,
4222 cfg->
ap_info->security_mode =
true;
4225 brcmf_configure_opensecurity(ndev, bssidx);
4226 cfg->
ap_info->security_mode =
false;
4232 settings->
beacon.tail_len);
4234 WL_ERR(
"Set Beacon IE Failed\n");
4236 WL_TRACE(
"Applied Vndr IEs for Beacon\n");
4241 (
u8 *)settings->
beacon.proberesp_ies,
4242 settings->
beacon.proberesp_ies_len);
4244 WL_ERR(
"Set Probe Resp IE Failed\n");
4246 WL_TRACE(
"Applied Vndr IEs for Probe Resp\n");
4253 WL_ERR(
"Beacon Interval Set Error, %d\n", err);
4262 WL_ERR(
"DTIM Interval Set Error, %d\n", err);
4267 err = brcmf_exec_dcmd_u32(ndev,
BRCMF_C_UP, &ioctl_value);
4269 WL_ERR(
"BRCMF_C_UP error (%d)\n", err);
4273 memset(&join_params, 0,
sizeof(join_params));
4278 sizeof(join_params));
4280 WL_ERR(
"SET SSID error (%d)\n", err);
4288 brcmf_set_mpc(ndev, 1);
4292 static int brcmf_cfg80211_stop_ap(
struct wiphy *wiphy,
struct net_device *ndev)
4307 WL_ERR(
"setting AP mode failed %d\n", err);
4311 err = brcmf_exec_dcmd_u32(ndev,
BRCMF_C_UP, &ioctl_value);
4313 WL_ERR(
"BRCMF_C_UP error %d\n", err);
4316 brcmf_set_mpc(ndev, 1);
4325 brcmf_cfg80211_del_station(
struct wiphy *wiphy,
struct net_device *ndev,
4336 if (!check_sys_up(wiphy))
4342 &scbval,
sizeof(scbval));
4344 WL_ERR(
"SCB_DEAUTHENTICATE_FOR_REASON failed %d\n", err);
4351 .change_virtual_intf = brcmf_cfg80211_change_iface,
4352 .scan = brcmf_cfg80211_scan,
4353 .set_wiphy_params = brcmf_cfg80211_set_wiphy_params,
4354 .join_ibss = brcmf_cfg80211_join_ibss,
4355 .leave_ibss = brcmf_cfg80211_leave_ibss,
4356 .get_station = brcmf_cfg80211_get_station,
4357 .set_tx_power = brcmf_cfg80211_set_tx_power,
4358 .get_tx_power = brcmf_cfg80211_get_tx_power,
4359 .add_key = brcmf_cfg80211_add_key,
4360 .del_key = brcmf_cfg80211_del_key,
4361 .get_key = brcmf_cfg80211_get_key,
4362 .set_default_key = brcmf_cfg80211_config_default_key,
4363 .set_default_mgmt_key = brcmf_cfg80211_config_default_mgmt_key,
4364 .set_power_mgmt = brcmf_cfg80211_set_power_mgmt,
4365 .set_bitrate_mask = brcmf_cfg80211_set_bitrate_mask,
4366 .connect = brcmf_cfg80211_connect,
4367 .disconnect = brcmf_cfg80211_disconnect,
4368 .suspend = brcmf_cfg80211_suspend,
4369 .resume = brcmf_cfg80211_resume,
4370 .set_pmksa = brcmf_cfg80211_set_pmksa,
4371 .del_pmksa = brcmf_cfg80211_del_pmksa,
4372 .flush_pmksa = brcmf_cfg80211_flush_pmksa,
4373 .start_ap = brcmf_cfg80211_start_ap,
4374 .stop_ap = brcmf_cfg80211_stop_ap,
4375 .del_station = brcmf_cfg80211_del_station,
4376 #ifndef CONFIG_BRCMISCAN
4378 .sched_scan_start = brcmf_cfg80211_sched_scan_start,
4379 .sched_scan_stop = brcmf_cfg80211_sched_scan_stop,
4381 #ifdef CONFIG_NL80211_TESTMODE
4382 .testmode_cmd = brcmf_cfg80211_testmode
4386 static s32 brcmf_mode_to_nl80211_iftype(
s32 mode)
4402 static void brcmf_wiphy_pno_params(
struct wiphy *wiphy)
4404 #ifndef CONFIG_BRCMISCAN
4425 WL_ERR(
"Could not allocate wiphy device\n");
4429 set_wiphy_dev(wdev->
wiphy, ndev);
4444 wdev->
wiphy->cipher_suites = __wl_cipher_suites;
4450 brcmf_wiphy_pno_params(wdev->
wiphy);
4453 WL_ERR(
"Could not register wiphy device (%d)\n", err);
4454 goto wiphy_register_out;
4464 return ERR_PTR(err);
4472 WL_ERR(
"wdev is invalid\n");
4488 WL_CONN(
"Processing set ssid\n");
4503 WL_CONN(
"Processing link down\n");
4516 WL_CONN(
"Processing Link %s & no network found\n",
4523 WL_CONN(
"Processing connecting & no network found\n");
4551 brcmf_clear_assoc_ies(cfg);
4553 err = brcmf_dev_bufvar_get(ndev,
"assoc_info", cfg->
extra_buf,
4556 WL_ERR(
"could not get assoc info (%d)\n", err);
4564 err = brcmf_dev_bufvar_get(ndev,
"assoc_req_ies",
4568 WL_ERR(
"could not get assoc req (%d)\n", err);
4580 err = brcmf_dev_bufvar_get(ndev,
"assoc_resp_ies",
4584 WL_ERR(
"could not get assoc resp (%d)\n", err);
4595 WL_CONN(
"req len (%d) resp len (%d)\n",
4608 struct wiphy *wiphy = cfg_to_wiphy(cfg);
4619 brcmf_get_assoc_ies(cfg);
4621 brcmf_update_bss_info(cfg);
4646 notify_channel = ieee80211_get_channel(wiphy, freq);
4653 WL_CONN(
"Report roaming result\n");
4673 brcmf_get_assoc_ies(cfg);
4675 brcmf_update_bss_info(cfg);
4688 WL_CONN(
"Report connect result - connection %s\n",
4689 completed ?
"succeeded" :
"failed");
4709 memset(&sinfo, 0,
sizeof(sinfo));
4716 WL_ERR(
"No IEs present in ASSOC/REASSOC_IND");
4743 err = brcmf_notify_connect_status_ap(cfg, ndev, e, data);
4744 }
else if (brcmf_is_linkup(cfg, e)) {
4746 if (brcmf_is_ibssmode(cfg)) {
4748 wl_inform_ibss(cfg, ndev, e->
addr);
4753 brcmf_bss_connect_done(cfg, ndev, e,
true);
4754 }
else if (brcmf_is_linkdown(cfg, e)) {
4756 if (brcmf_is_ibssmode(cfg)) {
4760 brcmf_link_down(cfg);
4762 brcmf_bss_connect_done(cfg, ndev, e,
false);
4767 brcmf_link_down(cfg);
4770 brcmf_init_prof(cfg->
profile);
4771 }
else if (brcmf_is_nonetwork(cfg, e)) {
4772 if (brcmf_is_ibssmode(cfg))
4775 brcmf_bss_connect_done(cfg, ndev, e,
false);
4792 brcmf_bss_roaming_done(cfg, ndev, e);
4794 brcmf_bss_connect_done(cfg, ndev, e,
true);
4828 bool scan_abort =
false;
4839 WL_ERR(
"Scan complete while device not scanning\n");
4846 sizeof(channel_inform_le));
4848 WL_ERR(
"scan busy (%d)\n", err);
4852 scan_channel =
le32_to_cpu(channel_inform_le.scan_channel);
4854 WL_CONN(
"channel_inform.scan_channel (%d)\n", scan_channel);
4863 WL_ERR(
"%s Scan_results error (%d)\n", ndev->
name, err);
4872 err = brcmf_inform_bss(cfg);
4878 WL_SCAN(
"calling cfg80211_scan_done\n");
4880 brcmf_set_mpc(ndev, 1);
4901 memset(el, 0,
sizeof(*el));
4949 goto init_priv_mem_out;
4952 goto init_priv_mem_out;
4955 goto init_priv_mem_out;
4958 goto init_priv_mem_out;
4962 goto init_priv_mem_out;
4965 goto init_priv_mem_out;
4968 goto init_priv_mem_out;
4971 goto init_priv_mem_out;
4974 goto init_priv_mem_out;
4977 goto init_priv_mem_out;
4982 brcmf_deinit_priv_mem(cfg);
5040 spin_unlock_irqrestore(&cfg->
evt_q_lock, flags);
5050 static void brcmf_cfg80211_event_handler(
struct work_struct *work)
5057 e = brcmf_deq_event(cfg);
5059 WL_ERR(
"event queue empty...\n");
5065 if (cfg->
el.handler[e->
etype])
5072 }
while ((e = brcmf_deq_event(cfg)));
5102 #ifdef CONFIG_BRCMISCAN
5121 err = brcmf_init_priv_mem(cfg);
5125 brcmf_init_eloop_handler(&cfg->
el);
5127 err = brcmf_init_iscan(cfg);
5130 brcmf_init_escan(cfg);
5131 brcmf_init_conf(cfg->
conf);
5132 brcmf_init_prof(cfg->
profile);
5133 brcmf_link_down(cfg);
5142 brcmf_flush_eq(cfg);
5143 brcmf_link_down(cfg);
5144 brcmf_abort_scanning(cfg);
5145 brcmf_deinit_priv_mem(cfg);
5157 WL_ERR(
"ndev is invalid\n");
5161 wdev = brcmf_alloc_wdev(busdev);
5167 cfg = wdev_to_cfg(wdev);
5173 err = wl_init_priv(cfg);
5175 WL_ERR(
"Failed to init iwm_priv (%d)\n", err);
5176 goto cfg80211_attach_out;
5181 cfg80211_attach_out:
5182 brcmf_free_wdev(cfg);
5188 wl_deinit_priv(cfg);
5189 brcmf_free_wdev(cfg);
5199 if (!brcmf_enq_event(cfg, event_type, e, data))
5214 iovbuf,
sizeof(iovbuf));
5217 WL_ERR(
"Get event_msgs error (%d)\n", err);
5218 goto dongle_eventmsg_out;
5245 iovbuf,
sizeof(iovbuf));
5248 WL_ERR(
"Set event_msgs error (%d)\n", err);
5249 goto dongle_eventmsg_out;
5252 dongle_eventmsg_out:
5274 sizeof(bcn_to_le), iovbuf,
sizeof(iovbuf));
5276 iovbuf,
sizeof(iovbuf));
5278 WL_ERR(
"bcn_timeout error (%d)\n", err);
5279 goto dongle_rom_out;
5287 WL_INFO(
"Internal Roaming = %s\n", roamvar ?
"Off" :
"On");
5290 sizeof(roamvar_le), iovbuf,
sizeof(iovbuf));
5293 WL_ERR(
"roam_off error (%d)\n", err);
5294 goto dongle_rom_out;
5300 (
void *)roamtrigger,
sizeof(roamtrigger));
5302 WL_ERR(
"WLC_SET_ROAM_TRIGGER error (%d)\n", err);
5303 goto dongle_rom_out;
5309 (
void *)roam_delta,
sizeof(roam_delta));
5311 WL_ERR(
"WLC_SET_ROAM_DELTA error (%d)\n", err);
5312 goto dongle_rom_out;
5320 brcmf_dongle_scantime(
struct net_device *ndev,
s32 scan_assoc_time,
5321 s32 scan_unassoc_time,
s32 scan_passive_time)
5329 &scan_assoc_tm_le,
sizeof(scan_assoc_tm_le));
5332 WL_INFO(
"Scan assoc time is not supported\n");
5334 WL_ERR(
"Scan assoc time error (%d)\n", err);
5335 goto dongle_scantime_out;
5338 &scan_unassoc_tm_le,
sizeof(scan_unassoc_tm_le));
5341 WL_INFO(
"Scan unassoc time is not supported\n");
5343 WL_ERR(
"Scan unassoc time error (%d)\n", err);
5344 goto dongle_scantime_out;
5348 &scan_passive_tm_le,
sizeof(scan_passive_tm_le));
5351 WL_INFO(
"Scan passive time is not supported\n");
5353 WL_ERR(
"Scan passive time error (%d)\n", err);
5354 goto dongle_scantime_out;
5357 dongle_scantime_out:
5363 struct wiphy *wiphy;
5369 &phy_list,
sizeof(phy_list));
5371 WL_ERR(
"error (%d)\n", err);
5375 phy = ((
char *)&phy_list)[0];
5377 if (phy ==
'n' || phy ==
'a') {
5378 wiphy = cfg_to_wiphy(cfg);
5387 return wl_update_wiphybands(cfg);
5400 ndev = cfg_to_ndev(cfg);
5406 err = brcmf_dongle_eventmsg(ndev);
5408 goto default_conf_out;
5413 goto default_conf_out;
5414 WL_INFO(
"power save set to %s\n",
5415 (power_mode ?
"enabled" :
"disabled"));
5417 err = brcmf_dongle_roam(ndev, (cfg->
roam_on ? 0 : 1),
5420 goto default_conf_out;
5421 err = brcmf_cfg80211_change_iface(wdev->
wiphy, ndev, wdev->
iftype,
5424 goto default_conf_out;
5425 err = brcmf_dongle_probecap(cfg);
5427 goto default_conf_out;
5445 sprintf(buf,
"netdev:%s", cfg_to_ndev(cfg)->name);
5447 cfg_to_wiphy(cfg)->debugfsdir);
5479 brcmf_debugfs_add_netdev_params(cfg);
5481 err = brcmf_config_dongle(cfg);
5485 brcmf_invoke_iscan(cfg);
5499 WL_INFO(
"Disassociating from AP");
5500 brcmf_link_down(cfg);
5509 brcmf_abort_scanning(cfg);
5512 brcmf_debugfs_remove_netdev(cfg);
5522 err = __brcmf_cfg80211_up(cfg);
5533 err = __brcmf_cfg80211_down(cfg);