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 _MON_DESTINATION_RING_WITH_DROP_H_
18 #define _MON_DESTINATION_RING_WITH_DROP_H_
19 #if !defined(__ASSEMBLER__)
20 #endif
21 
22 #define NUM_OF_DWORDS_MON_DESTINATION_RING_WITH_DROP 4
23 
24 
25 struct mon_destination_ring_with_drop {
26 #ifndef WIFI_BIT_ORDER_BIG_ENDIAN
27              uint32_t ppdu_drop_cnt                                           : 10, // [9:0]
28                       mpdu_drop_cnt                                           : 10, // [19:10]
29                       tlv_drop_cnt                                            : 10, // [29:20]
30                       end_of_ppdu_seen                                        :  1, // [30:30]
31                       reserved_0a                                             :  1; // [31:31]
32              uint32_t reserved_1a                                             : 32; // [31:0]
33              uint32_t ppdu_id                                                 : 32; // [31:0]
34              uint32_t reserved_3a                                             : 18, // [17:0]
35                       initiator                                               :  1, // [18:18]
36                       empty_descriptor                                        :  1, // [19:19]
37                       ring_id                                                 :  8, // [27:20]
38                       looping_count                                           :  4; // [31:28]
39 #else
40              uint32_t reserved_0a                                             :  1, // [31:31]
41                       end_of_ppdu_seen                                        :  1, // [30:30]
42                       tlv_drop_cnt                                            : 10, // [29:20]
43                       mpdu_drop_cnt                                           : 10, // [19:10]
44                       ppdu_drop_cnt                                           : 10; // [9:0]
45              uint32_t reserved_1a                                             : 32; // [31:0]
46              uint32_t ppdu_id                                                 : 32; // [31:0]
47              uint32_t looping_count                                           :  4, // [31:28]
48                       ring_id                                                 :  8, // [27:20]
49                       empty_descriptor                                        :  1, // [19:19]
50                       initiator                                               :  1, // [18:18]
51                       reserved_3a                                             : 18; // [17:0]
52 #endif
53 };
54 
55 
56 /* Description		PPDU_DROP_CNT
57 
58 			The number of PPDUs dropped due to the back-pressure
59 
60 			Set to 1023 if >1023 PPDUs got dropped
61 			<legal all>
62 */
63 
64 #define MON_DESTINATION_RING_WITH_DROP_PPDU_DROP_CNT_OFFSET                         0x00000000
65 #define MON_DESTINATION_RING_WITH_DROP_PPDU_DROP_CNT_LSB                            0
66 #define MON_DESTINATION_RING_WITH_DROP_PPDU_DROP_CNT_MSB                            9
67 #define MON_DESTINATION_RING_WITH_DROP_PPDU_DROP_CNT_MASK                           0x000003ff
68 
69 
70 /* Description		MPDU_DROP_CNT
71 
72 			The number of MPDUs dropped within the first PPDU due to
73 			 the back-pressure
74 
75 			Set to 1023 if >1023 MPDUs got dropped
76 			<legal all>
77 */
78 
79 #define MON_DESTINATION_RING_WITH_DROP_MPDU_DROP_CNT_OFFSET                         0x00000000
80 #define MON_DESTINATION_RING_WITH_DROP_MPDU_DROP_CNT_LSB                            10
81 #define MON_DESTINATION_RING_WITH_DROP_MPDU_DROP_CNT_MSB                            19
82 #define MON_DESTINATION_RING_WITH_DROP_MPDU_DROP_CNT_MASK                           0x000ffc00
83 
84 
85 /* Description		TLV_DROP_CNT
86 
87 			The number of PPDU-level (global or per-user) TLVs dropped
88 			 within the first PPDU due to the back-pressure
89 */
90 
91 #define MON_DESTINATION_RING_WITH_DROP_TLV_DROP_CNT_OFFSET                          0x00000000
92 #define MON_DESTINATION_RING_WITH_DROP_TLV_DROP_CNT_LSB                             20
93 #define MON_DESTINATION_RING_WITH_DROP_TLV_DROP_CNT_MSB                             29
94 #define MON_DESTINATION_RING_WITH_DROP_TLV_DROP_CNT_MASK                            0x3ff00000
95 
96 
97 /* Description		END_OF_PPDU_SEEN
98 
99 			Field valid only if mpdu_drop_cnt > 0 or tlv_drop_cnt >
100 			0
101 
102 			Set by TXMON if 'TX_FES_STATUS_END' is received for a partially
103 			 dropped PPDU when Initiator = 1.
104 			Set by TXMON if 'RESPONSE_END_STATUS' is received for a
105 			partially dropped PPDU when Initiator = 0.
106 			Set by RXMON if 'RX_PPDU_END_STATUS_DONE' is received for
107 			 a partially dropped PPDU.
108 */
109 
110 #define MON_DESTINATION_RING_WITH_DROP_END_OF_PPDU_SEEN_OFFSET                      0x00000000
111 #define MON_DESTINATION_RING_WITH_DROP_END_OF_PPDU_SEEN_LSB                         30
112 #define MON_DESTINATION_RING_WITH_DROP_END_OF_PPDU_SEEN_MSB                         30
113 #define MON_DESTINATION_RING_WITH_DROP_END_OF_PPDU_SEEN_MASK                        0x40000000
114 
115 
116 /* Description		RESERVED_0A
117 
118 			<legal 0>
119 */
120 
121 #define MON_DESTINATION_RING_WITH_DROP_RESERVED_0A_OFFSET                           0x00000000
122 #define MON_DESTINATION_RING_WITH_DROP_RESERVED_0A_LSB                              31
123 #define MON_DESTINATION_RING_WITH_DROP_RESERVED_0A_MSB                              31
124 #define MON_DESTINATION_RING_WITH_DROP_RESERVED_0A_MASK                             0x80000000
125 
126 
127 /* Description		RESERVED_1A
128 
129 			<legal 0>
130 */
131 
132 #define MON_DESTINATION_RING_WITH_DROP_RESERVED_1A_OFFSET                           0x00000004
133 #define MON_DESTINATION_RING_WITH_DROP_RESERVED_1A_LSB                              0
134 #define MON_DESTINATION_RING_WITH_DROP_RESERVED_1A_MSB                              31
135 #define MON_DESTINATION_RING_WITH_DROP_RESERVED_1A_MASK                             0xffffffff
136 
137 
138 /* Description		PPDU_ID
139 
140 			The ID of the last PPDU which saw the back-pressure on AXI
141 
142 
143 			TXMON fills this with the schedule_id from 'TX_FES_SETUP'
144 			when Initiator = 1.
145 			TXMON fills this with the Phy_ppdu_id from 'RX_RESPONSE_REQUIRED_INFO'
146 			when Initiator = 0.
147 			RXMON fills this with the Phy_ppdu_id from 'RX_PPDU_START.'
148 
149 			<legal all>
150 */
151 
152 #define MON_DESTINATION_RING_WITH_DROP_PPDU_ID_OFFSET                               0x00000008
153 #define MON_DESTINATION_RING_WITH_DROP_PPDU_ID_LSB                                  0
154 #define MON_DESTINATION_RING_WITH_DROP_PPDU_ID_MSB                                  31
155 #define MON_DESTINATION_RING_WITH_DROP_PPDU_ID_MASK                                 0xffffffff
156 
157 
158 /* Description		RESERVED_3A
159 
160 			<legal 0>
161 */
162 
163 #define MON_DESTINATION_RING_WITH_DROP_RESERVED_3A_OFFSET                           0x0000000c
164 #define MON_DESTINATION_RING_WITH_DROP_RESERVED_3A_LSB                              0
165 #define MON_DESTINATION_RING_WITH_DROP_RESERVED_3A_MSB                              17
166 #define MON_DESTINATION_RING_WITH_DROP_RESERVED_3A_MASK                             0x0003ffff
167 
168 
169 /* Description		INITIATOR
170 
171 			1: This descriptor belongs to a TX FES (TXOP initiator)
172 			0: This descriptor belongs to a response TX (TXOP responder)
173 
174 			<legal all>
175 */
176 
177 #define MON_DESTINATION_RING_WITH_DROP_INITIATOR_OFFSET                             0x0000000c
178 #define MON_DESTINATION_RING_WITH_DROP_INITIATOR_LSB                                18
179 #define MON_DESTINATION_RING_WITH_DROP_INITIATOR_MSB                                18
180 #define MON_DESTINATION_RING_WITH_DROP_INITIATOR_MASK                               0x00040000
181 
182 
183 /* Description		EMPTY_DESCRIPTOR
184 
185 			0: This descriptor is written on a flush or the end of a
186 			 PPDU or the end of status buffer (see 'MON_DESTINATION_RING'
187 			structure)
188 			1: This descriptor is written to indicate drop information
189 
190 			<legal 1>
191 */
192 
193 #define MON_DESTINATION_RING_WITH_DROP_EMPTY_DESCRIPTOR_OFFSET                      0x0000000c
194 #define MON_DESTINATION_RING_WITH_DROP_EMPTY_DESCRIPTOR_LSB                         19
195 #define MON_DESTINATION_RING_WITH_DROP_EMPTY_DESCRIPTOR_MSB                         19
196 #define MON_DESTINATION_RING_WITH_DROP_EMPTY_DESCRIPTOR_MASK                        0x00080000
197 
198 
199 /* Description		RING_ID
200 
201 			Consumer: SW/REO/DEBUG
202 			Producer: SRNG (of TXMON/RXMON)
203 
204 			For debugging.
205 			This field is filled in by the SRNG module.
206 			It help to identify the ring that is being looked
207 			<legal 0>
208 */
209 
210 #define MON_DESTINATION_RING_WITH_DROP_RING_ID_OFFSET                               0x0000000c
211 #define MON_DESTINATION_RING_WITH_DROP_RING_ID_LSB                                  20
212 #define MON_DESTINATION_RING_WITH_DROP_RING_ID_MSB                                  27
213 #define MON_DESTINATION_RING_WITH_DROP_RING_ID_MASK                                 0x0ff00000
214 
215 
216 /* Description		LOOPING_COUNT
217 
218 			Consumer: SW/DEBUG
219 			Producer: SRNG (of TXMON/RXMON)
220 
221 			For debugging.
222 			This field is filled in by the SRNG module.
223 
224 			A count value that indicates the number of times the producer
225 			 of entries into this Ring has looped around the ring.
226 			At initialization time, this value is set to 0. On the first
227 			 loop, this value is set to 1. After the max value is reached
228 			 allowed by the number of bits for this field, the count
229 			 value continues with 0 again.
230 
231 			In case SW is the consumer of the ring entries, it can use
232 			 this field to figure out up to where the producer of entries
233 			 has created new entries. This eliminates the need to check
234 			 where the "head pointer' of the ring is located once the
235 			 SW starts processing an interrupt indicating that new entries
236 			 have been put into this ring...
237 
238 			Also note that SW if it wants only needs to look at the
239 			LSB bit of this count value.
240 			<legal all>
241 */
242 
243 #define MON_DESTINATION_RING_WITH_DROP_LOOPING_COUNT_OFFSET                         0x0000000c
244 #define MON_DESTINATION_RING_WITH_DROP_LOOPING_COUNT_LSB                            28
245 #define MON_DESTINATION_RING_WITH_DROP_LOOPING_COUNT_MSB                            31
246 #define MON_DESTINATION_RING_WITH_DROP_LOOPING_COUNT_MASK                           0xf0000000
247 
248 
249 
250 #endif   // MON_DESTINATION_RING_WITH_DROP
251