diff options
Diffstat (limited to 'include/boardobj/boardobjgrp.h')
-rw-r--r-- | include/boardobj/boardobjgrp.h | 441 |
1 files changed, 441 insertions, 0 deletions
diff --git a/include/boardobj/boardobjgrp.h b/include/boardobj/boardobjgrp.h new file mode 100644 index 0000000..cd13b85 --- /dev/null +++ b/include/boardobj/boardobjgrp.h | |||
@@ -0,0 +1,441 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef NVGPU_BOARDOBJGRP_H | ||
24 | #define NVGPU_BOARDOBJGRP_H | ||
25 | |||
26 | struct boardobjgrp; | ||
27 | struct gk20a; | ||
28 | struct nvgpu_list_node; | ||
29 | struct pmu_surface; | ||
30 | |||
31 | |||
32 | /* ------------------------ Includes ----------------------------------------*/ | ||
33 | #include "ctrl/ctrlboardobj.h" | ||
34 | #include "boardobj.h" | ||
35 | #include "boardobjgrpmask.h" | ||
36 | #include <nvgpu/list.h> | ||
37 | #include <nvgpu/pmu.h> | ||
38 | |||
39 | /* | ||
40 | * Board Object Group destructor. | ||
41 | * | ||
42 | */ | ||
43 | typedef int boardobjgrp_destruct(struct boardobjgrp *pboardobjgrp); | ||
44 | |||
45 | /* | ||
46 | * Inserts a previously constructed Board Object into a Board Object Group for | ||
47 | * tracking. Objects are inserted in the array based on the given index. | ||
48 | */ | ||
49 | typedef int boardobjgrp_objinsert(struct boardobjgrp *pboardobjgrp, | ||
50 | struct boardobj *pboardobj, u8 index); | ||
51 | |||
52 | /* | ||
53 | * Retrieves a Board Object from a Board Object Group using the group's index. | ||
54 | * | ||
55 | */ | ||
56 | typedef struct boardobj *boardobjgrp_objgetbyidx( | ||
57 | struct boardobjgrp *pBobrdobjgrp, u8 index); | ||
58 | |||
59 | /* | ||
60 | * Retrieve Board Object immediately following one pointed by @ref pcurrentindex | ||
61 | * filtered out by the provided mask. If (pMask == NULL) => no filtering. | ||
62 | */ | ||
63 | typedef struct boardobj *boardobjgrp_objgetnext( | ||
64 | struct boardobjgrp *pboardobjgrp, | ||
65 | u8 *currentindex, struct boardobjgrpmask *mask); | ||
66 | |||
67 | /* | ||
68 | * Board Object Group Remover and destructor. This is used to remove and | ||
69 | * destruct specific entry from the Board Object Group. | ||
70 | */ | ||
71 | typedef int boardobjgrp_objremoveanddestroy(struct boardobjgrp *pboardobjgrp, | ||
72 | u8 index); | ||
73 | |||
74 | /* | ||
75 | * BOARDOBJGRP handler for PMU_UNIT_INIT. Calls the PMU_UNIT_INIT handlers | ||
76 | * for the constructed PMU CMDs, and then sets the object via the | ||
77 | * PMU_BOARDOBJ_CMD_GRP interface (if constructed). | ||
78 | */ | ||
79 | typedef int boardobjgrp_pmuinithandle(struct gk20a *g, | ||
80 | struct boardobjgrp *pboardobjGrp); | ||
81 | |||
82 | /* | ||
83 | * Fills out the appropriate the PMU_BOARDOBJGRP_<xyz> driver<->PMU description | ||
84 | * header structure, more specifically a mask of BOARDOBJs. | ||
85 | */ | ||
86 | typedef int boardobjgrp_pmuhdrdatainit(struct gk20a *g, | ||
87 | struct boardobjgrp *pboardobjgrp, | ||
88 | struct nv_pmu_boardobjgrp_super *pboardobjgrppmu, | ||
89 | struct boardobjgrpmask *mask); | ||
90 | |||
91 | /* | ||
92 | * Fills out the appropriate the PMU_BOARDOBJGRP_<xyz> driver->PMU description | ||
93 | * structure, describing the BOARDOBJGRP and all of its BOARDOBJs to the PMU. | ||
94 | */ | ||
95 | typedef int boardobjgrp_pmudatainit(struct gk20a *g, | ||
96 | struct boardobjgrp *pboardobjgrp, | ||
97 | struct nv_pmu_boardobjgrp_super *pboardobjgrppmu); | ||
98 | |||
99 | /* | ||
100 | * Sends a BOARDOBJGRP to the PMU via the PMU_BOARDOBJ_CMD_GRP interface. | ||
101 | * This interface leverages @ref boardobjgrp_pmudatainit to populate the | ||
102 | * structure. | ||
103 | */ | ||
104 | typedef int boardobjgrp_pmuset(struct gk20a *g, | ||
105 | struct boardobjgrp *pboardobjgrp); | ||
106 | |||
107 | /* | ||
108 | * Gets the dynamic status of the PMU BOARDOBJGRP via the | ||
109 | * PMU_BOARDOBJ_CMD_GRP GET_STATUS interface. | ||
110 | */ | ||
111 | typedef int boardobjgrp_pmugetstatus(struct gk20a *g, | ||
112 | struct boardobjgrp *pboardobjgrp, | ||
113 | struct boardobjgrpmask *mask); | ||
114 | |||
115 | typedef int boardobjgrp_pmudatainstget(struct gk20a *g, | ||
116 | struct nv_pmu_boardobjgrp *boardobjgrppmu, | ||
117 | struct nv_pmu_boardobj **ppboardobjpmudata, u8 idx); | ||
118 | |||
119 | typedef int boardobjgrp_pmustatusinstget(struct gk20a *g, void *pboardobjgrppmu, | ||
120 | struct nv_pmu_boardobj_query **ppBoardobjpmustatus, u8 idx); | ||
121 | |||
122 | /* | ||
123 | * Structure describing an PMU CMD for interacting with the representaition | ||
124 | * of this BOARDOBJGRP within the PMU. | ||
125 | */ | ||
126 | struct boardobjgrp_pmu_cmd { | ||
127 | u8 id; | ||
128 | u8 msgid; | ||
129 | u8 hdrsize; | ||
130 | u8 entrysize; | ||
131 | u16 dmem_buffer_size; | ||
132 | u32 super_surface_offset; | ||
133 | u32 fbsize; | ||
134 | struct nv_pmu_boardobjgrp_super *buf; | ||
135 | struct pmu_surface surf; | ||
136 | }; | ||
137 | |||
138 | /* | ||
139 | * Structure of state describing how to communicate with representation of this | ||
140 | * BOARDOBJGRP in the PMU. | ||
141 | */ | ||
142 | struct boardobjgrp_pmu { | ||
143 | u8 unitid; | ||
144 | u8 classid; | ||
145 | bool bset; | ||
146 | u8 rpc_func_id; | ||
147 | struct boardobjgrp_pmu_cmd set; | ||
148 | struct boardobjgrp_pmu_cmd getstatus; | ||
149 | }; | ||
150 | |||
151 | /* | ||
152 | * Function by which a class which implements BOARDOBJGRP can construct a PMU | ||
153 | * CMD. This provides the various information describing the PMU CMD including | ||
154 | * the CMD and MSG ID and the size of the various sturctures in the payload. | ||
155 | */ | ||
156 | typedef int boardobjgrp_pmucmd_construct(struct gk20a *g, | ||
157 | struct boardobjgrp *pboardobjgrp, | ||
158 | struct boardobjgrp_pmu_cmd *cmd, u8 id, u8 msgid, | ||
159 | u16 hdrsize, u16 entrysize, u16 fbsize, u32 ss_offset, u8 rpc_func_id); | ||
160 | |||
161 | /* | ||
162 | * Destroys BOARDOBJGRP PMU SW state. CMD. | ||
163 | */ | ||
164 | typedef int boardobjgrp_pmucmd_destroy(struct gk20a *g, | ||
165 | struct boardobjgrp_pmu_cmd *cmd); | ||
166 | |||
167 | /* | ||
168 | * init handler for the BOARDOBJGRP PMU CMD. Allocates and maps the | ||
169 | * PMU CMD payload within both the PMU and driver so that it can be referenced | ||
170 | * at run-time. | ||
171 | */ | ||
172 | typedef int boardobjgrp_pmucmd_pmuinithandle(struct gk20a *g, | ||
173 | struct boardobjgrp *pboardobjgrp, | ||
174 | struct boardobjgrp_pmu_cmd *cmd); | ||
175 | |||
176 | /* | ||
177 | * Base Class Group for all physical or logical device on the PCB. | ||
178 | * Contains fields common to all devices on the board. Specific types of | ||
179 | * devices groups may extend this object adding any details specific to that | ||
180 | * device group or device-type. | ||
181 | */ | ||
182 | struct boardobjgrp { | ||
183 | struct gk20a *g; | ||
184 | u32 objmask; | ||
185 | bool bconstructed; | ||
186 | u8 type; | ||
187 | u8 classid; | ||
188 | struct boardobj **ppobjects; | ||
189 | struct boardobjgrpmask *mask; | ||
190 | u8 objslots; | ||
191 | u8 objmaxidx; | ||
192 | struct boardobjgrp_pmu pmu; | ||
193 | |||
194 | /* Basic interfaces */ | ||
195 | boardobjgrp_destruct *destruct; | ||
196 | boardobjgrp_objinsert *objinsert; | ||
197 | boardobjgrp_objgetbyidx *objgetbyidx; | ||
198 | boardobjgrp_objgetnext *objgetnext; | ||
199 | boardobjgrp_objremoveanddestroy *objremoveanddestroy; | ||
200 | |||
201 | /* PMU interfaces */ | ||
202 | boardobjgrp_pmuinithandle *pmuinithandle; | ||
203 | boardobjgrp_pmuhdrdatainit *pmuhdrdatainit; | ||
204 | boardobjgrp_pmudatainit *pmudatainit; | ||
205 | boardobjgrp_pmuset *pmuset; | ||
206 | boardobjgrp_pmugetstatus *pmugetstatus; | ||
207 | |||
208 | boardobjgrp_pmudatainstget *pmudatainstget; | ||
209 | boardobjgrp_pmustatusinstget *pmustatusinstget; | ||
210 | struct nvgpu_list_node node; | ||
211 | }; | ||
212 | |||
213 | /* | ||
214 | * Macro test whether a specified index into the BOARDOBJGRP is valid. | ||
215 | * | ||
216 | */ | ||
217 | #define boardobjgrp_idxisvalid(_pboardobjgrp, _idx) \ | ||
218 | (((_idx) < (_pboardobjgrp)->objslots) && \ | ||
219 | ((_pboardobjgrp)->ppobjects[(_idx)] != NULL)) | ||
220 | |||
221 | /* | ||
222 | * Macro test whether a specified BOARDOBJGRP is empty. | ||
223 | */ | ||
224 | #define BOARDOBJGRP_IS_EMPTY(_pboardobjgrp) \ | ||
225 | ((!((_pboardobjgrp)->bconstructed)) || \ | ||
226 | ((_pboardobjgrp)->objmaxidx == CTRL_BOARDOBJ_IDX_INVALID)) | ||
227 | |||
228 | #define boardobjgrp_objinsert(_pboardobjgrp, _pboardobj, _idx) \ | ||
229 | ((_pboardobjgrp)->objinsert((_pboardobjgrp), (_pboardobj), (_idx))) | ||
230 | |||
231 | /* | ||
232 | * Helper macro to determine the "next" open/empty index after all allocated | ||
233 | * objects. This is intended to be used to find the index at which objects can | ||
234 | * be inserted contiguously (i.e. w/o fear of colliding with existing objects). | ||
235 | */ | ||
236 | #define BOARDOBJGRP_NEXT_EMPTY_IDX(_pboardobjgrp) \ | ||
237 | ((CTRL_BOARDOBJ_IDX_INVALID == (_pboardobjgrp)->objmaxidx) ? 0U : \ | ||
238 | ((((_pboardobjgrp)->objmaxidx + 1U) >= (_pboardobjgrp)->objslots) ? \ | ||
239 | (u8)CTRL_BOARDOBJ_IDX_INVALID : (u8)((_pboardobjgrp)->objmaxidx + 1U))) | ||
240 | |||
241 | /* | ||
242 | * Helper macro to determine the number of @ref BOARDOBJ pointers | ||
243 | * that are required to be allocated in PMU @ref ppObjects. | ||
244 | */ | ||
245 | #define BOARDOBJGRP_PMU_SLOTS_GET(_pboardobjgrp) \ | ||
246 | ((CTRL_BOARDOBJ_IDX_INVALID == (_pboardobjgrp)->objmaxidx) ? 0U : \ | ||
247 | (u8)((_pboardobjgrp)->objmaxidx + 1U)) | ||
248 | |||
249 | #define BOARDOBJGRP_OBJ_GET_BY_IDX(_pboardobjgrp, _idx) \ | ||
250 | ((_pboardobjgrp)->objgetbyidx((_pboardobjgrp), (_idx))) | ||
251 | |||
252 | /* | ||
253 | * macro to look-up next object while tolerating error if | ||
254 | * Board Object Group is not constructed. | ||
255 | */ | ||
256 | |||
257 | #define boardobjgrpobjgetnextsafe(_pgrp, _pindex, _pmask) \ | ||
258 | ((_pgrp)->bconstructed ? \ | ||
259 | (_pgrp)->objgetnext((_pgrp), (_pindex), (_pmask)) : NULL) | ||
260 | |||
261 | /* | ||
262 | * Used to traverse all Board Objects stored within @ref _pgrp in the increasing | ||
263 | * index order. | ||
264 | * If @ref _pmask is provided only objects specified by the mask are traversed. | ||
265 | */ | ||
266 | #define BOARDOBJGRP_ITERATOR(_pgrp, _ptype, _pobj, _index, _pmask) \ | ||
267 | for (_index = CTRL_BOARDOBJ_IDX_INVALID, \ | ||
268 | _pobj = (_ptype)boardobjgrpobjgetnextsafe((_pgrp), &_index, (_pmask));\ | ||
269 | _pobj != NULL; \ | ||
270 | _pobj = (_ptype)boardobjgrpobjgetnextsafe((_pgrp), &_index, (_pmask))) | ||
271 | #define BOARDOBJGRP_FOR_EACH(_pgrp, _ptype, _pobj, _index) \ | ||
272 | BOARDOBJGRP_ITERATOR(_pgrp, _ptype, _pobj, _index, NULL) | ||
273 | |||
274 | #define BOARDOBJGRP_FOR_EACH_INDEX_IN_MASK(mask_width, index, mask) \ | ||
275 | { \ | ||
276 | u##mask_width lcl_msk = (u##mask_width)(mask); \ | ||
277 | for (index = 0; lcl_msk != 0U; index++, lcl_msk >>= 1U) { \ | ||
278 | if (((u##mask_width)((u64)1) & lcl_msk) == 0U) { \ | ||
279 | continue; \ | ||
280 | } | ||
281 | |||
282 | #define BOARDOBJGRP_FOR_EACH_INDEX_IN_MASK_END \ | ||
283 | } \ | ||
284 | } | ||
285 | |||
286 | |||
287 | /*! | ||
288 | * Invalid UNIT_ID. Used to indicate that the implementing class has not set | ||
289 | * @ref BOARDOBJGRP::unitId and, thus, certain BOARDOBJGRP PMU interfaces are | ||
290 | * not supported. | ||
291 | */ | ||
292 | #define BOARDOBJGRP_UNIT_ID_INVALID 255U | ||
293 | |||
294 | /*! | ||
295 | * Invalid UNIT_ID. Used to indicate that the implementing class has not set | ||
296 | * @ref BOARDOBJGRP::grpType and, thus, certain BOARDOBJGRP PMU interfaces are | ||
297 | * not supported. | ||
298 | */ | ||
299 | #define BOARDOBJGRP_GRP_CLASS_ID_INVALID 255U | ||
300 | |||
301 | /*! | ||
302 | * Invalid UNIT_ID. Used to indicate that the implementing class has not set | ||
303 | * @ref BOARDOBJGRP::grpSetCmdId and, thus, certain BOARDOBJGRP PMU interfaces | ||
304 | * are not supported. | ||
305 | */ | ||
306 | #define BOARDOBJGRP_GRP_CMD_ID_INVALID 255U | ||
307 | #define BOARDOBJGRP_GRP_RPC_FUNC_ID_INVALID 255U | ||
308 | |||
309 | /*! | ||
310 | * Helper macro to construct a BOARDOBJGRP's PMU SW state. | ||
311 | * | ||
312 | * @param[out] pboardobjgrp BOARDOBJGRP pointer | ||
313 | * @param[in] _eng | ||
314 | * Implementing engine/unit which manages the BOARDOBJGRP. | ||
315 | * @param[in] _class | ||
316 | * Class ID of BOARDOBJGRP. | ||
317 | */ | ||
318 | #define BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, _ENG, _CLASS) \ | ||
319 | do { \ | ||
320 | (pboardobjgrp)->pmu.unitid = PMU_UNIT_##_ENG; \ | ||
321 | (pboardobjgrp)->pmu.classid = \ | ||
322 | NV_PMU_##_ENG##_BOARDOBJGRP_CLASS_ID_##_CLASS; \ | ||
323 | } while (0) | ||
324 | |||
325 | #define BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp, eng, ENG, \ | ||
326 | class, CLASS) \ | ||
327 | g->ops.pmu_ver.boardobj.boardobjgrp_pmucmd_construct_impl( \ | ||
328 | g, /* pgpu */ \ | ||
329 | pboardobjgrp, /* pboardobjgrp */ \ | ||
330 | &((pboardobjgrp)->pmu.set), /* pcmd */ \ | ||
331 | NV_PMU_##ENG##_CMD_ID_BOARDOBJ_GRP_SET, /* id */ \ | ||
332 | NV_PMU_##ENG##_MSG_ID_BOARDOBJ_GRP_SET, /* msgid */ \ | ||
333 | (u32)sizeof(union nv_pmu_##eng##_##class##_boardobjgrp_set_header_aligned), \ | ||
334 | (u32)sizeof(union nv_pmu_##eng##_##class##_boardobj_set_union_aligned), \ | ||
335 | (u32)sizeof(struct nv_pmu_##eng##_##class##_boardobj_grp_set), \ | ||
336 | (u32)offsetof(struct nv_pmu_super_surface, eng.class##_grp_set), \ | ||
337 | NV_PMU_RPC_ID_##ENG##_BOARD_OBJ_GRP_CMD) | ||
338 | |||
339 | #define BOARDOBJGRP_PMU_CMD_GRP_GET_STATUS_CONSTRUCT(g, pboardobjgrp, \ | ||
340 | eng, ENG, class, CLASS) \ | ||
341 | g->ops.pmu_ver.boardobj.boardobjgrp_pmucmd_construct_impl( \ | ||
342 | g, /* pGpu */ \ | ||
343 | pboardobjgrp, /* pBoardObjGrp */ \ | ||
344 | &((pboardobjgrp)->pmu.getstatus), /* pCmd */ \ | ||
345 | NV_PMU_##ENG##_CMD_ID_BOARDOBJ_GRP_GET_STATUS, /* id */ \ | ||
346 | NV_PMU_##ENG##_MSG_ID_BOARDOBJ_GRP_GET_STATUS, /* msgid */ \ | ||
347 | (u32)sizeof(union nv_pmu_##eng##_##class##_boardobjgrp_get_status_header_aligned), \ | ||
348 | (u32)sizeof(union nv_pmu_##eng##_##class##_boardobj_get_status_union_aligned), \ | ||
349 | (u32)sizeof(struct nv_pmu_##eng##_##class##_boardobj_grp_get_status), \ | ||
350 | (u32)offsetof(struct nv_pmu_super_surface, eng.class##_grp_get_status), \ | ||
351 | NV_PMU_RPC_ID_##ENG##_BOARD_OBJ_GRP_CMD) | ||
352 | |||
353 | /* ------------------------ Function Prototypes ----------------------------- */ | ||
354 | /* Constructor and destructor */ | ||
355 | int boardobjgrp_construct_super(struct gk20a *g, | ||
356 | struct boardobjgrp *pboardobjgrp); | ||
357 | boardobjgrp_destruct boardobjgrp_destruct_impl; | ||
358 | boardobjgrp_destruct boardobjgrp_destruct_super; | ||
359 | |||
360 | /* PMU_CMD interfaces */ | ||
361 | boardobjgrp_pmucmd_construct boardobjgrp_pmucmd_construct_impl; | ||
362 | boardobjgrp_pmucmd_destroy boardobjgrp_pmucmd_destroy_impl; | ||
363 | boardobjgrp_pmucmd_pmuinithandle boardobjgrp_pmucmd_pmuinithandle_impl; | ||
364 | |||
365 | boardobjgrp_pmucmd_construct boardobjgrp_pmucmd_construct_impl_v1; | ||
366 | |||
367 | /* BOARDOBJGRP interfaces */ | ||
368 | boardobjgrp_pmuinithandle boardobjgrp_pmuinithandle_impl; | ||
369 | boardobjgrp_pmuhdrdatainit boardobjgrp_pmuhdrdatainit_super; | ||
370 | boardobjgrp_pmudatainit boardobjgrp_pmudatainit_super; | ||
371 | |||
372 | boardobjgrp_pmudatainit boardobjgrp_pmudatainit_legacy; | ||
373 | boardobjgrp_pmuset boardobjgrp_pmuset_impl; | ||
374 | boardobjgrp_pmugetstatus boardobjgrp_pmugetstatus_impl; | ||
375 | boardobjgrp_pmuset boardobjgrp_pmuset_impl_v1; | ||
376 | boardobjgrp_pmugetstatus boardobjgrp_pmugetstatus_impl_v1; | ||
377 | |||
378 | void boardobjgrpe32hdrset(struct nv_pmu_boardobjgrp *hdr, u32 objmask); | ||
379 | |||
380 | #define HIGHESTBITIDX_32(n32) \ | ||
381 | { \ | ||
382 | u32 count = 0U; \ | ||
383 | while (n32 >>= 1U) { \ | ||
384 | count++; \ | ||
385 | } \ | ||
386 | n32 = count; \ | ||
387 | } | ||
388 | |||
389 | #define LOWESTBIT(x) ((x) & (((x)-1U) ^ (x))) | ||
390 | |||
391 | #define HIGHESTBIT(n32) \ | ||
392 | { \ | ||
393 | HIGHESTBITIDX_32(n32); \ | ||
394 | n32 = NVBIT(n32); \ | ||
395 | } | ||
396 | |||
397 | #define ONEBITSET(x) ((x) && (((x) & ((x)-1U)) == 0U)) | ||
398 | |||
399 | #define LOWESTBITIDX_32(n32) \ | ||
400 | { \ | ||
401 | n32 = LOWESTBIT(n32); \ | ||
402 | IDX_32(n32); \ | ||
403 | } | ||
404 | |||
405 | #define NUMSETBITS_32(n32) \ | ||
406 | { \ | ||
407 | n32 = n32 - ((n32 >> 1U) & 0x55555555U); \ | ||
408 | n32 = (n32 & 0x33333333U) + ((n32 >> 2U) & 0x33333333U); \ | ||
409 | n32 = (((n32 + (n32 >> 4U)) & 0x0F0F0F0FU) * 0x01010101U) >> 24U; \ | ||
410 | } | ||
411 | |||
412 | #define IDX_32(n32) \ | ||
413 | { \ | ||
414 | u32 idx = 0U; \ | ||
415 | if ((n32) & 0xFFFF0000U) \ | ||
416 | idx += 16U; \ | ||
417 | if ((n32) & 0xFF00FF00U) \ | ||
418 | idx += 8U; \ | ||
419 | if ((n32) & 0xF0F0F0F0U) \ | ||
420 | idx += 4U; \ | ||
421 | if ((n32) & 0xCCCCCCCCU) \ | ||
422 | idx += 2U; \ | ||
423 | if ((n32) & 0xAAAAAAAAU) \ | ||
424 | idx += 1U; \ | ||
425 | (n32) = idx; \ | ||
426 | } | ||
427 | |||
428 | static inline struct boardobjgrp * | ||
429 | boardobjgrp_from_node(struct nvgpu_list_node *node) | ||
430 | { | ||
431 | return (struct boardobjgrp *) | ||
432 | ((uintptr_t)node - offsetof(struct boardobjgrp, node)); | ||
433 | }; | ||
434 | |||
435 | int is_boardobjgrp_pmucmd_id_valid_v0(struct gk20a *g, | ||
436 | struct boardobjgrp *pboardobjgrp, | ||
437 | struct boardobjgrp_pmu_cmd *cmd); | ||
438 | int is_boardobjgrp_pmucmd_id_valid_v1(struct gk20a *g, | ||
439 | struct boardobjgrp *pboardobjgrp, | ||
440 | struct boardobjgrp_pmu_cmd *cmd); | ||
441 | #endif /* NVGPU_BOARDOBJGRP_H */ | ||