Commit 108ec4da authored by Felix Fietkau's avatar Felix Fietkau Committed by Kalle Valo

mt76: add a debugfs file to dump agc calibration information

Useful for debugging gain adjustment issues triggered by signal strength
changes.
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 8e31f0d3
...@@ -72,6 +72,7 @@ struct mt76x2_calibration { ...@@ -72,6 +72,7 @@ struct mt76x2_calibration {
int avg_rssi[MT_MAX_CHAINS]; int avg_rssi[MT_MAX_CHAINS];
int avg_rssi_all; int avg_rssi_all;
u16 false_cca;
s8 agc_gain_adjust; s8 agc_gain_adjust;
s8 low_gain; s8 low_gain;
......
...@@ -115,6 +115,18 @@ static const struct file_operations fops_dfs_stat = { ...@@ -115,6 +115,18 @@ static const struct file_operations fops_dfs_stat = {
.release = single_release, .release = single_release,
}; };
static int read_agc(struct seq_file *file, void *data)
{
struct mt76x2_dev *dev = dev_get_drvdata(file->private);
seq_printf(file, "avg_rssi: %d\n", dev->cal.avg_rssi_all);
seq_printf(file, "low_gain: %d\n", dev->cal.low_gain);
seq_printf(file, "false_cca: %d\n", dev->cal.false_cca);
seq_printf(file, "agc_gain_adjust: %d\n", dev->cal.agc_gain_adjust);
return 0;
}
void mt76x2_init_debugfs(struct mt76x2_dev *dev) void mt76x2_init_debugfs(struct mt76x2_dev *dev)
{ {
struct dentry *dir; struct dentry *dir;
...@@ -130,4 +142,6 @@ void mt76x2_init_debugfs(struct mt76x2_dev *dev) ...@@ -130,4 +142,6 @@ void mt76x2_init_debugfs(struct mt76x2_dev *dev)
debugfs_create_file("dfs_stats", 0400, dir, dev, &fops_dfs_stat); debugfs_create_file("dfs_stats", 0400, dir, dev, &fops_dfs_stat);
debugfs_create_devm_seqfile(dev->mt76.dev, "txpower", dir, debugfs_create_devm_seqfile(dev->mt76.dev, "txpower", dir,
read_txpower); read_txpower);
debugfs_create_devm_seqfile(dev->mt76.dev, "agc", dir, read_agc);
} }
...@@ -488,6 +488,7 @@ mt76x2_phy_adjust_vga_gain(struct mt76x2_dev *dev) ...@@ -488,6 +488,7 @@ mt76x2_phy_adjust_vga_gain(struct mt76x2_dev *dev)
u8 limit = dev->cal.low_gain > 0 ? 16 : 4; u8 limit = dev->cal.low_gain > 0 ? 16 : 4;
false_cca = FIELD_GET(MT_RX_STAT_1_CCA_ERRORS, mt76_rr(dev, MT_RX_STAT_1)); false_cca = FIELD_GET(MT_RX_STAT_1_CCA_ERRORS, mt76_rr(dev, MT_RX_STAT_1));
dev->cal.false_cca = false_cca;
if (false_cca > 800 && dev->cal.agc_gain_adjust < limit) if (false_cca > 800 && dev->cal.agc_gain_adjust < limit)
dev->cal.agc_gain_adjust += 2; dev->cal.agc_gain_adjust += 2;
else if (false_cca < 10 && dev->cal.agc_gain_adjust > 0) else if (false_cca < 10 && dev->cal.agc_gain_adjust > 0)
......
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