summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2015-10-16 11:54:47 -0400
committerJohannes Berg <johannes.berg@intel.com>2015-10-21 04:08:22 -0400
commite5a9f8d04660da7ef3a98260aa74c3976f9cb4cd (patch)
treeb1497de1b8ffd34b991cdf6e21de1c7a0a65f1de
parent976bd9efdae6a844079ba4a7898a38d229ef246c (diff)
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>
-rw-r--r--net/mac80211/debugfs_sta.c6
-rw-r--r--net/mac80211/ethtool.c26
-rw-r--r--net/mac80211/ibss.c13
-rw-r--r--net/mac80211/mesh_hwmp.c2
-rw-r--r--net/mac80211/mesh_plink.c6
-rw-r--r--net/mac80211/ocb.c2
-rw-r--r--net/mac80211/rx.c63
-rw-r--r--net/mac80211/sta_info.c77
-rw-r--r--net/mac80211/sta_info.h98
-rw-r--r--net/mac80211/status.c50
-rw-r--r--net/mac80211/tx.c20
11 files changed, 178 insertions, 185 deletions
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index 1200b6a581d2..a39512f09f9e 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -366,9 +366,9 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
366 DEBUGFS_ADD(ht_capa); 366 DEBUGFS_ADD(ht_capa);
367 DEBUGFS_ADD(vht_capa); 367 DEBUGFS_ADD(vht_capa);
368 368
369 DEBUGFS_ADD_COUNTER(rx_duplicates, num_duplicates); 369 DEBUGFS_ADD_COUNTER(rx_duplicates, rx_stats.num_duplicates);
370 DEBUGFS_ADD_COUNTER(rx_fragments, rx_fragments); 370 DEBUGFS_ADD_COUNTER(rx_fragments, rx_stats.fragments);
371 DEBUGFS_ADD_COUNTER(tx_filtered, tx_filtered_count); 371 DEBUGFS_ADD_COUNTER(tx_filtered, status_stats.filtered);
372 372
373 if (sizeof(sta->driver_buffered_tids) == sizeof(u32)) 373 if (sizeof(sta->driver_buffered_tids) == sizeof(u32))
374 debugfs_create_x32("driver_buffered_tids", 0400, 374 debugfs_create_x32("driver_buffered_tids", 0400,
diff --git a/net/mac80211/ethtool.c b/net/mac80211/ethtool.c
index 3fbf9c308ec5..9cc986deda61 100644
--- a/net/mac80211/ethtool.c
+++ b/net/mac80211/ethtool.c
@@ -77,19 +77,19 @@ static void ieee80211_get_stats(struct net_device *dev,
77 77
78 memset(data, 0, sizeof(u64) * STA_STATS_LEN); 78 memset(data, 0, sizeof(u64) * STA_STATS_LEN);
79 79
80#define ADD_STA_STATS(sta) \ 80#define ADD_STA_STATS(sta) \
81 do { \ 81 do { \
82 data[i++] += sta->rx_packets; \ 82 data[i++] += sta->rx_stats.packets; \
83 data[i++] += sta->rx_bytes; \ 83 data[i++] += sta->rx_stats.bytes; \
84 data[i++] += sta->num_duplicates; \ 84 data[i++] += sta->rx_stats.num_duplicates; \
85 data[i++] += sta->rx_fragments; \ 85 data[i++] += sta->rx_stats.fragments; \
86 data[i++] += sta->rx_dropped; \ 86 data[i++] += sta->rx_stats.dropped; \
87 \ 87 \
88 data[i++] += sinfo.tx_packets; \ 88 data[i++] += sinfo.tx_packets; \
89 data[i++] += sinfo.tx_bytes; \ 89 data[i++] += sinfo.tx_bytes; \
90 data[i++] += sta->tx_filtered_count; \ 90 data[i++] += sta->status_stats.filtered; \
91 data[i++] += sta->tx_retry_failed; \ 91 data[i++] += sta->status_stats.retry_failed; \
92 data[i++] += sta->tx_retry_count; \ 92 data[i++] += sta->status_stats.retry_count; \
93 } while (0) 93 } while (0)
94 94
95 /* For Managed stations, find the single station based on BSSID 95 /* For Managed stations, find the single station based on BSSID
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index bd853e7bde93..2001555d49cb 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -647,7 +647,7 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, const u8 *bssid,
647 return NULL; 647 return NULL;
648 } 648 }
649 649
650 sta->last_rx = jiffies; 650 sta->rx_stats.last_rx = jiffies;
651 651
652 /* make sure mandatory rates are always added */ 652 /* make sure mandatory rates are always added */
653 sband = local->hw.wiphy->bands[band]; 653 sband = local->hw.wiphy->bands[band];
@@ -669,7 +669,8 @@ static int ieee80211_sta_active_ibss(struct ieee80211_sub_if_data *sdata)
669 669
670 list_for_each_entry_rcu(sta, &local->sta_list, list) { 670 list_for_each_entry_rcu(sta, &local->sta_list, list) {
671 if (sta->sdata == sdata && 671 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,
673 jiffies)) { 674 jiffies)) {
674 active++; 675 active++;
675 break; 676 break;
@@ -1235,7 +1236,7 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
1235 if (!sta) 1236 if (!sta)
1236 return; 1237 return;
1237 1238
1238 sta->last_rx = jiffies; 1239 sta->rx_stats.last_rx = jiffies;
1239 1240
1240 /* make sure mandatory rates are always added */ 1241 /* make sure mandatory rates are always added */
1241 sband = local->hw.wiphy->bands[band]; 1242 sband = local->hw.wiphy->bands[band];
@@ -1253,7 +1254,7 @@ static void ieee80211_ibss_sta_expire(struct ieee80211_sub_if_data *sdata)
1253 struct ieee80211_local *local = sdata->local; 1254 struct ieee80211_local *local = sdata->local;
1254 struct sta_info *sta, *tmp; 1255 struct sta_info *sta, *tmp;
1255 unsigned long exp_time = IEEE80211_IBSS_INACTIVITY_LIMIT; 1256 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;
1257 1258
1258 mutex_lock(&local->sta_mtx); 1259 mutex_lock(&local->sta_mtx);
1259 1260
@@ -1261,8 +1262,8 @@ static void ieee80211_ibss_sta_expire(struct ieee80211_sub_if_data *sdata)
1261 if (sdata != sta->sdata) 1262 if (sdata != sta->sdata)
1262 continue; 1263 continue;
1263 1264
1264 if (time_after(jiffies, sta->last_rx + exp_time) || 1265 if (time_after(jiffies, sta->rx_stats.last_rx + exp_time) ||
1265 (time_after(jiffies, sta->last_rx + exp_rsn_time) && 1266 (time_after(jiffies, sta->rx_stats.last_rx + exp_rsn) &&
1266 sta->sta_state != IEEE80211_STA_AUTHORIZED)) { 1267 sta->sta_state != IEEE80211_STA_AUTHORIZED)) {
1267 sta_dbg(sta->sdata, "expiring inactive %sSTA %pM\n", 1268 sta_dbg(sta->sdata, "expiring inactive %sSTA %pM\n",
1268 sta->sta_state != IEEE80211_STA_AUTHORIZED ? 1269 sta->sta_state != IEEE80211_STA_AUTHORIZED ?
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index d80e0a4c16cf..c6be0b4f4058 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -329,7 +329,7 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local,
329 if (sta->mesh->fail_avg >= 100) 329 if (sta->mesh->fail_avg >= 100)
330 return MAX_METRIC; 330 return MAX_METRIC;
331 331
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);
333 rate = cfg80211_calculate_bitrate(&rinfo); 333 rate = cfg80211_calculate_bitrate(&rinfo);
334 if (WARN_ON(!rate)) 334 if (WARN_ON(!rate))
335 return MAX_METRIC; 335 return MAX_METRIC;
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index a360b24b7df8..c1f889270484 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -60,7 +60,9 @@ static bool rssi_threshold_check(struct ieee80211_sub_if_data *sdata,
60{ 60{
61 s32 rssi_threshold = sdata->u.mesh.mshcfg.rssi_threshold; 61 s32 rssi_threshold = sdata->u.mesh.mshcfg.rssi_threshold;
62 return rssi_threshold == 0 || 62 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);
64} 66}
65 67
66/** 68/**
@@ -390,7 +392,7 @@ static void mesh_sta_info_init(struct ieee80211_sub_if_data *sdata,
390 rates = ieee80211_sta_get_rates(sdata, elems, band, &basic_rates); 392 rates = ieee80211_sta_get_rates(sdata, elems, band, &basic_rates);
391 393
392 spin_lock_bh(&sta->mesh->plink_lock); 394 spin_lock_bh(&sta->mesh->plink_lock);
393 sta->last_rx = jiffies; 395 sta->rx_stats.last_rx = jiffies;
394 396
395 /* rates and capabilities don't change during peering */ 397 /* rates and capabilities don't change during peering */
396 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB && 398 if (sta->mesh->plink_state == NL80211_PLINK_ESTAB &&
diff --git a/net/mac80211/ocb.c b/net/mac80211/ocb.c
index 573b81a1fb2d..0be0aadfc559 100644
--- a/net/mac80211/ocb.c
+++ b/net/mac80211/ocb.c
@@ -75,7 +75,7 @@ void ieee80211_ocb_rx_no_sta(struct ieee80211_sub_if_data *sdata,
75 if (!sta) 75 if (!sta)
76 return; 76 return;
77 77
78 sta->last_rx = jiffies; 78 sta->rx_stats.last_rx = jiffies;
79 79
80 /* Add only mandatory rates for now */ 80 /* Add only mandatory rates for now */
81 sband = local->hw.wiphy->bands[band]; 81 sband = local->hw.wiphy->bands[band];
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 60692d964380..8bae5de0dc44 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1119,7 +1119,7 @@ ieee80211_rx_h_check_dup(struct ieee80211_rx_data *rx)
1119 if (unlikely(ieee80211_has_retry(hdr->frame_control) && 1119 if (unlikely(ieee80211_has_retry(hdr->frame_control) &&
1120 rx->sta->last_seq_ctrl[rx->seqno_idx] == hdr->seq_ctrl)) { 1120 rx->sta->last_seq_ctrl[rx->seqno_idx] == hdr->seq_ctrl)) {
1121 I802_DEBUG_INC(rx->local->dot11FrameDuplicateCount); 1121 I802_DEBUG_INC(rx->local->dot11FrameDuplicateCount);
1122 rx->sta->num_duplicates++; 1122 rx->sta->rx_stats.num_duplicates++;
1123 return RX_DROP_UNUSABLE; 1123 return RX_DROP_UNUSABLE;
1124 } else if (!(status->flag & RX_FLAG_AMSDU_MORE)) { 1124 } else if (!(status->flag & RX_FLAG_AMSDU_MORE)) {
1125 rx->sta->last_seq_ctrl[rx->seqno_idx] = hdr->seq_ctrl; 1125 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)
1396 NL80211_IFTYPE_ADHOC); 1396 NL80211_IFTYPE_ADHOC);
1397 if (ether_addr_equal(bssid, rx->sdata->u.ibss.bssid) && 1397 if (ether_addr_equal(bssid, rx->sdata->u.ibss.bssid) &&
1398 test_sta_flag(sta, WLAN_STA_AUTHORIZED)) { 1398 test_sta_flag(sta, WLAN_STA_AUTHORIZED)) {
1399 sta->last_rx = jiffies; 1399 sta->rx_stats.last_rx = jiffies;
1400 if (ieee80211_is_data(hdr->frame_control) && 1400 if (ieee80211_is_data(hdr->frame_control) &&
1401 !is_multicast_ether_addr(hdr->addr1)) { 1401 !is_multicast_ether_addr(hdr->addr1)) {
1402 sta->last_rx_rate_idx = status->rate_idx; 1402 sta->rx_stats.last_rate_idx =
1403 sta->last_rx_rate_flag = status->flag; 1403 status->rate_idx;
1404 sta->last_rx_rate_vht_flag = status->vht_flag; 1404 sta->rx_stats.last_rate_flag =
1405 sta->last_rx_rate_vht_nss = status->vht_nss; 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;
1406 } 1410 }
1407 } 1411 }
1408 } else if (rx->sdata->vif.type == NL80211_IFTYPE_OCB) { 1412 } else if (rx->sdata->vif.type == NL80211_IFTYPE_OCB) {
1409 sta->last_rx = jiffies; 1413 sta->rx_stats.last_rx = jiffies;
1410 } else if (!is_multicast_ether_addr(hdr->addr1)) { 1414 } else if (!is_multicast_ether_addr(hdr->addr1)) {
1411 /* 1415 /*
1412 * Mesh beacons will update last_rx when if they are found to 1416 * Mesh beacons will update last_rx when if they are found to
1413 * match the current local configuration when processed. 1417 * match the current local configuration when processed.
1414 */ 1418 */
1415 sta->last_rx = jiffies; 1419 sta->rx_stats.last_rx = jiffies;
1416 if (ieee80211_is_data(hdr->frame_control)) { 1420 if (ieee80211_is_data(hdr->frame_control)) {
1417 sta->last_rx_rate_idx = status->rate_idx; 1421 sta->rx_stats.last_rate_idx = status->rate_idx;
1418 sta->last_rx_rate_flag = status->flag; 1422 sta->rx_stats.last_rate_flag = status->flag;
1419 sta->last_rx_rate_vht_flag = status->vht_flag; 1423 sta->rx_stats.last_rate_vht_flag = status->vht_flag;
1420 sta->last_rx_rate_vht_nss = status->vht_nss; 1424 sta->rx_stats.last_rate_vht_nss = status->vht_nss;
1421 } 1425 }
1422 } 1426 }
1423 1427
1424 if (rx->sdata->vif.type == NL80211_IFTYPE_STATION) 1428 if (rx->sdata->vif.type == NL80211_IFTYPE_STATION)
1425 ieee80211_sta_rx_notify(rx->sdata, hdr); 1429 ieee80211_sta_rx_notify(rx->sdata, hdr);
1426 1430
1427 sta->rx_fragments++; 1431 sta->rx_stats.fragments++;
1428 sta->rx_bytes += rx->skb->len; 1432 sta->rx_stats.bytes += rx->skb->len;
1429 if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) { 1433 if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
1430 sta->last_signal = status->signal; 1434 sta->rx_stats.last_signal = status->signal;
1431 ewma_signal_add(&sta->avg_signal, -status->signal); 1435 ewma_signal_add(&sta->rx_stats.avg_signal, -status->signal);
1432 } 1436 }
1433 1437
1434 if (status->chains) { 1438 if (status->chains) {
1435 sta->chains = status->chains; 1439 sta->rx_stats.chains = status->chains;
1436 for (i = 0; i < ARRAY_SIZE(status->chain_signal); i++) { 1440 for (i = 0; i < ARRAY_SIZE(status->chain_signal); i++) {
1437 int signal = status->chain_signal[i]; 1441 int signal = status->chain_signal[i];
1438 1442
1439 if (!(status->chains & BIT(i))) 1443 if (!(status->chains & BIT(i)))
1440 continue; 1444 continue;
1441 1445
1442 sta->chain_signal_last[i] = signal; 1446 sta->rx_stats.chain_signal_last[i] = signal;
1443 ewma_signal_add(&sta->chain_signal_avg[i], -signal); 1447 ewma_signal_add(&sta->rx_stats.chain_signal_avg[i],
1448 -signal);
1444 } 1449 }
1445 } 1450 }
1446 1451
@@ -1500,7 +1505,7 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
1500 * Update counter and free packet here to avoid 1505 * Update counter and free packet here to avoid
1501 * counting this as a dropped packed. 1506 * counting this as a dropped packed.
1502 */ 1507 */
1503 sta->rx_packets++; 1508 sta->rx_stats.packets++;
1504 dev_kfree_skb(rx->skb); 1509 dev_kfree_skb(rx->skb);
1505 return RX_QUEUED; 1510 return RX_QUEUED;
1506 } 1511 }
@@ -1922,7 +1927,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
1922 ieee80211_led_rx(rx->local); 1927 ieee80211_led_rx(rx->local);
1923 out_no_led: 1928 out_no_led:
1924 if (rx->sta) 1929 if (rx->sta)
1925 rx->sta->rx_packets++; 1930 rx->sta->rx_stats.packets++;
1926 return RX_CONTINUE; 1931 return RX_CONTINUE;
1927} 1932}
1928 1933
@@ -2376,7 +2381,7 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
2376 * for non-QoS-data frames. Here we know it's a data 2381 * for non-QoS-data frames. Here we know it's a data
2377 * frame, so count MSDUs. 2382 * frame, so count MSDUs.
2378 */ 2383 */
2379 rx->sta->rx_msdu[rx->seqno_idx]++; 2384 rx->sta->rx_stats.msdu[rx->seqno_idx]++;
2380 } 2385 }
2381 2386
2382 /* 2387 /*
@@ -2413,7 +2418,7 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
2413 skb_queue_tail(&local->skb_queue_tdls_chsw, rx->skb); 2418 skb_queue_tail(&local->skb_queue_tdls_chsw, rx->skb);
2414 schedule_work(&local->tdls_chsw_work); 2419 schedule_work(&local->tdls_chsw_work);
2415 if (rx->sta) 2420 if (rx->sta)
2416 rx->sta->rx_packets++; 2421 rx->sta->rx_stats.packets++;
2417 2422
2418 return RX_QUEUED; 2423 return RX_QUEUED;
2419 } 2424 }
@@ -2875,7 +2880,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
2875 2880
2876 handled: 2881 handled:
2877 if (rx->sta) 2882 if (rx->sta)
2878 rx->sta->rx_packets++; 2883 rx->sta->rx_stats.packets++;
2879 dev_kfree_skb(rx->skb); 2884 dev_kfree_skb(rx->skb);
2880 return RX_QUEUED; 2885 return RX_QUEUED;
2881 2886
@@ -2884,7 +2889,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
2884 skb_queue_tail(&sdata->skb_queue, rx->skb); 2889 skb_queue_tail(&sdata->skb_queue, rx->skb);
2885 ieee80211_queue_work(&local->hw, &sdata->work); 2890 ieee80211_queue_work(&local->hw, &sdata->work);
2886 if (rx->sta) 2891 if (rx->sta)
2887 rx->sta->rx_packets++; 2892 rx->sta->rx_stats.packets++;
2888 return RX_QUEUED; 2893 return RX_QUEUED;
2889} 2894}
2890 2895
@@ -2911,7 +2916,7 @@ ieee80211_rx_h_userspace_mgmt(struct ieee80211_rx_data *rx)
2911 if (cfg80211_rx_mgmt(&rx->sdata->wdev, status->freq, sig, 2916 if (cfg80211_rx_mgmt(&rx->sdata->wdev, status->freq, sig,
2912 rx->skb->data, rx->skb->len, 0)) { 2917 rx->skb->data, rx->skb->len, 0)) {
2913 if (rx->sta) 2918 if (rx->sta)
2914 rx->sta->rx_packets++; 2919 rx->sta->rx_stats.packets++;
2915 dev_kfree_skb(rx->skb); 2920 dev_kfree_skb(rx->skb);
2916 return RX_QUEUED; 2921 return RX_QUEUED;
2917 } 2922 }
@@ -3030,7 +3035,7 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
3030 skb_queue_tail(&sdata->skb_queue, rx->skb); 3035 skb_queue_tail(&sdata->skb_queue, rx->skb);
3031 ieee80211_queue_work(&rx->local->hw, &sdata->work); 3036 ieee80211_queue_work(&rx->local->hw, &sdata->work);
3032 if (rx->sta) 3037 if (rx->sta)
3033 rx->sta->rx_packets++; 3038 rx->sta->rx_stats.packets++;
3034 3039
3035 return RX_QUEUED; 3040 return RX_QUEUED;
3036} 3041}
@@ -3112,7 +3117,7 @@ static void ieee80211_rx_handlers_result(struct ieee80211_rx_data *rx,
3112 case RX_DROP_MONITOR: 3117 case RX_DROP_MONITOR:
3113 I802_DEBUG_INC(rx->sdata->local->rx_handlers_drop); 3118 I802_DEBUG_INC(rx->sdata->local->rx_handlers_drop);
3114 if (rx->sta) 3119 if (rx->sta)
3115 rx->sta->rx_dropped++; 3120 rx->sta->rx_stats.dropped++;
3116 /* fall through */ 3121 /* fall through */
3117 case RX_CONTINUE: { 3122 case RX_CONTINUE: {
3118 struct ieee80211_rate *rate = NULL; 3123 struct ieee80211_rate *rate = NULL;
@@ -3132,7 +3137,7 @@ static void ieee80211_rx_handlers_result(struct ieee80211_rx_data *rx,
3132 case RX_DROP_UNUSABLE: 3137 case RX_DROP_UNUSABLE:
3133 I802_DEBUG_INC(rx->sdata->local->rx_handlers_drop); 3138 I802_DEBUG_INC(rx->sdata->local->rx_handlers_drop);
3134 if (rx->sta) 3139 if (rx->sta)
3135 rx->sta->rx_dropped++; 3140 rx->sta->rx_stats.dropped++;
3136 dev_kfree_skb(rx->skb); 3141 dev_kfree_skb(rx->skb);
3137 break; 3142 break;
3138 case RX_QUEUED: 3143 case RX_QUEUED:
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 0b8dd1cca6d8..f91d1873218c 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -331,7 +331,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
331 memcpy(sta->sta.addr, addr, ETH_ALEN); 331 memcpy(sta->sta.addr, addr, ETH_ALEN);
332 sta->local = local; 332 sta->local = local;
333 sta->sdata = sdata; 333 sta->sdata = sdata;
334 sta->last_rx = jiffies; 334 sta->rx_stats.last_rx = jiffies;
335 335
336 sta->sta_state = IEEE80211_STA_NONE; 336 sta->sta_state = IEEE80211_STA_NONE;
337 337
@@ -339,9 +339,9 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
339 sta->reserved_tid = IEEE80211_TID_UNRESERVED; 339 sta->reserved_tid = IEEE80211_TID_UNRESERVED;
340 340
341 sta->last_connected = ktime_get_seconds(); 341 sta->last_connected = ktime_get_seconds();
342 ewma_signal_init(&sta->avg_signal); 342 ewma_signal_init(&sta->rx_stats.avg_signal);
343 for (i = 0; i < ARRAY_SIZE(sta->chain_signal_avg); i++) 343 for (i = 0; i < ARRAY_SIZE(sta->rx_stats.chain_signal_avg); i++)
344 ewma_signal_init(&sta->chain_signal_avg[i]); 344 ewma_signal_init(&sta->rx_stats.chain_signal_avg[i]);
345 345
346 if (local->ops->wake_tx_queue) { 346 if (local->ops->wake_tx_queue) {
347 void *txq_data; 347 void *txq_data;
@@ -1066,7 +1066,7 @@ void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata,
1066 if (sdata != sta->sdata) 1066 if (sdata != sta->sdata)
1067 continue; 1067 continue;
1068 1068
1069 if (time_after(jiffies, sta->last_rx + exp_time)) { 1069 if (time_after(jiffies, sta->rx_stats.last_rx + exp_time)) {
1070 sta_dbg(sta->sdata, "expiring inactive STA %pM\n", 1070 sta_dbg(sta->sdata, "expiring inactive STA %pM\n",
1071 sta->sta.addr); 1071 sta->sta.addr);
1072 1072
@@ -1810,13 +1810,13 @@ static void sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo)
1810{ 1810{
1811 rinfo->flags = 0; 1811 rinfo->flags = 0;
1812 1812
1813 if (sta->last_rx_rate_flag & RX_FLAG_HT) { 1813 if (sta->rx_stats.last_rate_flag & RX_FLAG_HT) {
1814 rinfo->flags |= RATE_INFO_FLAGS_MCS; 1814 rinfo->flags |= RATE_INFO_FLAGS_MCS;
1815 rinfo->mcs = sta->last_rx_rate_idx; 1815 rinfo->mcs = sta->rx_stats.last_rate_idx;
1816 } else if (sta->last_rx_rate_flag & RX_FLAG_VHT) { 1816 } else if (sta->rx_stats.last_rate_flag & RX_FLAG_VHT) {
1817 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS; 1817 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
1818 rinfo->nss = sta->last_rx_rate_vht_nss; 1818 rinfo->nss = sta->rx_stats.last_rate_vht_nss;
1819 rinfo->mcs = sta->last_rx_rate_idx; 1819 rinfo->mcs = sta->rx_stats.last_rate_idx;
1820 } else { 1820 } else {
1821 struct ieee80211_supported_band *sband; 1821 struct ieee80211_supported_band *sband;
1822 int shift = ieee80211_vif_get_shift(&sta->sdata->vif); 1822 int shift = ieee80211_vif_get_shift(&sta->sdata->vif);
@@ -1824,22 +1824,22 @@ static void sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo)
1824 1824
1825 sband = sta->local->hw.wiphy->bands[ 1825 sband = sta->local->hw.wiphy->bands[
1826 ieee80211_get_sdata_band(sta->sdata)]; 1826 ieee80211_get_sdata_band(sta->sdata)];
1827 brate = sband->bitrates[sta->last_rx_rate_idx].bitrate; 1827 brate = sband->bitrates[sta->rx_stats.last_rate_idx].bitrate;
1828 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); 1828 rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
1829 } 1829 }
1830 1830
1831 if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI) 1831 if (sta->rx_stats.last_rate_flag & RX_FLAG_SHORT_GI)
1832 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; 1832 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
1833 1833
1834 if (sta->last_rx_rate_flag & RX_FLAG_5MHZ) 1834 if (sta->rx_stats.last_rate_flag & RX_FLAG_5MHZ)
1835 rinfo->bw = RATE_INFO_BW_5; 1835 rinfo->bw = RATE_INFO_BW_5;
1836 else if (sta->last_rx_rate_flag & RX_FLAG_10MHZ) 1836 else if (sta->rx_stats.last_rate_flag & RX_FLAG_10MHZ)
1837 rinfo->bw = RATE_INFO_BW_10; 1837 rinfo->bw = RATE_INFO_BW_10;
1838 else if (sta->last_rx_rate_flag & RX_FLAG_40MHZ) 1838 else if (sta->rx_stats.last_rate_flag & RX_FLAG_40MHZ)
1839 rinfo->bw = RATE_INFO_BW_40; 1839 rinfo->bw = RATE_INFO_BW_40;
1840 else if (sta->last_rx_rate_vht_flag & RX_VHT_FLAG_80MHZ) 1840 else if (sta->rx_stats.last_rate_vht_flag & RX_VHT_FLAG_80MHZ)
1841 rinfo->bw = RATE_INFO_BW_80; 1841 rinfo->bw = RATE_INFO_BW_80;
1842 else if (sta->last_rx_rate_vht_flag & RX_VHT_FLAG_160MHZ) 1842 else if (sta->rx_stats.last_rate_vht_flag & RX_VHT_FLAG_160MHZ)
1843 rinfo->bw = RATE_INFO_BW_160; 1843 rinfo->bw = RATE_INFO_BW_160;
1844 else 1844 else
1845 rinfo->bw = RATE_INFO_BW_20; 1845 rinfo->bw = RATE_INFO_BW_20;
@@ -1879,45 +1879,46 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
1879 } 1879 }
1880 1880
1881 sinfo->connected_time = ktime_get_seconds() - sta->last_connected; 1881 sinfo->connected_time = ktime_get_seconds() - sta->last_connected;
1882 sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); 1882 sinfo->inactive_time =
1883 jiffies_to_msecs(jiffies - sta->rx_stats.last_rx);
1883 1884
1884 if (!(sinfo->filled & (BIT(NL80211_STA_INFO_TX_BYTES64) | 1885 if (!(sinfo->filled & (BIT(NL80211_STA_INFO_TX_BYTES64) |
1885 BIT(NL80211_STA_INFO_TX_BYTES)))) { 1886 BIT(NL80211_STA_INFO_TX_BYTES)))) {
1886 sinfo->tx_bytes = 0; 1887 sinfo->tx_bytes = 0;
1887 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) 1888 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
1888 sinfo->tx_bytes += sta->tx_bytes[ac]; 1889 sinfo->tx_bytes += sta->tx_stats.bytes[ac];
1889 sinfo->filled |= BIT(NL80211_STA_INFO_TX_BYTES64); 1890 sinfo->filled |= BIT(NL80211_STA_INFO_TX_BYTES64);
1890 } 1891 }
1891 1892
1892 if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_PACKETS))) { 1893 if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_PACKETS))) {
1893 sinfo->tx_packets = 0; 1894 sinfo->tx_packets = 0;
1894 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) 1895 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
1895 sinfo->tx_packets += sta->tx_packets[ac]; 1896 sinfo->tx_packets += sta->tx_stats.packets[ac];
1896 sinfo->filled |= BIT(NL80211_STA_INFO_TX_PACKETS); 1897 sinfo->filled |= BIT(NL80211_STA_INFO_TX_PACKETS);
1897 } 1898 }
1898 1899
1899 if (!(sinfo->filled & (BIT(NL80211_STA_INFO_RX_BYTES64) | 1900 if (!(sinfo->filled & (BIT(NL80211_STA_INFO_RX_BYTES64) |
1900 BIT(NL80211_STA_INFO_RX_BYTES)))) { 1901 BIT(NL80211_STA_INFO_RX_BYTES)))) {
1901 sinfo->rx_bytes = sta->rx_bytes; 1902 sinfo->rx_bytes = sta->rx_stats.bytes;
1902 sinfo->filled |= BIT(NL80211_STA_INFO_RX_BYTES64); 1903 sinfo->filled |= BIT(NL80211_STA_INFO_RX_BYTES64);
1903 } 1904 }
1904 1905
1905 if (!(sinfo->filled & BIT(NL80211_STA_INFO_RX_PACKETS))) { 1906 if (!(sinfo->filled & BIT(NL80211_STA_INFO_RX_PACKETS))) {
1906 sinfo->rx_packets = sta->rx_packets; 1907 sinfo->rx_packets = sta->rx_stats.packets;
1907 sinfo->filled |= BIT(NL80211_STA_INFO_RX_PACKETS); 1908 sinfo->filled |= BIT(NL80211_STA_INFO_RX_PACKETS);
1908 } 1909 }
1909 1910
1910 if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_RETRIES))) { 1911 if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_RETRIES))) {
1911 sinfo->tx_retries = sta->tx_retry_count; 1912 sinfo->tx_retries = sta->status_stats.retry_count;
1912 sinfo->filled |= BIT(NL80211_STA_INFO_TX_RETRIES); 1913 sinfo->filled |= BIT(NL80211_STA_INFO_TX_RETRIES);
1913 } 1914 }
1914 1915
1915 if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_FAILED))) { 1916 if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_FAILED))) {
1916 sinfo->tx_failed = sta->tx_retry_failed; 1917 sinfo->tx_failed = sta->status_stats.retry_failed;
1917 sinfo->filled |= BIT(NL80211_STA_INFO_TX_FAILED); 1918 sinfo->filled |= BIT(NL80211_STA_INFO_TX_FAILED);
1918 } 1919 }
1919 1920
1920 sinfo->rx_dropped_misc = sta->rx_dropped; 1921 sinfo->rx_dropped_misc = sta->rx_stats.dropped;
1921 1922
1922 if (sdata->vif.type == NL80211_IFTYPE_STATION && 1923 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
1923 !(sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)) { 1924 !(sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)) {
@@ -1929,33 +1930,35 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
1929 if (ieee80211_hw_check(&sta->local->hw, SIGNAL_DBM) || 1930 if (ieee80211_hw_check(&sta->local->hw, SIGNAL_DBM) ||
1930 ieee80211_hw_check(&sta->local->hw, SIGNAL_UNSPEC)) { 1931 ieee80211_hw_check(&sta->local->hw, SIGNAL_UNSPEC)) {
1931 if (!(sinfo->filled & BIT(NL80211_STA_INFO_SIGNAL))) { 1932 if (!(sinfo->filled & BIT(NL80211_STA_INFO_SIGNAL))) {
1932 sinfo->signal = (s8)sta->last_signal; 1933 sinfo->signal = (s8)sta->rx_stats.last_signal;
1933 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); 1934 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
1934 } 1935 }
1935 1936
1936 if (!(sinfo->filled & BIT(NL80211_STA_INFO_SIGNAL_AVG))) { 1937 if (!(sinfo->filled & BIT(NL80211_STA_INFO_SIGNAL_AVG))) {
1937 sinfo->signal_avg = 1938 sinfo->signal_avg =
1938 (s8) -ewma_signal_read(&sta->avg_signal); 1939 -ewma_signal_read(&sta->rx_stats.avg_signal);
1939 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL_AVG); 1940 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL_AVG);
1940 } 1941 }
1941 } 1942 }
1942 1943
1943 if (sta->chains && 1944 if (sta->rx_stats.chains &&
1944 !(sinfo->filled & (BIT(NL80211_STA_INFO_CHAIN_SIGNAL) | 1945 !(sinfo->filled & (BIT(NL80211_STA_INFO_CHAIN_SIGNAL) |
1945 BIT(NL80211_STA_INFO_CHAIN_SIGNAL_AVG)))) { 1946 BIT(NL80211_STA_INFO_CHAIN_SIGNAL_AVG)))) {
1946 sinfo->filled |= BIT(NL80211_STA_INFO_CHAIN_SIGNAL) | 1947 sinfo->filled |= BIT(NL80211_STA_INFO_CHAIN_SIGNAL) |
1947 BIT(NL80211_STA_INFO_CHAIN_SIGNAL_AVG); 1948 BIT(NL80211_STA_INFO_CHAIN_SIGNAL_AVG);
1948 1949
1949 sinfo->chains = sta->chains; 1950 sinfo->chains = sta->rx_stats.chains;
1950 for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) { 1951 for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) {
1951 sinfo->chain_signal[i] = sta->chain_signal_last[i]; 1952 sinfo->chain_signal[i] =
1953 sta->rx_stats.chain_signal_last[i];
1952 sinfo->chain_signal_avg[i] = 1954 sinfo->chain_signal_avg[i] =
1953 (s8) -ewma_signal_read(&sta->chain_signal_avg[i]); 1955 -ewma_signal_read(&sta->rx_stats.chain_signal_avg[i]);
1954 } 1956 }
1955 } 1957 }
1956 1958
1957 if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_BITRATE))) { 1959 if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_BITRATE))) {
1958 sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate); 1960 sta_set_rate_info_tx(sta, &sta->tx_stats.last_rate,
1961 &sinfo->txrate);
1959 sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE); 1962 sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE);
1960 } 1963 }
1961 1964
@@ -1970,12 +1973,12 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
1970 1973
1971 if (!(tidstats->filled & BIT(NL80211_TID_STATS_RX_MSDU))) { 1974 if (!(tidstats->filled & BIT(NL80211_TID_STATS_RX_MSDU))) {
1972 tidstats->filled |= BIT(NL80211_TID_STATS_RX_MSDU); 1975 tidstats->filled |= BIT(NL80211_TID_STATS_RX_MSDU);
1973 tidstats->rx_msdu = sta->rx_msdu[i]; 1976 tidstats->rx_msdu = sta->rx_stats.msdu[i];
1974 } 1977 }
1975 1978
1976 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU))) { 1979 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU))) {
1977 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU); 1980 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU);
1978 tidstats->tx_msdu = sta->tx_msdu[i]; 1981 tidstats->tx_msdu = sta->tx_stats.msdu[i];
1979 } 1982 }
1980 1983
1981 if (!(tidstats->filled & 1984 if (!(tidstats->filled &
@@ -1983,7 +1986,8 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
1983 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { 1986 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
1984 tidstats->filled |= 1987 tidstats->filled |=
1985 BIT(NL80211_TID_STATS_TX_MSDU_RETRIES); 1988 BIT(NL80211_TID_STATS_TX_MSDU_RETRIES);
1986 tidstats->tx_msdu_retries = sta->tx_msdu_retries[i]; 1989 tidstats->tx_msdu_retries =
1990 sta->status_stats.msdu_retries[i];
1987 } 1991 }
1988 1992
1989 if (!(tidstats->filled & 1993 if (!(tidstats->filled &
@@ -1991,7 +1995,8 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
1991 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { 1995 ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
1992 tidstats->filled |= 1996 tidstats->filled |=
1993 BIT(NL80211_TID_STATS_TX_MSDU_FAILED); 1997 BIT(NL80211_TID_STATS_TX_MSDU_FAILED);
1994 tidstats->tx_msdu_failed = sta->tx_msdu_failed[i]; 1998 tidstats->tx_msdu_failed =
1999 sta->status_stats.msdu_failed[i];
1995 } 2000 }
1996 } 2001 }
1997 2002
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 3a401d40c329..2cafb21b422f 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -344,12 +344,6 @@ DECLARE_EWMA(signal, 1024, 8)
344 * @rate_ctrl_lock: spinlock used to protect rate control data 344 * @rate_ctrl_lock: spinlock used to protect rate control data
345 * (data inside the algorithm, so serializes calls there) 345 * (data inside the algorithm, so serializes calls there)
346 * @rate_ctrl_priv: rate control private per-STA pointer 346 * @rate_ctrl_priv: rate control private per-STA pointer
347 * @last_tx_rate: rate used for last transmit, to report to userspace as
348 * "the" transmit rate
349 * @last_rx_rate_idx: rx status rate index of the last data packet
350 * @last_rx_rate_flag: rx status flag of the last data packet
351 * @last_rx_rate_vht_flag: rx status vht flag of the last data packet
352 * @last_rx_rate_vht_nss: rx status nss of last data packet
353 * @lock: used for locking all fields that require locking, see comments 347 * @lock: used for locking all fields that require locking, see comments
354 * in the header file. 348 * in the header file.
355 * @drv_deliver_wk: used for delivering frames after driver PS unblocking 349 * @drv_deliver_wk: used for delivering frames after driver PS unblocking
@@ -364,22 +358,9 @@ DECLARE_EWMA(signal, 1024, 8)
364 * the station when it leaves powersave or polls for frames 358 * the station when it leaves powersave or polls for frames
365 * @driver_buffered_tids: bitmap of TIDs the driver has data buffered on 359 * @driver_buffered_tids: bitmap of TIDs the driver has data buffered on
366 * @txq_buffered_tids: bitmap of TIDs that mac80211 has txq data buffered on 360 * @txq_buffered_tids: bitmap of TIDs that mac80211 has txq data buffered on
367 * @rx_packets: Number of MSDUs received from this STA
368 * @rx_bytes: Number of bytes received from this STA
369 * @last_rx: time (in jiffies) when last frame was received from this STA
370 * @last_connected: time (in seconds) when a station got connected 361 * @last_connected: time (in seconds) when a station got connected
371 * @num_duplicates: number of duplicate frames received from this STA
372 * @rx_fragments: number of received MPDUs
373 * @rx_dropped: number of dropped MPDUs from this STA
374 * @last_signal: signal of last received frame from this STA
375 * @avg_signal: moving average of signal of received frames from this STA
376 * @last_seq_ctrl: last received seq/frag number from this STA (per TID 362 * @last_seq_ctrl: last received seq/frag number from this STA (per TID
377 * plus one for non-QoS frames) 363 * plus one for non-QoS frames)
378 * @tx_filtered_count: number of frames the hardware filtered for this STA
379 * @tx_retry_failed: number of frames that failed retry
380 * @tx_retry_count: total number of retries for frames to this STA
381 * @tx_packets: number of RX/TX MSDUs
382 * @tx_bytes: number of bytes transmitted to this STA
383 * @tid_seq: per-TID sequence numbers for sending to this STA 364 * @tid_seq: per-TID sequence numbers for sending to this STA
384 * @ampdu_mlme: A-MPDU state machine state 365 * @ampdu_mlme: A-MPDU state machine state
385 * @timer_to_tid: identity mapping to ID timers 366 * @timer_to_tid: identity mapping to ID timers
@@ -387,32 +368,22 @@ DECLARE_EWMA(signal, 1024, 8)
387 * @debugfs: debug filesystem info 368 * @debugfs: debug filesystem info
388 * @dead: set to true when sta is unlinked 369 * @dead: set to true when sta is unlinked
389 * @uploaded: set to true when sta is uploaded to the driver 370 * @uploaded: set to true when sta is uploaded to the driver
390 * @lost_packets: number of consecutive lost packets
391 * @sta: station information we share with the driver 371 * @sta: station information we share with the driver
392 * @sta_state: duplicates information about station state (for debug) 372 * @sta_state: duplicates information about station state (for debug)
393 * @beacon_loss_count: number of times beacon loss has triggered 373 * @beacon_loss_count: number of times beacon loss has triggered
394 * @rcu_head: RCU head used for freeing this station struct 374 * @rcu_head: RCU head used for freeing this station struct
395 * @cur_max_bandwidth: maximum bandwidth to use for TX to the station, 375 * @cur_max_bandwidth: maximum bandwidth to use for TX to the station,
396 * taken from HT/VHT capabilities or VHT operating mode notification 376 * taken from HT/VHT capabilities or VHT operating mode notification
397 * @chains: chains ever used for RX from this station
398 * @chain_signal_last: last signal (per chain)
399 * @chain_signal_avg: signal average (per chain)
400 * @known_smps_mode: the smps_mode the client thinks we are in. Relevant for 377 * @known_smps_mode: the smps_mode the client thinks we are in. Relevant for
401 * AP only. 378 * AP only.
402 * @cipher_scheme: optional cipher scheme for this station 379 * @cipher_scheme: optional cipher scheme for this station
403 * @last_tdls_pkt_time: holds the time in jiffies of last TDLS pkt ACKed
404 * @reserved_tid: reserved TID (if any, otherwise IEEE80211_TID_UNRESERVED) 380 * @reserved_tid: reserved TID (if any, otherwise IEEE80211_TID_UNRESERVED)
405 * @tx_msdu: MSDUs transmitted to this station, using IEEE80211_NUM_TID
406 * entry for non-QoS frames
407 * @tx_msdu_retries: MSDU retries for transmissions to to this station,
408 * using IEEE80211_NUM_TID entry for non-QoS frames
409 * @tx_msdu_failed: MSDU failures for transmissions to to this station,
410 * using IEEE80211_NUM_TID entry for non-QoS frames
411 * @rx_msdu: MSDUs received from this station, using IEEE80211_NUM_TID
412 * entry for non-QoS frames
413 * @fast_tx: TX fastpath information 381 * @fast_tx: TX fastpath information
414 * @tdls_chandef: a TDLS peer can have a wider chandef that is compatible to 382 * @tdls_chandef: a TDLS peer can have a wider chandef that is compatible to
415 * the BSS one. 383 * the BSS one.
384 * @tx_stats: TX statistics
385 * @rx_stats: RX statistics
386 * @status_stats: TX status statistics
416 */ 387 */
417struct sta_info { 388struct sta_info {
418 /* General information, mostly static */ 389 /* General information, mostly static */
@@ -456,41 +427,49 @@ struct sta_info {
456 unsigned long driver_buffered_tids; 427 unsigned long driver_buffered_tids;
457 unsigned long txq_buffered_tids; 428 unsigned long txq_buffered_tids;
458 429
459 /* Updated from RX path only, no locking requirements */
460 unsigned long rx_packets;
461 u64 rx_bytes;
462 unsigned long last_rx;
463 long last_connected; 430 long last_connected;
464 unsigned long num_duplicates;
465 unsigned long rx_fragments;
466 unsigned long rx_dropped;
467 int last_signal;
468 struct ewma_signal avg_signal;
469 431
470 u8 chains; 432 /* Updated from RX path only, no locking requirements */
471 s8 chain_signal_last[IEEE80211_MAX_CHAINS]; 433 struct {
472 struct ewma_signal chain_signal_avg[IEEE80211_MAX_CHAINS]; 434 unsigned long packets;
435 u64 bytes;
436 unsigned long last_rx;
437 unsigned long num_duplicates;
438 unsigned long fragments;
439 unsigned long dropped;
440 int last_signal;
441 struct ewma_signal avg_signal;
442 u8 chains;
443 s8 chain_signal_last[IEEE80211_MAX_CHAINS];
444 struct ewma_signal chain_signal_avg[IEEE80211_MAX_CHAINS];
445 int last_rate_idx;
446 u32 last_rate_flag;
447 u32 last_rate_vht_flag;
448 u8 last_rate_vht_nss;
449 u64 msdu[IEEE80211_NUM_TIDS + 1];
450 } rx_stats;
473 451
474 /* Plus 1 for non-QoS frames */ 452 /* Plus 1 for non-QoS frames */
475 __le16 last_seq_ctrl[IEEE80211_NUM_TIDS + 1]; 453 __le16 last_seq_ctrl[IEEE80211_NUM_TIDS + 1];
476 454
477 /* Updated from TX status path only, no locking requirements */ 455 /* Updated from TX status path only, no locking requirements */
478 unsigned long tx_filtered_count; 456 struct {
479 unsigned long tx_retry_failed, tx_retry_count; 457 unsigned long filtered;
458 unsigned long retry_failed, retry_count;
459 unsigned int lost_packets;
460 unsigned long last_tdls_pkt_time;
461 u64 msdu_retries[IEEE80211_NUM_TIDS + 1];
462 u64 msdu_failed[IEEE80211_NUM_TIDS + 1];
463 } status_stats;
480 464
481 /* Updated from TX path only, no locking requirements */ 465 /* Updated from TX path only, no locking requirements */
482 u64 tx_packets[IEEE80211_NUM_ACS]; 466 struct {
483 u64 tx_bytes[IEEE80211_NUM_ACS]; 467 u64 packets[IEEE80211_NUM_ACS];
484 struct ieee80211_tx_rate last_tx_rate; 468 u64 bytes[IEEE80211_NUM_ACS];
485 int last_rx_rate_idx; 469 struct ieee80211_tx_rate last_rate;
486 u32 last_rx_rate_flag; 470 u64 msdu[IEEE80211_NUM_TIDS + 1];
487 u32 last_rx_rate_vht_flag; 471 } tx_stats;
488 u8 last_rx_rate_vht_nss;
489 u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1]; 472 u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
490 u64 tx_msdu[IEEE80211_NUM_TIDS + 1];
491 u64 tx_msdu_retries[IEEE80211_NUM_TIDS + 1];
492 u64 tx_msdu_failed[IEEE80211_NUM_TIDS + 1];
493 u64 rx_msdu[IEEE80211_NUM_TIDS + 1];
494 473
495 /* 474 /*
496 * Aggregation information, locked with lock. 475 * Aggregation information, locked with lock.
@@ -507,14 +486,9 @@ struct sta_info {
507 486
508 enum ieee80211_sta_rx_bandwidth cur_max_bandwidth; 487 enum ieee80211_sta_rx_bandwidth cur_max_bandwidth;
509 488
510 unsigned int lost_packets;
511
512 enum ieee80211_smps_mode known_smps_mode; 489 enum ieee80211_smps_mode known_smps_mode;
513 const struct ieee80211_cipher_scheme *cipher_scheme; 490 const struct ieee80211_cipher_scheme *cipher_scheme;
514 491
515 /* TDLS timeout data */
516 unsigned long last_tdls_pkt_time;
517
518 u8 reserved_tid; 492 u8 reserved_tid;
519 493
520 struct cfg80211_chan_def tdls_chandef; 494 struct cfg80211_chan_def tdls_chandef;
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index da67b84905a8..7d14bbf8682b 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -67,7 +67,7 @@ static void ieee80211_handle_filtered_frame(struct ieee80211_local *local,
67 IEEE80211_TX_INTFL_RETRANSMISSION; 67 IEEE80211_TX_INTFL_RETRANSMISSION;
68 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; 68 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS;
69 69
70 sta->tx_filtered_count++; 70 sta->status_stats.filtered++;
71 71
72 /* 72 /*
73 * Clear more-data bit on filtered frames, it might be set 73 * Clear more-data bit on filtered frames, it might be set
@@ -182,7 +182,7 @@ static void ieee80211_frame_acked(struct sta_info *sta, struct sk_buff *skb)
182 struct ieee80211_sub_if_data *sdata = sta->sdata; 182 struct ieee80211_sub_if_data *sdata = sta->sdata;
183 183
184 if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) 184 if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS))
185 sta->last_rx = jiffies; 185 sta->rx_stats.last_rx = jiffies;
186 186
187 if (ieee80211_is_data_qos(mgmt->frame_control)) { 187 if (ieee80211_is_data_qos(mgmt->frame_control)) {
188 struct ieee80211_hdr *hdr = (void *) skb->data; 188 struct ieee80211_hdr *hdr = (void *) skb->data;
@@ -556,8 +556,9 @@ static void ieee80211_lost_packet(struct sta_info *sta,
556 !(info->flags & IEEE80211_TX_STAT_AMPDU)) 556 !(info->flags & IEEE80211_TX_STAT_AMPDU))
557 return; 557 return;
558 558
559 sta->lost_packets++; 559 sta->status_stats.lost_packets++;
560 if (!sta->sta.tdls && sta->lost_packets < STA_LOST_PKT_THRESHOLD) 560 if (!sta->sta.tdls &&
561 sta->status_stats.lost_packets < STA_LOST_PKT_THRESHOLD)
561 return; 562 return;
562 563
563 /* 564 /*
@@ -567,14 +568,15 @@ static void ieee80211_lost_packet(struct sta_info *sta,
567 * mechanism. 568 * mechanism.
568 */ 569 */
569 if (sta->sta.tdls && 570 if (sta->sta.tdls &&
570 (sta->lost_packets < STA_LOST_TDLS_PKT_THRESHOLD || 571 (sta->status_stats.lost_packets < STA_LOST_TDLS_PKT_THRESHOLD ||
571 time_before(jiffies, 572 time_before(jiffies,
572 sta->last_tdls_pkt_time + STA_LOST_TDLS_PKT_TIME))) 573 sta->status_stats.last_tdls_pkt_time +
574 STA_LOST_TDLS_PKT_TIME)))
573 return; 575 return;
574 576
575 cfg80211_cqm_pktloss_notify(sta->sdata->dev, sta->sta.addr, 577 cfg80211_cqm_pktloss_notify(sta->sdata->dev, sta->sta.addr,
576 sta->lost_packets, GFP_ATOMIC); 578 sta->status_stats.lost_packets, GFP_ATOMIC);
577 sta->lost_packets = 0; 579 sta->status_stats.lost_packets = 0;
578} 580}
579 581
580static int ieee80211_tx_get_rates(struct ieee80211_hw *hw, 582static int ieee80211_tx_get_rates(struct ieee80211_hw *hw,
@@ -635,18 +637,18 @@ void ieee80211_tx_status_noskb(struct ieee80211_hw *hw,
635 sta = container_of(pubsta, struct sta_info, sta); 637 sta = container_of(pubsta, struct sta_info, sta);
636 638
637 if (!acked) 639 if (!acked)
638 sta->tx_retry_failed++; 640 sta->status_stats.retry_failed++;
639 sta->tx_retry_count += retry_count; 641 sta->status_stats.retry_count += retry_count;
640 642
641 if (acked) { 643 if (acked) {
642 sta->last_rx = jiffies; 644 sta->rx_stats.last_rx = jiffies;
643 645
644 if (sta->lost_packets) 646 if (sta->status_stats.lost_packets)
645 sta->lost_packets = 0; 647 sta->status_stats.lost_packets = 0;
646 648
647 /* Track when last TDLS packet was ACKed */ 649 /* Track when last TDLS packet was ACKed */
648 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH)) 650 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH))
649 sta->last_tdls_pkt_time = jiffies; 651 sta->status_stats.last_tdls_pkt_time = jiffies;
650 } else { 652 } else {
651 ieee80211_lost_packet(sta, info); 653 ieee80211_lost_packet(sta, info);
652 } 654 }
@@ -783,7 +785,8 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
783 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL) && 785 if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL) &&
784 (ieee80211_is_data(hdr->frame_control)) && 786 (ieee80211_is_data(hdr->frame_control)) &&
785 (rates_idx != -1)) 787 (rates_idx != -1))
786 sta->last_tx_rate = info->status.rates[rates_idx]; 788 sta->tx_stats.last_rate =
789 info->status.rates[rates_idx];
787 790
788 if ((info->flags & IEEE80211_TX_STAT_AMPDU_NO_BACK) && 791 if ((info->flags & IEEE80211_TX_STAT_AMPDU_NO_BACK) &&
789 (ieee80211_is_data_qos(fc))) { 792 (ieee80211_is_data_qos(fc))) {
@@ -829,13 +832,15 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
829 return; 832 return;
830 } else { 833 } else {
831 if (!acked) 834 if (!acked)
832 sta->tx_retry_failed++; 835 sta->status_stats.retry_failed++;
833 sta->tx_retry_count += retry_count; 836 sta->status_stats.retry_count += retry_count;
834 837
835 if (ieee80211_is_data_present(fc)) { 838 if (ieee80211_is_data_present(fc)) {
836 if (!acked) 839 if (!acked)
837 sta->tx_msdu_failed[tid]++; 840 sta->status_stats.msdu_failed[tid]++;
838 sta->tx_msdu_retries[tid] += retry_count; 841
842 sta->status_stats.msdu_retries[tid] +=
843 retry_count;
839 } 844 }
840 } 845 }
841 846
@@ -853,12 +858,13 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
853 858
854 if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) { 859 if (ieee80211_hw_check(&local->hw, REPORTS_TX_ACK_STATUS)) {
855 if (info->flags & IEEE80211_TX_STAT_ACK) { 860 if (info->flags & IEEE80211_TX_STAT_ACK) {
856 if (sta->lost_packets) 861 if (sta->status_stats.lost_packets)
857 sta->lost_packets = 0; 862 sta->status_stats.lost_packets = 0;
858 863
859 /* Track when last TDLS packet was ACKed */ 864 /* Track when last TDLS packet was ACKed */
860 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH)) 865 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH))
861 sta->last_tdls_pkt_time = jiffies; 866 sta->status_stats.last_tdls_pkt_time =
867 jiffies;
862 } else { 868 } else {
863 ieee80211_lost_packet(sta, info); 869 ieee80211_lost_packet(sta, info);
864 } 870 }
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 464ba1a625bd..09e38a860a59 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -757,9 +757,9 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
757 if (txrc.reported_rate.idx < 0) { 757 if (txrc.reported_rate.idx < 0) {
758 txrc.reported_rate = tx->rate; 758 txrc.reported_rate = tx->rate;
759 if (tx->sta && ieee80211_is_data(hdr->frame_control)) 759 if (tx->sta && ieee80211_is_data(hdr->frame_control))
760 tx->sta->last_tx_rate = txrc.reported_rate; 760 tx->sta->tx_stats.last_rate = txrc.reported_rate;
761 } else if (tx->sta) 761 } else if (tx->sta)
762 tx->sta->last_tx_rate = txrc.reported_rate; 762 tx->sta->tx_stats.last_rate = txrc.reported_rate;
763 763
764 if (ratetbl) 764 if (ratetbl)
765 return TX_CONTINUE; 765 return TX_CONTINUE;
@@ -824,7 +824,7 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
824 hdr->seq_ctrl = cpu_to_le16(tx->sdata->sequence_number); 824 hdr->seq_ctrl = cpu_to_le16(tx->sdata->sequence_number);
825 tx->sdata->sequence_number += 0x10; 825 tx->sdata->sequence_number += 0x10;
826 if (tx->sta) 826 if (tx->sta)
827 tx->sta->tx_msdu[IEEE80211_NUM_TIDS]++; 827 tx->sta->tx_stats.msdu[IEEE80211_NUM_TIDS]++;
828 return TX_CONTINUE; 828 return TX_CONTINUE;
829 } 829 }
830 830
@@ -840,7 +840,7 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
840 840
841 qc = ieee80211_get_qos_ctl(hdr); 841 qc = ieee80211_get_qos_ctl(hdr);
842 tid = *qc & IEEE80211_QOS_CTL_TID_MASK; 842 tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
843 tx->sta->tx_msdu[tid]++; 843 tx->sta->tx_stats.msdu[tid]++;
844 844
845 if (!tx->sta->sta.txq[0]) 845 if (!tx->sta->sta.txq[0])
846 hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid); 846 hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid);
@@ -994,10 +994,10 @@ ieee80211_tx_h_stats(struct ieee80211_tx_data *tx)
994 994
995 skb_queue_walk(&tx->skbs, skb) { 995 skb_queue_walk(&tx->skbs, skb) {
996 ac = skb_get_queue_mapping(skb); 996 ac = skb_get_queue_mapping(skb);
997 tx->sta->tx_bytes[ac] += skb->len; 997 tx->sta->tx_stats.bytes[ac] += skb->len;
998 } 998 }
999 if (ac >= 0) 999 if (ac >= 0)
1000 tx->sta->tx_packets[ac]++; 1000 tx->sta->tx_stats.packets[ac]++;
1001 1001
1002 return TX_CONTINUE; 1002 return TX_CONTINUE;
1003} 1003}
@@ -2776,10 +2776,10 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
2776 } 2776 }
2777 2777
2778 if (skb_shinfo(skb)->gso_size) 2778 if (skb_shinfo(skb)->gso_size)
2779 sta->tx_msdu[tid] += 2779 sta->tx_stats.msdu[tid] +=
2780 DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size); 2780 DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size);
2781 else 2781 else
2782 sta->tx_msdu[tid]++; 2782 sta->tx_stats.msdu[tid]++;
2783 2783
2784 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; 2784 info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
2785 2785
@@ -2810,8 +2810,8 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
2810 /* statistics normally done by ieee80211_tx_h_stats (but that 2810 /* statistics normally done by ieee80211_tx_h_stats (but that
2811 * has to consider fragmentation, so is more complex) 2811 * has to consider fragmentation, so is more complex)
2812 */ 2812 */
2813 sta->tx_bytes[skb_get_queue_mapping(skb)] += skb->len; 2813 sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
2814 sta->tx_packets[skb_get_queue_mapping(skb)]++; 2814 sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
2815 2815
2816 if (fast_tx->pn_offs) { 2816 if (fast_tx->pn_offs) {
2817 u64 pn; 2817 u64 pn;