Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp946168rdb; Wed, 6 Dec 2023 04:46:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDRcrkSPPg7HYqIVn/P8RHuZmvaB+Iq+JjX703J+xf2IU25mWt5YH10v+mccZy+Yu4XQfE X-Received: by 2002:a17:902:b20a:b0:1d0:81a3:4434 with SMTP id t10-20020a170902b20a00b001d081a34434mr804845plr.41.1701866786618; Wed, 06 Dec 2023 04:46:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701866786; cv=none; d=google.com; s=arc-20160816; b=F6alkseNt+povpOHTzca6WHeK9GMWgPpih12k8TrMzZ+6WZefN1IpCf7YhzfMcSCMK s7Mg9e/QQv0x2COIyg0eFI5vvqBZQoApjbF8I3ogURsoRN/UMMzX6vbRM/B3rKFQT5jP TKY1nJY+8VdnprJgC/OKsd5WdNDyoDu6GKel7k3ygurjVWq/VzqK7ZdgphZJQ98Top64 FM/PCBapyz5jWaJj1JkQYF7diIV7PEr7KhmyD0yzhd++r+F0TJIAi6GWA/pUAkI39E/d Z0OK4L5F2xvi0hot4Ja8PFE7AwMc+p9fzHo/YA6IXCNlOyxlJ5V0qH4NKc7Iq1fl3wrJ rFXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=6nJ5+Lcykt19ojQtPZpP749Qcu4DzNEgynlISUgq78w=; fh=119R0DZRwIns1LRpqAK2A6izyPVjL4TEe6VydCwW0T8=; b=FqPbBiwq3H4HBME0EEBW4LqZqTLEZODndyRvjcSs/vowVgjT5rGktWWyf1/vEkIpaI yQ6hW2shNrzAJ5bvBBpr4Y6SjuLllEAO/TgW9Zy8kHKTLdUalAe1o8jl5dY9cC/7j0QC bVh0UwHIuSZ8tvB+azGOF4k+4KtwCZSLNqz5PVk8rHXw1CINM/giAdECZhrJ6DdUN71J Di5K0i6TeHS4TEOeWl8Hp1GehmVFn3UPt+Qajrw6vHSCcMrUh5NI3AdPRuPH/Bshrym5 0XDdXhBzwNSE9hdx7uH54NwDz7AopahosPYGuPGa4k3L+XtQePUIFw7Rh356Wx4CIGQ0 VZCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless+bounces-492-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-492-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y8-20020a17090322c800b001cdf038845csi11601856plg.10.2023.12.06.04.46.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 04:46:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-492-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless+bounces-492-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-492-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 17600281C2B for ; Wed, 6 Dec 2023 12:46:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF4163715D; Wed, 6 Dec 2023 12:46:21 +0000 (UTC) X-Original-To: linux-wireless@vger.kernel.org Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 213DF1A2 for ; Wed, 6 Dec 2023 04:46:17 -0800 (PST) X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 3B6CkBK613602919, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36505.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/2.95/5.92) with ESMTPS id 3B6CkBK613602919 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 Dec 2023 20:46:11 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36505.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.32; Wed, 6 Dec 2023 20:46:12 +0800 Received: from [127.0.1.1] (172.16.20.124) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 6 Dec 2023 20:46:11 +0800 From: Ping-Ke Shih To: CC: Subject: [PATCH 6/6] wifi: rtw89: phy: print out RFK log with formatted string Date: Wed, 6 Dec 2023 20:44:48 +0800 Message-ID: <20231206124448.10537-7-pkshih@realtek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231206124448.10537-1-pkshih@realtek.com> References: <20231206124448.10537-1-pkshih@realtek.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: RTEXMBS02.realtek.com.tw (172.21.6.95) To RTEXMBS04.realtek.com.tw (172.21.6.97) X-KSE-ServerInfo: RTEXMBS04.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-ServerInfo: RTEXH36505.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback 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 --- drivers/net/wireless/realtek/rtw89/fw.h | 5 ++++ drivers/net/wireless/realtek/rtw89/phy.c | 38 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw89/fw.h b/drivers/net/wireless/realtek/rtw89/fw.h index e2dc9e1604d1..ce27c8f326e7 100644 --- a/drivers/net/wireless/realtek/rtw89/fw.h +++ b/drivers/net/wireless/realtek/rtw89/fw.h @@ -3733,6 +3733,11 @@ struct rtw89_c2h_rf_log_hdr { u8 content[]; } __packed; +struct rtw89_c2h_rf_run_log { + __le32 fmt_idx; + __le32 arg[4]; +} __packed; + struct rtw89_c2h_rf_dpk_rpt_log { u8 ver; u8 idx[2]; diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c index 496160f72755..bafc7b1cc104 100644 --- a/drivers/net/wireless/realtek/rtw89/phy.c +++ b/drivers/net/wireless/realtek/rtw89/phy.c @@ -2566,6 +2566,38 @@ static void rtw89_phy_c2h_rfk_rpt_log(struct rtw89_dev *rtwdev, "unexpected RFK func %d report log with length %d\n", func, len); } +static bool rtw89_phy_c2h_rfk_run_log(struct rtw89_dev *rtwdev, + enum rtw89_phy_c2h_rfk_log_func func, + void *content, u16 len) +{ + struct rtw89_fw_elm_info *elm_info = &rtwdev->fw.elm_info; + const struct rtw89_c2h_rf_run_log *log = content; + const struct rtw89_fw_element_hdr *elm; + u32 fmt_idx; + u16 offset; + + if (sizeof(*log) != len) + return false; + + if (!elm_info->rfk_log_fmt) + return false; + + elm = elm_info->rfk_log_fmt->elm[func]; + fmt_idx = le32_to_cpu(log->fmt_idx); + if (!elm || fmt_idx >= elm->u.rfk_log_fmt.nr) + return false; + + offset = le16_to_cpu(elm->u.rfk_log_fmt.offset[fmt_idx]); + if (offset == 0) + return false; + + rtw89_debug(rtwdev, RTW89_DBG_RFK, &elm->u.common.contents[offset], + le32_to_cpu(log->arg[0]), le32_to_cpu(log->arg[1]), + le32_to_cpu(log->arg[2]), le32_to_cpu(log->arg[3])); + + return true; +} + static void rtw89_phy_c2h_rfk_log(struct rtw89_dev *rtwdev, struct sk_buff *c2h, u32 len, enum rtw89_phy_c2h_rfk_log_func func, const char *rfk_name) @@ -2575,6 +2607,7 @@ static void rtw89_phy_c2h_rfk_log(struct rtw89_dev *rtwdev, struct sk_buff *c2h, void *log_ptr = c2h_hdr; u16 content_len; u16 chunk_len; + bool handled; if (!rtw89_debug_is_enabled(rtwdev, RTW89_DBG_RFK)) return; @@ -2592,6 +2625,11 @@ static void rtw89_phy_c2h_rfk_log(struct rtw89_dev *rtwdev, struct sk_buff *c2h, switch (log_hdr->type) { case RTW89_RF_RUN_LOG: + handled = rtw89_phy_c2h_rfk_run_log(rtwdev, func, + log_hdr->content, content_len); + if (handled) + break; + rtw89_debug(rtwdev, RTW89_DBG_RFK, "%s run: %*ph\n", rfk_name, content_len, log_hdr->content); break; -- 2.25.1