]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw89: fw: parse firmware element of DIAG_MAC
authorPing-Ke Shih <pkshih@realtek.com>
Tue, 11 Nov 2025 02:24:46 +0000 (10:24 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Thu, 13 Nov 2025 01:34:39 +0000 (09:34 +0800)
The firmware element ID 28 is a set of rules to diagnose if MAC get
abnormal. The latter patch will use these rules via debugfs to know
the status.

The element contains rules with their textual messages shown as below:

   +------------------------------------+
   |                                    |
   |                +-----------+       |
   |                | rule_size |-------|----------+
   +----------------+-----------+-------+ --       |
   |             rule[0]                |   \      |
   |             rule[1]                |   |  <---+
   |                :                   |   /
   +------------------------------------+ --
   | msg[0]      msg[1]                 |  each msg has variable length
   |        msg[2]    msg[3] ...        |  (with address align 2)
   | ...                                |
   +------------------------------------+

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20251111022452.28093-3-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/fw.c
drivers/net/wireless/realtek/rtw89/fw.h

index e6584462f6c0fadd5501c693bd788a4ec13451b4..34c135269627bd2d4fda388130e5b8d6bf167088 100644 (file)
@@ -4728,6 +4728,7 @@ struct rtw89_fw_elm_info {
        struct rtw89_phy_rfk_log_fmt *rfk_log_fmt;
        const struct rtw89_regd_data *regd;
        const struct rtw89_fw_element_hdr *afe;
+       const struct rtw89_fw_element_hdr *diag_mac;
 };
 
 enum rtw89_fw_mss_dev_type {
index 96f0463e66d62407e9f9b177c2253d4be58dbf26..515e9f0983803780f504d17fe58281ce619beb9f 100644 (file)
@@ -1298,6 +1298,18 @@ int rtw89_build_afe_pwr_seq_from_elm(struct rtw89_dev *rtwdev,
        return 0;
 }
 
+static
+int rtw89_recognize_diag_mac_from_elm(struct rtw89_dev *rtwdev,
+                                     const struct rtw89_fw_element_hdr *elm,
+                                     const union rtw89_fw_element_arg arg)
+{
+       struct rtw89_fw_elm_info *elm_info = &rtwdev->fw.elm_info;
+
+       elm_info->diag_mac = elm;
+
+       return 0;
+}
+
 static const struct rtw89_fw_element_handler __fw_element_handlers[] = {
        [RTW89_FW_ELEMENT_ID_BBMCU0] = {__rtw89_fw_recognize_from_elm,
                                        { .fw_type = RTW89_FW_BBMCU0 }, NULL},
@@ -1386,6 +1398,9 @@ static const struct rtw89_fw_element_handler __fw_element_handlers[] = {
        [RTW89_FW_ELEMENT_ID_AFE_PWR_SEQ] = {
                rtw89_build_afe_pwr_seq_from_elm, {}, "AFE",
        },
+       [RTW89_FW_ELEMENT_ID_DIAG_MAC] = {
+               rtw89_recognize_diag_mac_from_elm, {}, NULL,
+       },
 };
 
 int rtw89_fw_recognize_elements(struct rtw89_dev *rtwdev)
index 3105802063683ab4ffeb270759db5d5377599593..6620256e3f22e16b8d942b37fd06ffe20ca12f22 100644 (file)
@@ -4026,6 +4026,7 @@ enum rtw89_fw_element_id {
        RTW89_FW_ELEMENT_ID_TXPWR_DA_LMT_RU_5GHZ = 25,
        RTW89_FW_ELEMENT_ID_TXPWR_DA_LMT_RU_6GHZ = 26,
        RTW89_FW_ELEMENT_ID_AFE_PWR_SEQ = 27,
+       RTW89_FW_ELEMENT_ID_DIAG_MAC = 28,
 
        RTW89_FW_ELEMENT_ID_NUM,
 };
@@ -4203,6 +4204,11 @@ struct rtw89_fw_element_hdr {
                                __le32 val;
                        } __packed infos[];
                } __packed afe;
+               struct {
+                       __le32 rule_size;
+                       u8 rsvd[4];
+                       u8 rules_and_msgs[];
+               } __packed diag_mac;
                struct __rtw89_fw_txpwr_element txpwr;
                struct __rtw89_fw_regd_element regd;
        } __packed u;