1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2008-2023 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 #ifndef __vgpu_vgpu_version_h__
25 #define __vgpu_vgpu_version_h__
26 
27 /* VGX interface version */
28 #define NV_RPC_VERSION_NUMBER_MAJOR                           31:24 /* R---D */
29 #define NV_RPC_VERSION_NUMBER_MINOR                           23:16 /* R---D */
30 
31 #define RPC_VERSION_FROM_VGX_VERSION(major, minor) ( DRF_NUM(_RPC, _VERSION_NUMBER, _MAJOR, major) | \
32                                                      DRF_NUM(_RPC, _VERSION_NUMBER, _MINOR, minor))
33 #define VGX_MAJOR_VERSION_NUMBER  0x24
34 #define VGX_MINOR_VERSION_NUMBER  0x0A
35 
36 #define VGX_MAJOR_VERSION_NUMBER_VGPU_12_0 0x1A
37 #define VGX_MINOR_VERSION_NUMBER_VGPU_12_0 0x18
38 #define VGX_MAJOR_VERSION_NUMBER_VGPU_13_0 0x1C
39 #define VGX_MINOR_VERSION_NUMBER_VGPU_13_0 0x0A
40 
41 /**
42  * This macro have the mapping between internal (RPC) and external version
43  * and is required to be updated appropriately with every new internal version.
44  *
45  * In case a new external version is added, a new entry representing the mapping
46  * for the external version should be appended. Please note that the external
47  * version should be updated when both of the following are true:
48  * 1. The new RPC version update cause a break in migration compatibility.
49  * 2. This is the first break in migration compatibility after a release.
50  */
51 #define NV_VGPU_GRIDSW_INTERNAL_TO_EXTERNAL_VERSION_MAPPING \
52     {{0x24, 0x0}, {0x24, 0x0A}, {0x13, 0x1}},               \
53     {{0x23, 0x0}, {0x23, 0x05}, {0x12, 0x1}},               \
54     {{0x22, 0x0}, {0x22, 0x02}, {0x11, 0x1}},               \
55     {{0x21, 0x0}, {0x21, 0x0C}, {0x10, 0x1}},               \
56     {{0x20, 0x0}, {0x20, 0x04}, {0xF, 0x1}},                \
57     {{0x1F, 0x0}, {0x1F, 0xF}, {0xE, 0x1}},                 \
58     {{0x1E, 0x0}, {0x1E, 0xE}, {0xD, 0x1}},                 \
59     {{0x1D, 0x0}, {0x1D, 0x6}, {0xC, 0x1}},                 \
60     {{0x1C, 0x0}, {0x1C, 0xA}, {0xB, 0x1}},                 \
61     {{0x1C, 0xB}, {0x1C, 0xC}, {0xB, 0x2}},                 \
62     {{0x1B, 0x0}, {0x1B, 0x5}, {0xA, 0x1}},                 \
63     {{0x1A, 0x0}, {0x1A, 0x18}, {0x9, 0x1}},                \
64     {{0x1A, 0x19}, {0x1A, 0x24}, {0x9, 0x2}},               \
65     {{0x19, 0x0}, {0x19, 0x1}, {0x8, 0x1}},                 \
66     {{0x18, 0x0}, {0x18, 0x14},{0x7, 0x1}},                 \
67     {{0x18, 0x15}, {0x18, 0x16},{0x7, 0x2}},                \
68     {{0x17, 0x0}, {0x17, 0x6}, {0x6, 0x1}},                 \
69     {{0x16, 0x0}, {0x16, 0x6}, {0x5, 0x1}},                 \
70     {{0x16, 0x7}, {0x16, 0x7}, {0x5, 0x2}}
71 
72 /*
73  * Internal Versioning
74  */
75 
76 #define NV_VGPU_GRIDSW_NUMBER_INTERNAL_MAJOR                           63:32
77 #define NV_VGPU_GRIDSW_NUMBER_INTERNAL_MINOR                           31:0
78 
79 #define GRIDSW_VERSION_INTERNAL(major, minor) (DRF_NUM64(_VGPU, _GRIDSW_NUMBER_INTERNAL, _MAJOR, major) | \
80                                                DRF_NUM64(_VGPU, _GRIDSW_NUMBER_INTERNAL, _MINOR, minor))
81 
82 
83 // The NV_VGPU_GRIDSW_VERSION_MIN_SUPPORTED_INTERNAL macros are auto-generated using the value from rpc-structures.def file.
84 #define AUTOGENERATE_RPC_MIN_SUPPORTED_VERSION_INFORMATION
85 #include "g_rpc-structures.h"
86 #undef AUTOGENERATE_RPC_MIN_SUPPORTED_VERSION_INFORMATION
87 
88 /*
89  * Versioning exposed externally
90  */
91 #define NV_VGPU_GRIDSW_NUMBER_EXTERNAL_MAJOR                           31:16
92 #define NV_VGPU_GRIDSW_NUMBER_EXTERNAL_MINOR                           15:0
93 
94 #define GRIDSW_VERSION_EXTERNAL(major, minor) (DRF_NUM(_VGPU, _GRIDSW_NUMBER_EXTERNAL, _MAJOR, major) | \
95                                                DRF_NUM(_VGPU, _GRIDSW_NUMBER_EXTERNAL, _MINOR, minor))
96 
97 /* WARNING: Should be updated with each vGPU release, if there is a break in
98  * migration compatibility during the development of that release. */
99 #define NV_VGPU_MAX_SUPPORTED_GRIDSW_VERSION_EXTERNAL_MAJOR 0x13
100 #define NV_VGPU_MAX_SUPPORTED_GRIDSW_VERSION_EXTERNAL_MINOR 0x1
101 
102 /* WARNING: Should be updated with each vGPU release, if minimum supported
103  * version change on the host.
104  */
105 #define NV_VGPU_MIN_SUPPORTED_GRIDSW_VERSION_EXTERNAL_MAJOR 0x7
106 #define NV_VGPU_MIN_SUPPORTED_GRIDSW_VERSION_EXTERNAL_MINOR 0x1
107 
108 #endif // __vgpu_vgpu_version_h__
109