diff options
author | Joshua Bakita <bakitajoshua@gmail.com> | 2023-06-28 18:24:25 -0400 |
---|---|---|
committer | Joshua Bakita <bakitajoshua@gmail.com> | 2023-06-28 18:24:25 -0400 |
commit | 01e6fac4d61fdd7fff5433942ec93fc2ea1e4df1 (patch) | |
tree | 4ef34501728a087be24f4ba0af90f91486bf780b /include/nvgpu/xve.h | |
parent | 306a03d18b305e4e573be3b2931978fa10679eb9 (diff) |
Include nvgpu headers
These are needed to build on NVIDIA's Jetson boards for the time
being. Only a couple structs are required, so it should be fairly
easy to remove this dependency at some point in the future.
Diffstat (limited to 'include/nvgpu/xve.h')
-rw-r--r-- | include/nvgpu/xve.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/include/nvgpu/xve.h b/include/nvgpu/xve.h new file mode 100644 index 0000000..2d0d698 --- /dev/null +++ b/include/nvgpu/xve.h | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | #ifndef NVGPU_XVE_H | ||
23 | #define NVGPU_XVE_H | ||
24 | |||
25 | #include <nvgpu/types.h> | ||
26 | #include <nvgpu/log2.h> | ||
27 | |||
28 | /* | ||
29 | * For the available speeds bitmap. | ||
30 | */ | ||
31 | #define GPU_XVE_SPEED_2P5 (1 << 0) | ||
32 | #define GPU_XVE_SPEED_5P0 (1 << 1) | ||
33 | #define GPU_XVE_SPEED_8P0 (1 << 2) | ||
34 | #define GPU_XVE_NR_SPEEDS 3 | ||
35 | |||
36 | #define GPU_XVE_SPEED_MASK (GPU_XVE_SPEED_2P5 | \ | ||
37 | GPU_XVE_SPEED_5P0 | \ | ||
38 | GPU_XVE_SPEED_8P0) | ||
39 | |||
40 | /* | ||
41 | * The HW uses a 2 bit field where speed is defined by a number: | ||
42 | * | ||
43 | * NV_XVE_LINK_CONTROL_STATUS_LINK_SPEED_2P5 = 1 | ||
44 | * NV_XVE_LINK_CONTROL_STATUS_LINK_SPEED_5P0 = 2 | ||
45 | * NV_XVE_LINK_CONTROL_STATUS_LINK_SPEED_8P0 = 3 | ||
46 | * | ||
47 | * This isn't ideal for a bitmap with available speeds. So the external | ||
48 | * APIs think about speeds as a bit in a bitmap and this function converts | ||
49 | * from those bits to the actual HW speed setting. | ||
50 | * | ||
51 | * @speed_bit must have only 1 bit set and must be one of the 3 available | ||
52 | * HW speeds. Not all chips support all speeds so use available_speeds() to | ||
53 | * determine what a given chip supports. | ||
54 | */ | ||
55 | static inline const char *xve_speed_to_str(u32 speed) | ||
56 | { | ||
57 | if (!speed || !is_power_of_2(speed) || | ||
58 | !(speed & GPU_XVE_SPEED_MASK)) { | ||
59 | return "Unknown ???"; | ||
60 | } | ||
61 | |||
62 | return speed & GPU_XVE_SPEED_2P5 ? "Gen1" : | ||
63 | speed & GPU_XVE_SPEED_5P0 ? "Gen2" : | ||
64 | speed & GPU_XVE_SPEED_8P0 ? "Gen3" : | ||
65 | "Unknown ???"; | ||
66 | } | ||
67 | |||
68 | #endif /* NVGPU_XVE_H */ | ||