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