xref: /linux/drivers/net/wireless/realtek/rtw89/ps.h (revision 7f71507851fc7764b36a3221839607d3a45c2025)
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright(c) 2019-2020  Realtek Corporation
3  */
4 
5 #ifndef __RTW89_PS_H_
6 #define __RTW89_PS_H_
7 
8 void rtw89_enter_lps(struct rtw89_dev *rtwdev, struct rtw89_vif_link *rtwvif_link,
9 		     bool ps_mode);
10 void rtw89_leave_lps(struct rtw89_dev *rtwdev);
11 void __rtw89_leave_ps_mode(struct rtw89_dev *rtwdev);
12 void __rtw89_enter_ps_mode(struct rtw89_dev *rtwdev, struct rtw89_vif_link *rtwvif_link);
13 void rtw89_leave_ps_mode(struct rtw89_dev *rtwdev);
14 void rtw89_enter_ips(struct rtw89_dev *rtwdev);
15 void rtw89_leave_ips(struct rtw89_dev *rtwdev);
16 void rtw89_set_coex_ctrl_lps(struct rtw89_dev *rtwdev, bool btc_ctrl);
17 void rtw89_process_p2p_ps(struct rtw89_dev *rtwdev,
18 			  struct rtw89_vif_link *rtwvif_link,
19 			  struct ieee80211_bss_conf *bss_conf);
20 void rtw89_recalc_lps(struct rtw89_dev *rtwdev);
21 void rtw89_p2p_noa_renew(struct rtw89_vif_link *rtwvif_link);
22 void rtw89_p2p_noa_append(struct rtw89_vif_link *rtwvif_link,
23 			  const struct ieee80211_p2p_noa_desc *desc);
24 u8 rtw89_p2p_noa_fetch(struct rtw89_vif_link *rtwvif_link, void **data);
25 
26 static inline void rtw89_leave_ips_by_hwflags(struct rtw89_dev *rtwdev)
27 {
28 	struct ieee80211_hw *hw = rtwdev->hw;
29 
30 	if (hw->conf.flags & IEEE80211_CONF_IDLE)
31 		rtw89_leave_ips(rtwdev);
32 }
33 
34 static inline void rtw89_enter_ips_by_hwflags(struct rtw89_dev *rtwdev)
35 {
36 	struct ieee80211_hw *hw = rtwdev->hw;
37 
38 	/* prevent entering IPS after ROC, but it is scanning */
39 	if (rtwdev->scanning)
40 		return;
41 
42 	if (hw->conf.flags & IEEE80211_CONF_IDLE)
43 		rtw89_enter_ips(rtwdev);
44 }
45 
46 #endif
47