]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: rtw89: phy: add C2H event handler for report of FW scan
authorKuan-Chung Chen <damon.chen@realtek.com>
Wed, 30 Apr 2025 05:51:56 +0000 (13:51 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Mon, 5 May 2025 02:23:14 +0000 (10:23 +0800)
Newer firmware will notify driver of the Packet Detection (PD)
value on the channel after switch channels during FW scan.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250430055157.13623-2-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/fw.h
drivers/net/wireless/realtek/rtw89/phy.c
drivers/net/wireless/realtek/rtw89/phy.h

index c7337bf46686fbb544b053f4491d056090ad7226..bb1b653085cf9492d8d7f5a8aaef8dd20e358cce 100644 (file)
@@ -3623,6 +3623,19 @@ struct rtw89_c2h_ra_rpt {
 #define RTW89_C2H_RA_RPT_W3_MD_SEL_B2 BIT(15)
 #define RTW89_C2H_RA_RPT_W3_BW_B2 BIT(16)
 
+struct rtw89_c2h_fw_scan_rpt {
+       struct rtw89_c2h_hdr hdr;
+       u8 phy_idx;
+       u8 band;
+       u8 center_ch;
+       u8 ofdm_pd_idx; /* in unit of 2 dBm */
+#define PD_LOWER_BOUND_BASE 102
+       s8 cck_pd_idx;
+       u8 rsvd0;
+       u8 rsvd1;
+       u8 rsvd2;
+} __packed;
+
 /* For WiFi 6 chips:
  *   VHT, HE, HT-old: [6:4]: NSS, [3:0]: MCS
  *   HT-new: [6:5]: NA, [4:0]: MCS
index 270f40e44c0b052401bc2112953a03be5526f908..e358cb83dae802ee264813cfd29a47193967771c 100644 (file)
@@ -3023,6 +3023,35 @@ void (* const rtw89_phy_c2h_ra_handler[])(struct rtw89_dev *rtwdev,
        [RTW89_PHY_C2H_FUNC_TXSTS] = NULL,
 };
 
+static void
+rtw89_phy_c2h_lowrt_rty(struct rtw89_dev *rtwdev, struct sk_buff *c2h, u32 len)
+{
+}
+
+static void
+rtw89_phy_c2h_fw_scan_rpt(struct rtw89_dev *rtwdev, struct sk_buff *c2h, u32 len)
+{
+       const struct rtw89_c2h_fw_scan_rpt *c2h_rpt =
+               (const struct rtw89_c2h_fw_scan_rpt *)c2h->data;
+
+       rtw89_debug(rtwdev, RTW89_DBG_DIG,
+                   "%s: band: %u, op_chan: %u, PD_low_bd(ofdm, cck): (-%d, %d), phy_idx: %u\n",
+                   __func__, c2h_rpt->band, c2h_rpt->center_ch,
+                   PD_LOWER_BOUND_BASE - (c2h_rpt->ofdm_pd_idx << 1),
+                   c2h_rpt->cck_pd_idx, c2h_rpt->phy_idx);
+}
+
+static
+void (* const rtw89_phy_c2h_dm_handler[])(struct rtw89_dev *rtwdev,
+                                         struct sk_buff *c2h, u32 len) = {
+       [RTW89_PHY_C2H_DM_FUNC_FW_TEST] = NULL,
+       [RTW89_PHY_C2H_DM_FUNC_FW_TRIG_TX_RPT] = NULL,
+       [RTW89_PHY_C2H_DM_FUNC_SIGB] = NULL,
+       [RTW89_PHY_C2H_DM_FUNC_LOWRT_RTY] = rtw89_phy_c2h_lowrt_rty,
+       [RTW89_PHY_C2H_DM_FUNC_MCC_DIG] = NULL,
+       [RTW89_PHY_C2H_DM_FUNC_FW_SCAN] = rtw89_phy_c2h_fw_scan_rpt,
+};
+
 static void rtw89_phy_c2h_rfk_rpt_log(struct rtw89_dev *rtwdev,
                                      enum rtw89_phy_c2h_rfk_log_func func,
                                      void *content, u16 len)
@@ -3558,9 +3587,9 @@ void rtw89_phy_c2h_handle(struct rtw89_dev *rtwdev, struct sk_buff *skb,
                        handler = rtw89_phy_c2h_rfk_report_handler[func];
                break;
        case RTW89_PHY_C2H_CLASS_DM:
-               if (func == RTW89_PHY_C2H_DM_FUNC_LOWRT_RTY)
-                       return;
-               fallthrough;
+               if (func < ARRAY_SIZE(rtw89_phy_c2h_dm_handler))
+                       handler = rtw89_phy_c2h_dm_handler[func];
+               break;
        default:
                rtw89_info(rtwdev, "PHY c2h class %d not support\n", class);
                return;
index cafb1a06d7b878d0715cd556ae1c96dc7028935c..5b451f1cfaac40d9b88284b07b1579d8b157e7d8 100644 (file)
@@ -164,6 +164,7 @@ enum rtw89_phy_c2h_dm_func {
        RTW89_PHY_C2H_DM_FUNC_SIGB,
        RTW89_PHY_C2H_DM_FUNC_LOWRT_RTY,
        RTW89_PHY_C2H_DM_FUNC_MCC_DIG,
+       RTW89_PHY_C2H_DM_FUNC_FW_SCAN = 0xc,
        RTW89_PHY_C2H_DM_FUNC_NUM,
 };