hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
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
/******************************************************************************
 *
 * Copyright(c) 2007 - 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 __RTW_WOW_H_
#define __RTW_WOW_H_
 
#ifdef CONFIG_WOWLAN
/* WoWLAN Info define */
/*=========================== Remote Control Info =========================== */
#define REMOTECTRL_INFO_VALID_CHECK        0xdd
#define REMOTECTRL_INFO_SYMBOL_CHK_PTK        BIT0
#define REMOTECTRL_INFO_SYMBOL_CHK_GTK        BIT1
/*============================================================================*/
   #ifdef CONFIG_PLATFORM_ANDROID_INTEL_X86
       /* TCP/ICMP/UDP multicast with specific IP addr */
       #define DEFAULT_PATTERN_NUM 4
   #else
       /* TCP/ICMP */
       #define DEFAULT_PATTERN_NUM 3
   #endif
 
#define MAX_WKFM_CAM_NUM    18 /* same as MAX_WOW_CAM_NUM */
 
#define MAX_WKFM_SIZE    16 /* (16 bytes for WKFM bit mask, 16*8 = 128 bits) */
#define MAX_WKFM_PATTERN_SIZE    128
#define MAX_IN_PATTERN_SIZE    512
 
/*
 * MAX_WKFM_PATTERN_STR_LEN : the max. length of wow pattern string
 *    e.g. echo 00:01:02:...:7f > /proc/net/rtl88x2bu/wlan0/wow_pattern_info
 *    - each byte of pattern is represented as 2-bytes ascii : MAX_WKFM_PATTERN_SIZE * 2
 *    - the number of common ':' in pattern string : MAX_WKFM_PATTERN_SIZE - 1
 *    - 1 byte '\n'(0x0a) is generated at the end when we use echo command
 *    so total max. length is (MAX_WKFM_PATTERN_SIZE * 3)
 */
#define MAX_WKFM_PATTERN_STR_LEN (MAX_WKFM_PATTERN_SIZE * 3)
 
#define WKFMCAM_ADDR_NUM 6
#define WKFMCAM_SIZE 24 /* each entry need 6*4 bytes */
 
#define IS_DISCONNECT_WOW_REASON(rsn) \
   (rsn == RTW_MAC_WOW_RX_DISASSOC || \
    rsn == RTW_MAC_WOW_RX_DEAUTH || \
    rsn == RTW_MAC_WOW_FW_DECISION_DISCONNECT || \
    rsn == RTW_MAC_WOW_NO_WAKE_RX_PAIRWISEKEY || \
    rsn == RTW_MAC_WOW_NO_WAKE_RX_GTK || \
    rsn == RTW_MAC_WOW_NO_WAKE_RX_DISASSOC || \
    rsn == RTW_MAC_WOW_NO_WAKE_RX_DEAUTH || \
    rsn == RTW_MAC_WOW_NO_WAKE_RX_EAPREQ_IDENTIFY || \
    rsn == RTW_MAC_WOW_NO_WAKE_FW_DECISION_DISCONNECT || \
    0)
 
struct aoac_report {
   u8 iv[8];
   u8 replay_counter_eapol_key[8];
   u8 group_key[32];
   u8 key_index;
   u8 security_type;
   u8 wow_pattern_idx;
   u8 version_info;
   u8 rekey_ok:1;
   u8 dummy:7;
   u8 reserved[3];
   u8 rxptk_iv[8];
   u8 rxgtk_iv[4][8];
};
 
enum pattern_type {
   RTW_INVALID_PATTERN,
   RTW_DEFAULT_PATTERN,
   RTW_CUSTOMIZED_PATTERN,
};
 
enum rtw_wow_dev2hst_gpio {
   DEV2HST_GPIO_OUTPUT = 0,
   DEV2HST_GPIO_INPUT = 1
};
 
enum rtw_wow_dev2hst_active {
   DEV2HST_LOW_ACTIVE = 0,
   DEV2HST_HIGH_ACTIVE = 1
};
 
enum rtw_wow_dev2hst_toggle_pulse {
   DEV2HST_TOGGLE = 0,
   DEV2HST_PULSE = 1
};
 
enum rtw_wow_dev2hst_time_unit {
   DEV2HST_32US = 0,
   DEV2HST_4MS = 1
};
 
typedef struct rtl_priv_pattern {
   int len;
   char content[MAX_WKFM_PATTERN_SIZE];
   char mask[MAX_WKFM_SIZE];
} rtl_priv_pattern_t;
 
struct wow_priv {
   enum rtw_mac_wow_wake_reason wow_wake_reason;
 
   struct rtw_wow_gpio_info wow_gpio;
   struct rtw_disc_det_info wow_disc;
#ifdef CONFIG_PNO_SUPPORT
   struct rtw_nlo_info wow_nlo;
#endif
   enum pattern_type wow_ptrn_valid[MAX_WKFM_CAM_NUM];
};
 
void rtw_init_wow(_adapter *padapter);
void rtw_free_wow(_adapter *adapter);
void rtw_get_sec_iv(_adapter *padapter, u8 *pcur_dot11txpn, u8 *StaAddr);
bool rtw_wowlan_parser_pattern_cmd(u8 *input, char *pattern,
               int *pattern_len, char *bit_mask);
u8 rtw_wow_pattern_set(_adapter *adapter,
              struct rtw_wowcam_upd_info * wowcam_info,
              enum pattern_type set_type);
void rtw_wow_pattern_clean(_adapter *adapter, enum pattern_type clean_type);
void rtw_set_default_pattern(_adapter *adapter);
void rtw_wow_pattern_sw_dump(_adapter *adapter);
void rtw_construct_remote_control_info(_adapter *adapter,
                      struct rtw_remote_wake_ctrl_info *ctrl_info);
void rtw_core_wow_handle_wake_up_rsn(void *drv_priv, u8 rsn);
#ifdef CONFIG_GTK_OL
void rtw_update_gtk_ofld_info(void *drv_priv, struct rtw_aoac_report *aoac_info,
                 u8 aoac_report_get_ok, u8 phase);
#endif
void rtw_wowlan_set_pattern_cast_type(_adapter *adapter, struct rtw_wowcam_upd_info *wowcam_info);
#ifdef CONFIG_WRC_WOW_MAGIC
/**
 * rtw_cfg_wrc_wol_magic - Enable/disable WRC magic packet wake up feature
 *
 * This function uses a non-wowlan adapter to set the address cam required by
 * the WRC (wireless remote control), and receives packets with A1 and A3 as the
 * MAC address of the wowlan adapter.
 *
 * When this feature is disabled, the driver will reallocate the wifi role of
 * the non-wowlan adapter.
 */
u8 rtw_cfg_wrc_wol_magic(_adapter *padapter, u8 enable);
#endif
#endif /* CONFIG_WOWLAN */
 
#ifdef CONFIG_PNO_SUPPORT
#define MAX_NLO_SCAN_PLANS 2
#define MAX_NLO_SCAN_PERIOD 600
#define MAX_NLO_NORMAL_SCAN_CYCLE 255
#define NLO_DEFAULT_SCAN_DELAY 3
int rtw_nlo_enable(struct net_device *net, struct cfg80211_ssid *ssids,
          int n_ssids, struct ieee80211_channel **channels,
          u32 n_channels, u32 delay, u32 interval, u32 iterations,
          u32 slow_interval);
int rtw_nlo_disable(struct net_device *net);
void rtw_nlo_debug(struct net_device * net);
#endif /* CONFIG_PNO_SUPPORT */
 
#endif /* __RTW_WOW_H_ */