39 #include <linux/module.h>
66 {.center_freq = 2412, .hw_value = 1,},
67 {.center_freq = 2417, .hw_value = 2,},
68 {.center_freq = 2422, .hw_value = 3,},
69 {.center_freq = 2427, .hw_value = 4,},
70 {.center_freq = 2432, .hw_value = 5,},
71 {.center_freq = 2437, .hw_value = 6,},
72 {.center_freq = 2442, .hw_value = 7,},
73 {.center_freq = 2447, .hw_value = 8,},
74 {.center_freq = 2452, .hw_value = 9,},
75 {.center_freq = 2457, .hw_value = 10,},
76 {.center_freq = 2462, .hw_value = 11,},
77 {.center_freq = 2467, .hw_value = 12,},
78 {.center_freq = 2472, .hw_value = 13,},
79 {.center_freq = 2484, .hw_value = 14,},
83 {.center_freq = 5180, .hw_value = 36,},
84 {.center_freq = 5200, .hw_value = 40,},
85 {.center_freq = 5220, .hw_value = 44,},
86 {.center_freq = 5240, .hw_value = 48,},
87 {.center_freq = 5260, .hw_value = 52,},
88 {.center_freq = 5280, .hw_value = 56,},
89 {.center_freq = 5300, .hw_value = 60,},
90 {.center_freq = 5320, .hw_value = 64,},
91 {.center_freq = 5500, .hw_value = 100,},
92 {.center_freq = 5520, .hw_value = 104,},
93 {.center_freq = 5540, .hw_value = 108,},
94 {.center_freq = 5560, .hw_value = 112,},
95 {.center_freq = 5580, .hw_value = 116,},
96 {.center_freq = 5600, .hw_value = 120,},
97 {.center_freq = 5620, .hw_value = 124,},
98 {.center_freq = 5640, .hw_value = 128,},
99 {.center_freq = 5660, .hw_value = 132,},
100 {.center_freq = 5680, .hw_value = 136,},
101 {.center_freq = 5700, .hw_value = 140,},
102 {.center_freq = 5745, .hw_value = 149,},
103 {.center_freq = 5765, .hw_value = 153,},
104 {.center_freq = 5785, .hw_value = 157,},
105 {.center_freq = 5805, .hw_value = 161,},
106 {.center_freq = 5825, .hw_value = 165,},
110 {.bitrate = 10, .hw_value = 0x00,},
111 {.bitrate = 20, .hw_value = 0x01,},
112 {.bitrate = 55, .hw_value = 0x02,},
113 {.bitrate = 110, .hw_value = 0x03,},
114 {.bitrate = 60, .hw_value = 0x04,},
115 {.bitrate = 90, .hw_value = 0x05,},
116 {.bitrate = 120, .hw_value = 0x06,},
117 {.bitrate = 180, .hw_value = 0x07,},
118 {.bitrate = 240, .hw_value = 0x08,},
119 {.bitrate = 360, .hw_value = 0x09,},
120 {.bitrate = 480, .hw_value = 0x0a,},
121 {.bitrate = 540, .hw_value = 0x0b,},
125 {.bitrate = 60, .hw_value = 0x04,},
126 {.bitrate = 90, .hw_value = 0x05,},
127 {.bitrate = 120, .hw_value = 0x06,},
128 {.bitrate = 180, .hw_value = 0x07,},
129 {.bitrate = 240, .hw_value = 0x08,},
130 {.bitrate = 360, .hw_value = 0x09,},
131 {.bitrate = 480, .hw_value = 0x0a,},
132 {.bitrate = 540, .hw_value = 0x0b,},
138 .channels = rtl_channeltable_2g,
139 .n_channels =
ARRAY_SIZE(rtl_channeltable_2g),
141 .bitrates = rtl_ratetable_2g,
150 .channels = rtl_channeltable_5g,
151 .n_channels =
ARRAY_SIZE(rtl_channeltable_5g),
153 .bitrates = rtl_ratetable_5g,
159 static const u8 tid_to_ac[] = {
172 return tid_to_ac[tid];
187 if (rtlpriv->
rtlhal.disable_amsdu_8k)
211 if (get_rf_type(rtlphy) ==
RF_1T2R || get_rf_type(rtlphy) ==
RF_2T2R) {
215 ht_cap->
mcs.rx_mask[0] = 0xFF;
216 ht_cap->
mcs.rx_mask[1] = 0xFF;
217 ht_cap->
mcs.rx_mask[4] = 0x01;
220 }
else if (get_rf_type(rtlphy) ==
RF_1T1R) {
224 ht_cap->
mcs.rx_mask[0] = 0xFF;
225 ht_cap->
mcs.rx_mask[1] = 0x00;
226 ht_cap->
mcs.rx_mask[4] = 0x01;
253 _rtl_init_hw_ht_capab(hw, &sband->
ht_cap);
268 _rtl_init_hw_ht_capab(hw, &sband->
ht_cap);
284 _rtl_init_hw_ht_capab(hw, &sband->
ht_cap);
299 _rtl_init_hw_ht_capab(hw, &sband->
ht_cap);
317 if (rtlpriv->
psc.swctrl_lps)
323 hw->
wiphy->interface_modes =
328 hw->
wiphy->rts_threshold = 2347;
342 if (is_valid_ether_addr(rtlefuse->
dev_addr)) {
343 SET_IEEE80211_PERM_ADDR(hw, rtlefuse->
dev_addr);
345 u8 rtlmac1[] = { 0x00, 0xe0, 0x4c, 0x81, 0x92, 0x00 };
347 SET_IEEE80211_PERM_ADDR(hw, rtlmac1);
352 static void _rtl_init_deferred_work(
struct ieee80211_hw *hw)
396 rtlpriv->
rfkill.rfkill_state =
true;
399 radio_state = rtlpriv->
cfg->ops->radio_onoff_checking(hw, &valid);
402 pr_info(
"wireless switch is %s\n",
403 rtlpriv->
rfkill.rfkill_state ?
"on" :
"off");
405 rtlpriv->
rfkill.rfkill_state = radio_state;
407 blocked = (rtlpriv->
rfkill.rfkill_state == 1) ? 0 : 1;
426 _rtl_init_mac80211(hw);
443 "regulatory_hint fail\n");
461 _rtl_init_deferred_work(hw);
483 static void _rtl_qurey_shortpreamble_mode(
struct ieee80211_hw *hw,
488 u8 rate_flag = info->
control.rates[0].flags;
507 u8 rate_flag = info->
control.rates[0].flags;
517 if (!(sta->
ht_cap.ht_supported))
538 static void _rtl_query_protection_mode(
struct ieee80211_hw *hw,
543 u8 rate_flag = info->
control.rates[0].flags;
565 static void _rtl_txrate_selectmode(
struct ieee80211_hw *hw,
595 if (rtlpriv->
dm.useramask) {
625 static void _rtl_query_bandwidth_mode(
struct ieee80211_hw *hw,
637 if (!(sta->
ht_cap.ht_supported) ||
660 if (get_rf_type(rtlphy) ==
RF_2T2R)
690 bool isht,
u8 desc_rate,
bool first_ampdu)
840 txrate = ieee80211_get_tx_rate(hw, info);
846 if (ieee80211_is_data(fc)) {
857 if (info->
control.rates[0].idx == 0 ||
858 ieee80211_is_nullfunc(fc)) {
871 if (sta && (sta->
ht_cap.ht_supported)) {
872 tcb_desc->
hw_rate = _rtl_get_highest_n_rate(hw);
884 if (is_multicast_ether_addr(ieee80211_get_DA(hdr)))
886 else if (is_broadcast_ether_addr(ieee80211_get_DA(hdr)))
889 _rtl_txrate_selectmode(hw, sta, tcb_desc);
890 _rtl_query_bandwidth_mode(hw, sta, tcb_desc);
891 _rtl_qurey_shortpreamble_mode(hw, tcb_desc, info);
892 _rtl_query_shortgi(hw, sta, tcb_desc, info);
893 _rtl_query_protection_mode(hw, tcb_desc, info);
913 if (!ieee80211_is_action(fc))
926 "%s ACT_ADDBAREQ From :%pM\n",
927 is_tx ?
"Tx" :
"Rx", hdr->
addr2);
931 "%s ACT_ADDBARSP From :%pM\n",
932 is_tx ?
"Tx" :
"Rx", hdr->
addr2);
936 "ACT_ADDBADEL From :%pM\n", hdr->
addr2);
957 if (!ieee80211_is_data(fc))
961 ip = (
struct iphdr *)((
u8 *) skb->
data + mac_hdr_len +
970 if (((((
u8 *) udp)[1] == 68) &&
971 (((
u8 *) udp)[3] == 67)) ||
972 ((((
u8 *) udp)[1] == 67) &&
973 (((
u8 *) udp)[3] == 68))) {
980 is_tx ?
"Tx" :
"Rx");
1000 "802.1X %s EAPOL pkt!!\n", is_tx ?
"Tx" :
"Rx");
1038 tid_data = &sta_entry->
tids[tid];
1120 bool busytraffic =
false;
1121 bool higher_busytraffic =
false;
1122 bool higher_busyrxtraffic =
false;
1124 u32 rx_cnt_inp4eriod = 0;
1125 u32 tx_cnt_inp4eriod = 0;
1126 u32 aver_rx_cnt_inperiod = 0;
1127 u32 aver_tx_cnt_inperiod = 0;
1130 bool enter_ps =
false;
1132 if (is_hal_stop(rtlhal))
1150 for (idx = 0; idx <= 2; idx++) {
1152 rtlpriv->
link_info.num_rx_in4period[idx + 1];
1154 rtlpriv->
link_info.num_tx_in4period[idx + 1];
1156 rtlpriv->
link_info.num_rx_in4period[3] =
1158 rtlpriv->
link_info.num_tx_in4period[3] =
1160 for (idx = 0; idx <= 3; idx++) {
1166 aver_rx_cnt_inperiod = rx_cnt_inp4eriod / 4;
1167 aver_tx_cnt_inperiod = tx_cnt_inp4eriod / 4;
1170 if (aver_rx_cnt_inperiod > 100 || aver_tx_cnt_inperiod > 100)
1174 if (aver_rx_cnt_inperiod > 4000 ||
1175 aver_tx_cnt_inperiod > 4000) {
1176 higher_busytraffic =
true;
1179 if (aver_rx_cnt_inperiod > 5000)
1180 higher_busyrxtraffic =
true;
1184 for (tid = 0; tid <= 7; tid++) {
1185 for (idx = 0; idx <= 2; idx++)
1186 rtlpriv->
link_info.tidtx_in4period[tid][idx] =
1189 rtlpriv->
link_info.tidtx_in4period[tid][3] =
1192 for (idx = 0; idx <= 3; idx++)
1193 tidtx_inp4eriod[tid] +=
1194 rtlpriv->
link_info.tidtx_in4period[tid][idx];
1195 aver_tidtx_inperiod[tid] = tidtx_inp4eriod[tid] / 4;
1196 if (aver_tidtx_inperiod[tid] > 5000)
1197 rtlpriv->
link_info.higher_busytxtraffic[tid] =
1200 rtlpriv->
link_info.higher_busytxtraffic[tid] =
1204 if (((rtlpriv->
link_info.num_rx_inperiod +
1205 rtlpriv->
link_info.num_tx_inperiod) > 8) ||
1206 (rtlpriv->
link_info.num_rx_inperiod > 2))
1220 for (tid = 0; tid <= 7; tid++)
1221 rtlpriv->
link_info.tidtx_inperiod[tid] = 0;
1223 rtlpriv->
link_info.busytraffic = busytraffic;
1224 rtlpriv->
link_info.higher_busytraffic = higher_busytraffic;
1225 rtlpriv->
link_info.higher_busyrxtraffic = higher_busyrxtraffic;
1228 rtlpriv->
cfg->ops->dm_watchdog(hw);
1237 &rtlpriv->
works.watchdog_wq, 0);
1253 pos = (
u8 *)mgmt->
u.beacon.variable;
1256 if (pos + 2 + pos[1] > end)
1282 action_frame = (
void *)
skb_put(skb, 27);
1283 memset(action_frame, 0, 27);
1296 action_frame->
u.action.u.ht_smps.smps_control =
1300 action_frame->
u.action.u.ht_smps.smps_control =
1304 action_frame->
u.action.u.ht_smps.smps_control =
1319 struct sk_buff *skb = rtl_make_smps_action(hw, smps, da, bssid);
1323 if (rtlpriv->
mac80211.act_scanning)
1341 rtlpriv->
cfg->ops->update_rate_tbl(hw, sta, 0);
1343 info->
control.rates[0].idx = 0;
1344 info->
band = hw->
conf.channel->band;
1345 rtlpriv->
intf_ops->adapter_tx(hw, sta, skb, &tcb_desc);
1356 static bool rtl_chk_vendor_ouisub(
struct ieee80211_hw *hw,
1360 bool matched =
false;
1361 static u8 athcap_1[] = { 0x00, 0x03, 0x7F };
1362 static u8 athcap_2[] = { 0x00, 0x13, 0x74 };
1363 static u8 broadcap_1[] = { 0x00, 0x10, 0x18 };
1364 static u8 broadcap_2[] = { 0x00, 0x0a, 0xf7 };
1365 static u8 broadcap_3[] = { 0x00, 0x05, 0xb5 };
1366 static u8 racap[] = { 0x00, 0x0c, 0x43 };
1367 static u8 ciscocap[] = { 0x00, 0x40, 0x96 };
1368 static u8 marvcap[] = { 0x00, 0x50, 0x43 };
1374 }
else if (
memcmp(vendor_ie.
octet, broadcap_1, 3) == 0 ||
1379 }
else if (
memcmp(vendor_ie.
octet, racap, 3) == 0) {
1382 }
else if (
memcmp(vendor_ie.
octet, ciscocap, 3) == 0) {
1385 }
else if (
memcmp(vendor_ie.
octet, marvcap, 3) == 0) {
1400 pos = (
u8 *)mgmt->
u.beacon.variable;
1403 if (pos[0] == 221) {
1404 vendor_ie.
length = pos[1];
1405 vendor_ie.
octet = &pos[2];
1406 if (rtl_chk_vendor_ouisub(hw, vendor_ie))
1410 if (pos + 2 + pos[1] > end)
1425 static u8 ap3_1[3] = { 0x00, 0x14, 0xbf };
1426 static u8 ap3_2[3] = { 0x00, 0x1a, 0x70 };
1427 static u8 ap3_3[3] = { 0x00, 0x1d, 0x7e };
1428 static u8 ap4_1[3] = { 0x00, 0x90, 0xcc };
1429 static u8 ap4_2[3] = { 0x00, 0x0e, 0x2e };
1430 static u8 ap4_3[3] = { 0x00, 0x18, 0x02 };
1431 static u8 ap4_4[3] = { 0x00, 0x17, 0x3f };
1432 static u8 ap4_5[3] = { 0x00, 0x1c, 0xdf };
1433 static u8 ap5_1[3] = { 0x00, 0x1c, 0xf0 };
1434 static u8 ap5_2[3] = { 0x00, 0x21, 0x91 };
1435 static u8 ap5_3[3] = { 0x00, 0x24, 0x01 };
1436 static u8 ap5_4[3] = { 0x00, 0x15, 0xe9 };
1437 static u8 ap5_5[3] = { 0x00, 0x17, 0x9A };
1438 static u8 ap5_6[3] = { 0x00, 0x18, 0xE7 };
1439 static u8 ap6_1[3] = { 0x00, 0x17, 0x94 };
1440 static u8 ap7_1[3] = { 0x00, 0x14, 0xa4 };
1465 if (rtl_find_221_ie(hw, data, len))
1515 return sprintf(buf,
"0x%08X\n", rtlpriv->
dbg.global_debuglevel);
1531 rtlpriv->
dbg.global_debuglevel =
val;
1533 rtlpriv->
dbg.global_debuglevel);
1540 rtl_show_debug_level, rtl_store_debug_level);
1542 static struct attribute *rtl_sysfs_entries[] = {
1544 &dev_attr_debug_level.attr,
1557 .attrs = rtl_sysfs_entries,
1566 static int __init rtl_core_module_init(
void)
1569 pr_err(
"Unable to register rtl_rc, use default RC !!\n");
1574 static void __exit rtl_core_module_exit(
void)