xref: /wlan-driver/qcacld-3.0/components/pmo/dispatcher/inc/wlan_pmo_wow_public_struct.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 /**
20  * DOC: Declare various struct, macros which shall be used in
21  * pmo wow related features.
22  *
23  * Note: This file shall not contain public API's prototype/declarations.
24  *
25  */
26 
27 #ifndef _WLAN_PMO_WOW_PUBLIC_STRUCT_H_
28 #include "wlan_pmo_lphb_public_struct.h"
29 
30 #define _WLAN_PMO_WOW_PUBLIC_STRUCT_H_
31 
32 #ifndef PMO_WOW_FILTERS_MAX
33 #define PMO_WOW_FILTERS_MAX             22
34 #endif
35 
36 #define PMO_WOWL_PTRN_MAX_SIZE          146
37 #define PMO_WOWL_PTRN_MASK_MAX_SIZE      19
38 #define PMO_WOWL_BCAST_PATTERN_MAX_SIZE 146
39 
40 #define PMO_WOW_INTER_PTRN_TOKENIZER   ';'
41 #define PMO_WOW_INTRA_PTRN_TOKENIZER   ':'
42 
43 #define PMO_WOW_PTRN_MASK_VALID     0xFF
44 #define PMO_NUM_BITS_IN_BYTE           8
45 
46 
47 /* Action frame categories */
48 
49 #define PMO_MAC_ACTION_SPECTRUM_MGMT   0
50 #define PMO_MAC_ACTION_QOS_MGMT        1
51 #define PMO_MAC_ACTION_DLP             2
52 #define PMO_MAC_ACTION_BLKACK          3
53 #define PMO_MAC_ACTION_PUBLIC_USAGE    4
54 #define PMO_MAC_ACTION_RRM             5
55 #define PMO_MAC_ACTION_FAST_BSS_TRNST  6
56 #define PMO_MAC_ACTION_HT              7
57 #define PMO_MAC_ACTION_SA_QUERY        8
58 #define PMO_MAC_ACTION_PROT_DUAL_PUB   9
59 #define PMO_MAC_ACTION_WNM            10
60 #define PMO_MAC_ACTION_UNPROT_WNM     11
61 #define PMO_MAC_ACTION_TDLS           12
62 #define PMO_MAC_ACITON_MESH           13
63 #define PMO_MAC_ACTION_MHF            14
64 #define PMO_MAC_SELF_PROTECTED        15
65 #define PMO_MAC_ACTION_WME            17
66 #define PMO_MAC_ACTION_FST            18
67 #define PMO_MAC_ACTION_RVS            19
68 #define PMO_MAC_ACTION_VHT            21
69 #define PMO_MAC_ACTION_EHT            36
70 #define PMO_MAC_ACTION_PROT_EHT       37
71 #define PMO_VENDOR_PROTECTED          126
72 #define PMO_MAC_ACTION_MAX            256
73 
74 /*
75  * ALLOWED_ACTION_FRAMES_BITMAP
76  *
77  * Bitmask is based on the below. The frames with 0's
78  * set to their corresponding bit can be dropped in FW.
79  *
80  * -----------------------------+-----+-------+
81  *         Type                 | Bit | Allow |
82  * -----------------------------+-----+-------+
83  * PMO_ACTION_SPECTRUM_MGMT    0      1
84  * PMO_ACTION_QOS_MGMT         1      1
85  * PMO_ACTION_DLP              2      0
86  * PMO_ACTION_BLKACK           3      0
87  * PMO_ACTION_PUBLIC_USAGE     4      1
88  * PMO_ACTION_RRM              5      0
89  * PMO_ACTION_FAST_BSS_TRNST   6      0
90  * PMO_ACTION_HT               7      0
91  * PMO_ACTION_SA_QUERY         8      1
92  * PMO_ACTION_PROT_DUAL_PUB    9      1
93  * PMO_ACTION_WNM             10      1
94  * PMO_ACTION_UNPROT_WNM      11      0
95  * PMO_ACTION_TDLS            12      0
96  * PMO_ACITON_MESH            13      0
97  * PMO_ACTION_MHF             14      0
98  * PMO_SELF_PROTECTED         15      0
99  * PMO_ACTION_WME             17      1
100  * PMO_ACTION_FST             18      1
101  * PMO_ACTION_RVS             19      1
102  * PMO_ACTION_VHT             21      1
103  * PMO_MAC_ACTION_EHT         36      1
104  * PMO_MAC_ACTION_PROT_EHT    37      1
105  * PMO_VENDOR_PROTECTED       126     1
106  * ----------------------------+------+-------+
107  */
108 #define SYSTEM_SUSPEND_ALLOWED_ACTION_FRAMES_BITMAP0 \
109 			((1 << PMO_MAC_ACTION_SPECTRUM_MGMT) | \
110 			 (1 << PMO_MAC_ACTION_QOS_MGMT) | \
111 			 (1 << PMO_MAC_ACTION_PUBLIC_USAGE) | \
112 			 (1 << PMO_MAC_ACTION_SA_QUERY) | \
113 			 (1 << PMO_MAC_ACTION_PROT_DUAL_PUB) | \
114 			 (1 << PMO_MAC_ACTION_WNM) | \
115 			 (1 << PMO_MAC_ACTION_WME) | \
116 			 (1 << PMO_MAC_ACTION_FST) | \
117 			 (1 << PMO_MAC_ACTION_RVS) | \
118 			 (1 << PMO_MAC_ACTION_VHT))
119 
120 #define ALLOWED_ACTION_FRAMES_BITMAP1 \
121 			 ((1 << (PMO_MAC_ACTION_EHT % 32)) |\
122 			 (1 << (PMO_MAC_ACTION_PROT_EHT % 32)))
123 #define ALLOWED_ACTION_FRAMES_BITMAP2   0x0
124 #define ALLOWED_ACTION_FRAMES_BITMAP3 \
125 		(1 << (PMO_VENDOR_PROTECTED % 32))
126 
127 #define ALLOWED_ACTION_FRAMES_BITMAP4   0x0
128 #define ALLOWED_ACTION_FRAMES_BITMAP5   0x0
129 #define ALLOWED_ACTION_FRAMES_BITMAP6   0x0
130 #define ALLOWED_ACTION_FRAMES_BITMAP7   0x0
131 
132 #define ALLOWED_ACTION_FRAME_MAP_WORDS (PMO_MAC_ACTION_MAX / 32)
133 
134 #define RUNTIME_PM_ALLOWED_ACTION_FRAMES_BITMAP0 \
135 		((1 << PMO_MAC_ACTION_SPECTRUM_MGMT) | \
136 		 (1 << PMO_MAC_ACTION_QOS_MGMT) | \
137 		 (1 << PMO_MAC_ACTION_PUBLIC_USAGE) | \
138 		 (1 << PMO_MAC_ACTION_RRM) | \
139 		 (1 << PMO_MAC_ACTION_SA_QUERY) | \
140 		 (1 << PMO_MAC_ACTION_PROT_DUAL_PUB) | \
141 		 (1 << PMO_MAC_ACTION_WNM) | \
142 		 (1 << PMO_MAC_ACTION_WME) | \
143 		 (1 << PMO_MAC_ACTION_FST) | \
144 		 (1 << PMO_MAC_ACTION_RVS) | \
145 		 (1 << PMO_MAC_ACTION_VHT))
146 
147 /* Public Action for 20/40 BSS Coexistence */
148 #define PMO_MAC_ACTION_MEASUREMENT_PILOT    7
149 
150 #define DROP_PUBLIC_ACTION_FRAME_BITMAP \
151 		(1 << PMO_MAC_ACTION_MEASUREMENT_PILOT)
152 
153 #ifndef ANI_SUPPORT_11H
154 /*
155  * DROP_SPEC_MGMT_ACTION_FRAME_BITMAP
156  *
157  * Bitmask is based on the below. The frames with 1's
158  * set to their corresponding bit can be dropped in FW.
159  *
160  * ----------------------------------+-----+------+
161  *         Type                      | Bit | Drop |
162  * ----------------------------------+-----+------+
163  * ACTION_SPCT_MSR_REQ                  0     1
164  * ACTION_SPCT_TPC_REQ                  2     1
165  * ----------------------------------+-----+------+
166  */
167 #define DROP_SPEC_MGMT_ACTION_FRAME_BITMAP \
168 		((1 << ACTION_SPCT_MSR_REQ) |\
169 		 (1 << ACTION_SPCT_TPC_REQ))
170 #else
171 /*
172  * If 11H support is defined, dont drop the above action category of
173  * spectrum mgmt action frames as host driver is processing them.
174  */
175 #define DROP_SPEC_MGMT_ACTION_FRAME_BITMAP 0
176 #endif /* ANI_SUPPORT_11H */
177 
178 #define PMO_SUPPORTED_ACTION_CATE           256
179 #define PMO_SUPPORTED_ACTION_CATE_ELE_LIST (PMO_SUPPORTED_ACTION_CATE/32)
180 
181 /**
182  * struct pmo_action_wakeup_set_params - action wakeup set params
183  * @vdev_id: virtual device id
184  * @operation: 0 reset to fw default, 1 set the bits,
185  *    2 add the setting bits, 3 delete the setting bits
186  * @action_category_map: bit mapping.
187  * @action_per_category: bitmap per action category
188  */
189 struct pmo_action_wakeup_set_params {
190 	uint32_t vdev_id;
191 	uint32_t operation;
192 	uint32_t action_category_map[PMO_SUPPORTED_ACTION_CATE_ELE_LIST];
193 	uint32_t action_per_category[PMO_SUPPORTED_ACTION_CATE];
194 };
195 
196 /**
197  * enum pmo_wow_action_wakeup_operation - describe action wakeup operation
198  * @pmo_action_wakeup_reset: reset
199  * @pmo_action_wakeup_set: set
200  * @pmo_action_wakeup_add_set: add and set
201  * @pmo_action_wakeup_del_set: delete and set
202  */
203 enum pmo_wow_action_wakeup_operation {
204 	pmo_action_wakeup_reset = 0,
205 	pmo_action_wakeup_set,
206 	pmo_action_wakeup_add_set,
207 	pmo_action_wakeup_del_set,
208 };
209 
210 /**
211  * enum pmo_wow_state: enumeration of wow state
212  * @pmo_wow_state_none: not in wow state
213  * @pmo_wow_state_legacy_d0: in d0 wow state trigger by legacy d0 wow command
214  * @pmo_wow_state_unified_d0: in d0 wow state trigger by unified wow command
215  * @pmo_wow_state_unified_d3: in d3 wow state trigger by unified wow command
216  */
217 enum pmo_wow_state {
218 	pmo_wow_state_none = 0,
219 	pmo_wow_state_legacy_d0,
220 	pmo_wow_state_unified_d0,
221 	pmo_wow_state_unified_d3,
222 };
223 
224 /**
225  * struct pmo_wow - store wow patterns
226  * @wow_enable: wow enable/disable
227  * @wow_enable_cmd_sent: is wow enable command sent to fw
228  * @is_wow_bus_suspended: true if bus is suspended
229  * @wow_state: state of wow
230  * @target_suspend: target suspend event
231  * @target_resume: target resume event
232  * @wow_nack: wow negative ack flag
233  * @reason_code : wow status reason code
234  * @wow_initial_wake_up: target initial wake up is received
235  * @wow_wake_lock: wow wake lock
236  * @lphb_cache: lphb cache
237  * @lphb_cb_ctx: callback context for lphb, kept as void* as
238  *                        osif structures are opaque to pmo.
239  * @lphb_cb: registered os if calllback function
240  * @ptrn_id_def: default pattern id counter for legacy firmware
241  * @ptrn_id_usr: user pattern id counter for legacy firmware
242  * @txrx_suspended: flag to determine if TX/RX is suspended
243  *		    during WoW
244  *
245  * This structure stores wow patterns and
246  * wow related parameters in host.
247  */
248 struct pmo_wow {
249 	bool wow_enable;
250 	bool wow_enable_cmd_sent;
251 	bool is_wow_bus_suspended;
252 	enum pmo_wow_state wow_state;
253 	qdf_event_t target_suspend;
254 	qdf_event_t target_resume;
255 	bool wow_nack;
256 	uint16_t reason_code;
257 	atomic_t wow_initial_wake_up;
258 	qdf_wake_lock_t wow_wake_lock;
259 	/*
260 	 * currently supports only vdev 0.
261 	 * cache has two entries: one for TCP and one for UDP.
262 	 */
263 	struct pmo_lphb_req lphb_cache[2];
264 	void *lphb_cb_ctx;
265 	pmo_lphb_callback lphb_cb;
266 
267 	uint8_t ptrn_id_def;
268 	uint8_t ptrn_id_usr;
269 	bool txrx_suspended;
270 };
271 
272 /* WOW related structures */
273 /**
274  * struct pmo_wow_add_pattern - wow pattern add structure
275  * @pattern_id: pattern id
276  * @pattern_byte_offset: pattern byte offset from beginning of the 802.11
277  *			 packet to start of the wake-up pattern
278  * @pattern_size: pattern size
279  * @pattern: pattern byte stream
280  * @pattern_mask_size: pattern mask size
281  * @pattern_mask: pattern mask
282  */
283 struct pmo_wow_add_pattern {
284 	uint8_t pattern_id;
285 	uint8_t pattern_byte_offset;
286 	uint8_t pattern_size;
287 	uint8_t pattern[PMO_WOWL_BCAST_PATTERN_MAX_SIZE];
288 	uint8_t pattern_mask_size;
289 	uint8_t pattern_mask[PMO_WOWL_BCAST_PATTERN_MAX_SIZE];
290 };
291 
292 /**
293  * struct pmo_wow_cmd_params - wow cmd parameter
294  * @enable: wow enable or disable flag
295  * @can_suspend_link: flag to indicate if link can be suspended
296  * @pause_iface_config: interface config
297  * @flags: bitmap of WMI_WOW_FLAG_* flags
298  */
299 struct pmo_wow_cmd_params {
300 	bool enable;
301 	bool can_suspend_link;
302 	uint8_t pause_iface_config;
303 	uint32_t flags;
304 };
305 
306 /**
307  * struct pmo_suspend_params - suspend cmd parameter
308  * @disable_target_intr: disable target interrupt
309  */
310 struct pmo_suspend_params {
311 	uint8_t disable_target_intr;
312 };
313 
314 #endif /* end  of _WLAN_PMO_WOW_PUBLIC_STRUCT_H_ */
315