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