Blame SOURCES/0028-rtw89-coex-Add-MAC-API-to-get-BT-polluted-counter.patch

56e3f4
From 28c1d4c167238010c6bfee8c86d9964a889b9acd Mon Sep 17 00:00:00 2001
56e3f4
From: =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= <ihuguet@redhat.com>
56e3f4
Date: Fri, 21 Jan 2022 08:49:04 +0100
56e3f4
Subject: [PATCH 28/36] rtw89: coex: Add MAC API to get BT polluted counter
56e3f4
MIME-Version: 1.0
56e3f4
Content-Type: text/plain; charset=UTF-8
56e3f4
Content-Transfer-Encoding: 8bit
56e3f4
56e3f4
Bugzilla: http://bugzilla.redhat.com/2033291
56e3f4
56e3f4
commit 8c7e9ceb5bacec842784e5568c36769e97d96acb
56e3f4
Author: Ching-Te Ku <ku920601@realtek.com>
56e3f4
Date:   Thu Dec 9 16:32:25 2021 +0800
56e3f4
56e3f4
    rtw89: coex: Add MAC API to get BT polluted counter
56e3f4
56e3f4
    Add function to get and parse BT polluted counter.
56e3f4
    When WLAN Tx was dropped by BT, the packet will be marked as BT polluted.
56e3f4
56e3f4
    Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
56e3f4
    Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
56e3f4
    Signed-off-by: Kalle Valo <kvalo@kernel.org>
56e3f4
    Link: https://lore.kernel.org/r/20211209083229.10815-4-pkshih@realtek.com
56e3f4
56e3f4
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
56e3f4
---
56e3f4
 drivers/net/wireless/realtek/rtw89/coex.c |  6 ++++--
56e3f4
 drivers/net/wireless/realtek/rtw89/core.h |  1 +
56e3f4
 drivers/net/wireless/realtek/rtw89/mac.c  | 12 ++++++++++++
56e3f4
 drivers/net/wireless/realtek/rtw89/mac.h  |  1 +
56e3f4
 4 files changed, 18 insertions(+), 2 deletions(-)
56e3f4
56e3f4
diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c
56e3f4
index c8f912e7344d..8763114eab27 100644
56e3f4
--- a/drivers/net/wireless/realtek/rtw89/coex.c
56e3f4
+++ b/drivers/net/wireless/realtek/rtw89/coex.c
56e3f4
@@ -1126,6 +1126,9 @@ static u32 _chk_btc_report(struct rtw89_dev *rtwdev,
56e3f4
 		wl->ver_info.fw_coex = prpt->wl_fw_coex_ver;
56e3f4
 		wl->ver_info.fw = prpt->wl_fw_ver;
56e3f4
 		dm->wl_fw_cx_offload = !!(prpt->wl_fw_cx_offload);
56e3f4
+
56e3f4
+		btc->cx.cnt_bt[BTC_BCNT_POLUT] =
56e3f4
+			rtw89_mac_get_plt_cnt(rtwdev, RTW89_MAC_0);
56e3f4
 	}
56e3f4
 
56e3f4
 	if (rpt_type >= BTC_RPT_TYPE_BT_VER &&
56e3f4
@@ -4798,7 +4801,6 @@ static void _show_bt_info(struct rtw89_dev *rtwdev, struct seq_file *m)
56e3f4
 	struct rtw89_btc_module *module = &btc->mdinfo;
56e3f4
 	struct rtw89_btc_bt_link_info *bt_linfo = &bt->link_info;
56e3f4
 	u8 *afh = bt_linfo->afh_map;
56e3f4
-	u16 polt_cnt = 0;
56e3f4
 
56e3f4
 	if (!(btc->dm.coex_info_map & BTC_COEX_INFO_BT))
56e3f4
 		return;
56e3f4
@@ -4884,7 +4886,7 @@ static void _show_bt_info(struct rtw89_dev *rtwdev, struct seq_file *m)
56e3f4
 		   " %-15s : Hi-rx = %d, Hi-tx = %d, Lo-rx = %d, Lo-tx = %d (bt_polut_wl_tx = %d)\n",
56e3f4
 		   "[trx_req_cnt]", cx->cnt_bt[BTC_BCNT_HIPRI_RX],
56e3f4
 		   cx->cnt_bt[BTC_BCNT_HIPRI_TX], cx->cnt_bt[BTC_BCNT_LOPRI_RX],
56e3f4
-		   cx->cnt_bt[BTC_BCNT_LOPRI_TX], polt_cnt);
56e3f4
+		   cx->cnt_bt[BTC_BCNT_LOPRI_TX], cx->cnt_bt[BTC_BCNT_POLUT]);
56e3f4
 }
