xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852bs/phl/phl_wow.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c)2019 Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  *****************************************************************************/
15 #ifndef _PHL_WOW_H_
16 #define _PHL_WOW_H_
17 
18 #define WOW_HUBMSG_MAXLEN 50
19 
20 #define PHL_WOW_ERR_DL_FW BIT0
21 #define PHL_WOW_ERR_PKT_OFLD BIT1
22 #define PHL_WOW_ERR_FUNC_EN BIT2
23 #define PHL_WOW_ERR_FUNC_DIS BIT3
24 #define PHL_WOW_ERR_MAC BIT4
25 #define PHL_WOW_ERR_TRX BIT5
26 #define PHL_WOW_ERR_HW BIT6
27 
28 #define phl_to_wow_info(_phl) (&_phl->wow_info)
29 #define get_wow_pairwise_algo_type(_wow_info) (_wow_info->wow_wake_info.pairwise_sec_algo)
30 #define get_wow_group_algo_type(_wow_info) (_wow_info->wow_wake_info.group_sec_algo)
31 
32 struct phl_wow_error {
33 	u16 init;
34 	u16 deinit;
35 };
36 
37 struct phl_wow_stat {
38 	/* init */
39 	u8 func_en;
40 	enum rtw_wow_op_mode op_mode;
41 	u8 keep_alive_en;
42 	u8 disc_det_en;
43 	u8 arp_en;
44 	u8 ndp_en;
45 	u8 gtk_en;
46 	u8 dot11w_en;
47 	/* deinit */
48 	enum rtw_wow_wake_reason wake_rsn;
49 	enum rtw_mac_pwr_st mac_pwr;
50 	/* common */
51 	struct phl_wow_error err;
52 	u8 aoac_rpt_fail_cnt;
53 };
54 
55 struct phl_wow_info {
56 	/* common */
57 	struct phl_info_t *phl_info;
58 	_os_lock wow_lock;
59 	u8 wow_msg[WOW_HUBMSG_MAXLEN];
60 	struct phl_wow_stat wow_stat;
61 
62 	/* general info, should reset */
63 	u8 func_en;
64 	struct phl_wow_error err;
65 	struct rtw_phl_stainfo_t *sta;
66 	enum rtw_wow_op_mode op_mode;
67 	u8 ps_pwr_lvl;
68 	enum rtw_mac_pwr_st mac_pwr;
69 
70 	/* pkt ofld token */
71 	u32 null_pkt_token;
72 	u32 arp_pkt_token;
73 	u32 ndp_pkt_token;
74 	u32 eapol_key_pkt_token;
75 	u32 sa_query_pkt_token;
76 	u32 kapkt_pkt_token;
77 	u32 ack_pkt_token;
78 	u32 wp_token;
79 	u32 probe_req_pkt_token;
80 
81 	/* func */
82 	struct rtw_keep_alive_info keep_alive_info;
83 	struct rtw_disc_det_info disc_det_info;
84 	struct rtw_nlo_info nlo_info;
85 	struct rtw_arp_ofld_info arp_ofld_info;
86 	struct rtw_ndp_ofld_info ndp_ofld_info;
87 	struct rtw_gtk_ofld_info gtk_ofld_info;
88 	struct rtw_realwow_info realwow_info;
89 	struct rtw_wow_wake_info wow_wake_info;
90 	struct rtw_pattern_match_info pattern_match_info;
91 	struct rtw_wow_gpio_info wow_gpio;
92 
93 	/* info to core */
94 	enum rtw_wow_wake_reason wake_rsn;
95 	struct rtw_aoac_report aoac_info;
96 };
97 
98 enum rtw_phl_status phl_wow_mdl_init(struct phl_info_t* phl_info);
99 void phl_wow_mdl_deinit(struct phl_info_t* phl_info);
100 
101 #ifdef CONFIG_WOWLAN
102 
103 void phl_record_wow_stat(struct phl_wow_info *wow_info);
104 
105 void phl_wow_handle_wake_rsn(struct phl_wow_info *wow_info, u8 *reset);
106 
107 enum rtw_phl_status phl_wow_init_precfg(struct phl_wow_info *wow_info);
108 
109 enum rtw_phl_status phl_wow_init_postcfg(struct phl_wow_info *wow_info);
110 
111 enum rtw_phl_status phl_wow_deinit_precfg(struct phl_wow_info *wow_info);
112 
113 enum rtw_phl_status phl_wow_deinit_postcfg(struct phl_wow_info *wow_info);
114 
115 void phl_reset_wow_info(struct phl_wow_info *wow_info);
116 
117 enum rtw_phl_status phl_wow_func_en(struct phl_wow_info *wow_info);
118 
119 void phl_wow_func_dis(struct phl_wow_info *wow_info);
120 
121 void phl_wow_decide_op_mode(struct phl_wow_info *wow_info, struct rtw_phl_stainfo_t *sta);
122 #ifdef CONFIG_POWER_SAVE
123 enum rtw_phl_status phl_wow_ps_proto_cfg(struct phl_wow_info *wow_info, bool enter_ps);
124 
125 void phl_wow_ps_pwr_ntfy(struct phl_wow_info *wow_info, bool enter_ps);
126 
127 enum rtw_phl_status phl_wow_ps_pwr_cfg(struct phl_wow_info *wow_info, bool enter_ps);
128 #endif
129 #endif /* CONFIG_WOWLAN */
130 
131 #endif /* _PHL_WOW_H_ */
132