wifi: rtw89: debugfs: support multiple adapters debugging
The rtw89 uses debugfs to access registers and driver states. To get a range of registers, the range value is set and stored to a variable, and get the set of register values by the stored range. However, the variable is a static global variable, which multiple adapters will be a problem, so move the variable to adapter context rtw89_dev. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20240816115700.17390-1-pkshih@realtek.com
This commit is contained in:
parent
77c977327d
commit
a3f00afc25
@ -4767,6 +4767,8 @@ EXPORT_SYMBOL(rtw89_core_register);
|
|||||||
void rtw89_core_unregister(struct rtw89_dev *rtwdev)
|
void rtw89_core_unregister(struct rtw89_dev *rtwdev)
|
||||||
{
|
{
|
||||||
rtw89_core_unregister_hw(rtwdev);
|
rtw89_core_unregister_hw(rtwdev);
|
||||||
|
|
||||||
|
rtw89_debugfs_deinit(rtwdev);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(rtw89_core_unregister);
|
EXPORT_SYMBOL(rtw89_core_unregister);
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ struct rtw89_efuse_block_cfg;
|
|||||||
struct rtw89_h2c_rf_tssi;
|
struct rtw89_h2c_rf_tssi;
|
||||||
struct rtw89_fw_txpwr_track_cfg;
|
struct rtw89_fw_txpwr_track_cfg;
|
||||||
struct rtw89_phy_rfk_log_fmt;
|
struct rtw89_phy_rfk_log_fmt;
|
||||||
|
struct rtw89_debugfs;
|
||||||
|
|
||||||
extern const struct ieee80211_ops rtw89_ops;
|
extern const struct ieee80211_ops rtw89_ops;
|
||||||
|
|
||||||
@ -5529,6 +5530,8 @@ struct rtw89_dev {
|
|||||||
struct napi_struct napi;
|
struct napi_struct napi;
|
||||||
int napi_budget_countdown;
|
int napi_budget_countdown;
|
||||||
|
|
||||||
|
struct rtw89_debugfs *debugfs;
|
||||||
|
|
||||||
/* HCI related data, keep last */
|
/* HCI related data, keep last */
|
||||||
u8 priv[] __aligned(sizeof(void *));
|
u8 priv[] __aligned(sizeof(void *));
|
||||||
};
|
};
|
||||||
|
@ -52,6 +52,27 @@ struct rtw89_debugfs_priv {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct rtw89_debugfs {
|
||||||
|
struct rtw89_debugfs_priv read_reg;
|
||||||
|
struct rtw89_debugfs_priv write_reg;
|
||||||
|
struct rtw89_debugfs_priv read_rf;
|
||||||
|
struct rtw89_debugfs_priv write_rf;
|
||||||
|
struct rtw89_debugfs_priv rf_reg_dump;
|
||||||
|
struct rtw89_debugfs_priv txpwr_table;
|
||||||
|
struct rtw89_debugfs_priv mac_reg_dump;
|
||||||
|
struct rtw89_debugfs_priv mac_mem_dump;
|
||||||
|
struct rtw89_debugfs_priv mac_dbg_port_dump;
|
||||||
|
struct rtw89_debugfs_priv send_h2c;
|
||||||
|
struct rtw89_debugfs_priv early_h2c;
|
||||||
|
struct rtw89_debugfs_priv fw_crash;
|
||||||
|
struct rtw89_debugfs_priv btc_info;
|
||||||
|
struct rtw89_debugfs_priv btc_manual;
|
||||||
|
struct rtw89_debugfs_priv fw_log_manual;
|
||||||
|
struct rtw89_debugfs_priv phy_info;
|
||||||
|
struct rtw89_debugfs_priv stations;
|
||||||
|
struct rtw89_debugfs_priv disable_dm;
|
||||||
|
};
|
||||||
|
|
||||||
static const u16 rtw89_rate_info_bw_to_mhz_map[] = {
|
static const u16 rtw89_rate_info_bw_to_mhz_map[] = {
|
||||||
[RATE_INFO_BW_20] = 20,
|
[RATE_INFO_BW_20] = 20,
|
||||||
[RATE_INFO_BW_40] = 40,
|
[RATE_INFO_BW_40] = 40,
|
||||||
@ -3463,9 +3484,9 @@ static ssize_t rtw89_debug_priv_btc_manual_set(struct file *filp,
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t rtw89_debug_fw_log_manual_set(struct file *filp,
|
static ssize_t rtw89_debug_priv_fw_log_manual_set(struct file *filp,
|
||||||
const char __user *user_buf,
|
const char __user *user_buf,
|
||||||
size_t count, loff_t *loff)
|
size_t count, loff_t *loff)
|
||||||
{
|
{
|
||||||
struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
|
struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
|
||||||
struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
|
struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
|
||||||
@ -3854,92 +3875,55 @@ rtw89_debug_priv_disable_dm_set(struct file *filp, const char __user *user_buf,
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_read_reg = {
|
#define rtw89_debug_priv_get(name) \
|
||||||
.cb_read = rtw89_debug_priv_read_reg_get,
|
{ \
|
||||||
.cb_write = rtw89_debug_priv_read_reg_select,
|
.cb_read = rtw89_debug_priv_ ##name## _get, \
|
||||||
};
|
}
|
||||||
|
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_write_reg = {
|
#define rtw89_debug_priv_set(name) \
|
||||||
.cb_write = rtw89_debug_priv_write_reg_set,
|
{ \
|
||||||
};
|
.cb_write = rtw89_debug_priv_ ##name## _set, \
|
||||||
|
}
|
||||||
|
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_read_rf = {
|
#define rtw89_debug_priv_select_and_get(name) \
|
||||||
.cb_read = rtw89_debug_priv_read_rf_get,
|
{ \
|
||||||
.cb_write = rtw89_debug_priv_read_rf_select,
|
.cb_write = rtw89_debug_priv_ ##name## _select, \
|
||||||
};
|
.cb_read = rtw89_debug_priv_ ##name## _get, \
|
||||||
|
}
|
||||||
|
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_write_rf = {
|
#define rtw89_debug_priv_set_and_get(name) \
|
||||||
.cb_write = rtw89_debug_priv_write_rf_set,
|
{ \
|
||||||
};
|
.cb_write = rtw89_debug_priv_ ##name## _set, \
|
||||||
|
.cb_read = rtw89_debug_priv_ ##name## _get, \
|
||||||
|
}
|
||||||
|
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_rf_reg_dump = {
|
static const struct rtw89_debugfs rtw89_debugfs_templ = {
|
||||||
.cb_read = rtw89_debug_priv_rf_reg_dump_get,
|
.read_reg = rtw89_debug_priv_select_and_get(read_reg),
|
||||||
};
|
.write_reg = rtw89_debug_priv_set(write_reg),
|
||||||
|
.read_rf = rtw89_debug_priv_select_and_get(read_rf),
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_txpwr_table = {
|
.write_rf = rtw89_debug_priv_set(write_rf),
|
||||||
.cb_read = rtw89_debug_priv_txpwr_table_get,
|
.rf_reg_dump = rtw89_debug_priv_get(rf_reg_dump),
|
||||||
};
|
.txpwr_table = rtw89_debug_priv_get(txpwr_table),
|
||||||
|
.mac_reg_dump = rtw89_debug_priv_select_and_get(mac_reg_dump),
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_mac_reg_dump = {
|
.mac_mem_dump = rtw89_debug_priv_select_and_get(mac_mem_dump),
|
||||||
.cb_read = rtw89_debug_priv_mac_reg_dump_get,
|
.mac_dbg_port_dump = rtw89_debug_priv_select_and_get(mac_dbg_port_dump),
|
||||||
.cb_write = rtw89_debug_priv_mac_reg_dump_select,
|
.send_h2c = rtw89_debug_priv_set(send_h2c),
|
||||||
};
|
.early_h2c = rtw89_debug_priv_set_and_get(early_h2c),
|
||||||
|
.fw_crash = rtw89_debug_priv_set_and_get(fw_crash),
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_mac_mem_dump = {
|
.btc_info = rtw89_debug_priv_get(btc_info),
|
||||||
.cb_read = rtw89_debug_priv_mac_mem_dump_get,
|
.btc_manual = rtw89_debug_priv_set(btc_manual),
|
||||||
.cb_write = rtw89_debug_priv_mac_mem_dump_select,
|
.fw_log_manual = rtw89_debug_priv_set(fw_log_manual),
|
||||||
};
|
.phy_info = rtw89_debug_priv_get(phy_info),
|
||||||
|
.stations = rtw89_debug_priv_get(stations),
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_mac_dbg_port_dump = {
|
.disable_dm = rtw89_debug_priv_set_and_get(disable_dm),
|
||||||
.cb_read = rtw89_debug_priv_mac_dbg_port_dump_get,
|
|
||||||
.cb_write = rtw89_debug_priv_mac_dbg_port_dump_select,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_send_h2c = {
|
|
||||||
.cb_write = rtw89_debug_priv_send_h2c_set,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_early_h2c = {
|
|
||||||
.cb_read = rtw89_debug_priv_early_h2c_get,
|
|
||||||
.cb_write = rtw89_debug_priv_early_h2c_set,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_fw_crash = {
|
|
||||||
.cb_read = rtw89_debug_priv_fw_crash_get,
|
|
||||||
.cb_write = rtw89_debug_priv_fw_crash_set,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_btc_info = {
|
|
||||||
.cb_read = rtw89_debug_priv_btc_info_get,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_btc_manual = {
|
|
||||||
.cb_write = rtw89_debug_priv_btc_manual_set,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_fw_log_manual = {
|
|
||||||
.cb_write = rtw89_debug_fw_log_manual_set,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_phy_info = {
|
|
||||||
.cb_read = rtw89_debug_priv_phy_info_get,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_stations = {
|
|
||||||
.cb_read = rtw89_debug_priv_stations_get,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct rtw89_debugfs_priv rtw89_debug_priv_disable_dm = {
|
|
||||||
.cb_read = rtw89_debug_priv_disable_dm_get,
|
|
||||||
.cb_write = rtw89_debug_priv_disable_dm_set,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define rtw89_debugfs_add(name, mode, fopname, parent) \
|
#define rtw89_debugfs_add(name, mode, fopname, parent) \
|
||||||
do { \
|
do { \
|
||||||
rtw89_debug_priv_ ##name.rtwdev = rtwdev; \
|
struct rtw89_debugfs_priv *priv = &rtwdev->debugfs->name; \
|
||||||
if (!debugfs_create_file(#name, mode, \
|
priv->rtwdev = rtwdev; \
|
||||||
parent, &rtw89_debug_priv_ ##name, \
|
if (IS_ERR(debugfs_create_file(#name, mode, parent, priv, \
|
||||||
&file_ops_ ##fopname)) \
|
&file_ops_ ##fopname))) \
|
||||||
pr_debug("Unable to initialize debugfs:%s\n", #name); \
|
pr_debug("Unable to initialize debugfs:%s\n", #name); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@ -3950,13 +3934,9 @@ static struct rtw89_debugfs_priv rtw89_debug_priv_disable_dm = {
|
|||||||
#define rtw89_debugfs_add_r(name) \
|
#define rtw89_debugfs_add_r(name) \
|
||||||
rtw89_debugfs_add(name, S_IFREG | 0444, single_r, debugfs_topdir)
|
rtw89_debugfs_add(name, S_IFREG | 0444, single_r, debugfs_topdir)
|
||||||
|
|
||||||
void rtw89_debugfs_init(struct rtw89_dev *rtwdev)
|
static
|
||||||
|
void rtw89_debugfs_add_sec0(struct rtw89_dev *rtwdev, struct dentry *debugfs_topdir)
|
||||||
{
|
{
|
||||||
struct dentry *debugfs_topdir;
|
|
||||||
|
|
||||||
debugfs_topdir = debugfs_create_dir("rtw89",
|
|
||||||
rtwdev->hw->wiphy->debugfsdir);
|
|
||||||
|
|
||||||
rtw89_debugfs_add_rw(read_reg);
|
rtw89_debugfs_add_rw(read_reg);
|
||||||
rtw89_debugfs_add_w(write_reg);
|
rtw89_debugfs_add_w(write_reg);
|
||||||
rtw89_debugfs_add_rw(read_rf);
|
rtw89_debugfs_add_rw(read_rf);
|
||||||
@ -3966,6 +3946,11 @@ void rtw89_debugfs_init(struct rtw89_dev *rtwdev)
|
|||||||
rtw89_debugfs_add_rw(mac_reg_dump);
|
rtw89_debugfs_add_rw(mac_reg_dump);
|
||||||
rtw89_debugfs_add_rw(mac_mem_dump);
|
rtw89_debugfs_add_rw(mac_mem_dump);
|
||||||
rtw89_debugfs_add_rw(mac_dbg_port_dump);
|
rtw89_debugfs_add_rw(mac_dbg_port_dump);
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void rtw89_debugfs_add_sec1(struct rtw89_dev *rtwdev, struct dentry *debugfs_topdir)
|
||||||
|
{
|
||||||
rtw89_debugfs_add_w(send_h2c);
|
rtw89_debugfs_add_w(send_h2c);
|
||||||
rtw89_debugfs_add_rw(early_h2c);
|
rtw89_debugfs_add_rw(early_h2c);
|
||||||
rtw89_debugfs_add_rw(fw_crash);
|
rtw89_debugfs_add_rw(fw_crash);
|
||||||
@ -3976,6 +3961,27 @@ void rtw89_debugfs_init(struct rtw89_dev *rtwdev)
|
|||||||
rtw89_debugfs_add_r(stations);
|
rtw89_debugfs_add_r(stations);
|
||||||
rtw89_debugfs_add_rw(disable_dm);
|
rtw89_debugfs_add_rw(disable_dm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rtw89_debugfs_init(struct rtw89_dev *rtwdev)
|
||||||
|
{
|
||||||
|
struct dentry *debugfs_topdir;
|
||||||
|
|
||||||
|
rtwdev->debugfs = kmemdup(&rtw89_debugfs_templ,
|
||||||
|
sizeof(rtw89_debugfs_templ), GFP_KERNEL);
|
||||||
|
if (!rtwdev->debugfs)
|
||||||
|
return;
|
||||||
|
|
||||||
|
debugfs_topdir = debugfs_create_dir("rtw89",
|
||||||
|
rtwdev->hw->wiphy->debugfsdir);
|
||||||
|
|
||||||
|
rtw89_debugfs_add_sec0(rtwdev, debugfs_topdir);
|
||||||
|
rtw89_debugfs_add_sec1(rtwdev, debugfs_topdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rtw89_debugfs_deinit(struct rtw89_dev *rtwdev)
|
||||||
|
{
|
||||||
|
kfree(rtwdev->debugfs);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_RTW89_DEBUGMSG
|
#ifdef CONFIG_RTW89_DEBUGMSG
|
||||||
|
@ -49,8 +49,10 @@ enum rtw89_debug_mac_reg_sel {
|
|||||||
|
|
||||||
#ifdef CONFIG_RTW89_DEBUGFS
|
#ifdef CONFIG_RTW89_DEBUGFS
|
||||||
void rtw89_debugfs_init(struct rtw89_dev *rtwdev);
|
void rtw89_debugfs_init(struct rtw89_dev *rtwdev);
|
||||||
|
void rtw89_debugfs_deinit(struct rtw89_dev *rtwdev);
|
||||||
#else
|
#else
|
||||||
static inline void rtw89_debugfs_init(struct rtw89_dev *rtwdev) {}
|
static inline void rtw89_debugfs_init(struct rtw89_dev *rtwdev) {}
|
||||||
|
static inline void rtw89_debugfs_deinit(struct rtw89_dev *rtwdev) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define rtw89_info(rtwdev, a...) dev_info((rtwdev)->dev, ##a)
|
#define rtw89_info(rtwdev, a...) dev_info((rtwdev)->dev, ##a)
|
||||||
|
Loading…
Reference in New Issue
Block a user