1 /*
2  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef _PHYRX_COMMON_USER_INFO_H_
18 #define _PHYRX_COMMON_USER_INFO_H_
19 #if !defined(__ASSEMBLER__)
20 #endif
21 
22 #define NUM_OF_DWORDS_PHYRX_COMMON_USER_INFO 4
23 
24 #define NUM_OF_QWORDS_PHYRX_COMMON_USER_INFO 2
25 
26 
27 struct phyrx_common_user_info {
28 #ifndef WIFI_BIT_ORDER_BIG_ENDIAN
29              uint32_t receive_duration                                        : 16, // [15:0]
30                       reserved_0a                                             : 16; // [31:16]
31              uint32_t u_sig_puncture_pattern_encoding                         :  6, // [5:0]
32                       reserved_1a                                             : 26; // [31:6]
33              uint32_t eht_ppdu_type                                           :  2, // [1:0]
34                       bss_color_id                                            :  6, // [7:2]
35                       dl_ul_flag                                              :  1, // [8:8]
36                       txop_duration                                           :  7, // [15:9]
37                       cp_setting                                              :  2, // [17:16]
38                       ltf_size                                                :  2, // [19:18]
39                       spatial_reuse                                           :  4, // [23:20]
40                       rx_ndp                                                  :  1, // [24:24]
41                       dot11be_su_extended                                     :  1, // [25:25]
42                       reserved_2a                                             :  6; // [31:26]
43              uint32_t eht_duplicate                                           :  2, // [1:0]
44                       eht_sig_cmn_field_type                                  :  2, // [3:2]
45                       doppler_indication                                      :  1, // [4:4]
46                       sta_id                                                  : 11, // [15:5]
47                       puncture_bitmap                                         : 16; // [31:16]
48 #else
49              uint32_t reserved_0a                                             : 16, // [31:16]
50                       receive_duration                                        : 16; // [15:0]
51              uint32_t reserved_1a                                             : 26, // [31:6]
52                       u_sig_puncture_pattern_encoding                         :  6; // [5:0]
53              uint32_t reserved_2a                                             :  6, // [31:26]
54                       dot11be_su_extended                                     :  1, // [25:25]
55                       rx_ndp                                                  :  1, // [24:24]
56                       spatial_reuse                                           :  4, // [23:20]
57                       ltf_size                                                :  2, // [19:18]
58                       cp_setting                                              :  2, // [17:16]
59                       txop_duration                                           :  7, // [15:9]
60                       dl_ul_flag                                              :  1, // [8:8]
61                       bss_color_id                                            :  6, // [7:2]
62                       eht_ppdu_type                                           :  2; // [1:0]
63              uint32_t puncture_bitmap                                         : 16, // [31:16]
64                       sta_id                                                  : 11, // [15:5]
65                       doppler_indication                                      :  1, // [4:4]
66                       eht_sig_cmn_field_type                                  :  2, // [3:2]
67                       eht_duplicate                                           :  2; // [1:0]
68 #endif
69 };
70 
71 
72 /* Description		RECEIVE_DURATION
73 
74 			The remaining receive duration of this PPDU in the medium
75 			 (in us).
76 			The timing reference point is the assertion of 'rx_frame'
77 			by PHY for the PPDU reception. The value shall be accurate
78 			 to within 2us.
79 			RXPCU shall subtract the time elapsed between 'rx_frame'
80 			assertion and reception of this TLV to find the actual remaining
81 			 receive duration.
82 			<legal all>
83 */
84 
85 #define PHYRX_COMMON_USER_INFO_RECEIVE_DURATION_OFFSET                              0x0000000000000000
86 #define PHYRX_COMMON_USER_INFO_RECEIVE_DURATION_LSB                                 0
87 #define PHYRX_COMMON_USER_INFO_RECEIVE_DURATION_MSB                                 15
88 #define PHYRX_COMMON_USER_INFO_RECEIVE_DURATION_MASK                                0x000000000000ffff
89 
90 
91 /* Description		RESERVED_0A
92 
93 			<legal 0>
94 */
95 
96 #define PHYRX_COMMON_USER_INFO_RESERVED_0A_OFFSET                                   0x0000000000000000
97 #define PHYRX_COMMON_USER_INFO_RESERVED_0A_LSB                                      16
98 #define PHYRX_COMMON_USER_INFO_RESERVED_0A_MSB                                      31
99 #define PHYRX_COMMON_USER_INFO_RESERVED_0A_MASK                                     0x00000000ffff0000
100 
101 
102 /* Description		U_SIG_PUNCTURE_PATTERN_ENCODING
103 
104 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV.
105 
106 
107 			The 6-bit value used in U-SIG and/or EHT-SIG Common field
108 			 for the puncture pattern
109 			<legal 0-29>
110 */
111 
112 #define PHYRX_COMMON_USER_INFO_U_SIG_PUNCTURE_PATTERN_ENCODING_OFFSET               0x0000000000000000
113 #define PHYRX_COMMON_USER_INFO_U_SIG_PUNCTURE_PATTERN_ENCODING_LSB                  32
114 #define PHYRX_COMMON_USER_INFO_U_SIG_PUNCTURE_PATTERN_ENCODING_MSB                  37
115 #define PHYRX_COMMON_USER_INFO_U_SIG_PUNCTURE_PATTERN_ENCODING_MASK                 0x0000003f00000000
116 
117 
118 /* Description		RESERVED_1A
119 
120 			<legal 0>
121 */
122 
123 #define PHYRX_COMMON_USER_INFO_RESERVED_1A_OFFSET                                   0x0000000000000000
124 #define PHYRX_COMMON_USER_INFO_RESERVED_1A_LSB                                      38
125 #define PHYRX_COMMON_USER_INFO_RESERVED_1A_MSB                                      63
126 #define PHYRX_COMMON_USER_INFO_RESERVED_1A_MASK                                     0xffffffc000000000
127 
128 
129 /* Description		EHT_PPDU_TYPE
130 
131 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV.
132 
133 
134 			<enum 0 EHT_PPDU_rsvd> DO NOT USE
135 			<enum 1 EHT_PPDU_TB>
136 			<enum 2 EHT_PPDU_MU> Need to look at both EHT-SIG content
137 			 channels
138 			<enum 3 EHT_PPDU_SU> Need to look at only one EHT-SIG content
139 			 channel
140 			<legal all>
141 */
142 
143 #define PHYRX_COMMON_USER_INFO_EHT_PPDU_TYPE_OFFSET                                 0x0000000000000008
144 #define PHYRX_COMMON_USER_INFO_EHT_PPDU_TYPE_LSB                                    0
145 #define PHYRX_COMMON_USER_INFO_EHT_PPDU_TYPE_MSB                                    1
146 #define PHYRX_COMMON_USER_INFO_EHT_PPDU_TYPE_MASK                                   0x0000000000000003
147 
148 
149 /* Description		BSS_COLOR_ID
150 
151 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV.
152 
153 
154 			BSS color ID
155 
156 			Field used by MAC HW
157 			<legal all>
158 */
159 
160 #define PHYRX_COMMON_USER_INFO_BSS_COLOR_ID_OFFSET                                  0x0000000000000008
161 #define PHYRX_COMMON_USER_INFO_BSS_COLOR_ID_LSB                                     2
162 #define PHYRX_COMMON_USER_INFO_BSS_COLOR_ID_MSB                                     7
163 #define PHYRX_COMMON_USER_INFO_BSS_COLOR_ID_MASK                                    0x00000000000000fc
164 
165 
166 /* Description		DL_UL_FLAG
167 
168 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV.
169 
170 
171 			Differentiates between DL and UL transmission
172 
173 			<enum 0 DL_UL_FLAG_IS_DL_OR_TDLS>
174 			<enum 1 DL_UL_FLAG_IS_UL>
175 			<legal all>
176 */
177 
178 #define PHYRX_COMMON_USER_INFO_DL_UL_FLAG_OFFSET                                    0x0000000000000008
179 #define PHYRX_COMMON_USER_INFO_DL_UL_FLAG_LSB                                       8
180 #define PHYRX_COMMON_USER_INFO_DL_UL_FLAG_MSB                                       8
181 #define PHYRX_COMMON_USER_INFO_DL_UL_FLAG_MASK                                      0x0000000000000100
182 
183 
184 /* Description		TXOP_DURATION
185 
186 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV.
187 
188 
189 			Indicates the remaining time in the current TXOP
190 
191 			Field used by MAC HW
192 			 <legal all>
193 */
194 
195 #define PHYRX_COMMON_USER_INFO_TXOP_DURATION_OFFSET                                 0x0000000000000008
196 #define PHYRX_COMMON_USER_INFO_TXOP_DURATION_LSB                                    9
197 #define PHYRX_COMMON_USER_INFO_TXOP_DURATION_MSB                                    15
198 #define PHYRX_COMMON_USER_INFO_TXOP_DURATION_MASK                                   0x000000000000fe00
199 
200 
201 /* Description		CP_SETTING
202 
203 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV.
204 
205 
206 			<enum 0     gi_0_8_us > Legacy normal GI
207 			<enum 1     gi_0_4_us > Legacy short GI
208 			<enum 2     gi_1_6_us > HE related GI
209 			<enum 3     gi_3_2_us > HE related GI
210 			<legal 0 - 3>
211 */
212 
213 #define PHYRX_COMMON_USER_INFO_CP_SETTING_OFFSET                                    0x0000000000000008
214 #define PHYRX_COMMON_USER_INFO_CP_SETTING_LSB                                       16
215 #define PHYRX_COMMON_USER_INFO_CP_SETTING_MSB                                       17
216 #define PHYRX_COMMON_USER_INFO_CP_SETTING_MASK                                      0x0000000000030000
217 
218 
219 /* Description		LTF_SIZE
220 
221 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV.
222 
223 
224 			Ltf size
225 
226 			<enum 0     ltf_1x >
227 			<enum 1     ltf_2x >
228 			<enum 2     ltf_4x >
229 			<legal 0 - 2>
230 */
231 
232 #define PHYRX_COMMON_USER_INFO_LTF_SIZE_OFFSET                                      0x0000000000000008
233 #define PHYRX_COMMON_USER_INFO_LTF_SIZE_LSB                                         18
234 #define PHYRX_COMMON_USER_INFO_LTF_SIZE_MSB                                         19
235 #define PHYRX_COMMON_USER_INFO_LTF_SIZE_MASK                                        0x00000000000c0000
236 
237 
238 /* Description		SPATIAL_REUSE
239 
240 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV.
241 
242 
243 			TODO: Placeholder
244 			<legal all>
245 */
246 
247 #define PHYRX_COMMON_USER_INFO_SPATIAL_REUSE_OFFSET                                 0x0000000000000008
248 #define PHYRX_COMMON_USER_INFO_SPATIAL_REUSE_LSB                                    20
249 #define PHYRX_COMMON_USER_INFO_SPATIAL_REUSE_MSB                                    23
250 #define PHYRX_COMMON_USER_INFO_SPATIAL_REUSE_MASK                                   0x0000000000f00000
251 
252 
253 /* Description		RX_NDP
254 
255 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV.
256 
257 
258 			On RX side, looked at by MAC HW
259 
260 			When set, PHY has received an (expected) NDP frame
261 			<legal all>
262 */
263 
264 #define PHYRX_COMMON_USER_INFO_RX_NDP_OFFSET                                        0x0000000000000008
265 #define PHYRX_COMMON_USER_INFO_RX_NDP_LSB                                           24
266 #define PHYRX_COMMON_USER_INFO_RX_NDP_MSB                                           24
267 #define PHYRX_COMMON_USER_INFO_RX_NDP_MASK                                          0x0000000001000000
268 
269 
270 /* Description		DOT11BE_SU_EXTENDED
271 
272 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV.
273 
274 
275 			On RX side, evaluated by MAC HW
276 
277 			This is the only way for MAC RX to know that this was a
278 			U_SIG_EHT_SU received in extended range format.
279 
280 			When set, the 11be frame is of the extended range format.
281 
282 			<legal all>
283 */
284 
285 #define PHYRX_COMMON_USER_INFO_DOT11BE_SU_EXTENDED_OFFSET                           0x0000000000000008
286 #define PHYRX_COMMON_USER_INFO_DOT11BE_SU_EXTENDED_LSB                              25
287 #define PHYRX_COMMON_USER_INFO_DOT11BE_SU_EXTENDED_MSB                              25
288 #define PHYRX_COMMON_USER_INFO_DOT11BE_SU_EXTENDED_MASK                             0x0000000002000000
289 
290 
291 /* Description		RESERVED_2A
292 
293 			<legal 0>
294 */
295 
296 #define PHYRX_COMMON_USER_INFO_RESERVED_2A_OFFSET                                   0x0000000000000008
297 #define PHYRX_COMMON_USER_INFO_RESERVED_2A_LSB                                      26
298 #define PHYRX_COMMON_USER_INFO_RESERVED_2A_MSB                                      31
299 #define PHYRX_COMMON_USER_INFO_RESERVED_2A_MASK                                     0x00000000fc000000
300 
301 
302 /* Description		EHT_DUPLICATE
303 
304 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV.
305 
306 
307 			Indicates EHT duplicate modulation
308 
309 			<enum 0 eht_no_duplicate>
310 			<enum 1 eht_2x_duplicate>
311 			<enum 2 eht_4x_duplicate>
312 
313 			<legal 0-2>
314 */
315 
316 #define PHYRX_COMMON_USER_INFO_EHT_DUPLICATE_OFFSET                                 0x0000000000000008
317 #define PHYRX_COMMON_USER_INFO_EHT_DUPLICATE_LSB                                    32
318 #define PHYRX_COMMON_USER_INFO_EHT_DUPLICATE_MSB                                    33
319 #define PHYRX_COMMON_USER_INFO_EHT_DUPLICATE_MASK                                   0x0000000300000000
320 
321 
322 /* Description		EHT_SIG_CMN_FIELD_TYPE
323 
324 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV.
325 
326 
327 			Indicates the type of EHT-SIG Common field
328 
329 			<enum 0 EHT_SIG_CMN_NO_PUNC> Non-OFDMA, EHT-SIG Common field
330 			 does not contain puncturing information
331 			<enum 1 EHT_SIG_CMN_PUNC> Non-OFDMA, EHT-SIG Common field
332 			 contains puncturing information
333 			<enum 2 EHT_SIG_OFDMA>
334 			OFDMA, EHT-SIG Common field contains RU structure
335 			<legal 0-2>
336 */
337 
338 #define PHYRX_COMMON_USER_INFO_EHT_SIG_CMN_FIELD_TYPE_OFFSET                        0x0000000000000008
339 #define PHYRX_COMMON_USER_INFO_EHT_SIG_CMN_FIELD_TYPE_LSB                           34
340 #define PHYRX_COMMON_USER_INFO_EHT_SIG_CMN_FIELD_TYPE_MSB                           35
341 #define PHYRX_COMMON_USER_INFO_EHT_SIG_CMN_FIELD_TYPE_MASK                          0x0000000c00000000
342 
343 
344 /* Description		DOPPLER_INDICATION
345 
346 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV.
347 
348 
349 			0: No Doppler support
350 			1: Doppler support
351 			<legal all>
352 */
353 
354 #define PHYRX_COMMON_USER_INFO_DOPPLER_INDICATION_OFFSET                            0x0000000000000008
355 #define PHYRX_COMMON_USER_INFO_DOPPLER_INDICATION_LSB                               36
356 #define PHYRX_COMMON_USER_INFO_DOPPLER_INDICATION_MSB                               36
357 #define PHYRX_COMMON_USER_INFO_DOPPLER_INDICATION_MASK                              0x0000001000000000
358 
359 
360 /* Description		STA_ID
361 
362 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV
363 			 and EHT_PPDU_type is EHT_PPDU_MU (MU-MIMO or OFDMA).
364 
365 			Identifies the STA that is addressed. Details of STA ID
366 			are TBD
367 */
368 
369 #define PHYRX_COMMON_USER_INFO_STA_ID_OFFSET                                        0x0000000000000008
370 #define PHYRX_COMMON_USER_INFO_STA_ID_LSB                                           37
371 #define PHYRX_COMMON_USER_INFO_STA_ID_MSB                                           47
372 #define PHYRX_COMMON_USER_INFO_STA_ID_MASK                                          0x0000ffe000000000
373 
374 
375 /* Description		PUNCTURE_BITMAP
376 
377 			Field only valid if PHY has sent 'PHYRX_GENERIC_U_SIG' TLV
378 			 and EHT_SIG_CMN_field_type is EHT_SIG_CMN_PUNC.
379 
380 			Indicates which 20 MHz sub-bands will be modulated vs punctured
381 			 (bits [15:0]) in CCA order (primary/secondary)
382 
383 			Bit 0: primary 20MHz sub-band
384 			Bit 1: secondary 20 MHz sub-band
385 			Bit 2: first 20 MHz sub-band in secondary 40 MHz
386 			Bit 3: second 20 MHz sub-band in secondary 40 MHz
387 			...
388 			Bit 15: last 20MHz sub-band in secondary 160 MHz
389 			A value of 0 means the band is punctured
390 			A value of 1 means the band is modulated
391 
392 			If the PPDU BW is less than 320 MHz, the MSB bits are reserved
393 			 and set to 0.
394 */
395 
396 #define PHYRX_COMMON_USER_INFO_PUNCTURE_BITMAP_OFFSET                               0x0000000000000008
397 #define PHYRX_COMMON_USER_INFO_PUNCTURE_BITMAP_LSB                                  48
398 #define PHYRX_COMMON_USER_INFO_PUNCTURE_BITMAP_MSB                                  63
399 #define PHYRX_COMMON_USER_INFO_PUNCTURE_BITMAP_MASK                                 0xffff000000000000
400 
401 
402 
403 #endif   // PHYRX_COMMON_USER_INFO
404