1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 /* Copyright(c) 2018-2019 Realtek Corporation 3 */ 4 5 #ifndef __RTW_UTIL_H__ 6 #define __RTW_UTIL_H__ 7 8 struct rtw_dev; 9 10 #define rtw_iterate_vifs_atomic(rtwdev, iterator, data) \ 11 ieee80211_iterate_active_interfaces_atomic(rtwdev->hw, \ 12 IEEE80211_IFACE_ITER_NORMAL, iterator, data) 13 #define rtw_iterate_stas_atomic(rtwdev, iterator, data) \ 14 ieee80211_iterate_stations_atomic(rtwdev->hw, iterator, data) 15 #define rtw_iterate_keys(rtwdev, vif, iterator, data) \ 16 ieee80211_iter_keys(rtwdev->hw, vif, iterator, data) 17 #define rtw_iterate_keys_rcu(rtwdev, vif, iterator, data) \ 18 ieee80211_iter_keys_rcu((rtwdev)->hw, vif, iterator, data) 19 20 void rtw_iterate_vifs(struct rtw_dev *rtwdev, 21 void (*iterator)(void *data, struct ieee80211_vif *vif), 22 void *data); 23 void rtw_iterate_stas(struct rtw_dev *rtwdev, 24 void (*iterator)(void *data, 25 struct ieee80211_sta *sta), 26 void *data); 27 28 static inline u8 *get_hdr_bssid(struct ieee80211_hdr *hdr) 29 { 30 __le16 fc = hdr->frame_control; 31 u8 *bssid; 32 33 if (ieee80211_has_tods(fc)) 34 bssid = hdr->addr1; 35 else if (ieee80211_has_fromds(fc)) 36 bssid = hdr->addr2; 37 else 38 bssid = hdr->addr3; 39 40 return bssid; 41 } 42 43 #endif 44