1 From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@redhat.com>
2 Date: Tue, 12 Nov 2019 14:08:35 +0100
3 Subject: [PATCH] mac80211: Add new sta_info getter by sta/vif addrs
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
8 In ieee80211_tx_status() we don't have an sdata struct when looking up the
9 destination sta. Instead, we just do a lookup by the vif addr that is the
10 source of the packet being completed. Factor this out into a new sta_info
11 getter helper, since we need to use it for accounting AQL as well.
13 Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
14 Link: https://lore.kernel.org/r/20191112130835.382062-1-toke@redhat.com
15 [remove internal rcu_read_lock(), document instead]
16 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 --- a/net/mac80211/sta_info.c
20 +++ b/net/mac80211/sta_info.c
21 @@ -210,6 +210,20 @@ struct sta_info *sta_info_get_bss(struct
25 +struct sta_info *sta_info_get_by_addrs(struct ieee80211_local *local,
26 + const u8 *sta_addr, const u8 *vif_addr)
28 + struct rhlist_head *tmp;
29 + struct sta_info *sta;
31 + for_each_sta_info(local, sta_addr, sta, tmp) {
32 + if (ether_addr_equal(vif_addr, sta->sdata->vif.addr))
39 struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata,
42 --- a/net/mac80211/sta_info.h
43 +++ b/net/mac80211/sta_info.h
44 @@ -725,6 +725,10 @@ struct sta_info *sta_info_get(struct iee
45 struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata,
48 +/* user must hold sta_mtx or be in RCU critical section */
49 +struct sta_info *sta_info_get_by_addrs(struct ieee80211_local *local,
50 + const u8 *sta_addr, const u8 *vif_addr);
52 #define for_each_sta_info(local, _addr, _sta, _tmp) \
53 rhl_for_each_entry_rcu(_sta, _tmp, \
54 sta_info_hash_lookup(local, _addr), hash_node)
55 --- a/net/mac80211/status.c
56 +++ b/net/mac80211/status.c
57 @@ -1086,19 +1086,13 @@ void ieee80211_tx_status(struct ieee8021
59 .info = IEEE80211_SKB_CB(skb),
61 - struct rhlist_head *tmp;
66 - for_each_sta_info(local, hdr->addr1, sta, tmp) {
67 - /* skip wrong virtual interface */
68 - if (!ether_addr_equal(hdr->addr2, sta->sdata->vif.addr))
71 + sta = sta_info_get_by_addrs(local, hdr->addr1, hdr->addr2);
73 status.sta = &sta->sta;
77 __ieee80211_tx_status(hw, &status);