1 #ifndef _G_HYPERVISOR_NVOC_H_
2 #define _G_HYPERVISOR_NVOC_H_
3 #include "nvoc/runtime.h"
4
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
9 /*
10 * SPDX-FileCopyrightText: Copyright (c) 2014-2022 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 #include "g_hypervisor_nvoc.h"
32
33 #ifndef HYPERVISOR_H
34 #define HYPERVISOR_H
35
36 /**************** Resource Manager Defines and Structures ******************\
37 * *
38 * Module: hypervisor.h *
39 * Defines and structures used for the hypervisor object. *
40 \***************************************************************************/
41
42 #include "core/core.h"
43 #include "nvoc/utility.h"
44 #include "nv-hypervisor.h"
45 #include "mem_mgr/mem.h"
46
47 /* ------------------------ Forward Declarations ---------------------------- */
48 struct OBJOS;
49
50 #ifndef __NVOC_CLASS_OBJOS_TYPEDEF__
51 #define __NVOC_CLASS_OBJOS_TYPEDEF__
52 typedef struct OBJOS OBJOS;
53 #endif /* __NVOC_CLASS_OBJOS_TYPEDEF__ */
54
55 #ifndef __nvoc_class_id_OBJOS
56 #define __nvoc_class_id_OBJOS 0xaa1d70
57 #endif /* __nvoc_class_id_OBJOS */
58
59
60
61 typedef struct OBJHYPERVISOR *POBJHYPERVISOR;
62
63 #ifndef __NVOC_CLASS_OBJHYPERVISOR_TYPEDEF__
64 #define __NVOC_CLASS_OBJHYPERVISOR_TYPEDEF__
65 typedef struct OBJHYPERVISOR OBJHYPERVISOR;
66 #endif /* __NVOC_CLASS_OBJHYPERVISOR_TYPEDEF__ */
67
68 #ifndef __nvoc_class_id_OBJHYPERVISOR
69 #define __nvoc_class_id_OBJHYPERVISOR 0x33c1ba
70 #endif /* __nvoc_class_id_OBJHYPERVISOR */
71
72
73 typedef struct HOST_VGPU_DEVICE HOST_VGPU_DEVICE;
74
75
76 // Private field names are wrapped in PRIVATE_FIELD, which does nothing for
77 // the matching C source file, but causes diagnostics to be issued if another
78 // source file references the field.
79 #ifdef NVOC_HYPERVISOR_H_PRIVATE_ACCESS_ALLOWED
80 #define PRIVATE_FIELD(x) x
81 #else
82 #define PRIVATE_FIELD(x) NVOC_PRIVATE_FIELD(x)
83 #endif
84
85 struct OBJHYPERVISOR {
86 const struct NVOC_RTTI *__nvoc_rtti;
87 struct Object __nvoc_base_Object;
88 struct Object *__nvoc_pbase_Object;
89 struct OBJHYPERVISOR *__nvoc_pbase_OBJHYPERVISOR;
90 NvBool PDB_PROP_HYPERVISOR_DRIVERVM_ENABLED;
91 NvBool bDetected;
92 NvBool bIsHVMGuest;
93 HYPERVISOR_TYPE type;
94 NvBool bIsHypervHost;
95 NvBool bIsHypervVgpuSupported;
96 };
97
98 #ifndef __NVOC_CLASS_OBJHYPERVISOR_TYPEDEF__
99 #define __NVOC_CLASS_OBJHYPERVISOR_TYPEDEF__
100 typedef struct OBJHYPERVISOR OBJHYPERVISOR;
101 #endif /* __NVOC_CLASS_OBJHYPERVISOR_TYPEDEF__ */
102
103 #ifndef __nvoc_class_id_OBJHYPERVISOR
104 #define __nvoc_class_id_OBJHYPERVISOR 0x33c1ba
105 #endif /* __nvoc_class_id_OBJHYPERVISOR */
106
107 extern const struct NVOC_CLASS_DEF __nvoc_class_def_OBJHYPERVISOR;
108
109 #define __staticCast_OBJHYPERVISOR(pThis) \
110 ((pThis)->__nvoc_pbase_OBJHYPERVISOR)
111
112 #ifdef __nvoc_hypervisor_h_disabled
113 #define __dynamicCast_OBJHYPERVISOR(pThis) ((OBJHYPERVISOR*)NULL)
114 #else //__nvoc_hypervisor_h_disabled
115 #define __dynamicCast_OBJHYPERVISOR(pThis) \
116 ((OBJHYPERVISOR*)__nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(OBJHYPERVISOR)))
117 #endif //__nvoc_hypervisor_h_disabled
118
119 #define PDB_PROP_HYPERVISOR_DRIVERVM_ENABLED_BASE_CAST
120 #define PDB_PROP_HYPERVISOR_DRIVERVM_ENABLED_BASE_NAME PDB_PROP_HYPERVISOR_DRIVERVM_ENABLED
121
122 NV_STATUS __nvoc_objCreateDynamic_OBJHYPERVISOR(OBJHYPERVISOR**, Dynamic*, NvU32, va_list);
123
124 NV_STATUS __nvoc_objCreate_OBJHYPERVISOR(OBJHYPERVISOR**, Dynamic*, NvU32);
125 #define __objCreate_OBJHYPERVISOR(ppNewObj, pParent, createFlags) \
126 __nvoc_objCreate_OBJHYPERVISOR((ppNewObj), staticCast((pParent), Dynamic), (createFlags))
127
128 NvBool hypervisorIsVgxHyper_IMPL(void);
129
130
131 #define hypervisorIsVgxHyper() hypervisorIsVgxHyper_IMPL()
132 #define hypervisorIsVgxHyper_HAL() hypervisorIsVgxHyper()
133
134 NV_STATUS hypervisorInjectInterrupt_IMPL(struct OBJHYPERVISOR *arg0, VGPU_NS_INTR *arg1);
135
136
137 #ifdef __nvoc_hypervisor_h_disabled
hypervisorInjectInterrupt(struct OBJHYPERVISOR * arg0,VGPU_NS_INTR * arg1)138 static inline NV_STATUS hypervisorInjectInterrupt(struct OBJHYPERVISOR *arg0, VGPU_NS_INTR *arg1) {
139 NV_ASSERT_FAILED_PRECOMP("OBJHYPERVISOR was disabled!");
140 return NV_ERR_NOT_SUPPORTED;
141 }
142 #else //__nvoc_hypervisor_h_disabled
143 #define hypervisorInjectInterrupt(arg0, arg1) hypervisorInjectInterrupt_IMPL(arg0, arg1)
144 #endif //__nvoc_hypervisor_h_disabled
145
146 #define hypervisorInjectInterrupt_HAL(arg0, arg1) hypervisorInjectInterrupt(arg0, arg1)
147
148 void hypervisorSetHypervVgpuSupported_IMPL(struct OBJHYPERVISOR *arg0);
149
150
151 #ifdef __nvoc_hypervisor_h_disabled
hypervisorSetHypervVgpuSupported(struct OBJHYPERVISOR * arg0)152 static inline void hypervisorSetHypervVgpuSupported(struct OBJHYPERVISOR *arg0) {
153 NV_ASSERT_FAILED_PRECOMP("OBJHYPERVISOR was disabled!");
154 }
155 #else //__nvoc_hypervisor_h_disabled
156 #define hypervisorSetHypervVgpuSupported(arg0) hypervisorSetHypervVgpuSupported_IMPL(arg0)
157 #endif //__nvoc_hypervisor_h_disabled
158
159 #define hypervisorSetHypervVgpuSupported_HAL(arg0) hypervisorSetHypervVgpuSupported(arg0)
160
161 NvBool hypervisorCheckForObjectAccess_IMPL(NvHandle hClient);
162
163 #define hypervisorCheckForObjectAccess(hClient) hypervisorCheckForObjectAccess_IMPL(hClient)
164 NvBool hypervisorIsType_IMPL(HYPERVISOR_TYPE hyperType);
165
166 #define hypervisorIsType(hyperType) hypervisorIsType_IMPL(hyperType)
167 NV_STATUS hypervisorConstruct_IMPL(struct OBJHYPERVISOR *arg_);
168
169 #define __nvoc_hypervisorConstruct(arg_) hypervisorConstruct_IMPL(arg_)
170 void hypervisorDestruct_IMPL(struct OBJHYPERVISOR *arg0);
171
172 #define __nvoc_hypervisorDestruct(arg0) hypervisorDestruct_IMPL(arg0)
173 NV_STATUS hypervisorDetection_IMPL(struct OBJHYPERVISOR *arg0, struct OBJOS *arg1);
174
175 #ifdef __nvoc_hypervisor_h_disabled
hypervisorDetection(struct OBJHYPERVISOR * arg0,struct OBJOS * arg1)176 static inline NV_STATUS hypervisorDetection(struct OBJHYPERVISOR *arg0, struct OBJOS *arg1) {
177 NV_ASSERT_FAILED_PRECOMP("OBJHYPERVISOR was disabled!");
178 return NV_ERR_NOT_SUPPORTED;
179 }
180 #else //__nvoc_hypervisor_h_disabled
181 #define hypervisorDetection(arg0, arg1) hypervisorDetection_IMPL(arg0, arg1)
182 #endif //__nvoc_hypervisor_h_disabled
183
184 NvBool hypervisorPcieP2pDetection_IMPL(struct OBJHYPERVISOR *arg0, NvU32 arg1);
185
186 #ifdef __nvoc_hypervisor_h_disabled
hypervisorPcieP2pDetection(struct OBJHYPERVISOR * arg0,NvU32 arg1)187 static inline NvBool hypervisorPcieP2pDetection(struct OBJHYPERVISOR *arg0, NvU32 arg1) {
188 NV_ASSERT_FAILED_PRECOMP("OBJHYPERVISOR was disabled!");
189 return NV_FALSE;
190 }
191 #else //__nvoc_hypervisor_h_disabled
192 #define hypervisorPcieP2pDetection(arg0, arg1) hypervisorPcieP2pDetection_IMPL(arg0, arg1)
193 #endif //__nvoc_hypervisor_h_disabled
194
195 HYPERVISOR_TYPE hypervisorGetHypervisorType_IMPL(struct OBJHYPERVISOR *arg0);
196
197 #ifdef __nvoc_hypervisor_h_disabled
hypervisorGetHypervisorType(struct OBJHYPERVISOR * arg0)198 static inline HYPERVISOR_TYPE hypervisorGetHypervisorType(struct OBJHYPERVISOR *arg0) {
199 NV_ASSERT_FAILED_PRECOMP("OBJHYPERVISOR was disabled!");
200 HYPERVISOR_TYPE ret;
201 portMemSet(&ret, 0, sizeof(HYPERVISOR_TYPE));
202 return ret;
203 }
204 #else //__nvoc_hypervisor_h_disabled
205 #define hypervisorGetHypervisorType(arg0) hypervisorGetHypervisorType_IMPL(arg0)
206 #endif //__nvoc_hypervisor_h_disabled
207
208 void hypervisorSetHypervisorType_IMPL(struct OBJHYPERVISOR *pHypervisor, HYPERVISOR_TYPE type);
209
210 #ifdef __nvoc_hypervisor_h_disabled
hypervisorSetHypervisorType(struct OBJHYPERVISOR * pHypervisor,HYPERVISOR_TYPE type)211 static inline void hypervisorSetHypervisorType(struct OBJHYPERVISOR *pHypervisor, HYPERVISOR_TYPE type) {
212 NV_ASSERT_FAILED_PRECOMP("OBJHYPERVISOR was disabled!");
213 }
214 #else //__nvoc_hypervisor_h_disabled
215 #define hypervisorSetHypervisorType(pHypervisor, type) hypervisorSetHypervisorType_IMPL(pHypervisor, type)
216 #endif //__nvoc_hypervisor_h_disabled
217
218 #undef PRIVATE_FIELD
219
220
221 #ifdef HAVE_DESIGNATED_INITIALIZERS
222 #define SFINIT(f, v) f = v
223 #else
224 #define SFINIT(f, v) v
225 #endif
226
227 // OPS for different hypervisor operations at runtime
228
229 //
230 // A hypervisor specific function for post detection (after hypervisor type
231 // has been identified). As the post detection, there could be hypervisor
232 // specific requirement to detect root/parent/child partition.
233 //
234 typedef NV_STATUS (*HypervisorPostDetection)(struct OBJOS *, NvBool *);
235
236 //
237 // A hypervisor specific function to identify if a hypervisor
238 // is allowed to run GPUs present in the mask (in: param) under
239 // PCI-E P2P configuration
240 //
241 typedef NvBool (*HypervisorIsPcieP2PSupported)(NvU32);
242
243 typedef struct _hypervisor_ops
244 {
245 const char *hypervisorName;
246 const char *hypervisorSig;
247 HypervisorPostDetection hypervisorPostDetection;
248 HypervisorIsPcieP2PSupported hypervisorIsPcieP2PSupported;
249 } HYPERVISOR_OPS, *PHYPERVISOR_OPS;
250
251 extern HYPERVISOR_OPS kvmHypervisorOps;
252 extern HYPERVISOR_OPS xenHypervisorOps;
253 extern HYPERVISOR_OPS hypervHypervisorOps;
254 extern HYPERVISOR_OPS vmwareHypervisorOps;
255
256 #endif // HYPERVISOR_H
257
258 #ifdef __cplusplus
259 } // extern "C"
260 #endif
261
262 #endif // _G_HYPERVISOR_NVOC_H_
263