1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
5 * Contact Information: wlanfae <wlanfae@realtek.com>
8 #include "rtl819x_HT.h"
9 u8 MCS_FILTER_ALL[16] = {
10 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
11 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
14 u8 MCS_FILTER_1SS[16] = {
15 0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
16 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
19 u16 MCS_DATA_RATE[2][2][77] = {
20 {{13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234,
21 260, 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416,
22 468, 520, 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182,
23 182, 208, 156, 195, 195, 234, 273, 273, 312, 130, 156, 181, 156,
24 181, 208, 234, 208, 234, 260, 260, 286, 195, 234, 273, 234, 273,
25 312, 351, 312, 351, 390, 390, 429},
26 {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289,
27 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520,
28 578, 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231,
29 173, 217, 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260,
30 231, 260, 289, 289, 318, 217, 260, 303, 260, 303, 347, 390, 347, 390,
32 {{27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486,
33 540, 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648,
34 864, 972, 1080, 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324,
35 378, 378, 432, 324, 405, 405, 486, 567, 567, 648, 270, 324, 378, 324,
36 378, 432, 486, 432, 486, 540, 540, 594, 405, 486, 567, 486, 567, 648,
37 729, 648, 729, 810, 810, 891},
38 {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540,
39 600, 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720,
40 960, 1080, 1200, 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360,
41 420, 420, 480, 360, 450, 450, 540, 630, 630, 720, 300, 360, 420, 360,
42 420, 480, 540, 480, 540, 600, 600, 660, 450, 540, 630, 540, 630, 720,
43 810, 720, 810, 900, 900, 990} }
46 static u8 UNKNOWN_BORADCOM[3] = {0x00, 0x14, 0xbf};
48 static u8 LINKSYSWRT330_LINKSYSWRT300_BROADCOM[3] = {0x00, 0x1a, 0x70};
50 static u8 LINKSYSWRT350_LINKSYSWRT150_BROADCOM[3] = {0x00, 0x1d, 0x7e};
52 static u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f};
54 static u8 BELKINF5D82334V3_RALINK[3] = {0x00, 0x1c, 0xdf};
56 static u8 PCI_RALINK[3] = {0x00, 0x90, 0xcc};
58 static u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e};
60 static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02};
62 static u8 DLINK_ATHEROS_1[3] = {0x00, 0x1c, 0xf0};
64 static u8 DLINK_ATHEROS_2[3] = {0x00, 0x21, 0x91};
66 static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94};
68 static u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4};
70 void ht_update_default_setting(struct rtllib_device *ieee)
72 struct rt_hi_throughput *ht_info = ieee->ht_info;
74 ht_info->ampdu_enable = 1;
75 ht_info->ampdu_factor = 2;
77 ieee->tx_dis_rate_fallback = 0;
78 ieee->tx_use_drv_assinged_rate = 0;
80 ieee->tx_enable_fw_calc_dur = 1;
82 ht_info->rx_reorder_win_size = 64;
83 ht_info->rx_reorder_pending_time = 30;
86 static u16 ht_mcs_to_data_rate(struct rtllib_device *ieee, u8 mcs_rate)
88 struct rt_hi_throughput *ht_info = ieee->ht_info;
90 u8 is40MHz = (ht_info->cur_bw_40mhz) ? 1 : 0;
91 u8 isShortGI = (ht_info->cur_bw_40mhz) ?
92 ((ht_info->cur_short_gi_40mhz) ? 1 : 0) :
93 ((ht_info->cur_short_gi_20mhz) ? 1 : 0);
94 return MCS_DATA_RATE[is40MHz][isShortGI][(mcs_rate & 0x7f)];
97 u16 tx_count_to_data_rate(struct rtllib_device *ieee, u8 data_rate)
99 u16 cck_of_dm_rate[12] = {0x02, 0x04, 0x0b, 0x16, 0x0c, 0x12, 0x18,
100 0x24, 0x30, 0x48, 0x60, 0x6c};
105 return cck_of_dm_rate[data_rate];
106 if (data_rate >= 0x10 && data_rate <= 0x1f) {
109 } else if (data_rate >= 0x20 && data_rate <= 0x2f) {
112 } else if (data_rate >= 0x30 && data_rate <= 0x3f) {
115 } else if (data_rate >= 0x40 && data_rate <= 0x4f) {
119 return MCS_DATA_RATE[is40MHz][isShortGI][data_rate & 0xf];
122 bool is_ht_half_nmode_aps(struct rtllib_device *ieee)
124 bool retValue = false;
125 struct rtllib_network *net = &ieee->current_network;
127 if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) ||
128 (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) ||
129 (memcmp(net->bssid, PCI_RALINK, 3) == 0) ||
130 (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) ||
131 (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) ||
132 (net->ralink_cap_exist))
134 else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) ||
135 !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) ||
136 !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ||
137 (net->broadcom_cap_exist))
139 else if (net->bssht.bd_rt2rt_aggregation)
147 static void ht_iot_peer_determine(struct rtllib_device *ieee)
149 struct rt_hi_throughput *ht_info = ieee->ht_info;
150 struct rtllib_network *net = &ieee->current_network;
152 if (net->bssht.bd_rt2rt_aggregation) {
153 ht_info->iot_peer = HT_IOT_PEER_REALTEK;
154 if (net->bssht.rt2rt_ht_mode & RT_HT_CAP_USE_92SE)
155 ht_info->iot_peer = HT_IOT_PEER_REALTEK_92SE;
156 if (net->bssht.rt2rt_ht_mode & RT_HT_CAP_USE_SOFTAP)
157 ht_info->iot_peer = HT_IOT_PEER_92U_SOFTAP;
158 } else if (net->broadcom_cap_exist) {
159 ht_info->iot_peer = HT_IOT_PEER_BROADCOM;
160 } else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) ||
161 !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) ||
162 !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)) {
163 ht_info->iot_peer = HT_IOT_PEER_BROADCOM;
164 } else if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) ||
165 (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) ||
166 (memcmp(net->bssid, PCI_RALINK, 3) == 0) ||
167 (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) ||
168 (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) ||
169 net->ralink_cap_exist) {
170 ht_info->iot_peer = HT_IOT_PEER_RALINK;
171 } else if ((net->atheros_cap_exist) ||
172 (memcmp(net->bssid, DLINK_ATHEROS_1, 3) == 0) ||
173 (memcmp(net->bssid, DLINK_ATHEROS_2, 3) == 0)) {
174 ht_info->iot_peer = HT_IOT_PEER_ATHEROS;
175 } else if ((memcmp(net->bssid, CISCO_BROADCOM, 3) == 0) ||
176 net->cisco_cap_exist) {
177 ht_info->iot_peer = HT_IOT_PEER_CISCO;
178 } else if ((memcmp(net->bssid, LINKSYS_MARVELL_4400N, 3) == 0) ||
179 net->marvell_cap_exist) {
180 ht_info->iot_peer = HT_IOT_PEER_MARVELL;
181 } else if (net->airgo_cap_exist) {
182 ht_info->iot_peer = HT_IOT_PEER_AIRGO;
184 ht_info->iot_peer = HT_IOT_PEER_UNKNOWN;
187 netdev_dbg(ieee->dev, "IOTPEER: %x\n", ht_info->iot_peer);
190 static u8 ht_iot_act_is_mgnt_use_cck_6m(struct rtllib_device *ieee,
191 struct rtllib_network *network)
195 if (ieee->ht_info->iot_peer == HT_IOT_PEER_BROADCOM)
201 static u8 ht_iot_act_is_ccd_fsync(struct rtllib_device *ieee)
205 if (ieee->ht_info->iot_peer == HT_IOT_PEER_BROADCOM)
210 static void ht_iot_act_determine_ra_func(struct rtllib_device *ieee, bool bPeerRx2ss)
212 struct rt_hi_throughput *ht_info = ieee->ht_info;
214 ht_info->iot_ra_func &= HT_IOT_RAFUNC_DISABLE_ALL;
216 if (ht_info->iot_peer == HT_IOT_PEER_RALINK && !bPeerRx2ss)
217 ht_info->iot_ra_func |= HT_IOT_RAFUNC_PEER_1R;
219 if (ht_info->iot_action & HT_IOT_ACT_AMSDU_ENABLE)
220 ht_info->iot_ra_func |= HT_IOT_RAFUNC_TX_AMSDU;
223 void ht_reset_iot_setting(struct rt_hi_throughput *ht_info)
225 ht_info->iot_action = 0;
226 ht_info->iot_peer = HT_IOT_PEER_UNKNOWN;
227 ht_info->iot_ra_func = 0;
230 void ht_construct_capability_element(struct rtllib_device *ieee, u8 *pos_ht_cap,
231 u8 *len, u8 is_encrypt, bool assoc)
233 struct rt_hi_throughput *ht = ieee->ht_info;
234 struct ht_capab_ele *cap_ele = NULL;
236 if (!pos_ht_cap || !ht) {
237 netdev_warn(ieee->dev,
238 "%s(): posHTCap and ht_info are null\n", __func__);
241 memset(pos_ht_cap, 0, *len);
243 if ((assoc) && (ht->peer_ht_spec_ver == HT_SPEC_VER_EWC)) {
244 static const u8 EWC11NHTCap[] = { 0x00, 0x90, 0x4c, 0x33 };
246 memcpy(pos_ht_cap, EWC11NHTCap, sizeof(EWC11NHTCap));
247 cap_ele = (struct ht_capab_ele *)&pos_ht_cap[4];
250 cap_ele = (struct ht_capab_ele *)pos_ht_cap;
254 cap_ele->AdvCoding = 0;
255 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
256 cap_ele->ChlWidth = 0;
258 cap_ele->ChlWidth = 1;
260 cap_ele->MimoPwrSave = 3;
261 cap_ele->GreenField = 0;
262 cap_ele->ShortGI20Mhz = 1;
263 cap_ele->ShortGI40Mhz = 1;
267 cap_ele->DelayBA = 0;
268 cap_ele->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE >= 7935) ? 1 : 0;
271 cap_ele->LSigTxopProtect = 0;
273 netdev_dbg(ieee->dev,
274 "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n",
275 cap_ele->ChlWidth, cap_ele->MaxAMSDUSize, cap_ele->DssCCk);
278 cap_ele->MPDUDensity = 7;
279 cap_ele->MaxRxAMPDUFactor = 2;
281 cap_ele->MaxRxAMPDUFactor = 3;
282 cap_ele->MPDUDensity = 0;
285 memcpy(cap_ele->MCS, ieee->reg_dot11ht_oper_rate_set, 16);
286 memset(&cap_ele->ExtHTCapInfo, 0, 2);
287 memset(cap_ele->TxBFCap, 0, 4);
292 if (ht->iot_action & HT_IOT_ACT_DISABLE_MCS15)
293 cap_ele->MCS[1] &= 0x7f;
295 if (ht->iot_action & HT_IOT_ACT_DISABLE_MCS14)
296 cap_ele->MCS[1] &= 0xbf;
298 if (ht->iot_action & HT_IOT_ACT_DISABLE_ALL_2SS)
299 cap_ele->MCS[1] &= 0x00;
301 if (ht->iot_action & HT_IOT_ACT_DISABLE_RX_40MHZ_SHORT_GI)
302 cap_ele->ShortGI40Mhz = 0;
304 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) {
305 cap_ele->ChlWidth = 0;
311 void ht_construct_rt2rt_agg_element(struct rtllib_device *ieee, u8 *posRT2RTAgg,
315 netdev_warn(ieee->dev, "%s(): posRT2RTAgg is null\n", __func__);
318 memset(posRT2RTAgg, 0, *len);
319 *posRT2RTAgg++ = 0x00;
320 *posRT2RTAgg++ = 0xe0;
321 *posRT2RTAgg++ = 0x4c;
322 *posRT2RTAgg++ = 0x02;
323 *posRT2RTAgg++ = 0x01;
327 if (ieee->bSupportRemoteWakeUp)
328 *posRT2RTAgg |= RT_HT_CAP_USE_WOW;
333 static u8 ht_pick_mcs_rate(struct rtllib_device *ieee, u8 *pOperateMCS)
338 netdev_warn(ieee->dev, "%s(): pOperateMCS is null\n", __func__);
342 switch (ieee->mode) {
343 case WIRELESS_MODE_B:
344 case WIRELESS_MODE_G:
345 for (i = 0; i <= 15; i++)
348 case WIRELESS_MODE_N_24G:
349 pOperateMCS[0] &= RATE_ADPT_1SS_MASK;
350 pOperateMCS[1] &= RATE_ADPT_2SS_MASK;
351 pOperateMCS[3] &= RATE_ADPT_MCS32_MASK;
360 u8 ht_get_highest_mcs_rate(struct rtllib_device *ieee, u8 *pMCSRateSet,
366 u8 availableMcsRate[16];
368 if (!pMCSRateSet || !pMCSFilter) {
369 netdev_warn(ieee->dev,
370 "%s(): pMCSRateSet and pMCSFilter are null\n",
374 for (i = 0; i < 16; i++)
375 availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i];
377 for (i = 0; i < 16; i++) {
378 if (availableMcsRate[i] != 0)
384 for (i = 0; i < 16; i++) {
385 if (availableMcsRate[i] != 0) {
386 bitMap = availableMcsRate[i];
387 for (j = 0; j < 8; j++) {
388 if ((bitMap % 2) != 0) {
389 if (ht_mcs_to_data_rate(ieee, (8 * i + j)) >
390 ht_mcs_to_data_rate(ieee, mcsRate))
397 return mcsRate | 0x80;
400 static u8 ht_filter_mcs_rate(struct rtllib_device *ieee, u8 *pSupportMCS,
405 for (i = 0; i <= 15; i++)
406 pOperateMCS[i] = ieee->reg_dot11tx_ht_oper_rate_set[i] &
409 ht_pick_mcs_rate(ieee, pOperateMCS);
411 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
414 for (i = 2; i <= 15; i++)
420 void ht_set_connect_bw_mode(struct rtllib_device *ieee,
421 enum ht_channel_width bandwidth,
422 enum ht_extchnl_offset Offset);
424 void ht_on_assoc_rsp(struct rtllib_device *ieee)
426 struct rt_hi_throughput *ht_info = ieee->ht_info;
427 struct ht_capab_ele *pPeerHTCap = NULL;
428 struct ht_info_ele *pPeerHTInfo = NULL;
429 u8 *pMcsFilter = NULL;
431 static const u8 EWC11NHTCap[] = { 0x00, 0x90, 0x4c, 0x33 };
432 static const u8 EWC11NHTInfo[] = { 0x00, 0x90, 0x4c, 0x34 };
434 if (!ht_info->current_ht_support) {
435 netdev_warn(ieee->dev, "%s(): HT_DISABLE\n", __func__);
438 netdev_dbg(ieee->dev, "%s(): HT_ENABLE\n", __func__);
440 if (!memcmp(ht_info->PeerHTCapBuf, EWC11NHTCap, sizeof(EWC11NHTCap)))
441 pPeerHTCap = (struct ht_capab_ele *)(&ht_info->PeerHTCapBuf[4]);
443 pPeerHTCap = (struct ht_capab_ele *)(ht_info->PeerHTCapBuf);
445 if (!memcmp(ht_info->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
446 pPeerHTInfo = (struct ht_info_ele *)
447 (&ht_info->PeerHTInfoBuf[4]);
449 pPeerHTInfo = (struct ht_info_ele *)(ht_info->PeerHTInfoBuf);
452 print_hex_dump_bytes("%s: ", __func__, DUMP_PREFIX_NONE,
453 pPeerHTCap, sizeof(struct ht_capab_ele));
455 ht_set_connect_bw_mode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth),
456 (enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset));
457 ht_info->cur_tx_bw40mhz = ((pPeerHTInfo->RecommemdedTxWidth == 1) ?
460 ht_info->cur_short_gi_20mhz = ((pPeerHTCap->ShortGI20Mhz == 1) ? true : false);
461 ht_info->cur_short_gi_40mhz = ((pPeerHTCap->ShortGI40Mhz == 1) ? true : false);
463 ht_info->current_ampdu_enable = ht_info->ampdu_enable;
464 if (ieee->rtllib_ap_sec_type &&
465 (ieee->rtllib_ap_sec_type(ieee) & (SEC_ALG_WEP | SEC_ALG_TKIP))) {
466 if ((ht_info->iot_peer == HT_IOT_PEER_ATHEROS) ||
467 (ht_info->iot_peer == HT_IOT_PEER_UNKNOWN))
468 ht_info->current_ampdu_enable = false;
471 if (ieee->current_network.bssht.bd_rt2rt_aggregation) {
472 if (ieee->pairwise_key_type != KEY_TYPE_NA)
473 ht_info->CurrentAMPDUFactor =
474 pPeerHTCap->MaxRxAMPDUFactor;
476 ht_info->CurrentAMPDUFactor = HT_AGG_SIZE_64K;
478 ht_info->CurrentAMPDUFactor = min_t(u32, pPeerHTCap->MaxRxAMPDUFactor,
482 ht_info->current_mpdu_density = pPeerHTCap->MPDUDensity;
483 if (ht_info->iot_action & HT_IOT_ACT_TX_USE_AMSDU_8K) {
484 ht_info->current_ampdu_enable = false;
486 ht_info->cur_rx_reorder_enable = 1;
488 if (pPeerHTCap->MCS[0] == 0)
489 pPeerHTCap->MCS[0] = 0xff;
491 ht_iot_act_determine_ra_func(ieee, ((pPeerHTCap->MCS[1]) != 0));
493 ht_filter_mcs_rate(ieee, pPeerHTCap->MCS, ieee->dot11ht_oper_rate_set);
495 pMcsFilter = MCS_FILTER_ALL;
496 ieee->HTHighestOperaRate = ht_get_highest_mcs_rate(ieee,
497 ieee->dot11ht_oper_rate_set,
499 ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
501 ht_info->current_op_mode = pPeerHTInfo->OptMode;
504 void ht_initialize_ht_info(struct rtllib_device *ieee)
506 struct rt_hi_throughput *ht_info = ieee->ht_info;
508 ht_info->current_ht_support = false;
510 ht_info->cur_bw_40mhz = false;
511 ht_info->cur_tx_bw40mhz = false;
513 ht_info->cur_short_gi_20mhz = false;
514 ht_info->cur_short_gi_40mhz = false;
516 ht_info->current_mpdu_density = 0;
517 ht_info->CurrentAMPDUFactor = ht_info->ampdu_factor;
519 memset((void *)(&ht_info->SelfHTCap), 0,
520 sizeof(ht_info->SelfHTCap));
521 memset((void *)(&ht_info->PeerHTCapBuf), 0,
522 sizeof(ht_info->PeerHTCapBuf));
523 memset((void *)(&ht_info->PeerHTInfoBuf), 0,
524 sizeof(ht_info->PeerHTInfoBuf));
526 ht_info->sw_bw_in_progress = false;
528 ht_info->peer_ht_spec_ver = HT_SPEC_VER_IEEE;
530 ht_info->current_rt2rt_aggregation = false;
531 ht_info->current_rt2rt_long_slot_time = false;
533 ht_info->iot_peer = 0;
534 ht_info->iot_action = 0;
535 ht_info->iot_ra_func = 0;
538 u8 *RegHTSuppRateSets = &ieee->reg_ht_supp_rate_set[0];
540 RegHTSuppRateSets[0] = 0xFF;
541 RegHTSuppRateSets[1] = 0xFF;
542 RegHTSuppRateSets[4] = 0x01;
546 void ht_initialize_bss_desc(struct bss_ht *pBssHT)
548 pBssHT->bd_support_ht = false;
549 memset(pBssHT->bd_ht_cap_buf, 0, sizeof(pBssHT->bd_ht_cap_buf));
550 pBssHT->bd_ht_cap_len = 0;
551 memset(pBssHT->bd_ht_info_buf, 0, sizeof(pBssHT->bd_ht_info_buf));
552 pBssHT->bd_ht_info_len = 0;
554 pBssHT->bd_ht_spec_ver = HT_SPEC_VER_IEEE;
556 pBssHT->bd_rt2rt_aggregation = false;
557 pBssHT->bd_rt2rt_long_slot_time = false;
558 pBssHT->rt2rt_ht_mode = (enum rt_ht_capability)0;
561 void ht_reset_self_and_save_peer_setting(struct rtllib_device *ieee,
562 struct rtllib_network *pNetwork)
564 struct rt_hi_throughput *ht_info = ieee->ht_info;
567 /* unmark enable_ht flag here is the same reason why unmarked in
568 * function rtllib_softmac_new_net. WB 2008.09.10
570 if (pNetwork->bssht.bd_support_ht) {
571 ht_info->current_ht_support = true;
572 ht_info->peer_ht_spec_ver = pNetwork->bssht.bd_ht_spec_ver;
574 if (pNetwork->bssht.bd_ht_cap_len > 0 &&
575 pNetwork->bssht.bd_ht_cap_len <= sizeof(ht_info->PeerHTCapBuf))
576 memcpy(ht_info->PeerHTCapBuf,
577 pNetwork->bssht.bd_ht_cap_buf,
578 pNetwork->bssht.bd_ht_cap_len);
580 if (pNetwork->bssht.bd_ht_info_len > 0 &&
581 pNetwork->bssht.bd_ht_info_len <=
582 sizeof(ht_info->PeerHTInfoBuf))
583 memcpy(ht_info->PeerHTInfoBuf,
584 pNetwork->bssht.bd_ht_info_buf,
585 pNetwork->bssht.bd_ht_info_len);
587 ht_info->current_rt2rt_aggregation =
588 pNetwork->bssht.bd_rt2rt_aggregation;
589 ht_info->current_rt2rt_long_slot_time =
590 pNetwork->bssht.bd_rt2rt_long_slot_time;
592 ht_iot_peer_determine(ieee);
594 ht_info->iot_action = 0;
595 bIOTAction = ht_iot_act_is_mgnt_use_cck_6m(ieee, pNetwork);
597 ht_info->iot_action |= HT_IOT_ACT_MGNT_USE_CCK_6M;
598 bIOTAction = ht_iot_act_is_ccd_fsync(ieee);
600 ht_info->iot_action |= HT_IOT_ACT_CDD_FSYNC;
602 ht_info->current_ht_support = false;
603 ht_info->current_rt2rt_aggregation = false;
604 ht_info->current_rt2rt_long_slot_time = false;
606 ht_info->iot_action = 0;
607 ht_info->iot_ra_func = 0;
611 void HT_update_self_and_peer_setting(struct rtllib_device *ieee,
612 struct rtllib_network *pNetwork)
614 struct rt_hi_throughput *ht_info = ieee->ht_info;
615 struct ht_info_ele *pPeerHTInfo =
616 (struct ht_info_ele *)pNetwork->bssht.bd_ht_info_buf;
618 if (ht_info->current_ht_support) {
619 if (pNetwork->bssht.bd_ht_info_len != 0)
620 ht_info->current_op_mode = pPeerHTInfo->OptMode;
623 EXPORT_SYMBOL(HT_update_self_and_peer_setting);
625 u8 ht_c_check(struct rtllib_device *ieee, u8 *pFrame)
627 if (ieee->ht_info->current_ht_support) {
628 if ((IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) {
629 netdev_dbg(ieee->dev, "HT CONTROL FILED EXIST!!\n");
636 static void ht_set_connect_bw_mode_callback(struct rtllib_device *ieee)
638 struct rt_hi_throughput *ht_info = ieee->ht_info;
640 if (ht_info->cur_bw_40mhz) {
641 if (ht_info->CurSTAExtChnlOffset == HT_EXTCHNL_OFFSET_UPPER)
642 ieee->set_chan(ieee->dev,
643 ieee->current_network.channel + 2);
644 else if (ht_info->CurSTAExtChnlOffset ==
645 HT_EXTCHNL_OFFSET_LOWER)
646 ieee->set_chan(ieee->dev,
647 ieee->current_network.channel - 2);
649 ieee->set_chan(ieee->dev,
650 ieee->current_network.channel);
652 ieee->set_bw_mode_handler(ieee->dev, HT_CHANNEL_WIDTH_20_40,
653 ht_info->CurSTAExtChnlOffset);
655 ieee->set_chan(ieee->dev, ieee->current_network.channel);
656 ieee->set_bw_mode_handler(ieee->dev, HT_CHANNEL_WIDTH_20,
657 HT_EXTCHNL_OFFSET_NO_EXT);
660 ht_info->sw_bw_in_progress = false;
663 void ht_set_connect_bw_mode(struct rtllib_device *ieee,
664 enum ht_channel_width bandwidth,
665 enum ht_extchnl_offset Offset)
667 struct rt_hi_throughput *ht_info = ieee->ht_info;
669 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
670 bandwidth = HT_CHANNEL_WIDTH_20;
672 if (ht_info->sw_bw_in_progress) {
673 pr_info("%s: sw_bw_in_progress!!\n", __func__);
676 if (bandwidth == HT_CHANNEL_WIDTH_20_40) {
677 if (ieee->current_network.channel < 2 &&
678 Offset == HT_EXTCHNL_OFFSET_LOWER)
679 Offset = HT_EXTCHNL_OFFSET_NO_EXT;
680 if (Offset == HT_EXTCHNL_OFFSET_UPPER ||
681 Offset == HT_EXTCHNL_OFFSET_LOWER) {
682 ht_info->cur_bw_40mhz = true;
683 ht_info->CurSTAExtChnlOffset = Offset;
685 ht_info->cur_bw_40mhz = false;
686 ht_info->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
689 ht_info->cur_bw_40mhz = false;
690 ht_info->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
693 netdev_dbg(ieee->dev, "%s():ht_info->bCurBW40MHz:%x\n", __func__,
694 ht_info->cur_bw_40mhz);
696 ht_info->sw_bw_in_progress = true;
698 ht_set_connect_bw_mode_callback(ieee);