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_dev2hst_gpio_info { 225 /* dword0 */ 226 u32 dev2hst_gpio_en:1; 227 u32 disable_inband:1; 228 u32 gpio_output_input:1; 229 u32 gpio_active:1; 230 u32 toggle_pulse:1; 231 u32 data_pin_wakeup:1; 232 u32 gpio_pulse_nonstop:1; 233 u32 gpio_time_unit:1; 234 u32 gpio_num:8; 235 u32 gpio_pulse_dura:8; 236 u32 gpio_pulse_period:8; 237 /* dword1 */ 238 u32 gpio_pulse_count:8; 239 u32 rsvd0:24; 240 /* dword2 */ 241 u32 customer_id:8; 242 u32 rsvd1:24; 243 /* dword3 */ 244 u32 rsn_a_en:1; 245 u32 rsn_a_toggle_pulse:1; 246 u32 rsn_a_pulse_nonstop:1; 247 u32 rsn_a_time_unit:1; 248 u32 rsvd2:28; 249 /* dword4 */ 250 u32 rsn_a:8; 251 u32 rsn_a_pulse_duration:8; 252 u32 rsn_a_pulse_period:8; 253 u32 rsn_a_pulse_count:8; 254 /* dword5 */ 255 u32 rsn_b_en:1; 256 u32 rsn_b_toggle_pulse:1; 257 u32 rsn_b_pulse_nonstop:1; 258 u32 rsn_b_time_unit:1; 259 u32 rsvd3:28; 260 /* dword6 */ 261 u32 rsn_b:8; 262 u32 rsn_b_pulse_duration:8; 263 u32 rsn_b_pulse_period:8; 264 u32 rsn_b_pulse_count:8; 265 }; 266 267 struct rtw_wow_gpio_info { 268 struct rtw_dev2hst_gpio_info d2h_gpio_info; 269 enum rtw_gpio_mode dev2hst_gpio_mode; 270 u8 dev2hst_gpio; 271 u8 dev2hst_high; 272 }; 273 274 struct rtw_remote_wake_ctrl_info { 275 /* core */ 276 u8 ptk_tx_iv[IV_LENGTH]; 277 u8 valid_check; 278 u8 symbol_check_en; 279 u8 gtk_key_idx; 280 u8 ptk_rx_iv[IV_LENGTH]; 281 u8 gtk_rx_iv_idx0[IV_LENGTH]; 282 u8 gtk_rx_iv_idx1[IV_LENGTH]; 283 u8 gtk_rx_iv_idx2[IV_LENGTH]; 284 u8 gtk_rx_iv_idx3[IV_LENGTH]; 285 }; 286 287 struct rtw_wow_wake_info { 288 /* core */ 289 u8 wow_en; 290 u8 drop_all_pkt; 291 u8 rx_parse_after_wake; 292 u8 pairwise_sec_algo; 293 u8 group_sec_algo; 294 u8 bip_sec_algo; 295 u8 pattern_match_en; 296 u8 magic_pkt_en; 297 u8 hw_unicast_en; 298 u8 fw_unicast_en; 299 u8 deauth_wakeup; 300 u8 rekey_wakeup; 301 u8 eap_wakeup; 302 u8 all_data_wakeup; 303 struct rtw_remote_wake_ctrl_info remote_wake_ctrl_info; 304 }; 305 306 struct rtw_aoac_report { 307 /* status check */ 308 u8 rpt_fail; 309 310 /* report from fw */ 311 u8 rpt_ver; 312 u8 sec_type; 313 u8 key_idx; 314 u8 pattern_idx; 315 u8 rekey_ok; 316 u8 ptk_tx_iv[IV_LENGTH]; 317 u8 eapol_key_replay_count[8]; 318 u8 gtk[32]; 319 u8 ptk_rx_iv[IV_LENGTH]; 320 u8 gtk_rx_iv[4][IV_LENGTH]; 321 u8 igtk_key_id[8]; 322 u8 igtk_ipn[8]; 323 u8 igtk[32]; 324 }; 325 326 #ifdef CONFIG_WOWLAN 327 328 /* Exported APIs to core */ 329 enum rtw_phl_status rtw_phl_cfg_keep_alive_info(void *phl, struct rtw_keep_alive_info *info); 330 enum rtw_phl_status rtw_phl_cfg_disc_det_info(void *phl, struct rtw_disc_det_info *info); 331 void rtw_phl_cfg_nlo_info(void *phl, struct rtw_nlo_info *info); 332 void rtw_phl_cfg_arp_ofld_info(void *phl, struct rtw_arp_ofld_info *info); 333 void rtw_phl_cfg_ndp_ofld_info(void *phl, struct rtw_ndp_ofld_info *info); 334 enum rtw_phl_status rtw_phl_remove_wow_ptrn_info(void *phl, u8 phl_ptrn_id); 335 enum rtw_phl_status rtw_phl_add_wow_ptrn_info(void *phl, struct rtw_wowcam_upd_info *info, u8 *phl_ptrn_id); 336 enum rtw_phl_status rtw_phl_cfg_gtk_ofld_info(void *phl, struct rtw_gtk_ofld_info *info); 337 enum rtw_phl_status rtw_phl_cfg_realwow_info(void *phl, struct rtw_realwow_info *info); 338 enum rtw_phl_status rtw_phl_cfg_wow_wake(void *phl, struct rtw_wow_wake_info *info); 339 enum rtw_phl_status rtw_phl_cfg_gpio_wake_pulse(void *phl, struct rtw_wow_gpio_info *info); 340 const char *rtw_phl_get_wow_rsn_str(void *phl, enum rtw_wow_wake_reason wake_rsn); 341 enum rtw_phl_status rtw_phl_cfg_wow_set_sw_gpio_mode(void *phl, struct rtw_wow_gpio_info *info); 342 enum rtw_phl_status rtw_phl_cfg_wow_sw_gpio_ctrl(void *phl, struct rtw_wow_gpio_info *info); 343 #endif /* CONFIG_WOWLAN */ 344 345 #endif /* _PHL_WOW_DEF_H_ */ 346 347