diff options
author | Johannes Berg <johannes.berg@intel.com> | 2018-05-18 09:57:55 +0200 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2018-05-18 11:14:35 +0200 |
commit | 73887fd906bb77a974fa02663df9937d0aff053a (patch) | |
tree | 9f2301560feb727cca41cb72fd8848dc302b7392 /net/mac80211 | |
parent | 8689c051a20195b228e19acb155c7d6e48a86753 (diff) |
cfg80211/mac80211: revert to stack allocation for sinfo
Arend's previous patch made the sinfo structure smaller
again by to dynamically allocating the per-tid stats
only when needed. Thus, revert to stack allocation for
the struct to simplify the code.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r-- | net/mac80211/ethtool.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/net/mac80211/ethtool.c b/net/mac80211/ethtool.c index 09210aa8ea9a..2ba5686cbcab 100644 --- a/net/mac80211/ethtool.c +++ b/net/mac80211/ethtool.c @@ -71,15 +71,11 @@ static void ieee80211_get_stats(struct net_device *dev, struct ieee80211_channel *channel; struct sta_info *sta; struct ieee80211_local *local = sdata->local; - struct station_info *sinfo; + struct station_info sinfo; struct survey_info survey; int i, q; #define STA_STATS_SURVEY_LEN 7 - sinfo = kmalloc(sizeof(*sinfo), GFP_KERNEL); - if (!sinfo) - return; - memset(data, 0, sizeof(u64) * STA_STATS_LEN); #define ADD_STA_STATS(sta) \ @@ -90,8 +86,8 @@ static void ieee80211_get_stats(struct net_device *dev, data[i++] += sta->rx_stats.fragments; \ data[i++] += sta->rx_stats.dropped; \ \ - data[i++] += sinfo->tx_packets; \ - data[i++] += sinfo->tx_bytes; \ + data[i++] += sinfo.tx_packets; \ + data[i++] += sinfo.tx_bytes; \ data[i++] += sta->status_stats.filtered; \ data[i++] += sta->status_stats.retry_failed; \ data[i++] += sta->status_stats.retry_count; \ @@ -111,8 +107,8 @@ static void ieee80211_get_stats(struct net_device *dev, if (!(sta && !WARN_ON(sta->sdata->dev != dev))) goto do_survey; - memset(sinfo, 0, sizeof(*sinfo)); - sta_set_sinfo(sta, sinfo); + memset(&sinfo, 0, sizeof(sinfo)); + sta_set_sinfo(sta, &sinfo); i = 0; ADD_STA_STATS(sta); @@ -120,17 +116,17 @@ static void ieee80211_get_stats(struct net_device *dev, data[i++] = sta->sta_state; - if (sinfo->filled & BIT(NL80211_STA_INFO_TX_BITRATE)) + if (sinfo.filled & BIT(NL80211_STA_INFO_TX_BITRATE)) data[i] = 100000ULL * - cfg80211_calculate_bitrate(&sinfo->txrate); + cfg80211_calculate_bitrate(&sinfo.txrate); i++; - if (sinfo->filled & BIT(NL80211_STA_INFO_RX_BITRATE)) + if (sinfo.filled & BIT(NL80211_STA_INFO_RX_BITRATE)) data[i] = 100000ULL * - cfg80211_calculate_bitrate(&sinfo->rxrate); + cfg80211_calculate_bitrate(&sinfo.rxrate); i++; - if (sinfo->filled & BIT(NL80211_STA_INFO_SIGNAL_AVG)) - data[i] = (u8)sinfo->signal_avg; + if (sinfo.filled & BIT(NL80211_STA_INFO_SIGNAL_AVG)) + data[i] = (u8)sinfo.signal_avg; i++; } else { list_for_each_entry(sta, &local->sta_list, list) { @@ -138,16 +134,14 @@ static void ieee80211_get_stats(struct net_device *dev, if (sta->sdata->dev != dev) continue; - memset(sinfo, 0, sizeof(*sinfo)); - sta_set_sinfo(sta, sinfo); + memset(&sinfo, 0, sizeof(sinfo)); + sta_set_sinfo(sta, &sinfo); i = 0; ADD_STA_STATS(sta); } } do_survey: - kfree(sinfo); - i = STA_STATS_LEN - STA_STATS_SURVEY_LEN; /* Get survey stats for current channel */ survey.filled = 0; |