mac80211: use DECLARE_EWMA
authorJohannes Berg <johannes.berg@intel.com>
Mon, 13 Jul 2015 10:26:46 +0000 (12:26 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 14 Aug 2015 15:49:53 +0000 (17:49 +0200)
Instead of using the out-of-line average calculation, use the new
DECLARE_EWMA() macro to declare a signal EWMA, and use that.

This actually *reduces* the code size slightly (on x86-64) while
also reducing the station info size by 80 bytes.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/Kconfig
net/mac80211/mesh_plink.c
net/mac80211/rx.c
net/mac80211/sta_info.c
net/mac80211/sta_info.h

index 086de496a4c197bb98a5e0b550a9b67d516d4902..3891cbd2adeab7bdcb062be3dfb36926cf91d23c 100644 (file)
@@ -7,7 +7,6 @@ config MAC80211
        select CRYPTO_CCM
        select CRYPTO_GCM
        select CRC32
-       select AVERAGE
        ---help---
          This option enables the hardware independent IEEE 802.11
          networking stack.
index e12be2e4e8df0024c9d4043364254513f6e5adb0..58384642e03c52bb6427fc809a9149769855e9c1 100644 (file)
@@ -60,7 +60,7 @@ static bool rssi_threshold_check(struct ieee80211_sub_if_data *sdata,
 {
        s32 rssi_threshold = sdata->u.mesh.mshcfg.rssi_threshold;
        return rssi_threshold == 0 ||
-              (sta && (s8) -ewma_read(&sta->avg_signal) > rssi_threshold);
+              (sta && (s8) -ewma_signal_read(&sta->avg_signal) > rssi_threshold);
 }
 
 /**
index 4d217d3265f481df712640b5401c27c7186dd7f6..5bc0b88d9eb1331a0dd47aab05ffa01c7a0bc845 100644 (file)
@@ -1428,7 +1428,7 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
        sta->rx_bytes += rx->skb->len;
        if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
                sta->last_signal = status->signal;
-               ewma_add(&sta->avg_signal, -status->signal);
+               ewma_signal_add(&sta->avg_signal, -status->signal);
        }
 
        if (status->chains) {
@@ -1440,7 +1440,7 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
                                continue;
 
                        sta->chain_signal_last[i] = signal;
-                       ewma_add(&sta->chain_signal_avg[i], -signal);
+                       ewma_signal_add(&sta->chain_signal_avg[i], -signal);
                }
        }
 
index 70cd9fa57424579d16514725c95f6c55d0f7b8aa..64f1936350c66e48fb076beb7b418d55f42c8753 100644 (file)
@@ -341,9 +341,9 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
 
        ktime_get_ts(&uptime);
        sta->last_connected = uptime.tv_sec;
-       ewma_init(&sta->avg_signal, 1024, 8);
+       ewma_signal_init(&sta->avg_signal);
        for (i = 0; i < ARRAY_SIZE(sta->chain_signal_avg); i++)
-               ewma_init(&sta->chain_signal_avg[i], 1024, 8);
+               ewma_signal_init(&sta->chain_signal_avg[i]);
 
        if (local->ops->wake_tx_queue) {
                void *txq_data;
@@ -1896,7 +1896,8 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
                }
 
                if (!(sinfo->filled & BIT(NL80211_STA_INFO_SIGNAL_AVG))) {
-                       sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
+                       sinfo->signal_avg =
+                               (s8) -ewma_signal_read(&sta->avg_signal);
                        sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL_AVG);
                }
        }
@@ -1911,7 +1912,7 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
                for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) {
                        sinfo->chain_signal[i] = sta->chain_signal_last[i];
                        sinfo->chain_signal_avg[i] =
-                               (s8) -ewma_read(&sta->chain_signal_avg[i]);
+                               (s8) -ewma_signal_read(&sta->chain_signal_avg[i]);
                }
        }
 
index 1d2805c598c055effac3698d324d095afa43d056..b087c71ff7fe4ef99ed3869cc2c7eecc174b95c0 100644 (file)
@@ -320,6 +320,8 @@ struct mesh_sta {
        unsigned int fail_avg;
 };
 
+DECLARE_EWMA(signal, 1024, 8)
+
 /**
  * struct sta_info - STA information
  *
@@ -462,12 +464,12 @@ struct sta_info {
        unsigned long rx_fragments;
        unsigned long rx_dropped;
        int last_signal;
-       struct ewma avg_signal;
+       struct ewma_signal avg_signal;
        int last_ack_signal;
 
        u8 chains;
        s8 chain_signal_last[IEEE80211_MAX_CHAINS];
-       struct ewma chain_signal_avg[IEEE80211_MAX_CHAINS];
+       struct ewma_signal chain_signal_avg[IEEE80211_MAX_CHAINS];
 
        /* Plus 1 for non-QoS frames */
        __le16 last_seq_ctrl[IEEE80211_NUM_TIDS + 1];