43 if (
unlikely(ieee80211_is_beacon(fc)))
45 if (ieee80211_is_mgmt(fc))
51 static u8 _rtl92d_query_rxpwrpercentage(
char antpower)
53 if ((antpower <= -100) || (antpower >= 20))
55 else if (antpower >= 0)
58 return 100 + antpower;
61 static u8 _rtl92d_evm_db_to_percentage(
char value)
69 ret_val = 0 - ret_val;
77 u8 signal_strength_index)
81 signal_power = (
long)((signal_strength_index + 1) >> 1);
86 static long _rtl92de_signal_scale_mapping(
struct ieee80211_hw *hw,
long currsig)
90 if (currsig >= 61 && currsig <= 100)
91 retsig = 90 + ((currsig - 60) / 4);
92 else if (currsig >= 41 && currsig <= 60)
93 retsig = 78 + ((currsig - 40) / 2);
94 else if (currsig >= 31 && currsig <= 40)
95 retsig = 66 + (currsig - 30);
96 else if (currsig >= 21 && currsig <= 30)
97 retsig = 54 + (currsig - 20);
98 else if (currsig >= 5 && currsig <= 20)
99 retsig = 42 + (((currsig - 5) * 2) / 3);
100 else if (currsig == 4)
102 else if (currsig == 3)
104 else if (currsig == 2)
106 else if (currsig == 1)
113 static void _rtl92de_query_rxphystatus(
struct ieee80211_hw *hw,
117 bool packet_match_bssid,
124 s8 rx_pwr_all, rx_pwr[4];
125 u8 rf_rx_num = 0, evm, pwdb_all;
126 u8 i, max_spatial_stream;
127 u32 rssi, total_rssi = 0;
134 pstats->
is_cck = is_cck_rate;
142 cck_highpwr = (
u8) rtl_get_bbreg(hw,
150 report = report >> 6;
153 rx_pwr_all = -46 - (cck_agc_rpt & 0x3e);
156 rx_pwr_all = -26 - (cck_agc_rpt & 0x3e);
159 rx_pwr_all = -12 - (cck_agc_rpt & 0x3e);
162 rx_pwr_all = 16 - (cck_agc_rpt & 0x3e);
167 report = p_drvinfo->
cfosho[0] & 0x60;
168 report = report >> 5;
171 rx_pwr_all = -46 - ((cck_agc_rpt & 0x1f) << 1);
174 rx_pwr_all = -26 - ((cck_agc_rpt & 0x1f) << 1);
177 rx_pwr_all = -12 - ((cck_agc_rpt & 0x1f) << 1);
180 rx_pwr_all = 16 - ((cck_agc_rpt & 0x1f) << 1);
184 pwdb_all = _rtl92d_query_rxpwrpercentage(rx_pwr_all);
191 if (pwdb_all > 34 && pwdb_all <= 42)
193 else if (pwdb_all > 26 && pwdb_all <= 34)
195 else if (pwdb_all > 14 && pwdb_all <= 26)
197 else if (pwdb_all > 4 && pwdb_all <= 14)
201 if (packet_match_bssid) {
212 sq = ((64 - sq) * 100) / 44;
219 rtlpriv->
dm.rfpath_rxenable[0] =
true;
220 rtlpriv->
dm.rfpath_rxenable[1] =
true;
222 if (rtlpriv->
dm.rfpath_rxenable[i])
226 rssi = _rtl92d_query_rxpwrpercentage(rx_pwr[i]);
228 rtlpriv->
stats.rx_snr_db[
i] =
230 if (packet_match_bssid)
233 rx_pwr_all = ((p_drvinfo->
pwdb_all >> 1) & 0x7f) - 106;
234 pwdb_all = _rtl92d_query_rxpwrpercentage(rx_pwr_all);
240 max_spatial_stream = 2;
242 max_spatial_stream = 1;
243 for (i = 0; i < max_spatial_stream; i++) {
244 evm = _rtl92d_evm_db_to_percentage(p_drvinfo->
rxevm[i]);
245 if (packet_match_bssid) {
257 else if (rf_rx_num != 0)
259 total_rssi /= rf_rx_num));
262 static void rtl92d_loop_over_paths(
struct ieee80211_hw *hw,
271 if (rtlpriv->
stats.rx_rssi_percentage[rfpath] == 0) {
272 rtlpriv->
stats.rx_rssi_percentage[rfpath] =
277 rtlpriv->
stats.rx_rssi_percentage[rfpath]) {
278 rtlpriv->
stats.rx_rssi_percentage[rfpath] =
279 ((rtlpriv->
stats.rx_rssi_percentage[rfpath] *
283 rtlpriv->
stats.rx_rssi_percentage[rfpath] =
284 rtlpriv->
stats.rx_rssi_percentage[rfpath] + 1;
286 rtlpriv->
stats.rx_rssi_percentage[rfpath] =
287 ((rtlpriv->
stats.rx_rssi_percentage[rfpath] *
295 static void _rtl92de_process_ui_rssi(
struct ieee80211_hw *hw,
299 u32 last_rssi, tmpval;
302 rtlpriv->
stats.rssi_calculate_cnt++;
303 if (rtlpriv->
stats.ui_rssi.total_num++ >=
305 rtlpriv->
stats.ui_rssi.total_num =
307 last_rssi = rtlpriv->
stats.ui_rssi.elements[
308 rtlpriv->
stats.ui_rssi.index];
309 rtlpriv->
stats.ui_rssi.total_val -= last_rssi;
312 rtlpriv->
stats.ui_rssi.elements
313 [rtlpriv->
stats.ui_rssi.index++] =
316 rtlpriv->
stats.ui_rssi.index = 0;
317 tmpval = rtlpriv->
stats.ui_rssi.total_val /
318 rtlpriv->
stats.ui_rssi.total_num;
319 rtlpriv->
stats.signal_strength = _rtl92de_translate_todbm(hw,
321 pstats->
rssi = rtlpriv->
stats.signal_strength;
324 rtl92d_loop_over_paths(hw, pstats);
327 static void _rtl92de_update_rxsignalstatistics(
struct ieee80211_hw *hw,
333 if (rtlpriv->
stats.recv_signal_power == 0)
339 rtlpriv->
stats.recv_signal_power = (rtlpriv->
stats.recv_signal_power *
343 static void _rtl92de_process_pwdb(
struct ieee80211_hw *hw,
348 long undecorated_smoothed_pwdb;
354 undecorated_smoothed_pwdb =
355 rtlpriv->
dm.undecorated_smoothed_pwdb;
358 if (undecorated_smoothed_pwdb < 0)
361 undecorated_smoothed_pwdb =
362 (((undecorated_smoothed_pwdb) *
365 undecorated_smoothed_pwdb =
366 undecorated_smoothed_pwdb + 1;
368 undecorated_smoothed_pwdb =
369 (((undecorated_smoothed_pwdb) *
373 rtlpriv->
dm.undecorated_smoothed_pwdb =
374 undecorated_smoothed_pwdb;
375 _rtl92de_update_rxsignalstatistics(hw, pstats);
379 static void rtl92d_loop_over_streams(
struct ieee80211_hw *hw,
385 for (stream = 0; stream < 2; stream++) {
387 if (rtlpriv->
stats.rx_evm_percentage[stream] == 0) {
388 rtlpriv->
stats.rx_evm_percentage[stream] =
391 rtlpriv->
stats.rx_evm_percentage[stream] =
392 ((rtlpriv->
stats.rx_evm_percentage[stream]
400 static void _rtl92de_process_ui_link_quality(
struct ieee80211_hw *hw,
404 u32 last_evm, tmpval;
409 if (rtlpriv->
stats.ui_link_quality.total_num++ >=
411 rtlpriv->
stats.ui_link_quality.total_num =
413 last_evm = rtlpriv->
stats.ui_link_quality.elements[
414 rtlpriv->
stats.ui_link_quality.index];
415 rtlpriv->
stats.ui_link_quality.total_val -= last_evm;
417 rtlpriv->
stats.ui_link_quality.total_val +=
419 rtlpriv->
stats.ui_link_quality.elements[
420 rtlpriv->
stats.ui_link_quality.index++] =
422 if (rtlpriv->
stats.ui_link_quality.index >=
424 rtlpriv->
stats.ui_link_quality.index = 0;
425 tmpval = rtlpriv->
stats.ui_link_quality.total_val /
426 rtlpriv->
stats.ui_link_quality.total_num;
427 rtlpriv->
stats.signal_quality = tmpval;
428 rtlpriv->
stats.last_sigstrength_inpercent = tmpval;
429 rtl92d_loop_over_streams(hw, pstats);
433 static void _rtl92de_process_phyinfo(
struct ieee80211_hw *hw,
442 _rtl92de_process_ui_rssi(hw, pcurrent_stats);
443 _rtl92de_process_pwdb(hw, pcurrent_stats);
444 _rtl92de_process_ui_link_quality(hw, pcurrent_stats);
447 static void _rtl92de_translate_rx_signal_stuff(
struct ieee80211_hw *hw,
460 bool packet_matchbssid, packet_toself, packet_beacon;
469 ether_addr_equal(mac->
bssid,
474 packet_toself = packet_matchbssid &&
475 ether_addr_equal(praddr, rtlefuse->
dev_addr);
476 if (ieee80211_is_beacon(fc))
477 packet_beacon =
true;
478 _rtl92de_query_rxphystatus(hw, pstats, pdesc, p_drvinfo,
479 packet_matchbssid, packet_toself,
481 _rtl92de_process_phyinfo(hw, tmp_buf, pstats);
507 rx_status->
freq = hw->
conf.channel->center_freq;
508 rx_status->
band = hw->
conf.channel->band;
528 _rtl92de_translate_rx_signal_stuff(hw,
538 static void _rtl92de_insert_emcontent(
struct rtl_tcb_desc *ptcb_desc,
541 memset(virtualaddress, 0, 8);
564 u8 *pdesc = pdesc_tx;
567 unsigned int buf_len = 0;
568 unsigned int skb_len = skb->
len;
569 u8 fw_qsel = _rtl92de_map_hwqueue_to_fwqueue(skb, hw_queue);
593 mapping = pci_map_single(rtlpci->
pdev, skb->
data, skb->
len,
596 if (ieee80211_is_nullfunc(fc) || ieee80211_is_ctl(fc)) {
607 "Insert 8 byte.pTcb->EMPktNum:%d\n",
609 _rtl92de_insert_emcontent(ptcb_desc,
665 u8 ampdu_density = sta->
ht_cap.ampdu_density;
671 keyconf = info->
control.hw_key;
672 switch (keyconf->
cipher) {
702 if (ieee80211_is_data_qos(fc)) {
705 "Enable RDG function\n");
716 if (rtlpriv->
dm.useramask) {
723 if (ieee80211_is_data_qos(fc))
726 if ((!ieee80211_is_data_qos(fc)) && ppsc->
fwctrl_lps) {
735 u8 *pdesc,
bool firstseg,
736 bool lastseg,
struct sk_buff *skb)
775 if (!ieee80211_is_data_qos(fc) && ppsc->
fwctrl_lps) {
798 RT_ASSERT(
false,
"ERR txdesc :%d not process\n",
818 RT_ASSERT(
false,
"ERR rxdesc :%d not process\n",
838 RT_ASSERT(
false,
"ERR txdesc :%d not process\n",
852 RT_ASSERT(
false,
"ERR rxdesc :%d not process\n",
867 BIT(0) << (hw_queue));