Skip to content

Commit e5a9f8d

Browse files
committed
mac80211: move station statistics into sub-structs
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>
1 parent 976bd9e commit e5a9f8d

File tree

11 files changed

+178
-185
lines changed

11 files changed

+178
-185
lines changed

net/mac80211/debugfs_sta.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,9 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
366366
DEBUGFS_ADD(ht_capa);
367367
DEBUGFS_ADD(vht_capa);
368368

369-
DEBUGFS_ADD_COUNTER(rx_duplicates, num_duplicates);
370-
DEBUGFS_ADD_COUNTER(rx_fragments, rx_fragments);
371-
DEBUGFS_ADD_COUNTER(tx_filtered, tx_filtered_count);
369+
DEBUGFS_ADD_COUNTER(rx_duplicates, rx_stats.num_duplicates);
370+
DEBUGFS_ADD_COUNTER(rx_fragments, rx_stats.fragments);
371+
DEBUGFS_ADD_COUNTER(tx_filtered, status_stats.filtered);
372372

373373
if (sizeof(sta->driver_buffered_tids) == sizeof(u32))
374374
debugfs_create_x32("driver_buffered_tids", 0400,

net/mac80211/ethtool.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,19 @@ static void ieee80211_get_stats(struct net_device *dev,
7777

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

80-
#define ADD_STA_STATS(sta) \
81-
do { \
82-
data[i++] += sta->rx_packets; \
83-
data[i++] += sta->rx_bytes; \
84-
data[i++] += sta->num_duplicates; \
85-
data[i++] += sta->rx_fragments; \
86-
data[i++] += sta->rx_dropped; \
87-
\
88-
data[i++] += sinfo.tx_packets; \
89-
data[i++] += sinfo.tx_bytes; \
90-
data[i++] += sta->tx_filtered_count; \
91-
data[i++] += sta->tx_retry_failed; \
92-
data[i++] += sta->tx_retry_count; \
80+
#define ADD_STA_STATS(sta) \
81+
do { \
82+
data[i++] += sta->rx_stats.packets; \
83+
data[i++] += sta->rx_stats.bytes; \
84+
data[i++] += sta->rx_stats.num_duplicates; \
85+
data[i++] += sta->rx_stats.fragments; \
86+
data[i++] += sta->rx_stats.dropped; \
87+
\
88+
data[i++] += sinfo.tx_packets; \
89+
data[i++] += sinfo.tx_bytes; \
90+
data[i++] += sta->status_stats.filtered; \
91+
data[i++] += sta->status_stats.retry_failed; \
92+
data[i++] += sta->status_stats.retry_count; \
9393
} while (0)
9494

9595
/* For Managed stations, find the single station based on BSSID

net/mac80211/ibss.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, const u8 *bssid,
647647
return NULL;
648648
}
649649

650-
sta->last_rx = jiffies;
650+
sta->rx_stats.last_rx = jiffies;
651651

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

670670
list_for_each_entry_rcu(sta, &local->sta_list, list) {
671671
if (sta->sdata == sdata &&
672-
time_after(sta->last_rx + IEEE80211_IBSS_MERGE_INTERVAL,
672+
time_after(sta->rx_stats.last_rx +
673+
IEEE80211_IBSS_MERGE_INTERVAL,
673674
jiffies)) {
674675
active++;
675676
break;
@@ -1235,7 +1236,7 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
12351236
if (!sta)
12361237
return;
12371238

1238-
sta->last_rx = jiffies;
1239+
sta->rx_stats.last_rx = jiffies;
12391240

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

12581259
mutex_lock(&local->sta_mtx);
12591260

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

1264-
if (time_after(jiffies, sta->last_rx + exp_time) ||
1265-
(time_after(jiffies, sta->last_rx + exp_rsn_time) &&
1265+
if (time_after(jiffies, sta->rx_stats.last_rx + exp_time) ||
1266+
(time_after(jiffies, sta->rx_stats.last_rx + exp_rsn) &&
12661267
sta->sta_state != IEEE80211_STA_AUTHORIZED)) {
12671268
sta_dbg(sta->sdata, "expiring inactive %sSTA %pM\n",
12681269
sta->sta_state != IEEE80211_STA_AUTHORIZED ?

net/mac80211/mesh_hwmp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local,
329329
if (sta->mesh->fail_avg >= 100)
330330
return MAX_METRIC;
331331

332-
sta_set_rate_info_tx(sta, &sta->last_tx_rate, &rinfo);
332+
sta_set_rate_info_tx(sta, &sta->tx_stats.last_rate, &rinfo);
333333
rate = cfg80211_calculate_bitrate(&rinfo);
334334
if (WARN_ON(!rate))
335335
return MAX_METRIC;

net/mac80211/mesh_plink.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ static bool rssi_threshold_check(struct ieee80211_sub_if_data *sdata,
6060
{
6161
s32 rssi_threshold = sdata->u.mesh.mshcfg.rssi_threshold;
6262
return rssi_threshold == 0 ||
63-
(sta && (s8) -ewma_signal_read(&sta->avg_signal) > rssi_threshold);
63+
(sta &&
64+
(s8)-ewma_signal_read(&sta->rx_stats.avg_signal) >
65+
rssi_threshold);
6466
}
6567

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

392394
spin_lock_bh(&sta->mesh->plink_lock);
393-
sta->last_rx = jiffies;
395+
sta->rx_stats.last_rx = jiffies;
394396

395397
/* rates and capabilities don't change during peering */
396398
if (sta->mesh->plink_state == NL80211_PLINK_ESTAB &&

net/mac80211/ocb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void ieee80211_ocb_rx_no_sta(struct ieee80211_sub_if_data *sdata,
7575
if (!sta)
7676
return;
7777

78-
sta->last_rx = jiffies;
78+
sta->rx_stats.last_rx = jiffies;
7979

8080
/* Add only mandatory rates for now */
8181
sband = local->hw.wiphy->bands[band];

net/mac80211/rx.c

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ ieee80211_rx_h_check_dup(struct ieee80211_rx_data *rx)
11191119
if (unlikely(ieee80211_has_retry(hdr->frame_control) &&
11201120
rx->sta->last_seq_ctrl[rx->seqno_idx] == hdr->seq_ctrl)) {
11211121
I802_DEBUG_INC(rx->local->dot11FrameDuplicateCount);
1122-
rx->sta->num_duplicates++;
1122+
rx->sta->rx_stats.num_duplicates++;
11231123
return RX_DROP_UNUSABLE;
11241124
} else if (!(status->flag & RX_FLAG_AMSDU_MORE)) {
11251125
rx->sta->last_seq_ctrl[rx->seqno_idx] = hdr->seq_ctrl;
@@ -1396,51 +1396,56 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
13961396
NL80211_IFTYPE_ADHOC);
13971397
if (ether_addr_equal(bssid, rx->sdata->u.ibss.bssid) &&
13981398
test_sta_flag(sta, WLAN_STA_AUTHORIZED)) {
1399-
sta->last_rx = jiffies;
1399+
sta->rx_stats.last_rx = jiffies;
14001400
if (ieee80211_is_data(hdr->frame_control) &&
14011401
!is_multicast_ether_addr(hdr->addr1)) {
1402-
sta->last_rx_rate_idx = status->rate_idx;
1403-
sta->last_rx_rate_flag = status->flag;
1404-
sta->last_rx_rate_vht_flag = status->vht_flag;
1405-
sta->last_rx_rate_vht_nss = status->vht_nss;
1402+
sta->rx_stats.last_rate_idx =
1403+
status->rate_idx;
1404+
sta->rx_stats.last_rate_flag =
1405+
status->flag;
1406+
sta->rx_stats.last_rate_vht_flag =
1407+
status->vht_flag;
1408+
sta->rx_stats.last_rate_vht_nss =
1409+
status->vht_nss;
14061410
}
14071411
}
14081412
} else if (rx->sdata->vif.type == NL80211_IFTYPE_OCB) {
1409-
sta->last_rx = jiffies;
1413+
sta->rx_stats.last_rx = jiffies;
14101414
} else if (!is_multicast_ether_addr(hdr->addr1)) {
14111415
/*
14121416
* Mesh beacons will update last_rx when if they are found to
14131417
* match the current local configuration when processed.
14141418
*/
1415-
sta->last_rx = jiffies;
1419+
sta->rx_stats.last_rx = jiffies;
14161420
if (ieee80211_is_data(hdr->frame_control)) {
1417-
sta->last_rx_rate_idx = status->rate_idx;
1418-
sta->last_rx_rate_flag = status->flag;
1419-
sta->last_rx_rate_vht_flag = status->vht_flag;
1420-
sta->last_rx_rate_vht_nss = status->vht_nss;
1421+
sta->rx_stats.last_rate_idx = status->rate_idx;
1422+
sta->rx_stats.last_rate_flag = status->flag;
1423+
sta->rx_stats.last_rate_vht_flag = status->vht_flag;
1424+
sta->rx_stats.last_rate_vht_nss = status->vht_nss;
14211425
}
14221426
}
14231427

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

1427-
sta->rx_fragments++;
1428-
sta->rx_bytes += rx->skb->len;
1431+
sta->rx_stats.fragments++;
1432+
sta->rx_stats.bytes += rx->skb->len;
14291433
if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
1430-
sta->last_signal = status->signal;
1431-
ewma_signal_add(&sta->avg_signal, -status->signal);
1434+
sta->rx_stats.last_signal = status->signal;
1435+
ewma_signal_add(&sta->rx_stats.avg_signal, -status->signal);
14321436
}
14331437

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

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

1442-
sta->chain_signal_last[i] = signal;
1443-
ewma_signal_add(&sta->chain_signal_avg[i], -signal);
1446+
sta->rx_stats.chain_signal_last[i] = signal;
1447+
ewma_signal_add(&sta->rx_stats.chain_signal_avg[i],
1448+
-signal);
14441449
}
14451450
}
14461451

@@ -1500,7 +1505,7 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
15001505
* Update counter and free packet here to avoid
15011506
* counting this as a dropped packed.
15021507
*/
1503-
sta->rx_packets++;
1508+
sta->rx_stats.packets++;
15041509
dev_kfree_skb(rx->skb);
15051510
return RX_QUEUED;
15061511
}
@@ -1922,7 +1927,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
19221927
ieee80211_led_rx(rx->local);
19231928
out_no_led:
19241929
if (rx->sta)
1925-
rx->sta->rx_packets++;
1930+
rx->sta->rx_stats.packets++;
19261931
return RX_CONTINUE;
19271932
}
19281933

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

