diff mbox series

[1/8] Wifi: rtw89: recognize log format from firmware file

Message ID 20230801021127.15919-2-pkshih@realtek.com (mailing list archive)
State Accepted
Commit 0520841960dee1e53449019d4409f0c3c03fb64f
Delegated to: Kalle Valo
Headers show
Series wifi: rtw89: support more formats of firmware file | expand

Commit Message

Ping-Ke Shih Aug. 1, 2023, 2:11 a.m. UTC
From: Chin-Yen Lee <timlee@realtek.com>

Firmware log format is an element of multi-firmware file
and used for firmware to provide log with formatted text.
Driver needs to recognize it in advance if it exists.

Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtw89/core.h |  4 ++++
 drivers/net/wireless/realtek/rtw89/fw.c   | 25 +++++++++++++++--------
 2 files changed, 21 insertions(+), 8 deletions(-)

Comments

Kalle Valo Aug. 3, 2023, 12:07 p.m. UTC | #1
Ping-Ke Shih <pkshih@realtek.com> wrote:

> From: Chin-Yen Lee <timlee@realtek.com>
> 
> Firmware log format is an element of multi-firmware file
> and used for firmware to provide log with formatted text.
> Driver needs to recognize it in advance if it exists.
> 
> Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>

8 patches applied to wireless-next.git, thanks.

0520841960de wifi: rtw89: recognize log format from firmware file
cad2bd8a136c wifi: rtw89: support firmware log with formatted text
1b073b350d24 wifi: rtw89: introduce v1 format of firmware header
12b1a12548eb wifi: rtw89: add firmware parser for v1 format
7d112665982b wifi: rtw89: add firmware suit for BB MCU 0/1
a337d4331fd6 wifi: rtw89: introduce infrastructure of firmware elements
894747206893 wifi: rtw89: add to parse firmware elements of BB and RF tables
dd59c6a32b71 wifi: rtw89: return failure if needed firmware elements are not recognized
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index d2c67db97db1a..a3acc0bb18926 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -3347,6 +3347,7 @@  enum rtw89_fw_type {
 	RTW89_FW_NORMAL = 1,
 	RTW89_FW_WOWLAN = 3,
 	RTW89_FW_NORMAL_CE = 5,
+	RTW89_FW_LOGFMT = 255,
 };
 
 enum rtw89_fw_feature {
@@ -3406,6 +3407,7 @@  struct rtw89_fw_info {
 	u8 c2h_counter;
 	struct rtw89_fw_suit normal;
 	struct rtw89_fw_suit wowlan;
+	struct rtw89_fw_suit logfmt;
 	bool fw_log_enable;
 	u32 feature_map;
 };
@@ -4942,6 +4944,8 @@  static inline struct rtw89_fw_suit *rtw89_fw_suit_get(struct rtw89_dev *rtwdev,
 
 	if (type == RTW89_FW_WOWLAN)
 		return &fw_info->wowlan;
+	else if (type == RTW89_FW_LOGFMT)
+		return &fw_info->logfmt;
 	return &fw_info->normal;
 }
 
diff --git a/drivers/net/wireless/realtek/rtw89/fw.c b/drivers/net/wireless/realtek/rtw89/fw.c
index 9637f5e48d842..6260bebf305e5 100644
--- a/drivers/net/wireless/realtek/rtw89/fw.c
+++ b/drivers/net/wireless/realtek/rtw89/fw.c
@@ -178,19 +178,22 @@  int rtw89_mfw_recognize(struct rtw89_dev *rtwdev, enum rtw89_fw_type type,
 
 	for (i = 0; i < mfw_hdr->fw_nr; i++) {
 		mfw_info = &mfw_hdr->info[i];
-		if (mfw_info->cv != rtwdev->hal.cv ||
-		    mfw_info->type != type ||
-		    mfw_info->mp)
-			continue;
-
-		fw_suit->data = mfw + le32_to_cpu(mfw_info->shift);
-		fw_suit->size = le32_to_cpu(mfw_info->size);
-		return 0;
+		if (mfw_info->type == type) {
+			if (mfw_info->cv == rtwdev->hal.cv && !mfw_info->mp)
+				goto found;
+			if (type == RTW89_FW_LOGFMT)
+				goto found;
+		}
 	}
 
 	if (!nowarn)
 		rtw89_err(rtwdev, "no suitable firmware found\n");
 	return -ENOENT;
+
+found:
+	fw_suit->data = mfw + le32_to_cpu(mfw_info->shift);
+	fw_suit->size = le32_to_cpu(mfw_info->size);
+	return 0;
 }
 
 static void rtw89_fw_update_ver(struct rtw89_dev *rtwdev,
@@ -199,6 +202,9 @@  static void rtw89_fw_update_ver(struct rtw89_dev *rtwdev,
 {
 	const struct rtw89_fw_hdr *hdr = (const struct rtw89_fw_hdr *)fw_suit->data;
 
+	if (type == RTW89_FW_LOGFMT)
+		return;
+
 	fw_suit->major_ver = le32_get_bits(hdr->w1, FW_HDR_W1_MAJOR_VERSION);
 	fw_suit->minor_ver = le32_get_bits(hdr->w1, FW_HDR_W1_MINOR_VERSION);
 	fw_suit->sub_ver = le32_get_bits(hdr->w1, FW_HDR_W1_SUBVERSION);
@@ -386,6 +392,9 @@  int rtw89_fw_recognize(struct rtw89_dev *rtwdev)
 	/* It still works if wowlan firmware isn't existing. */
 	__rtw89_fw_recognize(rtwdev, RTW89_FW_WOWLAN, false);
 
+	/* It still works if log format file isn't existing. */
+	__rtw89_fw_recognize(rtwdev, RTW89_FW_LOGFMT, true);
+
 	rtw89_fw_recognize_features(rtwdev);
 
 	rtw89_coex_recognize_ver(rtwdev);