18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
28c2ecf20Sopenharmony_ci/* Copyright(c) 2018-2019  Realtek Corporation
38c2ecf20Sopenharmony_ci */
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#ifndef __RTW_UTIL_H__
68c2ecf20Sopenharmony_ci#define __RTW_UTIL_H__
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_cistruct rtw_dev;
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#define rtw_iterate_vifs(rtwdev, iterator, data)                               \
118c2ecf20Sopenharmony_ci	ieee80211_iterate_active_interfaces(rtwdev->hw,                        \
128c2ecf20Sopenharmony_ci			IEEE80211_IFACE_ITER_NORMAL, iterator, data)
138c2ecf20Sopenharmony_ci#define rtw_iterate_vifs_atomic(rtwdev, iterator, data)                        \
148c2ecf20Sopenharmony_ci	ieee80211_iterate_active_interfaces_atomic(rtwdev->hw,                 \
158c2ecf20Sopenharmony_ci			IEEE80211_IFACE_ITER_NORMAL, iterator, data)
168c2ecf20Sopenharmony_ci#define rtw_iterate_stas_atomic(rtwdev, iterator, data)                        \
178c2ecf20Sopenharmony_ci	ieee80211_iterate_stations_atomic(rtwdev->hw, iterator, data)
188c2ecf20Sopenharmony_ci#define rtw_iterate_keys(rtwdev, vif, iterator, data)			       \
198c2ecf20Sopenharmony_ci	ieee80211_iter_keys(rtwdev->hw, vif, iterator, data)
208c2ecf20Sopenharmony_ci#define rtw_iterate_keys_rcu(rtwdev, vif, iterator, data)		       \
218c2ecf20Sopenharmony_ci	ieee80211_iter_keys_rcu((rtwdev)->hw, vif, iterator, data)
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_cistatic inline u8 *get_hdr_bssid(struct ieee80211_hdr *hdr)
248c2ecf20Sopenharmony_ci{
258c2ecf20Sopenharmony_ci	__le16 fc = hdr->frame_control;
268c2ecf20Sopenharmony_ci	u8 *bssid;
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci	if (ieee80211_has_tods(fc))
298c2ecf20Sopenharmony_ci		bssid = hdr->addr1;
308c2ecf20Sopenharmony_ci	else if (ieee80211_has_fromds(fc))
318c2ecf20Sopenharmony_ci		bssid = hdr->addr2;
328c2ecf20Sopenharmony_ci	else
338c2ecf20Sopenharmony_ci		bssid = hdr->addr3;
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci	return bssid;
368c2ecf20Sopenharmony_ci}
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#endif
39