Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of version 2 of the GNU General Public License as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | ******************************************************************************/ |
| 15 | #define _RTW_WLAN_UTIL_C_ |
| 16 | |
| 17 | #include <osdep_service.h> |
| 18 | #include <drv_types.h> |
| 19 | #include <linux/ieee80211.h> |
| 20 | #include <wifi.h> |
Jes Sorensen | 6ec2627 | 2014-07-17 22:59:46 +0200 | [diff] [blame] | 21 | #include <rtl8723a_spec.h> |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 22 | |
| 23 | static unsigned char ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f}; |
| 24 | static unsigned char ARTHEROS_OUI2[] = {0x00, 0x13, 0x74}; |
| 25 | |
| 26 | static unsigned char BROADCOM_OUI1[] = {0x00, 0x10, 0x18}; |
| 27 | static unsigned char BROADCOM_OUI2[] = {0x00, 0x0a, 0xf7}; |
| 28 | |
| 29 | static unsigned char CISCO_OUI[] = {0x00, 0x40, 0x96}; |
| 30 | static unsigned char MARVELL_OUI[] = {0x00, 0x50, 0x43}; |
| 31 | static unsigned char RALINK_OUI[] = {0x00, 0x0c, 0x43}; |
| 32 | static unsigned char REALTEK_OUI[] = {0x00, 0xe0, 0x4c}; |
| 33 | static unsigned char AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5}; |
| 34 | static unsigned char EPIGRAM_OUI[] = {0x00, 0x90, 0x4c}; |
| 35 | |
Jes Sorensen | 7871778 | 2014-05-09 15:04:07 +0200 | [diff] [blame] | 36 | static unsigned char WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02}; |
| 37 | static unsigned char RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02}; |
| 38 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 39 | #define R2T_PHY_DELAY 0 |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 40 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 41 | /* define WAIT_FOR_BCN_TO_MIN 3000 */ |
| 42 | #define WAIT_FOR_BCN_TO_MIN 6000 |
| 43 | #define WAIT_FOR_BCN_TO_MAX 20000 |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 44 | |
| 45 | static u8 rtw_basic_rate_cck[4] = { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 46 | IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, |
| 47 | IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, |
| 48 | IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, |
| 49 | IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | static u8 rtw_basic_rate_ofdm[3] = { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 53 | IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, |
| 54 | IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, |
| 55 | IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | static u8 rtw_basic_rate_mix[7] = { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 59 | IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, |
| 60 | IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, |
| 61 | IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, |
| 62 | IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK, |
| 63 | IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, |
| 64 | IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, |
| 65 | IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | int cckrates_included23a(unsigned char *rate, int ratelen) |
| 69 | { |
| 70 | int i; |
| 71 | |
| 72 | for (i = 0; i < ratelen; i++) { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 73 | if (((rate[i]) & 0x7f) == 2 || ((rate[i]) & 0x7f) == 4 || |
| 74 | ((rate[i]) & 0x7f) == 11 || ((rate[i]) & 0x7f) == 22) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 75 | return true; |
| 76 | } |
| 77 | |
| 78 | return false; |
| 79 | } |
| 80 | |
| 81 | int cckratesonly_included23a(unsigned char *rate, int ratelen) |
| 82 | { |
| 83 | int i; |
| 84 | |
| 85 | for (i = 0; i < ratelen; i++) { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 86 | if (((rate[i]) & 0x7f) != 2 && ((rate[i]) & 0x7f) != 4 && |
| 87 | ((rate[i]) & 0x7f) != 11 && ((rate[i]) & 0x7f) != 22) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 88 | return false; |
| 89 | } |
| 90 | |
| 91 | return true; |
| 92 | } |
| 93 | |
| 94 | unsigned char networktype_to_raid23a(unsigned char network_type) |
| 95 | { |
| 96 | unsigned char raid; |
| 97 | |
| 98 | switch (network_type) { |
| 99 | case WIRELESS_11B: |
| 100 | raid = RATR_INX_WIRELESS_B; |
| 101 | break; |
| 102 | case WIRELESS_11A: |
| 103 | case WIRELESS_11G: |
| 104 | raid = RATR_INX_WIRELESS_G; |
| 105 | break; |
| 106 | case WIRELESS_11BG: |
| 107 | raid = RATR_INX_WIRELESS_GB; |
| 108 | break; |
| 109 | case WIRELESS_11_24N: |
| 110 | case WIRELESS_11_5N: |
| 111 | raid = RATR_INX_WIRELESS_N; |
| 112 | break; |
| 113 | case WIRELESS_11A_5N: |
| 114 | case WIRELESS_11G_24N: |
| 115 | raid = RATR_INX_WIRELESS_NG; |
| 116 | break; |
| 117 | case WIRELESS_11BG_24N: |
| 118 | raid = RATR_INX_WIRELESS_NGB; |
| 119 | break; |
| 120 | default: |
| 121 | raid = RATR_INX_WIRELESS_GB; |
| 122 | break; |
| 123 | } |
| 124 | return raid; |
| 125 | } |
| 126 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 127 | u8 judge_network_type23a(struct rtw_adapter *padapter, |
| 128 | unsigned char *rate, int ratelen) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 129 | { |
| 130 | u8 network_type = 0; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 131 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 132 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 133 | |
| 134 | if (pmlmeext->cur_channel > 14) { |
| 135 | if (pmlmeinfo->HT_enable) |
| 136 | network_type = WIRELESS_11_5N; |
| 137 | network_type |= WIRELESS_11A; |
| 138 | } else { |
| 139 | if (pmlmeinfo->HT_enable) |
| 140 | network_type = WIRELESS_11_24N; |
| 141 | |
| 142 | if ((cckratesonly_included23a(rate, ratelen)) == true) |
| 143 | network_type |= WIRELESS_11B; |
| 144 | else if ((cckrates_included23a(rate, ratelen)) == true) |
| 145 | network_type |= WIRELESS_11BG; |
| 146 | else |
| 147 | network_type |= WIRELESS_11G; |
| 148 | } |
| 149 | return network_type; |
| 150 | } |
| 151 | |
Larry Finger | c0b99be | 2014-04-26 18:55:17 +0200 | [diff] [blame] | 152 | static unsigned char ratetbl_val_2wifirate(unsigned char rate) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 153 | { |
| 154 | unsigned char val = 0; |
| 155 | |
| 156 | switch (rate & 0x7f) { |
| 157 | case 0: |
| 158 | val = IEEE80211_CCK_RATE_1MB; |
| 159 | break; |
| 160 | case 1: |
| 161 | val = IEEE80211_CCK_RATE_2MB; |
| 162 | break; |
| 163 | case 2: |
| 164 | val = IEEE80211_CCK_RATE_5MB; |
| 165 | break; |
| 166 | case 3: |
| 167 | val = IEEE80211_CCK_RATE_11MB; |
| 168 | break; |
| 169 | case 4: |
| 170 | val = IEEE80211_OFDM_RATE_6MB; |
| 171 | break; |
| 172 | case 5: |
| 173 | val = IEEE80211_OFDM_RATE_9MB; |
| 174 | break; |
| 175 | case 6: |
| 176 | val = IEEE80211_OFDM_RATE_12MB; |
| 177 | break; |
| 178 | case 7: |
| 179 | val = IEEE80211_OFDM_RATE_18MB; |
| 180 | break; |
| 181 | case 8: |
| 182 | val = IEEE80211_OFDM_RATE_24MB; |
| 183 | break; |
| 184 | case 9: |
| 185 | val = IEEE80211_OFDM_RATE_36MB; |
| 186 | break; |
| 187 | case 10: |
| 188 | val = IEEE80211_OFDM_RATE_48MB; |
| 189 | break; |
| 190 | case 11: |
| 191 | val = IEEE80211_OFDM_RATE_54MB; |
| 192 | break; |
| 193 | } |
| 194 | return val; |
| 195 | } |
| 196 | |
Larry Finger | c0b99be | 2014-04-26 18:55:17 +0200 | [diff] [blame] | 197 | static int is_basicrate(struct rtw_adapter *padapter, unsigned char rate) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 198 | { |
| 199 | int i; |
| 200 | unsigned char val; |
| 201 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 202 | |
| 203 | for (i = 0; i < NumRates; i++) { |
| 204 | val = pmlmeext->basicrate[i]; |
| 205 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 206 | if (val != 0xff && val != 0xfe) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 207 | if (rate == ratetbl_val_2wifirate(val)) |
| 208 | return true; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | return false; |
| 213 | } |
| 214 | |
Larry Finger | c0b99be | 2014-04-26 18:55:17 +0200 | [diff] [blame] | 215 | static unsigned int ratetbl2rateset(struct rtw_adapter *padapter, |
| 216 | unsigned char *rateset) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 217 | { |
| 218 | int i; |
| 219 | unsigned char rate; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 220 | unsigned int len = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 221 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 222 | |
| 223 | for (i = 0; i < NumRates; i++) { |
| 224 | rate = pmlmeext->datarate[i]; |
| 225 | |
| 226 | switch (rate) { |
| 227 | case 0xff: |
| 228 | return len; |
| 229 | case 0xfe: |
| 230 | continue; |
| 231 | default: |
| 232 | rate = ratetbl_val_2wifirate(rate); |
| 233 | |
| 234 | if (is_basicrate(padapter, rate) == true) |
| 235 | rate |= IEEE80211_BASIC_RATE_MASK; |
| 236 | |
| 237 | rateset[len] = rate; |
| 238 | len++; |
| 239 | break; |
| 240 | } |
| 241 | } |
| 242 | return len; |
| 243 | } |
| 244 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 245 | void get_rate_set23a(struct rtw_adapter *padapter, |
| 246 | unsigned char *pbssrate, int *bssrate_len) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 247 | { |
| 248 | unsigned char supportedrates[NumRates]; |
| 249 | |
| 250 | memset(supportedrates, 0, NumRates); |
| 251 | *bssrate_len = ratetbl2rateset(padapter, supportedrates); |
| 252 | memcpy(pbssrate, supportedrates, *bssrate_len); |
| 253 | } |
| 254 | |
| 255 | void UpdateBrateTbl23a(struct rtw_adapter *Adapter, u8 *mBratesOS) |
| 256 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 257 | u8 i; |
| 258 | u8 rate; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 259 | |
| 260 | /* 1M, 2M, 5.5M, 11M, 6M, 12M, 24M are mandatory. */ |
| 261 | for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { |
| 262 | rate = mBratesOS[i] & 0x7f; |
| 263 | switch (rate) { |
| 264 | case IEEE80211_CCK_RATE_1MB: |
| 265 | case IEEE80211_CCK_RATE_2MB: |
| 266 | case IEEE80211_CCK_RATE_5MB: |
| 267 | case IEEE80211_CCK_RATE_11MB: |
| 268 | case IEEE80211_OFDM_RATE_6MB: |
| 269 | case IEEE80211_OFDM_RATE_12MB: |
| 270 | case IEEE80211_OFDM_RATE_24MB: |
| 271 | mBratesOS[i] |= IEEE80211_BASIC_RATE_MASK; |
| 272 | break; |
| 273 | default: |
| 274 | break; |
| 275 | } |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen) |
| 280 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 281 | u8 i; |
| 282 | u8 rate; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 283 | |
| 284 | for (i = 0; i < bssratelen; i++) { |
| 285 | rate = bssrateset[i] & 0x7f; |
| 286 | switch (rate) { |
| 287 | case IEEE80211_CCK_RATE_1MB: |
| 288 | case IEEE80211_CCK_RATE_2MB: |
| 289 | case IEEE80211_CCK_RATE_5MB: |
| 290 | case IEEE80211_CCK_RATE_11MB: |
| 291 | bssrateset[i] |= IEEE80211_BASIC_RATE_MASK; |
| 292 | break; |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 297 | inline u8 rtw_get_oper_ch23a(struct rtw_adapter *adapter) |
| 298 | { |
| 299 | return adapter_to_dvobj(adapter)->oper_channel; |
| 300 | } |
| 301 | |
| 302 | inline void rtw_set_oper_ch23a(struct rtw_adapter *adapter, u8 ch) |
| 303 | { |
| 304 | adapter_to_dvobj(adapter)->oper_channel = ch; |
| 305 | } |
| 306 | |
| 307 | inline u8 rtw_get_oper_bw23a(struct rtw_adapter *adapter) |
| 308 | { |
| 309 | return adapter_to_dvobj(adapter)->oper_bwmode; |
| 310 | } |
| 311 | |
| 312 | inline void rtw_set_oper_bw23a(struct rtw_adapter *adapter, u8 bw) |
| 313 | { |
| 314 | adapter_to_dvobj(adapter)->oper_bwmode = bw; |
| 315 | } |
| 316 | |
| 317 | inline u8 rtw_get_oper_ch23aoffset(struct rtw_adapter *adapter) |
| 318 | { |
| 319 | return adapter_to_dvobj(adapter)->oper_ch_offset; |
| 320 | } |
| 321 | |
| 322 | inline void rtw_set_oper_ch23aoffset23a(struct rtw_adapter *adapter, u8 offset) |
| 323 | { |
| 324 | adapter_to_dvobj(adapter)->oper_ch_offset = offset; |
| 325 | } |
| 326 | |
| 327 | void SelectChannel23a(struct rtw_adapter *padapter, unsigned char channel) |
| 328 | { |
| 329 | mutex_lock(&adapter_to_dvobj(padapter)->setch_mutex); |
| 330 | |
| 331 | /* saved channel info */ |
| 332 | rtw_set_oper_ch23a(padapter, channel); |
| 333 | |
Jes Sorensen | 8a6f555 | 2014-05-16 10:04:08 +0200 | [diff] [blame] | 334 | PHY_SwChnl8723A(padapter, channel); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 335 | |
| 336 | mutex_unlock(&adapter_to_dvobj(padapter)->setch_mutex); |
| 337 | } |
| 338 | |
Jes Sorensen | 9b0cb4b | 2014-05-21 09:38:23 +0200 | [diff] [blame] | 339 | static void set_bwmode(struct rtw_adapter *padapter, unsigned short bwmode, |
| 340 | unsigned char channel_offset) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 341 | { |
| 342 | mutex_lock(&adapter_to_dvobj(padapter)->setbw_mutex); |
| 343 | |
| 344 | /* saved bw info */ |
| 345 | rtw_set_oper_bw23a(padapter, bwmode); |
| 346 | rtw_set_oper_ch23aoffset23a(padapter, channel_offset); |
| 347 | |
Jes Sorensen | 8a6f555 | 2014-05-16 10:04:08 +0200 | [diff] [blame] | 348 | PHY_SetBWMode23a8723A(padapter, (enum ht_channel_width)bwmode, |
| 349 | channel_offset); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 350 | |
| 351 | mutex_unlock(&adapter_to_dvobj(padapter)->setbw_mutex); |
| 352 | } |
| 353 | |
| 354 | void set_channel_bwmode23a(struct rtw_adapter *padapter, unsigned char channel, |
Greg Donald | a82b4b0 | 2014-09-08 20:50:23 -0500 | [diff] [blame] | 355 | unsigned char channel_offset, unsigned short bwmode) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 356 | { |
| 357 | u8 center_ch; |
| 358 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 359 | if (bwmode == HT_CHANNEL_WIDTH_20 || |
| 360 | channel_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 361 | /* SelectChannel23a(padapter, channel); */ |
| 362 | center_ch = channel; |
| 363 | } else { |
| 364 | /* switch to the proper channel */ |
| 365 | if (channel_offset == HAL_PRIME_CHNL_OFFSET_LOWER) { |
| 366 | /* SelectChannel23a(padapter, channel + 2); */ |
| 367 | center_ch = channel + 2; |
| 368 | } else { |
| 369 | /* SelectChannel23a(padapter, channel - 2); */ |
| 370 | center_ch = channel - 2; |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | /* set Channel */ |
| 375 | mutex_lock(&adapter_to_dvobj(padapter)->setch_mutex); |
| 376 | |
| 377 | /* saved channel/bw info */ |
| 378 | rtw_set_oper_ch23a(padapter, channel); |
| 379 | rtw_set_oper_bw23a(padapter, bwmode); |
| 380 | rtw_set_oper_ch23aoffset23a(padapter, channel_offset); |
| 381 | |
Jes Sorensen | 8a6f555 | 2014-05-16 10:04:08 +0200 | [diff] [blame] | 382 | PHY_SwChnl8723A(padapter, center_ch); /* set center channel */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 383 | |
| 384 | mutex_unlock(&adapter_to_dvobj(padapter)->setch_mutex); |
| 385 | |
Jes Sorensen | 9b0cb4b | 2014-05-21 09:38:23 +0200 | [diff] [blame] | 386 | set_bwmode(padapter, bwmode, channel_offset); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 387 | } |
| 388 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 389 | inline u8 *get_my_bssid23a(struct wlan_bssid_ex *pnetwork) |
| 390 | { |
| 391 | return pnetwork->MacAddress; |
| 392 | } |
| 393 | |
Jes Sorensen | f6fe0a4 | 2014-05-16 10:04:39 +0200 | [diff] [blame] | 394 | bool is_client_associated_to_ap23a(struct rtw_adapter *padapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 395 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 396 | struct mlme_ext_priv *pmlmeext; |
| 397 | struct mlme_ext_info *pmlmeinfo; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 398 | |
| 399 | if (!padapter) |
Jes Sorensen | f6fe0a4 | 2014-05-16 10:04:39 +0200 | [diff] [blame] | 400 | return false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 401 | |
| 402 | pmlmeext = &padapter->mlmeextpriv; |
| 403 | pmlmeinfo = &pmlmeext->mlmext_info; |
| 404 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 405 | if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS && |
Jes Sorensen | 6ec2627 | 2014-07-17 22:59:46 +0200 | [diff] [blame] | 406 | (pmlmeinfo->state & 0x03) == MSR_INFRA) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 407 | return true; |
| 408 | else |
Jes Sorensen | f6fe0a4 | 2014-05-16 10:04:39 +0200 | [diff] [blame] | 409 | return false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 410 | } |
| 411 | |
Jes Sorensen | f6fe0a4 | 2014-05-16 10:04:39 +0200 | [diff] [blame] | 412 | bool is_client_associated_to_ibss23a(struct rtw_adapter *padapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 413 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 414 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 415 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 416 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 417 | if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS && |
Jes Sorensen | 6ec2627 | 2014-07-17 22:59:46 +0200 | [diff] [blame] | 418 | (pmlmeinfo->state & 0x03) == MSR_ADHOC) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 419 | return true; |
| 420 | else |
Jes Sorensen | f6fe0a4 | 2014-05-16 10:04:39 +0200 | [diff] [blame] | 421 | return false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 422 | } |
| 423 | |
Jes Sorensen | f6fe0a4 | 2014-05-16 10:04:39 +0200 | [diff] [blame] | 424 | bool is_IBSS_empty23a(struct rtw_adapter *padapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 425 | { |
| 426 | unsigned int i; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 427 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 428 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 429 | |
| 430 | for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { |
| 431 | if (pmlmeinfo->FW_sta_info[i].status == 1) |
Jes Sorensen | f6fe0a4 | 2014-05-16 10:04:39 +0200 | [diff] [blame] | 432 | return false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | return true; |
| 436 | } |
| 437 | |
| 438 | unsigned int decide_wait_for_beacon_timeout23a(unsigned int bcn_interval) |
| 439 | { |
| 440 | if ((bcn_interval << 2) < WAIT_FOR_BCN_TO_MIN) |
| 441 | return WAIT_FOR_BCN_TO_MIN; |
| 442 | else if ((bcn_interval << 2) > WAIT_FOR_BCN_TO_MAX) |
| 443 | return WAIT_FOR_BCN_TO_MAX; |
| 444 | else |
| 445 | return bcn_interval << 2; |
| 446 | } |
| 447 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 448 | void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry) |
| 449 | { |
| 450 | unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 451 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 452 | unsigned char null_key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 453 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 454 | 0x00, 0x00, 0x00, 0x00}; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 455 | |
Jes Sorensen | dc0d16a | 2014-04-09 23:20:29 +0200 | [diff] [blame] | 456 | rtl8723a_cam_write(padapter, entry, 0, null_sta, null_key); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | int allocate_fw_sta_entry23a(struct rtw_adapter *padapter) |
| 460 | { |
| 461 | unsigned int mac_id; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 462 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 463 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 464 | |
| 465 | for (mac_id = IBSS_START_MAC_ID; mac_id < NUM_STA; mac_id++) { |
| 466 | if (pmlmeinfo->FW_sta_info[mac_id].status == 0) { |
| 467 | pmlmeinfo->FW_sta_info[mac_id].status = 1; |
| 468 | pmlmeinfo->FW_sta_info[mac_id].retry = 0; |
| 469 | break; |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | return mac_id; |
| 474 | } |
| 475 | |
| 476 | void flush_all_cam_entry23a(struct rtw_adapter *padapter) |
| 477 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 478 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 479 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 480 | |
Jes Sorensen | 2a3bc8a | 2014-07-17 22:59:53 +0200 | [diff] [blame] | 481 | rtl8723a_cam_invalidate_all(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 482 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 483 | memset(pmlmeinfo->FW_sta_info, 0, sizeof(pmlmeinfo->FW_sta_info)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 484 | } |
| 485 | |
Jes Sorensen | 3cdf277 | 2014-06-09 15:16:03 +0200 | [diff] [blame] | 486 | int WMM_param_handler23a(struct rtw_adapter *padapter, const u8 *p) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 487 | { |
| 488 | /* struct registry_priv *pregpriv = &padapter->registrypriv; */ |
| 489 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 490 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 491 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 492 | |
Jes Sorensen | bd8ad4a | 2014-05-09 15:03:21 +0200 | [diff] [blame] | 493 | if (pmlmepriv->qos_option == 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 494 | pmlmeinfo->WMM_enable = 0; |
| 495 | return _FAIL; |
| 496 | } |
| 497 | |
| 498 | pmlmeinfo->WMM_enable = 1; |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 499 | memcpy(&pmlmeinfo->WMM_param, p + 2 + 6, |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 500 | sizeof(struct WMM_para_element)); |
| 501 | return true; |
| 502 | } |
| 503 | |
| 504 | void WMMOnAssocRsp23a(struct rtw_adapter *padapter) |
| 505 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 506 | u8 ACI, ACM, AIFS, ECWMin, ECWMax, aSifsTime; |
| 507 | u8 acm_mask; |
| 508 | u16 TXOP; |
| 509 | u32 acParm, i; |
| 510 | u32 edca[4], inx[4]; |
| 511 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 512 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 513 | struct xmit_priv *pxmitpriv = &padapter->xmitpriv; |
| 514 | struct registry_priv *pregpriv = &padapter->registrypriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 515 | |
| 516 | if (pmlmeinfo->WMM_enable == 0) { |
| 517 | padapter->mlmepriv.acm_mask = 0; |
| 518 | return; |
| 519 | } |
| 520 | |
| 521 | acm_mask = 0; |
| 522 | |
| 523 | if (pmlmeext->cur_wireless_mode == WIRELESS_11B) |
| 524 | aSifsTime = 10; |
| 525 | else |
| 526 | aSifsTime = 16; |
| 527 | |
| 528 | for (i = 0; i < 4; i++) { |
| 529 | ACI = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 5) & 0x03; |
| 530 | ACM = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 4) & 0x01; |
| 531 | |
| 532 | /* AIFS = AIFSN * slot time + SIFS - r2t phy delay */ |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 533 | AIFS = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN & 0x0f) * |
| 534 | pmlmeinfo->slotTime + aSifsTime; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 535 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 536 | ECWMin = pmlmeinfo->WMM_param.ac_param[i].CW & 0x0f; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 537 | ECWMax = (pmlmeinfo->WMM_param.ac_param[i].CW & 0xf0) >> 4; |
| 538 | TXOP = le16_to_cpu(pmlmeinfo->WMM_param.ac_param[i].TXOP_limit); |
| 539 | |
| 540 | acParm = AIFS | (ECWMin << 8) | (ECWMax << 12) | (TXOP << 16); |
| 541 | |
| 542 | switch (ACI) { |
| 543 | case 0x0: |
Jes Sorensen | 2487205e | 2014-04-09 23:20:30 +0200 | [diff] [blame] | 544 | rtl8723a_set_ac_param_be(padapter, acParm); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 545 | acm_mask |= (ACM? BIT(1):0); |
| 546 | edca[XMIT_BE_QUEUE] = acParm; |
| 547 | break; |
| 548 | case 0x1: |
Jes Sorensen | 2487205e | 2014-04-09 23:20:30 +0200 | [diff] [blame] | 549 | rtl8723a_set_ac_param_bk(padapter, acParm); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 550 | /* acm_mask |= (ACM? BIT(0):0); */ |
| 551 | edca[XMIT_BK_QUEUE] = acParm; |
| 552 | break; |
| 553 | case 0x2: |
Jes Sorensen | 2487205e | 2014-04-09 23:20:30 +0200 | [diff] [blame] | 554 | rtl8723a_set_ac_param_vi(padapter, acParm); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 555 | acm_mask |= (ACM? BIT(2):0); |
| 556 | edca[XMIT_VI_QUEUE] = acParm; |
| 557 | break; |
| 558 | case 0x3: |
Jes Sorensen | 2487205e | 2014-04-09 23:20:30 +0200 | [diff] [blame] | 559 | rtl8723a_set_ac_param_vo(padapter, acParm); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 560 | acm_mask |= (ACM? BIT(3):0); |
| 561 | edca[XMIT_VO_QUEUE] = acParm; |
| 562 | break; |
| 563 | } |
| 564 | |
| 565 | DBG_8723A("WMM(%x): %x, %x\n", ACI, ACM, acParm); |
| 566 | } |
| 567 | |
| 568 | if (padapter->registrypriv.acm_method == 1) |
Jes Sorensen | d5cdb9e | 2014-04-09 23:20:31 +0200 | [diff] [blame] | 569 | rtl8723a_set_acm_ctrl(padapter, acm_mask); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 570 | else |
| 571 | padapter->mlmepriv.acm_mask = acm_mask; |
| 572 | |
| 573 | inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; |
| 574 | |
| 575 | if (pregpriv->wifi_spec == 1) { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 576 | u32 j, tmp, change_inx = false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 577 | |
| 578 | /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */ |
| 579 | for (i = 0; i < 4; i++) { |
| 580 | for (j = i+1; j < 4; j++) { |
| 581 | /* compare CW and AIFS */ |
| 582 | if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) { |
| 583 | change_inx = true; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 584 | } else if ((edca[j] & 0xFFFF) == |
| 585 | (edca[i] & 0xFFFF)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 586 | /* compare TXOP */ |
| 587 | if ((edca[j] >> 16) > (edca[i] >> 16)) |
| 588 | change_inx = true; |
| 589 | } |
| 590 | |
| 591 | if (change_inx) { |
| 592 | tmp = edca[i]; |
| 593 | edca[i] = edca[j]; |
| 594 | edca[j] = tmp; |
| 595 | |
| 596 | tmp = inx[i]; |
| 597 | inx[i] = inx[j]; |
| 598 | inx[j] = tmp; |
| 599 | |
| 600 | change_inx = false; |
| 601 | } |
| 602 | } |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | for (i = 0; i<4; i++) { |
| 607 | pxmitpriv->wmm_para_seq[i] = inx[i]; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 608 | DBG_8723A("wmm_para_seq(%d): %d\n", i, |
| 609 | pxmitpriv->wmm_para_seq[i]); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | return; |
| 613 | } |
| 614 | |
Jes Sorensen | 7882ef4 | 2014-05-31 18:05:17 +0200 | [diff] [blame] | 615 | static void bwmode_update_check(struct rtw_adapter *padapter, const u8 *p) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 616 | { |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 617 | struct ieee80211_ht_operation *pHT_info; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 618 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 619 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 620 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 621 | struct registry_priv *pregistrypriv = &padapter->registrypriv; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 622 | struct ht_priv *phtpriv = &pmlmepriv->htpriv; |
| 623 | unsigned char new_bwmode; |
| 624 | unsigned char new_ch_offset; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 625 | |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 626 | if (!p) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 627 | return; |
| 628 | if (!phtpriv->ht_option) |
| 629 | return; |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 630 | if (p[1] != sizeof(struct ieee80211_ht_operation)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 631 | return; |
| 632 | |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 633 | pHT_info = (struct ieee80211_ht_operation *)(p + 2); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 634 | |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 635 | if ((pHT_info->ht_param & IEEE80211_HT_PARAM_CHAN_WIDTH_ANY) && |
| 636 | pregistrypriv->cbw40_enable) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 637 | new_bwmode = HT_CHANNEL_WIDTH_40; |
| 638 | |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 639 | switch (pHT_info->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET){ |
| 640 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 641 | new_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; |
| 642 | break; |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 643 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 644 | new_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; |
| 645 | break; |
| 646 | default: |
| 647 | new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; |
| 648 | break; |
| 649 | } |
| 650 | } else { |
| 651 | new_bwmode = HT_CHANNEL_WIDTH_20; |
| 652 | new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; |
| 653 | } |
| 654 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 655 | if (new_bwmode != pmlmeext->cur_bwmode || |
| 656 | new_ch_offset != pmlmeext->cur_ch_offset) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 657 | pmlmeinfo->bwmode_updated = true; |
| 658 | |
| 659 | pmlmeext->cur_bwmode = new_bwmode; |
| 660 | pmlmeext->cur_ch_offset = new_ch_offset; |
| 661 | |
| 662 | /* update HT info also */ |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 663 | HT_info_handler23a(padapter, p); |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 664 | } else |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 665 | pmlmeinfo->bwmode_updated = false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 666 | |
| 667 | if (pmlmeinfo->bwmode_updated) { |
| 668 | struct sta_info *psta; |
| 669 | struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; |
| 670 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 671 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 672 | /* set_channel_bwmode23a(padapter, pmlmeext->cur_channel, |
| 673 | pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 674 | |
| 675 | /* update ap's stainfo */ |
| 676 | psta = rtw_get_stainfo23a(pstapriv, cur_network->MacAddress); |
| 677 | if (psta) { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 678 | struct ht_priv *phtpriv_sta = &psta->htpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 679 | |
| 680 | if (phtpriv_sta->ht_option) { |
| 681 | /* bwmode */ |
| 682 | phtpriv_sta->bwmode = pmlmeext->cur_bwmode; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 683 | phtpriv_sta->ch_offset = |
| 684 | pmlmeext->cur_ch_offset; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 685 | } else { |
| 686 | phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 687 | phtpriv_sta->ch_offset = |
| 688 | HAL_PRIME_CHNL_OFFSET_DONT_CARE; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 689 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 690 | } |
| 691 | } |
| 692 | } |
| 693 | |
Jes Sorensen | 3cdf277 | 2014-06-09 15:16:03 +0200 | [diff] [blame] | 694 | void HT_caps_handler23a(struct rtw_adapter *padapter, const u8 *p) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 695 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 696 | unsigned int i; |
| 697 | u8 rf_type; |
| 698 | u8 max_AMPDU_len, min_MPDU_spacing; |
| 699 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 700 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 701 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 702 | struct ht_priv *phtpriv = &pmlmepriv->htpriv; |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 703 | struct ieee80211_ht_cap *cap; |
| 704 | u8 *dstcap; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 705 | |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 706 | if (!p) |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 707 | return; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 708 | |
Jes Sorensen | 6a5f657 | 2014-06-09 15:16:07 +0200 | [diff] [blame] | 709 | if (!phtpriv->ht_option) |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 710 | return; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 711 | |
| 712 | pmlmeinfo->HT_caps_enable = 1; |
| 713 | |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 714 | cap = &pmlmeinfo->ht_cap; |
| 715 | dstcap = (u8 *)cap; |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 716 | for (i = 0; i < p[1]; i++) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 717 | if (i != 2) { |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 718 | dstcap[i] &= p[i + 2]; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 719 | } else { |
| 720 | /* modify from fw by Thomas 2010/11/17 */ |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 721 | if ((cap->ampdu_params_info & |
| 722 | IEEE80211_HT_AMPDU_PARM_FACTOR) > |
| 723 | (p[i + 2] & IEEE80211_HT_AMPDU_PARM_FACTOR)) |
| 724 | max_AMPDU_len = p[i + 2] & |
| 725 | IEEE80211_HT_AMPDU_PARM_FACTOR; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 726 | else |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 727 | max_AMPDU_len = cap->ampdu_params_info & |
| 728 | IEEE80211_HT_AMPDU_PARM_FACTOR; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 729 | |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 730 | if ((cap->ampdu_params_info & |
| 731 | IEEE80211_HT_AMPDU_PARM_DENSITY) > |
| 732 | (p[i + 2] & IEEE80211_HT_AMPDU_PARM_DENSITY)) |
| 733 | min_MPDU_spacing = cap->ampdu_params_info & |
| 734 | IEEE80211_HT_AMPDU_PARM_DENSITY; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 735 | else |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 736 | min_MPDU_spacing = p[i + 2] & |
| 737 | IEEE80211_HT_AMPDU_PARM_DENSITY; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 738 | |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 739 | cap->ampdu_params_info = |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 740 | max_AMPDU_len | min_MPDU_spacing; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 741 | } |
| 742 | } |
| 743 | |
Jes Sorensen | c2370e8 | 2014-04-09 23:20:53 +0200 | [diff] [blame] | 744 | rf_type = rtl8723a_get_rf_type(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 745 | |
| 746 | /* update the MCS rates */ |
Jes Sorensen | 198e95d | 2014-05-31 18:05:10 +0200 | [diff] [blame] | 747 | for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 748 | if (rf_type == RF_1T1R || rf_type == RF_1T2R) |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 749 | cap->mcs.rx_mask[i] &= MCS_rate_1R23A[i]; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 750 | else |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 751 | cap->mcs.rx_mask[i] &= MCS_rate_2R23A[i]; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 752 | } |
| 753 | return; |
| 754 | } |
| 755 | |
Jes Sorensen | 7882ef4 | 2014-05-31 18:05:17 +0200 | [diff] [blame] | 756 | void HT_info_handler23a(struct rtw_adapter *padapter, const u8 *p) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 757 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 758 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 759 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 760 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 761 | struct ht_priv *phtpriv = &pmlmepriv->htpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 762 | |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 763 | if (!p) |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 764 | return; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 765 | |
Jes Sorensen | 6a5f657 | 2014-06-09 15:16:07 +0200 | [diff] [blame] | 766 | if (!phtpriv->ht_option) |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 767 | return; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 768 | |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 769 | if (p[1] != sizeof(struct ieee80211_ht_operation)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 770 | return; |
| 771 | |
| 772 | pmlmeinfo->HT_info_enable = 1; |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 773 | memcpy(&pmlmeinfo->HT_info, p + 2, p[1]); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 774 | return; |
| 775 | } |
| 776 | |
| 777 | void HTOnAssocRsp23a(struct rtw_adapter *padapter) |
| 778 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 779 | unsigned char max_AMPDU_len; |
| 780 | unsigned char min_MPDU_spacing; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 781 | /* struct registry_priv *pregpriv = &padapter->registrypriv; */ |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 782 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 783 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 784 | |
| 785 | DBG_8723A("%s\n", __func__); |
| 786 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 787 | if (pmlmeinfo->HT_info_enable && pmlmeinfo->HT_caps_enable) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 788 | pmlmeinfo->HT_enable = 1; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 789 | else { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 790 | pmlmeinfo->HT_enable = 0; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 791 | /* set_channel_bwmode23a(padapter, pmlmeext->cur_channel, |
| 792 | pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 793 | return; |
| 794 | } |
| 795 | |
| 796 | /* handle A-MPDU parameter field */ |
| 797 | /* |
| 798 | AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k |
| 799 | AMPDU_para [4:2]:Min MPDU Start Spacing |
| 800 | */ |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 801 | max_AMPDU_len = pmlmeinfo->ht_cap.ampdu_params_info & |
| 802 | IEEE80211_HT_AMPDU_PARM_FACTOR; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 803 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 804 | min_MPDU_spacing = |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 805 | (pmlmeinfo->ht_cap.ampdu_params_info & |
| 806 | IEEE80211_HT_AMPDU_PARM_DENSITY) >> 2; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 807 | |
Jes Sorensen | dce610a | 2014-04-09 23:20:32 +0200 | [diff] [blame] | 808 | rtl8723a_set_ampdu_min_space(padapter, min_MPDU_spacing); |
| 809 | rtl8723a_set_ampdu_factor(padapter, max_AMPDU_len); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 810 | } |
| 811 | |
Jes Sorensen | 7882ef4 | 2014-05-31 18:05:17 +0200 | [diff] [blame] | 812 | void ERP_IE_handler23a(struct rtw_adapter *padapter, const u8 *p) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 813 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 814 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 815 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 816 | |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 817 | if (p[1] > 1) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 818 | return; |
| 819 | |
| 820 | pmlmeinfo->ERP_enable = 1; |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 821 | memcpy(&pmlmeinfo->ERP_IE, p + 2, p[1]); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 822 | } |
| 823 | |
| 824 | void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta) |
| 825 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 826 | struct registry_priv *pregpriv = &padapter->registrypriv; |
| 827 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 828 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 829 | |
| 830 | switch (pregpriv->vrtl_carrier_sense) { /* 0:off 1:on 2:auto */ |
| 831 | case 0: /* off */ |
| 832 | psta->rtsen = 0; |
| 833 | psta->cts2self = 0; |
| 834 | break; |
| 835 | case 1: /* on */ |
| 836 | if (pregpriv->vcs_type == 1) { /* 1:RTS/CTS 2:CTS to self */ |
| 837 | psta->rtsen = 1; |
| 838 | psta->cts2self = 0; |
| 839 | } else { |
| 840 | psta->rtsen = 0; |
| 841 | psta->cts2self = 1; |
| 842 | } |
| 843 | break; |
| 844 | case 2: /* auto */ |
| 845 | default: |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 846 | if (pmlmeinfo->ERP_enable && pmlmeinfo->ERP_IE & BIT(1)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 847 | if (pregpriv->vcs_type == 1) { |
| 848 | psta->rtsen = 1; |
| 849 | psta->cts2self = 0; |
| 850 | } else { |
| 851 | psta->rtsen = 0; |
| 852 | psta->cts2self = 1; |
| 853 | } |
| 854 | } else { |
| 855 | psta->rtsen = 0; |
| 856 | psta->cts2self = 0; |
| 857 | } |
| 858 | break; |
| 859 | } |
| 860 | } |
| 861 | |
Jes Sorensen | c146551 | 2014-04-15 19:43:58 +0200 | [diff] [blame] | 862 | int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, |
Jes Sorensen | 3ffa435 | 2014-04-15 19:43:59 +0200 | [diff] [blame] | 863 | struct ieee80211_mgmt *mgmt, u32 pkt_len) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 864 | { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 865 | struct wlan_network *cur_network = &Adapter->mlmepriv.cur_network; |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 866 | struct ieee80211_ht_operation *pht_info; |
Jes Sorensen | c376183 | 2014-04-15 19:44:05 +0200 | [diff] [blame] | 867 | unsigned short val16; |
Jes Sorensen | bbf5fdb | 2014-06-09 15:16:26 +0200 | [diff] [blame] | 868 | u8 crypto, bcn_channel; |
Jes Sorensen | c376183 | 2014-04-15 19:44:05 +0200 | [diff] [blame] | 869 | int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0, r; |
Jes Sorensen | 68e6c79 | 2014-06-24 15:03:29 +0200 | [diff] [blame] | 870 | int pie_len, ssid_len, privacy; |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 871 | const u8 *p, *ssid; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 872 | |
| 873 | if (is_client_associated_to_ap23a(Adapter) == false) |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 874 | return _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 875 | |
Jes Sorensen | c146551 | 2014-04-15 19:43:58 +0200 | [diff] [blame] | 876 | if (unlikely(!ieee80211_is_beacon(mgmt->frame_control))) { |
| 877 | printk(KERN_WARNING "%s: received a non beacon frame!\n", |
| 878 | __func__); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 879 | return _FAIL; |
| 880 | } |
| 881 | |
Jes Sorensen | 0c45e61 | 2014-06-09 15:16:24 +0200 | [diff] [blame] | 882 | if (!ether_addr_equal(cur_network->network.MacAddress, mgmt->bssid)) { |
| 883 | DBG_8723A("%s: linked but recv other bssid bcn" |
| 884 | MAC_FMT MAC_FMT "\n", __func__, MAC_ARG(mgmt->bssid), |
Jes Sorensen | c146551 | 2014-04-15 19:43:58 +0200 | [diff] [blame] | 885 | MAC_ARG(cur_network->network.MacAddress)); |
Jes Sorensen | 5bd28bc | 2014-04-26 18:54:49 +0200 | [diff] [blame] | 886 | return _FAIL; |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 887 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 888 | |
| 889 | /* check bw and channel offset */ |
| 890 | /* parsing HT_CAP_IE */ |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 891 | pie_len = pkt_len - offsetof(struct ieee80211_mgmt, u.beacon.variable); |
Jes Sorensen | 3ffa435 | 2014-04-15 19:43:59 +0200 | [diff] [blame] | 892 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 893 | /* Checking for channel */ |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 894 | p = cfg80211_find_ie(WLAN_EID_DS_PARAMS, mgmt->u.beacon.variable, |
| 895 | pie_len); |
Jes Sorensen | 3ffa435 | 2014-04-15 19:43:59 +0200 | [diff] [blame] | 896 | if (p) |
| 897 | bcn_channel = p[2]; |
| 898 | else { |
| 899 | /* In 5G, some ap do not have DSSET IE checking HT |
| 900 | info for channel */ |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 901 | p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, |
| 902 | mgmt->u.beacon.variable, pie_len); |
Jes Sorensen | 3ffa435 | 2014-04-15 19:43:59 +0200 | [diff] [blame] | 903 | |
Jes Sorensen | ed08b4d | 2014-05-31 18:05:14 +0200 | [diff] [blame] | 904 | if (p && p[1] > 0) { |
| 905 | pht_info = (struct ieee80211_ht_operation *)(p + 2); |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 906 | bcn_channel = pht_info->primary_chan; |
Jes Sorensen | ed08b4d | 2014-05-31 18:05:14 +0200 | [diff] [blame] | 907 | } else { /* we don't find channel IE, so don't check it */ |
Jes Sorensen | 3ffa435 | 2014-04-15 19:43:59 +0200 | [diff] [blame] | 908 | DBG_8723A("Oops: %s we don't find channel IE, so don't " |
| 909 | "check it\n", __func__); |
| 910 | bcn_channel = Adapter->mlmeextpriv.cur_channel; |
| 911 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 912 | } |
| 913 | if (bcn_channel != Adapter->mlmeextpriv.cur_channel) { |
Jes Sorensen | 3ffa435 | 2014-04-15 19:43:59 +0200 | [diff] [blame] | 914 | DBG_8723A("%s beacon channel:%d cur channel:%d disconnect\n", |
| 915 | __func__, bcn_channel, |
| 916 | Adapter->mlmeextpriv.cur_channel); |
| 917 | goto _mismatch; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 918 | } |
| 919 | |
| 920 | /* checking SSID */ |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 921 | p = cfg80211_find_ie(WLAN_EID_SSID, mgmt->u.beacon.variable, pie_len); |
Jes Sorensen | 82695d5 | 2014-04-15 19:44:00 +0200 | [diff] [blame] | 922 | if (p && p[1]) { |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 923 | ssid = p + 2; |
| 924 | ssid_len = p[1]; |
Jes Sorensen | 82695d5 | 2014-04-15 19:44:00 +0200 | [diff] [blame] | 925 | } else { |
Jes Sorensen | 3ffa435 | 2014-04-15 19:43:59 +0200 | [diff] [blame] | 926 | DBG_8723A("%s marc: cannot find SSID for survey event\n", |
| 927 | __func__); |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 928 | ssid = NULL; |
| 929 | ssid_len = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 930 | } |
| 931 | |
| 932 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, |
| 933 | ("%s bssid.Ssid.Ssid:%s bssid.Ssid.SsidLength:%d " |
| 934 | "cur_network->network.Ssid.Ssid:%s len:%d\n", __func__, |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 935 | ssid, ssid_len, cur_network->network.Ssid.ssid, |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 936 | cur_network->network.Ssid.ssid_len)); |
| 937 | |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 938 | if (ssid_len != cur_network->network.Ssid.ssid_len || ssid_len > 32 || |
| 939 | (ssid_len && |
| 940 | memcmp(ssid, cur_network->network.Ssid.ssid, ssid_len))) { |
| 941 | DBG_8723A("%s(), SSID is not match return FAIL\n", __func__); |
| 942 | goto _mismatch; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | /* check encryption info */ |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 946 | val16 = le16_to_cpu(mgmt->u.beacon.capab_info); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 947 | |
Jes Sorensen | a665bcc | 2014-05-31 18:05:15 +0200 | [diff] [blame] | 948 | if (val16 & WLAN_CAPABILITY_PRIVACY) |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 949 | privacy = 1; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 950 | else |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 951 | privacy = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 952 | |
| 953 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, |
Jes Sorensen | c376183 | 2014-04-15 19:44:05 +0200 | [diff] [blame] | 954 | ("%s(): cur_network->network.Privacy is %d, bssid.Privacy " |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 955 | "is %d\n", __func__, cur_network->network.Privacy, privacy)); |
| 956 | if (cur_network->network.Privacy != privacy) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 957 | DBG_8723A("%s(), privacy is not match return FAIL\n", __func__); |
| 958 | goto _mismatch; |
| 959 | } |
| 960 | |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 961 | p = cfg80211_find_ie(WLAN_EID_RSN, mgmt->u.beacon.variable, pie_len); |
Jes Sorensen | 77953ed | 2014-06-09 15:16:00 +0200 | [diff] [blame] | 962 | if (p && p[1]) { |
Jes Sorensen | bbf5fdb | 2014-06-09 15:16:26 +0200 | [diff] [blame] | 963 | crypto = ENCRYP_PROTOCOL_WPA2; |
| 964 | if (p && p[1]) { |
| 965 | r = rtw_parse_wpa2_ie23a(p, p[1] + 2, &group_cipher, |
| 966 | &pairwise_cipher, &is_8021x); |
| 967 | if (r == _SUCCESS) |
| 968 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, |
| 969 | ("%s pnetwork->pairwise_cipher: %d, " |
| 970 | "pnetwork->group_cipher: %d, is_802x " |
| 971 | ": %d\n", __func__, pairwise_cipher, |
| 972 | group_cipher, is_8021x)); |
| 973 | } |
Jes Sorensen | 77953ed | 2014-06-09 15:16:00 +0200 | [diff] [blame] | 974 | } else { |
Jes Sorensen | f88ca60 | 2014-04-15 19:44:06 +0200 | [diff] [blame] | 975 | p = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, |
| 976 | WLAN_OUI_TYPE_MICROSOFT_WPA, |
Jes Sorensen | 17b1939 | 2014-06-09 15:16:25 +0200 | [diff] [blame] | 977 | mgmt->u.beacon.variable, pie_len); |
Jes Sorensen | bbf5fdb | 2014-06-09 15:16:26 +0200 | [diff] [blame] | 978 | if (p && p[1]) { |
| 979 | crypto = ENCRYP_PROTOCOL_WPA; |
Jes Sorensen | f88ca60 | 2014-04-15 19:44:06 +0200 | [diff] [blame] | 980 | r = rtw_parse_wpa_ie23a(p, p[1] + 2, &group_cipher, |
Jes Sorensen | c376183 | 2014-04-15 19:44:05 +0200 | [diff] [blame] | 981 | &pairwise_cipher, &is_8021x); |
| 982 | if (r == _SUCCESS) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 983 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, |
Jes Sorensen | c376183 | 2014-04-15 19:44:05 +0200 | [diff] [blame] | 984 | ("%s pnetwork->pairwise_cipher: %d, " |
| 985 | "group_cipher is %d, is_8021x is " |
| 986 | "%d\n", __func__, pairwise_cipher, |
| 987 | group_cipher, is_8021x)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 988 | } else { |
Jes Sorensen | bbf5fdb | 2014-06-09 15:16:26 +0200 | [diff] [blame] | 989 | if (privacy) |
| 990 | crypto = ENCRYP_PROTOCOL_WEP; |
| 991 | else |
| 992 | crypto = ENCRYP_PROTOCOL_OPENSYS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 993 | } |
Jes Sorensen | bbf5fdb | 2014-06-09 15:16:26 +0200 | [diff] [blame] | 994 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 995 | |
Jes Sorensen | bbf5fdb | 2014-06-09 15:16:26 +0200 | [diff] [blame] | 996 | if (cur_network->BcnInfo.encryp_protocol != crypto) { |
| 997 | DBG_8723A("%s(): encryption mismatch, return FAIL\n", __func__); |
| 998 | goto _mismatch; |
| 999 | } |
| 1000 | |
| 1001 | if (crypto == ENCRYP_PROTOCOL_WPA || crypto == ENCRYP_PROTOCOL_WPA2) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1002 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
Jes Sorensen | c376183 | 2014-04-15 19:44:05 +0200 | [diff] [blame] | 1003 | ("%s cur_network->group_cipher is %d: %d\n", __func__, |
| 1004 | cur_network->BcnInfo.group_cipher, group_cipher)); |
| 1005 | if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || |
| 1006 | group_cipher != cur_network->BcnInfo.group_cipher) { |
| 1007 | DBG_8723A("%s pairwise_cipher(%x:%x) or group_cipher " |
| 1008 | "(%x:%x) is not match, return FAIL\n", |
| 1009 | __func__, pairwise_cipher, |
| 1010 | cur_network->BcnInfo.pairwise_cipher, |
| 1011 | group_cipher, |
| 1012 | cur_network->BcnInfo.group_cipher); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1013 | goto _mismatch; |
| 1014 | } |
| 1015 | |
| 1016 | if (is_8021x != cur_network->BcnInfo.is_8021x) { |
Jes Sorensen | c376183 | 2014-04-15 19:44:05 +0200 | [diff] [blame] | 1017 | DBG_8723A("%s authentication is not match, return " |
| 1018 | "FAIL\n", __func__); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1019 | goto _mismatch; |
| 1020 | } |
| 1021 | } |
| 1022 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1023 | return _SUCCESS; |
| 1024 | |
| 1025 | _mismatch: |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1026 | |
| 1027 | return _FAIL; |
| 1028 | } |
| 1029 | |
Jes Sorensen | 7882ef4 | 2014-05-31 18:05:17 +0200 | [diff] [blame] | 1030 | void update_beacon23a_info(struct rtw_adapter *padapter, |
| 1031 | struct ieee80211_mgmt *mgmt, |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1032 | uint pkt_len, struct sta_info *psta) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1033 | { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1034 | unsigned int len; |
Jes Sorensen | 7882ef4 | 2014-05-31 18:05:17 +0200 | [diff] [blame] | 1035 | const u8 *p; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1036 | |
Jes Sorensen | 7882ef4 | 2014-05-31 18:05:17 +0200 | [diff] [blame] | 1037 | len = pkt_len - offsetof(struct ieee80211_mgmt, u.beacon.variable); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1038 | |
Jes Sorensen | 7882ef4 | 2014-05-31 18:05:17 +0200 | [diff] [blame] | 1039 | p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, mgmt->u.beacon.variable, |
| 1040 | len); |
| 1041 | if (p) |
| 1042 | bwmode_update_check(padapter, p); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1043 | |
Jes Sorensen | 7882ef4 | 2014-05-31 18:05:17 +0200 | [diff] [blame] | 1044 | p = cfg80211_find_ie(WLAN_EID_ERP_INFO, mgmt->u.beacon.variable, len); |
| 1045 | if (p) { |
| 1046 | ERP_IE_handler23a(padapter, p); |
| 1047 | VCS_update23a(padapter, psta); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1048 | } |
| 1049 | } |
| 1050 | |
Jes Sorensen | d578924 | 2014-05-16 10:04:35 +0200 | [diff] [blame] | 1051 | bool is_ap_in_tkip23a(struct rtw_adapter *padapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1052 | { |
| 1053 | u32 i; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1054 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 1055 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 1056 | struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1057 | const u8 *p; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1058 | |
Jes Sorensen | a94e12b | 2014-06-19 11:37:34 +0200 | [diff] [blame] | 1059 | if (cur_network->capability & WLAN_CAPABILITY_PRIVACY) { |
Jes Sorensen | 68e6c79 | 2014-06-24 15:03:29 +0200 | [diff] [blame] | 1060 | for (i = 0; i < pmlmeinfo->network.IELength;) { |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1061 | p = pmlmeinfo->network.IEs + i; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1062 | |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1063 | switch (p[0]) { |
Jes Sorensen | 9300c94 | 2014-04-15 19:43:21 +0200 | [diff] [blame] | 1064 | case WLAN_EID_VENDOR_SPECIFIC: |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1065 | if (!memcmp(p + 2, RTW_WPA_OUI23A_TYPE, 4) && |
| 1066 | !memcmp(p + 2 + 12, WPA_TKIP_CIPHER, 4)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1067 | return true; |
| 1068 | break; |
Jes Sorensen | 25c934f | 2014-04-15 19:43:29 +0200 | [diff] [blame] | 1069 | case WLAN_EID_RSN: |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1070 | if (!memcmp(p + 2 + 8, RSN_TKIP_CIPHER, 4)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1071 | return true; |
| 1072 | break; |
| 1073 | default: |
| 1074 | break; |
| 1075 | } |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1076 | i += (p[1] + 2); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1077 | } |
| 1078 | return false; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1079 | } else |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1080 | return false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1081 | } |
| 1082 | |
Greg Donald | 8e3d161 | 2014-10-02 18:28:41 -0500 | [diff] [blame] | 1083 | bool should_forbid_n_rate23a(struct rtw_adapter *padapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1084 | { |
| 1085 | u32 i; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1086 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1087 | struct wlan_bssid_ex *cur_network = &pmlmepriv->cur_network.network; |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1088 | const u8 *p; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1089 | |
Jes Sorensen | a94e12b | 2014-06-19 11:37:34 +0200 | [diff] [blame] | 1090 | if (cur_network->capability & WLAN_CAPABILITY_PRIVACY) { |
Jes Sorensen | 68e6c79 | 2014-06-24 15:03:29 +0200 | [diff] [blame] | 1091 | for (i = 0; i < cur_network->IELength;) { |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1092 | p = cur_network->IEs + i; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1093 | |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1094 | switch (p[0]) { |
Jes Sorensen | 9300c94 | 2014-04-15 19:43:21 +0200 | [diff] [blame] | 1095 | case WLAN_EID_VENDOR_SPECIFIC: |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1096 | if (!memcmp(p + 2, RTW_WPA_OUI23A_TYPE, 4) && |
| 1097 | (!memcmp(p + 2 + 12, |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1098 | WPA_CIPHER_SUITE_CCMP23A, 4) || |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1099 | !memcmp(p + 2 + 16, |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1100 | WPA_CIPHER_SUITE_CCMP23A, 4))) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1101 | return false; |
| 1102 | break; |
Jes Sorensen | 25c934f | 2014-04-15 19:43:29 +0200 | [diff] [blame] | 1103 | case WLAN_EID_RSN: |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1104 | if (!memcmp(p + 2 + 8, |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1105 | RSN_CIPHER_SUITE_CCMP23A, 4) || |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1106 | !memcmp(p + 2 + 12, |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1107 | RSN_CIPHER_SUITE_CCMP23A, 4)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1108 | return false; |
| 1109 | default: |
| 1110 | break; |
| 1111 | } |
| 1112 | |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1113 | i += (p[1] + 2); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1114 | } |
| 1115 | return true; |
| 1116 | } else { |
| 1117 | return false; |
| 1118 | } |
| 1119 | } |
| 1120 | |
Jes Sorensen | d578924 | 2014-05-16 10:04:35 +0200 | [diff] [blame] | 1121 | bool is_ap_in_wep23a(struct rtw_adapter *padapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1122 | { |
| 1123 | u32 i; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1124 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 1125 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 1126 | struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1127 | const u8 *p; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1128 | |
Jes Sorensen | a94e12b | 2014-06-19 11:37:34 +0200 | [diff] [blame] | 1129 | if (cur_network->capability & WLAN_CAPABILITY_PRIVACY) { |
Jes Sorensen | 68e6c79 | 2014-06-24 15:03:29 +0200 | [diff] [blame] | 1130 | for (i = 0; i < pmlmeinfo->network.IELength;) { |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1131 | p = pmlmeinfo->network.IEs + i; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1132 | |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1133 | switch (p[0]) { |
Jes Sorensen | 9300c94 | 2014-04-15 19:43:21 +0200 | [diff] [blame] | 1134 | case WLAN_EID_VENDOR_SPECIFIC: |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1135 | if (!memcmp(p + 2, RTW_WPA_OUI23A_TYPE, 4)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1136 | return false; |
| 1137 | break; |
Jes Sorensen | 25c934f | 2014-04-15 19:43:29 +0200 | [diff] [blame] | 1138 | case WLAN_EID_RSN: |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1139 | return false; |
| 1140 | |
| 1141 | default: |
| 1142 | break; |
| 1143 | } |
| 1144 | |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1145 | i += (p[1] + 2); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1146 | } |
| 1147 | |
| 1148 | return true; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1149 | } else |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1150 | return false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1151 | } |
| 1152 | |
Larry Finger | c0b99be | 2014-04-26 18:55:17 +0200 | [diff] [blame] | 1153 | static int wifirate2_ratetbl_inx23a(unsigned char rate) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1154 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1155 | int inx = 0; |
Yeliz Taneroglu | 547f975 | 2014-10-09 01:22:17 +0300 | [diff] [blame^] | 1156 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1157 | rate = rate & 0x7f; |
| 1158 | |
| 1159 | switch (rate) { |
| 1160 | case 54*2: |
| 1161 | inx = 11; |
| 1162 | break; |
| 1163 | case 48*2: |
| 1164 | inx = 10; |
| 1165 | break; |
| 1166 | case 36*2: |
| 1167 | inx = 9; |
| 1168 | break; |
| 1169 | case 24*2: |
| 1170 | inx = 8; |
| 1171 | break; |
| 1172 | case 18*2: |
| 1173 | inx = 7; |
| 1174 | break; |
| 1175 | case 12*2: |
| 1176 | inx = 6; |
| 1177 | break; |
| 1178 | case 9*2: |
| 1179 | inx = 5; |
| 1180 | break; |
| 1181 | case 6*2: |
| 1182 | inx = 4; |
| 1183 | break; |
| 1184 | case 11*2: |
| 1185 | inx = 3; |
| 1186 | break; |
| 1187 | case 11: |
| 1188 | inx = 2; |
| 1189 | break; |
| 1190 | case 2*2: |
| 1191 | inx = 1; |
| 1192 | break; |
| 1193 | case 1*2: |
| 1194 | inx = 0; |
| 1195 | break; |
| 1196 | } |
| 1197 | return inx; |
| 1198 | } |
| 1199 | |
| 1200 | unsigned int update_basic_rate23a(unsigned char *ptn, unsigned int ptn_sz) |
| 1201 | { |
| 1202 | unsigned int i, num_of_rate; |
| 1203 | unsigned int mask = 0; |
| 1204 | |
| 1205 | num_of_rate = (ptn_sz > NumRates)? NumRates: ptn_sz; |
| 1206 | |
| 1207 | for (i = 0; i < num_of_rate; i++) { |
| 1208 | if ((*(ptn + i)) & 0x80) |
| 1209 | mask |= 0x1 << wifirate2_ratetbl_inx23a(*(ptn + i)); |
| 1210 | } |
| 1211 | return mask; |
| 1212 | } |
| 1213 | |
| 1214 | unsigned int update_supported_rate23a(unsigned char *ptn, unsigned int ptn_sz) |
| 1215 | { |
| 1216 | unsigned int i, num_of_rate; |
| 1217 | unsigned int mask = 0; |
| 1218 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1219 | num_of_rate = (ptn_sz > NumRates) ? NumRates : ptn_sz; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1220 | |
| 1221 | for (i = 0; i < num_of_rate; i++) |
| 1222 | mask |= 0x1 << wifirate2_ratetbl_inx23a(*(ptn + i)); |
| 1223 | return mask; |
| 1224 | } |
| 1225 | |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 1226 | unsigned int update_MSC_rate23a(struct ieee80211_ht_cap *pHT_caps) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1227 | { |
| 1228 | unsigned int mask = 0; |
| 1229 | |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 1230 | mask = pHT_caps->mcs.rx_mask[0] << 12 | |
| 1231 | pHT_caps->mcs.rx_mask[1] << 20; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1232 | |
| 1233 | return mask; |
| 1234 | } |
| 1235 | |
| 1236 | int support_short_GI23a(struct rtw_adapter *padapter, |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 1237 | struct ieee80211_ht_cap *pHT_caps) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1238 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1239 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1240 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 1241 | unsigned char bit_offset; |
| 1242 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1243 | if (!pmlmeinfo->HT_enable) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1244 | return _FAIL; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1245 | if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1246 | return _FAIL; |
| 1247 | bit_offset = (pmlmeext->cur_bwmode & HT_CHANNEL_WIDTH_40)? 6: 5; |
| 1248 | |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 1249 | if (pHT_caps->cap_info & cpu_to_le16(0x1 << bit_offset)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1250 | return _SUCCESS; |
| 1251 | else |
| 1252 | return _FAIL; |
| 1253 | } |
| 1254 | |
| 1255 | unsigned char get_highest_rate_idx23a(u32 mask) |
| 1256 | { |
| 1257 | int i; |
| 1258 | unsigned char rate_idx = 0; |
| 1259 | |
| 1260 | for (i = 27; i >= 0; i--) { |
| 1261 | if (mask & BIT(i)) { |
| 1262 | rate_idx = i; |
| 1263 | break; |
| 1264 | } |
| 1265 | } |
| 1266 | return rate_idx; |
| 1267 | } |
| 1268 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1269 | void Update_RA_Entry23a(struct rtw_adapter *padapter, struct sta_info *psta) |
| 1270 | { |
| 1271 | rtw_hal_update_ra_mask23a(psta, 0); |
| 1272 | } |
| 1273 | |
Larry Finger | c0b99be | 2014-04-26 18:55:17 +0200 | [diff] [blame] | 1274 | static void enable_rate_adaptive(struct rtw_adapter *padapter, |
| 1275 | struct sta_info *psta) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1276 | { |
| 1277 | Update_RA_Entry23a(padapter, psta); |
| 1278 | } |
| 1279 | |
| 1280 | void set_sta_rate23a(struct rtw_adapter *padapter, struct sta_info *psta) |
| 1281 | { |
| 1282 | /* rate adaptive */ |
| 1283 | enable_rate_adaptive(padapter, psta); |
| 1284 | } |
| 1285 | |
| 1286 | /* Update RRSR and Rate for USERATE */ |
| 1287 | void update_tx_basic_rate23a(struct rtw_adapter *padapter, u8 wirelessmode) |
| 1288 | { |
| 1289 | unsigned char supported_rates[NDIS_802_11_LENGTH_RATES_EX]; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1290 | |
| 1291 | memset(supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX); |
| 1292 | |
Jes Sorensen | ff516e7 | 2014-05-09 15:03:28 +0200 | [diff] [blame] | 1293 | if (wirelessmode == WIRELESS_11B) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1294 | memcpy(supported_rates, rtw_basic_rate_cck, 4); |
| 1295 | } else if (wirelessmode & WIRELESS_11B) { |
| 1296 | memcpy(supported_rates, rtw_basic_rate_mix, 7); |
| 1297 | } else { |
| 1298 | memcpy(supported_rates, rtw_basic_rate_ofdm, 3); |
| 1299 | } |
| 1300 | |
| 1301 | if (wirelessmode & WIRELESS_11B) |
| 1302 | update_mgnt_tx_rate23a(padapter, IEEE80211_CCK_RATE_1MB); |
| 1303 | else |
| 1304 | update_mgnt_tx_rate23a(padapter, IEEE80211_OFDM_RATE_6MB); |
| 1305 | |
Jes Sorensen | fa2e520 | 2014-04-09 23:20:18 +0200 | [diff] [blame] | 1306 | HalSetBrateCfg23a(padapter, supported_rates); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1307 | } |
| 1308 | |
| 1309 | unsigned char check_assoc_AP23a(u8 *pframe, uint len) |
| 1310 | { |
Jes Sorensen | 68e6c79 | 2014-06-24 15:03:29 +0200 | [diff] [blame] | 1311 | int i; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1312 | u8 epigram_vendor_flag; |
| 1313 | u8 ralink_vendor_flag; |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1314 | const u8 *p; |
Yeliz Taneroglu | 547f975 | 2014-10-09 01:22:17 +0300 | [diff] [blame^] | 1315 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1316 | epigram_vendor_flag = 0; |
| 1317 | ralink_vendor_flag = 0; |
| 1318 | |
Jes Sorensen | 68e6c79 | 2014-06-24 15:03:29 +0200 | [diff] [blame] | 1319 | for (i = 0; i < len;) { |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1320 | p = pframe + i; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1321 | |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1322 | switch (p[0]) { |
Jes Sorensen | 9300c94 | 2014-04-15 19:43:21 +0200 | [diff] [blame] | 1323 | case WLAN_EID_VENDOR_SPECIFIC: |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1324 | if (!memcmp(p + 2, ARTHEROS_OUI1, 3) || |
| 1325 | !memcmp(p + 2, ARTHEROS_OUI2, 3)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1326 | DBG_8723A("link to Artheros AP\n"); |
| 1327 | return HT_IOT_PEER_ATHEROS; |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1328 | } else if (!memcmp(p + 2, BROADCOM_OUI1, 3) || |
| 1329 | !memcmp(p + 2, BROADCOM_OUI2, 3) || |
| 1330 | !memcmp(p + 2, BROADCOM_OUI2, 3)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1331 | DBG_8723A("link to Broadcom AP\n"); |
| 1332 | return HT_IOT_PEER_BROADCOM; |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1333 | } else if (!memcmp(p + 2, MARVELL_OUI, 3)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1334 | DBG_8723A("link to Marvell AP\n"); |
| 1335 | return HT_IOT_PEER_MARVELL; |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1336 | } else if (!memcmp(p + 2, RALINK_OUI, 3)) { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1337 | if (!ralink_vendor_flag) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1338 | ralink_vendor_flag = 1; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1339 | else { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1340 | DBG_8723A("link to Ralink AP\n"); |
| 1341 | return HT_IOT_PEER_RALINK; |
| 1342 | } |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1343 | } else if (!memcmp(p + 2, CISCO_OUI, 3)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1344 | DBG_8723A("link to Cisco AP\n"); |
| 1345 | return HT_IOT_PEER_CISCO; |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1346 | } else if (!memcmp(p + 2, REALTEK_OUI, 3)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1347 | DBG_8723A("link to Realtek 96B\n"); |
| 1348 | return HT_IOT_PEER_REALTEK; |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1349 | } else if (!memcmp(p + 2, AIRGOCAP_OUI, 3)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1350 | DBG_8723A("link to Airgo Cap\n"); |
| 1351 | return HT_IOT_PEER_AIRGO; |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1352 | } else if (!memcmp(p + 2, EPIGRAM_OUI, 3)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1353 | epigram_vendor_flag = 1; |
| 1354 | if (ralink_vendor_flag) { |
| 1355 | DBG_8723A("link to Tenda W311R AP\n"); |
| 1356 | return HT_IOT_PEER_TENDA; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1357 | } else |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1358 | DBG_8723A("Capture EPIGRAM_OUI\n"); |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1359 | } else |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1360 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1361 | default: |
| 1362 | break; |
| 1363 | } |
| 1364 | |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1365 | i += (p[1] + 2); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1366 | } |
| 1367 | |
| 1368 | if (ralink_vendor_flag && !epigram_vendor_flag) { |
| 1369 | DBG_8723A("link to Ralink AP\n"); |
| 1370 | return HT_IOT_PEER_RALINK; |
| 1371 | } else if (ralink_vendor_flag && epigram_vendor_flag) { |
| 1372 | DBG_8723A("link to Tenda W311R AP\n"); |
| 1373 | return HT_IOT_PEER_TENDA; |
| 1374 | } else { |
| 1375 | DBG_8723A("link to new AP\n"); |
| 1376 | return HT_IOT_PEER_UNKNOWN; |
| 1377 | } |
| 1378 | } |
| 1379 | |
| 1380 | void update_IOT_info23a(struct rtw_adapter *padapter) |
| 1381 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1382 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1383 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 1384 | |
| 1385 | switch (pmlmeinfo->assoc_AP_vendor) { |
| 1386 | case HT_IOT_PEER_MARVELL: |
| 1387 | pmlmeinfo->turboMode_cts2self = 1; |
| 1388 | pmlmeinfo->turboMode_rtsen = 0; |
| 1389 | break; |
| 1390 | case HT_IOT_PEER_RALINK: |
| 1391 | pmlmeinfo->turboMode_cts2self = 0; |
| 1392 | pmlmeinfo->turboMode_rtsen = 1; |
| 1393 | /* disable high power */ |
Jes Sorensen | 585eefb | 2014-04-09 23:20:43 +0200 | [diff] [blame] | 1394 | rtl8723a_odm_support_ability_clr(padapter, (u32) |
| 1395 | ~DYNAMIC_BB_DYNAMIC_TXPWR); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1396 | break; |
| 1397 | case HT_IOT_PEER_REALTEK: |
| 1398 | /* rtw_write16(padapter, 0x4cc, 0xffff); */ |
| 1399 | /* rtw_write16(padapter, 0x546, 0x01c0); */ |
| 1400 | /* disable high power */ |
Jes Sorensen | 585eefb | 2014-04-09 23:20:43 +0200 | [diff] [blame] | 1401 | rtl8723a_odm_support_ability_clr(padapter, (u32) |
| 1402 | ~DYNAMIC_BB_DYNAMIC_TXPWR); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1403 | break; |
| 1404 | default: |
| 1405 | pmlmeinfo->turboMode_cts2self = 0; |
| 1406 | pmlmeinfo->turboMode_rtsen = 1; |
| 1407 | break; |
| 1408 | } |
| 1409 | } |
| 1410 | |
| 1411 | void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap) |
| 1412 | { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1413 | struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1414 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1415 | |
| 1416 | if (updateCap & cShortPreamble) { |
| 1417 | /* Short Preamble */ |
| 1418 | if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) { |
| 1419 | /* PREAMBLE_LONG or PREAMBLE_AUTO */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1420 | pmlmeinfo->preamble_mode = PREAMBLE_SHORT; |
Jes Sorensen | 093dd41 | 2014-04-09 23:20:26 +0200 | [diff] [blame] | 1421 | rtl8723a_ack_preamble(Adapter, true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1422 | } |
| 1423 | } else { /* Long Preamble */ |
| 1424 | if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) { |
| 1425 | /* PREAMBLE_SHORT or PREAMBLE_AUTO */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1426 | pmlmeinfo->preamble_mode = PREAMBLE_LONG; |
Jes Sorensen | 093dd41 | 2014-04-09 23:20:26 +0200 | [diff] [blame] | 1427 | rtl8723a_ack_preamble(Adapter, false); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1428 | } |
| 1429 | } |
| 1430 | if (updateCap & cIBSS) { |
| 1431 | /* Filen: See 802.11-2007 p.91 */ |
| 1432 | pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; |
| 1433 | } else { |
| 1434 | /* Filen: See 802.11-2007 p.90 */ |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1435 | if (pmlmeext->cur_wireless_mode & |
| 1436 | (WIRELESS_11G | WIRELESS_11_24N)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1437 | if (updateCap & cShortSlotTime) { /* Short Slot Time */ |
| 1438 | if (pmlmeinfo->slotTime != SHORT_SLOT_TIME) |
| 1439 | pmlmeinfo->slotTime = SHORT_SLOT_TIME; |
| 1440 | } else { /* Long Slot Time */ |
| 1441 | if (pmlmeinfo->slotTime != NON_SHORT_SLOT_TIME) |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1442 | pmlmeinfo->slotTime = |
| 1443 | NON_SHORT_SLOT_TIME; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1444 | } |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1445 | } else if (pmlmeext->cur_wireless_mode & |
| 1446 | (WIRELESS_11A | WIRELESS_11_5N)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1447 | pmlmeinfo->slotTime = SHORT_SLOT_TIME; |
| 1448 | } else { |
| 1449 | /* B Mode */ |
| 1450 | pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; |
| 1451 | } |
| 1452 | } |
Jes Sorensen | 04c3842 | 2014-04-09 23:20:24 +0200 | [diff] [blame] | 1453 | rtl8723a_set_slot_time(Adapter, pmlmeinfo->slotTime); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1454 | } |
| 1455 | |
| 1456 | void update_wireless_mode23a(struct rtw_adapter *padapter) |
| 1457 | { |
| 1458 | int ratelen, network_type = 0; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1459 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1460 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 1461 | struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1462 | unsigned char *rate = cur_network->SupportedRates; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1463 | |
| 1464 | ratelen = rtw_get_rateset_len23a(cur_network->SupportedRates); |
| 1465 | |
| 1466 | if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) |
| 1467 | pmlmeinfo->HT_enable = 1; |
| 1468 | |
| 1469 | if (pmlmeext->cur_channel > 14) { |
| 1470 | if (pmlmeinfo->HT_enable) |
| 1471 | network_type = WIRELESS_11_5N; |
| 1472 | network_type |= WIRELESS_11A; |
| 1473 | } else { |
| 1474 | if (pmlmeinfo->HT_enable) |
| 1475 | network_type = WIRELESS_11_24N; |
| 1476 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1477 | if (cckratesonly_included23a(rate, ratelen) == true) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1478 | network_type |= WIRELESS_11B; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1479 | else if (cckrates_included23a(rate, ratelen) == true) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1480 | network_type |= WIRELESS_11BG; |
| 1481 | else |
| 1482 | network_type |= WIRELESS_11G; |
| 1483 | } |
| 1484 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1485 | pmlmeext->cur_wireless_mode = |
| 1486 | network_type & padapter->registrypriv.wireless_mode; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1487 | |
Jes Sorensen | 7b7aefa | 2014-04-09 23:20:25 +0200 | [diff] [blame] | 1488 | /* 0x0808 -> for CCK, 0x0a0a -> for OFDM */ |
| 1489 | /* change this value if having IOT issues. */ |
| 1490 | rtl8723a_set_resp_sifs(padapter, 0x08, 0x08, 0x0a, 0x0a); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1491 | |
| 1492 | if (pmlmeext->cur_wireless_mode & WIRELESS_11B) |
| 1493 | update_mgnt_tx_rate23a(padapter, IEEE80211_CCK_RATE_1MB); |
| 1494 | else |
| 1495 | update_mgnt_tx_rate23a(padapter, IEEE80211_OFDM_RATE_6MB); |
| 1496 | } |
| 1497 | |
| 1498 | void update_bmc_sta_support_rate23a(struct rtw_adapter *padapter, u32 mac_id) |
| 1499 | { |
| 1500 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 1501 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 1502 | |
| 1503 | if (pmlmeext->cur_wireless_mode & WIRELESS_11B) { |
| 1504 | /* Only B, B/G, and B/G/N AP could use CCK rate */ |
Jes Sorensen | 5bd28bc | 2014-04-26 18:54:49 +0200 | [diff] [blame] | 1505 | memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), |
| 1506 | rtw_basic_rate_cck, 4); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1507 | } else { |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1508 | memcpy(pmlmeinfo->FW_sta_info[mac_id].SupportedRates, |
Jes Sorensen | 5bd28bc | 2014-04-26 18:54:49 +0200 | [diff] [blame] | 1509 | rtw_basic_rate_ofdm, 3); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1510 | } |
| 1511 | } |
| 1512 | |
Jes Sorensen | bf35027 | 2014-04-15 19:44:01 +0200 | [diff] [blame] | 1513 | int update_sta_support_rate23a(struct rtw_adapter *padapter, u8 *pvar_ie, |
| 1514 | uint var_ie_len, int cam_idx) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1515 | { |
Jes Sorensen | bf35027 | 2014-04-15 19:44:01 +0200 | [diff] [blame] | 1516 | int supportRateNum = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1517 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 1518 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
Jes Sorensen | bf35027 | 2014-04-15 19:44:01 +0200 | [diff] [blame] | 1519 | const u8 *p; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1520 | |
Jes Sorensen | bf35027 | 2014-04-15 19:44:01 +0200 | [diff] [blame] | 1521 | p = cfg80211_find_ie(WLAN_EID_SUPP_RATES, pvar_ie, var_ie_len); |
| 1522 | if (!p) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1523 | return _FAIL; |
| 1524 | |
Jes Sorensen | bf35027 | 2014-04-15 19:44:01 +0200 | [diff] [blame] | 1525 | memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, p + 2, p[1]); |
| 1526 | supportRateNum = p[1]; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1527 | |
Jes Sorensen | bf35027 | 2014-04-15 19:44:01 +0200 | [diff] [blame] | 1528 | p = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, pvar_ie, var_ie_len); |
| 1529 | if (p) |
| 1530 | memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + |
| 1531 | supportRateNum, p + 2, p[1]); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1532 | return _SUCCESS; |
| 1533 | } |
| 1534 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1535 | void process_addba_req23a(struct rtw_adapter *padapter, |
| 1536 | u8 *paddba_req, u8 *addr) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1537 | { |
| 1538 | struct sta_info *psta; |
| 1539 | u16 tid, start_seq, param; |
| 1540 | struct recv_reorder_ctrl *preorder_ctrl; |
| 1541 | struct sta_priv *pstapriv = &padapter->stapriv; |
Greg Donald | 7e6646d | 2014-09-06 19:42:03 -0500 | [diff] [blame] | 1542 | struct ADDBA_request *preq = (struct ADDBA_request *)paddba_req; |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1543 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1544 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 1545 | |
| 1546 | psta = rtw_get_stainfo23a(pstapriv, addr); |
| 1547 | |
| 1548 | if (psta) { |
| 1549 | start_seq = le16_to_cpu(preq->BA_starting_seqctrl) >> 4; |
| 1550 | |
| 1551 | param = le16_to_cpu(preq->BA_para_set); |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1552 | tid = (param >> 2) & 0x0f; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1553 | |
| 1554 | preorder_ctrl = &psta->recvreorder_ctrl[tid]; |
| 1555 | |
| 1556 | preorder_ctrl->indicate_seq = 0xffff; |
| 1557 | |
Jes Sorensen | c227ed0 | 2014-05-09 15:03:27 +0200 | [diff] [blame] | 1558 | preorder_ctrl->enable = (pmlmeinfo->bAcceptAddbaReq == true) ? |
| 1559 | true : false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1560 | } |
| 1561 | } |