1 #ifndef _G_FABRIC_NVOC_H_
2 #define _G_FABRIC_NVOC_H_
3 #include "nvoc/runtime.h"
4 
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8 
9 /*
10  * SPDX-FileCopyrightText: Copyright (c) 2019-2023 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 /******************************************************************************
33  *
34  *   Description:
35  *       This file contains the functions managing the NVLink fabric
36  *
37  *****************************************************************************/
38 
39 #include "g_fabric_nvoc.h"
40 
41 #ifndef _FABRIC_H_
42 #define _FABRIC_H_
43 
44 #include "core/core.h"
45 #include "core/system.h"
46 #include "containers/multimap.h"
47 #include "containers/map.h"
48 #include "class/cl000f.h"
49 #include "ctrl/ctrl000f.h"
50 
51 
52 
53 // ****************************************************************************
54 //                          Type Definitions
55 // ****************************************************************************
56 
57 typedef struct
58 {
59     void *pData;
60 } FabricCacheMapEntry;
61 
62 MAKE_MAP(FabricCacheMap, FabricCacheMapEntry);
63 
64 typedef struct
65 {
66     FabricCacheMap map;
67 } FabricCacheEntry;
68 
69 MAKE_MULTIMAP(FabricCache, FabricCacheEntry);
70 
71 #include "nvlink_inband_msg.h"
72 
73 NV_STATUS fabricInitInbandMsgHdr(nvlink_inband_msg_header_t *pMsgHdr,
74                                  NvU32 type,
75                                  NvU32 len);
76 
77 void fabricMulticastWaitOnTeamCleanupCallback(void *pCbData);
78 
79 //
80 // The Fabric object is used to encapsulate the NVLink fabric
81 //
82 #ifdef NVOC_FABRIC_H_PRIVATE_ACCESS_ALLOWED
83 #define PRIVATE_FIELD(x) x
84 #else
85 #define PRIVATE_FIELD(x) NVOC_PRIVATE_FIELD(x)
86 #endif
87 struct Fabric {
88     const struct NVOC_RTTI *__nvoc_rtti;
89     struct Object __nvoc_base_Object;
90     struct Object *__nvoc_pbase_Object;
91     struct Fabric *__nvoc_pbase_Fabric;
92     NvU32 flags;
93     PORT_MUTEX *pMulticastFabricOpsMutex;
94     FabricCache fabricMulticastCache;
95 };
96 
97 #ifndef __NVOC_CLASS_Fabric_TYPEDEF__
98 #define __NVOC_CLASS_Fabric_TYPEDEF__
99 typedef struct Fabric Fabric;
100 #endif /* __NVOC_CLASS_Fabric_TYPEDEF__ */
101 
102 #ifndef __nvoc_class_id_Fabric
103 #define __nvoc_class_id_Fabric 0x0ac791
104 #endif /* __nvoc_class_id_Fabric */
105 
106 extern const struct NVOC_CLASS_DEF __nvoc_class_def_Fabric;
107 
108 #define __staticCast_Fabric(pThis) \
109     ((pThis)->__nvoc_pbase_Fabric)
110 
111 #ifdef __nvoc_fabric_h_disabled
112 #define __dynamicCast_Fabric(pThis) ((Fabric*)NULL)
113 #else //__nvoc_fabric_h_disabled
114 #define __dynamicCast_Fabric(pThis) \
115     ((Fabric*)__nvoc_dynamicCast(staticCast((pThis), Dynamic), classInfo(Fabric)))
116 #endif //__nvoc_fabric_h_disabled
117 
118 
119 NV_STATUS __nvoc_objCreateDynamic_Fabric(Fabric**, Dynamic*, NvU32, va_list);
120 
121 NV_STATUS __nvoc_objCreate_Fabric(Fabric**, Dynamic*, NvU32);
122 #define __objCreate_Fabric(ppNewObj, pParent, createFlags) \
123     __nvoc_objCreate_Fabric((ppNewObj), staticCast((pParent), Dynamic), (createFlags))
124 
125 NV_STATUS fabricConstruct_IMPL(struct Fabric *arg_pFabric);
126 
127 #define __nvoc_fabricConstruct(arg_pFabric) fabricConstruct_IMPL(arg_pFabric)
128 void fabricDestruct_IMPL(struct Fabric *pFabric);
129 
130 #define __nvoc_fabricDestruct(pFabric) fabricDestruct_IMPL(pFabric)
131 void fabricSetFmSessionFlags_IMPL(struct Fabric *pFabric, NvU32 flags);
132 
133 #ifdef __nvoc_fabric_h_disabled
134 static inline void fabricSetFmSessionFlags(struct Fabric *pFabric, NvU32 flags) {
135     NV_ASSERT_FAILED_PRECOMP("Fabric was disabled!");
136 }
137 #else //__nvoc_fabric_h_disabled
138 #define fabricSetFmSessionFlags(pFabric, flags) fabricSetFmSessionFlags_IMPL(pFabric, flags)
139 #endif //__nvoc_fabric_h_disabled
140 
141 NvU32 fabricGetFmSessionFlags_IMPL(struct Fabric *pFabric);
142 
143 #ifdef __nvoc_fabric_h_disabled
144 static inline NvU32 fabricGetFmSessionFlags(struct Fabric *pFabric) {
145     NV_ASSERT_FAILED_PRECOMP("Fabric was disabled!");
146     return 0;
147 }
148 #else //__nvoc_fabric_h_disabled
149 #define fabricGetFmSessionFlags(pFabric) fabricGetFmSessionFlags_IMPL(pFabric)
150 #endif //__nvoc_fabric_h_disabled
151 
152 void fabricMulticastFabricOpsMutexAcquire_IMPL(struct Fabric *pFabric);
153 
154 #ifdef __nvoc_fabric_h_disabled
155 static inline void fabricMulticastFabricOpsMutexAcquire(struct Fabric *pFabric) {
156     NV_ASSERT_FAILED_PRECOMP("Fabric was disabled!");
157 }
158 #else //__nvoc_fabric_h_disabled
159 #define fabricMulticastFabricOpsMutexAcquire(pFabric) fabricMulticastFabricOpsMutexAcquire_IMPL(pFabric)
160 #endif //__nvoc_fabric_h_disabled
161 
162 void fabricMulticastFabricOpsMutexRelease_IMPL(struct Fabric *pFabric);
163 
164 #ifdef __nvoc_fabric_h_disabled
165 static inline void fabricMulticastFabricOpsMutexRelease(struct Fabric *pFabric) {
166     NV_ASSERT_FAILED_PRECOMP("Fabric was disabled!");
167 }
168 #else //__nvoc_fabric_h_disabled
169 #define fabricMulticastFabricOpsMutexRelease(pFabric) fabricMulticastFabricOpsMutexRelease_IMPL(pFabric)
170 #endif //__nvoc_fabric_h_disabled
171 
172 NV_STATUS fabricMulticastSetupCacheInsertUnderLock_IMPL(struct Fabric *pFabric, NvU64 requesId, void *pData);
173 
174 #ifdef __nvoc_fabric_h_disabled
175 static inline NV_STATUS fabricMulticastSetupCacheInsertUnderLock(struct Fabric *pFabric, NvU64 requesId, void *pData) {
176     NV_ASSERT_FAILED_PRECOMP("Fabric was disabled!");
177     return NV_ERR_NOT_SUPPORTED;
178 }
179 #else //__nvoc_fabric_h_disabled
180 #define fabricMulticastSetupCacheInsertUnderLock(pFabric, requesId, pData) fabricMulticastSetupCacheInsertUnderLock_IMPL(pFabric, requesId, pData)
181 #endif //__nvoc_fabric_h_disabled
182 
183 void fabricMulticastSetupCacheDeleteUnderLock_IMPL(struct Fabric *pFabric, NvU64 requesId);
184 
185 #ifdef __nvoc_fabric_h_disabled
186 static inline void fabricMulticastSetupCacheDeleteUnderLock(struct Fabric *pFabric, NvU64 requesId) {
187     NV_ASSERT_FAILED_PRECOMP("Fabric was disabled!");
188 }
189 #else //__nvoc_fabric_h_disabled
190 #define fabricMulticastSetupCacheDeleteUnderLock(pFabric, requesId) fabricMulticastSetupCacheDeleteUnderLock_IMPL(pFabric, requesId)
191 #endif //__nvoc_fabric_h_disabled
192 
193 void *fabricMulticastSetupCacheGetUnderLock_IMPL(struct Fabric *pFabric, NvU64 requestId);
194 
195 #ifdef __nvoc_fabric_h_disabled
196 static inline void *fabricMulticastSetupCacheGetUnderLock(struct Fabric *pFabric, NvU64 requestId) {
197     NV_ASSERT_FAILED_PRECOMP("Fabric was disabled!");
198     return NULL;
199 }
200 #else //__nvoc_fabric_h_disabled
201 #define fabricMulticastSetupCacheGetUnderLock(pFabric, requestId) fabricMulticastSetupCacheGetUnderLock_IMPL(pFabric, requestId)
202 #endif //__nvoc_fabric_h_disabled
203 
204 NV_STATUS fabricMulticastCleanupCacheInsertUnderLock_IMPL(struct Fabric *pFabric, NvU64 requesId, void *pData);
205 
206 #ifdef __nvoc_fabric_h_disabled
207 static inline NV_STATUS fabricMulticastCleanupCacheInsertUnderLock(struct Fabric *pFabric, NvU64 requesId, void *pData) {
208     NV_ASSERT_FAILED_PRECOMP("Fabric was disabled!");
209     return NV_ERR_NOT_SUPPORTED;
210 }
211 #else //__nvoc_fabric_h_disabled
212 #define fabricMulticastCleanupCacheInsertUnderLock(pFabric, requesId, pData) fabricMulticastCleanupCacheInsertUnderLock_IMPL(pFabric, requesId, pData)
213 #endif //__nvoc_fabric_h_disabled
214 
215 void fabricMulticastCleanupCacheDeleteUnderLock_IMPL(struct Fabric *pFabric, NvU64 requesId);
216 
217 #ifdef __nvoc_fabric_h_disabled
218 static inline void fabricMulticastCleanupCacheDeleteUnderLock(struct Fabric *pFabric, NvU64 requesId) {
219     NV_ASSERT_FAILED_PRECOMP("Fabric was disabled!");
220 }
221 #else //__nvoc_fabric_h_disabled
222 #define fabricMulticastCleanupCacheDeleteUnderLock(pFabric, requesId) fabricMulticastCleanupCacheDeleteUnderLock_IMPL(pFabric, requesId)
223 #endif //__nvoc_fabric_h_disabled
224 
225 void *fabricMulticastCleanupCacheGetUnderLock_IMPL(struct Fabric *pFabric, NvU64 requestId);
226 
227 #ifdef __nvoc_fabric_h_disabled
228 static inline void *fabricMulticastCleanupCacheGetUnderLock(struct Fabric *pFabric, NvU64 requestId) {
229     NV_ASSERT_FAILED_PRECOMP("Fabric was disabled!");
230     return NULL;
231 }
232 #else //__nvoc_fabric_h_disabled
233 #define fabricMulticastCleanupCacheGetUnderLock(pFabric, requestId) fabricMulticastCleanupCacheGetUnderLock_IMPL(pFabric, requestId)
234 #endif //__nvoc_fabric_h_disabled
235 
236 #undef PRIVATE_FIELD
237 
238 
239 #endif // _FABRIC_H_
240 
241 #ifdef __cplusplus
242 } // extern "C"
243 #endif
244 #endif // _G_FABRIC_NVOC_H_
245