1 #ifndef _G_FLA_MEM_NVOC_H_
2 #define _G_FLA_MEM_NVOC_H_
3 #include "nvoc/runtime.h"
4 
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8 
9 /*
10  * SPDX-FileCopyrightText: Copyright (c) 2018-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_fla_mem_nvoc.h"
33 
34 #ifndef _FLA_MEMORY_H_
35 #define _FLA_MEMORY_H_
36 
37 #include "mem_mgr/mem.h"
38 
39 /*!
40  * This class is used by the FLA clients to allocate FLA memory handle
41  */
42 #ifdef NVOC_FLA_MEM_H_PRIVATE_ACCESS_ALLOWED
43 #define PRIVATE_FIELD(x) x
44 #else
45 #define PRIVATE_FIELD(x) NVOC_PRIVATE_FIELD(x)
46 #endif
47 struct FlaMemory {
48     const struct NVOC_RTTI *__nvoc_rtti;
49     struct Memory __nvoc_base_Memory;
50     struct Object *__nvoc_pbase_Object;
51     struct RsResource *__nvoc_pbase_RsResource;
52     struct RmResourceCommon *__nvoc_pbase_RmResourceCommon;
53     struct RmResource *__nvoc_pbase_RmResource;
54     struct Memory *__nvoc_pbase_Memory;
55     struct FlaMemory *__nvoc_pbase_FlaMemory;
56     NvBool (*__flamemCanCopy__)(struct FlaMemory *);
57     NV_STATUS (*__flamemCopyConstruct__)(struct FlaMemory *, CALL_CONTEXT *, struct RS_RES_ALLOC_PARAMS_INTERNAL *);
58     NV_STATUS (*__flamemCheckMemInterUnmap__)(struct FlaMemory *, NvBool);
59     NvBool (*__flamemShareCallback__)(struct FlaMemory *, struct RsClient *, struct RsResourceRef *, RS_SHARE_POLICY *);
60     NV_STATUS (*__flamemMapTo__)(struct FlaMemory *, RS_RES_MAP_TO_PARAMS *);
61     NV_STATUS (*__flamemGetMapAddrSpace__)(struct FlaMemory *, CALL_CONTEXT *, NvU32, NV_ADDRESS_SPACE *);
62     NvBool (*__flamemIsExportAllowed__)(struct FlaMemory *);
63     NvU32 (*__flamemGetRefCount__)(struct FlaMemory *);
64     void (*__flamemAddAdditionalDependants__)(struct RsClient *, struct FlaMemory *, RsResourceRef *);
65     NV_STATUS (*__flamemControl_Prologue__)(struct FlaMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
66     NvBool (*__flamemIsGpuMapAllowed__)(struct FlaMemory *, struct OBJGPU *);
67     NV_STATUS (*__flamemUnmapFrom__)(struct FlaMemory *, RS_RES_UNMAP_FROM_PARAMS *);
68     void (*__flamemControl_Epilogue__)(struct FlaMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
69     NV_STATUS (*__flamemControlLookup__)(struct FlaMemory *, struct RS_RES_CONTROL_PARAMS_INTERNAL *, const struct NVOC_EXPORTED_METHOD_DEF **);
70     NV_STATUS (*__flamemControl__)(struct FlaMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
71     NV_STATUS (*__flamemUnmap__)(struct FlaMemory *, CALL_CONTEXT *, RsCpuMapping *);
72     NV_STATUS (*__flamemGetMemInterMapParams__)(struct FlaMemory *, RMRES_MEM_INTER_MAP_PARAMS *);
73     NV_STATUS (*__flamemGetMemoryMappingDescriptor__)(struct FlaMemory *, MEMORY_DESCRIPTOR **);
74     NV_STATUS (*__flamemControlFilter__)(struct FlaMemory *, struct CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
75     NV_STATUS (*__flamemControlSerialization_Prologue__)(struct FlaMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
76     NV_STATUS (*__flamemIsReady__)(struct FlaMemory *, NvBool);
77     NV_STATUS (*__flamemCheckCopyPermissions__)(struct FlaMemory *, struct OBJGPU *, struct Device *);
78     void (*__flamemPreDestruct__)(struct FlaMemory *);
79     NV_STATUS (*__flamemIsDuplicate__)(struct FlaMemory *, NvHandle, NvBool *);
80     void (*__flamemControlSerialization_Epilogue__)(struct FlaMemory *, CALL_CONTEXT *, struct RS_RES_CONTROL_PARAMS_INTERNAL *);
81     NV_STATUS (*__flamemMap__)(struct FlaMemory *, CALL_CONTEXT *, struct RS_CPU_MAP_PARAMS *, RsCpuMapping *);
82     NvBool (*__flamemAccessCallback__)(struct FlaMemory *, struct RsClient *, void *, RsAccessRight);
83     NvU32 peerDeviceInst;
84     NvU32 peerGpuInst;
85     NvHandle hDupedExportMemory;
86 };
87 
88 #ifndef __NVOC_CLASS_FlaMemory_TYPEDEF__
89 #define __NVOC_CLASS_FlaMemory_TYPEDEF__
90 typedef struct FlaMemory FlaMemory;
91 #endif /* __NVOC_CLASS_FlaMemory_TYPEDEF__ */
92 
93 #ifndef __nvoc_class_id_FlaMemory
94 #define __nvoc_class_id_FlaMemory 0xe61ee1
95 #endif /* __nvoc_class_id_FlaMemory */
96 
97 extern const struct NVOC_CLASS_DEF __nvoc_class_def_FlaMemory;
98 
99 #define __staticCast_FlaMemory(pThis) \
100     ((pThis)->__nvoc_pbase_FlaMemory)
101 
102 #ifdef __nvoc_fla_mem_h_disabled
103 #define __dynamicCast_FlaMemory(pThis) ((FlaMemory*)NULL)
104 #else //__nvoc_fla_mem_h_disabled
105 #define __dynamicCast_FlaMemory(pThis) \
106     ((FlaMemory*)__nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(FlaMemory)))
107 #endif //__nvoc_fla_mem_h_disabled
108 
109 
110 NV_STATUS __nvoc_objCreateDynamic_FlaMemory(FlaMemory**, Dynamic*, NvU32, va_list);
111 
112 NV_STATUS __nvoc_objCreate_FlaMemory(FlaMemory**, Dynamic*, NvU32, CALL_CONTEXT * arg_pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL * arg_pParams);
113 #define __objCreate_FlaMemory(ppNewObj, pParent, createFlags, arg_pCallContext, arg_pParams) \
114     __nvoc_objCreate_FlaMemory((ppNewObj), staticCast((pParent), Dynamic), (createFlags), arg_pCallContext, arg_pParams)
115 
116 #define flamemCanCopy(pFlaMemory) flamemCanCopy_DISPATCH(pFlaMemory)
117 #define flamemCopyConstruct(pFlaMemory, pCallContext, pParams) flamemCopyConstruct_DISPATCH(pFlaMemory, pCallContext, pParams)
118 #define flamemCheckMemInterUnmap(pMemory, bSubdeviceHandleProvided) flamemCheckMemInterUnmap_DISPATCH(pMemory, bSubdeviceHandleProvided)
119 #define flamemShareCallback(pResource, pInvokingClient, pParentRef, pSharePolicy) flamemShareCallback_DISPATCH(pResource, pInvokingClient, pParentRef, pSharePolicy)
120 #define flamemMapTo(pResource, pParams) flamemMapTo_DISPATCH(pResource, pParams)
121 #define flamemGetMapAddrSpace(pMemory, pCallContext, mapFlags, pAddrSpace) flamemGetMapAddrSpace_DISPATCH(pMemory, pCallContext, mapFlags, pAddrSpace)
122 #define flamemIsExportAllowed(pMemory) flamemIsExportAllowed_DISPATCH(pMemory)
123 #define flamemGetRefCount(pResource) flamemGetRefCount_DISPATCH(pResource)
124 #define flamemAddAdditionalDependants(pClient, pResource, pReference) flamemAddAdditionalDependants_DISPATCH(pClient, pResource, pReference)
125 #define flamemControl_Prologue(pResource, pCallContext, pParams) flamemControl_Prologue_DISPATCH(pResource, pCallContext, pParams)
126 #define flamemIsGpuMapAllowed(pMemory, pGpu) flamemIsGpuMapAllowed_DISPATCH(pMemory, pGpu)
127 #define flamemUnmapFrom(pResource, pParams) flamemUnmapFrom_DISPATCH(pResource, pParams)
128 #define flamemControl_Epilogue(pResource, pCallContext, pParams) flamemControl_Epilogue_DISPATCH(pResource, pCallContext, pParams)
129 #define flamemControlLookup(pResource, pParams, ppEntry) flamemControlLookup_DISPATCH(pResource, pParams, ppEntry)
130 #define flamemControl(pMemory, pCallContext, pParams) flamemControl_DISPATCH(pMemory, pCallContext, pParams)
131 #define flamemUnmap(pMemory, pCallContext, pCpuMapping) flamemUnmap_DISPATCH(pMemory, pCallContext, pCpuMapping)
132 #define flamemGetMemInterMapParams(pMemory, pParams) flamemGetMemInterMapParams_DISPATCH(pMemory, pParams)
133 #define flamemGetMemoryMappingDescriptor(pMemory, ppMemDesc) flamemGetMemoryMappingDescriptor_DISPATCH(pMemory, ppMemDesc)
134 #define flamemControlFilter(pResource, pCallContext, pParams) flamemControlFilter_DISPATCH(pResource, pCallContext, pParams)
135 #define flamemControlSerialization_Prologue(pResource, pCallContext, pParams) flamemControlSerialization_Prologue_DISPATCH(pResource, pCallContext, pParams)
136 #define flamemIsReady(pMemory, bCopyConstructorContext) flamemIsReady_DISPATCH(pMemory, bCopyConstructorContext)
137 #define flamemCheckCopyPermissions(pMemory, pDstGpu, pDstDevice) flamemCheckCopyPermissions_DISPATCH(pMemory, pDstGpu, pDstDevice)
138 #define flamemPreDestruct(pResource) flamemPreDestruct_DISPATCH(pResource)
139 #define flamemIsDuplicate(pMemory, hMemory, pDuplicate) flamemIsDuplicate_DISPATCH(pMemory, hMemory, pDuplicate)
140 #define flamemControlSerialization_Epilogue(pResource, pCallContext, pParams) flamemControlSerialization_Epilogue_DISPATCH(pResource, pCallContext, pParams)
141 #define flamemMap(pMemory, pCallContext, pParams, pCpuMapping) flamemMap_DISPATCH(pMemory, pCallContext, pParams, pCpuMapping)
142 #define flamemAccessCallback(pResource, pInvokingClient, pAllocParams, accessRight) flamemAccessCallback_DISPATCH(pResource, pInvokingClient, pAllocParams, accessRight)
143 NvBool flamemCanCopy_IMPL(struct FlaMemory *pFlaMemory);
144 
145 static inline NvBool flamemCanCopy_DISPATCH(struct FlaMemory *pFlaMemory) {
146     return pFlaMemory->__flamemCanCopy__(pFlaMemory);
147 }
148 
149 NV_STATUS flamemCopyConstruct_IMPL(struct FlaMemory *pFlaMemory, CALL_CONTEXT *pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL *pParams);
150 
151 static inline NV_STATUS flamemCopyConstruct_DISPATCH(struct FlaMemory *pFlaMemory, CALL_CONTEXT *pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL *pParams) {
152     return pFlaMemory->__flamemCopyConstruct__(pFlaMemory, pCallContext, pParams);
153 }
154 
155 static inline NV_STATUS flamemCheckMemInterUnmap_DISPATCH(struct FlaMemory *pMemory, NvBool bSubdeviceHandleProvided) {
156     return pMemory->__flamemCheckMemInterUnmap__(pMemory, bSubdeviceHandleProvided);
157 }
158 
159 static inline NvBool flamemShareCallback_DISPATCH(struct FlaMemory *pResource, struct RsClient *pInvokingClient, struct RsResourceRef *pParentRef, RS_SHARE_POLICY *pSharePolicy) {
160     return pResource->__flamemShareCallback__(pResource, pInvokingClient, pParentRef, pSharePolicy);
161 }
162 
163 static inline NV_STATUS flamemMapTo_DISPATCH(struct FlaMemory *pResource, RS_RES_MAP_TO_PARAMS *pParams) {
164     return pResource->__flamemMapTo__(pResource, pParams);
165 }
166 
167 static inline NV_STATUS flamemGetMapAddrSpace_DISPATCH(struct FlaMemory *pMemory, CALL_CONTEXT *pCallContext, NvU32 mapFlags, NV_ADDRESS_SPACE *pAddrSpace) {
168     return pMemory->__flamemGetMapAddrSpace__(pMemory, pCallContext, mapFlags, pAddrSpace);
169 }
170 
171 static inline NvBool flamemIsExportAllowed_DISPATCH(struct FlaMemory *pMemory) {
172     return pMemory->__flamemIsExportAllowed__(pMemory);
173 }
174 
175 static inline NvU32 flamemGetRefCount_DISPATCH(struct FlaMemory *pResource) {
176     return pResource->__flamemGetRefCount__(pResource);
177 }
178 
179 static inline void flamemAddAdditionalDependants_DISPATCH(struct RsClient *pClient, struct FlaMemory *pResource, RsResourceRef *pReference) {
180     pResource->__flamemAddAdditionalDependants__(pClient, pResource, pReference);
181 }
182 
183 static inline NV_STATUS flamemControl_Prologue_DISPATCH(struct FlaMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
184     return pResource->__flamemControl_Prologue__(pResource, pCallContext, pParams);
185 }
186 
187 static inline NvBool flamemIsGpuMapAllowed_DISPATCH(struct FlaMemory *pMemory, struct OBJGPU *pGpu) {
188     return pMemory->__flamemIsGpuMapAllowed__(pMemory, pGpu);
189 }
190 
191 static inline NV_STATUS flamemUnmapFrom_DISPATCH(struct FlaMemory *pResource, RS_RES_UNMAP_FROM_PARAMS *pParams) {
192     return pResource->__flamemUnmapFrom__(pResource, pParams);
193 }
194 
195 static inline void flamemControl_Epilogue_DISPATCH(struct FlaMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
196     pResource->__flamemControl_Epilogue__(pResource, pCallContext, pParams);
197 }
198 
199 static inline NV_STATUS flamemControlLookup_DISPATCH(struct FlaMemory *pResource, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams, const struct NVOC_EXPORTED_METHOD_DEF **ppEntry) {
200     return pResource->__flamemControlLookup__(pResource, pParams, ppEntry);
201 }
202 
203 static inline NV_STATUS flamemControl_DISPATCH(struct FlaMemory *pMemory, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
204     return pMemory->__flamemControl__(pMemory, pCallContext, pParams);
205 }
206 
207 static inline NV_STATUS flamemUnmap_DISPATCH(struct FlaMemory *pMemory, CALL_CONTEXT *pCallContext, RsCpuMapping *pCpuMapping) {
208     return pMemory->__flamemUnmap__(pMemory, pCallContext, pCpuMapping);
209 }
210 
211 static inline NV_STATUS flamemGetMemInterMapParams_DISPATCH(struct FlaMemory *pMemory, RMRES_MEM_INTER_MAP_PARAMS *pParams) {
212     return pMemory->__flamemGetMemInterMapParams__(pMemory, pParams);
213 }
214 
215 static inline NV_STATUS flamemGetMemoryMappingDescriptor_DISPATCH(struct FlaMemory *pMemory, MEMORY_DESCRIPTOR **ppMemDesc) {
216     return pMemory->__flamemGetMemoryMappingDescriptor__(pMemory, ppMemDesc);
217 }
218 
219 static inline NV_STATUS flamemControlFilter_DISPATCH(struct FlaMemory *pResource, struct CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
220     return pResource->__flamemControlFilter__(pResource, pCallContext, pParams);
221 }
222 
223 static inline NV_STATUS flamemControlSerialization_Prologue_DISPATCH(struct FlaMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
224     return pResource->__flamemControlSerialization_Prologue__(pResource, pCallContext, pParams);
225 }
226 
227 static inline NV_STATUS flamemIsReady_DISPATCH(struct FlaMemory *pMemory, NvBool bCopyConstructorContext) {
228     return pMemory->__flamemIsReady__(pMemory, bCopyConstructorContext);
229 }
230 
231 static inline NV_STATUS flamemCheckCopyPermissions_DISPATCH(struct FlaMemory *pMemory, struct OBJGPU *pDstGpu, struct Device *pDstDevice) {
232     return pMemory->__flamemCheckCopyPermissions__(pMemory, pDstGpu, pDstDevice);
233 }
234 
235 static inline void flamemPreDestruct_DISPATCH(struct FlaMemory *pResource) {
236     pResource->__flamemPreDestruct__(pResource);
237 }
238 
239 static inline NV_STATUS flamemIsDuplicate_DISPATCH(struct FlaMemory *pMemory, NvHandle hMemory, NvBool *pDuplicate) {
240     return pMemory->__flamemIsDuplicate__(pMemory, hMemory, pDuplicate);
241 }
242 
243 static inline void flamemControlSerialization_Epilogue_DISPATCH(struct FlaMemory *pResource, CALL_CONTEXT *pCallContext, struct RS_RES_CONTROL_PARAMS_INTERNAL *pParams) {
244     pResource->__flamemControlSerialization_Epilogue__(pResource, pCallContext, pParams);
245 }
246 
247 static inline NV_STATUS flamemMap_DISPATCH(struct FlaMemory *pMemory, CALL_CONTEXT *pCallContext, struct RS_CPU_MAP_PARAMS *pParams, RsCpuMapping *pCpuMapping) {
248     return pMemory->__flamemMap__(pMemory, pCallContext, pParams, pCpuMapping);
249 }
250 
251 static inline NvBool flamemAccessCallback_DISPATCH(struct FlaMemory *pResource, struct RsClient *pInvokingClient, void *pAllocParams, RsAccessRight accessRight) {
252     return pResource->__flamemAccessCallback__(pResource, pInvokingClient, pAllocParams, accessRight);
253 }
254 
255 NV_STATUS flamemConstruct_IMPL(struct FlaMemory *arg_pFlaMemory, CALL_CONTEXT *arg_pCallContext, struct RS_RES_ALLOC_PARAMS_INTERNAL *arg_pParams);
256 
257 #define __nvoc_flamemConstruct(arg_pFlaMemory, arg_pCallContext, arg_pParams) flamemConstruct_IMPL(arg_pFlaMemory, arg_pCallContext, arg_pParams)
258 void flamemDestruct_IMPL(struct FlaMemory *pFlaMemory);
259 
260 #define __nvoc_flamemDestruct(pFlaMemory) flamemDestruct_IMPL(pFlaMemory)
261 #undef PRIVATE_FIELD
262 
263 
264 #endif
265 
266 #ifdef __cplusplus
267 } // extern "C"
268 #endif
269 
270 #endif // _G_FLA_MEM_NVOC_H_
271