Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
mac80211: move station statistics into sub-structs
Browse files Browse the repository at this point in the history
Group station statistics by where they're (mostly) updated
(TX, RX and TX-status) and group them into sub-structs of
the struct sta_info.

Also rename the variables since the grouping now makes it
obvious where they belong.

This makes it easier to identify where the statistics are
updated in the code, and thus easier to think about them.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
jmberg-intel committed Oct 21, 2015
1 parent 976bd9e commit e5a9f8d
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 185 deletions.
6 changes: 3 additions & 3 deletions net/mac80211/debugfs_sta.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,9 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
DEBUGFS_ADD(ht_capa);
DEBUGFS_ADD(vht_capa);

DEBUGFS_ADD_COUNTER(rx_duplicates, num_duplicates);
DEBUGFS_ADD_COUNTER(rx_fragments, rx_fragments);
DEBUGFS_ADD_COUNTER(tx_filtered, tx_filtered_count);
DEBUGFS_ADD_COUNTER(rx_duplicates, rx_stats.num_duplicates);
DEBUGFS_ADD_COUNTER(rx_fragments, rx_stats.fragments);
DEBUGFS_ADD_COUNTER(tx_filtered, status_stats.filtered);

if (sizeof(sta->driver_buffered_tids) == sizeof(u32))
debugfs_create_x32("driver_buffered_tids", 0400,
Expand Down
26 changes: 13 additions & 13 deletions net/mac80211/ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ static void ieee80211_get_stats(struct net_device *dev,

memset(data, 0, sizeof(u64) * STA_STATS_LEN);

#define ADD_STA_STATS(sta) \
do { \
data[i++] += sta->rx_packets; \
data[i++] += sta->rx_bytes; \
data[i++] += sta->num_duplicates; \
data[i++] += sta->rx_fragments; \
data[i++] += sta->rx_dropped; \
\
data[i++] += sinfo.tx_packets; \
data[i++] += sinfo.tx_bytes; \
data[i++] += sta->tx_filtered_count; \
data[i++] += sta->tx_retry_failed; \
data[i++] += sta->tx_retry_count; \
#define ADD_STA_STATS(sta) \
do { \
data[i++] += sta->rx_stats.packets; \
data[i++] += sta->rx_stats.bytes; \
data[i++] += sta->rx_stats.num_duplicates; \
data[i++] += sta->rx_stats.fragments; \
data[i++] += sta->rx_stats.dropped; \
\
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; \
} while (0)

/* For Managed stations, find the single station based on BSSID
Expand Down
13 changes: 7 additions & 6 deletions net/mac80211/ibss.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, const u8 *bssid,
return NULL;
}

sta->last_rx = jiffies;
sta->rx_stats.last_rx = jiffies;

/* make sure mandatory rates are always added */
sband = local->hw.wiphy->bands[band];
Expand All @@ -669,7 +669,8 @@ static int ieee80211_sta_active_ibss(struct ieee80211_sub_if_data *sdata)

list_for_each_entry_rcu(sta, &local->sta_list, list) {
if (sta->sdata == sdata &&
time_after(sta->last_rx + IEEE80211_IBSS_MERGE_INTERVAL,
time_after(sta->rx_stats.last_rx +
IEEE80211_IBSS_MERGE_INTERVAL,
jiffies)) {
active++;
break;
Expand Down Expand Up @@ -1235,7 +1236,7 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
if (!sta)
return;

sta->last_rx = jiffies;
sta->rx_stats.last_rx = jiffies;

/* make sure mandatory rates are always added */
sband = local->hw.wiphy->bands[band];
Expand All @@ -1253,16 +1254,16 @@ static void ieee80211_ibss_sta_expire(struct ieee80211_sub_if_data *sdata)
struct ieee80211_local *local = sdata->local;
struct sta_info *sta, *tmp;
unsigned long exp_time = IEEE80211_IBSS_INACTIVITY_LIMIT;
unsigned long exp_rsn_time = IEEE80211_IBSS_RSN_INACTIVITY_LIMIT;
unsigned long exp_rsn = IEEE80211_IBSS_RSN_INACTIVITY_LIMIT;

mutex_lock(&local->sta_mtx);

list_for_each_entry_safe(sta, tmp, &local->sta_list, list) {
if (sdata != sta->sdata)
continue;

if (time_after(jiffies, sta->last_rx + exp_time) ||
(time_after(jiffies, sta->last_rx + exp_rsn_time) &&
if (time_after(jiffies, sta->rx_stats.last_rx + exp_time) ||
(time_after(jiffies, sta->rx_stats.last_rx + exp_rsn) &&
sta->sta_state != IEEE80211_STA_AUTHORIZED)) {
sta_dbg(sta->sdata, "expiring inactive %sSTA %pM\n",
sta->sta_state != IEEE80211_STA_AUTHORIZED ?
Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/mesh_hwmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local,
if (sta->mesh->fail_avg >= 100)
return MAX_METRIC;

sta_set_rate_info_tx(sta, &sta->last_tx_rate, &rinfo);
sta_set_rate_info_tx(sta, &sta->tx_stats.last_rate, &rinfo);
rate = cfg80211_calculate_bitrate(&rinfo);
if (WARN_ON(!rate))
return MAX_METRIC;
Expand Down
6 changes: 4 additions & 2 deletions net/mac80211/mesh_plink.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ 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_signal_read(&sta->avg_signal) > rssi_threshold);
(sta &&
(s8)-ewma_signal_read(&sta->rx_stats.avg_signal) >
rssi_threshold);
}

/**
Expand Down Expand Up @@ -390,7 +392,7 @@ static void mesh_sta_info_init(struct ieee80211_sub_if_data *sdata,
rates = ieee80211_sta_get_rates(sdata, elems, band, &basic_rates);

spin_lock_bh(&sta->mesh->plink_lock);
sta->last_rx = jiffies;
sta->rx_stats.last_rx = jiffies;

/* rates and capabilities don't change during peering */
if (sta->mesh->plink_state == NL80211_PLINK_ESTAB &&
Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/ocb.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void ieee80211_ocb_rx_no_sta(struct ieee80211_sub_if_data *sdata,
if (!sta)
return;

sta->last_rx = jiffies;
sta->rx_stats.last_rx = jiffies;

/* Add only mandatory rates for now */
sband = local->hw.wiphy->bands[band];
Expand Down
63 changes: 34 additions & 29 deletions net/mac80211/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ ieee80211_rx_h_check_dup(struct ieee80211_rx_data *rx)
if (unlikely(ieee80211_has_retry(hdr->frame_control) &&
rx->sta->last_seq_ctrl[rx->seqno_idx] == hdr->seq_ctrl)) {
I802_DEBUG_INC(rx->local->dot11FrameDuplicateCount);
rx->sta->num_duplicates++;
rx->sta->rx_stats.num_duplicates++;
return RX_DROP_UNUSABLE;
} else if (!(status->flag & RX_FLAG_AMSDU_MORE)) {
rx->sta->last_seq_ctrl[rx->seqno_idx] = hdr->seq_ctrl;
Expand Down Expand Up @@ -1396,51 +1396,56 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
NL80211_IFTYPE_ADHOC);
if (ether_addr_equal(bssid, rx->sdata->u.ibss.bssid) &&
test_sta_flag(sta, WLAN_STA_AUTHORIZED)) {
sta->last_rx = jiffies;
sta->rx_stats.last_rx = jiffies;
if (ieee80211_is_data(hdr->frame_control) &&
!is_multicast_ether_addr(hdr->addr1)) {
sta->last_rx_rate_idx = status->rate_idx;
sta->last_rx_rate_flag = status->flag;
sta->last_rx_rate_vht_flag = status->vht_flag;
sta->last_rx_rate_vht_nss = status->vht_nss;
sta->rx_stats.last_rate_idx =
status->rate_idx;
sta->rx_stats.last_rate_flag =
status->flag;
sta->rx_stats.last_rate_vht_flag =
status->vht_flag;
sta->rx_stats.last_rate_vht_nss =
status->vht_nss;
}
}
} else if (rx->sdata->vif.type == NL80211_IFTYPE_OCB) {
sta->last_rx = jiffies;
sta->rx_stats.last_rx = jiffies;
} else if (!is_multicast_ether_addr(hdr->addr1)) {
/*
* Mesh beacons will update last_rx when if they are found to
* match the current local configuration when processed.
*/
sta->last_rx = jiffies;
sta->rx_stats.last_rx = jiffies;
if (ieee80211_is_data(hdr->frame_control)) {
sta->last_rx_rate_idx = status->rate_idx;
sta->last_rx_rate_flag = status->flag;
sta->last_rx_rate_vht_flag = status->vht_flag;
sta->last_rx_rate_vht_nss = status->vht_nss;
sta->rx_stats.last_rate_idx = status->rate_idx;
sta->rx_stats.last_rate_flag = status->flag;
sta->rx_stats.last_rate_vht_flag = status->vht_flag;
sta->rx_stats.last_rate_vht_nss = status->vht_nss;
}
}

if (rx->sdata->vif.type == NL80211_IFTYPE_STATION)
ieee80211_sta_rx_notify(rx->sdata, hdr);

sta->rx_fragments++;
sta->rx_bytes += rx->skb->len;
sta->rx_stats.fragments++;
sta->rx_stats.bytes += rx->skb->len;
if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
sta->last_signal = status->signal;
ewma_signal_add(&sta->avg_signal, -status->signal);
sta->rx_stats.last_signal = status->signal;
ewma_signal_add(&sta->rx_stats.avg_signal, -status->signal);
}

if (status->chains) {
sta->chains = status->chains;
sta->rx_stats.chains = status->chains;
for (i = 0; i < ARRAY_SIZE(status->chain_signal); i++) {
int signal = status->chain_signal[i];

if (!(status->chains & BIT(i)))
continue;

sta->chain_signal_last[i] = signal;
ewma_signal_add(&sta->chain_signal_avg[i], -signal);
sta->rx_stats.chain_signal_last[i] = signal;
ewma_signal_add(&sta->rx_stats.chain_signal_avg[i],
-signal);
}
}

Expand Down Expand Up @@ -1500,7 +1505,7 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
* Update counter and free packet here to avoid
* counting this as a dropped packed.
*/
sta->rx_packets++;
sta->rx_stats.packets++;
dev_kfree_skb(rx->skb);
return RX_QUEUED;
}
Expand Down Expand Up @@ -1922,7 +1927,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
ieee80211_led_rx(rx->local);
out_no_led:
if (rx->sta)
rx->sta->rx_packets++;
rx->sta->rx_stats.packets++;
return RX_CONTINUE;
}

Expand Down Expand Up @@ -2376,7 +2381,7 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
* for non-QoS-data frames. Here we know it's a data
* frame, so count MSDUs.
*/
rx->sta->rx_msdu[rx->seqno_idx]++;
rx->sta->rx_stats.msdu[rx->seqno_idx]++;
}

/*
Expand Down Expand Up @@ -2413,7 +2418,7 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
skb_queue_tail(&local->skb_queue_tdls_chsw, rx->skb);
schedule_work(&local->tdls_chsw_work);
if (rx->sta)
rx->sta->rx_packets++;
rx->sta->rx_stats.packets++;

return RX_QUEUED;
}
Expand Down Expand Up @@ -2875,7 +2880,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)

handled:
if (rx->sta)
rx->sta->rx_packets++;
rx->sta->rx_stats.packets++;
dev_kfree_skb(rx->skb);
return RX_QUEUED;

Expand All @@ -2884,7 +2889,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
skb_queue_tail(&sdata->skb_queue, rx->skb);
ieee80211_queue_work(&local->hw, &sdata->work);
if (rx->sta)
rx->sta->rx_packets++;
rx->sta->rx_stats.packets++;
return RX_QUEUED;
}

Expand All @@ -2911,7 +2916,7 @@ ieee80211_rx_h_userspace_mgmt(struct ieee80211_rx_data *rx)
if (cfg80211_rx_mgmt(&rx->sdata->wdev, status->freq, sig,
rx->skb->data, rx->skb->len, 0)) {
if (rx->sta)
rx->sta->rx_packets++;
rx->sta->rx_stats.packets++;
dev_kfree_skb(rx->skb);
return RX_QUEUED;
}
Expand Down Expand Up @@ -3030,7 +3035,7 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
skb_queue_tail(&sdata->skb_queue, rx->skb);
ieee80211_queue_work(&rx->local->hw, &sdata->work);
if (rx->sta)
rx->sta->rx_packets++;
rx->sta->rx_stats.packets++;

return RX_QUEUED;
}
Expand Down Expand Up @@ -3112,7 +3117,7 @@ static void ieee80211_rx_handlers_result(struct ieee80211_rx_data *rx,
case RX_DROP_MONITOR:
I802_DEBUG_INC(rx->sdata->local->rx_handlers_drop);
if (rx->sta)
rx->sta->rx_dropped++;
rx->sta->rx_stats.dropped++;
/* fall through */
case RX_CONTINUE: {
struct ieee80211_rate *rate = NULL;
Expand All @@ -3132,7 +3137,7 @@ static void ieee80211_rx_handlers_result(struct ieee80211_rx_data *rx,
case RX_DROP_UNUSABLE:
I802_DEBUG_INC(rx->sdata->local->rx_handlers_drop);
if (rx->sta)
rx->sta->rx_dropped++;
rx->sta->rx_stats.dropped++;
dev_kfree_skb(rx->skb);
break;
case RX_QUEUED:
Expand Down
Loading

0 comments on commit e5a9f8d

Please sign in to comment.