This source file includes following definitions.
- cckrates_included
- cckratesonly_included
- networktype_to_raid_ex
- ratetbl_val_2wifirate
- is_basicrate
- ratetbl2rateset
- get_rate_set
- set_mcs_rate_by_mask
- UpdateBrateTbl
- UpdateBrateTblForSoftAP
- Save_DM_Func_Flag
- Restore_DM_Func_Flag
- Switch_DM_Func
- Set_MSR
- rtw_get_oper_ch
- rtw_set_oper_ch
- rtw_get_oper_bw
- rtw_set_oper_bw
- rtw_get_oper_choffset
- rtw_set_oper_choffset
- rtw_get_center_ch
- rtw_get_on_cur_ch_time
- SelectChannel
- set_channel_bwmode
- get_my_bssid
- get_beacon_interval
- is_client_associated_to_ap
- is_client_associated_to_ibss
- is_IBSS_empty
- decide_wait_for_beacon_timeout
- invalidate_cam_all
- _ReadCAM
- read_cam
- _write_cam
- _clear_cam_entry
- write_cam
- clear_cam_entry
- write_cam_from_cache
- write_cam_cache
- clear_cam_cache
- _rtw_camid_is_gk
- _rtw_camid_search
- rtw_camid_search
- rtw_camid_alloc
- rtw_camid_free
- allocate_fw_sta_entry
- flush_all_cam_entry
- WMM_param_handler
- WMMOnAssocRsp
- bwmode_update_check
- HT_caps_handler
- HT_info_handler
- HTOnAssocRsp
- ERP_IE_handler
- VCS_update
- update_ldpc_stbc_cap
- rtw_check_bcn_info
- update_beacon_info
- is_ap_in_tkip
- support_short_GI
- get_highest_rate_idx
- Update_RA_Entry
- set_sta_rate
- check_assoc_AP
- update_IOT_info
- update_capinfo
- update_wireless_mode
- update_sta_basic_rate
- update_sta_support_rate
- process_addba_req
- update_TSF
- correct_TSF
- adaptive_early_32k
- rtw_alloc_macid
- rtw_release_macid
- rtw_search_max_mac_id
- dvobj_get_port0_adapter
- rtw_get_gpio
- rtw_set_gpio_output_value
- rtw_config_gpio
- rtw_get_current_ip_address
- rtw_get_sec_iv
- rtw_set_sec_pn
1
2
3
4
5
6
7 #define _RTW_WLAN_UTIL_C_
8
9 #include <drv_types.h>
10 #include <rtw_debug.h>
11 #include <hal_com_h2c.h>
12
13 #if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
14 #include <linux/inetdevice.h>
15 #endif
16
17 static unsigned char ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f};
18 static unsigned char ARTHEROS_OUI2[] = {0x00, 0x13, 0x74};
19
20 static unsigned char BROADCOM_OUI1[] = {0x00, 0x10, 0x18};
21 static unsigned char BROADCOM_OUI2[] = {0x00, 0x0a, 0xf7};
22 static unsigned char BROADCOM_OUI3[] = {0x00, 0x05, 0xb5};
23
24 static unsigned char CISCO_OUI[] = {0x00, 0x40, 0x96};
25 static unsigned char MARVELL_OUI[] = {0x00, 0x50, 0x43};
26 static unsigned char RALINK_OUI[] = {0x00, 0x0c, 0x43};
27 static unsigned char REALTEK_OUI[] = {0x00, 0xe0, 0x4c};
28 static unsigned char AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5};
29 static unsigned char RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02};
30 static unsigned char WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02};
31
32 extern unsigned char RTW_WPA_OUI[];
33 extern unsigned char WPA_TKIP_CIPHER[4];
34
35 #define R2T_PHY_DELAY (0)
36
37
38 #define WAIT_FOR_BCN_TO_MIN (6000)
39 #define WAIT_FOR_BCN_TO_MAX (20000)
40
41 #define DISCONNECT_BY_CHK_BCN_FAIL_OBSERV_PERIOD_IN_MS 1000
42 #define DISCONNECT_BY_CHK_BCN_FAIL_THRESHOLD 3
43
44 static u8 rtw_basic_rate_cck[4] = {
45 IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK,
46 IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK,
47 IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK,
48 IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK
49 };
50
51 static u8 rtw_basic_rate_ofdm[3] = {
52 IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK,
53 IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK,
54 IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK
55 };
56
57 int cckrates_included(unsigned char *rate, int ratelen)
58 {
59 int i;
60
61 for (i = 0; i < ratelen; i++) {
62 if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
63 (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
64 return true;
65 }
66
67 return false;
68 }
69
70 int cckratesonly_included(unsigned char *rate, int ratelen)
71 {
72 int i;
73
74 for (i = 0; i < ratelen; i++) {
75 if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
76 (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22))
77 return false;
78 }
79
80 return true;
81 }
82
83 u8 networktype_to_raid_ex(struct adapter *adapter, struct sta_info *psta)
84 {
85 u8 raid, cur_rf_type, rf_type = RF_1T1R;
86
87 rtw_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, (u8 *)(&cur_rf_type));
88
89 if (cur_rf_type == RF_1T1R) {
90 rf_type = RF_1T1R;
91 } else if (IsSupportedVHT(psta->wireless_mode)) {
92 if (psta->ra_mask & 0xffc00000)
93 rf_type = RF_2T2R;
94 } else if (IsSupportedHT(psta->wireless_mode)) {
95 if (psta->ra_mask & 0xfff00000)
96 rf_type = RF_2T2R;
97 }
98
99 switch (psta->wireless_mode) {
100 case WIRELESS_11B:
101 raid = RATEID_IDX_B;
102 break;
103 case WIRELESS_11A:
104 case WIRELESS_11G:
105 raid = RATEID_IDX_G;
106 break;
107 case WIRELESS_11BG:
108 raid = RATEID_IDX_BG;
109 break;
110 case WIRELESS_11_24N:
111 case WIRELESS_11_5N:
112 case WIRELESS_11A_5N:
113 case WIRELESS_11G_24N:
114 if (rf_type == RF_2T2R)
115 raid = RATEID_IDX_GN_N2SS;
116 else
117 raid = RATEID_IDX_GN_N1SS;
118 break;
119 case WIRELESS_11B_24N:
120 case WIRELESS_11BG_24N:
121 if (psta->bw_mode == CHANNEL_WIDTH_20) {
122 if (rf_type == RF_2T2R)
123 raid = RATEID_IDX_BGN_20M_2SS_BN;
124 else
125 raid = RATEID_IDX_BGN_20M_1SS_BN;
126 } else {
127 if (rf_type == RF_2T2R)
128 raid = RATEID_IDX_BGN_40M_2SS;
129 else
130 raid = RATEID_IDX_BGN_40M_1SS;
131 }
132 break;
133 default:
134 raid = RATEID_IDX_BGN_40M_2SS;
135 break;
136 }
137 return raid;
138 }
139
140 unsigned char ratetbl_val_2wifirate(unsigned char rate);
141 unsigned char ratetbl_val_2wifirate(unsigned char rate)
142 {
143 switch (rate & 0x7f) {
144 case 0:
145 return IEEE80211_CCK_RATE_1MB;
146 case 1:
147 return IEEE80211_CCK_RATE_2MB;
148 case 2:
149 return IEEE80211_CCK_RATE_5MB;
150 case 3:
151 return IEEE80211_CCK_RATE_11MB;
152 case 4:
153 return IEEE80211_OFDM_RATE_6MB;
154 case 5:
155 return IEEE80211_OFDM_RATE_9MB;
156 case 6:
157 return IEEE80211_OFDM_RATE_12MB;
158 case 7:
159 return IEEE80211_OFDM_RATE_18MB;
160 case 8:
161 return IEEE80211_OFDM_RATE_24MB;
162 case 9:
163 return IEEE80211_OFDM_RATE_36MB;
164 case 10:
165 return IEEE80211_OFDM_RATE_48MB;
166 case 11:
167 return IEEE80211_OFDM_RATE_54MB;
168 default:
169 return 0;
170 }
171 }
172
173 int is_basicrate(struct adapter *padapter, unsigned char rate);
174 int is_basicrate(struct adapter *padapter, unsigned char rate)
175 {
176 int i;
177 unsigned char val;
178 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
179
180 for (i = 0; i < NumRates; i++) {
181 val = pmlmeext->basicrate[i];
182
183 if ((val != 0xff) && (val != 0xfe))
184 if (rate == ratetbl_val_2wifirate(val))
185 return true;
186 }
187
188 return false;
189 }
190
191 unsigned int ratetbl2rateset(struct adapter *padapter, unsigned char *rateset);
192 unsigned int ratetbl2rateset(struct adapter *padapter, unsigned char *rateset)
193 {
194 int i;
195 unsigned char rate;
196 unsigned int len = 0;
197 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
198
199 for (i = 0; i < NumRates; i++) {
200 rate = pmlmeext->datarate[i];
201
202 switch (rate) {
203 case 0xff:
204 return len;
205
206 case 0xfe:
207 continue;
208
209 default:
210 rate = ratetbl_val_2wifirate(rate);
211
212 if (is_basicrate(padapter, rate) == true)
213 rate |= IEEE80211_BASIC_RATE_MASK;
214
215 rateset[len] = rate;
216 len++;
217 break;
218 }
219 }
220 return len;
221 }
222
223 void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *bssrate_len)
224 {
225 unsigned char supportedrates[NumRates];
226
227 memset(supportedrates, 0, NumRates);
228 *bssrate_len = ratetbl2rateset(padapter, supportedrates);
229 memcpy(pbssrate, supportedrates, *bssrate_len);
230 }
231
232 void set_mcs_rate_by_mask(u8 *mcs_set, u32 mask)
233 {
234 u8 mcs_rate_1r = (u8)(mask&0xff);
235 u8 mcs_rate_2r = (u8)((mask>>8)&0xff);
236 u8 mcs_rate_3r = (u8)((mask>>16)&0xff);
237 u8 mcs_rate_4r = (u8)((mask>>24)&0xff);
238
239 mcs_set[0] &= mcs_rate_1r;
240 mcs_set[1] &= mcs_rate_2r;
241 mcs_set[2] &= mcs_rate_3r;
242 mcs_set[3] &= mcs_rate_4r;
243 }
244
245 void UpdateBrateTbl(struct adapter *Adapter, u8 *mBratesOS)
246 {
247 u8 i;
248 u8 rate;
249
250
251 for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) {
252 rate = mBratesOS[i] & 0x7f;
253 switch (rate) {
254 case IEEE80211_CCK_RATE_1MB:
255 case IEEE80211_CCK_RATE_2MB:
256 case IEEE80211_CCK_RATE_5MB:
257 case IEEE80211_CCK_RATE_11MB:
258 case IEEE80211_OFDM_RATE_6MB:
259 case IEEE80211_OFDM_RATE_12MB:
260 case IEEE80211_OFDM_RATE_24MB:
261 mBratesOS[i] |= IEEE80211_BASIC_RATE_MASK;
262 break;
263 }
264 }
265 }
266
267 void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen)
268 {
269 u8 i;
270 u8 rate;
271
272 for (i = 0; i < bssratelen; i++) {
273 rate = bssrateset[i] & 0x7f;
274 switch (rate) {
275 case IEEE80211_CCK_RATE_1MB:
276 case IEEE80211_CCK_RATE_2MB:
277 case IEEE80211_CCK_RATE_5MB:
278 case IEEE80211_CCK_RATE_11MB:
279 bssrateset[i] |= IEEE80211_BASIC_RATE_MASK;
280 break;
281 }
282 }
283 }
284
285 void Save_DM_Func_Flag(struct adapter *padapter)
286 {
287 u8 bSaveFlag = true;
288 rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&bSaveFlag));
289 }
290
291 void Restore_DM_Func_Flag(struct adapter *padapter)
292 {
293 u8 bSaveFlag = false;
294 rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&bSaveFlag));
295 }
296
297 void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable)
298 {
299 if (enable == true)
300 rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_SET, (u8 *)(&mode));
301 else
302 rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode));
303 }
304
305 void Set_MSR(struct adapter *padapter, u8 type)
306 {
307 rtw_hal_set_hwreg(padapter, HW_VAR_MEDIA_STATUS, (u8 *)(&type));
308 }
309
310 inline u8 rtw_get_oper_ch(struct adapter *adapter)
311 {
312 return adapter_to_dvobj(adapter)->oper_channel;
313 }
314
315 inline void rtw_set_oper_ch(struct adapter *adapter, u8 ch)
316 {
317 #ifdef DBG_CH_SWITCH
318 const int len = 128;
319 char msg[128] = {0};
320 int cnt = 0;
321 int i = 0;
322 #endif
323 struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
324
325 if (dvobj->oper_channel != ch) {
326 dvobj->on_oper_ch_time = jiffies;
327
328 #ifdef DBG_CH_SWITCH
329 cnt += snprintf(msg+cnt, len-cnt, "switch to ch %3u", ch);
330
331 for (i = 0; i < dvobj->iface_nums; i++) {
332 struct adapter *iface = dvobj->padapters[i];
333 cnt += snprintf(msg+cnt, len-cnt, " ["ADPT_FMT":", ADPT_ARG(iface));
334 if (iface->mlmeextpriv.cur_channel == ch)
335 cnt += snprintf(msg+cnt, len-cnt, "C");
336 else
337 cnt += snprintf(msg+cnt, len-cnt, "_");
338 if (iface->wdinfo.listen_channel == ch && !rtw_p2p_chk_state(&iface->wdinfo, P2P_STATE_NONE))
339 cnt += snprintf(msg+cnt, len-cnt, "L");
340 else
341 cnt += snprintf(msg+cnt, len-cnt, "_");
342 cnt += snprintf(msg+cnt, len-cnt, "]");
343 }
344
345 DBG_871X(FUNC_ADPT_FMT" %s\n", FUNC_ADPT_ARG(adapter), msg);
346 #endif
347 }
348
349 dvobj->oper_channel = ch;
350 }
351
352 inline u8 rtw_get_oper_bw(struct adapter *adapter)
353 {
354 return adapter_to_dvobj(adapter)->oper_bwmode;
355 }
356
357 inline void rtw_set_oper_bw(struct adapter *adapter, u8 bw)
358 {
359 adapter_to_dvobj(adapter)->oper_bwmode = bw;
360 }
361
362 inline u8 rtw_get_oper_choffset(struct adapter *adapter)
363 {
364 return adapter_to_dvobj(adapter)->oper_ch_offset;
365 }
366
367 inline void rtw_set_oper_choffset(struct adapter *adapter, u8 offset)
368 {
369 adapter_to_dvobj(adapter)->oper_ch_offset = offset;
370 }
371
372 u8 rtw_get_center_ch(u8 channel, u8 chnl_bw, u8 chnl_offset)
373 {
374 u8 center_ch = channel;
375
376 if (chnl_bw == CHANNEL_WIDTH_80) {
377 if ((channel == 36) || (channel == 40) || (channel == 44) || (channel == 48))
378 center_ch = 42;
379 if ((channel == 52) || (channel == 56) || (channel == 60) || (channel == 64))
380 center_ch = 58;
381 if ((channel == 100) || (channel == 104) || (channel == 108) || (channel == 112))
382 center_ch = 106;
383 if ((channel == 116) || (channel == 120) || (channel == 124) || (channel == 128))
384 center_ch = 122;
385 if ((channel == 132) || (channel == 136) || (channel == 140) || (channel == 144))
386 center_ch = 138;
387 if ((channel == 149) || (channel == 153) || (channel == 157) || (channel == 161))
388 center_ch = 155;
389 else if (channel <= 14)
390 center_ch = 7;
391 } else if (chnl_bw == CHANNEL_WIDTH_40) {
392 if (chnl_offset == HAL_PRIME_CHNL_OFFSET_LOWER)
393 center_ch = channel + 2;
394 else
395 center_ch = channel - 2;
396 }
397
398 return center_ch;
399 }
400
401 inline unsigned long rtw_get_on_cur_ch_time(struct adapter *adapter)
402 {
403 if (adapter->mlmeextpriv.cur_channel == adapter_to_dvobj(adapter)->oper_channel)
404 return adapter_to_dvobj(adapter)->on_oper_ch_time;
405 else
406 return 0;
407 }
408
409 void SelectChannel(struct adapter *padapter, unsigned char channel)
410 {
411 if (mutex_lock_interruptible(&(adapter_to_dvobj(padapter)->setch_mutex)))
412 return;
413
414
415 rtw_set_oper_ch(padapter, channel);
416
417 rtw_hal_set_chan(padapter, channel);
418
419 mutex_unlock(&(adapter_to_dvobj(padapter)->setch_mutex));
420 }
421
422 void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigned char channel_offset, unsigned short bwmode)
423 {
424 u8 center_ch, chnl_offset80 = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
425
426 if (padapter->bNotifyChannelChange)
427 DBG_871X("[%s] ch = %d, offset = %d, bwmode = %d\n", __func__, channel, channel_offset, bwmode);
428
429 center_ch = rtw_get_center_ch(channel, bwmode, channel_offset);
430
431 if (bwmode == CHANNEL_WIDTH_80) {
432 if (center_ch > channel)
433 chnl_offset80 = HAL_PRIME_CHNL_OFFSET_LOWER;
434 else if (center_ch < channel)
435 chnl_offset80 = HAL_PRIME_CHNL_OFFSET_UPPER;
436 else
437 chnl_offset80 = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
438 }
439
440
441 if (mutex_lock_interruptible(&(adapter_to_dvobj(padapter)->setch_mutex)))
442 return;
443
444
445 rtw_set_oper_ch(padapter, channel);
446 rtw_set_oper_bw(padapter, bwmode);
447 rtw_set_oper_choffset(padapter, channel_offset);
448
449 rtw_hal_set_chnl_bw(padapter, center_ch, bwmode, channel_offset, chnl_offset80);
450
451 mutex_unlock(&(adapter_to_dvobj(padapter)->setch_mutex));
452 }
453
454 inline u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork)
455 {
456 return pnetwork->MacAddress;
457 }
458
459 u16 get_beacon_interval(struct wlan_bssid_ex *bss)
460 {
461 __le16 val;
462 memcpy((unsigned char *)&val, rtw_get_beacon_interval_from_ie(bss->IEs), 2);
463
464 return le16_to_cpu(val);
465 }
466
467 int is_client_associated_to_ap(struct adapter *padapter)
468 {
469 struct mlme_ext_priv *pmlmeext;
470 struct mlme_ext_info *pmlmeinfo;
471
472 if (!padapter)
473 return _FAIL;
474
475 pmlmeext = &padapter->mlmeextpriv;
476 pmlmeinfo = &(pmlmeext->mlmext_info);
477
478 if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE))
479 return true;
480 else
481 return _FAIL;
482 }
483
484 int is_client_associated_to_ibss(struct adapter *padapter)
485 {
486 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
487 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
488
489 if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE))
490 return true;
491 else
492 return _FAIL;
493 }
494
495 int is_IBSS_empty(struct adapter *padapter)
496 {
497 unsigned int i;
498 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
499 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
500
501 for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) {
502 if (pmlmeinfo->FW_sta_info[i].status == 1)
503 return _FAIL;
504 }
505
506 return true;
507 }
508
509 unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval)
510 {
511 if ((bcn_interval << 2) < WAIT_FOR_BCN_TO_MIN)
512 return WAIT_FOR_BCN_TO_MIN;
513 else if ((bcn_interval << 2) > WAIT_FOR_BCN_TO_MAX)
514 return WAIT_FOR_BCN_TO_MAX;
515 else
516 return bcn_interval << 2;
517 }
518
519 void invalidate_cam_all(struct adapter *padapter)
520 {
521 struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
522 struct cam_ctl_t *cam_ctl = &dvobj->cam_ctl;
523
524 rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL);
525
526 spin_lock_bh(&cam_ctl->lock);
527 cam_ctl->bitmap = 0;
528 memset(dvobj->cam_cache, 0, sizeof(struct cam_entry_cache)*TOTAL_CAM_ENTRY);
529 spin_unlock_bh(&cam_ctl->lock);
530 }
531
532 static u32 _ReadCAM(struct adapter *padapter, u32 addr)
533 {
534 u32 count = 0, cmd;
535 cmd = CAM_POLLINIG | addr;
536 rtw_write32(padapter, RWCAM, cmd);
537
538 do {
539 if (0 == (rtw_read32(padapter, REG_CAMCMD) & CAM_POLLINIG))
540 break;
541 } while (count++ < 100);
542
543 return rtw_read32(padapter, REG_CAMREAD);
544 }
545 void read_cam(struct adapter *padapter, u8 entry, u8 *get_key)
546 {
547 u32 j, addr, cmd;
548 addr = entry << 3;
549
550
551 for (j = 0; j < 6; j++) {
552 cmd = _ReadCAM(padapter, addr+j);
553
554 if (j > 1)
555 memcpy(get_key+(j-2)*4, &cmd, 4);
556 }
557
558 }
559
560 void _write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key)
561 {
562 unsigned int i, val, addr;
563 int j;
564 u32 cam_val[2];
565
566 addr = entry << 3;
567
568 for (j = 5; j >= 0; j--) {
569 switch (j) {
570 case 0:
571 val = (ctrl | (mac[0] << 16) | (mac[1] << 24));
572 break;
573 case 1:
574 val = (mac[2] | (mac[3] << 8) | (mac[4] << 16) | (mac[5] << 24));
575 break;
576 default:
577 i = (j - 2) << 2;
578 val = (key[i] | (key[i+1] << 8) | (key[i+2] << 16) | (key[i+3] << 24));
579 break;
580 }
581
582 cam_val[0] = val;
583 cam_val[1] = addr + (unsigned int)j;
584
585 rtw_hal_set_hwreg(padapter, HW_VAR_CAM_WRITE, (u8 *)cam_val);
586 }
587 }
588
589 void _clear_cam_entry(struct adapter *padapter, u8 entry)
590 {
591 unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
592 unsigned char null_key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
593
594 _write_cam(padapter, entry, 0, null_sta, null_key);
595 }
596
597 inline void write_cam(struct adapter *adapter, u8 id, u16 ctrl, u8 *mac, u8 *key)
598 {
599 _write_cam(adapter, id, ctrl, mac, key);
600 write_cam_cache(adapter, id, ctrl, mac, key);
601 }
602
603 inline void clear_cam_entry(struct adapter *adapter, u8 id)
604 {
605 _clear_cam_entry(adapter, id);
606 clear_cam_cache(adapter, id);
607 }
608
609 inline void write_cam_from_cache(struct adapter *adapter, u8 id)
610 {
611 struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
612 struct cam_ctl_t *cam_ctl = &dvobj->cam_ctl;
613 struct cam_entry_cache cache;
614
615 spin_lock_bh(&cam_ctl->lock);
616 memcpy(&cache, &dvobj->cam_cache[id], sizeof(struct cam_entry_cache));
617 spin_unlock_bh(&cam_ctl->lock);
618
619 _write_cam(adapter, id, cache.ctrl, cache.mac, cache.key);
620 }
621
622 void write_cam_cache(struct adapter *adapter, u8 id, u16 ctrl, u8 *mac, u8 *key)
623 {
624 struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
625 struct cam_ctl_t *cam_ctl = &dvobj->cam_ctl;
626
627 spin_lock_bh(&cam_ctl->lock);
628
629 dvobj->cam_cache[id].ctrl = ctrl;
630 memcpy(dvobj->cam_cache[id].mac, mac, ETH_ALEN);
631 memcpy(dvobj->cam_cache[id].key, key, 16);
632
633 spin_unlock_bh(&cam_ctl->lock);
634 }
635
636 void clear_cam_cache(struct adapter *adapter, u8 id)
637 {
638 struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
639 struct cam_ctl_t *cam_ctl = &dvobj->cam_ctl;
640
641 spin_lock_bh(&cam_ctl->lock);
642
643 memset(&(dvobj->cam_cache[id]), 0, sizeof(struct cam_entry_cache));
644
645 spin_unlock_bh(&cam_ctl->lock);
646 }
647
648 static bool _rtw_camid_is_gk(struct adapter *adapter, u8 cam_id)
649 {
650 struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
651 struct cam_ctl_t *cam_ctl = &dvobj->cam_ctl;
652 bool ret = false;
653
654 if (cam_id >= TOTAL_CAM_ENTRY)
655 goto exit;
656
657 if (!(cam_ctl->bitmap & BIT(cam_id)))
658 goto exit;
659
660 ret = (dvobj->cam_cache[cam_id].ctrl&BIT6)?true:false;
661
662 exit:
663 return ret;
664 }
665
666 static s16 _rtw_camid_search(struct adapter *adapter, u8 *addr, s16 kid)
667 {
668 struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
669 int i;
670 s16 cam_id = -1;
671
672 for (i = 0; i < TOTAL_CAM_ENTRY; i++) {
673 if (addr && memcmp(dvobj->cam_cache[i].mac, addr, ETH_ALEN))
674 continue;
675 if (kid >= 0 && kid != (dvobj->cam_cache[i].ctrl&0x03))
676 continue;
677
678 cam_id = i;
679 break;
680 }
681
682 if (addr)
683 DBG_871X(FUNC_ADPT_FMT" addr:"MAC_FMT" kid:%d, return cam_id:%d\n"
684 , FUNC_ADPT_ARG(adapter), MAC_ARG(addr), kid, cam_id);
685 else
686 DBG_871X(FUNC_ADPT_FMT" addr:%p kid:%d, return cam_id:%d\n"
687 , FUNC_ADPT_ARG(adapter), addr, kid, cam_id);
688
689 return cam_id;
690 }
691
692 s16 rtw_camid_search(struct adapter *adapter, u8 *addr, s16 kid)
693 {
694 struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
695 struct cam_ctl_t *cam_ctl = &dvobj->cam_ctl;
696 s16 cam_id = -1;
697
698 spin_lock_bh(&cam_ctl->lock);
699 cam_id = _rtw_camid_search(adapter, addr, kid);
700 spin_unlock_bh(&cam_ctl->lock);
701
702 return cam_id;
703 }
704
705 s16 rtw_camid_alloc(struct adapter *adapter, struct sta_info *sta, u8 kid)
706 {
707 struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
708 struct cam_ctl_t *cam_ctl = &dvobj->cam_ctl;
709 s16 cam_id = -1;
710 struct mlme_ext_info *mlmeinfo;
711
712 spin_lock_bh(&cam_ctl->lock);
713
714 mlmeinfo = &adapter->mlmeextpriv.mlmext_info;
715
716 if ((((mlmeinfo->state&0x03) == WIFI_FW_AP_STATE) || ((mlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE))
717 && !sta) {
718
719 if (kid > 3) {
720 DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" group key with invalid key id:%u\n"
721 , FUNC_ADPT_ARG(adapter), kid);
722 rtw_warn_on(1);
723 goto bitmap_handle;
724 }
725
726 cam_id = kid;
727 } else {
728 int i;
729 u8 *addr = sta?sta->hwaddr:NULL;
730
731 if (!sta) {
732 if (!(mlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) {
733
734 goto bitmap_handle;
735 }
736
737 addr = get_bssid(&adapter->mlmepriv);
738 }
739
740 i = _rtw_camid_search(adapter, addr, kid);
741 if (i >= 0) {
742
743 if (sta || _rtw_camid_is_gk(adapter, i))
744 cam_id = i;
745 else
746 DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" group key id:%u the same key id as pairwise key\n"
747 , FUNC_ADPT_ARG(adapter), kid);
748 goto bitmap_handle;
749 }
750
751 for (i = 4; i < TOTAL_CAM_ENTRY; i++)
752 if (!(cam_ctl->bitmap & BIT(i)))
753 break;
754
755 if (i == TOTAL_CAM_ENTRY) {
756 if (sta)
757 DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" pairwise key with "MAC_FMT" id:%u no room\n"
758 , FUNC_ADPT_ARG(adapter), MAC_ARG(sta->hwaddr), kid);
759 else
760 DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" group key id:%u no room\n"
761 , FUNC_ADPT_ARG(adapter), kid);
762 rtw_warn_on(1);
763 goto bitmap_handle;
764 }
765
766 cam_id = i;
767 }
768
769 bitmap_handle:
770 if (cam_id >= 0 && cam_id < 32)
771 cam_ctl->bitmap |= BIT(cam_id);
772
773 spin_unlock_bh(&cam_ctl->lock);
774
775 return cam_id;
776 }
777
778 void rtw_camid_free(struct adapter *adapter, u8 cam_id)
779 {
780 struct dvobj_priv *dvobj = adapter_to_dvobj(adapter);
781 struct cam_ctl_t *cam_ctl = &dvobj->cam_ctl;
782
783 spin_lock_bh(&cam_ctl->lock);
784
785 if (cam_id < TOTAL_CAM_ENTRY)
786 cam_ctl->bitmap &= ~(BIT(cam_id));
787
788 spin_unlock_bh(&cam_ctl->lock);
789 }
790
791 int allocate_fw_sta_entry(struct adapter *padapter)
792 {
793 unsigned int mac_id;
794 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
795 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
796
797 for (mac_id = IBSS_START_MAC_ID; mac_id < NUM_STA; mac_id++) {
798 if (pmlmeinfo->FW_sta_info[mac_id].status == 0) {
799 pmlmeinfo->FW_sta_info[mac_id].status = 1;
800 pmlmeinfo->FW_sta_info[mac_id].retry = 0;
801 break;
802 }
803 }
804
805 return mac_id;
806 }
807
808 void flush_all_cam_entry(struct adapter *padapter)
809 {
810 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
811 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
812
813 invalidate_cam_all(padapter);
814
815 rtw_hal_set_hwreg(padapter, HW_VAR_SEC_DK_CFG, (u8 *)false);
816
817 memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info));
818 }
819
820 int WMM_param_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE)
821 {
822
823 struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
824 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
825 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
826
827 if (pmlmepriv->qospriv.qos_option == 0) {
828 pmlmeinfo->WMM_enable = 0;
829 return false;
830 }
831
832 if (!memcmp(&(pmlmeinfo->WMM_param), (pIE->data + 6), sizeof(struct WMM_para_element)))
833 return false;
834 else
835 memcpy(&(pmlmeinfo->WMM_param), (pIE->data + 6), sizeof(struct WMM_para_element));
836
837 pmlmeinfo->WMM_enable = 1;
838 return true;
839 }
840
841 void WMMOnAssocRsp(struct adapter *padapter)
842 {
843 u8 ACI, ACM, AIFS, ECWMin, ECWMax, aSifsTime;
844 u8 acm_mask;
845 u16 TXOP;
846 u32 acParm, i;
847 u32 edca[4], inx[4];
848 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
849 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
850 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
851 struct registry_priv *pregpriv = &padapter->registrypriv;
852
853 acm_mask = 0;
854
855 if (pmlmeext->cur_wireless_mode & WIRELESS_11_24N)
856 aSifsTime = 16;
857 else
858 aSifsTime = 10;
859
860 if (pmlmeinfo->WMM_enable == 0) {
861 padapter->mlmepriv.acm_mask = 0;
862
863 AIFS = aSifsTime + (2 * pmlmeinfo->slotTime);
864
865 if (pmlmeext->cur_wireless_mode & (WIRELESS_11G | WIRELESS_11A)) {
866 ECWMin = 4;
867 ECWMax = 10;
868 } else if (pmlmeext->cur_wireless_mode & WIRELESS_11B) {
869 ECWMin = 5;
870 ECWMax = 10;
871 } else {
872 ECWMin = 4;
873 ECWMax = 10;
874 }
875
876 TXOP = 0;
877 acParm = AIFS | (ECWMin << 8) | (ECWMax << 12) | (TXOP << 16);
878 rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acParm));
879 rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acParm));
880 rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acParm));
881
882 ECWMin = 2;
883 ECWMax = 3;
884 TXOP = 0x2f;
885 acParm = AIFS | (ECWMin << 8) | (ECWMax << 12) | (TXOP << 16);
886 rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm));
887 } else {
888 edca[0] = edca[1] = edca[2] = edca[3] = 0;
889
890 for (i = 0; i < 4; i++) {
891 ACI = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 5) & 0x03;
892 ACM = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 4) & 0x01;
893
894
895 AIFS = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN & 0x0f) * pmlmeinfo->slotTime + aSifsTime;
896
897 ECWMin = (pmlmeinfo->WMM_param.ac_param[i].CW & 0x0f);
898 ECWMax = (pmlmeinfo->WMM_param.ac_param[i].CW & 0xf0) >> 4;
899 TXOP = le16_to_cpu(pmlmeinfo->WMM_param.ac_param[i].TXOP_limit);
900
901 acParm = AIFS | (ECWMin << 8) | (ECWMax << 12) | (TXOP << 16);
902
903 switch (ACI) {
904 case 0x0:
905 rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acParm));
906 acm_mask |= (ACM ? BIT(1):0);
907 edca[XMIT_BE_QUEUE] = acParm;
908 break;
909
910 case 0x1:
911 rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acParm));
912
913 edca[XMIT_BK_QUEUE] = acParm;
914 break;
915
916 case 0x2:
917 rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acParm));
918 acm_mask |= (ACM ? BIT(2):0);
919 edca[XMIT_VI_QUEUE] = acParm;
920 break;
921
922 case 0x3:
923 rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm));
924 acm_mask |= (ACM ? BIT(3):0);
925 edca[XMIT_VO_QUEUE] = acParm;
926 break;
927 }
928
929 DBG_871X("WMM(%x): %x, %x\n", ACI, ACM, acParm);
930 }
931
932 if (padapter->registrypriv.acm_method == 1)
933 rtw_hal_set_hwreg(padapter, HW_VAR_ACM_CTRL, (u8 *)(&acm_mask));
934 else
935 padapter->mlmepriv.acm_mask = acm_mask;
936
937 inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3;
938
939 if (pregpriv->wifi_spec == 1) {
940 u32 j, tmp, change_inx = false;
941
942
943 for (i = 0; i < 4; i++) {
944 for (j = i+1; j < 4; j++) {
945
946 if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) {
947 change_inx = true;
948 } else if ((edca[j] & 0xFFFF) == (edca[i] & 0xFFFF)) {
949
950 if ((edca[j] >> 16) > (edca[i] >> 16))
951 change_inx = true;
952 }
953
954 if (change_inx) {
955 tmp = edca[i];
956 edca[i] = edca[j];
957 edca[j] = tmp;
958
959 tmp = inx[i];
960 inx[i] = inx[j];
961 inx[j] = tmp;
962
963 change_inx = false;
964 }
965 }
966 }
967 }
968
969 for (i = 0; i < 4; i++) {
970 pxmitpriv->wmm_para_seq[i] = inx[i];
971 DBG_871X("wmm_para_seq(%d): %d\n", i, pxmitpriv->wmm_para_seq[i]);
972 }
973 }
974 }
975
976 static void bwmode_update_check(struct adapter *padapter, struct ndis_80211_var_ie *pIE)
977 {
978 unsigned char new_bwmode;
979 unsigned char new_ch_offset;
980 struct HT_info_element *pHT_info;
981 struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
982 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
983 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
984 struct registry_priv *pregistrypriv = &padapter->registrypriv;
985 struct ht_priv *phtpriv = &pmlmepriv->htpriv;
986 u8 cbw40_enable = 0;
987
988 if (!pIE)
989 return;
990
991 if (phtpriv->ht_option == false)
992 return;
993
994 if (pmlmeext->cur_bwmode >= CHANNEL_WIDTH_80)
995 return;
996
997 if (pIE->Length > sizeof(struct HT_info_element))
998 return;
999
1000 pHT_info = (struct HT_info_element *)pIE->data;
1001
1002 if (pmlmeext->cur_channel > 14) {
1003 if ((pregistrypriv->bw_mode & 0xf0) > 0)
1004 cbw40_enable = 1;
1005 } else
1006 if ((pregistrypriv->bw_mode & 0x0f) > 0)
1007 cbw40_enable = 1;
1008
1009 if ((pHT_info->infos[0] & BIT(2)) && cbw40_enable) {
1010 new_bwmode = CHANNEL_WIDTH_40;
1011
1012 switch (pHT_info->infos[0] & 0x3) {
1013 case 1:
1014 new_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
1015 break;
1016
1017 case 3:
1018 new_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
1019 break;
1020
1021 default:
1022 new_bwmode = CHANNEL_WIDTH_20;
1023 new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
1024 break;
1025 }
1026 } else {
1027 new_bwmode = CHANNEL_WIDTH_20;
1028 new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
1029 }
1030
1031 if ((new_bwmode != pmlmeext->cur_bwmode) || (new_ch_offset != pmlmeext->cur_ch_offset)) {
1032 pmlmeinfo->bwmode_updated = true;
1033
1034 pmlmeext->cur_bwmode = new_bwmode;
1035 pmlmeext->cur_ch_offset = new_ch_offset;
1036
1037
1038 HT_info_handler(padapter, pIE);
1039 } else
1040 pmlmeinfo->bwmode_updated = false;
1041
1042 if (true == pmlmeinfo->bwmode_updated) {
1043 struct sta_info *psta;
1044 struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network);
1045 struct sta_priv *pstapriv = &padapter->stapriv;
1046
1047
1048
1049
1050 psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress);
1051 if (psta) {
1052 struct ht_priv *phtpriv_sta = &psta->htpriv;
1053
1054 if (phtpriv_sta->ht_option) {
1055
1056 psta->bw_mode = pmlmeext->cur_bwmode;
1057 phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset;
1058 } else {
1059 psta->bw_mode = CHANNEL_WIDTH_20;
1060 phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
1061 }
1062
1063 rtw_dm_ra_mask_wk_cmd(padapter, (u8 *)psta);
1064 }
1065 }
1066 }
1067
1068 void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE)
1069 {
1070 unsigned int i;
1071 u8 rf_type;
1072 u8 max_AMPDU_len, min_MPDU_spacing;
1073 u8 cur_ldpc_cap = 0, cur_stbc_cap = 0;
1074 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1075 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1076 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
1077 struct ht_priv *phtpriv = &pmlmepriv->htpriv;
1078
1079 if (!pIE)
1080 return;
1081
1082 if (phtpriv->ht_option == false)
1083 return;
1084
1085 pmlmeinfo->HT_caps_enable = 1;
1086
1087 for (i = 0; i < (pIE->Length); i++) {
1088 if (i != 2) {
1089
1090
1091 pmlmeinfo->HT_caps.u.HT_cap[i] &= (pIE->data[i]);
1092 } else {
1093
1094 if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3) > (pIE->data[i] & 0x3))
1095 max_AMPDU_len = (pIE->data[i] & 0x3);
1096 else
1097 max_AMPDU_len = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3);
1098
1099 if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) > (pIE->data[i] & 0x1c))
1100 min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c);
1101 else
1102 min_MPDU_spacing = (pIE->data[i] & 0x1c);
1103
1104 pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para = max_AMPDU_len | min_MPDU_spacing;
1105 }
1106 }
1107 rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
1108
1109
1110 for (i = 0; i < 16; i++)
1111 pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= pmlmeext->default_supported_mcs_set[i];
1112
1113
1114 switch (rf_type) {
1115 case RF_1T1R:
1116 case RF_1T2R:
1117 set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_1R);
1118 break;
1119 case RF_2T2R:
1120 default:
1121 #ifdef CONFIG_DISABLE_MCS13TO15
1122 if (pmlmeext->cur_bwmode == CHANNEL_WIDTH_40 && pregistrypriv->wifi_spec != 1)
1123 set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R_13TO15_OFF);
1124 else
1125 set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R);
1126 #else
1127 set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R);
1128 #endif
1129 }
1130
1131 if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
1132
1133 if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX) && GET_HT_CAPABILITY_ELE_TX_STBC(pIE->data)) {
1134 SET_FLAG(cur_stbc_cap, STBC_HT_ENABLE_TX);
1135 DBG_871X("Enable HT Tx STBC !\n");
1136 }
1137 phtpriv->stbc_cap = cur_stbc_cap;
1138 } else {
1139
1140 if (TEST_FLAG(phtpriv->ldpc_cap, LDPC_HT_ENABLE_TX) && GET_HT_CAPABILITY_ELE_LDPC_CAP(pIE->data)) {
1141 SET_FLAG(cur_ldpc_cap, (LDPC_HT_ENABLE_TX | LDPC_HT_CAP_TX));
1142 DBG_871X("Enable HT Tx LDPC!\n");
1143 }
1144 phtpriv->ldpc_cap = cur_ldpc_cap;
1145
1146
1147 if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX) && GET_HT_CAPABILITY_ELE_RX_STBC(pIE->data)) {
1148 SET_FLAG(cur_stbc_cap, (STBC_HT_ENABLE_TX | STBC_HT_CAP_TX));
1149 DBG_871X("Enable HT Tx STBC!\n");
1150 }
1151 phtpriv->stbc_cap = cur_stbc_cap;
1152 }
1153 }
1154
1155 void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE)
1156 {
1157 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1158 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1159 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
1160 struct ht_priv *phtpriv = &pmlmepriv->htpriv;
1161
1162 if (!pIE)
1163 return;
1164
1165 if (phtpriv->ht_option == false)
1166 return;
1167
1168 if (pIE->Length > sizeof(struct HT_info_element))
1169 return;
1170
1171 pmlmeinfo->HT_info_enable = 1;
1172 memcpy(&(pmlmeinfo->HT_info), pIE->data, pIE->Length);
1173
1174 return;
1175 }
1176
1177 void HTOnAssocRsp(struct adapter *padapter)
1178 {
1179 unsigned char max_AMPDU_len;
1180 unsigned char min_MPDU_spacing;
1181
1182 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1183 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1184
1185 DBG_871X("%s\n", __func__);
1186
1187 if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) {
1188 pmlmeinfo->HT_enable = 1;
1189 } else {
1190 pmlmeinfo->HT_enable = 0;
1191
1192 return;
1193 }
1194
1195
1196
1197
1198
1199
1200 max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x03;
1201
1202 min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2;
1203
1204 rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing));
1205
1206 rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len));
1207 }
1208
1209 void ERP_IE_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE)
1210 {
1211 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1212 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1213
1214 if (pIE->Length > 1)
1215 return;
1216
1217 pmlmeinfo->ERP_enable = 1;
1218 memcpy(&(pmlmeinfo->ERP_IE), pIE->data, pIE->Length);
1219 }
1220
1221 void VCS_update(struct adapter *padapter, struct sta_info *psta)
1222 {
1223 struct registry_priv *pregpriv = &padapter->registrypriv;
1224 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1225 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1226
1227 switch (pregpriv->vrtl_carrier_sense) {
1228 case 0:
1229 psta->rtsen = 0;
1230 psta->cts2self = 0;
1231 break;
1232
1233 case 1:
1234 if (pregpriv->vcs_type == 1) {
1235 psta->rtsen = 1;
1236 psta->cts2self = 0;
1237 } else {
1238 psta->rtsen = 0;
1239 psta->cts2self = 1;
1240 }
1241 break;
1242
1243 case 2:
1244 default:
1245 if ((pmlmeinfo->ERP_enable) && (pmlmeinfo->ERP_IE & BIT(1))) {
1246 if (pregpriv->vcs_type == 1) {
1247 psta->rtsen = 1;
1248 psta->cts2self = 0;
1249 } else {
1250 psta->rtsen = 0;
1251 psta->cts2self = 1;
1252 }
1253 } else {
1254 psta->rtsen = 0;
1255 psta->cts2self = 0;
1256 }
1257 break;
1258 }
1259 }
1260
1261 void update_ldpc_stbc_cap(struct sta_info *psta)
1262 {
1263 if (psta->htpriv.ht_option) {
1264 if (TEST_FLAG(psta->htpriv.ldpc_cap, LDPC_HT_ENABLE_TX))
1265 psta->ldpc = 1;
1266
1267 if (TEST_FLAG(psta->htpriv.stbc_cap, STBC_HT_ENABLE_TX))
1268 psta->stbc = 1;
1269 } else {
1270 psta->ldpc = 0;
1271 psta->stbc = 0;
1272 }
1273 }
1274
1275 int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
1276 {
1277 unsigned int len;
1278 unsigned char *p;
1279 unsigned short val16, subtype;
1280 struct wlan_network *cur_network = &(Adapter->mlmepriv.cur_network);
1281
1282 u16 wpa_len = 0, rsn_len = 0;
1283 u8 encryp_protocol = 0;
1284 struct wlan_bssid_ex *bssid;
1285 int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0;
1286 unsigned char *pbuf;
1287 u32 wpa_ielen = 0;
1288 u8 *pbssid = GetAddr3Ptr(pframe);
1289 u32 hidden_ssid = 0;
1290 struct HT_info_element *pht_info = NULL;
1291 struct rtw_ieee80211_ht_cap *pht_cap = NULL;
1292 u32 bcn_channel;
1293 unsigned short ht_cap_info;
1294 unsigned char ht_info_infos_0;
1295 struct mlme_priv *pmlmepriv = &Adapter->mlmepriv;
1296
1297 if (is_client_associated_to_ap(Adapter) == false)
1298 return true;
1299
1300 len = packet_len - sizeof(struct ieee80211_hdr_3addr);
1301
1302 if (len > MAX_IE_SZ) {
1303 DBG_871X("%s IE too long for survey event\n", __func__);
1304 return _FAIL;
1305 }
1306
1307 if (memcmp(cur_network->network.MacAddress, pbssid, 6)) {
1308 DBG_871X("Oops: rtw_check_network_encrypt linked but recv other bssid bcn\n" MAC_FMT MAC_FMT,
1309 MAC_ARG(pbssid), MAC_ARG(cur_network->network.MacAddress));
1310 return true;
1311 }
1312
1313 bssid = rtw_zmalloc(sizeof(struct wlan_bssid_ex));
1314 if (!bssid) {
1315 DBG_871X("%s rtw_zmalloc fail !!!\n", __func__);
1316 return true;
1317 }
1318
1319 if ((pmlmepriv->timeBcnInfoChkStart != 0) && (jiffies_to_msecs(jiffies - pmlmepriv->timeBcnInfoChkStart) > DISCONNECT_BY_CHK_BCN_FAIL_OBSERV_PERIOD_IN_MS)) {
1320 pmlmepriv->timeBcnInfoChkStart = 0;
1321 pmlmepriv->NumOfBcnInfoChkFail = 0;
1322 }
1323
1324 subtype = GetFrameSubType(pframe) >> 4;
1325
1326 if (subtype == WIFI_BEACON)
1327 bssid->Reserved[0] = 1;
1328
1329 bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len;
1330
1331
1332 bssid->IELength = len;
1333 memcpy(bssid->IEs, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->IELength);
1334
1335
1336
1337 p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
1338 if (p && len > 0) {
1339 pht_cap = (struct rtw_ieee80211_ht_cap *)(p + 2);
1340 ht_cap_info = le16_to_cpu(pht_cap->cap_info);
1341 } else {
1342 ht_cap_info = 0;
1343 }
1344
1345 p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
1346 if (p && len > 0) {
1347 pht_info = (struct HT_info_element *)(p + 2);
1348 ht_info_infos_0 = pht_info->infos[0];
1349 } else {
1350 ht_info_infos_0 = 0;
1351 }
1352 if (ht_cap_info != cur_network->BcnInfo.ht_cap_info ||
1353 ((ht_info_infos_0&0x03) != (cur_network->BcnInfo.ht_info_infos_0&0x03))) {
1354 DBG_871X("%s bcn now: ht_cap_info:%x ht_info_infos_0:%x\n", __func__,
1355 ht_cap_info, ht_info_infos_0);
1356 DBG_871X("%s bcn link: ht_cap_info:%x ht_info_infos_0:%x\n", __func__,
1357 cur_network->BcnInfo.ht_cap_info, cur_network->BcnInfo.ht_info_infos_0);
1358 DBG_871X("%s bw mode change\n", __func__);
1359 {
1360
1361 cur_network->BcnInfo.ht_cap_info = ht_cap_info;
1362 cur_network->BcnInfo.ht_info_infos_0 = ht_info_infos_0;
1363
1364 }
1365
1366 }
1367
1368
1369 p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _DSSET_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
1370 if (p) {
1371 bcn_channel = *(p + 2);
1372 } else {
1373 rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
1374 if (pht_info) {
1375 bcn_channel = pht_info->primary_channel;
1376 } else {
1377
1378 bcn_channel = Adapter->mlmeextpriv.cur_channel;
1379 }
1380 }
1381 if (bcn_channel != Adapter->mlmeextpriv.cur_channel) {
1382 DBG_871X("%s beacon channel:%d cur channel:%d disconnect\n", __func__,
1383 bcn_channel, Adapter->mlmeextpriv.cur_channel);
1384 goto _mismatch;
1385 }
1386
1387
1388 p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
1389 if (!p) {
1390 DBG_871X("%s marc: cannot find SSID for survey event\n", __func__);
1391 hidden_ssid = true;
1392 } else {
1393 hidden_ssid = false;
1394 }
1395
1396 if ((NULL != p) && (false == hidden_ssid && (*(p + 1)))) {
1397 memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1));
1398 bssid->Ssid.SsidLength = *(p + 1);
1399 } else {
1400 bssid->Ssid.SsidLength = 0;
1401 bssid->Ssid.Ssid[0] = '\0';
1402 }
1403
1404 RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s bssid.Ssid.Ssid:%s bssid.Ssid.SsidLength:%d "
1405 "cur_network->network.Ssid.Ssid:%s len:%d\n", __func__, bssid->Ssid.Ssid,
1406 bssid->Ssid.SsidLength, cur_network->network.Ssid.Ssid,
1407 cur_network->network.Ssid.SsidLength));
1408
1409 if (memcmp(bssid->Ssid.Ssid, cur_network->network.Ssid.Ssid, 32) ||
1410 bssid->Ssid.SsidLength != cur_network->network.Ssid.SsidLength) {
1411 if (bssid->Ssid.Ssid[0] != '\0' && bssid->Ssid.SsidLength != 0) {
1412 DBG_871X("%s(), SSID is not match\n", __func__);
1413 goto _mismatch;
1414 }
1415 }
1416
1417
1418 val16 = rtw_get_capability((struct wlan_bssid_ex *)bssid);
1419
1420 if (val16 & BIT(4))
1421 bssid->Privacy = 1;
1422 else
1423 bssid->Privacy = 0;
1424
1425 RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
1426 ("%s(): cur_network->network.Privacy is %d, bssid.Privacy is %d\n",
1427 __func__, cur_network->network.Privacy, bssid->Privacy));
1428 if (cur_network->network.Privacy != bssid->Privacy) {
1429 DBG_871X("%s(), privacy is not match\n", __func__);
1430 goto _mismatch;
1431 }
1432
1433 rtw_get_sec_ie(bssid->IEs, bssid->IELength, NULL, &rsn_len, NULL, &wpa_len);
1434
1435 if (rsn_len > 0) {
1436 encryp_protocol = ENCRYP_PROTOCOL_WPA2;
1437 } else if (wpa_len > 0) {
1438 encryp_protocol = ENCRYP_PROTOCOL_WPA;
1439 } else {
1440 if (bssid->Privacy)
1441 encryp_protocol = ENCRYP_PROTOCOL_WEP;
1442 }
1443
1444 if (cur_network->BcnInfo.encryp_protocol != encryp_protocol) {
1445 DBG_871X("%s(): enctyp is not match\n", __func__);
1446 goto _mismatch;
1447 }
1448
1449 if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) {
1450 pbuf = rtw_get_wpa_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12);
1451 if (pbuf && (wpa_ielen > 0)) {
1452 if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) {
1453 RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
1454 ("%s pnetwork->pairwise_cipher: %d, group_cipher is %d, is_8021x is %d\n", __func__,
1455 pairwise_cipher, group_cipher, is_8021x));
1456 }
1457 } else {
1458 pbuf = rtw_get_wpa2_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12);
1459
1460 if (pbuf && (wpa_ielen > 0)) {
1461 if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) {
1462 RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
1463 ("%s pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_802x is %d\n",
1464 __func__, pairwise_cipher, group_cipher, is_8021x));
1465 }
1466 }
1467 }
1468
1469 RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
1470 ("%s cur_network->group_cipher is %d: %d\n", __func__, cur_network->BcnInfo.group_cipher, group_cipher));
1471 if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || group_cipher != cur_network->BcnInfo.group_cipher) {
1472 DBG_871X("%s pairwise_cipher(%x:%x) or group_cipher(%x:%x) is not match\n", __func__,
1473 pairwise_cipher, cur_network->BcnInfo.pairwise_cipher,
1474 group_cipher, cur_network->BcnInfo.group_cipher);
1475 goto _mismatch;
1476 }
1477
1478 if (is_8021x != cur_network->BcnInfo.is_8021x) {
1479 DBG_871X("%s authentication is not match\n", __func__);
1480 goto _mismatch;
1481 }
1482 }
1483
1484 kfree((u8 *)bssid);
1485 return _SUCCESS;
1486
1487 _mismatch:
1488 kfree((u8 *)bssid);
1489
1490 if (pmlmepriv->NumOfBcnInfoChkFail == 0)
1491 pmlmepriv->timeBcnInfoChkStart = jiffies;
1492
1493 pmlmepriv->NumOfBcnInfoChkFail++;
1494 DBG_871X("%s by "ADPT_FMT" - NumOfChkFail = %d (SeqNum of this Beacon frame = %d).\n", __func__, ADPT_ARG(Adapter), pmlmepriv->NumOfBcnInfoChkFail, GetSequence(pframe));
1495
1496 if ((pmlmepriv->timeBcnInfoChkStart != 0) && (jiffies_to_msecs(jiffies - pmlmepriv->timeBcnInfoChkStart) <= DISCONNECT_BY_CHK_BCN_FAIL_OBSERV_PERIOD_IN_MS)
1497 && (pmlmepriv->NumOfBcnInfoChkFail >= DISCONNECT_BY_CHK_BCN_FAIL_THRESHOLD)) {
1498 DBG_871X("%s by "ADPT_FMT" - NumOfChkFail = %d >= threshold : %d (in %d ms), return FAIL.\n", __func__, ADPT_ARG(Adapter), pmlmepriv->NumOfBcnInfoChkFail,
1499 DISCONNECT_BY_CHK_BCN_FAIL_THRESHOLD, jiffies_to_msecs(jiffies - pmlmepriv->timeBcnInfoChkStart));
1500 pmlmepriv->timeBcnInfoChkStart = 0;
1501 pmlmepriv->NumOfBcnInfoChkFail = 0;
1502 return _FAIL;
1503 }
1504
1505 return _SUCCESS;
1506 }
1507
1508 void update_beacon_info(struct adapter *padapter, u8 *pframe, uint pkt_len, struct sta_info *psta)
1509 {
1510 unsigned int i;
1511 unsigned int len;
1512 struct ndis_80211_var_ie *pIE;
1513
1514 len = pkt_len - (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN);
1515
1516 for (i = 0; i < len;) {
1517 pIE = (struct ndis_80211_var_ie *)(pframe + (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN) + i);
1518
1519 switch (pIE->ElementID) {
1520 case _VENDOR_SPECIFIC_IE_:
1521
1522 if (!memcmp(pIE->data, WMM_PARA_OUI, 6) && pIE->Length == WLAN_WMM_LEN)
1523 if (WMM_param_handler(padapter, pIE))
1524 report_wmm_edca_update(padapter);
1525
1526 break;
1527
1528 case _HT_EXTRA_INFO_IE_:
1529
1530 bwmode_update_check(padapter, pIE);
1531 break;
1532
1533 case _ERPINFO_IE_:
1534 ERP_IE_handler(padapter, pIE);
1535 VCS_update(padapter, psta);
1536 break;
1537
1538 default:
1539 break;
1540 }
1541
1542 i += (pIE->Length + 2);
1543 }
1544 }
1545
1546 unsigned int is_ap_in_tkip(struct adapter *padapter)
1547 {
1548 u32 i;
1549 struct ndis_80211_var_ie *pIE;
1550 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1551 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1552 struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network);
1553
1554 if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) {
1555 for (i = sizeof(struct ndis_802_11_fix_ie); i < pmlmeinfo->network.IELength;) {
1556 pIE = (struct ndis_80211_var_ie *)(pmlmeinfo->network.IEs + i);
1557
1558 switch (pIE->ElementID) {
1559 case _VENDOR_SPECIFIC_IE_:
1560 if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4)))
1561 return true;
1562
1563 break;
1564
1565 case _RSN_IE_2_:
1566 if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4))
1567 return true;
1568
1569 default:
1570 break;
1571 }
1572
1573 i += (pIE->Length + 2);
1574 }
1575
1576 return false;
1577 } else
1578 return false;
1579 }
1580
1581 int support_short_GI(struct adapter *padapter, struct HT_caps_element *pHT_caps, u8 bwmode)
1582 {
1583 unsigned char bit_offset;
1584 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1585 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1586
1587 if (!(pmlmeinfo->HT_enable))
1588 return _FAIL;
1589
1590 bit_offset = (bwmode & CHANNEL_WIDTH_40) ? 6 : 5;
1591
1592 if (le16_to_cpu(pHT_caps->u.HT_cap_element.HT_caps_info) & (0x1 << bit_offset))
1593 return _SUCCESS;
1594 else
1595 return _FAIL;
1596 }
1597
1598 unsigned char get_highest_rate_idx(u32 mask)
1599 {
1600 int i;
1601 unsigned char rate_idx = 0;
1602
1603 for (i = 31; i >= 0; i--) {
1604 if (mask & BIT(i)) {
1605 rate_idx = i;
1606 break;
1607 }
1608 }
1609
1610 return rate_idx;
1611 }
1612
1613 void Update_RA_Entry(struct adapter *padapter, struct sta_info *psta)
1614 {
1615 rtw_hal_update_ra_mask(psta, 0);
1616 }
1617
1618 void set_sta_rate(struct adapter *padapter, struct sta_info *psta)
1619 {
1620
1621 Update_RA_Entry(padapter, psta);
1622 }
1623
1624 unsigned char check_assoc_AP(u8 *pframe, uint len)
1625 {
1626 unsigned int i;
1627 struct ndis_80211_var_ie *pIE;
1628
1629 for (i = sizeof(struct ndis_802_11_fix_ie); i < len;) {
1630 pIE = (struct ndis_80211_var_ie *)(pframe + i);
1631
1632 switch (pIE->ElementID) {
1633 case _VENDOR_SPECIFIC_IE_:
1634 if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) {
1635 DBG_871X("link to Artheros AP\n");
1636 return HT_IOT_PEER_ATHEROS;
1637 } else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3))
1638 || (!memcmp(pIE->data, BROADCOM_OUI2, 3))
1639 || (!memcmp(pIE->data, BROADCOM_OUI3, 3))) {
1640 DBG_871X("link to Broadcom AP\n");
1641 return HT_IOT_PEER_BROADCOM;
1642 } else if (!memcmp(pIE->data, MARVELL_OUI, 3)) {
1643 DBG_871X("link to Marvell AP\n");
1644 return HT_IOT_PEER_MARVELL;
1645 } else if (!memcmp(pIE->data, RALINK_OUI, 3)) {
1646 DBG_871X("link to Ralink AP\n");
1647 return HT_IOT_PEER_RALINK;
1648 } else if (!memcmp(pIE->data, CISCO_OUI, 3)) {
1649 DBG_871X("link to Cisco AP\n");
1650 return HT_IOT_PEER_CISCO;
1651 } else if (!memcmp(pIE->data, REALTEK_OUI, 3)) {
1652 u32 Vender = HT_IOT_PEER_REALTEK;
1653
1654 if (pIE->Length >= 5) {
1655 if (pIE->data[4] == 1)
1656
1657
1658 if (pIE->data[5] & RT_HT_CAP_USE_92SE)
1659
1660 Vender = HT_IOT_PEER_REALTEK_92SE;
1661
1662 if (pIE->data[5] & RT_HT_CAP_USE_SOFTAP)
1663 Vender = HT_IOT_PEER_REALTEK_SOFTAP;
1664
1665 if (pIE->data[4] == 2) {
1666 if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_BCUT) {
1667 Vender = HT_IOT_PEER_REALTEK_JAGUAR_BCUTAP;
1668 DBG_871X("link to Realtek JAGUAR_BCUTAP\n");
1669 }
1670 if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_CCUT) {
1671 Vender = HT_IOT_PEER_REALTEK_JAGUAR_CCUTAP;
1672 DBG_871X("link to Realtek JAGUAR_CCUTAP\n");
1673 }
1674 }
1675 }
1676
1677 DBG_871X("link to Realtek AP\n");
1678 return Vender;
1679 } else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3)) {
1680 DBG_871X("link to Airgo Cap\n");
1681 return HT_IOT_PEER_AIRGO;
1682 } else
1683 break;
1684
1685 default:
1686 break;
1687 }
1688
1689 i += (pIE->Length + 2);
1690 }
1691
1692 DBG_871X("link to new AP\n");
1693 return HT_IOT_PEER_UNKNOWN;
1694 }
1695
1696 void update_IOT_info(struct adapter *padapter)
1697 {
1698 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1699 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1700
1701 switch (pmlmeinfo->assoc_AP_vendor) {
1702 case HT_IOT_PEER_MARVELL:
1703 pmlmeinfo->turboMode_cts2self = 1;
1704 pmlmeinfo->turboMode_rtsen = 0;
1705 break;
1706
1707 case HT_IOT_PEER_RALINK:
1708 pmlmeinfo->turboMode_cts2self = 0;
1709 pmlmeinfo->turboMode_rtsen = 1;
1710
1711 Switch_DM_Func(padapter, (~DYNAMIC_BB_DYNAMIC_TXPWR), false);
1712 break;
1713 case HT_IOT_PEER_REALTEK:
1714
1715
1716
1717 Switch_DM_Func(padapter, (~DYNAMIC_BB_DYNAMIC_TXPWR), false);
1718 break;
1719 default:
1720 pmlmeinfo->turboMode_cts2self = 0;
1721 pmlmeinfo->turboMode_rtsen = 1;
1722 break;
1723 }
1724 }
1725
1726 void update_capinfo(struct adapter *Adapter, u16 updateCap)
1727 {
1728 struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv;
1729 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1730 bool ShortPreamble;
1731
1732
1733
1734
1735 {
1736 if (updateCap & cShortPreamble) {
1737
1738 if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) {
1739 ShortPreamble = true;
1740 pmlmeinfo->preamble_mode = PREAMBLE_SHORT;
1741 rtw_hal_set_hwreg(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble);
1742 }
1743 } else {
1744
1745 if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) {
1746 ShortPreamble = false;
1747 pmlmeinfo->preamble_mode = PREAMBLE_LONG;
1748 rtw_hal_set_hwreg(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble);
1749 }
1750 }
1751 }
1752
1753 if (updateCap & cIBSS)
1754
1755 pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME;
1756 else {
1757
1758 if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N | WIRELESS_11A | WIRELESS_11_5N | WIRELESS_11AC))
1759 pmlmeinfo->slotTime = SHORT_SLOT_TIME;
1760 else if (pmlmeext->cur_wireless_mode & (WIRELESS_11G)) {
1761 if ((updateCap & cShortSlotTime) )
1762
1763 pmlmeinfo->slotTime = SHORT_SLOT_TIME;
1764 else
1765
1766 pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME;
1767 } else
1768
1769 pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME;
1770 }
1771
1772 rtw_hal_set_hwreg(Adapter, HW_VAR_SLOT_TIME, &pmlmeinfo->slotTime);
1773 }
1774
1775 void update_wireless_mode(struct adapter *padapter)
1776 {
1777 int ratelen, network_type = 0;
1778 u32 SIFS_Timer;
1779 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1780 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1781 struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network);
1782 unsigned char *rate = cur_network->SupportedRates;
1783
1784 ratelen = rtw_get_rateset_len(cur_network->SupportedRates);
1785
1786 if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable))
1787 pmlmeinfo->HT_enable = 1;
1788
1789 if (pmlmeext->cur_channel > 14) {
1790 if (pmlmeinfo->VHT_enable)
1791 network_type = WIRELESS_11AC;
1792 else if (pmlmeinfo->HT_enable)
1793 network_type = WIRELESS_11_5N;
1794
1795 network_type |= WIRELESS_11A;
1796 } else {
1797 if (pmlmeinfo->VHT_enable)
1798 network_type = WIRELESS_11AC;
1799 else if (pmlmeinfo->HT_enable)
1800 network_type = WIRELESS_11_24N;
1801
1802 if ((cckratesonly_included(rate, ratelen)) == true)
1803 network_type |= WIRELESS_11B;
1804 else if ((cckrates_included(rate, ratelen)) == true)
1805 network_type |= WIRELESS_11BG;
1806 else
1807 network_type |= WIRELESS_11G;
1808 }
1809
1810 pmlmeext->cur_wireless_mode = network_type & padapter->registrypriv.wireless_mode;
1811
1812 SIFS_Timer = 0x0a0a0808;
1813
1814
1815 padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_RESP_SIFS, (u8 *)&SIFS_Timer);
1816
1817 padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_WIRELESS_MODE, (u8 *)&(pmlmeext->cur_wireless_mode));
1818
1819 if (pmlmeext->cur_wireless_mode & WIRELESS_11B)
1820 update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB);
1821 else
1822 update_mgnt_tx_rate(padapter, IEEE80211_OFDM_RATE_6MB);
1823 }
1824
1825 void update_sta_basic_rate(struct sta_info *psta, u8 wireless_mode)
1826 {
1827 if (IsSupportedTxCCK(wireless_mode)) {
1828
1829 memcpy(psta->bssrateset, rtw_basic_rate_cck, 4);
1830 psta->bssratelen = 4;
1831 } else {
1832 memcpy(psta->bssrateset, rtw_basic_rate_ofdm, 3);
1833 psta->bssratelen = 3;
1834 }
1835 }
1836
1837 int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx)
1838 {
1839 unsigned int ie_len;
1840 struct ndis_80211_var_ie *pIE;
1841 int supportRateNum = 0;
1842 struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
1843 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1844
1845 pIE = (struct ndis_80211_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len);
1846 if (!pIE)
1847 return _FAIL;
1848
1849 memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len);
1850 supportRateNum = ie_len;
1851
1852 pIE = (struct ndis_80211_var_ie *)rtw_get_ie(pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len);
1853 if (pIE)
1854 memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len);
1855
1856 return _SUCCESS;
1857 }
1858
1859 void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr)
1860 {
1861 struct sta_info *psta;
1862 u16 tid, start_seq, param;
1863 struct recv_reorder_ctrl *preorder_ctrl;
1864 struct sta_priv *pstapriv = &padapter->stapriv;
1865 struct ADDBA_request *preq = (struct ADDBA_request *)paddba_req;
1866 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1867 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1868
1869 psta = rtw_get_stainfo(pstapriv, addr);
1870
1871 if (psta) {
1872 start_seq = le16_to_cpu(preq->BA_starting_seqctrl) >> 4;
1873
1874 param = le16_to_cpu(preq->BA_para_set);
1875 tid = (param>>2)&0x0f;
1876
1877 preorder_ctrl = &psta->recvreorder_ctrl[tid];
1878
1879 #ifdef CONFIG_UPDATE_INDICATE_SEQ_WHILE_PROCESS_ADDBA_REQ
1880 preorder_ctrl->indicate_seq = start_seq;
1881 #ifdef DBG_RX_SEQ
1882 DBG_871X("DBG_RX_SEQ %s:%d IndicateSeq: %d, start_seq: %d\n", __func__, __LINE__,
1883 preorder_ctrl->indicate_seq, start_seq);
1884 #endif
1885 #else
1886 preorder_ctrl->indicate_seq = 0xffff;
1887 #endif
1888
1889 preorder_ctrl->enable = pmlmeinfo->accept_addba_req;
1890 }
1891 }
1892
1893 void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len)
1894 {
1895 u8 *pIE;
1896 __le32 *pbuf;
1897
1898 pIE = pframe + sizeof(struct ieee80211_hdr_3addr);
1899 pbuf = (__le32 *)pIE;
1900
1901 pmlmeext->TSFValue = le32_to_cpu(*(pbuf+1));
1902
1903 pmlmeext->TSFValue = pmlmeext->TSFValue << 32;
1904
1905 pmlmeext->TSFValue |= le32_to_cpu(*pbuf);
1906 }
1907
1908 void correct_TSF(struct adapter *padapter, struct mlme_ext_priv *pmlmeext)
1909 {
1910 rtw_hal_set_hwreg(padapter, HW_VAR_CORRECT_TSF, NULL);
1911 }
1912
1913 void adaptive_early_32k(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len)
1914 {
1915 int i;
1916 u8 *pIE;
1917 __le32 *pbuf;
1918 u64 tsf = 0;
1919 u32 delay_ms;
1920 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
1921
1922 pmlmeext->bcn_cnt++;
1923
1924 pIE = pframe + sizeof(struct ieee80211_hdr_3addr);
1925 pbuf = (__le32 *)pIE;
1926
1927 tsf = le32_to_cpu(*(pbuf+1));
1928 tsf = tsf << 32;
1929 tsf |= le32_to_cpu(*pbuf);
1930
1931
1932
1933
1934
1935 delay_ms = do_div(tsf, (pmlmeinfo->bcn_interval*1024));
1936 delay_ms = delay_ms/1000;
1937
1938 if (delay_ms >= 8)
1939 pmlmeext->bcn_delay_cnt[8]++;
1940
1941 else
1942 pmlmeext->bcn_delay_cnt[delay_ms]++;
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957 if (pmlmeext->bcn_cnt > 100 && (pmlmeext->adaptive_tsf_done == true)) {
1958 u8 ratio_20_delay, ratio_80_delay;
1959 u8 DrvBcnEarly, DrvBcnTimeOut;
1960
1961 ratio_20_delay = 0;
1962 ratio_80_delay = 0;
1963 DrvBcnEarly = 0xff;
1964 DrvBcnTimeOut = 0xff;
1965
1966 DBG_871X("%s(): bcn_cnt = %d\n", __func__, pmlmeext->bcn_cnt);
1967
1968 for (i = 0; i < 9; i++) {
1969 pmlmeext->bcn_delay_ratio[i] = (pmlmeext->bcn_delay_cnt[i] * 100) / pmlmeext->bcn_cnt;
1970
1971 DBG_871X("%s():bcn_delay_cnt[%d]=%d, bcn_delay_ratio[%d]=%d\n", __func__, i,
1972 pmlmeext->bcn_delay_cnt[i], i, pmlmeext->bcn_delay_ratio[i]);
1973
1974 ratio_20_delay += pmlmeext->bcn_delay_ratio[i];
1975 ratio_80_delay += pmlmeext->bcn_delay_ratio[i];
1976
1977 if (ratio_20_delay > 20 && DrvBcnEarly == 0xff) {
1978 DrvBcnEarly = i;
1979 DBG_871X("%s(): DrvBcnEarly = %d\n", __func__, DrvBcnEarly);
1980 }
1981
1982 if (ratio_80_delay > 80 && DrvBcnTimeOut == 0xff) {
1983 DrvBcnTimeOut = i;
1984 DBG_871X("%s(): DrvBcnTimeOut = %d\n", __func__, DrvBcnTimeOut);
1985 }
1986
1987
1988 pmlmeext->bcn_delay_cnt[i] = 0;
1989 pmlmeext->bcn_delay_ratio[i] = 0;
1990 }
1991
1992 pmlmeext->DrvBcnEarly = DrvBcnEarly;
1993 pmlmeext->DrvBcnTimeOut = DrvBcnTimeOut;
1994
1995 pmlmeext->bcn_cnt = 0;
1996 }
1997 }
1998
1999 void rtw_alloc_macid(struct adapter *padapter, struct sta_info *psta)
2000 {
2001 int i;
2002 u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2003 struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter);
2004
2005 if (!memcmp(psta->hwaddr, bc_addr, ETH_ALEN))
2006 return;
2007
2008 if (!memcmp(psta->hwaddr, myid(&padapter->eeprompriv), ETH_ALEN)) {
2009 psta->mac_id = NUM_STA;
2010 return;
2011 }
2012
2013 spin_lock_bh(&pdvobj->lock);
2014 for (i = 0; i < NUM_STA; i++) {
2015 if (pdvobj->macid[i] == false) {
2016 pdvobj->macid[i] = true;
2017 break;
2018 }
2019 }
2020 spin_unlock_bh(&pdvobj->lock);
2021
2022 if (i > (NUM_STA-1)) {
2023 psta->mac_id = NUM_STA;
2024 DBG_871X(" no room for more MACIDs\n");
2025 } else {
2026 psta->mac_id = i;
2027 DBG_871X("%s = %d\n", __func__, psta->mac_id);
2028 }
2029 }
2030
2031 void rtw_release_macid(struct adapter *padapter, struct sta_info *psta)
2032 {
2033 u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2034 struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter);
2035
2036 if (!memcmp(psta->hwaddr, bc_addr, ETH_ALEN))
2037 return;
2038
2039 if (!memcmp(psta->hwaddr, myid(&padapter->eeprompriv), ETH_ALEN))
2040 return;
2041
2042 spin_lock_bh(&pdvobj->lock);
2043 if (psta->mac_id < NUM_STA && psta->mac_id != 1) {
2044 if (pdvobj->macid[psta->mac_id] == true) {
2045 DBG_871X("%s = %d\n", __func__, psta->mac_id);
2046 pdvobj->macid[psta->mac_id] = false;
2047 psta->mac_id = NUM_STA;
2048 }
2049 }
2050 spin_unlock_bh(&pdvobj->lock);
2051 }
2052
2053 u8 rtw_search_max_mac_id(struct adapter *padapter)
2054 {
2055 u8 max_mac_id = 0;
2056 struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter);
2057 int i;
2058 spin_lock_bh(&pdvobj->lock);
2059 for (i = (NUM_STA-1); i >= 0 ; i--) {
2060 if (pdvobj->macid[i] == true)
2061 break;
2062 }
2063 max_mac_id = i;
2064 spin_unlock_bh(&pdvobj->lock);
2065
2066 return max_mac_id;
2067 }
2068
2069 struct adapter *dvobj_get_port0_adapter(struct dvobj_priv *dvobj)
2070 {
2071 if (get_iface_type(dvobj->padapters[i]) != IFACE_PORT0)
2072 return NULL;
2073
2074 return dvobj->padapters;
2075 }
2076
2077 #ifdef CONFIG_GPIO_API
2078 int rtw_get_gpio(struct net_device *netdev, int gpio_num)
2079 {
2080 u8 value;
2081 u8 direction;
2082 struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev);
2083 struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(adapter);
2084
2085 rtw_ps_deny(adapter, PS_DENY_IOCTL);
2086
2087 DBG_871X("rf_pwrstate = 0x%02x\n", pwrpriv->rf_pwrstate);
2088 LeaveAllPowerSaveModeDirect(adapter);
2089
2090
2091 direction = (rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) & BIT(gpio_num)) >> gpio_num;
2092
2093
2094 if (direction)
2095 value = (rtw_read8(adapter, REG_GPIO_PIN_CTRL + 1) & BIT(gpio_num)) >> gpio_num;
2096 else
2097 value = (rtw_read8(adapter, REG_GPIO_PIN_CTRL) & BIT(gpio_num)) >> gpio_num;
2098
2099 rtw_ps_deny_cancel(adapter, PS_DENY_IOCTL);
2100 DBG_871X("%s direction =%d value =%d\n", __func__, direction, value);
2101
2102 return value;
2103 }
2104 EXPORT_SYMBOL(rtw_get_gpio);
2105
2106 int rtw_set_gpio_output_value(struct net_device *netdev, int gpio_num, bool isHigh)
2107 {
2108 u8 direction = 0;
2109 u8 res = -1;
2110 struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev);
2111
2112
2113 if (gpio_num > 7 || gpio_num < 4) {
2114 DBG_871X("%s The gpio number does not included 4~7.\n", __func__);
2115 return -1;
2116 }
2117
2118 rtw_ps_deny(adapter, PS_DENY_IOCTL);
2119
2120 LeaveAllPowerSaveModeDirect(adapter);
2121
2122
2123 direction = (rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) & BIT(gpio_num)) >> gpio_num;
2124
2125
2126 if (direction) {
2127 if (isHigh)
2128 rtw_write8(adapter, REG_GPIO_PIN_CTRL + 1, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 1) | BIT(gpio_num));
2129 else
2130 rtw_write8(adapter, REG_GPIO_PIN_CTRL + 1, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 1) & ~BIT(gpio_num));
2131
2132 DBG_871X("%s Set gpio %x[%d]=%d\n", __func__, REG_GPIO_PIN_CTRL+1, gpio_num, isHigh);
2133 res = 0;
2134 } else {
2135 DBG_871X("%s The gpio is input, not be set!\n", __func__);
2136 res = -1;
2137 }
2138
2139 rtw_ps_deny_cancel(adapter, PS_DENY_IOCTL);
2140 return res;
2141 }
2142 EXPORT_SYMBOL(rtw_set_gpio_output_value);
2143
2144 int rtw_config_gpio(struct net_device *netdev, int gpio_num, bool isOutput)
2145 {
2146 struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev);
2147
2148 if (gpio_num > 7 || gpio_num < 4) {
2149 DBG_871X("%s The gpio number does not included 4~7.\n", __func__);
2150 return -1;
2151 }
2152
2153 DBG_871X("%s gpio_num =%d direction =%d\n", __func__, gpio_num, isOutput);
2154
2155 rtw_ps_deny(adapter, PS_DENY_IOCTL);
2156
2157 LeaveAllPowerSaveModeDirect(adapter);
2158
2159 if (isOutput)
2160 rtw_write8(adapter, REG_GPIO_PIN_CTRL + 2, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) | BIT(gpio_num));
2161 else
2162 rtw_write8(adapter, REG_GPIO_PIN_CTRL + 2, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) & ~BIT(gpio_num));
2163
2164 rtw_ps_deny_cancel(adapter, PS_DENY_IOCTL);
2165
2166 return 0;
2167 }
2168 EXPORT_SYMBOL(rtw_config_gpio);
2169 #endif
2170
2171 #if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN)
2172 void rtw_get_current_ip_address(struct adapter *padapter, u8 *pcurrentip)
2173 {
2174 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
2175 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
2176 struct in_device *my_ip_ptr = padapter->pnetdev->ip_ptr;
2177 u8 ipaddress[4];
2178
2179 if ((pmlmeinfo->state & WIFI_FW_LINKING_STATE) ||
2180 pmlmeinfo->state & WIFI_FW_AP_STATE) {
2181 if (my_ip_ptr) {
2182 struct in_ifaddr *my_ifa_list = my_ip_ptr->ifa_list;
2183 if (my_ifa_list) {
2184 ipaddress[0] = my_ifa_list->ifa_address & 0xFF;
2185 ipaddress[1] = (my_ifa_list->ifa_address >> 8) & 0xFF;
2186 ipaddress[2] = (my_ifa_list->ifa_address >> 16) & 0xFF;
2187 ipaddress[3] = my_ifa_list->ifa_address >> 24;
2188 DBG_871X("%s: %d.%d.%d.%d ==========\n", __func__,
2189 ipaddress[0], ipaddress[1], ipaddress[2], ipaddress[3]);
2190 memcpy(pcurrentip, ipaddress, 4);
2191 }
2192 }
2193 }
2194 }
2195 #endif
2196 #ifdef CONFIG_WOWLAN
2197 void rtw_get_sec_iv(struct adapter *padapter, u8 *pcur_dot11txpn, u8 *StaAddr)
2198 {
2199 struct sta_info *psta;
2200 struct security_priv *psecpriv = &padapter->securitypriv;
2201
2202 memset(pcur_dot11txpn, 0, 8);
2203 if (NULL == StaAddr)
2204 return;
2205 psta = rtw_get_stainfo(&padapter->stapriv, StaAddr);
2206 DBG_871X("%s(): StaAddr: %02x %02x %02x %02x %02x %02x\n",
2207 __func__, StaAddr[0], StaAddr[1], StaAddr[2],
2208 StaAddr[3], StaAddr[4], StaAddr[5]);
2209
2210 if (psta) {
2211 if (psecpriv->dot11PrivacyAlgrthm != _NO_PRIVACY_ && psta->dot11txpn.val > 0)
2212 psta->dot11txpn.val--;
2213 AES_IV(pcur_dot11txpn, psta->dot11txpn, 0);
2214
2215 DBG_871X("%s(): CurrentIV: %02x %02x %02x %02x %02x %02x %02x %02x\n"
2216 , __func__, pcur_dot11txpn[0], pcur_dot11txpn[1],
2217 pcur_dot11txpn[2], pcur_dot11txpn[3], pcur_dot11txpn[4],
2218 pcur_dot11txpn[5], pcur_dot11txpn[6], pcur_dot11txpn[7]);
2219 }
2220 }
2221 void rtw_set_sec_pn(struct adapter *padapter)
2222 {
2223 struct sta_info *psta;
2224 struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
2225 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
2226 struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
2227 struct security_priv *psecpriv = &padapter->securitypriv;
2228
2229 psta = rtw_get_stainfo(&padapter->stapriv,
2230 get_my_bssid(&pmlmeinfo->network));
2231
2232 if (psta) {
2233 if (pwrpriv->wowlan_fw_iv > psta->dot11txpn.val) {
2234 if (psecpriv->dot11PrivacyAlgrthm != _NO_PRIVACY_)
2235 psta->dot11txpn.val = pwrpriv->wowlan_fw_iv + 2;
2236 } else {
2237 DBG_871X("%s(): FW IV is smaller than driver\n", __func__);
2238 psta->dot11txpn.val += 2;
2239 }
2240 DBG_871X("%s: dot11txpn: 0x%016llx\n", __func__, psta->dot11txpn.val);
2241 }
2242 }
2243 #endif
2244
2245 #ifdef CONFIG_PNO_SUPPORT
2246 #define CSCAN_TLV_TYPE_SSID_IE 'S'
2247 #define CIPHER_IE "key_mgmt ="
2248 #define CIPHER_NONE "NONE"
2249 #define CIPHER_WPA_PSK "WPA-PSK"
2250 #define CIPHER_WPA_EAP "WPA-EAP IEEE8021X"
2251
2252 #endif