xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852bs/phl/phl_wow_def.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_DEF_H_
16 #define _PHL_WOW_DEF_H_
17 
18 enum rtw_wow_op_mode {
19 	RTW_WOW_OP_NONE = 0,
20 	RTW_WOW_OP_PWR_DOWN,
21 	RTW_WOW_OP_DISCONNECT_STBY,
22 	RTW_WOW_OP_CONNECT_STBY,
23 	RTW_WOW_OP_MAX = 0xF
24 };
25 
26 enum rtw_wow_wake_reason {
27 	RTW_WOW_RSN_UNKNOWN = 0,
28 	RTW_WOW_RSN_RX_PAIRWISEKEY,
29 	RTW_WOW_RSN_RX_GTK,
30 	RTW_WOW_RSN_RX_FOURWAY_HANDSHAKE,
31 	RTW_WOW_RSN_RX_DISASSOC,
32 	RTW_WOW_RSN_RX_DEAUTH, /* 5 */
33 	RTW_WOW_RSN_RX_ARP_REQUEST,
34 	RTW_WOW_RSN_RX_NS,
35 	RTW_WOW_RSN_RX_EAPREQ_IDENTIFY,
36 	RTW_WOW_RSN_FW_DECISION_DISCONNECT,
37 	RTW_WOW_RSN_RX_MAGIC_PKT, /* 10 */
38 	RTW_WOW_RSN_RX_UNICAST_PKT,
39 	RTW_WOW_RSN_RX_PATTERN_PKT,
40 	RTW_WOW_RSN_RTD3_SSID_MATCH,
41 	RTW_WOW_RSN_RX_DATA_PKT,
42 	RTW_WOW_RSN_RX_SSDP_MATCH, /* 15 */
43 	RTW_WOW_RSN_RX_WSD_MATCH,
44 	RTW_WOW_RSN_RX_SLP_MATCH,
45 	RTW_WOW_RSN_RX_LLTD_MATCH,
46 	RTW_WOW_RSN_RX_MDNS_MATCH,
47 	RTW_WOW_RSN_RX_REALWOW_V2_WAKEUP_PKT, /* 20 */
48 	RTW_WOW_RSN_RX_REALWOW_V2_ACK_LOST,
49 	RTW_WOW_RSN_RX_REALWOW_V2_TX_KAPKT,
50 	RTW_WOW_RSN_ENABLE_FAIL_DMA_IDLE,
51 	RTW_WOW_RSN_ENABLE_FAIL_DMA_PAUSE,
52 	RTW_WOW_RSN_RTIME_FAIL_DMA_IDLE, /* 25 */
53 	RTW_WOW_RSN_RTIME_FAIL_DMA_PAUSE,
54 	RTW_WOW_RSN_RX_SNMP_MISMATCHED_PKT,
55 	RTW_WOW_RSN_RX_DESIGNATED_MAC_PKT,
56 	RTW_WOW_RSN_NLO_SSID_MACH,
57 	RTW_WOW_RSN_AP_OFFLOAD_WAKEUP, /* 30 */
58 	RTW_WOW_RSN_DMAC_ERROR_OCCURRED,
59 	RTW_WOW_RSN_EXCEPTION_OCCURRED,
60 	RTW_WOW_RSN_L0_TO_L1_ERROR_OCCURRED,
61 	RTW_WOW_RSN_ASSERT_OCCURRED,
62 	RTW_WOW_RSN_L2_ERROR_OCCURRED, /* 35 */
63 	RTW_WOW_RSN_WDT_TIMEOUT_WAKE,
64 	RTW_WOW_RSN_RX_ACTION,
65 	RTW_WOW_RSN_CLK_32K_UNLOCK,
66 	RTW_WOW_RSN_CLK_32K_LOCK,
67 	RTW_WOW_RSN_MAX = 0xFF
68 };
69 
70 
71 struct rtw_keep_alive_info {
72 	/* core */
73 	u8 keep_alive_en;
74 	u8 keep_alive_period;
75 	/* phl/hal */
76 	u8 null_pkt_id;
77 };
78 
79 struct rtw_disc_det_info {
80 	/* core */
81 	u8 disc_det_en;
82 	u8 disc_wake_en;
83 	u8 try_pkt_count;
84 	u8 check_period;
85 	u8 cnt_bcn_lost_en;
86 	u8 cnt_bcn_lost_limit;
87 };
88 
89 #define MAX_NLO_NUM 10
90 #define MAX_SSID_LEN 32
91 #define MAX_NLO_CHANNEL 40
92 
93 struct rtw_nlo_info {
94 	u8 nlo_en;
95 	u8 num_of_networks;
96 	u8 num_of_hidden_ap;
97 	u8 ssid[MAX_NLO_NUM][MAX_SSID_LEN];
98 	u8 ssidlen[MAX_NLO_NUM];
99 	u8 chipertype[MAX_NLO_NUM];
100 	u8 probe_req_id;
101 	struct scan_ofld_ch_info channel_list[MAX_NLO_CHANNEL];
102 	u8 channel_num;
103 	u32 delay; /* ms */
104 	u32 period; /* ms */
105 	u8 cycle;
106 	u32 slow_period; /* ms */
107 	void (* construct_pbreq)(void *priv, u8 *pkt_buf, u16 *len);
108 };
109 
110 struct rtw_arp_ofld_content {
111 	u8 arp_en;
112 	u8 remote_ipv4_addr[IPV4_ADDRESS_LENGTH];
113 	u8 host_ipv4_addr[IPV4_ADDRESS_LENGTH];
114 	u8 mac_addr[MAC_ADDRESS_LENGTH];
115 };
116 
117 struct rtw_arp_ofld_info {
118 	u8 arp_en;
119 	u8 arp_action; /* 0 = send arp response, 1 = wake up host */
120 	u8 arp_rsp_id;
121 	struct rtw_arp_ofld_content arp_ofld_content;
122 };
123 
124 struct rtw_ndp_ofld_content {
125 	u8 ndp_en;
126 	u8 chk_remote_ip;
127 	u8 num_target_ip;
128 	u8 mac_addr[MAC_ADDRESS_LENGTH];
129 	u8 remote_ipv6_addr[IPV6_ADDRESS_LENGTH];
130 	u8 target_ipv6_addr[2][IPV6_ADDRESS_LENGTH];
131 };
132 
133 struct rtw_ndp_ofld_info {
134 	u8 ndp_en;
135 	u8 ndp_id;
136 	struct rtw_ndp_ofld_content ndp_ofld_content[2];
137 };
138 
139 struct rtw_gtk_ofld_content {
140 	u8 kck[32];
141 	u32 kck_len;
142 	u8 kek[32];
143 	u32 kek_len;
144 	u8 tk1[16];
145 	u8 txmickey[8];
146 	u8 rxmickey[8];
147 	u8 replay_cnt[8];
148 
149 	u8 igtk_keyid[4];
150 	u8 ipn[8];
151 	u8 igtk[2][32];
152 	u8 igtk_len;
153 	u8 psk[32];
154 	u8 psk_len;
155 };
156 
157 struct rtw_gtk_ofld_info {
158 	/* core */
159 	u8 gtk_en;
160 	u8 tkip_en;
161 	u8 ieee80211w_en;
162 	u8 pairwise_wakeup;
163 	u8 bip_sec_algo;
164 	u8 akmtype_byte3;
165 	struct rtw_gtk_ofld_content gtk_ofld_content;
166 
167 	/* phl */
168 	u8 hw_11w_en; /* keep 1 for BIP-CMAC-128 so far */
169 	u8 gtk_rsp_id; /* eapol pkt id */
170 	u8 sa_query_id;
171 };
172 
173 #define MAX_WOW_PATTERN_SIZE_BIT 128
174 #define MAX_WOW_PATTERN_SIZE_BYTE 16
175 #define MAX_WOW_PATTERN_SIZE_DWORD 4
176 
177 struct rtw_wowcam_upd_info {
178 	u8 rw;
179 	u8 wow_cam_idx;
180 	u32 wake_mask[4];
181 	u16 match_crc;
182 
183 	u8 is_negative_pattern_match;
184 	u8 skip_mac_hdr;
185 	u8 uc;
186 	u8 mc;
187 	u8 bc;
188 
189 	u8 valid;
190 	u8 ptrn[MAX_WOW_PATTERN_SIZE_BIT];
191 	u32 ptrn_len;
192 	u8 mask[MAX_WOW_PATTERN_SIZE_BYTE];
193 };
194 
195 #define MAX_WOW_CAM_NUM 18
196 struct rtw_pattern_match_info{
197 	struct rtw_wowcam_upd_info wowcam_info[MAX_WOW_CAM_NUM];
198 };
199 
200 #define MAX_REALWOW_KCP_SIZE 124 /* (100 + 24) */
201 #define MAX_REALWOW_PAYLOAD 64
202 
203 struct rtw_realwow_ofld_content {
204 	u16 interval; /* unit : 1 ms */
205 	u16 keep_alive_pkt_size;
206 	u16 ack_lost_limit;
207 	u16 ack_ptrn_size;
208 	u16 wakeup_ptrn_size;
209 	u16 keep_alive_pkt_ptrn[MAX_REALWOW_KCP_SIZE];
210 	u8 ack_ptrn[MAX_REALWOW_PAYLOAD];
211 	u8 wakeup_ptrn[MAX_REALWOW_PAYLOAD];
212 	u32 wakeup_sec_num;
213 };
214 
215 struct rtw_realwow_info {
216 	u8 realwow_en;
217 	u8 auto_wakeup;
218 	u8 keepalive_id;
219 	u8 wakeup_pattern_id;
220 	u8 ack_pattern_id;
221 	struct rtw_realwow_ofld_content realwow_ofld_content;
222 };
223 
224 struct rtw_wow_gpio_info {
225 	u8 dev2hst_gpio_en;
226 	u8 disable_inband;
227 	u8 gpio_output_input;
228 	u8 gpio_active;
229 	u8 toggle_pulse;
230 	u8 data_pin_wakeup;
231 	u8 gpio_pulse_nonstop;
232 	u8 gpio_time_unit;
233 	u8 gpio_num;
234 	u8 gpio_pulse_dura;
235 	u8 gpio_pulse_period;
236 	u8 gpio_pulse_count;
237 	u8 customer_id;
238 	u8 gpio_pulse_en_a;
239 	u8 gpio_duration_unit_a;
240 	u8 gpio_pulse_nonstop_a;
241 	u8 special_reason_a;
242 	u8 gpio_duration_a;
243 	u8 gpio_pulse_count_a;
244 
245 	enum rtw_gpio_mode dev2hst_gpio_mode;
246 	u8 dev2hst_gpio;
247 	u8 dev2hst_high;
248 };
249 
250 struct rtw_remote_wake_ctrl_info {
251 	/* core */
252 	u8 ptk_tx_iv[IV_LENGTH];
253 	u8 valid_check;
254 	u8 symbol_check_en;
255 	u8 gtk_key_idx;
256 	u8 ptk_rx_iv[IV_LENGTH];
257 	u8 gtk_rx_iv_idx0[IV_LENGTH];
258 	u8 gtk_rx_iv_idx1[IV_LENGTH];
259 	u8 gtk_rx_iv_idx2[IV_LENGTH];
260 	u8 gtk_rx_iv_idx3[IV_LENGTH];
261 };
262 
263 struct rtw_wow_wake_info {
264 	/* core */
265 	u8 wow_en;
266 	u8 drop_all_pkt;
267 	u8 rx_parse_after_wake;
268 	u8 pairwise_sec_algo;
269 	u8 group_sec_algo;
270 	u8 bip_sec_algo;
271 	u8 pattern_match_en;
272 	u8 magic_pkt_en;
273 	u8 hw_unicast_en;
274 	u8 fw_unicast_en;
275 	u8 deauth_wakeup;
276 	u8 rekey_wakeup;
277 	u8 eap_wakeup;
278 	u8 all_data_wakeup;
279 	struct rtw_remote_wake_ctrl_info remote_wake_ctrl_info;
280 };
281 
282 struct rtw_aoac_report {
283 	/* status check */
284 	u8 rpt_fail;
285 
286 	/* report from fw */
287 	u8 rpt_ver;
288 	u8 sec_type;
289 	u8 key_idx;
290 	u8 pattern_idx;
291 	u8 rekey_ok;
292 	u8 ptk_tx_iv[IV_LENGTH];
293 	u8 eapol_key_replay_count[8];
294 	u8 gtk[32];
295 	u8 ptk_rx_iv[IV_LENGTH];
296 	u8 gtk_rx_iv[4][IV_LENGTH];
297 	u8 igtk_key_id[8];
298 	u8 igtk_ipn[8];
299 	u8 igtk[32];
300 };
301 
302 #ifdef CONFIG_WOWLAN
303 
304 /* Exported APIs to core */
305 enum rtw_phl_status rtw_phl_cfg_keep_alive_info(void *phl, struct rtw_keep_alive_info *info);
306 enum rtw_phl_status rtw_phl_cfg_disc_det_info(void *phl, struct rtw_disc_det_info *info);
307 void rtw_phl_cfg_nlo_info(void *phl, struct rtw_nlo_info *info);
308 void rtw_phl_cfg_arp_ofld_info(void *phl, struct rtw_arp_ofld_info *info);
309 void rtw_phl_cfg_ndp_ofld_info(void *phl, struct rtw_ndp_ofld_info *info);
310 enum rtw_phl_status rtw_phl_remove_wow_ptrn_info(void *phl, u8 phl_ptrn_id);
311 enum rtw_phl_status rtw_phl_add_wow_ptrn_info(void *phl, struct rtw_wowcam_upd_info *info, u8 *phl_ptrn_id);
312 enum rtw_phl_status rtw_phl_cfg_gtk_ofld_info(void *phl, struct rtw_gtk_ofld_info *info);
313 enum rtw_phl_status rtw_phl_cfg_realwow_info(void *phl, struct rtw_realwow_info *info);
314 enum rtw_phl_status rtw_phl_cfg_wow_wake(void *phl, struct rtw_wow_wake_info *info);
315 enum rtw_phl_status rtw_phl_cfg_gpio_wake_pulse(void *phl, struct rtw_wow_gpio_info *info);
316 const char *rtw_phl_get_wow_rsn_str(void *phl, enum rtw_wow_wake_reason wake_rsn);
317 enum rtw_phl_status rtw_phl_cfg_wow_set_sw_gpio_mode(void *phl, struct rtw_wow_gpio_info *info);
318 enum rtw_phl_status rtw_phl_cfg_wow_sw_gpio_ctrl(void *phl, struct rtw_wow_gpio_info *info);
319 #endif /* CONFIG_WOWLAN */
320 
321 #endif /* _PHL_WOW_DEF_H_ */
322 
323