Overlay/sys-libs/libnvidia-container/files/libnvidia-container-1.3.0-f...

119 lines
3.9 KiB
Diff

--- a/src/nvidia-modprobe-utils.h 2020-09-18 18:11:57.046187358 +0800
+++ b/src/nvidia-modprobe-utils.h 2020-09-18 23:35:14.062948666 +0800
@@ -31,29 +31,20 @@
#include <stdio.h>
#define NV_MAX_CHARACTER_DEVICE_FILE_STRLEN 128
-#define NV_MODULE_INSTANCE_NONE -1
-#define NV_MODULE_INSTANCE_ZERO 0
-#define NV_MAX_MODULE_INSTANCES 8
#define NV_CTL_DEVICE_NUM 255
#define NV_MODESET_MINOR_DEVICE_NUM 254
-
-#define NV_FRONTEND_CONTROL_DEVICE_MINOR_MAX NV_CTL_DEVICE_NUM
+#define NV_NVSWITCH_CTL_MINOR 255
#define NV_DEVICE_FILE_PATH "/dev/nvidia%d"
#define NV_CTRL_DEVICE_FILE_PATH "/dev/nvidiactl"
#define NV_MODESET_DEVICE_NAME "/dev/nvidia-modeset"
#define NV_VGPU_VFIO_DEVICE_NAME "/dev/nvidia-vgpu%d"
#define NV_NVLINK_DEVICE_NAME "/dev/nvidia-nvlink"
+#define NV_NVSWITCH_CTL_NAME "/dev/nvidia-nvswitchctl"
+#define NV_NVSWITCH_DEVICE_NAME "/dev/nvidia-nvswitch%d"
-#define NV_NMODULE_CTRL_DEVICE_FILE_PATH "/dev/nvidiactl%d"
-
-#define NV_FRONTEND_CONTROL_DEVICE_MINOR_MIN \
- (NV_FRONTEND_CONTROL_DEVICE_MINOR_MAX - \
- NV_MAX_MODULE_INSTANCES)
-
-#define NV_FRONTEND_IS_CONTROL_DEVICE(x) \
- ((x <= NV_FRONTEND_CONTROL_DEVICE_MINOR_MAX) && \
- (x > NV_FRONTEND_CONTROL_DEVICE_MINOR_MIN))
+#define NV_CAPS_MODULE_NAME "nvidia-caps"
+#define NV_CAP_DEVICE_NAME "/dev/" NV_CAPS_MODULE_NAME "/nvidia-cap%d"
#if defined(NV_LINUX)
@@ -76,40 +67,33 @@
return !!(state & (1 << value));
}
-int nvidia_get_file_state(int minor, int module_instance);
-int nvidia_modprobe(const int print_errors, int module_instance);
-int nvidia_mknod(int minor, int module_instance);
+int nvidia_get_file_state(int minor);
+int nvidia_modprobe(const int print_errors);
+int nvidia_mknod(int minor);
int nvidia_uvm_modprobe(void);
int nvidia_uvm_mknod(int base_minor);
int nvidia_modeset_modprobe(void);
int nvidia_modeset_mknod(void);
int nvidia_vgpu_vfio_mknod(int minor_num);
int nvidia_nvlink_mknod(void);
-
-int mknod_helper(int major, int minor, const char *path, const char *proc_path);
-int get_chardev_major(const char *name);
+int nvidia_nvlink_get_file_state(void);
+int nvidia_nvswitch_mknod(int minor);
+int nvidia_nvswitch_get_file_state(int minor);
+int nvidia_cap_mknod(const char* cap_file_path, int *minor);
+int nvidia_cap_get_file_state(const char* cap_file_path);
+int nvidia_cap_get_device_file_attrs(const char* cap_file_path, int *major, int *minor, char *name);
+int nvidia_get_chardev_major(const char *name);
#endif /* NV_LINUX */
/*
- * Detect use of multiple kernel module instances. Use a single
- * module instance unless instance != NV_MODULE_INSTANCE_NONE
- */
-static __inline__ int is_multi_module(int module_instance)
-{
- return (module_instance != NV_MODULE_INSTANCE_NONE);
-}
-
-
-/*
* Construct the device file name, based on 'minor'. If an error
* occurs, the nul terminator will be written to name[0].
*/
static __inline__ void assign_device_file_name
(
char name[NV_MAX_CHARACTER_DEVICE_FILE_STRLEN],
- int minor,
- int module_instance
+ int minor
)
{
int ret;
@@ -119,20 +102,12 @@
goto fail;
}
- if (!is_multi_module(module_instance) && minor == NV_CTL_DEVICE_NUM)
+ if (minor == NV_CTL_DEVICE_NUM)
{
ret = snprintf(name,
NV_MAX_CHARACTER_DEVICE_FILE_STRLEN,
NV_CTRL_DEVICE_FILE_PATH);
}
- else if (is_multi_module(module_instance) &&
- NV_FRONTEND_IS_CONTROL_DEVICE(minor))
- {
- ret = snprintf(name,
- NV_MAX_CHARACTER_DEVICE_FILE_STRLEN,
- NV_NMODULE_CTRL_DEVICE_FILE_PATH,
- module_instance);
- }
else
{
ret = snprintf(name,
@@ -154,4 +129,4 @@
name[0] = '\0';
}
-#endif /* __NVIDIA_MODPROBE_UTILS_H__ */
\ No newline at end of file
+#endif /* __NVIDIA_MODPROBE_UTILS_H__ */