mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
mt76x2: fix tracking rssi for dynamic gain adjustment
Only use unicast rssi, to avoid counting signal data from other networks. Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/kfifo.h>
|
||||
#include <linux/average.h>
|
||||
|
||||
#define MT7662_FIRMWARE "mt7662.bin"
|
||||
#define MT7662_ROM_PATCH "mt7662_rom_patch.bin"
|
||||
@@ -47,6 +48,8 @@
|
||||
#include "mt76x2_mac.h"
|
||||
#include "mt76x2_dfs.h"
|
||||
|
||||
DECLARE_EWMA(signal, 10, 8)
|
||||
|
||||
struct mt76x2_mcu {
|
||||
struct mutex mutex;
|
||||
|
||||
@@ -66,13 +69,14 @@ struct mt76x2_rx_freq_cal {
|
||||
struct mt76x2_calibration {
|
||||
struct mt76x2_rx_freq_cal rx;
|
||||
|
||||
struct ewma_signal rssi;
|
||||
u32 rssi_count;
|
||||
|
||||
u8 agc_gain_init[MT_MAX_CHAINS];
|
||||
u8 agc_gain_cur[MT_MAX_CHAINS];
|
||||
|
||||
int avg_rssi[MT_MAX_CHAINS];
|
||||
int avg_rssi_all;
|
||||
|
||||
u16 false_cca;
|
||||
s8 avg_rssi_all;
|
||||
s8 agc_gain_adjust;
|
||||
s8 low_gain;
|
||||
|
||||
|
||||
@@ -657,6 +657,7 @@ struct mt76x2_dev *mt76x2_alloc_device(struct device *pdev)
|
||||
mdev->drv = &drv_ops;
|
||||
mutex_init(&dev->mutex);
|
||||
spin_lock_init(&dev->irq_lock);
|
||||
ewma_signal_init(&dev->cal.rssi);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
@@ -374,6 +374,11 @@ int mt76x2_mac_process_rx(struct mt76x2_dev *dev, struct sk_buff *skb,
|
||||
status->tid = FIELD_GET(MT_RXWI_TID, tid_sn);
|
||||
status->seqno = FIELD_GET(MT_RXWI_SN, tid_sn);
|
||||
|
||||
if (unicast) {
|
||||
ewma_signal_add(&dev->cal.rssi, status->signal);
|
||||
dev->cal.rssi_count++;
|
||||
}
|
||||
|
||||
return mt76x2_mac_process_rate(status, rate);
|
||||
}
|
||||
|
||||
|
||||
+10
-9
@@ -502,19 +502,20 @@ mt76x2_phy_adjust_vga_gain(struct mt76x2_dev *dev)
|
||||
static void
|
||||
mt76x2_phy_update_channel_gain(struct mt76x2_dev *dev)
|
||||
{
|
||||
u32 val = mt76_rr(dev, MT_BBP(AGC, 20));
|
||||
int rssi0 = (s8) FIELD_GET(MT_BBP_AGC20_RSSI0, val);
|
||||
int rssi1 = (s8) FIELD_GET(MT_BBP_AGC20_RSSI1, val);
|
||||
u8 *gain = dev->cal.agc_gain_init;
|
||||
u8 gain_delta;
|
||||
int low_gain;
|
||||
u32 rssi_count;
|
||||
u32 val;
|
||||
|
||||
dev->cal.avg_rssi[0] = (dev->cal.avg_rssi[0] * 15) / 16 +
|
||||
(rssi0 << 8) / 16;
|
||||
dev->cal.avg_rssi[1] = (dev->cal.avg_rssi[1] * 15) / 16 +
|
||||
(rssi1 << 8) / 16;
|
||||
dev->cal.avg_rssi_all = (dev->cal.avg_rssi[0] +
|
||||
dev->cal.avg_rssi[1]) / 512;
|
||||
spin_lock_bh(&dev->mt76.rx_lock);
|
||||
dev->cal.avg_rssi_all = ewma_signal_read(&dev->cal.rssi);
|
||||
rssi_count = dev->cal.rssi_count;
|
||||
dev->cal.rssi_count = 0;
|
||||
spin_unlock_bh(&dev->mt76.rx_lock);
|
||||
|
||||
if (!rssi_count)
|
||||
dev->cal.avg_rssi_all = -75;
|
||||
|
||||
low_gain = (dev->cal.avg_rssi_all > mt76x2_get_rssi_gain_thresh(dev)) +
|
||||
(dev->cal.avg_rssi_all > mt76x2_get_low_rssi_gain_thresh(dev));
|
||||
|
||||
Reference in New Issue
Block a user