wifi: rtw89: Set default CQM config if not present
authorPo-Hao Huang <phhuang@realtek.com>
Fri, 19 Jan 2024 08:14:56 +0000 (16:14 +0800)
committerKalle Valo <kvalo@kernel.org>
Tue, 23 Jan 2024 11:38:15 +0000 (13:38 +0200)
When wpa_supplicant is initiated by users and not by NetworkManager,
the CQM configuration might not be set. Without this setting, ICs
with connection monitor handled by driver won't detect connection
loss. To fix this we prepare a default setting upon associated at
first, then update again if any is given later.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240119081501.25223-4-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/core.c
drivers/net/wireless/realtek/rtw89/fw.c
drivers/net/wireless/realtek/rtw89/fw.h

index aefb5a0..29df1ea 100644 (file)
@@ -3493,6 +3493,8 @@ int rtw89_core_sta_assoc(struct rtw89_dev *rtwdev,
                        rtw89_warn(rtwdev, "failed to send h2c general packet\n");
                        return ret;
                }
+
+               rtw89_fw_h2c_set_bcn_fltr_cfg(rtwdev, vif, true);
        }
 
        return ret;
index d967120..ed0ac37 100644 (file)
@@ -3216,6 +3216,8 @@ int rtw89_fw_h2c_set_bcn_fltr_cfg(struct rtw89_dev *rtwdev,
 {
        struct rtw89_vif *rtwvif = vif_to_rtwvif_safe(vif);
        struct ieee80211_bss_conf *bss_conf = vif ? &vif->bss_conf : NULL;
+       s32 thold = RTW89_DEFAULT_CQM_THOLD;
+       u32 hyst = RTW89_DEFAULT_CQM_HYST;
        struct rtw89_h2c_bcnfltr *h2c;
        u32 len = sizeof(*h2c);
        struct sk_buff *skb;
@@ -3236,14 +3238,19 @@ int rtw89_fw_h2c_set_bcn_fltr_cfg(struct rtw89_dev *rtwdev,
        skb_put(skb, len);
        h2c = (struct rtw89_h2c_bcnfltr *)skb->data;
 
+       if (bss_conf->cqm_rssi_hyst)
+               hyst = bss_conf->cqm_rssi_hyst;
+       if (bss_conf->cqm_rssi_thold)
+               thold = bss_conf->cqm_rssi_thold;
+
        h2c->w0 = le32_encode_bits(connect, RTW89_H2C_BCNFLTR_W0_MON_RSSI) |
                  le32_encode_bits(connect, RTW89_H2C_BCNFLTR_W0_MON_BCN) |
                  le32_encode_bits(connect, RTW89_H2C_BCNFLTR_W0_MON_EN) |
                  le32_encode_bits(RTW89_BCN_FLTR_OFFLOAD_MODE_DEFAULT,
                                   RTW89_H2C_BCNFLTR_W0_MODE) |
                  le32_encode_bits(RTW89_BCN_LOSS_CNT, RTW89_H2C_BCNFLTR_W0_BCN_LOSS_CNT) |
-                 le32_encode_bits(bss_conf->cqm_rssi_hyst, RTW89_H2C_BCNFLTR_W0_RSSI_HYST) |
-                 le32_encode_bits(bss_conf->cqm_rssi_thold + MAX_RSSI,
+                 le32_encode_bits(hyst, RTW89_H2C_BCNFLTR_W0_RSSI_HYST) |
+                 le32_encode_bits(thold + MAX_RSSI,
                                   RTW89_H2C_BCNFLTR_W0_RSSI_THRESHOLD) |
                  le32_encode_bits(rtwvif->mac_id, RTW89_H2C_BCNFLTR_W0_MAC_ID);
 
index f64fba1..5d51611 100644 (file)
@@ -188,6 +188,9 @@ enum rtw89_p2pps_action {
        RTW89_P2P_ACT_TERMINATE = 3,
 };
 
+#define RTW89_DEFAULT_CQM_HYST 4
+#define RTW89_DEFAULT_CQM_THOLD -70
+
 enum rtw89_bcn_fltr_offload_mode {
        RTW89_BCN_FLTR_OFFLOAD_MODE_0 = 0,
        RTW89_BCN_FLTR_OFFLOAD_MODE_1,