Skip to content

Commit ef0621e

Browse files
Felix Fietkaujmberg-intel
authored andcommitted
mac80211: add support for per-chain signal strength reporting
Signed-off-by: Felix Fietkau <nbd@openwrt.org> [fix unit documentation] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 119363c commit ef0621e

5 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎include/net/mac80211.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,10 @@ enum mac80211_rx_flags {
850850
* @signal: signal strength when receiving this frame, either in dBm, in dB or
851851
* unspecified depending on the hardware capabilities flags
852852
* @IEEE80211_HW_SIGNAL_*
853+
* @chains: bitmask of receive chains for which separate signal strength
854+
* values were filled.
855+
* @chain_signal: per-chain signal strength, in dBm (unlike @signal, doesn't
856+
* support dB or unspecified units)
853857
* @antenna: antenna used
854858
* @rate_idx: index of data rate into band's supported rates or MCS index if
855859
* HT or VHT is used (%RX_FLAG_HT/%RX_FLAG_VHT)
@@ -881,6 +885,8 @@ struct ieee80211_rx_status {
881885
u8 band;
882886
u8 antenna;
883887
s8 signal;
888+
u8 chains;
889+
s8 chain_signal[IEEE80211_MAX_CHAINS];
884890
u8 ampdu_delimiter_crc;
885891
u8 vendor_radiotap_align;
886892
u8 vendor_radiotap_oui[3];

‎net/mac80211/cfg.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
444444
struct ieee80211_local *local = sdata->local;
445445
struct timespec uptime;
446446
u64 packets = 0;
447-
int ac;
447+
int i, ac;
448448

449449
sinfo->generation = sdata->local->sta_generation;
450450

@@ -488,6 +488,17 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
488488
sinfo->signal = (s8)sta->last_signal;
489489
sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
490490
}
491+
if (sta->chains) {
492+
sinfo->filled |= STATION_INFO_CHAIN_SIGNAL |
493+
STATION_INFO_CHAIN_SIGNAL_AVG;
494+
495+
sinfo->chains = sta->chains;
496+
for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) {
497+
sinfo->chain_signal[i] = sta->chain_signal_last[i];
498+
sinfo->chain_signal_avg[i] =
499+
(s8) -ewma_read(&sta->chain_signal_avg[i]);
500+
}
501+
}
491502

492503
sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate);
493504
sta_set_rate_info_rx(sta, &sinfo->rxrate);

‎net/mac80211/rx.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
13721372
struct sk_buff *skb = rx->skb;
13731373
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
13741374
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1375+
int i;
13751376

13761377
if (!sta)
13771378
return RX_CONTINUE;
@@ -1422,6 +1423,19 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
14221423
ewma_add(&sta->avg_signal, -status->signal);
14231424
}
14241425

1426+
if (status->chains) {
1427+
sta->chains = status->chains;
1428+
for (i = 0; i < ARRAY_SIZE(status->chain_signal); i++) {
1429+
int signal = status->chain_signal[i];
1430+
1431+
if (!(status->chains & BIT(i)))
1432+
continue;
1433+
1434+
sta->chain_signal_last[i] = signal;
1435+
ewma_add(&sta->chain_signal_avg[i], -signal);
1436+
}
1437+
}
1438+
14251439
/*
14261440
* Change STA power saving mode only at the end of a frame
14271441
* exchange sequence.

‎net/mac80211/sta_info.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
358358
do_posix_clock_monotonic_gettime(&uptime);
359359
sta->last_connected = uptime.tv_sec;
360360
ewma_init(&sta->avg_signal, 1024, 8);
361+
for (i = 0; i < ARRAY_SIZE(sta->chain_signal_avg); i++)
362+
ewma_init(&sta->chain_signal_avg[i], 1024, 8);
361363

362364
if (sta_prepare_rate_control(local, sta, gfp)) {
363365
kfree(sta);

‎net/mac80211/sta_info.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,11 @@ struct sta_info {
344344
int last_signal;
345345
struct ewma avg_signal;
346346
int last_ack_signal;
347+
348+
u8 chains;
349+
s8 chain_signal_last[IEEE80211_MAX_CHAINS];
350+
struct ewma chain_signal_avg[IEEE80211_MAX_CHAINS];
351+
347352
/* Plus 1 for non-QoS frames */
348353
__le16 last_seq_ctrl[IEEE80211_NUM_TIDS + 1];
349354

0 commit comments

Comments
 (0)