Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2010 Broadcom Corporation |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 11 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 13 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | /* Toplevel file. Relies on dhd_linux.c to send commands to the dongle. */ |
| 18 | |
| 19 | #include <linux/kernel.h> |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 20 | #include <linux/etherdevice.h> |
Hante Meuleman | 68ca395 | 2014-02-25 20:30:26 +0100 | [diff] [blame] | 21 | #include <linux/module.h> |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 22 | #include <net/cfg80211.h> |
Arend van Spriel | cbaa177 | 2012-08-30 19:43:02 +0200 | [diff] [blame] | 23 | #include <net/netlink.h> |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 24 | |
| 25 | #include <brcmu_utils.h> |
| 26 | #include <defs.h> |
| 27 | #include <brcmu_wifi.h> |
| 28 | #include "dhd.h" |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 29 | #include "dhd_dbg.h" |
Arend van Spriel | 40c1c24 | 2013-04-05 10:57:44 +0200 | [diff] [blame] | 30 | #include "tracepoint.h" |
Hante Meuleman | 7a5c1f6 | 2013-02-08 15:53:44 +0100 | [diff] [blame] | 31 | #include "fwil_types.h" |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 32 | #include "p2p.h" |
Piotr Haber | 61730d4 | 2013-04-23 12:53:12 +0200 | [diff] [blame] | 33 | #include "btcoex.h" |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 34 | #include "wl_cfg80211.h" |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 35 | #include "fwil.h" |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 36 | |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 37 | #define BRCMF_SCAN_IE_LEN_MAX 2048 |
| 38 | #define BRCMF_PNO_VERSION 2 |
| 39 | #define BRCMF_PNO_TIME 30 |
| 40 | #define BRCMF_PNO_REPEAT 4 |
| 41 | #define BRCMF_PNO_FREQ_EXPO_MAX 3 |
| 42 | #define BRCMF_PNO_MAX_PFN_COUNT 16 |
| 43 | #define BRCMF_PNO_ENABLE_ADAPTSCAN_BIT 6 |
| 44 | #define BRCMF_PNO_HIDDEN_BIT 2 |
| 45 | #define BRCMF_PNO_WPA_AUTH_ANY 0xFFFFFFFF |
| 46 | #define BRCMF_PNO_SCAN_COMPLETE 1 |
| 47 | #define BRCMF_PNO_SCAN_INCOMPLETE 0 |
| 48 | |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 49 | #define BRCMF_IFACE_MAX_CNT 3 |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 50 | |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 51 | #define WPA_OUI "\x00\x50\xF2" /* WPA OUI */ |
| 52 | #define WPA_OUI_TYPE 1 |
| 53 | #define RSN_OUI "\x00\x0F\xAC" /* RSN OUI */ |
| 54 | #define WME_OUI_TYPE 2 |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 55 | #define WPS_OUI_TYPE 4 |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 56 | |
| 57 | #define VS_IE_FIXED_HDR_LEN 6 |
| 58 | #define WPA_IE_VERSION_LEN 2 |
| 59 | #define WPA_IE_MIN_OUI_LEN 4 |
| 60 | #define WPA_IE_SUITE_COUNT_LEN 2 |
| 61 | |
| 62 | #define WPA_CIPHER_NONE 0 /* None */ |
| 63 | #define WPA_CIPHER_WEP_40 1 /* WEP (40-bit) */ |
| 64 | #define WPA_CIPHER_TKIP 2 /* TKIP: default for WPA */ |
| 65 | #define WPA_CIPHER_AES_CCM 4 /* AES (CCM) */ |
| 66 | #define WPA_CIPHER_WEP_104 5 /* WEP (104-bit) */ |
| 67 | |
| 68 | #define RSN_AKM_NONE 0 /* None (IBSS) */ |
| 69 | #define RSN_AKM_UNSPECIFIED 1 /* Over 802.1x */ |
| 70 | #define RSN_AKM_PSK 2 /* Pre-shared Key */ |
| 71 | #define RSN_CAP_LEN 2 /* Length of RSN capabilities */ |
| 72 | #define RSN_CAP_PTK_REPLAY_CNTR_MASK 0x000C |
| 73 | |
| 74 | #define VNDR_IE_CMD_LEN 4 /* length of the set command |
| 75 | * string :"add", "del" (+ NUL) |
| 76 | */ |
| 77 | #define VNDR_IE_COUNT_OFFSET 4 |
| 78 | #define VNDR_IE_PKTFLAG_OFFSET 8 |
| 79 | #define VNDR_IE_VSIE_OFFSET 12 |
| 80 | #define VNDR_IE_HDR_SIZE 12 |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 81 | #define VNDR_IE_PARSE_LIMIT 5 |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 82 | |
| 83 | #define DOT11_MGMT_HDR_LEN 24 /* d11 management header len */ |
| 84 | #define DOT11_BCN_PRB_FIXED_LEN 12 /* beacon/probe fixed length */ |
Hante Meuleman | 0401289 | 2012-09-27 14:17:49 +0200 | [diff] [blame] | 85 | |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 86 | #define BRCMF_SCAN_JOIN_ACTIVE_DWELL_TIME_MS 320 |
| 87 | #define BRCMF_SCAN_JOIN_PASSIVE_DWELL_TIME_MS 400 |
| 88 | #define BRCMF_SCAN_JOIN_PROBE_INTERVAL_MS 20 |
| 89 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 90 | #define BRCMF_ASSOC_PARAMS_FIXED_SIZE \ |
| 91 | (sizeof(struct brcmf_assoc_params_le) - sizeof(u16)) |
| 92 | |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 93 | static bool check_vif_up(struct brcmf_cfg80211_vif *vif) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 94 | { |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 95 | if (!test_bit(BRCMF_VIF_STATUS_READY, &vif->sme_state)) { |
Arend van Spriel | 647c9ae | 2012-12-05 15:26:01 +0100 | [diff] [blame] | 96 | brcmf_dbg(INFO, "device is not ready : status (%lu)\n", |
| 97 | vif->sme_state); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 98 | return false; |
| 99 | } |
| 100 | return true; |
| 101 | } |
| 102 | |
| 103 | #define CHAN2G(_channel, _freq, _flags) { \ |
| 104 | .band = IEEE80211_BAND_2GHZ, \ |
| 105 | .center_freq = (_freq), \ |
| 106 | .hw_value = (_channel), \ |
| 107 | .flags = (_flags), \ |
| 108 | .max_antenna_gain = 0, \ |
| 109 | .max_power = 30, \ |
| 110 | } |
| 111 | |
| 112 | #define CHAN5G(_channel, _flags) { \ |
| 113 | .band = IEEE80211_BAND_5GHZ, \ |
| 114 | .center_freq = 5000 + (5 * (_channel)), \ |
| 115 | .hw_value = (_channel), \ |
| 116 | .flags = (_flags), \ |
| 117 | .max_antenna_gain = 0, \ |
| 118 | .max_power = 30, \ |
| 119 | } |
| 120 | |
| 121 | #define RATE_TO_BASE100KBPS(rate) (((rate) * 10) / 2) |
| 122 | #define RATETAB_ENT(_rateid, _flags) \ |
| 123 | { \ |
| 124 | .bitrate = RATE_TO_BASE100KBPS(_rateid), \ |
| 125 | .hw_value = (_rateid), \ |
| 126 | .flags = (_flags), \ |
| 127 | } |
| 128 | |
| 129 | static struct ieee80211_rate __wl_rates[] = { |
| 130 | RATETAB_ENT(BRCM_RATE_1M, 0), |
| 131 | RATETAB_ENT(BRCM_RATE_2M, IEEE80211_RATE_SHORT_PREAMBLE), |
| 132 | RATETAB_ENT(BRCM_RATE_5M5, IEEE80211_RATE_SHORT_PREAMBLE), |
| 133 | RATETAB_ENT(BRCM_RATE_11M, IEEE80211_RATE_SHORT_PREAMBLE), |
| 134 | RATETAB_ENT(BRCM_RATE_6M, 0), |
| 135 | RATETAB_ENT(BRCM_RATE_9M, 0), |
| 136 | RATETAB_ENT(BRCM_RATE_12M, 0), |
| 137 | RATETAB_ENT(BRCM_RATE_18M, 0), |
| 138 | RATETAB_ENT(BRCM_RATE_24M, 0), |
| 139 | RATETAB_ENT(BRCM_RATE_36M, 0), |
| 140 | RATETAB_ENT(BRCM_RATE_48M, 0), |
| 141 | RATETAB_ENT(BRCM_RATE_54M, 0), |
| 142 | }; |
| 143 | |
| 144 | #define wl_a_rates (__wl_rates + 4) |
| 145 | #define wl_a_rates_size 8 |
| 146 | #define wl_g_rates (__wl_rates + 0) |
| 147 | #define wl_g_rates_size 12 |
| 148 | |
| 149 | static struct ieee80211_channel __wl_2ghz_channels[] = { |
| 150 | CHAN2G(1, 2412, 0), |
| 151 | CHAN2G(2, 2417, 0), |
| 152 | CHAN2G(3, 2422, 0), |
| 153 | CHAN2G(4, 2427, 0), |
| 154 | CHAN2G(5, 2432, 0), |
| 155 | CHAN2G(6, 2437, 0), |
| 156 | CHAN2G(7, 2442, 0), |
| 157 | CHAN2G(8, 2447, 0), |
| 158 | CHAN2G(9, 2452, 0), |
| 159 | CHAN2G(10, 2457, 0), |
| 160 | CHAN2G(11, 2462, 0), |
| 161 | CHAN2G(12, 2467, 0), |
| 162 | CHAN2G(13, 2472, 0), |
| 163 | CHAN2G(14, 2484, 0), |
| 164 | }; |
| 165 | |
| 166 | static struct ieee80211_channel __wl_5ghz_a_channels[] = { |
| 167 | CHAN5G(34, 0), CHAN5G(36, 0), |
| 168 | CHAN5G(38, 0), CHAN5G(40, 0), |
| 169 | CHAN5G(42, 0), CHAN5G(44, 0), |
| 170 | CHAN5G(46, 0), CHAN5G(48, 0), |
| 171 | CHAN5G(52, 0), CHAN5G(56, 0), |
| 172 | CHAN5G(60, 0), CHAN5G(64, 0), |
| 173 | CHAN5G(100, 0), CHAN5G(104, 0), |
| 174 | CHAN5G(108, 0), CHAN5G(112, 0), |
| 175 | CHAN5G(116, 0), CHAN5G(120, 0), |
| 176 | CHAN5G(124, 0), CHAN5G(128, 0), |
| 177 | CHAN5G(132, 0), CHAN5G(136, 0), |
| 178 | CHAN5G(140, 0), CHAN5G(149, 0), |
| 179 | CHAN5G(153, 0), CHAN5G(157, 0), |
| 180 | CHAN5G(161, 0), CHAN5G(165, 0), |
| 181 | CHAN5G(184, 0), CHAN5G(188, 0), |
| 182 | CHAN5G(192, 0), CHAN5G(196, 0), |
| 183 | CHAN5G(200, 0), CHAN5G(204, 0), |
| 184 | CHAN5G(208, 0), CHAN5G(212, 0), |
| 185 | CHAN5G(216, 0), |
| 186 | }; |
| 187 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 188 | static struct ieee80211_supported_band __wl_band_2ghz = { |
| 189 | .band = IEEE80211_BAND_2GHZ, |
| 190 | .channels = __wl_2ghz_channels, |
| 191 | .n_channels = ARRAY_SIZE(__wl_2ghz_channels), |
| 192 | .bitrates = wl_g_rates, |
| 193 | .n_bitrates = wl_g_rates_size, |
Daniel Kim | d235367 | 2014-03-20 10:18:00 +0100 | [diff] [blame] | 194 | .ht_cap = {IEEE80211_HT_CAP_SUP_WIDTH_20_40, true}, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 195 | }; |
| 196 | |
| 197 | static struct ieee80211_supported_band __wl_band_5ghz_a = { |
| 198 | .band = IEEE80211_BAND_5GHZ, |
| 199 | .channels = __wl_5ghz_a_channels, |
| 200 | .n_channels = ARRAY_SIZE(__wl_5ghz_a_channels), |
| 201 | .bitrates = wl_a_rates, |
| 202 | .n_bitrates = wl_a_rates_size, |
| 203 | }; |
| 204 | |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 205 | /* This is to override regulatory domains defined in cfg80211 module (reg.c) |
| 206 | * By default world regulatory domain defined in reg.c puts the flags |
Luis R. Rodriguez | 8fe02e1 | 2013-10-21 19:22:25 +0200 | [diff] [blame] | 207 | * NL80211_RRF_NO_IR for 5GHz channels (for * 36..48 and 149..165). |
| 208 | * With respect to these flags, wpa_supplicant doesn't * start p2p |
| 209 | * operations on 5GHz channels. All the changes in world regulatory |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 210 | * domain are to be done here. |
| 211 | */ |
| 212 | static const struct ieee80211_regdomain brcmf_regdom = { |
| 213 | .n_reg_rules = 4, |
| 214 | .alpha2 = "99", |
| 215 | .reg_rules = { |
| 216 | /* IEEE 802.11b/g, channels 1..11 */ |
| 217 | REG_RULE(2412-10, 2472+10, 40, 6, 20, 0), |
| 218 | /* If any */ |
| 219 | /* IEEE 802.11 channel 14 - Only JP enables |
| 220 | * this and for 802.11b only |
| 221 | */ |
| 222 | REG_RULE(2484-10, 2484+10, 20, 6, 20, 0), |
| 223 | /* IEEE 802.11a, channel 36..64 */ |
Arend van Spriel | c555ecd | 2014-05-12 10:47:36 +0200 | [diff] [blame] | 224 | REG_RULE(5150-10, 5350+10, 80, 6, 20, 0), |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 225 | /* IEEE 802.11a, channel 100..165 */ |
Arend van Spriel | c555ecd | 2014-05-12 10:47:36 +0200 | [diff] [blame] | 226 | REG_RULE(5470-10, 5850+10, 80, 6, 20, 0), } |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 227 | }; |
| 228 | |
| 229 | static const u32 __wl_cipher_suites[] = { |
| 230 | WLAN_CIPHER_SUITE_WEP40, |
| 231 | WLAN_CIPHER_SUITE_WEP104, |
| 232 | WLAN_CIPHER_SUITE_TKIP, |
| 233 | WLAN_CIPHER_SUITE_CCMP, |
| 234 | WLAN_CIPHER_SUITE_AES_CMAC, |
| 235 | }; |
| 236 | |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 237 | /* Vendor specific ie. id = 221, oui and type defines exact ie */ |
| 238 | struct brcmf_vs_tlv { |
| 239 | u8 id; |
| 240 | u8 len; |
| 241 | u8 oui[3]; |
| 242 | u8 oui_type; |
| 243 | }; |
| 244 | |
| 245 | struct parsed_vndr_ie_info { |
| 246 | u8 *ie_ptr; |
| 247 | u32 ie_len; /* total length including id & length field */ |
| 248 | struct brcmf_vs_tlv vndrie; |
| 249 | }; |
| 250 | |
| 251 | struct parsed_vndr_ies { |
| 252 | u32 count; |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 253 | struct parsed_vndr_ie_info ie_info[VNDR_IE_PARSE_LIMIT]; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 254 | }; |
| 255 | |
Hante Meuleman | 68ca395 | 2014-02-25 20:30:26 +0100 | [diff] [blame] | 256 | static int brcmf_roamoff; |
| 257 | module_param_named(roamoff, brcmf_roamoff, int, S_IRUSR); |
| 258 | MODULE_PARM_DESC(roamoff, "do not use internal roaming engine"); |
| 259 | |
Alwin Beukers | ef6ac17 | 2011-10-12 20:51:26 +0200 | [diff] [blame] | 260 | /* Quarter dBm units to mW |
| 261 | * Table starts at QDBM_OFFSET, so the first entry is mW for qdBm=153 |
| 262 | * Table is offset so the last entry is largest mW value that fits in |
| 263 | * a u16. |
| 264 | */ |
| 265 | |
| 266 | #define QDBM_OFFSET 153 /* Offset for first entry */ |
| 267 | #define QDBM_TABLE_LEN 40 /* Table size */ |
| 268 | |
| 269 | /* Smallest mW value that will round up to the first table entry, QDBM_OFFSET. |
| 270 | * Value is ( mW(QDBM_OFFSET - 1) + mW(QDBM_OFFSET) ) / 2 |
| 271 | */ |
| 272 | #define QDBM_TABLE_LOW_BOUND 6493 /* Low bound */ |
| 273 | |
| 274 | /* Largest mW value that will round down to the last table entry, |
| 275 | * QDBM_OFFSET + QDBM_TABLE_LEN-1. |
| 276 | * Value is ( mW(QDBM_OFFSET + QDBM_TABLE_LEN - 1) + |
| 277 | * mW(QDBM_OFFSET + QDBM_TABLE_LEN) ) / 2. |
| 278 | */ |
| 279 | #define QDBM_TABLE_HIGH_BOUND 64938 /* High bound */ |
| 280 | |
| 281 | static const u16 nqdBm_to_mW_map[QDBM_TABLE_LEN] = { |
| 282 | /* qdBm: +0 +1 +2 +3 +4 +5 +6 +7 */ |
| 283 | /* 153: */ 6683, 7079, 7499, 7943, 8414, 8913, 9441, 10000, |
| 284 | /* 161: */ 10593, 11220, 11885, 12589, 13335, 14125, 14962, 15849, |
| 285 | /* 169: */ 16788, 17783, 18836, 19953, 21135, 22387, 23714, 25119, |
| 286 | /* 177: */ 26607, 28184, 29854, 31623, 33497, 35481, 37584, 39811, |
| 287 | /* 185: */ 42170, 44668, 47315, 50119, 53088, 56234, 59566, 63096 |
| 288 | }; |
| 289 | |
| 290 | static u16 brcmf_qdbm_to_mw(u8 qdbm) |
| 291 | { |
| 292 | uint factor = 1; |
| 293 | int idx = qdbm - QDBM_OFFSET; |
| 294 | |
| 295 | if (idx >= QDBM_TABLE_LEN) |
| 296 | /* clamp to max u16 mW value */ |
| 297 | return 0xFFFF; |
| 298 | |
| 299 | /* scale the qdBm index up to the range of the table 0-40 |
| 300 | * where an offset of 40 qdBm equals a factor of 10 mW. |
| 301 | */ |
| 302 | while (idx < 0) { |
| 303 | idx += 40; |
| 304 | factor *= 10; |
| 305 | } |
| 306 | |
| 307 | /* return the mW value scaled down to the correct factor of 10, |
| 308 | * adding in factor/2 to get proper rounding. |
| 309 | */ |
| 310 | return (nqdBm_to_mW_map[idx] + factor / 2) / factor; |
| 311 | } |
| 312 | |
| 313 | static u8 brcmf_mw_to_qdbm(u16 mw) |
| 314 | { |
| 315 | u8 qdbm; |
| 316 | int offset; |
| 317 | uint mw_uint = mw; |
| 318 | uint boundary; |
| 319 | |
| 320 | /* handle boundary case */ |
| 321 | if (mw_uint <= 1) |
| 322 | return 0; |
| 323 | |
| 324 | offset = QDBM_OFFSET; |
| 325 | |
| 326 | /* move mw into the range of the table */ |
| 327 | while (mw_uint < QDBM_TABLE_LOW_BOUND) { |
| 328 | mw_uint *= 10; |
| 329 | offset -= 40; |
| 330 | } |
| 331 | |
| 332 | for (qdbm = 0; qdbm < QDBM_TABLE_LEN - 1; qdbm++) { |
| 333 | boundary = nqdBm_to_mW_map[qdbm] + (nqdBm_to_mW_map[qdbm + 1] - |
| 334 | nqdBm_to_mW_map[qdbm]) / 2; |
| 335 | if (mw_uint < boundary) |
| 336 | break; |
| 337 | } |
| 338 | |
| 339 | qdbm += (u8) offset; |
| 340 | |
| 341 | return qdbm; |
| 342 | } |
| 343 | |
Arend van Spriel | 5a394eb | 2014-05-27 12:56:15 +0200 | [diff] [blame] | 344 | static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf, |
| 345 | struct cfg80211_chan_def *ch) |
Arend van Spriel | 600a897 | 2014-05-12 10:47:39 +0200 | [diff] [blame] | 346 | { |
| 347 | struct brcmu_chan ch_inf; |
| 348 | s32 primary_offset; |
| 349 | |
| 350 | brcmf_dbg(TRACE, "chandef: control %d center %d width %d\n", |
| 351 | ch->chan->center_freq, ch->center_freq1, ch->width); |
| 352 | ch_inf.chnum = ieee80211_frequency_to_channel(ch->center_freq1); |
| 353 | primary_offset = ch->center_freq1 - ch->chan->center_freq; |
| 354 | switch (ch->width) { |
| 355 | case NL80211_CHAN_WIDTH_20: |
| 356 | ch_inf.bw = BRCMU_CHAN_BW_20; |
| 357 | WARN_ON(primary_offset != 0); |
| 358 | break; |
| 359 | case NL80211_CHAN_WIDTH_40: |
| 360 | ch_inf.bw = BRCMU_CHAN_BW_40; |
| 361 | if (primary_offset < 0) |
| 362 | ch_inf.sb = BRCMU_CHAN_SB_U; |
| 363 | else |
| 364 | ch_inf.sb = BRCMU_CHAN_SB_L; |
| 365 | break; |
| 366 | case NL80211_CHAN_WIDTH_80: |
| 367 | ch_inf.bw = BRCMU_CHAN_BW_80; |
| 368 | if (primary_offset < 0) { |
| 369 | if (primary_offset < -CH_10MHZ_APART) |
| 370 | ch_inf.sb = BRCMU_CHAN_SB_UU; |
| 371 | else |
| 372 | ch_inf.sb = BRCMU_CHAN_SB_UL; |
| 373 | } else { |
| 374 | if (primary_offset > CH_10MHZ_APART) |
| 375 | ch_inf.sb = BRCMU_CHAN_SB_LL; |
| 376 | else |
| 377 | ch_inf.sb = BRCMU_CHAN_SB_LU; |
| 378 | } |
| 379 | break; |
| 380 | default: |
| 381 | WARN_ON_ONCE(1); |
| 382 | } |
| 383 | switch (ch->chan->band) { |
| 384 | case IEEE80211_BAND_2GHZ: |
| 385 | ch_inf.band = BRCMU_CHAN_BAND_2G; |
| 386 | break; |
| 387 | case IEEE80211_BAND_5GHZ: |
| 388 | ch_inf.band = BRCMU_CHAN_BAND_5G; |
| 389 | break; |
| 390 | default: |
| 391 | WARN_ON_ONCE(1); |
| 392 | } |
| 393 | d11inf->encchspec(&ch_inf); |
| 394 | |
| 395 | return ch_inf.chspec; |
| 396 | } |
| 397 | |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 398 | u16 channel_to_chanspec(struct brcmu_d11inf *d11inf, |
| 399 | struct ieee80211_channel *ch) |
Arend van Spriel | 6e18616 | 2012-10-22 10:36:22 -0700 | [diff] [blame] | 400 | { |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 401 | struct brcmu_chan ch_inf; |
Arend van Spriel | 6e18616 | 2012-10-22 10:36:22 -0700 | [diff] [blame] | 402 | |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 403 | ch_inf.chnum = ieee80211_frequency_to_channel(ch->center_freq); |
| 404 | ch_inf.bw = BRCMU_CHAN_BW_20; |
| 405 | d11inf->encchspec(&ch_inf); |
Arend van Spriel | 6e18616 | 2012-10-22 10:36:22 -0700 | [diff] [blame] | 406 | |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 407 | return ch_inf.chspec; |
Arend van Spriel | 6e18616 | 2012-10-22 10:36:22 -0700 | [diff] [blame] | 408 | } |
| 409 | |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 410 | /* Traverse a string of 1-byte tag/1-byte length/variable-length value |
| 411 | * triples, returning a pointer to the substring whose first element |
| 412 | * matches tag |
| 413 | */ |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 414 | const struct brcmf_tlv * |
| 415 | brcmf_parse_tlvs(const void *buf, int buflen, uint key) |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 416 | { |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 417 | const struct brcmf_tlv *elt = buf; |
| 418 | int totlen = buflen; |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 419 | |
| 420 | /* find tagged parameter */ |
| 421 | while (totlen >= TLV_HDR_LEN) { |
| 422 | int len = elt->len; |
| 423 | |
| 424 | /* validate remaining totlen */ |
| 425 | if ((elt->id == key) && (totlen >= (len + TLV_HDR_LEN))) |
| 426 | return elt; |
| 427 | |
| 428 | elt = (struct brcmf_tlv *)((u8 *)elt + (len + TLV_HDR_LEN)); |
| 429 | totlen -= (len + TLV_HDR_LEN); |
| 430 | } |
| 431 | |
| 432 | return NULL; |
| 433 | } |
| 434 | |
| 435 | /* Is any of the tlvs the expected entry? If |
| 436 | * not update the tlvs buffer pointer/length. |
| 437 | */ |
| 438 | static bool |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 439 | brcmf_tlv_has_ie(const u8 *ie, const u8 **tlvs, u32 *tlvs_len, |
| 440 | const u8 *oui, u32 oui_len, u8 type) |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 441 | { |
| 442 | /* If the contents match the OUI and the type */ |
| 443 | if (ie[TLV_LEN_OFF] >= oui_len + 1 && |
| 444 | !memcmp(&ie[TLV_BODY_OFF], oui, oui_len) && |
| 445 | type == ie[TLV_BODY_OFF + oui_len]) { |
| 446 | return true; |
| 447 | } |
| 448 | |
| 449 | if (tlvs == NULL) |
| 450 | return false; |
| 451 | /* point to the next ie */ |
| 452 | ie += ie[TLV_LEN_OFF] + TLV_HDR_LEN; |
| 453 | /* calculate the length of the rest of the buffer */ |
| 454 | *tlvs_len -= (int)(ie - *tlvs); |
| 455 | /* update the pointer to the start of the buffer */ |
| 456 | *tlvs = ie; |
| 457 | |
| 458 | return false; |
| 459 | } |
| 460 | |
| 461 | static struct brcmf_vs_tlv * |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 462 | brcmf_find_wpaie(const u8 *parse, u32 len) |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 463 | { |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 464 | const struct brcmf_tlv *ie; |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 465 | |
| 466 | while ((ie = brcmf_parse_tlvs(parse, len, WLAN_EID_VENDOR_SPECIFIC))) { |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 467 | if (brcmf_tlv_has_ie((const u8 *)ie, &parse, &len, |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 468 | WPA_OUI, TLV_OUI_LEN, WPA_OUI_TYPE)) |
| 469 | return (struct brcmf_vs_tlv *)ie; |
| 470 | } |
| 471 | return NULL; |
| 472 | } |
| 473 | |
| 474 | static struct brcmf_vs_tlv * |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 475 | brcmf_find_wpsie(const u8 *parse, u32 len) |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 476 | { |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 477 | const struct brcmf_tlv *ie; |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 478 | |
| 479 | while ((ie = brcmf_parse_tlvs(parse, len, WLAN_EID_VENDOR_SPECIFIC))) { |
| 480 | if (brcmf_tlv_has_ie((u8 *)ie, &parse, &len, |
| 481 | WPA_OUI, TLV_OUI_LEN, WPS_OUI_TYPE)) |
| 482 | return (struct brcmf_vs_tlv *)ie; |
| 483 | } |
| 484 | return NULL; |
| 485 | } |
| 486 | |
| 487 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 488 | static void convert_key_from_CPU(struct brcmf_wsec_key *key, |
| 489 | struct brcmf_wsec_key_le *key_le) |
| 490 | { |
| 491 | key_le->index = cpu_to_le32(key->index); |
| 492 | key_le->len = cpu_to_le32(key->len); |
| 493 | key_le->algo = cpu_to_le32(key->algo); |
| 494 | key_le->flags = cpu_to_le32(key->flags); |
| 495 | key_le->rxiv.hi = cpu_to_le32(key->rxiv.hi); |
| 496 | key_le->rxiv.lo = cpu_to_le16(key->rxiv.lo); |
| 497 | key_le->iv_initialized = cpu_to_le32(key->iv_initialized); |
| 498 | memcpy(key_le->data, key->data, sizeof(key->data)); |
| 499 | memcpy(key_le->ea, key->ea, sizeof(key->ea)); |
| 500 | } |
| 501 | |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 502 | static int |
Arend van Spriel | 2eaba7e | 2012-10-22 10:36:26 -0700 | [diff] [blame] | 503 | send_key_to_dongle(struct net_device *ndev, struct brcmf_wsec_key *key) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 504 | { |
| 505 | int err; |
| 506 | struct brcmf_wsec_key_le key_le; |
| 507 | |
| 508 | convert_key_from_CPU(key, &key_le); |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 509 | |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 510 | brcmf_netdev_wait_pend8021x(ndev); |
| 511 | |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 512 | err = brcmf_fil_bsscfg_data_set(netdev_priv(ndev), "wsec_key", &key_le, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 513 | sizeof(key_le)); |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 514 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 515 | if (err) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 516 | brcmf_err("wsec_key error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 517 | return err; |
| 518 | } |
| 519 | |
Hante Meuleman | b365745 | 2013-05-27 21:09:53 +0200 | [diff] [blame] | 520 | static s32 |
| 521 | brcmf_configure_arp_offload(struct brcmf_if *ifp, bool enable) |
| 522 | { |
| 523 | s32 err; |
| 524 | u32 mode; |
| 525 | |
| 526 | if (enable) |
| 527 | mode = BRCMF_ARP_OL_AGENT | BRCMF_ARP_OL_PEER_AUTO_REPLY; |
| 528 | else |
| 529 | mode = 0; |
| 530 | |
| 531 | /* Try to set and enable ARP offload feature, this may fail, then it */ |
| 532 | /* is simply not supported and err 0 will be returned */ |
| 533 | err = brcmf_fil_iovar_int_set(ifp, "arp_ol", mode); |
| 534 | if (err) { |
| 535 | brcmf_dbg(TRACE, "failed to set ARP offload mode to 0x%x, err = %d\n", |
| 536 | mode, err); |
| 537 | err = 0; |
| 538 | } else { |
| 539 | err = brcmf_fil_iovar_int_set(ifp, "arpoe", enable); |
| 540 | if (err) { |
| 541 | brcmf_dbg(TRACE, "failed to configure (%d) ARP offload err = %d\n", |
| 542 | enable, err); |
| 543 | err = 0; |
| 544 | } else |
| 545 | brcmf_dbg(TRACE, "successfully configured (%d) ARP offload to 0x%x\n", |
| 546 | enable, mode); |
| 547 | } |
| 548 | |
| 549 | return err; |
| 550 | } |
| 551 | |
Arend van Spriel | 967fe2c | 2014-03-15 17:18:21 +0100 | [diff] [blame] | 552 | static bool brcmf_is_apmode(struct brcmf_cfg80211_vif *vif) |
| 553 | { |
| 554 | enum nl80211_iftype iftype; |
| 555 | |
| 556 | iftype = vif->wdev.iftype; |
| 557 | return iftype == NL80211_IFTYPE_AP || iftype == NL80211_IFTYPE_P2P_GO; |
| 558 | } |
| 559 | |
| 560 | static bool brcmf_is_ibssmode(struct brcmf_cfg80211_vif *vif) |
| 561 | { |
| 562 | return vif->wdev.iftype == NL80211_IFTYPE_ADHOC; |
| 563 | } |
| 564 | |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 565 | static struct wireless_dev *brcmf_cfg80211_add_iface(struct wiphy *wiphy, |
| 566 | const char *name, |
| 567 | enum nl80211_iftype type, |
| 568 | u32 *flags, |
| 569 | struct vif_params *params) |
| 570 | { |
| 571 | brcmf_dbg(TRACE, "enter: %s type %d\n", name, type); |
| 572 | switch (type) { |
| 573 | case NL80211_IFTYPE_ADHOC: |
| 574 | case NL80211_IFTYPE_STATION: |
| 575 | case NL80211_IFTYPE_AP: |
| 576 | case NL80211_IFTYPE_AP_VLAN: |
| 577 | case NL80211_IFTYPE_WDS: |
| 578 | case NL80211_IFTYPE_MONITOR: |
| 579 | case NL80211_IFTYPE_MESH_POINT: |
| 580 | return ERR_PTR(-EOPNOTSUPP); |
| 581 | case NL80211_IFTYPE_P2P_CLIENT: |
| 582 | case NL80211_IFTYPE_P2P_GO: |
Arend van Spriel | 27f10e3 | 2013-04-05 10:57:50 +0200 | [diff] [blame] | 583 | case NL80211_IFTYPE_P2P_DEVICE: |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 584 | return brcmf_p2p_add_vif(wiphy, name, type, flags, params); |
| 585 | case NL80211_IFTYPE_UNSPECIFIED: |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 586 | default: |
| 587 | return ERR_PTR(-EINVAL); |
| 588 | } |
| 589 | } |
| 590 | |
Arend van Spriel | f96aa07 | 2013-04-05 10:57:48 +0200 | [diff] [blame] | 591 | void brcmf_set_mpc(struct brcmf_if *ifp, int mpc) |
Arend van Spriel | 5f4f9f1 | 2013-02-08 15:53:41 +0100 | [diff] [blame] | 592 | { |
Arend van Spriel | 5f4f9f1 | 2013-02-08 15:53:41 +0100 | [diff] [blame] | 593 | s32 err = 0; |
| 594 | |
| 595 | if (check_vif_up(ifp->vif)) { |
| 596 | err = brcmf_fil_iovar_int_set(ifp, "mpc", mpc); |
| 597 | if (err) { |
| 598 | brcmf_err("fail to set mpc\n"); |
| 599 | return; |
| 600 | } |
| 601 | brcmf_dbg(INFO, "MPC : %d\n", mpc); |
| 602 | } |
| 603 | } |
| 604 | |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 605 | s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg, |
| 606 | struct brcmf_if *ifp, bool aborted, |
| 607 | bool fw_abort) |
Arend van Spriel | 5f4f9f1 | 2013-02-08 15:53:41 +0100 | [diff] [blame] | 608 | { |
| 609 | struct brcmf_scan_params_le params_le; |
| 610 | struct cfg80211_scan_request *scan_request; |
| 611 | s32 err = 0; |
| 612 | |
| 613 | brcmf_dbg(SCAN, "Enter\n"); |
| 614 | |
| 615 | /* clear scan request, because the FW abort can cause a second call */ |
| 616 | /* to this functon and might cause a double cfg80211_scan_done */ |
| 617 | scan_request = cfg->scan_request; |
| 618 | cfg->scan_request = NULL; |
| 619 | |
| 620 | if (timer_pending(&cfg->escan_timeout)) |
| 621 | del_timer_sync(&cfg->escan_timeout); |
| 622 | |
| 623 | if (fw_abort) { |
| 624 | /* Do a scan abort to stop the driver's scan engine */ |
| 625 | brcmf_dbg(SCAN, "ABORT scan in firmware\n"); |
| 626 | memset(¶ms_le, 0, sizeof(params_le)); |
| 627 | memset(params_le.bssid, 0xFF, ETH_ALEN); |
| 628 | params_le.bss_type = DOT11_BSSTYPE_ANY; |
| 629 | params_le.scan_type = 0; |
| 630 | params_le.channel_num = cpu_to_le32(1); |
| 631 | params_le.nprobes = cpu_to_le32(1); |
| 632 | params_le.active_time = cpu_to_le32(-1); |
| 633 | params_le.passive_time = cpu_to_le32(-1); |
| 634 | params_le.home_time = cpu_to_le32(-1); |
| 635 | /* Scan is aborted by setting channel_list[0] to -1 */ |
| 636 | params_le.channel_list[0] = cpu_to_le16(-1); |
| 637 | /* E-Scan (or anyother type) can be aborted by SCAN */ |
Arend van Spriel | f96aa07 | 2013-04-05 10:57:48 +0200 | [diff] [blame] | 638 | err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SCAN, |
Arend van Spriel | 5f4f9f1 | 2013-02-08 15:53:41 +0100 | [diff] [blame] | 639 | ¶ms_le, sizeof(params_le)); |
| 640 | if (err) |
| 641 | brcmf_err("Scan abort failed\n"); |
| 642 | } |
Arend van Spriel | 0f0fe99 | 2014-05-27 12:56:14 +0200 | [diff] [blame] | 643 | |
| 644 | brcmf_set_mpc(ifp, 1); |
| 645 | |
Arend van Spriel | 5f4f9f1 | 2013-02-08 15:53:41 +0100 | [diff] [blame] | 646 | /* |
| 647 | * e-scan can be initiated by scheduled scan |
| 648 | * which takes precedence. |
| 649 | */ |
| 650 | if (cfg->sched_escan) { |
| 651 | brcmf_dbg(SCAN, "scheduled scan completed\n"); |
| 652 | cfg->sched_escan = false; |
| 653 | if (!aborted) |
| 654 | cfg80211_sched_scan_results(cfg_to_wiphy(cfg)); |
Arend van Spriel | 5f4f9f1 | 2013-02-08 15:53:41 +0100 | [diff] [blame] | 655 | } else if (scan_request) { |
| 656 | brcmf_dbg(SCAN, "ESCAN Completed scan: %s\n", |
| 657 | aborted ? "Aborted" : "Done"); |
| 658 | cfg80211_scan_done(scan_request, aborted); |
Arend van Spriel | 5f4f9f1 | 2013-02-08 15:53:41 +0100 | [diff] [blame] | 659 | } |
Hante Meuleman | 6eda4e2 | 2013-02-08 15:54:02 +0100 | [diff] [blame] | 660 | if (!test_and_clear_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status)) |
| 661 | brcmf_dbg(SCAN, "Scan complete, probably P2P scan\n"); |
Arend van Spriel | 5f4f9f1 | 2013-02-08 15:53:41 +0100 | [diff] [blame] | 662 | |
| 663 | return err; |
| 664 | } |
| 665 | |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 666 | static |
| 667 | int brcmf_cfg80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev) |
| 668 | { |
Arend van Spriel | 5f4f9f1 | 2013-02-08 15:53:41 +0100 | [diff] [blame] | 669 | struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy); |
| 670 | struct net_device *ndev = wdev->netdev; |
| 671 | |
| 672 | /* vif event pending in firmware */ |
| 673 | if (brcmf_cfg80211_vif_event_armed(cfg)) |
| 674 | return -EBUSY; |
| 675 | |
| 676 | if (ndev) { |
| 677 | if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status) && |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 678 | cfg->escan_info.ifp == netdev_priv(ndev)) |
| 679 | brcmf_notify_escan_complete(cfg, netdev_priv(ndev), |
| 680 | true, true); |
Arend van Spriel | 5f4f9f1 | 2013-02-08 15:53:41 +0100 | [diff] [blame] | 681 | |
| 682 | brcmf_fil_iovar_int_set(netdev_priv(ndev), "mpc", 1); |
| 683 | } |
| 684 | |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 685 | switch (wdev->iftype) { |
| 686 | case NL80211_IFTYPE_ADHOC: |
| 687 | case NL80211_IFTYPE_STATION: |
| 688 | case NL80211_IFTYPE_AP: |
| 689 | case NL80211_IFTYPE_AP_VLAN: |
| 690 | case NL80211_IFTYPE_WDS: |
| 691 | case NL80211_IFTYPE_MONITOR: |
| 692 | case NL80211_IFTYPE_MESH_POINT: |
| 693 | return -EOPNOTSUPP; |
| 694 | case NL80211_IFTYPE_P2P_CLIENT: |
| 695 | case NL80211_IFTYPE_P2P_GO: |
Arend van Spriel | 27f10e3 | 2013-04-05 10:57:50 +0200 | [diff] [blame] | 696 | case NL80211_IFTYPE_P2P_DEVICE: |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 697 | return brcmf_p2p_del_vif(wiphy, wdev); |
| 698 | case NL80211_IFTYPE_UNSPECIFIED: |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 699 | default: |
| 700 | return -EINVAL; |
| 701 | } |
| 702 | return -EOPNOTSUPP; |
| 703 | } |
| 704 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 705 | static s32 |
| 706 | brcmf_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev, |
| 707 | enum nl80211_iftype type, u32 *flags, |
| 708 | struct vif_params *params) |
| 709 | { |
Hante Meuleman | 7a5c1f6 | 2013-02-08 15:53:44 +0100 | [diff] [blame] | 710 | struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy); |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 711 | struct brcmf_if *ifp = netdev_priv(ndev); |
Arend van Spriel | 128ce3b | 2012-11-28 21:44:12 +0100 | [diff] [blame] | 712 | struct brcmf_cfg80211_vif *vif = ifp->vif; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 713 | s32 infra = 0; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 714 | s32 ap = 0; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 715 | s32 err = 0; |
| 716 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 717 | brcmf_dbg(TRACE, "Enter, ndev=%p, type=%d\n", ndev, type); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 718 | |
| 719 | switch (type) { |
| 720 | case NL80211_IFTYPE_MONITOR: |
| 721 | case NL80211_IFTYPE_WDS: |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 722 | brcmf_err("type (%d) : currently we do not support this type\n", |
| 723 | type); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 724 | return -EOPNOTSUPP; |
| 725 | case NL80211_IFTYPE_ADHOC: |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 726 | infra = 0; |
| 727 | break; |
| 728 | case NL80211_IFTYPE_STATION: |
Hante Meuleman | 1bc7c65 | 2013-02-08 15:53:56 +0100 | [diff] [blame] | 729 | /* Ignore change for p2p IF. Unclear why supplicant does this */ |
| 730 | if ((vif->wdev.iftype == NL80211_IFTYPE_P2P_CLIENT) || |
| 731 | (vif->wdev.iftype == NL80211_IFTYPE_P2P_GO)) { |
| 732 | brcmf_dbg(TRACE, "Ignoring cmd for p2p if\n"); |
| 733 | /* WAR: It is unexpected to get a change of VIF for P2P |
| 734 | * IF, but it happens. The request can not be handled |
| 735 | * but returning EPERM causes a crash. Returning 0 |
| 736 | * without setting ieee80211_ptr->iftype causes trace |
| 737 | * (WARN_ON) but it works with wpa_supplicant |
| 738 | */ |
| 739 | return 0; |
| 740 | } |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 741 | infra = 1; |
| 742 | break; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 743 | case NL80211_IFTYPE_AP: |
Hante Meuleman | 7a5c1f6 | 2013-02-08 15:53:44 +0100 | [diff] [blame] | 744 | case NL80211_IFTYPE_P2P_GO: |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 745 | ap = 1; |
| 746 | break; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 747 | default: |
| 748 | err = -EINVAL; |
| 749 | goto done; |
| 750 | } |
| 751 | |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 752 | if (ap) { |
Hante Meuleman | 7a5c1f6 | 2013-02-08 15:53:44 +0100 | [diff] [blame] | 753 | if (type == NL80211_IFTYPE_P2P_GO) { |
| 754 | brcmf_dbg(INFO, "IF Type = P2P GO\n"); |
| 755 | err = brcmf_p2p_ifchange(cfg, BRCMF_FIL_P2P_IF_GO); |
| 756 | } |
| 757 | if (!err) { |
| 758 | set_bit(BRCMF_VIF_STATUS_AP_CREATING, &vif->sme_state); |
| 759 | brcmf_dbg(INFO, "IF Type = AP\n"); |
| 760 | } |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 761 | } else { |
Arend van Spriel | 128ce3b | 2012-11-28 21:44:12 +0100 | [diff] [blame] | 762 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_INFRA, infra); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 763 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 764 | brcmf_err("WLC_SET_INFRA error (%d)\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 765 | err = -EAGAIN; |
| 766 | goto done; |
| 767 | } |
Arend van Spriel | 967fe2c | 2014-03-15 17:18:21 +0100 | [diff] [blame] | 768 | brcmf_dbg(INFO, "IF Type = %s\n", brcmf_is_ibssmode(vif) ? |
Arend van Spriel | 647c9ae | 2012-12-05 15:26:01 +0100 | [diff] [blame] | 769 | "Adhoc" : "Infra"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 770 | } |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 771 | ndev->ieee80211_ptr->iftype = type; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 772 | |
| 773 | done: |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 774 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 775 | |
| 776 | return err; |
| 777 | } |
| 778 | |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 779 | static void brcmf_escan_prep(struct brcmf_cfg80211_info *cfg, |
| 780 | struct brcmf_scan_params_le *params_le, |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 781 | struct cfg80211_scan_request *request) |
| 782 | { |
| 783 | u32 n_ssids; |
| 784 | u32 n_channels; |
| 785 | s32 i; |
| 786 | s32 offset; |
Arend van Spriel | 029591f | 2012-09-19 22:21:06 +0200 | [diff] [blame] | 787 | u16 chanspec; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 788 | char *ptr; |
Arend van Spriel | 029591f | 2012-09-19 22:21:06 +0200 | [diff] [blame] | 789 | struct brcmf_ssid_le ssid_le; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 790 | |
Arend van Spriel | ba40d16 | 2012-10-22 13:55:38 -0700 | [diff] [blame] | 791 | memset(params_le->bssid, 0xFF, ETH_ALEN); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 792 | params_le->bss_type = DOT11_BSSTYPE_ANY; |
| 793 | params_le->scan_type = 0; |
| 794 | params_le->channel_num = 0; |
| 795 | params_le->nprobes = cpu_to_le32(-1); |
| 796 | params_le->active_time = cpu_to_le32(-1); |
| 797 | params_le->passive_time = cpu_to_le32(-1); |
| 798 | params_le->home_time = cpu_to_le32(-1); |
| 799 | memset(¶ms_le->ssid_le, 0, sizeof(params_le->ssid_le)); |
| 800 | |
| 801 | /* if request is null exit so it will be all channel broadcast scan */ |
| 802 | if (!request) |
| 803 | return; |
| 804 | |
| 805 | n_ssids = request->n_ssids; |
| 806 | n_channels = request->n_channels; |
| 807 | /* Copy channel array if applicable */ |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 808 | brcmf_dbg(SCAN, "### List of channelspecs to scan ### %d\n", |
| 809 | n_channels); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 810 | if (n_channels > 0) { |
| 811 | for (i = 0; i < n_channels; i++) { |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 812 | chanspec = channel_to_chanspec(&cfg->d11inf, |
| 813 | request->channels[i]); |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 814 | brcmf_dbg(SCAN, "Chan : %d, Channel spec: %x\n", |
| 815 | request->channels[i]->hw_value, chanspec); |
Arend van Spriel | 029591f | 2012-09-19 22:21:06 +0200 | [diff] [blame] | 816 | params_le->channel_list[i] = cpu_to_le16(chanspec); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 817 | } |
| 818 | } else { |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 819 | brcmf_dbg(SCAN, "Scanning all channels\n"); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 820 | } |
| 821 | /* Copy ssid array if applicable */ |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 822 | brcmf_dbg(SCAN, "### List of SSIDs to scan ### %d\n", n_ssids); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 823 | if (n_ssids > 0) { |
| 824 | offset = offsetof(struct brcmf_scan_params_le, channel_list) + |
| 825 | n_channels * sizeof(u16); |
| 826 | offset = roundup(offset, sizeof(u32)); |
| 827 | ptr = (char *)params_le + offset; |
| 828 | for (i = 0; i < n_ssids; i++) { |
Arend van Spriel | 029591f | 2012-09-19 22:21:06 +0200 | [diff] [blame] | 829 | memset(&ssid_le, 0, sizeof(ssid_le)); |
| 830 | ssid_le.SSID_len = |
| 831 | cpu_to_le32(request->ssids[i].ssid_len); |
| 832 | memcpy(ssid_le.SSID, request->ssids[i].ssid, |
| 833 | request->ssids[i].ssid_len); |
| 834 | if (!ssid_le.SSID_len) |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 835 | brcmf_dbg(SCAN, "%d: Broadcast scan\n", i); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 836 | else |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 837 | brcmf_dbg(SCAN, "%d: scan for %s size =%d\n", |
| 838 | i, ssid_le.SSID, ssid_le.SSID_len); |
Arend van Spriel | 029591f | 2012-09-19 22:21:06 +0200 | [diff] [blame] | 839 | memcpy(ptr, &ssid_le, sizeof(ssid_le)); |
| 840 | ptr += sizeof(ssid_le); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 841 | } |
| 842 | } else { |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 843 | brcmf_dbg(SCAN, "Broadcast scan %p\n", request->ssids); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 844 | if ((request->ssids) && request->ssids->ssid_len) { |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 845 | brcmf_dbg(SCAN, "SSID %s len=%d\n", |
| 846 | params_le->ssid_le.SSID, |
| 847 | request->ssids->ssid_len); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 848 | params_le->ssid_le.SSID_len = |
| 849 | cpu_to_le32(request->ssids->ssid_len); |
| 850 | memcpy(¶ms_le->ssid_le.SSID, request->ssids->ssid, |
| 851 | request->ssids->ssid_len); |
| 852 | } |
| 853 | } |
| 854 | /* Adding mask to channel numbers */ |
| 855 | params_le->channel_num = |
| 856 | cpu_to_le32((n_ssids << BRCMF_SCAN_PARAMS_NSSID_SHIFT) | |
| 857 | (n_channels & BRCMF_SCAN_PARAMS_COUNT_MASK)); |
| 858 | } |
| 859 | |
| 860 | static s32 |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 861 | brcmf_run_escan(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp, |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 862 | struct cfg80211_scan_request *request, u16 action) |
| 863 | { |
| 864 | s32 params_size = BRCMF_SCAN_PARAMS_FIXED_SIZE + |
| 865 | offsetof(struct brcmf_escan_params_le, params_le); |
| 866 | struct brcmf_escan_params_le *params; |
| 867 | s32 err = 0; |
| 868 | |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 869 | brcmf_dbg(SCAN, "E-SCAN START\n"); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 870 | |
| 871 | if (request != NULL) { |
| 872 | /* Allocate space for populating ssids in struct */ |
| 873 | params_size += sizeof(u32) * ((request->n_channels + 1) / 2); |
| 874 | |
| 875 | /* Allocate space for populating ssids in struct */ |
| 876 | params_size += sizeof(struct brcmf_ssid) * request->n_ssids; |
| 877 | } |
| 878 | |
| 879 | params = kzalloc(params_size, GFP_KERNEL); |
| 880 | if (!params) { |
| 881 | err = -ENOMEM; |
| 882 | goto exit; |
| 883 | } |
| 884 | BUG_ON(params_size + sizeof("escan") >= BRCMF_DCMD_MEDLEN); |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 885 | brcmf_escan_prep(cfg, ¶ms->params_le, request); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 886 | params->version = cpu_to_le32(BRCMF_ESCAN_REQ_VERSION); |
| 887 | params->action = cpu_to_le16(action); |
| 888 | params->sync_id = cpu_to_le16(0x1234); |
| 889 | |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 890 | err = brcmf_fil_iovar_data_set(ifp, "escan", params, params_size); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 891 | if (err) { |
| 892 | if (err == -EBUSY) |
Arend van Spriel | 647c9ae | 2012-12-05 15:26:01 +0100 | [diff] [blame] | 893 | brcmf_dbg(INFO, "system busy : escan canceled\n"); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 894 | else |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 895 | brcmf_err("error (%d)\n", err); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 896 | } |
| 897 | |
| 898 | kfree(params); |
| 899 | exit: |
| 900 | return err; |
| 901 | } |
| 902 | |
| 903 | static s32 |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 904 | brcmf_do_escan(struct brcmf_cfg80211_info *cfg, struct wiphy *wiphy, |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 905 | struct brcmf_if *ifp, struct cfg80211_scan_request *request) |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 906 | { |
| 907 | s32 err; |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 908 | u32 passive_scan; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 909 | struct brcmf_scan_results *results; |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 910 | struct escan_info *escan = &cfg->escan_info; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 911 | |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 912 | brcmf_dbg(SCAN, "Enter\n"); |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 913 | escan->ifp = ifp; |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 914 | escan->wiphy = wiphy; |
| 915 | escan->escan_state = WL_ESCAN_STATE_SCANNING; |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 916 | passive_scan = cfg->active_scan ? 0 : 1; |
Arend van Spriel | f96aa07 | 2013-04-05 10:57:48 +0200 | [diff] [blame] | 917 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_PASSIVE_SCAN, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 918 | passive_scan); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 919 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 920 | brcmf_err("error (%d)\n", err); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 921 | return err; |
| 922 | } |
Arend van Spriel | f96aa07 | 2013-04-05 10:57:48 +0200 | [diff] [blame] | 923 | brcmf_set_mpc(ifp, 0); |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 924 | results = (struct brcmf_scan_results *)cfg->escan_info.escan_buf; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 925 | results->version = 0; |
| 926 | results->count = 0; |
| 927 | results->buflen = WL_ESCAN_RESULTS_FIXED_SIZE; |
| 928 | |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 929 | err = escan->run(cfg, ifp, request, WL_ESCAN_ACTION_START); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 930 | if (err) |
Arend van Spriel | f96aa07 | 2013-04-05 10:57:48 +0200 | [diff] [blame] | 931 | brcmf_set_mpc(ifp, 1); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 932 | return err; |
| 933 | } |
| 934 | |
| 935 | static s32 |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 936 | brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif, |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 937 | struct cfg80211_scan_request *request, |
| 938 | struct cfg80211_ssid *this_ssid) |
| 939 | { |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 940 | struct brcmf_if *ifp = vif->ifp; |
| 941 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 942 | struct cfg80211_ssid *ssids; |
Hante Meuleman | f0799895 | 2012-11-05 16:22:13 -0800 | [diff] [blame] | 943 | struct brcmf_cfg80211_scan_req *sr = &cfg->scan_req_int; |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 944 | u32 passive_scan; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 945 | bool escan_req; |
| 946 | bool spec_scan; |
| 947 | s32 err; |
| 948 | u32 SSID_len; |
| 949 | |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 950 | brcmf_dbg(SCAN, "START ESCAN\n"); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 951 | |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 952 | if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status)) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 953 | brcmf_err("Scanning already: status (%lu)\n", cfg->scan_status); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 954 | return -EAGAIN; |
| 955 | } |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 956 | if (test_bit(BRCMF_SCAN_STATUS_ABORT, &cfg->scan_status)) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 957 | brcmf_err("Scanning being aborted: status (%lu)\n", |
| 958 | cfg->scan_status); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 959 | return -EAGAIN; |
| 960 | } |
Arend van Spriel | 1687eee | 2013-04-23 12:53:11 +0200 | [diff] [blame] | 961 | if (test_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status)) { |
| 962 | brcmf_err("Scanning suppressed: status (%lu)\n", |
| 963 | cfg->scan_status); |
| 964 | return -EAGAIN; |
| 965 | } |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 966 | if (test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 967 | brcmf_err("Connecting: status (%lu)\n", ifp->vif->sme_state); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 968 | return -EAGAIN; |
| 969 | } |
| 970 | |
Hante Meuleman | 0f8ffe1 | 2013-02-08 15:53:42 +0100 | [diff] [blame] | 971 | /* If scan req comes for p2p0, send it over primary I/F */ |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 972 | if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif) |
| 973 | vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif; |
Hante Meuleman | 0f8ffe1 | 2013-02-08 15:53:42 +0100 | [diff] [blame] | 974 | |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 975 | /* Arm scan timeout timer */ |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 976 | mod_timer(&cfg->escan_timeout, jiffies + |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 977 | WL_ESCAN_TIMER_INTERVAL_MS * HZ / 1000); |
| 978 | |
| 979 | escan_req = false; |
| 980 | if (request) { |
| 981 | /* scan bss */ |
| 982 | ssids = request->ssids; |
| 983 | escan_req = true; |
| 984 | } else { |
| 985 | /* scan in ibss */ |
| 986 | /* we don't do escan in ibss */ |
| 987 | ssids = this_ssid; |
| 988 | } |
| 989 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 990 | cfg->scan_request = request; |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 991 | set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 992 | if (escan_req) { |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 993 | cfg->escan_info.run = brcmf_run_escan; |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 994 | err = brcmf_p2p_scan_prep(wiphy, request, vif); |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 995 | if (err) |
| 996 | goto scan_out; |
| 997 | |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 998 | err = brcmf_do_escan(cfg, wiphy, vif->ifp, request); |
Arend van Spriel | 2cb941c | 2012-11-05 16:22:10 -0800 | [diff] [blame] | 999 | if (err) |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 1000 | goto scan_out; |
| 1001 | } else { |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 1002 | brcmf_dbg(SCAN, "ssid \"%s\", ssid_len (%d)\n", |
| 1003 | ssids->ssid, ssids->ssid_len); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 1004 | memset(&sr->ssid_le, 0, sizeof(sr->ssid_le)); |
| 1005 | SSID_len = min_t(u8, sizeof(sr->ssid_le.SSID), ssids->ssid_len); |
| 1006 | sr->ssid_le.SSID_len = cpu_to_le32(0); |
| 1007 | spec_scan = false; |
| 1008 | if (SSID_len) { |
| 1009 | memcpy(sr->ssid_le.SSID, ssids->ssid, SSID_len); |
| 1010 | sr->ssid_le.SSID_len = cpu_to_le32(SSID_len); |
| 1011 | spec_scan = true; |
| 1012 | } else |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 1013 | brcmf_dbg(SCAN, "Broadcast scan\n"); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 1014 | |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 1015 | passive_scan = cfg->active_scan ? 0 : 1; |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 1016 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_PASSIVE_SCAN, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 1017 | passive_scan); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 1018 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1019 | brcmf_err("WLC_SET_PASSIVE_SCAN error (%d)\n", err); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 1020 | goto scan_out; |
| 1021 | } |
Arend van Spriel | f96aa07 | 2013-04-05 10:57:48 +0200 | [diff] [blame] | 1022 | brcmf_set_mpc(ifp, 0); |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 1023 | err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SCAN, |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 1024 | &sr->ssid_le, sizeof(sr->ssid_le)); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 1025 | if (err) { |
| 1026 | if (err == -EBUSY) |
Arend van Spriel | 647c9ae | 2012-12-05 15:26:01 +0100 | [diff] [blame] | 1027 | brcmf_dbg(INFO, "BUSY: scan for \"%s\" canceled\n", |
| 1028 | sr->ssid_le.SSID); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 1029 | else |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1030 | brcmf_err("WLC_SCAN error (%d)\n", err); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 1031 | |
Arend van Spriel | f96aa07 | 2013-04-05 10:57:48 +0200 | [diff] [blame] | 1032 | brcmf_set_mpc(ifp, 1); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 1033 | goto scan_out; |
| 1034 | } |
| 1035 | } |
| 1036 | |
| 1037 | return 0; |
| 1038 | |
| 1039 | scan_out: |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 1040 | clear_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status); |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1041 | if (timer_pending(&cfg->escan_timeout)) |
| 1042 | del_timer_sync(&cfg->escan_timeout); |
| 1043 | cfg->scan_request = NULL; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 1044 | return err; |
| 1045 | } |
| 1046 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1047 | static s32 |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 1048 | brcmf_cfg80211_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1049 | { |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 1050 | struct brcmf_cfg80211_vif *vif; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1051 | s32 err = 0; |
| 1052 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1053 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 1054 | vif = container_of(request->wdev, struct brcmf_cfg80211_vif, wdev); |
| 1055 | if (!check_vif_up(vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1056 | return -EIO; |
| 1057 | |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 1058 | err = brcmf_cfg80211_escan(wiphy, vif, request, NULL); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 1059 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1060 | if (err) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1061 | brcmf_err("scan error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1062 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1063 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1064 | return err; |
| 1065 | } |
| 1066 | |
| 1067 | static s32 brcmf_set_rts(struct net_device *ndev, u32 rts_threshold) |
| 1068 | { |
| 1069 | s32 err = 0; |
| 1070 | |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 1071 | err = brcmf_fil_iovar_int_set(netdev_priv(ndev), "rtsthresh", |
| 1072 | rts_threshold); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1073 | if (err) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1074 | brcmf_err("Error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1075 | |
| 1076 | return err; |
| 1077 | } |
| 1078 | |
| 1079 | static s32 brcmf_set_frag(struct net_device *ndev, u32 frag_threshold) |
| 1080 | { |
| 1081 | s32 err = 0; |
| 1082 | |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 1083 | err = brcmf_fil_iovar_int_set(netdev_priv(ndev), "fragthresh", |
| 1084 | frag_threshold); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1085 | if (err) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1086 | brcmf_err("Error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1087 | |
| 1088 | return err; |
| 1089 | } |
| 1090 | |
| 1091 | static s32 brcmf_set_retry(struct net_device *ndev, u32 retry, bool l) |
| 1092 | { |
| 1093 | s32 err = 0; |
Hante Meuleman | b87e2c4 | 2012-11-14 18:46:23 -0800 | [diff] [blame] | 1094 | u32 cmd = (l ? BRCMF_C_SET_LRL : BRCMF_C_SET_SRL); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1095 | |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 1096 | err = brcmf_fil_cmd_int_set(netdev_priv(ndev), cmd, retry); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1097 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1098 | brcmf_err("cmd (%d) , error (%d)\n", cmd, err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1099 | return err; |
| 1100 | } |
| 1101 | return err; |
| 1102 | } |
| 1103 | |
| 1104 | static s32 brcmf_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
| 1105 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1106 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
| 1107 | struct net_device *ndev = cfg_to_ndev(cfg); |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 1108 | struct brcmf_if *ifp = netdev_priv(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1109 | s32 err = 0; |
| 1110 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1111 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 1112 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1113 | return -EIO; |
| 1114 | |
| 1115 | if (changed & WIPHY_PARAM_RTS_THRESHOLD && |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1116 | (cfg->conf->rts_threshold != wiphy->rts_threshold)) { |
| 1117 | cfg->conf->rts_threshold = wiphy->rts_threshold; |
| 1118 | err = brcmf_set_rts(ndev, cfg->conf->rts_threshold); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1119 | if (!err) |
| 1120 | goto done; |
| 1121 | } |
| 1122 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD && |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1123 | (cfg->conf->frag_threshold != wiphy->frag_threshold)) { |
| 1124 | cfg->conf->frag_threshold = wiphy->frag_threshold; |
| 1125 | err = brcmf_set_frag(ndev, cfg->conf->frag_threshold); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1126 | if (!err) |
| 1127 | goto done; |
| 1128 | } |
| 1129 | if (changed & WIPHY_PARAM_RETRY_LONG |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1130 | && (cfg->conf->retry_long != wiphy->retry_long)) { |
| 1131 | cfg->conf->retry_long = wiphy->retry_long; |
| 1132 | err = brcmf_set_retry(ndev, cfg->conf->retry_long, true); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1133 | if (!err) |
| 1134 | goto done; |
| 1135 | } |
| 1136 | if (changed & WIPHY_PARAM_RETRY_SHORT |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1137 | && (cfg->conf->retry_short != wiphy->retry_short)) { |
| 1138 | cfg->conf->retry_short = wiphy->retry_short; |
| 1139 | err = brcmf_set_retry(ndev, cfg->conf->retry_short, false); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1140 | if (!err) |
| 1141 | goto done; |
| 1142 | } |
| 1143 | |
| 1144 | done: |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1145 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1146 | return err; |
| 1147 | } |
| 1148 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1149 | static void brcmf_init_prof(struct brcmf_cfg80211_profile *prof) |
| 1150 | { |
| 1151 | memset(prof, 0, sizeof(*prof)); |
| 1152 | } |
| 1153 | |
Arend van Spriel | 903e0ee | 2012-11-28 21:44:11 +0100 | [diff] [blame] | 1154 | static void brcmf_link_down(struct brcmf_cfg80211_vif *vif) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1155 | { |
Piotr Haber | 61730d4 | 2013-04-23 12:53:12 +0200 | [diff] [blame] | 1156 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(vif->wdev.wiphy); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1157 | s32 err = 0; |
| 1158 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1159 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1160 | |
Arend van Spriel | 903e0ee | 2012-11-28 21:44:11 +0100 | [diff] [blame] | 1161 | if (test_bit(BRCMF_VIF_STATUS_CONNECTED, &vif->sme_state)) { |
Arend van Spriel | 647c9ae | 2012-12-05 15:26:01 +0100 | [diff] [blame] | 1162 | brcmf_dbg(INFO, "Call WLC_DISASSOC to stop excess roaming\n "); |
Arend van Spriel | 903e0ee | 2012-11-28 21:44:11 +0100 | [diff] [blame] | 1163 | err = brcmf_fil_cmd_data_set(vif->ifp, |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 1164 | BRCMF_C_DISASSOC, NULL, 0); |
Arend van Spriel | a538ae3 | 2013-07-25 23:01:34 +0200 | [diff] [blame] | 1165 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1166 | brcmf_err("WLC_DISASSOC failed (%d)\n", err); |
Arend van Spriel | a538ae3 | 2013-07-25 23:01:34 +0200 | [diff] [blame] | 1167 | } |
Arend van Spriel | 903e0ee | 2012-11-28 21:44:11 +0100 | [diff] [blame] | 1168 | clear_bit(BRCMF_VIF_STATUS_CONNECTED, &vif->sme_state); |
Arend van Spriel | 43dffbc | 2014-01-06 12:40:46 +0100 | [diff] [blame] | 1169 | cfg80211_disconnected(vif->wdev.netdev, 0, NULL, 0, GFP_KERNEL); |
| 1170 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1171 | } |
Arend van Spriel | 903e0ee | 2012-11-28 21:44:11 +0100 | [diff] [blame] | 1172 | clear_bit(BRCMF_VIF_STATUS_CONNECTING, &vif->sme_state); |
Piotr Haber | 61730d4 | 2013-04-23 12:53:12 +0200 | [diff] [blame] | 1173 | clear_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status); |
| 1174 | brcmf_btcoex_set_mode(vif, BRCMF_BTCOEX_ENABLED, 0); |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1175 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1176 | } |
| 1177 | |
| 1178 | static s32 |
| 1179 | brcmf_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *ndev, |
| 1180 | struct cfg80211_ibss_params *params) |
| 1181 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1182 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 1183 | struct brcmf_if *ifp = netdev_priv(ndev); |
| 1184 | struct brcmf_cfg80211_profile *profile = &ifp->vif->profile; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1185 | struct brcmf_join_params join_params; |
| 1186 | size_t join_params_size = 0; |
| 1187 | s32 err = 0; |
| 1188 | s32 wsec = 0; |
| 1189 | s32 bcnprd; |
Hante Meuleman | 1701261 | 2013-02-06 18:40:44 +0100 | [diff] [blame] | 1190 | u16 chanspec; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1191 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1192 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 1193 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1194 | return -EIO; |
| 1195 | |
| 1196 | if (params->ssid) |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1197 | brcmf_dbg(CONN, "SSID: %s\n", params->ssid); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1198 | else { |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1199 | brcmf_dbg(CONN, "SSID: NULL, Not supported\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1200 | return -EOPNOTSUPP; |
| 1201 | } |
| 1202 | |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 1203 | set_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1204 | |
| 1205 | if (params->bssid) |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1206 | brcmf_dbg(CONN, "BSSID: %pM\n", params->bssid); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1207 | else |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1208 | brcmf_dbg(CONN, "No BSSID specified\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1209 | |
Johannes Berg | 683b6d3 | 2012-11-08 21:25:48 +0100 | [diff] [blame] | 1210 | if (params->chandef.chan) |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1211 | brcmf_dbg(CONN, "channel: %d\n", |
| 1212 | params->chandef.chan->center_freq); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1213 | else |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1214 | brcmf_dbg(CONN, "no channel specified\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1215 | |
| 1216 | if (params->channel_fixed) |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1217 | brcmf_dbg(CONN, "fixed channel required\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1218 | else |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1219 | brcmf_dbg(CONN, "no fixed channel required\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1220 | |
| 1221 | if (params->ie && params->ie_len) |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1222 | brcmf_dbg(CONN, "ie len: %d\n", params->ie_len); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1223 | else |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1224 | brcmf_dbg(CONN, "no ie specified\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1225 | |
| 1226 | if (params->beacon_interval) |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1227 | brcmf_dbg(CONN, "beacon interval: %d\n", |
| 1228 | params->beacon_interval); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1229 | else |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1230 | brcmf_dbg(CONN, "no beacon interval specified\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1231 | |
| 1232 | if (params->basic_rates) |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1233 | brcmf_dbg(CONN, "basic rates: %08X\n", params->basic_rates); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1234 | else |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1235 | brcmf_dbg(CONN, "no basic rates specified\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1236 | |
| 1237 | if (params->privacy) |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1238 | brcmf_dbg(CONN, "privacy required\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1239 | else |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1240 | brcmf_dbg(CONN, "no privacy required\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1241 | |
| 1242 | /* Configure Privacy for starter */ |
| 1243 | if (params->privacy) |
| 1244 | wsec |= WEP_ENABLED; |
| 1245 | |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 1246 | err = brcmf_fil_iovar_int_set(ifp, "wsec", wsec); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1247 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1248 | brcmf_err("wsec failed (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1249 | goto done; |
| 1250 | } |
| 1251 | |
| 1252 | /* Configure Beacon Interval for starter */ |
| 1253 | if (params->beacon_interval) |
| 1254 | bcnprd = params->beacon_interval; |
| 1255 | else |
| 1256 | bcnprd = 100; |
| 1257 | |
Hante Meuleman | b87e2c4 | 2012-11-14 18:46:23 -0800 | [diff] [blame] | 1258 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_BCNPRD, bcnprd); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1259 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1260 | brcmf_err("WLC_SET_BCNPRD failed (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1261 | goto done; |
| 1262 | } |
| 1263 | |
| 1264 | /* Configure required join parameter */ |
| 1265 | memset(&join_params, 0, sizeof(struct brcmf_join_params)); |
| 1266 | |
| 1267 | /* SSID */ |
Arend van Spriel | 6c8c4f7 | 2012-09-27 14:17:57 +0200 | [diff] [blame] | 1268 | profile->ssid.SSID_len = min_t(u32, params->ssid_len, 32); |
| 1269 | memcpy(profile->ssid.SSID, params->ssid, profile->ssid.SSID_len); |
| 1270 | memcpy(join_params.ssid_le.SSID, params->ssid, profile->ssid.SSID_len); |
| 1271 | join_params.ssid_le.SSID_len = cpu_to_le32(profile->ssid.SSID_len); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1272 | join_params_size = sizeof(join_params.ssid_le); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1273 | |
| 1274 | /* BSSID */ |
| 1275 | if (params->bssid) { |
| 1276 | memcpy(join_params.params_le.bssid, params->bssid, ETH_ALEN); |
| 1277 | join_params_size = sizeof(join_params.ssid_le) + |
| 1278 | BRCMF_ASSOC_PARAMS_FIXED_SIZE; |
Arend van Spriel | 6c8c4f7 | 2012-09-27 14:17:57 +0200 | [diff] [blame] | 1279 | memcpy(profile->bssid, params->bssid, ETH_ALEN); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1280 | } else { |
Arend van Spriel | ba40d16 | 2012-10-22 13:55:38 -0700 | [diff] [blame] | 1281 | memset(join_params.params_le.bssid, 0xFF, ETH_ALEN); |
Arend van Spriel | 6c8c4f7 | 2012-09-27 14:17:57 +0200 | [diff] [blame] | 1282 | memset(profile->bssid, 0, ETH_ALEN); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1283 | } |
| 1284 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1285 | /* Channel */ |
Johannes Berg | 683b6d3 | 2012-11-08 21:25:48 +0100 | [diff] [blame] | 1286 | if (params->chandef.chan) { |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1287 | u32 target_channel; |
| 1288 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1289 | cfg->channel = |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1290 | ieee80211_frequency_to_channel( |
Johannes Berg | 683b6d3 | 2012-11-08 21:25:48 +0100 | [diff] [blame] | 1291 | params->chandef.chan->center_freq); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1292 | if (params->channel_fixed) { |
| 1293 | /* adding chanspec */ |
Arend van Spriel | 600a897 | 2014-05-12 10:47:39 +0200 | [diff] [blame] | 1294 | chanspec = chandef_to_chanspec(&cfg->d11inf, |
| 1295 | ¶ms->chandef); |
Hante Meuleman | 1701261 | 2013-02-06 18:40:44 +0100 | [diff] [blame] | 1296 | join_params.params_le.chanspec_list[0] = |
| 1297 | cpu_to_le16(chanspec); |
| 1298 | join_params.params_le.chanspec_num = cpu_to_le32(1); |
| 1299 | join_params_size += sizeof(join_params.params_le); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1300 | } |
| 1301 | |
| 1302 | /* set channel for starter */ |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1303 | target_channel = cfg->channel; |
Hante Meuleman | b87e2c4 | 2012-11-14 18:46:23 -0800 | [diff] [blame] | 1304 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_CHANNEL, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 1305 | target_channel); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1306 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1307 | brcmf_err("WLC_SET_CHANNEL failed (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1308 | goto done; |
| 1309 | } |
| 1310 | } else |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1311 | cfg->channel = 0; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1312 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1313 | cfg->ibss_starter = false; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1314 | |
| 1315 | |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 1316 | err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SSID, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 1317 | &join_params, join_params_size); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1318 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1319 | brcmf_err("WLC_SET_SSID failed (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1320 | goto done; |
| 1321 | } |
| 1322 | |
| 1323 | done: |
| 1324 | if (err) |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 1325 | clear_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state); |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1326 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1327 | return err; |
| 1328 | } |
| 1329 | |
| 1330 | static s32 |
| 1331 | brcmf_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *ndev) |
| 1332 | { |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 1333 | struct brcmf_if *ifp = netdev_priv(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1334 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1335 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 1336 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1337 | return -EIO; |
| 1338 | |
Arend van Spriel | 903e0ee | 2012-11-28 21:44:11 +0100 | [diff] [blame] | 1339 | brcmf_link_down(ifp->vif); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1340 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1341 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1342 | |
Peter Senna Tschudin | 12f3237 | 2014-05-31 10:14:06 -0300 | [diff] [blame^] | 1343 | return 0; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1344 | } |
| 1345 | |
| 1346 | static s32 brcmf_set_wpa_version(struct net_device *ndev, |
| 1347 | struct cfg80211_connect_params *sme) |
| 1348 | { |
Arend van Spriel | 6ac4f4e | 2012-10-22 13:55:31 -0700 | [diff] [blame] | 1349 | struct brcmf_cfg80211_profile *profile = ndev_to_prof(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1350 | struct brcmf_cfg80211_security *sec; |
| 1351 | s32 val = 0; |
| 1352 | s32 err = 0; |
| 1353 | |
| 1354 | if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) |
| 1355 | val = WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED; |
| 1356 | else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) |
| 1357 | val = WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED; |
| 1358 | else |
| 1359 | val = WPA_AUTH_DISABLED; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1360 | brcmf_dbg(CONN, "setting wpa_auth to 0x%0x\n", val); |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 1361 | err = brcmf_fil_bsscfg_int_set(netdev_priv(ndev), "wpa_auth", val); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1362 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1363 | brcmf_err("set wpa_auth failed (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1364 | return err; |
| 1365 | } |
Arend van Spriel | 06bb123 | 2012-09-27 14:17:56 +0200 | [diff] [blame] | 1366 | sec = &profile->sec; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1367 | sec->wpa_versions = sme->crypto.wpa_versions; |
| 1368 | return err; |
| 1369 | } |
| 1370 | |
| 1371 | static s32 brcmf_set_auth_type(struct net_device *ndev, |
| 1372 | struct cfg80211_connect_params *sme) |
| 1373 | { |
Arend van Spriel | 6ac4f4e | 2012-10-22 13:55:31 -0700 | [diff] [blame] | 1374 | struct brcmf_cfg80211_profile *profile = ndev_to_prof(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1375 | struct brcmf_cfg80211_security *sec; |
| 1376 | s32 val = 0; |
| 1377 | s32 err = 0; |
| 1378 | |
| 1379 | switch (sme->auth_type) { |
| 1380 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
| 1381 | val = 0; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1382 | brcmf_dbg(CONN, "open system\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1383 | break; |
| 1384 | case NL80211_AUTHTYPE_SHARED_KEY: |
| 1385 | val = 1; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1386 | brcmf_dbg(CONN, "shared key\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1387 | break; |
| 1388 | case NL80211_AUTHTYPE_AUTOMATIC: |
| 1389 | val = 2; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1390 | brcmf_dbg(CONN, "automatic\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1391 | break; |
| 1392 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1393 | brcmf_dbg(CONN, "network eap\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1394 | default: |
| 1395 | val = 2; |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1396 | brcmf_err("invalid auth type (%d)\n", sme->auth_type); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1397 | break; |
| 1398 | } |
| 1399 | |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 1400 | err = brcmf_fil_bsscfg_int_set(netdev_priv(ndev), "auth", val); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1401 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1402 | brcmf_err("set auth failed (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1403 | return err; |
| 1404 | } |
Arend van Spriel | 06bb123 | 2012-09-27 14:17:56 +0200 | [diff] [blame] | 1405 | sec = &profile->sec; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1406 | sec->auth_type = sme->auth_type; |
| 1407 | return err; |
| 1408 | } |
| 1409 | |
| 1410 | static s32 |
Daniel Kim | 87b7e9e | 2014-03-25 21:45:09 +0100 | [diff] [blame] | 1411 | brcmf_set_wsec_mode(struct net_device *ndev, |
| 1412 | struct cfg80211_connect_params *sme, bool mfp) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1413 | { |
Arend van Spriel | 6ac4f4e | 2012-10-22 13:55:31 -0700 | [diff] [blame] | 1414 | struct brcmf_cfg80211_profile *profile = ndev_to_prof(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1415 | struct brcmf_cfg80211_security *sec; |
| 1416 | s32 pval = 0; |
| 1417 | s32 gval = 0; |
Daniel Kim | 87b7e9e | 2014-03-25 21:45:09 +0100 | [diff] [blame] | 1418 | s32 wsec; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1419 | s32 err = 0; |
| 1420 | |
| 1421 | if (sme->crypto.n_ciphers_pairwise) { |
| 1422 | switch (sme->crypto.ciphers_pairwise[0]) { |
| 1423 | case WLAN_CIPHER_SUITE_WEP40: |
| 1424 | case WLAN_CIPHER_SUITE_WEP104: |
| 1425 | pval = WEP_ENABLED; |
| 1426 | break; |
| 1427 | case WLAN_CIPHER_SUITE_TKIP: |
| 1428 | pval = TKIP_ENABLED; |
| 1429 | break; |
| 1430 | case WLAN_CIPHER_SUITE_CCMP: |
| 1431 | pval = AES_ENABLED; |
| 1432 | break; |
| 1433 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 1434 | pval = AES_ENABLED; |
| 1435 | break; |
| 1436 | default: |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1437 | brcmf_err("invalid cipher pairwise (%d)\n", |
| 1438 | sme->crypto.ciphers_pairwise[0]); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1439 | return -EINVAL; |
| 1440 | } |
| 1441 | } |
| 1442 | if (sme->crypto.cipher_group) { |
| 1443 | switch (sme->crypto.cipher_group) { |
| 1444 | case WLAN_CIPHER_SUITE_WEP40: |
| 1445 | case WLAN_CIPHER_SUITE_WEP104: |
| 1446 | gval = WEP_ENABLED; |
| 1447 | break; |
| 1448 | case WLAN_CIPHER_SUITE_TKIP: |
| 1449 | gval = TKIP_ENABLED; |
| 1450 | break; |
| 1451 | case WLAN_CIPHER_SUITE_CCMP: |
| 1452 | gval = AES_ENABLED; |
| 1453 | break; |
| 1454 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 1455 | gval = AES_ENABLED; |
| 1456 | break; |
| 1457 | default: |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1458 | brcmf_err("invalid cipher group (%d)\n", |
| 1459 | sme->crypto.cipher_group); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1460 | return -EINVAL; |
| 1461 | } |
| 1462 | } |
| 1463 | |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1464 | brcmf_dbg(CONN, "pval (%d) gval (%d)\n", pval, gval); |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 1465 | /* In case of privacy, but no security and WPS then simulate */ |
| 1466 | /* setting AES. WPS-2.0 allows no security */ |
| 1467 | if (brcmf_find_wpsie(sme->ie, sme->ie_len) && !pval && !gval && |
| 1468 | sme->privacy) |
| 1469 | pval = AES_ENABLED; |
Daniel Kim | 87b7e9e | 2014-03-25 21:45:09 +0100 | [diff] [blame] | 1470 | |
| 1471 | if (mfp) |
| 1472 | wsec = pval | gval | MFP_CAPABLE; |
| 1473 | else |
| 1474 | wsec = pval | gval; |
| 1475 | err = brcmf_fil_bsscfg_int_set(netdev_priv(ndev), "wsec", wsec); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1476 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1477 | brcmf_err("error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1478 | return err; |
| 1479 | } |
| 1480 | |
Arend van Spriel | 06bb123 | 2012-09-27 14:17:56 +0200 | [diff] [blame] | 1481 | sec = &profile->sec; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1482 | sec->cipher_pairwise = sme->crypto.ciphers_pairwise[0]; |
| 1483 | sec->cipher_group = sme->crypto.cipher_group; |
| 1484 | |
| 1485 | return err; |
| 1486 | } |
| 1487 | |
| 1488 | static s32 |
| 1489 | brcmf_set_key_mgmt(struct net_device *ndev, struct cfg80211_connect_params *sme) |
| 1490 | { |
Arend van Spriel | 6ac4f4e | 2012-10-22 13:55:31 -0700 | [diff] [blame] | 1491 | struct brcmf_cfg80211_profile *profile = ndev_to_prof(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1492 | struct brcmf_cfg80211_security *sec; |
| 1493 | s32 val = 0; |
| 1494 | s32 err = 0; |
| 1495 | |
| 1496 | if (sme->crypto.n_akm_suites) { |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 1497 | err = brcmf_fil_bsscfg_int_get(netdev_priv(ndev), |
| 1498 | "wpa_auth", &val); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1499 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1500 | brcmf_err("could not get wpa_auth (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1501 | return err; |
| 1502 | } |
| 1503 | if (val & (WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED)) { |
| 1504 | switch (sme->crypto.akm_suites[0]) { |
| 1505 | case WLAN_AKM_SUITE_8021X: |
| 1506 | val = WPA_AUTH_UNSPECIFIED; |
| 1507 | break; |
| 1508 | case WLAN_AKM_SUITE_PSK: |
| 1509 | val = WPA_AUTH_PSK; |
| 1510 | break; |
| 1511 | default: |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1512 | brcmf_err("invalid cipher group (%d)\n", |
| 1513 | sme->crypto.cipher_group); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1514 | return -EINVAL; |
| 1515 | } |
| 1516 | } else if (val & (WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED)) { |
| 1517 | switch (sme->crypto.akm_suites[0]) { |
| 1518 | case WLAN_AKM_SUITE_8021X: |
| 1519 | val = WPA2_AUTH_UNSPECIFIED; |
| 1520 | break; |
| 1521 | case WLAN_AKM_SUITE_PSK: |
| 1522 | val = WPA2_AUTH_PSK; |
| 1523 | break; |
| 1524 | default: |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1525 | brcmf_err("invalid cipher group (%d)\n", |
| 1526 | sme->crypto.cipher_group); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1527 | return -EINVAL; |
| 1528 | } |
| 1529 | } |
| 1530 | |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1531 | brcmf_dbg(CONN, "setting wpa_auth to %d\n", val); |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 1532 | err = brcmf_fil_bsscfg_int_set(netdev_priv(ndev), |
| 1533 | "wpa_auth", val); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1534 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1535 | brcmf_err("could not set wpa_auth (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1536 | return err; |
| 1537 | } |
| 1538 | } |
Arend van Spriel | 06bb123 | 2012-09-27 14:17:56 +0200 | [diff] [blame] | 1539 | sec = &profile->sec; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1540 | sec->wpa_auth = sme->crypto.akm_suites[0]; |
| 1541 | |
| 1542 | return err; |
| 1543 | } |
| 1544 | |
| 1545 | static s32 |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 1546 | brcmf_set_sharedkey(struct net_device *ndev, |
| 1547 | struct cfg80211_connect_params *sme) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1548 | { |
Arend van Spriel | 6ac4f4e | 2012-10-22 13:55:31 -0700 | [diff] [blame] | 1549 | struct brcmf_cfg80211_profile *profile = ndev_to_prof(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1550 | struct brcmf_cfg80211_security *sec; |
| 1551 | struct brcmf_wsec_key key; |
| 1552 | s32 val; |
| 1553 | s32 err = 0; |
| 1554 | |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1555 | brcmf_dbg(CONN, "key len (%d)\n", sme->key_len); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1556 | |
Roland Vossen | a718e2f | 2011-10-12 20:51:24 +0200 | [diff] [blame] | 1557 | if (sme->key_len == 0) |
| 1558 | return 0; |
| 1559 | |
Arend van Spriel | 06bb123 | 2012-09-27 14:17:56 +0200 | [diff] [blame] | 1560 | sec = &profile->sec; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1561 | brcmf_dbg(CONN, "wpa_versions 0x%x cipher_pairwise 0x%x\n", |
| 1562 | sec->wpa_versions, sec->cipher_pairwise); |
Roland Vossen | a718e2f | 2011-10-12 20:51:24 +0200 | [diff] [blame] | 1563 | |
| 1564 | if (sec->wpa_versions & (NL80211_WPA_VERSION_1 | NL80211_WPA_VERSION_2)) |
| 1565 | return 0; |
| 1566 | |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 1567 | if (!(sec->cipher_pairwise & |
| 1568 | (WLAN_CIPHER_SUITE_WEP40 | WLAN_CIPHER_SUITE_WEP104))) |
| 1569 | return 0; |
Roland Vossen | a718e2f | 2011-10-12 20:51:24 +0200 | [diff] [blame] | 1570 | |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 1571 | memset(&key, 0, sizeof(key)); |
| 1572 | key.len = (u32) sme->key_len; |
| 1573 | key.index = (u32) sme->key_idx; |
| 1574 | if (key.len > sizeof(key.data)) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1575 | brcmf_err("Too long key length (%u)\n", key.len); |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 1576 | return -EINVAL; |
| 1577 | } |
| 1578 | memcpy(key.data, sme->key, key.len); |
| 1579 | key.flags = BRCMF_PRIMARY_KEY; |
| 1580 | switch (sec->cipher_pairwise) { |
| 1581 | case WLAN_CIPHER_SUITE_WEP40: |
| 1582 | key.algo = CRYPTO_ALGO_WEP1; |
| 1583 | break; |
| 1584 | case WLAN_CIPHER_SUITE_WEP104: |
| 1585 | key.algo = CRYPTO_ALGO_WEP128; |
| 1586 | break; |
| 1587 | default: |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1588 | brcmf_err("Invalid algorithm (%d)\n", |
| 1589 | sme->crypto.ciphers_pairwise[0]); |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 1590 | return -EINVAL; |
| 1591 | } |
| 1592 | /* Set the new key/index */ |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1593 | brcmf_dbg(CONN, "key length (%d) key index (%d) algo (%d)\n", |
| 1594 | key.len, key.index, key.algo); |
| 1595 | brcmf_dbg(CONN, "key \"%s\"\n", key.data); |
Arend van Spriel | 2eaba7e | 2012-10-22 10:36:26 -0700 | [diff] [blame] | 1596 | err = send_key_to_dongle(ndev, &key); |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 1597 | if (err) |
| 1598 | return err; |
| 1599 | |
| 1600 | if (sec->auth_type == NL80211_AUTHTYPE_SHARED_KEY) { |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1601 | brcmf_dbg(CONN, "set auth_type to shared key\n"); |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 1602 | val = WL_AUTH_SHARED_KEY; /* shared key */ |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 1603 | err = brcmf_fil_bsscfg_int_set(netdev_priv(ndev), "auth", val); |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 1604 | if (err) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1605 | brcmf_err("set auth failed (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1606 | } |
| 1607 | return err; |
| 1608 | } |
| 1609 | |
Arend van Spriel | cbb1ec9 | 2013-02-06 18:40:47 +0100 | [diff] [blame] | 1610 | static |
| 1611 | enum nl80211_auth_type brcmf_war_auth_type(struct brcmf_if *ifp, |
| 1612 | enum nl80211_auth_type type) |
| 1613 | { |
| 1614 | u32 ci; |
| 1615 | if (type == NL80211_AUTHTYPE_AUTOMATIC) { |
| 1616 | /* shift to ignore chip revision */ |
| 1617 | ci = brcmf_get_chip_info(ifp) >> 4; |
| 1618 | switch (ci) { |
| 1619 | case 43236: |
| 1620 | brcmf_dbg(CONN, "43236 WAR: use OPEN instead of AUTO\n"); |
| 1621 | return NL80211_AUTHTYPE_OPEN_SYSTEM; |
| 1622 | default: |
| 1623 | break; |
| 1624 | } |
| 1625 | } |
| 1626 | return type; |
| 1627 | } |
| 1628 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1629 | static s32 |
| 1630 | brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev, |
Arend van Spriel | cbb1ec9 | 2013-02-06 18:40:47 +0100 | [diff] [blame] | 1631 | struct cfg80211_connect_params *sme) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1632 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1633 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 1634 | struct brcmf_if *ifp = netdev_priv(ndev); |
| 1635 | struct brcmf_cfg80211_profile *profile = &ifp->vif->profile; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1636 | struct ieee80211_channel *chan = sme->channel; |
| 1637 | struct brcmf_join_params join_params; |
| 1638 | size_t join_params_size; |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 1639 | const struct brcmf_tlv *rsn_ie; |
| 1640 | const struct brcmf_vs_tlv *wpa_ie; |
| 1641 | const void *ie; |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 1642 | u32 ie_len; |
| 1643 | struct brcmf_ext_join_params_le *ext_join_params; |
Hante Meuleman | 1701261 | 2013-02-06 18:40:44 +0100 | [diff] [blame] | 1644 | u16 chanspec; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1645 | s32 err = 0; |
| 1646 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1647 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 1648 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1649 | return -EIO; |
| 1650 | |
| 1651 | if (!sme->ssid) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1652 | brcmf_err("Invalid ssid\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1653 | return -EOPNOTSUPP; |
| 1654 | } |
| 1655 | |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 1656 | if (ifp->vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif) { |
| 1657 | /* A normal (non P2P) connection request setup. */ |
| 1658 | ie = NULL; |
| 1659 | ie_len = 0; |
| 1660 | /* find the WPA_IE */ |
| 1661 | wpa_ie = brcmf_find_wpaie((u8 *)sme->ie, sme->ie_len); |
| 1662 | if (wpa_ie) { |
| 1663 | ie = wpa_ie; |
| 1664 | ie_len = wpa_ie->len + TLV_HDR_LEN; |
| 1665 | } else { |
| 1666 | /* find the RSN_IE */ |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 1667 | rsn_ie = brcmf_parse_tlvs((const u8 *)sme->ie, |
| 1668 | sme->ie_len, |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 1669 | WLAN_EID_RSN); |
| 1670 | if (rsn_ie) { |
| 1671 | ie = rsn_ie; |
| 1672 | ie_len = rsn_ie->len + TLV_HDR_LEN; |
| 1673 | } |
| 1674 | } |
| 1675 | brcmf_fil_iovar_data_set(ifp, "wpaie", ie, ie_len); |
| 1676 | } |
| 1677 | |
| 1678 | err = brcmf_vif_set_mgmt_ie(ifp->vif, BRCMF_VNDR_IE_ASSOCREQ_FLAG, |
| 1679 | sme->ie, sme->ie_len); |
| 1680 | if (err) |
| 1681 | brcmf_err("Set Assoc REQ IE Failed\n"); |
| 1682 | else |
| 1683 | brcmf_dbg(TRACE, "Applied Vndr IEs for Assoc request\n"); |
| 1684 | |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 1685 | set_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1686 | |
| 1687 | if (chan) { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1688 | cfg->channel = |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1689 | ieee80211_frequency_to_channel(chan->center_freq); |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 1690 | chanspec = channel_to_chanspec(&cfg->d11inf, chan); |
Hante Meuleman | 1701261 | 2013-02-06 18:40:44 +0100 | [diff] [blame] | 1691 | brcmf_dbg(CONN, "channel=%d, center_req=%d, chanspec=0x%04x\n", |
| 1692 | cfg->channel, chan->center_freq, chanspec); |
| 1693 | } else { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1694 | cfg->channel = 0; |
Hante Meuleman | 1701261 | 2013-02-06 18:40:44 +0100 | [diff] [blame] | 1695 | chanspec = 0; |
| 1696 | } |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1697 | |
Arend van Spriel | 647c9ae | 2012-12-05 15:26:01 +0100 | [diff] [blame] | 1698 | brcmf_dbg(INFO, "ie (%p), ie_len (%zd)\n", sme->ie, sme->ie_len); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1699 | |
| 1700 | err = brcmf_set_wpa_version(ndev, sme); |
| 1701 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1702 | brcmf_err("wl_set_wpa_version failed (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1703 | goto done; |
| 1704 | } |
| 1705 | |
Arend van Spriel | cbb1ec9 | 2013-02-06 18:40:47 +0100 | [diff] [blame] | 1706 | sme->auth_type = brcmf_war_auth_type(ifp, sme->auth_type); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1707 | err = brcmf_set_auth_type(ndev, sme); |
| 1708 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1709 | brcmf_err("wl_set_auth_type failed (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1710 | goto done; |
| 1711 | } |
| 1712 | |
Daniel Kim | 87b7e9e | 2014-03-25 21:45:09 +0100 | [diff] [blame] | 1713 | err = brcmf_set_wsec_mode(ndev, sme, sme->mfp == NL80211_MFP_REQUIRED); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1714 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1715 | brcmf_err("wl_set_set_cipher failed (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1716 | goto done; |
| 1717 | } |
| 1718 | |
| 1719 | err = brcmf_set_key_mgmt(ndev, sme); |
| 1720 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1721 | brcmf_err("wl_set_key_mgmt failed (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1722 | goto done; |
| 1723 | } |
| 1724 | |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 1725 | err = brcmf_set_sharedkey(ndev, sme); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1726 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1727 | brcmf_err("brcmf_set_sharedkey failed (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1728 | goto done; |
| 1729 | } |
| 1730 | |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 1731 | profile->ssid.SSID_len = min_t(u32, (u32)sizeof(profile->ssid.SSID), |
| 1732 | (u32)sme->ssid_len); |
| 1733 | memcpy(&profile->ssid.SSID, sme->ssid, profile->ssid.SSID_len); |
| 1734 | if (profile->ssid.SSID_len < IEEE80211_MAX_SSID_LEN) { |
| 1735 | profile->ssid.SSID[profile->ssid.SSID_len] = 0; |
| 1736 | brcmf_dbg(CONN, "SSID \"%s\", len (%d)\n", profile->ssid.SSID, |
| 1737 | profile->ssid.SSID_len); |
| 1738 | } |
| 1739 | |
| 1740 | /* Join with specific BSSID and cached SSID |
| 1741 | * If SSID is zero join based on BSSID only |
| 1742 | */ |
| 1743 | join_params_size = offsetof(struct brcmf_ext_join_params_le, assoc_le) + |
| 1744 | offsetof(struct brcmf_assoc_params_le, chanspec_list); |
| 1745 | if (cfg->channel) |
| 1746 | join_params_size += sizeof(u16); |
| 1747 | ext_join_params = kzalloc(join_params_size, GFP_KERNEL); |
| 1748 | if (ext_join_params == NULL) { |
| 1749 | err = -ENOMEM; |
| 1750 | goto done; |
| 1751 | } |
| 1752 | ext_join_params->ssid_le.SSID_len = cpu_to_le32(profile->ssid.SSID_len); |
| 1753 | memcpy(&ext_join_params->ssid_le.SSID, sme->ssid, |
| 1754 | profile->ssid.SSID_len); |
Hante Meuleman | 63dd99e | 2014-03-15 17:18:19 +0100 | [diff] [blame] | 1755 | |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 1756 | /* Set up join scan parameters */ |
| 1757 | ext_join_params->scan_le.scan_type = -1; |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 1758 | ext_join_params->scan_le.home_time = cpu_to_le32(-1); |
| 1759 | |
| 1760 | if (sme->bssid) |
| 1761 | memcpy(&ext_join_params->assoc_le.bssid, sme->bssid, ETH_ALEN); |
| 1762 | else |
| 1763 | memset(&ext_join_params->assoc_le.bssid, 0xFF, ETH_ALEN); |
| 1764 | |
| 1765 | if (cfg->channel) { |
| 1766 | ext_join_params->assoc_le.chanspec_num = cpu_to_le32(1); |
| 1767 | |
| 1768 | ext_join_params->assoc_le.chanspec_list[0] = |
| 1769 | cpu_to_le16(chanspec); |
Hante Meuleman | 63dd99e | 2014-03-15 17:18:19 +0100 | [diff] [blame] | 1770 | /* Increase dwell time to receive probe response or detect |
| 1771 | * beacon from target AP at a noisy air only during connect |
| 1772 | * command. |
| 1773 | */ |
| 1774 | ext_join_params->scan_le.active_time = |
| 1775 | cpu_to_le32(BRCMF_SCAN_JOIN_ACTIVE_DWELL_TIME_MS); |
| 1776 | ext_join_params->scan_le.passive_time = |
| 1777 | cpu_to_le32(BRCMF_SCAN_JOIN_PASSIVE_DWELL_TIME_MS); |
| 1778 | /* To sync with presence period of VSDB GO send probe request |
| 1779 | * more frequently. Probe request will be stopped when it gets |
| 1780 | * probe response from target AP/GO. |
| 1781 | */ |
| 1782 | ext_join_params->scan_le.nprobes = |
| 1783 | cpu_to_le32(BRCMF_SCAN_JOIN_ACTIVE_DWELL_TIME_MS / |
| 1784 | BRCMF_SCAN_JOIN_PROBE_INTERVAL_MS); |
| 1785 | } else { |
| 1786 | ext_join_params->scan_le.active_time = cpu_to_le32(-1); |
| 1787 | ext_join_params->scan_le.passive_time = cpu_to_le32(-1); |
| 1788 | ext_join_params->scan_le.nprobes = cpu_to_le32(-1); |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 1789 | } |
| 1790 | |
| 1791 | err = brcmf_fil_bsscfg_data_set(ifp, "join", ext_join_params, |
| 1792 | join_params_size); |
| 1793 | kfree(ext_join_params); |
| 1794 | if (!err) |
| 1795 | /* This is it. join command worked, we are done */ |
| 1796 | goto done; |
| 1797 | |
| 1798 | /* join command failed, fallback to set ssid */ |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1799 | memset(&join_params, 0, sizeof(join_params)); |
| 1800 | join_params_size = sizeof(join_params.ssid_le); |
| 1801 | |
Arend van Spriel | 6c8c4f7 | 2012-09-27 14:17:57 +0200 | [diff] [blame] | 1802 | memcpy(&join_params.ssid_le.SSID, sme->ssid, profile->ssid.SSID_len); |
Arend van Spriel | 6c8c4f7 | 2012-09-27 14:17:57 +0200 | [diff] [blame] | 1803 | join_params.ssid_le.SSID_len = cpu_to_le32(profile->ssid.SSID_len); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1804 | |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 1805 | if (sme->bssid) |
| 1806 | memcpy(join_params.params_le.bssid, sme->bssid, ETH_ALEN); |
| 1807 | else |
| 1808 | memset(join_params.params_le.bssid, 0xFF, ETH_ALEN); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1809 | |
Hante Meuleman | 1701261 | 2013-02-06 18:40:44 +0100 | [diff] [blame] | 1810 | if (cfg->channel) { |
| 1811 | join_params.params_le.chanspec_list[0] = cpu_to_le16(chanspec); |
| 1812 | join_params.params_le.chanspec_num = cpu_to_le32(1); |
| 1813 | join_params_size += sizeof(join_params.params_le); |
| 1814 | } |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 1815 | err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SSID, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 1816 | &join_params, join_params_size); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1817 | if (err) |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 1818 | brcmf_err("BRCMF_C_SET_SSID failed (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1819 | |
| 1820 | done: |
| 1821 | if (err) |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 1822 | clear_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state); |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1823 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1824 | return err; |
| 1825 | } |
| 1826 | |
| 1827 | static s32 |
| 1828 | brcmf_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *ndev, |
| 1829 | u16 reason_code) |
| 1830 | { |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 1831 | struct brcmf_if *ifp = netdev_priv(ndev); |
| 1832 | struct brcmf_cfg80211_profile *profile = &ifp->vif->profile; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1833 | struct brcmf_scb_val_le scbval; |
| 1834 | s32 err = 0; |
| 1835 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1836 | brcmf_dbg(TRACE, "Enter. Reason code = %d\n", reason_code); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 1837 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1838 | return -EIO; |
| 1839 | |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 1840 | clear_bit(BRCMF_VIF_STATUS_CONNECTED, &ifp->vif->sme_state); |
Arend van Spriel | 43dffbc | 2014-01-06 12:40:46 +0100 | [diff] [blame] | 1841 | cfg80211_disconnected(ndev, reason_code, NULL, 0, GFP_KERNEL); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1842 | |
Arend van Spriel | 06bb123 | 2012-09-27 14:17:56 +0200 | [diff] [blame] | 1843 | memcpy(&scbval.ea, &profile->bssid, ETH_ALEN); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1844 | scbval.val = cpu_to_le32(reason_code); |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 1845 | err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_DISASSOC, |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 1846 | &scbval, sizeof(scbval)); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1847 | if (err) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1848 | brcmf_err("error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1849 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1850 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1851 | return err; |
| 1852 | } |
| 1853 | |
| 1854 | static s32 |
Johannes Berg | c844211 | 2012-10-24 10:17:18 +0200 | [diff] [blame] | 1855 | brcmf_cfg80211_set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, |
Luis R. Rodriguez | d3f3113 | 2011-11-28 16:38:48 -0500 | [diff] [blame] | 1856 | enum nl80211_tx_power_setting type, s32 mbm) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1857 | { |
| 1858 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1859 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 1860 | struct net_device *ndev = cfg_to_ndev(cfg); |
| 1861 | struct brcmf_if *ifp = netdev_priv(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1862 | u16 txpwrmw; |
| 1863 | s32 err = 0; |
| 1864 | s32 disable = 0; |
Luis R. Rodriguez | d3f3113 | 2011-11-28 16:38:48 -0500 | [diff] [blame] | 1865 | s32 dbm = MBM_TO_DBM(mbm); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1866 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1867 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 1868 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1869 | return -EIO; |
| 1870 | |
| 1871 | switch (type) { |
| 1872 | case NL80211_TX_POWER_AUTOMATIC: |
| 1873 | break; |
| 1874 | case NL80211_TX_POWER_LIMITED: |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1875 | case NL80211_TX_POWER_FIXED: |
| 1876 | if (dbm < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1877 | brcmf_err("TX_POWER_FIXED - dbm is negative\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1878 | err = -EINVAL; |
| 1879 | goto done; |
| 1880 | } |
| 1881 | break; |
| 1882 | } |
| 1883 | /* Make sure radio is off or on as far as software is concerned */ |
| 1884 | disable = WL_RADIO_SW_DISABLE << 16; |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 1885 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_RADIO, disable); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1886 | if (err) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1887 | brcmf_err("WLC_SET_RADIO error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1888 | |
| 1889 | if (dbm > 0xffff) |
| 1890 | txpwrmw = 0xffff; |
| 1891 | else |
| 1892 | txpwrmw = (u16) dbm; |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 1893 | err = brcmf_fil_iovar_int_set(ifp, "qtxpower", |
| 1894 | (s32)brcmf_mw_to_qdbm(txpwrmw)); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1895 | if (err) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1896 | brcmf_err("qtxpower error (%d)\n", err); |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1897 | cfg->conf->tx_power = dbm; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1898 | |
| 1899 | done: |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1900 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1901 | return err; |
| 1902 | } |
| 1903 | |
Johannes Berg | c844211 | 2012-10-24 10:17:18 +0200 | [diff] [blame] | 1904 | static s32 brcmf_cfg80211_get_tx_power(struct wiphy *wiphy, |
| 1905 | struct wireless_dev *wdev, |
| 1906 | s32 *dbm) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1907 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 1908 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 1909 | struct brcmf_if *ifp = netdev_priv(cfg_to_ndev(cfg)); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1910 | s32 txpwrdbm; |
| 1911 | u8 result; |
| 1912 | s32 err = 0; |
| 1913 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1914 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 1915 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1916 | return -EIO; |
| 1917 | |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 1918 | err = brcmf_fil_iovar_int_get(ifp, "qtxpower", &txpwrdbm); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1919 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1920 | brcmf_err("error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1921 | goto done; |
| 1922 | } |
| 1923 | |
| 1924 | result = (u8) (txpwrdbm & ~WL_TXPWR_OVERRIDE); |
Alwin Beukers | ef6ac17 | 2011-10-12 20:51:26 +0200 | [diff] [blame] | 1925 | *dbm = (s32) brcmf_qdbm_to_mw(result); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1926 | |
| 1927 | done: |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1928 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1929 | return err; |
| 1930 | } |
| 1931 | |
| 1932 | static s32 |
| 1933 | brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *ndev, |
| 1934 | u8 key_idx, bool unicast, bool multicast) |
| 1935 | { |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 1936 | struct brcmf_if *ifp = netdev_priv(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1937 | u32 index; |
| 1938 | u32 wsec; |
| 1939 | s32 err = 0; |
| 1940 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1941 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1942 | brcmf_dbg(CONN, "key index (%d)\n", key_idx); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 1943 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1944 | return -EIO; |
| 1945 | |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 1946 | err = brcmf_fil_bsscfg_int_get(ifp, "wsec", &wsec); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1947 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1948 | brcmf_err("WLC_GET_WSEC error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1949 | goto done; |
| 1950 | } |
| 1951 | |
| 1952 | if (wsec & WEP_ENABLED) { |
| 1953 | /* Just select a new current key */ |
| 1954 | index = key_idx; |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 1955 | err = brcmf_fil_cmd_int_set(ifp, |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 1956 | BRCMF_C_SET_KEY_PRIMARY, index); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1957 | if (err) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1958 | brcmf_err("error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1959 | } |
| 1960 | done: |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 1961 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1962 | return err; |
| 1963 | } |
| 1964 | |
| 1965 | static s32 |
| 1966 | brcmf_add_keyext(struct wiphy *wiphy, struct net_device *ndev, |
| 1967 | u8 key_idx, const u8 *mac_addr, struct key_params *params) |
| 1968 | { |
Hante Meuleman | 992f606 | 2013-04-02 21:06:17 +0200 | [diff] [blame] | 1969 | struct brcmf_if *ifp = netdev_priv(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1970 | struct brcmf_wsec_key key; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1971 | s32 err = 0; |
Hante Meuleman | 992f606 | 2013-04-02 21:06:17 +0200 | [diff] [blame] | 1972 | u8 keybuf[8]; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1973 | |
| 1974 | memset(&key, 0, sizeof(key)); |
| 1975 | key.index = (u32) key_idx; |
| 1976 | /* Instead of bcast for ea address for default wep keys, |
| 1977 | driver needs it to be Null */ |
| 1978 | if (!is_multicast_ether_addr(mac_addr)) |
| 1979 | memcpy((char *)&key.ea, (void *)mac_addr, ETH_ALEN); |
| 1980 | key.len = (u32) params->key_len; |
| 1981 | /* check for key index change */ |
| 1982 | if (key.len == 0) { |
| 1983 | /* key delete */ |
Arend van Spriel | 2eaba7e | 2012-10-22 10:36:26 -0700 | [diff] [blame] | 1984 | err = send_key_to_dongle(ndev, &key); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1985 | if (err) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1986 | brcmf_err("key delete error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1987 | } else { |
| 1988 | if (key.len > sizeof(key.data)) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 1989 | brcmf_err("Invalid key length (%d)\n", key.len); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1990 | return -EINVAL; |
| 1991 | } |
| 1992 | |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 1993 | brcmf_dbg(CONN, "Setting the key index %d\n", key.index); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1994 | memcpy(key.data, params->key, key.len); |
| 1995 | |
Arend van Spriel | 967fe2c | 2014-03-15 17:18:21 +0100 | [diff] [blame] | 1996 | if (!brcmf_is_apmode(ifp->vif) && |
Hante Meuleman | 992f606 | 2013-04-02 21:06:17 +0200 | [diff] [blame] | 1997 | (params->cipher == WLAN_CIPHER_SUITE_TKIP)) { |
| 1998 | brcmf_dbg(CONN, "Swapping RX/TX MIC key\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 1999 | memcpy(keybuf, &key.data[24], sizeof(keybuf)); |
| 2000 | memcpy(&key.data[24], &key.data[16], sizeof(keybuf)); |
| 2001 | memcpy(&key.data[16], keybuf, sizeof(keybuf)); |
| 2002 | } |
| 2003 | |
| 2004 | /* if IW_ENCODE_EXT_RX_SEQ_VALID set */ |
| 2005 | if (params->seq && params->seq_len == 6) { |
| 2006 | /* rx iv */ |
| 2007 | u8 *ivptr; |
| 2008 | ivptr = (u8 *) params->seq; |
| 2009 | key.rxiv.hi = (ivptr[5] << 24) | (ivptr[4] << 16) | |
| 2010 | (ivptr[3] << 8) | ivptr[2]; |
| 2011 | key.rxiv.lo = (ivptr[1] << 8) | ivptr[0]; |
| 2012 | key.iv_initialized = true; |
| 2013 | } |
| 2014 | |
| 2015 | switch (params->cipher) { |
| 2016 | case WLAN_CIPHER_SUITE_WEP40: |
| 2017 | key.algo = CRYPTO_ALGO_WEP1; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2018 | brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_WEP40\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2019 | break; |
| 2020 | case WLAN_CIPHER_SUITE_WEP104: |
| 2021 | key.algo = CRYPTO_ALGO_WEP128; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2022 | brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_WEP104\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2023 | break; |
| 2024 | case WLAN_CIPHER_SUITE_TKIP: |
| 2025 | key.algo = CRYPTO_ALGO_TKIP; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2026 | brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_TKIP\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2027 | break; |
| 2028 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 2029 | key.algo = CRYPTO_ALGO_AES_CCM; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2030 | brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_AES_CMAC\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2031 | break; |
| 2032 | case WLAN_CIPHER_SUITE_CCMP: |
| 2033 | key.algo = CRYPTO_ALGO_AES_CCM; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2034 | brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_CCMP\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2035 | break; |
| 2036 | default: |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2037 | brcmf_err("Invalid cipher (0x%x)\n", params->cipher); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2038 | return -EINVAL; |
| 2039 | } |
Arend van Spriel | 2eaba7e | 2012-10-22 10:36:26 -0700 | [diff] [blame] | 2040 | err = send_key_to_dongle(ndev, &key); |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 2041 | if (err) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2042 | brcmf_err("wsec_key error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2043 | } |
| 2044 | return err; |
| 2045 | } |
| 2046 | |
| 2047 | static s32 |
| 2048 | brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, |
| 2049 | u8 key_idx, bool pairwise, const u8 *mac_addr, |
| 2050 | struct key_params *params) |
| 2051 | { |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 2052 | struct brcmf_if *ifp = netdev_priv(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2053 | struct brcmf_wsec_key key; |
| 2054 | s32 val; |
| 2055 | s32 wsec; |
| 2056 | s32 err = 0; |
| 2057 | u8 keybuf[8]; |
| 2058 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2059 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2060 | brcmf_dbg(CONN, "key index (%d)\n", key_idx); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 2061 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2062 | return -EIO; |
| 2063 | |
Daniel Kim | 787eb03 | 2014-01-29 15:32:23 +0100 | [diff] [blame] | 2064 | if (mac_addr && |
| 2065 | (params->cipher != WLAN_CIPHER_SUITE_WEP40) && |
| 2066 | (params->cipher != WLAN_CIPHER_SUITE_WEP104)) { |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2067 | brcmf_dbg(TRACE, "Exit"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2068 | return brcmf_add_keyext(wiphy, ndev, key_idx, mac_addr, params); |
| 2069 | } |
| 2070 | memset(&key, 0, sizeof(key)); |
| 2071 | |
| 2072 | key.len = (u32) params->key_len; |
| 2073 | key.index = (u32) key_idx; |
| 2074 | |
| 2075 | if (key.len > sizeof(key.data)) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2076 | brcmf_err("Too long key length (%u)\n", key.len); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2077 | err = -EINVAL; |
| 2078 | goto done; |
| 2079 | } |
| 2080 | memcpy(key.data, params->key, key.len); |
| 2081 | |
| 2082 | key.flags = BRCMF_PRIMARY_KEY; |
| 2083 | switch (params->cipher) { |
| 2084 | case WLAN_CIPHER_SUITE_WEP40: |
| 2085 | key.algo = CRYPTO_ALGO_WEP1; |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 2086 | val = WEP_ENABLED; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2087 | brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_WEP40\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2088 | break; |
| 2089 | case WLAN_CIPHER_SUITE_WEP104: |
| 2090 | key.algo = CRYPTO_ALGO_WEP128; |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 2091 | val = WEP_ENABLED; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2092 | brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_WEP104\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2093 | break; |
| 2094 | case WLAN_CIPHER_SUITE_TKIP: |
Arend van Spriel | 967fe2c | 2014-03-15 17:18:21 +0100 | [diff] [blame] | 2095 | if (!brcmf_is_apmode(ifp->vif)) { |
Hante Meuleman | 992f606 | 2013-04-02 21:06:17 +0200 | [diff] [blame] | 2096 | brcmf_dbg(CONN, "Swapping RX/TX MIC key\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2097 | memcpy(keybuf, &key.data[24], sizeof(keybuf)); |
| 2098 | memcpy(&key.data[24], &key.data[16], sizeof(keybuf)); |
| 2099 | memcpy(&key.data[16], keybuf, sizeof(keybuf)); |
| 2100 | } |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2101 | key.algo = CRYPTO_ALGO_TKIP; |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 2102 | val = TKIP_ENABLED; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2103 | brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_TKIP\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2104 | break; |
| 2105 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 2106 | key.algo = CRYPTO_ALGO_AES_CCM; |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 2107 | val = AES_ENABLED; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2108 | brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_AES_CMAC\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2109 | break; |
| 2110 | case WLAN_CIPHER_SUITE_CCMP: |
| 2111 | key.algo = CRYPTO_ALGO_AES_CCM; |
Hante Meuleman | f09d0c0 | 2012-09-27 14:17:48 +0200 | [diff] [blame] | 2112 | val = AES_ENABLED; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2113 | brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_CCMP\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2114 | break; |
| 2115 | default: |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2116 | brcmf_err("Invalid cipher (0x%x)\n", params->cipher); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2117 | err = -EINVAL; |
| 2118 | goto done; |
| 2119 | } |
| 2120 | |
Arend van Spriel | 2eaba7e | 2012-10-22 10:36:26 -0700 | [diff] [blame] | 2121 | err = send_key_to_dongle(ndev, &key); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2122 | if (err) |
| 2123 | goto done; |
| 2124 | |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 2125 | err = brcmf_fil_bsscfg_int_get(ifp, "wsec", &wsec); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2126 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2127 | brcmf_err("get wsec error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2128 | goto done; |
| 2129 | } |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2130 | wsec |= val; |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 2131 | err = brcmf_fil_bsscfg_int_set(ifp, "wsec", wsec); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2132 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2133 | brcmf_err("set wsec error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2134 | goto done; |
| 2135 | } |
| 2136 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2137 | done: |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2138 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2139 | return err; |
| 2140 | } |
| 2141 | |
| 2142 | static s32 |
| 2143 | brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, |
| 2144 | u8 key_idx, bool pairwise, const u8 *mac_addr) |
| 2145 | { |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 2146 | struct brcmf_if *ifp = netdev_priv(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2147 | struct brcmf_wsec_key key; |
| 2148 | s32 err = 0; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2149 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2150 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 2151 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2152 | return -EIO; |
| 2153 | |
Hante Meuleman | 256c374 | 2012-11-05 16:22:28 -0800 | [diff] [blame] | 2154 | if (key_idx >= DOT11_MAX_DEFAULT_KEYS) { |
| 2155 | /* we ignore this key index in this case */ |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2156 | brcmf_err("invalid key index (%d)\n", key_idx); |
Hante Meuleman | 256c374 | 2012-11-05 16:22:28 -0800 | [diff] [blame] | 2157 | return -EINVAL; |
| 2158 | } |
| 2159 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2160 | memset(&key, 0, sizeof(key)); |
| 2161 | |
| 2162 | key.index = (u32) key_idx; |
| 2163 | key.flags = BRCMF_PRIMARY_KEY; |
| 2164 | key.algo = CRYPTO_ALGO_OFF; |
| 2165 | |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2166 | brcmf_dbg(CONN, "key index (%d)\n", key_idx); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2167 | |
| 2168 | /* Set the new key/index */ |
Arend van Spriel | 2eaba7e | 2012-10-22 10:36:26 -0700 | [diff] [blame] | 2169 | err = send_key_to_dongle(ndev, &key); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2170 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2171 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2172 | return err; |
| 2173 | } |
| 2174 | |
| 2175 | static s32 |
| 2176 | brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev, |
| 2177 | u8 key_idx, bool pairwise, const u8 *mac_addr, void *cookie, |
| 2178 | void (*callback) (void *cookie, struct key_params * params)) |
| 2179 | { |
| 2180 | struct key_params params; |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 2181 | struct brcmf_if *ifp = netdev_priv(ndev); |
| 2182 | struct brcmf_cfg80211_profile *profile = &ifp->vif->profile; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2183 | struct brcmf_cfg80211_security *sec; |
| 2184 | s32 wsec; |
| 2185 | s32 err = 0; |
| 2186 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2187 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2188 | brcmf_dbg(CONN, "key index (%d)\n", key_idx); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 2189 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2190 | return -EIO; |
| 2191 | |
| 2192 | memset(¶ms, 0, sizeof(params)); |
| 2193 | |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 2194 | err = brcmf_fil_bsscfg_int_get(ifp, "wsec", &wsec); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2195 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2196 | brcmf_err("WLC_GET_WSEC error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2197 | /* Ignore this error, may happen during DISASSOC */ |
| 2198 | err = -EAGAIN; |
| 2199 | goto done; |
| 2200 | } |
Hante Meuleman | c5bf53a | 2013-04-02 21:06:19 +0200 | [diff] [blame] | 2201 | if (wsec & WEP_ENABLED) { |
Arend van Spriel | 06bb123 | 2012-09-27 14:17:56 +0200 | [diff] [blame] | 2202 | sec = &profile->sec; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2203 | if (sec->cipher_pairwise & WLAN_CIPHER_SUITE_WEP40) { |
| 2204 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2205 | brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_WEP40\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2206 | } else if (sec->cipher_pairwise & WLAN_CIPHER_SUITE_WEP104) { |
| 2207 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2208 | brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_WEP104\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2209 | } |
Hante Meuleman | c5bf53a | 2013-04-02 21:06:19 +0200 | [diff] [blame] | 2210 | } else if (wsec & TKIP_ENABLED) { |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2211 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2212 | brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_TKIP\n"); |
Hante Meuleman | c5bf53a | 2013-04-02 21:06:19 +0200 | [diff] [blame] | 2213 | } else if (wsec & AES_ENABLED) { |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2214 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2215 | brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_AES_CMAC\n"); |
Hante Meuleman | c5bf53a | 2013-04-02 21:06:19 +0200 | [diff] [blame] | 2216 | } else { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2217 | brcmf_err("Invalid algo (0x%x)\n", wsec); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2218 | err = -EINVAL; |
| 2219 | goto done; |
| 2220 | } |
| 2221 | callback(cookie, ¶ms); |
| 2222 | |
| 2223 | done: |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2224 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2225 | return err; |
| 2226 | } |
| 2227 | |
| 2228 | static s32 |
| 2229 | brcmf_cfg80211_config_default_mgmt_key(struct wiphy *wiphy, |
| 2230 | struct net_device *ndev, u8 key_idx) |
| 2231 | { |
Arend van Spriel | 647c9ae | 2012-12-05 15:26:01 +0100 | [diff] [blame] | 2232 | brcmf_dbg(INFO, "Not supported\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2233 | |
| 2234 | return -EOPNOTSUPP; |
| 2235 | } |
| 2236 | |
| 2237 | static s32 |
| 2238 | brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev, |
Johannes Berg | 3b3a016 | 2014-05-19 17:19:31 +0200 | [diff] [blame] | 2239 | const u8 *mac, struct station_info *sinfo) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2240 | { |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 2241 | struct brcmf_if *ifp = netdev_priv(ndev); |
| 2242 | struct brcmf_cfg80211_profile *profile = &ifp->vif->profile; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2243 | struct brcmf_scb_val_le scb_val; |
| 2244 | int rssi; |
| 2245 | s32 rate; |
| 2246 | s32 err = 0; |
Arend van Spriel | 06bb123 | 2012-09-27 14:17:56 +0200 | [diff] [blame] | 2247 | u8 *bssid = profile->bssid; |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 2248 | struct brcmf_sta_info_le sta_info_le; |
Hante Meuleman | 9ee66d1 | 2014-01-29 15:32:11 +0100 | [diff] [blame] | 2249 | u32 beacon_period; |
| 2250 | u32 dtim_period; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2251 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2252 | brcmf_dbg(TRACE, "Enter, MAC %pM\n", mac); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 2253 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2254 | return -EIO; |
| 2255 | |
Arend van Spriel | 967fe2c | 2014-03-15 17:18:21 +0100 | [diff] [blame] | 2256 | if (brcmf_is_apmode(ifp->vif)) { |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 2257 | memcpy(&sta_info_le, mac, ETH_ALEN); |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 2258 | err = brcmf_fil_iovar_data_get(ifp, "sta_info", |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 2259 | &sta_info_le, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 2260 | sizeof(sta_info_le)); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2261 | if (err < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2262 | brcmf_err("GET STA INFO failed, %d\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2263 | goto done; |
Hante Meuleman | 7f6c562 | 2012-08-30 10:05:37 +0200 | [diff] [blame] | 2264 | } |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2265 | sinfo->filled = STATION_INFO_INACTIVE_TIME; |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 2266 | sinfo->inactive_time = le32_to_cpu(sta_info_le.idle) * 1000; |
| 2267 | if (le32_to_cpu(sta_info_le.flags) & BRCMF_STA_ASSOC) { |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2268 | sinfo->filled |= STATION_INFO_CONNECTED_TIME; |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 2269 | sinfo->connected_time = le32_to_cpu(sta_info_le.in); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2270 | } |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2271 | brcmf_dbg(TRACE, "STA idle time : %d ms, connected time :%d sec\n", |
| 2272 | sinfo->inactive_time, sinfo->connected_time); |
Arend van Spriel | 967fe2c | 2014-03-15 17:18:21 +0100 | [diff] [blame] | 2273 | } else if (ifp->vif->wdev.iftype == NL80211_IFTYPE_STATION) { |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2274 | if (memcmp(mac, bssid, ETH_ALEN)) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2275 | brcmf_err("Wrong Mac address cfg_mac-%pM wl_bssid-%pM\n", |
| 2276 | mac, bssid); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2277 | err = -ENOENT; |
| 2278 | goto done; |
| 2279 | } |
| 2280 | /* Report the current tx rate */ |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 2281 | err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_RATE, &rate); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2282 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2283 | brcmf_err("Could not get rate (%d)\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2284 | goto done; |
| 2285 | } else { |
| 2286 | sinfo->filled |= STATION_INFO_TX_BITRATE; |
| 2287 | sinfo->txrate.legacy = rate * 5; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2288 | brcmf_dbg(CONN, "Rate %d Mbps\n", rate / 2); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2289 | } |
| 2290 | |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 2291 | if (test_bit(BRCMF_VIF_STATUS_CONNECTED, |
| 2292 | &ifp->vif->sme_state)) { |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2293 | memset(&scb_val, 0, sizeof(scb_val)); |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 2294 | err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_RSSI, |
| 2295 | &scb_val, sizeof(scb_val)); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2296 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2297 | brcmf_err("Could not get rssi (%d)\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2298 | goto done; |
| 2299 | } else { |
| 2300 | rssi = le32_to_cpu(scb_val.val); |
| 2301 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 2302 | sinfo->signal = rssi; |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2303 | brcmf_dbg(CONN, "RSSI %d dBm\n", rssi); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2304 | } |
Hante Meuleman | 9ee66d1 | 2014-01-29 15:32:11 +0100 | [diff] [blame] | 2305 | err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_BCNPRD, |
| 2306 | &beacon_period); |
| 2307 | if (err) { |
| 2308 | brcmf_err("Could not get beacon period (%d)\n", |
| 2309 | err); |
| 2310 | goto done; |
| 2311 | } else { |
| 2312 | sinfo->bss_param.beacon_interval = |
| 2313 | beacon_period; |
| 2314 | brcmf_dbg(CONN, "Beacon peroid %d\n", |
| 2315 | beacon_period); |
| 2316 | } |
| 2317 | err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_DTIMPRD, |
| 2318 | &dtim_period); |
| 2319 | if (err) { |
| 2320 | brcmf_err("Could not get DTIM period (%d)\n", |
| 2321 | err); |
| 2322 | goto done; |
| 2323 | } else { |
| 2324 | sinfo->bss_param.dtim_period = dtim_period; |
| 2325 | brcmf_dbg(CONN, "DTIM peroid %d\n", |
| 2326 | dtim_period); |
| 2327 | } |
| 2328 | sinfo->filled |= STATION_INFO_BSS_PARAM; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 2329 | } |
| 2330 | } else |
| 2331 | err = -EPERM; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2332 | done: |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2333 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2334 | return err; |
| 2335 | } |
| 2336 | |
| 2337 | static s32 |
| 2338 | brcmf_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *ndev, |
| 2339 | bool enabled, s32 timeout) |
| 2340 | { |
| 2341 | s32 pm; |
| 2342 | s32 err = 0; |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2343 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 2344 | struct brcmf_if *ifp = netdev_priv(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2345 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2346 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2347 | |
| 2348 | /* |
| 2349 | * Powersave enable/disable request is coming from the |
| 2350 | * cfg80211 even before the interface is up. In that |
| 2351 | * scenario, driver will be storing the power save |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2352 | * preference in cfg struct to apply this to |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2353 | * FW later while initializing the dongle |
| 2354 | */ |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2355 | cfg->pwr_save = enabled; |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 2356 | if (!check_vif_up(ifp->vif)) { |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2357 | |
Arend van Spriel | 647c9ae | 2012-12-05 15:26:01 +0100 | [diff] [blame] | 2358 | brcmf_dbg(INFO, "Device is not ready, storing the value in cfg_info struct\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2359 | goto done; |
| 2360 | } |
| 2361 | |
| 2362 | pm = enabled ? PM_FAST : PM_OFF; |
Hante Meuleman | 102fd0d | 2013-05-27 21:09:59 +0200 | [diff] [blame] | 2363 | /* Do not enable the power save after assoc if it is a p2p interface */ |
| 2364 | if (ifp->vif->wdev.iftype == NL80211_IFTYPE_P2P_CLIENT) { |
| 2365 | brcmf_dbg(INFO, "Do not enable power save for P2P clients\n"); |
| 2366 | pm = PM_OFF; |
| 2367 | } |
Arend van Spriel | 647c9ae | 2012-12-05 15:26:01 +0100 | [diff] [blame] | 2368 | brcmf_dbg(INFO, "power save %s\n", (pm ? "enabled" : "disabled")); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2369 | |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 2370 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_PM, pm); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2371 | if (err) { |
| 2372 | if (err == -ENODEV) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2373 | brcmf_err("net_device is not ready yet\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2374 | else |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2375 | brcmf_err("error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2376 | } |
| 2377 | done: |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2378 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2379 | return err; |
| 2380 | } |
| 2381 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2382 | static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_info *cfg, |
Roland Vossen | d34bf64 | 2011-10-18 14:03:01 +0200 | [diff] [blame] | 2383 | struct brcmf_bss_info_le *bi) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2384 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2385 | struct wiphy *wiphy = cfg_to_wiphy(cfg); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2386 | struct ieee80211_channel *notify_channel; |
| 2387 | struct cfg80211_bss *bss; |
| 2388 | struct ieee80211_supported_band *band; |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 2389 | struct brcmu_chan ch; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2390 | u16 channel; |
| 2391 | u32 freq; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2392 | u16 notify_capability; |
| 2393 | u16 notify_interval; |
| 2394 | u8 *notify_ie; |
| 2395 | size_t notify_ielen; |
| 2396 | s32 notify_signal; |
| 2397 | |
| 2398 | if (le32_to_cpu(bi->length) > WL_BSS_INFO_MAX) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2399 | brcmf_err("Bss info is larger than buffer. Discarding\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2400 | return 0; |
| 2401 | } |
| 2402 | |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 2403 | if (!bi->ctl_ch) { |
| 2404 | ch.chspec = le16_to_cpu(bi->chanspec); |
| 2405 | cfg->d11inf.decchspec(&ch); |
| 2406 | bi->ctl_ch = ch.chnum; |
| 2407 | } |
| 2408 | channel = bi->ctl_ch; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2409 | |
| 2410 | if (channel <= CH_MAX_2G_CHANNEL) |
| 2411 | band = wiphy->bands[IEEE80211_BAND_2GHZ]; |
| 2412 | else |
| 2413 | band = wiphy->bands[IEEE80211_BAND_5GHZ]; |
| 2414 | |
| 2415 | freq = ieee80211_channel_to_frequency(channel, band->band); |
| 2416 | notify_channel = ieee80211_get_channel(wiphy, freq); |
| 2417 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2418 | notify_capability = le16_to_cpu(bi->capability); |
| 2419 | notify_interval = le16_to_cpu(bi->beacon_period); |
| 2420 | notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset); |
| 2421 | notify_ielen = le32_to_cpu(bi->ie_length); |
| 2422 | notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100; |
| 2423 | |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2424 | brcmf_dbg(CONN, "bssid: %pM\n", bi->BSSID); |
| 2425 | brcmf_dbg(CONN, "Channel: %d(%d)\n", channel, freq); |
| 2426 | brcmf_dbg(CONN, "Capability: %X\n", notify_capability); |
| 2427 | brcmf_dbg(CONN, "Beacon interval: %d\n", notify_interval); |
| 2428 | brcmf_dbg(CONN, "Signal: %d\n", notify_signal); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2429 | |
| 2430 | bss = cfg80211_inform_bss(wiphy, notify_channel, (const u8 *)bi->BSSID, |
Johannes Berg | 8e6cffb | 2012-03-13 13:57:03 +0100 | [diff] [blame] | 2431 | 0, notify_capability, notify_interval, notify_ie, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2432 | notify_ielen, notify_signal, GFP_KERNEL); |
| 2433 | |
Franky Lin | e78946e | 2011-11-10 20:30:34 +0100 | [diff] [blame] | 2434 | if (!bss) |
| 2435 | return -ENOMEM; |
| 2436 | |
Johannes Berg | 5b112d3 | 2013-02-01 01:49:58 +0100 | [diff] [blame] | 2437 | cfg80211_put_bss(wiphy, bss); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2438 | |
Peter Senna Tschudin | 12f3237 | 2014-05-31 10:14:06 -0300 | [diff] [blame^] | 2439 | return 0; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2440 | } |
| 2441 | |
Roland Vossen | 6f09be0 | 2011-10-18 14:03:02 +0200 | [diff] [blame] | 2442 | static struct brcmf_bss_info_le * |
| 2443 | next_bss_le(struct brcmf_scan_results *list, struct brcmf_bss_info_le *bss) |
| 2444 | { |
| 2445 | if (bss == NULL) |
| 2446 | return list->bss_info_le; |
| 2447 | return (struct brcmf_bss_info_le *)((unsigned long)bss + |
| 2448 | le32_to_cpu(bss->length)); |
| 2449 | } |
| 2450 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2451 | static s32 brcmf_inform_bss(struct brcmf_cfg80211_info *cfg) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2452 | { |
| 2453 | struct brcmf_scan_results *bss_list; |
Roland Vossen | d34bf64 | 2011-10-18 14:03:01 +0200 | [diff] [blame] | 2454 | struct brcmf_bss_info_le *bi = NULL; /* must be initialized */ |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2455 | s32 err = 0; |
| 2456 | int i; |
| 2457 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2458 | bss_list = cfg->bss_list; |
Arend van Spriel | 0ecd816 | 2012-11-05 16:22:11 -0800 | [diff] [blame] | 2459 | if (bss_list->count != 0 && |
| 2460 | bss_list->version != BRCMF_BSS_INFO_VERSION) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2461 | brcmf_err("Version %d != WL_BSS_INFO_VERSION\n", |
| 2462 | bss_list->version); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2463 | return -EOPNOTSUPP; |
| 2464 | } |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 2465 | brcmf_dbg(SCAN, "scanned AP count (%d)\n", bss_list->count); |
Hante Meuleman | f0799895 | 2012-11-05 16:22:13 -0800 | [diff] [blame] | 2466 | for (i = 0; i < bss_list->count; i++) { |
Roland Vossen | 6f09be0 | 2011-10-18 14:03:02 +0200 | [diff] [blame] | 2467 | bi = next_bss_le(bss_list, bi); |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2468 | err = brcmf_inform_single_bss(cfg, bi); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2469 | if (err) |
| 2470 | break; |
| 2471 | } |
| 2472 | return err; |
| 2473 | } |
| 2474 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2475 | static s32 wl_inform_ibss(struct brcmf_cfg80211_info *cfg, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2476 | struct net_device *ndev, const u8 *bssid) |
| 2477 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2478 | struct wiphy *wiphy = cfg_to_wiphy(cfg); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2479 | struct ieee80211_channel *notify_channel; |
Roland Vossen | d34bf64 | 2011-10-18 14:03:01 +0200 | [diff] [blame] | 2480 | struct brcmf_bss_info_le *bi = NULL; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2481 | struct ieee80211_supported_band *band; |
Franky Lin | e78946e | 2011-11-10 20:30:34 +0100 | [diff] [blame] | 2482 | struct cfg80211_bss *bss; |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 2483 | struct brcmu_chan ch; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2484 | u8 *buf = NULL; |
| 2485 | s32 err = 0; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2486 | u32 freq; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2487 | u16 notify_capability; |
| 2488 | u16 notify_interval; |
| 2489 | u8 *notify_ie; |
| 2490 | size_t notify_ielen; |
| 2491 | s32 notify_signal; |
| 2492 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2493 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2494 | |
| 2495 | buf = kzalloc(WL_BSS_INFO_MAX, GFP_KERNEL); |
| 2496 | if (buf == NULL) { |
| 2497 | err = -ENOMEM; |
| 2498 | goto CleanUp; |
| 2499 | } |
| 2500 | |
| 2501 | *(__le32 *)buf = cpu_to_le32(WL_BSS_INFO_MAX); |
| 2502 | |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 2503 | err = brcmf_fil_cmd_data_get(netdev_priv(ndev), BRCMF_C_GET_BSS_INFO, |
| 2504 | buf, WL_BSS_INFO_MAX); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2505 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2506 | brcmf_err("WLC_GET_BSS_INFO failed: %d\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2507 | goto CleanUp; |
| 2508 | } |
| 2509 | |
Roland Vossen | d34bf64 | 2011-10-18 14:03:01 +0200 | [diff] [blame] | 2510 | bi = (struct brcmf_bss_info_le *)(buf + 4); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2511 | |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 2512 | ch.chspec = le16_to_cpu(bi->chanspec); |
| 2513 | cfg->d11inf.decchspec(&ch); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2514 | |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 2515 | if (ch.band == BRCMU_CHAN_BAND_2G) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2516 | band = wiphy->bands[IEEE80211_BAND_2GHZ]; |
| 2517 | else |
| 2518 | band = wiphy->bands[IEEE80211_BAND_5GHZ]; |
| 2519 | |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 2520 | freq = ieee80211_channel_to_frequency(ch.chnum, band->band); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2521 | notify_channel = ieee80211_get_channel(wiphy, freq); |
| 2522 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2523 | notify_capability = le16_to_cpu(bi->capability); |
| 2524 | notify_interval = le16_to_cpu(bi->beacon_period); |
| 2525 | notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset); |
| 2526 | notify_ielen = le32_to_cpu(bi->ie_length); |
| 2527 | notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100; |
| 2528 | |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 2529 | brcmf_dbg(CONN, "channel: %d(%d)\n", ch.chnum, freq); |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2530 | brcmf_dbg(CONN, "capability: %X\n", notify_capability); |
| 2531 | brcmf_dbg(CONN, "beacon interval: %d\n", notify_interval); |
| 2532 | brcmf_dbg(CONN, "signal: %d\n", notify_signal); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2533 | |
Franky Lin | e78946e | 2011-11-10 20:30:34 +0100 | [diff] [blame] | 2534 | bss = cfg80211_inform_bss(wiphy, notify_channel, bssid, |
Johannes Berg | 8e6cffb | 2012-03-13 13:57:03 +0100 | [diff] [blame] | 2535 | 0, notify_capability, notify_interval, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2536 | notify_ie, notify_ielen, notify_signal, GFP_KERNEL); |
| 2537 | |
Franky Lin | e78946e | 2011-11-10 20:30:34 +0100 | [diff] [blame] | 2538 | if (!bss) { |
| 2539 | err = -ENOMEM; |
| 2540 | goto CleanUp; |
| 2541 | } |
| 2542 | |
Johannes Berg | 5b112d3 | 2013-02-01 01:49:58 +0100 | [diff] [blame] | 2543 | cfg80211_put_bss(wiphy, bss); |
Franky Lin | e78946e | 2011-11-10 20:30:34 +0100 | [diff] [blame] | 2544 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2545 | CleanUp: |
| 2546 | |
| 2547 | kfree(buf); |
| 2548 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2549 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2550 | |
| 2551 | return err; |
| 2552 | } |
| 2553 | |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 2554 | static s32 brcmf_update_bss_info(struct brcmf_cfg80211_info *cfg, |
| 2555 | struct brcmf_if *ifp) |
Alwin Beukers | f8e4b41 | 2011-10-12 20:51:28 +0200 | [diff] [blame] | 2556 | { |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 2557 | struct brcmf_cfg80211_profile *profile = ndev_to_prof(ifp->ndev); |
Roland Vossen | d34bf64 | 2011-10-18 14:03:01 +0200 | [diff] [blame] | 2558 | struct brcmf_bss_info_le *bi; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2559 | struct brcmf_ssid *ssid; |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 2560 | const struct brcmf_tlv *tim; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2561 | u16 beacon_interval; |
| 2562 | u8 dtim_period; |
| 2563 | size_t ie_len; |
| 2564 | u8 *ie; |
| 2565 | s32 err = 0; |
| 2566 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2567 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | 128ce3b | 2012-11-28 21:44:12 +0100 | [diff] [blame] | 2568 | if (brcmf_is_ibssmode(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2569 | return err; |
| 2570 | |
Arend van Spriel | 06bb123 | 2012-09-27 14:17:56 +0200 | [diff] [blame] | 2571 | ssid = &profile->ssid; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2572 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2573 | *(__le32 *)cfg->extra_buf = cpu_to_le32(WL_EXTRA_BUF_MAX); |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 2574 | err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_BSS_INFO, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 2575 | cfg->extra_buf, WL_EXTRA_BUF_MAX); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2576 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2577 | brcmf_err("Could not get bss info %d\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2578 | goto update_bss_info_out; |
| 2579 | } |
| 2580 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2581 | bi = (struct brcmf_bss_info_le *)(cfg->extra_buf + 4); |
| 2582 | err = brcmf_inform_single_bss(cfg, bi); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2583 | if (err) |
| 2584 | goto update_bss_info_out; |
| 2585 | |
| 2586 | ie = ((u8 *)bi) + le16_to_cpu(bi->ie_offset); |
| 2587 | ie_len = le32_to_cpu(bi->ie_length); |
| 2588 | beacon_interval = le16_to_cpu(bi->beacon_period); |
| 2589 | |
Alwin Beukers | f8e4b41 | 2011-10-12 20:51:28 +0200 | [diff] [blame] | 2590 | tim = brcmf_parse_tlvs(ie, ie_len, WLAN_EID_TIM); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2591 | if (tim) |
| 2592 | dtim_period = tim->data[1]; |
| 2593 | else { |
| 2594 | /* |
| 2595 | * active scan was done so we could not get dtim |
| 2596 | * information out of probe response. |
| 2597 | * so we speficially query dtim information to dongle. |
| 2598 | */ |
| 2599 | u32 var; |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 2600 | err = brcmf_fil_iovar_int_get(ifp, "dtim_assoc", &var); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2601 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2602 | brcmf_err("wl dtim_assoc failed (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2603 | goto update_bss_info_out; |
| 2604 | } |
| 2605 | dtim_period = (u8)var; |
| 2606 | } |
| 2607 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2608 | update_bss_info_out: |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2609 | brcmf_dbg(TRACE, "Exit"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2610 | return err; |
| 2611 | } |
| 2612 | |
Hante Meuleman | 18e2f61 | 2013-02-08 15:53:49 +0100 | [diff] [blame] | 2613 | void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2614 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2615 | struct escan_info *escan = &cfg->escan_info; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2616 | |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 2617 | set_bit(BRCMF_SCAN_STATUS_ABORT, &cfg->scan_status); |
Hante Meuleman | f0799895 | 2012-11-05 16:22:13 -0800 | [diff] [blame] | 2618 | if (cfg->scan_request) { |
Arend van Spriel | 108a4be | 2012-09-19 22:21:07 +0200 | [diff] [blame] | 2619 | escan->escan_state = WL_ESCAN_STATE_IDLE; |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 2620 | brcmf_notify_escan_complete(cfg, escan->ifp, true, true); |
Arend van Spriel | 108a4be | 2012-09-19 22:21:07 +0200 | [diff] [blame] | 2621 | } |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 2622 | clear_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status); |
| 2623 | clear_bit(BRCMF_SCAN_STATUS_ABORT, &cfg->scan_status); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2624 | } |
| 2625 | |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2626 | static void brcmf_cfg80211_escan_timeout_worker(struct work_struct *work) |
| 2627 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2628 | struct brcmf_cfg80211_info *cfg = |
| 2629 | container_of(work, struct brcmf_cfg80211_info, |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2630 | escan_timeout_work); |
| 2631 | |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 2632 | brcmf_notify_escan_complete(cfg, cfg->escan_info.ifp, true, true); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2633 | } |
| 2634 | |
| 2635 | static void brcmf_escan_timeout(unsigned long data) |
| 2636 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2637 | struct brcmf_cfg80211_info *cfg = |
| 2638 | (struct brcmf_cfg80211_info *)data; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2639 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2640 | if (cfg->scan_request) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2641 | brcmf_err("timer expired\n"); |
Hante Meuleman | f0799895 | 2012-11-05 16:22:13 -0800 | [diff] [blame] | 2642 | schedule_work(&cfg->escan_timeout_work); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2643 | } |
| 2644 | } |
| 2645 | |
| 2646 | static s32 |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 2647 | brcmf_compare_update_same_bss(struct brcmf_cfg80211_info *cfg, |
| 2648 | struct brcmf_bss_info_le *bss, |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2649 | struct brcmf_bss_info_le *bss_info_le) |
| 2650 | { |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 2651 | struct brcmu_chan ch_bss, ch_bss_info_le; |
| 2652 | |
| 2653 | ch_bss.chspec = le16_to_cpu(bss->chanspec); |
| 2654 | cfg->d11inf.decchspec(&ch_bss); |
| 2655 | ch_bss_info_le.chspec = le16_to_cpu(bss_info_le->chanspec); |
| 2656 | cfg->d11inf.decchspec(&ch_bss_info_le); |
| 2657 | |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2658 | if (!memcmp(&bss_info_le->BSSID, &bss->BSSID, ETH_ALEN) && |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 2659 | ch_bss.band == ch_bss_info_le.band && |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2660 | bss_info_le->SSID_len == bss->SSID_len && |
| 2661 | !memcmp(bss_info_le->SSID, bss->SSID, bss_info_le->SSID_len)) { |
Arend van Spriel | 6f5838a | 2013-11-29 12:25:19 +0100 | [diff] [blame] | 2662 | if ((bss->flags & BRCMF_BSS_RSSI_ON_CHANNEL) == |
| 2663 | (bss_info_le->flags & BRCMF_BSS_RSSI_ON_CHANNEL)) { |
Arend van Spriel | 029591f | 2012-09-19 22:21:06 +0200 | [diff] [blame] | 2664 | s16 bss_rssi = le16_to_cpu(bss->RSSI); |
| 2665 | s16 bss_info_rssi = le16_to_cpu(bss_info_le->RSSI); |
| 2666 | |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2667 | /* preserve max RSSI if the measurements are |
| 2668 | * both on-channel or both off-channel |
| 2669 | */ |
Arend van Spriel | 029591f | 2012-09-19 22:21:06 +0200 | [diff] [blame] | 2670 | if (bss_info_rssi > bss_rssi) |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2671 | bss->RSSI = bss_info_le->RSSI; |
Arend van Spriel | 6f5838a | 2013-11-29 12:25:19 +0100 | [diff] [blame] | 2672 | } else if ((bss->flags & BRCMF_BSS_RSSI_ON_CHANNEL) && |
| 2673 | (bss_info_le->flags & BRCMF_BSS_RSSI_ON_CHANNEL) == 0) { |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2674 | /* preserve the on-channel rssi measurement |
| 2675 | * if the new measurement is off channel |
| 2676 | */ |
| 2677 | bss->RSSI = bss_info_le->RSSI; |
Arend van Spriel | 6f5838a | 2013-11-29 12:25:19 +0100 | [diff] [blame] | 2678 | bss->flags |= BRCMF_BSS_RSSI_ON_CHANNEL; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2679 | } |
| 2680 | return 1; |
| 2681 | } |
| 2682 | return 0; |
| 2683 | } |
| 2684 | |
| 2685 | static s32 |
Arend van Spriel | 1993732 | 2012-11-05 16:22:32 -0800 | [diff] [blame] | 2686 | brcmf_cfg80211_escan_handler(struct brcmf_if *ifp, |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2687 | const struct brcmf_event_msg *e, void *data) |
| 2688 | { |
Arend van Spriel | 1993732 | 2012-11-05 16:22:32 -0800 | [diff] [blame] | 2689 | struct brcmf_cfg80211_info *cfg = ifp->drvr->config; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2690 | s32 status; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2691 | struct brcmf_escan_result_le *escan_result_le; |
| 2692 | struct brcmf_bss_info_le *bss_info_le; |
| 2693 | struct brcmf_bss_info_le *bss = NULL; |
| 2694 | u32 bi_length; |
| 2695 | struct brcmf_scan_results *list; |
| 2696 | u32 i; |
Arend van Spriel | 97ed15c | 2012-09-13 21:12:06 +0200 | [diff] [blame] | 2697 | bool aborted; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2698 | |
Arend van Spriel | 5c36b99 | 2012-11-14 18:46:05 -0800 | [diff] [blame] | 2699 | status = e->status; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2700 | |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 2701 | if (!test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status)) { |
| 2702 | brcmf_err("scan not ready, bssidx=%d\n", ifp->bssidx); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2703 | return -EPERM; |
| 2704 | } |
| 2705 | |
| 2706 | if (status == BRCMF_E_STATUS_PARTIAL) { |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 2707 | brcmf_dbg(SCAN, "ESCAN Partial result\n"); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2708 | escan_result_le = (struct brcmf_escan_result_le *) data; |
| 2709 | if (!escan_result_le) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2710 | brcmf_err("Invalid escan result (NULL pointer)\n"); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2711 | goto exit; |
| 2712 | } |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2713 | if (le16_to_cpu(escan_result_le->bss_count) != 1) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2714 | brcmf_err("Invalid bss_count %d: ignoring\n", |
| 2715 | escan_result_le->bss_count); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2716 | goto exit; |
| 2717 | } |
| 2718 | bss_info_le = &escan_result_le->bss_info_le; |
| 2719 | |
Hante Meuleman | 6eda4e2 | 2013-02-08 15:54:02 +0100 | [diff] [blame] | 2720 | if (brcmf_p2p_scan_finding_common_channel(cfg, bss_info_le)) |
| 2721 | goto exit; |
| 2722 | |
| 2723 | if (!cfg->scan_request) { |
| 2724 | brcmf_dbg(SCAN, "result without cfg80211 request\n"); |
| 2725 | goto exit; |
| 2726 | } |
| 2727 | |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2728 | bi_length = le32_to_cpu(bss_info_le->length); |
| 2729 | if (bi_length != (le32_to_cpu(escan_result_le->buflen) - |
| 2730 | WL_ESCAN_RESULTS_FIXED_SIZE)) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2731 | brcmf_err("Invalid bss_info length %d: ignoring\n", |
| 2732 | bi_length); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2733 | goto exit; |
| 2734 | } |
| 2735 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2736 | if (!(cfg_to_wiphy(cfg)->interface_modes & |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2737 | BIT(NL80211_IFTYPE_ADHOC))) { |
| 2738 | if (le16_to_cpu(bss_info_le->capability) & |
| 2739 | WLAN_CAPABILITY_IBSS) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2740 | brcmf_err("Ignoring IBSS result\n"); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2741 | goto exit; |
| 2742 | } |
| 2743 | } |
| 2744 | |
| 2745 | list = (struct brcmf_scan_results *) |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2746 | cfg->escan_info.escan_buf; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2747 | if (bi_length > WL_ESCAN_BUF_SIZE - list->buflen) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 2748 | brcmf_err("Buffer is too small: ignoring\n"); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2749 | goto exit; |
| 2750 | } |
| 2751 | |
| 2752 | for (i = 0; i < list->count; i++) { |
| 2753 | bss = bss ? (struct brcmf_bss_info_le *) |
| 2754 | ((unsigned char *)bss + |
| 2755 | le32_to_cpu(bss->length)) : list->bss_info_le; |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 2756 | if (brcmf_compare_update_same_bss(cfg, bss, |
| 2757 | bss_info_le)) |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2758 | goto exit; |
| 2759 | } |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2760 | memcpy(&(cfg->escan_info.escan_buf[list->buflen]), |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2761 | bss_info_le, bi_length); |
| 2762 | list->version = le32_to_cpu(bss_info_le->version); |
| 2763 | list->buflen += bi_length; |
| 2764 | list->count++; |
| 2765 | } else { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2766 | cfg->escan_info.escan_state = WL_ESCAN_STATE_IDLE; |
Hante Meuleman | 6eda4e2 | 2013-02-08 15:54:02 +0100 | [diff] [blame] | 2767 | if (brcmf_p2p_scan_finding_common_channel(cfg, NULL)) |
| 2768 | goto exit; |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2769 | if (cfg->scan_request) { |
| 2770 | cfg->bss_list = (struct brcmf_scan_results *) |
| 2771 | cfg->escan_info.escan_buf; |
| 2772 | brcmf_inform_bss(cfg); |
Arend van Spriel | 97ed15c | 2012-09-13 21:12:06 +0200 | [diff] [blame] | 2773 | aborted = status != BRCMF_E_STATUS_SUCCESS; |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 2774 | brcmf_notify_escan_complete(cfg, ifp, aborted, |
Arend van Spriel | 97ed15c | 2012-09-13 21:12:06 +0200 | [diff] [blame] | 2775 | false); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2776 | } else |
Hante Meuleman | 6eda4e2 | 2013-02-08 15:54:02 +0100 | [diff] [blame] | 2777 | brcmf_dbg(SCAN, "Ignored scan complete result 0x%x\n", |
| 2778 | status); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2779 | } |
| 2780 | exit: |
Peter Senna Tschudin | 12f3237 | 2014-05-31 10:14:06 -0300 | [diff] [blame^] | 2781 | return 0; |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2782 | } |
| 2783 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2784 | static void brcmf_init_escan(struct brcmf_cfg80211_info *cfg) |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2785 | { |
Arend van Spriel | 5c36b99 | 2012-11-14 18:46:05 -0800 | [diff] [blame] | 2786 | brcmf_fweh_register(cfg->pub, BRCMF_E_ESCAN_RESULT, |
| 2787 | brcmf_cfg80211_escan_handler); |
Hante Meuleman | f0799895 | 2012-11-05 16:22:13 -0800 | [diff] [blame] | 2788 | cfg->escan_info.escan_state = WL_ESCAN_STATE_IDLE; |
| 2789 | /* Init scan_timeout timer */ |
| 2790 | init_timer(&cfg->escan_timeout); |
| 2791 | cfg->escan_timeout.data = (unsigned long) cfg; |
| 2792 | cfg->escan_timeout.function = brcmf_escan_timeout; |
| 2793 | INIT_WORK(&cfg->escan_timeout_work, |
| 2794 | brcmf_cfg80211_escan_timeout_worker); |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 2795 | } |
| 2796 | |
Alexandre Oliva | 5addc0d | 2012-01-16 14:00:12 -0500 | [diff] [blame] | 2797 | static __always_inline void brcmf_delay(u32 ms) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2798 | { |
| 2799 | if (ms < 1000 / HZ) { |
| 2800 | cond_resched(); |
| 2801 | mdelay(ms); |
| 2802 | } else { |
| 2803 | msleep(ms); |
| 2804 | } |
| 2805 | } |
| 2806 | |
| 2807 | static s32 brcmf_cfg80211_resume(struct wiphy *wiphy) |
| 2808 | { |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2809 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2810 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2811 | return 0; |
| 2812 | } |
| 2813 | |
| 2814 | static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy, |
| 2815 | struct cfg80211_wowlan *wow) |
| 2816 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2817 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
| 2818 | struct net_device *ndev = cfg_to_ndev(cfg); |
Arend van Spriel | 7d64107 | 2012-10-22 13:55:39 -0700 | [diff] [blame] | 2819 | struct brcmf_cfg80211_vif *vif; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2820 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2821 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2822 | |
| 2823 | /* |
Arend van Spriel | 7d64107 | 2012-10-22 13:55:39 -0700 | [diff] [blame] | 2824 | * if the primary net_device is not READY there is nothing |
| 2825 | * we can do but pray resume goes smoothly. |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2826 | */ |
Arend van Spriel | 7d64107 | 2012-10-22 13:55:39 -0700 | [diff] [blame] | 2827 | vif = ((struct brcmf_if *)netdev_priv(ndev))->vif; |
| 2828 | if (!check_vif_up(vif)) |
| 2829 | goto exit; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2830 | |
Arend van Spriel | 7d64107 | 2012-10-22 13:55:39 -0700 | [diff] [blame] | 2831 | list_for_each_entry(vif, &cfg->vif_list, list) { |
| 2832 | if (!test_bit(BRCMF_VIF_STATUS_READY, &vif->sme_state)) |
| 2833 | continue; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2834 | /* |
Arend van Spriel | 7d64107 | 2012-10-22 13:55:39 -0700 | [diff] [blame] | 2835 | * While going to suspend if associated with AP disassociate |
| 2836 | * from AP to save power while system is in suspended state |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2837 | */ |
Arend van Spriel | 903e0ee | 2012-11-28 21:44:11 +0100 | [diff] [blame] | 2838 | brcmf_link_down(vif); |
Arend van Spriel | 7d64107 | 2012-10-22 13:55:39 -0700 | [diff] [blame] | 2839 | |
Arend van Spriel | 903e0ee | 2012-11-28 21:44:11 +0100 | [diff] [blame] | 2840 | /* Make sure WPA_Supplicant receives all the event |
| 2841 | * generated due to DISASSOC call to the fw to keep |
| 2842 | * the state fw and WPA_Supplicant state consistent |
| 2843 | */ |
| 2844 | brcmf_delay(500); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2845 | } |
| 2846 | |
Arend van Spriel | 7d64107 | 2012-10-22 13:55:39 -0700 | [diff] [blame] | 2847 | /* end any scanning */ |
| 2848 | if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status)) |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2849 | brcmf_abort_scanning(cfg); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2850 | |
| 2851 | /* Turn off watchdog timer */ |
Arend van Spriel | f96aa07 | 2013-04-05 10:57:48 +0200 | [diff] [blame] | 2852 | brcmf_set_mpc(netdev_priv(ndev), 1); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2853 | |
Arend van Spriel | 7d64107 | 2012-10-22 13:55:39 -0700 | [diff] [blame] | 2854 | exit: |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2855 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 7d64107 | 2012-10-22 13:55:39 -0700 | [diff] [blame] | 2856 | /* clear any scanning activity */ |
| 2857 | cfg->scan_status = 0; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2858 | return 0; |
| 2859 | } |
| 2860 | |
| 2861 | static __used s32 |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2862 | brcmf_update_pmklist(struct net_device *ndev, |
| 2863 | struct brcmf_cfg80211_pmk_list *pmk_list, s32 err) |
| 2864 | { |
| 2865 | int i, j; |
Arend van Spriel | 40c8e95 | 2011-10-12 20:51:20 +0200 | [diff] [blame] | 2866 | int pmkid_len; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2867 | |
Arend van Spriel | 40c8e95 | 2011-10-12 20:51:20 +0200 | [diff] [blame] | 2868 | pmkid_len = le32_to_cpu(pmk_list->pmkids.npmkid); |
| 2869 | |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2870 | brcmf_dbg(CONN, "No of elements %d\n", pmkid_len); |
Arend van Spriel | 40c8e95 | 2011-10-12 20:51:20 +0200 | [diff] [blame] | 2871 | for (i = 0; i < pmkid_len; i++) { |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2872 | brcmf_dbg(CONN, "PMKID[%d]: %pM =\n", i, |
| 2873 | &pmk_list->pmkids.pmkid[i].BSSID); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2874 | for (j = 0; j < WLAN_PMKID_LEN; j++) |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2875 | brcmf_dbg(CONN, "%02x\n", |
| 2876 | pmk_list->pmkids.pmkid[i].PMKID[j]); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2877 | } |
| 2878 | |
| 2879 | if (!err) |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 2880 | brcmf_fil_iovar_data_set(netdev_priv(ndev), "pmkid_info", |
| 2881 | (char *)pmk_list, sizeof(*pmk_list)); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2882 | |
| 2883 | return err; |
| 2884 | } |
| 2885 | |
| 2886 | static s32 |
| 2887 | brcmf_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *ndev, |
| 2888 | struct cfg80211_pmksa *pmksa) |
| 2889 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2890 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 2891 | struct brcmf_if *ifp = netdev_priv(ndev); |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2892 | struct pmkid_list *pmkids = &cfg->pmk_list->pmkids; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2893 | s32 err = 0; |
| 2894 | int i; |
Arend van Spriel | 40c8e95 | 2011-10-12 20:51:20 +0200 | [diff] [blame] | 2895 | int pmkid_len; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2896 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2897 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 2898 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2899 | return -EIO; |
| 2900 | |
Arend van Spriel | 40c8e95 | 2011-10-12 20:51:20 +0200 | [diff] [blame] | 2901 | pmkid_len = le32_to_cpu(pmkids->npmkid); |
| 2902 | for (i = 0; i < pmkid_len; i++) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2903 | if (!memcmp(pmksa->bssid, pmkids->pmkid[i].BSSID, ETH_ALEN)) |
| 2904 | break; |
| 2905 | if (i < WL_NUM_PMKIDS_MAX) { |
| 2906 | memcpy(pmkids->pmkid[i].BSSID, pmksa->bssid, ETH_ALEN); |
| 2907 | memcpy(pmkids->pmkid[i].PMKID, pmksa->pmkid, WLAN_PMKID_LEN); |
Arend van Spriel | 40c8e95 | 2011-10-12 20:51:20 +0200 | [diff] [blame] | 2908 | if (i == pmkid_len) { |
| 2909 | pmkid_len++; |
| 2910 | pmkids->npmkid = cpu_to_le32(pmkid_len); |
| 2911 | } |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2912 | } else |
| 2913 | err = -EINVAL; |
| 2914 | |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2915 | brcmf_dbg(CONN, "set_pmksa,IW_PMKSA_ADD - PMKID: %pM =\n", |
| 2916 | pmkids->pmkid[pmkid_len].BSSID); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2917 | for (i = 0; i < WLAN_PMKID_LEN; i++) |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2918 | brcmf_dbg(CONN, "%02x\n", pmkids->pmkid[pmkid_len].PMKID[i]); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2919 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2920 | err = brcmf_update_pmklist(ndev, cfg->pmk_list, err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2921 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2922 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2923 | return err; |
| 2924 | } |
| 2925 | |
| 2926 | static s32 |
| 2927 | brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *ndev, |
| 2928 | struct cfg80211_pmksa *pmksa) |
| 2929 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2930 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 2931 | struct brcmf_if *ifp = netdev_priv(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2932 | struct pmkid_list pmkid; |
| 2933 | s32 err = 0; |
Arend van Spriel | 40c8e95 | 2011-10-12 20:51:20 +0200 | [diff] [blame] | 2934 | int i, pmkid_len; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2935 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2936 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 2937 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2938 | return -EIO; |
| 2939 | |
| 2940 | memcpy(&pmkid.pmkid[0].BSSID, pmksa->bssid, ETH_ALEN); |
| 2941 | memcpy(&pmkid.pmkid[0].PMKID, pmksa->pmkid, WLAN_PMKID_LEN); |
| 2942 | |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2943 | brcmf_dbg(CONN, "del_pmksa,IW_PMKSA_REMOVE - PMKID: %pM =\n", |
| 2944 | &pmkid.pmkid[0].BSSID); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2945 | for (i = 0; i < WLAN_PMKID_LEN; i++) |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 2946 | brcmf_dbg(CONN, "%02x\n", pmkid.pmkid[0].PMKID[i]); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2947 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2948 | pmkid_len = le32_to_cpu(cfg->pmk_list->pmkids.npmkid); |
Arend van Spriel | 40c8e95 | 2011-10-12 20:51:20 +0200 | [diff] [blame] | 2949 | for (i = 0; i < pmkid_len; i++) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2950 | if (!memcmp |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2951 | (pmksa->bssid, &cfg->pmk_list->pmkids.pmkid[i].BSSID, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2952 | ETH_ALEN)) |
| 2953 | break; |
| 2954 | |
Arend van Spriel | 40c8e95 | 2011-10-12 20:51:20 +0200 | [diff] [blame] | 2955 | if ((pmkid_len > 0) |
| 2956 | && (i < pmkid_len)) { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2957 | memset(&cfg->pmk_list->pmkids.pmkid[i], 0, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2958 | sizeof(struct pmkid)); |
Arend van Spriel | 40c8e95 | 2011-10-12 20:51:20 +0200 | [diff] [blame] | 2959 | for (; i < (pmkid_len - 1); i++) { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2960 | memcpy(&cfg->pmk_list->pmkids.pmkid[i].BSSID, |
| 2961 | &cfg->pmk_list->pmkids.pmkid[i + 1].BSSID, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2962 | ETH_ALEN); |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2963 | memcpy(&cfg->pmk_list->pmkids.pmkid[i].PMKID, |
| 2964 | &cfg->pmk_list->pmkids.pmkid[i + 1].PMKID, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2965 | WLAN_PMKID_LEN); |
| 2966 | } |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2967 | cfg->pmk_list->pmkids.npmkid = cpu_to_le32(pmkid_len - 1); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2968 | } else |
| 2969 | err = -EINVAL; |
| 2970 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2971 | err = brcmf_update_pmklist(ndev, cfg->pmk_list, err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2972 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2973 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2974 | return err; |
| 2975 | |
| 2976 | } |
| 2977 | |
| 2978 | static s32 |
| 2979 | brcmf_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *ndev) |
| 2980 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2981 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 2982 | struct brcmf_if *ifp = netdev_priv(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2983 | s32 err = 0; |
| 2984 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2985 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 2986 | if (!check_vif_up(ifp->vif)) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2987 | return -EIO; |
| 2988 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 2989 | memset(cfg->pmk_list, 0, sizeof(*cfg->pmk_list)); |
| 2990 | err = brcmf_update_pmklist(ndev, cfg->pmk_list, err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2991 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 2992 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 2993 | return err; |
| 2994 | |
| 2995 | } |
| 2996 | |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 2997 | /* |
| 2998 | * PFN result doesn't have all the info which are |
| 2999 | * required by the supplicant |
| 3000 | * (For e.g IEs) Do a target Escan so that sched scan results are reported |
| 3001 | * via wl_inform_single_bss in the required format. Escan does require the |
| 3002 | * scan request in the form of cfg80211_scan_request. For timebeing, create |
| 3003 | * cfg80211_scan_request one out of the received PNO event. |
| 3004 | */ |
| 3005 | static s32 |
Arend van Spriel | 1993732 | 2012-11-05 16:22:32 -0800 | [diff] [blame] | 3006 | brcmf_notify_sched_scan_results(struct brcmf_if *ifp, |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3007 | const struct brcmf_event_msg *e, void *data) |
| 3008 | { |
Arend van Spriel | 1993732 | 2012-11-05 16:22:32 -0800 | [diff] [blame] | 3009 | struct brcmf_cfg80211_info *cfg = ifp->drvr->config; |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3010 | struct brcmf_pno_net_info_le *netinfo, *netinfo_start; |
| 3011 | struct cfg80211_scan_request *request = NULL; |
| 3012 | struct cfg80211_ssid *ssid = NULL; |
| 3013 | struct ieee80211_channel *channel = NULL; |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 3014 | struct wiphy *wiphy = cfg_to_wiphy(cfg); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3015 | int err = 0; |
| 3016 | int channel_req = 0; |
| 3017 | int band = 0; |
| 3018 | struct brcmf_pno_scanresults_le *pfn_result; |
| 3019 | u32 result_count; |
| 3020 | u32 status; |
| 3021 | |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 3022 | brcmf_dbg(SCAN, "Enter\n"); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3023 | |
Arend van Spriel | 5c36b99 | 2012-11-14 18:46:05 -0800 | [diff] [blame] | 3024 | if (e->event_code == BRCMF_E_PFN_NET_LOST) { |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 3025 | brcmf_dbg(SCAN, "PFN NET LOST event. Do Nothing\n"); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3026 | return 0; |
| 3027 | } |
| 3028 | |
| 3029 | pfn_result = (struct brcmf_pno_scanresults_le *)data; |
| 3030 | result_count = le32_to_cpu(pfn_result->count); |
| 3031 | status = le32_to_cpu(pfn_result->status); |
| 3032 | |
| 3033 | /* |
| 3034 | * PFN event is limited to fit 512 bytes so we may get |
| 3035 | * multiple NET_FOUND events. For now place a warning here. |
| 3036 | */ |
| 3037 | WARN_ON(status != BRCMF_PNO_SCAN_COMPLETE); |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 3038 | brcmf_dbg(SCAN, "PFN NET FOUND event. count: %d\n", result_count); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3039 | if (result_count > 0) { |
| 3040 | int i; |
| 3041 | |
| 3042 | request = kzalloc(sizeof(*request), GFP_KERNEL); |
Dan Carpenter | 58901d1 | 2012-09-26 10:21:48 +0300 | [diff] [blame] | 3043 | ssid = kcalloc(result_count, sizeof(*ssid), GFP_KERNEL); |
| 3044 | channel = kcalloc(result_count, sizeof(*channel), GFP_KERNEL); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3045 | if (!request || !ssid || !channel) { |
| 3046 | err = -ENOMEM; |
| 3047 | goto out_err; |
| 3048 | } |
| 3049 | |
| 3050 | request->wiphy = wiphy; |
| 3051 | data += sizeof(struct brcmf_pno_scanresults_le); |
| 3052 | netinfo_start = (struct brcmf_pno_net_info_le *)data; |
| 3053 | |
| 3054 | for (i = 0; i < result_count; i++) { |
| 3055 | netinfo = &netinfo_start[i]; |
| 3056 | if (!netinfo) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3057 | brcmf_err("Invalid netinfo ptr. index: %d\n", |
| 3058 | i); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3059 | err = -EINVAL; |
| 3060 | goto out_err; |
| 3061 | } |
| 3062 | |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 3063 | brcmf_dbg(SCAN, "SSID:%s Channel:%d\n", |
| 3064 | netinfo->SSID, netinfo->channel); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3065 | memcpy(ssid[i].ssid, netinfo->SSID, netinfo->SSID_len); |
| 3066 | ssid[i].ssid_len = netinfo->SSID_len; |
| 3067 | request->n_ssids++; |
| 3068 | |
| 3069 | channel_req = netinfo->channel; |
| 3070 | if (channel_req <= CH_MAX_2G_CHANNEL) |
| 3071 | band = NL80211_BAND_2GHZ; |
| 3072 | else |
| 3073 | band = NL80211_BAND_5GHZ; |
| 3074 | channel[i].center_freq = |
| 3075 | ieee80211_channel_to_frequency(channel_req, |
| 3076 | band); |
| 3077 | channel[i].band = band; |
| 3078 | channel[i].flags |= IEEE80211_CHAN_NO_HT40; |
| 3079 | request->channels[i] = &channel[i]; |
| 3080 | request->n_channels++; |
| 3081 | } |
| 3082 | |
| 3083 | /* assign parsed ssid array */ |
| 3084 | if (request->n_ssids) |
| 3085 | request->ssids = &ssid[0]; |
| 3086 | |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 3087 | if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status)) { |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3088 | /* Abort any on-going scan */ |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 3089 | brcmf_abort_scanning(cfg); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3090 | } |
| 3091 | |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 3092 | set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status); |
Arend van Spriel | 2668b0b | 2014-01-13 22:20:28 +0100 | [diff] [blame] | 3093 | cfg->escan_info.run = brcmf_run_escan; |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 3094 | err = brcmf_do_escan(cfg, wiphy, ifp, request); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3095 | if (err) { |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 3096 | clear_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3097 | goto out_err; |
| 3098 | } |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 3099 | cfg->sched_escan = true; |
| 3100 | cfg->scan_request = request; |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3101 | } else { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3102 | brcmf_err("FALSE PNO Event. (pfn_count == 0)\n"); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3103 | goto out_err; |
| 3104 | } |
| 3105 | |
| 3106 | kfree(ssid); |
| 3107 | kfree(channel); |
| 3108 | kfree(request); |
| 3109 | return 0; |
| 3110 | |
| 3111 | out_err: |
| 3112 | kfree(ssid); |
| 3113 | kfree(channel); |
| 3114 | kfree(request); |
| 3115 | cfg80211_sched_scan_stopped(wiphy); |
| 3116 | return err; |
| 3117 | } |
| 3118 | |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3119 | static int brcmf_dev_pno_clean(struct net_device *ndev) |
| 3120 | { |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3121 | int ret; |
| 3122 | |
| 3123 | /* Disable pfn */ |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3124 | ret = brcmf_fil_iovar_int_set(netdev_priv(ndev), "pfn", 0); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3125 | if (ret == 0) { |
| 3126 | /* clear pfn */ |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3127 | ret = brcmf_fil_iovar_data_set(netdev_priv(ndev), "pfnclear", |
| 3128 | NULL, 0); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3129 | } |
| 3130 | if (ret < 0) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3131 | brcmf_err("failed code %d\n", ret); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3132 | |
| 3133 | return ret; |
| 3134 | } |
| 3135 | |
| 3136 | static int brcmf_dev_pno_config(struct net_device *ndev) |
| 3137 | { |
| 3138 | struct brcmf_pno_param_le pfn_param; |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3139 | |
| 3140 | memset(&pfn_param, 0, sizeof(pfn_param)); |
| 3141 | pfn_param.version = cpu_to_le32(BRCMF_PNO_VERSION); |
| 3142 | |
| 3143 | /* set extra pno params */ |
| 3144 | pfn_param.flags = cpu_to_le16(1 << BRCMF_PNO_ENABLE_ADAPTSCAN_BIT); |
| 3145 | pfn_param.repeat = BRCMF_PNO_REPEAT; |
| 3146 | pfn_param.exp = BRCMF_PNO_FREQ_EXPO_MAX; |
| 3147 | |
| 3148 | /* set up pno scan fr */ |
| 3149 | pfn_param.scan_freq = cpu_to_le32(BRCMF_PNO_TIME); |
| 3150 | |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3151 | return brcmf_fil_iovar_data_set(netdev_priv(ndev), "pfn_set", |
| 3152 | &pfn_param, sizeof(pfn_param)); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3153 | } |
| 3154 | |
| 3155 | static int |
| 3156 | brcmf_cfg80211_sched_scan_start(struct wiphy *wiphy, |
| 3157 | struct net_device *ndev, |
| 3158 | struct cfg80211_sched_scan_request *request) |
| 3159 | { |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 3160 | struct brcmf_if *ifp = netdev_priv(ndev); |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 3161 | struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3162 | struct brcmf_pno_net_param_le pfn; |
| 3163 | int i; |
| 3164 | int ret = 0; |
| 3165 | |
Arend van Spriel | dc7bdbf | 2013-03-03 12:45:25 +0100 | [diff] [blame] | 3166 | brcmf_dbg(SCAN, "Enter n_match_sets:%d n_ssids:%d\n", |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 3167 | request->n_match_sets, request->n_ssids); |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 3168 | if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status)) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3169 | brcmf_err("Scanning already: status (%lu)\n", cfg->scan_status); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3170 | return -EAGAIN; |
| 3171 | } |
Arend van Spriel | 1687eee | 2013-04-23 12:53:11 +0200 | [diff] [blame] | 3172 | if (test_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status)) { |
| 3173 | brcmf_err("Scanning suppressed: status (%lu)\n", |
| 3174 | cfg->scan_status); |
| 3175 | return -EAGAIN; |
| 3176 | } |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3177 | |
Arend van Spriel | dc7bdbf | 2013-03-03 12:45:25 +0100 | [diff] [blame] | 3178 | if (!request->n_ssids || !request->n_match_sets) { |
Arend van Spriel | 181f2d1 | 2014-05-27 12:56:13 +0200 | [diff] [blame] | 3179 | brcmf_dbg(SCAN, "Invalid sched scan req!! n_ssids:%d\n", |
Arend van Spriel | dc7bdbf | 2013-03-03 12:45:25 +0100 | [diff] [blame] | 3180 | request->n_ssids); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3181 | return -EINVAL; |
| 3182 | } |
| 3183 | |
| 3184 | if (request->n_ssids > 0) { |
| 3185 | for (i = 0; i < request->n_ssids; i++) { |
| 3186 | /* Active scan req for ssids */ |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 3187 | brcmf_dbg(SCAN, ">>> Active scan req for ssid (%s)\n", |
| 3188 | request->ssids[i].ssid); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3189 | |
| 3190 | /* |
| 3191 | * match_set ssids is a supert set of n_ssid list, |
| 3192 | * so we need not add these set seperately. |
| 3193 | */ |
| 3194 | } |
| 3195 | } |
| 3196 | |
| 3197 | if (request->n_match_sets > 0) { |
| 3198 | /* clean up everything */ |
| 3199 | ret = brcmf_dev_pno_clean(ndev); |
| 3200 | if (ret < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3201 | brcmf_err("failed error=%d\n", ret); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3202 | return ret; |
| 3203 | } |
| 3204 | |
| 3205 | /* configure pno */ |
| 3206 | ret = brcmf_dev_pno_config(ndev); |
| 3207 | if (ret < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3208 | brcmf_err("PNO setup failed!! ret=%d\n", ret); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3209 | return -EINVAL; |
| 3210 | } |
| 3211 | |
| 3212 | /* configure each match set */ |
| 3213 | for (i = 0; i < request->n_match_sets; i++) { |
| 3214 | struct cfg80211_ssid *ssid; |
| 3215 | u32 ssid_len; |
| 3216 | |
| 3217 | ssid = &request->match_sets[i].ssid; |
| 3218 | ssid_len = ssid->ssid_len; |
| 3219 | |
| 3220 | if (!ssid_len) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3221 | brcmf_err("skip broadcast ssid\n"); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3222 | continue; |
| 3223 | } |
| 3224 | pfn.auth = cpu_to_le32(WLAN_AUTH_OPEN); |
| 3225 | pfn.wpa_auth = cpu_to_le32(BRCMF_PNO_WPA_AUTH_ANY); |
| 3226 | pfn.wsec = cpu_to_le32(0); |
| 3227 | pfn.infra = cpu_to_le32(1); |
| 3228 | pfn.flags = cpu_to_le32(1 << BRCMF_PNO_HIDDEN_BIT); |
| 3229 | pfn.ssid.SSID_len = cpu_to_le32(ssid_len); |
| 3230 | memcpy(pfn.ssid.SSID, ssid->ssid, ssid_len); |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 3231 | ret = brcmf_fil_iovar_data_set(ifp, "pfn_add", &pfn, |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3232 | sizeof(pfn)); |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 3233 | brcmf_dbg(SCAN, ">>> PNO filter %s for ssid (%s)\n", |
| 3234 | ret == 0 ? "set" : "failed", ssid->ssid); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3235 | } |
| 3236 | /* Enable the PNO */ |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 3237 | if (brcmf_fil_iovar_int_set(ifp, "pfn", 1) < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3238 | brcmf_err("PNO enable failed!! ret=%d\n", ret); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3239 | return -EINVAL; |
| 3240 | } |
| 3241 | } else { |
| 3242 | return -EINVAL; |
| 3243 | } |
| 3244 | |
| 3245 | return 0; |
| 3246 | } |
| 3247 | |
| 3248 | static int brcmf_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
| 3249 | struct net_device *ndev) |
| 3250 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 3251 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3252 | |
Arend van Spriel | 4e8a008 | 2012-12-05 15:26:03 +0100 | [diff] [blame] | 3253 | brcmf_dbg(SCAN, "enter\n"); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3254 | brcmf_dev_pno_clean(ndev); |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 3255 | if (cfg->sched_escan) |
Arend van Spriel | a0f472a | 2013-04-05 10:57:49 +0200 | [diff] [blame] | 3256 | brcmf_notify_escan_complete(cfg, netdev_priv(ndev), true, true); |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3257 | return 0; |
| 3258 | } |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 3259 | |
Arend van Spriel | cbaa177 | 2012-08-30 19:43:02 +0200 | [diff] [blame] | 3260 | #ifdef CONFIG_NL80211_TESTMODE |
David Spinadel | fc73f11 | 2013-07-31 18:04:15 +0300 | [diff] [blame] | 3261 | static int brcmf_cfg80211_testmode(struct wiphy *wiphy, |
| 3262 | struct wireless_dev *wdev, |
| 3263 | void *data, int len) |
Arend van Spriel | cbaa177 | 2012-08-30 19:43:02 +0200 | [diff] [blame] | 3264 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 3265 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 3266 | struct net_device *ndev = cfg_to_ndev(cfg); |
Arend van Spriel | cbaa177 | 2012-08-30 19:43:02 +0200 | [diff] [blame] | 3267 | struct brcmf_dcmd *dcmd = data; |
| 3268 | struct sk_buff *reply; |
| 3269 | int ret; |
| 3270 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3271 | brcmf_dbg(TRACE, "cmd %x set %d buf %p len %d\n", dcmd->cmd, dcmd->set, |
| 3272 | dcmd->buf, dcmd->len); |
Hante Meuleman | f368a5b | 2012-10-22 10:36:16 -0700 | [diff] [blame] | 3273 | |
| 3274 | if (dcmd->set) |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3275 | ret = brcmf_fil_cmd_data_set(netdev_priv(ndev), dcmd->cmd, |
| 3276 | dcmd->buf, dcmd->len); |
Hante Meuleman | f368a5b | 2012-10-22 10:36:16 -0700 | [diff] [blame] | 3277 | else |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3278 | ret = brcmf_fil_cmd_data_get(netdev_priv(ndev), dcmd->cmd, |
| 3279 | dcmd->buf, dcmd->len); |
Arend van Spriel | cbaa177 | 2012-08-30 19:43:02 +0200 | [diff] [blame] | 3280 | if (ret == 0) { |
| 3281 | reply = cfg80211_testmode_alloc_reply_skb(wiphy, sizeof(*dcmd)); |
| 3282 | nla_put(reply, NL80211_ATTR_TESTDATA, sizeof(*dcmd), dcmd); |
| 3283 | ret = cfg80211_testmode_reply(reply); |
| 3284 | } |
| 3285 | return ret; |
| 3286 | } |
| 3287 | #endif |
| 3288 | |
Hante Meuleman | 1f17011 | 2013-02-06 18:40:38 +0100 | [diff] [blame] | 3289 | static s32 brcmf_configure_opensecurity(struct brcmf_if *ifp) |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3290 | { |
| 3291 | s32 err; |
| 3292 | |
| 3293 | /* set auth */ |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3294 | err = brcmf_fil_bsscfg_int_set(ifp, "auth", 0); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3295 | if (err < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3296 | brcmf_err("auth error %d\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3297 | return err; |
| 3298 | } |
| 3299 | /* set wsec */ |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3300 | err = brcmf_fil_bsscfg_int_set(ifp, "wsec", 0); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3301 | if (err < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3302 | brcmf_err("wsec error %d\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3303 | return err; |
| 3304 | } |
| 3305 | /* set upper-layer auth */ |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3306 | err = brcmf_fil_bsscfg_int_set(ifp, "wpa_auth", WPA_AUTH_NONE); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3307 | if (err < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3308 | brcmf_err("wpa_auth error %d\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3309 | return err; |
| 3310 | } |
| 3311 | |
| 3312 | return 0; |
| 3313 | } |
| 3314 | |
| 3315 | static bool brcmf_valid_wpa_oui(u8 *oui, bool is_rsn_ie) |
| 3316 | { |
| 3317 | if (is_rsn_ie) |
| 3318 | return (memcmp(oui, RSN_OUI, TLV_OUI_LEN) == 0); |
| 3319 | |
| 3320 | return (memcmp(oui, WPA_OUI, TLV_OUI_LEN) == 0); |
| 3321 | } |
| 3322 | |
| 3323 | static s32 |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 3324 | brcmf_configure_wpaie(struct net_device *ndev, |
| 3325 | const struct brcmf_vs_tlv *wpa_ie, |
| 3326 | bool is_rsn_ie) |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3327 | { |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3328 | struct brcmf_if *ifp = netdev_priv(ndev); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3329 | u32 auth = 0; /* d11 open authentication */ |
| 3330 | u16 count; |
| 3331 | s32 err = 0; |
| 3332 | s32 len = 0; |
| 3333 | u32 i; |
| 3334 | u32 wsec; |
| 3335 | u32 pval = 0; |
| 3336 | u32 gval = 0; |
| 3337 | u32 wpa_auth = 0; |
| 3338 | u32 offset; |
| 3339 | u8 *data; |
| 3340 | u16 rsn_cap; |
| 3341 | u32 wme_bss_disable; |
| 3342 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3343 | brcmf_dbg(TRACE, "Enter\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3344 | if (wpa_ie == NULL) |
| 3345 | goto exit; |
| 3346 | |
| 3347 | len = wpa_ie->len + TLV_HDR_LEN; |
| 3348 | data = (u8 *)wpa_ie; |
Hante Meuleman | 619c5a9 | 2013-01-02 15:12:39 +0100 | [diff] [blame] | 3349 | offset = TLV_HDR_LEN; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3350 | if (!is_rsn_ie) |
| 3351 | offset += VS_IE_FIXED_HDR_LEN; |
Hante Meuleman | 619c5a9 | 2013-01-02 15:12:39 +0100 | [diff] [blame] | 3352 | else |
| 3353 | offset += WPA_IE_VERSION_LEN; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3354 | |
| 3355 | /* check for multicast cipher suite */ |
| 3356 | if (offset + WPA_IE_MIN_OUI_LEN > len) { |
| 3357 | err = -EINVAL; |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3358 | brcmf_err("no multicast cipher suite\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3359 | goto exit; |
| 3360 | } |
| 3361 | |
| 3362 | if (!brcmf_valid_wpa_oui(&data[offset], is_rsn_ie)) { |
| 3363 | err = -EINVAL; |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3364 | brcmf_err("ivalid OUI\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3365 | goto exit; |
| 3366 | } |
| 3367 | offset += TLV_OUI_LEN; |
| 3368 | |
| 3369 | /* pick up multicast cipher */ |
| 3370 | switch (data[offset]) { |
| 3371 | case WPA_CIPHER_NONE: |
| 3372 | gval = 0; |
| 3373 | break; |
| 3374 | case WPA_CIPHER_WEP_40: |
| 3375 | case WPA_CIPHER_WEP_104: |
| 3376 | gval = WEP_ENABLED; |
| 3377 | break; |
| 3378 | case WPA_CIPHER_TKIP: |
| 3379 | gval = TKIP_ENABLED; |
| 3380 | break; |
| 3381 | case WPA_CIPHER_AES_CCM: |
| 3382 | gval = AES_ENABLED; |
| 3383 | break; |
| 3384 | default: |
| 3385 | err = -EINVAL; |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3386 | brcmf_err("Invalid multi cast cipher info\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3387 | goto exit; |
| 3388 | } |
| 3389 | |
| 3390 | offset++; |
| 3391 | /* walk thru unicast cipher list and pick up what we recognize */ |
| 3392 | count = data[offset] + (data[offset + 1] << 8); |
| 3393 | offset += WPA_IE_SUITE_COUNT_LEN; |
| 3394 | /* Check for unicast suite(s) */ |
| 3395 | if (offset + (WPA_IE_MIN_OUI_LEN * count) > len) { |
| 3396 | err = -EINVAL; |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3397 | brcmf_err("no unicast cipher suite\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3398 | goto exit; |
| 3399 | } |
| 3400 | for (i = 0; i < count; i++) { |
| 3401 | if (!brcmf_valid_wpa_oui(&data[offset], is_rsn_ie)) { |
| 3402 | err = -EINVAL; |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3403 | brcmf_err("ivalid OUI\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3404 | goto exit; |
| 3405 | } |
| 3406 | offset += TLV_OUI_LEN; |
| 3407 | switch (data[offset]) { |
| 3408 | case WPA_CIPHER_NONE: |
| 3409 | break; |
| 3410 | case WPA_CIPHER_WEP_40: |
| 3411 | case WPA_CIPHER_WEP_104: |
| 3412 | pval |= WEP_ENABLED; |
| 3413 | break; |
| 3414 | case WPA_CIPHER_TKIP: |
| 3415 | pval |= TKIP_ENABLED; |
| 3416 | break; |
| 3417 | case WPA_CIPHER_AES_CCM: |
| 3418 | pval |= AES_ENABLED; |
| 3419 | break; |
| 3420 | default: |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3421 | brcmf_err("Ivalid unicast security info\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3422 | } |
| 3423 | offset++; |
| 3424 | } |
| 3425 | /* walk thru auth management suite list and pick up what we recognize */ |
| 3426 | count = data[offset] + (data[offset + 1] << 8); |
| 3427 | offset += WPA_IE_SUITE_COUNT_LEN; |
| 3428 | /* Check for auth key management suite(s) */ |
| 3429 | if (offset + (WPA_IE_MIN_OUI_LEN * count) > len) { |
| 3430 | err = -EINVAL; |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3431 | brcmf_err("no auth key mgmt suite\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3432 | goto exit; |
| 3433 | } |
| 3434 | for (i = 0; i < count; i++) { |
| 3435 | if (!brcmf_valid_wpa_oui(&data[offset], is_rsn_ie)) { |
| 3436 | err = -EINVAL; |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3437 | brcmf_err("ivalid OUI\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3438 | goto exit; |
| 3439 | } |
| 3440 | offset += TLV_OUI_LEN; |
| 3441 | switch (data[offset]) { |
| 3442 | case RSN_AKM_NONE: |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3443 | brcmf_dbg(TRACE, "RSN_AKM_NONE\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3444 | wpa_auth |= WPA_AUTH_NONE; |
| 3445 | break; |
| 3446 | case RSN_AKM_UNSPECIFIED: |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3447 | brcmf_dbg(TRACE, "RSN_AKM_UNSPECIFIED\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3448 | is_rsn_ie ? (wpa_auth |= WPA2_AUTH_UNSPECIFIED) : |
| 3449 | (wpa_auth |= WPA_AUTH_UNSPECIFIED); |
| 3450 | break; |
| 3451 | case RSN_AKM_PSK: |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3452 | brcmf_dbg(TRACE, "RSN_AKM_PSK\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3453 | is_rsn_ie ? (wpa_auth |= WPA2_AUTH_PSK) : |
| 3454 | (wpa_auth |= WPA_AUTH_PSK); |
| 3455 | break; |
| 3456 | default: |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3457 | brcmf_err("Ivalid key mgmt info\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3458 | } |
| 3459 | offset++; |
| 3460 | } |
| 3461 | |
| 3462 | if (is_rsn_ie) { |
| 3463 | wme_bss_disable = 1; |
| 3464 | if ((offset + RSN_CAP_LEN) <= len) { |
| 3465 | rsn_cap = data[offset] + (data[offset + 1] << 8); |
| 3466 | if (rsn_cap & RSN_CAP_PTK_REPLAY_CNTR_MASK) |
| 3467 | wme_bss_disable = 0; |
| 3468 | } |
| 3469 | /* set wme_bss_disable to sync RSN Capabilities */ |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3470 | err = brcmf_fil_bsscfg_int_set(ifp, "wme_bss_disable", |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 3471 | wme_bss_disable); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3472 | if (err < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3473 | brcmf_err("wme_bss_disable error %d\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3474 | goto exit; |
| 3475 | } |
| 3476 | } |
| 3477 | /* FOR WPS , set SES_OW_ENABLED */ |
| 3478 | wsec = (pval | gval | SES_OW_ENABLED); |
| 3479 | |
| 3480 | /* set auth */ |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3481 | err = brcmf_fil_bsscfg_int_set(ifp, "auth", auth); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3482 | if (err < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3483 | brcmf_err("auth error %d\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3484 | goto exit; |
| 3485 | } |
| 3486 | /* set wsec */ |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3487 | err = brcmf_fil_bsscfg_int_set(ifp, "wsec", wsec); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3488 | if (err < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3489 | brcmf_err("wsec error %d\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3490 | goto exit; |
| 3491 | } |
| 3492 | /* set upper-layer auth */ |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3493 | err = brcmf_fil_bsscfg_int_set(ifp, "wpa_auth", wpa_auth); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3494 | if (err < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3495 | brcmf_err("wpa_auth error %d\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3496 | goto exit; |
| 3497 | } |
| 3498 | |
| 3499 | exit: |
| 3500 | return err; |
| 3501 | } |
| 3502 | |
| 3503 | static s32 |
Arend van Spriel | 3082b9b | 2012-11-05 16:22:12 -0800 | [diff] [blame] | 3504 | brcmf_parse_vndr_ies(const u8 *vndr_ie_buf, u32 vndr_ie_len, |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3505 | struct parsed_vndr_ies *vndr_ies) |
| 3506 | { |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3507 | struct brcmf_vs_tlv *vndrie; |
| 3508 | struct brcmf_tlv *ie; |
| 3509 | struct parsed_vndr_ie_info *parsed_info; |
| 3510 | s32 remaining_len; |
| 3511 | |
| 3512 | remaining_len = (s32)vndr_ie_len; |
| 3513 | memset(vndr_ies, 0, sizeof(*vndr_ies)); |
| 3514 | |
| 3515 | ie = (struct brcmf_tlv *)vndr_ie_buf; |
| 3516 | while (ie) { |
| 3517 | if (ie->id != WLAN_EID_VENDOR_SPECIFIC) |
| 3518 | goto next; |
| 3519 | vndrie = (struct brcmf_vs_tlv *)ie; |
| 3520 | /* len should be bigger than OUI length + one */ |
| 3521 | if (vndrie->len < (VS_IE_FIXED_HDR_LEN - TLV_HDR_LEN + 1)) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3522 | brcmf_err("invalid vndr ie. length is too small %d\n", |
| 3523 | vndrie->len); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3524 | goto next; |
| 3525 | } |
| 3526 | /* if wpa or wme ie, do not add ie */ |
| 3527 | if (!memcmp(vndrie->oui, (u8 *)WPA_OUI, TLV_OUI_LEN) && |
| 3528 | ((vndrie->oui_type == WPA_OUI_TYPE) || |
| 3529 | (vndrie->oui_type == WME_OUI_TYPE))) { |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3530 | brcmf_dbg(TRACE, "Found WPA/WME oui. Do not add it\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3531 | goto next; |
| 3532 | } |
| 3533 | |
| 3534 | parsed_info = &vndr_ies->ie_info[vndr_ies->count]; |
| 3535 | |
| 3536 | /* save vndr ie information */ |
| 3537 | parsed_info->ie_ptr = (char *)vndrie; |
| 3538 | parsed_info->ie_len = vndrie->len + TLV_HDR_LEN; |
| 3539 | memcpy(&parsed_info->vndrie, vndrie, sizeof(*vndrie)); |
| 3540 | |
| 3541 | vndr_ies->count++; |
| 3542 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3543 | brcmf_dbg(TRACE, "** OUI %02x %02x %02x, type 0x%02x\n", |
| 3544 | parsed_info->vndrie.oui[0], |
| 3545 | parsed_info->vndrie.oui[1], |
| 3546 | parsed_info->vndrie.oui[2], |
| 3547 | parsed_info->vndrie.oui_type); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3548 | |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 3549 | if (vndr_ies->count >= VNDR_IE_PARSE_LIMIT) |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3550 | break; |
| 3551 | next: |
Hante Meuleman | b41fc3d | 2012-11-28 21:44:13 +0100 | [diff] [blame] | 3552 | remaining_len -= (ie->len + TLV_HDR_LEN); |
| 3553 | if (remaining_len <= TLV_HDR_LEN) |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3554 | ie = NULL; |
| 3555 | else |
Hante Meuleman | b41fc3d | 2012-11-28 21:44:13 +0100 | [diff] [blame] | 3556 | ie = (struct brcmf_tlv *)(((u8 *)ie) + ie->len + |
| 3557 | TLV_HDR_LEN); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3558 | } |
Peter Senna Tschudin | 12f3237 | 2014-05-31 10:14:06 -0300 | [diff] [blame^] | 3559 | return 0; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3560 | } |
| 3561 | |
| 3562 | static u32 |
| 3563 | brcmf_vndr_ie(u8 *iebuf, s32 pktflag, u8 *ie_ptr, u32 ie_len, s8 *add_del_cmd) |
| 3564 | { |
| 3565 | |
| 3566 | __le32 iecount_le; |
| 3567 | __le32 pktflag_le; |
| 3568 | |
| 3569 | strncpy(iebuf, add_del_cmd, VNDR_IE_CMD_LEN - 1); |
| 3570 | iebuf[VNDR_IE_CMD_LEN - 1] = '\0'; |
| 3571 | |
| 3572 | iecount_le = cpu_to_le32(1); |
| 3573 | memcpy(&iebuf[VNDR_IE_COUNT_OFFSET], &iecount_le, sizeof(iecount_le)); |
| 3574 | |
| 3575 | pktflag_le = cpu_to_le32(pktflag); |
| 3576 | memcpy(&iebuf[VNDR_IE_PKTFLAG_OFFSET], &pktflag_le, sizeof(pktflag_le)); |
| 3577 | |
| 3578 | memcpy(&iebuf[VNDR_IE_VSIE_OFFSET], ie_ptr, ie_len); |
| 3579 | |
| 3580 | return ie_len + VNDR_IE_HDR_SIZE; |
| 3581 | } |
| 3582 | |
Arend van Spriel | 1332e26 | 2012-11-05 16:22:18 -0800 | [diff] [blame] | 3583 | s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag, |
| 3584 | const u8 *vndr_ie_buf, u32 vndr_ie_len) |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3585 | { |
Arend van Spriel | 1332e26 | 2012-11-05 16:22:18 -0800 | [diff] [blame] | 3586 | struct brcmf_if *ifp; |
| 3587 | struct vif_saved_ie *saved_ie; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3588 | s32 err = 0; |
| 3589 | u8 *iovar_ie_buf; |
| 3590 | u8 *curr_ie_buf; |
| 3591 | u8 *mgmt_ie_buf = NULL; |
Dan Carpenter | 3e4f319 | 2012-10-10 11:13:12 -0700 | [diff] [blame] | 3592 | int mgmt_ie_buf_len; |
Dan Carpenter | 81118d1 | 2012-10-10 11:13:07 -0700 | [diff] [blame] | 3593 | u32 *mgmt_ie_len; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3594 | u32 del_add_ie_buf_len = 0; |
| 3595 | u32 total_ie_buf_len = 0; |
| 3596 | u32 parsed_ie_buf_len = 0; |
| 3597 | struct parsed_vndr_ies old_vndr_ies; |
| 3598 | struct parsed_vndr_ies new_vndr_ies; |
| 3599 | struct parsed_vndr_ie_info *vndrie_info; |
| 3600 | s32 i; |
| 3601 | u8 *ptr; |
Dan Carpenter | 3e4f319 | 2012-10-10 11:13:12 -0700 | [diff] [blame] | 3602 | int remained_buf_len; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3603 | |
Arend van Spriel | 1332e26 | 2012-11-05 16:22:18 -0800 | [diff] [blame] | 3604 | if (!vif) |
| 3605 | return -ENODEV; |
| 3606 | ifp = vif->ifp; |
| 3607 | saved_ie = &vif->saved_ie; |
| 3608 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3609 | brcmf_dbg(TRACE, "bssidx %d, pktflag : 0x%02X\n", ifp->bssidx, pktflag); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3610 | iovar_ie_buf = kzalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL); |
| 3611 | if (!iovar_ie_buf) |
| 3612 | return -ENOMEM; |
| 3613 | curr_ie_buf = iovar_ie_buf; |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 3614 | switch (pktflag) { |
| 3615 | case BRCMF_VNDR_IE_PRBREQ_FLAG: |
| 3616 | mgmt_ie_buf = saved_ie->probe_req_ie; |
| 3617 | mgmt_ie_len = &saved_ie->probe_req_ie_len; |
| 3618 | mgmt_ie_buf_len = sizeof(saved_ie->probe_req_ie); |
| 3619 | break; |
| 3620 | case BRCMF_VNDR_IE_PRBRSP_FLAG: |
| 3621 | mgmt_ie_buf = saved_ie->probe_res_ie; |
| 3622 | mgmt_ie_len = &saved_ie->probe_res_ie_len; |
| 3623 | mgmt_ie_buf_len = sizeof(saved_ie->probe_res_ie); |
| 3624 | break; |
| 3625 | case BRCMF_VNDR_IE_BEACON_FLAG: |
| 3626 | mgmt_ie_buf = saved_ie->beacon_ie; |
| 3627 | mgmt_ie_len = &saved_ie->beacon_ie_len; |
| 3628 | mgmt_ie_buf_len = sizeof(saved_ie->beacon_ie); |
| 3629 | break; |
| 3630 | case BRCMF_VNDR_IE_ASSOCREQ_FLAG: |
| 3631 | mgmt_ie_buf = saved_ie->assoc_req_ie; |
| 3632 | mgmt_ie_len = &saved_ie->assoc_req_ie_len; |
| 3633 | mgmt_ie_buf_len = sizeof(saved_ie->assoc_req_ie); |
| 3634 | break; |
| 3635 | default: |
| 3636 | err = -EPERM; |
| 3637 | brcmf_err("not suitable type\n"); |
| 3638 | goto exit; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3639 | } |
| 3640 | |
| 3641 | if (vndr_ie_len > mgmt_ie_buf_len) { |
| 3642 | err = -ENOMEM; |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3643 | brcmf_err("extra IE size too big\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3644 | goto exit; |
| 3645 | } |
| 3646 | |
| 3647 | /* parse and save new vndr_ie in curr_ie_buff before comparing it */ |
| 3648 | if (vndr_ie_buf && vndr_ie_len && curr_ie_buf) { |
| 3649 | ptr = curr_ie_buf; |
| 3650 | brcmf_parse_vndr_ies(vndr_ie_buf, vndr_ie_len, &new_vndr_ies); |
| 3651 | for (i = 0; i < new_vndr_ies.count; i++) { |
| 3652 | vndrie_info = &new_vndr_ies.ie_info[i]; |
| 3653 | memcpy(ptr + parsed_ie_buf_len, vndrie_info->ie_ptr, |
| 3654 | vndrie_info->ie_len); |
| 3655 | parsed_ie_buf_len += vndrie_info->ie_len; |
| 3656 | } |
| 3657 | } |
| 3658 | |
Hante Meuleman | b41fc3d | 2012-11-28 21:44:13 +0100 | [diff] [blame] | 3659 | if (mgmt_ie_buf && *mgmt_ie_len) { |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3660 | if (parsed_ie_buf_len && (parsed_ie_buf_len == *mgmt_ie_len) && |
| 3661 | (memcmp(mgmt_ie_buf, curr_ie_buf, |
| 3662 | parsed_ie_buf_len) == 0)) { |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3663 | brcmf_dbg(TRACE, "Previous mgmt IE equals to current IE\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3664 | goto exit; |
| 3665 | } |
| 3666 | |
| 3667 | /* parse old vndr_ie */ |
| 3668 | brcmf_parse_vndr_ies(mgmt_ie_buf, *mgmt_ie_len, &old_vndr_ies); |
| 3669 | |
| 3670 | /* make a command to delete old ie */ |
| 3671 | for (i = 0; i < old_vndr_ies.count; i++) { |
| 3672 | vndrie_info = &old_vndr_ies.ie_info[i]; |
| 3673 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3674 | brcmf_dbg(TRACE, "DEL ID : %d, Len: %d , OUI:%02x:%02x:%02x\n", |
| 3675 | vndrie_info->vndrie.id, |
| 3676 | vndrie_info->vndrie.len, |
| 3677 | vndrie_info->vndrie.oui[0], |
| 3678 | vndrie_info->vndrie.oui[1], |
| 3679 | vndrie_info->vndrie.oui[2]); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3680 | |
| 3681 | del_add_ie_buf_len = brcmf_vndr_ie(curr_ie_buf, pktflag, |
| 3682 | vndrie_info->ie_ptr, |
| 3683 | vndrie_info->ie_len, |
| 3684 | "del"); |
| 3685 | curr_ie_buf += del_add_ie_buf_len; |
| 3686 | total_ie_buf_len += del_add_ie_buf_len; |
| 3687 | } |
| 3688 | } |
| 3689 | |
| 3690 | *mgmt_ie_len = 0; |
| 3691 | /* Add if there is any extra IE */ |
| 3692 | if (mgmt_ie_buf && parsed_ie_buf_len) { |
| 3693 | ptr = mgmt_ie_buf; |
| 3694 | |
| 3695 | remained_buf_len = mgmt_ie_buf_len; |
| 3696 | |
| 3697 | /* make a command to add new ie */ |
| 3698 | for (i = 0; i < new_vndr_ies.count; i++) { |
| 3699 | vndrie_info = &new_vndr_ies.ie_info[i]; |
| 3700 | |
Hante Meuleman | b41fc3d | 2012-11-28 21:44:13 +0100 | [diff] [blame] | 3701 | /* verify remained buf size before copy data */ |
| 3702 | if (remained_buf_len < (vndrie_info->vndrie.len + |
| 3703 | VNDR_IE_VSIE_OFFSET)) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3704 | brcmf_err("no space in mgmt_ie_buf: len left %d", |
| 3705 | remained_buf_len); |
Hante Meuleman | b41fc3d | 2012-11-28 21:44:13 +0100 | [diff] [blame] | 3706 | break; |
| 3707 | } |
| 3708 | remained_buf_len -= (vndrie_info->ie_len + |
| 3709 | VNDR_IE_VSIE_OFFSET); |
| 3710 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3711 | brcmf_dbg(TRACE, "ADDED ID : %d, Len: %d, OUI:%02x:%02x:%02x\n", |
| 3712 | vndrie_info->vndrie.id, |
| 3713 | vndrie_info->vndrie.len, |
| 3714 | vndrie_info->vndrie.oui[0], |
| 3715 | vndrie_info->vndrie.oui[1], |
| 3716 | vndrie_info->vndrie.oui[2]); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3717 | |
| 3718 | del_add_ie_buf_len = brcmf_vndr_ie(curr_ie_buf, pktflag, |
| 3719 | vndrie_info->ie_ptr, |
| 3720 | vndrie_info->ie_len, |
| 3721 | "add"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3722 | |
| 3723 | /* save the parsed IE in wl struct */ |
| 3724 | memcpy(ptr + (*mgmt_ie_len), vndrie_info->ie_ptr, |
| 3725 | vndrie_info->ie_len); |
| 3726 | *mgmt_ie_len += vndrie_info->ie_len; |
| 3727 | |
| 3728 | curr_ie_buf += del_add_ie_buf_len; |
| 3729 | total_ie_buf_len += del_add_ie_buf_len; |
| 3730 | } |
| 3731 | } |
| 3732 | if (total_ie_buf_len) { |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 3733 | err = brcmf_fil_bsscfg_data_set(ifp, "vndr_ie", iovar_ie_buf, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 3734 | total_ie_buf_len); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3735 | if (err) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3736 | brcmf_err("vndr ie set error : %d\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3737 | } |
| 3738 | |
| 3739 | exit: |
| 3740 | kfree(iovar_ie_buf); |
| 3741 | return err; |
| 3742 | } |
| 3743 | |
Arend van Spriel | 5f4f9f1 | 2013-02-08 15:53:41 +0100 | [diff] [blame] | 3744 | s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif) |
| 3745 | { |
| 3746 | s32 pktflags[] = { |
| 3747 | BRCMF_VNDR_IE_PRBREQ_FLAG, |
| 3748 | BRCMF_VNDR_IE_PRBRSP_FLAG, |
| 3749 | BRCMF_VNDR_IE_BEACON_FLAG |
| 3750 | }; |
| 3751 | int i; |
| 3752 | |
| 3753 | for (i = 0; i < ARRAY_SIZE(pktflags); i++) |
| 3754 | brcmf_vif_set_mgmt_ie(vif, pktflags[i], NULL, 0); |
| 3755 | |
| 3756 | memset(&vif->saved_ie, 0, sizeof(vif->saved_ie)); |
| 3757 | return 0; |
| 3758 | } |
| 3759 | |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3760 | static s32 |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 3761 | brcmf_config_ap_mgmt_ie(struct brcmf_cfg80211_vif *vif, |
| 3762 | struct cfg80211_beacon_data *beacon) |
| 3763 | { |
| 3764 | s32 err; |
| 3765 | |
| 3766 | /* Set Beacon IEs to FW */ |
| 3767 | err = brcmf_vif_set_mgmt_ie(vif, BRCMF_VNDR_IE_BEACON_FLAG, |
| 3768 | beacon->tail, beacon->tail_len); |
| 3769 | if (err) { |
| 3770 | brcmf_err("Set Beacon IE Failed\n"); |
| 3771 | return err; |
| 3772 | } |
| 3773 | brcmf_dbg(TRACE, "Applied Vndr IEs for Beacon\n"); |
| 3774 | |
| 3775 | /* Set Probe Response IEs to FW */ |
| 3776 | err = brcmf_vif_set_mgmt_ie(vif, BRCMF_VNDR_IE_PRBRSP_FLAG, |
| 3777 | beacon->proberesp_ies, |
| 3778 | beacon->proberesp_ies_len); |
| 3779 | if (err) |
| 3780 | brcmf_err("Set Probe Resp IE Failed\n"); |
| 3781 | else |
| 3782 | brcmf_dbg(TRACE, "Applied Vndr IEs for Probe Resp\n"); |
| 3783 | |
| 3784 | return err; |
| 3785 | } |
| 3786 | |
| 3787 | static s32 |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3788 | brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev, |
| 3789 | struct cfg80211_ap_settings *settings) |
| 3790 | { |
| 3791 | s32 ie_offset; |
Hante Meuleman | 1c9d30c | 2013-05-27 21:09:58 +0200 | [diff] [blame] | 3792 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3793 | struct brcmf_if *ifp = netdev_priv(ndev); |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 3794 | const struct brcmf_tlv *ssid_ie; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3795 | struct brcmf_ssid_le ssid_le; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3796 | s32 err = -EPERM; |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 3797 | const struct brcmf_tlv *rsn_ie; |
| 3798 | const struct brcmf_vs_tlv *wpa_ie; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3799 | struct brcmf_join_params join_params; |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 3800 | enum nl80211_iftype dev_role; |
| 3801 | struct brcmf_fil_bss_enable_le bss_enable; |
Arend van Spriel | 06c0158 | 2014-05-12 10:47:37 +0200 | [diff] [blame] | 3802 | u16 chanspec; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3803 | |
Arend van Spriel | 06c0158 | 2014-05-12 10:47:37 +0200 | [diff] [blame] | 3804 | brcmf_dbg(TRACE, "ctrlchn=%d, center=%d, bw=%d, beacon_interval=%d, dtim_period=%d,\n", |
| 3805 | settings->chandef.chan->hw_value, |
| 3806 | settings->chandef.center_freq1, settings->chandef.width, |
Arend van Spriel | a9a5687 | 2014-05-12 10:47:33 +0200 | [diff] [blame] | 3807 | settings->beacon_interval, settings->dtim_period); |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3808 | brcmf_dbg(TRACE, "ssid=%s(%zu), auth_type=%d, inactivity_timeout=%d\n", |
| 3809 | settings->ssid, settings->ssid_len, settings->auth_type, |
| 3810 | settings->inactivity_timeout); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3811 | |
Hante Meuleman | 426d0a5 | 2013-02-08 15:53:53 +0100 | [diff] [blame] | 3812 | dev_role = ifp->vif->wdev.iftype; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3813 | |
| 3814 | memset(&ssid_le, 0, sizeof(ssid_le)); |
| 3815 | if (settings->ssid == NULL || settings->ssid_len == 0) { |
| 3816 | ie_offset = DOT11_MGMT_HDR_LEN + DOT11_BCN_PRB_FIXED_LEN; |
| 3817 | ssid_ie = brcmf_parse_tlvs( |
| 3818 | (u8 *)&settings->beacon.head[ie_offset], |
| 3819 | settings->beacon.head_len - ie_offset, |
| 3820 | WLAN_EID_SSID); |
| 3821 | if (!ssid_ie) |
| 3822 | return -EINVAL; |
| 3823 | |
| 3824 | memcpy(ssid_le.SSID, ssid_ie->data, ssid_ie->len); |
| 3825 | ssid_le.SSID_len = cpu_to_le32(ssid_ie->len); |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3826 | brcmf_dbg(TRACE, "SSID is (%s) in Head\n", ssid_le.SSID); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3827 | } else { |
| 3828 | memcpy(ssid_le.SSID, settings->ssid, settings->ssid_len); |
| 3829 | ssid_le.SSID_len = cpu_to_le32((u32)settings->ssid_len); |
| 3830 | } |
| 3831 | |
Arend van Spriel | f96aa07 | 2013-04-05 10:57:48 +0200 | [diff] [blame] | 3832 | brcmf_set_mpc(ifp, 0); |
Hante Meuleman | b365745 | 2013-05-27 21:09:53 +0200 | [diff] [blame] | 3833 | brcmf_configure_arp_offload(ifp, false); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3834 | |
| 3835 | /* find the RSN_IE */ |
| 3836 | rsn_ie = brcmf_parse_tlvs((u8 *)settings->beacon.tail, |
| 3837 | settings->beacon.tail_len, WLAN_EID_RSN); |
| 3838 | |
| 3839 | /* find the WPA_IE */ |
| 3840 | wpa_ie = brcmf_find_wpaie((u8 *)settings->beacon.tail, |
| 3841 | settings->beacon.tail_len); |
| 3842 | |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3843 | if ((wpa_ie != NULL || rsn_ie != NULL)) { |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3844 | brcmf_dbg(TRACE, "WPA(2) IE is found\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3845 | if (wpa_ie != NULL) { |
| 3846 | /* WPA IE */ |
Arend van Spriel | 3477852 | 2012-11-05 16:22:19 -0800 | [diff] [blame] | 3847 | err = brcmf_configure_wpaie(ndev, wpa_ie, false); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3848 | if (err < 0) |
| 3849 | goto exit; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3850 | } else { |
| 3851 | /* RSN IE */ |
| 3852 | err = brcmf_configure_wpaie(ndev, |
Arend van Spriel | 3477852 | 2012-11-05 16:22:19 -0800 | [diff] [blame] | 3853 | (struct brcmf_vs_tlv *)rsn_ie, true); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3854 | if (err < 0) |
| 3855 | goto exit; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3856 | } |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3857 | } else { |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3858 | brcmf_dbg(TRACE, "No WPA(2) IEs found\n"); |
Hante Meuleman | 1f17011 | 2013-02-06 18:40:38 +0100 | [diff] [blame] | 3859 | brcmf_configure_opensecurity(ifp); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3860 | } |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3861 | |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 3862 | brcmf_config_ap_mgmt_ie(ifp->vif, &settings->beacon); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3863 | |
Arend van Spriel | 600a897 | 2014-05-12 10:47:39 +0200 | [diff] [blame] | 3864 | chanspec = chandef_to_chanspec(&cfg->d11inf, &settings->chandef); |
Arend van Spriel | 06c0158 | 2014-05-12 10:47:37 +0200 | [diff] [blame] | 3865 | err = brcmf_fil_iovar_int_set(ifp, "chanspec", chanspec); |
Hante Meuleman | 1c9d30c | 2013-05-27 21:09:58 +0200 | [diff] [blame] | 3866 | if (err < 0) { |
Arend van Spriel | 06c0158 | 2014-05-12 10:47:37 +0200 | [diff] [blame] | 3867 | brcmf_err("Set Channel failed: chspec=%d, %d\n", chanspec, err); |
Hante Meuleman | 1c9d30c | 2013-05-27 21:09:58 +0200 | [diff] [blame] | 3868 | goto exit; |
| 3869 | } |
| 3870 | |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3871 | if (settings->beacon_interval) { |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3872 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_BCNPRD, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 3873 | settings->beacon_interval); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3874 | if (err < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3875 | brcmf_err("Beacon Interval Set Error, %d\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3876 | goto exit; |
| 3877 | } |
| 3878 | } |
| 3879 | if (settings->dtim_period) { |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 3880 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_DTIMPRD, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 3881 | settings->dtim_period); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3882 | if (err < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3883 | brcmf_err("DTIM Interval Set Error, %d\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3884 | goto exit; |
| 3885 | } |
| 3886 | } |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 3887 | |
| 3888 | if (dev_role == NL80211_IFTYPE_AP) { |
| 3889 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_DOWN, 1); |
| 3890 | if (err < 0) { |
| 3891 | brcmf_err("BRCMF_C_DOWN error %d\n", err); |
| 3892 | goto exit; |
| 3893 | } |
Hante Meuleman | 2880b86 | 2013-02-08 12:06:31 +0100 | [diff] [blame] | 3894 | brcmf_fil_iovar_int_set(ifp, "apsta", 0); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3895 | } |
| 3896 | |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 3897 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_INFRA, 1); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3898 | if (err < 0) { |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 3899 | brcmf_err("SET INFRA error %d\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3900 | goto exit; |
| 3901 | } |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 3902 | if (dev_role == NL80211_IFTYPE_AP) { |
| 3903 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_AP, 1); |
| 3904 | if (err < 0) { |
| 3905 | brcmf_err("setting AP mode failed %d\n", err); |
| 3906 | goto exit; |
| 3907 | } |
| 3908 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 1); |
| 3909 | if (err < 0) { |
| 3910 | brcmf_err("BRCMF_C_UP error (%d)\n", err); |
| 3911 | goto exit; |
| 3912 | } |
| 3913 | |
| 3914 | memset(&join_params, 0, sizeof(join_params)); |
| 3915 | /* join parameters starts with ssid */ |
| 3916 | memcpy(&join_params.ssid_le, &ssid_le, sizeof(ssid_le)); |
| 3917 | /* create softap */ |
| 3918 | err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SSID, |
| 3919 | &join_params, sizeof(join_params)); |
| 3920 | if (err < 0) { |
| 3921 | brcmf_err("SET SSID error (%d)\n", err); |
| 3922 | goto exit; |
| 3923 | } |
| 3924 | brcmf_dbg(TRACE, "AP mode configuration complete\n"); |
| 3925 | } else { |
| 3926 | err = brcmf_fil_bsscfg_data_set(ifp, "ssid", &ssid_le, |
| 3927 | sizeof(ssid_le)); |
| 3928 | if (err < 0) { |
| 3929 | brcmf_err("setting ssid failed %d\n", err); |
| 3930 | goto exit; |
| 3931 | } |
| 3932 | bss_enable.bsscfg_idx = cpu_to_le32(ifp->bssidx); |
| 3933 | bss_enable.enable = cpu_to_le32(1); |
| 3934 | err = brcmf_fil_iovar_data_set(ifp, "bss", &bss_enable, |
| 3935 | sizeof(bss_enable)); |
| 3936 | if (err < 0) { |
| 3937 | brcmf_err("bss_enable config failed %d\n", err); |
| 3938 | goto exit; |
| 3939 | } |
| 3940 | |
| 3941 | brcmf_dbg(TRACE, "GO mode configuration complete\n"); |
| 3942 | } |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 3943 | clear_bit(BRCMF_VIF_STATUS_AP_CREATING, &ifp->vif->sme_state); |
| 3944 | set_bit(BRCMF_VIF_STATUS_AP_CREATED, &ifp->vif->sme_state); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3945 | |
| 3946 | exit: |
Hante Meuleman | b365745 | 2013-05-27 21:09:53 +0200 | [diff] [blame] | 3947 | if (err) { |
Arend van Spriel | f96aa07 | 2013-04-05 10:57:48 +0200 | [diff] [blame] | 3948 | brcmf_set_mpc(ifp, 1); |
Hante Meuleman | b365745 | 2013-05-27 21:09:53 +0200 | [diff] [blame] | 3949 | brcmf_configure_arp_offload(ifp, true); |
| 3950 | } |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3951 | return err; |
| 3952 | } |
| 3953 | |
| 3954 | static int brcmf_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *ndev) |
| 3955 | { |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 3956 | struct brcmf_if *ifp = netdev_priv(ndev); |
Hante Meuleman | 5c33a94 | 2013-04-02 21:06:18 +0200 | [diff] [blame] | 3957 | s32 err; |
Hante Meuleman | 426d0a5 | 2013-02-08 15:53:53 +0100 | [diff] [blame] | 3958 | struct brcmf_fil_bss_enable_le bss_enable; |
Hante Meuleman | 5c33a94 | 2013-04-02 21:06:18 +0200 | [diff] [blame] | 3959 | struct brcmf_join_params join_params; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3960 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 3961 | brcmf_dbg(TRACE, "Enter\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3962 | |
Hante Meuleman | 426d0a5 | 2013-02-08 15:53:53 +0100 | [diff] [blame] | 3963 | if (ifp->vif->wdev.iftype == NL80211_IFTYPE_AP) { |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3964 | /* Due to most likely deauths outstanding we sleep */ |
| 3965 | /* first to make sure they get processed by fw. */ |
| 3966 | msleep(400); |
Hante Meuleman | 5c33a94 | 2013-04-02 21:06:18 +0200 | [diff] [blame] | 3967 | |
| 3968 | memset(&join_params, 0, sizeof(join_params)); |
| 3969 | err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SSID, |
| 3970 | &join_params, sizeof(join_params)); |
| 3971 | if (err < 0) |
| 3972 | brcmf_err("SET SSID error (%d)\n", err); |
Arend van Spriel | 128ce3b | 2012-11-28 21:44:12 +0100 | [diff] [blame] | 3973 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 0); |
Hante Meuleman | 5c33a94 | 2013-04-02 21:06:18 +0200 | [diff] [blame] | 3974 | if (err < 0) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 3975 | brcmf_err("BRCMF_C_UP error %d\n", err); |
Hante Meuleman | 5c33a94 | 2013-04-02 21:06:18 +0200 | [diff] [blame] | 3976 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_AP, 0); |
| 3977 | if (err < 0) |
| 3978 | brcmf_err("setting AP mode failed %d\n", err); |
| 3979 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_INFRA, 0); |
| 3980 | if (err < 0) |
| 3981 | brcmf_err("setting INFRA mode failed %d\n", err); |
Hante Meuleman | 426d0a5 | 2013-02-08 15:53:53 +0100 | [diff] [blame] | 3982 | } else { |
| 3983 | bss_enable.bsscfg_idx = cpu_to_le32(ifp->bssidx); |
| 3984 | bss_enable.enable = cpu_to_le32(0); |
| 3985 | err = brcmf_fil_iovar_data_set(ifp, "bss", &bss_enable, |
| 3986 | sizeof(bss_enable)); |
| 3987 | if (err < 0) |
| 3988 | brcmf_err("bss_enable config failed %d\n", err); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3989 | } |
Arend van Spriel | f96aa07 | 2013-04-05 10:57:48 +0200 | [diff] [blame] | 3990 | brcmf_set_mpc(ifp, 1); |
Hante Meuleman | b365745 | 2013-05-27 21:09:53 +0200 | [diff] [blame] | 3991 | brcmf_configure_arp_offload(ifp, true); |
Hante Meuleman | 426d0a5 | 2013-02-08 15:53:53 +0100 | [diff] [blame] | 3992 | set_bit(BRCMF_VIF_STATUS_AP_CREATING, &ifp->vif->sme_state); |
| 3993 | clear_bit(BRCMF_VIF_STATUS_AP_CREATED, &ifp->vif->sme_state); |
| 3994 | |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 3995 | return err; |
| 3996 | } |
| 3997 | |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 3998 | static s32 |
| 3999 | brcmf_cfg80211_change_beacon(struct wiphy *wiphy, struct net_device *ndev, |
| 4000 | struct cfg80211_beacon_data *info) |
| 4001 | { |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 4002 | struct brcmf_if *ifp = netdev_priv(ndev); |
| 4003 | s32 err; |
| 4004 | |
| 4005 | brcmf_dbg(TRACE, "Enter\n"); |
| 4006 | |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 4007 | err = brcmf_config_ap_mgmt_ie(ifp->vif, info); |
| 4008 | |
| 4009 | return err; |
| 4010 | } |
| 4011 | |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4012 | static int |
| 4013 | brcmf_cfg80211_del_station(struct wiphy *wiphy, struct net_device *ndev, |
Johannes Berg | 3b3a016 | 2014-05-19 17:19:31 +0200 | [diff] [blame] | 4014 | const u8 *mac) |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4015 | { |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 4016 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4017 | struct brcmf_scb_val_le scbval; |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 4018 | struct brcmf_if *ifp = netdev_priv(ndev); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4019 | s32 err; |
| 4020 | |
| 4021 | if (!mac) |
| 4022 | return -EFAULT; |
| 4023 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 4024 | brcmf_dbg(TRACE, "Enter %pM\n", mac); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4025 | |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 4026 | if (ifp->vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif) |
| 4027 | ifp = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif->ifp; |
Arend van Spriel | ce81e31 | 2012-10-22 13:55:37 -0700 | [diff] [blame] | 4028 | if (!check_vif_up(ifp->vif)) |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4029 | return -EIO; |
| 4030 | |
| 4031 | memcpy(&scbval.ea, mac, ETH_ALEN); |
| 4032 | scbval.val = cpu_to_le32(WLAN_REASON_DEAUTH_LEAVING); |
Arend van Spriel | 0abb5f21 | 2012-10-22 13:55:32 -0700 | [diff] [blame] | 4033 | err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SCB_DEAUTHENTICATE_FOR_REASON, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 4034 | &scbval, sizeof(scbval)); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4035 | if (err) |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 4036 | brcmf_err("SCB_DEAUTHENTICATE_FOR_REASON failed %d\n", err); |
Hante Meuleman | 7ab6acd | 2013-02-08 15:53:58 +0100 | [diff] [blame] | 4037 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 4038 | brcmf_dbg(TRACE, "Exit\n"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4039 | return err; |
| 4040 | } |
| 4041 | |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4042 | |
| 4043 | static void |
| 4044 | brcmf_cfg80211_mgmt_frame_register(struct wiphy *wiphy, |
| 4045 | struct wireless_dev *wdev, |
| 4046 | u16 frame_type, bool reg) |
| 4047 | { |
Arend van Spriel | 7fa2e35 | 2013-04-05 10:57:47 +0200 | [diff] [blame] | 4048 | struct brcmf_cfg80211_vif *vif; |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4049 | u16 mgmt_type; |
| 4050 | |
| 4051 | brcmf_dbg(TRACE, "Enter, frame_type %04x, reg=%d\n", frame_type, reg); |
| 4052 | |
| 4053 | mgmt_type = (frame_type & IEEE80211_FCTL_STYPE) >> 4; |
Arend van Spriel | 7fa2e35 | 2013-04-05 10:57:47 +0200 | [diff] [blame] | 4054 | vif = container_of(wdev, struct brcmf_cfg80211_vif, wdev); |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4055 | if (reg) |
| 4056 | vif->mgmt_rx_reg |= BIT(mgmt_type); |
| 4057 | else |
Hante Meuleman | 318a64c | 2013-02-08 15:53:45 +0100 | [diff] [blame] | 4058 | vif->mgmt_rx_reg &= ~BIT(mgmt_type); |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4059 | } |
| 4060 | |
| 4061 | |
| 4062 | static int |
| 4063 | brcmf_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, |
Andrei Otcheretianski | b176e62 | 2013-11-18 19:06:49 +0200 | [diff] [blame] | 4064 | struct cfg80211_mgmt_tx_params *params, u64 *cookie) |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4065 | { |
| 4066 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
Andrei Otcheretianski | b176e62 | 2013-11-18 19:06:49 +0200 | [diff] [blame] | 4067 | struct ieee80211_channel *chan = params->chan; |
| 4068 | const u8 *buf = params->buf; |
| 4069 | size_t len = params->len; |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4070 | const struct ieee80211_mgmt *mgmt; |
| 4071 | struct brcmf_cfg80211_vif *vif; |
| 4072 | s32 err = 0; |
| 4073 | s32 ie_offset; |
| 4074 | s32 ie_len; |
Hante Meuleman | 18e2f61 | 2013-02-08 15:53:49 +0100 | [diff] [blame] | 4075 | struct brcmf_fil_action_frame_le *action_frame; |
| 4076 | struct brcmf_fil_af_params_le *af_params; |
| 4077 | bool ack; |
| 4078 | s32 chan_nr; |
Antonio Quartulli | c2ff8ca | 2013-06-11 14:20:01 +0200 | [diff] [blame] | 4079 | u32 freq; |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4080 | |
| 4081 | brcmf_dbg(TRACE, "Enter\n"); |
| 4082 | |
| 4083 | *cookie = 0; |
| 4084 | |
| 4085 | mgmt = (const struct ieee80211_mgmt *)buf; |
| 4086 | |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 4087 | if (!ieee80211_is_mgmt(mgmt->frame_control)) { |
| 4088 | brcmf_err("Driver only allows MGMT packet type\n"); |
| 4089 | return -EPERM; |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4090 | } |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 4091 | |
Antonio Quartulli | c2ff8ca | 2013-06-11 14:20:01 +0200 | [diff] [blame] | 4092 | vif = container_of(wdev, struct brcmf_cfg80211_vif, wdev); |
| 4093 | |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 4094 | if (ieee80211_is_probe_resp(mgmt->frame_control)) { |
| 4095 | /* Right now the only reason to get a probe response */ |
| 4096 | /* is for p2p listen response or for p2p GO from */ |
| 4097 | /* wpa_supplicant. Unfortunately the probe is send */ |
| 4098 | /* on primary ndev, while dongle wants it on the p2p */ |
| 4099 | /* vif. Since this is only reason for a probe */ |
| 4100 | /* response to be sent, the vif is taken from cfg. */ |
| 4101 | /* If ever desired to send proberesp for non p2p */ |
| 4102 | /* response then data should be checked for */ |
| 4103 | /* "DIRECT-". Note in future supplicant will take */ |
| 4104 | /* dedicated p2p wdev to do this and then this 'hack'*/ |
| 4105 | /* is not needed anymore. */ |
| 4106 | ie_offset = DOT11_MGMT_HDR_LEN + |
| 4107 | DOT11_BCN_PRB_FIXED_LEN; |
| 4108 | ie_len = len - ie_offset; |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 4109 | if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif) |
| 4110 | vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif; |
| 4111 | err = brcmf_vif_set_mgmt_ie(vif, |
| 4112 | BRCMF_VNDR_IE_PRBRSP_FLAG, |
| 4113 | &buf[ie_offset], |
| 4114 | ie_len); |
| 4115 | cfg80211_mgmt_tx_status(wdev, *cookie, buf, len, true, |
| 4116 | GFP_KERNEL); |
Hante Meuleman | 18e2f61 | 2013-02-08 15:53:49 +0100 | [diff] [blame] | 4117 | } else if (ieee80211_is_action(mgmt->frame_control)) { |
| 4118 | af_params = kzalloc(sizeof(*af_params), GFP_KERNEL); |
| 4119 | if (af_params == NULL) { |
| 4120 | brcmf_err("unable to allocate frame\n"); |
| 4121 | err = -ENOMEM; |
| 4122 | goto exit; |
| 4123 | } |
| 4124 | action_frame = &af_params->action_frame; |
| 4125 | /* Add the packet Id */ |
| 4126 | action_frame->packet_id = cpu_to_le32(*cookie); |
| 4127 | /* Add BSSID */ |
| 4128 | memcpy(&action_frame->da[0], &mgmt->da[0], ETH_ALEN); |
| 4129 | memcpy(&af_params->bssid[0], &mgmt->bssid[0], ETH_ALEN); |
| 4130 | /* Add the length exepted for 802.11 header */ |
| 4131 | action_frame->len = cpu_to_le16(len - DOT11_MGMT_HDR_LEN); |
Antonio Quartulli | c2ff8ca | 2013-06-11 14:20:01 +0200 | [diff] [blame] | 4132 | /* Add the channel. Use the one specified as parameter if any or |
| 4133 | * the current one (got from the firmware) otherwise |
| 4134 | */ |
| 4135 | if (chan) |
| 4136 | freq = chan->center_freq; |
| 4137 | else |
| 4138 | brcmf_fil_cmd_int_get(vif->ifp, BRCMF_C_GET_CHANNEL, |
| 4139 | &freq); |
| 4140 | chan_nr = ieee80211_frequency_to_channel(freq); |
Hante Meuleman | 18e2f61 | 2013-02-08 15:53:49 +0100 | [diff] [blame] | 4141 | af_params->channel = cpu_to_le32(chan_nr); |
| 4142 | |
| 4143 | memcpy(action_frame->data, &buf[DOT11_MGMT_HDR_LEN], |
| 4144 | le16_to_cpu(action_frame->len)); |
| 4145 | |
| 4146 | brcmf_dbg(TRACE, "Action frame, cookie=%lld, len=%d, freq=%d\n", |
Antonio Quartulli | 86a9c4a | 2013-06-19 13:35:31 +0200 | [diff] [blame] | 4147 | *cookie, le16_to_cpu(action_frame->len), freq); |
Hante Meuleman | 18e2f61 | 2013-02-08 15:53:49 +0100 | [diff] [blame] | 4148 | |
Arend van Spriel | 7fa2e35 | 2013-04-05 10:57:47 +0200 | [diff] [blame] | 4149 | ack = brcmf_p2p_send_action_frame(cfg, cfg_to_ndev(cfg), |
Hante Meuleman | 18e2f61 | 2013-02-08 15:53:49 +0100 | [diff] [blame] | 4150 | af_params); |
| 4151 | |
| 4152 | cfg80211_mgmt_tx_status(wdev, *cookie, buf, len, ack, |
| 4153 | GFP_KERNEL); |
| 4154 | kfree(af_params); |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 4155 | } else { |
| 4156 | brcmf_dbg(TRACE, "Unhandled, fc=%04x!!\n", mgmt->frame_control); |
| 4157 | brcmf_dbg_hex_dump(true, buf, len, "payload, len=%Zu\n", len); |
| 4158 | } |
| 4159 | |
Hante Meuleman | 18e2f61 | 2013-02-08 15:53:49 +0100 | [diff] [blame] | 4160 | exit: |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4161 | return err; |
| 4162 | } |
| 4163 | |
| 4164 | |
| 4165 | static int |
| 4166 | brcmf_cfg80211_cancel_remain_on_channel(struct wiphy *wiphy, |
| 4167 | struct wireless_dev *wdev, |
| 4168 | u64 cookie) |
| 4169 | { |
| 4170 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
| 4171 | struct brcmf_cfg80211_vif *vif; |
| 4172 | int err = 0; |
| 4173 | |
| 4174 | brcmf_dbg(TRACE, "Enter p2p listen cancel\n"); |
| 4175 | |
| 4176 | vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif; |
| 4177 | if (vif == NULL) { |
| 4178 | brcmf_err("No p2p device available for probe response\n"); |
| 4179 | err = -ENODEV; |
| 4180 | goto exit; |
| 4181 | } |
| 4182 | brcmf_p2p_cancel_remain_on_channel(vif->ifp); |
| 4183 | exit: |
| 4184 | return err; |
| 4185 | } |
| 4186 | |
Piotr Haber | 61730d4 | 2013-04-23 12:53:12 +0200 | [diff] [blame] | 4187 | static int brcmf_cfg80211_crit_proto_start(struct wiphy *wiphy, |
| 4188 | struct wireless_dev *wdev, |
| 4189 | enum nl80211_crit_proto_id proto, |
| 4190 | u16 duration) |
| 4191 | { |
| 4192 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
| 4193 | struct brcmf_cfg80211_vif *vif; |
| 4194 | |
| 4195 | vif = container_of(wdev, struct brcmf_cfg80211_vif, wdev); |
| 4196 | |
| 4197 | /* only DHCP support for now */ |
| 4198 | if (proto != NL80211_CRIT_PROTO_DHCP) |
| 4199 | return -EINVAL; |
| 4200 | |
| 4201 | /* suppress and abort scanning */ |
| 4202 | set_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status); |
| 4203 | brcmf_abort_scanning(cfg); |
| 4204 | |
| 4205 | return brcmf_btcoex_set_mode(vif, BRCMF_BTCOEX_DISABLED, duration); |
| 4206 | } |
| 4207 | |
| 4208 | static void brcmf_cfg80211_crit_proto_stop(struct wiphy *wiphy, |
| 4209 | struct wireless_dev *wdev) |
| 4210 | { |
| 4211 | struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); |
| 4212 | struct brcmf_cfg80211_vif *vif; |
| 4213 | |
| 4214 | vif = container_of(wdev, struct brcmf_cfg80211_vif, wdev); |
| 4215 | |
| 4216 | brcmf_btcoex_set_mode(vif, BRCMF_BTCOEX_ENABLED, 0); |
| 4217 | clear_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status); |
| 4218 | } |
| 4219 | |
Arend van Spriel | 89c2f38 | 2013-08-10 12:27:25 +0200 | [diff] [blame] | 4220 | static int brcmf_convert_nl80211_tdls_oper(enum nl80211_tdls_operation oper) |
| 4221 | { |
| 4222 | int ret; |
| 4223 | |
| 4224 | switch (oper) { |
| 4225 | case NL80211_TDLS_DISCOVERY_REQ: |
| 4226 | ret = BRCMF_TDLS_MANUAL_EP_DISCOVERY; |
| 4227 | break; |
| 4228 | case NL80211_TDLS_SETUP: |
| 4229 | ret = BRCMF_TDLS_MANUAL_EP_CREATE; |
| 4230 | break; |
| 4231 | case NL80211_TDLS_TEARDOWN: |
| 4232 | ret = BRCMF_TDLS_MANUAL_EP_DELETE; |
| 4233 | break; |
| 4234 | default: |
| 4235 | brcmf_err("unsupported operation: %d\n", oper); |
| 4236 | ret = -EOPNOTSUPP; |
| 4237 | } |
| 4238 | return ret; |
| 4239 | } |
| 4240 | |
| 4241 | static int brcmf_cfg80211_tdls_oper(struct wiphy *wiphy, |
Johannes Berg | 3b3a016 | 2014-05-19 17:19:31 +0200 | [diff] [blame] | 4242 | struct net_device *ndev, const u8 *peer, |
Arend van Spriel | 89c2f38 | 2013-08-10 12:27:25 +0200 | [diff] [blame] | 4243 | enum nl80211_tdls_operation oper) |
| 4244 | { |
| 4245 | struct brcmf_if *ifp; |
| 4246 | struct brcmf_tdls_iovar_le info; |
| 4247 | int ret = 0; |
| 4248 | |
| 4249 | ret = brcmf_convert_nl80211_tdls_oper(oper); |
| 4250 | if (ret < 0) |
| 4251 | return ret; |
| 4252 | |
| 4253 | ifp = netdev_priv(ndev); |
| 4254 | memset(&info, 0, sizeof(info)); |
| 4255 | info.mode = (u8)ret; |
| 4256 | if (peer) |
| 4257 | memcpy(info.ea, peer, ETH_ALEN); |
| 4258 | |
| 4259 | ret = brcmf_fil_iovar_data_set(ifp, "tdls_endpoint", |
| 4260 | &info, sizeof(info)); |
| 4261 | if (ret < 0) |
| 4262 | brcmf_err("tdls_endpoint iovar failed: ret=%d\n", ret); |
| 4263 | |
| 4264 | return ret; |
| 4265 | } |
| 4266 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4267 | static struct cfg80211_ops wl_cfg80211_ops = { |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 4268 | .add_virtual_intf = brcmf_cfg80211_add_iface, |
| 4269 | .del_virtual_intf = brcmf_cfg80211_del_iface, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4270 | .change_virtual_intf = brcmf_cfg80211_change_iface, |
| 4271 | .scan = brcmf_cfg80211_scan, |
| 4272 | .set_wiphy_params = brcmf_cfg80211_set_wiphy_params, |
| 4273 | .join_ibss = brcmf_cfg80211_join_ibss, |
| 4274 | .leave_ibss = brcmf_cfg80211_leave_ibss, |
| 4275 | .get_station = brcmf_cfg80211_get_station, |
| 4276 | .set_tx_power = brcmf_cfg80211_set_tx_power, |
| 4277 | .get_tx_power = brcmf_cfg80211_get_tx_power, |
| 4278 | .add_key = brcmf_cfg80211_add_key, |
| 4279 | .del_key = brcmf_cfg80211_del_key, |
| 4280 | .get_key = brcmf_cfg80211_get_key, |
| 4281 | .set_default_key = brcmf_cfg80211_config_default_key, |
| 4282 | .set_default_mgmt_key = brcmf_cfg80211_config_default_mgmt_key, |
| 4283 | .set_power_mgmt = brcmf_cfg80211_set_power_mgmt, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4284 | .connect = brcmf_cfg80211_connect, |
| 4285 | .disconnect = brcmf_cfg80211_disconnect, |
| 4286 | .suspend = brcmf_cfg80211_suspend, |
| 4287 | .resume = brcmf_cfg80211_resume, |
| 4288 | .set_pmksa = brcmf_cfg80211_set_pmksa, |
| 4289 | .del_pmksa = brcmf_cfg80211_del_pmksa, |
Arend van Spriel | cbaa177 | 2012-08-30 19:43:02 +0200 | [diff] [blame] | 4290 | .flush_pmksa = brcmf_cfg80211_flush_pmksa, |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4291 | .start_ap = brcmf_cfg80211_start_ap, |
| 4292 | .stop_ap = brcmf_cfg80211_stop_ap, |
Hante Meuleman | a0f0795 | 2013-02-08 15:53:47 +0100 | [diff] [blame] | 4293 | .change_beacon = brcmf_cfg80211_change_beacon, |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4294 | .del_station = brcmf_cfg80211_del_station, |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 4295 | .sched_scan_start = brcmf_cfg80211_sched_scan_start, |
| 4296 | .sched_scan_stop = brcmf_cfg80211_sched_scan_stop, |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4297 | .mgmt_frame_register = brcmf_cfg80211_mgmt_frame_register, |
| 4298 | .mgmt_tx = brcmf_cfg80211_mgmt_tx, |
| 4299 | .remain_on_channel = brcmf_p2p_remain_on_channel, |
| 4300 | .cancel_remain_on_channel = brcmf_cfg80211_cancel_remain_on_channel, |
Arend van Spriel | 27f10e3 | 2013-04-05 10:57:50 +0200 | [diff] [blame] | 4301 | .start_p2p_device = brcmf_p2p_start_device, |
| 4302 | .stop_p2p_device = brcmf_p2p_stop_device, |
Piotr Haber | 61730d4 | 2013-04-23 12:53:12 +0200 | [diff] [blame] | 4303 | .crit_proto_start = brcmf_cfg80211_crit_proto_start, |
| 4304 | .crit_proto_stop = brcmf_cfg80211_crit_proto_stop, |
Arend van Spriel | 89c2f38 | 2013-08-10 12:27:25 +0200 | [diff] [blame] | 4305 | .tdls_oper = brcmf_cfg80211_tdls_oper, |
Johannes Berg | e333547 | 2013-08-06 11:13:19 +0200 | [diff] [blame] | 4306 | CFG80211_TESTMODE_CMD(brcmf_cfg80211_testmode) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4307 | }; |
| 4308 | |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 4309 | static void brcmf_wiphy_pno_params(struct wiphy *wiphy) |
| 4310 | { |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 4311 | /* scheduled scan settings */ |
| 4312 | wiphy->max_sched_scan_ssids = BRCMF_PNO_MAX_PFN_COUNT; |
| 4313 | wiphy->max_match_sets = BRCMF_PNO_MAX_PFN_COUNT; |
| 4314 | wiphy->max_sched_scan_ie_len = BRCMF_SCAN_IE_LEN_MAX; |
| 4315 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
Arend van Spriel | e580607 | 2012-09-19 22:21:08 +0200 | [diff] [blame] | 4316 | } |
| 4317 | |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 4318 | static const struct ieee80211_iface_limit brcmf_iface_limits[] = { |
| 4319 | { |
Hante Meuleman | dded3d5 | 2013-02-08 15:53:57 +0100 | [diff] [blame] | 4320 | .max = 2, |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 4321 | .types = BIT(NL80211_IFTYPE_STATION) | |
| 4322 | BIT(NL80211_IFTYPE_ADHOC) | |
| 4323 | BIT(NL80211_IFTYPE_AP) |
| 4324 | }, |
| 4325 | { |
| 4326 | .max = 1, |
| 4327 | .types = BIT(NL80211_IFTYPE_P2P_CLIENT) | |
| 4328 | BIT(NL80211_IFTYPE_P2P_GO) |
| 4329 | }, |
Arend van Spriel | 9af221b | 2013-05-14 20:52:36 +0200 | [diff] [blame] | 4330 | { |
| 4331 | .max = 1, |
| 4332 | .types = BIT(NL80211_IFTYPE_P2P_DEVICE) |
| 4333 | } |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 4334 | }; |
| 4335 | static const struct ieee80211_iface_combination brcmf_iface_combos[] = { |
| 4336 | { |
Hante Meuleman | dded3d5 | 2013-02-08 15:53:57 +0100 | [diff] [blame] | 4337 | .max_interfaces = BRCMF_IFACE_MAX_CNT, |
Hante Meuleman | 1c9d30c | 2013-05-27 21:09:58 +0200 | [diff] [blame] | 4338 | .num_different_channels = 2, |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 4339 | .n_limits = ARRAY_SIZE(brcmf_iface_limits), |
| 4340 | .limits = brcmf_iface_limits |
| 4341 | } |
| 4342 | }; |
| 4343 | |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4344 | static const struct ieee80211_txrx_stypes |
| 4345 | brcmf_txrx_stypes[NUM_NL80211_IFTYPES] = { |
| 4346 | [NL80211_IFTYPE_STATION] = { |
| 4347 | .tx = 0xffff, |
| 4348 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 4349 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
| 4350 | }, |
| 4351 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 4352 | .tx = 0xffff, |
| 4353 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 4354 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
| 4355 | }, |
| 4356 | [NL80211_IFTYPE_P2P_GO] = { |
| 4357 | .tx = 0xffff, |
| 4358 | .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | |
| 4359 | BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | |
| 4360 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | |
| 4361 | BIT(IEEE80211_STYPE_DISASSOC >> 4) | |
| 4362 | BIT(IEEE80211_STYPE_AUTH >> 4) | |
| 4363 | BIT(IEEE80211_STYPE_DEAUTH >> 4) | |
| 4364 | BIT(IEEE80211_STYPE_ACTION >> 4) |
Arend van Spriel | bffc61c | 2013-04-05 10:57:52 +0200 | [diff] [blame] | 4365 | }, |
| 4366 | [NL80211_IFTYPE_P2P_DEVICE] = { |
| 4367 | .tx = 0xffff, |
| 4368 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 4369 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4370 | } |
| 4371 | }; |
| 4372 | |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4373 | static struct wiphy *brcmf_setup_wiphy(struct device *phydev) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4374 | { |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4375 | struct wiphy *wiphy; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4376 | s32 err = 0; |
| 4377 | |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4378 | wiphy = wiphy_new(&wl_cfg80211_ops, sizeof(struct brcmf_cfg80211_info)); |
| 4379 | if (!wiphy) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 4380 | brcmf_err("Could not allocate wiphy device\n"); |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4381 | return ERR_PTR(-ENOMEM); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4382 | } |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4383 | set_wiphy_dev(wiphy, phydev); |
| 4384 | wiphy->max_scan_ssids = WL_NUM_SCAN_MAX; |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 4385 | wiphy->max_scan_ie_len = BRCMF_SCAN_IE_LEN_MAX; |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4386 | wiphy->max_num_pmkids = WL_NUM_PMKIDS_MAX; |
| 4387 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | |
| 4388 | BIT(NL80211_IFTYPE_ADHOC) | |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 4389 | BIT(NL80211_IFTYPE_AP) | |
| 4390 | BIT(NL80211_IFTYPE_P2P_CLIENT) | |
Arend van Spriel | 9af221b | 2013-05-14 20:52:36 +0200 | [diff] [blame] | 4391 | BIT(NL80211_IFTYPE_P2P_GO) | |
| 4392 | BIT(NL80211_IFTYPE_P2P_DEVICE); |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 4393 | wiphy->iface_combinations = brcmf_iface_combos; |
| 4394 | wiphy->n_iface_combinations = ARRAY_SIZE(brcmf_iface_combos); |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4395 | wiphy->bands[IEEE80211_BAND_2GHZ] = &__wl_band_2ghz; |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4396 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 4397 | wiphy->cipher_suites = __wl_cipher_suites; |
| 4398 | wiphy->n_cipher_suites = ARRAY_SIZE(__wl_cipher_suites); |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4399 | wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT | |
Hante Meuleman | 6eda4e2 | 2013-02-08 15:54:02 +0100 | [diff] [blame] | 4400 | WIPHY_FLAG_OFFCHAN_TX | |
Arend van Spriel | 89c2f38 | 2013-08-10 12:27:25 +0200 | [diff] [blame] | 4401 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | |
| 4402 | WIPHY_FLAG_SUPPORTS_TDLS; |
Daniel Kim | 604bf23 | 2014-05-12 10:47:27 +0200 | [diff] [blame] | 4403 | if (!brcmf_roamoff) |
| 4404 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4405 | wiphy->mgmt_stypes = brcmf_txrx_stypes; |
| 4406 | wiphy->max_remain_on_channel_duration = 5000; |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4407 | brcmf_wiphy_pno_params(wiphy); |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 4408 | brcmf_dbg(INFO, "Registering custom regulatory\n"); |
Luis R. Rodriguez | a2f73b6 | 2013-11-11 22:15:29 +0100 | [diff] [blame] | 4409 | wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 4410 | wiphy_apply_custom_regulatory(wiphy, &brcmf_regdom); |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4411 | err = wiphy_register(wiphy); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4412 | if (err < 0) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 4413 | brcmf_err("Could not register wiphy device (%d)\n", err); |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4414 | wiphy_free(wiphy); |
| 4415 | return ERR_PTR(err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4416 | } |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4417 | return wiphy; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4418 | } |
| 4419 | |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4420 | struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg, |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 4421 | enum nl80211_iftype type, |
| 4422 | bool pm_block) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4423 | { |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4424 | struct brcmf_cfg80211_vif *vif; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4425 | |
Arend van Spriel | 33a6b15 | 2013-02-08 15:53:39 +0100 | [diff] [blame] | 4426 | brcmf_dbg(TRACE, "allocating virtual interface (size=%zu)\n", |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 4427 | sizeof(*vif)); |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4428 | vif = kzalloc(sizeof(*vif), GFP_KERNEL); |
| 4429 | if (!vif) |
| 4430 | return ERR_PTR(-ENOMEM); |
| 4431 | |
| 4432 | vif->wdev.wiphy = cfg->wiphy; |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 4433 | vif->wdev.iftype = type; |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4434 | |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4435 | vif->pm_block = pm_block; |
| 4436 | vif->roam_off = -1; |
| 4437 | |
Arend van Spriel | 6ac4f4e | 2012-10-22 13:55:31 -0700 | [diff] [blame] | 4438 | brcmf_init_prof(&vif->profile); |
| 4439 | |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4440 | list_add_tail(&vif->list, &cfg->vif_list); |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4441 | return vif; |
| 4442 | } |
| 4443 | |
Arend van Spriel | 427dec5 | 2014-01-06 12:40:47 +0100 | [diff] [blame] | 4444 | void brcmf_free_vif(struct brcmf_cfg80211_vif *vif) |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4445 | { |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4446 | list_del(&vif->list); |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4447 | kfree(vif); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4448 | } |
| 4449 | |
Arend van Spriel | 9df4d54 | 2014-01-06 12:40:49 +0100 | [diff] [blame] | 4450 | void brcmf_cfg80211_free_netdev(struct net_device *ndev) |
| 4451 | { |
| 4452 | struct brcmf_cfg80211_vif *vif; |
| 4453 | struct brcmf_if *ifp; |
| 4454 | |
| 4455 | ifp = netdev_priv(ndev); |
| 4456 | vif = ifp->vif; |
| 4457 | |
| 4458 | brcmf_free_vif(vif); |
| 4459 | free_netdev(ndev); |
| 4460 | } |
| 4461 | |
Arend van Spriel | 903e0ee | 2012-11-28 21:44:11 +0100 | [diff] [blame] | 4462 | static bool brcmf_is_linkup(const struct brcmf_event_msg *e) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4463 | { |
Arend van Spriel | 5c36b99 | 2012-11-14 18:46:05 -0800 | [diff] [blame] | 4464 | u32 event = e->event_code; |
| 4465 | u32 status = e->status; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4466 | |
| 4467 | if (event == BRCMF_E_SET_SSID && status == BRCMF_E_STATUS_SUCCESS) { |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 4468 | brcmf_dbg(CONN, "Processing set ssid\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4469 | return true; |
| 4470 | } |
| 4471 | |
| 4472 | return false; |
| 4473 | } |
| 4474 | |
Arend van Spriel | 903e0ee | 2012-11-28 21:44:11 +0100 | [diff] [blame] | 4475 | static bool brcmf_is_linkdown(const struct brcmf_event_msg *e) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4476 | { |
Arend van Spriel | 5c36b99 | 2012-11-14 18:46:05 -0800 | [diff] [blame] | 4477 | u32 event = e->event_code; |
| 4478 | u16 flags = e->flags; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4479 | |
Hante Meuleman | 68ca395 | 2014-02-25 20:30:26 +0100 | [diff] [blame] | 4480 | if ((event == BRCMF_E_DEAUTH) || (event == BRCMF_E_DEAUTH_IND) || |
| 4481 | (event == BRCMF_E_DISASSOC_IND) || |
| 4482 | ((event == BRCMF_E_LINK) && (!(flags & BRCMF_EVENT_MSG_LINK)))) { |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 4483 | brcmf_dbg(CONN, "Processing link down\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4484 | return true; |
| 4485 | } |
| 4486 | return false; |
| 4487 | } |
| 4488 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4489 | static bool brcmf_is_nonetwork(struct brcmf_cfg80211_info *cfg, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4490 | const struct brcmf_event_msg *e) |
| 4491 | { |
Arend van Spriel | 5c36b99 | 2012-11-14 18:46:05 -0800 | [diff] [blame] | 4492 | u32 event = e->event_code; |
| 4493 | u32 status = e->status; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4494 | |
| 4495 | if (event == BRCMF_E_LINK && status == BRCMF_E_STATUS_NO_NETWORKS) { |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 4496 | brcmf_dbg(CONN, "Processing Link %s & no network found\n", |
| 4497 | e->flags & BRCMF_EVENT_MSG_LINK ? "up" : "down"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4498 | return true; |
| 4499 | } |
| 4500 | |
| 4501 | if (event == BRCMF_E_SET_SSID && status != BRCMF_E_STATUS_SUCCESS) { |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 4502 | brcmf_dbg(CONN, "Processing connecting & no network found\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4503 | return true; |
| 4504 | } |
| 4505 | |
| 4506 | return false; |
| 4507 | } |
| 4508 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4509 | static void brcmf_clear_assoc_ies(struct brcmf_cfg80211_info *cfg) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4510 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4511 | struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4512 | |
| 4513 | kfree(conn_info->req_ie); |
| 4514 | conn_info->req_ie = NULL; |
| 4515 | conn_info->req_ie_len = 0; |
| 4516 | kfree(conn_info->resp_ie); |
| 4517 | conn_info->resp_ie = NULL; |
| 4518 | conn_info->resp_ie_len = 0; |
| 4519 | } |
| 4520 | |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 4521 | static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_info *cfg, |
| 4522 | struct brcmf_if *ifp) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4523 | { |
Arend van Spriel | c4e382d | 2011-10-12 20:51:21 +0200 | [diff] [blame] | 4524 | struct brcmf_cfg80211_assoc_ielen_le *assoc_info; |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4525 | struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4526 | u32 req_len; |
| 4527 | u32 resp_len; |
| 4528 | s32 err = 0; |
| 4529 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4530 | brcmf_clear_assoc_ies(cfg); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4531 | |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 4532 | err = brcmf_fil_iovar_data_get(ifp, "assoc_info", |
| 4533 | cfg->extra_buf, WL_ASSOC_INFO_MAX); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4534 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 4535 | brcmf_err("could not get assoc info (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4536 | return err; |
| 4537 | } |
Arend van Spriel | c4e382d | 2011-10-12 20:51:21 +0200 | [diff] [blame] | 4538 | assoc_info = |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4539 | (struct brcmf_cfg80211_assoc_ielen_le *)cfg->extra_buf; |
Arend van Spriel | c4e382d | 2011-10-12 20:51:21 +0200 | [diff] [blame] | 4540 | req_len = le32_to_cpu(assoc_info->req_len); |
| 4541 | resp_len = le32_to_cpu(assoc_info->resp_len); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4542 | if (req_len) { |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 4543 | err = brcmf_fil_iovar_data_get(ifp, "assoc_req_ies", |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 4544 | cfg->extra_buf, |
| 4545 | WL_ASSOC_INFO_MAX); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4546 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 4547 | brcmf_err("could not get assoc req (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4548 | return err; |
| 4549 | } |
| 4550 | conn_info->req_ie_len = req_len; |
| 4551 | conn_info->req_ie = |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4552 | kmemdup(cfg->extra_buf, conn_info->req_ie_len, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4553 | GFP_KERNEL); |
| 4554 | } else { |
| 4555 | conn_info->req_ie_len = 0; |
| 4556 | conn_info->req_ie = NULL; |
| 4557 | } |
| 4558 | if (resp_len) { |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 4559 | err = brcmf_fil_iovar_data_get(ifp, "assoc_resp_ies", |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 4560 | cfg->extra_buf, |
| 4561 | WL_ASSOC_INFO_MAX); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4562 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 4563 | brcmf_err("could not get assoc resp (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4564 | return err; |
| 4565 | } |
| 4566 | conn_info->resp_ie_len = resp_len; |
| 4567 | conn_info->resp_ie = |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4568 | kmemdup(cfg->extra_buf, conn_info->resp_ie_len, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4569 | GFP_KERNEL); |
| 4570 | } else { |
| 4571 | conn_info->resp_ie_len = 0; |
| 4572 | conn_info->resp_ie = NULL; |
| 4573 | } |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 4574 | brcmf_dbg(CONN, "req len (%d) resp len (%d)\n", |
| 4575 | conn_info->req_ie_len, conn_info->resp_ie_len); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4576 | |
| 4577 | return err; |
| 4578 | } |
| 4579 | |
| 4580 | static s32 |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4581 | brcmf_bss_roaming_done(struct brcmf_cfg80211_info *cfg, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4582 | struct net_device *ndev, |
| 4583 | const struct brcmf_event_msg *e) |
| 4584 | { |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 4585 | struct brcmf_if *ifp = netdev_priv(ndev); |
| 4586 | struct brcmf_cfg80211_profile *profile = &ifp->vif->profile; |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4587 | struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg); |
| 4588 | struct wiphy *wiphy = cfg_to_wiphy(cfg); |
Franky Lin | a180b83 | 2012-10-10 11:13:09 -0700 | [diff] [blame] | 4589 | struct ieee80211_channel *notify_channel = NULL; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4590 | struct ieee80211_supported_band *band; |
Franky Lin | a180b83 | 2012-10-10 11:13:09 -0700 | [diff] [blame] | 4591 | struct brcmf_bss_info_le *bi; |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 4592 | struct brcmu_chan ch; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4593 | u32 freq; |
| 4594 | s32 err = 0; |
Franky Lin | a180b83 | 2012-10-10 11:13:09 -0700 | [diff] [blame] | 4595 | u8 *buf; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4596 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 4597 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4598 | |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 4599 | brcmf_get_assoc_ies(cfg, ifp); |
Arend van Spriel | 6c8c4f7 | 2012-09-27 14:17:57 +0200 | [diff] [blame] | 4600 | memcpy(profile->bssid, e->addr, ETH_ALEN); |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 4601 | brcmf_update_bss_info(cfg, ifp); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4602 | |
Franky Lin | a180b83 | 2012-10-10 11:13:09 -0700 | [diff] [blame] | 4603 | buf = kzalloc(WL_BSS_INFO_MAX, GFP_KERNEL); |
| 4604 | if (buf == NULL) { |
| 4605 | err = -ENOMEM; |
| 4606 | goto done; |
| 4607 | } |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4608 | |
Franky Lin | a180b83 | 2012-10-10 11:13:09 -0700 | [diff] [blame] | 4609 | /* data sent to dongle has to be little endian */ |
| 4610 | *(__le32 *)buf = cpu_to_le32(WL_BSS_INFO_MAX); |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 4611 | err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_BSS_INFO, |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 4612 | buf, WL_BSS_INFO_MAX); |
Franky Lin | a180b83 | 2012-10-10 11:13:09 -0700 | [diff] [blame] | 4613 | |
| 4614 | if (err) |
| 4615 | goto done; |
| 4616 | |
| 4617 | bi = (struct brcmf_bss_info_le *)(buf + 4); |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 4618 | ch.chspec = le16_to_cpu(bi->chanspec); |
| 4619 | cfg->d11inf.decchspec(&ch); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4620 | |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 4621 | if (ch.band == BRCMU_CHAN_BAND_2G) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4622 | band = wiphy->bands[IEEE80211_BAND_2GHZ]; |
| 4623 | else |
| 4624 | band = wiphy->bands[IEEE80211_BAND_5GHZ]; |
| 4625 | |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 4626 | freq = ieee80211_channel_to_frequency(ch.chnum, band->band); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4627 | notify_channel = ieee80211_get_channel(wiphy, freq); |
| 4628 | |
Franky Lin | a180b83 | 2012-10-10 11:13:09 -0700 | [diff] [blame] | 4629 | done: |
| 4630 | kfree(buf); |
Arend van Spriel | 06bb123 | 2012-09-27 14:17:56 +0200 | [diff] [blame] | 4631 | cfg80211_roamed(ndev, notify_channel, (u8 *)profile->bssid, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4632 | conn_info->req_ie, conn_info->req_ie_len, |
| 4633 | conn_info->resp_ie, conn_info->resp_ie_len, GFP_KERNEL); |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 4634 | brcmf_dbg(CONN, "Report roaming result\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4635 | |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 4636 | set_bit(BRCMF_VIF_STATUS_CONNECTED, &ifp->vif->sme_state); |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 4637 | brcmf_dbg(TRACE, "Exit\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4638 | return err; |
| 4639 | } |
| 4640 | |
| 4641 | static s32 |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4642 | brcmf_bss_connect_done(struct brcmf_cfg80211_info *cfg, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4643 | struct net_device *ndev, const struct brcmf_event_msg *e, |
| 4644 | bool completed) |
| 4645 | { |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 4646 | struct brcmf_if *ifp = netdev_priv(ndev); |
| 4647 | struct brcmf_cfg80211_profile *profile = &ifp->vif->profile; |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4648 | struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4649 | |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 4650 | brcmf_dbg(TRACE, "Enter\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4651 | |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 4652 | if (test_and_clear_bit(BRCMF_VIF_STATUS_CONNECTING, |
| 4653 | &ifp->vif->sme_state)) { |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4654 | if (completed) { |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 4655 | brcmf_get_assoc_ies(cfg, ifp); |
Arend van Spriel | 6c8c4f7 | 2012-09-27 14:17:57 +0200 | [diff] [blame] | 4656 | memcpy(profile->bssid, e->addr, ETH_ALEN); |
Hante Meuleman | 89286dc | 2013-02-08 15:53:46 +0100 | [diff] [blame] | 4657 | brcmf_update_bss_info(cfg, ifp); |
| 4658 | set_bit(BRCMF_VIF_STATUS_CONNECTED, |
| 4659 | &ifp->vif->sme_state); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4660 | } |
| 4661 | cfg80211_connect_result(ndev, |
Arend van Spriel | 06bb123 | 2012-09-27 14:17:56 +0200 | [diff] [blame] | 4662 | (u8 *)profile->bssid, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4663 | conn_info->req_ie, |
| 4664 | conn_info->req_ie_len, |
| 4665 | conn_info->resp_ie, |
| 4666 | conn_info->resp_ie_len, |
| 4667 | completed ? WLAN_STATUS_SUCCESS : |
| 4668 | WLAN_STATUS_AUTH_TIMEOUT, |
| 4669 | GFP_KERNEL); |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 4670 | brcmf_dbg(CONN, "Report connect result - connection %s\n", |
| 4671 | completed ? "succeeded" : "failed"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4672 | } |
Arend van Spriel | d96b801 | 2012-12-05 15:26:02 +0100 | [diff] [blame] | 4673 | brcmf_dbg(TRACE, "Exit\n"); |
Peter Senna Tschudin | 12f3237 | 2014-05-31 10:14:06 -0300 | [diff] [blame^] | 4674 | return 0; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4675 | } |
| 4676 | |
| 4677 | static s32 |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4678 | brcmf_notify_connect_status_ap(struct brcmf_cfg80211_info *cfg, |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4679 | struct net_device *ndev, |
| 4680 | const struct brcmf_event_msg *e, void *data) |
| 4681 | { |
Hante Meuleman | 7ee2960 | 2013-02-06 18:40:43 +0100 | [diff] [blame] | 4682 | static int generation; |
Arend van Spriel | 5c36b99 | 2012-11-14 18:46:05 -0800 | [diff] [blame] | 4683 | u32 event = e->event_code; |
| 4684 | u32 reason = e->reason; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4685 | struct station_info sinfo; |
| 4686 | |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 4687 | brcmf_dbg(CONN, "event %d, reason %d\n", event, reason); |
Arend van Spriel | 5f4f9f1 | 2013-02-08 15:53:41 +0100 | [diff] [blame] | 4688 | if (event == BRCMF_E_LINK && reason == BRCMF_E_REASON_LINK_BSSCFG_DIS && |
| 4689 | ndev != cfg_to_ndev(cfg)) { |
| 4690 | brcmf_dbg(CONN, "AP mode link down\n"); |
| 4691 | complete(&cfg->vif_disabled); |
| 4692 | return 0; |
| 4693 | } |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4694 | |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4695 | if (((event == BRCMF_E_ASSOC_IND) || (event == BRCMF_E_REASSOC_IND)) && |
Hante Meuleman | 7ee2960 | 2013-02-06 18:40:43 +0100 | [diff] [blame] | 4696 | (reason == BRCMF_E_STATUS_SUCCESS)) { |
| 4697 | memset(&sinfo, 0, sizeof(sinfo)); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4698 | sinfo.filled = STATION_INFO_ASSOC_REQ_IES; |
| 4699 | if (!data) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 4700 | brcmf_err("No IEs present in ASSOC/REASSOC_IND"); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4701 | return -EINVAL; |
| 4702 | } |
| 4703 | sinfo.assoc_req_ies = data; |
Hante Meuleman | 7ee2960 | 2013-02-06 18:40:43 +0100 | [diff] [blame] | 4704 | sinfo.assoc_req_ies_len = e->datalen; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4705 | generation++; |
| 4706 | sinfo.generation = generation; |
Hante Meuleman | 7ee2960 | 2013-02-06 18:40:43 +0100 | [diff] [blame] | 4707 | cfg80211_new_sta(ndev, e->addr, &sinfo, GFP_KERNEL); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4708 | } else if ((event == BRCMF_E_DISASSOC_IND) || |
| 4709 | (event == BRCMF_E_DEAUTH_IND) || |
| 4710 | (event == BRCMF_E_DEAUTH)) { |
Hante Meuleman | 7ee2960 | 2013-02-06 18:40:43 +0100 | [diff] [blame] | 4711 | cfg80211_del_sta(ndev, e->addr, GFP_KERNEL); |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4712 | } |
Hante Meuleman | 7ee2960 | 2013-02-06 18:40:43 +0100 | [diff] [blame] | 4713 | return 0; |
Hante Meuleman | 1a87334 | 2012-09-27 14:17:54 +0200 | [diff] [blame] | 4714 | } |
| 4715 | |
| 4716 | static s32 |
Arend van Spriel | 1993732 | 2012-11-05 16:22:32 -0800 | [diff] [blame] | 4717 | brcmf_notify_connect_status(struct brcmf_if *ifp, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4718 | const struct brcmf_event_msg *e, void *data) |
| 4719 | { |
Arend van Spriel | 1993732 | 2012-11-05 16:22:32 -0800 | [diff] [blame] | 4720 | struct brcmf_cfg80211_info *cfg = ifp->drvr->config; |
| 4721 | struct net_device *ndev = ifp->ndev; |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 4722 | struct brcmf_cfg80211_profile *profile = &ifp->vif->profile; |
Antonio Quartulli | fe94f3a | 2014-01-29 17:53:43 +0100 | [diff] [blame] | 4723 | struct ieee80211_channel *chan; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4724 | s32 err = 0; |
| 4725 | |
Arend van Spriel | 967fe2c | 2014-03-15 17:18:21 +0100 | [diff] [blame] | 4726 | if (brcmf_is_apmode(ifp->vif)) { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4727 | err = brcmf_notify_connect_status_ap(cfg, ndev, e, data); |
Arend van Spriel | 903e0ee | 2012-11-28 21:44:11 +0100 | [diff] [blame] | 4728 | } else if (brcmf_is_linkup(e)) { |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 4729 | brcmf_dbg(CONN, "Linkup\n"); |
Arend van Spriel | 128ce3b | 2012-11-28 21:44:12 +0100 | [diff] [blame] | 4730 | if (brcmf_is_ibssmode(ifp->vif)) { |
Antonio Quartulli | fe94f3a | 2014-01-29 17:53:43 +0100 | [diff] [blame] | 4731 | chan = ieee80211_get_channel(cfg->wiphy, cfg->channel); |
Arend van Spriel | 6c8c4f7 | 2012-09-27 14:17:57 +0200 | [diff] [blame] | 4732 | memcpy(profile->bssid, e->addr, ETH_ALEN); |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4733 | wl_inform_ibss(cfg, ndev, e->addr); |
Antonio Quartulli | fe94f3a | 2014-01-29 17:53:43 +0100 | [diff] [blame] | 4734 | cfg80211_ibss_joined(ndev, e->addr, chan, GFP_KERNEL); |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 4735 | clear_bit(BRCMF_VIF_STATUS_CONNECTING, |
| 4736 | &ifp->vif->sme_state); |
| 4737 | set_bit(BRCMF_VIF_STATUS_CONNECTED, |
| 4738 | &ifp->vif->sme_state); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4739 | } else |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4740 | brcmf_bss_connect_done(cfg, ndev, e, true); |
Arend van Spriel | 903e0ee | 2012-11-28 21:44:11 +0100 | [diff] [blame] | 4741 | } else if (brcmf_is_linkdown(e)) { |
Arend van Spriel | 1688673 | 2012-12-05 15:26:04 +0100 | [diff] [blame] | 4742 | brcmf_dbg(CONN, "Linkdown\n"); |
Arend van Spriel | 128ce3b | 2012-11-28 21:44:12 +0100 | [diff] [blame] | 4743 | if (!brcmf_is_ibssmode(ifp->vif)) { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4744 | brcmf_bss_connect_done(cfg, ndev, e, false); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4745 | } |
Arend van Spriel | 903e0ee | 2012-11-28 21:44:11 +0100 | [diff] [blame] | 4746 | brcmf_link_down(ifp->vif); |
Arend van Spriel | 6ac4f4e | 2012-10-22 13:55:31 -0700 | [diff] [blame] | 4747 | brcmf_init_prof(ndev_to_prof(ndev)); |
Arend van Spriel | 5f4f9f1 | 2013-02-08 15:53:41 +0100 | [diff] [blame] | 4748 | if (ndev != cfg_to_ndev(cfg)) |
| 4749 | complete(&cfg->vif_disabled); |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4750 | } else if (brcmf_is_nonetwork(cfg, e)) { |
Arend van Spriel | 128ce3b | 2012-11-28 21:44:12 +0100 | [diff] [blame] | 4751 | if (brcmf_is_ibssmode(ifp->vif)) |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 4752 | clear_bit(BRCMF_VIF_STATUS_CONNECTING, |
| 4753 | &ifp->vif->sme_state); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4754 | else |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4755 | brcmf_bss_connect_done(cfg, ndev, e, false); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4756 | } |
| 4757 | |
| 4758 | return err; |
| 4759 | } |
| 4760 | |
| 4761 | static s32 |
Arend van Spriel | 1993732 | 2012-11-05 16:22:32 -0800 | [diff] [blame] | 4762 | brcmf_notify_roaming_status(struct brcmf_if *ifp, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4763 | const struct brcmf_event_msg *e, void *data) |
| 4764 | { |
Arend van Spriel | 1993732 | 2012-11-05 16:22:32 -0800 | [diff] [blame] | 4765 | struct brcmf_cfg80211_info *cfg = ifp->drvr->config; |
Arend van Spriel | 5c36b99 | 2012-11-14 18:46:05 -0800 | [diff] [blame] | 4766 | u32 event = e->event_code; |
| 4767 | u32 status = e->status; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4768 | |
| 4769 | if (event == BRCMF_E_ROAM && status == BRCMF_E_STATUS_SUCCESS) { |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 4770 | if (test_bit(BRCMF_VIF_STATUS_CONNECTED, &ifp->vif->sme_state)) |
Arend van Spriel | 1993732 | 2012-11-05 16:22:32 -0800 | [diff] [blame] | 4771 | brcmf_bss_roaming_done(cfg, ifp->ndev, e); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4772 | else |
Arend van Spriel | 1993732 | 2012-11-05 16:22:32 -0800 | [diff] [blame] | 4773 | brcmf_bss_connect_done(cfg, ifp->ndev, e, true); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4774 | } |
| 4775 | |
Peter Senna Tschudin | 12f3237 | 2014-05-31 10:14:06 -0300 | [diff] [blame^] | 4776 | return 0; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4777 | } |
| 4778 | |
| 4779 | static s32 |
Arend van Spriel | 1993732 | 2012-11-05 16:22:32 -0800 | [diff] [blame] | 4780 | brcmf_notify_mic_status(struct brcmf_if *ifp, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4781 | const struct brcmf_event_msg *e, void *data) |
| 4782 | { |
Arend van Spriel | 5c36b99 | 2012-11-14 18:46:05 -0800 | [diff] [blame] | 4783 | u16 flags = e->flags; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4784 | enum nl80211_key_type key_type; |
| 4785 | |
| 4786 | if (flags & BRCMF_EVENT_MSG_GROUP) |
| 4787 | key_type = NL80211_KEYTYPE_GROUP; |
| 4788 | else |
| 4789 | key_type = NL80211_KEYTYPE_PAIRWISE; |
| 4790 | |
Arend van Spriel | 1993732 | 2012-11-05 16:22:32 -0800 | [diff] [blame] | 4791 | cfg80211_michael_mic_failure(ifp->ndev, (u8 *)&e->addr, key_type, -1, |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4792 | NULL, GFP_KERNEL); |
| 4793 | |
| 4794 | return 0; |
| 4795 | } |
| 4796 | |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 4797 | static s32 brcmf_notify_vif_event(struct brcmf_if *ifp, |
| 4798 | const struct brcmf_event_msg *e, void *data) |
| 4799 | { |
| 4800 | struct brcmf_cfg80211_info *cfg = ifp->drvr->config; |
| 4801 | struct brcmf_if_event *ifevent = (struct brcmf_if_event *)data; |
| 4802 | struct brcmf_cfg80211_vif_event *event = &cfg->vif_event; |
| 4803 | struct brcmf_cfg80211_vif *vif; |
| 4804 | |
| 4805 | brcmf_dbg(TRACE, "Enter: action %u flags %u ifidx %u bsscfg %u\n", |
| 4806 | ifevent->action, ifevent->flags, ifevent->ifidx, |
| 4807 | ifevent->bssidx); |
| 4808 | |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 4809 | mutex_lock(&event->vif_event_lock); |
| 4810 | event->action = ifevent->action; |
| 4811 | vif = event->vif; |
| 4812 | |
| 4813 | switch (ifevent->action) { |
| 4814 | case BRCMF_E_IF_ADD: |
| 4815 | /* waiting process may have timed out */ |
Wei Yongjun | dc4a787 | 2013-02-22 21:32:20 +0800 | [diff] [blame] | 4816 | if (!cfg->vif_event.vif) { |
| 4817 | mutex_unlock(&event->vif_event_lock); |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 4818 | return -EBADF; |
Wei Yongjun | dc4a787 | 2013-02-22 21:32:20 +0800 | [diff] [blame] | 4819 | } |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 4820 | |
| 4821 | ifp->vif = vif; |
| 4822 | vif->ifp = ifp; |
Arend van Spriel | 01b8e7d | 2013-04-05 10:57:51 +0200 | [diff] [blame] | 4823 | if (ifp->ndev) { |
| 4824 | vif->wdev.netdev = ifp->ndev; |
| 4825 | ifp->ndev->ieee80211_ptr = &vif->wdev; |
| 4826 | SET_NETDEV_DEV(ifp->ndev, wiphy_dev(cfg->wiphy)); |
| 4827 | } |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 4828 | mutex_unlock(&event->vif_event_lock); |
| 4829 | wake_up(&event->vif_wq); |
Hante Meuleman | 4b3a89d | 2013-02-08 15:54:01 +0100 | [diff] [blame] | 4830 | return 0; |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 4831 | |
| 4832 | case BRCMF_E_IF_DEL: |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 4833 | mutex_unlock(&event->vif_event_lock); |
| 4834 | /* event may not be upon user request */ |
| 4835 | if (brcmf_cfg80211_vif_event_armed(cfg)) |
| 4836 | wake_up(&event->vif_wq); |
| 4837 | return 0; |
| 4838 | |
Hante Meuleman | 7a5c1f6 | 2013-02-08 15:53:44 +0100 | [diff] [blame] | 4839 | case BRCMF_E_IF_CHANGE: |
| 4840 | mutex_unlock(&event->vif_event_lock); |
| 4841 | wake_up(&event->vif_wq); |
| 4842 | return 0; |
| 4843 | |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 4844 | default: |
| 4845 | mutex_unlock(&event->vif_event_lock); |
| 4846 | break; |
| 4847 | } |
| 4848 | return -EINVAL; |
| 4849 | } |
| 4850 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4851 | static void brcmf_init_conf(struct brcmf_cfg80211_conf *conf) |
| 4852 | { |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4853 | conf->frag_threshold = (u32)-1; |
| 4854 | conf->rts_threshold = (u32)-1; |
| 4855 | conf->retry_short = (u32)-1; |
| 4856 | conf->retry_long = (u32)-1; |
| 4857 | conf->tx_power = -1; |
| 4858 | } |
| 4859 | |
Arend van Spriel | 5c36b99 | 2012-11-14 18:46:05 -0800 | [diff] [blame] | 4860 | static void brcmf_register_event_handlers(struct brcmf_cfg80211_info *cfg) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4861 | { |
Arend van Spriel | 5c36b99 | 2012-11-14 18:46:05 -0800 | [diff] [blame] | 4862 | brcmf_fweh_register(cfg->pub, BRCMF_E_LINK, |
| 4863 | brcmf_notify_connect_status); |
| 4864 | brcmf_fweh_register(cfg->pub, BRCMF_E_DEAUTH_IND, |
| 4865 | brcmf_notify_connect_status); |
| 4866 | brcmf_fweh_register(cfg->pub, BRCMF_E_DEAUTH, |
| 4867 | brcmf_notify_connect_status); |
| 4868 | brcmf_fweh_register(cfg->pub, BRCMF_E_DISASSOC_IND, |
| 4869 | brcmf_notify_connect_status); |
| 4870 | brcmf_fweh_register(cfg->pub, BRCMF_E_ASSOC_IND, |
| 4871 | brcmf_notify_connect_status); |
| 4872 | brcmf_fweh_register(cfg->pub, BRCMF_E_REASSOC_IND, |
| 4873 | brcmf_notify_connect_status); |
| 4874 | brcmf_fweh_register(cfg->pub, BRCMF_E_ROAM, |
| 4875 | brcmf_notify_roaming_status); |
| 4876 | brcmf_fweh_register(cfg->pub, BRCMF_E_MIC_ERROR, |
| 4877 | brcmf_notify_mic_status); |
| 4878 | brcmf_fweh_register(cfg->pub, BRCMF_E_SET_SSID, |
| 4879 | brcmf_notify_connect_status); |
| 4880 | brcmf_fweh_register(cfg->pub, BRCMF_E_PFN_NET_FOUND, |
| 4881 | brcmf_notify_sched_scan_results); |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 4882 | brcmf_fweh_register(cfg->pub, BRCMF_E_IF, |
| 4883 | brcmf_notify_vif_event); |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4884 | brcmf_fweh_register(cfg->pub, BRCMF_E_P2P_PROBEREQ_MSG, |
Hante Meuleman | 6eda4e2 | 2013-02-08 15:54:02 +0100 | [diff] [blame] | 4885 | brcmf_p2p_notify_rx_mgmt_p2p_probereq); |
Hante Meuleman | 0de8aac | 2013-02-08 15:53:38 +0100 | [diff] [blame] | 4886 | brcmf_fweh_register(cfg->pub, BRCMF_E_P2P_DISC_LISTEN_COMPLETE, |
| 4887 | brcmf_p2p_notify_listen_complete); |
Hante Meuleman | e6da340 | 2013-02-08 15:53:48 +0100 | [diff] [blame] | 4888 | brcmf_fweh_register(cfg->pub, BRCMF_E_ACTION_FRAME_RX, |
| 4889 | brcmf_p2p_notify_action_frame_rx); |
Hante Meuleman | 18e2f61 | 2013-02-08 15:53:49 +0100 | [diff] [blame] | 4890 | brcmf_fweh_register(cfg->pub, BRCMF_E_ACTION_FRAME_COMPLETE, |
| 4891 | brcmf_p2p_notify_action_tx_complete); |
Hante Meuleman | 6eda4e2 | 2013-02-08 15:54:02 +0100 | [diff] [blame] | 4892 | brcmf_fweh_register(cfg->pub, BRCMF_E_ACTION_FRAME_OFF_CHAN_COMPLETE, |
| 4893 | brcmf_p2p_notify_action_tx_complete); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4894 | } |
| 4895 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4896 | static void brcmf_deinit_priv_mem(struct brcmf_cfg80211_info *cfg) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4897 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4898 | kfree(cfg->conf); |
| 4899 | cfg->conf = NULL; |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4900 | kfree(cfg->escan_ioctl_buf); |
| 4901 | cfg->escan_ioctl_buf = NULL; |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4902 | kfree(cfg->extra_buf); |
| 4903 | cfg->extra_buf = NULL; |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4904 | kfree(cfg->pmk_list); |
| 4905 | cfg->pmk_list = NULL; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4906 | } |
| 4907 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4908 | static s32 brcmf_init_priv_mem(struct brcmf_cfg80211_info *cfg) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4909 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4910 | cfg->conf = kzalloc(sizeof(*cfg->conf), GFP_KERNEL); |
| 4911 | if (!cfg->conf) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4912 | goto init_priv_mem_out; |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4913 | cfg->escan_ioctl_buf = kzalloc(BRCMF_DCMD_MEDLEN, GFP_KERNEL); |
| 4914 | if (!cfg->escan_ioctl_buf) |
Hante Meuleman | e756af5 | 2012-09-11 21:18:52 +0200 | [diff] [blame] | 4915 | goto init_priv_mem_out; |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4916 | cfg->extra_buf = kzalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL); |
| 4917 | if (!cfg->extra_buf) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4918 | goto init_priv_mem_out; |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4919 | cfg->pmk_list = kzalloc(sizeof(*cfg->pmk_list), GFP_KERNEL); |
| 4920 | if (!cfg->pmk_list) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4921 | goto init_priv_mem_out; |
| 4922 | |
| 4923 | return 0; |
| 4924 | |
| 4925 | init_priv_mem_out: |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4926 | brcmf_deinit_priv_mem(cfg); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4927 | |
| 4928 | return -ENOMEM; |
| 4929 | } |
| 4930 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4931 | static s32 wl_init_priv(struct brcmf_cfg80211_info *cfg) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4932 | { |
| 4933 | s32 err = 0; |
| 4934 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4935 | cfg->scan_request = NULL; |
| 4936 | cfg->pwr_save = true; |
Hante Meuleman | 68ca395 | 2014-02-25 20:30:26 +0100 | [diff] [blame] | 4937 | cfg->active_scan = true; /* we do active scan per default */ |
| 4938 | cfg->dongle_up = false; /* dongle is not up yet */ |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4939 | err = brcmf_init_priv_mem(cfg); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4940 | if (err) |
| 4941 | return err; |
Arend van Spriel | 5c36b99 | 2012-11-14 18:46:05 -0800 | [diff] [blame] | 4942 | brcmf_register_event_handlers(cfg); |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4943 | mutex_init(&cfg->usr_sync); |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4944 | brcmf_init_escan(cfg); |
| 4945 | brcmf_init_conf(cfg->conf); |
Arend van Spriel | 5f4f9f1 | 2013-02-08 15:53:41 +0100 | [diff] [blame] | 4946 | init_completion(&cfg->vif_disabled); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4947 | return err; |
| 4948 | } |
| 4949 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4950 | static void wl_deinit_priv(struct brcmf_cfg80211_info *cfg) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4951 | { |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4952 | cfg->dongle_up = false; /* dongle down */ |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4953 | brcmf_abort_scanning(cfg); |
| 4954 | brcmf_deinit_priv_mem(cfg); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4955 | } |
| 4956 | |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 4957 | static void init_vif_event(struct brcmf_cfg80211_vif_event *event) |
| 4958 | { |
| 4959 | init_waitqueue_head(&event->vif_wq); |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 4960 | mutex_init(&event->vif_event_lock); |
| 4961 | } |
| 4962 | |
Arend van Spriel | 67b3bd4 | 2014-03-20 10:18:03 +0100 | [diff] [blame] | 4963 | static int brcmf_enable_bw40_2g(struct brcmf_if *ifp) |
Daniel Kim | d235367 | 2014-03-20 10:18:00 +0100 | [diff] [blame] | 4964 | { |
| 4965 | struct brcmf_fil_bwcap_le band_bwcap; |
Arend van Spriel | 67b3bd4 | 2014-03-20 10:18:03 +0100 | [diff] [blame] | 4966 | u32 val; |
Daniel Kim | d235367 | 2014-03-20 10:18:00 +0100 | [diff] [blame] | 4967 | int err; |
| 4968 | |
Arend van Spriel | 67b3bd4 | 2014-03-20 10:18:03 +0100 | [diff] [blame] | 4969 | /* verify support for bw_cap command */ |
| 4970 | val = WLC_BAND_5G; |
| 4971 | err = brcmf_fil_iovar_int_get(ifp, "bw_cap", &val); |
Daniel Kim | d235367 | 2014-03-20 10:18:00 +0100 | [diff] [blame] | 4972 | |
Arend van Spriel | 67b3bd4 | 2014-03-20 10:18:03 +0100 | [diff] [blame] | 4973 | if (!err) { |
| 4974 | /* only set 2G bandwidth using bw_cap command */ |
| 4975 | band_bwcap.band = cpu_to_le32(WLC_BAND_2G); |
Daniel Kim | 03e5da1 | 2014-05-09 12:37:05 +0200 | [diff] [blame] | 4976 | band_bwcap.bw_cap = cpu_to_le32(WLC_BW_CAP_40MHZ); |
Arend van Spriel | 67b3bd4 | 2014-03-20 10:18:03 +0100 | [diff] [blame] | 4977 | err = brcmf_fil_iovar_data_set(ifp, "bw_cap", &band_bwcap, |
| 4978 | sizeof(band_bwcap)); |
| 4979 | } else { |
| 4980 | brcmf_dbg(INFO, "fallback to mimo_bw_cap\n"); |
| 4981 | val = WLC_N_BW_40ALL; |
| 4982 | err = brcmf_fil_iovar_int_set(ifp, "mimo_bw_cap", val); |
| 4983 | } |
Daniel Kim | d235367 | 2014-03-20 10:18:00 +0100 | [diff] [blame] | 4984 | return err; |
| 4985 | } |
| 4986 | |
Arend van Spriel | d9cb259 | 2012-12-05 15:25:54 +0100 | [diff] [blame] | 4987 | struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr, |
| 4988 | struct device *busdev) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4989 | { |
Arend van Spriel | 1ed9baf | 2012-10-22 10:36:20 -0700 | [diff] [blame] | 4990 | struct net_device *ndev = drvr->iflist[0]->ndev; |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 4991 | struct brcmf_cfg80211_info *cfg; |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 4992 | struct wiphy *wiphy; |
| 4993 | struct brcmf_cfg80211_vif *vif; |
| 4994 | struct brcmf_if *ifp; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4995 | s32 err = 0; |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 4996 | s32 io_type; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 4997 | |
| 4998 | if (!ndev) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 4999 | brcmf_err("ndev is invalid\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5000 | return NULL; |
| 5001 | } |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5002 | |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 5003 | ifp = netdev_priv(ndev); |
| 5004 | wiphy = brcmf_setup_wiphy(busdev); |
| 5005 | if (IS_ERR(wiphy)) |
| 5006 | return NULL; |
| 5007 | |
| 5008 | cfg = wiphy_priv(wiphy); |
| 5009 | cfg->wiphy = wiphy; |
| 5010 | cfg->pub = drvr; |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 5011 | init_vif_event(&cfg->vif_event); |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 5012 | INIT_LIST_HEAD(&cfg->vif_list); |
| 5013 | |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 5014 | vif = brcmf_alloc_vif(cfg, NL80211_IFTYPE_STATION, false); |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 5015 | if (IS_ERR(vif)) { |
| 5016 | wiphy_free(wiphy); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5017 | return NULL; |
| 5018 | } |
| 5019 | |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 5020 | vif->ifp = ifp; |
| 5021 | vif->wdev.netdev = ndev; |
| 5022 | ndev->ieee80211_ptr = &vif->wdev; |
| 5023 | SET_NETDEV_DEV(ndev, wiphy_dev(cfg->wiphy)); |
| 5024 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5025 | err = wl_init_priv(cfg); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5026 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 5027 | brcmf_err("Failed to init iwm_priv (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5028 | goto cfg80211_attach_out; |
| 5029 | } |
Arend van Spriel | 3eacf86 | 2012-10-22 13:55:30 -0700 | [diff] [blame] | 5030 | ifp->vif = vif; |
Hante Meuleman | 2fde59d | 2013-02-08 15:53:52 +0100 | [diff] [blame] | 5031 | |
| 5032 | err = brcmf_p2p_attach(cfg); |
| 5033 | if (err) { |
| 5034 | brcmf_err("P2P initilisation failed (%d)\n", err); |
| 5035 | goto cfg80211_p2p_attach_out; |
| 5036 | } |
Piotr Haber | 61730d4 | 2013-04-23 12:53:12 +0200 | [diff] [blame] | 5037 | err = brcmf_btcoex_attach(cfg); |
| 5038 | if (err) { |
| 5039 | brcmf_err("BT-coex initialisation failed (%d)\n", err); |
| 5040 | brcmf_p2p_detach(&cfg->p2p); |
| 5041 | goto cfg80211_p2p_attach_out; |
| 5042 | } |
Hante Meuleman | 2fde59d | 2013-02-08 15:53:52 +0100 | [diff] [blame] | 5043 | |
Daniel Kim | d235367 | 2014-03-20 10:18:00 +0100 | [diff] [blame] | 5044 | /* If cfg80211 didn't disable 40MHz HT CAP in wiphy_register(), |
| 5045 | * setup 40MHz in 2GHz band and enable OBSS scanning. |
| 5046 | */ |
| 5047 | if (wiphy->bands[IEEE80211_BAND_2GHZ]->ht_cap.cap & |
| 5048 | IEEE80211_HT_CAP_SUP_WIDTH_20_40) { |
Arend van Spriel | 67b3bd4 | 2014-03-20 10:18:03 +0100 | [diff] [blame] | 5049 | err = brcmf_enable_bw40_2g(ifp); |
| 5050 | if (!err) |
Daniel Kim | d235367 | 2014-03-20 10:18:00 +0100 | [diff] [blame] | 5051 | err = brcmf_fil_iovar_int_set(ifp, "obss_coex", |
| 5052 | BRCMF_OBSS_COEX_AUTO); |
Daniel Kim | d235367 | 2014-03-20 10:18:00 +0100 | [diff] [blame] | 5053 | } |
| 5054 | |
Arend van Spriel | 89c2f38 | 2013-08-10 12:27:25 +0200 | [diff] [blame] | 5055 | err = brcmf_fil_iovar_int_set(ifp, "tdls_enable", 1); |
| 5056 | if (err) { |
| 5057 | brcmf_dbg(INFO, "TDLS not enabled (%d)\n", err); |
| 5058 | wiphy->flags &= ~WIPHY_FLAG_SUPPORTS_TDLS; |
| 5059 | } |
| 5060 | |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 5061 | err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_VERSION, |
| 5062 | &io_type); |
| 5063 | if (err) { |
| 5064 | brcmf_err("Failed to get D11 version (%d)\n", err); |
| 5065 | goto cfg80211_p2p_attach_out; |
| 5066 | } |
| 5067 | cfg->d11inf.io_type = (u8)io_type; |
| 5068 | brcmu_d11_attach(&cfg->d11inf); |
| 5069 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5070 | return cfg; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5071 | |
Hante Meuleman | 2fde59d | 2013-02-08 15:53:52 +0100 | [diff] [blame] | 5072 | cfg80211_p2p_attach_out: |
| 5073 | wl_deinit_priv(cfg); |
| 5074 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5075 | cfg80211_attach_out: |
Arend van Spriel | 427dec5 | 2014-01-06 12:40:47 +0100 | [diff] [blame] | 5076 | brcmf_free_vif(vif); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5077 | return NULL; |
| 5078 | } |
| 5079 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5080 | void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5081 | { |
Arend van Spriel | e147995 | 2014-01-06 12:40:48 +0100 | [diff] [blame] | 5082 | if (!cfg) |
| 5083 | return; |
| 5084 | |
Arend van Spriel | 427dec5 | 2014-01-06 12:40:47 +0100 | [diff] [blame] | 5085 | WARN_ON(!list_empty(&cfg->vif_list)); |
| 5086 | wiphy_unregister(cfg->wiphy); |
Piotr Haber | 61730d4 | 2013-04-23 12:53:12 +0200 | [diff] [blame] | 5087 | brcmf_btcoex_detach(cfg); |
Arend van Spriel | 427dec5 | 2014-01-06 12:40:47 +0100 | [diff] [blame] | 5088 | wl_deinit_priv(cfg); |
| 5089 | wiphy_free(cfg->wiphy); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5090 | } |
| 5091 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5092 | static s32 |
Hante Meuleman | 68ca395 | 2014-02-25 20:30:26 +0100 | [diff] [blame] | 5093 | brcmf_dongle_roam(struct brcmf_if *ifp, u32 bcn_timeout) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5094 | { |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5095 | s32 err = 0; |
Arend van Spriel | f588bc0 | 2011-10-12 20:51:22 +0200 | [diff] [blame] | 5096 | __le32 roamtrigger[2]; |
| 5097 | __le32 roam_delta[2]; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5098 | |
| 5099 | /* |
| 5100 | * Setup timeout if Beacons are lost and roam is |
| 5101 | * off to report link down |
| 5102 | */ |
Hante Meuleman | 68ca395 | 2014-02-25 20:30:26 +0100 | [diff] [blame] | 5103 | if (brcmf_roamoff) { |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 5104 | err = brcmf_fil_iovar_int_set(ifp, "bcn_timeout", bcn_timeout); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5105 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 5106 | brcmf_err("bcn_timeout error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5107 | goto dongle_rom_out; |
| 5108 | } |
| 5109 | } |
| 5110 | |
| 5111 | /* |
| 5112 | * Enable/Disable built-in roaming to allow supplicant |
| 5113 | * to take care of roaming |
| 5114 | */ |
Hante Meuleman | 68ca395 | 2014-02-25 20:30:26 +0100 | [diff] [blame] | 5115 | brcmf_dbg(INFO, "Internal Roaming = %s\n", |
| 5116 | brcmf_roamoff ? "Off" : "On"); |
| 5117 | err = brcmf_fil_iovar_int_set(ifp, "roam_off", !!(brcmf_roamoff)); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5118 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 5119 | brcmf_err("roam_off error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5120 | goto dongle_rom_out; |
| 5121 | } |
| 5122 | |
Arend van Spriel | f588bc0 | 2011-10-12 20:51:22 +0200 | [diff] [blame] | 5123 | roamtrigger[0] = cpu_to_le32(WL_ROAM_TRIGGER_LEVEL); |
| 5124 | roamtrigger[1] = cpu_to_le32(BRCM_BAND_ALL); |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 5125 | err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_ROAM_TRIGGER, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 5126 | (void *)roamtrigger, sizeof(roamtrigger)); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5127 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 5128 | brcmf_err("WLC_SET_ROAM_TRIGGER error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5129 | goto dongle_rom_out; |
| 5130 | } |
| 5131 | |
Arend van Spriel | f588bc0 | 2011-10-12 20:51:22 +0200 | [diff] [blame] | 5132 | roam_delta[0] = cpu_to_le32(WL_ROAM_DELTA); |
| 5133 | roam_delta[1] = cpu_to_le32(BRCM_BAND_ALL); |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 5134 | err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_ROAM_DELTA, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 5135 | (void *)roam_delta, sizeof(roam_delta)); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5136 | if (err) { |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 5137 | brcmf_err("WLC_SET_ROAM_DELTA error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5138 | goto dongle_rom_out; |
| 5139 | } |
| 5140 | |
| 5141 | dongle_rom_out: |
| 5142 | return err; |
| 5143 | } |
| 5144 | |
| 5145 | static s32 |
Hante Meuleman | 40a2329 | 2013-01-02 15:22:51 +0100 | [diff] [blame] | 5146 | brcmf_dongle_scantime(struct brcmf_if *ifp, s32 scan_assoc_time, |
Arend van Spriel | c68cdc0 | 2011-10-12 20:51:23 +0200 | [diff] [blame] | 5147 | s32 scan_unassoc_time, s32 scan_passive_time) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5148 | { |
| 5149 | s32 err = 0; |
| 5150 | |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 5151 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_CHANNEL_TIME, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 5152 | scan_assoc_time); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5153 | if (err) { |
| 5154 | if (err == -EOPNOTSUPP) |
Arend van Spriel | 647c9ae | 2012-12-05 15:26:01 +0100 | [diff] [blame] | 5155 | brcmf_dbg(INFO, "Scan assoc time is not supported\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5156 | else |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 5157 | brcmf_err("Scan assoc time error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5158 | goto dongle_scantime_out; |
| 5159 | } |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 5160 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_UNASSOC_TIME, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 5161 | scan_unassoc_time); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5162 | if (err) { |
| 5163 | if (err == -EOPNOTSUPP) |
Arend van Spriel | 647c9ae | 2012-12-05 15:26:01 +0100 | [diff] [blame] | 5164 | brcmf_dbg(INFO, "Scan unassoc time is not supported\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5165 | else |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 5166 | brcmf_err("Scan unassoc time error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5167 | goto dongle_scantime_out; |
| 5168 | } |
| 5169 | |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 5170 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_PASSIVE_TIME, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 5171 | scan_passive_time); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5172 | if (err) { |
| 5173 | if (err == -EOPNOTSUPP) |
Arend van Spriel | 647c9ae | 2012-12-05 15:26:01 +0100 | [diff] [blame] | 5174 | brcmf_dbg(INFO, "Scan passive time is not supported\n"); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5175 | else |
Arend van Spriel | 57d6e91 | 2012-12-05 15:26:00 +0100 | [diff] [blame] | 5176 | brcmf_err("Scan passive time error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5177 | goto dongle_scantime_out; |
| 5178 | } |
| 5179 | |
| 5180 | dongle_scantime_out: |
| 5181 | return err; |
| 5182 | } |
| 5183 | |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5184 | |
Arend van Spriel | 2375d97 | 2014-01-06 12:40:41 +0100 | [diff] [blame] | 5185 | static s32 brcmf_construct_reginfo(struct brcmf_cfg80211_info *cfg, |
| 5186 | u32 bw_cap[]) |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5187 | { |
| 5188 | struct brcmf_if *ifp = netdev_priv(cfg_to_ndev(cfg)); |
| 5189 | struct ieee80211_channel *band_chan_arr; |
| 5190 | struct brcmf_chanspec_list *list; |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 5191 | struct brcmu_chan ch; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5192 | s32 err; |
| 5193 | u8 *pbuf; |
| 5194 | u32 i, j; |
| 5195 | u32 total; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5196 | enum ieee80211_band band; |
| 5197 | u32 channel; |
| 5198 | u32 *n_cnt; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5199 | u32 index; |
| 5200 | u32 ht40_flag; |
| 5201 | bool update; |
| 5202 | u32 array_size; |
| 5203 | |
| 5204 | pbuf = kzalloc(BRCMF_DCMD_MEDLEN, GFP_KERNEL); |
| 5205 | |
| 5206 | if (pbuf == NULL) |
| 5207 | return -ENOMEM; |
| 5208 | |
| 5209 | list = (struct brcmf_chanspec_list *)pbuf; |
| 5210 | |
| 5211 | err = brcmf_fil_iovar_data_get(ifp, "chanspecs", pbuf, |
| 5212 | BRCMF_DCMD_MEDLEN); |
| 5213 | if (err) { |
| 5214 | brcmf_err("get chanspecs error (%d)\n", err); |
| 5215 | goto exit; |
| 5216 | } |
| 5217 | |
| 5218 | __wl_band_2ghz.n_channels = 0; |
| 5219 | __wl_band_5ghz_a.n_channels = 0; |
| 5220 | |
| 5221 | total = le32_to_cpu(list->count); |
| 5222 | for (i = 0; i < total; i++) { |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 5223 | ch.chspec = (u16)le32_to_cpu(list->element[i]); |
| 5224 | cfg->d11inf.decchspec(&ch); |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5225 | |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 5226 | if (ch.band == BRCMU_CHAN_BAND_2G) { |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5227 | band_chan_arr = __wl_2ghz_channels; |
| 5228 | array_size = ARRAY_SIZE(__wl_2ghz_channels); |
| 5229 | n_cnt = &__wl_band_2ghz.n_channels; |
| 5230 | band = IEEE80211_BAND_2GHZ; |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 5231 | } else if (ch.band == BRCMU_CHAN_BAND_5G) { |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5232 | band_chan_arr = __wl_5ghz_a_channels; |
| 5233 | array_size = ARRAY_SIZE(__wl_5ghz_a_channels); |
| 5234 | n_cnt = &__wl_band_5ghz_a.n_channels; |
| 5235 | band = IEEE80211_BAND_5GHZ; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5236 | } else { |
Arend van Spriel | 2375d97 | 2014-01-06 12:40:41 +0100 | [diff] [blame] | 5237 | brcmf_err("Invalid channel Spec. 0x%x.\n", ch.chspec); |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5238 | continue; |
| 5239 | } |
Arend van Spriel | 2375d97 | 2014-01-06 12:40:41 +0100 | [diff] [blame] | 5240 | if (!(bw_cap[band] & WLC_BW_40MHZ_BIT) && |
| 5241 | ch.bw == BRCMU_CHAN_BW_40) |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5242 | continue; |
Arend van Spriel | ee942ec | 2014-05-12 10:47:38 +0200 | [diff] [blame] | 5243 | if (!(bw_cap[band] & WLC_BW_80MHZ_BIT) && |
| 5244 | ch.bw == BRCMU_CHAN_BW_80) |
| 5245 | continue; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5246 | update = false; |
| 5247 | for (j = 0; (j < *n_cnt && (*n_cnt < array_size)); j++) { |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 5248 | if (band_chan_arr[j].hw_value == ch.chnum) { |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5249 | update = true; |
| 5250 | break; |
| 5251 | } |
| 5252 | } |
| 5253 | if (update) |
| 5254 | index = j; |
| 5255 | else |
| 5256 | index = *n_cnt; |
| 5257 | if (index < array_size) { |
| 5258 | band_chan_arr[index].center_freq = |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 5259 | ieee80211_channel_to_frequency(ch.chnum, band); |
| 5260 | band_chan_arr[index].hw_value = ch.chnum; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5261 | |
Arend van Spriel | ee942ec | 2014-05-12 10:47:38 +0200 | [diff] [blame] | 5262 | /* assuming the chanspecs order is HT20, |
| 5263 | * HT40 upper, HT40 lower, and VHT80. |
| 5264 | */ |
| 5265 | if (ch.bw == BRCMU_CHAN_BW_80) { |
| 5266 | band_chan_arr[index].flags &= |
| 5267 | ~IEEE80211_CHAN_NO_80MHZ; |
| 5268 | } else if (ch.bw == BRCMU_CHAN_BW_40) { |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5269 | ht40_flag = band_chan_arr[index].flags & |
| 5270 | IEEE80211_CHAN_NO_HT40; |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 5271 | if (ch.sb == BRCMU_CHAN_SB_U) { |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5272 | if (ht40_flag == IEEE80211_CHAN_NO_HT40) |
| 5273 | band_chan_arr[index].flags &= |
| 5274 | ~IEEE80211_CHAN_NO_HT40; |
| 5275 | band_chan_arr[index].flags |= |
| 5276 | IEEE80211_CHAN_NO_HT40PLUS; |
| 5277 | } else { |
| 5278 | /* It should be one of |
| 5279 | * IEEE80211_CHAN_NO_HT40 or |
| 5280 | * IEEE80211_CHAN_NO_HT40PLUS |
| 5281 | */ |
| 5282 | band_chan_arr[index].flags &= |
| 5283 | ~IEEE80211_CHAN_NO_HT40; |
| 5284 | if (ht40_flag == IEEE80211_CHAN_NO_HT40) |
| 5285 | band_chan_arr[index].flags |= |
| 5286 | IEEE80211_CHAN_NO_HT40MINUS; |
| 5287 | } |
| 5288 | } else { |
Arend van Spriel | ee942ec | 2014-05-12 10:47:38 +0200 | [diff] [blame] | 5289 | /* disable other bandwidths for now as mentioned |
| 5290 | * order assure they are enabled for subsequent |
| 5291 | * chanspecs. |
| 5292 | */ |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5293 | band_chan_arr[index].flags = |
Arend van Spriel | ee942ec | 2014-05-12 10:47:38 +0200 | [diff] [blame] | 5294 | IEEE80211_CHAN_NO_HT40 | |
| 5295 | IEEE80211_CHAN_NO_80MHZ; |
Franky Lin | 83cf17a | 2013-04-11 13:28:50 +0200 | [diff] [blame] | 5296 | ch.bw = BRCMU_CHAN_BW_20; |
| 5297 | cfg->d11inf.encchspec(&ch); |
| 5298 | channel = ch.chspec; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5299 | err = brcmf_fil_bsscfg_int_get(ifp, |
| 5300 | "per_chan_info", |
| 5301 | &channel); |
| 5302 | if (!err) { |
| 5303 | if (channel & WL_CHAN_RADAR) |
| 5304 | band_chan_arr[index].flags |= |
| 5305 | (IEEE80211_CHAN_RADAR | |
Luis R. Rodriguez | 8fe02e1 | 2013-10-21 19:22:25 +0200 | [diff] [blame] | 5306 | IEEE80211_CHAN_NO_IR); |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5307 | if (channel & WL_CHAN_PASSIVE) |
| 5308 | band_chan_arr[index].flags |= |
Luis R. Rodriguez | 8fe02e1 | 2013-10-21 19:22:25 +0200 | [diff] [blame] | 5309 | IEEE80211_CHAN_NO_IR; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5310 | } |
| 5311 | } |
| 5312 | if (!update) |
| 5313 | (*n_cnt)++; |
| 5314 | } |
| 5315 | } |
| 5316 | exit: |
| 5317 | kfree(pbuf); |
| 5318 | return err; |
| 5319 | } |
| 5320 | |
Arend van Spriel | 2375d97 | 2014-01-06 12:40:41 +0100 | [diff] [blame] | 5321 | static void brcmf_get_bwcap(struct brcmf_if *ifp, u32 bw_cap[]) |
| 5322 | { |
| 5323 | u32 band, mimo_bwcap; |
| 5324 | int err; |
| 5325 | |
| 5326 | band = WLC_BAND_2G; |
| 5327 | err = brcmf_fil_iovar_int_get(ifp, "bw_cap", &band); |
| 5328 | if (!err) { |
| 5329 | bw_cap[IEEE80211_BAND_2GHZ] = band; |
| 5330 | band = WLC_BAND_5G; |
| 5331 | err = brcmf_fil_iovar_int_get(ifp, "bw_cap", &band); |
| 5332 | if (!err) { |
| 5333 | bw_cap[IEEE80211_BAND_5GHZ] = band; |
| 5334 | return; |
| 5335 | } |
| 5336 | WARN_ON(1); |
| 5337 | return; |
| 5338 | } |
| 5339 | brcmf_dbg(INFO, "fallback to mimo_bw_cap info\n"); |
| 5340 | mimo_bwcap = 0; |
| 5341 | err = brcmf_fil_iovar_int_get(ifp, "mimo_bw_cap", &mimo_bwcap); |
| 5342 | if (err) |
| 5343 | /* assume 20MHz if firmware does not give a clue */ |
| 5344 | mimo_bwcap = WLC_N_BW_20ALL; |
| 5345 | |
| 5346 | switch (mimo_bwcap) { |
| 5347 | case WLC_N_BW_40ALL: |
| 5348 | bw_cap[IEEE80211_BAND_2GHZ] |= WLC_BW_40MHZ_BIT; |
| 5349 | /* fall-thru */ |
| 5350 | case WLC_N_BW_20IN2G_40IN5G: |
| 5351 | bw_cap[IEEE80211_BAND_5GHZ] |= WLC_BW_40MHZ_BIT; |
| 5352 | /* fall-thru */ |
| 5353 | case WLC_N_BW_20ALL: |
| 5354 | bw_cap[IEEE80211_BAND_2GHZ] |= WLC_BW_20MHZ_BIT; |
| 5355 | bw_cap[IEEE80211_BAND_5GHZ] |= WLC_BW_20MHZ_BIT; |
| 5356 | break; |
| 5357 | default: |
| 5358 | brcmf_err("invalid mimo_bw_cap value\n"); |
| 5359 | } |
| 5360 | } |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5361 | |
Arend van Spriel | 18d6c53 | 2014-05-12 10:47:35 +0200 | [diff] [blame] | 5362 | static void brcmf_update_ht_cap(struct ieee80211_supported_band *band, |
| 5363 | u32 bw_cap[2], u32 nchain) |
| 5364 | { |
| 5365 | band->ht_cap.ht_supported = true; |
| 5366 | if (bw_cap[band->band] & WLC_BW_40MHZ_BIT) { |
| 5367 | band->ht_cap.cap |= IEEE80211_HT_CAP_SGI_40; |
| 5368 | band->ht_cap.cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 5369 | } |
| 5370 | band->ht_cap.cap |= IEEE80211_HT_CAP_SGI_20; |
| 5371 | band->ht_cap.cap |= IEEE80211_HT_CAP_DSSSCCK40; |
| 5372 | band->ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; |
| 5373 | band->ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16; |
| 5374 | memset(band->ht_cap.mcs.rx_mask, 0xff, nchain); |
| 5375 | band->ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; |
| 5376 | } |
| 5377 | |
| 5378 | static __le16 brcmf_get_mcs_map(u32 nchain, enum ieee80211_vht_mcs_support supp) |
| 5379 | { |
| 5380 | u16 mcs_map; |
| 5381 | int i; |
| 5382 | |
| 5383 | for (i = 0, mcs_map = 0xFFFF; i < nchain; i++) |
| 5384 | mcs_map = (mcs_map << 2) | supp; |
| 5385 | |
| 5386 | return cpu_to_le16(mcs_map); |
| 5387 | } |
| 5388 | |
| 5389 | static void brcmf_update_vht_cap(struct ieee80211_supported_band *band, |
| 5390 | u32 bw_cap[2], u32 nchain) |
| 5391 | { |
| 5392 | __le16 mcs_map; |
| 5393 | |
| 5394 | /* not allowed in 2.4G band */ |
| 5395 | if (band->band == IEEE80211_BAND_2GHZ) |
| 5396 | return; |
| 5397 | |
| 5398 | band->vht_cap.vht_supported = true; |
| 5399 | /* 80MHz is mandatory */ |
| 5400 | band->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 5401 | if (bw_cap[band->band] & WLC_BW_160MHZ_BIT) { |
| 5402 | band->vht_cap.cap |= IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
| 5403 | band->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 5404 | } |
| 5405 | /* all support 256-QAM */ |
| 5406 | mcs_map = brcmf_get_mcs_map(nchain, IEEE80211_VHT_MCS_SUPPORT_0_9); |
| 5407 | band->vht_cap.vht_mcs.rx_mcs_map = mcs_map; |
| 5408 | band->vht_cap.vht_mcs.tx_mcs_map = mcs_map; |
| 5409 | } |
| 5410 | |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5411 | static s32 brcmf_update_wiphybands(struct brcmf_cfg80211_info *cfg) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5412 | { |
Arend van Spriel | ac24be6 | 2012-10-22 10:36:23 -0700 | [diff] [blame] | 5413 | struct brcmf_if *ifp = netdev_priv(cfg_to_ndev(cfg)); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5414 | struct wiphy *wiphy; |
| 5415 | s32 phy_list; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5416 | u32 band_list[3]; |
Arend van Spriel | 18d6c53 | 2014-05-12 10:47:35 +0200 | [diff] [blame] | 5417 | u32 nmode = 0; |
| 5418 | u32 vhtmode = 0; |
Arend van Spriel | 2375d97 | 2014-01-06 12:40:41 +0100 | [diff] [blame] | 5419 | u32 bw_cap[2] = { 0, 0 }; |
Daniel Kim | 4aca7a1 | 2014-02-25 20:30:36 +0100 | [diff] [blame] | 5420 | u32 rxchain; |
| 5421 | u32 nchain; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5422 | s8 phy; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5423 | s32 err; |
| 5424 | u32 nband; |
| 5425 | s32 i; |
Arend van Spriel | 2375d97 | 2014-01-06 12:40:41 +0100 | [diff] [blame] | 5426 | struct ieee80211_supported_band *bands[2] = { NULL, NULL }; |
| 5427 | struct ieee80211_supported_band *band; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5428 | |
Hante Meuleman | b87e2c4 | 2012-11-14 18:46:23 -0800 | [diff] [blame] | 5429 | err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_PHYLIST, |
Hante Meuleman | 81f5dcb | 2012-10-22 10:36:14 -0700 | [diff] [blame] | 5430 | &phy_list, sizeof(phy_list)); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5431 | if (err) { |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5432 | brcmf_err("BRCMF_C_GET_PHYLIST error (%d)\n", err); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5433 | return err; |
| 5434 | } |
| 5435 | |
Hante Meuleman | 3ba8137 | 2012-09-19 22:21:13 +0200 | [diff] [blame] | 5436 | phy = ((char *)&phy_list)[0]; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5437 | brcmf_dbg(INFO, "BRCMF_C_GET_PHYLIST reported: %c phy\n", phy); |
| 5438 | |
| 5439 | |
| 5440 | err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_BANDLIST, |
| 5441 | &band_list, sizeof(band_list)); |
| 5442 | if (err) { |
| 5443 | brcmf_err("BRCMF_C_GET_BANDLIST error (%d)\n", err); |
| 5444 | return err; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5445 | } |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5446 | brcmf_dbg(INFO, "BRCMF_C_GET_BANDLIST reported: 0x%08x 0x%08x 0x%08x phy\n", |
| 5447 | band_list[0], band_list[1], band_list[2]); |
| 5448 | |
Arend van Spriel | 18d6c53 | 2014-05-12 10:47:35 +0200 | [diff] [blame] | 5449 | (void)brcmf_fil_iovar_int_get(ifp, "vhtmode", &vhtmode); |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5450 | err = brcmf_fil_iovar_int_get(ifp, "nmode", &nmode); |
| 5451 | if (err) { |
| 5452 | brcmf_err("nmode error (%d)\n", err); |
| 5453 | } else { |
Arend van Spriel | 2375d97 | 2014-01-06 12:40:41 +0100 | [diff] [blame] | 5454 | brcmf_get_bwcap(ifp, bw_cap); |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5455 | } |
Arend van Spriel | 18d6c53 | 2014-05-12 10:47:35 +0200 | [diff] [blame] | 5456 | brcmf_dbg(INFO, "nmode=%d, vhtmode=%d, bw_cap=(%d, %d)\n", |
| 5457 | nmode, vhtmode, bw_cap[IEEE80211_BAND_2GHZ], |
| 5458 | bw_cap[IEEE80211_BAND_5GHZ]); |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5459 | |
Daniel Kim | 4aca7a1 | 2014-02-25 20:30:36 +0100 | [diff] [blame] | 5460 | err = brcmf_fil_iovar_int_get(ifp, "rxchain", &rxchain); |
| 5461 | if (err) { |
| 5462 | brcmf_err("rxchain error (%d)\n", err); |
| 5463 | nchain = 1; |
| 5464 | } else { |
| 5465 | for (nchain = 0; rxchain; nchain++) |
| 5466 | rxchain = rxchain & (rxchain - 1); |
| 5467 | } |
| 5468 | brcmf_dbg(INFO, "nchain=%d\n", nchain); |
| 5469 | |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5470 | err = brcmf_construct_reginfo(cfg, bw_cap); |
| 5471 | if (err) { |
| 5472 | brcmf_err("brcmf_construct_reginfo failed (%d)\n", err); |
| 5473 | return err; |
| 5474 | } |
| 5475 | |
| 5476 | nband = band_list[0]; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5477 | |
| 5478 | for (i = 1; i <= nband && i < ARRAY_SIZE(band_list); i++) { |
Arend van Spriel | 2375d97 | 2014-01-06 12:40:41 +0100 | [diff] [blame] | 5479 | band = NULL; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5480 | if ((band_list[i] == WLC_BAND_5G) && |
Arend van Spriel | 2375d97 | 2014-01-06 12:40:41 +0100 | [diff] [blame] | 5481 | (__wl_band_5ghz_a.n_channels > 0)) |
| 5482 | band = &__wl_band_5ghz_a; |
| 5483 | else if ((band_list[i] == WLC_BAND_2G) && |
| 5484 | (__wl_band_2ghz.n_channels > 0)) |
| 5485 | band = &__wl_band_2ghz; |
| 5486 | else |
| 5487 | continue; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5488 | |
Arend van Spriel | 18d6c53 | 2014-05-12 10:47:35 +0200 | [diff] [blame] | 5489 | if (nmode) |
| 5490 | brcmf_update_ht_cap(band, bw_cap, nchain); |
| 5491 | if (vhtmode) |
| 5492 | brcmf_update_vht_cap(band, bw_cap, nchain); |
Arend van Spriel | 2375d97 | 2014-01-06 12:40:41 +0100 | [diff] [blame] | 5493 | bands[band->band] = band; |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5494 | } |
| 5495 | |
| 5496 | wiphy = cfg_to_wiphy(cfg); |
| 5497 | wiphy->bands[IEEE80211_BAND_2GHZ] = bands[IEEE80211_BAND_2GHZ]; |
| 5498 | wiphy->bands[IEEE80211_BAND_5GHZ] = bands[IEEE80211_BAND_5GHZ]; |
| 5499 | wiphy_apply_custom_regulatory(wiphy, &brcmf_regdom); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5500 | |
| 5501 | return err; |
| 5502 | } |
| 5503 | |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5504 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5505 | static s32 brcmf_dongle_probecap(struct brcmf_cfg80211_info *cfg) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5506 | { |
Hante Meuleman | d48200b | 2013-04-03 12:40:29 +0200 | [diff] [blame] | 5507 | return brcmf_update_wiphybands(cfg); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5508 | } |
| 5509 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5510 | static s32 brcmf_config_dongle(struct brcmf_cfg80211_info *cfg) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5511 | { |
| 5512 | struct net_device *ndev; |
| 5513 | struct wireless_dev *wdev; |
Hante Meuleman | 40a2329 | 2013-01-02 15:22:51 +0100 | [diff] [blame] | 5514 | struct brcmf_if *ifp; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5515 | s32 power_mode; |
| 5516 | s32 err = 0; |
| 5517 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5518 | if (cfg->dongle_up) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5519 | return err; |
| 5520 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5521 | ndev = cfg_to_ndev(cfg); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5522 | wdev = ndev->ieee80211_ptr; |
Hante Meuleman | 40a2329 | 2013-01-02 15:22:51 +0100 | [diff] [blame] | 5523 | ifp = netdev_priv(ndev); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5524 | |
Hante Meuleman | 40a2329 | 2013-01-02 15:22:51 +0100 | [diff] [blame] | 5525 | /* make sure RF is ready for work */ |
| 5526 | brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 0); |
| 5527 | |
| 5528 | brcmf_dongle_scantime(ifp, WL_SCAN_CHANNEL_TIME, |
| 5529 | WL_SCAN_UNASSOC_TIME, WL_SCAN_PASSIVE_TIME); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5530 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5531 | power_mode = cfg->pwr_save ? PM_FAST : PM_OFF; |
Hante Meuleman | 40a2329 | 2013-01-02 15:22:51 +0100 | [diff] [blame] | 5532 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_PM, power_mode); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5533 | if (err) |
| 5534 | goto default_conf_out; |
Arend van Spriel | 647c9ae | 2012-12-05 15:26:01 +0100 | [diff] [blame] | 5535 | brcmf_dbg(INFO, "power save set to %s\n", |
| 5536 | (power_mode ? "enabled" : "disabled")); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5537 | |
Hante Meuleman | 68ca395 | 2014-02-25 20:30:26 +0100 | [diff] [blame] | 5538 | err = brcmf_dongle_roam(ifp, WL_BEACON_TIMEOUT); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5539 | if (err) |
| 5540 | goto default_conf_out; |
Franky Lin | 5dd161f | 2012-10-10 11:13:10 -0700 | [diff] [blame] | 5541 | err = brcmf_cfg80211_change_iface(wdev->wiphy, ndev, wdev->iftype, |
| 5542 | NULL, NULL); |
Hante Meuleman | 40a2329 | 2013-01-02 15:22:51 +0100 | [diff] [blame] | 5543 | if (err) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5544 | goto default_conf_out; |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5545 | err = brcmf_dongle_probecap(cfg); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5546 | if (err) |
| 5547 | goto default_conf_out; |
| 5548 | |
Hante Meuleman | b365745 | 2013-05-27 21:09:53 +0200 | [diff] [blame] | 5549 | brcmf_configure_arp_offload(ifp, true); |
| 5550 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5551 | cfg->dongle_up = true; |
Hante Meuleman | 40a2329 | 2013-01-02 15:22:51 +0100 | [diff] [blame] | 5552 | default_conf_out: |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5553 | |
| 5554 | return err; |
| 5555 | |
| 5556 | } |
| 5557 | |
Arend van Spriel | bdf5ff5 | 2012-11-14 18:46:09 -0800 | [diff] [blame] | 5558 | static s32 __brcmf_cfg80211_up(struct brcmf_if *ifp) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5559 | { |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 5560 | set_bit(BRCMF_VIF_STATUS_READY, &ifp->vif->sme_state); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5561 | |
Arend van Spriel | bdf5ff5 | 2012-11-14 18:46:09 -0800 | [diff] [blame] | 5562 | return brcmf_config_dongle(ifp->drvr->config); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5563 | } |
| 5564 | |
Arend van Spriel | bdf5ff5 | 2012-11-14 18:46:09 -0800 | [diff] [blame] | 5565 | static s32 __brcmf_cfg80211_down(struct brcmf_if *ifp) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5566 | { |
Arend van Spriel | bdf5ff5 | 2012-11-14 18:46:09 -0800 | [diff] [blame] | 5567 | struct brcmf_cfg80211_info *cfg = ifp->drvr->config; |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 5568 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5569 | /* |
| 5570 | * While going down, if associated with AP disassociate |
| 5571 | * from AP to save power |
| 5572 | */ |
Arend van Spriel | 903e0ee | 2012-11-28 21:44:11 +0100 | [diff] [blame] | 5573 | if (check_vif_up(ifp->vif)) { |
| 5574 | brcmf_link_down(ifp->vif); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5575 | |
| 5576 | /* Make sure WPA_Supplicant receives all the event |
| 5577 | generated due to DISASSOC call to the fw to keep |
| 5578 | the state fw and WPA_Supplicant state consistent |
| 5579 | */ |
| 5580 | brcmf_delay(500); |
| 5581 | } |
| 5582 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5583 | brcmf_abort_scanning(cfg); |
Arend van Spriel | c117903 | 2012-10-22 13:55:33 -0700 | [diff] [blame] | 5584 | clear_bit(BRCMF_VIF_STATUS_READY, &ifp->vif->sme_state); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5585 | |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5586 | return 0; |
| 5587 | } |
| 5588 | |
Arend van Spriel | bdf5ff5 | 2012-11-14 18:46:09 -0800 | [diff] [blame] | 5589 | s32 brcmf_cfg80211_up(struct net_device *ndev) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5590 | { |
Arend van Spriel | bdf5ff5 | 2012-11-14 18:46:09 -0800 | [diff] [blame] | 5591 | struct brcmf_if *ifp = netdev_priv(ndev); |
| 5592 | struct brcmf_cfg80211_info *cfg = ifp->drvr->config; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5593 | s32 err = 0; |
| 5594 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5595 | mutex_lock(&cfg->usr_sync); |
Arend van Spriel | bdf5ff5 | 2012-11-14 18:46:09 -0800 | [diff] [blame] | 5596 | err = __brcmf_cfg80211_up(ifp); |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5597 | mutex_unlock(&cfg->usr_sync); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5598 | |
| 5599 | return err; |
| 5600 | } |
| 5601 | |
Arend van Spriel | bdf5ff5 | 2012-11-14 18:46:09 -0800 | [diff] [blame] | 5602 | s32 brcmf_cfg80211_down(struct net_device *ndev) |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5603 | { |
Arend van Spriel | bdf5ff5 | 2012-11-14 18:46:09 -0800 | [diff] [blame] | 5604 | struct brcmf_if *ifp = netdev_priv(ndev); |
| 5605 | struct brcmf_cfg80211_info *cfg = ifp->drvr->config; |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5606 | s32 err = 0; |
| 5607 | |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5608 | mutex_lock(&cfg->usr_sync); |
Arend van Spriel | bdf5ff5 | 2012-11-14 18:46:09 -0800 | [diff] [blame] | 5609 | err = __brcmf_cfg80211_down(ifp); |
Arend van Spriel | 27a68fe | 2012-09-27 14:17:55 +0200 | [diff] [blame] | 5610 | mutex_unlock(&cfg->usr_sync); |
Arend van Spriel | 5b435de | 2011-10-05 13:19:03 +0200 | [diff] [blame] | 5611 | |
| 5612 | return err; |
| 5613 | } |
| 5614 | |
Arend van Spriel | a7965fb | 2013-04-11 17:08:37 +0200 | [diff] [blame] | 5615 | enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp) |
| 5616 | { |
| 5617 | struct wireless_dev *wdev = &ifp->vif->wdev; |
| 5618 | |
| 5619 | return wdev->iftype; |
| 5620 | } |
| 5621 | |
Arend van Spriel | 9f440b7 | 2013-02-08 15:53:36 +0100 | [diff] [blame] | 5622 | u32 wl_get_vif_state_all(struct brcmf_cfg80211_info *cfg, unsigned long state) |
| 5623 | { |
| 5624 | struct brcmf_cfg80211_vif *vif; |
| 5625 | bool result = 0; |
| 5626 | |
| 5627 | list_for_each_entry(vif, &cfg->vif_list, list) { |
| 5628 | if (test_bit(state, &vif->sme_state)) |
| 5629 | result++; |
| 5630 | } |
| 5631 | return result; |
| 5632 | } |
Arend van Spriel | d3c0b63 | 2013-02-08 15:53:37 +0100 | [diff] [blame] | 5633 | |
| 5634 | static inline bool vif_event_equals(struct brcmf_cfg80211_vif_event *event, |
| 5635 | u8 action) |
| 5636 | { |
| 5637 | u8 evt_action; |
| 5638 | |
| 5639 | mutex_lock(&event->vif_event_lock); |
| 5640 | evt_action = event->action; |
| 5641 | mutex_unlock(&event->vif_event_lock); |
| 5642 | return evt_action == action; |
| 5643 | } |
| 5644 | |
| 5645 | void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg, |
| 5646 | struct brcmf_cfg80211_vif *vif) |
| 5647 | { |
| 5648 | struct brcmf_cfg80211_vif_event *event = &cfg->vif_event; |
| 5649 | |
| 5650 | mutex_lock(&event->vif_event_lock); |
| 5651 | event->vif = vif; |
| 5652 | event->action = 0; |
| 5653 | mutex_unlock(&event->vif_event_lock); |
| 5654 | } |
| 5655 | |
| 5656 | bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg) |
| 5657 | { |
| 5658 | struct brcmf_cfg80211_vif_event *event = &cfg->vif_event; |
| 5659 | bool armed; |
| 5660 | |
| 5661 | mutex_lock(&event->vif_event_lock); |
| 5662 | armed = event->vif != NULL; |
| 5663 | mutex_unlock(&event->vif_event_lock); |
| 5664 | |
| 5665 | return armed; |
| 5666 | } |
| 5667 | int brcmf_cfg80211_wait_vif_event_timeout(struct brcmf_cfg80211_info *cfg, |
| 5668 | u8 action, ulong timeout) |
| 5669 | { |
| 5670 | struct brcmf_cfg80211_vif_event *event = &cfg->vif_event; |
| 5671 | |
| 5672 | return wait_event_timeout(event->vif_wq, |
| 5673 | vif_event_equals(event, action), timeout); |
| 5674 | } |
| 5675 | |