mac80211: Add new sta_info getter by sta/vif addrs
PATCH 1/1 mac80211: Add new sta_info getter by sta/vif addrs
In ieee80211_tx_status() we don't have an sdata struct when looking up the destination sta. Instead, we just do a lookup by the vif addr that is the source of the packet being completed. Factor this out into a new sta_info getter helper, since we need to use it for accounting AQL as well.
--- net/mac80211/sta_info.c | 20 ++++++++++++++++++++ net/mac80211/sta_info.h | 3 +++ net/mac80211/status.c | 10 ++-------- 3 files changed, 25 insertions(+), 8 deletions(-)
net/mac80211/sta_info.c +20 -0
@@ -210,6 +210,26 @@ struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata,return NULL ; } +struct sta_info *sta_info_get_by_addrs (struct ieee80211_local *local, +const u8 *sta_addr,const u8 *vif_addr) +{ +struct rhlist_head *tmp; +struct sta_info *sta; + +rcu_read_lock (); +for_each_sta_info (local, sta_addr, sta, tmp) { +if (ether_addr_equal (vif_addr, sta->sdata->vif.addr)) { +rcu_read_unlock (); +/* this is safe as the caller must already hold +* another rcu read section or the mutex +*/ +return sta; + } + } +rcu_read_unlock (); +return NULL ; +} +struct sta_info *sta_info_get_by_idx (struct ieee80211_sub_if_data *sdata,int idx) {
net/mac80211/sta_info.h +3 -0
@@ -725,6 +725,9 @@ struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata,struct sta_info *sta_info_get_bss (struct ieee80211_sub_if_data *sdata,const u8 *addr); +struct sta_info *sta_info_get_by_addrs (struct ieee80211_local *local, +const u8 *sta_addr,const u8 *vif_addr); +#define for_each_sta_info (local, _addr, _sta, _tmp) \ rhl_for_each_entry_rcu(_sta, _tmp, \ sta_info_hash_lookup(local, _addr), hash_node)
net/mac80211/status.c +2 -8
@@ -1073,19 +1073,13 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) .skb = skb, .info = IEEE80211_SKB_CB(skb), }; -struct rhlist_head *tmp;struct sta_info *sta;rcu_read_lock (); -for_each_sta_info (local, hdr->addr1, sta, tmp) { -/* skip wrong virtual interface */ -if (!ether_addr_equal (hdr->addr2, sta->sdata->vif.addr)) -continue ; - + sta =sta_info_get_by_addrs (local, hdr->addr1, hdr->addr2); +if (sta) status.sta = &sta->sta; -break ; - }__ieee80211_tx_status (hw, &status);rcu_read_unlock ();
Signature · 1 line
2.24.0
Quoted 6 lines · Toke Høiland-Jørgensen
In
ieee80211_tx_status()we don't have an sdata struct when looking up the destination sta. Instead, we just do a lookup by the vif addr that is the source of the packet being completed. Factor this out into a newsta_infogetter helper, since we need to use it for accounting AQL as well.Signed-off-by Toke Høiland-Jørgensen <[email protected]>
This was another self-contained change that is a pre-requisite for the AQL patch, but I figured I could just send on its own while we iterate on the main patch.
Johannes, do feel free to tell me if it is annoying to do it this way; I'm just trying to speed things up a bit (while eyeing the fast approaching merge window :)).
-Toke