1 #ifndef _G_MEM_LIST_NVOC_H_
2 #define _G_MEM_LIST_NVOC_H_
3 #include "nvoc/runtime.h"
4
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
9 /*
10 * SPDX-FileCopyrightText: Copyright (c) 1993-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
11 * SPDX-License-Identifier: MIT
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included in
21 * all copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 * DEALINGS IN THE SOFTWARE.
30 */
31
32 #include "g_mem_list_nvoc.h"
33
34 #ifndef _MEMORY_LIST_H_
35 #define _MEMORY_LIST_H_
36
37 #include "mem_mgr/mem.h"
38
39 /*!
40 * These classes are used by the vGPU support to create memory objects for memory
41 * assigned to a guest VM.
42 */
43
44 // Private field names are wrapped in PRIVATE_FIELD, which does nothing for
45 // the matching C source file, but causes diagnostics to be issued if another
46 // source file references the field.
47 #ifdef NVOC_MEM_LIST_H_PRIVATE_ACCESS_ALLOWED
48 #define PRIVATE_FIELD(x) x
49 #else
50 #define PRIVATE_FIELD(x) NVOC_PRIVATE_FIELD(x)
51 #endif
52
53 struct MemoryList {
54 const struct NVOC_RTTI *__nvoc_rtti;
55 struct Memory __nvoc_base_Memory;
56 struct Object *__nvoc_pbase_Object;
57 struct RsResource *__nvoc_pbase_RsResource;
58 struct RmResourceCommon *__nvoc_pbase_RmResourceCommon;
59 struct RmResource *__nvoc_pbase_RmResource;
60 struct Memory *__nvoc_pbase_Memory;
61 struct MemoryList *__nvoc_pbase_MemoryList;
62 NvBool (*__memlistCanCopy__)(struct MemoryList *);
63 NV_STATUS (*__memlistCheckMemInterUnmap__)(struct MemoryList *, NvBool);
64 NvBool (*__memlistShareCallback__)(struct MemoryList *, struct RsClient *, struct RsResourceRef *, RS_SHARE_POLICY *);
65 NV_STATUS (*__memlistMapTo__)(struct MemoryList *, RS_RES_MAP_TO_PARAMS *);
66 NV_STATUS (*__memlistGetMapAddrSpace__)(struct MemoryList *, CALL_CONTEXT *, NvU32, NV_ADDRESS_SPACE *);
67 NvBool (*__memlistIsExportAllowed__)(struct MemoryList *);
68 NvU32 (*__memlistGetRefCount__)(struct MemoryList *);
69 void (*__memlistAddAdditionalDependants__)(struct RsClient *, struct MemoryList *, RsResourceRef *);
70 NV_STATUS (*__memlistControl_Prologue__)(struct MemoryList *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
71 NvBool (*__memlistIsGpuMapAllowed__)(struct MemoryList *, struct OBJGPU *);
72 NV_STATUS (*__memlistUnmapFrom__)(struct MemoryList *, RS_RES_UNMAP_FROM_PARAMS *);
73 void (*__memlistControl_Epilogue__)(struct MemoryList *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
74 NV_STATUS (*__memlistControl__)(struct MemoryList *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
75 NV_STATUS (*__memlistUnmap__)(struct MemoryList *, CALL_CONTEXT *, RsCpuMapping *);
76 NV_STATUS (*__memlistGetMemInterMapParams__)(struct MemoryList *, RMRES_MEM_INTER_MAP_PARAMS *);
77 NV_STATUS (*__memlistGetMemoryMappingDescriptor__)(struct MemoryList *, MEMORY_DESCRIPTOR **);
78 NV_STATUS (*__memlistControlFilter__)(struct MemoryList *, struct CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
79 NV_STATUS (*__memlistControlSerialization_Prologue__)(struct MemoryList *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
80 NvBool (*__memlistIsPartialUnmapSupported__)(struct MemoryList *);
81 NV_STATUS (*__memlistIsReady__)(struct MemoryList *, NvBool);
82 NV_STATUS (*__memlistCheckCopyPermissions__)(struct MemoryList *, struct OBJGPU *, struct Device *);
83 void (*__memlistPreDestruct__)(struct MemoryList *);
84 NV_STATUS (*__memlistIsDuplicate__)(struct MemoryList *, NvHandle, NvBool *);
85 void (*__memlistControlSerialization_Epilogue__)(struct MemoryList *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
86 NV_STATUS (*__memlistMap__)(struct MemoryList *, CALL_CONTEXT *, struct RS_CPU_MAP_PARAMS *, RsCpuMapping *);
87 NvBool (*__memlistAccessCallback__)(struct MemoryList *, struct RsClient *, void *, RsAccessRight);
88 };
89
90 #ifndef __NVOC_CLASS_MemoryList_TYPEDEF__
91 #define __NVOC_CLASS_MemoryList_TYPEDEF__
92 typedef struct MemoryList MemoryList;
93 #endif /* __NVOC_CLASS_MemoryList_TYPEDEF__ */
94
95 #ifndef __nvoc_class_id_MemoryList
96 #define __nvoc_class_id_MemoryList 0x298f78
97 #endif /* __nvoc_class_id_MemoryList */
98
99 extern const struct NVOC_CLASS_DEF __nvoc_class_def_MemoryList;
100
101 #define __staticCast_MemoryList(pThis) \
102 ((pThis)->__nvoc_pbase_MemoryList)
103
104 #ifdef __nvoc_mem_list_h_disabled
105 #define __dynamicCast_MemoryList(pThis) ((MemoryList*)NULL)
106 #else //__nvoc_mem_list_h_disabled
107 #define __dynamicCast_MemoryList(pThis) \
108 ((MemoryList*)__nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(MemoryList)))
109 #endif //__nvoc_mem_list_h_disabled
110
111
112 NV_STATUS __nvoc_objCreateDynamic_MemoryList(MemoryList**, Dynamic*, NvU32, va_list);
113
114 NV_STATUS __nvoc_objCreate_MemoryList(MemoryList**, Dynamic*, NvU32, CALL_CONTEXT * arg_pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL * arg_pParams);
115 #define __objCreate_MemoryList(ppNewObj, pParent, createFlags, arg_pCallContext, arg_pParams) \
116 __nvoc_objCreate_MemoryList((ppNewObj), staticCast((pParent), Dynamic), (createFlags), arg_pCallContext, arg_pParams)
117
118 #define memlistCanCopy(pMemoryList) memlistCanCopy_DISPATCH(pMemoryList)
119 #define memlistCheckMemInterUnmap(pMemory, bSubdeviceHandleProvided) memlistCheckMemInterUnmap_DISPATCH(pMemory, bSubdeviceHandleProvided)
120 #define memlistShareCallback(pResource, pInvokingClient, pParentRef, pSharePolicy) memlistShareCallback_DISPATCH(pResource, pInvokingClient, pParentRef, pSharePolicy)
121 #define memlistMapTo(pResource, pParams) memlistMapTo_DISPATCH(pResource, pParams)
122 #define memlistGetMapAddrSpace(pMemory, pCallContext, mapFlags, pAddrSpace) memlistGetMapAddrSpace_DISPATCH(pMemory, pCallContext, mapFlags, pAddrSpace)
123 #define memlistIsExportAllowed(pMemory) memlistIsExportAllowed_DISPATCH(pMemory)
124 #define memlistGetRefCount(pResource) memlistGetRefCount_DISPATCH(pResource)
125 #define memlistAddAdditionalDependants(pClient, pResource, pReference) memlistAddAdditionalDependants_DISPATCH(pClient, pResource, pReference)
126 #define memlistControl_Prologue(pResource, pCallContext, pParams) memlistControl_Prologue_DISPATCH(pResource, pCallContext, pParams)
127 #define memlistIsGpuMapAllowed(pMemory, pGpu) memlistIsGpuMapAllowed_DISPATCH(pMemory, pGpu)
128 #define memlistUnmapFrom(pResource, pParams) memlistUnmapFrom_DISPATCH(pResource, pParams)
129 #define memlistControl_Epilogue(pResource, pCallContext, pParams) memlistControl_Epilogue_DISPATCH(pResource, pCallContext, pParams)
130 #define memlistControl(pMemory, pCallContext, pParams) memlistControl_DISPATCH(pMemory, pCallContext, pParams)
131 #define memlistUnmap(pMemory, pCallContext, pCpuMapping) memlistUnmap_DISPATCH(pMemory, pCallContext, pCpuMapping)
132 #define memlistGetMemInterMapParams(pMemory, pParams) memlistGetMemInterMapParams_DISPATCH(pMemory, pParams)
133 #define memlistGetMemoryMappingDescriptor(pMemory, ppMemDesc) memlistGetMemoryMappingDescriptor_DISPATCH(pMemory, ppMemDesc)
134 #define memlistControlFilter(pResource, pCallContext, pParams) memlistControlFilter_DISPATCH(pResource, pCallContext, pParams)
135 #define memlistControlSerialization_Prologue(pResource, pCallContext, pParams) memlistControlSerialization_Prologue_DISPATCH(pResource, pCallContext, pParams)
136 #define memlistIsPartialUnmapSupported(pResource) memlistIsPartialUnmapSupported_DISPATCH(pResource)
137 #define memlistIsReady(pMemory, bCopyConstructorContext) memlistIsReady_DISPATCH(pMemory, bCopyConstructorContext)
138 #define memlistCheckCopyPermissions(pMemory, pDstGpu, pDstDevice) memlistCheckCopyPermissions_DISPATCH(pMemory, pDstGpu, pDstDevice)
139 #define memlistPreDestruct(pResource) memlistPreDestruct_DISPATCH(pResource)
140 #define memlistIsDuplicate(pMemory, hMemory, pDuplicate) memlistIsDuplicate_DISPATCH(pMemory, hMemory, pDuplicate)
141 #define memlistControlSerialization_Epilogue(pResource, pCallContext, pParams) memlistControlSerialization_Epilogue_DISPATCH(pResource, pCallContext, pParams)
142 #define memlistMap(pMemory, pCallContext, pParams, pCpuMapping) memlistMap_DISPATCH(pMemory, pCallContext, pParams, pCpuMapping)
143 #define memlistAccessCallback(pResource, pInvokingClient, pAllocParams, accessRight) memlistAccessCallback_DISPATCH(pResource, pInvokingClient, pAllocParams, accessRight)
144 NvBool memlistCanCopy_IMPL(struct MemoryList *pMemoryList);
145
memlistCanCopy_DISPATCH(struct MemoryList * pMemoryList)146 static inline NvBool memlistCanCopy_DISPATCH(struct MemoryList *pMemoryList) {
147 return pMemoryList->__memlistCanCopy__(pMemoryList);
148 }
149
memlistCheckMemInterUnmap_DISPATCH(struct MemoryList * pMemory,NvBool bSubdeviceHandleProvided)150 static inline NV_STATUS memlistCheckMemInterUnmap_DISPATCH(struct MemoryList *pMemory, NvBool bSubdeviceHandleProvided) {
151 return pMemory->__memlistCheckMemInterUnmap__(pMemory, bSubdeviceHandleProvided);
152 }
153
memlistShareCallback_DISPATCH(struct MemoryList * pResource,struct RsClient * pInvokingClient,struct RsResourceRef * pParentRef,RS_SHARE_POLICY * pSharePolicy)154 static inline NvBool memlistShareCallback_DISPATCH(struct MemoryList *pResource, struct RsClient *pInvokingClient, struct RsResourceRef *pParentRef, RS_SHARE_POLICY *pSharePolicy) {
155 return pResource->__memlistShareCallback__(pResource, pInvokingClient, pParentRef, pSharePolicy);
156 }
157
memlistMapTo_DISPATCH(struct MemoryList * pResource,RS_RES_MAP_TO_PARAMS * pParams)158 static inline NV_STATUS memlistMapTo_DISPATCH(struct MemoryList *pResource, RS_RES_MAP_TO_PARAMS *pParams) {
159 return pResource->__memlistMapTo__(pResource, pParams);
160 }
161
memlistGetMapAddrSpace_DISPATCH(struct MemoryList * pMemory,CALL_CONTEXT * pCallContext,NvU32 mapFlags,NV_ADDRESS_SPACE * pAddrSpace)162 static inline NV_STATUS memlistGetMapAddrSpace_DISPATCH(struct MemoryList *pMemory, CALL_CONTEXT *pCallContext, NvU32 mapFlags, NV_ADDRESS_SPACE *pAddrSpace) {
163 return pMemory->__memlistGetMapAddrSpace__(pMemory, pCallContext, mapFlags, pAddrSpace);
164 }
165
memlistIsExportAllowed_DISPATCH(struct MemoryList * pMemory)166 static inline NvBool memlistIsExportAllowed_DISPATCH(struct MemoryList *pMemory) {
167 return pMemory->__memlistIsExportAllowed__(pMemory);
168 }
169
memlistGetRefCount_DISPATCH(struct MemoryList * pResource)170 static inline NvU32 memlistGetRefCount_DISPATCH(struct MemoryList *pResource) {
171 return pResource->__memlistGetRefCount__(pResource);
172 }
173
memlistAddAdditionalDependants_DISPATCH(struct RsClient * pClient,struct MemoryList * pResource,RsResourceRef * pReference)174 static inline void memlistAddAdditionalDependants_DISPATCH(struct RsClient *pClient, struct MemoryList *pResource, RsResourceRef *pReference) {
175 pResource->__memlistAddAdditionalDependants__(pClient, pResource, pReference);
176 }
177
memlistControl_Prologue_DISPATCH(struct MemoryList * pResource,CALL_CONTEXT * pCallContext,struct RS_RES_CONTROL_PARAMS_INTERNAL * pParams)178 static inline NV_STATUS memlistControl_Prologue_DISPATCH(struct MemoryList *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
179 return pResource->__memlistControl_Prologue__(pResource, pCallContext, pParams);
180 }
181
memlistIsGpuMapAllowed_DISPATCH(struct MemoryList * pMemory,struct OBJGPU * pGpu)182 static inline NvBool memlistIsGpuMapAllowed_DISPATCH(struct MemoryList *pMemory, struct OBJGPU *pGpu) {
183 return pMemory->__memlistIsGpuMapAllowed__(pMemory, pGpu);
184 }
185
memlistUnmapFrom_DISPATCH(struct MemoryList * pResource,RS_RES_UNMAP_FROM_PARAMS * pParams)186 static inline NV_STATUS memlistUnmapFrom_DISPATCH(struct MemoryList *pResource, RS_RES_UNMAP_FROM_PARAMS *pParams) {
187 return pResource->__memlistUnmapFrom__(pResource, pParams);
188 }
189
memlistControl_Epilogue_DISPATCH(struct MemoryList * pResource,CALL_CONTEXT * pCallContext,struct RS_RES_CONTROL_PARAMS_INTERNAL * pParams)190 static inline void memlistControl_Epilogue_DISPATCH(struct MemoryList *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
191 pResource->__memlistControl_Epilogue__(pResource, pCallContext, pParams);
192 }
193
memlistControl_DISPATCH(struct MemoryList * pMemory,CALL_CONTEXT * pCallContext,struct RS_RES_CONTROL_PARAMS_INTERNAL * pParams)194 static inline NV_STATUS memlistControl_DISPATCH(struct MemoryList *pMemory, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
195 return pMemory->__memlistControl__(pMemory, pCallContext, pParams);
196 }
197
memlistUnmap_DISPATCH(struct MemoryList * pMemory,CALL_CONTEXT * pCallContext,RsCpuMapping * pCpuMapping)198 static inline NV_STATUS memlistUnmap_DISPATCH(struct MemoryList *pMemory, CALL_CONTEXT *pCallContext, RsCpuMapping *pCpuMapping) {
199 return pMemory->__memlistUnmap__(pMemory, pCallContext, pCpuMapping);
200 }
201
memlistGetMemInterMapParams_DISPATCH(struct MemoryList * pMemory,RMRES_MEM_INTER_MAP_PARAMS * pParams)202 static inline NV_STATUS memlistGetMemInterMapParams_DISPATCH(struct MemoryList *pMemory, RMRES_MEM_INTER_MAP_PARAMS *pParams) {
203 return pMemory->__memlistGetMemInterMapParams__(pMemory, pParams);
204 }
205
memlistGetMemoryMappingDescriptor_DISPATCH(struct MemoryList * pMemory,MEMORY_DESCRIPTOR ** ppMemDesc)206 static inline NV_STATUS memlistGetMemoryMappingDescriptor_DISPATCH(struct MemoryList *pMemory, MEMORY_DESCRIPTOR **ppMemDesc) {
207 return pMemory->__memlistGetMemoryMappingDescriptor__(pMemory, ppMemDesc);
208 }
209
memlistControlFilter_DISPATCH(struct MemoryList * pResource,struct CALL_CONTEXT * pCallContext,struct RS_RES_CONTROL_PARAMS_INTERNAL * pParams)210 static inline NV_STATUS memlistControlFilter_DISPATCH(struct MemoryList *pResource, struct CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
211 return pResource->__memlistControlFilter__(pResource, pCallContext, pParams);
212 }
213
memlistControlSerialization_Prologue_DISPATCH(struct MemoryList * pResource,CALL_CONTEXT * pCallContext,struct RS_RES_CONTROL_PARAMS_INTERNAL * pParams)214 static inline NV_STATUS memlistControlSerialization_Prologue_DISPATCH(struct MemoryList *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
215 return pResource->__memlistControlSerialization_Prologue__(pResource, pCallContext, pParams);
216 }
217
memlistIsPartialUnmapSupported_DISPATCH(struct MemoryList * pResource)218 static inline NvBool memlistIsPartialUnmapSupported_DISPATCH(struct MemoryList *pResource) {
219 return pResource->__memlistIsPartialUnmapSupported__(pResource);
220 }
221
memlistIsReady_DISPATCH(struct MemoryList * pMemory,NvBool bCopyConstructorContext)222 static inline NV_STATUS memlistIsReady_DISPATCH(struct MemoryList *pMemory, NvBool bCopyConstructorContext) {
223 return pMemory->__memlistIsReady__(pMemory, bCopyConstructorContext);
224 }
225
memlistCheckCopyPermissions_DISPATCH(struct MemoryList * pMemory,struct OBJGPU * pDstGpu,struct Device * pDstDevice)226 static inline NV_STATUS memlistCheckCopyPermissions_DISPATCH(struct MemoryList *pMemory, struct OBJGPU *pDstGpu, struct Device *pDstDevice) {
227 return pMemory->__memlistCheckCopyPermissions__(pMemory, pDstGpu, pDstDevice);
228 }
229
memlistPreDestruct_DISPATCH(struct MemoryList * pResource)230 static inline void memlistPreDestruct_DISPATCH(struct MemoryList *pResource) {
231 pResource->__memlistPreDestruct__(pResource);
232 }
233
memlistIsDuplicate_DISPATCH(struct MemoryList * pMemory,NvHandle hMemory,NvBool * pDuplicate)234 static inline NV_STATUS memlistIsDuplicate_DISPATCH(struct MemoryList *pMemory, NvHandle hMemory, NvBool *pDuplicate) {
235 return pMemory->__memlistIsDuplicate__(pMemory, hMemory, pDuplicate);
236 }
237
memlistControlSerialization_Epilogue_DISPATCH(struct MemoryList * pResource,CALL_CONTEXT * pCallContext,struct RS_RES_CONTROL_PARAMS_INTERNAL * pParams)238 static inline void memlistControlSerialization_Epilogue_DISPATCH(struct MemoryList *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
239 pResource->__memlistControlSerialization_Epilogue__(pResource, pCallContext, pParams);
240 }
241
memlistMap_DISPATCH(struct MemoryList * pMemory,CALL_CONTEXT * pCallContext,struct RS_CPU_MAP_PARAMS * pParams,RsCpuMapping * pCpuMapping)242 static inline NV_STATUS memlistMap_DISPATCH(struct MemoryList *pMemory, CALL_CONTEXT *pCallContext, struct RS_CPU_MAP_PARAMS *pParams, RsCpuMapping *pCpuMapping) {
243 return pMemory->__memlistMap__(pMemory, pCallContext, pParams, pCpuMapping);
244 }
245
memlistAccessCallback_DISPATCH(struct MemoryList * pResource,struct RsClient * pInvokingClient,void * pAllocParams,RsAccessRight accessRight)246 static inline NvBool memlistAccessCallback_DISPATCH(struct MemoryList *pResource, struct RsClient *pInvokingClient, void *pAllocParams, RsAccessRight accessRight) {
247 return pResource->__memlistAccessCallback__(pResource, pInvokingClient, pAllocParams, accessRight);
248 }
249
250 NV_STATUS memlistConstruct_IMPL(struct MemoryList *arg_pMemoryList, CALL_CONTEXT *arg_pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL *arg_pParams);
251
252 #define __nvoc_memlistConstruct(arg_pMemoryList, arg_pCallContext, arg_pParams) memlistConstruct_IMPL(arg_pMemoryList, arg_pCallContext, arg_pParams)
253 #undef PRIVATE_FIELD
254
255
256 #endif
257
258 #ifdef __cplusplus
259 } // extern "C"
260 #endif
261
262 #endif // _G_MEM_LIST_NVOC_H_
263