1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2016-2021 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 #ifndef _RESOURCE_DESC_FLAGS_H_
24 #define _RESOURCE_DESC_FLAGS_H_
25 
26 // Flags for RS_ENTRY
27 #define RS_FLAGS_NONE                             0
28 
29 #define RS_FLAGS_ACQUIRE_GPUS_LOCK_ON_ALLOC       NVBIT(0)   ///< GPUs Lock is acquired on allocation
30 #define RS_FLAGS_ACQUIRE_GPUS_LOCK_ON_FREE        NVBIT(1)   ///< GPUs Lock is acquired for free
31 #define RS_FLAGS_ACQUIRE_GPUS_LOCK                (RS_FLAGS_ACQUIRE_GPUS_LOCK_ON_ALLOC | RS_FLAGS_ACQUIRE_GPUS_LOCK_ON_FREE)
32 
33 #define RS_FLAGS_ACQUIRE_GPU_GROUP_LOCK_ON_ALLOC  NVBIT(2)   ///< GPU Group Lock is acquired on allocation
34 #define RS_FLAGS_ACQUIRE_GPU_GROUP_LOCK_ON_FREE   NVBIT(3)   ///< GPU Group Lock is acquired for free
35 #define RS_FLAGS_ACQUIRE_GPU_GROUP_LOCK           (RS_FLAGS_ACQUIRE_GPU_GROUP_LOCK_ON_ALLOC | RS_FLAGS_ACQUIRE_GPU_GROUP_LOCK_ON_FREE)
36 
37 #define RS_FLAGS_ALLOC_RPC_TO_VGPU_HOST           NVBIT(4)   ///< Issue RPC to host to allocate resource for virtual GPUs
38 
39 #define RS_FLAGS_ACQUIRE_RO_API_LOCK_ON_ALLOC     NVBIT(5)   ///< Acquire the RO API lock for allocation, default is RW API lock
40 
41 #define RS_FLAGS_ALLOC_RPC_TO_PHYS_RM             NVBIT(6)   ///< Issue RPC to allocate resource in physical RM
42 
43 #define RS_FLAGS_ALLOC_RPC_TO_ALL                 (RS_FLAGS_ALLOC_RPC_TO_VGPU_HOST | RS_FLAGS_ALLOC_RPC_TO_PHYS_RM)
44 
45 #define RS_FLAGS_INTERNAL_ONLY                    NVBIT(7)   ///< Class cannot be allocated outside of RM
46 
47 #define RS_FLAGS_CHANNEL_DESCENDANT_COMMON        (RS_FLAGS_ACQUIRE_GPUS_LOCK | RS_FLAGS_ALLOC_RPC_TO_ALL)
48 
49 #define RS_FREE_PRIORITY_DEFAULT                  0
50 #define RS_FREE_PRIORITY_HIGH                     1          ///< Resources with this priority will be freed ahead of others
51 
52 #define RS_FLAGS_ALLOC_NON_PRIVILEGED             NVBIT(8)   ///< Class is non privileged
53 
54 #define RS_FLAGS_ALLOC_PRIVILEGED                 NVBIT(9)   ///< Class requires at least admin privilege
55 
56 #define RS_FLAGS_ALLOC_KERNEL_PRIVILEGED          NVBIT(10)  ///< Class requires at least kernel privilege
57 
58 /**
59  * CPU_PLUGIN_FOR_* indicates object can be allocated in the respective environment
60  *                  if the context is at least cached admin privileged
61  *     - Cached-admin Hyper-V may access flagged privileged and kernel privileged objects
62  *     - Other, runtime-admin hosts may access flagged kernel privileged objects
63  *     - Note that runtime-admin hosts do not need the flag to allocate admin privileged objects
64  *
65  * GSP_PLUGIN_FOR_* is even stricter; any admin and kernel privileged object allocated in a VF context
66  *                  is required to have the flag or it will be rejected.
67  */
68 #define RS_FLAGS_ALLOC_CPU_PLUGIN_FOR_VGPU_GSP    NVBIT(11)  ///< CPU-RM, SRIOV, vGPU-GSP enabled, hypervisor environment
69 
70 #define RS_FLAGS_ALLOC_CPU_PLUGIN_FOR_SRIOV       NVBIT(12)  ///< CPU-RM, SRIOV, vGPU-GSP disabled, hypervisor environment
71 
72 #define RS_FLAGS_ALLOC_CPU_PLUGIN_FOR_LEGACY      NVBIT(13)  ///< CPU-RM, non-SRIOV or SRIOV-Heavy, hypervisor environment.
73 
74 #define RS_FLAGS_ALLOC_GSP_PLUGIN_FOR_VGPU_GSP    NVBIT(14)  ///< GSP-RM, SRIOV, vGPU-GSP enabled, VF context.
75 
76 #define RS_FLAGS_ALLOC_ALL_VGPU_PLUGINS           (RS_FLAGS_ALLOC_CPU_PLUGIN_FOR_VGPU_GSP | RS_FLAGS_ALLOC_CPU_PLUGIN_FOR_SRIOV | RS_FLAGS_ALLOC_CPU_PLUGIN_FOR_LEGACY | RS_FLAGS_ALLOC_GSP_PLUGIN_FOR_VGPU_GSP)
77 
78 #define RS_FLAGS_DUAL_CLIENT_LOCK                 NVBIT(15)  ///< Class needs to lock two clients when being allocated, must update serverAllocLookupSecondClient in order to use
79 
80 #endif // _RESOURCE_DESC_FLAGS_H_
81