mt76: add a debugfs file to dump agc calibration information
authorFelix Fietkau <nbd@nbd.name>
Thu, 21 Jun 2018 09:17:59 +0000 (11:17 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Wed, 27 Jun 2018 16:15:06 +0000 (19:15 +0300)
Useful for debugging gain adjustment issues triggered by signal strength
changes.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/mediatek/mt76/mt76x2.h
drivers/net/wireless/mediatek/mt76/mt76x2_debugfs.c
drivers/net/wireless/mediatek/mt76/mt76x2_phy.c

index 06ca5a7..21de116 100644 (file)
@@ -72,6 +72,7 @@ struct mt76x2_calibration {
        int avg_rssi[MT_MAX_CHAINS];
        int avg_rssi_all;
 
+       u16 false_cca;
        s8 agc_gain_adjust;
        s8 low_gain;
 
index 955ea3e..3f86e01 100644 (file)
@@ -115,6 +115,18 @@ static const struct file_operations fops_dfs_stat = {
        .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)
 {
        struct dentry *dir;
@@ -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_devm_seqfile(dev->mt76.dev, "txpower", dir,
                                    read_txpower);
+
+       debugfs_create_devm_seqfile(dev->mt76.dev, "agc", dir, read_agc);
 }
index 9c7b19c..94943ae 100644 (file)
@@ -488,6 +488,7 @@ mt76x2_phy_adjust_vga_gain(struct mt76x2_dev *dev)
        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));
+       dev->cal.false_cca = false_cca;
        if (false_cca > 800 && dev->cal.agc_gain_adjust < limit)
                dev->cal.agc_gain_adjust += 2;
        else if (false_cca < 10 && dev->cal.agc_gain_adjust > 0)