Skip to content

Commit f0536b0

Browse files
Ping-Ke ShihKalle Valo
authored andcommitted
wifi: rtw89: phy: print out RFK log with formatted string
With formatted string loaded from firmware file, we can use the formatted string ID and get corresponding string, and then use regular rtw89_debug() to show the message if debug mask of RFK is enabled. If the string ID doesn't present, fallback to print plain hexadecimal. Signed-off-by: Ping-Ke Shih <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://msgid.link/[email protected]
1 parent edd77bb commit f0536b0

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

drivers/net/wireless/realtek/rtw89/fw.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3733,6 +3733,11 @@ struct rtw89_c2h_rf_log_hdr {
37333733
u8 content[];
37343734
} __packed;
37353735

3736+
struct rtw89_c2h_rf_run_log {
3737+
__le32 fmt_idx;
3738+
__le32 arg[4];
3739+
} __packed;
3740+
37363741
struct rtw89_c2h_rf_dpk_rpt_log {
37373742
u8 ver;
37383743
u8 idx[2];

drivers/net/wireless/realtek/rtw89/phy.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,6 +2566,38 @@ static void rtw89_phy_c2h_rfk_rpt_log(struct rtw89_dev *rtwdev,
25662566
"unexpected RFK func %d report log with length %d\n", func, len);
25672567
}
25682568

2569+
static bool rtw89_phy_c2h_rfk_run_log(struct rtw89_dev *rtwdev,
2570+
enum rtw89_phy_c2h_rfk_log_func func,
2571+
void *content, u16 len)
2572+
{
2573+
struct rtw89_fw_elm_info *elm_info = &rtwdev->fw.elm_info;
2574+
const struct rtw89_c2h_rf_run_log *log = content;
2575+
const struct rtw89_fw_element_hdr *elm;
2576+
u32 fmt_idx;
2577+
u16 offset;
2578+
2579+
if (sizeof(*log) != len)
2580+
return false;
2581+
2582+
if (!elm_info->rfk_log_fmt)
2583+
return false;
2584+
2585+
elm = elm_info->rfk_log_fmt->elm[func];
2586+
fmt_idx = le32_to_cpu(log->fmt_idx);
2587+
if (!elm || fmt_idx >= elm->u.rfk_log_fmt.nr)
2588+
return false;
2589+
2590+
offset = le16_to_cpu(elm->u.rfk_log_fmt.offset[fmt_idx]);
2591+
if (offset == 0)
2592+
return false;
2593+
2594+
rtw89_debug(rtwdev, RTW89_DBG_RFK, &elm->u.common.contents[offset],
2595+
le32_to_cpu(log->arg[0]), le32_to_cpu(log->arg[1]),
2596+
le32_to_cpu(log->arg[2]), le32_to_cpu(log->arg[3]));
2597+
2598+
return true;
2599+
}
2600+
25692601
static void rtw89_phy_c2h_rfk_log(struct rtw89_dev *rtwdev, struct sk_buff *c2h,
25702602
u32 len, enum rtw89_phy_c2h_rfk_log_func func,
25712603
const char *rfk_name)
@@ -2575,6 +2607,7 @@ static void rtw89_phy_c2h_rfk_log(struct rtw89_dev *rtwdev, struct sk_buff *c2h,
25752607
void *log_ptr = c2h_hdr;
25762608
u16 content_len;
25772609
u16 chunk_len;
2610+
bool handled;
25782611

25792612
if (!rtw89_debug_is_enabled(rtwdev, RTW89_DBG_RFK))
25802613
return;
@@ -2592,6 +2625,11 @@ static void rtw89_phy_c2h_rfk_log(struct rtw89_dev *rtwdev, struct sk_buff *c2h,
25922625

25932626
switch (log_hdr->type) {
25942627
case RTW89_RF_RUN_LOG:
2628+
handled = rtw89_phy_c2h_rfk_run_log(rtwdev, func,
2629+
log_hdr->content, content_len);
2630+
if (handled)
2631+
break;
2632+
25952633
rtw89_debug(rtwdev, RTW89_DBG_RFK, "%s run: %*ph\n",
25962634
rfk_name, content_len, log_hdr->content);
25972635
break;

0 commit comments

Comments
 (0)