wifi: unlocked station statistics
Johannes Berg
maintainercover wifi: unlocked station statistics
PoC-level at this point, though I did go over it once.
Obviously goes on top of the RTNL redux and AP locking sets, but I haven't even retested it since the cleanups. Just FYI.
I'll test it at some later date and repost as part of the other patchsets, but will drop the ath12k patch right now.
johannes
Johannes Berg
maintainerRFC PATCH 1/4 wifi: cfg80211: support unlocked station get/dump
From: Johannes Berg <[email protected]>
Qualcomm reported that there can be a lot of lock contention on the wiphy mutex due to background processes dumping the station statistics.
In many drivers (e.g. all mac80211 drivers without their own station statistics) it doesn't need to be locked, the data is never guaranteed to be fully consistent anyway given it's collected by concurrent TX/RX.
Support unlocked get/dump station methods so that drivers can reduce lock contention by implementing these methods. As in the other cases, it's allowed to return -EAGAIN if a locked call is needed.
--- include/net/cfg80211.h | 14 +++ net/wireless/nl80211.c | 201 ++++++++++++++++++++++++++++++++-------- net/wireless/rdev-ops.h | 27 ++++++ net/wireless/trace.h | 19 +++- 4 files changed, 219 insertions(+), 42 deletions(-)
include/net/cfg80211.h +14 -0
@@ -4963,7 +4963,13 @@ struct mgmt_frame_regs {* them, also against the existing state! Drivers must call * cfg80211_check_station_change() to validate the information. * @get_station: get station information for the station identified by @mac +* @get_station_unlocked: Like @get_station, but called without the wiphy +* mutex. Return -EAGAIN to get @get_station called with the wiphy mutex +* held instead. * @dump_station: dump station callback -- resume dump at index @idx +* @dump_station_unlocked: Like @dump_station, but called without the wiphy +* mutex. Return -EAGAIN to get @dump_station called with the wiphy mutex +* held instead. * * @add_mpath: add a fixed mesh path * @del_mpath: delete a given mesh path
@@ -5395,8 +5401,16 @@ struct cfg80211_ops { struct station_parameters *params);int (*get_station)(struct wiphy *wiphy,struct wireless_dev *wdev,const u8 *mac,struct station_info *sinfo); +int (*get_station_unlocked)(struct wiphy *wiphy, +struct wireless_dev *wdev, +const u8 *mac, +struct station_info *sinfo);int (*dump_station)(struct wiphy *wiphy,struct wireless_dev *wdev,int idx,u8 *mac,struct station_info *sinfo); +int (*dump_station_unlocked)(struct wiphy *wiphy, +struct wireless_dev *wdev, +int idx,u8 *mac, +struct station_info *sinfo);int (*add_mpath)(struct wiphy *wiphy,struct net_device *dev,const u8 *dst,const u8 *next_hop);
net/wireless/nl80211.c +160 -41
309 lines not on this page · raw message
net/wireless/rdev-ops.h +27 -0
@@ -248,6 +248,19 @@ static inline int rdev_get_station(struct cfg80211_registered_device *rdev,return ret; } +static inline int +rdev_get_station_unlocked (struct cfg80211_registered_device *rdev, +struct wireless_dev *wdev,const u8 *mac, +struct station_info *sinfo) +{ +int ret; + +trace_rdev_get_station_unlocked (&rdev->wiphy, wdev, mac); + ret = rdev->ops->get_station_unlocked (&rdev->wiphy, wdev, mac, sinfo); +trace_rdev_return_int_station_info (&rdev->wiphy, ret, sinfo); +return ret; +} +static inline int rdev_dump_station (struct cfg80211_registered_device *rdev,struct wireless_dev *wdev,int idx,u8 *mac,struct station_info *sinfo)
@@ -259,6 +272,20 @@ static inline int rdev_dump_station(struct cfg80211_registered_device *rdev,return ret; } +static inline int +rdev_dump_station_unlocked (struct cfg80211_registered_device *rdev, +struct wireless_dev *wdev,int idx,u8 *mac, +struct station_info *sinfo) +{ +int ret; + +trace_rdev_dump_station_unlocked (&rdev->wiphy, wdev, idx, mac); + ret = rdev->ops->dump_station_unlocked (&rdev->wiphy, wdev, idx, mac, + sinfo); +trace_rdev_return_int_station_info (&rdev->wiphy, ret, sinfo); +return ret; +} +static inline int rdev_add_mpath (struct cfg80211_registered_device *rdev,struct net_device *dev,u8 *dst,u8 *next_hop) {
net/wireless/trace.h +18 -1
@@ -1056,12 +1056,17 @@ DEFINE_EVENT(wiphy_wdev_mac_evt, rdev_get_station,TP_ARGS (wiphy, wdev, mac) ); +DEFINE_EVENT (wiphy_wdev_mac_evt, rdev_get_station_unlocked, + TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, const u8 *mac), +TP_ARGS (wiphy, wdev, mac) +); +DEFINE_EVENT (wiphy_netdev_mac_evt, rdev_del_mpath, TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac),TP_ARGS (wiphy, netdev, mac) ); -TRACE_EVENT(rdev_dump_station, +DECLARE_EVENT_CLASS(rdev_dump_station_evt, TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, int _idx, u8 *mac), TP_ARGS(wiphy, wdev, _idx, mac),
@@ -1082,6 +1087,18 @@ TRACE_EVENT(rdev_dump_station, __entry->idx) ); +DEFINE_EVENT (rdev_dump_station_evt, rdev_dump_station, + TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, int _idx, + u8 *mac), +TP_ARGS (wiphy, wdev, _idx, mac) +); + +DEFINE_EVENT (rdev_dump_station_evt, rdev_dump_station_unlocked, + TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, int _idx, + u8 *mac), +TP_ARGS (wiphy, wdev, _idx, mac) +); + TRACE_EVENT(rdev_return_int_station_info, TP_PROTO(struct wiphy *wiphy, int ret, struct station_info *sinfo), TP_ARGS(wiphy, ret, sinfo),
Signature · 1 line
2.56.0
Johannes Berg
maintainerRFC PATCH 2/4 wifi: mac80211: refactor station statistics
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
Refactor the code a bit to pass around link-STA pointers instead of looking them up again and again. This will simplify the next changes, since otherwise all of these lookups would have to be converted to RCU-safe ones. It also simplifies the code generally.
--- net/mac80211/sta_info.c | 87 ++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 48 deletions(-)
net/mac80211/sta_info.c +39 -48
@@ -2547,20 +2547,11 @@ void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local, }static struct ieee80211_sta_rx_stats * -sta_get_last_rx_stats (struct sta_info *sta,int link_id) +sta_get_last_rx_stats (struct link_sta_info *link_sta_info) { -struct ieee80211_sta_rx_stats *stats; -struct link_sta_info *link_sta_info; +struct ieee80211_sta_rx_stats *stats = &link_sta_info->rx_stats;int cpu; -if (link_id <0 ) - link_sta_info = &sta->deflink; -else - link_sta_info =wiphy_dereference (sta->local->hw.wiphy, - sta->link[link_id]); - - stats = &link_sta_info->rx_stats; -if (!link_sta_info->pcpu_rx_stats)return stats;
@@ -2576,6 +2567,19 @@ sta_get_last_rx_stats(struct sta_info *sta, int link_id)return stats; } +static unsigned long sta_link_last_active (struct link_sta_info *link_sta_info) +{ +struct ieee80211_sta_rx_stats *stats; + + stats =sta_get_last_rx_stats (link_sta_info); + +if (!link_sta_info->status_stats.last_ack || +time_after (stats->last_rx, link_sta_info->status_stats.last_ack)) +return stats->last_rx; + +return link_sta_info->status_stats.last_ack; +} +static void sta_stats_decode_rate (struct ieee80211_local *local,u32 rate,struct rate_info *rinfo) {
@@ -2653,10 +2657,11 @@ static void sta_stats_decode_rate(struct ieee80211_local *local, u32 rate, } } -static int sta_set_rate_info_rx (struct sta_info *sta,struct rate_info *rinfo, -int link_id) +static int sta_set_rate_info_rx (struct sta_info *sta, +struct link_sta_info *link_sta_info, +struct rate_info *rinfo) { -u32 rate =READ_ONCE (sta_get_last_rx_stats (sta, link_id)->last_rate); +u32 rate =READ_ONCE (sta_get_last_rx_stats (link_sta_info)->last_rate);if (rate ==STA_STATS_RATE_INVALID )return -EINVAL ;
@@ -2680,19 +2685,13 @@ static inline u64 sta_get_tidstats_msdu(struct ieee80211_sta_rx_stats *rxstats, }static void sta_set_tidstats (struct sta_info *sta, +struct link_sta_info *link_sta_info,struct cfg80211_tid_stats *tidstats, -int tid,int link_id) +int tid,bool txq_stats) {struct ieee80211_local *local = sta->local; -struct link_sta_info *link_sta_info;int cpu; -if (link_id <0 ) - link_sta_info = &sta->deflink; -else - link_sta_info =wiphy_dereference (sta->local->hw.wiphy, - sta->link[link_id]); -if (!(tidstats->filled &BIT (NL80211_TID_STATS_RX_MSDU ))) { tidstats->rx_msdu += sta_get_tidstats_msdu(&link_sta_info->rx_stats,
@@ -2731,7 +2730,7 @@ static void sta_set_tidstats(struct sta_info *sta, link_sta_info->status_stats.msdu_failed[tid]; } -if (link_id <0 && tid <IEEE80211_NUM_TIDS ) { +if (txq_stats && tid <IEEE80211_NUM_TIDS ) {spin_lock_bh (&local->fq.lock); tidstats->filled |=BIT (NL80211_TID_STATS_TXQ_STATS );
@@ -2837,20 +2836,17 @@ static u32 sta_estimate_expected_throughput(struct sta_info *sta, }static void sta_set_link_sinfo (struct sta_info *sta, +struct link_sta_info *link_sta_info,struct link_station_info *link_sinfo,struct ieee80211_link_data *link,bool tidstats) {struct ieee80211_sub_if_data *sdata = sta->sdata;struct ieee80211_sta_rx_stats *last_rxstats; -int i, ac, cpu, link_id = link->link_id; -struct link_sta_info *link_sta_info; +int i, ac, cpu;u32 thr =0 ; - last_rxstats =sta_get_last_rx_stats (sta, link_id); - - link_sta_info =wiphy_dereference (sta->local->hw.wiphy, - sta->link[link_id]); + last_rxstats =sta_get_last_rx_stats (link_sta_info);/* do before driver, so beacon filtering drivers have a * chance to e.g. just add the number of filtered beacons
@@ -2876,8 +2872,7 @@ static void sta_set_link_sinfo(struct sta_info *sta, link_sinfo->inactive_time =jiffies_delta_to_msecs (jiffies - -ieee80211_sta_last_active (sta, - link_id)); +sta_link_last_active (link_sta_info));if (!(link_sinfo->filled & (BIT_ULL (NL80211_STA_INFO_TX_BYTES64 ) |BIT_ULL (NL80211_STA_INFO_TX_BYTES )))) {
@@ -3025,8 +3020,8 @@ static void sta_set_link_sinfo(struct sta_info *sta, }if (!(link_sinfo->filled &BIT_ULL (NL80211_STA_INFO_RX_BITRATE ))) { -if (sta_set_rate_info_rx (sta, &link_sinfo->rxrate, - link_id) ==0 ) +if (sta_set_rate_info_rx (sta, link_sta_info, + &link_sinfo->rxrate) ==0 ) link_sinfo->filled |=BIT_ULL (NL80211_STA_INFO_RX_BITRATE ); }
@@ -3034,8 +3029,8 @@ static void sta_set_link_sinfo(struct sta_info *sta,if (tidstats && !cfg80211_link_sinfo_alloc_tid_stats (link_sinfo,GFP_KERNEL )) {for (i =0 ; i <IEEE80211_NUM_TIDS +1 ; i++) -sta_set_tidstats (sta, &link_sinfo->pertid[i], i, - link_id); +sta_set_tidstats (sta, link_sta_info, + &link_sinfo->pertid[i], i, false); }if (sdata->vif.type ==NL80211_IFTYPE_STATION ) {
@@ -3091,7 +3086,7 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,int i, ac, cpu;struct ieee80211_sta_rx_stats *last_rxstats; - last_rxstats =sta_get_last_rx_stats (sta,-1 ); + last_rxstats =sta_get_last_rx_stats (&sta->deflink); sinfo->generation = sdata->local->sta_generation;
@@ -3119,7 +3114,7 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo, sinfo->assoc_at = sta->assoc_at; sinfo->inactive_time =jiffies_delta_to_msecs (jiffies - -ieee80211_sta_last_active (sta,-1 )); +sta_link_last_active (&sta->deflink));if (!(sinfo->filled & (BIT_ULL (NL80211_STA_INFO_TX_BYTES64 ) |BIT_ULL (NL80211_STA_INFO_TX_BYTES )))) {
@@ -3258,13 +3253,15 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,if (!(sinfo->filled &BIT_ULL (NL80211_STA_INFO_RX_BITRATE )) && !sta->sta.valid_links) { -if (sta_set_rate_info_rx (sta, &sinfo->rxrate,-1 ) ==0 ) +if (sta_set_rate_info_rx (sta, &sta->deflink, + &sinfo->rxrate) ==0 ) sinfo->filled |=BIT_ULL (NL80211_STA_INFO_RX_BITRATE ); }if (tidstats && !cfg80211_sinfo_alloc_tid_stats (sinfo,GFP_KERNEL )) {for (i =0 ; i <IEEE80211_NUM_TIDS +1 ; i++) -sta_set_tidstats (sta, &sinfo->pertid[i], i,-1 ); +sta_set_tidstats (sta, &sta->deflink, + &sinfo->pertid[i], i, true); }#ifdef CONFIG_MAC80211_MESH
@@ -3367,7 +3364,8 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo, sinfo->valid_links &= ~BIT (link_id);continue ; } -sta_set_link_sinfo (sta, link_sinfo, link, tidstats); +sta_set_link_sinfo (sta, link_sta, link_sinfo, link, + tidstats);if (!thr && (link_sinfo->filled &BIT_ULL (NL80211_STA_INFO_EXPECTED_THROUGHPUT ))) est_thr += link_sinfo->expected_throughput;
@@ -3400,22 +3398,15 @@ u32 sta_get_expected_throughput(struct sta_info *sta)unsigned long ieee80211_sta_last_active (struct sta_info *sta,int link_id) { -struct ieee80211_sta_rx_stats *stats;struct link_sta_info *link_sta_info; - stats =sta_get_last_rx_stats (sta, link_id); -if (link_id <0 ) link_sta_info = &sta->deflink;else link_sta_info =wiphy_dereference (sta->local->hw.wiphy, sta->link[link_id]); -if (!link_sta_info->status_stats.last_ack || -time_after (stats->last_rx, link_sta_info->status_stats.last_ack)) -return stats->last_rx; - -return link_sta_info->status_stats.last_ack; +return sta_link_last_active (link_sta_info); }int ieee80211_sta_allocate_link (struct sta_info *sta,unsigned int link_id)
Signature · 1 line
2.56.0
Johannes Berg
maintainerRFC PATCH 3/4 wifi: mac80211: implement unlocked STA statistics
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
Implement the new cfg80211 unlocked STA statistics. If the driver has an operation, then we need to always do the locked again, so return -EAGAIN unconditionally if it has a locked but not atomic operation, but drivers can implement the new atomic methods to provide needed data atomically (and can also return -EAGAIN).
This should, given a driver without any ops or adding the atomic ops, reduce wiphy mutex contention.
--- include/net/mac80211.h | 18 ++++++ net/mac80211/cfg.c | 120 ++++++++++++++++++++++++++++---------- net/mac80211/driver-ops.c | 76 ++++++++++++++++++++++++ net/mac80211/driver-ops.h | 46 ++++----------- net/mac80211/sta_info.c | 54 ++++++++++------- net/mac80211/sta_info.h | 10 +++- 6 files changed, 233 insertions(+), 91 deletions(-)
include/net/mac80211.h +18 -0
@@ -4369,6 +4369,13 @@ struct ieee80211_prep_tx_info {* Statistics that the driver doesn't fill will be filled by mac80211. * The callback can sleep. * +* @sta_statistics_atomic: Like @sta_statistics, but called under RCU, so it +* must be atomic. This is called instead of @sta_statistics if available, +* but may return -EAGAIN to fall back to @sta_statistics with the wiphy +* mutex held. +* Note that it's not guaranteed this will always be called first, some +* (internal) calls may call @sta_statistics directly. +* * @link_sta_statistics: Get link statistics for this station. For example with * beacon filtering, the statistics kept by mac80211 might not be * accurate, so let the driver pre-fill the statistics. The driver can
@@ -4378,6 +4385,9 @@ struct ieee80211_prep_tx_info {* Statistics that the driver doesn't fill will be filled by mac80211. * The callback can sleep. * +* @link_sta_statistics_atomic: Like @link_sta_statistics, with the same +* locking/retry semantics as @sta_statistics_atomic. Must be atomic. +* * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), * bursting) for a hardware TX queue. * Returns a negative error code on failure.
@@ -4883,6 +4893,10 @@ struct ieee80211_ops {struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct station_info *sinfo); +int (*sta_statistics_atomic)(struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_sta *sta, +struct station_info *sinfo); int (*conf_tx)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, unsigned int link_id, u16 ac,
@@ -4898,6 +4912,10 @@ struct ieee80211_ops {struct ieee80211_vif *vif, struct ieee80211_link_sta *link_sta, struct link_station_info *link_sinfo); +int (*link_sta_statistics_atomic)(struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_link_sta *link_sta, +struct link_station_info *link_sinfo);/** * @ampdu_action:
net/mac80211/cfg.c +89 -31
157 lines not on this page · raw message
net/mac80211/driver-ops.c +76 -0
79 lines not on this page · raw message
net/mac80211/driver-ops.h +10 -36
52 lines not on this page · raw message
net/mac80211/sta_info.c +32 -22
122 lines not on this page · raw message
net/mac80211/sta_info.h +8 -2
@@ -989,8 +989,14 @@ static inline int sta_info_flush(struct ieee80211_sub_if_data *sdata,void sta_set_rate_info_tx (struct sta_info *sta,const struct ieee80211_tx_rate *rate,struct rate_info *rinfo); -void sta_set_sinfo (struct sta_info *sta,struct station_info *sinfo, -bool tidstats); +int __sta_set_sinfo (struct sta_info *sta,struct station_info *sinfo, +bool tidstats,bool locked); + +static inline void sta_set_sinfo (struct sta_info *sta, +struct station_info *sinfo,bool tidstats) +{ +__sta_set_sinfo (sta, sinfo, tidstats, true); +}void sta_set_accumulated_removed_links_sinfo (struct sta_info *sta,struct station_info *sinfo);
Signature · 1 line
2.56.0
Johannes Berg
maintainerRe: [RFC PATCH 3/4] wifi: mac80211: implement unlocked STA statistics
Quoted 8 lines · Johannes Berg
net/mac80211/driver-ops.c +7
-0+int drv_sta_statistics (struct ieee80211_local *local, +struct ieee80211_sub_if_data *sdata, +struct ieee80211_sta *sta, +struct station_info *sinfo, +bool locked) +{ +int ret;
net/mac80211/driver-ops.c int drv_change_sta_links(struct ieee80211_local *local, · line 653
Quoted 10 lines
net/mac80211/driver-ops.c +10
-0+ + sdata =get_bss_sdata (sdata); +if (!check_sdata_in_driver (sdata)) +return 0 ; + +trace_drv_sta_statistics (local, sdata, sta); + +if (!locked) { +might_sleep (); +lockdep_assert_wiphy (local->hw.wiphy);
This obviously came out the wrong way around - it should of course be "if (locked)" since only then can we sleep here and hold the mutex.
Quoted 6 lines
net/mac80211/driver-ops.c +5
-0+int drv_link_sta_statistics (struct ieee80211_local *local, +struct ieee80211_sub_if_data *sdata, +struct ieee80211_link_sta *link_sta, +struct link_station_info *link_sinfo, +bool locked)
net/mac80211/driver-ops.c int drv_change_sta_links(struct ieee80211_local *local, · line 689
Quoted 10 lines
net/mac80211/driver-ops.c +10
-0+{ +int ret; + + sdata =get_bss_sdata (sdata); +if (!check_sdata_in_driver (sdata)) +return 0 ; + +if (locked) { +might_sleep (); +lockdep_assert_wiphy (local->hw.wiphy);
This one I got right ... :)
johannes
Johannes Berg
maintainerRFC PATCH 4/4 wifi: ath12k: implement unlocked station statistics
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
Most of the time we just return cached statistics, that can be done unlocked. If querying the firmware is needed, return -EAGAIN to fall back to the locked version.
--- drivers/net/wireless/ath/ath12k/mac.c | 117 +++++++++++++++------ drivers/net/wireless/ath/ath12k/mac.h | 8 ++ drivers/net/wireless/ath/ath12k/wifi7/hw.c | 2 + 3 files changed, 94 insertions(+), 33 deletions(-)
drivers/net/wireless/ath/ath12k/mac.c +84 -33
@@ -920,7 +920,8 @@ struct ath12k *ath12k_get_ar_by_vif(struct ieee80211_hw *hw,struct ath12k_hw *ah =ath12k_hw_to_ah (hw);struct ath12k_link_vif *arvif; -lockdep_assert_wiphy (hw->wiphy); +/* also used under RCU for station statistics */ +lockdep_assert (lockdep_is_held (&hw->wiphy->mtx) ||rcu_read_lock_held ());/* If there is one pdev within ah, then we return * ar directly.
@@ -931,7 +932,7 @@ struct ath12k *ath12k_get_ar_by_vif(struct ieee80211_hw *hw,if (!(ahvif->links_map &BIT (link_id)))return NULL ; - arvif =wiphy_dereference (hw->wiphy, ahvif->link[link_id]); + arvif =rcu_dereference_wiphy (hw->wiphy, ahvif->link[link_id]);if (arvif && arvif->is_created)return arvif->ar;
@@ -13737,10 +13738,11 @@ static void ath12k_mac_put_chain_rssi(struct station_info *sinfo, } } -void ath12k_mac_op_sta_statistics (struct ieee80211_hw *hw, -struct ieee80211_vif *vif, -struct ieee80211_sta *sta, -struct station_info *sinfo) +static int ath12k_mac_sta_statistics (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_sta *sta, +struct station_info *sinfo, +bool atomic) {struct ath12k_sta *ahsta =ath12k_sta_to_ahsta (sta);struct ath12k_dp_link_peer_rate_info rate_info = {};
@@ -13752,12 +13754,17 @@ void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw,struct ath12k *ar;bool db2dbm; -lockdep_assert_wiphy (hw->wiphy); +/* station interfaces query the firmware, which sleeps */ +if (atomic && ahsta->ahvif->vdev_type ==WMI_VDEV_TYPE_STA ) +return -EAGAIN ; + +if (!atomic) +lockdep_assert_wiphy (hw->wiphy); arsta = &ahsta->deflink; ar =ath12k_get_ar_by_vif (hw, vif, arsta->link_id);if (!ar) -return ; +return 0 ; dp =ath12k_ab_to_dp (ar->ab);ath12k_dp_link_peer_get_sta_rate_info_stats (dp, arsta->addr, &rate_info);
@@ -13791,23 +13798,22 @@ void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw,/* TODO: Use real NF instead of default one. */ signal = rate_info.rssi_comb; - params.pdev_id =ath12k_mac_get_target_pdev_id (ar); - params.vdev_id =0 ; - params.stats_id =WMI_REQUEST_VDEV_STAT ; +if (ahsta->ahvif->vdev_type ==WMI_VDEV_TYPE_STA ) { + params.pdev_id =ath12k_mac_get_target_pdev_id (ar); + params.vdev_id =0 ; + params.stats_id =WMI_REQUEST_VDEV_STAT ; -if (!signal && - ahsta->ahvif->vdev_type ==WMI_VDEV_TYPE_STA && - !(ath12k_mac_get_fw_stats (ar, ¶ms))) { - signal = arsta->rssi_beacon; -ath12k_fw_stats_reset (ar); - } +if (!signal && !ath12k_mac_get_fw_stats (ar, ¶ms)) { + signal = arsta->rssi_beacon; +ath12k_fw_stats_reset (ar); + } - params.stats_id =WMI_REQUEST_RSSI_PER_CHAIN_STAT ; -if (!(sinfo->filled &BIT_ULL (NL80211_STA_INFO_CHAIN_SIGNAL )) && - ahsta->ahvif->vdev_type ==WMI_VDEV_TYPE_STA && - !(ath12k_mac_get_fw_stats (ar, ¶ms))) { -ath12k_mac_put_chain_rssi (sinfo, arsta); -ath12k_fw_stats_reset (ar); + params.stats_id =WMI_REQUEST_RSSI_PER_CHAIN_STAT ; +if (!(sinfo->filled &BIT_ULL (NL80211_STA_INFO_CHAIN_SIGNAL )) && + !ath12k_mac_get_fw_stats (ar, ¶ms)) { +ath12k_mac_put_chain_rssi (sinfo, arsta); +ath12k_fw_stats_reset (ar); + } }spin_lock_bh (&ar->data_lock);
@@ -13830,7 +13836,7 @@ void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw, peer =ath12k_dp_link_peer_find_by_addr (dp, arsta->addr);if (!peer) {spin_unlock_bh (&dp->dp_lock); -return ; +return 0 ; } sinfo->tx_retries = peer->tx_retry_count;
@@ -13839,13 +13845,32 @@ void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw, sinfo->filled |=BIT_ULL (NL80211_STA_INFO_TX_FAILED );spin_unlock_bh (&dp->dp_lock); +return 0 ; +} + +void ath12k_mac_op_sta_statistics (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_sta *sta, +struct station_info *sinfo) +{ +ath12k_mac_sta_statistics (hw, vif, sta, sinfo, false); }EXPORT_SYMBOL (ath12k_mac_op_sta_statistics); -void ath12k_mac_op_link_sta_statistics (struct ieee80211_hw *hw, -struct ieee80211_vif *vif, -struct ieee80211_link_sta *link_sta, -struct link_station_info *link_sinfo) +int ath12k_mac_op_sta_statistics_atomic (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_sta *sta, +struct station_info *sinfo) +{ +return ath12k_mac_sta_statistics (hw, vif, sta, sinfo, true); +} +EXPORT_SYMBOL (ath12k_mac_op_sta_statistics_atomic); + +static int ath12k_mac_link_sta_statistics (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_link_sta *link_sta, +struct link_station_info *link_sinfo, +bool atomic) {struct ath12k_sta *ahsta =ath12k_sta_to_ahsta (link_sta->sta);struct ath12k_fw_stats_req_params params = {};
@@ -13855,16 +13880,22 @@ void ath12k_mac_op_link_sta_statistics(struct ieee80211_hw *hw,s8 signal;bool db2dbm; -lockdep_assert_wiphy (hw->wiphy); +/* station interfaces query the firmware, which sleeps */ +if (atomic && ahsta->ahvif->vdev_type ==WMI_VDEV_TYPE_STA ) +return -EAGAIN ; - arsta =wiphy_dereference (hw->wiphy, ahsta->link[link_sta->link_id]); +if (!atomic) +lockdep_assert_wiphy (hw->wiphy); + + arsta =rcu_dereference_wiphy (hw->wiphy, + ahsta->link[link_sta->link_id]);if (!arsta) -return ; +return 0 ; ar =ath12k_get_ar_by_vif (hw, vif, arsta->link_id);if (!ar) -return ; +return 0 ; db2dbm =test_bit (WMI_TLV_SERVICE_HW_DB2DBM_CONVERSION_SUPPORT , ar->ab->wmi_ab.svc_map);
@@ -13873,7 +13904,7 @@ void ath12k_mac_op_link_sta_statistics(struct ieee80211_hw *hw, peer =ath12k_dp_link_peer_find_by_addr (ar->ab->dp, arsta->addr);if (!peer) {spin_unlock_bh (&ar->ab->dp->dp_lock); -return ; +return 0 ; } link_sinfo->rx_duration = peer->rx_duration;
@@ -13934,9 +13965,29 @@ void ath12k_mac_op_link_sta_statistics(struct ieee80211_hw *hw, db2dbm ? signal : signal +ATH12K_DEFAULT_NOISE_FLOOR ; link_sinfo->filled |=BIT_ULL (NL80211_STA_INFO_SIGNAL ); } + +return 0 ; +} + +void ath12k_mac_op_link_sta_statistics (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_link_sta *link_sta, +struct link_station_info *link_sinfo) +{ +ath12k_mac_link_sta_statistics (hw, vif, link_sta, link_sinfo, false); }EXPORT_SYMBOL (ath12k_mac_op_link_sta_statistics); +int ath12k_mac_op_link_sta_statistics_atomic (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_link_sta *link_sta, +struct link_station_info *link_sinfo) +{ +return ath12k_mac_link_sta_statistics (hw, vif, link_sta, link_sinfo, + true); +} +EXPORT_SYMBOL (ath12k_mac_op_link_sta_statistics_atomic); +int ath12k_mac_op_cancel_remain_on_channel (struct ieee80211_hw *hw,struct ieee80211_vif *vif) {
drivers/net/wireless/ath/ath12k/mac.h +8 -0
@@ -311,10 +311,18 @@ void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw,struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct station_info *sinfo); +int ath12k_mac_op_sta_statistics_atomic (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_sta *sta, +struct station_info *sinfo);void ath12k_mac_op_link_sta_statistics (struct ieee80211_hw *hw,struct ieee80211_vif *vif,struct ieee80211_link_sta *link_sta,struct link_station_info *link_sinfo); +int ath12k_mac_op_link_sta_statistics_atomic (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_link_sta *link_sta, +struct link_station_info *link_sinfo); int ath12k_mac_op_remain_on_channel(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_channel *chan,
drivers/net/wireless/ath/ath12k/wifi7/hw.c +2 -0
@@ -1207,7 +1207,9 @@ static const struct ieee80211_ops ath12k_ops_wifi7 = { .get_survey = ath12k_mac_op_get_survey, .flush = ath12k_mac_op_flush, .sta_statistics = ath12k_mac_op_sta_statistics, + .sta_statistics_atomic = ath12k_mac_op_sta_statistics_atomic, .link_sta_statistics = ath12k_mac_op_link_sta_statistics, + .link_sta_statistics_atomic = ath12k_mac_op_link_sta_statistics_atomic, .remain_on_channel = ath12k_mac_op_remain_on_channel, .cancel_remain_on_channel = ath12k_mac_op_cancel_remain_on_channel, .change_sta_links = ath12k_mac_op_change_sta_links,
Signature · 1 line
2.56.0