sta_info.c (0d7043f355d0045bd38b025630a7defefa3ec07f) sta_info.c (b16798f5b907733966fd1a558fca823b3c67e4a1)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
5 * Copyright 2013-2014 Intel Mobile Communications GmbH
6 * Copyright (C) 2015 - 2017 Intel Deutschland GmbH
7 * Copyright (C) 2018-2020 Intel Corporation
8 */

--- 1035 unchanged lines hidden (view full) ---

1044 /*
1045 * NOTE: This assumes at least synchronize_net() was done
1046 * after _part1 and before _part2!
1047 */
1048
1049 might_sleep();
1050 lockdep_assert_held(&local->sta_mtx);
1051
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright 2002-2005, Instant802 Networks, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
5 * Copyright 2013-2014 Intel Mobile Communications GmbH
6 * Copyright (C) 2015 - 2017 Intel Deutschland GmbH
7 * Copyright (C) 2018-2020 Intel Corporation
8 */

--- 1035 unchanged lines hidden (view full) ---

1044 /*
1045 * NOTE: This assumes at least synchronize_net() was done
1046 * after _part1 and before _part2!
1047 */
1048
1049 might_sleep();
1050 lockdep_assert_held(&local->sta_mtx);
1051
1052 while (sta->sta_state == IEEE80211_STA_AUTHORIZED) {
1053 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1054 WARN_ON_ONCE(ret);
1055 }
1056
1052 /* now keys can no longer be reached */
1053 ieee80211_free_sta_keys(local, sta);
1054
1055 /* disable TIM bit - last chance to tell driver */
1056 __sta_info_recalc_tim(sta, true);
1057
1058 sta->dead = true;
1059

--- 286 unchanged lines hidden (view full) ---

1346 * so clear these flags now to avoid them sticking around.
1347 */
1348 clear_sta_flag(sta, WLAN_STA_PSPOLL);
1349 clear_sta_flag(sta, WLAN_STA_UAPSD);
1350 spin_unlock(&sta->ps_lock);
1351
1352 atomic_dec(&ps->num_sta_ps);
1353
1057 /* now keys can no longer be reached */
1058 ieee80211_free_sta_keys(local, sta);
1059
1060 /* disable TIM bit - last chance to tell driver */
1061 __sta_info_recalc_tim(sta, true);
1062
1063 sta->dead = true;
1064

--- 286 unchanged lines hidden (view full) ---

1351 * so clear these flags now to avoid them sticking around.
1352 */
1353 clear_sta_flag(sta, WLAN_STA_PSPOLL);
1354 clear_sta_flag(sta, WLAN_STA_UAPSD);
1355 spin_unlock(&sta->ps_lock);
1356
1357 atomic_dec(&ps->num_sta_ps);
1358
1359 /* This station just woke up and isn't aware of our SMPS state */
1360 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
1361 !ieee80211_smps_is_restrictive(sta->known_smps_mode,
1362 sdata->smps_mode) &&
1363 sta->known_smps_mode != sdata->bss->req_smps &&
1364 sta_info_tx_streams(sta) != 1) {
1365 ht_dbg(sdata,
1366 "%pM just woke up and MIMO capable - update SMPS\n",
1367 sta->sta.addr);
1368 ieee80211_send_smps_action(sdata, sdata->bss->req_smps,
1369 sta->sta.addr,
1370 sdata->vif.bss_conf.bssid);
1371 }
1372
1354 local->total_ps_buffered -= buffered;
1355
1356 sta_info_recalc_tim(sta);
1357
1358 ps_dbg(sdata,
1359 "STA %pM aid %d sending %d filtered/%d PS frames since STA woke up\n",
1360 sta->sta.addr, sta->sta.aid, filtered, buffered);
1361

--- 783 unchanged lines hidden (view full) ---

2145
2146 if (rate == STA_STATS_RATE_INVALID)
2147 return -EINVAL;
2148
2149 sta_stats_decode_rate(sta->local, rate, rinfo);
2150 return 0;
2151}
2152
1373 local->total_ps_buffered -= buffered;
1374
1375 sta_info_recalc_tim(sta);
1376
1377 ps_dbg(sdata,
1378 "STA %pM aid %d sending %d filtered/%d PS frames since STA woke up\n",
1379 sta->sta.addr, sta->sta.aid, filtered, buffered);
1380

--- 783 unchanged lines hidden (view full) ---