56e3f4
 
56e3f4
 #define CASE_BTC_RSN_STR(e) case BTC_RSN_ ## e: return #e
56e3f4
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
56e3f4
index c03e3a13bd56..7c84556ec4ad 100644
56e3f4
--- a/drivers/net/wireless/realtek/rtw89/core.h
56e3f4
+++ b/drivers/net/wireless/realtek/rtw89/core.h
56e3f4
@@ -805,6 +805,7 @@ enum rtw89_btc_bt_state_cnt {
56e3f4
 	BTC_BCNT_HIPRI_RX,
56e3f4
 	BTC_BCNT_LOPRI_TX,
56e3f4
 	BTC_BCNT_LOPRI_RX,
56e3f4
+	BTC_BCNT_POLUT,
56e3f4
 	BTC_BCNT_RATECHG,
56e3f4
 	BTC_BCNT_NUM
56e3f4
 };
56e3f4
diff --git a/drivers/net/wireless/realtek/rtw89/mac.c b/drivers/net/wireless/realtek/rtw89/mac.c
56e3f4
index 999459489e92..b98c47e9ecfe 100644
56e3f4
--- a/drivers/net/wireless/realtek/rtw89/mac.c
56e3f4
+++ b/drivers/net/wireless/realtek/rtw89/mac.c
56e3f4
@@ -3450,6 +3450,18 @@ bool rtw89_mac_get_ctrl_path(struct rtw89_dev *rtwdev)
56e3f4
 	return FIELD_GET(B_AX_LTE_MUX_CTRL_PATH >> 24, val);
56e3f4
 }
56e3f4
 
56e3f4
+u16 rtw89_mac_get_plt_cnt(struct rtw89_dev *rtwdev, u8 band)
56e3f4
+{
56e3f4
+	u32 reg;
56e3f4
+	u16 cnt;
56e3f4
+
56e3f4
+	reg = rtw89_mac_reg_by_idx(R_AX_BT_PLT, band);
56e3f4
+	cnt = rtw89_read32_mask(rtwdev, reg, B_AX_BT_PLT_PKT_CNT_MASK);
56e3f4
+	rtw89_write16_set(rtwdev, reg, B_AX_BT_PLT_RST);
56e3f4
+
56e3f4
+	return cnt;
56e3f4
+}
56e3f4
+
56e3f4
 static void rtw89_mac_bfee_ctrl(struct rtw89_dev *rtwdev, u8 mac_idx, bool en)
56e3f4
 {
56e3f4
 	u32 reg;
56e3f4
diff --git a/drivers/net/wireless/realtek/rtw89/mac.h b/drivers/net/wireless/realtek/rtw89/mac.h
56e3f4
index 94cd29bd83d7..b7d13edf7dd1 100644
56e3f4
--- a/drivers/net/wireless/realtek/rtw89/mac.h
56e3f4
+++ b/drivers/net/wireless/realtek/rtw89/mac.h
56e3f4
@@ -788,6 +788,7 @@ int rtw89_mac_coex_init(struct rtw89_dev *rtwdev, const struct rtw89_mac_ax_coex
56e3f4
 int rtw89_mac_cfg_gnt(struct rtw89_dev *rtwdev,
56e3f4
 		      const struct rtw89_mac_ax_coex_gnt *gnt_cfg);
56e3f4
 int rtw89_mac_cfg_plt(struct rtw89_dev *rtwdev, struct rtw89_mac_ax_plt *plt);
56e3f4
+u16 rtw89_mac_get_plt_cnt(struct rtw89_dev *rtwdev, u8 band);
56e3f4
 void rtw89_mac_cfg_sb(struct rtw89_dev *rtwdev, u32 val);
56e3f4
 u32 rtw89_mac_get_sb(struct rtw89_dev *rtwdev);
56e3f4
 bool rtw89_mac_get_ctrl_path(struct rtw89_dev *rtwdev);
56e3f4
-- 
56e3f4
2.13.6
56e3f4