1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #pragma once
25 
26 #include <nvtypes.h>
27 
28 //
29 // This file was generated with FINN, an NVIDIA coding tool.
30 // Source file:      ctrl/ctrl2080/ctrl2080grmgr.finn
31 //
32 
33 #include "ctrl/ctrl2080/ctrl2080base.h"
34 
35 /* NV20_SUBDEVICE_XX grmgr control commands and parameters */
36 
37 //
38 // NV2080_CTRL_CMD_GRMGR_GET_GR_FS_INFO
39 //
40 // This control call works as a batched query interface where we
41 // have multiple different queries that can be passed in
42 // and RM will return the associated data and status type
43 // If there is any error in NV2080_CTRL_GRMGR_GET_GR_FS_INFO_PARAMS,
44 // we will immediately fail the call.
45 // However, if there is an error in the query-specific calls, we will
46 // log the error and march on.
47 //
48 // NV2080_CTRL_GRMGR_GET_GR_FS_INFO_PARAMS
49 //  numQueries[IN]
50 //      - Specifies the number of valid queries that the caller will be passing in
51 //
52 // Possible status values returned are:
53 //   NV_OK
54 //   NV_ERR_INVALID_ARGUMENT
55 //   NV_ERR_INVALID_STATE
56 //
57 #define NV2080_CTRL_CMD_GRMGR_GET_GR_FS_INFO        (0x20803801) /* finn: Evaluated from "(FINN_NV20_SUBDEVICE_0_GRMGR_INTERFACE_ID << 8) | NV2080_CTRL_GRMGR_GET_GR_FS_INFO_PARAMS_MESSAGE_ID" */
58 
59 // Max number of queries that can be batched in a single call to NV2080_CTRL_CMD_GRMGR_GET_GR_FS_INFO
60 #define NV2080_CTRL_GRMGR_GR_FS_INFO_MAX_QUERIES    96
61 
62 //
63 // Preference is to keep max.size of union at 24 bytes (i.e. 6 32-bit members)
64 // so that the size of entire query struct is maintained at 32 bytes, to ensure
65 // that overall params struct does not exceed 4kB
66 //
67 #define NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_MAX_SIZE 32
68 #define NV2080_CTRL_GRMGR_MAX_SMC_IDS               8
69 
70 /*!
71  * NV2080_CTRL_GRMGR_GR_FS_INFO_GPC_COUNT_PARAMS
72  *  gpcCount[OUT]
73  *      - No. of logical/local GPCs which client can use to create the
74  *        logical/local mask respectively
75  */
76 typedef struct NV2080_CTRL_GRMGR_GR_FS_INFO_GPC_COUNT_PARAMS {
77     NvU32 gpcCount;         // param[out] - logical/local GPC mask
78 } NV2080_CTRL_GRMGR_GR_FS_INFO_GPC_COUNT_PARAMS;
79 
80 /*!
81  * NV2080_CTRL_GRMGR_GR_FS_INFO_CHIPLET_GPC_MAP_PARAMS
82  *  gpcId[IN]
83  *      - Logical/local GPC ID
84  *  chipletGpcMap[OUT]
85  *      - Returns chiplet GPC ID for legacy case and device monitoring client
86  *      - Returns local GPC ID (== input gpcId) for SMC client
87  *      - Does not support DM attribution case
88  */
89 typedef struct NV2080_CTRL_GRMGR_GR_FS_INFO_CHIPLET_GPC_MAP_PARAMS {
90     NvU32 gpcId;            // param[in] - logical/local GPC ID
91     NvU32 chipletGpcMap;    // param[out] - chiplet GPC ID
92 } NV2080_CTRL_GRMGR_GR_FS_INFO_CHIPLET_GPC_MAP_PARAMS;
93 
94 /*!
95  * NV2080_CTRL_GRMGR_GR_FS_INFO_TPC_MASK_PARAMS
96  *  gpcId[IN]
97  *      - Logical/local GPC ID
98  *  tpcMask[OUT]
99  *      - Returns physical TPC mask for legacy, DM client and SMC cases
100  *      - Does not support DM attribution case
101  */
102 typedef struct NV2080_CTRL_GRMGR_GR_FS_INFO_TPC_MASK_PARAMS {
103     NvU32 gpcId;            // param[in] - logical/local GPC ID
104     NvU32 tpcMask;          // param[out] - physical TPC mask
105 } NV2080_CTRL_GRMGR_GR_FS_INFO_TPC_MASK_PARAMS;
106 
107 /*!
108  * NV2080_CTRL_GRMGR_GR_FS_INFO_PPC_MASK_PARAMS
109  *  gpcId[IN]
110  *      - Logical/local GPC ID
111  *  ppcMask[OUT]
112  *      - Returns physical PPC mask for legacy, DM client and SMC cases
113  *      - Does not support DM attribution case
114  */
115 typedef struct NV2080_CTRL_GRMGR_GR_FS_INFO_PPC_MASK_PARAMS {
116     NvU32 gpcId;            // param[in] - logical/local GPC ID
117     NvU32 ppcMask;          // param[out] - physical PPC mask
118 } NV2080_CTRL_GRMGR_GR_FS_INFO_PPC_MASK_PARAMS;
119 
120 /*!
121  *  !!! DEPRECATED - This query will return NV_ERR_NOT_SUPPORTED since deleting
122  *               it would break driver compatibility !!!
123  *
124  *  NV2080_CTRL_GRMGR_GR_FS_INFO_PARTITION_CHIPLET_GPC_MAP_PARAMS
125  *  swizzId[IN]
126  *      - Swizz ID of partition
127  *      - A DM client with an invalid swizz ID, will fail this call
128  *      - This parameter is not compulsory for an SMC client; the subscription
129  *        itself will do the necessary validation.
130  *  gpcId[IN]
131  *      - Logical/local GPC ID
132  *  chipletGpcMap[OUT]
133  *      - Returns chiplet GPC ID for legacy case and device monitoring client
134  *      - Returns local GPC ID (== input gpcId) for SMC client
135  *      - Does not support non-attribution case for DM client
136  */
137 typedef struct NV2080_CTRL_GRMGR_GR_FS_INFO_PARTITION_CHIPLET_GPC_MAP_PARAMS {
138     NvU32 swizzId;          // param[in]  - swizz ID of partition
139     NvU32 gpcId;            // param[in]  - logical/local GPC ID
140     NvU32 chipletGpcMap;    // param[out] - chiplet GPC ID
141 } NV2080_CTRL_GRMGR_GR_FS_INFO_PARTITION_CHIPLET_GPC_MAP_PARAMS;
142 
143 /*!
144  * NV2080_CTRL_GRMGR_GR_FS_INFO_ROP_MASK_PARAMS
145  *  gpcId[IN]
146  *      - Logical/local GPC ID
147  *  ropMask[OUT]
148  *      - Returns physical ROP mask for legacy, DM client
149  *      - Returns logical ROP mask for SMC
150  */
151 typedef struct NV2080_CTRL_GRMGR_GR_FS_INFO_ROP_MASK_PARAMS {
152     NvU32 gpcId;            // param[in] - logical/local GPC ID
153     NvU32 ropMask;          // param[out] - physical ROP mask
154 } NV2080_CTRL_GRMGR_GR_FS_INFO_ROP_MASK_PARAMS;
155 
156 /*!
157  *  NV2080_CTRL_GRMGR_GR_FS_INFO_CHIPLET_SYSPIPE_MASK_PARAMS
158  *  chipletSyspipeMask [OUT]
159  *      - Mask of chiplet SMC-IDs for DM client attribution case
160  *      - Mask of local SMC-IDs for SMC client
161  *      - Legacy case returns 1 GR
162  *      - Does not support attribution case for DM client
163  */
164 typedef struct NV2080_CTRL_GRMGR_GR_FS_INFO_CHIPLET_SYSPIPE_MASK_PARAMS {
165     NvU32 chipletSyspipeMask;   // param[out] - Mask of chiplet SMC IDs
166 } NV2080_CTRL_GRMGR_GR_FS_INFO_CHIPLET_SYSPIPE_MASK_PARAMS;
167 
168 /*!
169  *  NV2080_CTRL_GRMGR_GR_FS_INFO_PARTITION_CHIPLET_SYSPIPE_IDS_PARAMS
170  *  swizzId[IN]
171  *      - Swizz ID of partition
172  *      - A DM client with an invalid swizz ID, will fail this call
173  *  physSyspipeId[GRMGR_MAX_SMC_IDS] [OUT]
174  *      - Physical SMC-IDs mapped to partition local idx for DM client attribution case
175  *      - Does not support non-attribution case for DM client, SMC clients, legacy case
176  *  physSyspipeIdCount[OUT]
177  *      - Valid count of physSmcIds which has been populated in above array.
178  *      - Failure case will return 0
179  */
180 typedef struct NV2080_CTRL_GRMGR_GR_FS_INFO_PARTITION_CHIPLET_SYSPIPE_IDS_PARAMS {
181     NvU16 swizzId;                                          // param[in]  - swizz ID of partition
182     NvU16 physSyspipeIdCount;                               // param[out] - Count of physSmcIds in above array
183     NvU8  physSyspipeId[NV2080_CTRL_GRMGR_MAX_SMC_IDS];      // param[out] - physical/local SMC IDs
184 } NV2080_CTRL_GRMGR_GR_FS_INFO_PARTITION_CHIPLET_SYSPIPE_IDS_PARAMS;
185 
186 /*!
187  * NV2080_CTRL_GRMGR_GR_FS_INFO_PROFILER_MON_GPC_MASK_PARAMS
188  * swizzId[IN]
189  *      - Swizz ID of partition
190  *      - Mandatory parameter
191  *      - A DM client with an invalid swizz ID, will fail this call
192  * grIdx[IN]
193  *      - Local grIdx for a partition
194  *      - Mandatory parameter
195  * gpcEnMask[OUT]
196  *      - Logical enabled GPC mask associated with requested grIdx of the partition i.e swizzid->engineId->gpcMask
197  *      - These Ids should be used as input further
198  *      - Does not support non-attribution case for DM client, SMC clients, legacy case
199  */
200 typedef struct NV2080_CTRL_GRMGR_GR_FS_INFO_PROFILER_MON_GPC_MASK_PARAMS {
201     NvU32 swizzId;      // param[in]  - swizz ID of partition
202     NvU32 grIdx;        // param[in]  - partition local GR ID
203     NvU32 gpcEnMask;    // param[out] - logical enabled GPC mask
204 } NV2080_CTRL_GRMGR_GR_FS_INFO_PROFILER_MON_GPC_MASK_PARAMS;
205 
206 /*!
207  * NV2080_CTRL_GRMGR_GR_FS_INFO_PARTITION_SYSPIPE_ID
208  * syspipeId[OUT]
209  *      - Partition-local GR idx for client subscribed to exec partition
210  *      - Does not support legacy case, DM client, or SMC client subscribed only to partition
211  */
212 typedef struct NV2080_CTRL_GRMGR_GR_FS_INFO_PARTITION_SYSPIPE_ID_PARAMS {
213     NvU32 syspipeId;    // param[out] - partition-local Gr idx
214 } NV2080_CTRL_GRMGR_GR_FS_INFO_PARTITION_SYSPIPE_ID_PARAMS;
215 
216 /*!
217  * queryType[IN]
218  *  - Use queryType defines to specify what information is being requested
219  * status[OUT]
220  *  - Possible status values returned are:
221  *      NV_OK
222  *      NV_ERR_INVALID_ARGUMENT
223  *      NV_ERR_INVALID_STATE
224  */
225 typedef struct NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_PARAMS {
226     NvU16 queryType;
227     NvU8  reserved[2]; // To keep the struct aligned for now and available for future use (if needed)
228     NvU32 status;
229     union {
230         NV2080_CTRL_GRMGR_GR_FS_INFO_GPC_COUNT_PARAMS                     gpcCountData;
231         NV2080_CTRL_GRMGR_GR_FS_INFO_CHIPLET_GPC_MAP_PARAMS               chipletGpcMapData;
232         NV2080_CTRL_GRMGR_GR_FS_INFO_TPC_MASK_PARAMS                      tpcMaskData;
233         NV2080_CTRL_GRMGR_GR_FS_INFO_PPC_MASK_PARAMS                      ppcMaskData;
234         NV2080_CTRL_GRMGR_GR_FS_INFO_PARTITION_CHIPLET_GPC_MAP_PARAMS     partitionGpcMapData;
235         NV2080_CTRL_GRMGR_GR_FS_INFO_CHIPLET_SYSPIPE_MASK_PARAMS          syspipeMaskData;
236         NV2080_CTRL_GRMGR_GR_FS_INFO_PARTITION_CHIPLET_SYSPIPE_IDS_PARAMS partitionChipletSyspipeData;
237         NV2080_CTRL_GRMGR_GR_FS_INFO_PROFILER_MON_GPC_MASK_PARAMS         dmGpcMaskData;
238         NV2080_CTRL_GRMGR_GR_FS_INFO_PARTITION_SYSPIPE_ID_PARAMS          partitionSyspipeIdData;
239         NV2080_CTRL_GRMGR_GR_FS_INFO_ROP_MASK_PARAMS                      ropMaskData;
240     } queryData;
241 } NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_PARAMS;
242 
243 #define NV2080_CTRL_GRMGR_GET_GR_FS_INFO_PARAMS_MESSAGE_ID (0x1U)
244 
245 typedef struct NV2080_CTRL_GRMGR_GET_GR_FS_INFO_PARAMS {
246     NvU16                                     numQueries;
247     NvU8                                      reserved[6]; // To keep the struct aligned for now and available for future use (if needed)
248     NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_PARAMS queries[NV2080_CTRL_GRMGR_GR_FS_INFO_MAX_QUERIES];
249 } NV2080_CTRL_GRMGR_GET_GR_FS_INFO_PARAMS;
250 
251 #define NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_INVALID                       0
252 #define NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_GPC_COUNT                     1
253 #define NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_CHIPLET_GPC_MAP               2
254 #define NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_TPC_MASK                      3
255 #define NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_PPC_MASK                      4
256 #define NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_PARTITION_CHIPLET_GPC_MAP     5   /* deprecated */
257 #define NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_CHIPLET_SYSPIPE_MASK          6
258 #define NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_PARTITION_CHIPLET_SYSPIPE_IDS 7
259 #define NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_PROFILER_MON_GPC_MASK         8
260 #define NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_PARTITION_SYSPIPE_ID          9
261 #define NV2080_CTRL_GRMGR_GR_FS_INFO_QUERY_ROP_MASK                      10
262 
263 /* _ctrl2080grmgr_h_ */
264