mt76: improve signal strength reporting
Instead of just taking the maximum per-chain signal strength values, add an approximation for the sum of the combined signal. This should more accurately reflect the real signal strength, especially if the per-chain signal strength values are close to each other Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
77787358be
commit
4550fb9e98
6 changed files with 33 additions and 29 deletions
|
@ -932,6 +932,35 @@ void mt76_wcid_key_setup(struct mt76_dev *dev, struct mt76_wcid *wcid,
|
|||
}
|
||||
EXPORT_SYMBOL(mt76_wcid_key_setup);
|
||||
|
||||
static int
|
||||
mt76_rx_signal(struct mt76_rx_status *status)
|
||||
{
|
||||
s8 *chain_signal = status->chain_signal;
|
||||
int signal = -128;
|
||||
u8 chains;
|
||||
|
||||
for (chains = status->chains; chains; chains >>= 1, chain_signal++) {
|
||||
int cur, diff;
|
||||
|
||||
if (!(chains & BIT(0)))
|
||||
continue;
|
||||
|
||||
cur = *chain_signal;
|
||||
if (cur > signal)
|
||||
swap(cur, signal);
|
||||
|
||||
diff = signal - cur;
|
||||
if (diff == 0)
|
||||
signal += 3;
|
||||
else if (diff <= 2)
|
||||
signal += 2;
|
||||
else if (diff <= 6)
|
||||
signal += 1;
|
||||
}
|
||||
|
||||
return signal;
|
||||
}
|
||||
|
||||
static void
|
||||
mt76_rx_convert(struct mt76_dev *dev, struct sk_buff *skb,
|
||||
struct ieee80211_hw **hw,
|
||||
|
@ -960,6 +989,9 @@ mt76_rx_convert(struct mt76_dev *dev, struct sk_buff *skb,
|
|||
status->ampdu_reference = mstat.ampdu_ref;
|
||||
status->device_timestamp = mstat.timestamp;
|
||||
status->mactime = mstat.timestamp;
|
||||
status->signal = mt76_rx_signal(&mstat);
|
||||
if (status->signal <= -128)
|
||||
status->flag |= RX_FLAG_NO_SIGNAL_VAL;
|
||||
|
||||
if (ieee80211_is_beacon(hdr->frame_control) ||
|
||||
ieee80211_is_probe_resp(hdr->frame_control))
|
||||
|
|
|
@ -643,11 +643,6 @@ mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb)
|
|||
status->chain_signal[1] = FIELD_GET(MT_RXV4_IB_RSSI1, rxdg3) +
|
||||
dev->rssi_offset[1];
|
||||
|
||||
status->signal = status->chain_signal[0];
|
||||
if (status->chains & BIT(1))
|
||||
status->signal = max(status->signal,
|
||||
status->chain_signal[1]);
|
||||
|
||||
if (FIELD_GET(MT_RXV1_FRAME_MODE, rxdg0) == 1)
|
||||
status->bw = RATE_INFO_BW_40;
|
||||
|
||||
|
|
|
@ -576,15 +576,6 @@ static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)
|
|||
status->chain_signal[1] = to_rssi(MT_RXV4_RCPI1, rxdg3);
|
||||
status->chain_signal[2] = to_rssi(MT_RXV4_RCPI2, rxdg3);
|
||||
status->chain_signal[3] = to_rssi(MT_RXV4_RCPI3, rxdg3);
|
||||
status->signal = status->chain_signal[0];
|
||||
|
||||
for (i = 1; i < hweight8(mphy->antenna_mask); i++) {
|
||||
if (!(status->chains & BIT(i)))
|
||||
continue;
|
||||
|
||||
status->signal = max(status->signal,
|
||||
status->chain_signal[i]);
|
||||
}
|
||||
|
||||
mt7615_mac_fill_tm_rx(mphy->priv, rxd);
|
||||
|
||||
|
|
|
@ -860,9 +860,7 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb,
|
|||
status->chain_signal[1] = mt76x02_mac_get_rssi(dev,
|
||||
rxwi->rssi[1],
|
||||
1);
|
||||
signal = max_t(s8, signal, status->chain_signal[1]);
|
||||
}
|
||||
status->signal = signal;
|
||||
status->freq = dev->mphy.chandef.chan->center_freq;
|
||||
status->band = dev->mphy.chandef.chan->band;
|
||||
|
||||
|
|
|
@ -593,7 +593,7 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
|
|||
u16 seq_ctrl = 0;
|
||||
u8 qos_ctl = 0;
|
||||
__le16 fc = 0;
|
||||
int i, idx;
|
||||
int idx;
|
||||
|
||||
memset(status, 0, sizeof(*status));
|
||||
|
||||
|
@ -753,15 +753,6 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
|
|||
status->chain_signal[1] = to_rssi(MT_PRXV_RCPI1, v1);
|
||||
status->chain_signal[2] = to_rssi(MT_PRXV_RCPI2, v1);
|
||||
status->chain_signal[3] = to_rssi(MT_PRXV_RCPI3, v1);
|
||||
status->signal = status->chain_signal[0];
|
||||
|
||||
for (i = 1; i < hweight8(mphy->antenna_mask); i++) {
|
||||
if (!(status->chains & BIT(i)))
|
||||
continue;
|
||||
|
||||
status->signal = max(status->signal,
|
||||
status->chain_signal[i]);
|
||||
}
|
||||
|
||||
/* RXD Group 5 - C-RXV */
|
||||
if (rxd1 & MT_RXD1_NORMAL_GROUP_5) {
|
||||
|
|
|
@ -670,9 +670,6 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
|
|||
status->chain_signal[i]);
|
||||
}
|
||||
|
||||
if (status->signal == -128)
|
||||
status->flag |= RX_FLAG_NO_SIGNAL_VAL;
|
||||
|
||||
stbc = FIELD_GET(MT_PRXV_STBC, v0);
|
||||
gi = FIELD_GET(MT_PRXV_SGI, v0);
|
||||
cck = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue