40 static u8 _rtl92se_map_hwqueue_to_fwqueue(
struct sk_buff *
skb,
u8 skb_queue)
44 if (
unlikely(ieee80211_is_beacon(fc)))
46 if (ieee80211_is_mgmt(fc))
48 if (ieee80211_is_nullfunc(fc))
54 static u8 _rtl92s_query_rxpwrpercentage(
char antpower)
56 if ((antpower <= -100) || (antpower >= 20))
58 else if (antpower >= 0)
61 return 100 + antpower;
64 static u8 _rtl92s_evm_db_to_percentage(
char value)
75 ret_val = 0 - ret_val;
85 u8 signal_strength_index)
89 signal_power = (
long)((signal_strength_index + 1) >> 1);
94 static long _rtl92se_signal_scale_mapping(
struct ieee80211_hw *hw,
102 else if (currsig > 14 && currsig <= 47)
103 retsig = 100 - ((47 - currsig) * 3) / 2;
104 else if (currsig > 2 && currsig <= 14)
105 retsig = 48 - ((14 - currsig) * 15) / 7;
106 else if (currsig >= 0)
107 retsig = currsig * 9 + 1;
113 static void _rtl92se_query_rxphystatus(
struct ieee80211_hw *hw,
116 bool packet_match_bssid,
122 s8 rx_pwr_all = 0, rx_pwr[4];
123 u8 rf_rx_num = 0, evm, pwdb_all;
124 u8 i, max_spatial_stream;
125 u32 rssi, total_rssi = 0;
126 bool in_powersavemode =
false;
127 bool is_cck = pstats->
is_cck;
139 if (!in_powersavemode)
140 cck_highpwr = (
u8) rtl_get_bbreg(hw,
149 report = report >> 6;
152 rx_pwr_all = -40 - (cck_agc_rpt & 0x3e);
155 rx_pwr_all = -20 - (cck_agc_rpt & 0x3e);
158 rx_pwr_all = -2 - (cck_agc_rpt & 0x3e);
161 rx_pwr_all = 14 - (cck_agc_rpt & 0x3e);
166 report = p_drvinfo->
cfosho[0] & 0x60;
167 report = report >> 5;
170 rx_pwr_all = -40 - ((cck_agc_rpt & 0x1f) << 1);
173 rx_pwr_all = -20 - ((cck_agc_rpt & 0x1f) << 1);
176 rx_pwr_all = -2 - ((cck_agc_rpt & 0x1f) << 1);
179 rx_pwr_all = 14 - ((cck_agc_rpt & 0x1f) << 1);
184 pwdb_all = _rtl92s_query_rxpwrpercentage(rx_pwr_all);
192 if (pwdb_all > 34 && pwdb_all <= 42)
194 else if (pwdb_all > 26 && pwdb_all <= 34)
196 else if (pwdb_all > 14 && pwdb_all <= 26)
198 else if (pwdb_all > 4 && pwdb_all <= 14)
204 if (packet_match_bssid) {
215 sq = ((64 - sq) * 100) / 44;
223 rtlpriv->
dm.rfpath_rxenable[0] =
224 rtlpriv->
dm.rfpath_rxenable[1] =
true;
226 if (rtlpriv->
dm.rfpath_rxenable[i])
231 rssi = _rtl92s_query_rxpwrpercentage(rx_pwr[i]);
233 rtlpriv->
stats.rx_snr_db[
i] =
236 if (packet_match_bssid)
240 rx_pwr_all = ((p_drvinfo->
pwdb_all >> 1) & 0x7f) - 110;
241 pwdb_all = _rtl92s_query_rxpwrpercentage(rx_pwr_all);
248 max_spatial_stream = 2;
250 max_spatial_stream = 1;
252 for (i = 0; i < max_spatial_stream; i++) {
253 evm = _rtl92s_evm_db_to_percentage(p_drvinfo->
rxevm[i]);
255 if (packet_match_bssid) {
268 else if (rf_rx_num != 0)
270 total_rssi /= rf_rx_num));
273 static void _rtl92se_process_ui_rssi(
struct ieee80211_hw *hw,
279 u32 last_rssi, tmpval;
282 rtlpriv->
stats.rssi_calculate_cnt++;
284 if (rtlpriv->
stats.ui_rssi.total_num++ >=
286 rtlpriv->
stats.ui_rssi.total_num =
288 last_rssi = rtlpriv->
stats.ui_rssi.elements[
289 rtlpriv->
stats.ui_rssi.index];
290 rtlpriv->
stats.ui_rssi.total_val -= last_rssi;
294 rtlpriv->
stats.ui_rssi.elements[rtlpriv->
stats.ui_rssi.index++]
298 rtlpriv->
stats.ui_rssi.index = 0;
300 tmpval = rtlpriv->
stats.ui_rssi.total_val /
301 rtlpriv->
stats.ui_rssi.total_num;
302 rtlpriv->
stats.signal_strength = _rtl92se_translate_todbm(hw,
304 pstats->
rssi = rtlpriv->
stats.signal_strength;
310 if (rtlpriv->
stats.rx_rssi_percentage[rfpath] == 0) {
311 rtlpriv->
stats.rx_rssi_percentage[rfpath] =
317 rtlpriv->
stats.rx_rssi_percentage[rfpath]) {
318 rtlpriv->
stats.rx_rssi_percentage[rfpath] =
319 ((rtlpriv->
stats.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] =
329 ((rtlpriv->
stats.rx_rssi_percentage[rfpath]
339 static void _rtl92se_update_rxsignalstatistics(
struct ieee80211_hw *hw,
345 if (rtlpriv->
stats.recv_signal_power == 0)
353 rtlpriv->
stats.recv_signal_power = (rtlpriv->
stats.recv_signal_power * 5
358 static void _rtl92se_process_pwdb(
struct ieee80211_hw *hw,
363 long undec_sm_pwdb = 0;
369 rtlpriv->
dm.undecorated_smoothed_pwdb;
373 if (undec_sm_pwdb < 0)
382 undec_sm_pwdb = undec_sm_pwdb + 1;
384 undec_sm_pwdb = (((undec_sm_pwdb) *
389 rtlpriv->
dm.undecorated_smoothed_pwdb = undec_sm_pwdb;
390 _rtl92se_update_rxsignalstatistics(hw, pstats);
394 static void rtl_92s_process_streams(
struct ieee80211_hw *hw,
400 for (stream = 0; stream < 2; stream++) {
402 if (rtlpriv->
stats.rx_evm_percentage[stream] == 0) {
403 rtlpriv->
stats.rx_evm_percentage[stream] =
407 rtlpriv->
stats.rx_evm_percentage[stream] =
408 ((rtlpriv->
stats.rx_evm_percentage[stream] *
416 static void _rtl92se_process_ui_link_quality(
struct ieee80211_hw *hw,
420 u32 last_evm = 0, tmpval;
425 if (rtlpriv->
stats.ui_link_quality.total_num++ >=
427 rtlpriv->
stats.ui_link_quality.total_num =
430 rtlpriv->
stats.ui_link_quality.elements[
431 rtlpriv->
stats.ui_link_quality.index];
432 rtlpriv->
stats.ui_link_quality.total_val -=
436 rtlpriv->
stats.ui_link_quality.total_val +=
438 rtlpriv->
stats.ui_link_quality.elements[
439 rtlpriv->
stats.ui_link_quality.index++] =
442 if (rtlpriv->
stats.ui_link_quality.index >=
444 rtlpriv->
stats.ui_link_quality.index = 0;
446 tmpval = rtlpriv->
stats.ui_link_quality.total_val /
447 rtlpriv->
stats.ui_link_quality.total_num;
448 rtlpriv->
stats.signal_quality = tmpval;
450 rtlpriv->
stats.last_sigstrength_inpercent = tmpval;
452 rtl_92s_process_streams(hw, pstats);
458 static void _rtl92se_process_phyinfo(
struct ieee80211_hw *hw,
467 _rtl92se_process_ui_rssi(hw, pcurrent_stats);
468 _rtl92se_process_pwdb(hw, pcurrent_stats);
469 _rtl92se_process_ui_link_quality(hw, pcurrent_stats);
472 static void _rtl92se_translate_rx_signal_stuff(
struct ieee80211_hw *hw,
484 bool packet_matchbssid, packet_toself, packet_beacon;
495 ether_addr_equal(mac->
bssid,
501 packet_toself = packet_matchbssid &&
502 ether_addr_equal(praddr, rtlefuse->
dev_addr);
504 if (ieee80211_is_beacon(fc))
505 packet_beacon =
true;
507 _rtl92se_query_rxphystatus(hw, pstats, pdesc, p_drvinfo,
508 packet_matchbssid, packet_toself, packet_beacon);
509 _rtl92se_process_phyinfo(hw, tmp_buf, pstats);
519 bool first_ampdu =
false;
542 rx_status->
freq = hw->
conf.channel->center_freq;
543 rx_status->
band = hw->
conf.channel->band;
567 if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
581 _rtl92se_translate_rx_signal_stuff(hw, skb, stats, pdesc,
603 u8 *pdesc = pdesc_tx;
606 u8 reserved_macid = 0;
607 u8 fw_qsel = _rtl92se_map_hwqueue_to_fwqueue(skb, hw_queue);
631 if (rtlpriv->
dm.useramask) {
633 if (ptcb_desc->
mac_id < 32) {
635 reserved_macid |= ptcb_desc->
mac_id;
711 keyconf = info->
control.hw_key;
712 switch (keyconf->
cipher) {
744 if (!ieee80211_is_data_qos(fc))
765 bool firstseg,
bool lastseg,
struct sk_buff *skb)
828 RT_ASSERT(
false,
"ERR txdesc :%d not process\n",
848 RT_ASSERT(
false,
"ERR rxdesc :%d not process\n",
868 RT_ASSERT(
false,
"ERR txdesc :%d not process\n",
881 RT_ASSERT(
false,
"ERR rxdesc :%d not process\n",
892 rtl_write_word(rtlpriv,
TP_POLL,
BIT(0) << (hw_queue));