2164
2165 if (rate == STA_STATS_RATE_INVALID)
2166 return -EINVAL;
2167
2168 sta_stats_decode_rate(sta->local, rate, rinfo);
2169 return 0;
2170}
2171
2153static inline u64 sta_get_tidstats_msdu(struct ieee80211_sta_rx_stats *rxstats,
2154 int tid)
2155{
2156 unsigned int start;
2157 u64 value;
2158
2159 do {
2160 start = u64_stats_fetch_begin(&rxstats->syncp);
2161 value = rxstats->msdu[tid];
2162 } while (u64_stats_fetch_retry(&rxstats->syncp, start));
2163
2164 return value;
2165}
2166
2167static void sta_set_tidstats(struct sta_info *sta,
2168 struct cfg80211_tid_stats *tidstats,
2169 int tid)
2170{
2171 struct ieee80211_local *local = sta->local;
2172static void sta_set_tidstats(struct sta_info *sta,
2173 struct cfg80211_tid_stats *tidstats,
2174 int tid)
2175{
2176 struct ieee80211_local *local = sta->local;
2172 int cpu;
2173
2174 if (!(tidstats->filled & BIT(NL80211_TID_STATS_RX_MSDU))) {
2177
2178 if (!(tidstats->filled & BIT(NL80211_TID_STATS_RX_MSDU))) {
2175 if (!ieee80211_hw_check(&local->hw, USES_RSS))
2176 tidstats->rx_msdu +=
2177 sta_get_tidstats_msdu(&sta->rx_stats, tid);
2179 unsigned int start;
2178
2180
2179 if (sta->pcpu_rx_stats) {
2180 for_each_possible_cpu(cpu) {
2181 struct ieee80211_sta_rx_stats *cpurxs;
2181 do {
2182 start = u64_stats_fetch_begin(&sta->rx_stats.syncp);
2183 tidstats->rx_msdu = sta->rx_stats.msdu[tid];
2184 } while (u64_stats_fetch_retry(&sta->rx_stats.syncp, start));
2182
2185
2183 cpurxs = per_cpu_ptr(sta->pcpu_rx_stats, cpu);
2184 tidstats->rx_msdu +=
2185 sta_get_tidstats_msdu(cpurxs, tid);
2186 }
2187 }
2188
2189 tidstats->filled |= BIT(NL80211_TID_STATS_RX_MSDU);
2190 }
2191
2192 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU))) {
2193 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU);
2194 tidstats->tx_msdu = sta->tx_stats.msdu[tid];
2195 }
2196

--- 86 unchanged lines hidden (view full) ---

2283 sinfo->tx_packets = 0;
2284 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
2285 sinfo->tx_packets += sta->tx_stats.packets[ac];
2286 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS);
2287 }
2288
2289 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_RX_BYTES64) |
2290 BIT_ULL(NL80211_STA_INFO_RX_BYTES)))) {
2186 tidstats->filled |= BIT(NL80211_TID_STATS_RX_MSDU);
2187 }
2188
2189 if (!(tidstats->filled & BIT(NL80211_TID_STATS_TX_MSDU))) {
2190 tidstats->filled |= BIT(NL80211_TID_STATS_TX_MSDU);
2191 tidstats->tx_msdu = sta->tx_stats.msdu[tid];
2192 }
2193

--- 86 unchanged lines hidden (view full) ---

2280 sinfo->tx_packets = 0;
2281 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
2282 sinfo->tx_packets += sta->tx_stats.packets[ac];
2283 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS);
2284 }
2285
2286 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_RX_BYTES64) |
2287 BIT_ULL(NL80211_STA_INFO_RX_BYTES)))) {
2291 if (!ieee80211_hw_check(&local->hw, USES_RSS))
2292 sinfo->rx_bytes += sta_get_stats_bytes(&sta->rx_stats);
2288 sinfo->rx_bytes += sta_get_stats_bytes(&sta->rx_stats);
2293
2294 if (sta->pcpu_rx_stats) {
2295 for_each_possible_cpu(cpu) {
2296 struct ieee80211_sta_rx_stats *cpurxs;
2297
2298 cpurxs = per_cpu_ptr(sta->pcpu_rx_stats, cpu);
2299 sinfo->rx_bytes += sta_get_stats_bytes(cpurxs);
2300 }

--- 252 unchanged lines hidden ---
2289
2290 if (sta->pcpu_rx_stats) {
2291 for_each_possible_cpu(cpu) {
2292 struct ieee80211_sta_rx_stats *cpurxs;
2293
2294 cpurxs = per_cpu_ptr(sta->pcpu_rx_stats, cpu);
2295 sinfo->rx_bytes += sta_get_stats_bytes(cpurxs);
2296 }

--- 252 unchanged lines hidden ---