1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3 *
4 * Copyright(c) 2007 - 2017 Realtek Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 *****************************************************************************/
16 #ifndef __RTW_PWRCTRL_H_
17 #define __RTW_PWRCTRL_H_
18
19
20 #define FW_PWR0 0
21 #define FW_PWR1 1
22 #define FW_PWR2 2
23 #define FW_PWR3 3
24
25
26 #define HW_PWR0 7
27 #define HW_PWR1 6
28 #define HW_PWR2 2
29 #define HW_PWR3 0
30 #define HW_PWR4 8
31
32 #define FW_PWRMSK 0x7
33
34
35 #define XMIT_ALIVE BIT(0)
36 #define RECV_ALIVE BIT(1)
37 #define CMD_ALIVE BIT(2)
38 #define EVT_ALIVE BIT(3)
39 #ifdef CONFIG_BT_COEXIST
40 #define BTCOEX_ALIVE BIT(4)
41 #endif /* CONFIG_BT_COEXIST */
42 #define LPS_ALIVE BIT(5)
43
44 #ifdef CONFIG_WOWLAN
45 #ifdef CONFIG_PLATFORM_ANDROID_INTEL_X86
46 /* TCP/ICMP/UDP multicast with specific IP addr */
47 #define DEFAULT_PATTERN_NUM 4
48 #else
49 /* TCP/ICMP */
50 #define DEFAULT_PATTERN_NUM 3
51 #endif
52
53 #ifdef CONFIG_WOW_PATTERN_HW_CAM /* Frame Mask Cam number for pattern match */
54 #define MAX_WKFM_CAM_NUM 12
55 #else
56 #define MAX_WKFM_CAM_NUM 16
57 #endif
58
59 #define MAX_WKFM_SIZE 16 /* (16 bytes for WKFM bit mask, 16*8 = 128 bits) */
60 #define MAX_WKFM_PATTERN_SIZE 128
61 #define MAX_IN_PATTERN_SIZE 512
62
63 /*
64 * MAX_WKFM_PATTERN_STR_LEN : the max. length of wow pattern string
65 * e.g. echo 00:01:02:...:7f > /proc/net/rtl88x2bu/wlan0/wow_pattern_info
66 * - each byte of pattern is represented as 2-bytes ascii : MAX_WKFM_PATTERN_SIZE * 2
67 * - the number of common ':' in pattern string : MAX_WKFM_PATTERN_SIZE - 1
68 * - 1 byte '\n'(0x0a) is generated at the end when we use echo command
69 * so total max. length is (MAX_WKFM_PATTERN_SIZE * 3)
70 */
71 #define MAX_WKFM_PATTERN_STR_LEN (MAX_WKFM_PATTERN_SIZE * 3)
72
73 #define WKFMCAM_ADDR_NUM 6
74 #define WKFMCAM_SIZE 24 /* each entry need 6*4 bytes */
75 enum pattern_type {
76 PATTERN_BROADCAST = 0,
77 PATTERN_MULTICAST,
78 PATTERN_UNICAST,
79 PATTERN_VALID,
80 PATTERN_INVALID,
81 };
82
83 typedef struct rtl_priv_pattern {
84 int len;
85 char content[MAX_WKFM_PATTERN_SIZE];
86 char mask[MAX_WKFM_SIZE];
87 } rtl_priv_pattern_t;
88
89 #endif /* CONFIG_WOWLAN */
90
91 enum Power_Mgnt {
92 PS_MODE_ACTIVE = 0 ,
93 PS_MODE_MIN ,
94 PS_MODE_MAX ,
95 PS_MODE_DTIM , /* PS_MODE_SELF_DEFINED */
96 PS_MODE_VOIP ,
97 PS_MODE_UAPSD_WMM ,
98 PS_MODE_UAPSD ,
99 PS_MODE_IBSS ,
100 PS_MODE_WWLAN ,
101 PM_Radio_Off ,
102 PM_Card_Disable ,
103 PS_MODE_NUM,
104 };
105
106 enum lps_level {
107 LPS_NORMAL = 0,
108 LPS_LCLK,
109 LPS_PG,
110 LPS_LEVEL_MAX,
111 };
112
113 #ifdef CONFIG_PNO_SUPPORT
114 #define MAX_PNO_LIST_COUNT 16
115 #define MAX_SCAN_LIST_COUNT 14 /* 2.4G only */
116 #define MAX_HIDDEN_AP 8 /* 8 hidden AP */
117 #endif
118
119 /*
120 BIT[2:0] = HW state
121 BIT[3] = Protocol PS state, 0: register active state , 1: register sleep state
122 BIT[4] = sub-state
123 */
124
125 #define PS_DPS BIT(0)
126 #define PS_LCLK (PS_DPS)
127 #define PS_RF_OFF BIT(1)
128 #define PS_ALL_ON BIT(2)
129 #define PS_ST_ACTIVE BIT(3)
130
131 #define PS_ISR_ENABLE BIT(4)
132 #define PS_IMR_ENABLE BIT(5)
133 #define PS_ACK BIT(6)
134 #define PS_TOGGLE BIT(7)
135
136 #define PS_STATE_MASK (0x0F)
137 #define PS_STATE_HW_MASK (0x07)
138 #define PS_SEQ_MASK (0xc0)
139
140 #define PS_STATE(x) (PS_STATE_MASK & (x))
141 #define PS_STATE_HW(x) (PS_STATE_HW_MASK & (x))
142 #define PS_SEQ(x) (PS_SEQ_MASK & (x))
143
144 #define PS_STATE_S0 (PS_DPS)
145 #define PS_STATE_S1 (PS_LCLK)
146 #define PS_STATE_S2 (PS_RF_OFF)
147 #define PS_STATE_S3 (PS_ALL_ON)
148 #define PS_STATE_S4 ((PS_ST_ACTIVE) | (PS_ALL_ON))
149
150
151 #define PS_IS_RF_ON(x) ((x) & (PS_ALL_ON))
152 #define PS_IS_ACTIVE(x) ((x) & (PS_ST_ACTIVE))
153 #define CLR_PS_STATE(x) ((x) = ((x) & (0xF0)))
154
155
156 struct reportpwrstate_parm {
157 unsigned char mode;
158 unsigned char state; /* the CPWM value */
159 unsigned short rsvd;
160 };
161
162
163 typedef _sema _pwrlock;
164
165
_init_pwrlock(_pwrlock * plock)166 __inline static void _init_pwrlock(_pwrlock *plock)
167 {
168 _rtw_init_sema(plock, 1);
169 }
170
_free_pwrlock(_pwrlock * plock)171 __inline static void _free_pwrlock(_pwrlock *plock)
172 {
173 _rtw_free_sema(plock);
174 }
175
176
_enter_pwrlock(_pwrlock * plock)177 __inline static void _enter_pwrlock(_pwrlock *plock)
178 {
179 _rtw_down_sema(plock);
180 }
181
182
_exit_pwrlock(_pwrlock * plock)183 __inline static void _exit_pwrlock(_pwrlock *plock)
184 {
185 _rtw_up_sema(plock);
186 }
187
188 #define LPS_DELAY_MS 1000 /* 1 sec */
189
190 #define EXE_PWR_NONE 0x01
191 #define EXE_PWR_IPS 0x02
192 #define EXE_PWR_LPS 0x04
193
194 /* RF state. */
195 typedef enum _rt_rf_power_state {
196 rf_on, /* RF is on after RFSleep or RFOff */
197 rf_sleep, /* 802.11 Power Save mode */
198 rf_off, /* HW/SW Radio OFF or Inactive Power Save */
199 /* =====Add the new RF state above this line===== */
200 rf_max
201 } rt_rf_power_state;
202
203 /* ASPM OSC Control bit, added by Roger, 2013.03.29. */
204 #define RT_PCI_ASPM_OSC_IGNORE 0 /* PCI ASPM ignore OSC control in default */
205 #define RT_PCI_ASPM_OSC_ENABLE BIT0 /* PCI ASPM controlled by OS according to ACPI Spec 5.0 */
206 #define RT_PCI_ASPM_OSC_DISABLE BIT1 /* PCI ASPM controlled by driver or BIOS, i.e., force enable ASPM */
207
208
209 enum _PS_BBRegBackup_ {
210 PSBBREG_RF0 = 0,
211 PSBBREG_RF1,
212 PSBBREG_RF2,
213 PSBBREG_AFE0,
214 PSBBREG_TOTALCNT
215 };
216
217 enum { /* for ips_mode */
218 IPS_NONE = 0,
219 IPS_NORMAL,
220 IPS_LEVEL_2,
221 IPS_NUM
222 };
223
224 /* Design for pwrctrl_priv.ips_deny, 32 bits for 32 reasons at most */
225 typedef enum _PS_DENY_REASON {
226 PS_DENY_DRV_INITIAL = 0,
227 PS_DENY_SCAN,
228 PS_DENY_JOIN,
229 PS_DENY_DISCONNECT,
230 PS_DENY_SUSPEND,
231 PS_DENY_IOCTL,
232 PS_DENY_MGNT_TX,
233 PS_DENY_MONITOR_MODE,
234 PS_DENY_BEAMFORMING, /* Beamforming */
235 PS_DENY_DRV_REMOVE = 30,
236 PS_DENY_OTHERS = 31
237 } PS_DENY_REASON;
238
239 #ifdef CONFIG_WAR_OFFLOAD
240 /* only support mDNS V4/V6 rsp now */
241 enum {
242 WAR_ARP_RSP_EN = 0x0000001,
243 WAR_ICMPV6_NS_RSP_EN = 0x00000002,
244 WAR_ICMPV4_ECHO_RSP_EN = 0x00000004,
245 WAR_ICMPV6_ECHO_RSP_EN = 0x00000008,
246 WAR_NETBIOS_RSP_EN = 0x00000010,
247 WAR_LLMNR_V4_RSP_EN = 0x00000020,
248 WAR_LLMNR_V6_RSP_EN = 0x00000040,
249 WAR_SNMP_V4_RSP_EN = 0x00000080,
250 WAR_SNMP_V6_RSP_EN = 0x00000100,
251 WAR_SNMP_V4_WAKEUP_EN = 0x00000200,
252 WAR_SNMP_V6_WAKEUP_EN = 0x00000400,
253 WAR_SSDP_V4_WAKEUP_EN = 0x00000800,
254 WAR_SSDP_V6_WAKEUP_EN = 0x00001000,
255 WAR_WSD_V4_WAKEUP_EN = 0x00002000,
256 WAR_WSD_V6_WAKEUP_EN = 0x00004000,
257 WAR_SLP_V4_WAKEUP_EN = 0x00008000,
258 WAR_SLP_V6_WAKEUP_EN = 0x00010000,
259 WAR_MDNS_V4_RSP_EN = 0x00020000,
260 WAR_MDNS_V6_RSP_EN = 0x00040000,
261 WAR_DESIGNATED_MAC_EN = 0x00080000,
262 WAR_LLTD_WAKEUP_EN = 0x00100000,
263 WAR_ARP_WAKEUP_EN = 0x00200000,
264 WAR_MAGIC_WAKEUP_EN = 0x00400000,
265 WAR_MDNS_V4_WAKEUP_EN = 0x000800000,
266 WAR_MDNS_V6_WAKEUP_EN = 0x001000000
267 };
268
269 #endif /* CONFIG_WAR_OFFLOAD */
270
271 #ifdef CONFIG_PNO_SUPPORT
272 typedef struct pno_nlo_info {
273 u32 fast_scan_period; /* Fast scan period */
274 u8 ssid_num; /* number of entry */
275 u8 hidden_ssid_num;
276 u32 slow_scan_period; /* slow scan period */
277 u32 fast_scan_iterations; /* Fast scan iterations */
278 u8 ssid_length[MAX_PNO_LIST_COUNT]; /* SSID Length Array */
279 u8 ssid_cipher_info[MAX_PNO_LIST_COUNT]; /* Cipher information for security */
280 u8 ssid_channel_info[MAX_PNO_LIST_COUNT]; /* channel information */
281 u8 loc_probe_req[MAX_HIDDEN_AP]; /* loc_probeReq */
282 } pno_nlo_info_t;
283
284 typedef struct pno_ssid {
285 u32 SSID_len;
286 u8 SSID[32];
287 } pno_ssid_t;
288
289 typedef struct pno_ssid_list {
290 pno_ssid_t node[MAX_PNO_LIST_COUNT];
291 } pno_ssid_list_t;
292
293 typedef struct pno_scan_channel_info {
294 u8 channel;
295 u8 tx_power;
296 u8 timeout;
297 u8 active; /* set 1 means active scan, or pasivite scan. */
298 } pno_scan_channel_info_t;
299
300 typedef struct pno_scan_info {
301 u8 enableRFE; /* Enable RFE */
302 u8 period_scan_time; /* exclusive with fast_scan_period and slow_scan_period */
303 u8 periodScan; /* exclusive with fast_scan_period and slow_scan_period */
304 u8 orig_80_offset; /* original channel 80 offset */
305 u8 orig_40_offset; /* original channel 40 offset */
306 u8 orig_bw; /* original bandwidth */
307 u8 orig_ch; /* original channel */
308 u8 channel_num; /* number of channel */
309 u64 rfe_type; /* rfe_type && 0x00000000000000ff */
310 pno_scan_channel_info_t ssid_channel_info[MAX_SCAN_LIST_COUNT];
311 } pno_scan_info_t;
312 #endif /* CONFIG_PNO_SUPPORT */
313
314 #ifdef CONFIG_LPS_POFF
315 /* Driver context for LPS 32K Close IO Power */
316 typedef struct lps_poff_info {
317 bool bEn;
318 u8 *pStaticFile;
319 u8 *pDynamicFile;
320 u32 ConfFileOffset;
321 u32 tx_bndy_static;
322 u32 tx_bndy_dynamic;
323 u16 ConfLenForPTK;
324 u16 ConfLenForGTK;
325 ATOMIC_T bEnterPOFF;
326 ATOMIC_T bTxBoundInProgress;
327 ATOMIC_T bSetPOFFParm;
328 } lps_poff_info_t;
329 #endif /*CONFIG_LPS_POFF*/
330
331 struct aoac_report {
332 u8 iv[8];
333 u8 replay_counter_eapol_key[8];
334 u8 group_key[32];
335 u8 key_index;
336 u8 security_type;
337 u8 wow_pattern_idx;
338 u8 version_info;
339 u8 rekey_ok:1;
340 u8 dummy:7;
341 u8 reserved[3];
342 u8 rxptk_iv[8];
343 u8 rxgtk_iv[4][8];
344 };
345
346 #ifdef CONFIG_WAR_OFFLOAD
347
348 struct war_ipv4_fmt {
349 u32 ip_addr[4];
350 u32 ip_subnet[4];
351 u32 ip_gateway[4];
352 };
353
354 struct war_ipv6_fmt {
355 u8 ipv6_addr[8][16];
356 };
357
358 #if defined(CONFIG_OFFLOAD_MDNS_V4) || defined(CONFIG_OFFLOAD_MDNS_V6)
359 /* limitation of mDNS parameter : length and number */
360 #define MAX_MDNS_SERVICE_NAME_LEN 15
361 #define MAX_MDNS_TRANS_LEN 4 /* _tcp or _udp */
362 #define MAX_MDNS_DOMAIN_LEN 5 /* local only for mdns */
363 #define MAX_MDNS_MACHINE_NAME_LEN (63+1) /* +1 for the length byte used by the DNS format */
364 #define MAX_MDNS_TARGET_LEN 63
365 #define MAX_MDNS_DOMAIN_NAME_LEN 63
366 #define MAX_MDNS_TXT_LEN 1536
367 #define MAX_MDNS_TXT_SINGLE_LEN 255
368
369
370 #define MAX_MDNS_SERVICE_NUM 10
371 #define MAX_MDNS_TXT_NUM 8
372 #define MAX_MDNS_MACHINE_NAME_NUM 3
373
374 /* for monitor rsvd page using */
375 #define MAX_MDNS_PARA_SIZE 1700 // 14*128 = 1792
376 #define MAX_MDNS_TXT_TOTAL_SIZE 10*MAX_MDNS_TXT_LEN
377 #define MAX_MDNS_RSP_PKT_SIZE 760 // 6*128 = 768
378
379 #define RTW_MDNS_SRV_INFO(sname, sname_len, tname, tname_len, dname, dname_len, port0, port1, ttlv, tar, tar_len, idx) \
380 { .service=sname, .service_len=sname_len, .transport=tname, .transport_len=tname_len, \
381 .domain=dname , .domain_len=dname_len , .port[0]=port0, .port[1]=port1, .ttl=ttlv, \
382 .target=tar, .target_len=tar_len, .txt_rsp_idx=idx }
383
384
385 struct war_mdns_service_info {
386 u8 service[MAX_MDNS_SERVICE_NAME_LEN+1];
387 u8 service_len;
388 u8 transport[MAX_MDNS_TRANS_LEN+1];
389 u8 transport_len;
390 u8 domain[MAX_MDNS_DOMAIN_LEN+1];
391 u8 domain_len;
392 u8 port[2];
393 u32 ttl;
394 u8 target[MAX_MDNS_TARGET_LEN+1];
395 u8 target_len;
396 s8 txt_rsp_idx;
397 };
398
399 struct war_mdns_machine_name {
400 u8 name[MAX_MDNS_MACHINE_NAME_LEN];
401 u8 name_len;
402 };
403
404 struct war_mdns_txt_rsp {
405 u8 txt[MAX_MDNS_TXT_LEN];
406 u16 txt_len;
407 };
408 #endif
409 #endif /* CONFIG_WAR_OFFLOAD */
410
411
412 struct rsvd_page_cache_t;
413
414 struct pwrctrl_priv {
415 _pwrlock lock;
416 _pwrlock check_32k_lock;
417 volatile u8 rpwm; /* requested power state for fw */
418 volatile u8 cpwm; /* fw current power state. updated when 1. read from HCPWM 2. driver lowers power level */
419 volatile u8 tog; /* toggling */
420 volatile u8 cpwm_tog; /* toggling */
421 u8 rpwm_retry;
422
423 u8 pwr_mode;
424 u8 smart_ps;
425 u8 bcn_ant_mode;
426 u8 dtim;
427 #ifdef CONFIG_LPS_CHK_BY_TP
428 u8 lps_chk_by_tp;
429 u16 lps_tx_tp_th;/*Mbps*/
430 u16 lps_rx_tp_th;/*Mbps*/
431 u16 lps_bi_tp_th;/*Mbps*//*TRX TP*/
432 int lps_chk_cnt_th;
433 int lps_chk_cnt;
434 u32 lps_tx_pkts;
435 u32 lps_rx_pkts;
436
437 #endif
438
439 #ifdef CONFIG_WMMPS_STA
440 u8 wmm_smart_ps;
441 #endif /* CONFIG_WMMPS_STA */
442
443 u32 alives;
444 _workitem cpwm_event;
445 _workitem dma_event; /*for handle un-synchronized tx dma*/
446 #ifdef CONFIG_LPS_RPWM_TIMER
447 u8 brpwmtimeout;
448 _workitem rpwmtimeoutwi;
449 _timer pwr_rpwm_timer;
450 #endif /* CONFIG_LPS_RPWM_TIMER */
451 u8 bpower_saving; /* for LPS/IPS */
452
453 u8 b_hw_radio_off;
454 u8 reg_rfoff;
455 u8 reg_pdnmode; /* powerdown mode */
456 u32 rfoff_reason;
457
458 uint ips_enter_cnts;
459 uint ips_leave_cnts;
460 uint lps_enter_cnts;
461 uint lps_leave_cnts;
462
463 u8 ips_mode;
464 u8 ips_org_mode;
465 u8 ips_mode_req; /* used to accept the mode setting request, will update to ipsmode later */
466 uint bips_processing;
467 systime ips_deny_time; /* will deny IPS when system time is smaller than this */
468 u8 pre_ips_type;/* 0: default flow, 1: carddisbale flow */
469
470 /* ps_deny: if 0, power save is free to go; otherwise deny all kinds of power save. */
471 /* Use PS_DENY_REASON to decide reason. */
472 /* Don't access this variable directly without control function, */
473 /* and this variable should be protected by lock. */
474 u32 ps_deny;
475
476 u8 ps_processing; /* temporarily used to mark whether in rtw_ps_processor */
477
478 u8 fw_psmode_iface_id;
479 u8 bLeisurePs;
480 u8 LpsIdleCount;
481 u8 power_mgnt;
482 u8 org_power_mgnt;
483 u8 bFwCurrentInPSMode;
484 systime lps_deny_time; /* will deny LPS when system time is smaller than this */
485 s32 pnp_current_pwr_state;
486 u8 pnp_bstop_trx;
487 u8 bInSuspend;
488 #ifdef CONFIG_BT_COEXIST
489 u8 bAutoResume;
490 u8 autopm_cnt;
491 #endif
492 u8 bSupportRemoteWakeup;
493 u8 wowlan_wake_reason;
494 u8 wowlan_last_wake_reason;
495 u8 wowlan_ap_mode;
496 u8 wowlan_mode;
497 u8 wowlan_p2p_mode;
498 u8 wowlan_pno_enable;
499 u8 wowlan_in_resume;
500
501 #ifdef CONFIG_GPIO_WAKEUP
502 u8 is_high_active;
503 u8 wowlan_gpio_index;
504 u8 wowlan_gpio_output_state;
505 #endif /* CONFIG_GPIO_WAKEUP */
506 u8 hst2dev_high_active;
507 #ifdef CONFIG_WOWLAN
508 bool default_patterns_en;
509 #ifdef CONFIG_IPV6
510 u8 wowlan_ns_offload_en;
511 #endif /*CONFIG_IPV6*/
512 u8 wowlan_txpause_status;
513 u8 wowlan_pattern_idx;
514 u64 wowlan_fw_iv;
515 struct rtl_priv_pattern patterns[MAX_WKFM_CAM_NUM];
516 #ifdef CONFIG_PNO_SUPPORT
517 u8 pno_inited;
518 pno_nlo_info_t *pnlo_info;
519 pno_scan_info_t *pscan_info;
520 pno_ssid_list_t *pno_ssid_list;
521 #endif /* CONFIG_PNO_SUPPORT */
522 #ifdef CONFIG_WOW_PATTERN_HW_CAM
523 _mutex wowlan_pattern_cam_mutex;
524 #endif
525 u8 wowlan_aoac_rpt_loc;
526 struct aoac_report wowlan_aoac_rpt;
527 u8 wowlan_power_mgmt;
528 u8 wowlan_lps_level;
529 #ifdef CONFIG_LPS_1T1R
530 u8 wowlan_lps_1t1r;
531 #endif
532
533 #ifdef CONFIG_WOW_KEEP_ALIVE_PATTERN
534 /*data 0,rsv page location*/
535 u8 wowlan_keep_alive_mode;
536 u8 keep_alive_pattern_loc;
537 /*data 1 ,cam id, rx udp packet*/
538 u8 wowlan_keep_alive_ack_index;
539 /*data 2 ,cam id, pattern match packet*/
540 u8 wowlan_wake_pattern_index;
541 /*data3,unit: TBTT*/
542 u16 wowlan_keep_alive_period;
543 /*data4,unit: TBTT*/
544 u8 wowlan_keep_alive_retry_interval;
545 /*data5*/
546 u8 wowlan_keep_alive_retry_counter;
547 /*from echo*/
548 u8 keep_alive_pattern[WLAN_MAX_KEEP_ALIVE_IE_LEN];
549 u32 keep_alive_pattern_len;
550 #endif /*CONFIG_WOW_KEEP_ALIVE_PATTERN*/
551
552 #ifdef CONFIG_WAR_OFFLOAD
553 u8 wowlan_war_offload_mode;
554 u32 wowlan_war_offload_ctrl;
555 struct war_ipv4_fmt wowlan_war_offload_ipv4;
556 struct war_ipv6_fmt wowlan_war_offload_ipv6;
557 u8 wowlan_war_offload_mac[6];
558 #if defined(CONFIG_OFFLOAD_MDNS_V4) || defined(CONFIG_OFFLOAD_MDNS_V6)
559 struct war_mdns_machine_name wowlan_war_offload_mdns_mnane[MAX_MDNS_MACHINE_NAME_NUM];
560 struct war_mdns_service_info wowlan_war_offload_mdns_service[MAX_MDNS_SERVICE_NUM];
561 struct war_mdns_txt_rsp wowlan_war_offload_mdns_txt_rsp[MAX_MDNS_TXT_NUM];
562 u8 wowlan_war_offload_mdns_mnane_num;
563 u8 wowlan_war_offload_mdns_service_info_num;
564 u8 wowlan_war_offload_mdns_txt_rsp_num;
565 u8 wowlan_war_offload_mdns_domain_name[MAX_MDNS_DOMAIN_NAME_LEN+1];
566 u8 wowlan_war_offload_mdns_domain_name_len;
567 u32 wowlan_war_offload_mdns_para_cur_size;
568 u32 wowlan_war_offload_mdns_rsp_cur_size;
569 #endif /* CONFIG_OFFLOAD_MDNS_V4 || CONFIG_OFFLOAD_MDNS_V6 */
570 #endif /* CONFIG_WAR_OFFLOAD */
571 #endif /* CONFIG_WOWLAN */
572 _timer pwr_state_check_timer;
573 int pwr_state_check_interval;
574 u8 pwr_state_check_cnts;
575
576
577 rt_rf_power_state rf_pwrstate;/* cur power state, only for IPS */
578 /* rt_rf_power_state current_rfpwrstate; */
579 rt_rf_power_state change_rfpwrstate;
580
581 u8 bHWPowerdown; /* power down mode selection. 0:radio off, 1:power down */
582 u8 bHWPwrPindetect; /* come from registrypriv.hwpwrp_detect. enable power down function. 0:disable, 1:enable */
583 u8 bkeepfwalive;
584 u8 brfoffbyhw;
585 unsigned long PS_BBRegBackup[PSBBREG_TOTALCNT];
586
587 #ifdef CONFIG_RESUME_IN_WORKQUEUE
588 struct workqueue_struct *rtw_workqueue;
589 _workitem resume_work;
590 #endif
591
592 #ifdef CONFIG_HAS_EARLYSUSPEND
593 struct early_suspend early_suspend;
594 u8 do_late_resume;
595 #endif /* CONFIG_HAS_EARLYSUSPEND */
596
597 #ifdef CONFIG_ANDROID_POWER
598 android_early_suspend_t early_suspend;
599 u8 do_late_resume;
600 #endif
601
602 #ifdef CONFIG_LPS_POFF
603 lps_poff_info_t *plps_poff_info;
604 #endif
605 u8 lps_level_bk;
606 u8 lps_level; /*LPS_NORMAL,LPA_CG,LPS_PG*/
607 #ifdef CONFIG_LPS_1T1R
608 u8 lps_1t1r_bk;
609 u8 lps_1t1r;
610 #endif
611 #ifdef CONFIG_LPS_PG
612 struct rsvd_page_cache_t lpspg_info;
613 #ifdef CONFIG_RTL8822C
614 struct rsvd_page_cache_t lpspg_dpk_info;
615 struct rsvd_page_cache_t lpspg_iqk_info;
616 #endif
617 #endif
618 u8 current_lps_hw_port_id;
619
620 #ifdef CONFIG_RTW_CFGVENDOR_LLSTATS
621 systime radio_on_start_time;
622 systime pwr_saving_start_time;
623 u32 pwr_saving_time;
624 u32 on_time;
625 u32 tx_time;
626 u32 rx_time;
627 #endif /* CONFIG_RTW_CFGVENDOR_LLSTATS */
628
629 #ifdef CONFIG_LPS_ACK
630 struct submit_ctx lps_ack_sctx;
631 s8 lps_ack_status;
632 _mutex lps_ack_mutex;
633 #endif /* CONFIG_LPS_ACK */
634 };
635
636 #define rtw_get_ips_mode_req(pwrctl) \
637 (pwrctl)->ips_mode_req
638
639 #define rtw_ips_mode_req(pwrctl, ips_mode) \
640 (pwrctl)->ips_mode_req = (ips_mode)
641
642 #define RTW_PWR_STATE_CHK_INTERVAL 2000
643
644 #define _rtw_set_pwr_state_check_timer(pwrctl, ms) \
645 do { \
646 /*RTW_INFO("%s _rtw_set_pwr_state_check_timer(%p, %d)\n", __FUNCTION__, (pwrctl), (ms));*/ \
647 _set_timer(&(pwrctl)->pwr_state_check_timer, (ms)); \
648 } while (0)
649
650 #define rtw_set_pwr_state_check_timer(pwrctl) \
651 _rtw_set_pwr_state_check_timer((pwrctl), (pwrctl)->pwr_state_check_interval)
652
653 extern void rtw_init_pwrctrl_priv(_adapter *adapter);
654 extern void rtw_free_pwrctrl_priv(_adapter *adapter);
655
656 #ifdef CONFIG_LPS_LCLK
657 s32 rtw_register_task_alive(PADAPTER, u32 task);
658 void rtw_unregister_task_alive(PADAPTER, u32 task);
659 extern s32 rtw_register_tx_alive(PADAPTER padapter);
660 extern void rtw_unregister_tx_alive(PADAPTER padapter);
661 extern s32 rtw_register_rx_alive(PADAPTER padapter);
662 extern void rtw_unregister_rx_alive(PADAPTER padapter);
663 extern s32 rtw_register_cmd_alive(PADAPTER padapter);
664 extern void rtw_unregister_cmd_alive(PADAPTER padapter);
665 extern s32 rtw_register_evt_alive(PADAPTER padapter);
666 extern void rtw_unregister_evt_alive(PADAPTER padapter);
667 extern void cpwm_int_hdl(PADAPTER padapter, struct reportpwrstate_parm *preportpwrstate);
668 extern void LPS_Leave_check(PADAPTER padapter);
669 #endif
670
671 extern void LeaveAllPowerSaveMode(PADAPTER Adapter);
672 extern void LeaveAllPowerSaveModeDirect(PADAPTER Adapter);
673 #ifdef CONFIG_IPS
674 void _ips_enter(_adapter *padapter);
675 void ips_enter(_adapter *padapter);
676 int _ips_leave(_adapter *padapter);
677 int ips_leave(_adapter *padapter);
678 #endif
679
680 void rtw_ps_processor(_adapter *padapter);
681
682 #ifdef SUPPORT_HW_RFOFF_DETECTED
683 rt_rf_power_state RfOnOffDetect(PADAPTER pAdapter);
684 #endif
685
686
687 #ifdef DBG_CHECK_FW_PS_STATE
688 int rtw_fw_ps_state(PADAPTER padapter);
689 #endif
690
691 #ifdef CONFIG_LPS
692 extern const char * const LPS_CTRL_PHYDM;
693 void LPS_Enter(PADAPTER padapter, const char *msg);
694 void LPS_Leave(PADAPTER padapter, const char *msg);
695 void rtw_exec_lps(_adapter *padapter, u8 ps_mode);
696 void rtw_lps_rfon_ctrl(_adapter *padapter, u8 rfon_ctrl);
697 #ifdef CONFIG_CHECK_LEAVE_LPS
698 #ifdef CONFIG_LPS_CHK_BY_TP
699 void traffic_check_for_leave_lps_by_tp(PADAPTER padapter, u8 tx, struct sta_info *sta);
700 #endif
701 void traffic_check_for_leave_lps(PADAPTER padapter, u8 tx, u32 tx_packets);
702 #endif /*CONFIG_CHECK_LEAVE_LPS*/
703 void rtw_set_ps_mode(PADAPTER padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode, const char *msg);
704 void rtw_set_fw_in_ips_mode(PADAPTER padapter, u8 enable);
705 u8 rtw_set_rpwm(_adapter *padapter, u8 val8);
706 #ifdef CONFIG_WOWLAN
707 void rtw_wow_lps_level_decide(_adapter *adapter, u8 wow_en);
708 #endif /* CONFIG_WOWLAN */
709 #endif /* CONFIG_LPS */
710
711 #ifdef CONFIG_RESUME_IN_WORKQUEUE
712 void rtw_resume_in_workqueue(struct pwrctrl_priv *pwrpriv);
713 #endif /* CONFIG_RESUME_IN_WORKQUEUE */
714
715 #if defined(CONFIG_HAS_EARLYSUSPEND) || defined(CONFIG_ANDROID_POWER)
716 bool rtw_is_earlysuspend_registered(struct pwrctrl_priv *pwrpriv);
717 bool rtw_is_do_late_resume(struct pwrctrl_priv *pwrpriv);
718 void rtw_set_do_late_resume(struct pwrctrl_priv *pwrpriv, bool enable);
719 void rtw_register_early_suspend(struct pwrctrl_priv *pwrpriv);
720 void rtw_unregister_early_suspend(struct pwrctrl_priv *pwrpriv);
721 #else
722 #define rtw_is_earlysuspend_registered(pwrpriv) _FALSE
723 #define rtw_is_do_late_resume(pwrpriv) _FALSE
724 #define rtw_set_do_late_resume(pwrpriv, enable) do {} while (0)
725 #define rtw_register_early_suspend(pwrpriv) do {} while (0)
726 #define rtw_unregister_early_suspend(pwrpriv) do {} while (0)
727 #endif /* CONFIG_HAS_EARLYSUSPEND || CONFIG_ANDROID_POWER */
728
729 u8 rtw_interface_ps_func(_adapter *padapter, HAL_INTF_PS_FUNC efunc_id, u8 *val);
730 void rtw_set_ips_deny(_adapter *padapter, u32 ms);
731 int _rtw_pwr_wakeup(_adapter *padapter, u32 ips_deffer_ms, const char *caller);
732 #define rtw_pwr_wakeup(adapter) _rtw_pwr_wakeup(adapter, RTW_PWR_STATE_CHK_INTERVAL, __FUNCTION__)
733 #define rtw_pwr_wakeup_ex(adapter, ips_deffer_ms) _rtw_pwr_wakeup(adapter, ips_deffer_ms, __FUNCTION__)
734 int rtw_pm_set_ips(_adapter *padapter, u8 mode);
735 int rtw_pm_set_lps(_adapter *padapter, u8 mode);
736 int rtw_pm_set_lps_level(_adapter *padapter, u8 level);
737 #ifdef CONFIG_LPS_1T1R
738 int rtw_pm_set_lps_1t1r(_adapter *padapter, u8 en);
739 #endif
740 void rtw_set_lps_deny(_adapter *adapter, u32 ms);
741 #ifdef CONFIG_WOWLAN
742 int rtw_pm_set_wow_lps(_adapter *padapter, u8 mode);
743 int rtw_pm_set_wow_lps_level(_adapter *padapter, u8 level);
744 #ifdef CONFIG_LPS_1T1R
745 int rtw_pm_set_wow_lps_1t1r(_adapter *padapter, u8 en);
746 #endif
747 #endif /* CONFIG_WOWLAN */
748
749 void rtw_ps_deny(PADAPTER padapter, PS_DENY_REASON reason);
750 void rtw_ps_deny_cancel(PADAPTER padapter, PS_DENY_REASON reason);
751 u32 rtw_ps_deny_get(PADAPTER padapter);
752
753 #if defined(CONFIG_WOWLAN)
754 void rtw_get_current_ip_address(PADAPTER padapter, u8 *pcurrentip);
755 void rtw_get_sec_iv(PADAPTER padapter, u8 *pcur_dot11txpn, u8 *StaAddr);
756 bool rtw_wowlan_parser_pattern_cmd(u8 *input, char *pattern,
757 int *pattern_len, char *bit_mask);
758 void rtw_wow_pattern_sw_reset(_adapter *adapter);
759 u8 rtw_set_default_pattern(_adapter *adapter);
760 void rtw_wow_pattern_sw_dump(_adapter *adapter);
761 #ifdef CONFIG_WAR_OFFLOAD
762 #if defined(CONFIG_OFFLOAD_MDNS_V4) || defined(CONFIG_OFFLOAD_MDNS_V6)
763 void rtw_wow_war_mdns_dump_buf(struct seq_file *m, u8 *title, u8 *buf, u32 len);
764 void rtw_wow_war_mdns_dump_txt(struct seq_file *m, u8 *title, u8 *buf, u32 len);
765 bool rtw_wow_war_mdns_parser_pattern(u8 *input, char *target, u32 *target_len, u32 max_len);
766 void rtw_wow_war_mdns_parms_reset(_adapter *adapter, u8 is_set_default);
767 #endif /* defined(CONFIG_OFFLOAD_MDNS_V4) || defined(CONFIG_OFFLOAD_MDNS_V6) */
768 #endif /* CONFIG_WAR_OFFLOAD */
769
770 #endif /* CONFIG_WOWLAN */
771 void rtw_ssmps_enter(_adapter *adapter, struct sta_info *sta);
772 void rtw_ssmps_leave(_adapter *adapter, struct sta_info *sta);
773 #endif /* __RTL871X_PWRCTRL_H_ */
774