23822387
/*
@@ -2413,7 +2418,7 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
24132418
skb_queue_tail(&local->skb_queue_tdls_chsw, rx->skb);
24142419
schedule_work(&local->tdls_chsw_work);
24152420
if (rx->sta)
2416-
rx->sta->rx_packets++;
2421+
rx->sta->rx_stats.packets++;
24172422

24182423
return RX_QUEUED;
24192424
}
@@ -2875,7 +2880,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
28752880

28762881
handled:
28772882
if (rx->sta)
2878-
rx->sta->rx_packets++;
2883+
rx->sta->rx_stats.packets++;
28792884
dev_kfree_skb(rx->skb);
28802885
return RX_QUEUED;
28812886

@@ -2884,7 +2889,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
28842889
skb_queue_tail(&sdata->skb_queue, rx->skb);
28852890
ieee80211_queue_work(&local->hw, &sdata->work);
28862891
if (rx->sta)
2887-
rx->sta->rx_packets++;
2892+
rx->sta->rx_stats.packets++;
28882893
return RX_QUEUED;
28892894
}
28902895

@@ -2911,7 +2916,7 @@ ieee80211_rx_h_userspace_mgmt(struct ieee80211_rx_data *rx)
29112916
if (cfg80211_rx_mgmt(&rx->sdata->wdev, status->freq, sig,
29122917
rx->skb->data, rx->skb->len, 0)) {
29132918
if (rx->sta)
2914-
rx->sta->rx_packets++;
2919+
rx->sta->rx_stats.packets++;
29152920
dev_kfree_skb(rx->skb);
29162921
return RX_QUEUED;
29172922
}
@@ -3030,7 +3035,7 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
30303035
skb_queue_tail(&sdata->skb_queue, rx->skb);
30313036
ieee80211_queue_work(&rx->local->hw, &sdata->work);
30323037
if (rx->sta)
3033-
rx->sta->rx_packets++;
3038+
rx->sta->rx_stats.packets++;
30343039

30353040
return RX_QUEUED;
30363041
}
@@ -3112,7 +3117,7 @@ static void ieee80211_rx_handlers_result(struct ieee80211_rx_data *rx,
31123117
case RX_DROP_MONITOR:
31133118
I802_DEBUG_INC(rx->sdata->local->rx_handlers_drop);
31143119
if (rx->sta)
3115-
rx->sta->rx_dropped++;
3120+
rx->sta->rx_stats.dropped++;
31163121
/* fall through */
31173122
case RX_CONTINUE: {
31183123
struct ieee80211_rate *rate = NULL;
@@ -3132,7 +3137,7 @@ static void ieee80211_rx_handlers_result(struct ieee80211_rx_data *rx,
31323137
case RX_DROP_UNUSABLE:
31333138
I802_DEBUG_INC(rx->sdata->local->rx_handlers_drop);
31343139
if (rx->sta)
3135-
rx->sta->rx_dropped++;
3140+
rx->sta->rx_stats.dropped++;
31363141
dev_kfree_skb(rx->skb);
31373142
break;
31383143
case RX_QUEUED:

0 commit comments

Comments
 (0)