1 #ifndef _G_GPU_BOOST_MGR_NVOC_H_ 2 #define _G_GPU_BOOST_MGR_NVOC_H_ 3 #include "nvoc/runtime.h" 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 /* 10 * SPDX-FileCopyrightText: Copyright (c) 2015-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 32 #include "g_gpu_boost_mgr_nvoc.h" 33 34 #ifndef GPU_BOOST_MGR_H 35 #define GPU_BOOST_MGR_H 36 37 /*! 38 * @file 39 * @brief Definition of the Sync Gpu Boost Manager object 40 */ 41 42 /* --------------------------- Includes --------------------------------------*/ 43 #include "core/core.h" 44 #include "core/system.h" 45 #include "ctrl/ctrl0000/ctrl0000syncgpuboost.h" // NV0000_SYNC_GPU_BOOST_MAX_GROUPS 46 47 #include "containers/btree.h" 48 #include "nvlimits.h" 49 50 /* ----------------------------- Macros --------------------------------------*/ 51 /*! 52 * This macro shall be used to iterate over all the GPUs in a Sync GPU Boost Group 53 * @param[in] pBoostMgr @ref OBJGPUBOOSTMGR pointer 54 * @param[in] grpId ID of the SGBG to loop over 55 * @param[in][out] pGpuItr Pointer to OBJGPU, used by the loop to iterate over. 56 * 57 * For every successful iteration, pGpuItr will point to the GPU being looped over. 58 * After all the iterations are complete, pGpuItr will be NULL. 59 */ 60 #define GPUBOOSTMGR_ITR_START(pBoostMgr, grpId, pGpuItr) \ 61 { \ 62 NvU32 itrIdx = 0; \ 63 NV_ASSERT(NULL != (pBoostMgr)); \ 64 while (NULL != ((pGpuItr) = gpuboostmgrGpuItr((pBoostMgr), (grpId), &(itrIdx)))) \ 65 { 66 67 #define GPUBOOSTMGR_ITR_END \ 68 } \ 69 } 70 71 /* --------------------------- Datatypes ------------------------------------ */ 72 73 /*! 74 * Defines a group of GPUs linked together for a synchronized workload. 75 * The linking is independent of the SLI status of the GPUs. 76 */ 77 typedef struct SYNC_GPU_BOOST_GROUP 78 { 79 // Number of elements in @ref gpuIds 80 NvU32 gpuCount; 81 82 // Number of clients holding a reference to this SGBG 83 NvU32 refCount; 84 85 // IDs of GPUs to be put in the Sync Boost Group 86 NvU32 gpuIds[NV_MAX_DEVICES]; 87 88 // If this group represents a bridgeless SLI 89 NvBool bBridgeless; 90 } SYNC_GPU_BOOST_GROUP; 91 92 typedef struct OBJGPUBOOSTMGR *POBJGPUBOOSTMGR; 93 94 /*! 95 * This is the Sync Gpu Boost Manager for RM. It keeps track of the 96 * Sync Gpu Boost Groups defined for the system and provides various methods related 97 * to their management. 98 */ 99 #ifdef NVOC_GPU_BOOST_MGR_H_PRIVATE_ACCESS_ALLOWED 100 #define PRIVATE_FIELD(x) x 101 #else 102 #define PRIVATE_FIELD(x) NVOC_PRIVATE_FIELD(x) 103 #endif 104 struct OBJGPUBOOSTMGR { 105 const struct NVOC_RTTI *__nvoc_rtti; 106 struct Object __nvoc_base_Object; 107 struct Object *__nvoc_pbase_Object; 108 struct OBJGPUBOOSTMGR *__nvoc_pbase_OBJGPUBOOSTMGR; 109 NODE *pGpuIdTree; 110 NvU32 groupCount; 111 SYNC_GPU_BOOST_GROUP pBoostGroups[16]; 112 }; 113 114 #ifndef __NVOC_CLASS_OBJGPUBOOSTMGR_TYPEDEF__ 115 #define __NVOC_CLASS_OBJGPUBOOSTMGR_TYPEDEF__ 116 typedef struct OBJGPUBOOSTMGR OBJGPUBOOSTMGR; 117 #endif /* __NVOC_CLASS_OBJGPUBOOSTMGR_TYPEDEF__ */ 118 119 #ifndef __nvoc_class_id_OBJGPUBOOSTMGR 120 #define __nvoc_class_id_OBJGPUBOOSTMGR 0x9f6bbf 121 #endif /* __nvoc_class_id_OBJGPUBOOSTMGR */ 122 123 extern const struct NVOC_CLASS_DEF __nvoc_class_def_OBJGPUBOOSTMGR; 124 125 #define __staticCast_OBJGPUBOOSTMGR(pThis) \ 126 ((pThis)->__nvoc_pbase_OBJGPUBOOSTMGR) 127 128 #ifdef __nvoc_gpu_boost_mgr_h_disabled 129 #define __dynamicCast_OBJGPUBOOSTMGR(pThis) ((OBJGPUBOOSTMGR*)NULL) 130 #else //__nvoc_gpu_boost_mgr_h_disabled 131 #define __dynamicCast_OBJGPUBOOSTMGR(pThis) \ 132 ((OBJGPUBOOSTMGR*)__nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(OBJGPUBOOSTMGR))) 133 #endif //__nvoc_gpu_boost_mgr_h_disabled 134 135 136 NV_STATUS __nvoc_objCreateDynamic_OBJGPUBOOSTMGR(OBJGPUBOOSTMGR**, Dynamic*, NvU32, va_list); 137 138 NV_STATUS __nvoc_objCreate_OBJGPUBOOSTMGR(OBJGPUBOOSTMGR**, Dynamic*, NvU32); 139 #define __objCreate_OBJGPUBOOSTMGR(ppNewObj, pParent, createFlags) \ 140 __nvoc_objCreate_OBJGPUBOOSTMGR((ppNewObj), staticCast((pParent), Dynamic), (createFlags)) 141 142 NV_STATUS gpuboostmgrConstruct_IMPL(struct OBJGPUBOOSTMGR *arg_pBoostMgr); 143 144 #define __nvoc_gpuboostmgrConstruct(arg_pBoostMgr) gpuboostmgrConstruct_IMPL(arg_pBoostMgr) 145 void gpuboostmgrDestruct_IMPL(struct OBJGPUBOOSTMGR *pBoostMgr); 146 147 #define __nvoc_gpuboostmgrDestruct(pBoostMgr) gpuboostmgrDestruct_IMPL(pBoostMgr) 148 NV_STATUS gpuboostmgrCreateGroup_IMPL(struct OBJGPUBOOSTMGR *pBoostMgr, NV0000_SYNC_GPU_BOOST_GROUP_CONFIG *pBoostConfig); 149 150 #ifdef __nvoc_gpu_boost_mgr_h_disabled 151 static inline NV_STATUS gpuboostmgrCreateGroup(struct OBJGPUBOOSTMGR *pBoostMgr, NV0000_SYNC_GPU_BOOST_GROUP_CONFIG *pBoostConfig) { 152 NV_ASSERT_FAILED_PRECOMP("OBJGPUBOOSTMGR was disabled!"); 153 return NV_ERR_NOT_SUPPORTED; 154 } 155 #else //__nvoc_gpu_boost_mgr_h_disabled 156 #define gpuboostmgrCreateGroup(pBoostMgr, pBoostConfig) gpuboostmgrCreateGroup_IMPL(pBoostMgr, pBoostConfig) 157 #endif //__nvoc_gpu_boost_mgr_h_disabled 158 159 NV_STATUS gpuboostmgrDestroyGroup_IMPL(struct OBJGPUBOOSTMGR *pBoostMgr, NvU32 boostGroupId); 160 161 #ifdef __nvoc_gpu_boost_mgr_h_disabled 162 static inline NV_STATUS gpuboostmgrDestroyGroup(struct OBJGPUBOOSTMGR *pBoostMgr, NvU32 boostGroupId) { 163 NV_ASSERT_FAILED_PRECOMP("OBJGPUBOOSTMGR was disabled!"); 164 return NV_ERR_NOT_SUPPORTED; 165 } 166 #else //__nvoc_gpu_boost_mgr_h_disabled 167 #define gpuboostmgrDestroyGroup(pBoostMgr, boostGroupId) gpuboostmgrDestroyGroup_IMPL(pBoostMgr, boostGroupId) 168 #endif //__nvoc_gpu_boost_mgr_h_disabled 169 170 NV_STATUS gpuboostmgrQueryGroups_IMPL(struct OBJGPUBOOSTMGR *pBoostMgr, NV0000_SYNC_GPU_BOOST_GROUP_INFO_PARAMS *pParams); 171 172 #ifdef __nvoc_gpu_boost_mgr_h_disabled 173 static inline NV_STATUS gpuboostmgrQueryGroups(struct OBJGPUBOOSTMGR *pBoostMgr, NV0000_SYNC_GPU_BOOST_GROUP_INFO_PARAMS *pParams) { 174 NV_ASSERT_FAILED_PRECOMP("OBJGPUBOOSTMGR was disabled!"); 175 return NV_ERR_NOT_SUPPORTED; 176 } 177 #else //__nvoc_gpu_boost_mgr_h_disabled 178 #define gpuboostmgrQueryGroups(pBoostMgr, pParams) gpuboostmgrQueryGroups_IMPL(pBoostMgr, pParams) 179 #endif //__nvoc_gpu_boost_mgr_h_disabled 180 181 NV_STATUS gpuboostmgrCheckConfig_IMPL(struct OBJGPUBOOSTMGR *pBoostMgr, NV0000_SYNC_GPU_BOOST_GROUP_CONFIG *pBoostConfig); 182 183 #ifdef __nvoc_gpu_boost_mgr_h_disabled 184 static inline NV_STATUS gpuboostmgrCheckConfig(struct OBJGPUBOOSTMGR *pBoostMgr, NV0000_SYNC_GPU_BOOST_GROUP_CONFIG *pBoostConfig) { 185 NV_ASSERT_FAILED_PRECOMP("OBJGPUBOOSTMGR was disabled!"); 186 return NV_ERR_NOT_SUPPORTED; 187 } 188 #else //__nvoc_gpu_boost_mgr_h_disabled 189 #define gpuboostmgrCheckConfig(pBoostMgr, pBoostConfig) gpuboostmgrCheckConfig_IMPL(pBoostMgr, pBoostConfig) 190 #endif //__nvoc_gpu_boost_mgr_h_disabled 191 192 NV_STATUS gpuboostmgrValidateGroupId_IMPL(struct OBJGPUBOOSTMGR *pBoostMgr, NvU32 boostGroupId); 193 194 #ifdef __nvoc_gpu_boost_mgr_h_disabled 195 static inline NV_STATUS gpuboostmgrValidateGroupId(struct OBJGPUBOOSTMGR *pBoostMgr, NvU32 boostGroupId) { 196 NV_ASSERT_FAILED_PRECOMP("OBJGPUBOOSTMGR was disabled!"); 197 return NV_ERR_NOT_SUPPORTED; 198 } 199 #else //__nvoc_gpu_boost_mgr_h_disabled 200 #define gpuboostmgrValidateGroupId(pBoostMgr, boostGroupId) gpuboostmgrValidateGroupId_IMPL(pBoostMgr, boostGroupId) 201 #endif //__nvoc_gpu_boost_mgr_h_disabled 202 203 NV_STATUS gpuboostmgrIncrementRefCount_IMPL(struct OBJGPUBOOSTMGR *pBoostMgr, NvU32 boostGroupId); 204 205 #ifdef __nvoc_gpu_boost_mgr_h_disabled 206 static inline NV_STATUS gpuboostmgrIncrementRefCount(struct OBJGPUBOOSTMGR *pBoostMgr, NvU32 boostGroupId) { 207 NV_ASSERT_FAILED_PRECOMP("OBJGPUBOOSTMGR was disabled!"); 208 return NV_ERR_NOT_SUPPORTED; 209 } 210 #else //__nvoc_gpu_boost_mgr_h_disabled 211 #define gpuboostmgrIncrementRefCount(pBoostMgr, boostGroupId) gpuboostmgrIncrementRefCount_IMPL(pBoostMgr, boostGroupId) 212 #endif //__nvoc_gpu_boost_mgr_h_disabled 213 214 NV_STATUS gpuboostmgrDecrementRefCount_IMPL(struct OBJGPUBOOSTMGR *pBoostMgr, NvU32 boostGroupId); 215 216 #ifdef __nvoc_gpu_boost_mgr_h_disabled 217 static inline NV_STATUS gpuboostmgrDecrementRefCount(struct OBJGPUBOOSTMGR *pBoostMgr, NvU32 boostGroupId) { 218 NV_ASSERT_FAILED_PRECOMP("OBJGPUBOOSTMGR was disabled!"); 219 return NV_ERR_NOT_SUPPORTED; 220 } 221 #else //__nvoc_gpu_boost_mgr_h_disabled 222 #define gpuboostmgrDecrementRefCount(pBoostMgr, boostGroupId) gpuboostmgrDecrementRefCount_IMPL(pBoostMgr, boostGroupId) 223 #endif //__nvoc_gpu_boost_mgr_h_disabled 224 225 OBJGPU *gpuboostmgrGpuItr_IMPL(struct OBJGPUBOOSTMGR *pBoostMgr, NvU32 grpId, NvU32 *pIndex); 226 227 #ifdef __nvoc_gpu_boost_mgr_h_disabled 228 static inline OBJGPU *gpuboostmgrGpuItr(struct OBJGPUBOOSTMGR *pBoostMgr, NvU32 grpId, NvU32 *pIndex) { 229 NV_ASSERT_FAILED_PRECOMP("OBJGPUBOOSTMGR was disabled!"); 230 return NULL; 231 } 232 #else //__nvoc_gpu_boost_mgr_h_disabled 233 #define gpuboostmgrGpuItr(pBoostMgr, grpId, pIndex) gpuboostmgrGpuItr_IMPL(pBoostMgr, grpId, pIndex) 234 #endif //__nvoc_gpu_boost_mgr_h_disabled 235 236 NV_STATUS gpuboostmgrGetBoostGrpIdFromGpu_IMPL(struct OBJGPUBOOSTMGR *pBoostMgr, OBJGPU *pGpu, NvU32 *pGrpId); 237 238 #ifdef __nvoc_gpu_boost_mgr_h_disabled 239 static inline NV_STATUS gpuboostmgrGetBoostGrpIdFromGpu(struct OBJGPUBOOSTMGR *pBoostMgr, OBJGPU *pGpu, NvU32 *pGrpId) { 240 NV_ASSERT_FAILED_PRECOMP("OBJGPUBOOSTMGR was disabled!"); 241 return NV_ERR_NOT_SUPPORTED; 242 } 243 #else //__nvoc_gpu_boost_mgr_h_disabled 244 #define gpuboostmgrGetBoostGrpIdFromGpu(pBoostMgr, pGpu, pGrpId) gpuboostmgrGetBoostGrpIdFromGpu_IMPL(pBoostMgr, pGpu, pGrpId) 245 #endif //__nvoc_gpu_boost_mgr_h_disabled 246 247 NvBool gpuboostmgrIsBoostGrpActive_IMPL(struct OBJGPUBOOSTMGR *pBoostMgr, NvU32 grpId); 248 249 #ifdef __nvoc_gpu_boost_mgr_h_disabled 250 static inline NvBool gpuboostmgrIsBoostGrpActive(struct OBJGPUBOOSTMGR *pBoostMgr, NvU32 grpId) { 251 NV_ASSERT_FAILED_PRECOMP("OBJGPUBOOSTMGR was disabled!"); 252 return NV_FALSE; 253 } 254 #else //__nvoc_gpu_boost_mgr_h_disabled 255 #define gpuboostmgrIsBoostGrpActive(pBoostMgr, grpId) gpuboostmgrIsBoostGrpActive_IMPL(pBoostMgr, grpId) 256 #endif //__nvoc_gpu_boost_mgr_h_disabled 257 258 #undef PRIVATE_FIELD 259 260 261 #endif // GPU_BOOST_MGR_H 262 263 #ifdef __cplusplus 264 } // extern "C" 265 #endif 266 #endif // _G_GPU_BOOST_MGR_NVOC_H_ 267