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