43 if (
unlikely(ieee80211_is_beacon(fc)))
45 if (ieee80211_is_mgmt(fc))
51 static u8 _rtl92c_query_rxpwrpercentage(
char antpower)
53 if ((antpower <= -100) || (antpower >= 20))
55 else if (antpower >= 0)
58 return 100 + antpower;
61 static u8 _rtl92c_evm_db_to_percentage(
char value)
72 ret_val = 0 - ret_val;
82 u8 signal_strength_index)
86 signal_power = (
long)((signal_strength_index + 1) >> 1);
91 static long _rtl92ce_signal_scale_mapping(
struct ieee80211_hw *hw,
96 if (currsig >= 61 && currsig <= 100)
97 retsig = 90 + ((currsig - 60) / 4);
98 else if (currsig >= 41 && currsig <= 60)
99 retsig = 78 + ((currsig - 40) / 2);
100 else if (currsig >= 31 && currsig <= 40)
101 retsig = 66 + (currsig - 30);
102 else if (currsig >= 21 && currsig <= 30)
103 retsig = 54 + (currsig - 20);
104 else if (currsig >= 5 && currsig <= 20)
105 retsig = 42 + (((currsig - 5) * 2) / 3);
106 else if (currsig == 4)
108 else if (currsig == 3)
110 else if (currsig == 2)
112 else if (currsig == 1)
120 static void _rtl92ce_query_rxphystatus(
struct ieee80211_hw *hw,
124 bool packet_match_bssid,
130 s8 rx_pwr_all = 0, rx_pwr[4];
131 u8 evm, pwdb_all, rf_rx_num = 0;
132 u8 i, max_spatial_stream;
133 u32 rssi, total_rssi = 0;
134 bool in_powersavemode =
false;
140 pstats->
is_cck = is_cck_rate;
142 pstats->
is_cck = is_cck_rate;
150 if (!in_powersavemode)
151 cck_highpwr = (
u8) rtl_get_bbreg(hw,
160 report = report >> 6;
163 rx_pwr_all = -46 - (cck_agc_rpt & 0x3e);
166 rx_pwr_all = -26 - (cck_agc_rpt & 0x3e);
169 rx_pwr_all = -12 - (cck_agc_rpt & 0x3e);
172 rx_pwr_all = 16 - (cck_agc_rpt & 0x3e);
177 report = p_drvinfo->
cfosho[0] & 0x60;
178 report = report >> 5;
181 rx_pwr_all = -46 - ((cck_agc_rpt & 0x1f) << 1);
184 rx_pwr_all = -26 - ((cck_agc_rpt & 0x1f) << 1);
187 rx_pwr_all = -12 - ((cck_agc_rpt & 0x1f) << 1);
190 rx_pwr_all = 16 - ((cck_agc_rpt & 0x1f) << 1);
195 pwdb_all = _rtl92c_query_rxpwrpercentage(rx_pwr_all);
199 if (packet_match_bssid) {
210 sq = ((64 - sq) * 100) / 44;
218 rtlpriv->
dm.rfpath_rxenable[0] =
219 rtlpriv->
dm.rfpath_rxenable[1] =
true;
221 if (rtlpriv->
dm.rfpath_rxenable[i])
226 rssi = _rtl92c_query_rxpwrpercentage(rx_pwr[i]);
228 rtlpriv->
stats.rx_snr_db[
i] =
231 if (packet_match_bssid)
235 rx_pwr_all = ((p_drvinfo->
pwdb_all >> 1) & 0x7f) - 110;
236 pwdb_all = _rtl92c_query_rxpwrpercentage(rx_pwr_all);
243 max_spatial_stream = 2;
245 max_spatial_stream = 1;
247 for (i = 0; i < max_spatial_stream; i++) {
248 evm = _rtl92c_evm_db_to_percentage(p_drvinfo->
rxevm[i]);
250 if (packet_match_bssid) {
262 (
u8) (_rtl92ce_signal_scale_mapping(hw, pwdb_all));
263 else if (rf_rx_num != 0)
265 (
u8) (_rtl92ce_signal_scale_mapping
266 (hw, total_rssi /= rf_rx_num));
269 static void _rtl92ce_process_ui_rssi(
struct ieee80211_hw *hw,
275 u32 last_rssi, tmpval;
278 rtlpriv->
stats.rssi_calculate_cnt++;
280 if (rtlpriv->
stats.ui_rssi.total_num++ >=
283 rtlpriv->
stats.ui_rssi.total_num =
286 rtlpriv->
stats.ui_rssi.elements[rtlpriv->
287 stats.ui_rssi.index];
288 rtlpriv->
stats.ui_rssi.total_val -= last_rssi;
292 rtlpriv->
stats.ui_rssi.elements[rtlpriv->
stats.ui_rssi.
297 rtlpriv->
stats.ui_rssi.index = 0;
299 tmpval = rtlpriv->
stats.ui_rssi.total_val /
300 rtlpriv->
stats.ui_rssi.total_num;
301 rtlpriv->
stats.signal_strength =
302 _rtl92ce_translate_todbm(hw, (
u8) tmpval);
303 pstats->
rssi = rtlpriv->
stats.signal_strength;
309 if (rtlpriv->
stats.rx_rssi_percentage[rfpath] == 0) {
310 rtlpriv->
stats.rx_rssi_percentage[rfpath] =
316 rtlpriv->
stats.rx_rssi_percentage[rfpath]) {
317 rtlpriv->
stats.rx_rssi_percentage[rfpath] =
319 rx_rssi_percentage[rfpath] *
324 rtlpriv->
stats.rx_rssi_percentage[rfpath] =
325 rtlpriv->
stats.rx_rssi_percentage[rfpath] +
328 rtlpriv->
stats.rx_rssi_percentage[rfpath] =
330 rx_rssi_percentage[rfpath] *
340 static void _rtl92ce_update_rxsignalstatistics(
struct ieee80211_hw *hw,
346 if (rtlpriv->
stats.recv_signal_power == 0)
355 rtlpriv->
stats.recv_signal_power =
356 (rtlpriv->
stats.recv_signal_power * 5 +
360 static void _rtl92ce_process_pwdb(
struct ieee80211_hw *hw,
365 long undecorated_smoothed_pwdb;
370 undecorated_smoothed_pwdb =
371 rtlpriv->
dm.undecorated_smoothed_pwdb;
375 if (undecorated_smoothed_pwdb < 0)
379 undecorated_smoothed_pwdb =
380 (((undecorated_smoothed_pwdb) *
384 undecorated_smoothed_pwdb = undecorated_smoothed_pwdb
387 undecorated_smoothed_pwdb =
388 (((undecorated_smoothed_pwdb) *
393 rtlpriv->
dm.undecorated_smoothed_pwdb =
394 undecorated_smoothed_pwdb;
395 _rtl92ce_update_rxsignalstatistics(hw, pstats);
399 static void _rtl92ce_process_ui_link_quality(
struct ieee80211_hw *hw,
403 u32 last_evm, n_spatialstream, tmpval;
408 if (rtlpriv->
stats.ui_link_quality.total_num++ >=
410 rtlpriv->
stats.ui_link_quality.total_num =
414 ui_link_quality.elements[rtlpriv->
415 stats.ui_link_quality.
417 rtlpriv->
stats.ui_link_quality.total_val -=
421 rtlpriv->
stats.ui_link_quality.total_val +=
423 rtlpriv->
stats.ui_link_quality.elements[rtlpriv->
stats.
428 if (rtlpriv->
stats.ui_link_quality.index >=
430 rtlpriv->
stats.ui_link_quality.index = 0;
432 tmpval = rtlpriv->
stats.ui_link_quality.total_val /
433 rtlpriv->
stats.ui_link_quality.total_num;
434 rtlpriv->
stats.signal_quality = tmpval;
436 rtlpriv->
stats.last_sigstrength_inpercent = tmpval;
438 for (n_spatialstream = 0; n_spatialstream < 2;
441 rx_mimo_signalquality[n_spatialstream] !=
444 rx_evm_percentage[n_spatialstream]
454 rx_evm_percentage[n_spatialstream] =
456 stats.rx_evm_percentage
460 rx_mimo_signalquality
461 [n_spatialstream] * 1)) /
471 static void _rtl92ce_process_phyinfo(
struct ieee80211_hw *hw,
480 _rtl92ce_process_ui_rssi(hw, pcurrent_stats);
481 _rtl92ce_process_pwdb(hw, pcurrent_stats);
482 _rtl92ce_process_ui_link_quality(hw, pcurrent_stats);
485 static void _rtl92ce_translate_rx_signal_stuff(
struct ieee80211_hw *hw,
499 bool packet_matchbssid, packet_toself, packet_beacon;
511 ether_addr_equal(mac->
bssid,
517 packet_toself = packet_matchbssid &&
518 ether_addr_equal(praddr, rtlefuse->
dev_addr);
520 if (ieee80211_is_beacon(fc))
521 packet_beacon =
true;
523 _rtl92ce_query_rxphystatus(hw, pstats, pdesc, p_drvinfo,
524 packet_matchbssid, packet_toself,
527 _rtl92ce_process_phyinfo(hw, tmp_buf, pstats);
555 rx_status->
freq = hw->
conf.channel->center_freq;
556 rx_status->
band = hw->
conf.channel->band;
585 _rtl92ce_translate_rx_signal_stuff(hw,
608 bool defaultadapter =
true;
609 u8 *pdesc = pdesc_tx;
612 u8 fw_qsel = _rtl92ce_map_hwqueue_to_fwqueue(skb, hw_queue);
625 sta = get_sta(hw, mac->
vif, mac->
bssid);
641 if (ieee80211_is_nullfunc(fc) || ieee80211_is_ctl(fc)) {
661 cts_enable) ? 1 : 0));
694 u8 ampdu_density = sta->
ht_cap.ampdu_density;
702 switch (keyconf->
cipher) {
726 if (ieee80211_is_data_qos(fc)) {
729 "Enable RDG function\n");
744 if (rtlpriv->
dm.useramask) {
752 if ((!ieee80211_is_data_qos(fc)) && ppsc->
fwctrl_lps) {
762 if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) ||
763 is_broadcast_ether_addr(ieee80211_get_DA(hdr))) {
771 u8 *pdesc,
bool firstseg,
772 bool lastseg,
struct sk_buff *skb)
819 if (!ieee80211_is_data_qos(fc)) {
840 RT_ASSERT(
false,
"ERR txdesc :%d not process\n",
860 RT_ASSERT(
false,
"ERR rxdesc :%d not process\n",
880 RT_ASSERT(
false,
"ERR txdesc :%d not process\n",
894 RT_ASSERT(
false,
"ERR rxdesc :%d not process\n",
909 BIT(0) << (hw_queue));