Commit 1fe188da authored by Yan-Hsuan Chuang's avatar Yan-Hsuan Chuang Committed by Kalle Valo

rtw88: add a debugfs entry to dump coex's info

Add a new entry "coex_info" in debugfs to dump coex's states for
us to debug on coex's issues.

The basic concept for co-existence (coex, usually for WiFi + BT)
is to decide a strategy based on the current status of WiFi and
BT. So, it means the WiFi driver requires to gather information
from BT side and choose a strategy (TDMA/table/HW settings).

Althrough we can easily check the current status of WiFi, e.g.,
from kernel log or just dump the hardware registers, it is still
very difficult for us to gather so many different types of WiFi
states (such as RFE config, antenna, channel/band, TRX, Power
save). Also we will need BT's information that is stored in
"struct rtw_coex". So it is necessary for us to have a debugfs
that can dump all of the WiFi/BT information required.

Note that to debug on coex related issues, we usually need a
longer period of time of coex_info dump every 2 seconds (for
example, 30 secs, so we should have 15 times of coex_info's
dump).
Signed-off-by: default avatarYan-Hsuan Chuang <yhchuang@realtek.com>
Reviewed-by: default avatarChris Chiu <chiu@endlessm.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200313033008.20070-2-yhchuang@realtek.com
parent cd556e40
This diff is collapsed.
...@@ -46,6 +46,14 @@ ...@@ -46,6 +46,14 @@
(__rssi__ == COEX_RSSI_STATE_LOW || \ (__rssi__ == COEX_RSSI_STATE_LOW || \
__rssi__ == COEX_RSSI_STATE_STAY_LOW ? true : false); }) __rssi__ == COEX_RSSI_STATE_STAY_LOW ? true : false); })
#define GET_COEX_RESP_BT_SUPP_VER(payload) \
le64_get_bits(*((__le64 *)(payload)), GENMASK_ULL(39, 32))
#define GET_COEX_RESP_BT_SUPP_FEAT(payload) \
le64_get_bits(*((__le64 *)(payload)), GENMASK_ULL(39, 24))
#define GET_COEX_RESP_BT_PATCH_VER(payload) \
le64_get_bits(*((__le64 *)(payload)), GENMASK_ULL(55, 24))
#define GET_COEX_RESP_BT_REG_VAL(payload) \
le64_get_bits(*((__le64 *)(payload)), GENMASK_ULL(39, 24))
#define GET_COEX_RESP_BT_SCAN_TYPE(payload) \ #define GET_COEX_RESP_BT_SCAN_TYPE(payload) \
le64_get_bits(*((__le64 *)(payload)), GENMASK(31, 24)) le64_get_bits(*((__le64 *)(payload)), GENMASK(31, 24))
...@@ -367,4 +375,6 @@ void rtw_coex_wl_fwdbginfo_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length); ...@@ -367,4 +375,6 @@ void rtw_coex_wl_fwdbginfo_notify(struct rtw_dev *rtwdev, u8 *buf, u8 length);
void rtw_coex_switchband_notify(struct rtw_dev *rtwdev, u8 type); void rtw_coex_switchband_notify(struct rtw_dev *rtwdev, u8 type);
void rtw_coex_wl_status_change_notify(struct rtw_dev *rtwdev); void rtw_coex_wl_status_change_notify(struct rtw_dev *rtwdev);
void rtw_coex_display_coex_info(struct rtw_dev *rtwdev, struct seq_file *m);
#endif #endif
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include "main.h" #include "main.h"
#include "coex.h"
#include "sec.h" #include "sec.h"
#include "fw.h" #include "fw.h"
#include "debug.h" #include "debug.h"
...@@ -691,6 +692,17 @@ static int rtw_debugfs_get_phy_info(struct seq_file *m, void *v) ...@@ -691,6 +692,17 @@ static int rtw_debugfs_get_phy_info(struct seq_file *m, void *v)
dm_info->ht_ok_cnt, dm_info->ht_err_cnt); dm_info->ht_ok_cnt, dm_info->ht_err_cnt);
seq_printf(m, " * VHT cnt (ok, err) = (%u, %u)\n", seq_printf(m, " * VHT cnt (ok, err) = (%u, %u)\n",
dm_info->vht_ok_cnt, dm_info->vht_err_cnt); dm_info->vht_ok_cnt, dm_info->vht_err_cnt);
return 0;
}
static int rtw_debugfs_get_coex_info(struct seq_file *m, void *v)
{
struct rtw_debugfs_priv *debugfs_priv = m->private;
struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
rtw_coex_display_coex_info(rtwdev, m);
return 0; return 0;
} }
...@@ -784,6 +796,10 @@ static struct rtw_debugfs_priv rtw_debug_priv_phy_info = { ...@@ -784,6 +796,10 @@ static struct rtw_debugfs_priv rtw_debug_priv_phy_info = {
.cb_read = rtw_debugfs_get_phy_info, .cb_read = rtw_debugfs_get_phy_info,
}; };
static struct rtw_debugfs_priv rtw_debug_priv_coex_info = {
.cb_read = rtw_debugfs_get_coex_info,
};
#define rtw_debugfs_add_core(name, mode, fopname, parent) \ #define rtw_debugfs_add_core(name, mode, fopname, parent) \
do { \ do { \
rtw_debug_priv_ ##name.rtwdev = rtwdev; \ rtw_debug_priv_ ##name.rtwdev = rtwdev; \
...@@ -814,6 +830,7 @@ void rtw_debugfs_init(struct rtw_dev *rtwdev) ...@@ -814,6 +830,7 @@ void rtw_debugfs_init(struct rtw_dev *rtwdev)
rtw_debugfs_add_rw(dump_cam); rtw_debugfs_add_rw(dump_cam);
rtw_debugfs_add_rw(rsvd_page); rtw_debugfs_add_rw(rsvd_page);
rtw_debugfs_add_r(phy_info); rtw_debugfs_add_r(phy_info);
rtw_debugfs_add_r(coex_info);
rtw_debugfs_add_r(mac_0); rtw_debugfs_add_r(mac_0);
rtw_debugfs_add_r(mac_1); rtw_debugfs_add_r(mac_1);
rtw_debugfs_add_r(mac_2); rtw_debugfs_add_r(mac_2);
......
...@@ -515,6 +515,18 @@ struct rtw_hw_reg { ...@@ -515,6 +515,18 @@ struct rtw_hw_reg {
u32 mask; u32 mask;
}; };
struct rtw_reg_domain {
u32 addr;
u32 mask;
#define RTW_REG_DOMAIN_MAC32 0
#define RTW_REG_DOMAIN_MAC16 1
#define RTW_REG_DOMAIN_MAC8 2
#define RTW_REG_DOMAIN_RF_A 3
#define RTW_REG_DOMAIN_RF_B 4
#define RTW_REG_DOMAIN_NL 0xFF
u8 domain;
};
struct rtw_backup_info { struct rtw_backup_info {
u8 len; u8 len;
u32 reg; u32 reg;
...@@ -1107,6 +1119,7 @@ struct rtw_chip_info { ...@@ -1107,6 +1119,7 @@ struct rtw_chip_info {
u8 bt_afh_span_bw40; u8 bt_afh_span_bw40;
u8 afh_5g_num; u8 afh_5g_num;
u8 wl_rf_para_num; u8 wl_rf_para_num;
u8 coex_info_hw_regs_num;
const u8 *bt_rssi_step; const u8 *bt_rssi_step;
const u8 *wl_rssi_step; const u8 *wl_rssi_step;
const struct coex_table_para *table_nsant; const struct coex_table_para *table_nsant;
...@@ -1116,6 +1129,7 @@ struct rtw_chip_info { ...@@ -1116,6 +1129,7 @@ struct rtw_chip_info {
const struct coex_rf_para *wl_rf_para_tx; const struct coex_rf_para *wl_rf_para_tx;
const struct coex_rf_para *wl_rf_para_rx; const struct coex_rf_para *wl_rf_para_rx;
const struct coex_5g_afh_map *afh_5g; const struct coex_5g_afh_map *afh_5g;
const struct rtw_reg_domain *coex_info_hw_regs;
}; };
enum rtw_coex_bt_state_cnt { enum rtw_coex_bt_state_cnt {
...@@ -1162,6 +1176,7 @@ struct rtw_coex_rfe { ...@@ -1162,6 +1176,7 @@ struct rtw_coex_rfe {
struct rtw_coex_dm { struct rtw_coex_dm {
bool cur_ps_tdma_on; bool cur_ps_tdma_on;
bool cur_wl_rx_low_gain_en; bool cur_wl_rx_low_gain_en;
bool ignore_wl_act;
u8 reason; u8 reason;
u8 bt_rssi_state[4]; u8 bt_rssi_state[4];
...@@ -1242,6 +1257,9 @@ struct rtw_coex_stat { ...@@ -1242,6 +1257,9 @@ struct rtw_coex_stat {
u32 bt_supported_version; u32 bt_supported_version;
u32 bt_supported_feature; u32 bt_supported_feature;
u32 patch_ver;
u16 bt_reg_vendor_ae;
u16 bt_reg_vendor_ac;
s8 bt_rssi; s8 bt_rssi;
u8 kt_ver; u8 kt_ver;
u8 gnt_workaround_state; u8 gnt_workaround_state;
......
...@@ -2371,6 +2371,33 @@ static const struct rtw_pwr_track_tbl rtw8822b_rtw_pwr_track_tbl = { ...@@ -2371,6 +2371,33 @@ static const struct rtw_pwr_track_tbl rtw8822b_rtw_pwr_track_tbl = {
.pwrtrk_2g_ccka_p = rtw8822b_pwrtrk_2g_cck_a_p, .pwrtrk_2g_ccka_p = rtw8822b_pwrtrk_2g_cck_a_p,
}; };
static const struct rtw_reg_domain coex_info_hw_regs_8822b[] = {
{0xcb0, MASKDWORD, RTW_REG_DOMAIN_MAC32},
{0xcb4, MASKDWORD, RTW_REG_DOMAIN_MAC32},
{0xcba, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
{0xcbd, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
{0xc58, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
{0xcbd, BIT(0), RTW_REG_DOMAIN_MAC8},
{0, 0, RTW_REG_DOMAIN_NL},
{0x430, MASKDWORD, RTW_REG_DOMAIN_MAC32},
{0x434, MASKDWORD, RTW_REG_DOMAIN_MAC32},
{0x42a, MASKLWORD, RTW_REG_DOMAIN_MAC16},
{0x426, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
{0x45e, BIT(3), RTW_REG_DOMAIN_MAC8},
{0x454, MASKLWORD, RTW_REG_DOMAIN_MAC16},
{0, 0, RTW_REG_DOMAIN_NL},
{0x4c, BIT(24) | BIT(23), RTW_REG_DOMAIN_MAC32},
{0x64, BIT(0), RTW_REG_DOMAIN_MAC8},
{0x4c6, BIT(4), RTW_REG_DOMAIN_MAC8},
{0x40, BIT(5), RTW_REG_DOMAIN_MAC8},
{0x1, RFREG_MASK, RTW_REG_DOMAIN_RF_B},
{0, 0, RTW_REG_DOMAIN_NL},
{0x550, MASKDWORD, RTW_REG_DOMAIN_MAC32},
{0x522, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
{0x953, BIT(1), RTW_REG_DOMAIN_MAC8},
{0xc50, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
};
struct rtw_chip_info rtw8822b_hw_spec = { struct rtw_chip_info rtw8822b_hw_spec = {
.ops = &rtw8822b_ops, .ops = &rtw8822b_ops,
.id = RTW_CHIP_TYPE_8822B, .id = RTW_CHIP_TYPE_8822B,
...@@ -2439,6 +2466,9 @@ struct rtw_chip_info rtw8822b_hw_spec = { ...@@ -2439,6 +2466,9 @@ struct rtw_chip_info rtw8822b_hw_spec = {
.bt_afh_span_bw40 = 0x36, .bt_afh_span_bw40 = 0x36,
.afh_5g_num = ARRAY_SIZE(afh_5g_8822b), .afh_5g_num = ARRAY_SIZE(afh_5g_8822b),
.afh_5g = afh_5g_8822b, .afh_5g = afh_5g_8822b,
.coex_info_hw_regs_num = ARRAY_SIZE(coex_info_hw_regs_8822b),
.coex_info_hw_regs = coex_info_hw_regs_8822b,
}; };
EXPORT_SYMBOL(rtw8822b_hw_spec); EXPORT_SYMBOL(rtw8822b_hw_spec);
......
...@@ -4092,6 +4092,31 @@ static const struct wiphy_wowlan_support rtw_wowlan_stub_8822c = { ...@@ -4092,6 +4092,31 @@ static const struct wiphy_wowlan_support rtw_wowlan_stub_8822c = {
}; };
#endif #endif
static const struct rtw_reg_domain coex_info_hw_regs_8822c[] = {
{0x1860, BIT(3), RTW_REG_DOMAIN_MAC8},
{0x4160, BIT(3), RTW_REG_DOMAIN_MAC8},
{0x1c32, BIT(6), RTW_REG_DOMAIN_MAC8},
{0x1c38, BIT(28), RTW_REG_DOMAIN_MAC32},
{0, 0, RTW_REG_DOMAIN_NL},
{0x430, MASKDWORD, RTW_REG_DOMAIN_MAC32},
{0x434, MASKDWORD, RTW_REG_DOMAIN_MAC32},
{0x42a, MASKLWORD, RTW_REG_DOMAIN_MAC16},
{0x426, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
{0x45e, BIT(3), RTW_REG_DOMAIN_MAC8},
{0x454, MASKLWORD, RTW_REG_DOMAIN_MAC16},
{0, 0, RTW_REG_DOMAIN_NL},
{0x4c, BIT(24) | BIT(23), RTW_REG_DOMAIN_MAC32},
{0x64, BIT(0), RTW_REG_DOMAIN_MAC8},
{0x4c6, BIT(4), RTW_REG_DOMAIN_MAC8},
{0x40, BIT(5), RTW_REG_DOMAIN_MAC8},
{0x1, RFREG_MASK, RTW_REG_DOMAIN_RF_B},
{0, 0, RTW_REG_DOMAIN_NL},
{0x550, MASKDWORD, RTW_REG_DOMAIN_MAC32},
{0x522, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
{0x953, BIT(1), RTW_REG_DOMAIN_MAC8},
{0xc50, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
};
struct rtw_chip_info rtw8822c_hw_spec = { struct rtw_chip_info rtw8822c_hw_spec = {
.ops = &rtw8822c_ops, .ops = &rtw8822c_ops,
.id = RTW_CHIP_TYPE_8822C, .id = RTW_CHIP_TYPE_8822C,
...@@ -4168,6 +4193,9 @@ struct rtw_chip_info rtw8822c_hw_spec = { ...@@ -4168,6 +4193,9 @@ struct rtw_chip_info rtw8822c_hw_spec = {
.bt_afh_span_bw40 = 0x36, .bt_afh_span_bw40 = 0x36,
.afh_5g_num = ARRAY_SIZE(afh_5g_8822c), .afh_5g_num = ARRAY_SIZE(afh_5g_8822c),
.afh_5g = afh_5g_8822c, .afh_5g = afh_5g_8822c,
.coex_info_hw_regs_num = ARRAY_SIZE(coex_info_hw_regs_8822c),
.coex_info_hw_regs = coex_info_hw_regs_8822c,
}; };
EXPORT_SYMBOL(rtw8822c_hw_spec); EXPORT_SYMBOL(rtw8822c_hw_spec);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment