1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #pragma once
25 
26 #include <nvtypes.h>
27 
28 //
29 // This file was generated with FINN, an NVIDIA coding tool.
30 // Source file:      ctrl/ctrl00f8.finn
31 //
32 
33 #include "ctrl/ctrlxxxx.h"
34 #include "ctrl90f1.h"
35 #include "mmu_fmt_types.h"
36 
37 #define NV00F8_CTRL_CMD(cat,idx)       NVXXXX_CTRL_CMD(0x00f8, NV00F8_CTRL_##cat, idx)
38 
39 /* NV00F8 command categories (6bits) */
40 #define NV00F8_CTRL_RESERVED (0x00U)
41 #define NV00F8_CTRL_FABRIC   (0x01U)
42 
43 /*
44  * NV00F8_CTRL_CMD_NULL
45  *
46  * This command does nothing.
47  * This command does not take any parameters.
48  *
49  * Possible status values returned are:
50  *   NV_OK
51  */
52 #define NV00F8_CTRL_CMD_NULL (0xf80000U) /* finn: Evaluated from "(FINN_NV_MEMORY_FABRIC_RESERVED_INTERFACE_ID << 8) | 0x0" */
53 
54 
55 
56 /*
57  * NV00F8_CTRL_CMD_GET_INFO
58  *
59  * Queries memory allocation attributes.
60  *
61  *  size [OUT]
62  *    Size of the allocation.
63  *
64  *  pageSize [OUT]
65  *    Page size of the allocation.
66  *
67  *  allocFlags [OUT]
68  *    Flags passed during the allocation.
69  *
70  *  physAttrs [OUT]
71  *    Physical attributes associated with memory allocation.
72  *    For flexible mappings, it is not possible to retrieve this information,
73  *    behavior is undefined (returns all zeros).
74  */
75 #define NV00F8_CTRL_CMD_GET_INFO (0xf80101U) /* finn: Evaluated from "(FINN_NV_MEMORY_FABRIC_FABRIC_INTERFACE_ID << 8) | NV00F8_CTRL_GET_INFO_PARAMS_MESSAGE_ID" */
76 
77 /*
78  * addressSpace
79  *     Same as NV0041_CTRL_SURFACE_INFO_INDEX_ADDR_SPACE_TYPE.
80  *
81  * compressionCoverage
82  *     Same as NV0041_CTRL_SURFACE_INFO_INDEX_COMPR_COVERAGE.
83  */
84 typedef struct NV_PHYSICAL_MEMORY_ATTRS {
85     NvU32 addressSpace;
86     NvU32 compressionCoverage;
87 } NV_PHYSICAL_MEMORY_ATTRS;
88 
89 #define NV00F8_CTRL_GET_INFO_PARAMS_MESSAGE_ID (0x1U)
90 
91 typedef struct NV00F8_CTRL_GET_INFO_PARAMS {
92     NV_DECLARE_ALIGNED(NvU64 size, 8);
93     NV_DECLARE_ALIGNED(NvU64 pageSize, 8);
94     NvU32                    allocFlags;
95     NV_PHYSICAL_MEMORY_ATTRS physAttrs;
96 } NV00F8_CTRL_GET_INFO_PARAMS;
97 
98 /*
99  * NV00F8_CTRL_CMD_DESCRIBE
100  *
101  * Queries the physical attributes of the fabric memory allocation.
102  *
103  *  offset [IN]
104  *    Offset into memory allocation to query physical addresses for.
105  *
106  *  totalPfns [OUT]
107  *    Number of PFNs in memory allocation.
108  *
109  *  pfnArray [OUT]
110  *    Array of PFNs in memory allocation (2MB page size shifted).
111  *
112  *  numPfns [OUT]
113  *    Number of valid entries in pfnArray.
114  *
115  * Note: This ctrl call is only available for kerenl mode client in vGPU platforms.
116  */
117 
118 #define NV00F8_CTRL_CMD_DESCRIBE            (0xf80102) /* finn: Evaluated from "(FINN_NV_MEMORY_FABRIC_FABRIC_INTERFACE_ID << 8) | NV00F8_CTRL_DESCRIBE_PARAMS_MESSAGE_ID" */
119 
120 #define NV00F8_CTRL_DESCRIBE_PFN_ARRAY_SIZE 512
121 
122 #define NV00F8_CTRL_DESCRIBE_PARAMS_MESSAGE_ID (0x2U)
123 
124 typedef struct NV00F8_CTRL_DESCRIBE_PARAMS {
125     NV_DECLARE_ALIGNED(NvU64 offset, 8);
126     NV_DECLARE_ALIGNED(NvU64 totalPfns, 8);
127     NvU32 pfnArray[NV00F8_CTRL_DESCRIBE_PFN_ARRAY_SIZE];
128     NvU32 numPfns;
129 } NV00F8_CTRL_DESCRIBE_PARAMS;
130 
131 /*
132  *  hMemory
133  *    Physical memory handle to be attached.
134  *
135  *  offset
136  *    Offset into the fabric object.
137  *    Must be physical memory pagesize aligned (at least).
138  *
139  *  mapOffSet
140  *    Offset into the physical memory descriptor.
141  *    Must be physical memory pagesize aligned.
142  *
143  *  mapLength
144  *    Length of physical memory handle to be mapped.
145  *    Must be physical memory pagesize aligned and less than or equal to
146  *    fabric alloc size.
147  */
148 typedef struct NV00F8_CTRL_ATTACH_MEM_INFO {
149     NvHandle hMemory;
150     NV_DECLARE_ALIGNED(NvU64 offset, 8);
151     NV_DECLARE_ALIGNED(NvU64 mapOffset, 8);
152     NV_DECLARE_ALIGNED(NvU64 mapLength, 8);
153 } NV00F8_CTRL_ATTACH_MEM_INFO;
154 
155 /*
156  * NV00F8_CTRL_CMD_ATTACH_MEM
157  *
158  * Attaches physical memory info to the fabric object.
159  *
160  *  memInfos [IN]
161  *    Memory infos to be attached.
162  *
163  *  numMemInfos [IN]
164  *    Number of memory infos to be attached.
165  *
166  *  flags [IN]
167  *    For future use only. Must be zero for now.
168  *
169  *  numAttached [OUT]
170  *    Successful attach count (returns a valid value on error too)
171  *
172  *  Restrictions:
173  *  a. Physical memory with 2MB pagesize is allowed
174  *  b. Only vidmem physical memory handle can be attached
175  *  c. Supported only for flexible fabric objects.
176  */
177 #define NV00F8_CTRL_CMD_ATTACH_MEM      (0xf80103) /* finn: Evaluated from "(FINN_NV_MEMORY_FABRIC_FABRIC_INTERFACE_ID << 8) | NV00F8_CTRL_ATTACH_MEM_PARAMS_MESSAGE_ID" */
178 
179 #define NV00F8_MAX_ATTACHABLE_MEM_INFOS 64
180 
181 #define NV00F8_CTRL_ATTACH_MEM_PARAMS_MESSAGE_ID (0x3U)
182 
183 typedef struct NV00F8_CTRL_ATTACH_MEM_PARAMS {
184     NV_DECLARE_ALIGNED(NV00F8_CTRL_ATTACH_MEM_INFO memInfos[NV00F8_MAX_ATTACHABLE_MEM_INFOS], 8);
185     NvU16 numMemInfos;
186     NvU32 flags;
187     NvU16 numAttached;
188 } NV00F8_CTRL_ATTACH_MEM_PARAMS;
189 
190 /*
191  * NV00F8_CTRL_CMD_DETACH_MEM
192  *
193  * Detaches physical memory handle from the fabric object.
194  *
195  *  offsets [IN]
196  *    Offsets at which memory was attached.
197  *
198  *  numOffsets [IN]
199  *    Number of offsets to be detached.
200  *
201  *  flags [IN]
202  *    For future use only. Must be zero for now.
203  *
204  *  numDetached [OUT]
205  *    Successful detach count (returns a valid value on error too)
206  */
207 #define NV00F8_CTRL_CMD_DETACH_MEM    (0xf80104) /* finn: Evaluated from "(FINN_NV_MEMORY_FABRIC_FABRIC_INTERFACE_ID << 8) | NV00F8_CTRL_DETACH_MEM_PARAMS_MESSAGE_ID" */
208 
209 #define NV00F8_MAX_DETACHABLE_OFFSETS 64
210 
211 #define NV00F8_CTRL_DETACH_MEM_PARAMS_MESSAGE_ID (0x4U)
212 
213 typedef struct NV00F8_CTRL_DETACH_MEM_PARAMS {
214     NV_DECLARE_ALIGNED(NvU64 offsets[NV00F8_MAX_DETACHABLE_OFFSETS], 8);
215     NvU16 numOffsets;
216     NvU32 flags;
217     NvU16 numDetached;
218 } NV00F8_CTRL_DETACH_MEM_PARAMS;
219 
220 /*
221  * NV00F8_CTRL_CMD_GET_NUM_ATTACHED_MEM
222  *
223  * Returns number of attached physical memory info to the fabric object in
224  * a given offset range.
225  *
226  *  offsetStart [IN]
227  *    Offsets at which memory was attached.
228  *
229  *  offsetEnd [IN]
230  *    Offsets at which memory was attached.
231  *
232  *  numMemInfos [OUT]
233  *    Number of memory infos.
234  */
235 #define NV00F8_CTRL_CMD_GET_NUM_ATTACHED_MEM (0xf80105) /* finn: Evaluated from "(FINN_NV_MEMORY_FABRIC_FABRIC_INTERFACE_ID << 8) | NV00F8_CTRL_GET_NUM_ATTACHED_MEM_PARAMS_MESSAGE_ID" */
236 
237 #define NV00F8_CTRL_GET_NUM_ATTACHED_MEM_PARAMS_MESSAGE_ID (0x5U)
238 
239 typedef struct NV00F8_CTRL_GET_NUM_ATTACHED_MEM_PARAMS {
240     NV_DECLARE_ALIGNED(NvU64 offsetStart, 8);
241     NV_DECLARE_ALIGNED(NvU64 offsetEnd, 8);
242     NvU16 numMemInfos;
243 } NV00F8_CTRL_GET_NUM_ATTACHED_MEM_PARAMS;
244 
245 /*
246  * NV00F8_CTRL_CMD_GET_ATTACHED_MEM
247  *
248  * Queries attached physical memory info to the fabric object.
249  *
250  *  offsetStart [IN]
251  *    Offsets at which memory was attached.
252  *
253  *  numMemInfos [IN]
254  *    Number of memory infos to be filled.
255  *
256  *  memInfos [IN/OUT]
257  *    Attached memory infos.
258  *    Use must populate a non-zero `hMemory` handle. This handle will be used by
259  *    RM for duping physical memory.
260  */
261 #define NV00F8_CTRL_CMD_GET_ATTACHED_MEM (0xf80106) /* finn: Evaluated from "(FINN_NV_MEMORY_FABRIC_FABRIC_INTERFACE_ID << 8) | NV00F8_CTRL_GET_ATTACHED_MEM_PARAMS_MESSAGE_ID" */
262 
263 #define NV00F8_MAX_ATTACHED_MEM_INFOS    64
264 
265 #define NV00F8_CTRL_GET_ATTACHED_MEM_PARAMS_MESSAGE_ID (0x6U)
266 
267 typedef struct NV00F8_CTRL_GET_ATTACHED_MEM_PARAMS {
268     NV_DECLARE_ALIGNED(NvU64 offsetStart, 8);
269     NvU16 numMemInfos;
270     NV_DECLARE_ALIGNED(NV00F8_CTRL_ATTACH_MEM_INFO memInfos[NV00F8_MAX_ATTACHED_MEM_INFOS], 8);
271 } NV00F8_CTRL_GET_ATTACHED_MEM_PARAMS;
272 
273 /*
274  * NV00F8_CTRL_CMD_GET_PAGE_LEVEL_INFO
275  *
276  * Queries page table  information for a specific memory fabric address. This
277  * call is only supported for Verif platforms. This will return the same info
278  * as NV90F1_CTRL_VASPACE_GET_PAGE_LEVEL_INFO_PARAMS.
279  *
280  *  offset [IN]
281  *    Memory fabric Offset from the base address for which page table
282  *    information is queried. This offset should be aligned to physical page
283  *    size.
284  *
285  *  numLevels [OUT]
286  *    Number of levels populated.
287  *
288  *  levels [OUT]
289  *    Per-level information.
290  *
291  *  pFmt
292  *    Same as NV90F1_CTRL_VASPACE_GET_PAGE_LEVEL_INFO_PARAMS.
293  *
294  *  levelFmt
295  *    Same as NV90F1_CTRL_VASPACE_GET_PAGE_LEVEL_INFO_PARAMS.
296  *
297  *  sublevelFmt
298  *    Same as NV90F1_CTRL_VASPACE_GET_PAGE_LEVEL_INFO_PARAMS.
299  *
300  *  aperture
301  *    Same as NV90F1_CTRL_VASPACE_GET_PAGE_LEVEL_INFO_PARAMS.
302  *
303  *  size
304  *    Same as NV90F1_CTRL_VASPACE_GET_PAGE_LEVEL_INFO_PARAMS.
305  */
306 #define NV00F8_CTRL_CMD_GET_PAGE_LEVEL_INFO (0xf80107U) /* finn: Evaluated from "(FINN_NV_MEMORY_FABRIC_FABRIC_INTERFACE_ID << 8) | NV00F8_CTRL_GET_PAGE_LEVEL_INFO_PARAMS_MESSAGE_ID" */
307 
308 #define NV00F8_CTRL_GET_PAGE_LEVEL_INFO_PARAMS_MESSAGE_ID (0x7U)
309 
310 typedef struct NV00F8_CTRL_GET_PAGE_LEVEL_INFO_PARAMS {
311     NV_DECLARE_ALIGNED(NvU64 offset, 8);
312     NvU32 numLevels;
313     NV_DECLARE_ALIGNED(NV_CTRL_VASPACE_PAGE_LEVEL levels[GMMU_FMT_MAX_LEVELS], 8);
314 } NV00F8_CTRL_GET_PAGE_LEVEL_INFO_PARAMS;
315 
316 /* _ctrl00f8_h_ */
317