diff options
author | Bruno Randolf <br1@einfach.org> | 2010-11-15 20:58:48 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-11-18 14:22:20 -0500 |
commit | 86107fd170bc379869250eb7e1bd393a3a70e8ae (patch) | |
tree | 579ee24be87e94246450420f4de57d8eda942848 /net | |
parent | eef39befaae2a1559efe197d795c376a317af2af (diff) |
nl80211/mac80211: Report signal average
Extend nl80211 to report an exponential weighted moving average (EWMA) of the
signal value. Since the signal value usually fluctuates between different
packets, an average can be more useful than the value of the last packet.
This uses the recently added generic EWMA library function.
Signed-off-by: Bruno Randolf <br1@einfach.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/mac80211/Kconfig | 1 | ||||
-rw-r--r-- | net/mac80211/cfg.c | 3 | ||||
-rw-r--r-- | net/mac80211/rx.c | 1 | ||||
-rw-r--r-- | net/mac80211/sta_info.c | 2 | ||||
-rw-r--r-- | net/mac80211/sta_info.h | 3 | ||||
-rw-r--r-- | net/wireless/nl80211.c | 3 |
6 files changed, 12 insertions, 1 deletions
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig index 4d6f8653ec88..798d9b9462e2 100644 --- a/net/mac80211/Kconfig +++ b/net/mac80211/Kconfig | |||
@@ -6,6 +6,7 @@ config MAC80211 | |||
6 | select CRYPTO_ARC4 | 6 | select CRYPTO_ARC4 |
7 | select CRYPTO_AES | 7 | select CRYPTO_AES |
8 | select CRC32 | 8 | select CRC32 |
9 | select AVERAGE | ||
9 | ---help--- | 10 | ---help--- |
10 | This option enables the hardware independent IEEE 802.11 | 11 | This option enables the hardware independent IEEE 802.11 |
11 | networking stack. | 12 | networking stack. |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 0c544074479e..92c9cf6a7d1c 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -343,8 +343,9 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) | |||
343 | 343 | ||
344 | if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) || | 344 | if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) || |
345 | (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) { | 345 | (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) { |
346 | sinfo->filled |= STATION_INFO_SIGNAL; | 346 | sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG; |
347 | sinfo->signal = (s8)sta->last_signal; | 347 | sinfo->signal = (s8)sta->last_signal; |
348 | sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal); | ||
348 | } | 349 | } |
349 | 350 | ||
350 | sinfo->txrate.flags = 0; | 351 | sinfo->txrate.flags = 0; |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index d2fcd22ab06d..9dd60a74181f 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -1156,6 +1156,7 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) | |||
1156 | sta->rx_fragments++; | 1156 | sta->rx_fragments++; |
1157 | sta->rx_bytes += rx->skb->len; | 1157 | sta->rx_bytes += rx->skb->len; |
1158 | sta->last_signal = status->signal; | 1158 | sta->last_signal = status->signal; |
1159 | ewma_add(&sta->avg_signal, -status->signal); | ||
1159 | 1160 | ||
1160 | /* | 1161 | /* |
1161 | * Change STA power saving mode only at the end of a frame | 1162 | * Change STA power saving mode only at the end of a frame |
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index eff58571fd7e..f43fca8907f7 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c | |||
@@ -244,6 +244,8 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata, | |||
244 | sta->local = local; | 244 | sta->local = local; |
245 | sta->sdata = sdata; | 245 | sta->sdata = sdata; |
246 | 246 | ||
247 | ewma_init(&sta->avg_signal, 1000, 8); | ||
248 | |||
247 | if (sta_prepare_rate_control(local, sta, gfp)) { | 249 | if (sta_prepare_rate_control(local, sta, gfp)) { |
248 | kfree(sta); | 250 | kfree(sta); |
249 | return NULL; | 251 | return NULL; |
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 9265acadef32..84062e2c782c 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/types.h> | 13 | #include <linux/types.h> |
14 | #include <linux/if_ether.h> | 14 | #include <linux/if_ether.h> |
15 | #include <linux/workqueue.h> | 15 | #include <linux/workqueue.h> |
16 | #include <linux/average.h> | ||
16 | #include "key.h" | 17 | #include "key.h" |
17 | 18 | ||
18 | /** | 19 | /** |
@@ -224,6 +225,7 @@ enum plink_state { | |||
224 | * @rx_fragments: number of received MPDUs | 225 | * @rx_fragments: number of received MPDUs |
225 | * @rx_dropped: number of dropped MPDUs from this STA | 226 | * @rx_dropped: number of dropped MPDUs from this STA |
226 | * @last_signal: signal of last received frame from this STA | 227 | * @last_signal: signal of last received frame from this STA |
228 | * @avg_signal: moving average of signal of received frames from this STA | ||
227 | * @last_seq_ctrl: last received seq/frag number from this STA (per RX queue) | 229 | * @last_seq_ctrl: last received seq/frag number from this STA (per RX queue) |
228 | * @tx_filtered_count: number of frames the hardware filtered for this STA | 230 | * @tx_filtered_count: number of frames the hardware filtered for this STA |
229 | * @tx_retry_failed: number of frames that failed retry | 231 | * @tx_retry_failed: number of frames that failed retry |
@@ -291,6 +293,7 @@ struct sta_info { | |||
291 | unsigned long rx_fragments; | 293 | unsigned long rx_fragments; |
292 | unsigned long rx_dropped; | 294 | unsigned long rx_dropped; |
293 | int last_signal; | 295 | int last_signal; |
296 | struct ewma avg_signal; | ||
294 | __le16 last_seq_ctrl[NUM_RX_DATA_QUEUES]; | 297 | __le16 last_seq_ctrl[NUM_RX_DATA_QUEUES]; |
295 | 298 | ||
296 | /* Updated from TX status path only, no locking requirements */ | 299 | /* Updated from TX status path only, no locking requirements */ |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 605553842226..d06a40d17002 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -1872,6 +1872,9 @@ static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq, | |||
1872 | if (sinfo->filled & STATION_INFO_SIGNAL) | 1872 | if (sinfo->filled & STATION_INFO_SIGNAL) |
1873 | NLA_PUT_U8(msg, NL80211_STA_INFO_SIGNAL, | 1873 | NLA_PUT_U8(msg, NL80211_STA_INFO_SIGNAL, |
1874 | sinfo->signal); | 1874 | sinfo->signal); |
1875 | if (sinfo->filled & STATION_INFO_SIGNAL_AVG) | ||
1876 | NLA_PUT_U8(msg, NL80211_STA_INFO_SIGNAL_AVG, | ||
1877 | sinfo->signal_avg); | ||
1875 | if (sinfo->filled & STATION_INFO_TX_BITRATE) { | 1878 | if (sinfo->filled & STATION_INFO_TX_BITRATE) { |
1876 | txrate = nla_nest_start(msg, NL80211_STA_INFO_TX_BITRATE); | 1879 | txrate = nla_nest_start(msg, NL80211_STA_INFO_TX_BITRATE); |
1877 | if (!txrate) | 1880 | if (!txrate) |