Skip to content

Commit

Permalink
wifi: rtw89: adjust DIG threshold to reduce false alarm
Browse files Browse the repository at this point in the history
Use RSSI without subtracting offset as packet detection lower bound and
set an absolute minimal threshold. It's equivalent to setting a higher
noise floor, thereby reducing false alarm and improving interference
endurance.

Signed-off-by: Eric Huang <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
Link: https://patch.msgid.link/[email protected]
(cherry picked from commit 9ecb64ed07efda833608d1095a5c0ee92179f035)
  • Loading branch information
Eric Huang authored and opsiff committed Nov 7, 2024
1 parent 78357d8 commit 6334b37
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions drivers/net/wireless/realtek/rtw89/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -5384,7 +5384,7 @@ static void rtw89_phy_dig_update_para(struct rtw89_dev *rtwdev)
memcpy(dig->igi_rssi_th, igi_rssi_th, sizeof(dig->igi_rssi_th));
}

static const u8 pd_low_th_offset = 20, dynamic_igi_min = 0x20;
static const u8 pd_low_th_offset = 16, dynamic_igi_min = 0x20;
static const u8 igi_max_performance_mode = 0x5a;
static const u8 dynamic_pd_threshold_max;

Expand Down Expand Up @@ -5682,38 +5682,47 @@ void rtw89_phy_dig_reset(struct rtw89_dev *rtwdev)
}

#define IGI_RSSI_MIN 10
#define ABS_IGI_MIN 0xc
void rtw89_phy_dig(struct rtw89_dev *rtwdev)
{
struct rtw89_dig_info *dig = &rtwdev->dig;
bool is_linked = rtwdev->total_sta_assoc > 0;
u8 igi_min;

if (unlikely(dig->bypass_dig)) {
dig->bypass_dig = false;
return;
}

rtw89_phy_dig_update_rssi_info(rtwdev);

if (!dig->is_linked_pre && is_linked) {
rtw89_debug(rtwdev, RTW89_DBG_DIG, "First connected\n");
rtw89_phy_dig_update_para(rtwdev);
dig->igi_fa_rssi = dig->igi_rssi;
} else if (dig->is_linked_pre && !is_linked) {
rtw89_debug(rtwdev, RTW89_DBG_DIG, "First disconnected\n");
rtw89_phy_dig_update_para(rtwdev);
dig->igi_fa_rssi = dig->igi_rssi;
}
dig->is_linked_pre = is_linked;

rtw89_phy_dig_igi_offset_by_env(rtwdev);
rtw89_phy_dig_update_rssi_info(rtwdev);

dig->dyn_igi_min = (dig->igi_rssi > IGI_RSSI_MIN) ?
dig->igi_rssi - IGI_RSSI_MIN : 0;
dig->dyn_igi_max = dig->dyn_igi_min + IGI_OFFSET_MAX;
dig->igi_fa_rssi = dig->dyn_igi_min + dig->fa_rssi_ofst;
igi_min = max_t(int, dig->igi_rssi - IGI_RSSI_MIN, 0);
dig->dyn_igi_max = min(igi_min + IGI_OFFSET_MAX, igi_max_performance_mode);
dig->dyn_igi_min = max(igi_min, ABS_IGI_MIN);

dig->igi_fa_rssi = clamp(dig->igi_fa_rssi, dig->dyn_igi_min,
dig->dyn_igi_max);
if (dig->dyn_igi_max >= dig->dyn_igi_min) {
dig->igi_fa_rssi += dig->fa_rssi_ofst;
dig->igi_fa_rssi = clamp(dig->igi_fa_rssi, dig->dyn_igi_min,
dig->dyn_igi_max);
} else {
dig->igi_fa_rssi = dig->dyn_igi_max;
}

rtw89_debug(rtwdev, RTW89_DBG_DIG,
"rssi=%03d, dyn(max,min)=(%d,%d), final_rssi=%d\n",
"rssi=%03d, dyn_joint(max,min)=(%d,%d), final_rssi=%d\n",
dig->igi_rssi, dig->dyn_igi_max, dig->dyn_igi_min,
dig->igi_fa_rssi);

Expand Down

0 comments on commit 6334b37

Please sign in to comment.